gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

sqlite_linux_arm.go (5438867B)


      1 // Code generated by 'ccgo -DSQLITE_PRIVATE= -export-defines "" -export-enums "" -export-externs X -export-fields F -export-typedefs "" -ignore-unsupported-alignment -pkgname sqlite3 -volatile=sqlite3_io_error_pending,sqlite3_open_file_count,sqlite3_pager_readdb_count,sqlite3_pager_writedb_count,sqlite3_pager_writej_count,sqlite3_search_count,sqlite3_sort_count,saved_cnt,randomnessPid -o lib/sqlite_linux_arm.go -trace-translation-units testdata/sqlite-amalgamation-3410200/sqlite3.c -full-path-comments -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CORE -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT.
      2 
      3 package sqlite3
      4 
      5 import (
      6 	"math"
      7 	"reflect"
      8 	"sync/atomic"
      9 	"unsafe"
     10 
     11 	"modernc.org/libc"
     12 	"modernc.org/libc/sys/types"
     13 )
     14 
     15 var _ = math.Pi
     16 var _ reflect.Kind
     17 var _ atomic.Value
     18 var _ unsafe.Pointer
     19 var _ *libc.TLS
     20 var _ types.Size_t
     21 
     22 const (
     23 	ACCESSPERMS                           = 511
     24 	ADJ_ESTERROR                          = 0x0008
     25 	ADJ_FREQUENCY                         = 0x0002
     26 	ADJ_MAXERROR                          = 0x0004
     27 	ADJ_MICRO                             = 0x1000
     28 	ADJ_NANO                              = 0x2000
     29 	ADJ_OFFSET                            = 0x0001
     30 	ADJ_OFFSET_SINGLESHOT                 = 0x8001
     31 	ADJ_OFFSET_SS_READ                    = 0xa001
     32 	ADJ_SETOFFSET                         = 0x0100
     33 	ADJ_STATUS                            = 0x0010
     34 	ADJ_TAI                               = 0x0080
     35 	ADJ_TICK                              = 0x4000
     36 	ADJ_TIMECONST                         = 0x0020
     37 	ALLPERMS                              = 4095
     38 	AT_EACCESS                            = 0x200
     39 	AT_EMPTY_PATH                         = 0x1000
     40 	AT_FDCWD                              = -100
     41 	AT_NO_AUTOMOUNT                       = 0x800
     42 	AT_RECURSIVE                          = 0x8000
     43 	AT_REMOVEDIR                          = 0x200
     44 	AT_STATX_DONT_SYNC                    = 0x4000
     45 	AT_STATX_FORCE_SYNC                   = 0x2000
     46 	AT_STATX_SYNC_AS_STAT                 = 0x0000
     47 	AT_STATX_SYNC_TYPE                    = 0x6000
     48 	AT_SYMLINK_FOLLOW                     = 0x400
     49 	AT_SYMLINK_NOFOLLOW                   = 0x100
     50 	BIG_ENDIAN                            = 4321
     51 	BITVEC_SZ                             = 512
     52 	BITVEC_SZELEM                         = 8
     53 	BTALLOC_ANY                           = 0
     54 	BTALLOC_EXACT                         = 1
     55 	BTALLOC_LE                            = 2
     56 	BTCF_AtLast                           = 0x08
     57 	BTCF_Incrblob                         = 0x10
     58 	BTCF_Multiple                         = 0x20
     59 	BTCF_Pinned                           = 0x40
     60 	BTCF_ValidNKey                        = 0x02
     61 	BTCF_ValidOvfl                        = 0x04
     62 	BTCF_WriteFlag                        = 0x01
     63 	BTCURSOR_MAX_DEPTH                    = 20
     64 	BTREE_APPEND                          = 0x08
     65 	BTREE_APPLICATION_ID                  = 8
     66 	BTREE_AUTOVACUUM_FULL                 = 1
     67 	BTREE_AUTOVACUUM_INCR                 = 2
     68 	BTREE_AUTOVACUUM_NONE                 = 0
     69 	BTREE_AUXDELETE                       = 0x04
     70 	BTREE_BLOBKEY                         = 2
     71 	BTREE_BULKLOAD                        = 0x00000001
     72 	BTREE_DATA_VERSION                    = 15
     73 	BTREE_DEFAULT_CACHE_SIZE              = 3
     74 	BTREE_FILE_FORMAT                     = 2
     75 	BTREE_FORDELETE                       = 0x00000008
     76 	BTREE_FREE_PAGE_COUNT                 = 0
     77 	BTREE_HINT_RANGE                      = 0
     78 	BTREE_INCR_VACUUM                     = 7
     79 	BTREE_INTKEY                          = 1
     80 	BTREE_LARGEST_ROOT_PAGE               = 4
     81 	BTREE_MEMORY                          = 2
     82 	BTREE_OMIT_JOURNAL                    = 1
     83 	BTREE_PREFORMAT                       = 0x80
     84 	BTREE_SAVEPOSITION                    = 0x02
     85 	BTREE_SCHEMA_VERSION                  = 1
     86 	BTREE_SEEK_EQ                         = 0x00000002
     87 	BTREE_SINGLE                          = 4
     88 	BTREE_TEXT_ENCODING                   = 5
     89 	BTREE_UNORDERED                       = 8
     90 	BTREE_USER_VERSION                    = 6
     91 	BTREE_WRCSR                           = 0x00000004
     92 	BTS_EXCLUSIVE                         = 0x0040
     93 	BTS_FAST_SECURE                       = 0x000c
     94 	BTS_INITIALLY_EMPTY                   = 0x0010
     95 	BTS_NO_WAL                            = 0x0020
     96 	BTS_OVERWRITE                         = 0x0008
     97 	BTS_PAGESIZE_FIXED                    = 0x0002
     98 	BTS_PENDING                           = 0x0080
     99 	BTS_READ_ONLY                         = 0x0001
    100 	BTS_SECURE_DELETE                     = 0x0004
    101 	BUFSIZ                                = 8192
    102 	BYTE_ORDER                            = 1234
    103 	CACHE_STALE                           = 0
    104 	CBRK                                  = 0
    105 	CC_AND                                = 24
    106 	CC_BANG                               = 15
    107 	CC_BOM                                = 30
    108 	CC_COMMA                              = 23
    109 	CC_DIGIT                              = 3
    110 	CC_DOLLAR                             = 4
    111 	CC_DOT                                = 26
    112 	CC_EQ                                 = 14
    113 	CC_GT                                 = 13
    114 	CC_ID                                 = 27
    115 	CC_ILLEGAL                            = 28
    116 	CC_KYWD                               = 2
    117 	CC_KYWD0                              = 1
    118 	CC_LP                                 = 17
    119 	CC_LT                                 = 12
    120 	CC_MINUS                              = 11
    121 	CC_NUL                                = 29
    122 	CC_PERCENT                            = 22
    123 	CC_PIPE                               = 10
    124 	CC_PLUS                               = 20
    125 	CC_QUOTE                              = 8
    126 	CC_QUOTE2                             = 9
    127 	CC_RP                                 = 18
    128 	CC_SEMI                               = 19
    129 	CC_SLASH                              = 16
    130 	CC_SPACE                              = 7
    131 	CC_STAR                               = 21
    132 	CC_TILDA                              = 25
    133 	CC_VARALPHA                           = 5
    134 	CC_VARNUM                             = 6
    135 	CC_X                                  = 0
    136 	CDISCARD                              = 15
    137 	CDSUSP                                = 25
    138 	CEOF                                  = 4
    139 	CEOL                                  = 0
    140 	CEOT                                  = 4
    141 	CERASE                                = 0177
    142 	CFLUSH                                = 15
    143 	CINTR                                 = 3
    144 	CKCNSTRNT_COLUMN                      = 0x01
    145 	CKCNSTRNT_ROWID                       = 0x02
    146 	CKILL                                 = 21
    147 	CLNEXT                                = 22
    148 	CLOCK_BOOTTIME                        = 7
    149 	CLOCK_BOOTTIME_ALARM                  = 9
    150 	CLOCK_MONOTONIC                       = 1
    151 	CLOCK_MONOTONIC_COARSE                = 6
    152 	CLOCK_MONOTONIC_RAW                   = 4
    153 	CLOCK_PROCESS_CPUTIME_ID              = 2
    154 	CLOCK_REALTIME                        = 0
    155 	CLOCK_REALTIME_ALARM                  = 8
    156 	CLOCK_REALTIME_COARSE                 = 5
    157 	CLOCK_TAI                             = 11
    158 	CLOCK_THREAD_CPUTIME_ID               = 3
    159 	CMIN                                  = 1
    160 	COLFLAG_BUSY                          = 0x0100
    161 	COLFLAG_GENERATED                     = 0x0060
    162 	COLFLAG_HASCOLL                       = 0x0200
    163 	COLFLAG_HASTYPE                       = 0x0004
    164 	COLFLAG_HIDDEN                        = 0x0002
    165 	COLFLAG_NOEXPAND                      = 0x0400
    166 	COLFLAG_NOINSERT                      = 0x0062
    167 	COLFLAG_NOTAVAIL                      = 0x0080
    168 	COLFLAG_PRIMKEY                       = 0x0001
    169 	COLFLAG_SORTERREF                     = 0x0010
    170 	COLFLAG_STORED                        = 0x0040
    171 	COLFLAG_UNIQUE                        = 0x0008
    172 	COLFLAG_VIRTUAL                       = 0x0020
    173 	COLNAME_COLUMN                        = 4
    174 	COLNAME_DATABASE                      = 2
    175 	COLNAME_DECLTYPE                      = 1
    176 	COLNAME_N                             = 5
    177 	COLNAME_NAME                          = 0
    178 	COLNAME_TABLE                         = 3
    179 	COLTYPE_ANY                           = 1
    180 	COLTYPE_BLOB                          = 2
    181 	COLTYPE_CUSTOM                        = 0
    182 	COLTYPE_INT                           = 3
    183 	COLTYPE_INTEGER                       = 4
    184 	COLTYPE_REAL                          = 5
    185 	COLTYPE_TEXT                          = 6
    186 	CQUIT                                 = 034
    187 	CREPRINT                              = 18
    188 	CRPRNT                                = 18
    189 	CSTART                                = 17
    190 	CSTATUS                               = 0
    191 	CSTOP                                 = 19
    192 	CSUSP                                 = 26
    193 	CTIME                                 = 0
    194 	CURSOR_FAULT                          = 4
    195 	CURSOR_INVALID                        = 1
    196 	CURSOR_REQUIRESEEK                    = 3
    197 	CURSOR_SKIPNEXT                       = 2
    198 	CURSOR_VALID                          = 0
    199 	CURTYPE_BTREE                         = 0
    200 	CURTYPE_PSEUDO                        = 3
    201 	CURTYPE_SORTER                        = 1
    202 	CURTYPE_VTAB                          = 2
    203 	CWERASE                               = 23
    204 	DBFLAG_EncodingFixed                  = 0x0040
    205 	DBFLAG_InternalFunc                   = 0x0020
    206 	DBFLAG_PreferBuiltin                  = 0x0002
    207 	DBFLAG_SchemaChange                   = 0x0001
    208 	DBFLAG_SchemaKnownOk                  = 0x0010
    209 	DBFLAG_Vacuum                         = 0x0004
    210 	DBFLAG_VacuumInto                     = 0x0008
    211 	DB_ResetWanted                        = 0x0008
    212 	DB_SchemaLoaded                       = 0x0001
    213 	DB_UnresetViews                       = 0x0002
    214 	DEFFILEMODE                           = 438
    215 	DIRECT_MODE                           = 0
    216 	DN_ACCESS                             = 0x00000001
    217 	DN_ATTRIB                             = 0x00000020
    218 	DN_CREATE                             = 0x00000004
    219 	DN_DELETE                             = 0x00000008
    220 	DN_MODIFY                             = 0x00000002
    221 	DN_MULTISHOT                          = 0x80000000
    222 	DN_RENAME                             = 0x00000010
    223 	DOTLOCK_SUFFIX                        = ".lock"
    224 	E2BIG                                 = 7
    225 	EACCES                                = 13
    226 	EADDRINUSE                            = 98
    227 	EADDRNOTAVAIL                         = 99
    228 	EADV                                  = 68
    229 	EAFNOSUPPORT                          = 97
    230 	EAGAIN                                = 11
    231 	EALREADY                              = 114
    232 	EBADE                                 = 52
    233 	EBADF                                 = 9
    234 	EBADFD                                = 77
    235 	EBADMSG                               = 74
    236 	EBADR                                 = 53
    237 	EBADRQC                               = 56
    238 	EBADSLT                               = 57
    239 	EBFONT                                = 59
    240 	EBUSY                                 = 16
    241 	ECANCELED                             = 125
    242 	ECHILD                                = 10
    243 	ECHRNG                                = 44
    244 	ECOMM                                 = 70
    245 	ECONNABORTED                          = 103
    246 	ECONNREFUSED                          = 111
    247 	ECONNRESET                            = 104
    248 	EDEADLK                               = 35
    249 	EDEADLOCK                             = 35
    250 	EDESTADDRREQ                          = 89
    251 	EDOM                                  = 33
    252 	EDOTDOT                               = 73
    253 	EDQUOT                                = 122
    254 	EEXIST                                = 17
    255 	EFAULT                                = 14
    256 	EFBIG                                 = 27
    257 	EHOSTDOWN                             = 112
    258 	EHOSTUNREACH                          = 113
    259 	EHWPOISON                             = 133
    260 	EIDRM                                 = 43
    261 	EILSEQ                                = 84
    262 	EINPROGRESS                           = 115
    263 	EINTR                                 = 4
    264 	EINVAL                                = 22
    265 	EIO                                   = 5
    266 	EISCONN                               = 106
    267 	EISDIR                                = 21
    268 	EISNAM                                = 120
    269 	EKEYEXPIRED                           = 127
    270 	EKEYREJECTED                          = 129
    271 	EKEYREVOKED                           = 128
    272 	EL2HLT                                = 51
    273 	EL2NSYNC                              = 45
    274 	EL3HLT                                = 46
    275 	EL3RST                                = 47
    276 	ELIBACC                               = 79
    277 	ELIBBAD                               = 80
    278 	ELIBEXEC                              = 83
    279 	ELIBMAX                               = 82
    280 	ELIBSCN                               = 81
    281 	ELNRNG                                = 48
    282 	ELOOP                                 = 40
    283 	EMEDIUMTYPE                           = 124
    284 	EMFILE                                = 24
    285 	EMLINK                                = 31
    286 	EMSGSIZE                              = 90
    287 	EMULTIHOP                             = 72
    288 	ENAMETOOLONG                          = 36
    289 	ENAME_NAME                            = 0
    290 	ENAME_SPAN                            = 1
    291 	ENAME_TAB                             = 2
    292 	ENAVAIL                               = 119
    293 	ENETDOWN                              = 100
    294 	ENETRESET                             = 102
    295 	ENETUNREACH                           = 101
    296 	ENFILE                                = 23
    297 	ENOANO                                = 55
    298 	ENOBUFS                               = 105
    299 	ENOCSI                                = 50
    300 	ENODATA                               = 61
    301 	ENODEV                                = 19
    302 	ENOENT                                = 2
    303 	ENOEXEC                               = 8
    304 	ENOKEY                                = 126
    305 	ENOLCK                                = 37
    306 	ENOLINK                               = 67
    307 	ENOMEDIUM                             = 123
    308 	ENOMEM                                = 12
    309 	ENOMSG                                = 42
    310 	ENONET                                = 64
    311 	ENOPKG                                = 65
    312 	ENOPROTOOPT                           = 92
    313 	ENOSPC                                = 28
    314 	ENOSR                                 = 63
    315 	ENOSTR                                = 60
    316 	ENOSYS                                = 38
    317 	ENOTBLK                               = 15
    318 	ENOTCONN                              = 107
    319 	ENOTDIR                               = 20
    320 	ENOTEMPTY                             = 39
    321 	ENOTNAM                               = 118
    322 	ENOTRECOVERABLE                       = 131
    323 	ENOTSOCK                              = 88
    324 	ENOTSUP                               = 95
    325 	ENOTTY                                = 25
    326 	ENOTUNIQ                              = 76
    327 	ENXIO                                 = 6
    328 	EOF                                   = -1
    329 	EOPNOTSUPP                            = 95
    330 	EOVERFLOW                             = 75
    331 	EOWNERDEAD                            = 130
    332 	EPERM                                 = 1
    333 	EPFNOSUPPORT                          = 96
    334 	EPIPE                                 = 32
    335 	EPROTO                                = 71
    336 	EPROTONOSUPPORT                       = 93
    337 	EPROTOTYPE                            = 91
    338 	EP_Agg                                = 0x000010
    339 	EP_CanBeNull                          = 0x200000
    340 	EP_Collate                            = 0x000200
    341 	EP_Commuted                           = 0x000400
    342 	EP_ConstFunc                          = 0x100000
    343 	EP_DblQuoted                          = 0x000080
    344 	EP_Distinct                           = 0x000004
    345 	EP_FixedCol                           = 0x000020
    346 	EP_FromDDL                            = 0x40000000
    347 	EP_HasFunc                            = 0x000008
    348 	EP_IfNullRow                          = 0x040000
    349 	EP_Immutable                          = 0x02
    350 	EP_InfixFunc                          = 0x000100
    351 	EP_InnerON                            = 0x000002
    352 	EP_IntValue                           = 0x000800
    353 	EP_IsFalse                            = 0x20000000
    354 	EP_IsTrue                             = 0x10000000
    355 	EP_Leaf                               = 0x800000
    356 	EP_NoReduce                           = 0x01
    357 	EP_OuterON                            = 0x000001
    358 	EP_Propagate                          = 4194824
    359 	EP_Quoted                             = 0x4000000
    360 	EP_Reduced                            = 0x004000
    361 	EP_Skip                               = 0x002000
    362 	EP_Static                             = 0x8000000
    363 	EP_Subquery                           = 0x400000
    364 	EP_Subrtn                             = 0x2000000
    365 	EP_TokenOnly                          = 0x010000
    366 	EP_Unlikely                           = 0x080000
    367 	EP_VarSelect                          = 0x000040
    368 	EP_Win                                = 0x008000
    369 	EP_WinFunc                            = 0x1000000
    370 	EP_xIsSelect                          = 0x001000
    371 	ERANGE                                = 34
    372 	EREMCHG                               = 78
    373 	EREMOTE                               = 66
    374 	EREMOTEIO                             = 121
    375 	ERESTART                              = 85
    376 	ERFKILL                               = 132
    377 	EROFS                                 = 30
    378 	ESHUTDOWN                             = 108
    379 	ESOCKTNOSUPPORT                       = 94
    380 	ESPIPE                                = 29
    381 	ESRCH                                 = 3
    382 	ESRMNT                                = 69
    383 	ESTALE                                = 116
    384 	ESTRPIPE                              = 86
    385 	ETIME                                 = 62
    386 	ETIMEDOUT                             = 110
    387 	ETOOMANYREFS                          = 109
    388 	ETXTBSY                               = 26
    389 	EU4_EXPR                              = 2
    390 	EU4_IDX                               = 1
    391 	EU4_NONE                              = 0
    392 	EUCLEAN                               = 117
    393 	EUNATCH                               = 49
    394 	EUSERS                                = 87
    395 	EWOULDBLOCK                           = 11
    396 	EXCLUDED_TABLE_NUMBER                 = 2
    397 	EXCLUSIVE_LOCK                        = 4
    398 	EXDEV                                 = 18
    399 	EXFULL                                = 54
    400 	EXIT_FAILURE                          = 1
    401 	EXIT_SUCCESS                          = 0
    402 	EXPRDUP_REDUCE                        = 0x0001
    403 	F2FS_FEATURE_ATOMIC_WRITE             = 0x0004
    404 	F2FS_IOCTL_MAGIC                      = 0xf5
    405 	F2FS_IOC_ABORT_VOLATILE_WRITE         = 62725
    406 	F2FS_IOC_COMMIT_ATOMIC_WRITE          = 62722
    407 	F2FS_IOC_START_ATOMIC_WRITE           = 62721
    408 	F2FS_IOC_START_VOLATILE_WRITE         = 62723
    409 	FALLOC_FL_COLLAPSE_RANGE              = 0x08
    410 	FALLOC_FL_INSERT_RANGE                = 0x20
    411 	FALLOC_FL_KEEP_SIZE                   = 0x01
    412 	FALLOC_FL_NO_HIDE_STALE               = 0x04
    413 	FALLOC_FL_PUNCH_HOLE                  = 0x02
    414 	FALLOC_FL_UNSHARE_RANGE               = 0x40
    415 	FALLOC_FL_ZERO_RANGE                  = 0x10
    416 	FAPPEND                               = 1024
    417 	FASYNC                                = 8192
    418 	FD_CLOEXEC                            = 1
    419 	FD_SETSIZE                            = 1024
    420 	FFSYNC                                = 1052672
    421 	FILENAME_MAX                          = 4096
    422 	FIOASYNC                              = 0x5452
    423 	FIOCLEX                               = 0x5451
    424 	FIONBIO                               = 0x5421
    425 	FIONCLEX                              = 0x5450
    426 	FIONREAD                              = 0x541B
    427 	FIOQSIZE                              = 0x545E
    428 	FLAG_SIGNED                           = 1
    429 	FLAG_STRING                           = 4
    430 	FNDELAY                               = 2048
    431 	FNONBLOCK                             = 2048
    432 	FOPEN_MAX                             = 16
    433 	FP_ILOGB0                             = -2147483647
    434 	FP_ILOGBNAN                           = 2147483647
    435 	FP_INFINITE1                          = 1
    436 	FP_INT_DOWNWARD1                      = 1
    437 	FP_INT_TONEAREST1                     = 4
    438 	FP_INT_TONEARESTFROMZERO1             = 3
    439 	FP_INT_TOWARDZERO1                    = 2
    440 	FP_INT_UPWARD1                        = 0
    441 	FP_LLOGB0                             = -2147483647
    442 	FP_LLOGBNAN                           = 2147483647
    443 	FP_NAN1                               = 0
    444 	FP_NORMAL1                            = 4
    445 	FP_SUBNORMAL1                         = 3
    446 	FP_ZERO1                              = 2
    447 	FTS5CSR_EOF                           = 0x01
    448 	FTS5CSR_FREE_ZRANK                    = 0x10
    449 	FTS5CSR_REQUIRE_CONTENT               = 0x02
    450 	FTS5CSR_REQUIRE_DOCSIZE               = 0x04
    451 	FTS5CSR_REQUIRE_INST                  = 0x08
    452 	FTS5CSR_REQUIRE_POSLIST               = 0x40
    453 	FTS5CSR_REQUIRE_RESEEK                = 0x20
    454 	FTS5INDEX_QUERY_DESC                  = 0x0002
    455 	FTS5INDEX_QUERY_NOOUTPUT              = 0x0020
    456 	FTS5INDEX_QUERY_PREFIX                = 0x0001
    457 	FTS5INDEX_QUERY_SCAN                  = 0x0008
    458 	FTS5INDEX_QUERY_SKIPEMPTY             = 0x0010
    459 	FTS5INDEX_QUERY_TEST_NOIDX            = 0x0004
    460 	FTS5_AND                              = 2
    461 	FTS5_AVERAGES_ROWID                   = 1
    462 	FTS5_BI_MATCH                         = 0x0001
    463 	FTS5_BI_ORDER_DESC                    = 0x0080
    464 	FTS5_BI_ORDER_RANK                    = 0x0020
    465 	FTS5_BI_ORDER_ROWID                   = 0x0040
    466 	FTS5_BI_RANK                          = 0x0002
    467 	FTS5_BI_ROWID_EQ                      = 0x0004
    468 	FTS5_BI_ROWID_GE                      = 0x0010
    469 	FTS5_BI_ROWID_LE                      = 0x0008
    470 	FTS5_CARET                            = 12
    471 	FTS5_COLON                            = 5
    472 	FTS5_COMMA                            = 13
    473 	FTS5_CONTENT_EXTERNAL                 = 2
    474 	FTS5_CONTENT_NONE                     = 1
    475 	FTS5_CONTENT_NORMAL                   = 0
    476 	FTS5_CORRUPT                          = 267
    477 	FTS5_CURRENT_VERSION                  = 4
    478 	FTS5_DATA_DLI_B                       = 1
    479 	FTS5_DATA_HEIGHT_B                    = 5
    480 	FTS5_DATA_ID_B                        = 16
    481 	FTS5_DATA_PADDING                     = 20
    482 	FTS5_DATA_PAGE_B                      = 31
    483 	FTS5_DATA_ZERO_PADDING                = 8
    484 	FTS5_DEFAULT_AUTOMERGE                = 4
    485 	FTS5_DEFAULT_CRISISMERGE              = 16
    486 	FTS5_DEFAULT_HASHSIZE                 = 1048576
    487 	FTS5_DEFAULT_NEARDIST                 = 10
    488 	FTS5_DEFAULT_PAGE_SIZE                = 4050
    489 	FTS5_DEFAULT_RANK                     = "bm25"
    490 	FTS5_DEFAULT_USERMERGE                = 4
    491 	FTS5_DETAIL_COLUMNS                   = 2
    492 	FTS5_DETAIL_FULL                      = 0
    493 	FTS5_DETAIL_NONE                      = 1
    494 	FTS5_EOF                              = 0
    495 	FTS5_LCP                              = 7
    496 	FTS5_LP                               = 10
    497 	FTS5_MAIN_PREFIX                      = 48
    498 	FTS5_MAX_LEVEL                        = 64
    499 	FTS5_MAX_PAGE_SIZE                    = 65536
    500 	FTS5_MAX_PREFIX_INDEXES               = 31
    501 	FTS5_MAX_SEGMENT                      = 2000
    502 	FTS5_MAX_TOKEN_SIZE                   = 32768
    503 	FTS5_MERGE_NLIST                      = 16
    504 	FTS5_MINUS                            = 6
    505 	FTS5_MIN_DLIDX_SIZE                   = 4
    506 	FTS5_NOT                              = 3
    507 	FTS5_OPT_WORK_UNIT                    = 1000
    508 	FTS5_OR                               = 1
    509 	FTS5_PATTERN_GLOB                     = 66
    510 	FTS5_PATTERN_LIKE                     = 65
    511 	FTS5_PATTERN_NONE                     = 0
    512 	FTS5_PLAN_MATCH                       = 1
    513 	FTS5_PLAN_ROWID                       = 6
    514 	FTS5_PLAN_SCAN                        = 5
    515 	FTS5_PLAN_SORTED_MATCH                = 4
    516 	FTS5_PLAN_SOURCE                      = 2
    517 	FTS5_PLAN_SPECIAL                     = 3
    518 	FTS5_PLUS                             = 14
    519 	FTS5_PORTER_MAX_TOKEN                 = 64
    520 	FTS5_RANK_NAME                        = "rank"
    521 	FTS5_RCP                              = 8
    522 	FTS5_REMOVE_DIACRITICS_COMPLEX        = 2
    523 	FTS5_REMOVE_DIACRITICS_NONE           = 0
    524 	FTS5_REMOVE_DIACRITICS_SIMPLE         = 1
    525 	FTS5_ROWID_NAME                       = "rowid"
    526 	FTS5_RP                               = 11
    527 	FTS5_SEGITER_ONETERM                  = 0x01
    528 	FTS5_SEGITER_REVERSE                  = 0x02
    529 	FTS5_STAR                             = 15
    530 	FTS5_STMT_DELETE_CONTENT              = 5
    531 	FTS5_STMT_DELETE_DOCSIZE              = 7
    532 	FTS5_STMT_INSERT_CONTENT              = 3
    533 	FTS5_STMT_LOOKUP                      = 2
    534 	FTS5_STMT_LOOKUP_DOCSIZE              = 8
    535 	FTS5_STMT_REPLACE_CONFIG              = 9
    536 	FTS5_STMT_REPLACE_CONTENT             = 4
    537 	FTS5_STMT_REPLACE_DOCSIZE             = 6
    538 	FTS5_STMT_SCAN                        = 10
    539 	FTS5_STMT_SCAN_ASC                    = 0
    540 	FTS5_STMT_SCAN_DESC                   = 1
    541 	FTS5_STRING                           = 9
    542 	FTS5_STRUCTURE_ROWID                  = 10
    543 	FTS5_TERM                             = 4
    544 	FTS5_TOKENIZE_AUX                     = 0x0008
    545 	FTS5_TOKENIZE_DOCUMENT                = 0x0004
    546 	FTS5_TOKENIZE_PREFIX                  = 0x0002
    547 	FTS5_TOKENIZE_QUERY                   = 0x0001
    548 	FTS5_TOKEN_COLOCATED                  = 0x0001
    549 	FTS5_VOCAB_COL                        = 0
    550 	FTS5_VOCAB_COL_SCHEMA                 = "term, col, doc, cnt"
    551 	FTS5_VOCAB_INSTANCE                   = 2
    552 	FTS5_VOCAB_INST_SCHEMA                = "term, doc, col, offset"
    553 	FTS5_VOCAB_ROW                        = 1
    554 	FTS5_VOCAB_ROW_SCHEMA                 = "term, doc, cnt"
    555 	FTS5_VOCAB_TERM_EQ                    = 0x01
    556 	FTS5_VOCAB_TERM_GE                    = 0x02
    557 	FTS5_VOCAB_TERM_LE                    = 0x04
    558 	FTS5_WORK_UNIT                        = 64
    559 	FULLY_WITHIN                          = 2
    560 	FUNC_PERFECT_MATCH                    = 6
    561 	F_ADD_SEALS                           = 1033
    562 	F_DUPFD                               = 0
    563 	F_DUPFD_CLOEXEC                       = 1030
    564 	F_EXLCK                               = 4
    565 	F_GETFD                               = 1
    566 	F_GETFL                               = 3
    567 	F_GETLEASE                            = 1025
    568 	F_GETLK                               = 12
    569 	F_GETLK64                             = 12
    570 	F_GETOWN                              = 9
    571 	F_GETOWN_EX                           = 16
    572 	F_GETPIPE_SZ                          = 1032
    573 	F_GETSIG                              = 11
    574 	F_GET_FILE_RW_HINT                    = 1037
    575 	F_GET_RW_HINT                         = 1035
    576 	F_GET_SEALS                           = 1034
    577 	F_LOCK                                = 1
    578 	F_NOTIFY                              = 1026
    579 	F_OFD_GETLK                           = 36
    580 	F_OFD_SETLK                           = 37
    581 	F_OFD_SETLKW                          = 38
    582 	F_OK                                  = 0
    583 	F_RDLCK                               = 0
    584 	F_SEAL_FUTURE_WRITE                   = 0x0010
    585 	F_SEAL_GROW                           = 0x0004
    586 	F_SEAL_SEAL                           = 0x0001
    587 	F_SEAL_SHRINK                         = 0x0002
    588 	F_SEAL_WRITE                          = 0x0008
    589 	F_SETFD                               = 2
    590 	F_SETFL                               = 4
    591 	F_SETLEASE                            = 1024
    592 	F_SETLK                               = 13
    593 	F_SETLK64                             = 13
    594 	F_SETLKW                              = 14
    595 	F_SETLKW64                            = 14
    596 	F_SETOWN                              = 8
    597 	F_SETOWN_EX                           = 15
    598 	F_SETPIPE_SZ                          = 1031
    599 	F_SETSIG                              = 10
    600 	F_SET_FILE_RW_HINT                    = 1038
    601 	F_SET_RW_HINT                         = 1036
    602 	F_SHLCK                               = 8
    603 	F_TEST                                = 3
    604 	F_TLOCK                               = 2
    605 	F_ULOCK                               = 0
    606 	F_UNLCK                               = 2
    607 	F_WRLCK                               = 1
    608 	GCC_VERSION                           = 10002001
    609 	GEOPOLY_PI                            = 3.1415926535897932385
    610 	HASHSIZE                              = 97
    611 	HASHTABLE_HASH_1                      = 383
    612 	HASHTABLE_NPAGE                       = 4096
    613 	HASHTABLE_NSLOT                       = 8192
    614 	HAVE_FCHMOD                           = 0
    615 	HAVE_FCHOWN                           = 1
    616 	HAVE_FULLFSYNC                        = 0
    617 	HAVE_GETHOSTUUID                      = 0
    618 	HAVE_LSTAT                            = 1
    619 	HAVE_MREMAP                           = 1
    620 	HAVE_READLINK                         = 1
    621 	HAVE_USLEEP                           = 1
    622 	INCRINIT_NORMAL                       = 0
    623 	INCRINIT_ROOT                         = 2
    624 	INCRINIT_TASK                         = 1
    625 	INITFLAG_AlterAdd                     = 0x0003
    626 	INITFLAG_AlterDrop                    = 0x0002
    627 	INITFLAG_AlterMask                    = 0x0003
    628 	INITFLAG_AlterRename                  = 0x0001
    629 	INLINEFUNC_affinity                   = 4
    630 	INLINEFUNC_coalesce                   = 0
    631 	INLINEFUNC_expr_compare               = 3
    632 	INLINEFUNC_expr_implies_expr          = 2
    633 	INLINEFUNC_iif                        = 5
    634 	INLINEFUNC_implies_nonnull_row        = 1
    635 	INLINEFUNC_sqlite_offset              = 6
    636 	INLINEFUNC_unlikely                   = 99
    637 	INTERFACE                             = 1
    638 	IN_INDEX_EPH                          = 2
    639 	IN_INDEX_INDEX_ASC                    = 3
    640 	IN_INDEX_INDEX_DESC                   = 4
    641 	IN_INDEX_LOOP                         = 0x0004
    642 	IN_INDEX_MEMBERSHIP                   = 0x0002
    643 	IN_INDEX_NOOP                         = 5
    644 	IN_INDEX_NOOP_OK                      = 0x0001
    645 	IN_INDEX_ROWID                        = 1
    646 	IOCSIZE_MASK                          = 1073676288
    647 	IOCSIZE_SHIFT                         = 16
    648 	IOC_IN                                = 1073741824
    649 	IOC_INOUT                             = 3221225472
    650 	IOC_OUT                               = 2147483648
    651 	IsStat4                               = 1
    652 	JEACH_ATOM                            = 3
    653 	JEACH_FULLKEY                         = 6
    654 	JEACH_ID                              = 4
    655 	JEACH_JSON                            = 8
    656 	JEACH_KEY                             = 0
    657 	JEACH_PARENT                          = 5
    658 	JEACH_PATH                            = 7
    659 	JEACH_ROOT                            = 9
    660 	JEACH_TYPE                            = 2
    661 	JEACH_VALUE                           = 1
    662 	JNODE_APPEND                          = 0x20
    663 	JNODE_ESCAPE                          = 0x02
    664 	JNODE_LABEL                           = 0x40
    665 	JNODE_PATCH                           = 0x10
    666 	JNODE_RAW                             = 0x01
    667 	JNODE_REMOVE                          = 0x04
    668 	JNODE_REPLACE                         = 0x08
    669 	JSON_ABPATH                           = 0x03
    670 	JSON_ARRAY                            = 6
    671 	JSON_CACHE_ID                         = -429938
    672 	JSON_CACHE_SZ                         = 4
    673 	JSON_FALSE                            = 2
    674 	JSON_INT                              = 3
    675 	JSON_ISSET                            = 0x04
    676 	JSON_JSON                             = 0x01
    677 	JSON_MAX_DEPTH                        = 2000
    678 	JSON_NULL                             = 0
    679 	JSON_OBJECT                           = 7
    680 	JSON_REAL                             = 4
    681 	JSON_SQL                              = 0x02
    682 	JSON_STRING                           = 5
    683 	JSON_SUBTYPE                          = 74
    684 	JSON_TRUE                             = 1
    685 	JT_CROSS                              = 0x02
    686 	JT_ERROR                              = 0x80
    687 	JT_INNER                              = 0x01
    688 	JT_LEFT                               = 0x08
    689 	JT_LTORJ                              = 0x40
    690 	JT_NATURAL                            = 0x04
    691 	JT_OUTER                              = 0x20
    692 	JT_RIGHT                              = 0x10
    693 	KEYINFO_ORDER_BIGNULL                 = 0x02
    694 	KEYINFO_ORDER_DESC                    = 0x01
    695 	LEGACY_SCHEMA_TABLE                   = "sqlite_master"
    696 	LEGACY_TEMP_SCHEMA_TABLE              = "sqlite_temp_master"
    697 	LITTLE_ENDIAN                         = 1234
    698 	LM_ID_BASE                            = 0
    699 	LM_ID_NEWLM                           = -1
    700 	LOCATE_NOERR                          = 0x02
    701 	LOCATE_VIEW                           = 0x01
    702 	LOCK_EX                               = 2
    703 	LOCK_MAND                             = 32
    704 	LOCK_NB                               = 4
    705 	LOCK_READ                             = 64
    706 	LOCK_RW                               = 192
    707 	LOCK_SH                               = 1
    708 	LOCK_UN                               = 8
    709 	LOCK_WRITE                            = 128
    710 	LOOKASIDE_SMALL                       = 128
    711 	L_INCR                                = 1
    712 	L_SET                                 = 0
    713 	L_XTND                                = 2
    714 	L_ctermid                             = 9
    715 	L_cuserid                             = 9
    716 	L_tmpnam                              = 20
    717 	M10d_Any                              = 1
    718 	M10d_No                               = 2
    719 	M10d_Yes                              = 0
    720 	MADV_COLD                             = 20
    721 	MADV_DODUMP                           = 17
    722 	MADV_DOFORK                           = 11
    723 	MADV_DONTDUMP                         = 16
    724 	MADV_DONTFORK                         = 10
    725 	MADV_DONTNEED                         = 4
    726 	MADV_FREE                             = 8
    727 	MADV_HUGEPAGE                         = 14
    728 	MADV_HWPOISON                         = 100
    729 	MADV_KEEPONFORK                       = 19
    730 	MADV_MERGEABLE                        = 12
    731 	MADV_NOHUGEPAGE                       = 15
    732 	MADV_NORMAL                           = 0
    733 	MADV_PAGEOUT                          = 21
    734 	MADV_RANDOM                           = 1
    735 	MADV_REMOVE                           = 9
    736 	MADV_SEQUENTIAL                       = 2
    737 	MADV_UNMERGEABLE                      = 13
    738 	MADV_WILLNEED                         = 3
    739 	MADV_WIPEONFORK                       = 18
    740 	MAP_ANON                              = 32
    741 	MAP_ANONYMOUS                         = 0x20
    742 	MAP_DENYWRITE                         = 0x00800
    743 	MAP_EXECUTABLE                        = 0x01000
    744 	MAP_FILE                              = 0
    745 	MAP_FIXED                             = 0x10
    746 	MAP_FIXED_NOREPLACE                   = 0x100000
    747 	MAP_GROWSDOWN                         = 0x00100
    748 	MAP_HUGETLB                           = 0x40000
    749 	MAP_HUGE_MASK                         = 0x3f
    750 	MAP_HUGE_SHIFT                        = 26
    751 	MAP_LOCKED                            = 0x02000
    752 	MAP_NONBLOCK                          = 0x10000
    753 	MAP_NORESERVE                         = 0x04000
    754 	MAP_POPULATE                          = 0x08000
    755 	MAP_PRIVATE                           = 0x02
    756 	MAP_SHARED                            = 0x01
    757 	MAP_SHARED_VALIDATE                   = 0x03
    758 	MAP_STACK                             = 0x20000
    759 	MAP_SYNC                              = 0x80000
    760 	MAP_TYPE                              = 0x0f
    761 	MATH_ERREXCEPT                        = 2
    762 	MATH_ERRNO                            = 1
    763 	MAXFLOAT                              = 3.40282347e+38
    764 	MAX_HANDLE_SZ                         = 128
    765 	MAX_PATHNAME                          = 512
    766 	MAX_SECTOR_SIZE                       = 0x10000
    767 	MCL_CURRENT                           = 1
    768 	MCL_FUTURE                            = 2
    769 	MCL_ONFAULT                           = 4
    770 	MEMJOURNAL_DFLT_FILECHUNKSIZE         = 1024
    771 	MEMTYPE_HEAP                          = 0x01
    772 	MEMTYPE_LOOKASIDE                     = 0x02
    773 	MEMTYPE_PCACHE                        = 0x04
    774 	MEM_AffMask                           = 0x003f
    775 	MEM_Agg                               = 0x8000
    776 	MEM_Blob                              = 0x0010
    777 	MEM_Cleared                           = 0x0100
    778 	MEM_Dyn                               = 0x1000
    779 	MEM_Ephem                             = 0x4000
    780 	MEM_FromBind                          = 0x0040
    781 	MEM_Int                               = 0x0004
    782 	MEM_IntReal                           = 0x0020
    783 	MEM_Null                              = 0x0001
    784 	MEM_Real                              = 0x0008
    785 	MEM_Static                            = 0x2000
    786 	MEM_Str                               = 0x0002
    787 	MEM_Subtype                           = 0x0800
    788 	MEM_Term                              = 0x0200
    789 	MEM_TypeMask                          = 0x0dbf
    790 	MEM_Undefined                         = 0x0000
    791 	MEM_Zero                              = 0x0400
    792 	MFD_ALLOW_SEALING                     = 2
    793 	MFD_CLOEXEC                           = 1
    794 	MFD_HUGETLB                           = 4
    795 	MLOCK_ONFAULT                         = 1
    796 	MOD_CLKA                              = 32769
    797 	MOD_CLKB                              = 16384
    798 	MOD_ESTERROR                          = 8
    799 	MOD_FREQUENCY                         = 2
    800 	MOD_MAXERROR                          = 4
    801 	MOD_MICRO                             = 4096
    802 	MOD_NANO                              = 8192
    803 	MOD_OFFSET                            = 1
    804 	MOD_STATUS                            = 16
    805 	MOD_TAI                               = 128
    806 	MOD_TIMECONST                         = 32
    807 	MREMAP_FIXED                          = 2
    808 	MREMAP_MAYMOVE                        = 1
    809 	MSVC_VERSION                          = 0
    810 	MS_ASYNC                              = 1
    811 	MS_INVALIDATE                         = 2
    812 	MS_SYNC                               = 4
    813 	M_1_PI                                = 0.31830988618379067154
    814 	M_1_PIf32                             = 0
    815 	M_1_PIf32x                            = 0
    816 	M_1_PIf64                             = 0
    817 	M_1_PIl                               = 0.318309886183790671537767526745028724
    818 	M_2_PI                                = 0.63661977236758134308
    819 	M_2_PIf32                             = 0
    820 	M_2_PIf32x                            = 0
    821 	M_2_PIf64                             = 0
    822 	M_2_PIl                               = 0.636619772367581343075535053490057448
    823 	M_2_SQRTPI                            = 1.12837916709551257390
    824 	M_2_SQRTPIf32                         = 0
    825 	M_2_SQRTPIf32x                        = 0
    826 	M_2_SQRTPIf64                         = 0
    827 	M_2_SQRTPIl                           = 1.128379167095512573896158903121545172
    828 	M_E                                   = 2.7182818284590452354
    829 	M_Ef32                                = 0
    830 	M_Ef32x                               = 0
    831 	M_Ef64                                = 0
    832 	M_El                                  = 2.718281828459045235360287471352662498
    833 	M_LN10                                = 2.30258509299404568402
    834 	M_LN10f32                             = 0
    835 	M_LN10f32x                            = 0
    836 	M_LN10f64                             = 0
    837 	M_LN10l                               = 2.302585092994045684017991454684364208
    838 	M_LN2                                 = 0.69314718055994530942
    839 	M_LN2f32                              = 0
    840 	M_LN2f32x                             = 0
    841 	M_LN2f64                              = 0
    842 	M_LN2l                                = 0.693147180559945309417232121458176568
    843 	M_LOG10E                              = 0.43429448190325182765
    844 	M_LOG10Ef32                           = 0
    845 	M_LOG10Ef32x                          = 0
    846 	M_LOG10Ef64                           = 0
    847 	M_LOG10El                             = 0.434294481903251827651128918916605082
    848 	M_LOG2E                               = 1.4426950408889634074
    849 	M_LOG2Ef32                            = 0
    850 	M_LOG2Ef32x                           = 0
    851 	M_LOG2Ef64                            = 0
    852 	M_LOG2El                              = 1.442695040888963407359924681001892137
    853 	M_PI                                  = 3.14159265358979323846
    854 	M_PI_2                                = 1.57079632679489661923
    855 	M_PI_2f32                             = 0
    856 	M_PI_2f32x                            = 0
    857 	M_PI_2f64                             = 0
    858 	M_PI_2l                               = 1.570796326794896619231321691639751442
    859 	M_PI_4                                = 0.78539816339744830962
    860 	M_PI_4f32                             = 0
    861 	M_PI_4f32x                            = 0
    862 	M_PI_4f64                             = 0
    863 	M_PI_4l                               = 0.785398163397448309615660845819875721
    864 	M_PIf32                               = 0
    865 	M_PIf32x                              = 0
    866 	M_PIf64                               = 0
    867 	M_PIl                                 = 3.141592653589793238462643383279502884
    868 	M_SQRT1_2                             = 0.70710678118654752440
    869 	M_SQRT1_2f32                          = 0
    870 	M_SQRT1_2f32x                         = 0
    871 	M_SQRT1_2f64                          = 0
    872 	M_SQRT1_2l                            = 0.707106781186547524400844362104849039
    873 	M_SQRT2                               = 1.41421356237309504880
    874 	M_SQRT2f32                            = 0
    875 	M_SQRT2f32x                           = 0
    876 	M_SQRT2f64                            = 0
    877 	M_SQRT2l                              = 1.414213562373095048801688724209698079
    878 	NB                                    = 3
    879 	NCC                                   = 8
    880 	NC_AllowAgg                           = 0x000001
    881 	NC_AllowWin                           = 0x004000
    882 	NC_Complex                            = 0x002000
    883 	NC_FromDDL                            = 0x040000
    884 	NC_GenCol                             = 0x000008
    885 	NC_HasAgg                             = 0x000010
    886 	NC_HasWin                             = 0x008000
    887 	NC_IdxExpr                            = 0x000020
    888 	NC_InAggFunc                          = 0x020000
    889 	NC_IsCheck                            = 0x000004
    890 	NC_IsDDL                              = 0x010000
    891 	NC_MinMaxAgg                          = 0x001000
    892 	NC_NoSelect                           = 0x080000
    893 	NC_OrderAgg                           = 0x8000000
    894 	NC_PartIdx                            = 0x000002
    895 	NC_SelfRef                            = 0x00002e
    896 	NC_Subquery                           = 0x000040
    897 	NC_UAggInfo                           = 0x000100
    898 	NC_UBaseReg                           = 0x000400
    899 	NC_UEList                             = 0x000080
    900 	NC_UUpsert                            = 0x000200
    901 	NDEBUG                                = 1
    902 	NN                                    = 1
    903 	NOT_WITHIN                            = 0
    904 	NO_LOCK                               = 0
    905 	N_6PACK                               = 7
    906 	N_AX25                                = 5
    907 	N_HCI                                 = 15
    908 	N_HDLC                                = 13
    909 	N_IRDA                                = 11
    910 	N_MASC                                = 8
    911 	N_MOUSE                               = 2
    912 	N_OR_COST                             = 3
    913 	N_PPP                                 = 3
    914 	N_PROFIBUS_FDL                        = 10
    915 	N_R3964                               = 9
    916 	N_SLIP                                = 1
    917 	N_SMSBLOCK                            = 12
    918 	N_SORT_BUCKET                         = 32
    919 	N_STATEMENT                           = 8
    920 	N_STRIP                               = 4
    921 	N_SYNC_PPP                            = 14
    922 	N_TTY                                 = 0
    923 	N_X25                                 = 6
    924 	OE_Abort                              = 2
    925 	OE_Cascade                            = 10
    926 	OE_Default                            = 11
    927 	OE_Fail                               = 3
    928 	OE_Ignore                             = 4
    929 	OE_None                               = 0
    930 	OE_Replace                            = 5
    931 	OE_Restrict                           = 7
    932 	OE_Rollback                           = 1
    933 	OE_SetDflt                            = 9
    934 	OE_SetNull                            = 8
    935 	OE_Update                             = 6
    936 	OMIT_TEMPDB                           = 0
    937 	ONEPASS_MULTI                         = 2
    938 	ONEPASS_OFF                           = 0
    939 	ONEPASS_SINGLE                        = 1
    940 	OPFLAG_APPEND                         = 0x08
    941 	OPFLAG_AUXDELETE                      = 0x04
    942 	OPFLAG_BULKCSR                        = 0x01
    943 	OPFLAG_EPHEM                          = 0x01
    944 	OPFLAG_FORDELETE                      = 0x08
    945 	OPFLAG_ISNOOP                         = 0x40
    946 	OPFLAG_ISUPDATE                       = 0x04
    947 	OPFLAG_LASTROWID                      = 0x20
    948 	OPFLAG_LENGTHARG                      = 0x40
    949 	OPFLAG_NCHANGE                        = 0x01
    950 	OPFLAG_NOCHNG                         = 0x01
    951 	OPFLAG_NOCHNG_MAGIC                   = 0x6d
    952 	OPFLAG_P2ISREG                        = 0x10
    953 	OPFLAG_PERMUTE                        = 0x01
    954 	OPFLAG_PREFORMAT                      = 0x80
    955 	OPFLAG_SAVEPOSITION                   = 0x02
    956 	OPFLAG_SEEKEQ                         = 0x02
    957 	OPFLAG_TYPEOFARG                      = 0x80
    958 	OPFLAG_USESEEKRESULT                  = 0x10
    959 	OPFLG_IN1                             = 0x02
    960 	OPFLG_IN2                             = 0x04
    961 	OPFLG_IN3                             = 0x08
    962 	OPFLG_JUMP                            = 0x01
    963 	OPFLG_NCYCLE                          = 0x40
    964 	OPFLG_OUT2                            = 0x10
    965 	OPFLG_OUT3                            = 0x20
    966 	OP_Abortable                          = 186
    967 	OP_Add                                = 106
    968 	OP_AddImm                             = 86
    969 	OP_Affinity                           = 96
    970 	OP_AggFinal                           = 165
    971 	OP_AggInverse                         = 161
    972 	OP_AggStep                            = 162
    973 	OP_AggStep1                           = 163
    974 	OP_AggValue                           = 164
    975 	OP_And                                = 44
    976 	OP_AutoCommit                         = 1
    977 	OP_BeginSubrtn                        = 74
    978 	OP_BitAnd                             = 102
    979 	OP_BitNot                             = 114
    980 	OP_BitOr                              = 103
    981 	OP_Blob                               = 77
    982 	OP_Cast                               = 88
    983 	OP_Checkpoint                         = 3
    984 	OP_Clear                              = 145
    985 	OP_Close                              = 122
    986 	OP_ClrSubtype                         = 179
    987 	OP_CollSeq                            = 85
    988 	OP_Column                             = 94
    989 	OP_ColumnsUsed                        = 123
    990 	OP_Compare                            = 90
    991 	OP_Concat                             = 111
    992 	OP_Copy                               = 80
    993 	OP_Count                              = 98
    994 	OP_CreateBtree                        = 147
    995 	OP_CursorHint                         = 182
    996 	OP_CursorLock                         = 167
    997 	OP_CursorUnlock                       = 168
    998 	OP_DecrJumpZero                       = 61
    999 	OP_DeferredSeek                       = 141
   1000 	OP_Delete                             = 130
   1001 	OP_Destroy                            = 144
   1002 	OP_Divide                             = 109
   1003 	OP_DropIndex                          = 152
   1004 	OP_DropTable                          = 151
   1005 	OP_DropTrigger                        = 154
   1006 	OP_ElseEq                             = 58
   1007 	OP_EndCoroutine                       = 68
   1008 	OP_Eq                                 = 53
   1009 	OP_Expire                             = 166
   1010 	OP_Explain                            = 185
   1011 	OP_Filter                             = 64
   1012 	OP_FilterAdd                          = 180
   1013 	OP_FinishSeek                         = 143
   1014 	OP_FkCheck                            = 83
   1015 	OP_FkCounter                          = 158
   1016 	OP_FkIfZero                           = 49
   1017 	OP_Found                              = 29
   1018 	OP_Function                           = 66
   1019 	OP_Ge                                 = 57
   1020 	OP_Gosub                              = 10
   1021 	OP_Goto                               = 9
   1022 	OP_Gt                                 = 54
   1023 	OP_Halt                               = 70
   1024 	OP_HaltIfNull                         = 69
   1025 	OP_IdxDelete                          = 140
   1026 	OP_IdxGE                              = 45
   1027 	OP_IdxGT                              = 41
   1028 	OP_IdxInsert                          = 138
   1029 	OP_IdxLE                              = 40
   1030 	OP_IdxLT                              = 42
   1031 	OP_IdxRowid                           = 142
   1032 	OP_If                                 = 16
   1033 	OP_IfNoHope                           = 26
   1034 	OP_IfNot                              = 17
   1035 	OP_IfNotOpen                          = 25
   1036 	OP_IfNotZero                          = 60
   1037 	OP_IfNullRow                          = 20
   1038 	OP_IfPos                              = 59
   1039 	OP_IfSmaller                          = 33
   1040 	OP_IncrVacuum                         = 62
   1041 	OP_Init                               = 8
   1042 	OP_InitCoroutine                      = 11
   1043 	OP_Insert                             = 128
   1044 	OP_Int64                              = 72
   1045 	OP_IntCopy                            = 82
   1046 	OP_Integer                            = 71
   1047 	OP_IntegrityCk                        = 155
   1048 	OP_IsNull                             = 50
   1049 	OP_IsTrue                             = 91
   1050 	OP_IsType                             = 18
   1051 	OP_JournalMode                        = 4
   1052 	OP_Jump                               = 14
   1053 	OP_Last                               = 32
   1054 	OP_Le                                 = 55
   1055 	OP_LoadAnalysis                       = 150
   1056 	OP_Lt                                 = 56
   1057 	OP_MakeRecord                         = 97
   1058 	OP_MaxPgcnt                           = 178
   1059 	OP_MemMax                             = 159
   1060 	OP_Move                               = 79
   1061 	OP_Multiply                           = 108
   1062 	OP_MustBeInt                          = 13
   1063 	OP_Ne                                 = 52
   1064 	OP_NewRowid                           = 127
   1065 	OP_Next                               = 39
   1066 	OP_NoConflict                         = 27
   1067 	OP_Noop                               = 184
   1068 	OP_Not                                = 19
   1069 	OP_NotExists                          = 31
   1070 	OP_NotFound                           = 28
   1071 	OP_NotNull                            = 51
   1072 	OP_Null                               = 75
   1073 	OP_NullRow                            = 136
   1074 	OP_Offset                             = 93
   1075 	OP_OffsetLimit                        = 160
   1076 	OP_Once                               = 15
   1077 	OP_OpenAutoindex                      = 116
   1078 	OP_OpenDup                            = 115
   1079 	OP_OpenEphemeral                      = 118
   1080 	OP_OpenPseudo                         = 121
   1081 	OP_OpenRead                           = 112
   1082 	OP_OpenWrite                          = 113
   1083 	OP_Or                                 = 43
   1084 	OP_Pagecount                          = 177
   1085 	OP_Param                              = 157
   1086 	OP_ParseSchema                        = 149
   1087 	OP_Permutation                        = 89
   1088 	OP_Prev                               = 38
   1089 	OP_Program                            = 48
   1090 	OP_PureFunc                           = 65
   1091 	OP_ReadCookie                         = 99
   1092 	OP_Real                               = 153
   1093 	OP_RealAffinity                       = 87
   1094 	OP_ReleaseReg                         = 183
   1095 	OP_Remainder                          = 110
   1096 	OP_ReopenIdx                          = 101
   1097 	OP_ResetCount                         = 131
   1098 	OP_ResetSorter                        = 146
   1099 	OP_ResultRow                          = 84
   1100 	OP_Return                             = 67
   1101 	OP_Rewind                             = 36
   1102 	OP_RowCell                            = 129
   1103 	OP_RowData                            = 134
   1104 	OP_RowSetAdd                          = 156
   1105 	OP_RowSetRead                         = 46
   1106 	OP_RowSetTest                         = 47
   1107 	OP_Rowid                              = 135
   1108 	OP_SCopy                              = 81
   1109 	OP_Savepoint                          = 0
   1110 	OP_SeekEnd                            = 137
   1111 	OP_SeekGE                             = 23
   1112 	OP_SeekGT                             = 24
   1113 	OP_SeekHit                            = 125
   1114 	OP_SeekLE                             = 22
   1115 	OP_SeekLT                             = 21
   1116 	OP_SeekRowid                          = 30
   1117 	OP_SeekScan                           = 124
   1118 	OP_Sequence                           = 126
   1119 	OP_SequenceTest                       = 120
   1120 	OP_SetCookie                          = 100
   1121 	OP_ShiftLeft                          = 104
   1122 	OP_ShiftRight                         = 105
   1123 	OP_SoftNull                           = 76
   1124 	OP_Sort                               = 35
   1125 	OP_SorterCompare                      = 132
   1126 	OP_SorterData                         = 133
   1127 	OP_SorterInsert                       = 139
   1128 	OP_SorterNext                         = 37
   1129 	OP_SorterOpen                         = 119
   1130 	OP_SorterSort                         = 34
   1131 	OP_SqlExec                            = 148
   1132 	OP_String                             = 73
   1133 	OP_String8                            = 117
   1134 	OP_Subtract                           = 107
   1135 	OP_TableLock                          = 169
   1136 	OP_Trace                              = 181
   1137 	OP_Transaction                        = 2
   1138 	OP_TypeCheck                          = 95
   1139 	OP_VBegin                             = 170
   1140 	OP_VColumn                            = 175
   1141 	OP_VCreate                            = 171
   1142 	OP_VDestroy                           = 172
   1143 	OP_VFilter                            = 6
   1144 	OP_VInitIn                            = 174
   1145 	OP_VNext                              = 63
   1146 	OP_VOpen                              = 173
   1147 	OP_VRename                            = 176
   1148 	OP_VUpdate                            = 7
   1149 	OP_Vacuum                             = 5
   1150 	OP_Variable                           = 78
   1151 	OP_Yield                              = 12
   1152 	OP_ZeroOrNull                         = 92
   1153 	OS_VXWORKS                            = 0
   1154 	O_ACCMODE                             = 0003
   1155 	O_APPEND                              = 02000
   1156 	O_ASYNC                               = 020000
   1157 	O_BINARY                              = 0
   1158 	O_CLOEXEC                             = 524288
   1159 	O_CREAT                               = 0100
   1160 	O_DIRECT                              = 65536
   1161 	O_DIRECTORY                           = 16384
   1162 	O_DSYNC                               = 4096
   1163 	O_EXCL                                = 0200
   1164 	O_FSYNC                               = 1052672
   1165 	O_LARGEFILE                           = 131072
   1166 	O_NDELAY                              = 2048
   1167 	O_NOATIME                             = 262144
   1168 	O_NOCTTY                              = 0400
   1169 	O_NOFOLLOW                            = 32768
   1170 	O_NONBLOCK                            = 04000
   1171 	O_PATH                                = 2097152
   1172 	O_RDONLY                              = 00
   1173 	O_RDWR                                = 02
   1174 	O_RSYNC                               = 1052672
   1175 	O_SYNC                                = 04010000
   1176 	O_TMPFILE                             = 4210688
   1177 	O_TRUNC                               = 01000
   1178 	O_WRONLY                              = 01
   1179 	P4_COLLSEQ                            = -2
   1180 	P4_DYNAMIC                            = -6
   1181 	P4_EXPR                               = -9
   1182 	P4_FREE_IF_LE                         = -6
   1183 	P4_FUNCCTX                            = -15
   1184 	P4_FUNCDEF                            = -7
   1185 	P4_INT32                              = -3
   1186 	P4_INT64                              = -13
   1187 	P4_INTARRAY                           = -14
   1188 	P4_KEYINFO                            = -8
   1189 	P4_MEM                                = -10
   1190 	P4_NOTUSED                            = 0
   1191 	P4_REAL                               = -12
   1192 	P4_STATIC                             = -1
   1193 	P4_SUBPROGRAM                         = -4
   1194 	P4_TABLE                              = -5
   1195 	P4_TRANSIENT                          = 0
   1196 	P4_VTAB                               = -11
   1197 	P5_ConstraintCheck                    = 3
   1198 	P5_ConstraintFK                       = 4
   1199 	P5_ConstraintNotNull                  = 1
   1200 	P5_ConstraintUnique                   = 2
   1201 	PAGER_CACHESPILL                      = 0x20
   1202 	PAGER_CKPT_FULLFSYNC                  = 0x10
   1203 	PAGER_ERROR                           = 6
   1204 	PAGER_FLAGS_MASK                      = 0x38
   1205 	PAGER_FULLFSYNC                       = 0x08
   1206 	PAGER_GET_NOCONTENT                   = 0x01
   1207 	PAGER_GET_READONLY                    = 0x02
   1208 	PAGER_JOURNALMODE_DELETE              = 0
   1209 	PAGER_JOURNALMODE_MEMORY              = 4
   1210 	PAGER_JOURNALMODE_OFF                 = 2
   1211 	PAGER_JOURNALMODE_PERSIST             = 1
   1212 	PAGER_JOURNALMODE_QUERY               = -1
   1213 	PAGER_JOURNALMODE_TRUNCATE            = 3
   1214 	PAGER_JOURNALMODE_WAL                 = 5
   1215 	PAGER_LOCKINGMODE_EXCLUSIVE           = 1
   1216 	PAGER_LOCKINGMODE_NORMAL              = 0
   1217 	PAGER_LOCKINGMODE_QUERY               = -1
   1218 	PAGER_MEMORY                          = 0x0002
   1219 	PAGER_OMIT_JOURNAL                    = 0x0001
   1220 	PAGER_OPEN                            = 0
   1221 	PAGER_READER                          = 1
   1222 	PAGER_STAT_HIT                        = 0
   1223 	PAGER_STAT_MISS                       = 1
   1224 	PAGER_STAT_SPILL                      = 3
   1225 	PAGER_STAT_WRITE                      = 2
   1226 	PAGER_SYNCHRONOUS_EXTRA               = 0x04
   1227 	PAGER_SYNCHRONOUS_FULL                = 0x03
   1228 	PAGER_SYNCHRONOUS_MASK                = 0x07
   1229 	PAGER_SYNCHRONOUS_NORMAL              = 0x02
   1230 	PAGER_SYNCHRONOUS_OFF                 = 0x01
   1231 	PAGER_WRITER_CACHEMOD                 = 3
   1232 	PAGER_WRITER_DBMOD                    = 4
   1233 	PAGER_WRITER_FINISHED                 = 5
   1234 	PAGER_WRITER_LOCKED                   = 2
   1235 	PARSE_MODE_DECLARE_VTAB               = 1
   1236 	PARSE_MODE_NORMAL                     = 0
   1237 	PARSE_MODE_RENAME                     = 2
   1238 	PARSE_MODE_UNMAP                      = 3
   1239 	PARTLY_WITHIN                         = 1
   1240 	PCACHE1_MIGHT_USE_GROUP_MUTEX         = 1
   1241 	PCACHE_DIRTYLIST_ADD                  = 2
   1242 	PCACHE_DIRTYLIST_FRONT                = 3
   1243 	PCACHE_DIRTYLIST_REMOVE               = 1
   1244 	PDP_ENDIAN                            = 3412
   1245 	PENDING_LOCK                          = 3
   1246 	PGHDR_CLEAN                           = 0x001
   1247 	PGHDR_DIRTY                           = 0x002
   1248 	PGHDR_DONT_WRITE                      = 0x010
   1249 	PGHDR_MMAP                            = 0x020
   1250 	PGHDR_NEED_SYNC                       = 0x008
   1251 	PGHDR_WAL_APPEND                      = 0x040
   1252 	PGHDR_WRITEABLE                       = 0x004
   1253 	PKEY_DISABLE_ACCESS                   = 0x1
   1254 	PKEY_DISABLE_WRITE                    = 0x2
   1255 	POSIX_FADV_DONTNEED                   = 4
   1256 	POSIX_FADV_NOREUSE                    = 5
   1257 	POSIX_FADV_NORMAL                     = 0
   1258 	POSIX_FADV_RANDOM                     = 1
   1259 	POSIX_FADV_SEQUENTIAL                 = 2
   1260 	POSIX_FADV_WILLNEED                   = 3
   1261 	POSIX_MADV_DONTNEED                   = 4
   1262 	POSIX_MADV_NORMAL                     = 0
   1263 	POSIX_MADV_RANDOM                     = 1
   1264 	POSIX_MADV_SEQUENTIAL                 = 2
   1265 	POSIX_MADV_WILLNEED                   = 3
   1266 	PREFERRED_SCHEMA_TABLE                = "sqlite_schema"
   1267 	PREFERRED_TEMP_SCHEMA_TABLE           = "sqlite_temp_schema"
   1268 	PROT_EXEC                             = 0x4
   1269 	PROT_GROWSDOWN                        = 0x01000000
   1270 	PROT_GROWSUP                          = 0x02000000
   1271 	PROT_NONE                             = 0x0
   1272 	PROT_READ                             = 0x1
   1273 	PROT_WRITE                            = 0x2
   1274 	PTF_INTKEY                            = 0x01
   1275 	PTF_LEAF                              = 0x08
   1276 	PTF_LEAFDATA                          = 0x04
   1277 	PTF_ZERODATA                          = 0x02
   1278 	PTRMAP_BTREE                          = 5
   1279 	PTRMAP_FREEPAGE                       = 2
   1280 	PTRMAP_OVERFLOW1                      = 3
   1281 	PTRMAP_OVERFLOW2                      = 4
   1282 	PTRMAP_ROOTPAGE                       = 1
   1283 	P_tmpdir                              = "/tmp"
   1284 	PragFlg_NeedSchema                    = 0x01
   1285 	PragFlg_NoColumns                     = 0x02
   1286 	PragFlg_NoColumns1                    = 0x04
   1287 	PragFlg_ReadOnly                      = 0x08
   1288 	PragFlg_Result0                       = 0x10
   1289 	PragFlg_Result1                       = 0x20
   1290 	PragFlg_SchemaOpt                     = 0x40
   1291 	PragFlg_SchemaReq                     = 0x80
   1292 	PragTyp_ACTIVATE_EXTENSIONS           = 0
   1293 	PragTyp_ANALYSIS_LIMIT                = 1
   1294 	PragTyp_AUTO_VACUUM                   = 3
   1295 	PragTyp_BUSY_TIMEOUT                  = 5
   1296 	PragTyp_CACHE_SIZE                    = 6
   1297 	PragTyp_CACHE_SPILL                   = 7
   1298 	PragTyp_CASE_SENSITIVE_LIKE           = 8
   1299 	PragTyp_COLLATION_LIST                = 9
   1300 	PragTyp_COMPILE_OPTIONS               = 10
   1301 	PragTyp_DATABASE_LIST                 = 12
   1302 	PragTyp_DATA_STORE_DIRECTORY          = 11
   1303 	PragTyp_DEFAULT_CACHE_SIZE            = 13
   1304 	PragTyp_ENCODING                      = 14
   1305 	PragTyp_FLAG                          = 4
   1306 	PragTyp_FOREIGN_KEY_CHECK             = 15
   1307 	PragTyp_FOREIGN_KEY_LIST              = 16
   1308 	PragTyp_FUNCTION_LIST                 = 17
   1309 	PragTyp_HARD_HEAP_LIMIT               = 18
   1310 	PragTyp_HEADER_VALUE                  = 2
   1311 	PragTyp_INCREMENTAL_VACUUM            = 19
   1312 	PragTyp_INDEX_INFO                    = 20
   1313 	PragTyp_INDEX_LIST                    = 21
   1314 	PragTyp_INTEGRITY_CHECK               = 22
   1315 	PragTyp_JOURNAL_MODE                  = 23
   1316 	PragTyp_JOURNAL_SIZE_LIMIT            = 24
   1317 	PragTyp_LOCKING_MODE                  = 26
   1318 	PragTyp_LOCK_PROXY_FILE               = 25
   1319 	PragTyp_LOCK_STATUS                   = 44
   1320 	PragTyp_MMAP_SIZE                     = 28
   1321 	PragTyp_MODULE_LIST                   = 29
   1322 	PragTyp_OPTIMIZE                      = 30
   1323 	PragTyp_PAGE_COUNT                    = 27
   1324 	PragTyp_PAGE_SIZE                     = 31
   1325 	PragTyp_PRAGMA_LIST                   = 32
   1326 	PragTyp_SECURE_DELETE                 = 33
   1327 	PragTyp_SHRINK_MEMORY                 = 34
   1328 	PragTyp_SOFT_HEAP_LIMIT               = 35
   1329 	PragTyp_STATS                         = 45
   1330 	PragTyp_SYNCHRONOUS                   = 36
   1331 	PragTyp_TABLE_INFO                    = 37
   1332 	PragTyp_TABLE_LIST                    = 38
   1333 	PragTyp_TEMP_STORE                    = 39
   1334 	PragTyp_TEMP_STORE_DIRECTORY          = 40
   1335 	PragTyp_THREADS                       = 41
   1336 	PragTyp_WAL_AUTOCHECKPOINT            = 42
   1337 	PragTyp_WAL_CHECKPOINT                = 43
   1338 	RAND_MAX                              = 2147483647
   1339 	RBU_CREATE_STATE                      = "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"
   1340 	RBU_DELETE                            = 2
   1341 	RBU_ENABLE_DELTA_CKSUM                = 0
   1342 	RBU_EXCLUSIVE_CHECKPOINT              = "rbu_exclusive_checkpoint"
   1343 	RBU_IDX_DELETE                        = 4
   1344 	RBU_IDX_INSERT                        = 5
   1345 	RBU_INSERT                            = 1
   1346 	RBU_PK_EXTERNAL                       = 3
   1347 	RBU_PK_IPK                            = 2
   1348 	RBU_PK_NONE                           = 1
   1349 	RBU_PK_NOTABLE                        = 0
   1350 	RBU_PK_VTAB                           = 5
   1351 	RBU_PK_WITHOUT_ROWID                  = 4
   1352 	RBU_REPLACE                           = 3
   1353 	RBU_STAGE_CAPTURE                     = 3
   1354 	RBU_STAGE_CKPT                        = 4
   1355 	RBU_STAGE_DONE                        = 5
   1356 	RBU_STAGE_MOVE                        = 2
   1357 	RBU_STAGE_OAL                         = 1
   1358 	RBU_STATE_CKPT                        = 6
   1359 	RBU_STATE_COOKIE                      = 7
   1360 	RBU_STATE_DATATBL                     = 10
   1361 	RBU_STATE_IDX                         = 3
   1362 	RBU_STATE_OALSZ                       = 8
   1363 	RBU_STATE_PHASEONESTEP                = 9
   1364 	RBU_STATE_PROGRESS                    = 5
   1365 	RBU_STATE_ROW                         = 4
   1366 	RBU_STATE_STAGE                       = 1
   1367 	RBU_STATE_TBL                         = 2
   1368 	RBU_UPDATE                            = 6
   1369 	READMARK_NOT_USED                     = 0xffffffff
   1370 	READ_LOCK                             = 1
   1371 	RENAME_EXCHANGE                       = 2
   1372 	RENAME_NOREPLACE                      = 1
   1373 	RENAME_WHITEOUT                       = 4
   1374 	RESERVED_LOCK                         = 2
   1375 	RETURNING_TRIGGER_NAME                = "sqlite_returning"
   1376 	RNDAWAY                               = 0
   1377 	RNDTOWARDS                            = 0
   1378 	ROWSET_ALLOCATION_SIZE                = 1024
   1379 	ROWSET_NEXT                           = 0x02
   1380 	ROWSET_SORTED                         = 0x01
   1381 	RTLD_BINDING_MASK                     = 0x3
   1382 	RTLD_DEEPBIND                         = 0x00008
   1383 	RTLD_GLOBAL                           = 0x00100
   1384 	RTLD_LAZY                             = 0x00001
   1385 	RTLD_LOCAL                            = 0
   1386 	RTLD_NODELETE                         = 0x01000
   1387 	RTLD_NOLOAD                           = 0x00004
   1388 	RTLD_NOW                              = 0x00002
   1389 	RTREE_CACHE_SZ                        = 5
   1390 	RTREE_CHECK_MAX_ERROR                 = 100
   1391 	RTREE_COORD_INT32                     = 1
   1392 	RTREE_COORD_REAL32                    = 0
   1393 	RTREE_DEFAULT_ROWEST                  = 1048576
   1394 	RTREE_EQ                              = 0x41
   1395 	RTREE_FALSE                           = 0x40
   1396 	RTREE_GE                              = 0x44
   1397 	RTREE_GT                              = 0x45
   1398 	RTREE_LE                              = 0x42
   1399 	RTREE_LT                              = 0x43
   1400 	RTREE_MATCH                           = 0x46
   1401 	RTREE_MAXCELLS                        = 51
   1402 	RTREE_MAX_AUX_COLUMN                  = 100
   1403 	RTREE_MAX_DEPTH                       = 40
   1404 	RTREE_MAX_DIMENSIONS                  = 5
   1405 	RTREE_MIN_ROWEST                      = 100
   1406 	RTREE_QUERY                           = 0x47
   1407 	RTREE_TRUE                            = 0x3f
   1408 	RTREE_ZERO                            = 0.0
   1409 	RWF_WRITE_LIFE_NOT_SET                = 0
   1410 	RWH_WRITE_LIFE_EXTREME                = 5
   1411 	RWH_WRITE_LIFE_LONG                   = 4
   1412 	RWH_WRITE_LIFE_MEDIUM                 = 3
   1413 	RWH_WRITE_LIFE_NONE                   = 1
   1414 	RWH_WRITE_LIFE_SHORT                  = 2
   1415 	R_OK                                  = 4
   1416 	SAVEPOINT_BEGIN                       = 0
   1417 	SAVEPOINT_RELEASE                     = 1
   1418 	SAVEPOINT_ROLLBACK                    = 2
   1419 	SCHEMA_ROOT                           = 1
   1420 	SEEK_CUR                              = 1
   1421 	SEEK_DATA                             = 3
   1422 	SEEK_END                              = 2
   1423 	SEEK_HOLE                             = 4
   1424 	SEEK_SET                              = 0
   1425 	SESSIONS_STRM_CHUNK_SIZE              = 1024
   1426 	SESSION_MAX_BUFFER_SZ                 = 2147483391
   1427 	SESSION_UPDATE_CACHE_SZ               = 12
   1428 	SF_Aggregate                          = 0x0000008
   1429 	SF_All                                = 0x0000002
   1430 	SF_ComplexResult                      = 0x0040000
   1431 	SF_Compound                           = 0x0000100
   1432 	SF_Converted                          = 0x0010000
   1433 	SF_CopyCte                            = 0x4000000
   1434 	SF_Distinct                           = 0x0000001
   1435 	SF_Expanded                           = 0x0000040
   1436 	SF_FixedLimit                         = 0x0004000
   1437 	SF_HasAgg                             = 0x0000010
   1438 	SF_HasTypeInfo                        = 0x0000080
   1439 	SF_IncludeHidden                      = 0x0020000
   1440 	SF_MaybeConvert                       = 0x0008000
   1441 	SF_MinMaxAgg                          = 0x0001000
   1442 	SF_MultiPart                          = 0x2000000
   1443 	SF_MultiValue                         = 0x0000400
   1444 	SF_NestedFrom                         = 0x0000800
   1445 	SF_NoopOrderBy                        = 0x0400000
   1446 	SF_OrderByReqd                        = 0x8000000
   1447 	SF_PushDown                           = 0x1000000
   1448 	SF_Recursive                          = 0x0002000
   1449 	SF_Resolved                           = 0x0000004
   1450 	SF_UFSrcCheck                         = 0x0800000
   1451 	SF_UpdateFrom                         = 0x10000000
   1452 	SF_UsesEphemeral                      = 0x0000020
   1453 	SF_Values                             = 0x0000200
   1454 	SF_View                               = 0x0200000
   1455 	SF_WhereBegin                         = 0x0080000
   1456 	SF_WinRewrite                         = 0x0100000
   1457 	SHARED_LOCK                           = 1
   1458 	SHARED_SIZE                           = 510
   1459 	SIOCADDDLCI                           = 0x8980
   1460 	SIOCADDMULTI                          = 0x8931
   1461 	SIOCADDRT                             = 0x890B
   1462 	SIOCDARP                              = 0x8953
   1463 	SIOCDELDLCI                           = 0x8981
   1464 	SIOCDELMULTI                          = 0x8932
   1465 	SIOCDELRT                             = 0x890C
   1466 	SIOCDEVPRIVATE                        = 0x89F0
   1467 	SIOCDIFADDR                           = 0x8936
   1468 	SIOCDRARP                             = 0x8960
   1469 	SIOCGARP                              = 0x8954
   1470 	SIOCGIFADDR                           = 0x8915
   1471 	SIOCGIFBR                             = 0x8940
   1472 	SIOCGIFBRDADDR                        = 0x8919
   1473 	SIOCGIFCONF                           = 0x8912
   1474 	SIOCGIFCOUNT                          = 0x8938
   1475 	SIOCGIFDSTADDR                        = 0x8917
   1476 	SIOCGIFENCAP                          = 0x8925
   1477 	SIOCGIFFLAGS                          = 0x8913
   1478 	SIOCGIFHWADDR                         = 0x8927
   1479 	SIOCGIFINDEX                          = 0x8933
   1480 	SIOCGIFMAP                            = 0x8970
   1481 	SIOCGIFMEM                            = 0x891f
   1482 	SIOCGIFMETRIC                         = 0x891d
   1483 	SIOCGIFMTU                            = 0x8921
   1484 	SIOCGIFNAME                           = 0x8910
   1485 	SIOCGIFNETMASK                        = 0x891b
   1486 	SIOCGIFPFLAGS                         = 0x8935
   1487 	SIOCGIFSLAVE                          = 0x8929
   1488 	SIOCGIFTXQLEN                         = 0x8942
   1489 	SIOCGRARP                             = 0x8961
   1490 	SIOCPROTOPRIVATE                      = 0x89E0
   1491 	SIOCRTMSG                             = 0x890D
   1492 	SIOCSARP                              = 0x8955
   1493 	SIOCSIFADDR                           = 0x8916
   1494 	SIOCSIFBR                             = 0x8941
   1495 	SIOCSIFBRDADDR                        = 0x891a
   1496 	SIOCSIFDSTADDR                        = 0x8918
   1497 	SIOCSIFENCAP                          = 0x8926
   1498 	SIOCSIFFLAGS                          = 0x8914
   1499 	SIOCSIFHWADDR                         = 0x8924
   1500 	SIOCSIFHWBROADCAST                    = 0x8937
   1501 	SIOCSIFLINK                           = 0x8911
   1502 	SIOCSIFMAP                            = 0x8971
   1503 	SIOCSIFMEM                            = 0x8920
   1504 	SIOCSIFMETRIC                         = 0x891e
   1505 	SIOCSIFMTU                            = 0x8922
   1506 	SIOCSIFNAME                           = 0x8923
   1507 	SIOCSIFNETMASK                        = 0x891c
   1508 	SIOCSIFPFLAGS                         = 0x8934
   1509 	SIOCSIFSLAVE                          = 0x8930
   1510 	SIOCSIFTXQLEN                         = 0x8943
   1511 	SIOCSRARP                             = 0x8962
   1512 	SIOGIFINDEX                           = 35123
   1513 	SLOT_2_0                              = 0x001fc07f
   1514 	SLOT_4_2_0                            = 0xf01fc07f
   1515 	SORTER_MAX_MERGE_COUNT                = 16
   1516 	SORTER_TYPE_INTEGER                   = 0x01
   1517 	SORTER_TYPE_TEXT                      = 0x02
   1518 	SORTFLAG_UseSorter                    = 0x01
   1519 	SPILLFLAG_NOSYNC                      = 0x04
   1520 	SPILLFLAG_OFF                         = 0x01
   1521 	SPILLFLAG_ROLLBACK                    = 0x02
   1522 	SPLICE_F_GIFT                         = 8
   1523 	SPLICE_F_MORE                         = 4
   1524 	SPLICE_F_MOVE                         = 1
   1525 	SPLICE_F_NONBLOCK                     = 2
   1526 	SQLITE3EXT_H                          = 0
   1527 	SQLITE3_H                             = 0
   1528 	SQLITE3_TEXT                          = 3
   1529 	SQLITEINT_H                           = 0
   1530 	SQLITE_ABORT                          = 4
   1531 	SQLITE_ABORT_ROLLBACK                 = 516
   1532 	SQLITE_ACCESS_EXISTS                  = 0
   1533 	SQLITE_ACCESS_READ                    = 2
   1534 	SQLITE_ACCESS_READWRITE               = 1
   1535 	SQLITE_AFF_BLOB                       = 0x41
   1536 	SQLITE_AFF_FLEXNUM                    = 0x46
   1537 	SQLITE_AFF_INTEGER                    = 0x44
   1538 	SQLITE_AFF_MASK                       = 0x47
   1539 	SQLITE_AFF_NONE                       = 0x40
   1540 	SQLITE_AFF_NUMERIC                    = 0x43
   1541 	SQLITE_AFF_REAL                       = 0x45
   1542 	SQLITE_AFF_TEXT                       = 0x42
   1543 	SQLITE_ALLOW_COVERING_INDEX_SCAN      = 1
   1544 	SQLITE_ALTER_TABLE                    = 26
   1545 	SQLITE_AMALGAMATION                   = 1
   1546 	SQLITE_ANALYZE                        = 28
   1547 	SQLITE_ANY                            = 5
   1548 	SQLITE_API                            = 0
   1549 	SQLITE_APICALL                        = 0
   1550 	SQLITE_ASCII                          = 1
   1551 	SQLITE_ATOMIC_INTRINSICS              = 1
   1552 	SQLITE_ATTACH                         = 24
   1553 	SQLITE_AUTH                           = 23
   1554 	SQLITE_AUTH_USER                      = 279
   1555 	SQLITE_AllOpts                        = 0xffffffff
   1556 	SQLITE_AutoIndex                      = 0x00008000
   1557 	SQLITE_BIGENDIAN                      = 0
   1558 	SQLITE_BIG_DBL                        = 0
   1559 	SQLITE_BLDF1_INDEXED                  = 0x0001
   1560 	SQLITE_BLDF1_UNIQUE                   = 0x0002
   1561 	SQLITE_BLDF2_2NDPASS                  = 0x0004
   1562 	SQLITE_BLOB                           = 4
   1563 	SQLITE_BTREE_H                        = 0
   1564 	SQLITE_BUSY                           = 5
   1565 	SQLITE_BUSY_RECOVERY                  = 261
   1566 	SQLITE_BUSY_SNAPSHOT                  = 517
   1567 	SQLITE_BUSY_TIMEOUT                   = 773
   1568 	SQLITE_BYTEORDER                      = 1234
   1569 	SQLITE_BalancedMerge                  = 0x00200000
   1570 	SQLITE_BloomFilter                    = 0x00080000
   1571 	SQLITE_BloomPulldown                  = 0x00100000
   1572 	SQLITE_CALLBACK                       = 0
   1573 	SQLITE_CANTOPEN                       = 14
   1574 	SQLITE_CANTOPEN_CONVPATH              = 1038
   1575 	SQLITE_CANTOPEN_DIRTYWAL              = 1294
   1576 	SQLITE_CANTOPEN_FULLPATH              = 782
   1577 	SQLITE_CANTOPEN_ISDIR                 = 526
   1578 	SQLITE_CANTOPEN_NOTEMPDIR             = 270
   1579 	SQLITE_CANTOPEN_SYMLINK               = 1550
   1580 	SQLITE_CDECL                          = 0
   1581 	SQLITE_CHANGESETAPPLY_INVERT          = 0x0002
   1582 	SQLITE_CHANGESETAPPLY_NOSAVEPOINT     = 0x0001
   1583 	SQLITE_CHANGESETSTART_INVERT          = 0x0002
   1584 	SQLITE_CHANGESET_ABORT                = 2
   1585 	SQLITE_CHANGESET_CONFLICT             = 3
   1586 	SQLITE_CHANGESET_CONSTRAINT           = 4
   1587 	SQLITE_CHANGESET_DATA                 = 1
   1588 	SQLITE_CHANGESET_FOREIGN_KEY          = 5
   1589 	SQLITE_CHANGESET_NOTFOUND             = 2
   1590 	SQLITE_CHANGESET_OMIT                 = 0
   1591 	SQLITE_CHANGESET_REPLACE              = 1
   1592 	SQLITE_CHECKPOINT_FULL                = 1
   1593 	SQLITE_CHECKPOINT_PASSIVE             = 0
   1594 	SQLITE_CHECKPOINT_RESTART             = 2
   1595 	SQLITE_CHECKPOINT_TRUNCATE            = 3
   1596 	SQLITE_CONFIG_COVERING_INDEX_SCAN     = 20
   1597 	SQLITE_CONFIG_GETMALLOC               = 5
   1598 	SQLITE_CONFIG_GETMUTEX                = 11
   1599 	SQLITE_CONFIG_GETPCACHE               = 15
   1600 	SQLITE_CONFIG_GETPCACHE2              = 19
   1601 	SQLITE_CONFIG_HEAP                    = 8
   1602 	SQLITE_CONFIG_LOG                     = 16
   1603 	SQLITE_CONFIG_LOOKASIDE               = 13
   1604 	SQLITE_CONFIG_MALLOC                  = 4
   1605 	SQLITE_CONFIG_MEMDB_MAXSIZE           = 29
   1606 	SQLITE_CONFIG_MEMSTATUS               = 9
   1607 	SQLITE_CONFIG_MMAP_SIZE               = 22
   1608 	SQLITE_CONFIG_MULTITHREAD             = 2
   1609 	SQLITE_CONFIG_MUTEX                   = 10
   1610 	SQLITE_CONFIG_PAGECACHE               = 7
   1611 	SQLITE_CONFIG_PCACHE                  = 14
   1612 	SQLITE_CONFIG_PCACHE2                 = 18
   1613 	SQLITE_CONFIG_PCACHE_HDRSZ            = 24
   1614 	SQLITE_CONFIG_PMASZ                   = 25
   1615 	SQLITE_CONFIG_SCRATCH                 = 6
   1616 	SQLITE_CONFIG_SERIALIZED              = 3
   1617 	SQLITE_CONFIG_SINGLETHREAD            = 1
   1618 	SQLITE_CONFIG_SMALL_MALLOC            = 27
   1619 	SQLITE_CONFIG_SORTERREF_SIZE          = 28
   1620 	SQLITE_CONFIG_SQLLOG                  = 21
   1621 	SQLITE_CONFIG_STMTJRNL_SPILL          = 26
   1622 	SQLITE_CONFIG_URI                     = 17
   1623 	SQLITE_CONFIG_WIN32_HEAPSIZE          = 23
   1624 	SQLITE_CONSTRAINT                     = 19
   1625 	SQLITE_CONSTRAINT_CHECK               = 275
   1626 	SQLITE_CONSTRAINT_COMMITHOOK          = 531
   1627 	SQLITE_CONSTRAINT_DATATYPE            = 3091
   1628 	SQLITE_CONSTRAINT_FOREIGNKEY          = 787
   1629 	SQLITE_CONSTRAINT_FUNCTION            = 1043
   1630 	SQLITE_CONSTRAINT_NOTNULL             = 1299
   1631 	SQLITE_CONSTRAINT_PINNED              = 2835
   1632 	SQLITE_CONSTRAINT_PRIMARYKEY          = 1555
   1633 	SQLITE_CONSTRAINT_ROWID               = 2579
   1634 	SQLITE_CONSTRAINT_TRIGGER             = 1811
   1635 	SQLITE_CONSTRAINT_UNIQUE              = 2067
   1636 	SQLITE_CONSTRAINT_VTAB                = 2323
   1637 	SQLITE_COPY                           = 0
   1638 	SQLITE_CORE                           = 1
   1639 	SQLITE_CORRUPT                        = 11
   1640 	SQLITE_CORRUPT_INDEX                  = 779
   1641 	SQLITE_CORRUPT_SEQUENCE               = 523
   1642 	SQLITE_CORRUPT_VTAB                   = 267
   1643 	SQLITE_CREATE_INDEX                   = 1
   1644 	SQLITE_CREATE_TABLE                   = 2
   1645 	SQLITE_CREATE_TEMP_INDEX              = 3
   1646 	SQLITE_CREATE_TEMP_TABLE              = 4
   1647 	SQLITE_CREATE_TEMP_TRIGGER            = 5
   1648 	SQLITE_CREATE_TEMP_VIEW               = 6
   1649 	SQLITE_CREATE_TRIGGER                 = 7
   1650 	SQLITE_CREATE_VIEW                    = 8
   1651 	SQLITE_CREATE_VTABLE                  = 29
   1652 	SQLITE_CacheSpill                     = 0x00000020
   1653 	SQLITE_CellSizeCk                     = 0x00200000
   1654 	SQLITE_CkptFullFSync                  = 0x00000010
   1655 	SQLITE_Coroutines                     = 0x02000000
   1656 	SQLITE_CountOfView                    = 0x00000200
   1657 	SQLITE_CoverIdxScan                   = 0x00000020
   1658 	SQLITE_CursorHints                    = 0x00000400
   1659 	SQLITE_DBCONFIG_DEFENSIVE             = 1010
   1660 	SQLITE_DBCONFIG_DQS_DDL               = 1014
   1661 	SQLITE_DBCONFIG_DQS_DML               = 1013
   1662 	SQLITE_DBCONFIG_ENABLE_FKEY           = 1002
   1663 	SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004
   1664 	SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005
   1665 	SQLITE_DBCONFIG_ENABLE_QPSG           = 1007
   1666 	SQLITE_DBCONFIG_ENABLE_TRIGGER        = 1003
   1667 	SQLITE_DBCONFIG_ENABLE_VIEW           = 1015
   1668 	SQLITE_DBCONFIG_LEGACY_ALTER_TABLE    = 1012
   1669 	SQLITE_DBCONFIG_LEGACY_FILE_FORMAT    = 1016
   1670 	SQLITE_DBCONFIG_LOOKASIDE             = 1001
   1671 	SQLITE_DBCONFIG_MAINDBNAME            = 1000
   1672 	SQLITE_DBCONFIG_MAX                   = 1017
   1673 	SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      = 1006
   1674 	SQLITE_DBCONFIG_RESET_DATABASE        = 1009
   1675 	SQLITE_DBCONFIG_TRIGGER_EQP           = 1008
   1676 	SQLITE_DBCONFIG_TRUSTED_SCHEMA        = 1017
   1677 	SQLITE_DBCONFIG_WRITABLE_SCHEMA       = 1011
   1678 	SQLITE_DBSTATUS_CACHE_HIT             = 7
   1679 	SQLITE_DBSTATUS_CACHE_MISS            = 8
   1680 	SQLITE_DBSTATUS_CACHE_SPILL           = 12
   1681 	SQLITE_DBSTATUS_CACHE_USED            = 1
   1682 	SQLITE_DBSTATUS_CACHE_USED_SHARED     = 11
   1683 	SQLITE_DBSTATUS_CACHE_WRITE           = 9
   1684 	SQLITE_DBSTATUS_DEFERRED_FKS          = 10
   1685 	SQLITE_DBSTATUS_LOOKASIDE_HIT         = 4
   1686 	SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL   = 6
   1687 	SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE   = 5
   1688 	SQLITE_DBSTATUS_LOOKASIDE_USED        = 0
   1689 	SQLITE_DBSTATUS_MAX                   = 12
   1690 	SQLITE_DBSTATUS_SCHEMA_USED           = 2
   1691 	SQLITE_DBSTATUS_STMT_USED             = 3
   1692 	SQLITE_DEFAULT_AUTOVACUUM             = 0
   1693 	SQLITE_DEFAULT_CACHE_SIZE             = -2000
   1694 	SQLITE_DEFAULT_FILE_FORMAT            = 4
   1695 	SQLITE_DEFAULT_FILE_PERMISSIONS       = 0644
   1696 	SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT     = -1
   1697 	SQLITE_DEFAULT_LOOKASIDE              = 40
   1698 	SQLITE_DEFAULT_MEMSTATUS              = 0
   1699 	SQLITE_DEFAULT_MMAP_SIZE              = 0
   1700 	SQLITE_DEFAULT_PAGE_SIZE              = 4096
   1701 	SQLITE_DEFAULT_PCACHE_INITSZ          = 20
   1702 	SQLITE_DEFAULT_PROXYDIR_PERMISSIONS   = 0755
   1703 	SQLITE_DEFAULT_RECURSIVE_TRIGGERS     = 0
   1704 	SQLITE_DEFAULT_SECTOR_SIZE            = 4096
   1705 	SQLITE_DEFAULT_SORTERREF_SIZE         = 0x7fffffff
   1706 	SQLITE_DEFAULT_SYNCHRONOUS            = 2
   1707 	SQLITE_DEFAULT_WAL_AUTOCHECKPOINT     = 1000
   1708 	SQLITE_DEFAULT_WAL_SYNCHRONOUS        = 2
   1709 	SQLITE_DEFAULT_WORKER_THREADS         = 0
   1710 	SQLITE_DELETE                         = 9
   1711 	SQLITE_DENY                           = 1
   1712 	SQLITE_DEPRECATED                     = 0
   1713 	SQLITE_DESERIALIZE_FREEONCLOSE        = 1
   1714 	SQLITE_DESERIALIZE_READONLY           = 4
   1715 	SQLITE_DESERIALIZE_RESIZEABLE         = 2
   1716 	SQLITE_DETACH                         = 25
   1717 	SQLITE_DETERMINISTIC                  = 0x000000800
   1718 	SQLITE_DIRECTONLY                     = 0x000080000
   1719 	SQLITE_DONE                           = 101
   1720 	SQLITE_DQS                            = 3
   1721 	SQLITE_DROP_INDEX                     = 10
   1722 	SQLITE_DROP_TABLE                     = 11
   1723 	SQLITE_DROP_TEMP_INDEX                = 12
   1724 	SQLITE_DROP_TEMP_TABLE                = 13
   1725 	SQLITE_DROP_TEMP_TRIGGER              = 14
   1726 	SQLITE_DROP_TEMP_VIEW                 = 15
   1727 	SQLITE_DROP_TRIGGER                   = 16
   1728 	SQLITE_DROP_VIEW                      = 17
   1729 	SQLITE_DROP_VTABLE                    = 30
   1730 	SQLITE_Defensive                      = 0x10000000
   1731 	SQLITE_DeferFKs                       = 0x00080000
   1732 	SQLITE_DistinctOpt                    = 0x00000010
   1733 	SQLITE_DqsDDL                         = 0x20000000
   1734 	SQLITE_DqsDML                         = 0x40000000
   1735 	SQLITE_ECEL_DUP                       = 0x01
   1736 	SQLITE_ECEL_FACTOR                    = 0x02
   1737 	SQLITE_ECEL_OMITREF                   = 0x08
   1738 	SQLITE_ECEL_REF                       = 0x04
   1739 	SQLITE_EMPTY                          = 16
   1740 	SQLITE_ENABLE_COLUMN_METADATA         = 1
   1741 	SQLITE_ENABLE_FTS5                    = 1
   1742 	SQLITE_ENABLE_GEOPOLY                 = 1
   1743 	SQLITE_ENABLE_LOCKING_STYLE           = 0
   1744 	SQLITE_ENABLE_MATH_FUNCTIONS          = 1
   1745 	SQLITE_ENABLE_MEMORY_MANAGEMENT       = 1
   1746 	SQLITE_ENABLE_OFFSET_SQL_FUNC         = 1
   1747 	SQLITE_ENABLE_PREUPDATE_HOOK          = 1
   1748 	SQLITE_ENABLE_RBU                     = 1
   1749 	SQLITE_ENABLE_RTREE                   = 1
   1750 	SQLITE_ENABLE_SESSION                 = 1
   1751 	SQLITE_ENABLE_SNAPSHOT                = 1
   1752 	SQLITE_ENABLE_STAT4                   = 1
   1753 	SQLITE_ENABLE_UNLOCK_NOTIFY           = 1
   1754 	SQLITE_ERROR                          = 1
   1755 	SQLITE_ERROR_MISSING_COLLSEQ          = 257
   1756 	SQLITE_ERROR_RETRY                    = 513
   1757 	SQLITE_ERROR_SNAPSHOT                 = 769
   1758 	SQLITE_EXPERIMENTAL                   = 0
   1759 	SQLITE_EXTENSION_INIT1                = 0
   1760 	SQLITE_EXTENSION_INIT3                = 0
   1761 	SQLITE_EnableQPSG                     = 0x00800000
   1762 	SQLITE_EnableTrigger                  = 0x00040000
   1763 	SQLITE_EnableView                     = 0x80000000
   1764 	SQLITE_FAIL                           = 3
   1765 	SQLITE_FAULTINJECTOR_COUNT            = 1
   1766 	SQLITE_FAULTINJECTOR_MALLOC           = 0
   1767 	SQLITE_FCNTL_BEGIN_ATOMIC_WRITE       = 31
   1768 	SQLITE_FCNTL_BUSYHANDLER              = 15
   1769 	SQLITE_FCNTL_CHUNK_SIZE               = 6
   1770 	SQLITE_FCNTL_CKPT_DONE                = 37
   1771 	SQLITE_FCNTL_CKPT_START               = 39
   1772 	SQLITE_FCNTL_CKSM_FILE                = 41
   1773 	SQLITE_FCNTL_COMMIT_ATOMIC_WRITE      = 32
   1774 	SQLITE_FCNTL_COMMIT_PHASETWO          = 22
   1775 	SQLITE_FCNTL_DATA_VERSION             = 35
   1776 	SQLITE_FCNTL_DB_UNCHANGED             = 0xca093fa0
   1777 	SQLITE_FCNTL_EXTERNAL_READER          = 40
   1778 	SQLITE_FCNTL_FILE_POINTER             = 7
   1779 	SQLITE_FCNTL_GET_LOCKPROXYFILE        = 2
   1780 	SQLITE_FCNTL_HAS_MOVED                = 20
   1781 	SQLITE_FCNTL_JOURNAL_POINTER          = 28
   1782 	SQLITE_FCNTL_LAST_ERRNO               = 4
   1783 	SQLITE_FCNTL_LOCKSTATE                = 1
   1784 	SQLITE_FCNTL_LOCK_TIMEOUT             = 34
   1785 	SQLITE_FCNTL_MMAP_SIZE                = 18
   1786 	SQLITE_FCNTL_OVERWRITE                = 11
   1787 	SQLITE_FCNTL_PDB                      = 30
   1788 	SQLITE_FCNTL_PERSIST_WAL              = 10
   1789 	SQLITE_FCNTL_POWERSAFE_OVERWRITE      = 13
   1790 	SQLITE_FCNTL_PRAGMA                   = 14
   1791 	SQLITE_FCNTL_RBU                      = 26
   1792 	SQLITE_FCNTL_RBUCNT                   = 5149216
   1793 	SQLITE_FCNTL_RESERVE_BYTES            = 38
   1794 	SQLITE_FCNTL_RESET_CACHE              = 42
   1795 	SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE    = 33
   1796 	SQLITE_FCNTL_SET_LOCKPROXYFILE        = 3
   1797 	SQLITE_FCNTL_SIZE_HINT                = 5
   1798 	SQLITE_FCNTL_SIZE_LIMIT               = 36
   1799 	SQLITE_FCNTL_SYNC                     = 21
   1800 	SQLITE_FCNTL_SYNC_OMITTED             = 8
   1801 	SQLITE_FCNTL_TEMPFILENAME             = 16
   1802 	SQLITE_FCNTL_TRACE                    = 19
   1803 	SQLITE_FCNTL_VFSNAME                  = 12
   1804 	SQLITE_FCNTL_VFS_POINTER              = 27
   1805 	SQLITE_FCNTL_WAL_BLOCK                = 24
   1806 	SQLITE_FCNTL_WIN32_AV_RETRY           = 9
   1807 	SQLITE_FCNTL_WIN32_GET_HANDLE         = 29
   1808 	SQLITE_FCNTL_WIN32_SET_HANDLE         = 23
   1809 	SQLITE_FCNTL_ZIPVFS                   = 25
   1810 	SQLITE_FILE_HEADER                    = "SQLite format 3"
   1811 	SQLITE_FLOAT                          = 2
   1812 	SQLITE_FORMAT                         = 24
   1813 	SQLITE_FP_PRECISION_LIMIT             = 100000000
   1814 	SQLITE_FRAME_MAGIC                    = 0x879fb71e
   1815 	SQLITE_FSFLAGS_IS_MSDOS               = 0x1
   1816 	SQLITE_FULL                           = 13
   1817 	SQLITE_FUNCTION                       = 31
   1818 	SQLITE_FUNC_ANYORDER                  = 0x08000000
   1819 	SQLITE_FUNC_BUILTIN                   = 0x00800000
   1820 	SQLITE_FUNC_CASE                      = 0x0008
   1821 	SQLITE_FUNC_CONSTANT                  = 0x0800
   1822 	SQLITE_FUNC_COUNT                     = 0x0100
   1823 	SQLITE_FUNC_DIRECT                    = 0x00080000
   1824 	SQLITE_FUNC_ENCMASK                   = 0x0003
   1825 	SQLITE_FUNC_EPHEM                     = 0x0010
   1826 	SQLITE_FUNC_HASH_SZ                   = 23
   1827 	SQLITE_FUNC_INLINE                    = 0x00400000
   1828 	SQLITE_FUNC_INTERNAL                  = 0x00040000
   1829 	SQLITE_FUNC_LENGTH                    = 0x0040
   1830 	SQLITE_FUNC_LIKE                      = 0x0004
   1831 	SQLITE_FUNC_MINMAX                    = 0x1000
   1832 	SQLITE_FUNC_NEEDCOLL                  = 0x0020
   1833 	SQLITE_FUNC_SLOCHNG                   = 0x2000
   1834 	SQLITE_FUNC_SUBTYPE                   = 0x00100000
   1835 	SQLITE_FUNC_TEST                      = 0x4000
   1836 	SQLITE_FUNC_TYPEOF                    = 0x0080
   1837 	SQLITE_FUNC_UNLIKELY                  = 0x0400
   1838 	SQLITE_FUNC_UNSAFE                    = 0x00200000
   1839 	SQLITE_FUNC_WINDOW                    = 0x00010000
   1840 	SQLITE_FactorOutConst                 = 0x00000008
   1841 	SQLITE_FlttnUnionAll                  = 0x00800000
   1842 	SQLITE_ForeignKeys                    = 0x00004000
   1843 	SQLITE_Fts3Tokenizer                  = 0x00400000
   1844 	SQLITE_FullColNames                   = 0x00000004
   1845 	SQLITE_FullFSync                      = 0x00000008
   1846 	SQLITE_GET_LOCKPROXYFILE              = 2
   1847 	SQLITE_GroupByOrder                   = 0x00000004
   1848 	SQLITE_HASH_H                         = 0
   1849 	SQLITE_HAVE_C99_MATH_FUNCS            = 1
   1850 	SQLITE_IDXTYPE_APPDEF                 = 0
   1851 	SQLITE_IDXTYPE_IPK                    = 3
   1852 	SQLITE_IDXTYPE_PRIMARYKEY             = 2
   1853 	SQLITE_IDXTYPE_UNIQUE                 = 1
   1854 	SQLITE_IGNORE                         = 2
   1855 	SQLITE_INDEX_CONSTRAINT_EQ            = 2
   1856 	SQLITE_INDEX_CONSTRAINT_FUNCTION      = 150
   1857 	SQLITE_INDEX_CONSTRAINT_GE            = 32
   1858 	SQLITE_INDEX_CONSTRAINT_GLOB          = 66
   1859 	SQLITE_INDEX_CONSTRAINT_GT            = 4
   1860 	SQLITE_INDEX_CONSTRAINT_IS            = 72
   1861 	SQLITE_INDEX_CONSTRAINT_ISNOT         = 69
   1862 	SQLITE_INDEX_CONSTRAINT_ISNOTNULL     = 70
   1863 	SQLITE_INDEX_CONSTRAINT_ISNULL        = 71
   1864 	SQLITE_INDEX_CONSTRAINT_LE            = 8
   1865 	SQLITE_INDEX_CONSTRAINT_LIKE          = 65
   1866 	SQLITE_INDEX_CONSTRAINT_LIMIT         = 73
   1867 	SQLITE_INDEX_CONSTRAINT_LT            = 16
   1868 	SQLITE_INDEX_CONSTRAINT_MATCH         = 64
   1869 	SQLITE_INDEX_CONSTRAINT_NE            = 68
   1870 	SQLITE_INDEX_CONSTRAINT_OFFSET        = 74
   1871 	SQLITE_INDEX_CONSTRAINT_REGEXP        = 67
   1872 	SQLITE_INDEX_SCAN_UNIQUE              = 1
   1873 	SQLITE_INNOCUOUS                      = 0x000200000
   1874 	SQLITE_INSERT                         = 18
   1875 	SQLITE_INTEGER                        = 1
   1876 	SQLITE_INTEGRITY_CHECK_ERROR_MAX      = 100
   1877 	SQLITE_INTERNAL                       = 2
   1878 	SQLITE_INTERRUPT                      = 9
   1879 	SQLITE_IOCAP_ATOMIC                   = 0x00000001
   1880 	SQLITE_IOCAP_ATOMIC16K                = 0x00000040
   1881 	SQLITE_IOCAP_ATOMIC1K                 = 0x00000004
   1882 	SQLITE_IOCAP_ATOMIC2K                 = 0x00000008
   1883 	SQLITE_IOCAP_ATOMIC32K                = 0x00000080
   1884 	SQLITE_IOCAP_ATOMIC4K                 = 0x00000010
   1885 	SQLITE_IOCAP_ATOMIC512                = 0x00000002
   1886 	SQLITE_IOCAP_ATOMIC64K                = 0x00000100
   1887 	SQLITE_IOCAP_ATOMIC8K                 = 0x00000020
   1888 	SQLITE_IOCAP_BATCH_ATOMIC             = 0x00004000
   1889 	SQLITE_IOCAP_IMMUTABLE                = 0x00002000
   1890 	SQLITE_IOCAP_POWERSAFE_OVERWRITE      = 0x00001000
   1891 	SQLITE_IOCAP_SAFE_APPEND              = 0x00000200
   1892 	SQLITE_IOCAP_SEQUENTIAL               = 0x00000400
   1893 	SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN    = 0x00000800
   1894 	SQLITE_IOERR                          = 10
   1895 	SQLITE_IOERR_ACCESS                   = 3338
   1896 	SQLITE_IOERR_AUTH                     = 7178
   1897 	SQLITE_IOERR_BEGIN_ATOMIC             = 7434
   1898 	SQLITE_IOERR_BLOCKED                  = 2826
   1899 	SQLITE_IOERR_CHECKRESERVEDLOCK        = 3594
   1900 	SQLITE_IOERR_CLOSE                    = 4106
   1901 	SQLITE_IOERR_COMMIT_ATOMIC            = 7690
   1902 	SQLITE_IOERR_CONVPATH                 = 6666
   1903 	SQLITE_IOERR_CORRUPTFS                = 8458
   1904 	SQLITE_IOERR_DATA                     = 8202
   1905 	SQLITE_IOERR_DELETE                   = 2570
   1906 	SQLITE_IOERR_DELETE_NOENT             = 5898
   1907 	SQLITE_IOERR_DIR_CLOSE                = 4362
   1908 	SQLITE_IOERR_DIR_FSYNC                = 1290
   1909 	SQLITE_IOERR_FSTAT                    = 1802
   1910 	SQLITE_IOERR_FSYNC                    = 1034
   1911 	SQLITE_IOERR_GETTEMPPATH              = 6410
   1912 	SQLITE_IOERR_LOCK                     = 3850
   1913 	SQLITE_IOERR_MMAP                     = 6154
   1914 	SQLITE_IOERR_NOMEM                    = 3082
   1915 	SQLITE_IOERR_NOMEM_BKPT               = 3082
   1916 	SQLITE_IOERR_RDLOCK                   = 2314
   1917 	SQLITE_IOERR_READ                     = 266
   1918 	SQLITE_IOERR_ROLLBACK_ATOMIC          = 7946
   1919 	SQLITE_IOERR_SEEK                     = 5642
   1920 	SQLITE_IOERR_SHMLOCK                  = 5130
   1921 	SQLITE_IOERR_SHMMAP                   = 5386
   1922 	SQLITE_IOERR_SHMOPEN                  = 4618
   1923 	SQLITE_IOERR_SHMSIZE                  = 4874
   1924 	SQLITE_IOERR_SHORT_READ               = 522
   1925 	SQLITE_IOERR_TRUNCATE                 = 1546
   1926 	SQLITE_IOERR_UNLOCK                   = 2058
   1927 	SQLITE_IOERR_VNODE                    = 6922
   1928 	SQLITE_IOERR_WRITE                    = 778
   1929 	SQLITE_IgnoreChecks                   = 0x00000200
   1930 	SQLITE_IndexedExpr                    = 0x01000000
   1931 	SQLITE_JUMPIFNULL                     = 0x10
   1932 	SQLITE_LAST_ERRNO                     = 4
   1933 	SQLITE_LIKE_DOESNT_MATCH_BLOBS        = 1
   1934 	SQLITE_LIMIT_ATTACHED                 = 7
   1935 	SQLITE_LIMIT_COLUMN                   = 2
   1936 	SQLITE_LIMIT_COMPOUND_SELECT          = 4
   1937 	SQLITE_LIMIT_EXPR_DEPTH               = 3
   1938 	SQLITE_LIMIT_FUNCTION_ARG             = 6
   1939 	SQLITE_LIMIT_LENGTH                   = 0
   1940 	SQLITE_LIMIT_LIKE_PATTERN_LENGTH      = 8
   1941 	SQLITE_LIMIT_SQL_LENGTH               = 1
   1942 	SQLITE_LIMIT_TRIGGER_DEPTH            = 10
   1943 	SQLITE_LIMIT_VARIABLE_NUMBER          = 9
   1944 	SQLITE_LIMIT_VDBE_OP                  = 5
   1945 	SQLITE_LIMIT_WORKER_THREADS           = 11
   1946 	SQLITE_LITTLEENDIAN                   = 1
   1947 	SQLITE_LOCKED                         = 6
   1948 	SQLITE_LOCKED_SHAREDCACHE             = 262
   1949 	SQLITE_LOCKED_VTAB                    = 518
   1950 	SQLITE_LOCK_EXCLUSIVE                 = 4
   1951 	SQLITE_LOCK_NONE                      = 0
   1952 	SQLITE_LOCK_PENDING                   = 3
   1953 	SQLITE_LOCK_RESERVED                  = 2
   1954 	SQLITE_LOCK_SHARED                    = 1
   1955 	SQLITE_LegacyAlter                    = 0x04000000
   1956 	SQLITE_LegacyFileFmt                  = 0x00000002
   1957 	SQLITE_LoadExtFunc                    = 0x00020000
   1958 	SQLITE_LoadExtension                  = 0x00010000
   1959 	SQLITE_MALLOC_SOFT_LIMIT              = 1024
   1960 	SQLITE_MATCH                          = 0
   1961 	SQLITE_MAX_ALLOCATION_SIZE            = 2147483391
   1962 	SQLITE_MAX_ATTACHED                   = 10
   1963 	SQLITE_MAX_COLUMN                     = 2000
   1964 	SQLITE_MAX_COMPOUND_SELECT            = 500
   1965 	SQLITE_MAX_DB                         = 12
   1966 	SQLITE_MAX_DEFAULT_PAGE_SIZE          = 8192
   1967 	SQLITE_MAX_EXPR_DEPTH                 = 1000
   1968 	SQLITE_MAX_FILE_FORMAT                = 4
   1969 	SQLITE_MAX_FUNCTION_ARG               = 127
   1970 	SQLITE_MAX_LENGTH                     = 1000000000
   1971 	SQLITE_MAX_LIKE_PATTERN_LENGTH        = 50000
   1972 	SQLITE_MAX_MEMORY                     = 0
   1973 	SQLITE_MAX_MMAP_SIZE                  = 0x7fff0000
   1974 	SQLITE_MAX_PAGE_COUNT                 = 1073741823
   1975 	SQLITE_MAX_PAGE_SIZE                  = 65536
   1976 	SQLITE_MAX_PATHLEN                    = 4096
   1977 	SQLITE_MAX_PMASZ                      = 536870912
   1978 	SQLITE_MAX_PREPARE_RETRY              = 25
   1979 	SQLITE_MAX_SCHEMA_RETRY               = 50
   1980 	SQLITE_MAX_SQL_LENGTH                 = 1000000000
   1981 	SQLITE_MAX_SRCLIST                    = 200
   1982 	SQLITE_MAX_SYMLINK                    = 200
   1983 	SQLITE_MAX_SYMLINKS                   = 100
   1984 	SQLITE_MAX_TRIGGER_DEPTH              = 1000
   1985 	SQLITE_MAX_VARIABLE_NUMBER            = 32766
   1986 	SQLITE_MAX_VDBE_OP                    = 250000000
   1987 	SQLITE_MAX_WORKER_THREADS             = 8
   1988 	SQLITE_MEMDB_DEFAULT_MAXSIZE          = 1073741824
   1989 	SQLITE_MINIMUM_FILE_DESCRIPTOR        = 3
   1990 	SQLITE_MISMATCH                       = 20
   1991 	SQLITE_MISUSE                         = 21
   1992 	SQLITE_MSVC_H                         = 0
   1993 	SQLITE_MUTEX_APPDEF                   = 1
   1994 	SQLITE_MUTEX_FAST                     = 0
   1995 	SQLITE_MUTEX_NOOP                     = 1
   1996 	SQLITE_MUTEX_RECURSIVE                = 1
   1997 	SQLITE_MUTEX_STATIC_APP1              = 8
   1998 	SQLITE_MUTEX_STATIC_APP2              = 9
   1999 	SQLITE_MUTEX_STATIC_APP3              = 10
   2000 	SQLITE_MUTEX_STATIC_LRU               = 6
   2001 	SQLITE_MUTEX_STATIC_LRU2              = 7
   2002 	SQLITE_MUTEX_STATIC_MAIN              = 2
   2003 	SQLITE_MUTEX_STATIC_MASTER            = 2
   2004 	SQLITE_MUTEX_STATIC_MEM               = 3
   2005 	SQLITE_MUTEX_STATIC_MEM2              = 4
   2006 	SQLITE_MUTEX_STATIC_OPEN              = 4
   2007 	SQLITE_MUTEX_STATIC_PMEM              = 7
   2008 	SQLITE_MUTEX_STATIC_PRNG              = 5
   2009 	SQLITE_MUTEX_STATIC_TEMPDIR           = 11
   2010 	SQLITE_MUTEX_STATIC_VFS1              = 11
   2011 	SQLITE_MUTEX_STATIC_VFS2              = 12
   2012 	SQLITE_MUTEX_STATIC_VFS3              = 13
   2013 	SQLITE_MX_JUMP_OPCODE                 = 64
   2014 	SQLITE_MinMaxOpt                      = 0x00010000
   2015 	SQLITE_NOLFS                          = 22
   2016 	SQLITE_NOMATCH                        = 1
   2017 	SQLITE_NOMEM                          = 7
   2018 	SQLITE_NOMEM_BKPT                     = 7
   2019 	SQLITE_NOTADB                         = 26
   2020 	SQLITE_NOTFOUND                       = 12
   2021 	SQLITE_NOTICE                         = 27
   2022 	SQLITE_NOTICE_RBU                     = 795
   2023 	SQLITE_NOTICE_RECOVER_ROLLBACK        = 539
   2024 	SQLITE_NOTICE_RECOVER_WAL             = 283
   2025 	SQLITE_NOTNULL                        = 0x90
   2026 	SQLITE_NOWILDCARDMATCH                = 2
   2027 	SQLITE_NO_TSAN                        = 0
   2028 	SQLITE_NTUNE                          = 6
   2029 	SQLITE_NULL                           = 5
   2030 	SQLITE_NULLEQ                         = 0x80
   2031 	SQLITE_N_BTREE_META                   = 16
   2032 	SQLITE_N_KEYWORD                      = 147
   2033 	SQLITE_N_LIMIT                        = 12
   2034 	SQLITE_N_STDTYPE                      = 6
   2035 	SQLITE_NoCkptOnClose                  = 0x00000800
   2036 	SQLITE_NoSchemaError                  = 0x08000000
   2037 	SQLITE_NullCallback                   = 0x00000100
   2038 	SQLITE_OK                             = 0
   2039 	SQLITE_OK_LOAD_PERMANENTLY            = 256
   2040 	SQLITE_OK_SYMLINK                     = 512
   2041 	SQLITE_OPEN_AUTOPROXY                 = 0x00000020
   2042 	SQLITE_OPEN_CREATE                    = 0x00000004
   2043 	SQLITE_OPEN_DELETEONCLOSE             = 0x00000008
   2044 	SQLITE_OPEN_EXCLUSIVE                 = 0x00000010
   2045 	SQLITE_OPEN_EXRESCODE                 = 0x02000000
   2046 	SQLITE_OPEN_FULLMUTEX                 = 0x00010000
   2047 	SQLITE_OPEN_MAIN_DB                   = 0x00000100
   2048 	SQLITE_OPEN_MAIN_JOURNAL              = 0x00000800
   2049 	SQLITE_OPEN_MASTER_JOURNAL            = 0x00004000
   2050 	SQLITE_OPEN_MEMORY                    = 0x00000080
   2051 	SQLITE_OPEN_NOFOLLOW                  = 0x01000000
   2052 	SQLITE_OPEN_NOMUTEX                   = 0x00008000
   2053 	SQLITE_OPEN_PRIVATECACHE              = 0x00040000
   2054 	SQLITE_OPEN_READONLY                  = 0x00000001
   2055 	SQLITE_OPEN_READWRITE                 = 0x00000002
   2056 	SQLITE_OPEN_SHAREDCACHE               = 0x00020000
   2057 	SQLITE_OPEN_SUBJOURNAL                = 0x00002000
   2058 	SQLITE_OPEN_SUPER_JOURNAL             = 0x00004000
   2059 	SQLITE_OPEN_TEMP_DB                   = 0x00000200
   2060 	SQLITE_OPEN_TEMP_JOURNAL              = 0x00001000
   2061 	SQLITE_OPEN_TRANSIENT_DB              = 0x00000400
   2062 	SQLITE_OPEN_URI                       = 0x00000040
   2063 	SQLITE_OPEN_WAL                       = 0x00080000
   2064 	SQLITE_OS_KV                          = 0
   2065 	SQLITE_OS_OTHER                       = 0
   2066 	SQLITE_OS_SETUP_H                     = 0
   2067 	SQLITE_OS_UNIX                        = 1
   2068 	SQLITE_OS_WIN                         = 0
   2069 	SQLITE_OmitNoopJoin                   = 0x00000100
   2070 	SQLITE_OmitOrderBy                    = 0x00040000
   2071 	SQLITE_OrderByIdxJoin                 = 0x00000040
   2072 	SQLITE_PAGER_H                        = 0
   2073 	SQLITE_PERM                           = 3
   2074 	SQLITE_POWERSAFE_OVERWRITE            = 1
   2075 	SQLITE_PRAGMA                         = 19
   2076 	SQLITE_PREPARE_MASK                   = 0x0f
   2077 	SQLITE_PREPARE_NORMALIZE              = 0x02
   2078 	SQLITE_PREPARE_NO_VTAB                = 0x04
   2079 	SQLITE_PREPARE_PERSISTENT             = 0x01
   2080 	SQLITE_PREPARE_SAVESQL                = 0x80
   2081 	SQLITE_PRINTF_INTERNAL                = 0x01
   2082 	SQLITE_PRINTF_MALLOCED                = 0x04
   2083 	SQLITE_PRINTF_SQLFUNC                 = 0x02
   2084 	SQLITE_PRINT_BUF_SIZE                 = 70
   2085 	SQLITE_PRIVATE                        = 0
   2086 	SQLITE_PROTOCOL                       = 15
   2087 	SQLITE_PTRSIZE                        = 4
   2088 	SQLITE_PropagateConst                 = 0x00008000
   2089 	SQLITE_PushDown                       = 0x00001000
   2090 	SQLITE_QUERY_PLANNER_LIMIT            = 20000
   2091 	SQLITE_QUERY_PLANNER_LIMIT_INCR       = 1000
   2092 	SQLITE_QueryFlattener                 = 0x00000001
   2093 	SQLITE_QueryOnly                      = 0x00100000
   2094 	SQLITE_RANGE                          = 25
   2095 	SQLITE_RBU_STATE_CHECKPOINT           = 3
   2096 	SQLITE_RBU_STATE_DONE                 = 4
   2097 	SQLITE_RBU_STATE_ERROR                = 5
   2098 	SQLITE_RBU_STATE_MOVE                 = 2
   2099 	SQLITE_RBU_STATE_OAL                  = 1
   2100 	SQLITE_RBU_UPDATE_CACHESIZE           = 16
   2101 	SQLITE_READ                           = 20
   2102 	SQLITE_READONLY                       = 8
   2103 	SQLITE_READONLY_CANTINIT              = 1288
   2104 	SQLITE_READONLY_CANTLOCK              = 520
   2105 	SQLITE_READONLY_DBMOVED               = 1032
   2106 	SQLITE_READONLY_DIRECTORY             = 1544
   2107 	SQLITE_READONLY_RECOVERY              = 264
   2108 	SQLITE_READONLY_ROLLBACK              = 776
   2109 	SQLITE_RECURSIVE                      = 33
   2110 	SQLITE_REINDEX                        = 27
   2111 	SQLITE_REPLACE                        = 5
   2112 	SQLITE_ROLLBACK                       = 1
   2113 	SQLITE_ROW                            = 100
   2114 	SQLITE_ReadUncommit                   = 0x00000400
   2115 	SQLITE_RecTriggers                    = 0x00002000
   2116 	SQLITE_ReleaseReg                     = 0x00400000
   2117 	SQLITE_ResetDatabase                  = 0x02000000
   2118 	SQLITE_ReverseOrder                   = 0x00001000
   2119 	SQLITE_SAVEPOINT                      = 32
   2120 	SQLITE_SCANSTAT_COMPLEX               = 0x0001
   2121 	SQLITE_SCANSTAT_EST                   = 2
   2122 	SQLITE_SCANSTAT_EXPLAIN               = 4
   2123 	SQLITE_SCANSTAT_NAME                  = 3
   2124 	SQLITE_SCANSTAT_NCYCLE                = 7
   2125 	SQLITE_SCANSTAT_NLOOP                 = 0
   2126 	SQLITE_SCANSTAT_NVISIT                = 1
   2127 	SQLITE_SCANSTAT_PARENTID              = 6
   2128 	SQLITE_SCANSTAT_SELECTID              = 5
   2129 	SQLITE_SCHEMA                         = 17
   2130 	SQLITE_SELECT                         = 21
   2131 	SQLITE_SERIALIZE_NOCOPY               = 0x001
   2132 	SQLITE_SESSION_CONFIG_STRMSIZE        = 1
   2133 	SQLITE_SESSION_OBJCONFIG_SIZE         = 1
   2134 	SQLITE_SET_LOCKPROXYFILE              = 3
   2135 	SQLITE_SHM_EXCLUSIVE                  = 8
   2136 	SQLITE_SHM_LOCK                       = 2
   2137 	SQLITE_SHM_NLOCK                      = 8
   2138 	SQLITE_SHM_SHARED                     = 4
   2139 	SQLITE_SHM_UNLOCK                     = 1
   2140 	SQLITE_SORTER_PMASZ                   = 250
   2141 	SQLITE_SOUNDEX                        = 1
   2142 	SQLITE_SOURCE_ID                      = "2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da"
   2143 	SQLITE_SO_ASC                         = 0
   2144 	SQLITE_SO_DESC                        = 1
   2145 	SQLITE_SO_UNDEFINED                   = -1
   2146 	SQLITE_STAT4_SAMPLES                  = 24
   2147 	SQLITE_STATE_BUSY                     = 0x6d
   2148 	SQLITE_STATE_CLOSED                   = 0xce
   2149 	SQLITE_STATE_ERROR                    = 0xd5
   2150 	SQLITE_STATE_OPEN                     = 0x76
   2151 	SQLITE_STATE_SICK                     = 0xba
   2152 	SQLITE_STATE_ZOMBIE                   = 0xa7
   2153 	SQLITE_STATUS_MALLOC_COUNT            = 9
   2154 	SQLITE_STATUS_MALLOC_SIZE             = 5
   2155 	SQLITE_STATUS_MEMORY_USED             = 0
   2156 	SQLITE_STATUS_PAGECACHE_OVERFLOW      = 2
   2157 	SQLITE_STATUS_PAGECACHE_SIZE          = 7
   2158 	SQLITE_STATUS_PAGECACHE_USED          = 1
   2159 	SQLITE_STATUS_PARSER_STACK            = 6
   2160 	SQLITE_STATUS_SCRATCH_OVERFLOW        = 4
   2161 	SQLITE_STATUS_SCRATCH_SIZE            = 8
   2162 	SQLITE_STATUS_SCRATCH_USED            = 3
   2163 	SQLITE_STDCALL                        = 0
   2164 	SQLITE_STMTJRNL_SPILL                 = 65536
   2165 	SQLITE_STMTSTATUS_AUTOINDEX           = 3
   2166 	SQLITE_STMTSTATUS_FILTER_HIT          = 8
   2167 	SQLITE_STMTSTATUS_FILTER_MISS         = 7
   2168 	SQLITE_STMTSTATUS_FULLSCAN_STEP       = 1
   2169 	SQLITE_STMTSTATUS_MEMUSED             = 99
   2170 	SQLITE_STMTSTATUS_REPREPARE           = 5
   2171 	SQLITE_STMTSTATUS_RUN                 = 6
   2172 	SQLITE_STMTSTATUS_SORT                = 2
   2173 	SQLITE_STMTSTATUS_VM_STEP             = 4
   2174 	SQLITE_SUBTYPE                        = 0x000100000
   2175 	SQLITE_SYNC_DATAONLY                  = 0x00010
   2176 	SQLITE_SYNC_FULL                      = 0x00003
   2177 	SQLITE_SYNC_NORMAL                    = 0x00002
   2178 	SQLITE_SYSAPI                         = 0
   2179 	SQLITE_SYSTEM_MALLOC                  = 1
   2180 	SQLITE_SeekScan                       = 0x00020000
   2181 	SQLITE_ShortColNames                  = 0x00000040
   2182 	SQLITE_SimplifyJoin                   = 0x00002000
   2183 	SQLITE_SkipScan                       = 0x00004000
   2184 	SQLITE_Stat4                          = 0x00000800
   2185 	SQLITE_TCLAPI                         = 0
   2186 	SQLITE_TEMP_FILE_PREFIX               = "etilqs_"
   2187 	SQLITE_TEMP_STORE                     = 1
   2188 	SQLITE_TESTCTRL_ALWAYS                = 13
   2189 	SQLITE_TESTCTRL_ASSERT                = 12
   2190 	SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS   = 10
   2191 	SQLITE_TESTCTRL_BITVEC_TEST           = 8
   2192 	SQLITE_TESTCTRL_BYTEORDER             = 22
   2193 	SQLITE_TESTCTRL_EXPLAIN_STMT          = 19
   2194 	SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS   = 29
   2195 	SQLITE_TESTCTRL_FAULT_INSTALL         = 9
   2196 	SQLITE_TESTCTRL_FIRST                 = 5
   2197 	SQLITE_TESTCTRL_IMPOSTER              = 25
   2198 	SQLITE_TESTCTRL_INTERNAL_FUNCTIONS    = 17
   2199 	SQLITE_TESTCTRL_ISINIT                = 23
   2200 	SQLITE_TESTCTRL_ISKEYWORD             = 16
   2201 	SQLITE_TESTCTRL_LAST                  = 33
   2202 	SQLITE_TESTCTRL_LOCALTIME_FAULT       = 18
   2203 	SQLITE_TESTCTRL_LOGEST                = 33
   2204 	SQLITE_TESTCTRL_NEVER_CORRUPT         = 20
   2205 	SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD  = 19
   2206 	SQLITE_TESTCTRL_OPTIMIZATIONS         = 15
   2207 	SQLITE_TESTCTRL_PARSER_COVERAGE       = 26
   2208 	SQLITE_TESTCTRL_PENDING_BYTE          = 11
   2209 	SQLITE_TESTCTRL_PRNG_RESET            = 7
   2210 	SQLITE_TESTCTRL_PRNG_RESTORE          = 6
   2211 	SQLITE_TESTCTRL_PRNG_SAVE             = 5
   2212 	SQLITE_TESTCTRL_PRNG_SEED             = 28
   2213 	SQLITE_TESTCTRL_RESERVE               = 14
   2214 	SQLITE_TESTCTRL_RESULT_INTREAL        = 27
   2215 	SQLITE_TESTCTRL_SCRATCHMALLOC         = 17
   2216 	SQLITE_TESTCTRL_SEEK_COUNT            = 30
   2217 	SQLITE_TESTCTRL_SORTER_MMAP           = 24
   2218 	SQLITE_TESTCTRL_TRACEFLAGS            = 31
   2219 	SQLITE_TESTCTRL_TUNE                  = 32
   2220 	SQLITE_TESTCTRL_VDBE_COVERAGE         = 21
   2221 	SQLITE_TEXT                           = 3
   2222 	SQLITE_THREADSAFE                     = 1
   2223 	SQLITE_TOKEN_KEYWORD                  = 0x2
   2224 	SQLITE_TOKEN_QUOTED                   = 0x1
   2225 	SQLITE_TOOBIG                         = 18
   2226 	SQLITE_TRACE_CLOSE                    = 0x08
   2227 	SQLITE_TRACE_LEGACY                   = 0x40
   2228 	SQLITE_TRACE_NONLEGACY_MASK           = 0x0f
   2229 	SQLITE_TRACE_PROFILE                  = 0x02
   2230 	SQLITE_TRACE_ROW                      = 0x04
   2231 	SQLITE_TRACE_STMT                     = 0x01
   2232 	SQLITE_TRACE_XPROFILE                 = 0x80
   2233 	SQLITE_TRANSACTION                    = 22
   2234 	SQLITE_TXN_NONE                       = 0
   2235 	SQLITE_TXN_READ                       = 1
   2236 	SQLITE_TXN_WRITE                      = 2
   2237 	SQLITE_Transitive                     = 0x00000080
   2238 	SQLITE_TriggerEQP                     = 0x01000000
   2239 	SQLITE_TrustedSchema                  = 0x00000080
   2240 	SQLITE_UPDATE                         = 23
   2241 	SQLITE_USE_URI                        = 0
   2242 	SQLITE_UTF16                          = 4
   2243 	SQLITE_UTF16BE                        = 3
   2244 	SQLITE_UTF16LE                        = 2
   2245 	SQLITE_UTF16NATIVE                    = 2
   2246 	SQLITE_UTF16_ALIGNED                  = 8
   2247 	SQLITE_UTF8                           = 1
   2248 	SQLITE_VDBEINT_H                      = 0
   2249 	SQLITE_VDBE_H                         = 0
   2250 	SQLITE_VERSION                        = "3.41.2"
   2251 	SQLITE_VERSION_NUMBER                 = 3041002
   2252 	SQLITE_VTABRISK_High                  = 2
   2253 	SQLITE_VTABRISK_Low                   = 0
   2254 	SQLITE_VTABRISK_Normal                = 1
   2255 	SQLITE_VTAB_CONSTRAINT_SUPPORT        = 1
   2256 	SQLITE_VTAB_DIRECTONLY                = 3
   2257 	SQLITE_VTAB_INNOCUOUS                 = 2
   2258 	SQLITE_WAL_H                          = 0
   2259 	SQLITE_WARNING                        = 28
   2260 	SQLITE_WARNING_AUTOINDEX              = 284
   2261 	SQLITE_WHEREINT_H                     = 0
   2262 	SQLITE_WIN32_DATA_DIRECTORY_TYPE      = 1
   2263 	SQLITE_WIN32_TEMP_DIRECTORY_TYPE      = 2
   2264 	SQLITE_WSD                            = 0
   2265 	SQLITE_WindowFunc                     = 0x00000002
   2266 	SQLITE_WriteSchema                    = 0x00000001
   2267 	SRT_Coroutine                         = 13
   2268 	SRT_Discard                           = 4
   2269 	SRT_DistFifo                          = 5
   2270 	SRT_DistQueue                         = 6
   2271 	SRT_EphemTab                          = 12
   2272 	SRT_Except                            = 2
   2273 	SRT_Exists                            = 3
   2274 	SRT_Fifo                              = 8
   2275 	SRT_Mem                               = 10
   2276 	SRT_Output                            = 9
   2277 	SRT_Queue                             = 7
   2278 	SRT_Set                               = 11
   2279 	SRT_Table                             = 14
   2280 	SRT_Union                             = 1
   2281 	SRT_Upfrom                            = 15
   2282 	STATX_ALL                             = 0x00000fff
   2283 	STATX_ATIME                           = 0x00000020
   2284 	STATX_ATTR_APPEND                     = 0x00000020
   2285 	STATX_ATTR_AUTOMOUNT                  = 0x00001000
   2286 	STATX_ATTR_COMPRESSED                 = 0x00000004
   2287 	STATX_ATTR_DAX                        = 0x00200000
   2288 	STATX_ATTR_ENCRYPTED                  = 0x00000800
   2289 	STATX_ATTR_IMMUTABLE                  = 0x00000010
   2290 	STATX_ATTR_MOUNT_ROOT                 = 0x00002000
   2291 	STATX_ATTR_NODUMP                     = 0x00000040
   2292 	STATX_ATTR_VERITY                     = 0x00100000
   2293 	STATX_BASIC_STATS                     = 0x000007ff
   2294 	STATX_BLOCKS                          = 0x00000400
   2295 	STATX_BTIME                           = 0x00000800
   2296 	STATX_CTIME                           = 0x00000080
   2297 	STATX_GID                             = 0x00000010
   2298 	STATX_INO                             = 0x00000100
   2299 	STATX_MNT_ID                          = 0x00001000
   2300 	STATX_MODE                            = 0x00000002
   2301 	STATX_MTIME                           = 0x00000040
   2302 	STATX_NLINK                           = 0x00000004
   2303 	STATX_SIZE                            = 0x00000200
   2304 	STATX_TYPE                            = 0x00000001
   2305 	STATX_UID                             = 0x00000008
   2306 	STATX__RESERVED                       = 0x80000000
   2307 	STAT_GET_NDLT                         = 4
   2308 	STAT_GET_NEQ                          = 2
   2309 	STAT_GET_NLT                          = 3
   2310 	STAT_GET_ROWID                        = 1
   2311 	STAT_GET_STAT1                        = 0
   2312 	STA_CLK                               = 0x8000
   2313 	STA_CLOCKERR                          = 0x1000
   2314 	STA_DEL                               = 0x0020
   2315 	STA_FLL                               = 0x0008
   2316 	STA_FREQHOLD                          = 0x0080
   2317 	STA_INS                               = 0x0010
   2318 	STA_MODE                              = 0x4000
   2319 	STA_NANO                              = 0x2000
   2320 	STA_PLL                               = 0x0001
   2321 	STA_PPSERROR                          = 0x0800
   2322 	STA_PPSFREQ                           = 0x0002
   2323 	STA_PPSJITTER                         = 0x0200
   2324 	STA_PPSSIGNAL                         = 0x0100
   2325 	STA_PPSTIME                           = 0x0004
   2326 	STA_PPSWANDER                         = 0x0400
   2327 	STA_RONLY                             = 65280
   2328 	STA_UNSYNC                            = 0x0040
   2329 	STDERR_FILENO                         = 2
   2330 	STDIN_FILENO                          = 0
   2331 	STDOUT_FILENO                         = 1
   2332 	SYNC_FILE_RANGE_WAIT_AFTER            = 4
   2333 	SYNC_FILE_RANGE_WAIT_BEFORE           = 1
   2334 	SYNC_FILE_RANGE_WRITE                 = 2
   2335 	SYNC_FILE_RANGE_WRITE_AND_WAIT        = 7
   2336 	S_BLKSIZE                             = 512
   2337 	S_IEXEC                               = 64
   2338 	S_IFBLK                               = 24576
   2339 	S_IFCHR                               = 8192
   2340 	S_IFDIR                               = 16384
   2341 	S_IFIFO                               = 4096
   2342 	S_IFLNK                               = 40960
   2343 	S_IFMT                                = 61440
   2344 	S_IFREG                               = 32768
   2345 	S_IFSOCK                              = 49152
   2346 	S_IREAD                               = 256
   2347 	S_IRGRP                               = 32
   2348 	S_IROTH                               = 4
   2349 	S_IRUSR                               = 256
   2350 	S_IRWXG                               = 56
   2351 	S_IRWXO                               = 7
   2352 	S_IRWXU                               = 448
   2353 	S_ISGID                               = 1024
   2354 	S_ISUID                               = 2048
   2355 	S_ISVTX                               = 512
   2356 	S_IWGRP                               = 16
   2357 	S_IWOTH                               = 2
   2358 	S_IWRITE                              = 128
   2359 	S_IWUSR                               = 128
   2360 	S_IXGRP                               = 8
   2361 	S_IXOTH                               = 1
   2362 	S_IXUSR                               = 64
   2363 	TABTYP_NORM                           = 0
   2364 	TABTYP_VIEW                           = 2
   2365 	TABTYP_VTAB                           = 1
   2366 	TCFLSH                                = 0x540B
   2367 	TCGETA                                = 0x5405
   2368 	TCGETS                                = 0x5401
   2369 	TCGETX                                = 0x5432
   2370 	TCSBRK                                = 0x5409
   2371 	TCSBRKP                               = 0x5425
   2372 	TCSETA                                = 0x5406
   2373 	TCSETAF                               = 0x5408
   2374 	TCSETAW                               = 0x5407
   2375 	TCSETS                                = 0x5402
   2376 	TCSETSF                               = 0x5404
   2377 	TCSETSW                               = 0x5403
   2378 	TCSETX                                = 0x5433
   2379 	TCSETXF                               = 0x5434
   2380 	TCSETXW                               = 0x5435
   2381 	TCXONC                                = 0x540A
   2382 	TERM_ANDINFO                          = 0x0020
   2383 	TERM_CODED                            = 0x0004
   2384 	TERM_COPIED                           = 0x0008
   2385 	TERM_DYNAMIC                          = 0x0001
   2386 	TERM_HEURTRUTH                        = 0x2000
   2387 	TERM_HIGHTRUTH                        = 0x4000
   2388 	TERM_IS                               = 0x0800
   2389 	TERM_LIKE                             = 0x0400
   2390 	TERM_LIKECOND                         = 0x0200
   2391 	TERM_LIKEOPT                          = 0x0100
   2392 	TERM_OK                               = 0x0040
   2393 	TERM_ORINFO                           = 0x0010
   2394 	TERM_SLICE                            = 0x8000
   2395 	TERM_VARSELECT                        = 0x1000
   2396 	TERM_VIRTUAL                          = 0x0002
   2397 	TERM_VNULL                            = 0x0080
   2398 	TF_Autoincrement                      = 0x00000008
   2399 	TF_Ephemeral                          = 0x00004000
   2400 	TF_Eponymous                          = 0x00008000
   2401 	TF_HasGenerated                       = 0x00000060
   2402 	TF_HasHidden                          = 0x00000002
   2403 	TF_HasNotNull                         = 0x00000800
   2404 	TF_HasPrimaryKey                      = 0x00000004
   2405 	TF_HasStat1                           = 0x00000010
   2406 	TF_HasStat4                           = 0x00002000
   2407 	TF_HasStored                          = 0x00000040
   2408 	TF_HasVirtual                         = 0x00000020
   2409 	TF_NoVisibleRowid                     = 0x00000200
   2410 	TF_OOOHidden                          = 0x00000400
   2411 	TF_Readonly                           = 0x00000001
   2412 	TF_Shadow                             = 0x00001000
   2413 	TF_StatsUsed                          = 0x00000100
   2414 	TF_Strict                             = 0x00010000
   2415 	TF_WithoutRowid                       = 0x00000080
   2416 	TIMER_ABSTIME                         = 1
   2417 	TIMER_END                             = 0
   2418 	TIMER_START                           = 0
   2419 	TIME_UTC                              = 1
   2420 	TIOCCBRK                              = 0x5428
   2421 	TIOCCONS                              = 0x541D
   2422 	TIOCEXCL                              = 0x540C
   2423 	TIOCGETD                              = 0x5424
   2424 	TIOCGICOUNT                           = 0x545D
   2425 	TIOCGLCKTRMIOS                        = 0x5456
   2426 	TIOCGPGRP                             = 0x540F
   2427 	TIOCGPTPEER                           = 21569
   2428 	TIOCGRS485                            = 0x542E
   2429 	TIOCGSERIAL                           = 0x541E
   2430 	TIOCGSID                              = 0x5429
   2431 	TIOCGSOFTCAR                          = 0x5419
   2432 	TIOCGWINSZ                            = 0x5413
   2433 	TIOCINQ                               = 21531
   2434 	TIOCLINUX                             = 0x541C
   2435 	TIOCMBIC                              = 0x5417
   2436 	TIOCMBIS                              = 0x5416
   2437 	TIOCMGET                              = 0x5415
   2438 	TIOCMIWAIT                            = 0x545C
   2439 	TIOCMSET                              = 0x5418
   2440 	TIOCM_CAR                             = 0x040
   2441 	TIOCM_CD                              = 64
   2442 	TIOCM_CTS                             = 0x020
   2443 	TIOCM_DSR                             = 0x100
   2444 	TIOCM_DTR                             = 0x002
   2445 	TIOCM_LE                              = 0x001
   2446 	TIOCM_RI                              = 128
   2447 	TIOCM_RNG                             = 0x080
   2448 	TIOCM_RTS                             = 0x004
   2449 	TIOCM_SR                              = 0x010
   2450 	TIOCM_ST                              = 0x008
   2451 	TIOCNOTTY                             = 0x5422
   2452 	TIOCNXCL                              = 0x540D
   2453 	TIOCOUTQ                              = 0x5411
   2454 	TIOCPKT                               = 0x5420
   2455 	TIOCPKT_DATA                          = 0
   2456 	TIOCPKT_DOSTOP                        = 32
   2457 	TIOCPKT_FLUSHREAD                     = 1
   2458 	TIOCPKT_FLUSHWRITE                    = 2
   2459 	TIOCPKT_IOCTL                         = 64
   2460 	TIOCPKT_NOSTOP                        = 16
   2461 	TIOCPKT_START                         = 8
   2462 	TIOCPKT_STOP                          = 4
   2463 	TIOCSBRK                              = 0x5427
   2464 	TIOCSCTTY                             = 0x540E
   2465 	TIOCSERCONFIG                         = 0x5453
   2466 	TIOCSERGETLSR                         = 0x5459
   2467 	TIOCSERGETMULTI                       = 0x545A
   2468 	TIOCSERGSTRUCT                        = 0x5458
   2469 	TIOCSERGWILD                          = 0x5454
   2470 	TIOCSERSETMULTI                       = 0x545B
   2471 	TIOCSERSWILD                          = 0x5455
   2472 	TIOCSER_TEMT                          = 0x01
   2473 	TIOCSETD                              = 0x5423
   2474 	TIOCSLCKTRMIOS                        = 0x5457
   2475 	TIOCSPGRP                             = 0x5410
   2476 	TIOCSRS485                            = 0x542F
   2477 	TIOCSSERIAL                           = 0x541F
   2478 	TIOCSSOFTCAR                          = 0x541A
   2479 	TIOCSTI                               = 0x5412
   2480 	TIOCSWINSZ                            = 0x5414
   2481 	TIOCVHANGUP                           = 0x5437
   2482 	TK_ABORT                              = 27
   2483 	TK_ACTION                             = 28
   2484 	TK_ADD                                = 163
   2485 	TK_AFTER                              = 29
   2486 	TK_AGG_COLUMN                         = 169
   2487 	TK_AGG_FUNCTION                       = 168
   2488 	TK_ALL                                = 135
   2489 	TK_ALTER                              = 162
   2490 	TK_ALWAYS                             = 96
   2491 	TK_ANALYZE                            = 30
   2492 	TK_AND                                = 44
   2493 	TK_ANY                                = 101
   2494 	TK_AS                                 = 24
   2495 	TK_ASC                                = 31
   2496 	TK_ASTERISK                           = 180
   2497 	TK_ATTACH                             = 32
   2498 	TK_AUTOINCR                           = 126
   2499 	TK_BEFORE                             = 33
   2500 	TK_BEGIN                              = 5
   2501 	TK_BETWEEN                            = 48
   2502 	TK_BITAND                             = 102
   2503 	TK_BITNOT                             = 114
   2504 	TK_BITOR                              = 103
   2505 	TK_BLOB                               = 154
   2506 	TK_BY                                 = 34
   2507 	TK_CASCADE                            = 35
   2508 	TK_CASE                               = 157
   2509 	TK_CAST                               = 36
   2510 	TK_CHECK                              = 124
   2511 	TK_COLLATE                            = 113
   2512 	TK_COLUMN                             = 167
   2513 	TK_COLUMNKW                           = 60
   2514 	TK_COMMA                              = 25
   2515 	TK_COMMIT                             = 10
   2516 	TK_CONCAT                             = 111
   2517 	TK_CONFLICT                           = 37
   2518 	TK_CONSTRAINT                         = 119
   2519 	TK_CREATE                             = 17
   2520 	TK_CTIME_KW                           = 100
   2521 	TK_CURRENT                            = 85
   2522 	TK_DATABASE                           = 38
   2523 	TK_DEFAULT                            = 120
   2524 	TK_DEFERRABLE                         = 131
   2525 	TK_DEFERRED                           = 7
   2526 	TK_DELETE                             = 128
   2527 	TK_DESC                               = 39
   2528 	TK_DETACH                             = 40
   2529 	TK_DISTINCT                           = 140
   2530 	TK_DO                                 = 61
   2531 	TK_DOT                                = 141
   2532 	TK_DROP                               = 133
   2533 	TK_EACH                               = 41
   2534 	TK_ELSE                               = 160
   2535 	TK_END                                = 11
   2536 	TK_EQ                                 = 53
   2537 	TK_ERROR                              = 182
   2538 	TK_ESCAPE                             = 58
   2539 	TK_EXCEPT                             = 136
   2540 	TK_EXCLUDE                            = 91
   2541 	TK_EXCLUSIVE                          = 9
   2542 	TK_EXISTS                             = 20
   2543 	TK_EXPLAIN                            = 2
   2544 	TK_FAIL                               = 42
   2545 	TK_FILTER                             = 166
   2546 	TK_FIRST                              = 83
   2547 	TK_FLOAT                              = 153
   2548 	TK_FOLLOWING                          = 86
   2549 	TK_FOR                                = 62
   2550 	TK_FOREIGN                            = 132
   2551 	TK_FROM                               = 142
   2552 	TK_FUNCTION                           = 172
   2553 	TK_GE                                 = 57
   2554 	TK_GENERATED                          = 95
   2555 	TK_GROUP                              = 146
   2556 	TK_GROUPS                             = 92
   2557 	TK_GT                                 = 54
   2558 	TK_HAVING                             = 147
   2559 	TK_ID                                 = 59
   2560 	TK_IF                                 = 18
   2561 	TK_IF_NULL_ROW                        = 179
   2562 	TK_IGNORE                             = 63
   2563 	TK_ILLEGAL                            = 184
   2564 	TK_IMMEDIATE                          = 8
   2565 	TK_IN                                 = 49
   2566 	TK_INDEX                              = 161
   2567 	TK_INDEXED                            = 116
   2568 	TK_INITIALLY                          = 64
   2569 	TK_INSERT                             = 127
   2570 	TK_INSTEAD                            = 65
   2571 	TK_INTEGER                            = 155
   2572 	TK_INTERSECT                          = 137
   2573 	TK_INTO                               = 151
   2574 	TK_IS                                 = 45
   2575 	TK_ISNOT                              = 171
   2576 	TK_ISNULL                             = 50
   2577 	TK_JOIN                               = 143
   2578 	TK_JOIN_KW                            = 118
   2579 	TK_KEY                                = 67
   2580 	TK_LAST                               = 84
   2581 	TK_LE                                 = 55
   2582 	TK_LIKE_KW                            = 47
   2583 	TK_LIMIT                              = 148
   2584 	TK_LP                                 = 22
   2585 	TK_LSHIFT                             = 104
   2586 	TK_LT                                 = 56
   2587 	TK_MATCH                              = 46
   2588 	TK_MATERIALIZED                       = 97
   2589 	TK_MINUS                              = 107
   2590 	TK_NE                                 = 52
   2591 	TK_NO                                 = 66
   2592 	TK_NOT                                = 19
   2593 	TK_NOTHING                            = 152
   2594 	TK_NOTNULL                            = 51
   2595 	TK_NULL                               = 121
   2596 	TK_NULLS                              = 82
   2597 	TK_OF                                 = 68
   2598 	TK_OFFSET                             = 69
   2599 	TK_ON                                 = 115
   2600 	TK_OR                                 = 43
   2601 	TK_ORDER                              = 145
   2602 	TK_OTHERS                             = 93
   2603 	TK_OVER                               = 165
   2604 	TK_PARTITION                          = 87
   2605 	TK_PLAN                               = 4
   2606 	TK_PLUS                               = 106
   2607 	TK_PRAGMA                             = 70
   2608 	TK_PRECEDING                          = 88
   2609 	TK_PRIMARY                            = 122
   2610 	TK_PTR                                = 112
   2611 	TK_QUERY                              = 3
   2612 	TK_RAISE                              = 71
   2613 	TK_RANGE                              = 89
   2614 	TK_RECURSIVE                          = 72
   2615 	TK_REFERENCES                         = 125
   2616 	TK_REGISTER                           = 176
   2617 	TK_REINDEX                            = 98
   2618 	TK_RELEASE                            = 14
   2619 	TK_REM                                = 110
   2620 	TK_RENAME                             = 99
   2621 	TK_REPLACE                            = 73
   2622 	TK_RESTRICT                           = 74
   2623 	TK_RETURNING                          = 150
   2624 	TK_ROLLBACK                           = 12
   2625 	TK_ROW                                = 75
   2626 	TK_ROWS                               = 76
   2627 	TK_RP                                 = 23
   2628 	TK_RSHIFT                             = 105
   2629 	TK_SAVEPOINT                          = 13
   2630 	TK_SELECT                             = 138
   2631 	TK_SELECT_COLUMN                      = 178
   2632 	TK_SEMI                               = 1
   2633 	TK_SET                                = 130
   2634 	TK_SLASH                              = 109
   2635 	TK_SPACE                              = 183
   2636 	TK_SPAN                               = 181
   2637 	TK_STAR                               = 108
   2638 	TK_STRING                             = 117
   2639 	TK_TABLE                              = 16
   2640 	TK_TEMP                               = 21
   2641 	TK_THEN                               = 159
   2642 	TK_TIES                               = 94
   2643 	TK_TO                                 = 15
   2644 	TK_TRANSACTION                        = 6
   2645 	TK_TRIGGER                            = 77
   2646 	TK_TRUEFALSE                          = 170
   2647 	TK_TRUTH                              = 175
   2648 	TK_UMINUS                             = 173
   2649 	TK_UNBOUNDED                          = 90
   2650 	TK_UNION                              = 134
   2651 	TK_UNIQUE                             = 123
   2652 	TK_UPDATE                             = 129
   2653 	TK_UPLUS                              = 174
   2654 	TK_USING                              = 144
   2655 	TK_VACUUM                             = 78
   2656 	TK_VALUES                             = 139
   2657 	TK_VARIABLE                           = 156
   2658 	TK_VECTOR                             = 177
   2659 	TK_VIEW                               = 79
   2660 	TK_VIRTUAL                            = 80
   2661 	TK_WHEN                               = 158
   2662 	TK_WHERE                              = 149
   2663 	TK_WINDOW                             = 164
   2664 	TK_WITH                               = 81
   2665 	TK_WITHOUT                            = 26
   2666 	TMP_MAX                               = 238328
   2667 	TRANS_NONE                            = 0
   2668 	TRANS_READ                            = 1
   2669 	TRANS_WRITE                           = 2
   2670 	TREETRACE_ENABLED                     = 0
   2671 	TRIGGER_AFTER                         = 2
   2672 	TRIGGER_BEFORE                        = 1
   2673 	UNIXFILE_DELETE                       = 0x20
   2674 	UNIXFILE_DIRSYNC                      = 0x08
   2675 	UNIXFILE_EXCL                         = 0x01
   2676 	UNIXFILE_NOLOCK                       = 0x80
   2677 	UNIXFILE_PERSIST_WAL                  = 0x04
   2678 	UNIXFILE_PSOW                         = 0x10
   2679 	UNIXFILE_RDONLY                       = 0x02
   2680 	UNIXFILE_URI                          = 0x40
   2681 	UNIX_SHM_BASE                         = 120
   2682 	UNIX_SHM_DMS                          = 128
   2683 	UNKNOWN_LOCK                          = 5
   2684 	UTIME_NOW                             = 1073741823
   2685 	UTIME_OMIT                            = 1073741822
   2686 	VDBE_DISPLAY_P4                       = 1
   2687 	VDBE_HALT_STATE                       = 3
   2688 	VDBE_INIT_STATE                       = 0
   2689 	VDBE_READY_STATE                      = 1
   2690 	VDBE_RUN_STATE                        = 2
   2691 	WALINDEX_MAX_VERSION                  = 3007000
   2692 	WAL_ALL_BUT_WRITE                     = 1
   2693 	WAL_CKPT_LOCK                         = 1
   2694 	WAL_EXCLUSIVE_MODE                    = 1
   2695 	WAL_FRAME_HDRSIZE                     = 24
   2696 	WAL_HDRSIZE                           = 32
   2697 	WAL_HEAPMEMORY_MODE                   = 2
   2698 	WAL_LOCK_CKPT                         = 1
   2699 	WAL_LOCK_READ0                        = 3
   2700 	WAL_LOCK_WRITE                        = 0
   2701 	WAL_MAGIC                             = 0x377f0682
   2702 	WAL_MAX_VERSION                       = 3007000
   2703 	WAL_NORMAL_MODE                       = 0
   2704 	WAL_NREADER                           = 5
   2705 	WAL_RDONLY                            = 1
   2706 	WAL_RDWR                              = 0
   2707 	WAL_RECOVER_LOCK                      = 2
   2708 	WAL_RETRY                             = -1
   2709 	WAL_SAVEPOINT_NDATA                   = 4
   2710 	WAL_SHM_RDONLY                        = 2
   2711 	WAL_WRITE_LOCK                        = 0
   2712 	WCONTINUED                            = 8
   2713 	WEXITED                               = 4
   2714 	WHERE_AGG_DISTINCT                    = 0x0400
   2715 	WHERE_AUTO_INDEX                      = 0x00004000
   2716 	WHERE_BIGNULL_SORT                    = 0x00080000
   2717 	WHERE_BLOOMFILTER                     = 0x00400000
   2718 	WHERE_BOTH_LIMIT                      = 0x00000030
   2719 	WHERE_BTM_LIMIT                       = 0x00000020
   2720 	WHERE_COLUMN_EQ                       = 0x00000001
   2721 	WHERE_COLUMN_IN                       = 0x00000004
   2722 	WHERE_COLUMN_NULL                     = 0x00000008
   2723 	WHERE_COLUMN_RANGE                    = 0x00000002
   2724 	WHERE_CONSTRAINT                      = 0x0000000f
   2725 	WHERE_DISTINCTBY                      = 0x0080
   2726 	WHERE_DISTINCT_NOOP                   = 0
   2727 	WHERE_DISTINCT_ORDERED                = 2
   2728 	WHERE_DISTINCT_UNIQUE                 = 1
   2729 	WHERE_DISTINCT_UNORDERED              = 3
   2730 	WHERE_DUPLICATES_OK                   = 0x0010
   2731 	WHERE_EXPRIDX                         = 0x04000000
   2732 	WHERE_GROUPBY                         = 0x0040
   2733 	WHERE_IDX_ONLY                        = 0x00000040
   2734 	WHERE_INDEXED                         = 0x00000200
   2735 	WHERE_IN_ABLE                         = 0x00000800
   2736 	WHERE_IN_EARLYOUT                     = 0x00040000
   2737 	WHERE_IN_SEEKSCAN                     = 0x00100000
   2738 	WHERE_IPK                             = 0x00000100
   2739 	WHERE_MULTI_OR                        = 0x00002000
   2740 	WHERE_OMIT_OFFSET                     = 0x01000000
   2741 	WHERE_ONEPASS_DESIRED                 = 0x0004
   2742 	WHERE_ONEPASS_MULTIROW                = 0x0008
   2743 	WHERE_ONEROW                          = 0x00001000
   2744 	WHERE_ORDERBY_LIMIT                   = 0x0800
   2745 	WHERE_ORDERBY_MAX                     = 0x0002
   2746 	WHERE_ORDERBY_MIN                     = 0x0001
   2747 	WHERE_ORDERBY_NORMAL                  = 0x0000
   2748 	WHERE_OR_SUBCLAUSE                    = 0x0020
   2749 	WHERE_PARTIALIDX                      = 0x00020000
   2750 	WHERE_RIGHT_JOIN                      = 0x1000
   2751 	WHERE_SELFCULL                        = 0x00800000
   2752 	WHERE_SKIPSCAN                        = 0x00008000
   2753 	WHERE_SORTBYGROUP                     = 0x0200
   2754 	WHERE_TOP_LIMIT                       = 0x00000010
   2755 	WHERE_TRANSCONS                       = 0x00200000
   2756 	WHERE_UNQ_WANTED                      = 0x00010000
   2757 	WHERE_USE_LIMIT                       = 0x4000
   2758 	WHERE_VIEWSCAN                        = 0x02000000
   2759 	WHERE_VIRTUALTABLE                    = 0x00000400
   2760 	WHERE_WANT_DISTINCT                   = 0x0100
   2761 	WINDOW_AGGINVERSE                     = 2
   2762 	WINDOW_AGGSTEP                        = 3
   2763 	WINDOW_ENDING_INT                     = 1
   2764 	WINDOW_ENDING_NUM                     = 4
   2765 	WINDOW_NTH_VALUE_INT                  = 2
   2766 	WINDOW_RETURN_ROW                     = 1
   2767 	WINDOW_STARTING_INT                   = 0
   2768 	WINDOW_STARTING_NUM                   = 3
   2769 	WNOHANG                               = 1
   2770 	WNOWAIT                               = 0x01000000
   2771 	WO_ALL                                = 0x3fff
   2772 	WO_AND                                = 0x0400
   2773 	WO_AUX                                = 0x0040
   2774 	WO_EQ                                 = 0x0002
   2775 	WO_EQUIV                              = 0x0800
   2776 	WO_GE                                 = 32
   2777 	WO_GT                                 = 4
   2778 	WO_IN                                 = 0x0001
   2779 	WO_IS                                 = 0x0080
   2780 	WO_ISNULL                             = 0x0100
   2781 	WO_LE                                 = 8
   2782 	WO_LT                                 = 16
   2783 	WO_NOOP                               = 0x1000
   2784 	WO_OR                                 = 0x0200
   2785 	WO_ROWVAL                             = 0x2000
   2786 	WO_SINGLE                             = 0x01ff
   2787 	WRC_Abort                             = 2
   2788 	WRC_Continue                          = 0
   2789 	WRC_Prune                             = 1
   2790 	WRITE_LOCK                            = 2
   2791 	WSTOPPED                              = 2
   2792 	WUNTRACED                             = 2
   2793 	W_OK                                  = 2
   2794 	XN_EXPR                               = -2
   2795 	XN_ROWID                              = -1
   2796 	X_OK                                  = 1
   2797 	YYFALLBACK                            = 1
   2798 	YYNOCODE                              = 319
   2799 	YYNOERRORRECOVERY                     = 1
   2800 	YYNRULE                               = 405
   2801 	YYNRULE_WITH_ACTION                   = 342
   2802 	YYNSTATE                              = 576
   2803 	YYNTOKEN                              = 185
   2804 	YYPARSEFREENEVERNULL                  = 1
   2805 	YYSTACKDEPTH                          = 100
   2806 	YYWILDCARD                            = 101
   2807 	YY_ACCEPT_ACTION                      = 1241
   2808 	YY_ACTTAB_COUNT                       = 2098
   2809 	YY_ERROR_ACTION                       = 1240
   2810 	YY_MAX_REDUCE                         = 1647
   2811 	YY_MAX_SHIFT                          = 575
   2812 	YY_MAX_SHIFTREDUCE                    = 1239
   2813 	YY_MIN_REDUCE                         = 1243
   2814 	YY_MIN_SHIFTREDUCE                    = 835
   2815 	YY_NO_ACTION                          = 1242
   2816 	YY_REDUCE_COUNT                       = 408
   2817 	YY_REDUCE_MAX                         = 1740
   2818 	YY_REDUCE_MIN                         = -271
   2819 	YY_SHIFT_COUNT                        = 575
   2820 	YY_SHIFT_MAX                          = 2074
   2821 	YY_SHIFT_MIN                          = 0
   2822 	X_ALLOCA_H                            = 1
   2823 	X_ANSI_STDARG_H_                      = 0
   2824 	X_ANSI_STDDEF_H                       = 0
   2825 	X_ASM_GENERIC_ERRNO_BASE_H            = 0
   2826 	X_ASM_GENERIC_ERRNO_H                 = 0
   2827 	X_ASM_GENERIC_INT_LL64_H              = 0
   2828 	X_ASM_GENERIC_IOCTL_H                 = 0
   2829 	X_ASM_TYPES_H                         = 0
   2830 	X_ASSERT_H                            = 1
   2831 	X_ATFILE_SOURCE                       = 1
   2832 	X_BITS_BYTESWAP_H                     = 1
   2833 	X_BITS_ENDIANNESS_H                   = 1
   2834 	X_BITS_ENDIAN_H                       = 1
   2835 	X_BITS_ERRNO_H                        = 1
   2836 	X_BITS_FLOATN_COMMON_H                = 0
   2837 	X_BITS_LIBM_SIMD_DECL_STUBS_H         = 1
   2838 	X_BITS_POSIX_OPT_H                    = 1
   2839 	X_BITS_PTHREADTYPES_ARCH_H            = 1
   2840 	X_BITS_PTHREADTYPES_COMMON_H          = 1
   2841 	X_BITS_STAT_H                         = 1
   2842 	X_BITS_STDINT_INTN_H                  = 1
   2843 	X_BITS_STDIO_LIM_H                    = 1
   2844 	X_BITS_TIME64_H                       = 1
   2845 	X_BITS_TIMEX_H                        = 1
   2846 	X_BITS_TIME_H                         = 1
   2847 	X_BITS_TYPESIZES_H                    = 1
   2848 	X_BITS_TYPES_H                        = 1
   2849 	X_BITS_TYPES_LOCALE_T_H               = 1
   2850 	X_BITS_TYPES___LOCALE_T_H             = 1
   2851 	X_BITS_UINTN_IDENTITY_H               = 1
   2852 	X_BSD_PTRDIFF_T_                      = 0
   2853 	X_BSD_SIZE_T_                         = 0
   2854 	X_BSD_SIZE_T_DEFINED_                 = 0
   2855 	X_DEFAULT_SOURCE                      = 1
   2856 	X_DLFCN_H                             = 1
   2857 	X_ENDIAN_H                            = 1
   2858 	X_ERRNO_H                             = 1
   2859 	X_FALLOC_H_                           = 0
   2860 	X_FCNTL_H                             = 1
   2861 	X_FEATURES_H                          = 1
   2862 	X_FILE_OFFSET_BITS                    = 64
   2863 	X_FTS5INT_H                           = 0
   2864 	X_FTS5_H                              = 0
   2865 	X_FTSINT_H                            = 0
   2866 	X_GCC_MAX_ALIGN_T                     = 0
   2867 	X_GCC_PTRDIFF_T                       = 0
   2868 	X_GCC_SIZE_T                          = 0
   2869 	X_GCC_WCHAR_T                         = 0
   2870 	X_GETOPT_CORE_H                       = 1
   2871 	X_GETOPT_POSIX_H                      = 1
   2872 	X_GNU_SOURCE                          = 0
   2873 	X_IOC_DIRBITS                         = 2
   2874 	X_IOC_DIRMASK                         = 3
   2875 	X_IOC_DIRSHIFT                        = 30
   2876 	X_IOC_NONE                            = 0
   2877 	X_IOC_NRBITS                          = 8
   2878 	X_IOC_NRMASK                          = 255
   2879 	X_IOC_NRSHIFT                         = 0
   2880 	X_IOC_READ                            = 2
   2881 	X_IOC_SIZEBITS                        = 14
   2882 	X_IOC_SIZEMASK                        = 16383
   2883 	X_IOC_SIZESHIFT                       = 16
   2884 	X_IOC_TYPEBITS                        = 8
   2885 	X_IOC_TYPEMASK                        = 255
   2886 	X_IOC_TYPESHIFT                       = 8
   2887 	X_IOC_WRITE                           = 1
   2888 	X_IOFBF                               = 0
   2889 	X_IOLBF                               = 1
   2890 	X_IONBF                               = 2
   2891 	X_IO_EOF_SEEN                         = 0x0010
   2892 	X_IO_ERR_SEEN                         = 0x0020
   2893 	X_IO_USER_LOCK                        = 0x8000
   2894 	X_ISOC11_SOURCE                       = 1
   2895 	X_ISOC2X_SOURCE                       = 1
   2896 	X_ISOC95_SOURCE                       = 1
   2897 	X_ISOC99_SOURCE                       = 1
   2898 	X_LARGEFILE64_SOURCE                  = 1
   2899 	X_LARGEFILE_SOURCE                    = 1
   2900 	X_LARGE_FILE                          = 1
   2901 	X_LFS64_ASYNCHRONOUS_IO               = 1
   2902 	X_LFS64_LARGEFILE                     = 1
   2903 	X_LFS64_STDIO                         = 1
   2904 	X_LFS_ASYNCHRONOUS_IO                 = 1
   2905 	X_LFS_LARGEFILE                       = 1
   2906 	X_LINUX_IOCTL_H                       = 0
   2907 	X_LINUX_POSIX_TYPES_H                 = 0
   2908 	X_LINUX_STAT_H                        = 0
   2909 	X_LINUX_TYPES_H                       = 0
   2910 	X_MATH_H                              = 1
   2911 	X_MKNOD_VER                           = 1
   2912 	X_MKNOD_VER_LINUX                     = 1
   2913 	X_MKNOD_VER_SVR4                      = 2
   2914 	X_OS_COMMON_H_                        = 0
   2915 	X_POSIX2_CHAR_TERM                    = 200809
   2916 	X_POSIX2_C_BIND                       = 200809
   2917 	X_POSIX2_C_DEV                        = 200809
   2918 	X_POSIX2_C_VERSION                    = 200809
   2919 	X_POSIX2_LOCALEDEF                    = 200809
   2920 	X_POSIX2_SW_DEV                       = 200809
   2921 	X_POSIX2_VERSION                      = 200809
   2922 	X_POSIX_ADVISORY_INFO                 = 200809
   2923 	X_POSIX_ASYNCHRONOUS_IO               = 200809
   2924 	X_POSIX_ASYNC_IO                      = 1
   2925 	X_POSIX_BARRIERS                      = 200809
   2926 	X_POSIX_CHOWN_RESTRICTED              = 0
   2927 	X_POSIX_CLOCK_SELECTION               = 200809
   2928 	X_POSIX_CPUTIME                       = 0
   2929 	X_POSIX_C_SOURCE                      = 200809
   2930 	X_POSIX_FSYNC                         = 200809
   2931 	X_POSIX_IPV6                          = 200809
   2932 	X_POSIX_JOB_CONTROL                   = 1
   2933 	X_POSIX_MAPPED_FILES                  = 200809
   2934 	X_POSIX_MEMLOCK                       = 200809
   2935 	X_POSIX_MEMLOCK_RANGE                 = 200809
   2936 	X_POSIX_MEMORY_PROTECTION             = 200809
   2937 	X_POSIX_MESSAGE_PASSING               = 200809
   2938 	X_POSIX_MONOTONIC_CLOCK               = 0
   2939 	X_POSIX_NO_TRUNC                      = 1
   2940 	X_POSIX_PRIORITIZED_IO                = 200809
   2941 	X_POSIX_PRIORITY_SCHEDULING           = 200809
   2942 	X_POSIX_RAW_SOCKETS                   = 200809
   2943 	X_POSIX_READER_WRITER_LOCKS           = 200809
   2944 	X_POSIX_REALTIME_SIGNALS              = 200809
   2945 	X_POSIX_REENTRANT_FUNCTIONS           = 1
   2946 	X_POSIX_REGEXP                        = 1
   2947 	X_POSIX_SAVED_IDS                     = 1
   2948 	X_POSIX_SEMAPHORES                    = 200809
   2949 	X_POSIX_SHARED_MEMORY_OBJECTS         = 200809
   2950 	X_POSIX_SHELL                         = 1
   2951 	X_POSIX_SOURCE                        = 1
   2952 	X_POSIX_SPAWN                         = 200809
   2953 	X_POSIX_SPIN_LOCKS                    = 200809
   2954 	X_POSIX_SPORADIC_SERVER               = -1
   2955 	X_POSIX_SYNCHRONIZED_IO               = 200809
   2956 	X_POSIX_THREADS                       = 200809
   2957 	X_POSIX_THREAD_ATTR_STACKADDR         = 200809
   2958 	X_POSIX_THREAD_ATTR_STACKSIZE         = 200809
   2959 	X_POSIX_THREAD_CPUTIME                = 0
   2960 	X_POSIX_THREAD_PRIORITY_SCHEDULING    = 200809
   2961 	X_POSIX_THREAD_PRIO_INHERIT           = 200809
   2962 	X_POSIX_THREAD_PRIO_PROTECT           = 200809
   2963 	X_POSIX_THREAD_PROCESS_SHARED         = 200809
   2964 	X_POSIX_THREAD_ROBUST_PRIO_INHERIT    = 200809
   2965 	X_POSIX_THREAD_ROBUST_PRIO_PROTECT    = -1
   2966 	X_POSIX_THREAD_SAFE_FUNCTIONS         = 200809
   2967 	X_POSIX_THREAD_SPORADIC_SERVER        = -1
   2968 	X_POSIX_TIMEOUTS                      = 200809
   2969 	X_POSIX_TIMERS                        = 200809
   2970 	X_POSIX_TRACE                         = -1
   2971 	X_POSIX_TRACE_EVENT_FILTER            = -1
   2972 	X_POSIX_TRACE_INHERIT                 = -1
   2973 	X_POSIX_TRACE_LOG                     = -1
   2974 	X_POSIX_TYPED_MEMORY_OBJECTS          = -1
   2975 	X_POSIX_V6_ILP32_OFF32                = 1
   2976 	X_POSIX_V6_ILP32_OFFBIG               = 1
   2977 	X_POSIX_V6_LP64_OFF64                 = -1
   2978 	X_POSIX_V6_LPBIG_OFFBIG               = -1
   2979 	X_POSIX_V7_ILP32_OFF32                = 1
   2980 	X_POSIX_V7_ILP32_OFFBIG               = 1
   2981 	X_POSIX_V7_LP64_OFF64                 = -1
   2982 	X_POSIX_V7_LPBIG_OFFBIG               = -1
   2983 	X_POSIX_VDISABLE                      = 0
   2984 	X_POSIX_VERSION                       = 200809
   2985 	X_PTRDIFF_T                           = 0
   2986 	X_PTRDIFF_T_                          = 0
   2987 	X_PTRDIFF_T_DECLARED                  = 0
   2988 	X_SIZET_                              = 0
   2989 	X_SIZE_T                              = 0
   2990 	X_SIZE_T_                             = 0
   2991 	X_SIZE_T_DECLARED                     = 0
   2992 	X_SIZE_T_DEFINED                      = 0
   2993 	X_SIZE_T_DEFINED_                     = 0
   2994 	X_SQLITE3RBU_H                        = 0
   2995 	X_SQLITE3RTREE_H_                     = 0
   2996 	X_SQLITE_OS_H_                        = 0
   2997 	X_STATBUF_ST_BLKSIZE                  = 0
   2998 	X_STATBUF_ST_NSEC                     = 0
   2999 	X_STATBUF_ST_RDEV                     = 0
   3000 	X_STAT_VER                            = 3
   3001 	X_STAT_VER_KERNEL                     = 1
   3002 	X_STAT_VER_LINUX                      = 3
   3003 	X_STAT_VER_LINUX_OLD                  = 1
   3004 	X_STAT_VER_SVR4                       = 2
   3005 	X_STDARG_H                            = 0
   3006 	X_STDC_PREDEF_H                       = 1
   3007 	X_STDDEF_H                            = 0
   3008 	X_STDDEF_H_                           = 0
   3009 	X_STDIO_H                             = 1
   3010 	X_STDLIB_H                            = 1
   3011 	X_STRINGS_H                           = 1
   3012 	X_STRING_H                            = 1
   3013 	X_STRUCT_TIMESPEC                     = 1
   3014 	X_SYS_CDEFS_H                         = 1
   3015 	X_SYS_IOCTL_H                         = 1
   3016 	X_SYS_MMAN_H                          = 1
   3017 	X_SYS_SELECT_H                        = 1
   3018 	X_SYS_SIZE_T_H                        = 0
   3019 	X_SYS_STAT_H                          = 1
   3020 	X_SYS_TIME_H                          = 1
   3021 	X_SYS_TTYDEFAULTS_H_                  = 0
   3022 	X_SYS_TYPES_H                         = 1
   3023 	X_THREAD_MUTEX_INTERNAL_H             = 1
   3024 	X_THREAD_SHARED_TYPES_H               = 1
   3025 	X_TIME_H                              = 1
   3026 	X_T_PTRDIFF                           = 0
   3027 	X_T_PTRDIFF_                          = 0
   3028 	X_T_SIZE                              = 0
   3029 	X_T_SIZE_                             = 0
   3030 	X_T_WCHAR                             = 0
   3031 	X_T_WCHAR_                            = 0
   3032 	X_UNISTD_H                            = 1
   3033 	X_VA_LIST                             = 0
   3034 	X_VA_LIST_                            = 0
   3035 	X_VA_LIST_DEFINED                     = 0
   3036 	X_VA_LIST_T_H                         = 0
   3037 	X_WCHAR_T                             = 0
   3038 	X_WCHAR_T_                            = 0
   3039 	X_WCHAR_T_DECLARED                    = 0
   3040 	X_WCHAR_T_DEFINED                     = 0
   3041 	X_WCHAR_T_DEFINED_                    = 0
   3042 	X_WCHAR_T_H                           = 0
   3043 	X_XBS5_ILP32_OFF32                    = 1
   3044 	X_XBS5_ILP32_OFFBIG                   = 1
   3045 	X_XBS5_LP64_OFF64                     = -1
   3046 	X_XBS5_LPBIG_OFFBIG                   = -1
   3047 	X_XOPEN_ENH_I18N                      = 1
   3048 	X_XOPEN_LEGACY                        = 1
   3049 	X_XOPEN_REALTIME                      = 1
   3050 	X_XOPEN_REALTIME_THREADS              = 1
   3051 	X_XOPEN_SHM                           = 1
   3052 	X_XOPEN_SOURCE                        = 700
   3053 	X_XOPEN_SOURCE_EXTENDED               = 1
   3054 	X_XOPEN_UNIX                          = 1
   3055 	X_XOPEN_VERSION                       = 700
   3056 	X_XOPEN_XCU_VERSION                   = 4
   3057 	X_XOPEN_XPG2                          = 1
   3058 	X_XOPEN_XPG3                          = 1
   3059 	X_XOPEN_XPG4                          = 1
   3060 	BBatch                                = 0
   3061 	EtBUFSIZE                             = 70
   3062 	EtCHARX                               = 8
   3063 	EtDECIMAL                             = 16
   3064 	EtDYNSTRING                           = 6
   3065 	EtEXP                                 = 2
   3066 	EtFLOAT                               = 1
   3067 	EtGENERIC                             = 3
   3068 	EtINVALID                             = 17
   3069 	EtORDINAL                             = 15
   3070 	EtPERCENT                             = 7
   3071 	EtPOINTER                             = 13
   3072 	EtRADIX                               = 0
   3073 	EtSIZE                                = 4
   3074 	EtSQLESCAPE                           = 9
   3075 	EtSQLESCAPE2                          = 10
   3076 	EtSQLESCAPE3                          = 14
   3077 	EtSRCITEM                             = 12
   3078 	EtSTRING                              = 5
   3079 	EtTOKEN                               = 11
   3080 	Fts5YYNFTS5TOKEN                      = 16
   3081 	Fts5YYNOCODE                          = 27
   3082 	Fts5YYNOERRORRECOVERY                 = 1
   3083 	Fts5YYNRULE                           = 28
   3084 	Fts5YYNRULE_WITH_ACTION               = 28
   3085 	Fts5YYNSTATE                          = 35
   3086 	Fts5YYPARSEFREENOTNULL                = 1
   3087 	Fts5YYSTACKDEPTH                      = 100
   3088 	Fts5YY_ACCEPT_ACTION                  = 81
   3089 	Fts5YY_ACTTAB_COUNT                   = 105
   3090 	Fts5YY_ERROR_ACTION                   = 80
   3091 	Fts5YY_MAX_REDUCE                     = 110
   3092 	Fts5YY_MAX_SHIFT                      = 34
   3093 	Fts5YY_MAX_SHIFTREDUCE                = 79
   3094 	Fts5YY_MIN_REDUCE                     = 83
   3095 	Fts5YY_MIN_SHIFTREDUCE                = 52
   3096 	Fts5YY_NO_ACTION                      = 82
   3097 	Fts5YY_REDUCE_COUNT                   = 17
   3098 	Fts5YY_REDUCE_MAX                     = 67
   3099 	Fts5YY_REDUCE_MIN                     = -17
   3100 	Fts5YY_SHIFT_COUNT                    = 34
   3101 	Fts5YY_SHIFT_MAX                      = 93
   3102 	Fts5YY_SHIFT_MIN                      = 0
   3103 	Linux                                 = 1
   3104 	Math_errhandling                      = 3
   3105 	Sqlite3Fts5ParserCTX_FETCH            = 0
   3106 	Sqlite3Fts5ParserCTX_PARAM            = 0
   3107 	Sqlite3Fts5ParserCTX_PDECL            = 0
   3108 	Sqlite3Fts5ParserCTX_SDECL            = 0
   3109 	Sqlite3Fts5ParserCTX_STORE            = 0
   3110 	Sqlite3ParserARG_FETCH                = 0
   3111 	Sqlite3ParserARG_PARAM                = 0
   3112 	Sqlite3ParserARG_PDECL                = 0
   3113 	Sqlite3ParserARG_SDECL                = 0
   3114 	Sqlite3ParserARG_STORE                = 0
   3115 	Sqlite3Parser_ENGINEALWAYSONSTACK     = 1
   3116 	TkCREATE                              = 4
   3117 	TkEND                                 = 7
   3118 	TkEXPLAIN                             = 3
   3119 	TkOTHER                               = 2
   3120 	TkSEMI                                = 0
   3121 	TkTEMP                                = 5
   3122 	TkTRIGGER                             = 6
   3123 	TkWS                                  = 1
   3124 	Unix                                  = 1
   3125 	WsdAutoextInit                        = 0
   3126 	WsdHooksInit                          = 0
   3127 	WsdStatInit                           = 0
   3128 )
   3129 
   3130 const (
   3131 	X_PC_LINK_MAX           = 0
   3132 	X_PC_MAX_CANON          = 1
   3133 	X_PC_MAX_INPUT          = 2
   3134 	X_PC_NAME_MAX           = 3
   3135 	X_PC_PATH_MAX           = 4
   3136 	X_PC_PIPE_BUF           = 5
   3137 	X_PC_CHOWN_RESTRICTED   = 6
   3138 	X_PC_NO_TRUNC           = 7
   3139 	X_PC_VDISABLE           = 8
   3140 	X_PC_SYNC_IO            = 9
   3141 	X_PC_ASYNC_IO           = 10
   3142 	X_PC_PRIO_IO            = 11
   3143 	X_PC_SOCK_MAXBUF        = 12
   3144 	X_PC_FILESIZEBITS       = 13
   3145 	X_PC_REC_INCR_XFER_SIZE = 14
   3146 	X_PC_REC_MAX_XFER_SIZE  = 15
   3147 	X_PC_REC_MIN_XFER_SIZE  = 16
   3148 	X_PC_REC_XFER_ALIGN     = 17
   3149 	X_PC_ALLOC_SIZE_MIN     = 18
   3150 	X_PC_SYMLINK_MAX        = 19
   3151 	X_PC_2_SYMLINKS         = 20
   3152 )
   3153 
   3154 const (
   3155 	X_CS_PATH = 0
   3156 
   3157 	X_CS_V6_WIDTH_RESTRICTED_ENVS = 1
   3158 
   3159 	X_CS_GNU_LIBC_VERSION       = 2
   3160 	X_CS_GNU_LIBPTHREAD_VERSION = 3
   3161 
   3162 	X_CS_V5_WIDTH_RESTRICTED_ENVS = 4
   3163 
   3164 	X_CS_V7_WIDTH_RESTRICTED_ENVS = 5
   3165 
   3166 	X_CS_LFS_CFLAGS      = 1000
   3167 	X_CS_LFS_LDFLAGS     = 1001
   3168 	X_CS_LFS_LIBS        = 1002
   3169 	X_CS_LFS_LINTFLAGS   = 1003
   3170 	X_CS_LFS64_CFLAGS    = 1004
   3171 	X_CS_LFS64_LDFLAGS   = 1005
   3172 	X_CS_LFS64_LIBS      = 1006
   3173 	X_CS_LFS64_LINTFLAGS = 1007
   3174 
   3175 	X_CS_XBS5_ILP32_OFF32_CFLAGS     = 1100
   3176 	X_CS_XBS5_ILP32_OFF32_LDFLAGS    = 1101
   3177 	X_CS_XBS5_ILP32_OFF32_LIBS       = 1102
   3178 	X_CS_XBS5_ILP32_OFF32_LINTFLAGS  = 1103
   3179 	X_CS_XBS5_ILP32_OFFBIG_CFLAGS    = 1104
   3180 	X_CS_XBS5_ILP32_OFFBIG_LDFLAGS   = 1105
   3181 	X_CS_XBS5_ILP32_OFFBIG_LIBS      = 1106
   3182 	X_CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 1107
   3183 	X_CS_XBS5_LP64_OFF64_CFLAGS      = 1108
   3184 	X_CS_XBS5_LP64_OFF64_LDFLAGS     = 1109
   3185 	X_CS_XBS5_LP64_OFF64_LIBS        = 1110
   3186 	X_CS_XBS5_LP64_OFF64_LINTFLAGS   = 1111
   3187 	X_CS_XBS5_LPBIG_OFFBIG_CFLAGS    = 1112
   3188 	X_CS_XBS5_LPBIG_OFFBIG_LDFLAGS   = 1113
   3189 	X_CS_XBS5_LPBIG_OFFBIG_LIBS      = 1114
   3190 	X_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 1115
   3191 
   3192 	X_CS_POSIX_V6_ILP32_OFF32_CFLAGS     = 1116
   3193 	X_CS_POSIX_V6_ILP32_OFF32_LDFLAGS    = 1117
   3194 	X_CS_POSIX_V6_ILP32_OFF32_LIBS       = 1118
   3195 	X_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS  = 1119
   3196 	X_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS    = 1120
   3197 	X_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS   = 1121
   3198 	X_CS_POSIX_V6_ILP32_OFFBIG_LIBS      = 1122
   3199 	X_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123
   3200 	X_CS_POSIX_V6_LP64_OFF64_CFLAGS      = 1124
   3201 	X_CS_POSIX_V6_LP64_OFF64_LDFLAGS     = 1125
   3202 	X_CS_POSIX_V6_LP64_OFF64_LIBS        = 1126
   3203 	X_CS_POSIX_V6_LP64_OFF64_LINTFLAGS   = 1127
   3204 	X_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS    = 1128
   3205 	X_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS   = 1129
   3206 	X_CS_POSIX_V6_LPBIG_OFFBIG_LIBS      = 1130
   3207 	X_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131
   3208 
   3209 	X_CS_POSIX_V7_ILP32_OFF32_CFLAGS     = 1132
   3210 	X_CS_POSIX_V7_ILP32_OFF32_LDFLAGS    = 1133
   3211 	X_CS_POSIX_V7_ILP32_OFF32_LIBS       = 1134
   3212 	X_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS  = 1135
   3213 	X_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS    = 1136
   3214 	X_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS   = 1137
   3215 	X_CS_POSIX_V7_ILP32_OFFBIG_LIBS      = 1138
   3216 	X_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139
   3217 	X_CS_POSIX_V7_LP64_OFF64_CFLAGS      = 1140
   3218 	X_CS_POSIX_V7_LP64_OFF64_LDFLAGS     = 1141
   3219 	X_CS_POSIX_V7_LP64_OFF64_LIBS        = 1142
   3220 	X_CS_POSIX_V7_LP64_OFF64_LINTFLAGS   = 1143
   3221 	X_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS    = 1144
   3222 	X_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS   = 1145
   3223 	X_CS_POSIX_V7_LPBIG_OFFBIG_LIBS      = 1146
   3224 	X_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147
   3225 
   3226 	X_CS_V6_ENV = 1148
   3227 	X_CS_V7_ENV = 1149
   3228 )
   3229 
   3230 const (
   3231 	X_SC_ARG_MAX               = 0
   3232 	X_SC_CHILD_MAX             = 1
   3233 	X_SC_CLK_TCK               = 2
   3234 	X_SC_NGROUPS_MAX           = 3
   3235 	X_SC_OPEN_MAX              = 4
   3236 	X_SC_STREAM_MAX            = 5
   3237 	X_SC_TZNAME_MAX            = 6
   3238 	X_SC_JOB_CONTROL           = 7
   3239 	X_SC_SAVED_IDS             = 8
   3240 	X_SC_REALTIME_SIGNALS      = 9
   3241 	X_SC_PRIORITY_SCHEDULING   = 10
   3242 	X_SC_TIMERS                = 11
   3243 	X_SC_ASYNCHRONOUS_IO       = 12
   3244 	X_SC_PRIORITIZED_IO        = 13
   3245 	X_SC_SYNCHRONIZED_IO       = 14
   3246 	X_SC_FSYNC                 = 15
   3247 	X_SC_MAPPED_FILES          = 16
   3248 	X_SC_MEMLOCK               = 17
   3249 	X_SC_MEMLOCK_RANGE         = 18
   3250 	X_SC_MEMORY_PROTECTION     = 19
   3251 	X_SC_MESSAGE_PASSING       = 20
   3252 	X_SC_SEMAPHORES            = 21
   3253 	X_SC_SHARED_MEMORY_OBJECTS = 22
   3254 	X_SC_AIO_LISTIO_MAX        = 23
   3255 	X_SC_AIO_MAX               = 24
   3256 	X_SC_AIO_PRIO_DELTA_MAX    = 25
   3257 	X_SC_DELAYTIMER_MAX        = 26
   3258 	X_SC_MQ_OPEN_MAX           = 27
   3259 	X_SC_MQ_PRIO_MAX           = 28
   3260 	X_SC_VERSION               = 29
   3261 	X_SC_PAGESIZE              = 30
   3262 	X_SC_RTSIG_MAX             = 31
   3263 	X_SC_SEM_NSEMS_MAX         = 32
   3264 	X_SC_SEM_VALUE_MAX         = 33
   3265 	X_SC_SIGQUEUE_MAX          = 34
   3266 	X_SC_TIMER_MAX             = 35
   3267 
   3268 	X_SC_BC_BASE_MAX        = 36
   3269 	X_SC_BC_DIM_MAX         = 37
   3270 	X_SC_BC_SCALE_MAX       = 38
   3271 	X_SC_BC_STRING_MAX      = 39
   3272 	X_SC_COLL_WEIGHTS_MAX   = 40
   3273 	X_SC_EQUIV_CLASS_MAX    = 41
   3274 	X_SC_EXPR_NEST_MAX      = 42
   3275 	X_SC_LINE_MAX           = 43
   3276 	X_SC_RE_DUP_MAX         = 44
   3277 	X_SC_CHARCLASS_NAME_MAX = 45
   3278 
   3279 	X_SC_2_VERSION   = 46
   3280 	X_SC_2_C_BIND    = 47
   3281 	X_SC_2_C_DEV     = 48
   3282 	X_SC_2_FORT_DEV  = 49
   3283 	X_SC_2_FORT_RUN  = 50
   3284 	X_SC_2_SW_DEV    = 51
   3285 	X_SC_2_LOCALEDEF = 52
   3286 
   3287 	X_SC_PII                 = 53
   3288 	X_SC_PII_XTI             = 54
   3289 	X_SC_PII_SOCKET          = 55
   3290 	X_SC_PII_INTERNET        = 56
   3291 	X_SC_PII_OSI             = 57
   3292 	X_SC_POLL                = 58
   3293 	X_SC_SELECT              = 59
   3294 	X_SC_UIO_MAXIOV          = 60
   3295 	X_SC_IOV_MAX             = 60
   3296 	X_SC_PII_INTERNET_STREAM = 61
   3297 	X_SC_PII_INTERNET_DGRAM  = 62
   3298 	X_SC_PII_OSI_COTS        = 63
   3299 	X_SC_PII_OSI_CLTS        = 64
   3300 	X_SC_PII_OSI_M           = 65
   3301 	X_SC_T_IOV_MAX           = 66
   3302 
   3303 	X_SC_THREADS                      = 67
   3304 	X_SC_THREAD_SAFE_FUNCTIONS        = 68
   3305 	X_SC_GETGR_R_SIZE_MAX             = 69
   3306 	X_SC_GETPW_R_SIZE_MAX             = 70
   3307 	X_SC_LOGIN_NAME_MAX               = 71
   3308 	X_SC_TTY_NAME_MAX                 = 72
   3309 	X_SC_THREAD_DESTRUCTOR_ITERATIONS = 73
   3310 	X_SC_THREAD_KEYS_MAX              = 74
   3311 	X_SC_THREAD_STACK_MIN             = 75
   3312 	X_SC_THREAD_THREADS_MAX           = 76
   3313 	X_SC_THREAD_ATTR_STACKADDR        = 77
   3314 	X_SC_THREAD_ATTR_STACKSIZE        = 78
   3315 	X_SC_THREAD_PRIORITY_SCHEDULING   = 79
   3316 	X_SC_THREAD_PRIO_INHERIT          = 80
   3317 	X_SC_THREAD_PRIO_PROTECT          = 81
   3318 	X_SC_THREAD_PROCESS_SHARED        = 82
   3319 
   3320 	X_SC_NPROCESSORS_CONF = 83
   3321 	X_SC_NPROCESSORS_ONLN = 84
   3322 	X_SC_PHYS_PAGES       = 85
   3323 	X_SC_AVPHYS_PAGES     = 86
   3324 	X_SC_ATEXIT_MAX       = 87
   3325 	X_SC_PASS_MAX         = 88
   3326 
   3327 	X_SC_XOPEN_VERSION     = 89
   3328 	X_SC_XOPEN_XCU_VERSION = 90
   3329 	X_SC_XOPEN_UNIX        = 91
   3330 	X_SC_XOPEN_CRYPT       = 92
   3331 	X_SC_XOPEN_ENH_I18N    = 93
   3332 	X_SC_XOPEN_SHM         = 94
   3333 
   3334 	X_SC_2_CHAR_TERM = 95
   3335 	X_SC_2_C_VERSION = 96
   3336 	X_SC_2_UPE       = 97
   3337 
   3338 	X_SC_XOPEN_XPG2 = 98
   3339 	X_SC_XOPEN_XPG3 = 99
   3340 	X_SC_XOPEN_XPG4 = 100
   3341 
   3342 	X_SC_CHAR_BIT   = 101
   3343 	X_SC_CHAR_MAX   = 102
   3344 	X_SC_CHAR_MIN   = 103
   3345 	X_SC_INT_MAX    = 104
   3346 	X_SC_INT_MIN    = 105
   3347 	X_SC_LONG_BIT   = 106
   3348 	X_SC_WORD_BIT   = 107
   3349 	X_SC_MB_LEN_MAX = 108
   3350 	X_SC_NZERO      = 109
   3351 	X_SC_SSIZE_MAX  = 110
   3352 	X_SC_SCHAR_MAX  = 111
   3353 	X_SC_SCHAR_MIN  = 112
   3354 	X_SC_SHRT_MAX   = 113
   3355 	X_SC_SHRT_MIN   = 114
   3356 	X_SC_UCHAR_MAX  = 115
   3357 	X_SC_UINT_MAX   = 116
   3358 	X_SC_ULONG_MAX  = 117
   3359 	X_SC_USHRT_MAX  = 118
   3360 
   3361 	X_SC_NL_ARGMAX  = 119
   3362 	X_SC_NL_LANGMAX = 120
   3363 	X_SC_NL_MSGMAX  = 121
   3364 	X_SC_NL_NMAX    = 122
   3365 	X_SC_NL_SETMAX  = 123
   3366 	X_SC_NL_TEXTMAX = 124
   3367 
   3368 	X_SC_XBS5_ILP32_OFF32  = 125
   3369 	X_SC_XBS5_ILP32_OFFBIG = 126
   3370 	X_SC_XBS5_LP64_OFF64   = 127
   3371 	X_SC_XBS5_LPBIG_OFFBIG = 128
   3372 
   3373 	X_SC_XOPEN_LEGACY           = 129
   3374 	X_SC_XOPEN_REALTIME         = 130
   3375 	X_SC_XOPEN_REALTIME_THREADS = 131
   3376 
   3377 	X_SC_ADVISORY_INFO          = 132
   3378 	X_SC_BARRIERS               = 133
   3379 	X_SC_BASE                   = 134
   3380 	X_SC_C_LANG_SUPPORT         = 135
   3381 	X_SC_C_LANG_SUPPORT_R       = 136
   3382 	X_SC_CLOCK_SELECTION        = 137
   3383 	X_SC_CPUTIME                = 138
   3384 	X_SC_THREAD_CPUTIME         = 139
   3385 	X_SC_DEVICE_IO              = 140
   3386 	X_SC_DEVICE_SPECIFIC        = 141
   3387 	X_SC_DEVICE_SPECIFIC_R      = 142
   3388 	X_SC_FD_MGMT                = 143
   3389 	X_SC_FIFO                   = 144
   3390 	X_SC_PIPE                   = 145
   3391 	X_SC_FILE_ATTRIBUTES        = 146
   3392 	X_SC_FILE_LOCKING           = 147
   3393 	X_SC_FILE_SYSTEM            = 148
   3394 	X_SC_MONOTONIC_CLOCK        = 149
   3395 	X_SC_MULTI_PROCESS          = 150
   3396 	X_SC_SINGLE_PROCESS         = 151
   3397 	X_SC_NETWORKING             = 152
   3398 	X_SC_READER_WRITER_LOCKS    = 153
   3399 	X_SC_SPIN_LOCKS             = 154
   3400 	X_SC_REGEXP                 = 155
   3401 	X_SC_REGEX_VERSION          = 156
   3402 	X_SC_SHELL                  = 157
   3403 	X_SC_SIGNALS                = 158
   3404 	X_SC_SPAWN                  = 159
   3405 	X_SC_SPORADIC_SERVER        = 160
   3406 	X_SC_THREAD_SPORADIC_SERVER = 161
   3407 	X_SC_SYSTEM_DATABASE        = 162
   3408 	X_SC_SYSTEM_DATABASE_R      = 163
   3409 	X_SC_TIMEOUTS               = 164
   3410 	X_SC_TYPED_MEMORY_OBJECTS   = 165
   3411 	X_SC_USER_GROUPS            = 166
   3412 	X_SC_USER_GROUPS_R          = 167
   3413 	X_SC_2_PBS                  = 168
   3414 	X_SC_2_PBS_ACCOUNTING       = 169
   3415 	X_SC_2_PBS_LOCATE           = 170
   3416 	X_SC_2_PBS_MESSAGE          = 171
   3417 	X_SC_2_PBS_TRACK            = 172
   3418 	X_SC_SYMLOOP_MAX            = 173
   3419 	X_SC_STREAMS                = 174
   3420 	X_SC_2_PBS_CHECKPOINT       = 175
   3421 
   3422 	X_SC_V6_ILP32_OFF32  = 176
   3423 	X_SC_V6_ILP32_OFFBIG = 177
   3424 	X_SC_V6_LP64_OFF64   = 178
   3425 	X_SC_V6_LPBIG_OFFBIG = 179
   3426 
   3427 	X_SC_HOST_NAME_MAX      = 180
   3428 	X_SC_TRACE              = 181
   3429 	X_SC_TRACE_EVENT_FILTER = 182
   3430 	X_SC_TRACE_INHERIT      = 183
   3431 	X_SC_TRACE_LOG          = 184
   3432 
   3433 	X_SC_LEVEL1_ICACHE_SIZE     = 185
   3434 	X_SC_LEVEL1_ICACHE_ASSOC    = 186
   3435 	X_SC_LEVEL1_ICACHE_LINESIZE = 187
   3436 	X_SC_LEVEL1_DCACHE_SIZE     = 188
   3437 	X_SC_LEVEL1_DCACHE_ASSOC    = 189
   3438 	X_SC_LEVEL1_DCACHE_LINESIZE = 190
   3439 	X_SC_LEVEL2_CACHE_SIZE      = 191
   3440 	X_SC_LEVEL2_CACHE_ASSOC     = 192
   3441 	X_SC_LEVEL2_CACHE_LINESIZE  = 193
   3442 	X_SC_LEVEL3_CACHE_SIZE      = 194
   3443 	X_SC_LEVEL3_CACHE_ASSOC     = 195
   3444 	X_SC_LEVEL3_CACHE_LINESIZE  = 196
   3445 	X_SC_LEVEL4_CACHE_SIZE      = 197
   3446 	X_SC_LEVEL4_CACHE_ASSOC     = 198
   3447 	X_SC_LEVEL4_CACHE_LINESIZE  = 199
   3448 
   3449 	X_SC_IPV6        = 235
   3450 	X_SC_RAW_SOCKETS = 236
   3451 
   3452 	X_SC_V7_ILP32_OFF32  = 237
   3453 	X_SC_V7_ILP32_OFFBIG = 238
   3454 	X_SC_V7_LP64_OFF64   = 239
   3455 	X_SC_V7_LPBIG_OFFBIG = 240
   3456 
   3457 	X_SC_SS_REPL_MAX = 241
   3458 
   3459 	X_SC_TRACE_EVENT_NAME_MAX = 242
   3460 	X_SC_TRACE_NAME_MAX       = 243
   3461 	X_SC_TRACE_SYS_MAX        = 244
   3462 	X_SC_TRACE_USER_EVENT_MAX = 245
   3463 
   3464 	X_SC_XOPEN_STREAMS = 246
   3465 
   3466 	X_SC_THREAD_ROBUST_PRIO_INHERIT = 247
   3467 	X_SC_THREAD_ROBUST_PRIO_PROTECT = 248
   3468 )
   3469 
   3470 const (
   3471 	F_OWNER_TID  = 0
   3472 	F_OWNER_PID  = 1
   3473 	F_OWNER_PGRP = 2
   3474 	F_OWNER_GID  = 2
   3475 )
   3476 
   3477 const (
   3478 	P_ALL  = 0
   3479 	P_PID  = 1
   3480 	P_PGID = 2
   3481 )
   3482 
   3483 const (
   3484 	RTLD_DL_SYMENT = 1
   3485 
   3486 	RTLD_DL_LINKMAP = 2
   3487 )
   3488 
   3489 const (
   3490 	RTLD_DI_LMID = 1
   3491 
   3492 	RTLD_DI_LINKMAP = 2
   3493 
   3494 	RTLD_DI_CONFIGADDR = 3
   3495 
   3496 	RTLD_DI_SERINFO     = 4
   3497 	RTLD_DI_SERINFOSIZE = 5
   3498 
   3499 	RTLD_DI_ORIGIN = 6
   3500 
   3501 	RTLD_DI_PROFILENAME = 7
   3502 	RTLD_DI_PROFILEOUT  = 8
   3503 
   3504 	RTLD_DI_TLS_MODID = 9
   3505 
   3506 	RTLD_DI_TLS_DATA = 10
   3507 
   3508 	RTLD_DI_MAX = 10
   3509 )
   3510 
   3511 const (
   3512 	FP_INT_UPWARD            = 0
   3513 	FP_INT_DOWNWARD          = 1
   3514 	FP_INT_TOWARDZERO        = 2
   3515 	FP_INT_TONEARESTFROMZERO = 3
   3516 	FP_INT_TONEAREST         = 4
   3517 )
   3518 
   3519 const (
   3520 	FP_NAN       = 0
   3521 	FP_INFINITE  = 1
   3522 	FP_ZERO      = 2
   3523 	FP_SUBNORMAL = 3
   3524 	FP_NORMAL    = 4
   3525 )
   3526 
   3527 const (
   3528 	ITIMER_REAL = 0
   3529 
   3530 	ITIMER_VIRTUAL = 1
   3531 
   3532 	ITIMER_PROF = 2
   3533 )
   3534 
   3535 type Ptrdiff_t = int32
   3536 
   3537 type Size_t = uint32
   3538 
   3539 type Wchar_t = uint32
   3540 
   3541 type X__builtin_va_list = uintptr
   3542 type X__float128 = float64
   3543 
   3544 type X__gnuc_va_list = X__builtin_va_list
   3545 
   3546 // The macro _VA_LIST_ is the same thing used by this file in Ultrix.
   3547 //
   3548 //	But on BSD NET2 we must not test or define or undef it.
   3549 //	(Note that the comments in NET 2's ansi.h
   3550 //	are incorrect for _VA_LIST_--see stdio.h!)
   3551 //
   3552 // The macro _VA_LIST_DEFINED is used in Windows NT 3.5
   3553 // The macro _VA_LIST is used in SCO Unix 3.2.
   3554 // The macro _VA_LIST_T_H is used in the Bull dpx2
   3555 // The macro __va_list__ is used by BeOS.
   3556 type Va_list = X__gnuc_va_list
   3557 
   3558 // CAPI3REF: Run-Time Library Version Numbers
   3559 // KEYWORDS: sqlite3_version sqlite3_sourceid
   3560 //
   3561 // These interfaces provide the same information as the [SQLITE_VERSION],
   3562 // [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
   3563 // but are associated with the library instead of the header file.  ^(Cautious
   3564 // programmers might include assert() statements in their application to
   3565 // verify that values returned by these interfaces match the macros in
   3566 // the header, and thus ensure that the application is
   3567 // compiled with matching library and header files.
   3568 //
   3569 //	assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
   3570 //	assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
   3571 //	assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
   3572 //
   3573 // ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
   3574 // macro.  ^The sqlite3_libversion() function returns a pointer to the
   3575 // to the sqlite3_version[] string constant.  The sqlite3_libversion()
   3576 // function is provided for use in DLLs since DLL users usually do not have
   3577 // direct access to string constants within the DLL.  ^The
   3578 // sqlite3_libversion_number() function returns an integer equal to
   3579 // [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns
   3580 // a pointer to a string constant whose value is the same as the
   3581 // [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built
   3582 // using an edited copy of [the amalgamation], then the last four characters
   3583 // of the hash might be different from [SQLITE_SOURCE_ID].)^
   3584 //
   3585 // See also: [sqlite_version()] and [sqlite_source_id()].
   3586 var Xsqlite3_version = *(*[7]uint8)(unsafe.Pointer(ts))
   3587 
   3588 type sqlite3 = struct {
   3589 	FpVfs                   uintptr
   3590 	FpVdbe                  uintptr
   3591 	FpDfltColl              uintptr
   3592 	Fmutex                  uintptr
   3593 	FaDb                    uintptr
   3594 	FnDb                    int32
   3595 	FmDbFlags               U32
   3596 	F__ccgo_pad1            [4]byte
   3597 	Fflags                  U64
   3598 	FlastRowid              I64
   3599 	FszMmap                 I64
   3600 	FnSchemaLock            U32
   3601 	FopenFlags              uint32
   3602 	FerrCode                int32
   3603 	FerrByteOffset          int32
   3604 	FerrMask                int32
   3605 	FiSysErrno              int32
   3606 	FdbOptFlags             U32
   3607 	Fenc                    U8
   3608 	FautoCommit             U8
   3609 	Ftemp_store             U8
   3610 	FmallocFailed           U8
   3611 	FbBenignMalloc          U8
   3612 	FdfltLockMode           U8
   3613 	FnextAutovac            int8
   3614 	FsuppressErr            U8
   3615 	FvtabOnConflict         U8
   3616 	FisTransactionSavepoint U8
   3617 	FmTrace                 U8
   3618 	FnoSharedCache          U8
   3619 	FnSqlExec               U8
   3620 	FeOpenState             U8
   3621 	F__ccgo_pad2            [2]byte
   3622 	FnextPagesize           int32
   3623 	FnChange                I64
   3624 	FnTotalChange           I64
   3625 	FaLimit                 [12]int32
   3626 	FnMaxSorterMmap         int32
   3627 	Finit                   struct {
   3628 		FnewTnum       Pgno
   3629 		FiDb           U8
   3630 		Fbusy          U8
   3631 		F__ccgo_pad1   [2]byte
   3632 		ForphanTrigger uint8
   3633 		F__ccgo_pad2   [3]byte
   3634 		FazInit        uintptr
   3635 	}
   3636 	FnVdbeActive        int32
   3637 	FnVdbeRead          int32
   3638 	FnVdbeWrite         int32
   3639 	FnVdbeExec          int32
   3640 	FnVDestroy          int32
   3641 	FnExtension         int32
   3642 	FaExtension         uintptr
   3643 	Ftrace              struct{ FxLegacy uintptr }
   3644 	FpTraceArg          uintptr
   3645 	FxProfile           uintptr
   3646 	FpProfileArg        uintptr
   3647 	FpCommitArg         uintptr
   3648 	FxCommitCallback    uintptr
   3649 	FpRollbackArg       uintptr
   3650 	FxRollbackCallback  uintptr
   3651 	FpUpdateArg         uintptr
   3652 	FxUpdateCallback    uintptr
   3653 	FpAutovacPagesArg   uintptr
   3654 	FxAutovacDestr      uintptr
   3655 	FxAutovacPages      uintptr
   3656 	FpParse             uintptr
   3657 	FpPreUpdateArg      uintptr
   3658 	FxPreUpdateCallback uintptr
   3659 	FpPreUpdate         uintptr
   3660 	FxWalCallback       uintptr
   3661 	FpWalArg            uintptr
   3662 	FxCollNeeded        uintptr
   3663 	FxCollNeeded16      uintptr
   3664 	FpCollNeededArg     uintptr
   3665 	FpErr               uintptr
   3666 	F__ccgo_pad3        [4]byte
   3667 	Fu1                 struct {
   3668 		F__ccgo_pad1   [0]uint64
   3669 		FisInterrupted int32
   3670 		F__ccgo_pad2   [4]byte
   3671 	}
   3672 	Flookaside           Lookaside
   3673 	FxAuth               Sqlite3_xauth
   3674 	FpAuthArg            uintptr
   3675 	FxProgress           uintptr
   3676 	FpProgressArg        uintptr
   3677 	FnProgressOps        uint32
   3678 	FnVTrans             int32
   3679 	FaModule             Hash
   3680 	FpVtabCtx            uintptr
   3681 	FaVTrans             uintptr
   3682 	FpDisconnect         uintptr
   3683 	FaFunc               Hash
   3684 	FaCollSeq            Hash
   3685 	FbusyHandler         BusyHandler
   3686 	FaDbStatic           [2]Db
   3687 	FpSavepoint          uintptr
   3688 	FnAnalysisLimit      int32
   3689 	FbusyTimeout         int32
   3690 	FnSavepoint          int32
   3691 	FnStatement          int32
   3692 	FnDeferredCons       I64
   3693 	FnDeferredImmCons    I64
   3694 	FpnBytesFreed        uintptr
   3695 	FpBlockingConnection uintptr
   3696 	FpUnlockConnection   uintptr
   3697 	FpUnlockArg          uintptr
   3698 	FxUnlockNotify       uintptr
   3699 	FpNextBlocked        uintptr
   3700 }
   3701 
   3702 // CAPI3REF: Database Connection Handle
   3703 // KEYWORDS: {database connection} {database connections}
   3704 //
   3705 // Each open SQLite database is represented by a pointer to an instance of
   3706 // the opaque structure named "sqlite3".  It is useful to think of an sqlite3
   3707 // pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and
   3708 // [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
   3709 // and [sqlite3_close_v2()] are its destructors.  There are many other
   3710 // interfaces (such as
   3711 // [sqlite3_prepare_v2()], [sqlite3_create_function()], and
   3712 // [sqlite3_busy_timeout()] to name but three) that are methods on an
   3713 // sqlite3 object.
   3714 type Sqlite3 = sqlite3
   3715 
   3716 // CAPI3REF: 64-Bit Integer Types
   3717 // KEYWORDS: sqlite_int64 sqlite_uint64
   3718 //
   3719 // Because there is no cross-platform way to specify 64-bit integer types
   3720 // SQLite includes typedefs for 64-bit signed and unsigned integers.
   3721 //
   3722 // The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
   3723 // The sqlite_int64 and sqlite_uint64 types are supported for backwards
   3724 // compatibility only.
   3725 //
   3726 // ^The sqlite3_int64 and sqlite_int64 types can store integer values
   3727 // between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
   3728 // sqlite3_uint64 and sqlite_uint64 types can store integer values
   3729 // between 0 and +18446744073709551615 inclusive.
   3730 type Sqlite_int64 = int64
   3731 type Sqlite_uint64 = uint64
   3732 type Sqlite3_int64 = Sqlite_int64
   3733 type Sqlite3_uint64 = Sqlite_uint64
   3734 
   3735 // The type for a callback function.
   3736 // This is legacy and deprecated.  It is included for historical
   3737 // compatibility and is not documented.
   3738 type Sqlite3_callback = uintptr
   3739 
   3740 type sqlite3_file = struct{ FpMethods uintptr }
   3741 
   3742 // CAPI3REF: OS Interface Open File Handle
   3743 //
   3744 // An [sqlite3_file] object represents an open file in the
   3745 // [sqlite3_vfs | OS interface layer].  Individual OS interface
   3746 // implementations will
   3747 // want to subclass this object by appending additional fields
   3748 // for their own use.  The pMethods entry is a pointer to an
   3749 // [sqlite3_io_methods] object that defines methods for performing
   3750 // I/O operations on the open file.
   3751 type Sqlite3_file = sqlite3_file
   3752 type sqlite3_io_methods = struct {
   3753 	FiVersion               int32
   3754 	FxClose                 uintptr
   3755 	FxRead                  uintptr
   3756 	FxWrite                 uintptr
   3757 	FxTruncate              uintptr
   3758 	FxSync                  uintptr
   3759 	FxFileSize              uintptr
   3760 	FxLock                  uintptr
   3761 	FxUnlock                uintptr
   3762 	FxCheckReservedLock     uintptr
   3763 	FxFileControl           uintptr
   3764 	FxSectorSize            uintptr
   3765 	FxDeviceCharacteristics uintptr
   3766 	FxShmMap                uintptr
   3767 	FxShmLock               uintptr
   3768 	FxShmBarrier            uintptr
   3769 	FxShmUnmap              uintptr
   3770 	FxFetch                 uintptr
   3771 	FxUnfetch               uintptr
   3772 }
   3773 
   3774 // CAPI3REF: OS Interface File Virtual Methods Object
   3775 //
   3776 // Every file opened by the [sqlite3_vfs.xOpen] method populates an
   3777 // [sqlite3_file] object (or, more commonly, a subclass of the
   3778 // [sqlite3_file] object) with a pointer to an instance of this object.
   3779 // This object defines the methods used to perform various operations
   3780 // against the open file represented by the [sqlite3_file] object.
   3781 //
   3782 // If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
   3783 // to a non-NULL pointer, then the sqlite3_io_methods.xClose method
   3784 // may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The
   3785 // only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
   3786 // is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
   3787 // to NULL.
   3788 //
   3789 // The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
   3790 // [SQLITE_SYNC_FULL].  The first choice is the normal fsync().
   3791 // The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]
   3792 // flag may be ORed in to indicate that only the data of the file
   3793 // and not its inode needs to be synced.
   3794 //
   3795 // The integer values to xLock() and xUnlock() are one of
   3796 // <ul>
   3797 // <li> [SQLITE_LOCK_NONE],
   3798 // <li> [SQLITE_LOCK_SHARED],
   3799 // <li> [SQLITE_LOCK_RESERVED],
   3800 // <li> [SQLITE_LOCK_PENDING], or
   3801 // <li> [SQLITE_LOCK_EXCLUSIVE].
   3802 // </ul>
   3803 // xLock() upgrades the database file lock.  In other words, xLock() moves the
   3804 // database file lock in the direction NONE toward EXCLUSIVE. The argument to
   3805 // xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
   3806 // SQLITE_LOCK_NONE.  If the database file lock is already at or above the
   3807 // requested lock, then the call to xLock() is a no-op.
   3808 // xUnlock() downgrades the database file lock to either SHARED or NONE.
   3809 //
   3810 //	If the lock is already at or below the requested lock state, then the call
   3811 //
   3812 // to xUnlock() is a no-op.
   3813 // The xCheckReservedLock() method checks whether any database connection,
   3814 // either in this process or in some other process, is holding a RESERVED,
   3815 // PENDING, or EXCLUSIVE lock on the file.  It returns true
   3816 // if such a lock exists and false otherwise.
   3817 //
   3818 // The xFileControl() method is a generic interface that allows custom
   3819 // VFS implementations to directly control an open file using the
   3820 // [sqlite3_file_control()] interface.  The second "op" argument is an
   3821 // integer opcode.  The third argument is a generic pointer intended to
   3822 // point to a structure that may contain arguments or space in which to
   3823 // write return values.  Potential uses for xFileControl() might be
   3824 // functions to enable blocking locks with timeouts, to change the
   3825 // locking strategy (for example to use dot-file locks), to inquire
   3826 // about the status of a lock, or to break stale locks.  The SQLite
   3827 // core reserves all opcodes less than 100 for its own use.
   3828 // A [file control opcodes | list of opcodes] less than 100 is available.
   3829 // Applications that define a custom xFileControl method should use opcodes
   3830 // greater than 100 to avoid conflicts.  VFS implementations should
   3831 // return [SQLITE_NOTFOUND] for file control opcodes that they do not
   3832 // recognize.
   3833 //
   3834 // The xSectorSize() method returns the sector size of the
   3835 // device that underlies the file.  The sector size is the
   3836 // minimum write that can be performed without disturbing
   3837 // other bytes in the file.  The xDeviceCharacteristics()
   3838 // method returns a bit vector describing behaviors of the
   3839 // underlying device:
   3840 //
   3841 // <ul>
   3842 // <li> [SQLITE_IOCAP_ATOMIC]
   3843 // <li> [SQLITE_IOCAP_ATOMIC512]
   3844 // <li> [SQLITE_IOCAP_ATOMIC1K]
   3845 // <li> [SQLITE_IOCAP_ATOMIC2K]
   3846 // <li> [SQLITE_IOCAP_ATOMIC4K]
   3847 // <li> [SQLITE_IOCAP_ATOMIC8K]
   3848 // <li> [SQLITE_IOCAP_ATOMIC16K]
   3849 // <li> [SQLITE_IOCAP_ATOMIC32K]
   3850 // <li> [SQLITE_IOCAP_ATOMIC64K]
   3851 // <li> [SQLITE_IOCAP_SAFE_APPEND]
   3852 // <li> [SQLITE_IOCAP_SEQUENTIAL]
   3853 // <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]
   3854 // <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
   3855 // <li> [SQLITE_IOCAP_IMMUTABLE]
   3856 // <li> [SQLITE_IOCAP_BATCH_ATOMIC]
   3857 // </ul>
   3858 //
   3859 // The SQLITE_IOCAP_ATOMIC property means that all writes of
   3860 // any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
   3861 // mean that writes of blocks that are nnn bytes in size and
   3862 // are aligned to an address which is an integer multiple of
   3863 // nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
   3864 // that when data is appended to a file, the data is appended
   3865 // first then the size of the file is extended, never the other
   3866 // way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
   3867 // information is written to disk in the same order as calls
   3868 // to xWrite().
   3869 //
   3870 // If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
   3871 // in the unread portions of the buffer with zeros.  A VFS that
   3872 // fails to zero-fill short reads might seem to work.  However,
   3873 // failure to zero-fill short reads will eventually lead to
   3874 // database corruption.
   3875 type Sqlite3_io_methods = sqlite3_io_methods
   3876 
   3877 type sqlite3_api_routines = struct {
   3878 	Faggregate_context      uintptr
   3879 	Faggregate_count        uintptr
   3880 	Fbind_blob              uintptr
   3881 	Fbind_double            uintptr
   3882 	Fbind_int               uintptr
   3883 	Fbind_int64             uintptr
   3884 	Fbind_null              uintptr
   3885 	Fbind_parameter_count   uintptr
   3886 	Fbind_parameter_index   uintptr
   3887 	Fbind_parameter_name    uintptr
   3888 	Fbind_text              uintptr
   3889 	Fbind_text16            uintptr
   3890 	Fbind_value             uintptr
   3891 	Fbusy_handler           uintptr
   3892 	Fbusy_timeout           uintptr
   3893 	Fchanges                uintptr
   3894 	Fclose                  uintptr
   3895 	Fcollation_needed       uintptr
   3896 	Fcollation_needed16     uintptr
   3897 	Fcolumn_blob            uintptr
   3898 	Fcolumn_bytes           uintptr
   3899 	Fcolumn_bytes16         uintptr
   3900 	Fcolumn_count           uintptr
   3901 	Fcolumn_database_name   uintptr
   3902 	Fcolumn_database_name16 uintptr
   3903 	Fcolumn_decltype        uintptr
   3904 	Fcolumn_decltype16      uintptr
   3905 	Fcolumn_double          uintptr
   3906 	Fcolumn_int             uintptr
   3907 	Fcolumn_int64           uintptr
   3908 	Fcolumn_name            uintptr
   3909 	Fcolumn_name16          uintptr
   3910 	Fcolumn_origin_name     uintptr
   3911 	Fcolumn_origin_name16   uintptr
   3912 	Fcolumn_table_name      uintptr
   3913 	Fcolumn_table_name16    uintptr
   3914 	Fcolumn_text            uintptr
   3915 	Fcolumn_text16          uintptr
   3916 	Fcolumn_type            uintptr
   3917 	Fcolumn_value           uintptr
   3918 	Fcommit_hook            uintptr
   3919 	Fcomplete               uintptr
   3920 	Fcomplete16             uintptr
   3921 	Fcreate_collation       uintptr
   3922 	Fcreate_collation16     uintptr
   3923 	Fcreate_function        uintptr
   3924 	Fcreate_function16      uintptr
   3925 	Fcreate_module          uintptr
   3926 	Fdata_count             uintptr
   3927 	Fdb_handle              uintptr
   3928 	Fdeclare_vtab           uintptr
   3929 	Fenable_shared_cache    uintptr
   3930 	Ferrcode                uintptr
   3931 	Ferrmsg                 uintptr
   3932 	Ferrmsg16               uintptr
   3933 	Fexec                   uintptr
   3934 	Fexpired                uintptr
   3935 	Ffinalize               uintptr
   3936 	Ffree                   uintptr
   3937 	Ffree_table             uintptr
   3938 	Fget_autocommit         uintptr
   3939 	Fget_auxdata            uintptr
   3940 	Fget_table              uintptr
   3941 	Fglobal_recover         uintptr
   3942 	Finterruptx             uintptr
   3943 	Flast_insert_rowid      uintptr
   3944 	Flibversion             uintptr
   3945 	Flibversion_number      uintptr
   3946 	Fmalloc                 uintptr
   3947 	Fmprintf                uintptr
   3948 	Fopen                   uintptr
   3949 	Fopen16                 uintptr
   3950 	Fprepare                uintptr
   3951 	Fprepare16              uintptr
   3952 	Fprofile                uintptr
   3953 	Fprogress_handler       uintptr
   3954 	Frealloc                uintptr
   3955 	Freset                  uintptr
   3956 	Fresult_blob            uintptr
   3957 	Fresult_double          uintptr
   3958 	Fresult_error           uintptr
   3959 	Fresult_error16         uintptr
   3960 	Fresult_int             uintptr
   3961 	Fresult_int64           uintptr
   3962 	Fresult_null            uintptr
   3963 	Fresult_text            uintptr
   3964 	Fresult_text16          uintptr
   3965 	Fresult_text16be        uintptr
   3966 	Fresult_text16le        uintptr
   3967 	Fresult_value           uintptr
   3968 	Frollback_hook          uintptr
   3969 	Fset_authorizer         uintptr
   3970 	Fset_auxdata            uintptr
   3971 	Fxsnprintf              uintptr
   3972 	Fstep                   uintptr
   3973 	Ftable_column_metadata  uintptr
   3974 	Fthread_cleanup         uintptr
   3975 	Ftotal_changes          uintptr
   3976 	Ftrace                  uintptr
   3977 	Ftransfer_bindings      uintptr
   3978 	Fupdate_hook            uintptr
   3979 	Fuser_data              uintptr
   3980 	Fvalue_blob             uintptr
   3981 	Fvalue_bytes            uintptr
   3982 	Fvalue_bytes16          uintptr
   3983 	Fvalue_double           uintptr
   3984 	Fvalue_int              uintptr
   3985 	Fvalue_int64            uintptr
   3986 	Fvalue_numeric_type     uintptr
   3987 	Fvalue_text             uintptr
   3988 	Fvalue_text16           uintptr
   3989 	Fvalue_text16be         uintptr
   3990 	Fvalue_text16le         uintptr
   3991 	Fvalue_type             uintptr
   3992 	Fvmprintf               uintptr
   3993 	Foverload_function      uintptr
   3994 	Fprepare_v2             uintptr
   3995 	Fprepare16_v2           uintptr
   3996 	Fclear_bindings         uintptr
   3997 	Fcreate_module_v2       uintptr
   3998 	Fbind_zeroblob          uintptr
   3999 	Fblob_bytes             uintptr
   4000 	Fblob_close             uintptr
   4001 	Fblob_open              uintptr
   4002 	Fblob_read              uintptr
   4003 	Fblob_write             uintptr
   4004 	Fcreate_collation_v2    uintptr
   4005 	Ffile_control           uintptr
   4006 	Fmemory_highwater       uintptr
   4007 	Fmemory_used            uintptr
   4008 	Fmutex_alloc            uintptr
   4009 	Fmutex_enter            uintptr
   4010 	Fmutex_free             uintptr
   4011 	Fmutex_leave            uintptr
   4012 	Fmutex_try              uintptr
   4013 	Fopen_v2                uintptr
   4014 	Frelease_memory         uintptr
   4015 	Fresult_error_nomem     uintptr
   4016 	Fresult_error_toobig    uintptr
   4017 	Fsleep                  uintptr
   4018 	Fsoft_heap_limit        uintptr
   4019 	Fvfs_find               uintptr
   4020 	Fvfs_register           uintptr
   4021 	Fvfs_unregister         uintptr
   4022 	Fxthreadsafe            uintptr
   4023 	Fresult_zeroblob        uintptr
   4024 	Fresult_error_code      uintptr
   4025 	Ftest_control           uintptr
   4026 	Frandomness             uintptr
   4027 	Fcontext_db_handle      uintptr
   4028 	Fextended_result_codes  uintptr
   4029 	Flimit                  uintptr
   4030 	Fnext_stmt              uintptr
   4031 	Fsql                    uintptr
   4032 	Fstatus                 uintptr
   4033 	Fbackup_finish          uintptr
   4034 	Fbackup_init            uintptr
   4035 	Fbackup_pagecount       uintptr
   4036 	Fbackup_remaining       uintptr
   4037 	Fbackup_step            uintptr
   4038 	Fcompileoption_get      uintptr
   4039 	Fcompileoption_used     uintptr
   4040 	Fcreate_function_v2     uintptr
   4041 	Fdb_config              uintptr
   4042 	Fdb_mutex               uintptr
   4043 	Fdb_status              uintptr
   4044 	Fextended_errcode       uintptr
   4045 	Flog                    uintptr
   4046 	Fsoft_heap_limit64      uintptr
   4047 	Fsourceid               uintptr
   4048 	Fstmt_status            uintptr
   4049 	Fstrnicmp               uintptr
   4050 	Funlock_notify          uintptr
   4051 	Fwal_autocheckpoint     uintptr
   4052 	Fwal_checkpoint         uintptr
   4053 	Fwal_hook               uintptr
   4054 	Fblob_reopen            uintptr
   4055 	Fvtab_config            uintptr
   4056 	Fvtab_on_conflict       uintptr
   4057 	Fclose_v2               uintptr
   4058 	Fdb_filename            uintptr
   4059 	Fdb_readonly            uintptr
   4060 	Fdb_release_memory      uintptr
   4061 	Ferrstr                 uintptr
   4062 	Fstmt_busy              uintptr
   4063 	Fstmt_readonly          uintptr
   4064 	Fstricmp                uintptr
   4065 	Furi_boolean            uintptr
   4066 	Furi_int64              uintptr
   4067 	Furi_parameter          uintptr
   4068 	Fxvsnprintf             uintptr
   4069 	Fwal_checkpoint_v2      uintptr
   4070 	Fauto_extension         uintptr
   4071 	Fbind_blob64            uintptr
   4072 	Fbind_text64            uintptr
   4073 	Fcancel_auto_extension  uintptr
   4074 	Fload_extension         uintptr
   4075 	Fmalloc64               uintptr
   4076 	Fmsize                  uintptr
   4077 	Frealloc64              uintptr
   4078 	Freset_auto_extension   uintptr
   4079 	Fresult_blob64          uintptr
   4080 	Fresult_text64          uintptr
   4081 	Fstrglob                uintptr
   4082 	Fvalue_dup              uintptr
   4083 	Fvalue_free             uintptr
   4084 	Fresult_zeroblob64      uintptr
   4085 	Fbind_zeroblob64        uintptr
   4086 	Fvalue_subtype          uintptr
   4087 	Fresult_subtype         uintptr
   4088 	Fstatus64               uintptr
   4089 	Fstrlike                uintptr
   4090 	Fdb_cacheflush          uintptr
   4091 	Fsystem_errno           uintptr
   4092 	Ftrace_v2               uintptr
   4093 	Fexpanded_sql           uintptr
   4094 	Fset_last_insert_rowid  uintptr
   4095 	Fprepare_v3             uintptr
   4096 	Fprepare16_v3           uintptr
   4097 	Fbind_pointer           uintptr
   4098 	Fresult_pointer         uintptr
   4099 	Fvalue_pointer          uintptr
   4100 	Fvtab_nochange          uintptr
   4101 	Fvalue_nochange         uintptr
   4102 	Fvtab_collation         uintptr
   4103 	Fkeyword_count          uintptr
   4104 	Fkeyword_name           uintptr
   4105 	Fkeyword_check          uintptr
   4106 	Fstr_new                uintptr
   4107 	Fstr_finish             uintptr
   4108 	Fstr_appendf            uintptr
   4109 	Fstr_vappendf           uintptr
   4110 	Fstr_append             uintptr
   4111 	Fstr_appendall          uintptr
   4112 	Fstr_appendchar         uintptr
   4113 	Fstr_reset              uintptr
   4114 	Fstr_errcode            uintptr
   4115 	Fstr_length             uintptr
   4116 	Fstr_value              uintptr
   4117 	Fcreate_window_function uintptr
   4118 	Fnormalized_sql         uintptr
   4119 	Fstmt_isexplain         uintptr
   4120 	Fvalue_frombind         uintptr
   4121 	Fdrop_modules           uintptr
   4122 	Fhard_heap_limit64      uintptr
   4123 	Furi_key                uintptr
   4124 	Ffilename_database      uintptr
   4125 	Ffilename_journal       uintptr
   4126 	Ffilename_wal           uintptr
   4127 	Fcreate_filename        uintptr
   4128 	Ffree_filename          uintptr
   4129 	Fdatabase_file_object   uintptr
   4130 	Ftxn_state              uintptr
   4131 	Fchanges64              uintptr
   4132 	Ftotal_changes64        uintptr
   4133 	Fautovacuum_pages       uintptr
   4134 	Ferror_offset           uintptr
   4135 	Fvtab_rhs_value         uintptr
   4136 	Fvtab_distinct          uintptr
   4137 	Fvtab_in                uintptr
   4138 	Fvtab_in_first          uintptr
   4139 	Fvtab_in_next           uintptr
   4140 	Fdeserialize            uintptr
   4141 	Fserialize              uintptr
   4142 	Fdb_name                uintptr
   4143 	Fvalue_encoding         uintptr
   4144 	Fis_interrupted         uintptr
   4145 }
   4146 
   4147 // CAPI3REF: Loadable Extension Thunk
   4148 //
   4149 // A pointer to the opaque sqlite3_api_routines structure is passed as
   4150 // the third parameter to entry points of [loadable extensions].  This
   4151 // structure must be typedefed in order to work around compiler warnings
   4152 // on some platforms.
   4153 type Sqlite3_api_routines = sqlite3_api_routines
   4154 
   4155 // CAPI3REF: File Name
   4156 //
   4157 // Type [sqlite3_filename] is used by SQLite to pass filenames to the
   4158 // xOpen method of a [VFS]. It may be cast to (const char*) and treated
   4159 // as a normal, nul-terminated, UTF-8 buffer containing the filename, but
   4160 // may also be passed to special APIs such as:
   4161 //
   4162 // <ul>
   4163 // <li>  sqlite3_filename_database()
   4164 // <li>  sqlite3_filename_journal()
   4165 // <li>  sqlite3_filename_wal()
   4166 // <li>  sqlite3_uri_parameter()
   4167 // <li>  sqlite3_uri_boolean()
   4168 // <li>  sqlite3_uri_int64()
   4169 // <li>  sqlite3_uri_key()
   4170 // </ul>
   4171 type Sqlite3_filename = uintptr
   4172 
   4173 type sqlite3_vfs = struct {
   4174 	FiVersion          int32
   4175 	FszOsFile          int32
   4176 	FmxPathname        int32
   4177 	FpNext             uintptr
   4178 	FzName             uintptr
   4179 	FpAppData          uintptr
   4180 	FxOpen             uintptr
   4181 	FxDelete           uintptr
   4182 	FxAccess           uintptr
   4183 	FxFullPathname     uintptr
   4184 	FxDlOpen           uintptr
   4185 	FxDlError          uintptr
   4186 	FxDlSym            uintptr
   4187 	FxDlClose          uintptr
   4188 	FxRandomness       uintptr
   4189 	FxSleep            uintptr
   4190 	FxCurrentTime      uintptr
   4191 	FxGetLastError     uintptr
   4192 	FxCurrentTimeInt64 uintptr
   4193 	FxSetSystemCall    uintptr
   4194 	FxGetSystemCall    uintptr
   4195 	FxNextSystemCall   uintptr
   4196 }
   4197 
   4198 // CAPI3REF: OS Interface Object
   4199 //
   4200 // An instance of the sqlite3_vfs object defines the interface between
   4201 // the SQLite core and the underlying operating system.  The "vfs"
   4202 // in the name of the object stands for "virtual file system".  See
   4203 // the [VFS | VFS documentation] for further information.
   4204 //
   4205 // The VFS interface is sometimes extended by adding new methods onto
   4206 // the end.  Each time such an extension occurs, the iVersion field
   4207 // is incremented.  The iVersion value started out as 1 in
   4208 // SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
   4209 // with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
   4210 // to 3 with SQLite [version 3.7.6] on [dateof:3.7.6].  Additional fields
   4211 // may be appended to the sqlite3_vfs object and the iVersion value
   4212 // may increase again in future versions of SQLite.
   4213 // Note that due to an oversight, the structure
   4214 // of the sqlite3_vfs object changed in the transition from
   4215 // SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
   4216 // and yet the iVersion field was not increased.
   4217 //
   4218 // The szOsFile field is the size of the subclassed [sqlite3_file]
   4219 // structure used by this VFS.  mxPathname is the maximum length of
   4220 // a pathname in this VFS.
   4221 //
   4222 // Registered sqlite3_vfs objects are kept on a linked list formed by
   4223 // the pNext pointer.  The [sqlite3_vfs_register()]
   4224 // and [sqlite3_vfs_unregister()] interfaces manage this list
   4225 // in a thread-safe way.  The [sqlite3_vfs_find()] interface
   4226 // searches the list.  Neither the application code nor the VFS
   4227 // implementation should use the pNext pointer.
   4228 //
   4229 // The pNext field is the only field in the sqlite3_vfs
   4230 // structure that SQLite will ever modify.  SQLite will only access
   4231 // or modify this field while holding a particular static mutex.
   4232 // The application should never modify anything within the sqlite3_vfs
   4233 // object once the object has been registered.
   4234 //
   4235 // The zName field holds the name of the VFS module.  The name must
   4236 // be unique across all VFS modules.
   4237 //
   4238 // [[sqlite3_vfs.xOpen]]
   4239 // ^SQLite guarantees that the zFilename parameter to xOpen
   4240 // is either a NULL pointer or string obtained
   4241 // from xFullPathname() with an optional suffix added.
   4242 // ^If a suffix is added to the zFilename parameter, it will
   4243 // consist of a single "-" character followed by no more than
   4244 // 11 alphanumeric and/or "-" characters.
   4245 // ^SQLite further guarantees that
   4246 // the string will be valid and unchanged until xClose() is
   4247 // called. Because of the previous sentence,
   4248 // the [sqlite3_file] can safely store a pointer to the
   4249 // filename if it needs to remember the filename for some reason.
   4250 // If the zFilename parameter to xOpen is a NULL pointer then xOpen
   4251 // must invent its own temporary name for the file.  ^Whenever the
   4252 // xFilename parameter is NULL it will also be the case that the
   4253 // flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
   4254 //
   4255 // The flags argument to xOpen() includes all bits set in
   4256 // the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]
   4257 // or [sqlite3_open16()] is used, then flags includes at least
   4258 // [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
   4259 // If xOpen() opens a file read-only then it sets *pOutFlags to
   4260 // include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
   4261 //
   4262 // ^(SQLite will also add one of the following flags to the xOpen()
   4263 // call, depending on the object being opened:
   4264 //
   4265 // <ul>
   4266 // <li>  [SQLITE_OPEN_MAIN_DB]
   4267 // <li>  [SQLITE_OPEN_MAIN_JOURNAL]
   4268 // <li>  [SQLITE_OPEN_TEMP_DB]
   4269 // <li>  [SQLITE_OPEN_TEMP_JOURNAL]
   4270 // <li>  [SQLITE_OPEN_TRANSIENT_DB]
   4271 // <li>  [SQLITE_OPEN_SUBJOURNAL]
   4272 // <li>  [SQLITE_OPEN_SUPER_JOURNAL]
   4273 // <li>  [SQLITE_OPEN_WAL]
   4274 // </ul>)^
   4275 //
   4276 // The file I/O implementation can use the object type flags to
   4277 // change the way it deals with files.  For example, an application
   4278 // that does not care about crash recovery or rollback might make
   4279 // the open of a journal file a no-op.  Writes to this journal would
   4280 // also be no-ops, and any attempt to read the journal would return
   4281 // SQLITE_IOERR.  Or the implementation might recognize that a database
   4282 // file will be doing page-aligned sector reads and writes in a random
   4283 // order and set up its I/O subsystem accordingly.
   4284 //
   4285 // SQLite might also add one of the following flags to the xOpen method:
   4286 //
   4287 // <ul>
   4288 // <li> [SQLITE_OPEN_DELETEONCLOSE]
   4289 // <li> [SQLITE_OPEN_EXCLUSIVE]
   4290 // </ul>
   4291 //
   4292 // The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
   4293 // deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
   4294 // will be set for TEMP databases and their journals, transient
   4295 // databases, and subjournals.
   4296 //
   4297 // ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
   4298 // with the [SQLITE_OPEN_CREATE] flag, which are both directly
   4299 // analogous to the O_EXCL and O_CREAT flags of the POSIX open()
   4300 // API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
   4301 // SQLITE_OPEN_CREATE, is used to indicate that file should always
   4302 // be created, and that it is an error if it already exists.
   4303 // It is <i>not</i> used to indicate the file should be opened
   4304 // for exclusive access.
   4305 //
   4306 // ^At least szOsFile bytes of memory are allocated by SQLite
   4307 // to hold the [sqlite3_file] structure passed as the third
   4308 // argument to xOpen.  The xOpen method does not have to
   4309 // allocate the structure; it should just fill it in.  Note that
   4310 // the xOpen method must set the sqlite3_file.pMethods to either
   4311 // a valid [sqlite3_io_methods] object or to NULL.  xOpen must do
   4312 // this even if the open fails.  SQLite expects that the sqlite3_file.pMethods
   4313 // element will be valid after xOpen returns regardless of the success
   4314 // or failure of the xOpen call.
   4315 //
   4316 // [[sqlite3_vfs.xAccess]]
   4317 // ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
   4318 // to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
   4319 // test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
   4320 // to test whether a file is at least readable.  The SQLITE_ACCESS_READ
   4321 // flag is never actually used and is not implemented in the built-in
   4322 // VFSes of SQLite.  The file is named by the second argument and can be a
   4323 // directory. The xAccess method returns [SQLITE_OK] on success or some
   4324 // non-zero error code if there is an I/O error or if the name of
   4325 // the file given in the second argument is illegal.  If SQLITE_OK
   4326 // is returned, then non-zero or zero is written into *pResOut to indicate
   4327 // whether or not the file is accessible.
   4328 //
   4329 // ^SQLite will always allocate at least mxPathname+1 bytes for the
   4330 // output buffer xFullPathname.  The exact size of the output buffer
   4331 // is also passed as a parameter to both  methods. If the output buffer
   4332 // is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
   4333 // handled as a fatal error by SQLite, vfs implementations should endeavor
   4334 // to prevent this by setting mxPathname to a sufficiently large value.
   4335 //
   4336 // The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
   4337 // interfaces are not strictly a part of the filesystem, but they are
   4338 // included in the VFS structure for completeness.
   4339 // The xRandomness() function attempts to return nBytes bytes
   4340 // of good-quality randomness into zOut.  The return value is
   4341 // the actual number of bytes of randomness obtained.
   4342 // The xSleep() method causes the calling thread to sleep for at
   4343 // least the number of microseconds given.  ^The xCurrentTime()
   4344 // method returns a Julian Day Number for the current date and time as
   4345 // a floating point value.
   4346 // ^The xCurrentTimeInt64() method returns, as an integer, the Julian
   4347 // Day Number multiplied by 86400000 (the number of milliseconds in
   4348 // a 24-hour day).
   4349 // ^SQLite will use the xCurrentTimeInt64() method to get the current
   4350 // date and time if that method is available (if iVersion is 2 or
   4351 // greater and the function pointer is not NULL) and will fall back
   4352 // to xCurrentTime() if xCurrentTimeInt64() is unavailable.
   4353 //
   4354 // ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
   4355 // are not used by the SQLite core.  These optional interfaces are provided
   4356 // by some VFSes to facilitate testing of the VFS code. By overriding
   4357 // system calls with functions under its control, a test program can
   4358 // simulate faults and error conditions that would otherwise be difficult
   4359 // or impossible to induce.  The set of system calls that can be overridden
   4360 // varies from one VFS to another, and from one version of the same VFS to the
   4361 // next.  Applications that use these interfaces must be prepared for any
   4362 // or all of these interfaces to be NULL or for their behavior to change
   4363 // from one release to the next.  Applications must not attempt to access
   4364 // any of these methods if the iVersion of the VFS is less than 3.
   4365 type Sqlite3_vfs = sqlite3_vfs
   4366 type Sqlite3_syscall_ptr = uintptr
   4367 
   4368 type sqlite3_mem_methods = struct {
   4369 	FxMalloc   uintptr
   4370 	FxFree     uintptr
   4371 	FxRealloc  uintptr
   4372 	FxSize     uintptr
   4373 	FxRoundup  uintptr
   4374 	FxInit     uintptr
   4375 	FxShutdown uintptr
   4376 	FpAppData  uintptr
   4377 }
   4378 
   4379 // CAPI3REF: Memory Allocation Routines
   4380 //
   4381 // An instance of this object defines the interface between SQLite
   4382 // and low-level memory allocation routines.
   4383 //
   4384 // This object is used in only one place in the SQLite interface.
   4385 // A pointer to an instance of this object is the argument to
   4386 // [sqlite3_config()] when the configuration option is
   4387 // [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].
   4388 // By creating an instance of this object
   4389 // and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
   4390 // during configuration, an application can specify an alternative
   4391 // memory allocation subsystem for SQLite to use for all of its
   4392 // dynamic memory needs.
   4393 //
   4394 // Note that SQLite comes with several [built-in memory allocators]
   4395 // that are perfectly adequate for the overwhelming majority of applications
   4396 // and that this object is only useful to a tiny minority of applications
   4397 // with specialized memory allocation requirements.  This object is
   4398 // also used during testing of SQLite in order to specify an alternative
   4399 // memory allocator that simulates memory out-of-memory conditions in
   4400 // order to verify that SQLite recovers gracefully from such
   4401 // conditions.
   4402 //
   4403 // The xMalloc, xRealloc, and xFree methods must work like the
   4404 // malloc(), realloc() and free() functions from the standard C library.
   4405 // ^SQLite guarantees that the second argument to
   4406 // xRealloc is always a value returned by a prior call to xRoundup.
   4407 //
   4408 // xSize should return the allocated size of a memory allocation
   4409 // previously obtained from xMalloc or xRealloc.  The allocated size
   4410 // is always at least as big as the requested size but may be larger.
   4411 //
   4412 // The xRoundup method returns what would be the allocated size of
   4413 // a memory allocation given a particular requested size.  Most memory
   4414 // allocators round up memory allocations at least to the next multiple
   4415 // of 8.  Some allocators round up to a larger multiple or to a power of 2.
   4416 // Every memory allocation request coming in through [sqlite3_malloc()]
   4417 // or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0,
   4418 // that causes the corresponding memory allocation to fail.
   4419 //
   4420 // The xInit method initializes the memory allocator.  For example,
   4421 // it might allocate any required mutexes or initialize internal data
   4422 // structures.  The xShutdown method is invoked (indirectly) by
   4423 // [sqlite3_shutdown()] and should deallocate any resources acquired
   4424 // by xInit.  The pAppData pointer is used as the only parameter to
   4425 // xInit and xShutdown.
   4426 //
   4427 // SQLite holds the [SQLITE_MUTEX_STATIC_MAIN] mutex when it invokes
   4428 // the xInit method, so the xInit method need not be threadsafe.  The
   4429 // xShutdown method is only called from [sqlite3_shutdown()] so it does
   4430 // not need to be threadsafe either.  For all other methods, SQLite
   4431 // holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
   4432 // [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
   4433 // it is by default) and so the methods are automatically serialized.
   4434 // However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
   4435 // methods must be threadsafe or else make their own arrangements for
   4436 // serialization.
   4437 //
   4438 // SQLite will never invoke xInit() more than once without an intervening
   4439 // call to xShutdown().
   4440 type Sqlite3_mem_methods = sqlite3_mem_methods
   4441 
   4442 type sqlite3_value = struct {
   4443 	Fu        struct{ Fr float64 }
   4444 	Fz        uintptr
   4445 	Fn        int32
   4446 	Fflags    U16
   4447 	Fenc      U8
   4448 	FeSubtype U8
   4449 	Fdb       uintptr
   4450 	FszMalloc int32
   4451 	FuTemp    U32
   4452 	FzMalloc  uintptr
   4453 	FxDel     uintptr
   4454 }
   4455 
   4456 // CAPI3REF: Dynamically Typed Value Object
   4457 // KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
   4458 //
   4459 // SQLite uses the sqlite3_value object to represent all values
   4460 // that can be stored in a database table. SQLite uses dynamic typing
   4461 // for the values it stores.  ^Values stored in sqlite3_value objects
   4462 // can be integers, floating point values, strings, BLOBs, or NULL.
   4463 //
   4464 // An sqlite3_value object may be either "protected" or "unprotected".
   4465 // Some interfaces require a protected sqlite3_value.  Other interfaces
   4466 // will accept either a protected or an unprotected sqlite3_value.
   4467 // Every interface that accepts sqlite3_value arguments specifies
   4468 // whether or not it requires a protected sqlite3_value.  The
   4469 // [sqlite3_value_dup()] interface can be used to construct a new
   4470 // protected sqlite3_value from an unprotected sqlite3_value.
   4471 //
   4472 // The terms "protected" and "unprotected" refer to whether or not
   4473 // a mutex is held.  An internal mutex is held for a protected
   4474 // sqlite3_value object but no mutex is held for an unprotected
   4475 // sqlite3_value object.  If SQLite is compiled to be single-threaded
   4476 // (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
   4477 // or if SQLite is run in one of reduced mutex modes
   4478 // [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]
   4479 // then there is no distinction between protected and unprotected
   4480 // sqlite3_value objects and they can be used interchangeably.  However,
   4481 // for maximum code portability it is recommended that applications
   4482 // still make the distinction between protected and unprotected
   4483 // sqlite3_value objects even when not strictly required.
   4484 //
   4485 // ^The sqlite3_value objects that are passed as parameters into the
   4486 // implementation of [application-defined SQL functions] are protected.
   4487 // ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
   4488 // are protected.
   4489 // ^The sqlite3_value object returned by
   4490 // [sqlite3_column_value()] is unprotected.
   4491 // Unprotected sqlite3_value objects may only be used as arguments
   4492 // to [sqlite3_result_value()], [sqlite3_bind_value()], and
   4493 // [sqlite3_value_dup()].
   4494 // The [sqlite3_value_blob | sqlite3_value_type()] family of
   4495 // interfaces require protected sqlite3_value objects.
   4496 type Sqlite3_value = sqlite3_value
   4497 
   4498 type sqlite3_context = struct {
   4499 	FpOut        uintptr
   4500 	FpFunc       uintptr
   4501 	FpMem        uintptr
   4502 	FpVdbe       uintptr
   4503 	FiOp         int32
   4504 	FisError     int32
   4505 	Fenc         U8
   4506 	FskipFlag    U8
   4507 	Fargc        U8
   4508 	F__ccgo_pad1 [1]byte
   4509 	Fargv        [1]uintptr
   4510 }
   4511 
   4512 // CAPI3REF: SQL Function Context Object
   4513 //
   4514 // The context in which an SQL function executes is stored in an
   4515 // sqlite3_context object.  ^A pointer to an sqlite3_context object
   4516 // is always first parameter to [application-defined SQL functions].
   4517 // The application-defined SQL function implementation will pass this
   4518 // pointer through into calls to [sqlite3_result_int | sqlite3_result()],
   4519 // [sqlite3_aggregate_context()], [sqlite3_user_data()],
   4520 // [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
   4521 // and/or [sqlite3_set_auxdata()].
   4522 type Sqlite3_context = sqlite3_context
   4523 
   4524 // CAPI3REF: Constants Defining Special Destructor Behavior
   4525 //
   4526 // These are special values for the destructor that is passed in as the
   4527 // final argument to routines like [sqlite3_result_blob()].  ^If the destructor
   4528 // argument is SQLITE_STATIC, it means that the content pointer is constant
   4529 // and will never change.  It does not need to be destroyed.  ^The
   4530 // SQLITE_TRANSIENT value means that the content will likely change in
   4531 // the near future and that SQLite should make its own private copy of
   4532 // the content before returning.
   4533 //
   4534 // The typedef is necessary to work around problems in certain
   4535 // C++ compilers.
   4536 type Sqlite3_destructor_type = uintptr
   4537 
   4538 type sqlite3_vtab = struct {
   4539 	FpModule uintptr
   4540 	FnRef    int32
   4541 	FzErrMsg uintptr
   4542 }
   4543 
   4544 // Structures used by the virtual table interface
   4545 type Sqlite3_vtab = sqlite3_vtab
   4546 type sqlite3_index_info = struct {
   4547 	FnConstraint      int32
   4548 	FaConstraint      uintptr
   4549 	FnOrderBy         int32
   4550 	FaOrderBy         uintptr
   4551 	FaConstraintUsage uintptr
   4552 	FidxNum           int32
   4553 	FidxStr           uintptr
   4554 	FneedToFreeIdxStr int32
   4555 	ForderByConsumed  int32
   4556 	F__ccgo_pad1      [4]byte
   4557 	FestimatedCost    float64
   4558 	FestimatedRows    Sqlite3_int64
   4559 	FidxFlags         int32
   4560 	F__ccgo_pad2      [4]byte
   4561 	FcolUsed          Sqlite3_uint64
   4562 }
   4563 
   4564 type Sqlite3_index_info = sqlite3_index_info
   4565 type sqlite3_vtab_cursor = struct{ FpVtab uintptr }
   4566 
   4567 type Sqlite3_vtab_cursor = sqlite3_vtab_cursor
   4568 type sqlite3_module = struct {
   4569 	FiVersion      int32
   4570 	FxCreate       uintptr
   4571 	FxConnect      uintptr
   4572 	FxBestIndex    uintptr
   4573 	FxDisconnect   uintptr
   4574 	FxDestroy      uintptr
   4575 	FxOpen         uintptr
   4576 	FxClose        uintptr
   4577 	FxFilter       uintptr
   4578 	FxNext         uintptr
   4579 	FxEof          uintptr
   4580 	FxColumn       uintptr
   4581 	FxRowid        uintptr
   4582 	FxUpdate       uintptr
   4583 	FxBegin        uintptr
   4584 	FxSync         uintptr
   4585 	FxCommit       uintptr
   4586 	FxRollback     uintptr
   4587 	FxFindFunction uintptr
   4588 	FxRename       uintptr
   4589 	FxSavepoint    uintptr
   4590 	FxRelease      uintptr
   4591 	FxRollbackTo   uintptr
   4592 	FxShadowName   uintptr
   4593 }
   4594 
   4595 type Sqlite3_module = sqlite3_module
   4596 
   4597 type sqlite3_index_constraint = struct {
   4598 	FiColumn     int32
   4599 	Fop          uint8
   4600 	Fusable      uint8
   4601 	F__ccgo_pad1 [2]byte
   4602 	FiTermOffset int32
   4603 }
   4604 
   4605 type sqlite3_index_orderby = struct {
   4606 	FiColumn     int32
   4607 	Fdesc        uint8
   4608 	F__ccgo_pad1 [3]byte
   4609 }
   4610 
   4611 type sqlite3_index_constraint_usage = struct {
   4612 	FargvIndex   int32
   4613 	Fomit        uint8
   4614 	F__ccgo_pad1 [3]byte
   4615 }
   4616 
   4617 type sqlite3_mutex_methods = struct {
   4618 	FxMutexInit    uintptr
   4619 	FxMutexEnd     uintptr
   4620 	FxMutexAlloc   uintptr
   4621 	FxMutexFree    uintptr
   4622 	FxMutexEnter   uintptr
   4623 	FxMutexTry     uintptr
   4624 	FxMutexLeave   uintptr
   4625 	FxMutexHeld    uintptr
   4626 	FxMutexNotheld uintptr
   4627 }
   4628 
   4629 // CAPI3REF: Mutex Methods Object
   4630 //
   4631 // An instance of this structure defines the low-level routines
   4632 // used to allocate and use mutexes.
   4633 //
   4634 // Usually, the default mutex implementations provided by SQLite are
   4635 // sufficient, however the application has the option of substituting a custom
   4636 // implementation for specialized deployments or systems for which SQLite
   4637 // does not provide a suitable implementation. In this case, the application
   4638 // creates and populates an instance of this structure to pass
   4639 // to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
   4640 // Additionally, an instance of this structure can be used as an
   4641 // output variable when querying the system for the current mutex
   4642 // implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
   4643 //
   4644 // ^The xMutexInit method defined by this structure is invoked as
   4645 // part of system initialization by the sqlite3_initialize() function.
   4646 // ^The xMutexInit routine is called by SQLite exactly once for each
   4647 // effective call to [sqlite3_initialize()].
   4648 //
   4649 // ^The xMutexEnd method defined by this structure is invoked as
   4650 // part of system shutdown by the sqlite3_shutdown() function. The
   4651 // implementation of this method is expected to release all outstanding
   4652 // resources obtained by the mutex methods implementation, especially
   4653 // those obtained by the xMutexInit method.  ^The xMutexEnd()
   4654 // interface is invoked exactly once for each call to [sqlite3_shutdown()].
   4655 //
   4656 // ^(The remaining seven methods defined by this structure (xMutexAlloc,
   4657 // xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
   4658 // xMutexNotheld) implement the following interfaces (respectively):
   4659 //
   4660 // <ul>
   4661 //
   4662 //	<li>  [sqlite3_mutex_alloc()] </li>
   4663 //	<li>  [sqlite3_mutex_free()] </li>
   4664 //	<li>  [sqlite3_mutex_enter()] </li>
   4665 //	<li>  [sqlite3_mutex_try()] </li>
   4666 //	<li>  [sqlite3_mutex_leave()] </li>
   4667 //	<li>  [sqlite3_mutex_held()] </li>
   4668 //	<li>  [sqlite3_mutex_notheld()] </li>
   4669 //
   4670 // </ul>)^
   4671 //
   4672 // The only difference is that the public sqlite3_XXX functions enumerated
   4673 // above silently ignore any invocations that pass a NULL pointer instead
   4674 // of a valid mutex handle. The implementations of the methods defined
   4675 // by this structure are not required to handle this case. The results
   4676 // of passing a NULL pointer instead of a valid mutex handle are undefined
   4677 // (i.e. it is acceptable to provide an implementation that segfaults if
   4678 // it is passed a NULL pointer).
   4679 //
   4680 // The xMutexInit() method must be threadsafe.  It must be harmless to
   4681 // invoke xMutexInit() multiple times within the same process and without
   4682 // intervening calls to xMutexEnd().  Second and subsequent calls to
   4683 // xMutexInit() must be no-ops.
   4684 //
   4685 // xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
   4686 // and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
   4687 // allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
   4688 // memory allocation for a fast or recursive mutex.
   4689 //
   4690 // ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
   4691 // called, but only if the prior call to xMutexInit returned SQLITE_OK.
   4692 // If xMutexInit fails in any way, it is expected to clean up after itself
   4693 // prior to returning.
   4694 type Sqlite3_mutex_methods = sqlite3_mutex_methods
   4695 
   4696 type sqlite3_str = struct {
   4697 	Fdb          uintptr
   4698 	FzText       uintptr
   4699 	FnAlloc      U32
   4700 	FmxAlloc     U32
   4701 	FnChar       U32
   4702 	FaccError    U8
   4703 	FprintfFlags U8
   4704 	F__ccgo_pad1 [2]byte
   4705 }
   4706 
   4707 // CAPI3REF: Dynamic String Object
   4708 // KEYWORDS: {dynamic string}
   4709 //
   4710 // An instance of the sqlite3_str object contains a dynamically-sized
   4711 // string under construction.
   4712 //
   4713 // The lifecycle of an sqlite3_str object is as follows:
   4714 // <ol>
   4715 // <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
   4716 // <li> ^Text is appended to the sqlite3_str object using various
   4717 // methods, such as [sqlite3_str_appendf()].
   4718 // <li> ^The sqlite3_str object is destroyed and the string it created
   4719 // is returned using the [sqlite3_str_finish()] interface.
   4720 // </ol>
   4721 type Sqlite3_str = sqlite3_str
   4722 
   4723 type sqlite3_pcache_page = struct {
   4724 	FpBuf   uintptr
   4725 	FpExtra uintptr
   4726 }
   4727 
   4728 // CAPI3REF: Custom Page Cache Object
   4729 //
   4730 // The sqlite3_pcache_page object represents a single page in the
   4731 // page cache.  The page cache will allocate instances of this
   4732 // object.  Various methods of the page cache use pointers to instances
   4733 // of this object as parameters or as their return value.
   4734 //
   4735 // See [sqlite3_pcache_methods2] for additional information.
   4736 type Sqlite3_pcache_page = sqlite3_pcache_page
   4737 
   4738 type sqlite3_pcache_methods2 = struct {
   4739 	FiVersion   int32
   4740 	FpArg       uintptr
   4741 	FxInit      uintptr
   4742 	FxShutdown  uintptr
   4743 	FxCreate    uintptr
   4744 	FxCachesize uintptr
   4745 	FxPagecount uintptr
   4746 	FxFetch     uintptr
   4747 	FxUnpin     uintptr
   4748 	FxRekey     uintptr
   4749 	FxTruncate  uintptr
   4750 	FxDestroy   uintptr
   4751 	FxShrink    uintptr
   4752 }
   4753 
   4754 // CAPI3REF: Application Defined Page Cache.
   4755 // KEYWORDS: {page cache}
   4756 //
   4757 // ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can
   4758 // register an alternative page cache implementation by passing in an
   4759 // instance of the sqlite3_pcache_methods2 structure.)^
   4760 // In many applications, most of the heap memory allocated by
   4761 // SQLite is used for the page cache.
   4762 // By implementing a
   4763 // custom page cache using this API, an application can better control
   4764 // the amount of memory consumed by SQLite, the way in which
   4765 // that memory is allocated and released, and the policies used to
   4766 // determine exactly which parts of a database file are cached and for
   4767 // how long.
   4768 //
   4769 // The alternative page cache mechanism is an
   4770 // extreme measure that is only needed by the most demanding applications.
   4771 // The built-in page cache is recommended for most uses.
   4772 //
   4773 // ^(The contents of the sqlite3_pcache_methods2 structure are copied to an
   4774 // internal buffer by SQLite within the call to [sqlite3_config].  Hence
   4775 // the application may discard the parameter after the call to
   4776 // [sqlite3_config()] returns.)^
   4777 //
   4778 // [[the xInit() page cache method]]
   4779 // ^(The xInit() method is called once for each effective
   4780 // call to [sqlite3_initialize()])^
   4781 // (usually only once during the lifetime of the process). ^(The xInit()
   4782 // method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
   4783 // The intent of the xInit() method is to set up global data structures
   4784 // required by the custom page cache implementation.
   4785 // ^(If the xInit() method is NULL, then the
   4786 // built-in default page cache is used instead of the application defined
   4787 // page cache.)^
   4788 //
   4789 // [[the xShutdown() page cache method]]
   4790 // ^The xShutdown() method is called by [sqlite3_shutdown()].
   4791 // It can be used to clean up
   4792 // any outstanding resources before process shutdown, if required.
   4793 // ^The xShutdown() method may be NULL.
   4794 //
   4795 // ^SQLite automatically serializes calls to the xInit method,
   4796 // so the xInit method need not be threadsafe.  ^The
   4797 // xShutdown method is only called from [sqlite3_shutdown()] so it does
   4798 // not need to be threadsafe either.  All other methods must be threadsafe
   4799 // in multithreaded applications.
   4800 //
   4801 // ^SQLite will never invoke xInit() more than once without an intervening
   4802 // call to xShutdown().
   4803 //
   4804 // [[the xCreate() page cache methods]]
   4805 // ^SQLite invokes the xCreate() method to construct a new cache instance.
   4806 // SQLite will typically create one cache instance for each open database file,
   4807 // though this is not guaranteed. ^The
   4808 // first parameter, szPage, is the size in bytes of the pages that must
   4809 // be allocated by the cache.  ^szPage will always a power of two.  ^The
   4810 // second parameter szExtra is a number of bytes of extra storage
   4811 // associated with each page cache entry.  ^The szExtra parameter will
   4812 // a number less than 250.  SQLite will use the
   4813 // extra szExtra bytes on each page to store metadata about the underlying
   4814 // database page on disk.  The value passed into szExtra depends
   4815 // on the SQLite version, the target platform, and how SQLite was compiled.
   4816 // ^The third argument to xCreate(), bPurgeable, is true if the cache being
   4817 // created will be used to cache database pages of a file stored on disk, or
   4818 // false if it is used for an in-memory database. The cache implementation
   4819 // does not have to do anything special based with the value of bPurgeable;
   4820 // it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will
   4821 // never invoke xUnpin() except to deliberately delete a page.
   4822 // ^In other words, calls to xUnpin() on a cache with bPurgeable set to
   4823 // false will always have the "discard" flag set to true.
   4824 // ^Hence, a cache created with bPurgeable false will
   4825 // never contain any unpinned pages.
   4826 //
   4827 // [[the xCachesize() page cache method]]
   4828 // ^(The xCachesize() method may be called at any time by SQLite to set the
   4829 // suggested maximum cache-size (number of pages stored by) the cache
   4830 // instance passed as the first argument. This is the value configured using
   4831 // the SQLite "[PRAGMA cache_size]" command.)^  As with the bPurgeable
   4832 // parameter, the implementation is not required to do anything with this
   4833 // value; it is advisory only.
   4834 //
   4835 // [[the xPagecount() page cache methods]]
   4836 // The xPagecount() method must return the number of pages currently
   4837 // stored in the cache, both pinned and unpinned.
   4838 //
   4839 // [[the xFetch() page cache methods]]
   4840 // The xFetch() method locates a page in the cache and returns a pointer to
   4841 // an sqlite3_pcache_page object associated with that page, or a NULL pointer.
   4842 // The pBuf element of the returned sqlite3_pcache_page object will be a
   4843 // pointer to a buffer of szPage bytes used to store the content of a
   4844 // single database page.  The pExtra element of sqlite3_pcache_page will be
   4845 // a pointer to the szExtra bytes of extra storage that SQLite has requested
   4846 // for each entry in the page cache.
   4847 //
   4848 // The page to be fetched is determined by the key. ^The minimum key value
   4849 // is 1.  After it has been retrieved using xFetch, the page is considered
   4850 // to be "pinned".
   4851 //
   4852 // If the requested page is already in the page cache, then the page cache
   4853 // implementation must return a pointer to the page buffer with its content
   4854 // intact.  If the requested page is not already in the cache, then the
   4855 // cache implementation should use the value of the createFlag
   4856 // parameter to help it determined what action to take:
   4857 //
   4858 // <table border=1 width=85% align=center>
   4859 // <tr><th> createFlag <th> Behavior when page is not already in cache
   4860 // <tr><td> 0 <td> Do not allocate a new page.  Return NULL.
   4861 // <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
   4862 //
   4863 //	Otherwise return NULL.
   4864 //
   4865 // <tr><td> 2 <td> Make every effort to allocate a new page.  Only return
   4866 //
   4867 //	NULL if allocating a new page is effectively impossible.
   4868 //
   4869 // </table>
   4870 //
   4871 // ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite
   4872 // will only use a createFlag of 2 after a prior call with a createFlag of 1
   4873 // failed.)^  In between the xFetch() calls, SQLite may
   4874 // attempt to unpin one or more cache pages by spilling the content of
   4875 // pinned pages to disk and synching the operating system disk cache.
   4876 //
   4877 // [[the xUnpin() page cache method]]
   4878 // ^xUnpin() is called by SQLite with a pointer to a currently pinned page
   4879 // as its second argument.  If the third parameter, discard, is non-zero,
   4880 // then the page must be evicted from the cache.
   4881 // ^If the discard parameter is
   4882 // zero, then the page may be discarded or retained at the discretion of
   4883 // page cache implementation. ^The page cache implementation
   4884 // may choose to evict unpinned pages at any time.
   4885 //
   4886 // The cache must not perform any reference counting. A single
   4887 // call to xUnpin() unpins the page regardless of the number of prior calls
   4888 // to xFetch().
   4889 //
   4890 // [[the xRekey() page cache methods]]
   4891 // The xRekey() method is used to change the key value associated with the
   4892 // page passed as the second argument. If the cache
   4893 // previously contains an entry associated with newKey, it must be
   4894 // discarded. ^Any prior cache entry associated with newKey is guaranteed not
   4895 // to be pinned.
   4896 //
   4897 // When SQLite calls the xTruncate() method, the cache must discard all
   4898 // existing cache entries with page numbers (keys) greater than or equal
   4899 // to the value of the iLimit parameter passed to xTruncate(). If any
   4900 // of these pages are pinned, they are implicitly unpinned, meaning that
   4901 // they can be safely discarded.
   4902 //
   4903 // [[the xDestroy() page cache method]]
   4904 // ^The xDestroy() method is used to delete a cache allocated by xCreate().
   4905 // All resources associated with the specified cache should be freed. ^After
   4906 // calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
   4907 // handle invalid, and will not use it with any other sqlite3_pcache_methods2
   4908 // functions.
   4909 //
   4910 // [[the xShrink() page cache method]]
   4911 // ^SQLite invokes the xShrink() method when it wants the page cache to
   4912 // free up as much of heap memory as possible.  The page cache implementation
   4913 // is not obligated to free any memory, but well-behaved implementations should
   4914 // do their best.
   4915 type Sqlite3_pcache_methods2 = sqlite3_pcache_methods2
   4916 
   4917 type sqlite3_pcache_methods = struct {
   4918 	FpArg       uintptr
   4919 	FxInit      uintptr
   4920 	FxShutdown  uintptr
   4921 	FxCreate    uintptr
   4922 	FxCachesize uintptr
   4923 	FxPagecount uintptr
   4924 	FxFetch     uintptr
   4925 	FxUnpin     uintptr
   4926 	FxRekey     uintptr
   4927 	FxTruncate  uintptr
   4928 	FxDestroy   uintptr
   4929 }
   4930 
   4931 // This is the obsolete pcache_methods object that has now been replaced
   4932 // by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is
   4933 // retained in the header file for backwards compatibility only.
   4934 type Sqlite3_pcache_methods = sqlite3_pcache_methods
   4935 
   4936 type sqlite3_backup = struct {
   4937 	FpDestDb     uintptr
   4938 	FpDest       uintptr
   4939 	FiDestSchema U32
   4940 	FbDestLocked int32
   4941 	FiNext       Pgno
   4942 	FpSrcDb      uintptr
   4943 	FpSrc        uintptr
   4944 	Frc          int32
   4945 	FnRemaining  Pgno
   4946 	FnPagecount  Pgno
   4947 	FisAttached  int32
   4948 	FpNext       uintptr
   4949 }
   4950 
   4951 // CAPI3REF: Online Backup Object
   4952 //
   4953 // The sqlite3_backup object records state information about an ongoing
   4954 // online backup operation.  ^The sqlite3_backup object is created by
   4955 // a call to [sqlite3_backup_init()] and is destroyed by a call to
   4956 // [sqlite3_backup_finish()].
   4957 //
   4958 // See Also: [Using the SQLite Online Backup API]
   4959 type Sqlite3_backup = sqlite3_backup
   4960 
   4961 type sqlite3_snapshot = struct{ Fhidden [48]uint8 }
   4962 
   4963 // CAPI3REF: Database Snapshot
   4964 // KEYWORDS: {snapshot} {sqlite3_snapshot}
   4965 //
   4966 // An instance of the snapshot object records the state of a [WAL mode]
   4967 // database for some specific point in history.
   4968 //
   4969 // In [WAL mode], multiple [database connections] that are open on the
   4970 // same database file can each be reading a different historical version
   4971 // of the database file.  When a [database connection] begins a read
   4972 // transaction, that connection sees an unchanging copy of the database
   4973 // as it existed for the point in time when the transaction first started.
   4974 // Subsequent changes to the database from other connections are not seen
   4975 // by the reader until a new read transaction is started.
   4976 //
   4977 // The sqlite3_snapshot object records state information about an historical
   4978 // version of the database file so that it is possible to later open a new read
   4979 // transaction that sees that historical version of the database rather than
   4980 // the most recent version.
   4981 type Sqlite3_snapshot = sqlite3_snapshot
   4982 
   4983 type sqlite3_rtree_geometry = struct {
   4984 	FpContext uintptr
   4985 	FnParam   int32
   4986 	FaParam   uintptr
   4987 	FpUser    uintptr
   4988 	FxDelUser uintptr
   4989 }
   4990 
   4991 type Sqlite3_rtree_geometry = sqlite3_rtree_geometry
   4992 type sqlite3_rtree_query_info = struct {
   4993 	FpContext      uintptr
   4994 	FnParam        int32
   4995 	FaParam        uintptr
   4996 	FpUser         uintptr
   4997 	FxDelUser      uintptr
   4998 	FaCoord        uintptr
   4999 	FanQueue       uintptr
   5000 	FnCoord        int32
   5001 	FiLevel        int32
   5002 	FmxLevel       int32
   5003 	FiRowid        Sqlite3_int64
   5004 	FrParentScore  Sqlite3_rtree_dbl
   5005 	FeParentWithin int32
   5006 	FeWithin       int32
   5007 	FrScore        Sqlite3_rtree_dbl
   5008 	FapSqlParam    uintptr
   5009 	F__ccgo_pad1   [4]byte
   5010 }
   5011 
   5012 type Sqlite3_rtree_query_info = sqlite3_rtree_query_info
   5013 
   5014 // The double-precision datatype used by RTree depends on the
   5015 // SQLITE_RTREE_INT_ONLY compile-time option.
   5016 type Sqlite3_rtree_dbl = float64
   5017 
   5018 type sqlite3_session = struct {
   5019 	Fdb                uintptr
   5020 	FzDb               uintptr
   5021 	FbEnableSize       int32
   5022 	FbEnable           int32
   5023 	FbIndirect         int32
   5024 	FbAutoAttach       int32
   5025 	Frc                int32
   5026 	FpFilterCtx        uintptr
   5027 	FxTableFilter      uintptr
   5028 	F__ccgo_pad1       [4]byte
   5029 	FnMalloc           I64
   5030 	FnMaxChangesetSize I64
   5031 	FpZeroBlob         uintptr
   5032 	FpNext             uintptr
   5033 	FpTable            uintptr
   5034 	Fhook              SessionHook
   5035 }
   5036 
   5037 // CAPI3REF: Session Object Handle
   5038 //
   5039 // An instance of this object is a [session] that can be used to
   5040 // record changes to a database.
   5041 type Sqlite3_session = sqlite3_session
   5042 
   5043 type sqlite3_changeset_iter = struct {
   5044 	Fin         SessionInput
   5045 	Ftblhdr     SessionBuffer
   5046 	FbPatchset  int32
   5047 	FbInvert    int32
   5048 	FbSkipEmpty int32
   5049 	Frc         int32
   5050 	FpConflict  uintptr
   5051 	FzTab       uintptr
   5052 	FnCol       int32
   5053 	Fop         int32
   5054 	FbIndirect  int32
   5055 	FabPK       uintptr
   5056 	FapValue    uintptr
   5057 }
   5058 
   5059 // CAPI3REF: Changeset Iterator Handle
   5060 //
   5061 // An instance of this object acts as a cursor for iterating
   5062 // over the elements of a [changeset] or [patchset].
   5063 type Sqlite3_changeset_iter = sqlite3_changeset_iter
   5064 
   5065 type sqlite3_changegroup = struct {
   5066 	Frc     int32
   5067 	FbPatch int32
   5068 	FpList  uintptr
   5069 }
   5070 
   5071 // CAPI3REF: Changegroup Handle
   5072 //
   5073 // A changegroup is an object used to combine two or more
   5074 // [changesets] or [patchsets]
   5075 type Sqlite3_changegroup = sqlite3_changegroup
   5076 
   5077 type sqlite3_rebaser = struct{ Fgrp Sqlite3_changegroup }
   5078 
   5079 // CAPI3REF: Rebasing changesets
   5080 // EXPERIMENTAL
   5081 //
   5082 // Suppose there is a site hosting a database in state S0. And that
   5083 // modifications are made that move that database to state S1 and a
   5084 // changeset recorded (the "local" changeset). Then, a changeset based
   5085 // on S0 is received from another site (the "remote" changeset) and
   5086 // applied to the database. The database is then in state
   5087 // (S1+"remote"), where the exact state depends on any conflict
   5088 // resolution decisions (OMIT or REPLACE) made while applying "remote".
   5089 // Rebasing a changeset is to update it to take those conflict
   5090 // resolution decisions into account, so that the same conflicts
   5091 // do not have to be resolved elsewhere in the network.
   5092 //
   5093 // For example, if both the local and remote changesets contain an
   5094 // INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)":
   5095 //
   5096 //	local:  INSERT INTO t1 VALUES(1, 'v1');
   5097 //	remote: INSERT INTO t1 VALUES(1, 'v2');
   5098 //
   5099 // and the conflict resolution is REPLACE, then the INSERT change is
   5100 // removed from the local changeset (it was overridden). Or, if the
   5101 // conflict resolution was "OMIT", then the local changeset is modified
   5102 // to instead contain:
   5103 //
   5104 //	UPDATE t1 SET b = 'v2' WHERE a=1;
   5105 //
   5106 // Changes within the local changeset are rebased as follows:
   5107 //
   5108 // <dl>
   5109 // <dt>Local INSERT<dd>
   5110 //
   5111 //	This may only conflict with a remote INSERT. If the conflict
   5112 //	resolution was OMIT, then add an UPDATE change to the rebased
   5113 //	changeset. Or, if the conflict resolution was REPLACE, add
   5114 //	nothing to the rebased changeset.
   5115 //
   5116 // <dt>Local DELETE<dd>
   5117 //
   5118 //	This may conflict with a remote UPDATE or DELETE. In both cases the
   5119 //	only possible resolution is OMIT. If the remote operation was a
   5120 //	DELETE, then add no change to the rebased changeset. If the remote
   5121 //	operation was an UPDATE, then the old.* fields of change are updated
   5122 //	to reflect the new.* values in the UPDATE.
   5123 //
   5124 // <dt>Local UPDATE<dd>
   5125 //
   5126 //	This may conflict with a remote UPDATE or DELETE. If it conflicts
   5127 //	with a DELETE, and the conflict resolution was OMIT, then the update
   5128 //	is changed into an INSERT. Any undefined values in the new.* record
   5129 //	from the update change are filled in using the old.* values from
   5130 //	the conflicting DELETE. Or, if the conflict resolution was REPLACE,
   5131 //	the UPDATE change is simply omitted from the rebased changeset.
   5132 //
   5133 //	If conflict is with a remote UPDATE and the resolution is OMIT, then
   5134 //	the old.* values are rebased using the new.* values in the remote
   5135 //	change. Or, if the resolution is REPLACE, then the change is copied
   5136 //	into the rebased changeset with updates to columns also updated by
   5137 //	the conflicting remote UPDATE removed. If this means no columns would
   5138 //	be updated, the change is omitted.
   5139 //
   5140 // </dl>
   5141 //
   5142 // A local change may be rebased against multiple remote changes
   5143 // simultaneously. If a single key is modified by multiple remote
   5144 // changesets, they are combined as follows before the local changeset
   5145 // is rebased:
   5146 //
   5147 // <ul>
   5148 //
   5149 //	<li> If there has been one or more REPLACE resolutions on a
   5150 //	     key, it is rebased according to a REPLACE.
   5151 //
   5152 //	<li> If there have been no REPLACE resolutions on a key, then
   5153 //	     the local changeset is rebased according to the most recent
   5154 //	     of the OMIT resolutions.
   5155 //
   5156 // </ul>
   5157 //
   5158 // Note that conflict resolutions from multiple remote changesets are
   5159 // combined on a per-field basis, not per-row. This means that in the
   5160 // case of multiple remote UPDATE operations, some fields of a single
   5161 // local change may be rebased for REPLACE while others are rebased for
   5162 // OMIT.
   5163 //
   5164 // In order to rebase a local changeset, the remote changeset must first
   5165 // be applied to the local database using sqlite3changeset_apply_v2() and
   5166 // the buffer of rebase information captured. Then:
   5167 //
   5168 // <ol>
   5169 //
   5170 //	<li> An sqlite3_rebaser object is created by calling
   5171 //	     sqlite3rebaser_create().
   5172 //	<li> The new object is configured with the rebase buffer obtained from
   5173 //	     sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().
   5174 //	     If the local changeset is to be rebased against multiple remote
   5175 //	     changesets, then sqlite3rebaser_configure() should be called
   5176 //	     multiple times, in the same order that the multiple
   5177 //	     sqlite3changeset_apply_v2() calls were made.
   5178 //	<li> Each local changeset is rebased by calling sqlite3rebaser_rebase().
   5179 //	<li> The sqlite3_rebaser object is deleted by calling
   5180 //	     sqlite3rebaser_delete().
   5181 //
   5182 // </ol>
   5183 type Sqlite3_rebaser = sqlite3_rebaser
   5184 
   5185 type Fts5ExtensionApi1 = struct {
   5186 	FiVersion           int32
   5187 	FxUserData          uintptr
   5188 	FxColumnCount       uintptr
   5189 	FxRowCount          uintptr
   5190 	FxColumnTotalSize   uintptr
   5191 	FxTokenize          uintptr
   5192 	FxPhraseCount       uintptr
   5193 	FxPhraseSize        uintptr
   5194 	FxInstCount         uintptr
   5195 	FxInst              uintptr
   5196 	FxRowid             uintptr
   5197 	FxColumnText        uintptr
   5198 	FxColumnSize        uintptr
   5199 	FxQueryPhrase       uintptr
   5200 	FxSetAuxdata        uintptr
   5201 	FxGetAuxdata        uintptr
   5202 	FxPhraseFirst       uintptr
   5203 	FxPhraseNext        uintptr
   5204 	FxPhraseFirstColumn uintptr
   5205 	FxPhraseNextColumn  uintptr
   5206 }
   5207 
   5208 type Fts5ExtensionApi = Fts5ExtensionApi1
   5209 type Fts5PhraseIter1 = struct {
   5210 	Fa uintptr
   5211 	Fb uintptr
   5212 }
   5213 
   5214 type Fts5PhraseIter = Fts5PhraseIter1
   5215 
   5216 type Fts5_extension_function = uintptr
   5217 type fts5_tokenizer = struct {
   5218 	FxCreate   uintptr
   5219 	FxDelete   uintptr
   5220 	FxTokenize uintptr
   5221 }
   5222 
   5223 type Fts5_tokenizer = fts5_tokenizer
   5224 
   5225 type fts5_api = struct {
   5226 	FiVersion         int32
   5227 	FxCreateTokenizer uintptr
   5228 	FxFindTokenizer   uintptr
   5229 	FxCreateFunction  uintptr
   5230 }
   5231 
   5232 // ************************************************************************
   5233 //
   5234 // FTS5 EXTENSION REGISTRATION API
   5235 type Fts5_api = fts5_api
   5236 
   5237 // Forward declarations of structures.
   5238 type Hash1 = struct {
   5239 	Fhtsize uint32
   5240 	Fcount  uint32
   5241 	Ffirst  uintptr
   5242 	Fht     uintptr
   5243 }
   5244 
   5245 // Forward declarations of structures.
   5246 type Hash = Hash1
   5247 type HashElem1 = struct {
   5248 	Fnext uintptr
   5249 	Fprev uintptr
   5250 	Fdata uintptr
   5251 	FpKey uintptr
   5252 }
   5253 
   5254 type HashElem = HashElem1
   5255 
   5256 type _ht = struct {
   5257 	Fcount uint32
   5258 	Fchain uintptr
   5259 }
   5260 
   5261 // Convenience types.
   5262 type X__u_char = uint8
   5263 type X__u_short = uint16
   5264 type X__u_int = uint32
   5265 type X__u_long = uint32
   5266 
   5267 // Fixed-size types, underlying types depend on word size and compiler.
   5268 type X__int8_t = int8
   5269 type X__uint8_t = uint8
   5270 type X__int16_t = int16
   5271 type X__uint16_t = uint16
   5272 type X__int32_t = int32
   5273 type X__uint32_t = uint32
   5274 type X__int64_t = int64
   5275 type X__uint64_t = uint64
   5276 
   5277 // Smallest types with at least a given width.
   5278 type X__int_least8_t = X__int8_t
   5279 type X__uint_least8_t = X__uint8_t
   5280 type X__int_least16_t = X__int16_t
   5281 type X__uint_least16_t = X__uint16_t
   5282 type X__int_least32_t = X__int32_t
   5283 type X__uint_least32_t = X__uint32_t
   5284 type X__int_least64_t = X__int64_t
   5285 type X__uint_least64_t = X__uint64_t
   5286 
   5287 // quad_t is also 64 bits.
   5288 type X__quad_t = int64
   5289 type X__u_quad_t = uint64
   5290 
   5291 // Largest integral types.
   5292 type X__intmax_t = int64
   5293 type X__uintmax_t = uint64
   5294 
   5295 type X__dev_t = X__uint64_t
   5296 type X__uid_t = uint32
   5297 type X__gid_t = uint32
   5298 type X__ino_t = uint32
   5299 type X__ino64_t = X__uint64_t
   5300 type X__mode_t = uint32
   5301 type X__nlink_t = uint32
   5302 type X__off_t = int32
   5303 type X__off64_t = X__int64_t
   5304 type X__pid_t = int32
   5305 type X__fsid_t = struct{ F__val [2]int32 }
   5306 type X__clock_t = int32
   5307 type X__rlim_t = uint32
   5308 type X__rlim64_t = X__uint64_t
   5309 type X__id_t = uint32
   5310 type X__time_t = int32
   5311 type X__useconds_t = uint32
   5312 type X__suseconds_t = int32
   5313 
   5314 type X__daddr_t = int32
   5315 type X__key_t = int32
   5316 
   5317 // Clock ID used in clock and timer functions.
   5318 type X__clockid_t = int32
   5319 
   5320 // Timer ID returned by `timer_create'.
   5321 type X__timer_t = uintptr
   5322 
   5323 // Type to represent block size.
   5324 type X__blksize_t = int32
   5325 
   5326 // Type to count number of disk blocks.
   5327 type X__blkcnt_t = int32
   5328 type X__blkcnt64_t = X__int64_t
   5329 
   5330 // Type to count file system blocks.
   5331 type X__fsblkcnt_t = uint32
   5332 type X__fsblkcnt64_t = X__uint64_t
   5333 
   5334 // Type to count file system nodes.
   5335 type X__fsfilcnt_t = uint32
   5336 type X__fsfilcnt64_t = X__uint64_t
   5337 
   5338 // Type of miscellaneous file system fields.
   5339 type X__fsword_t = int32
   5340 
   5341 type X__ssize_t = int32
   5342 
   5343 // Signed long type used in system calls.
   5344 type X__syscall_slong_t = int32
   5345 
   5346 // Unsigned long type used in system calls.
   5347 type X__syscall_ulong_t = uint32
   5348 
   5349 // These few don't really vary by system, they always correspond
   5350 //
   5351 //	to one of the other defined types.
   5352 type X__loff_t = X__off64_t
   5353 type X__caddr_t = uintptr
   5354 
   5355 // Duplicates info from stdint.h but this is used in unistd.h.
   5356 type X__intptr_t = int32
   5357 
   5358 // Duplicate info from sys/socket.h.
   5359 type X__socklen_t = uint32
   5360 
   5361 // C99: An integer type that can be accessed as an atomic entity,
   5362 //
   5363 //	even in the presence of asynchronous interrupts.
   5364 //	It is not currently necessary for this to be machine-specific.
   5365 type X__sig_atomic_t = int32
   5366 
   5367 // Seconds since the Epoch, visible to user code when time_t is too
   5368 //
   5369 //	narrow only for consistency with the old way of widening too-narrow
   5370 //	types.  User code should never use __time64_t.
   5371 type X__time64_t = X__int64_t
   5372 
   5373 // Conversion state information.
   5374 type X__mbstate_t = struct {
   5375 	F__count int32
   5376 	F__value struct{ F__wch uint32 }
   5377 }
   5378 
   5379 type _G_fpos_t = struct {
   5380 	F__pos   X__off_t
   5381 	F__state X__mbstate_t
   5382 }
   5383 
   5384 // The tag name of this struct is _G_fpos_t to preserve historic
   5385 //
   5386 //	C++ mangled names for functions taking fpos_t arguments.
   5387 //	That name should not be used in new code.
   5388 type X__fpos_t = _G_fpos_t
   5389 
   5390 type _G_fpos64_t = struct {
   5391 	F__pos   X__off64_t
   5392 	F__state X__mbstate_t
   5393 }
   5394 
   5395 // The tag name of this struct is _G_fpos64_t to preserve historic
   5396 //
   5397 //	C++ mangled names for functions taking fpos_t and/or fpos64_t
   5398 //	arguments.  That name should not be used in new code.
   5399 type X__fpos64_t = _G_fpos64_t
   5400 
   5401 type _IO_FILE = struct {
   5402 	F_flags          int32
   5403 	F_IO_read_ptr    uintptr
   5404 	F_IO_read_end    uintptr
   5405 	F_IO_read_base   uintptr
   5406 	F_IO_write_base  uintptr
   5407 	F_IO_write_ptr   uintptr
   5408 	F_IO_write_end   uintptr
   5409 	F_IO_buf_base    uintptr
   5410 	F_IO_buf_end     uintptr
   5411 	F_IO_save_base   uintptr
   5412 	F_IO_backup_base uintptr
   5413 	F_IO_save_end    uintptr
   5414 	F_markers        uintptr
   5415 	F_chain          uintptr
   5416 	F_fileno         int32
   5417 	F_flags2         int32
   5418 	F_old_offset     X__off_t
   5419 	F_cur_column     uint16
   5420 	F_vtable_offset  int8
   5421 	F_shortbuf       [1]uint8
   5422 	F_lock           uintptr
   5423 	F__ccgo_pad1     [4]byte
   5424 	F_offset         X__off64_t
   5425 	F_codecvt        uintptr
   5426 	F_wide_data      uintptr
   5427 	F_freeres_list   uintptr
   5428 	F_freeres_buf    uintptr
   5429 	F__pad5          Size_t
   5430 	F_mode           int32
   5431 	F_unused2        [40]uint8
   5432 }
   5433 
   5434 type X__FILE = _IO_FILE
   5435 
   5436 // The opaque type of streams.  This is the definition used elsewhere.
   5437 type FILE = _IO_FILE
   5438 
   5439 type _IO_cookie_io_functions_t = struct {
   5440 	Fread  uintptr
   5441 	Fwrite uintptr
   5442 	Fseek  uintptr
   5443 	Fclose uintptr
   5444 }
   5445 
   5446 // The structure with the cookie function pointers.
   5447 //
   5448 //	The tag name of this struct is _IO_cookie_io_functions_t to
   5449 //	preserve historic C++ mangled names for functions taking
   5450 //	cookie_io_functions_t arguments.  That name should not be used in
   5451 //	new code.
   5452 type Cookie_io_functions_t = _IO_cookie_io_functions_t
   5453 
   5454 type Off_t = X__off64_t
   5455 type Off64_t = X__off64_t
   5456 
   5457 type Ssize_t = X__ssize_t
   5458 
   5459 // The type of the second argument to `fgetpos' and `fsetpos'.
   5460 type Fpos_t = X__fpos64_t
   5461 type Fpos64_t = X__fpos64_t
   5462 
   5463 type Idtype_t = uint32
   5464 
   5465 // Returned by `div'.
   5466 type Div_t = struct {
   5467 	Fquot int32
   5468 	Frem  int32
   5469 }
   5470 
   5471 // Returned by `ldiv'.
   5472 type Ldiv_t = struct {
   5473 	Fquot int32
   5474 	Frem  int32
   5475 }
   5476 
   5477 // Returned by `lldiv'.
   5478 type Lldiv_t = struct {
   5479 	Fquot int64
   5480 	Frem  int64
   5481 }
   5482 
   5483 type __locale_struct = struct {
   5484 	F__locales       [13]uintptr
   5485 	F__ctype_b       uintptr
   5486 	F__ctype_tolower uintptr
   5487 	F__ctype_toupper uintptr
   5488 	F__names         [13]uintptr
   5489 }
   5490 
   5491 type X__locale_t = uintptr
   5492 
   5493 type Locale_t = X__locale_t
   5494 
   5495 type U_char = X__u_char
   5496 type U_short = X__u_short
   5497 type U_int = X__u_int
   5498 type U_long = X__u_long
   5499 type Quad_t = X__quad_t
   5500 type U_quad_t = X__u_quad_t
   5501 type Fsid_t = X__fsid_t
   5502 type Loff_t = X__loff_t
   5503 
   5504 type Ino_t = X__ino64_t
   5505 type Ino64_t = X__ino64_t
   5506 
   5507 type Dev_t = X__dev_t
   5508 
   5509 type Gid_t = X__gid_t
   5510 
   5511 type Mode_t = X__mode_t
   5512 
   5513 type Nlink_t = X__nlink_t
   5514 
   5515 type Uid_t = X__uid_t
   5516 
   5517 type Pid_t = X__pid_t
   5518 
   5519 type Id_t = X__id_t
   5520 
   5521 type Daddr_t = X__daddr_t
   5522 type Caddr_t = X__caddr_t
   5523 
   5524 type Key_t = X__key_t
   5525 
   5526 // Returned by `clock'.
   5527 type Clock_t = X__clock_t
   5528 
   5529 // Clock ID used in clock and timer functions.
   5530 type Clockid_t = X__clockid_t
   5531 
   5532 // Returned by `time'.
   5533 type Time_t = X__time_t
   5534 
   5535 // Timer ID returned by `timer_create'.
   5536 type Timer_t = X__timer_t
   5537 
   5538 type Useconds_t = X__useconds_t
   5539 type Suseconds_t = X__suseconds_t
   5540 
   5541 // Old compatibility names for C types.
   5542 type Ulong = uint32
   5543 type Ushort = uint16
   5544 type Uint = uint32
   5545 
   5546 type Int8_t = X__int8_t
   5547 type Int16_t = X__int16_t
   5548 type Int32_t = X__int32_t
   5549 type Int64_t = X__int64_t
   5550 
   5551 // These were defined by ISO C without the first `_'.
   5552 type U_int8_t = X__uint8_t
   5553 type U_int16_t = X__uint16_t
   5554 type U_int32_t = X__uint32_t
   5555 type U_int64_t = X__uint64_t
   5556 
   5557 type Register_t = int32
   5558 
   5559 type X__sigset_t = struct{ F__val [32]uint32 }
   5560 
   5561 // A set of signals to be blocked, unblocked, or waited for.
   5562 type Sigset_t = X__sigset_t
   5563 
   5564 type timeval = struct {
   5565 	Ftv_sec  X__time_t
   5566 	Ftv_usec X__suseconds_t
   5567 }
   5568 
   5569 type timespec = struct {
   5570 	Ftv_sec  X__time_t
   5571 	Ftv_nsec X__syscall_slong_t
   5572 }
   5573 
   5574 // The fd_set member is required to be an array of longs.
   5575 type X__fd_mask = int32
   5576 
   5577 // fd_set for select and pselect.
   5578 type Fd_set = struct{ Ffds_bits [32]X__fd_mask }
   5579 
   5580 // Sometimes the fd_set member is assumed to have this type.
   5581 type Fd_mask = X__fd_mask
   5582 
   5583 type Blksize_t = X__blksize_t
   5584 
   5585 // Types from the Large File Support interface.
   5586 type Blkcnt_t = X__blkcnt64_t
   5587 type Fsblkcnt_t = X__fsblkcnt64_t
   5588 type Fsfilcnt_t = X__fsfilcnt64_t
   5589 
   5590 type Blkcnt64_t = X__blkcnt64_t
   5591 type Fsblkcnt64_t = X__fsblkcnt64_t
   5592 type Fsfilcnt64_t = X__fsfilcnt64_t
   5593 
   5594 type __pthread_internal_list = struct {
   5595 	F__prev uintptr
   5596 	F__next uintptr
   5597 }
   5598 
   5599 type X__pthread_list_t = __pthread_internal_list
   5600 
   5601 type __pthread_internal_slist = struct{ F__next uintptr }
   5602 
   5603 type X__pthread_slist_t = __pthread_internal_slist
   5604 
   5605 type __pthread_mutex_s = struct {
   5606 	F__lock   int32
   5607 	F__count  uint32
   5608 	F__owner  int32
   5609 	F__kind   int32
   5610 	F__nusers uint32
   5611 	F__20     struct{ F__spins int32 }
   5612 }
   5613 
   5614 type __pthread_rwlock_arch_t = struct {
   5615 	F__readers       uint32
   5616 	F__writers       uint32
   5617 	F__wrphase_futex uint32
   5618 	F__writers_futex uint32
   5619 	F__pad3          uint32
   5620 	F__pad4          uint32
   5621 	F__flags         uint8
   5622 	F__shared        uint8
   5623 	F__pad1          uint8
   5624 	F__pad2          uint8
   5625 	F__cur_writer    int32
   5626 }
   5627 
   5628 type __pthread_cond_s = struct {
   5629 	F__0            struct{ F__wseq uint64 }
   5630 	F__8            struct{ F__g1_start uint64 }
   5631 	F__g_refs       [2]uint32
   5632 	F__g_size       [2]uint32
   5633 	F__g1_orig_size uint32
   5634 	F__wrefs        uint32
   5635 	F__g_signals    [2]uint32
   5636 }
   5637 
   5638 // Thread identifiers.  The structure of the attribute type is not
   5639 //
   5640 //	exposed on purpose.
   5641 type Pthread_t = uint32
   5642 
   5643 // Data structures for mutex handling.  The structure of the attribute
   5644 //
   5645 //	type is not exposed on purpose.
   5646 type Pthread_mutexattr_t = struct {
   5647 	F__ccgo_pad1 [0]uint32
   5648 	F__size      [4]uint8
   5649 }
   5650 
   5651 // Data structure for condition variable handling.  The structure of
   5652 //
   5653 //	the attribute type is not exposed on purpose.
   5654 type Pthread_condattr_t = struct {
   5655 	F__ccgo_pad1 [0]uint32
   5656 	F__size      [4]uint8
   5657 }
   5658 
   5659 // Keys for thread-specific data
   5660 type Pthread_key_t = uint32
   5661 
   5662 // Once-only execution
   5663 type Pthread_once_t = int32
   5664 
   5665 type pthread_attr_t = struct {
   5666 	F__ccgo_pad1 [0]uint32
   5667 	F__size      [36]uint8
   5668 }
   5669 
   5670 type Pthread_attr_t = pthread_attr_t
   5671 
   5672 type Pthread_mutex_t = struct{ F__data __pthread_mutex_s }
   5673 
   5674 type Pthread_cond_t = struct{ F__data __pthread_cond_s }
   5675 
   5676 // Data structure for reader-writer lock variable handling.  The
   5677 //
   5678 //	structure of the attribute type is deliberately not exposed.
   5679 type Pthread_rwlock_t = struct{ F__data __pthread_rwlock_arch_t }
   5680 
   5681 type Pthread_rwlockattr_t = struct {
   5682 	F__ccgo_pad1 [0]uint32
   5683 	F__size      [8]uint8
   5684 }
   5685 
   5686 // POSIX spinlock data type.
   5687 type Pthread_spinlock_t = int32
   5688 
   5689 // POSIX barriers data type.  The structure of the type is
   5690 //
   5691 //	deliberately not exposed.
   5692 type Pthread_barrier_t = struct {
   5693 	F__ccgo_pad1 [0]uint32
   5694 	F__size      [20]uint8
   5695 }
   5696 
   5697 type Pthread_barrierattr_t = struct {
   5698 	F__ccgo_pad1 [0]uint32
   5699 	F__size      [4]uint8
   5700 }
   5701 
   5702 type random_data = struct {
   5703 	Ffptr      uintptr
   5704 	Frptr      uintptr
   5705 	Fstate     uintptr
   5706 	Frand_type int32
   5707 	Frand_deg  int32
   5708 	Frand_sep  int32
   5709 	Fend_ptr   uintptr
   5710 }
   5711 
   5712 type drand48_data = struct {
   5713 	F__x     [3]uint16
   5714 	F__old_x [3]uint16
   5715 	F__c     uint16
   5716 	F__init  uint16
   5717 	F__a     uint64
   5718 }
   5719 
   5720 // Shorthand for type of comparison functions.
   5721 type X__compar_fn_t = uintptr
   5722 
   5723 type Comparison_fn_t = X__compar_fn_t
   5724 type X__compar_d_fn_t = uintptr
   5725 
   5726 // Type whose alignment is supported in every context and is at least
   5727 //
   5728 //	as great as that of any standard type not using alignment
   5729 //	specifiers.
   5730 type Max_align_t = struct {
   5731 	F__max_align_ll int64
   5732 	F__max_align_ld float64
   5733 }
   5734 
   5735 // Integers of known sizes.  These typedefs might change for architectures
   5736 // where the sizes very.  Preprocessor macros are available so that the
   5737 // types can be conveniently redefined at compile-type.  Like this:
   5738 //
   5739 //	cc '-DUINTPTR_TYPE=long long int' ...
   5740 type I64 = Sqlite_int64
   5741 type U64 = Sqlite_uint64
   5742 type U32 = uint32
   5743 type U16 = uint16
   5744 type I16 = int16
   5745 type U8 = uint8
   5746 type I8 = int8
   5747 
   5748 // The datatype used to store estimates of the number of rows in a
   5749 // table or index.
   5750 type TRowcnt = U64
   5751 
   5752 // Estimated quantities used for query planning are stored as 16-bit
   5753 // logarithms.  For quantity X, the value stored is 10*log2(X).  This
   5754 // gives a possible range of values of approximately 1.0e986 to 1e-986.
   5755 // But the allowed values are "grainy".  Not every value is representable.
   5756 // For example, quantities 16 and 17 are both represented by a LogEst
   5757 // of 40.  However, since LogEst quantities are suppose to be estimates,
   5758 // not exact values, this imprecision is not a problem.
   5759 //
   5760 // "LogEst" is short for "Logarithmic Estimate".
   5761 //
   5762 // Examples:
   5763 //
   5764 //	 1 -> 0              20 -> 43          10000 -> 132
   5765 //	 2 -> 10             25 -> 46          25000 -> 146
   5766 //	 3 -> 16            100 -> 66        1000000 -> 199
   5767 //	 4 -> 20           1000 -> 99        1048576 -> 200
   5768 //	10 -> 33           1024 -> 100    4294967296 -> 320
   5769 //
   5770 // The LogEst can be negative to indicate fractional values.
   5771 // Examples:
   5772 //
   5773 //	0.5 -> -10           0.1 -> -33        0.0625 -> -40
   5774 type LogEst = int16
   5775 
   5776 // The uptr type is an unsigned integer large enough to hold a pointer
   5777 type Uptr = U32
   5778 
   5779 // An instance of the following structure is used to store the busy-handler
   5780 // callback for a given sqlite handle.
   5781 //
   5782 // The sqlite.busyHandler member of the sqlite struct contains the busy
   5783 // callback for the database handle. Each pager opened via the sqlite
   5784 // handle is passed a pointer to sqlite.busyHandler. The busy-handler
   5785 // callback is currently invoked only from within pager.c.
   5786 type BusyHandler1 = struct {
   5787 	FxBusyHandler uintptr
   5788 	FpBusyArg     uintptr
   5789 	FnBusy        int32
   5790 }
   5791 
   5792 // An instance of the following structure is used to store the busy-handler
   5793 // callback for a given sqlite handle.
   5794 //
   5795 // The sqlite.busyHandler member of the sqlite struct contains the busy
   5796 // callback for the database handle. Each pager opened via the sqlite
   5797 // handle is passed a pointer to sqlite.busyHandler. The busy-handler
   5798 // callback is currently invoked only from within pager.c.
   5799 type BusyHandler = BusyHandler1
   5800 
   5801 // Forward references to structures
   5802 type AggInfo1 = struct {
   5803 	FdirectMode     U8
   5804 	FuseSortingIdx  U8
   5805 	FnSortingColumn U16
   5806 	FsortingIdx     int32
   5807 	FsortingIdxPTab int32
   5808 	FiFirstReg      int32
   5809 	FpGroupBy       uintptr
   5810 	FaCol           uintptr
   5811 	FnColumn        int32
   5812 	FnAccumulator   int32
   5813 	FaFunc          uintptr
   5814 	FnFunc          int32
   5815 	FselId          U32
   5816 }
   5817 
   5818 // Forward references to structures
   5819 type AggInfo = AggInfo1
   5820 type AuthContext1 = struct {
   5821 	FzAuthContext uintptr
   5822 	FpParse       uintptr
   5823 }
   5824 
   5825 type AuthContext = AuthContext1
   5826 type AutoincInfo1 = struct {
   5827 	FpNext  uintptr
   5828 	FpTab   uintptr
   5829 	FiDb    int32
   5830 	FregCtr int32
   5831 }
   5832 
   5833 type AutoincInfo = AutoincInfo1
   5834 type Bitvec1 = struct {
   5835 	FiSize    U32
   5836 	FnSet     U32
   5837 	FiDivisor U32
   5838 	Fu        struct {
   5839 		F__ccgo_pad1 [0]uint32
   5840 		FaBitmap     [500]U8
   5841 	}
   5842 }
   5843 
   5844 type Bitvec = Bitvec1
   5845 type CollSeq1 = struct {
   5846 	FzName       uintptr
   5847 	Fenc         U8
   5848 	F__ccgo_pad1 [3]byte
   5849 	FpUser       uintptr
   5850 	FxCmp        uintptr
   5851 	FxDel        uintptr
   5852 }
   5853 
   5854 type CollSeq = CollSeq1
   5855 type Column1 = struct {
   5856 	FzCnName     uintptr
   5857 	FnotNull     uint8
   5858 	F__ccgo_pad1 [1]byte
   5859 	Faffinity    uint8
   5860 	FszEst       U8
   5861 	FhName       U8
   5862 	F__ccgo_pad2 [1]byte
   5863 	FiDflt       U16
   5864 	FcolFlags    U16
   5865 	F__ccgo_pad3 [2]byte
   5866 }
   5867 
   5868 type Column = Column1
   5869 type Cte1 = struct {
   5870 	FzName       uintptr
   5871 	FpCols       uintptr
   5872 	FpSelect     uintptr
   5873 	FzCteErr     uintptr
   5874 	FpUse        uintptr
   5875 	FeM10d       U8
   5876 	F__ccgo_pad1 [3]byte
   5877 }
   5878 
   5879 type Cte = Cte1
   5880 type CteUse1 = struct {
   5881 	FnUse        int32
   5882 	FaddrM9e     int32
   5883 	FregRtn      int32
   5884 	FiCur        int32
   5885 	FnRowEst     LogEst
   5886 	FeM10d       U8
   5887 	F__ccgo_pad1 [1]byte
   5888 }
   5889 
   5890 type CteUse = CteUse1
   5891 type Db1 = struct {
   5892 	FzDbSName     uintptr
   5893 	FpBt          uintptr
   5894 	Fsafety_level U8
   5895 	FbSyncSet     U8
   5896 	F__ccgo_pad1  [2]byte
   5897 	FpSchema      uintptr
   5898 }
   5899 
   5900 type Db = Db1
   5901 type DbFixer1 = struct {
   5902 	FpParse      uintptr
   5903 	Fw           Walker
   5904 	FpSchema     uintptr
   5905 	FbTemp       U8
   5906 	F__ccgo_pad1 [3]byte
   5907 	FzDb         uintptr
   5908 	FzType       uintptr
   5909 	FpName       uintptr
   5910 }
   5911 
   5912 type DbFixer = DbFixer1
   5913 type Schema1 = struct {
   5914 	Fschema_cookie int32
   5915 	FiGeneration   int32
   5916 	FtblHash       Hash
   5917 	FidxHash       Hash
   5918 	FtrigHash      Hash
   5919 	FfkeyHash      Hash
   5920 	FpSeqTab       uintptr
   5921 	Ffile_format   U8
   5922 	Fenc           U8
   5923 	FschemaFlags   U16
   5924 	Fcache_size    int32
   5925 }
   5926 
   5927 type Schema = Schema1
   5928 type Expr1 = struct {
   5929 	Fop          U8
   5930 	FaffExpr     uint8
   5931 	Fop2         U8
   5932 	F__ccgo_pad1 [1]byte
   5933 	Fflags       U32
   5934 	Fu           struct{ FzToken uintptr }
   5935 	FpLeft       uintptr
   5936 	FpRight      uintptr
   5937 	Fx           struct{ FpList uintptr }
   5938 	FnHeight     int32
   5939 	FiTable      int32
   5940 	FiColumn     YnVar
   5941 	FiAgg        I16
   5942 	Fw           struct{ FiJoin int32 }
   5943 	FpAggInfo    uintptr
   5944 	Fy           struct {
   5945 		FpTab        uintptr
   5946 		F__ccgo_pad1 [4]byte
   5947 	}
   5948 }
   5949 
   5950 type Expr = Expr1
   5951 type ExprList1 = struct {
   5952 	FnExpr  int32
   5953 	FnAlloc int32
   5954 	Fa      [1]struct {
   5955 		FpExpr  uintptr
   5956 		FzEName uintptr
   5957 		Ffg     struct {
   5958 			F__ccgo_pad1 [0]uint32
   5959 			FsortFlags   U8
   5960 			F__ccgo_pad2 [3]byte
   5961 			FeEName      uint16
   5962 			F__ccgo_pad3 [2]byte
   5963 		}
   5964 		Fu struct {
   5965 			F__ccgo_pad1 [0]uint32
   5966 			Fx           struct {
   5967 				FiOrderByCol U16
   5968 				FiAlias      U16
   5969 			}
   5970 		}
   5971 	}
   5972 }
   5973 
   5974 type ExprList = ExprList1
   5975 type FKey1 = struct {
   5976 	FpFrom       uintptr
   5977 	FpNextFrom   uintptr
   5978 	FzTo         uintptr
   5979 	FpNextTo     uintptr
   5980 	FpPrevTo     uintptr
   5981 	FnCol        int32
   5982 	FisDeferred  U8
   5983 	FaAction     [2]U8
   5984 	F__ccgo_pad1 [1]byte
   5985 	FapTrigger   [2]uintptr
   5986 	FaCol        [1]struct {
   5987 		FiFrom int32
   5988 		FzCol  uintptr
   5989 	}
   5990 }
   5991 
   5992 type FKey = FKey1
   5993 type FuncDestructor1 = struct {
   5994 	FnRef      int32
   5995 	FxDestroy  uintptr
   5996 	FpUserData uintptr
   5997 }
   5998 
   5999 type FuncDestructor = FuncDestructor1
   6000 type FuncDef1 = struct {
   6001 	FnArg        I8
   6002 	F__ccgo_pad1 [3]byte
   6003 	FfuncFlags   U32
   6004 	FpUserData   uintptr
   6005 	FpNext       uintptr
   6006 	FxSFunc      uintptr
   6007 	FxFinalize   uintptr
   6008 	FxValue      uintptr
   6009 	FxInverse    uintptr
   6010 	FzName       uintptr
   6011 	Fu           struct{ FpHash uintptr }
   6012 }
   6013 
   6014 type FuncDef = FuncDef1
   6015 type FuncDefHash1 = struct{ Fa [23]uintptr }
   6016 
   6017 type FuncDefHash = FuncDefHash1
   6018 type IdList1 = struct {
   6019 	FnId         int32
   6020 	FeU4         U8
   6021 	F__ccgo_pad1 [3]byte
   6022 	Fa           [1]struct {
   6023 		FzName uintptr
   6024 		Fu4    struct{ Fidx int32 }
   6025 	}
   6026 }
   6027 
   6028 type IdList = IdList1
   6029 type Index1 = struct {
   6030 	FzName         uintptr
   6031 	FaiColumn      uintptr
   6032 	FaiRowLogEst   uintptr
   6033 	FpTable        uintptr
   6034 	FzColAff       uintptr
   6035 	FpNext         uintptr
   6036 	FpSchema       uintptr
   6037 	FaSortOrder    uintptr
   6038 	FazColl        uintptr
   6039 	FpPartIdxWhere uintptr
   6040 	FaColExpr      uintptr
   6041 	Ftnum          Pgno
   6042 	FszIdxRow      LogEst
   6043 	FnKeyCol       U16
   6044 	FnColumn       U16
   6045 	FonError       U8
   6046 	F__ccgo_pad1   [1]byte
   6047 	FidxType       uint16
   6048 	F__ccgo_pad2   [2]byte
   6049 	FnSample       int32
   6050 	FnSampleCol    int32
   6051 	FaAvgEq        uintptr
   6052 	FaSample       uintptr
   6053 	FaiRowEst      uintptr
   6054 	FnRowEst0      TRowcnt
   6055 	FcolNotIdxed   Bitmask
   6056 }
   6057 
   6058 type Index = Index1
   6059 type IndexedExpr1 = struct {
   6060 	FpExpr         uintptr
   6061 	FiDataCur      int32
   6062 	FiIdxCur       int32
   6063 	FiIdxCol       int32
   6064 	FbMaybeNullRow U8
   6065 	Faff           U8
   6066 	F__ccgo_pad1   [2]byte
   6067 	FpIENext       uintptr
   6068 }
   6069 
   6070 type IndexedExpr = IndexedExpr1
   6071 type IndexSample1 = struct {
   6072 	Fp     uintptr
   6073 	Fn     int32
   6074 	FanEq  uintptr
   6075 	FanLt  uintptr
   6076 	FanDLt uintptr
   6077 }
   6078 
   6079 type IndexSample = IndexSample1
   6080 type KeyInfo1 = struct {
   6081 	FnRef        U32
   6082 	Fenc         U8
   6083 	F__ccgo_pad1 [1]byte
   6084 	FnKeyField   U16
   6085 	FnAllField   U16
   6086 	F__ccgo_pad2 [2]byte
   6087 	Fdb          uintptr
   6088 	FaSortFlags  uintptr
   6089 	FaColl       [1]uintptr
   6090 }
   6091 
   6092 type KeyInfo = KeyInfo1
   6093 type Lookaside1 = struct {
   6094 	FbDisable    U32
   6095 	Fsz          U16
   6096 	FszTrue      U16
   6097 	FbMalloced   U8
   6098 	F__ccgo_pad1 [3]byte
   6099 	FnSlot       U32
   6100 	FanStat      [3]U32
   6101 	FpInit       uintptr
   6102 	FpFree       uintptr
   6103 	FpSmallInit  uintptr
   6104 	FpSmallFree  uintptr
   6105 	FpMiddle     uintptr
   6106 	FpStart      uintptr
   6107 	FpEnd        uintptr
   6108 	FpTrueEnd    uintptr
   6109 }
   6110 
   6111 type Lookaside = Lookaside1
   6112 type LookasideSlot1 = struct{ FpNext uintptr }
   6113 
   6114 type LookasideSlot = LookasideSlot1
   6115 type Module1 = struct {
   6116 	FpModule    uintptr
   6117 	FzName      uintptr
   6118 	FnRefModule int32
   6119 	FpAux       uintptr
   6120 	FxDestroy   uintptr
   6121 	FpEpoTab    uintptr
   6122 }
   6123 
   6124 type Module = Module1
   6125 type NameContext1 = struct {
   6126 	FpParse     uintptr
   6127 	FpSrcList   uintptr
   6128 	FuNC        struct{ FpEList uintptr }
   6129 	FpNext      uintptr
   6130 	FnRef       int32
   6131 	FnNcErr     int32
   6132 	FncFlags    int32
   6133 	FpWinSelect uintptr
   6134 }
   6135 
   6136 type NameContext = NameContext1
   6137 type OnOrUsing1 = struct {
   6138 	FpOn    uintptr
   6139 	FpUsing uintptr
   6140 }
   6141 
   6142 type OnOrUsing = OnOrUsing1
   6143 type Parse1 = struct {
   6144 	Fdb               uintptr
   6145 	FzErrMsg          uintptr
   6146 	FpVdbe            uintptr
   6147 	Frc               int32
   6148 	FcolNamesSet      U8
   6149 	FcheckSchema      U8
   6150 	Fnested           U8
   6151 	FnTempReg         U8
   6152 	FisMultiWrite     U8
   6153 	FmayAbort         U8
   6154 	FhasCompound      U8
   6155 	FokConstFactor    U8
   6156 	FdisableLookaside U8
   6157 	FprepFlags        U8
   6158 	FwithinRJSubrtn   U8
   6159 	F__ccgo_pad1      [1]byte
   6160 	FnRangeReg        int32
   6161 	FiRangeReg        int32
   6162 	FnErr             int32
   6163 	FnTab             int32
   6164 	FnMem             int32
   6165 	FszOpAlloc        int32
   6166 	FiSelfTab         int32
   6167 	FnLabel           int32
   6168 	FnLabelAlloc      int32
   6169 	FaLabel           uintptr
   6170 	FpConstExpr       uintptr
   6171 	FpIdxEpr          uintptr
   6172 	FconstraintName   Token
   6173 	FwriteMask        YDbMask
   6174 	FcookieMask       YDbMask
   6175 	FregRowid         int32
   6176 	FregRoot          int32
   6177 	FnMaxArg          int32
   6178 	FnSelect          int32
   6179 	FnTableLock       int32
   6180 	FaTableLock       uintptr
   6181 	FpAinc            uintptr
   6182 	FpToplevel        uintptr
   6183 	FpTriggerTab      uintptr
   6184 	FpTriggerPrg      uintptr
   6185 	FpCleanup         uintptr
   6186 	Fu1               struct{ FaddrCrTab int32 }
   6187 	FnQueryLoop       U32
   6188 	Foldmask          U32
   6189 	Fnewmask          U32
   6190 	FnProgressSteps   U32
   6191 	FeTriggerOp       U8
   6192 	FbReturning       U8
   6193 	FeOrconf          U8
   6194 	FdisableTriggers  U8
   6195 	FaTempReg         [8]int32
   6196 	FpOuterParse      uintptr
   6197 	FsNameToken       Token
   6198 	FsLastToken       Token
   6199 	FnVar             YnVar
   6200 	FiPkSortOrder     U8
   6201 	Fexplain          U8
   6202 	FeParseMode       U8
   6203 	F__ccgo_pad2      [3]byte
   6204 	FnVtabLock        int32
   6205 	FnHeight          int32
   6206 	FaddrExplain      int32
   6207 	FpVList           uintptr
   6208 	FpReprepare       uintptr
   6209 	FzTail            uintptr
   6210 	FpNewTable        uintptr
   6211 	FpNewIndex        uintptr
   6212 	FpNewTrigger      uintptr
   6213 	FzAuthContext     uintptr
   6214 	FsArg             Token
   6215 	FapVtabLock       uintptr
   6216 	FpWith            uintptr
   6217 	FpRename          uintptr
   6218 }
   6219 
   6220 type Parse = Parse1
   6221 type ParseCleanup1 = struct {
   6222 	FpNext    uintptr
   6223 	FpPtr     uintptr
   6224 	FxCleanup uintptr
   6225 }
   6226 
   6227 type ParseCleanup = ParseCleanup1
   6228 type PreUpdate1 = struct {
   6229 	Fv            uintptr
   6230 	FpCsr         uintptr
   6231 	Fop           int32
   6232 	FaRecord      uintptr
   6233 	Fkeyinfo      KeyInfo
   6234 	FpUnpacked    uintptr
   6235 	FpNewUnpacked uintptr
   6236 	FiNewReg      int32
   6237 	FiBlobWrite   int32
   6238 	FiKey1        I64
   6239 	FiKey2        I64
   6240 	FaNew         uintptr
   6241 	FpTab         uintptr
   6242 	FpPk          uintptr
   6243 	F__ccgo_pad1  [4]byte
   6244 }
   6245 
   6246 type PreUpdate = PreUpdate1
   6247 type PrintfArguments1 = struct {
   6248 	FnArg  int32
   6249 	FnUsed int32
   6250 	FapArg uintptr
   6251 }
   6252 
   6253 type PrintfArguments = PrintfArguments1
   6254 type RenameToken1 = struct {
   6255 	Fp     uintptr
   6256 	Ft     Token
   6257 	FpNext uintptr
   6258 }
   6259 
   6260 type RenameToken = RenameToken1
   6261 type Returning1 = struct {
   6262 	FpParse    uintptr
   6263 	FpReturnEL uintptr
   6264 	FretTrig   Trigger
   6265 	FretTStep  TriggerStep
   6266 	FiRetCur   int32
   6267 	FnRetCol   int32
   6268 	FiRetReg   int32
   6269 }
   6270 
   6271 type Returning = Returning1
   6272 type RowSet1 = struct {
   6273 	FpChunk  uintptr
   6274 	Fdb      uintptr
   6275 	FpEntry  uintptr
   6276 	FpLast   uintptr
   6277 	FpFresh  uintptr
   6278 	FpForest uintptr
   6279 	FnFresh  U16
   6280 	FrsFlags U16
   6281 	FiBatch  int32
   6282 }
   6283 
   6284 type RowSet = RowSet1
   6285 type Savepoint1 = struct {
   6286 	FzName            uintptr
   6287 	F__ccgo_pad1      [4]byte
   6288 	FnDeferredCons    I64
   6289 	FnDeferredImmCons I64
   6290 	FpNext            uintptr
   6291 	F__ccgo_pad2      [4]byte
   6292 }
   6293 
   6294 type Savepoint = Savepoint1
   6295 type Select1 = struct {
   6296 	Fop           U8
   6297 	F__ccgo_pad1  [1]byte
   6298 	FnSelectRow   LogEst
   6299 	FselFlags     U32
   6300 	FiLimit       int32
   6301 	FiOffset      int32
   6302 	FselId        U32
   6303 	FaddrOpenEphm [2]int32
   6304 	FpEList       uintptr
   6305 	FpSrc         uintptr
   6306 	FpWhere       uintptr
   6307 	FpGroupBy     uintptr
   6308 	FpHaving      uintptr
   6309 	FpOrderBy     uintptr
   6310 	FpPrior       uintptr
   6311 	FpNext        uintptr
   6312 	FpLimit       uintptr
   6313 	FpWith        uintptr
   6314 	FpWin         uintptr
   6315 	FpWinDefn     uintptr
   6316 }
   6317 
   6318 type Select = Select1
   6319 type SQLiteThread1 = struct {
   6320 	FxTask   uintptr
   6321 	FpIn     uintptr
   6322 	FpResult uintptr
   6323 }
   6324 
   6325 type SQLiteThread = SQLiteThread1
   6326 type SelectDest1 = struct {
   6327 	FeDest       U8
   6328 	F__ccgo_pad1 [3]byte
   6329 	FiSDParm     int32
   6330 	FiSDParm2    int32
   6331 	FiSdst       int32
   6332 	FnSdst       int32
   6333 	FzAffSdst    uintptr
   6334 	FpOrderBy    uintptr
   6335 }
   6336 
   6337 type SelectDest = SelectDest1
   6338 type SrcItem1 = struct {
   6339 	FpSchema     uintptr
   6340 	FzDatabase   uintptr
   6341 	FzName       uintptr
   6342 	FzAlias      uintptr
   6343 	FpTab        uintptr
   6344 	FpSelect     uintptr
   6345 	FaddrFillSub int32
   6346 	FregReturn   int32
   6347 	FregResult   int32
   6348 	Ffg          struct {
   6349 		F__ccgo_pad1 [0]uint32
   6350 		Fjointype    U8
   6351 		F__ccgo_pad2 [3]byte
   6352 		FnotIndexed  uint16
   6353 		F__ccgo_pad3 [2]byte
   6354 	}
   6355 	FiCursor     int32
   6356 	Fu3          struct{ FpOn uintptr }
   6357 	F__ccgo_pad1 [4]byte
   6358 	FcolUsed     Bitmask
   6359 	Fu1          struct{ FzIndexedBy uintptr }
   6360 	Fu2          struct{ FpIBIndex uintptr }
   6361 }
   6362 
   6363 type SrcItem = SrcItem1
   6364 type SrcList1 = struct {
   6365 	FnSrc   int32
   6366 	FnAlloc U32
   6367 	Fa      [1]SrcItem
   6368 }
   6369 
   6370 type SrcList = SrcList1
   6371 type StrAccum = sqlite3_str
   6372 type Table1 = struct {
   6373 	FzName      uintptr
   6374 	FaCol       uintptr
   6375 	FpIndex     uintptr
   6376 	FzColAff    uintptr
   6377 	FpCheck     uintptr
   6378 	Ftnum       Pgno
   6379 	FnTabRef    U32
   6380 	FtabFlags   U32
   6381 	FiPKey      I16
   6382 	FnCol       I16
   6383 	FnNVCol     I16
   6384 	FnRowLogEst LogEst
   6385 	FszTabRow   LogEst
   6386 	FkeyConf    U8
   6387 	FeTabType   U8
   6388 	Fu          struct {
   6389 		Ftab struct {
   6390 			FaddColOffset int32
   6391 			FpFKey        uintptr
   6392 			FpDfltList    uintptr
   6393 		}
   6394 	}
   6395 	FpTrigger uintptr
   6396 	FpSchema  uintptr
   6397 }
   6398 
   6399 // Internal alias for sqlite3_str
   6400 type Table = Table1
   6401 type TableLock1 = struct {
   6402 	FiDb         int32
   6403 	FiTab        Pgno
   6404 	FisWriteLock U8
   6405 	F__ccgo_pad1 [3]byte
   6406 	FzLockName   uintptr
   6407 }
   6408 
   6409 type TableLock = TableLock1
   6410 type Token1 = struct {
   6411 	Fz uintptr
   6412 	Fn uint32
   6413 }
   6414 
   6415 type Token = Token1
   6416 type Trigger1 = struct {
   6417 	FzName       uintptr
   6418 	Ftable       uintptr
   6419 	Fop          U8
   6420 	Ftr_tm       U8
   6421 	FbReturning  U8
   6422 	F__ccgo_pad1 [1]byte
   6423 	FpWhen       uintptr
   6424 	FpColumns    uintptr
   6425 	FpSchema     uintptr
   6426 	FpTabSchema  uintptr
   6427 	Fstep_list   uintptr
   6428 	FpNext       uintptr
   6429 }
   6430 
   6431 type Trigger = Trigger1
   6432 type TriggerPrg1 = struct {
   6433 	FpTrigger uintptr
   6434 	FpNext    uintptr
   6435 	FpProgram uintptr
   6436 	Forconf   int32
   6437 	FaColmask [2]U32
   6438 }
   6439 
   6440 type TriggerPrg = TriggerPrg1
   6441 type TriggerStep1 = struct {
   6442 	Fop          U8
   6443 	Forconf      U8
   6444 	F__ccgo_pad1 [2]byte
   6445 	FpTrig       uintptr
   6446 	FpSelect     uintptr
   6447 	FzTarget     uintptr
   6448 	FpFrom       uintptr
   6449 	FpWhere      uintptr
   6450 	FpExprList   uintptr
   6451 	FpIdList     uintptr
   6452 	FpUpsert     uintptr
   6453 	FzSpan       uintptr
   6454 	FpNext       uintptr
   6455 	FpLast       uintptr
   6456 }
   6457 
   6458 type TriggerStep = TriggerStep1
   6459 type UnpackedRecord1 = struct {
   6460 	FpKeyInfo uintptr
   6461 	FaMem     uintptr
   6462 	Fu        struct {
   6463 		F__ccgo_pad1 [0]uint64
   6464 		Fz           uintptr
   6465 		F__ccgo_pad2 [4]byte
   6466 	}
   6467 	Fn           int32
   6468 	FnField      U16
   6469 	Fdefault_rc  I8
   6470 	FerrCode     U8
   6471 	Fr1          I8
   6472 	Fr2          I8
   6473 	FeqSeen      U8
   6474 	F__ccgo_pad1 [5]byte
   6475 }
   6476 
   6477 type UnpackedRecord = UnpackedRecord1
   6478 type Upsert1 = struct {
   6479 	FpUpsertTarget      uintptr
   6480 	FpUpsertTargetWhere uintptr
   6481 	FpUpsertSet         uintptr
   6482 	FpUpsertWhere       uintptr
   6483 	FpNextUpsert        uintptr
   6484 	FisDoUpdate         U8
   6485 	F__ccgo_pad1        [3]byte
   6486 	FpToFree            uintptr
   6487 	FpUpsertIdx         uintptr
   6488 	FpUpsertSrc         uintptr
   6489 	FregData            int32
   6490 	FiDataCur           int32
   6491 	FiIdxCur            int32
   6492 }
   6493 
   6494 type Upsert = Upsert1
   6495 type VTable1 = struct {
   6496 	Fdb          uintptr
   6497 	FpMod        uintptr
   6498 	FpVtab       uintptr
   6499 	FnRef        int32
   6500 	FbConstraint U8
   6501 	FeVtabRisk   U8
   6502 	F__ccgo_pad1 [2]byte
   6503 	FiSavepoint  int32
   6504 	FpNext       uintptr
   6505 }
   6506 
   6507 type VTable = VTable1
   6508 type VtabCtx1 = struct {
   6509 	FpVTable   uintptr
   6510 	FpTab      uintptr
   6511 	FpPrior    uintptr
   6512 	FbDeclared int32
   6513 }
   6514 
   6515 type VtabCtx = VtabCtx1
   6516 type Walker1 = struct {
   6517 	FpParse           uintptr
   6518 	FxExprCallback    uintptr
   6519 	FxSelectCallback  uintptr
   6520 	FxSelectCallback2 uintptr
   6521 	FwalkerDepth      int32
   6522 	FeCode            U16
   6523 	F__ccgo_pad1      [2]byte
   6524 	Fu                struct{ FpNC uintptr }
   6525 }
   6526 
   6527 type Walker = Walker1
   6528 type WhereInfo1 = struct {
   6529 	FpParse          uintptr
   6530 	FpTabList        uintptr
   6531 	FpOrderBy        uintptr
   6532 	FpResultSet      uintptr
   6533 	FpSelect         uintptr
   6534 	FaiCurOnePass    [2]int32
   6535 	FiContinue       int32
   6536 	FiBreak          int32
   6537 	FsavedNQueryLoop int32
   6538 	FwctrlFlags      U16
   6539 	FiLimit          LogEst
   6540 	FnLevel          U8
   6541 	FnOBSat          I8
   6542 	FeOnePass        U8
   6543 	FeDistinct       U8
   6544 	FbDeferredSeek   uint8
   6545 	F__ccgo_pad1     [1]byte
   6546 	FnRowOut         LogEst
   6547 	FiTop            int32
   6548 	FiEndWhere       int32
   6549 	FpLoops          uintptr
   6550 	FpMemToFree      uintptr
   6551 	F__ccgo_pad2     [4]byte
   6552 	FrevMask         Bitmask
   6553 	FsWC             WhereClause
   6554 	FsMaskSet        WhereMaskSet
   6555 	Fa               [1]WhereLevel
   6556 }
   6557 
   6558 type WhereInfo = WhereInfo1
   6559 type Window1 = struct {
   6560 	FzName          uintptr
   6561 	FzBase          uintptr
   6562 	FpPartition     uintptr
   6563 	FpOrderBy       uintptr
   6564 	FeFrmType       U8
   6565 	FeStart         U8
   6566 	FeEnd           U8
   6567 	FbImplicitFrame U8
   6568 	FeExclude       U8
   6569 	F__ccgo_pad1    [3]byte
   6570 	FpStart         uintptr
   6571 	FpEnd           uintptr
   6572 	FppThis         uintptr
   6573 	FpNextWin       uintptr
   6574 	FpFilter        uintptr
   6575 	FpWFunc         uintptr
   6576 	FiEphCsr        int32
   6577 	FregAccum       int32
   6578 	FregResult      int32
   6579 	FcsrApp         int32
   6580 	FregApp         int32
   6581 	FregPart        int32
   6582 	FpOwner         uintptr
   6583 	FnBufferCol     int32
   6584 	FiArgCol        int32
   6585 	FregOne         int32
   6586 	FregStartRowid  int32
   6587 	FregEndRowid    int32
   6588 	FbExprArgs      U8
   6589 	F__ccgo_pad2    [3]byte
   6590 }
   6591 
   6592 type Window = Window1
   6593 type With1 = struct {
   6594 	FnCte   int32
   6595 	FbView  int32
   6596 	FpOuter uintptr
   6597 	Fa      [1]Cte
   6598 }
   6599 
   6600 type With = With1
   6601 
   6602 // The bitmask datatype defined below is used for various optimizations.
   6603 //
   6604 // Changing this from a 64-bit to a 32-bit type limits the number of
   6605 // tables in a join to 32 instead of 64.  But it also reduces the size
   6606 // of the library by 738 bytes on ix86.
   6607 type Bitmask = U64
   6608 
   6609 // A VList object records a mapping between parameters/variables/wildcards
   6610 // in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
   6611 // variable number associated with that parameter.  See the format description
   6612 // on the sqlite3VListAdd() routine for more information.  A VList is really
   6613 // just an array of integers.
   6614 type VList = int32
   6615 
   6616 // The type used to represent a page number.  The first page in a file
   6617 // is called page 1.  0 is used to represent "not a page".
   6618 type Pgno = U32
   6619 
   6620 // Each open file is managed by a separate instance of the "Pager" structure.
   6621 type Pager1 = struct {
   6622 	FpVfs              uintptr
   6623 	FexclusiveMode     U8
   6624 	FjournalMode       U8
   6625 	FuseJournal        U8
   6626 	FnoSync            U8
   6627 	FfullSync          U8
   6628 	FextraSync         U8
   6629 	FsyncFlags         U8
   6630 	FwalSyncFlags      U8
   6631 	FtempFile          U8
   6632 	FnoLock            U8
   6633 	FreadOnly          U8
   6634 	FmemDb             U8
   6635 	FmemVfs            U8
   6636 	FeState            U8
   6637 	FeLock             U8
   6638 	FchangeCountDone   U8
   6639 	FsetSuper          U8
   6640 	FdoNotSpill        U8
   6641 	FsubjInMemory      U8
   6642 	FbUseFetch         U8
   6643 	FhasHeldSharedLock U8
   6644 	F__ccgo_pad1       [3]byte
   6645 	FdbSize            Pgno
   6646 	FdbOrigSize        Pgno
   6647 	FdbFileSize        Pgno
   6648 	FdbHintSize        Pgno
   6649 	FerrCode           int32
   6650 	FnRec              int32
   6651 	FcksumInit         U32
   6652 	FnSubRec           U32
   6653 	FpInJournal        uintptr
   6654 	Ffd                uintptr
   6655 	Fjfd               uintptr
   6656 	Fsjfd              uintptr
   6657 	F__ccgo_pad2       [4]byte
   6658 	FjournalOff        I64
   6659 	FjournalHdr        I64
   6660 	FpBackup           uintptr
   6661 	FaSavepoint        uintptr
   6662 	FnSavepoint        int32
   6663 	FiDataVersion      U32
   6664 	FdbFileVers        [16]uint8
   6665 	FnMmapOut          int32
   6666 	F__ccgo_pad3       [4]byte
   6667 	FszMmap            Sqlite3_int64
   6668 	FpMmapFreelist     uintptr
   6669 	FnExtra            U16
   6670 	FnReserve          I16
   6671 	FvfsFlags          U32
   6672 	FsectorSize        U32
   6673 	FmxPgno            Pgno
   6674 	FlckPgno           Pgno
   6675 	FpageSize          I64
   6676 	FjournalSizeLimit  I64
   6677 	FzFilename         uintptr
   6678 	FzJournal          uintptr
   6679 	FxBusyHandler      uintptr
   6680 	FpBusyHandlerArg   uintptr
   6681 	FaStat             [4]int32
   6682 	FxReiniter         uintptr
   6683 	FxGet              uintptr
   6684 	FpTmpSpace         uintptr
   6685 	FpPCache           uintptr
   6686 	FpWal              uintptr
   6687 	FzWal              uintptr
   6688 }
   6689 
   6690 // Each open file is managed by a separate instance of the "Pager" structure.
   6691 type Pager = Pager1
   6692 
   6693 // Handle type for pages.
   6694 type PgHdr2 = struct {
   6695 	FpPage       uintptr
   6696 	FpData       uintptr
   6697 	FpExtra      uintptr
   6698 	FpCache      uintptr
   6699 	FpDirty      uintptr
   6700 	FpPager      uintptr
   6701 	Fpgno        Pgno
   6702 	Fflags       U16
   6703 	F__ccgo_pad1 [2]byte
   6704 	FnRef        I64
   6705 	FpDirtyNext  uintptr
   6706 	FpDirtyPrev  uintptr
   6707 }
   6708 
   6709 // Handle type for pages.
   6710 type DbPage = PgHdr2
   6711 
   6712 // Forward declarations of structure
   6713 type Btree1 = struct {
   6714 	Fdb             uintptr
   6715 	FpBt            uintptr
   6716 	FinTrans        U8
   6717 	Fsharable       U8
   6718 	Flocked         U8
   6719 	FhasIncrblobCur U8
   6720 	FwantToLock     int32
   6721 	FnBackup        int32
   6722 	FiBDataVersion  U32
   6723 	FpNext          uintptr
   6724 	FpPrev          uintptr
   6725 	Flock           BtLock
   6726 }
   6727 
   6728 // Forward declarations of structure
   6729 type Btree = Btree1
   6730 type BtCursor1 = struct {
   6731 	FeState        U8
   6732 	FcurFlags      U8
   6733 	FcurPagerFlags U8
   6734 	Fhints         U8
   6735 	FskipNext      int32
   6736 	FpBtree        uintptr
   6737 	FaOverflow     uintptr
   6738 	FpKey          uintptr
   6739 	FpBt           uintptr
   6740 	FpNext         uintptr
   6741 	F__ccgo_pad1   [4]byte
   6742 	Finfo          CellInfo
   6743 	FnKey          I64
   6744 	FpgnoRoot      Pgno
   6745 	FiPage         I8
   6746 	FcurIntKey     U8
   6747 	Fix            U16
   6748 	FaiIdx         [19]U16
   6749 	F__ccgo_pad2   [2]byte
   6750 	FpKeyInfo      uintptr
   6751 	FpPage         uintptr
   6752 	FapPage        [19]uintptr
   6753 	F__ccgo_pad3   [4]byte
   6754 }
   6755 
   6756 type BtCursor = BtCursor1
   6757 type BtShared1 = struct {
   6758 	FpPager          uintptr
   6759 	Fdb              uintptr
   6760 	FpCursor         uintptr
   6761 	FpPage1          uintptr
   6762 	FopenFlags       U8
   6763 	FautoVacuum      U8
   6764 	FincrVacuum      U8
   6765 	FbDoTruncate     U8
   6766 	FinTransaction   U8
   6767 	Fmax1bytePayload U8
   6768 	FnReserveWanted  U8
   6769 	F__ccgo_pad1     [1]byte
   6770 	FbtsFlags        U16
   6771 	FmaxLocal        U16
   6772 	FminLocal        U16
   6773 	FmaxLeaf         U16
   6774 	FminLeaf         U16
   6775 	F__ccgo_pad2     [2]byte
   6776 	FpageSize        U32
   6777 	FusableSize      U32
   6778 	FnTransaction    int32
   6779 	FnPage           U32
   6780 	FpSchema         uintptr
   6781 	FxFreeSchema     uintptr
   6782 	Fmutex           uintptr
   6783 	FpHasContent     uintptr
   6784 	FnRef            int32
   6785 	FpNext           uintptr
   6786 	FpLock           uintptr
   6787 	FpWriter         uintptr
   6788 	FpTmpSpace       uintptr
   6789 	FnPreformatSize  int32
   6790 }
   6791 
   6792 type BtShared = BtShared1
   6793 type BtreePayload1 = struct {
   6794 	FpKey        uintptr
   6795 	F__ccgo_pad1 [4]byte
   6796 	FnKey        Sqlite3_int64
   6797 	FpData       uintptr
   6798 	FaMem        uintptr
   6799 	FnMem        U16
   6800 	F__ccgo_pad2 [2]byte
   6801 	FnData       int32
   6802 	FnZero       int32
   6803 	F__ccgo_pad3 [4]byte
   6804 }
   6805 
   6806 type BtreePayload = BtreePayload1
   6807 
   6808 // A single VDBE is an opaque structure named "Vdbe".  Only routines
   6809 // in the source file sqliteVdbe.c are allowed to see the insides
   6810 // of this structure.
   6811 type Vdbe1 = struct {
   6812 	Fdb                 uintptr
   6813 	FppVPrev            uintptr
   6814 	FpVNext             uintptr
   6815 	FpParse             uintptr
   6816 	FnVar               YnVar
   6817 	F__ccgo_pad1        [2]byte
   6818 	FnMem               int32
   6819 	FnCursor            int32
   6820 	FcacheCtr           U32
   6821 	Fpc                 int32
   6822 	Frc                 int32
   6823 	FnChange            I64
   6824 	FiStatement         int32
   6825 	F__ccgo_pad2        [4]byte
   6826 	FiCurrentTime       I64
   6827 	FnFkConstraint      I64
   6828 	FnStmtDefCons       I64
   6829 	FnStmtDefImmCons    I64
   6830 	FaMem               uintptr
   6831 	FapArg              uintptr
   6832 	FapCsr              uintptr
   6833 	FaVar               uintptr
   6834 	FaOp                uintptr
   6835 	FnOp                int32
   6836 	FnOpAlloc           int32
   6837 	FaColName           uintptr
   6838 	FpResultRow         uintptr
   6839 	FzErrMsg            uintptr
   6840 	FpVList             uintptr
   6841 	F__ccgo_pad3        [4]byte
   6842 	FstartTime          I64
   6843 	FnResColumn         U16
   6844 	FerrorAction        U8
   6845 	FminWriteFileFormat U8
   6846 	FprepFlags          U8
   6847 	FeVdbeState         U8
   6848 	F__ccgo_pad4        [2]byte
   6849 	Fexpired            uint8
   6850 	F__ccgo_pad5        [3]byte
   6851 	FbtreeMask          YDbMask
   6852 	FlockMask           YDbMask
   6853 	FaCounter           [9]U32
   6854 	FzSql               uintptr
   6855 	FpFree              uintptr
   6856 	FpFrame             uintptr
   6857 	FpDelFrame          uintptr
   6858 	FnFrame             int32
   6859 	Fexpmask            U32
   6860 	FpProgram           uintptr
   6861 	FpAuxData           uintptr
   6862 }
   6863 
   6864 // A single VDBE is an opaque structure named "Vdbe".  Only routines
   6865 // in the source file sqliteVdbe.c are allowed to see the insides
   6866 // of this structure.
   6867 type Vdbe = Vdbe1
   6868 
   6869 // The names of the following types declared in vdbeInt.h are required
   6870 // for the VdbeOp definition.
   6871 type Mem = sqlite3_value
   6872 type SubProgram1 = struct {
   6873 	FaOp   uintptr
   6874 	FnOp   int32
   6875 	FnMem  int32
   6876 	FnCsr  int32
   6877 	FaOnce uintptr
   6878 	Ftoken uintptr
   6879 	FpNext uintptr
   6880 }
   6881 
   6882 type SubProgram = SubProgram1
   6883 
   6884 // A single instruction of the virtual machine has an opcode
   6885 // and as many as three operands.  The instruction is recorded
   6886 // as an instance of the following structure:
   6887 type VdbeOp1 = struct {
   6888 	Fopcode U8
   6889 	Fp4type int8
   6890 	Fp5     U16
   6891 	Fp1     int32
   6892 	Fp2     int32
   6893 	Fp3     int32
   6894 	Fp4     struct{ Fi int32 }
   6895 }
   6896 
   6897 type p4union = struct{ Fi int32 }
   6898 
   6899 type VdbeOp = VdbeOp1
   6900 
   6901 // A smaller version of VdbeOp used for the VdbeAddOpList() function because
   6902 // it takes up less space.
   6903 type VdbeOpList1 = struct {
   6904 	Fopcode U8
   6905 	Fp1     int8
   6906 	Fp2     int8
   6907 	Fp3     int8
   6908 }
   6909 
   6910 type VdbeOpList = VdbeOpList1
   6911 
   6912 type RecordCompare = uintptr
   6913 
   6914 type PgHdr = PgHdr2
   6915 type PCache2 = struct {
   6916 	FpDirty      uintptr
   6917 	FpDirtyTail  uintptr
   6918 	FpSynced     uintptr
   6919 	F__ccgo_pad1 [4]byte
   6920 	FnRefSum     I64
   6921 	FszCache     int32
   6922 	FszSpill     int32
   6923 	FszPage      int32
   6924 	FszExtra     int32
   6925 	FbPurgeable  U8
   6926 	FeCreate     U8
   6927 	F__ccgo_pad2 [2]byte
   6928 	FxStress     uintptr
   6929 	FpStress     uintptr
   6930 	FpCache      uintptr
   6931 }
   6932 
   6933 type PCache = PCache2
   6934 
   6935 // typedef for the authorization callback function.
   6936 type Sqlite3_xauth = uintptr
   6937 
   6938 type sqlite3InitInfo = struct {
   6939 	FnewTnum       Pgno
   6940 	FiDb           U8
   6941 	Fbusy          U8
   6942 	F__ccgo_pad1   [2]byte
   6943 	ForphanTrigger uint8
   6944 	F__ccgo_pad2   [3]byte
   6945 	FazInit        uintptr
   6946 }
   6947 
   6948 type sColMap = struct {
   6949 	FiFrom int32
   6950 	FzCol  uintptr
   6951 }
   6952 
   6953 // An instance of this structure contains information needed to generate
   6954 // code for a SELECT that contains aggregate functions.
   6955 //
   6956 // If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a
   6957 // pointer to this structure.  The Expr.iAgg field is the index in
   6958 // AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate
   6959 // code for that node.
   6960 //
   6961 // AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
   6962 // original Select structure that describes the SELECT statement.  These
   6963 // fields do not need to be freed when deallocating the AggInfo structure.
   6964 type AggInfo_col = struct {
   6965 	FpTab          uintptr
   6966 	FpCExpr        uintptr
   6967 	FiTable        int32
   6968 	FiColumn       I16
   6969 	FiSorterColumn I16
   6970 }
   6971 
   6972 // An instance of this structure contains information needed to generate
   6973 // code for a SELECT that contains aggregate functions.
   6974 //
   6975 // If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a
   6976 // pointer to this structure.  The Expr.iAgg field is the index in
   6977 // AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate
   6978 // code for that node.
   6979 //
   6980 // AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
   6981 // original Select structure that describes the SELECT statement.  These
   6982 // fields do not need to be freed when deallocating the AggInfo structure.
   6983 type AggInfo_func = struct {
   6984 	FpFExpr    uintptr
   6985 	FpFunc     uintptr
   6986 	FiDistinct int32
   6987 	FiDistAddr int32
   6988 }
   6989 
   6990 // The datatype ynVar is a signed integer, either 16-bit or 32-bit.
   6991 // Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater
   6992 // than 32767 we have to make it 32-bit.  16-bit is preferred because
   6993 // it uses less memory in the Expr object, which is a big memory user
   6994 // in systems with lots of prepared statements.  And few applications
   6995 // need more than about 10 or 20 variables.  But some extreme users want
   6996 // to have prepared statements with over 32766 variables, and for them
   6997 // the option is available (at compile-time).
   6998 type YnVar = I16
   6999 
   7000 // A list of expressions.  Each expression may optionally have a
   7001 // name.  An expr/name combination can be used in several ways, such
   7002 // as the list of "expr AS ID" fields following a "SELECT" or in the
   7003 // list of "ID = expr" items in an UPDATE.  A list of expressions can
   7004 // also be used as the argument to a function, in which case the a.zName
   7005 // field is not used.
   7006 //
   7007 // In order to try to keep memory usage down, the Expr.a.zEName field
   7008 // is used for multiple purposes:
   7009 //
   7010 //	 eEName          Usage
   7011 //	----------       -------------------------
   7012 //	ENAME_NAME       (1) the AS of result set column
   7013 //	                 (2) COLUMN= of an UPDATE
   7014 //
   7015 //	ENAME_TAB        DB.TABLE.NAME used to resolve names
   7016 //	                 of subqueries
   7017 //
   7018 //	ENAME_SPAN       Text of the original result set
   7019 //	                 expression.
   7020 type ExprList_item = struct {
   7021 	FpExpr  uintptr
   7022 	FzEName uintptr
   7023 	Ffg     struct {
   7024 		F__ccgo_pad1 [0]uint32
   7025 		FsortFlags   U8
   7026 		F__ccgo_pad2 [3]byte
   7027 		FeEName      uint16
   7028 		F__ccgo_pad3 [2]byte
   7029 	}
   7030 	Fu struct {
   7031 		F__ccgo_pad1 [0]uint32
   7032 		Fx           struct {
   7033 			FiOrderByCol U16
   7034 			FiAlias      U16
   7035 		}
   7036 	}
   7037 }
   7038 
   7039 // An instance of this structure can hold a simple list of identifiers,
   7040 // such as the list "a,b,c" in the following statements:
   7041 //
   7042 //	INSERT INTO t(a,b,c) VALUES ...;
   7043 //	CREATE INDEX idx ON t(a,b,c);
   7044 //	CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;
   7045 //
   7046 // The IdList.a.idx field is used when the IdList represents the list of
   7047 // column names after a table name in an INSERT statement.  In the statement
   7048 //
   7049 //	INSERT INTO t(a,b,c) ...
   7050 //
   7051 // If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
   7052 type IdList_item = struct {
   7053 	FzName uintptr
   7054 	Fu4    struct{ Fidx int32 }
   7055 }
   7056 
   7057 // The yDbMask datatype for the bitmask of all attached databases.
   7058 type YDbMask = uint32
   7059 
   7060 // A pointer to this structure is used to communicate information
   7061 // from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
   7062 type InitData = struct {
   7063 	Fdb         uintptr
   7064 	FpzErrMsg   uintptr
   7065 	FiDb        int32
   7066 	Frc         int32
   7067 	FmInitFlags U32
   7068 	FnInitRow   U32
   7069 	FmxPage     Pgno
   7070 }
   7071 
   7072 // Structure containing global configuration data for the SQLite library.
   7073 //
   7074 // This structure also contains some state information.
   7075 type Sqlite3Config = struct {
   7076 	FbMemstat            int32
   7077 	FbCoreMutex          U8
   7078 	FbFullMutex          U8
   7079 	FbOpenUri            U8
   7080 	FbUseCis             U8
   7081 	FbSmallMalloc        U8
   7082 	FbExtraSchemaChecks  U8
   7083 	F__ccgo_pad1         [2]byte
   7084 	FmxStrlen            int32
   7085 	FneverCorrupt        int32
   7086 	FszLookaside         int32
   7087 	FnLookaside          int32
   7088 	FnStmtSpill          int32
   7089 	Fm                   Sqlite3_mem_methods
   7090 	Fmutex               Sqlite3_mutex_methods
   7091 	Fpcache2             Sqlite3_pcache_methods2
   7092 	FpHeap               uintptr
   7093 	FnHeap               int32
   7094 	FmnReq               int32
   7095 	FmxReq               int32
   7096 	FszMmap              Sqlite3_int64
   7097 	FmxMmap              Sqlite3_int64
   7098 	FpPage               uintptr
   7099 	FszPage              int32
   7100 	FnPage               int32
   7101 	FmxParserStack       int32
   7102 	FsharedCacheEnabled  int32
   7103 	FszPma               U32
   7104 	FisInit              int32
   7105 	FinProgress          int32
   7106 	FisMutexInit         int32
   7107 	FisMallocInit        int32
   7108 	FisPCacheInit        int32
   7109 	FnRefInitMutex       int32
   7110 	FpInitMutex          uintptr
   7111 	FxLog                uintptr
   7112 	FpLogArg             uintptr
   7113 	F__ccgo_pad2         [4]byte
   7114 	FmxMemdbSize         Sqlite3_int64
   7115 	FxTestCallback       uintptr
   7116 	FbLocaltimeFault     int32
   7117 	FxAltLocaltime       uintptr
   7118 	FiOnceResetThreshold int32
   7119 	FszSorterRef         U32
   7120 	FiPrngSeed           uint32
   7121 }
   7122 
   7123 // Context pointer passed down through the tree-walk.
   7124 type RefSrcList = struct {
   7125 	Fdb          uintptr
   7126 	FpRef        uintptr
   7127 	FnExclude    I64
   7128 	FaiExclude   uintptr
   7129 	F__ccgo_pad1 [4]byte
   7130 }
   7131 
   7132 // Context pointer passed down through the tree-walk.
   7133 type IdxCover = struct {
   7134 	FpIdx uintptr
   7135 	FiCur int32
   7136 }
   7137 
   7138 // Context pointer passed down through the tree-walk.
   7139 type WindowRewrite1 = struct {
   7140 	FpWin       uintptr
   7141 	FpSrc       uintptr
   7142 	FpSub       uintptr
   7143 	FpTab       uintptr
   7144 	FpSubSelect uintptr
   7145 }
   7146 
   7147 // Context pointer passed down through the tree-walk.
   7148 type WhereConst1 = struct {
   7149 	FpParse      uintptr
   7150 	FpOomFault   uintptr
   7151 	FnConst      int32
   7152 	FnChng       int32
   7153 	FbHasAffBlob int32
   7154 	FmExcludeOn  U32
   7155 	FapExpr      uintptr
   7156 }
   7157 
   7158 // Context pointer passed down through the tree-walk.
   7159 type RenameCtx1 = struct {
   7160 	FpList uintptr
   7161 	FnList int32
   7162 	FiCol  int32
   7163 	FpTab  uintptr
   7164 	FzOld  uintptr
   7165 }
   7166 
   7167 // Context pointer passed down through the tree-walk.
   7168 type CoveringIndexCheck1 = struct {
   7169 	FpIdx        uintptr
   7170 	FiTabCur     int32
   7171 	FbExpr       U8
   7172 	FbUnidx      U8
   7173 	F__ccgo_pad1 [2]byte
   7174 }
   7175 
   7176 var sqlite3azCompileOpt = [52]uintptr{
   7177 	ts + 7,
   7178 	ts + 27,
   7179 	ts + 56,
   7180 	ts + 75,
   7181 	ts + 100,
   7182 	ts + 122,
   7183 	ts + 152,
   7184 	ts + 172,
   7185 	ts + 192,
   7186 	ts + 215,
   7187 	ts + 240,
   7188 	ts + 267,
   7189 	ts + 292,
   7190 	ts + 314,
   7191 	ts + 346,
   7192 	ts + 372,
   7193 	ts + 397,
   7194 	ts + 420,
   7195 	ts + 432,
   7196 	ts + 447,
   7197 	ts + 469,
   7198 	ts + 494,
   7199 	ts + 517,
   7200 	ts + 539,
   7201 	ts + 550,
   7202 	ts + 563,
   7203 	ts + 578,
   7204 	ts + 594,
   7205 	ts + 607,
   7206 	ts + 628,
   7207 	ts + 652,
   7208 	ts + 675,
   7209 	ts + 691,
   7210 	ts + 707,
   7211 	ts + 731,
   7212 	ts + 758,
   7213 	ts + 778,
   7214 	ts + 799,
   7215 	ts + 821,
   7216 	ts + 851,
   7217 	ts + 876,
   7218 	ts + 902,
   7219 	ts + 922,
   7220 	ts + 948,
   7221 	ts + 971,
   7222 	ts + 997,
   7223 	ts + 1019,
   7224 	ts + 1040,
   7225 	ts + 1051,
   7226 	ts + 1059,
   7227 	ts + 1073,
   7228 	ts + 1086,
   7229 }
   7230 
   7231 func Xsqlite3CompileOptions(tls *libc.TLS, pnOpt uintptr) uintptr {
   7232 	*(*int32)(unsafe.Pointer(pnOpt)) = int32(uint32(unsafe.Sizeof(sqlite3azCompileOpt)) / uint32(unsafe.Sizeof(uintptr(0))))
   7233 	return uintptr(unsafe.Pointer(&sqlite3azCompileOpt))
   7234 }
   7235 
   7236 // An array to map all upper-case characters into their corresponding
   7237 // lower-case character.
   7238 //
   7239 // SQLite only considers US-ASCII (or EBCDIC) characters.  We do not
   7240 // handle case conversions for the UTF character set since the tables
   7241 // involved are nearly as big or bigger than SQLite itself.
   7242 var Xsqlite3UpperToLower = [274]uint8{
   7243 	uint8(0), uint8(1), uint8(2), uint8(3), uint8(4), uint8(5), uint8(6), uint8(7), uint8(8), uint8(9), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17),
   7244 	uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24), uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35),
   7245 	uint8(36), uint8(37), uint8(38), uint8(39), uint8(40), uint8(41), uint8(42), uint8(43), uint8(44), uint8(45), uint8(46), uint8(47), uint8(48), uint8(49), uint8(50), uint8(51), uint8(52), uint8(53),
   7246 	uint8(54), uint8(55), uint8(56), uint8(57), uint8(58), uint8(59), uint8(60), uint8(61), uint8(62), uint8(63), uint8(64), uint8(97), uint8(98), uint8(99), uint8(100), uint8(101), uint8(102), uint8(103),
   7247 	uint8(104), uint8(105), uint8(106), uint8(107), uint8(108), uint8(109), uint8(110), uint8(111), uint8(112), uint8(113), uint8(114), uint8(115), uint8(116), uint8(117), uint8(118), uint8(119), uint8(120), uint8(121),
   7248 	uint8(122), uint8(91), uint8(92), uint8(93), uint8(94), uint8(95), uint8(96), uint8(97), uint8(98), uint8(99), uint8(100), uint8(101), uint8(102), uint8(103), uint8(104), uint8(105), uint8(106), uint8(107),
   7249 	uint8(108), uint8(109), uint8(110), uint8(111), uint8(112), uint8(113), uint8(114), uint8(115), uint8(116), uint8(117), uint8(118), uint8(119), uint8(120), uint8(121), uint8(122), uint8(123), uint8(124), uint8(125),
   7250 	uint8(126), uint8(127), uint8(128), uint8(129), uint8(130), uint8(131), uint8(132), uint8(133), uint8(134), uint8(135), uint8(136), uint8(137), uint8(138), uint8(139), uint8(140), uint8(141), uint8(142), uint8(143),
   7251 	uint8(144), uint8(145), uint8(146), uint8(147), uint8(148), uint8(149), uint8(150), uint8(151), uint8(152), uint8(153), uint8(154), uint8(155), uint8(156), uint8(157), uint8(158), uint8(159), uint8(160), uint8(161),
   7252 	uint8(162), uint8(163), uint8(164), uint8(165), uint8(166), uint8(167), uint8(168), uint8(169), uint8(170), uint8(171), uint8(172), uint8(173), uint8(174), uint8(175), uint8(176), uint8(177), uint8(178), uint8(179),
   7253 	uint8(180), uint8(181), uint8(182), uint8(183), uint8(184), uint8(185), uint8(186), uint8(187), uint8(188), uint8(189), uint8(190), uint8(191), uint8(192), uint8(193), uint8(194), uint8(195), uint8(196), uint8(197),
   7254 	uint8(198), uint8(199), uint8(200), uint8(201), uint8(202), uint8(203), uint8(204), uint8(205), uint8(206), uint8(207), uint8(208), uint8(209), uint8(210), uint8(211), uint8(212), uint8(213), uint8(214), uint8(215),
   7255 	uint8(216), uint8(217), uint8(218), uint8(219), uint8(220), uint8(221), uint8(222), uint8(223), uint8(224), uint8(225), uint8(226), uint8(227), uint8(228), uint8(229), uint8(230), uint8(231), uint8(232), uint8(233),
   7256 	uint8(234), uint8(235), uint8(236), uint8(237), uint8(238), uint8(239), uint8(240), uint8(241), uint8(242), uint8(243), uint8(244), uint8(245), uint8(246), uint8(247), uint8(248), uint8(249), uint8(250), uint8(251),
   7257 	uint8(252), uint8(253), uint8(254), uint8(255),
   7258 	uint8(1), uint8(0), uint8(0), uint8(1), uint8(1), uint8(0),
   7259 	uint8(0), uint8(1), uint8(0), uint8(1), uint8(0), uint8(1),
   7260 	uint8(1), uint8(0), uint8(1), uint8(0), uint8(0), uint8(1),
   7261 }
   7262 var Xsqlite3aLTb uintptr = 0
   7263 var Xsqlite3aEQb uintptr = 0
   7264 var Xsqlite3aGTb uintptr = 0
   7265 
   7266 // The following 256 byte lookup table is used to support SQLites built-in
   7267 // equivalents to the following standard library functions:
   7268 //
   7269 //	isspace()                        0x01
   7270 //	isalpha()                        0x02
   7271 //	isdigit()                        0x04
   7272 //	isalnum()                        0x06
   7273 //	isxdigit()                       0x08
   7274 //	toupper()                        0x20
   7275 //	SQLite identifier character      0x40
   7276 //	Quote character                  0x80
   7277 //
   7278 // Bit 0x20 is set if the mapped character requires translation to upper
   7279 // case. i.e. if the character is a lower-case ASCII character.
   7280 // If x is a lower-case ASCII character, then its upper-case equivalent
   7281 // is (x - 0x20). Therefore toupper() can be implemented as:
   7282 //
   7283 //	(x & ~(map[x]&0x20))
   7284 //
   7285 // The equivalent of tolower() is implemented using the sqlite3UpperToLower[]
   7286 // array. tolower() is used more often than toupper() by SQLite.
   7287 //
   7288 // Bit 0x40 is set if the character is non-alphanumeric and can be used in an
   7289 // SQLite identifier.  Identifiers are alphanumerics, "_", "$", and any
   7290 // non-ASCII UTF character. Hence the test for whether or not a character is
   7291 // part of an identifier is 0x46.
   7292 var Xsqlite3CtypeMap = [256]uint8{
   7293 	uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00),
   7294 	uint8(0x00), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x00), uint8(0x00),
   7295 	uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00),
   7296 	uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00),
   7297 	uint8(0x01), uint8(0x00), uint8(0x80), uint8(0x00), uint8(0x40), uint8(0x00), uint8(0x00), uint8(0x80),
   7298 	uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00),
   7299 	uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c),
   7300 	uint8(0x0c), uint8(0x0c), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00),
   7301 	uint8(0x00), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x02),
   7302 	uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02),
   7303 	uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02),
   7304 	uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x80), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x40),
   7305 	uint8(0x80), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x22),
   7306 	uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22),
   7307 	uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22),
   7308 	uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00),
   7309 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7310 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7311 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7312 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7313 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7314 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7315 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7316 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7317 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7318 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7319 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7320 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7321 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7322 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7323 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7324 	uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40),
   7325 }
   7326 
   7327 // The following singleton contains the global configuration for
   7328 // the SQLite library.
   7329 var Xsqlite3Config = Sqlite3Config{
   7330 	FbCoreMutex:         U8(1),
   7331 	FbFullMutex:         U8(libc.Bool32(SQLITE_THREADSAFE == 1)),
   7332 	FbUseCis:            U8(SQLITE_ALLOW_COVERING_INDEX_SCAN),
   7333 	FbExtraSchemaChecks: U8(1),
   7334 	FmxStrlen:           0x7ffffffe,
   7335 	FszLookaside:        1200, FnLookaside: 40,
   7336 	FnStmtSpill:          64 * 1024,
   7337 	FmxMmap:              int64(SQLITE_MAX_MMAP_SIZE),
   7338 	FnPage:               SQLITE_DEFAULT_PCACHE_INITSZ,
   7339 	FszPma:               U32(SQLITE_SORTER_PMASZ),
   7340 	FmxMemdbSize:         int64(SQLITE_MEMDB_DEFAULT_MAXSIZE),
   7341 	FiOnceResetThreshold: 0x7ffffffe,
   7342 	FszSorterRef:         U32(SQLITE_DEFAULT_SORTERREF_SIZE),
   7343 }
   7344 
   7345 // Hash table for global functions - functions common to all
   7346 // database connections.  After initialization, this table is
   7347 // read-only.
   7348 var Xsqlite3BuiltinFunctions FuncDefHash
   7349 
   7350 // The value of the "pending" byte must be 0x40000000 (1 byte past the
   7351 // 1-gibabyte boundary) in a compatible database.  SQLite never uses
   7352 // the database page that contains the pending byte.  It never attempts
   7353 // to read or write that page.  The pending byte page is set aside
   7354 // for use by the VFS layers as space for managing file locks.
   7355 //
   7356 // During testing, it is often desirable to move the pending byte to
   7357 // a different position in the file.  This allows code that has to
   7358 // deal with the pending byte to run on files that are much smaller
   7359 // than 1 GiB.  The sqlite3_test_control() interface can be used to
   7360 // move the pending byte.
   7361 //
   7362 // IMPORTANT:  Changing the pending byte to any value other than
   7363 // 0x40000000 results in an incompatible database file format!
   7364 // Changing the pending byte during operation will result in undefined
   7365 // and incorrect behavior.
   7366 var Xsqlite3PendingByte int32 = 0x40000000
   7367 
   7368 // Tracing flags set by SQLITE_TESTCTRL_TRACEFLAGS.
   7369 var Xsqlite3TreeTrace U32 = U32(0)
   7370 var Xsqlite3WhereTrace U32 = U32(0)
   7371 
   7372 // #include "opcodes.h"
   7373 // Properties of opcodes.  The OPFLG_INITIALIZER macro is
   7374 // created by mkopcodeh.awk during compilation.  Data is obtained
   7375 // from the comments following the "case OP_xxxx:" statements in
   7376 // the vdbe.c file.
   7377 var Xsqlite3OpcodeProperty = [187]uint8{uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x10), uint8(0x00), uint8(0x41), uint8(0x00), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x03), uint8(0x03), uint8(0x01), uint8(0x01), uint8(0x03), uint8(0x03), uint8(0x01), uint8(0x12), uint8(0x01), uint8(0x49), uint8(0x49), uint8(0x49), uint8(0x49), uint8(0x01), uint8(0x49), uint8(0x49), uint8(0x49), uint8(0x49), uint8(0x49), uint8(0x49), uint8(0x41), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x41), uint8(0x01), uint8(0x41), uint8(0x41), uint8(0x41), uint8(0x41), uint8(0x41), uint8(0x26), uint8(0x26), uint8(0x41), uint8(0x23), uint8(0x0b), uint8(0x01), uint8(0x01), uint8(0x03), uint8(0x03), uint8(0x0b), uint8(0x0b), uint8(0x0b), uint8(0x0b), uint8(0x0b), uint8(0x0b), uint8(0x01), uint8(0x03), uint8(0x03), uint8(0x03), uint8(0x01), uint8(0x41), uint8(0x01), uint8(0x00), uint8(0x00), uint8(0x02), uint8(0x02), uint8(0x08), uint8(0x00), uint8(0x10), uint8(0x10), uint8(0x10), uint8(0x00), uint8(0x10), uint8(0x00), uint8(0x10), uint8(0x10), uint8(0x00), uint8(0x00), uint8(0x10), uint8(0x10), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x00), uint8(0x00), uint8(0x12), uint8(0x1e), uint8(0x20), uint8(0x40), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x10), uint8(0x10), uint8(0x00), uint8(0x40), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x26), uint8(0x40), uint8(0x00), uint8(0x12), uint8(0x40), uint8(0x40), uint8(0x10), uint8(0x40), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x40), uint8(0x00), uint8(0x40), uint8(0x40), uint8(0x10), uint8(0x10), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x50), uint8(0x00), uint8(0x40), uint8(0x04), uint8(0x04), uint8(0x00), uint8(0x40), uint8(0x50), uint8(0x40), uint8(0x10), uint8(0x00), uint8(0x00), uint8(0x10), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x10), uint8(0x00), uint8(0x00), uint8(0x06), uint8(0x10), uint8(0x00), uint8(0x04), uint8(0x1a), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x40), uint8(0x50), uint8(0x40), uint8(0x00), uint8(0x10), uint8(0x10), uint8(0x02), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00)}
   7378 
   7379 // Name of the default collating sequence
   7380 var Xsqlite3StrBINARY = *(*[7]uint8)(unsafe.Pointer(ts + 1099))
   7381 
   7382 // Standard typenames.  These names must match the COLTYPE_* definitions.
   7383 // Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
   7384 //
   7385 //	sqlite3StdType[]            The actual names of the datatypes.
   7386 //
   7387 //	sqlite3StdTypeLen[]         The length (in bytes) of each entry
   7388 //	                            in sqlite3StdType[].
   7389 //
   7390 //	sqlite3StdTypeAffinity[]    The affinity associated with each entry
   7391 //	                            in sqlite3StdType[].
   7392 var Xsqlite3StdTypeLen = [6]uint8{uint8(3), uint8(4), uint8(3), uint8(7), uint8(4), uint8(4)}
   7393 var Xsqlite3StdTypeAffinity = [6]uint8{
   7394 	uint8(SQLITE_AFF_NUMERIC),
   7395 	uint8(SQLITE_AFF_BLOB),
   7396 	uint8(SQLITE_AFF_INTEGER),
   7397 	uint8(SQLITE_AFF_INTEGER),
   7398 	uint8(SQLITE_AFF_REAL),
   7399 	uint8(SQLITE_AFF_TEXT),
   7400 }
   7401 var Xsqlite3StdType = [6]uintptr{
   7402 	ts + 1106,
   7403 	ts + 1110,
   7404 	ts + 1115,
   7405 	ts + 1119,
   7406 	ts + 1127,
   7407 	ts + 1132,
   7408 }
   7409 
   7410 // SQL is translated into a sequence of instructions to be
   7411 // executed by a virtual machine.  Each instruction is an instance
   7412 // of the following structure.
   7413 type Op = VdbeOp1
   7414 
   7415 // Boolean values
   7416 type Bool = uint32
   7417 
   7418 // Opaque type used by code in vdbesort.c
   7419 type VdbeSorter1 = struct {
   7420 	FmnPmaSize   int32
   7421 	FmxPmaSize   int32
   7422 	FmxKeysize   int32
   7423 	Fpgsz        int32
   7424 	FpReader     uintptr
   7425 	FpMerger     uintptr
   7426 	Fdb          uintptr
   7427 	FpKeyInfo    uintptr
   7428 	FpUnpacked   uintptr
   7429 	Flist        SorterList
   7430 	FiMemory     int32
   7431 	FnMemory     int32
   7432 	FbUsePMA     U8
   7433 	FbUseThreads U8
   7434 	FiPrev       U8
   7435 	FnTask       U8
   7436 	FtypeMask    U8
   7437 	F__ccgo_pad1 [3]byte
   7438 	FaTask       [1]SortSubtask
   7439 }
   7440 
   7441 // Opaque type used by code in vdbesort.c
   7442 type VdbeSorter = VdbeSorter1
   7443 
   7444 // Elements of the linked list at Vdbe.pAuxData
   7445 type AuxData1 = struct {
   7446 	FiAuxOp     int32
   7447 	FiAuxArg    int32
   7448 	FpAux       uintptr
   7449 	FxDeleteAux uintptr
   7450 	FpNextAux   uintptr
   7451 }
   7452 
   7453 // Elements of the linked list at Vdbe.pAuxData
   7454 type AuxData = AuxData1
   7455 
   7456 // A VdbeCursor is an superclass (a wrapper) for various cursor objects:
   7457 //
   7458 //   - A b-tree cursor
   7459 //   - In the main database or in an ephemeral database
   7460 //   - On either an index or a table
   7461 //   - A sorter
   7462 //   - A virtual table
   7463 //   - A one-row "pseudotable" stored in a single register
   7464 type VdbeCursor1 = struct {
   7465 	FeCurType       U8
   7466 	FiDb            I8
   7467 	FnullRow        U8
   7468 	FdeferredMoveto U8
   7469 	FisTable        U8
   7470 	F__ccgo_pad1    [3]byte
   7471 	FisEphemeral    uint8
   7472 	F__ccgo_pad2    [1]byte
   7473 	FseekHit        U16
   7474 	Fub             struct{ FpBtx uintptr }
   7475 	FseqCount       I64
   7476 	FcacheStatus    U32
   7477 	FseekResult     int32
   7478 	FpAltCursor     uintptr
   7479 	Fuc             struct{ FpCursor uintptr }
   7480 	FpKeyInfo       uintptr
   7481 	FiHdrOffset     U32
   7482 	FpgnoRoot       Pgno
   7483 	FnField         I16
   7484 	FnHdrParsed     U16
   7485 	FmovetoTarget   I64
   7486 	FaOffset        uintptr
   7487 	FaRow           uintptr
   7488 	FpayloadSize    U32
   7489 	FszRow          U32
   7490 	FaType          [1]U32
   7491 	F__ccgo_pad3    [4]byte
   7492 }
   7493 
   7494 // A VdbeCursor is an superclass (a wrapper) for various cursor objects:
   7495 //
   7496 //   - A b-tree cursor
   7497 //   - In the main database or in an ephemeral database
   7498 //   - On either an index or a table
   7499 //   - A sorter
   7500 //   - A virtual table
   7501 //   - A one-row "pseudotable" stored in a single register
   7502 type VdbeCursor = VdbeCursor1
   7503 
   7504 // When a sub-program is executed (OP_Program), a structure of this type
   7505 // is allocated to store the current value of the program counter, as
   7506 // well as the current memory cell array and various other frame specific
   7507 // values stored in the Vdbe struct. When the sub-program is finished,
   7508 // these values are copied back to the Vdbe from the VdbeFrame structure,
   7509 // restoring the state of the VM to as it was before the sub-program
   7510 // began executing.
   7511 //
   7512 // The memory for a VdbeFrame object is allocated and managed by a memory
   7513 // cell in the parent (calling) frame. When the memory cell is deleted or
   7514 // overwritten, the VdbeFrame object is not freed immediately. Instead, it
   7515 // is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame
   7516 // list is deleted when the VM is reset in VdbeHalt(). The reason for doing
   7517 // this instead of deleting the VdbeFrame immediately is to avoid recursive
   7518 // calls to sqlite3VdbeMemRelease() when the memory cells belonging to the
   7519 // child frame are released.
   7520 //
   7521 // The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is
   7522 // set to NULL if the currently executing frame is the main program.
   7523 type VdbeFrame1 = struct {
   7524 	Fv           uintptr
   7525 	FpParent     uintptr
   7526 	FaOp         uintptr
   7527 	FaMem        uintptr
   7528 	FapCsr       uintptr
   7529 	FaOnce       uintptr
   7530 	Ftoken       uintptr
   7531 	F__ccgo_pad1 [4]byte
   7532 	FlastRowid   I64
   7533 	FpAuxData    uintptr
   7534 	FnCursor     int32
   7535 	Fpc          int32
   7536 	FnOp         int32
   7537 	FnMem        int32
   7538 	FnChildMem   int32
   7539 	FnChildCsr   int32
   7540 	F__ccgo_pad2 [4]byte
   7541 	FnChange     I64
   7542 	FnDbChange   I64
   7543 }
   7544 
   7545 // When a sub-program is executed (OP_Program), a structure of this type
   7546 // is allocated to store the current value of the program counter, as
   7547 // well as the current memory cell array and various other frame specific
   7548 // values stored in the Vdbe struct. When the sub-program is finished,
   7549 // these values are copied back to the Vdbe from the VdbeFrame structure,
   7550 // restoring the state of the VM to as it was before the sub-program
   7551 // began executing.
   7552 //
   7553 // The memory for a VdbeFrame object is allocated and managed by a memory
   7554 // cell in the parent (calling) frame. When the memory cell is deleted or
   7555 // overwritten, the VdbeFrame object is not freed immediately. Instead, it
   7556 // is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame
   7557 // list is deleted when the VM is reset in VdbeHalt(). The reason for doing
   7558 // this instead of deleting the VdbeFrame immediately is to avoid recursive
   7559 // calls to sqlite3VdbeMemRelease() when the memory cells belonging to the
   7560 // child frame are released.
   7561 //
   7562 // The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is
   7563 // set to NULL if the currently executing frame is the main program.
   7564 type VdbeFrame = VdbeFrame1
   7565 
   7566 // Internally, the vdbe manipulates nearly all SQL values as Mem
   7567 // structures. Each Mem struct may cache multiple representations (string,
   7568 // integer etc.) of the same value.
   7569 type MemValue = struct{ Fr float64 }
   7570 
   7571 // A bitfield type for use inside of structures.  Always follow with :N where
   7572 // N is the number of bits.
   7573 type Bft = uint32
   7574 
   7575 // The ScanStatus object holds a single value for the
   7576 // sqlite3_stmt_scanstatus() interface.
   7577 //
   7578 // aAddrRange[]:
   7579 //
   7580 //	This array is used by ScanStatus elements associated with EQP
   7581 //	notes that make an SQLITE_SCANSTAT_NCYCLE value available. It is
   7582 //	an array of up to 3 ranges of VM addresses for which the Vdbe.anCycle[]
   7583 //	values should be summed to calculate the NCYCLE value. Each pair of
   7584 //	integer addresses is a start and end address (both inclusive) for a range
   7585 //	instructions. A start value of 0 indicates an empty range.
   7586 type ScanStatus1 = struct {
   7587 	FaddrExplain int32
   7588 	FaAddrRange  [6]int32
   7589 	FaddrLoop    int32
   7590 	FaddrVisit   int32
   7591 	FiSelectID   int32
   7592 	FnEst        LogEst
   7593 	F__ccgo_pad1 [2]byte
   7594 	FzName       uintptr
   7595 }
   7596 
   7597 // The ScanStatus object holds a single value for the
   7598 // sqlite3_stmt_scanstatus() interface.
   7599 //
   7600 // aAddrRange[]:
   7601 //
   7602 //	This array is used by ScanStatus elements associated with EQP
   7603 //	notes that make an SQLITE_SCANSTAT_NCYCLE value available. It is
   7604 //	an array of up to 3 ranges of VM addresses for which the Vdbe.anCycle[]
   7605 //	values should be summed to calculate the NCYCLE value. Each pair of
   7606 //	integer addresses is a start and end address (both inclusive) for a range
   7607 //	instructions. A start value of 0 indicates an empty range.
   7608 type ScanStatus = ScanStatus1
   7609 
   7610 // The DblquoteStr object holds the text of a double-quoted
   7611 // string for a prepared statement.  A linked list of these objects
   7612 // is constructed during statement parsing and is held on Vdbe.pDblStr.
   7613 // When computing a normalized SQL statement for an SQL statement, that
   7614 // list is consulted for each double-quoted identifier to see if the
   7615 // identifier should really be a string literal.
   7616 type DblquoteStr1 = struct {
   7617 	FpNextStr uintptr
   7618 	Fz        [8]uint8
   7619 }
   7620 
   7621 // The DblquoteStr object holds the text of a double-quoted
   7622 // string for a prepared statement.  A linked list of these objects
   7623 // is constructed during statement parsing and is held on Vdbe.pDblStr.
   7624 // When computing a normalized SQL statement for an SQL statement, that
   7625 // list is consulted for each double-quoted identifier to see if the
   7626 // identifier should really be a string literal.
   7627 type DblquoteStr = DblquoteStr1
   7628 
   7629 // An instance of this object is used to pass an vector of values into
   7630 // OP_VFilter, the xFilter method of a virtual table.  The vector is the
   7631 // set of values on the right-hand side of an IN constraint.
   7632 //
   7633 // The value as passed into xFilter is an sqlite3_value with a "pointer"
   7634 // type, such as is generated by sqlite3_result_pointer() and read by
   7635 // sqlite3_value_pointer.  Such values have MEM_Term|MEM_Subtype|MEM_Null
   7636 // and a subtype of 'p'.  The sqlite3_vtab_in_first() and _next() interfaces
   7637 // know how to use this object to step through all the values in the
   7638 // right operand of the IN constraint.
   7639 type ValueList1 = struct {
   7640 	FpCsr uintptr
   7641 	FpOut uintptr
   7642 }
   7643 
   7644 // An instance of this object is used to pass an vector of values into
   7645 // OP_VFilter, the xFilter method of a virtual table.  The vector is the
   7646 // set of values on the right-hand side of an IN constraint.
   7647 //
   7648 // The value as passed into xFilter is an sqlite3_value with a "pointer"
   7649 // type, such as is generated by sqlite3_result_pointer() and read by
   7650 // sqlite3_value_pointer.  Such values have MEM_Term|MEM_Subtype|MEM_Null
   7651 // and a subtype of 'p'.  The sqlite3_vtab_in_first() and _next() interfaces
   7652 // know how to use this object to step through all the values in the
   7653 // right operand of the IN constraint.
   7654 type ValueList = ValueList1
   7655 
   7656 // Variables in which to record status information.
   7657 type Sqlite3StatValueType = U32
   7658 type sqlite3StatType = struct {
   7659 	FnowValue [10]Sqlite3StatValueType
   7660 	FmxValue  [10]Sqlite3StatValueType
   7661 }
   7662 
   7663 type Sqlite3StatType = sqlite3StatType
   7664 
   7665 var sqlite3Stat = sqlite3StatType{}
   7666 
   7667 var statMutex = [10]uint8{
   7668 	uint8(0),
   7669 	uint8(1),
   7670 	uint8(1),
   7671 	uint8(0),
   7672 	uint8(0),
   7673 	uint8(0),
   7674 	uint8(0),
   7675 	uint8(1),
   7676 	uint8(0),
   7677 	uint8(0),
   7678 }
   7679 
   7680 // Return the current value of a status parameter.  The caller must
   7681 // be holding the appropriate mutex.
   7682 func Xsqlite3StatusValue(tls *libc.TLS, op int32) Sqlite3_int64 {
   7683 	return Sqlite3_int64(*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4)))
   7684 }
   7685 
   7686 // Add N to the value of a status record.  The caller must hold the
   7687 // appropriate mutex.  (Locking is checked by assert()).
   7688 //
   7689 // The StatusUp() routine can accept positive or negative values for N.
   7690 // The value of N is added to the current status value and the high-water
   7691 // mark is adjusted if necessary.
   7692 //
   7693 // The StatusDown() routine lowers the current value by N.  The highwater
   7694 // mark is unchanged.  N must be non-negative for StatusDown().
   7695 func Xsqlite3StatusUp(tls *libc.TLS, op int32, N int32) {
   7696 	*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4)) += Sqlite3StatValueType(N)
   7697 	if *(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4)) > *(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + 40 + uintptr(op)*4)) {
   7698 		*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + 40 + uintptr(op)*4)) = *(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4))
   7699 	}
   7700 }
   7701 
   7702 func Xsqlite3StatusDown(tls *libc.TLS, op int32, N int32) {
   7703 	*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4)) -= Sqlite3StatValueType(N)
   7704 }
   7705 
   7706 // Adjust the highwater mark if necessary.
   7707 // The caller must hold the appropriate mutex.
   7708 func Xsqlite3StatusHighwater(tls *libc.TLS, op int32, X int32) {
   7709 	var newValue Sqlite3StatValueType
   7710 
   7711 	newValue = Sqlite3StatValueType(X)
   7712 
   7713 	if newValue > *(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + 40 + uintptr(op)*4)) {
   7714 		*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + 40 + uintptr(op)*4)) = newValue
   7715 	}
   7716 }
   7717 
   7718 // Query status information.
   7719 func Xsqlite3_status64(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) int32 {
   7720 	var pMutex uintptr
   7721 	_ = pMutex
   7722 
   7723 	if op < 0 || op >= int32(uint32(unsafe.Sizeof([10]Sqlite3StatValueType{}))/uint32(unsafe.Sizeof(Sqlite3StatValueType(0)))) {
   7724 		return Xsqlite3MisuseError(tls, 23233)
   7725 	}
   7726 	if statMutex[op] != 0 {
   7727 		pMutex = Xsqlite3Pcache1Mutex(tls)
   7728 	} else {
   7729 		pMutex = Xsqlite3MallocMutex(tls)
   7730 	}
   7731 	Xsqlite3_mutex_enter(tls, pMutex)
   7732 	*(*Sqlite3_int64)(unsafe.Pointer(pCurrent)) = Sqlite3_int64(*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4)))
   7733 	*(*Sqlite3_int64)(unsafe.Pointer(pHighwater)) = Sqlite3_int64(*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + 40 + uintptr(op)*4)))
   7734 	if resetFlag != 0 {
   7735 		*(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + 40 + uintptr(op)*4)) = *(*Sqlite3StatValueType)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Stat)) + uintptr(op)*4))
   7736 	}
   7737 	Xsqlite3_mutex_leave(tls, pMutex)
   7738 	_ = pMutex
   7739 	return SQLITE_OK
   7740 }
   7741 
   7742 func Xsqlite3_status(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) int32 {
   7743 	bp := tls.Alloc(16)
   7744 	defer tls.Free(16)
   7745 
   7746 	*(*Sqlite3_int64)(unsafe.Pointer(bp)) = int64(0)
   7747 	*(*Sqlite3_int64)(unsafe.Pointer(bp + 8)) = int64(0)
   7748 	var rc int32
   7749 	rc = Xsqlite3_status64(tls, op, bp, bp+8, resetFlag)
   7750 	if rc == 0 {
   7751 		*(*int32)(unsafe.Pointer(pCurrent)) = int32(*(*Sqlite3_int64)(unsafe.Pointer(bp)))
   7752 		*(*int32)(unsafe.Pointer(pHighwater)) = int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8)))
   7753 	}
   7754 	return rc
   7755 }
   7756 
   7757 func countLookasideSlots(tls *libc.TLS, p uintptr) U32 {
   7758 	var cnt U32 = U32(0)
   7759 	for p != 0 {
   7760 		p = (*LookasideSlot)(unsafe.Pointer(p)).FpNext
   7761 		cnt++
   7762 	}
   7763 	return cnt
   7764 }
   7765 
   7766 // Count the number of slots of lookaside memory that are outstanding
   7767 func Xsqlite3LookasideUsed(tls *libc.TLS, db uintptr, pHighwater uintptr) int32 {
   7768 	var nInit U32 = countLookasideSlots(tls, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit)
   7769 	var nFree U32 = countLookasideSlots(tls, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree)
   7770 	nInit = nInit + countLookasideSlots(tls, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit)
   7771 	nFree = nFree + countLookasideSlots(tls, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree)
   7772 	if pHighwater != 0 {
   7773 		*(*int32)(unsafe.Pointer(pHighwater)) = int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot - nInit)
   7774 	}
   7775 	return int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot - (nInit + nFree))
   7776 }
   7777 
   7778 // Query status information for a single database connection
   7779 func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) int32 {
   7780 	bp := tls.Alloc(12)
   7781 	defer tls.Free(12)
   7782 
   7783 	var rc int32 = SQLITE_OK
   7784 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
   7785 	{
   7786 		switch op {
   7787 		case SQLITE_DBSTATUS_LOOKASIDE_USED:
   7788 			{
   7789 				*(*int32)(unsafe.Pointer(pCurrent)) = Xsqlite3LookasideUsed(tls, db, pHighwater)
   7790 				if resetFlag != 0 {
   7791 					var p uintptr = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree
   7792 					if p != 0 {
   7793 						for (*LookasideSlot)(unsafe.Pointer(p)).FpNext != 0 {
   7794 							p = (*LookasideSlot)(unsafe.Pointer(p)).FpNext
   7795 						}
   7796 						(*LookasideSlot)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit
   7797 						(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree
   7798 						(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = uintptr(0)
   7799 					}
   7800 					p = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree
   7801 					if p != 0 {
   7802 						for (*LookasideSlot)(unsafe.Pointer(p)).FpNext != 0 {
   7803 							p = (*LookasideSlot)(unsafe.Pointer(p)).FpNext
   7804 						}
   7805 						(*LookasideSlot)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit
   7806 						(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree
   7807 						(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = uintptr(0)
   7808 					}
   7809 				}
   7810 				break
   7811 
   7812 			}
   7813 
   7814 		case SQLITE_DBSTATUS_LOOKASIDE_HIT:
   7815 			fallthrough
   7816 		case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:
   7817 			fallthrough
   7818 		case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL:
   7819 			{
   7820 				*(*int32)(unsafe.Pointer(pCurrent)) = 0
   7821 				*(*int32)(unsafe.Pointer(pHighwater)) = int32(*(*U32)(unsafe.Pointer(db + 320 + 16 + uintptr(op-SQLITE_DBSTATUS_LOOKASIDE_HIT)*4)))
   7822 				if resetFlag != 0 {
   7823 					*(*U32)(unsafe.Pointer(db + 320 + 16 + uintptr(op-SQLITE_DBSTATUS_LOOKASIDE_HIT)*4)) = U32(0)
   7824 				}
   7825 				break
   7826 
   7827 			}
   7828 
   7829 		case SQLITE_DBSTATUS_CACHE_USED_SHARED:
   7830 			fallthrough
   7831 		case SQLITE_DBSTATUS_CACHE_USED:
   7832 			{
   7833 				var totalUsed int32 = 0
   7834 				var i int32
   7835 				Xsqlite3BtreeEnterAll(tls, db)
   7836 				for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
   7837 					var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
   7838 					if pBt != 0 {
   7839 						var pPager uintptr = Xsqlite3BtreePager(tls, pBt)
   7840 						var nByte int32 = Xsqlite3PagerMemUsed(tls, pPager)
   7841 						if op == SQLITE_DBSTATUS_CACHE_USED_SHARED {
   7842 							nByte = nByte / Xsqlite3BtreeConnectionCount(tls, pBt)
   7843 						}
   7844 						totalUsed = totalUsed + nByte
   7845 					}
   7846 				}
   7847 				Xsqlite3BtreeLeaveAll(tls, db)
   7848 				*(*int32)(unsafe.Pointer(pCurrent)) = totalUsed
   7849 				*(*int32)(unsafe.Pointer(pHighwater)) = 0
   7850 				break
   7851 
   7852 			}
   7853 
   7854 		case SQLITE_DBSTATUS_SCHEMA_USED:
   7855 			{
   7856 				var i int32
   7857 				*(*int32)(unsafe.Pointer(bp)) = 0
   7858 
   7859 				Xsqlite3BtreeEnterAll(tls, db)
   7860 				(*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed = bp
   7861 
   7862 				(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart
   7863 				for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
   7864 					var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpSchema
   7865 					if pSchema != uintptr(0) {
   7866 						var p uintptr
   7867 
   7868 						*(*int32)(unsafe.Pointer(bp)) += int32(uint32((*struct{ f func(*libc.TLS, int32) int32 })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxRoundup})).f(tls, int32(unsafe.Sizeof(HashElem{})))) * ((*Schema)(unsafe.Pointer(pSchema)).FtblHash.Fcount +
   7869 							(*Schema)(unsafe.Pointer(pSchema)).FtrigHash.Fcount +
   7870 							(*Schema)(unsafe.Pointer(pSchema)).FidxHash.Fcount +
   7871 							(*Schema)(unsafe.Pointer(pSchema)).FfkeyHash.Fcount))
   7872 						*(*int32)(unsafe.Pointer(bp)) += int32(Xsqlite3_msize(tls, (*Schema)(unsafe.Pointer(pSchema)).FtblHash.Fht))
   7873 						*(*int32)(unsafe.Pointer(bp)) += int32(Xsqlite3_msize(tls, (*Schema)(unsafe.Pointer(pSchema)).FtrigHash.Fht))
   7874 						*(*int32)(unsafe.Pointer(bp)) += int32(Xsqlite3_msize(tls, (*Schema)(unsafe.Pointer(pSchema)).FidxHash.Fht))
   7875 						*(*int32)(unsafe.Pointer(bp)) += int32(Xsqlite3_msize(tls, (*Schema)(unsafe.Pointer(pSchema)).FfkeyHash.Fht))
   7876 
   7877 						for p = (*Hash)(unsafe.Pointer(pSchema + 40)).Ffirst; p != 0; p = (*HashElem)(unsafe.Pointer(p)).Fnext {
   7878 							Xsqlite3DeleteTrigger(tls, db, (*HashElem)(unsafe.Pointer(p)).Fdata)
   7879 						}
   7880 						for p = (*Hash)(unsafe.Pointer(pSchema + 8)).Ffirst; p != 0; p = (*HashElem)(unsafe.Pointer(p)).Fnext {
   7881 							Xsqlite3DeleteTable(tls, db, (*HashElem)(unsafe.Pointer(p)).Fdata)
   7882 						}
   7883 					}
   7884 				}
   7885 				(*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed = uintptr(0)
   7886 				(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd
   7887 				Xsqlite3BtreeLeaveAll(tls, db)
   7888 
   7889 				*(*int32)(unsafe.Pointer(pHighwater)) = 0
   7890 				*(*int32)(unsafe.Pointer(pCurrent)) = *(*int32)(unsafe.Pointer(bp))
   7891 				break
   7892 
   7893 			}
   7894 
   7895 		case SQLITE_DBSTATUS_STMT_USED:
   7896 			{
   7897 				var pVdbe uintptr
   7898 				*(*int32)(unsafe.Pointer(bp + 4)) = 0
   7899 
   7900 				(*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed = bp + 4
   7901 
   7902 				(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart
   7903 				for pVdbe = (*Sqlite3)(unsafe.Pointer(db)).FpVdbe; pVdbe != 0; pVdbe = (*Vdbe1)(unsafe.Pointer(pVdbe)).FpVNext {
   7904 					Xsqlite3VdbeDelete(tls, pVdbe)
   7905 				}
   7906 				(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd
   7907 				(*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed = uintptr(0)
   7908 
   7909 				*(*int32)(unsafe.Pointer(pHighwater)) = 0
   7910 				*(*int32)(unsafe.Pointer(pCurrent)) = *(*int32)(unsafe.Pointer(bp + 4))
   7911 
   7912 				break
   7913 
   7914 			}
   7915 
   7916 		case SQLITE_DBSTATUS_CACHE_SPILL:
   7917 			op = SQLITE_DBSTATUS_CACHE_WRITE + 1
   7918 			fallthrough
   7919 		case SQLITE_DBSTATUS_CACHE_HIT:
   7920 			fallthrough
   7921 		case SQLITE_DBSTATUS_CACHE_MISS:
   7922 			fallthrough
   7923 		case SQLITE_DBSTATUS_CACHE_WRITE:
   7924 			{
   7925 				var i int32
   7926 				*(*int32)(unsafe.Pointer(bp + 8)) = 0
   7927 
   7928 				for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
   7929 					if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpBt != 0 {
   7930 						var pPager uintptr = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpBt)
   7931 						Xsqlite3PagerCacheStat(tls, pPager, op, resetFlag, bp+8)
   7932 					}
   7933 				}
   7934 				*(*int32)(unsafe.Pointer(pHighwater)) = 0
   7935 
   7936 				*(*int32)(unsafe.Pointer(pCurrent)) = *(*int32)(unsafe.Pointer(bp + 8))
   7937 				break
   7938 
   7939 			}
   7940 
   7941 		case SQLITE_DBSTATUS_DEFERRED_FKS:
   7942 			{
   7943 				*(*int32)(unsafe.Pointer(pHighwater)) = 0
   7944 				*(*int32)(unsafe.Pointer(pCurrent)) = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons > int64(0) || (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons > int64(0))
   7945 				break
   7946 
   7947 			}
   7948 
   7949 		default:
   7950 			{
   7951 				rc = SQLITE_ERROR
   7952 
   7953 			}
   7954 		}
   7955 	}
   7956 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
   7957 	return rc
   7958 }
   7959 
   7960 type timex = struct {
   7961 	Fmodes     uint32
   7962 	Foffset    X__syscall_slong_t
   7963 	Ffreq      X__syscall_slong_t
   7964 	Fmaxerror  X__syscall_slong_t
   7965 	Festerror  X__syscall_slong_t
   7966 	Fstatus    int32
   7967 	Fconstant  X__syscall_slong_t
   7968 	Fprecision X__syscall_slong_t
   7969 	Ftolerance X__syscall_slong_t
   7970 	Ftime      struct {
   7971 		Ftv_sec  X__time_t
   7972 		Ftv_usec X__suseconds_t
   7973 	}
   7974 	Ftick    X__syscall_slong_t
   7975 	Fppsfreq X__syscall_slong_t
   7976 	Fjitter  X__syscall_slong_t
   7977 	Fshift   int32
   7978 	Fstabil  X__syscall_slong_t
   7979 	Fjitcnt  X__syscall_slong_t
   7980 	Fcalcnt  X__syscall_slong_t
   7981 	Ferrcnt  X__syscall_slong_t
   7982 	Fstbcnt  X__syscall_slong_t
   7983 	Ftai     int32
   7984 	__84     uint32
   7985 	__88     uint32
   7986 	__92     uint32
   7987 	__96     uint32
   7988 	__100    uint32
   7989 	__104    uint32
   7990 	__108    uint32
   7991 	__112    uint32
   7992 	__116    uint32
   7993 	__120    uint32
   7994 	__124    uint32
   7995 }
   7996 
   7997 type tm = struct {
   7998 	Ftm_sec    int32
   7999 	Ftm_min    int32
   8000 	Ftm_hour   int32
   8001 	Ftm_mday   int32
   8002 	Ftm_mon    int32
   8003 	Ftm_year   int32
   8004 	Ftm_wday   int32
   8005 	Ftm_yday   int32
   8006 	Ftm_isdst  int32
   8007 	Ftm_gmtoff int32
   8008 	Ftm_zone   uintptr
   8009 }
   8010 
   8011 type itimerspec = struct {
   8012 	Fit_interval struct {
   8013 		Ftv_sec  X__time_t
   8014 		Ftv_nsec X__syscall_slong_t
   8015 	}
   8016 	Fit_value struct {
   8017 		Ftv_sec  X__time_t
   8018 		Ftv_nsec X__syscall_slong_t
   8019 	}
   8020 }
   8021 
   8022 // A structure for holding a single date and time.
   8023 type DateTime1 = struct {
   8024 	FiJD         Sqlite3_int64
   8025 	FY           int32
   8026 	FM           int32
   8027 	FD           int32
   8028 	Fh           int32
   8029 	Fm           int32
   8030 	Ftz          int32
   8031 	Fs           float64
   8032 	FvalidJD     uint8
   8033 	FrawS        uint8
   8034 	FvalidYMD    uint8
   8035 	FvalidHMS    uint8
   8036 	FvalidTZ     uint8
   8037 	FtzSet       uint8
   8038 	FisError     uint8
   8039 	F__ccgo_pad1 [1]byte
   8040 }
   8041 
   8042 // A structure for holding a single date and time.
   8043 type DateTime = DateTime1
   8044 
   8045 func getDigits(tls *libc.TLS, zDate uintptr, zFormat uintptr, va uintptr) int32 {
   8046 	var ap Va_list
   8047 	_ = ap
   8048 	var cnt int32
   8049 	var nextC uint8
   8050 	var N uint8
   8051 	var min uint8
   8052 	var val int32
   8053 	var max U16
   8054 	cnt = 0
   8055 	ap = va
   8056 __1:
   8057 	N = uint8(int32(*(*uint8)(unsafe.Pointer(zFormat))) - '0')
   8058 	min = uint8(int32(*(*uint8)(unsafe.Pointer(zFormat + 1))) - '0')
   8059 	val = 0
   8060 
   8061 	max = aMx[int32(*(*uint8)(unsafe.Pointer(zFormat + 2)))-'a']
   8062 	nextC = *(*uint8)(unsafe.Pointer(zFormat + 3))
   8063 	val = 0
   8064 __4:
   8065 	if !(libc.PostDecUint8(&N, 1) != 0) {
   8066 		goto __5
   8067 	}
   8068 	if !!(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zDate))])&0x04 != 0) {
   8069 		goto __6
   8070 	}
   8071 	goto end_getDigits
   8072 __6:
   8073 	;
   8074 	val = val*10 + int32(*(*uint8)(unsafe.Pointer(zDate))) - '0'
   8075 	zDate++
   8076 	goto __4
   8077 __5:
   8078 	;
   8079 	if !(val < int32(min) || val > int32(max) || int32(nextC) != 0 && int32(nextC) != int32(*(*uint8)(unsafe.Pointer(zDate)))) {
   8080 		goto __7
   8081 	}
   8082 	goto end_getDigits
   8083 __7:
   8084 	;
   8085 	*(*int32)(unsafe.Pointer(libc.VaUintptr(&ap))) = val
   8086 	zDate++
   8087 	cnt++
   8088 	zFormat += uintptr(4)
   8089 	goto __2
   8090 __2:
   8091 	if nextC != 0 {
   8092 		goto __1
   8093 	}
   8094 	goto __3
   8095 __3:
   8096 	;
   8097 end_getDigits:
   8098 	_ = ap
   8099 	return cnt
   8100 }
   8101 
   8102 var aMx = [6]U16{U16(12), U16(14), U16(24), U16(31), U16(59), U16(9999)}
   8103 
   8104 func parseTimezone(tls *libc.TLS, zDate uintptr, p uintptr) int32 {
   8105 	bp := tls.Alloc(24)
   8106 	defer tls.Free(24)
   8107 
   8108 	var sgn int32
   8109 
   8110 	var c int32
   8111 	sgn = 0
   8112 __1:
   8113 	if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zDate))])&0x01 != 0) {
   8114 		goto __2
   8115 	}
   8116 	zDate++
   8117 	goto __1
   8118 __2:
   8119 	;
   8120 	(*DateTime)(unsafe.Pointer(p)).Ftz = 0
   8121 	c = int32(*(*uint8)(unsafe.Pointer(zDate)))
   8122 	if !(c == '-') {
   8123 		goto __3
   8124 	}
   8125 	sgn = -1
   8126 	goto __4
   8127 __3:
   8128 	if !(c == '+') {
   8129 		goto __5
   8130 	}
   8131 	sgn = +1
   8132 	goto __6
   8133 __5:
   8134 	if !(c == 'Z' || c == 'z') {
   8135 		goto __7
   8136 	}
   8137 	zDate++
   8138 	goto zulu_time
   8139 	goto __8
   8140 __7:
   8141 	return libc.Bool32(c != 0)
   8142 __8:
   8143 	;
   8144 __6:
   8145 	;
   8146 __4:
   8147 	;
   8148 	zDate++
   8149 	if !(getDigits(tls, zDate, ts+1137, libc.VaList(bp, bp+16, bp+20)) != 2) {
   8150 		goto __9
   8151 	}
   8152 	return 1
   8153 __9:
   8154 	;
   8155 	zDate += uintptr(5)
   8156 	(*DateTime)(unsafe.Pointer(p)).Ftz = sgn * (*(*int32)(unsafe.Pointer(bp + 20)) + *(*int32)(unsafe.Pointer(bp + 16))*60)
   8157 zulu_time:
   8158 __10:
   8159 	if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zDate))])&0x01 != 0) {
   8160 		goto __11
   8161 	}
   8162 	zDate++
   8163 	goto __10
   8164 __11:
   8165 	;
   8166 	(*DateTime)(unsafe.Pointer(p)).FtzSet = uint8(1)
   8167 	return libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zDate))) != 0)
   8168 }
   8169 
   8170 func parseHhMmSs(tls *libc.TLS, zDate uintptr, p uintptr) int32 {
   8171 	bp := tls.Alloc(36)
   8172 	defer tls.Free(36)
   8173 
   8174 	var ms float64 = 0.0
   8175 	if getDigits(tls, zDate, ts+1145, libc.VaList(bp, bp+24, bp+28)) != 2 {
   8176 		return 1
   8177 	}
   8178 	zDate += uintptr(5)
   8179 	if int32(*(*uint8)(unsafe.Pointer(zDate))) == ':' {
   8180 		zDate++
   8181 		if getDigits(tls, zDate, ts+1153, libc.VaList(bp+16, bp+32)) != 1 {
   8182 			return 1
   8183 		}
   8184 		zDate += uintptr(2)
   8185 		if int32(*(*uint8)(unsafe.Pointer(zDate))) == '.' && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zDate + 1))])&0x04 != 0 {
   8186 			var rScale float64 = 1.0
   8187 			zDate++
   8188 			for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zDate))])&0x04 != 0 {
   8189 				ms = ms*10.0 + float64(*(*uint8)(unsafe.Pointer(zDate))) - float64('0')
   8190 				rScale = rScale * 10.0
   8191 				zDate++
   8192 			}
   8193 			ms = ms / rScale
   8194 		}
   8195 	} else {
   8196 		*(*int32)(unsafe.Pointer(bp + 32)) = 0
   8197 	}
   8198 	(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8199 	(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8200 	(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1)
   8201 	(*DateTime)(unsafe.Pointer(p)).Fh = *(*int32)(unsafe.Pointer(bp + 24))
   8202 	(*DateTime)(unsafe.Pointer(p)).Fm = *(*int32)(unsafe.Pointer(bp + 28))
   8203 	(*DateTime)(unsafe.Pointer(p)).Fs = float64(*(*int32)(unsafe.Pointer(bp + 32))) + ms
   8204 	if parseTimezone(tls, zDate, p) != 0 {
   8205 		return 1
   8206 	}
   8207 	(*DateTime)(unsafe.Pointer(p)).FvalidTZ = func() uint8 {
   8208 		if (*DateTime)(unsafe.Pointer(p)).Ftz != 0 {
   8209 			return uint8(1)
   8210 		}
   8211 		return uint8(0)
   8212 	}()
   8213 	return 0
   8214 }
   8215 
   8216 func datetimeError(tls *libc.TLS, p uintptr) {
   8217 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(DateTime{})))
   8218 	(*DateTime)(unsafe.Pointer(p)).FisError = uint8(1)
   8219 }
   8220 
   8221 func computeJD(tls *libc.TLS, p uintptr) {
   8222 	var Y int32
   8223 	var M int32
   8224 	var D int32
   8225 	var A int32
   8226 	var B int32
   8227 	var X1 int32
   8228 	var X2 int32
   8229 
   8230 	if (*DateTime)(unsafe.Pointer(p)).FvalidJD != 0 {
   8231 		return
   8232 	}
   8233 	if (*DateTime)(unsafe.Pointer(p)).FvalidYMD != 0 {
   8234 		Y = (*DateTime)(unsafe.Pointer(p)).FY
   8235 		M = (*DateTime)(unsafe.Pointer(p)).FM
   8236 		D = (*DateTime)(unsafe.Pointer(p)).FD
   8237 	} else {
   8238 		Y = 2000
   8239 		M = 1
   8240 		D = 1
   8241 	}
   8242 	if Y < -4713 || Y > 9999 || (*DateTime)(unsafe.Pointer(p)).FrawS != 0 {
   8243 		datetimeError(tls, p)
   8244 		return
   8245 	}
   8246 	if M <= 2 {
   8247 		Y--
   8248 		M = M + 12
   8249 	}
   8250 	A = Y / 100
   8251 	B = 2 - A + A/4
   8252 	X1 = 36525 * (Y + 4716) / 100
   8253 	X2 = 306001 * (M + 1) / 10000
   8254 	(*DateTime)(unsafe.Pointer(p)).FiJD = libc.Int64FromFloat64((float64(X1+X2+D+B) - 1524.5) * float64(86400000))
   8255 	(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
   8256 	if (*DateTime)(unsafe.Pointer(p)).FvalidHMS != 0 {
   8257 		*(*Sqlite3_int64)(unsafe.Pointer(p)) += Sqlite3_int64((*DateTime)(unsafe.Pointer(p)).Fh*3600000+(*DateTime)(unsafe.Pointer(p)).Fm*60000) + libc.Int64FromFloat64((*DateTime)(unsafe.Pointer(p)).Fs*float64(1000)+0.5)
   8258 		if (*DateTime)(unsafe.Pointer(p)).FvalidTZ != 0 {
   8259 			*(*Sqlite3_int64)(unsafe.Pointer(p)) -= Sqlite3_int64((*DateTime)(unsafe.Pointer(p)).Ftz * 60000)
   8260 			(*DateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0)
   8261 			(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0)
   8262 			(*DateTime)(unsafe.Pointer(p)).FvalidTZ = uint8(0)
   8263 		}
   8264 	}
   8265 }
   8266 
   8267 func parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) int32 {
   8268 	bp := tls.Alloc(36)
   8269 	defer tls.Free(36)
   8270 
   8271 	var neg int32
   8272 
   8273 	if int32(*(*uint8)(unsafe.Pointer(zDate))) == '-' {
   8274 		zDate++
   8275 		neg = 1
   8276 	} else {
   8277 		neg = 0
   8278 	}
   8279 	if getDigits(tls, zDate, ts+1157, libc.VaList(bp, bp+24, bp+28, bp+32)) != 3 {
   8280 		return 1
   8281 	}
   8282 	zDate += uintptr(10)
   8283 	for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zDate))])&0x01 != 0 || 'T' == int32(*(*U8)(unsafe.Pointer(zDate))) {
   8284 		zDate++
   8285 	}
   8286 	if parseHhMmSs(tls, zDate, p) == 0 {
   8287 	} else if int32(*(*uint8)(unsafe.Pointer(zDate))) == 0 {
   8288 		(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0)
   8289 	} else {
   8290 		return 1
   8291 	}
   8292 	(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8293 	(*DateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1)
   8294 	(*DateTime)(unsafe.Pointer(p)).FY = func() int32 {
   8295 		if neg != 0 {
   8296 			return -*(*int32)(unsafe.Pointer(bp + 24))
   8297 		}
   8298 		return *(*int32)(unsafe.Pointer(bp + 24))
   8299 	}()
   8300 	(*DateTime)(unsafe.Pointer(p)).FM = *(*int32)(unsafe.Pointer(bp + 28))
   8301 	(*DateTime)(unsafe.Pointer(p)).FD = *(*int32)(unsafe.Pointer(bp + 32))
   8302 	if (*DateTime)(unsafe.Pointer(p)).FvalidTZ != 0 {
   8303 		computeJD(tls, p)
   8304 	}
   8305 	return 0
   8306 }
   8307 
   8308 func setDateTimeToCurrent(tls *libc.TLS, context uintptr, p uintptr) int32 {
   8309 	(*DateTime)(unsafe.Pointer(p)).FiJD = Xsqlite3StmtCurrentTime(tls, context)
   8310 	if (*DateTime)(unsafe.Pointer(p)).FiJD > int64(0) {
   8311 		(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
   8312 		return 0
   8313 	} else {
   8314 		return 1
   8315 	}
   8316 	return int32(0)
   8317 }
   8318 
   8319 func setRawDateNumber(tls *libc.TLS, p uintptr, r float64) {
   8320 	(*DateTime)(unsafe.Pointer(p)).Fs = r
   8321 	(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(1)
   8322 	if r >= 0.0 && r < 5373484.5 {
   8323 		(*DateTime)(unsafe.Pointer(p)).FiJD = libc.Int64FromFloat64(r*86400000.0 + 0.5)
   8324 		(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
   8325 	}
   8326 }
   8327 
   8328 func parseDateOrTime(tls *libc.TLS, context uintptr, zDate uintptr, p uintptr) int32 {
   8329 	bp := tls.Alloc(8)
   8330 	defer tls.Free(8)
   8331 
   8332 	if parseYyyyMmDd(tls, zDate, p) == 0 {
   8333 		return 0
   8334 	} else if parseHhMmSs(tls, zDate, p) == 0 {
   8335 		return 0
   8336 	} else if Xsqlite3StrICmp(tls, zDate, ts+1169) == 0 && Xsqlite3NotPureFunc(tls, context) != 0 {
   8337 		return setDateTimeToCurrent(tls, context, p)
   8338 	} else if Xsqlite3AtoF(tls, zDate, bp, Xsqlite3Strlen30(tls, zDate), uint8(SQLITE_UTF8)) > 0 {
   8339 		setRawDateNumber(tls, p, *(*float64)(unsafe.Pointer(bp)))
   8340 		return 0
   8341 	}
   8342 	return 1
   8343 }
   8344 
   8345 func validJulianDay(tls *libc.TLS, iJD Sqlite3_int64) int32 {
   8346 	return libc.Bool32(iJD >= int64(0) && iJD <= int64(0x1a640)<<32|int64(0x1072fdff))
   8347 }
   8348 
   8349 func computeYMD(tls *libc.TLS, p uintptr) {
   8350 	var Z int32
   8351 	var A int32
   8352 	var B int32
   8353 	var C int32
   8354 	var D int32
   8355 	var E int32
   8356 	var X1 int32
   8357 	if (*DateTime)(unsafe.Pointer(p)).FvalidYMD != 0 {
   8358 		return
   8359 	}
   8360 	if !(int32((*DateTime)(unsafe.Pointer(p)).FvalidJD) != 0) {
   8361 		(*DateTime)(unsafe.Pointer(p)).FY = 2000
   8362 		(*DateTime)(unsafe.Pointer(p)).FM = 1
   8363 		(*DateTime)(unsafe.Pointer(p)).FD = 1
   8364 	} else if !(validJulianDay(tls, (*DateTime)(unsafe.Pointer(p)).FiJD) != 0) {
   8365 		datetimeError(tls, p)
   8366 		return
   8367 	} else {
   8368 		Z = int32(((*DateTime)(unsafe.Pointer(p)).FiJD + int64(43200000)) / int64(86400000))
   8369 		A = libc.Int32FromFloat64((float64(Z) - 1867216.25) / 36524.25)
   8370 		A = Z + 1 + A - A/4
   8371 		B = A + 1524
   8372 		C = libc.Int32FromFloat64((float64(B) - 122.1) / 365.25)
   8373 		D = 36525 * (C & 32767) / 100
   8374 		E = libc.Int32FromFloat64(float64(B-D) / 30.6001)
   8375 		X1 = libc.Int32FromFloat64(30.6001 * float64(E))
   8376 		(*DateTime)(unsafe.Pointer(p)).FD = B - D - X1
   8377 		(*DateTime)(unsafe.Pointer(p)).FM = func() int32 {
   8378 			if E < 14 {
   8379 				return E - 1
   8380 			}
   8381 			return E - 13
   8382 		}()
   8383 		(*DateTime)(unsafe.Pointer(p)).FY = func() int32 {
   8384 			if (*DateTime)(unsafe.Pointer(p)).FM > 2 {
   8385 				return C - 4716
   8386 			}
   8387 			return C - 4715
   8388 		}()
   8389 	}
   8390 	(*DateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1)
   8391 }
   8392 
   8393 func computeHMS(tls *libc.TLS, p uintptr) {
   8394 	var s int32
   8395 	if (*DateTime)(unsafe.Pointer(p)).FvalidHMS != 0 {
   8396 		return
   8397 	}
   8398 	computeJD(tls, p)
   8399 	s = int32(((*DateTime)(unsafe.Pointer(p)).FiJD + int64(43200000)) % int64(86400000))
   8400 	(*DateTime)(unsafe.Pointer(p)).Fs = float64(s) / 1000.0
   8401 	s = libc.Int32FromFloat64((*DateTime)(unsafe.Pointer(p)).Fs)
   8402 	*(*float64)(unsafe.Pointer(p + 32)) -= float64(s)
   8403 	(*DateTime)(unsafe.Pointer(p)).Fh = s / 3600
   8404 	s = s - (*DateTime)(unsafe.Pointer(p)).Fh*3600
   8405 	(*DateTime)(unsafe.Pointer(p)).Fm = s / 60
   8406 	*(*float64)(unsafe.Pointer(p + 32)) += float64(s - (*DateTime)(unsafe.Pointer(p)).Fm*60)
   8407 	(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8408 	(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1)
   8409 }
   8410 
   8411 func computeYMD_HMS(tls *libc.TLS, p uintptr) {
   8412 	computeYMD(tls, p)
   8413 	computeHMS(tls, p)
   8414 }
   8415 
   8416 func clearYMD_HMS_TZ(tls *libc.TLS, p uintptr) {
   8417 	(*DateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0)
   8418 	(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0)
   8419 	(*DateTime)(unsafe.Pointer(p)).FvalidTZ = uint8(0)
   8420 }
   8421 
   8422 func osLocaltime(tls *libc.TLS, t uintptr, pTm uintptr) int32 {
   8423 	var rc int32
   8424 	var pX uintptr
   8425 	var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
   8426 	Xsqlite3_mutex_enter(tls, mutex)
   8427 	pX = libc.Xlocaltime(tls, t)
   8428 	if Xsqlite3Config.FbLocaltimeFault != 0 {
   8429 		if Xsqlite3Config.FxAltLocaltime != uintptr(0) &&
   8430 			0 == (*struct {
   8431 				f func(*libc.TLS, uintptr, uintptr) int32
   8432 			})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.FxAltLocaltime})).f(tls, t, pTm) {
   8433 			pX = pTm
   8434 		} else {
   8435 			pX = uintptr(0)
   8436 		}
   8437 	}
   8438 	if pX != 0 {
   8439 		*(*tm)(unsafe.Pointer(pTm)) = *(*tm)(unsafe.Pointer(pX))
   8440 	}
   8441 	Xsqlite3_mutex_leave(tls, mutex)
   8442 	rc = libc.Bool32(pX == uintptr(0))
   8443 	return rc
   8444 }
   8445 
   8446 func toLocaltime(tls *libc.TLS, p uintptr, pCtx uintptr) int32 {
   8447 	bp := tls.Alloc(100)
   8448 	defer tls.Free(100)
   8449 
   8450 	var iYearDiff int32
   8451 
   8452 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(tm{})))
   8453 
   8454 	computeJD(tls, p)
   8455 	if (*DateTime)(unsafe.Pointer(p)).FiJD < int64(2108667600)*int64(100000) ||
   8456 		(*DateTime)(unsafe.Pointer(p)).FiJD > int64(2130141456)*int64(100000) {
   8457 		*(*DateTime)(unsafe.Pointer(bp + 48)) = *(*DateTime)(unsafe.Pointer(p))
   8458 		computeYMD_HMS(tls, bp+48)
   8459 		iYearDiff = 2000 + (*DateTime)(unsafe.Pointer(bp+48)).FY%4 - (*DateTime)(unsafe.Pointer(bp+48)).FY
   8460 		*(*int32)(unsafe.Pointer(bp + 48 + 8)) += iYearDiff
   8461 		(*DateTime)(unsafe.Pointer(bp + 48)).FvalidJD = uint8(0)
   8462 		computeJD(tls, bp+48)
   8463 		*(*Time_t)(unsafe.Pointer(bp + 96)) = Time_t((*DateTime)(unsafe.Pointer(bp+48)).FiJD/int64(1000) - int64(21086676)*int64(10000))
   8464 	} else {
   8465 		iYearDiff = 0
   8466 		*(*Time_t)(unsafe.Pointer(bp + 96)) = Time_t((*DateTime)(unsafe.Pointer(p)).FiJD/int64(1000) - int64(21086676)*int64(10000))
   8467 	}
   8468 	if osLocaltime(tls, bp+96, bp) != 0 {
   8469 		Xsqlite3_result_error(tls, pCtx, ts+1173, -1)
   8470 		return SQLITE_ERROR
   8471 	}
   8472 	(*DateTime)(unsafe.Pointer(p)).FY = (*tm)(unsafe.Pointer(bp)).Ftm_year + 1900 - iYearDiff
   8473 	(*DateTime)(unsafe.Pointer(p)).FM = (*tm)(unsafe.Pointer(bp)).Ftm_mon + 1
   8474 	(*DateTime)(unsafe.Pointer(p)).FD = (*tm)(unsafe.Pointer(bp)).Ftm_mday
   8475 	(*DateTime)(unsafe.Pointer(p)).Fh = (*tm)(unsafe.Pointer(bp)).Ftm_hour
   8476 	(*DateTime)(unsafe.Pointer(p)).Fm = (*tm)(unsafe.Pointer(bp)).Ftm_min
   8477 	(*DateTime)(unsafe.Pointer(p)).Fs = float64((*tm)(unsafe.Pointer(bp)).Ftm_sec) + float64((*DateTime)(unsafe.Pointer(p)).FiJD%int64(1000))*0.001
   8478 	(*DateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1)
   8479 	(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1)
   8480 	(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8481 	(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8482 	(*DateTime)(unsafe.Pointer(p)).FvalidTZ = uint8(0)
   8483 	(*DateTime)(unsafe.Pointer(p)).FisError = uint8(0)
   8484 	return SQLITE_OK
   8485 }
   8486 
   8487 var aXformType = [6]struct {
   8488 	FnName  U8
   8489 	FzName  [7]uint8
   8490 	FrLimit float32
   8491 	FrXform float32
   8492 }{
   8493 	{FnName: U8(6), FzName: *(*[7]uint8)(unsafe.Pointer(ts + 1196)), FrLimit: 4.6427e+14, FrXform: 1.0},
   8494 	{FnName: U8(6), FzName: *(*[7]uint8)(unsafe.Pointer(ts + 1203)), FrLimit: 7.7379e+12, FrXform: 60.0},
   8495 	{FnName: U8(4), FzName: *(*[7]uint8)(unsafe.Pointer(ts + 1210)), FrLimit: 1.2897e+11, FrXform: 3600.0},
   8496 	{FnName: U8(3), FzName: *(*[7]uint8)(unsafe.Pointer(ts + 1217)), FrLimit: 5373485.0, FrXform: 86400.0},
   8497 	{FnName: U8(5), FzName: *(*[7]uint8)(unsafe.Pointer(ts + 1224)), FrLimit: 176546.0, FrXform: 2592000.0},
   8498 	{FnName: U8(4), FzName: *(*[7]uint8)(unsafe.Pointer(ts + 1231)), FrLimit: 14713.0, FrXform: 31536000.0},
   8499 }
   8500 
   8501 func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr, idx int32) int32 {
   8502 	bp := tls.Alloc(104)
   8503 	defer tls.Free(104)
   8504 
   8505 	var rc int32 = 1
   8506 
   8507 	switch int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(z))]) {
   8508 	case 'a':
   8509 		{
   8510 			if Xsqlite3_stricmp(tls, z, ts+1238) == 0 {
   8511 				if idx > 1 {
   8512 					return 1
   8513 				}
   8514 				if !(int32((*DateTime)(unsafe.Pointer(p)).FrawS) != 0) || (*DateTime)(unsafe.Pointer(p)).FvalidJD != 0 {
   8515 					rc = 0
   8516 					(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8517 				} else if (*DateTime)(unsafe.Pointer(p)).Fs >= float64(int64(-21086676)*int64(10000)) &&
   8518 					(*DateTime)(unsafe.Pointer(p)).Fs <= float64(int64(25340230)*int64(10000)+int64(799)) {
   8519 					*(*float64)(unsafe.Pointer(bp + 48)) = (*DateTime)(unsafe.Pointer(p)).Fs*1000.0 + 210866760000000.0
   8520 					clearYMD_HMS_TZ(tls, p)
   8521 					(*DateTime)(unsafe.Pointer(p)).FiJD = libc.Int64FromFloat64(*(*float64)(unsafe.Pointer(bp + 48)) + 0.5)
   8522 					(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
   8523 					(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8524 					rc = 0
   8525 				}
   8526 			}
   8527 			break
   8528 
   8529 		}
   8530 	case 'j':
   8531 		{
   8532 			if Xsqlite3_stricmp(tls, z, ts+1243) == 0 {
   8533 				if idx > 1 {
   8534 					return 1
   8535 				}
   8536 				if (*DateTime)(unsafe.Pointer(p)).FvalidJD != 0 && (*DateTime)(unsafe.Pointer(p)).FrawS != 0 {
   8537 					rc = 0
   8538 					(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8539 				}
   8540 			}
   8541 			break
   8542 
   8543 		}
   8544 	case 'l':
   8545 		{
   8546 			if Xsqlite3_stricmp(tls, z, ts+1253) == 0 && Xsqlite3NotPureFunc(tls, pCtx) != 0 {
   8547 				rc = toLocaltime(tls, p, pCtx)
   8548 			}
   8549 			break
   8550 
   8551 		}
   8552 	case 'u':
   8553 		{
   8554 			if Xsqlite3_stricmp(tls, z, ts+1263) == 0 && (*DateTime)(unsafe.Pointer(p)).FrawS != 0 {
   8555 				if idx > 1 {
   8556 					return 1
   8557 				}
   8558 				*(*float64)(unsafe.Pointer(bp + 48)) = (*DateTime)(unsafe.Pointer(p)).Fs*1000.0 + 210866760000000.0
   8559 				if *(*float64)(unsafe.Pointer(bp + 48)) >= 0.0 && *(*float64)(unsafe.Pointer(bp + 48)) < 464269060800000.0 {
   8560 					clearYMD_HMS_TZ(tls, p)
   8561 					(*DateTime)(unsafe.Pointer(p)).FiJD = libc.Int64FromFloat64(*(*float64)(unsafe.Pointer(bp + 48)) + 0.5)
   8562 					(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
   8563 					(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8564 					rc = 0
   8565 				}
   8566 			} else if Xsqlite3_stricmp(tls, z, ts+1273) == 0 && Xsqlite3NotPureFunc(tls, pCtx) != 0 {
   8567 				if int32((*DateTime)(unsafe.Pointer(p)).FtzSet) == 0 {
   8568 					var iOrigJD I64
   8569 					var iGuess I64
   8570 					var cnt int32 = 0
   8571 					var iErr I64
   8572 
   8573 					computeJD(tls, p)
   8574 					iGuess = libc.AssignInt64(&iOrigJD, (*DateTime)(unsafe.Pointer(p)).FiJD)
   8575 					iErr = int64(0)
   8576 					for __ccgo := true; __ccgo; __ccgo = iErr != 0 && libc.PostIncInt32(&cnt, 1) < 3 {
   8577 						libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(DateTime{})))
   8578 						iGuess = iGuess - iErr
   8579 						(*DateTime)(unsafe.Pointer(bp)).FiJD = iGuess
   8580 						(*DateTime)(unsafe.Pointer(bp)).FvalidJD = uint8(1)
   8581 						rc = toLocaltime(tls, bp, pCtx)
   8582 						if rc != 0 {
   8583 							return rc
   8584 						}
   8585 						computeJD(tls, bp)
   8586 						iErr = (*DateTime)(unsafe.Pointer(bp)).FiJD - iOrigJD
   8587 					}
   8588 					libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(DateTime{})))
   8589 					(*DateTime)(unsafe.Pointer(p)).FiJD = iGuess
   8590 					(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
   8591 					(*DateTime)(unsafe.Pointer(p)).FtzSet = uint8(1)
   8592 				}
   8593 				rc = SQLITE_OK
   8594 			}
   8595 			break
   8596 
   8597 		}
   8598 	case 'w':
   8599 		{
   8600 			if Xsqlite3_strnicmp(tls, z, ts+1277, 8) == 0 &&
   8601 				Xsqlite3AtoF(tls, z+8, bp+48, Xsqlite3Strlen30(tls, z+8), uint8(SQLITE_UTF8)) > 0 &&
   8602 				*(*float64)(unsafe.Pointer(bp + 48)) >= 0.0 && *(*float64)(unsafe.Pointer(bp + 48)) < 7.0 && float64(libc.AssignInt32(&n, int32(*(*float64)(unsafe.Pointer(bp + 48))))) == *(*float64)(unsafe.Pointer(bp + 48)) {
   8603 				var Z Sqlite3_int64
   8604 				computeYMD_HMS(tls, p)
   8605 				(*DateTime)(unsafe.Pointer(p)).FvalidTZ = uint8(0)
   8606 				(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8607 				computeJD(tls, p)
   8608 				Z = ((*DateTime)(unsafe.Pointer(p)).FiJD + int64(129600000)) / int64(86400000) % int64(7)
   8609 				if Z > Sqlite3_int64(n) {
   8610 					Z = Z - int64(7)
   8611 				}
   8612 				*(*Sqlite3_int64)(unsafe.Pointer(p)) += (Sqlite3_int64(n) - Z) * int64(86400000)
   8613 				clearYMD_HMS_TZ(tls, p)
   8614 				rc = 0
   8615 			}
   8616 			break
   8617 
   8618 		}
   8619 	case 's':
   8620 		{
   8621 			if Xsqlite3_strnicmp(tls, z, ts+1286, 9) != 0 {
   8622 				break
   8623 			}
   8624 			if !(int32((*DateTime)(unsafe.Pointer(p)).FvalidJD) != 0) && !(int32((*DateTime)(unsafe.Pointer(p)).FvalidYMD) != 0) && !(int32((*DateTime)(unsafe.Pointer(p)).FvalidHMS) != 0) {
   8625 				break
   8626 			}
   8627 			z += uintptr(9)
   8628 			computeYMD(tls, p)
   8629 			(*DateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1)
   8630 			(*DateTime)(unsafe.Pointer(p)).Fh = libc.AssignPtrInt32(p+24, 0)
   8631 			(*DateTime)(unsafe.Pointer(p)).Fs = 0.0
   8632 			(*DateTime)(unsafe.Pointer(p)).FrawS = uint8(0)
   8633 			(*DateTime)(unsafe.Pointer(p)).FvalidTZ = uint8(0)
   8634 			(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8635 			if Xsqlite3_stricmp(tls, z, ts+1296) == 0 {
   8636 				(*DateTime)(unsafe.Pointer(p)).FD = 1
   8637 				rc = 0
   8638 			} else if Xsqlite3_stricmp(tls, z, ts+1302) == 0 {
   8639 				(*DateTime)(unsafe.Pointer(p)).FM = 1
   8640 				(*DateTime)(unsafe.Pointer(p)).FD = 1
   8641 				rc = 0
   8642 			} else if Xsqlite3_stricmp(tls, z, ts+1307) == 0 {
   8643 				rc = 0
   8644 			}
   8645 			break
   8646 
   8647 		}
   8648 	case '+':
   8649 		fallthrough
   8650 	case '-':
   8651 		fallthrough
   8652 	case '0':
   8653 		fallthrough
   8654 	case '1':
   8655 		fallthrough
   8656 	case '2':
   8657 		fallthrough
   8658 	case '3':
   8659 		fallthrough
   8660 	case '4':
   8661 		fallthrough
   8662 	case '5':
   8663 		fallthrough
   8664 	case '6':
   8665 		fallthrough
   8666 	case '7':
   8667 		fallthrough
   8668 	case '8':
   8669 		fallthrough
   8670 	case '9':
   8671 		{
   8672 			var rRounder float64
   8673 			var i int32
   8674 			for n = 1; *(*uint8)(unsafe.Pointer(z + uintptr(n))) != 0 && int32(*(*uint8)(unsafe.Pointer(z + uintptr(n)))) != ':' && !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(n)))])&0x01 != 0); n++ {
   8675 			}
   8676 			if Xsqlite3AtoF(tls, z, bp+48, n, uint8(SQLITE_UTF8)) <= 0 {
   8677 				rc = 1
   8678 				break
   8679 			}
   8680 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(n)))) == ':' {
   8681 				var z2 uintptr = z
   8682 
   8683 				var day Sqlite3_int64
   8684 				if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z2))])&0x04 != 0) {
   8685 					z2++
   8686 				}
   8687 				libc.Xmemset(tls, bp+56, 0, uint32(unsafe.Sizeof(DateTime{})))
   8688 				if parseHhMmSs(tls, z2, bp+56) != 0 {
   8689 					break
   8690 				}
   8691 				computeJD(tls, bp+56)
   8692 				*(*Sqlite3_int64)(unsafe.Pointer(bp + 56)) -= int64(43200000)
   8693 				day = (*DateTime)(unsafe.Pointer(bp+56)).FiJD / int64(86400000)
   8694 				*(*Sqlite3_int64)(unsafe.Pointer(bp + 56)) -= day * int64(86400000)
   8695 				if int32(*(*uint8)(unsafe.Pointer(z))) == '-' {
   8696 					(*DateTime)(unsafe.Pointer(bp + 56)).FiJD = -(*DateTime)(unsafe.Pointer(bp + 56)).FiJD
   8697 				}
   8698 				computeJD(tls, p)
   8699 				clearYMD_HMS_TZ(tls, p)
   8700 				*(*Sqlite3_int64)(unsafe.Pointer(p)) += (*DateTime)(unsafe.Pointer(bp + 56)).FiJD
   8701 				rc = 0
   8702 				break
   8703 			}
   8704 
   8705 			z += uintptr(n)
   8706 			for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x01 != 0 {
   8707 				z++
   8708 			}
   8709 			n = Xsqlite3Strlen30(tls, z)
   8710 			if n > 10 || n < 3 {
   8711 				break
   8712 			}
   8713 			if int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(z + uintptr(n-1)))]) == 's' {
   8714 				n--
   8715 			}
   8716 			computeJD(tls, p)
   8717 			rc = 1
   8718 			if *(*float64)(unsafe.Pointer(bp + 48)) < float64(0) {
   8719 				rRounder = -0.5
   8720 			} else {
   8721 				rRounder = +0.5
   8722 			}
   8723 			for i = 0; i < int32(uint32(unsafe.Sizeof(aXformType))/uint32(unsafe.Sizeof(struct {
   8724 				FnName  U8
   8725 				FzName  [7]uint8
   8726 				FrLimit float32
   8727 				FrXform float32
   8728 			}{}))); i++ {
   8729 				if int32(aXformType[i].FnName) == n &&
   8730 					Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&aXformType))+uintptr(i)*16+1, z, n) == 0 &&
   8731 					*(*float64)(unsafe.Pointer(bp + 48)) > float64(-aXformType[i].FrLimit) && *(*float64)(unsafe.Pointer(bp + 48)) < float64(aXformType[i].FrLimit) {
   8732 					switch i {
   8733 					case 4:
   8734 						{
   8735 							var x int32
   8736 
   8737 							computeYMD_HMS(tls, p)
   8738 							*(*int32)(unsafe.Pointer(p + 12)) += int32(*(*float64)(unsafe.Pointer(bp + 48)))
   8739 							if (*DateTime)(unsafe.Pointer(p)).FM > 0 {
   8740 								x = ((*DateTime)(unsafe.Pointer(p)).FM - 1) / 12
   8741 							} else {
   8742 								x = ((*DateTime)(unsafe.Pointer(p)).FM - 12) / 12
   8743 							}
   8744 							*(*int32)(unsafe.Pointer(p + 8)) += x
   8745 							*(*int32)(unsafe.Pointer(p + 12)) -= x * 12
   8746 							(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8747 							*(*float64)(unsafe.Pointer(bp + 48)) -= float64(int32(*(*float64)(unsafe.Pointer(bp + 48))))
   8748 							break
   8749 
   8750 						}
   8751 						fallthrough
   8752 					case 5:
   8753 						{
   8754 							var y int32 = int32(*(*float64)(unsafe.Pointer(bp + 48)))
   8755 
   8756 							computeYMD_HMS(tls, p)
   8757 							*(*int32)(unsafe.Pointer(p + 8)) += y
   8758 							(*DateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0)
   8759 							*(*float64)(unsafe.Pointer(bp + 48)) -= float64(int32(*(*float64)(unsafe.Pointer(bp + 48))))
   8760 							break
   8761 
   8762 						}
   8763 					}
   8764 					computeJD(tls, p)
   8765 					*(*Sqlite3_int64)(unsafe.Pointer(p)) += libc.Int64FromFloat64(*(*float64)(unsafe.Pointer(bp + 48))*1000.0*float64(aXformType[i].FrXform) + rRounder)
   8766 					rc = 0
   8767 					break
   8768 				}
   8769 			}
   8770 			clearYMD_HMS_TZ(tls, p)
   8771 			break
   8772 
   8773 		}
   8774 	default:
   8775 		{
   8776 			break
   8777 
   8778 		}
   8779 	}
   8780 	return rc
   8781 }
   8782 
   8783 func isDate(tls *libc.TLS, context uintptr, argc int32, argv uintptr, p uintptr) int32 {
   8784 	var i int32
   8785 	var n int32
   8786 	var z uintptr
   8787 	var eType int32
   8788 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(DateTime{})))
   8789 	if argc == 0 {
   8790 		if !(Xsqlite3NotPureFunc(tls, context) != 0) {
   8791 			return 1
   8792 		}
   8793 		return setDateTimeToCurrent(tls, context, p)
   8794 	}
   8795 	if libc.AssignInt32(&eType, Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv)))) == SQLITE_FLOAT ||
   8796 		eType == SQLITE_INTEGER {
   8797 		setRawDateNumber(tls, p, Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))))
   8798 	} else {
   8799 		z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
   8800 		if !(z != 0) || parseDateOrTime(tls, context, z, p) != 0 {
   8801 			return 1
   8802 		}
   8803 	}
   8804 	for i = 1; i < argc; i++ {
   8805 		z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
   8806 		n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
   8807 		if z == uintptr(0) || parseModifier(tls, context, z, n, p, i) != 0 {
   8808 			return 1
   8809 		}
   8810 	}
   8811 	computeJD(tls, p)
   8812 	if (*DateTime)(unsafe.Pointer(p)).FisError != 0 || !(validJulianDay(tls, (*DateTime)(unsafe.Pointer(p)).FiJD) != 0) {
   8813 		return 1
   8814 	}
   8815 	return 0
   8816 }
   8817 
   8818 func juliandayFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
   8819 	bp := tls.Alloc(48)
   8820 	defer tls.Free(48)
   8821 
   8822 	if isDate(tls, context, argc, argv, bp) == 0 {
   8823 		computeJD(tls, bp)
   8824 		Xsqlite3_result_double(tls, context, float64((*DateTime)(unsafe.Pointer(bp)).FiJD)/86400000.0)
   8825 	}
   8826 }
   8827 
   8828 func unixepochFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
   8829 	bp := tls.Alloc(48)
   8830 	defer tls.Free(48)
   8831 
   8832 	if isDate(tls, context, argc, argv, bp) == 0 {
   8833 		computeJD(tls, bp)
   8834 		Xsqlite3_result_int64(tls, context, (*DateTime)(unsafe.Pointer(bp)).FiJD/int64(1000)-int64(21086676)*int64(10000))
   8835 	}
   8836 }
   8837 
   8838 func datetimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
   8839 	bp := tls.Alloc(72)
   8840 	defer tls.Free(72)
   8841 
   8842 	if isDate(tls, context, argc, argv, bp) == 0 {
   8843 		var Y int32
   8844 		var s int32
   8845 
   8846 		computeYMD_HMS(tls, bp)
   8847 		Y = (*DateTime)(unsafe.Pointer(bp)).FY
   8848 		if Y < 0 {
   8849 			Y = -Y
   8850 		}
   8851 		*(*uint8)(unsafe.Pointer(bp + 48 + 1)) = uint8('0' + Y/1000%10)
   8852 		*(*uint8)(unsafe.Pointer(bp + 48 + 2)) = uint8('0' + Y/100%10)
   8853 		*(*uint8)(unsafe.Pointer(bp + 48 + 3)) = uint8('0' + Y/10%10)
   8854 		*(*uint8)(unsafe.Pointer(bp + 48 + 4)) = uint8('0' + Y%10)
   8855 		*(*uint8)(unsafe.Pointer(bp + 48 + 5)) = uint8('-')
   8856 		*(*uint8)(unsafe.Pointer(bp + 48 + 6)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FM/10%10)
   8857 		*(*uint8)(unsafe.Pointer(bp + 48 + 7)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FM%10)
   8858 		*(*uint8)(unsafe.Pointer(bp + 48 + 8)) = uint8('-')
   8859 		*(*uint8)(unsafe.Pointer(bp + 48 + 9)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FD/10%10)
   8860 		*(*uint8)(unsafe.Pointer(bp + 48 + 10)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FD%10)
   8861 		*(*uint8)(unsafe.Pointer(bp + 48 + 11)) = uint8(' ')
   8862 		*(*uint8)(unsafe.Pointer(bp + 48 + 12)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fh/10%10)
   8863 		*(*uint8)(unsafe.Pointer(bp + 48 + 13)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fh%10)
   8864 		*(*uint8)(unsafe.Pointer(bp + 48 + 14)) = uint8(':')
   8865 		*(*uint8)(unsafe.Pointer(bp + 48 + 15)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fm/10%10)
   8866 		*(*uint8)(unsafe.Pointer(bp + 48 + 16)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fm%10)
   8867 		*(*uint8)(unsafe.Pointer(bp + 48 + 17)) = uint8(':')
   8868 		s = libc.Int32FromFloat64((*DateTime)(unsafe.Pointer(bp)).Fs)
   8869 		*(*uint8)(unsafe.Pointer(bp + 48 + 18)) = uint8('0' + s/10%10)
   8870 		*(*uint8)(unsafe.Pointer(bp + 48 + 19)) = uint8('0' + s%10)
   8871 		*(*uint8)(unsafe.Pointer(bp + 48 + 20)) = uint8(0)
   8872 		if (*DateTime)(unsafe.Pointer(bp)).FY < 0 {
   8873 			*(*uint8)(unsafe.Pointer(bp + 48)) = uint8('-')
   8874 			Xsqlite3_result_text(tls, context, bp+48, 20, libc.UintptrFromInt32(-1))
   8875 		} else {
   8876 			Xsqlite3_result_text(tls, context, bp+48+1, 19, libc.UintptrFromInt32(-1))
   8877 		}
   8878 	}
   8879 }
   8880 
   8881 func timeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
   8882 	bp := tls.Alloc(64)
   8883 	defer tls.Free(64)
   8884 
   8885 	if isDate(tls, context, argc, argv, bp) == 0 {
   8886 		var s int32
   8887 
   8888 		computeHMS(tls, bp)
   8889 		*(*uint8)(unsafe.Pointer(bp + 48)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fh/10%10)
   8890 		*(*uint8)(unsafe.Pointer(bp + 48 + 1)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fh%10)
   8891 		*(*uint8)(unsafe.Pointer(bp + 48 + 2)) = uint8(':')
   8892 		*(*uint8)(unsafe.Pointer(bp + 48 + 3)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fm/10%10)
   8893 		*(*uint8)(unsafe.Pointer(bp + 48 + 4)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).Fm%10)
   8894 		*(*uint8)(unsafe.Pointer(bp + 48 + 5)) = uint8(':')
   8895 		s = libc.Int32FromFloat64((*DateTime)(unsafe.Pointer(bp)).Fs)
   8896 		*(*uint8)(unsafe.Pointer(bp + 48 + 6)) = uint8('0' + s/10%10)
   8897 		*(*uint8)(unsafe.Pointer(bp + 48 + 7)) = uint8('0' + s%10)
   8898 		*(*uint8)(unsafe.Pointer(bp + 48 + 8)) = uint8(0)
   8899 		Xsqlite3_result_text(tls, context, bp+48, 8, libc.UintptrFromInt32(-1))
   8900 	}
   8901 }
   8902 
   8903 func dateFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
   8904 	bp := tls.Alloc(64)
   8905 	defer tls.Free(64)
   8906 
   8907 	if isDate(tls, context, argc, argv, bp) == 0 {
   8908 		var Y int32
   8909 
   8910 		computeYMD(tls, bp)
   8911 		Y = (*DateTime)(unsafe.Pointer(bp)).FY
   8912 		if Y < 0 {
   8913 			Y = -Y
   8914 		}
   8915 		*(*uint8)(unsafe.Pointer(bp + 48 + 1)) = uint8('0' + Y/1000%10)
   8916 		*(*uint8)(unsafe.Pointer(bp + 48 + 2)) = uint8('0' + Y/100%10)
   8917 		*(*uint8)(unsafe.Pointer(bp + 48 + 3)) = uint8('0' + Y/10%10)
   8918 		*(*uint8)(unsafe.Pointer(bp + 48 + 4)) = uint8('0' + Y%10)
   8919 		*(*uint8)(unsafe.Pointer(bp + 48 + 5)) = uint8('-')
   8920 		*(*uint8)(unsafe.Pointer(bp + 48 + 6)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FM/10%10)
   8921 		*(*uint8)(unsafe.Pointer(bp + 48 + 7)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FM%10)
   8922 		*(*uint8)(unsafe.Pointer(bp + 48 + 8)) = uint8('-')
   8923 		*(*uint8)(unsafe.Pointer(bp + 48 + 9)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FD/10%10)
   8924 		*(*uint8)(unsafe.Pointer(bp + 48 + 10)) = uint8('0' + (*DateTime)(unsafe.Pointer(bp)).FD%10)
   8925 		*(*uint8)(unsafe.Pointer(bp + 48 + 11)) = uint8(0)
   8926 		if (*DateTime)(unsafe.Pointer(bp)).FY < 0 {
   8927 			*(*uint8)(unsafe.Pointer(bp + 48)) = uint8('-')
   8928 			Xsqlite3_result_text(tls, context, bp+48, 11, libc.UintptrFromInt32(-1))
   8929 		} else {
   8930 			Xsqlite3_result_text(tls, context, bp+48+1, 10, libc.UintptrFromInt32(-1))
   8931 		}
   8932 	}
   8933 }
   8934 
   8935 func strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
   8936 	bp := tls.Alloc(208)
   8937 	defer tls.Free(208)
   8938 
   8939 	var i Size_t
   8940 	var j Size_t
   8941 	var db uintptr
   8942 	var zFmt uintptr
   8943 
   8944 	if argc == 0 {
   8945 		return
   8946 	}
   8947 	zFmt = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
   8948 	if zFmt == uintptr(0) || isDate(tls, context, argc-1, argv+uintptr(1)*4, bp+88) != 0 {
   8949 		return
   8950 	}
   8951 	db = Xsqlite3_context_db_handle(tls, context)
   8952 	Xsqlite3StrAccumInit(tls, bp+136, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer(db + 120)))
   8953 
   8954 	computeJD(tls, bp+88)
   8955 	computeYMD_HMS(tls, bp+88)
   8956 	for i = libc.AssignUint32(&j, Size_t(0)); *(*uint8)(unsafe.Pointer(zFmt + uintptr(i))) != 0; i++ {
   8957 		if int32(*(*uint8)(unsafe.Pointer(zFmt + uintptr(i)))) != '%' {
   8958 			continue
   8959 		}
   8960 		if j < i {
   8961 			Xsqlite3_str_append(tls, bp+136, zFmt+uintptr(j), int32(i-j))
   8962 		}
   8963 		i++
   8964 		j = i + Size_t(1)
   8965 		switch int32(*(*uint8)(unsafe.Pointer(zFmt + uintptr(i)))) {
   8966 		case 'd':
   8967 			{
   8968 				Xsqlite3_str_appendf(tls, bp+136, ts+1311, libc.VaList(bp, (*DateTime)(unsafe.Pointer(bp+88)).FD))
   8969 				break
   8970 
   8971 			}
   8972 		case 'f':
   8973 			{
   8974 				var s float64 = (*DateTime)(unsafe.Pointer(bp + 88)).Fs
   8975 				if s > 59.999 {
   8976 					s = 59.999
   8977 				}
   8978 				Xsqlite3_str_appendf(tls, bp+136, ts+1316, libc.VaList(bp+8, s))
   8979 				break
   8980 
   8981 			}
   8982 		case 'H':
   8983 			{
   8984 				Xsqlite3_str_appendf(tls, bp+136, ts+1311, libc.VaList(bp+16, (*DateTime)(unsafe.Pointer(bp+88)).Fh))
   8985 				break
   8986 
   8987 			}
   8988 		case 'W':
   8989 			fallthrough
   8990 		case 'j':
   8991 			{
   8992 				var nDay int32
   8993 				*(*DateTime)(unsafe.Pointer(bp + 160)) = *(*DateTime)(unsafe.Pointer(bp + 88))
   8994 				(*DateTime)(unsafe.Pointer(bp + 160)).FvalidJD = uint8(0)
   8995 				(*DateTime)(unsafe.Pointer(bp + 160)).FM = 1
   8996 				(*DateTime)(unsafe.Pointer(bp + 160)).FD = 1
   8997 				computeJD(tls, bp+160)
   8998 				nDay = int32(((*DateTime)(unsafe.Pointer(bp+88)).FiJD - (*DateTime)(unsafe.Pointer(bp+160)).FiJD + int64(43200000)) / int64(86400000))
   8999 				if int32(*(*uint8)(unsafe.Pointer(zFmt + uintptr(i)))) == 'W' {
   9000 					var wd int32
   9001 					wd = int32(((*DateTime)(unsafe.Pointer(bp+88)).FiJD + int64(43200000)) / int64(86400000) % int64(7))
   9002 					Xsqlite3_str_appendf(tls, bp+136, ts+1311, libc.VaList(bp+24, (nDay+7-wd)/7))
   9003 				} else {
   9004 					Xsqlite3_str_appendf(tls, bp+136, ts+1323, libc.VaList(bp+32, nDay+1))
   9005 				}
   9006 				break
   9007 
   9008 			}
   9009 		case 'J':
   9010 			{
   9011 				Xsqlite3_str_appendf(tls, bp+136, ts+1328, libc.VaList(bp+40, float64((*DateTime)(unsafe.Pointer(bp+88)).FiJD)/86400000.0))
   9012 				break
   9013 
   9014 			}
   9015 		case 'm':
   9016 			{
   9017 				Xsqlite3_str_appendf(tls, bp+136, ts+1311, libc.VaList(bp+48, (*DateTime)(unsafe.Pointer(bp+88)).FM))
   9018 				break
   9019 
   9020 			}
   9021 		case 'M':
   9022 			{
   9023 				Xsqlite3_str_appendf(tls, bp+136, ts+1311, libc.VaList(bp+56, (*DateTime)(unsafe.Pointer(bp+88)).Fm))
   9024 				break
   9025 
   9026 			}
   9027 		case 's':
   9028 			{
   9029 				var iS I64 = (*DateTime)(unsafe.Pointer(bp+88)).FiJD/int64(1000) - int64(21086676)*int64(10000)
   9030 				Xsqlite3_str_appendf(tls, bp+136, ts+1334, libc.VaList(bp+64, iS))
   9031 				break
   9032 
   9033 			}
   9034 		case 'S':
   9035 			{
   9036 				Xsqlite3_str_appendf(tls, bp+136, ts+1311, libc.VaList(bp+72, libc.Int32FromFloat64((*DateTime)(unsafe.Pointer(bp+88)).Fs)))
   9037 				break
   9038 
   9039 			}
   9040 		case 'w':
   9041 			{
   9042 				Xsqlite3_str_appendchar(tls, bp+136, 1,
   9043 					uint8(int32(uint8(((*DateTime)(unsafe.Pointer(bp+88)).FiJD+int64(129600000))/int64(86400000)%int64(7)))+'0'))
   9044 				break
   9045 
   9046 			}
   9047 		case 'Y':
   9048 			{
   9049 				Xsqlite3_str_appendf(tls, bp+136, ts+1339, libc.VaList(bp+80, (*DateTime)(unsafe.Pointer(bp+88)).FY))
   9050 				break
   9051 
   9052 			}
   9053 		case '%':
   9054 			{
   9055 				Xsqlite3_str_appendchar(tls, bp+136, 1, uint8('%'))
   9056 				break
   9057 
   9058 			}
   9059 		default:
   9060 			{
   9061 				Xsqlite3_str_reset(tls, bp+136)
   9062 				return
   9063 
   9064 			}
   9065 		}
   9066 	}
   9067 	if j < i {
   9068 		Xsqlite3_str_append(tls, bp+136, zFmt+uintptr(j), int32(i-j))
   9069 	}
   9070 	Xsqlite3ResultStrAccum(tls, context, bp+136)
   9071 }
   9072 
   9073 func ctimeFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
   9074 	_ = NotUsed
   9075 	_ = NotUsed2
   9076 	timeFunc(tls, context, 0, uintptr(0))
   9077 }
   9078 
   9079 func cdateFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
   9080 	_ = NotUsed
   9081 	_ = NotUsed2
   9082 	dateFunc(tls, context, 0, uintptr(0))
   9083 }
   9084 
   9085 func ctimestampFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
   9086 	_ = NotUsed
   9087 	_ = NotUsed2
   9088 	datetimeFunc(tls, context, 0, uintptr(0))
   9089 }
   9090 
   9091 // This function registered all of the above C functions as SQL
   9092 // functions.  This should be the only routine in this file with
   9093 // external linkage.
   9094 func Xsqlite3RegisterDateTimeFunctions(tls *libc.TLS) {
   9095 	Xsqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&aDateTimeFuncs)), int32(uint32(unsafe.Sizeof(aDateTimeFuncs))/uint32(unsafe.Sizeof(FuncDef{}))))
   9096 }
   9097 
   9098 var aDateTimeFuncs = [9]FuncDef{
   9099 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FpUserData: 0, FxSFunc: 0, FzName: ts + 1243},
   9100 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FpUserData: 0, FxSFunc: 0, FzName: ts + 1263},
   9101 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FpUserData: 0, FxSFunc: 0, FzName: ts + 1344},
   9102 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FpUserData: 0, FxSFunc: 0, FzName: ts + 1349},
   9103 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FpUserData: 0, FxSFunc: 0, FzName: ts + 1354},
   9104 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FpUserData: 0, FxSFunc: 0, FzName: ts + 1363},
   9105 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 1372},
   9106 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 1385},
   9107 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 1403}}
   9108 
   9109 // The following routines are convenience wrappers around methods
   9110 // of the sqlite3_file object.  This is mostly just syntactic sugar. All
   9111 // of this would be completely automatic if SQLite were coded using
   9112 // C++ instead of plain old C.
   9113 func Xsqlite3OsClose(tls *libc.TLS, pId uintptr) {
   9114 	if (*Sqlite3_file)(unsafe.Pointer(pId)).FpMethods != 0 {
   9115 		(*struct {
   9116 			f func(*libc.TLS, uintptr) int32
   9117 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pId)).FpMethods)).FxClose})).f(tls, pId)
   9118 		(*Sqlite3_file)(unsafe.Pointer(pId)).FpMethods = uintptr(0)
   9119 	}
   9120 }
   9121 
   9122 func Xsqlite3OsRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset I64) int32 {
   9123 	return (*struct {
   9124 		f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
   9125 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxRead})).f(tls, id, pBuf, amt, offset)
   9126 }
   9127 
   9128 func Xsqlite3OsWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset I64) int32 {
   9129 	return (*struct {
   9130 		f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
   9131 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxWrite})).f(tls, id, pBuf, amt, offset)
   9132 }
   9133 
   9134 func Xsqlite3OsTruncate(tls *libc.TLS, id uintptr, size I64) int32 {
   9135 	return (*struct {
   9136 		f func(*libc.TLS, uintptr, Sqlite3_int64) int32
   9137 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxTruncate})).f(tls, id, size)
   9138 }
   9139 
   9140 func Xsqlite3OsSync(tls *libc.TLS, id uintptr, flags int32) int32 {
   9141 	if flags != 0 {
   9142 		return (*struct {
   9143 			f func(*libc.TLS, uintptr, int32) int32
   9144 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxSync})).f(tls, id, flags)
   9145 	}
   9146 	return SQLITE_OK
   9147 }
   9148 
   9149 func Xsqlite3OsFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 {
   9150 	return (*struct {
   9151 		f func(*libc.TLS, uintptr, uintptr) int32
   9152 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFileSize})).f(tls, id, pSize)
   9153 }
   9154 
   9155 func Xsqlite3OsLock(tls *libc.TLS, id uintptr, lockType int32) int32 {
   9156 	return (*struct {
   9157 		f func(*libc.TLS, uintptr, int32) int32
   9158 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxLock})).f(tls, id, lockType)
   9159 }
   9160 
   9161 func Xsqlite3OsUnlock(tls *libc.TLS, id uintptr, lockType int32) int32 {
   9162 	return (*struct {
   9163 		f func(*libc.TLS, uintptr, int32) int32
   9164 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxUnlock})).f(tls, id, lockType)
   9165 }
   9166 
   9167 func Xsqlite3OsCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 {
   9168 	return (*struct {
   9169 		f func(*libc.TLS, uintptr, uintptr) int32
   9170 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxCheckReservedLock})).f(tls, id, pResOut)
   9171 }
   9172 
   9173 // Use sqlite3OsFileControl() when we are doing something that might fail
   9174 // and we need to know about the failures.  Use sqlite3OsFileControlHint()
   9175 // when simply tossing information over the wall to the VFS and we do not
   9176 // really care if the VFS receives and understands the information since it
   9177 // is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()
   9178 // routine has no return value since the return value would be meaningless.
   9179 func Xsqlite3OsFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 {
   9180 	if (*Sqlite3_file)(unsafe.Pointer(id)).FpMethods == uintptr(0) {
   9181 		return SQLITE_NOTFOUND
   9182 	}
   9183 	return (*struct {
   9184 		f func(*libc.TLS, uintptr, int32, uintptr) int32
   9185 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFileControl})).f(tls, id, op, pArg)
   9186 }
   9187 
   9188 func Xsqlite3OsFileControlHint(tls *libc.TLS, id uintptr, op int32, pArg uintptr) {
   9189 	if (*Sqlite3_file)(unsafe.Pointer(id)).FpMethods != 0 {
   9190 		(*struct {
   9191 			f func(*libc.TLS, uintptr, int32, uintptr) int32
   9192 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFileControl})).f(tls, id, op, pArg)
   9193 	}
   9194 }
   9195 
   9196 func Xsqlite3OsSectorSize(tls *libc.TLS, id uintptr) int32 {
   9197 	var xSectorSize uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxSectorSize
   9198 	return func() int32 {
   9199 		if xSectorSize != 0 {
   9200 			return (*struct {
   9201 				f func(*libc.TLS, uintptr) int32
   9202 			})(unsafe.Pointer(&struct{ uintptr }{xSectorSize})).f(tls, id)
   9203 		}
   9204 		return SQLITE_DEFAULT_SECTOR_SIZE
   9205 	}()
   9206 }
   9207 
   9208 func Xsqlite3OsDeviceCharacteristics(tls *libc.TLS, id uintptr) int32 {
   9209 	if (*Sqlite3_file)(unsafe.Pointer(id)).FpMethods == uintptr(0) {
   9210 		return 0
   9211 	}
   9212 	return (*struct {
   9213 		f func(*libc.TLS, uintptr) int32
   9214 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxDeviceCharacteristics})).f(tls, id)
   9215 }
   9216 
   9217 func Xsqlite3OsShmLock(tls *libc.TLS, id uintptr, offset int32, n int32, flags int32) int32 {
   9218 	return (*struct {
   9219 		f func(*libc.TLS, uintptr, int32, int32, int32) int32
   9220 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmLock})).f(tls, id, offset, n, flags)
   9221 }
   9222 
   9223 func Xsqlite3OsShmBarrier(tls *libc.TLS, id uintptr) {
   9224 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmBarrier})).f(tls, id)
   9225 }
   9226 
   9227 func Xsqlite3OsShmUnmap(tls *libc.TLS, id uintptr, deleteFlag int32) int32 {
   9228 	return (*struct {
   9229 		f func(*libc.TLS, uintptr, int32) int32
   9230 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmUnmap})).f(tls, id, deleteFlag)
   9231 }
   9232 
   9233 func Xsqlite3OsShmMap(tls *libc.TLS, id uintptr, iPage int32, pgsz int32, bExtend int32, pp uintptr) int32 {
   9234 	return (*struct {
   9235 		f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32
   9236 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmMap})).f(tls, id, iPage, pgsz, bExtend, pp)
   9237 }
   9238 
   9239 // The real implementation of xFetch and xUnfetch
   9240 func Xsqlite3OsFetch(tls *libc.TLS, id uintptr, iOff I64, iAmt int32, pp uintptr) int32 {
   9241 	return (*struct {
   9242 		f func(*libc.TLS, uintptr, Sqlite3_int64, int32, uintptr) int32
   9243 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFetch})).f(tls, id, iOff, iAmt, pp)
   9244 }
   9245 
   9246 func Xsqlite3OsUnfetch(tls *libc.TLS, id uintptr, iOff I64, p uintptr) int32 {
   9247 	return (*struct {
   9248 		f func(*libc.TLS, uintptr, Sqlite3_int64, uintptr) int32
   9249 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxUnfetch})).f(tls, id, iOff, p)
   9250 }
   9251 
   9252 // The next group of routines are convenience wrappers around the
   9253 // VFS methods.
   9254 func Xsqlite3OsOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags int32, pFlagsOut uintptr) int32 {
   9255 	var rc int32
   9256 
   9257 	rc = (*struct {
   9258 		f func(*libc.TLS, uintptr, Sqlite3_filename, uintptr, int32, uintptr) int32
   9259 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen})).f(tls, pVfs, zPath, pFile, flags&0x1087f7f, pFlagsOut)
   9260 
   9261 	return rc
   9262 }
   9263 
   9264 func Xsqlite3OsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 {
   9265 	if (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxDelete != uintptr(0) {
   9266 		return (*struct {
   9267 			f func(*libc.TLS, uintptr, uintptr, int32) int32
   9268 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxDelete})).f(tls, pVfs, zPath, dirSync)
   9269 	}
   9270 	return SQLITE_OK
   9271 }
   9272 
   9273 func Xsqlite3OsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 {
   9274 	return (*struct {
   9275 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
   9276 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxAccess})).f(tls, pVfs, zPath, flags, pResOut)
   9277 }
   9278 
   9279 func Xsqlite3OsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nPathOut int32, zPathOut uintptr) int32 {
   9280 	*(*uint8)(unsafe.Pointer(zPathOut)) = uint8(0)
   9281 	return (*struct {
   9282 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
   9283 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxFullPathname})).f(tls, pVfs, zPath, nPathOut, zPathOut)
   9284 }
   9285 
   9286 func Xsqlite3OsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr {
   9287 	return (*struct {
   9288 		f func(*libc.TLS, uintptr, uintptr) uintptr
   9289 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlOpen})).f(tls, pVfs, zPath)
   9290 }
   9291 
   9292 func Xsqlite3OsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) {
   9293 	(*struct {
   9294 		f func(*libc.TLS, uintptr, int32, uintptr)
   9295 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlError})).f(tls, pVfs, nByte, zBufOut)
   9296 }
   9297 
   9298 func Xsqlite3OsDlSym(tls *libc.TLS, pVfs uintptr, pHdle uintptr, zSym uintptr) uintptr {
   9299 	return (*struct {
   9300 		f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr
   9301 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlSym})).f(tls, pVfs, pHdle, zSym)
   9302 }
   9303 
   9304 func Xsqlite3OsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) {
   9305 	(*struct {
   9306 		f func(*libc.TLS, uintptr, uintptr)
   9307 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlClose})).f(tls, pVfs, pHandle)
   9308 }
   9309 
   9310 func Xsqlite3OsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 {
   9311 	if Xsqlite3Config.FiPrngSeed != 0 {
   9312 		libc.Xmemset(tls, zBufOut, 0, uint32(nByte))
   9313 		if nByte > int32(unsafe.Sizeof(uint32(0))) {
   9314 			nByte = int32(unsafe.Sizeof(uint32(0)))
   9315 		}
   9316 		libc.Xmemcpy(tls, zBufOut, uintptr(unsafe.Pointer(&Xsqlite3Config))+276, uint32(nByte))
   9317 		return SQLITE_OK
   9318 	} else {
   9319 		return (*struct {
   9320 			f func(*libc.TLS, uintptr, int32, uintptr) int32
   9321 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxRandomness})).f(tls, pVfs, nByte, zBufOut)
   9322 	}
   9323 	return int32(0)
   9324 
   9325 }
   9326 
   9327 func Xsqlite3OsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 {
   9328 	return (*struct {
   9329 		f func(*libc.TLS, uintptr, int32) int32
   9330 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxSleep})).f(tls, pVfs, nMicro)
   9331 }
   9332 
   9333 func Xsqlite3OsGetLastError(tls *libc.TLS, pVfs uintptr) int32 {
   9334 	if (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxGetLastError != 0 {
   9335 		return (*struct {
   9336 			f func(*libc.TLS, uintptr, int32, uintptr) int32
   9337 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxGetLastError})).f(tls, pVfs, 0, uintptr(0))
   9338 	}
   9339 	return 0
   9340 }
   9341 
   9342 func Xsqlite3OsCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 {
   9343 	bp := tls.Alloc(8)
   9344 	defer tls.Free(8)
   9345 
   9346 	var rc int32
   9347 
   9348 	if (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion >= 2 && (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64 != 0 {
   9349 		rc = (*struct {
   9350 			f func(*libc.TLS, uintptr, uintptr) int32
   9351 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64})).f(tls, pVfs, pTimeOut)
   9352 	} else {
   9353 		rc = (*struct {
   9354 			f func(*libc.TLS, uintptr, uintptr) int32
   9355 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTime})).f(tls, pVfs, bp)
   9356 		*(*Sqlite3_int64)(unsafe.Pointer(pTimeOut)) = libc.Int64FromFloat64(*(*float64)(unsafe.Pointer(bp)) * 86400000.0)
   9357 	}
   9358 	return rc
   9359 }
   9360 
   9361 func Xsqlite3OsOpenMalloc(tls *libc.TLS, pVfs uintptr, zFile uintptr, ppFile uintptr, flags int32, pOutFlags uintptr) int32 {
   9362 	var rc int32
   9363 	var pFile uintptr
   9364 	pFile = Xsqlite3MallocZero(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile))
   9365 	if pFile != 0 {
   9366 		rc = Xsqlite3OsOpen(tls, pVfs, zFile, pFile, flags, pOutFlags)
   9367 		if rc != SQLITE_OK {
   9368 			Xsqlite3_free(tls, pFile)
   9369 			*(*uintptr)(unsafe.Pointer(ppFile)) = uintptr(0)
   9370 		} else {
   9371 			*(*uintptr)(unsafe.Pointer(ppFile)) = pFile
   9372 		}
   9373 	} else {
   9374 		*(*uintptr)(unsafe.Pointer(ppFile)) = uintptr(0)
   9375 		rc = SQLITE_NOMEM
   9376 	}
   9377 
   9378 	return rc
   9379 }
   9380 
   9381 func Xsqlite3OsCloseFree(tls *libc.TLS, pFile uintptr) {
   9382 	Xsqlite3OsClose(tls, pFile)
   9383 	Xsqlite3_free(tls, pFile)
   9384 }
   9385 
   9386 // This function is a wrapper around the OS specific implementation of
   9387 // sqlite3_os_init(). The purpose of the wrapper is to provide the
   9388 // ability to simulate a malloc failure, so that the handling of an
   9389 // error in sqlite3_os_init() by the upper layers can be tested.
   9390 func Xsqlite3OsInit(tls *libc.TLS) int32 {
   9391 	var p uintptr = Xsqlite3_malloc(tls, 10)
   9392 	if p == uintptr(0) {
   9393 		return SQLITE_NOMEM
   9394 	}
   9395 	Xsqlite3_free(tls, p)
   9396 	return Xsqlite3_os_init(tls)
   9397 }
   9398 
   9399 var vfsList uintptr = uintptr(0)
   9400 
   9401 // Locate a VFS by name.  If no name is given, simply return the
   9402 // first VFS on the list.
   9403 func Xsqlite3_vfs_find(tls *libc.TLS, zVfs uintptr) uintptr {
   9404 	var pVfs uintptr = uintptr(0)
   9405 	var mutex uintptr
   9406 	var rc int32 = Xsqlite3_initialize(tls)
   9407 	if rc != 0 {
   9408 		return uintptr(0)
   9409 	}
   9410 	mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
   9411 	Xsqlite3_mutex_enter(tls, mutex)
   9412 	for pVfs = vfsList; pVfs != 0; pVfs = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext {
   9413 		if zVfs == uintptr(0) {
   9414 			break
   9415 		}
   9416 		if libc.Xstrcmp(tls, zVfs, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName) == 0 {
   9417 			break
   9418 		}
   9419 	}
   9420 	Xsqlite3_mutex_leave(tls, mutex)
   9421 	return pVfs
   9422 }
   9423 
   9424 func vfsUnlink(tls *libc.TLS, pVfs uintptr) {
   9425 	if pVfs == uintptr(0) {
   9426 	} else if vfsList == pVfs {
   9427 		vfsList = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext
   9428 	} else if vfsList != 0 {
   9429 		var p uintptr = vfsList
   9430 		for (*Sqlite3_vfs)(unsafe.Pointer(p)).FpNext != 0 && (*Sqlite3_vfs)(unsafe.Pointer(p)).FpNext != pVfs {
   9431 			p = (*Sqlite3_vfs)(unsafe.Pointer(p)).FpNext
   9432 		}
   9433 		if (*Sqlite3_vfs)(unsafe.Pointer(p)).FpNext == pVfs {
   9434 			(*Sqlite3_vfs)(unsafe.Pointer(p)).FpNext = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext
   9435 		}
   9436 	}
   9437 }
   9438 
   9439 // Register a VFS with the system.  It is harmless to register the same
   9440 // VFS multiple times.  The new VFS becomes the default if makeDflt is
   9441 // true.
   9442 func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) int32 {
   9443 	var mutex uintptr
   9444 	var rc int32 = Xsqlite3_initialize(tls)
   9445 	if rc != 0 {
   9446 		return rc
   9447 	}
   9448 
   9449 	mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
   9450 	Xsqlite3_mutex_enter(tls, mutex)
   9451 	vfsUnlink(tls, pVfs)
   9452 	if makeDflt != 0 || vfsList == uintptr(0) {
   9453 		(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext = vfsList
   9454 		vfsList = pVfs
   9455 	} else {
   9456 		(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext = (*Sqlite3_vfs)(unsafe.Pointer(vfsList)).FpNext
   9457 		(*Sqlite3_vfs)(unsafe.Pointer(vfsList)).FpNext = pVfs
   9458 	}
   9459 
   9460 	Xsqlite3_mutex_leave(tls, mutex)
   9461 	return SQLITE_OK
   9462 }
   9463 
   9464 // Unregister a VFS so that it is no longer accessible.
   9465 func Xsqlite3_vfs_unregister(tls *libc.TLS, pVfs uintptr) int32 {
   9466 	var mutex uintptr
   9467 	var rc int32 = Xsqlite3_initialize(tls)
   9468 	if rc != 0 {
   9469 		return rc
   9470 	}
   9471 	mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
   9472 	Xsqlite3_mutex_enter(tls, mutex)
   9473 	vfsUnlink(tls, pVfs)
   9474 	Xsqlite3_mutex_leave(tls, mutex)
   9475 	return SQLITE_OK
   9476 }
   9477 
   9478 // Global variables.
   9479 type BenignMallocHooks1 = struct {
   9480 	FxBenignBegin uintptr
   9481 	FxBenignEnd   uintptr
   9482 }
   9483 
   9484 // Global variables.
   9485 type BenignMallocHooks = BenignMallocHooks1
   9486 
   9487 var sqlite3Hooks = BenignMallocHooks1{}
   9488 
   9489 // Register hooks to call when sqlite3BeginBenignMalloc() and
   9490 // sqlite3EndBenignMalloc() are called, respectively.
   9491 func Xsqlite3BenignMallocHooks(tls *libc.TLS, xBenignBegin uintptr, xBenignEnd uintptr) {
   9492 	sqlite3Hooks.FxBenignBegin = xBenignBegin
   9493 	sqlite3Hooks.FxBenignEnd = xBenignEnd
   9494 }
   9495 
   9496 // This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that
   9497 // subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()
   9498 // indicates that subsequent malloc failures are non-benign.
   9499 func Xsqlite3BeginBenignMalloc(tls *libc.TLS) {
   9500 	if sqlite3Hooks.FxBenignBegin != 0 {
   9501 		(*struct{ f func(*libc.TLS) })(unsafe.Pointer(&struct{ uintptr }{sqlite3Hooks.FxBenignBegin})).f(tls)
   9502 	}
   9503 }
   9504 
   9505 func Xsqlite3EndBenignMalloc(tls *libc.TLS) {
   9506 	if sqlite3Hooks.FxBenignEnd != 0 {
   9507 		(*struct{ f func(*libc.TLS) })(unsafe.Pointer(&struct{ uintptr }{sqlite3Hooks.FxBenignEnd})).f(tls)
   9508 	}
   9509 }
   9510 
   9511 func sqlite3MemMalloc(tls *libc.TLS, nByte int32) uintptr {
   9512 	bp := tls.Alloc(8)
   9513 	defer tls.Free(8)
   9514 
   9515 	var p uintptr
   9516 
   9517 	p = libc.Xmalloc(tls, uint32(nByte+8))
   9518 	if p != 0 {
   9519 		*(*Sqlite3_int64)(unsafe.Pointer(p)) = Sqlite3_int64(nByte)
   9520 		p += 8
   9521 	} else {
   9522 		Xsqlite3_log(tls, SQLITE_NOMEM, ts+1416, libc.VaList(bp, nByte))
   9523 	}
   9524 	return p
   9525 }
   9526 
   9527 func sqlite3MemFree(tls *libc.TLS, pPrior uintptr) {
   9528 	var p uintptr = pPrior
   9529 
   9530 	p -= 8
   9531 	libc.Xfree(tls, p)
   9532 }
   9533 
   9534 func sqlite3MemSize(tls *libc.TLS, pPrior uintptr) int32 {
   9535 	var p uintptr
   9536 
   9537 	p = pPrior
   9538 	p -= 8
   9539 	return int32(*(*Sqlite3_int64)(unsafe.Pointer(p)))
   9540 }
   9541 
   9542 func sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) uintptr {
   9543 	bp := tls.Alloc(16)
   9544 	defer tls.Free(16)
   9545 
   9546 	var p uintptr = pPrior
   9547 
   9548 	p -= 8
   9549 	p = libc.Xrealloc(tls, p, uint32(nByte+8))
   9550 	if p != 0 {
   9551 		*(*Sqlite3_int64)(unsafe.Pointer(p)) = Sqlite3_int64(nByte)
   9552 		p += 8
   9553 	} else {
   9554 		Xsqlite3_log(tls, SQLITE_NOMEM,
   9555 			ts+1454,
   9556 			libc.VaList(bp, sqlite3MemSize(tls, pPrior), nByte))
   9557 	}
   9558 	return p
   9559 }
   9560 
   9561 func sqlite3MemRoundup(tls *libc.TLS, n int32) int32 {
   9562 	return (n + 7) & libc.CplInt32(7)
   9563 }
   9564 
   9565 func sqlite3MemInit(tls *libc.TLS, NotUsed uintptr) int32 {
   9566 	_ = NotUsed
   9567 	return SQLITE_OK
   9568 }
   9569 
   9570 func sqlite3MemShutdown(tls *libc.TLS, NotUsed uintptr) {
   9571 	_ = NotUsed
   9572 	return
   9573 }
   9574 
   9575 // This routine is the only routine in this file with external linkage.
   9576 //
   9577 // Populate the low-level memory allocation function pointers in
   9578 // sqlite3GlobalConfig.m with pointers to the routines in this file.
   9579 func Xsqlite3MemSetDefault(tls *libc.TLS) {
   9580 	bp := tls.Alloc(8)
   9581 	defer tls.Free(8)
   9582 
   9583 	Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods))))
   9584 }
   9585 
   9586 var defaultMethods = Sqlite3_mem_methods{
   9587 	FxMalloc:   0,
   9588 	FxFree:     0,
   9589 	FxRealloc:  0,
   9590 	FxSize:     0,
   9591 	FxRoundup:  0,
   9592 	FxInit:     0,
   9593 	FxShutdown: 0,
   9594 }
   9595 
   9596 // Initialize the mutex system.
   9597 func Xsqlite3MutexInit(tls *libc.TLS) int32 {
   9598 	var rc int32 = SQLITE_OK
   9599 	if !(int32(Xsqlite3Config.Fmutex.FxMutexAlloc) != 0) {
   9600 		var pFrom uintptr
   9601 		var pTo uintptr = uintptr(unsafe.Pointer(&Xsqlite3Config)) + 64
   9602 
   9603 		if Xsqlite3Config.FbCoreMutex != 0 {
   9604 			pFrom = Xsqlite3DefaultMutex(tls)
   9605 		} else {
   9606 			pFrom = Xsqlite3NoopMutex(tls)
   9607 		}
   9608 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexInit = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexInit
   9609 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexEnd = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexEnd
   9610 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexFree = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexFree
   9611 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexEnter = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexEnter
   9612 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexTry = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexTry
   9613 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexLeave = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexLeave
   9614 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexHeld = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexHeld
   9615 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexNotheld = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexNotheld
   9616 
   9617 		(*Sqlite3_mutex_methods)(unsafe.Pointer(pTo)).FxMutexAlloc = (*Sqlite3_mutex_methods)(unsafe.Pointer(pFrom)).FxMutexAlloc
   9618 	}
   9619 
   9620 	rc = (*struct{ f func(*libc.TLS) int32 })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexInit})).f(tls)
   9621 
   9622 	return rc
   9623 }
   9624 
   9625 // Shutdown the mutex system. This call frees resources allocated by
   9626 // sqlite3MutexInit().
   9627 func Xsqlite3MutexEnd(tls *libc.TLS) int32 {
   9628 	var rc int32 = SQLITE_OK
   9629 	if Xsqlite3Config.Fmutex.FxMutexEnd != 0 {
   9630 		rc = (*struct{ f func(*libc.TLS) int32 })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexEnd})).f(tls)
   9631 	}
   9632 
   9633 	return rc
   9634 }
   9635 
   9636 // Retrieve a pointer to a static mutex or allocate a new dynamic one.
   9637 func Xsqlite3_mutex_alloc(tls *libc.TLS, id int32) uintptr {
   9638 	if id <= SQLITE_MUTEX_RECURSIVE && Xsqlite3_initialize(tls) != 0 {
   9639 		return uintptr(0)
   9640 	}
   9641 	if id > SQLITE_MUTEX_RECURSIVE && Xsqlite3MutexInit(tls) != 0 {
   9642 		return uintptr(0)
   9643 	}
   9644 
   9645 	return (*struct {
   9646 		f func(*libc.TLS, int32) uintptr
   9647 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexAlloc})).f(tls, id)
   9648 }
   9649 
   9650 func Xsqlite3MutexAlloc(tls *libc.TLS, id int32) uintptr {
   9651 	if !(int32(Xsqlite3Config.FbCoreMutex) != 0) {
   9652 		return uintptr(0)
   9653 	}
   9654 
   9655 	return (*struct {
   9656 		f func(*libc.TLS, int32) uintptr
   9657 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexAlloc})).f(tls, id)
   9658 }
   9659 
   9660 // Free a dynamic mutex.
   9661 func Xsqlite3_mutex_free(tls *libc.TLS, p uintptr) {
   9662 	if p != 0 {
   9663 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexFree})).f(tls, p)
   9664 	}
   9665 }
   9666 
   9667 // Obtain the mutex p. If some other thread already has the mutex, block
   9668 // until it can be obtained.
   9669 func Xsqlite3_mutex_enter(tls *libc.TLS, p uintptr) {
   9670 	if p != 0 {
   9671 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexEnter})).f(tls, p)
   9672 	}
   9673 }
   9674 
   9675 // Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
   9676 // thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
   9677 func Xsqlite3_mutex_try(tls *libc.TLS, p uintptr) int32 {
   9678 	var rc int32 = SQLITE_OK
   9679 	if p != 0 {
   9680 		return (*struct {
   9681 			f func(*libc.TLS, uintptr) int32
   9682 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexTry})).f(tls, p)
   9683 	}
   9684 	return rc
   9685 }
   9686 
   9687 // The sqlite3_mutex_leave() routine exits a mutex that was previously
   9688 // entered by the same thread.  The behavior is undefined if the mutex
   9689 // is not currently entered. If a NULL pointer is passed as an argument
   9690 // this function is a no-op.
   9691 func Xsqlite3_mutex_leave(tls *libc.TLS, p uintptr) {
   9692 	if p != 0 {
   9693 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fmutex.FxMutexLeave})).f(tls, p)
   9694 	}
   9695 }
   9696 
   9697 func noopMutexInit(tls *libc.TLS) int32 {
   9698 	return SQLITE_OK
   9699 }
   9700 
   9701 func noopMutexEnd(tls *libc.TLS) int32 {
   9702 	return SQLITE_OK
   9703 }
   9704 
   9705 func noopMutexAlloc(tls *libc.TLS, id int32) uintptr {
   9706 	_ = id
   9707 	return uintptr(8)
   9708 }
   9709 
   9710 func noopMutexFree(tls *libc.TLS, p uintptr) {
   9711 	_ = p
   9712 	return
   9713 }
   9714 
   9715 func noopMutexEnter(tls *libc.TLS, p uintptr) {
   9716 	_ = p
   9717 	return
   9718 }
   9719 
   9720 func noopMutexTry(tls *libc.TLS, p uintptr) int32 {
   9721 	_ = p
   9722 	return SQLITE_OK
   9723 }
   9724 
   9725 func noopMutexLeave(tls *libc.TLS, p uintptr) {
   9726 	_ = p
   9727 	return
   9728 }
   9729 
   9730 func Xsqlite3NoopMutex(tls *libc.TLS) uintptr {
   9731 	return uintptr(unsafe.Pointer(&sMutex))
   9732 }
   9733 
   9734 var sMutex = Sqlite3_mutex_methods{
   9735 	FxMutexInit:  0,
   9736 	FxMutexEnd:   0,
   9737 	FxMutexAlloc: 0,
   9738 	FxMutexFree:  0,
   9739 	FxMutexEnter: 0,
   9740 	FxMutexTry:   0,
   9741 	FxMutexLeave: 0,
   9742 }
   9743 
   9744 // If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation
   9745 // is used regardless of the run-time threadsafety setting.
   9746 func Xsqlite3DefaultMutex(tls *libc.TLS) uintptr {
   9747 	return Xsqlite3NoopMutex(tls)
   9748 }
   9749 
   9750 // Attempt to release up to n bytes of non-essential memory currently
   9751 // held by SQLite. An example of non-essential memory is memory used to
   9752 // cache database pages that are not currently in use.
   9753 func Xsqlite3_release_memory(tls *libc.TLS, n int32) int32 {
   9754 	return Xsqlite3PcacheReleaseMemory(tls, n)
   9755 }
   9756 
   9757 // State information local to the memory allocation subsystem.
   9758 type Mem0Global = struct {
   9759 	Fmutex          uintptr
   9760 	F__ccgo_pad1    [4]byte
   9761 	FalarmThreshold Sqlite3_int64
   9762 	FhardLimit      Sqlite3_int64
   9763 	FnearlyFull     int32
   9764 	F__ccgo_pad2    [4]byte
   9765 }
   9766 
   9767 var mem0 = Mem0Global{}
   9768 
   9769 // Return the memory allocator mutex. sqlite3_status() needs it.
   9770 func Xsqlite3MallocMutex(tls *libc.TLS) uintptr {
   9771 	return mem0.Fmutex
   9772 }
   9773 
   9774 // Deprecated external interface.  It used to set an alarm callback
   9775 // that was invoked when memory usage grew too large.  Now it is a
   9776 // no-op.
   9777 func Xsqlite3_memory_alarm(tls *libc.TLS, xCallback uintptr, pArg uintptr, iThreshold Sqlite3_int64) int32 {
   9778 	_ = xCallback
   9779 	_ = pArg
   9780 	_ = iThreshold
   9781 	return SQLITE_OK
   9782 }
   9783 
   9784 // Set the soft heap-size limit for the library.  An argument of
   9785 // zero disables the limit.  A negative argument is a no-op used to
   9786 // obtain the return value.
   9787 //
   9788 // The return value is the value of the heap limit just before this
   9789 // interface was called.
   9790 //
   9791 // If the hard heap limit is enabled, then the soft heap limit cannot
   9792 // be disabled nor raised above the hard heap limit.
   9793 func Xsqlite3_soft_heap_limit64(tls *libc.TLS, n Sqlite3_int64) Sqlite3_int64 {
   9794 	var priorLimit Sqlite3_int64
   9795 	var excess Sqlite3_int64
   9796 	var nUsed Sqlite3_int64
   9797 	var rc int32 = Xsqlite3_initialize(tls)
   9798 	if rc != 0 {
   9799 		return int64(-1)
   9800 	}
   9801 	Xsqlite3_mutex_enter(tls, mem0.Fmutex)
   9802 	priorLimit = mem0.FalarmThreshold
   9803 	if n < int64(0) {
   9804 		Xsqlite3_mutex_leave(tls, mem0.Fmutex)
   9805 		return priorLimit
   9806 	}
   9807 	if mem0.FhardLimit > int64(0) && (n > mem0.FhardLimit || n == int64(0)) {
   9808 		n = mem0.FhardLimit
   9809 	}
   9810 	mem0.FalarmThreshold = n
   9811 	nUsed = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED)
   9812 	libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&mem0))+24, libc.Bool32(n > int64(0) && n <= nUsed), 0)
   9813 	Xsqlite3_mutex_leave(tls, mem0.Fmutex)
   9814 	excess = Xsqlite3_memory_used(tls) - n
   9815 	if excess > int64(0) {
   9816 		Xsqlite3_release_memory(tls, int32(excess&int64(0x7fffffff)))
   9817 	}
   9818 	return priorLimit
   9819 }
   9820 
   9821 func Xsqlite3_soft_heap_limit(tls *libc.TLS, n int32) {
   9822 	if n < 0 {
   9823 		n = 0
   9824 	}
   9825 	Xsqlite3_soft_heap_limit64(tls, int64(n))
   9826 }
   9827 
   9828 // Set the hard heap-size limit for the library. An argument of zero
   9829 // disables the hard heap limit.  A negative argument is a no-op used
   9830 // to obtain the return value without affecting the hard heap limit.
   9831 //
   9832 // The return value is the value of the hard heap limit just prior to
   9833 // calling this interface.
   9834 //
   9835 // Setting the hard heap limit will also activate the soft heap limit
   9836 // and constrain the soft heap limit to be no more than the hard heap
   9837 // limit.
   9838 func Xsqlite3_hard_heap_limit64(tls *libc.TLS, n Sqlite3_int64) Sqlite3_int64 {
   9839 	var priorLimit Sqlite3_int64
   9840 	var rc int32 = Xsqlite3_initialize(tls)
   9841 	if rc != 0 {
   9842 		return int64(-1)
   9843 	}
   9844 	Xsqlite3_mutex_enter(tls, mem0.Fmutex)
   9845 	priorLimit = mem0.FhardLimit
   9846 	if n >= int64(0) {
   9847 		mem0.FhardLimit = n
   9848 		if n < mem0.FalarmThreshold || mem0.FalarmThreshold == int64(0) {
   9849 			mem0.FalarmThreshold = n
   9850 		}
   9851 	}
   9852 	Xsqlite3_mutex_leave(tls, mem0.Fmutex)
   9853 	return priorLimit
   9854 }
   9855 
   9856 // Initialize the memory allocation subsystem.
   9857 func Xsqlite3MallocInit(tls *libc.TLS) int32 {
   9858 	var rc int32
   9859 	if Xsqlite3Config.Fm.FxMalloc == uintptr(0) {
   9860 		Xsqlite3MemSetDefault(tls)
   9861 	}
   9862 	mem0.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MEM)
   9863 	if Xsqlite3Config.FpPage == uintptr(0) || Xsqlite3Config.FszPage < 512 ||
   9864 		Xsqlite3Config.FnPage <= 0 {
   9865 		Xsqlite3Config.FpPage = uintptr(0)
   9866 		Xsqlite3Config.FszPage = 0
   9867 	}
   9868 	rc = (*struct {
   9869 		f func(*libc.TLS, uintptr) int32
   9870 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxInit})).f(tls, Xsqlite3Config.Fm.FpAppData)
   9871 	if rc != SQLITE_OK {
   9872 		libc.Xmemset(tls, uintptr(unsafe.Pointer(&mem0)), 0, uint32(unsafe.Sizeof(mem0)))
   9873 	}
   9874 	return rc
   9875 }
   9876 
   9877 // Return true if the heap is currently under memory pressure - in other
   9878 // words if the amount of heap used is close to the limit set by
   9879 // sqlite3_soft_heap_limit().
   9880 func Xsqlite3HeapNearlyFull(tls *libc.TLS) int32 {
   9881 	return libc.AtomicLoadNInt32(uintptr(unsafe.Pointer(&mem0))+24, 0)
   9882 }
   9883 
   9884 // Deinitialize the memory allocation subsystem.
   9885 func Xsqlite3MallocEnd(tls *libc.TLS) {
   9886 	if Xsqlite3Config.Fm.FxShutdown != 0 {
   9887 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxShutdown})).f(tls, Xsqlite3Config.Fm.FpAppData)
   9888 	}
   9889 	libc.Xmemset(tls, uintptr(unsafe.Pointer(&mem0)), 0, uint32(unsafe.Sizeof(mem0)))
   9890 }
   9891 
   9892 // Return the amount of memory currently checked out.
   9893 func Xsqlite3_memory_used(tls *libc.TLS) Sqlite3_int64 {
   9894 	bp := tls.Alloc(16)
   9895 	defer tls.Free(16)
   9896 
   9897 	Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp, bp+8, 0)
   9898 	return *(*Sqlite3_int64)(unsafe.Pointer(bp))
   9899 }
   9900 
   9901 // Return the maximum amount of memory that has ever been
   9902 // checked out since either the beginning of this process
   9903 // or since the most recent reset.
   9904 func Xsqlite3_memory_highwater(tls *libc.TLS, resetFlag int32) Sqlite3_int64 {
   9905 	bp := tls.Alloc(16)
   9906 	defer tls.Free(16)
   9907 
   9908 	Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp, bp+8, resetFlag)
   9909 	return *(*Sqlite3_int64)(unsafe.Pointer(bp + 8))
   9910 }
   9911 
   9912 func sqlite3MallocAlarm(tls *libc.TLS, nByte int32) {
   9913 	if mem0.FalarmThreshold <= int64(0) {
   9914 		return
   9915 	}
   9916 	Xsqlite3_mutex_leave(tls, mem0.Fmutex)
   9917 	Xsqlite3_release_memory(tls, nByte)
   9918 	Xsqlite3_mutex_enter(tls, mem0.Fmutex)
   9919 }
   9920 
   9921 func mallocWithAlarm(tls *libc.TLS, n int32, pp uintptr) {
   9922 	var p uintptr
   9923 	var nFull int32
   9924 
   9925 	nFull = (*struct{ f func(*libc.TLS, int32) int32 })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxRoundup})).f(tls, n)
   9926 
   9927 	Xsqlite3StatusHighwater(tls, SQLITE_STATUS_MALLOC_SIZE, n)
   9928 	if mem0.FalarmThreshold > int64(0) {
   9929 		var nUsed Sqlite3_int64 = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED)
   9930 		if nUsed >= mem0.FalarmThreshold-Sqlite3_int64(nFull) {
   9931 			libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&mem0))+24, int32(1), 0)
   9932 			sqlite3MallocAlarm(tls, nFull)
   9933 			if mem0.FhardLimit != 0 {
   9934 				nUsed = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED)
   9935 				if nUsed >= mem0.FhardLimit-Sqlite3_int64(nFull) {
   9936 					*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
   9937 					return
   9938 				}
   9939 			}
   9940 		} else {
   9941 			libc.AtomicStoreNInt32(uintptr(unsafe.Pointer(&mem0))+24, int32(0), 0)
   9942 		}
   9943 	}
   9944 	p = (*struct {
   9945 		f func(*libc.TLS, int32) uintptr
   9946 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxMalloc})).f(tls, nFull)
   9947 	if p == uintptr(0) && mem0.FalarmThreshold > int64(0) {
   9948 		sqlite3MallocAlarm(tls, nFull)
   9949 		p = (*struct {
   9950 			f func(*libc.TLS, int32) uintptr
   9951 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxMalloc})).f(tls, nFull)
   9952 	}
   9953 	if p != 0 {
   9954 		nFull = Xsqlite3MallocSize(tls, p)
   9955 		Xsqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, nFull)
   9956 		Xsqlite3StatusUp(tls, SQLITE_STATUS_MALLOC_COUNT, 1)
   9957 	}
   9958 	*(*uintptr)(unsafe.Pointer(pp)) = p
   9959 }
   9960 
   9961 // Allocate memory.  This routine is like sqlite3_malloc() except that it
   9962 // assumes the memory subsystem has already been initialized.
   9963 func Xsqlite3Malloc(tls *libc.TLS, n U64) uintptr {
   9964 	bp := tls.Alloc(4)
   9965 	defer tls.Free(4)
   9966 
   9967 	if n == uint64(0) || n > uint64(SQLITE_MAX_ALLOCATION_SIZE) {
   9968 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
   9969 	} else if Xsqlite3Config.FbMemstat != 0 {
   9970 		Xsqlite3_mutex_enter(tls, mem0.Fmutex)
   9971 		mallocWithAlarm(tls, int32(n), bp)
   9972 		Xsqlite3_mutex_leave(tls, mem0.Fmutex)
   9973 	} else {
   9974 		*(*uintptr)(unsafe.Pointer(bp)) = (*struct {
   9975 			f func(*libc.TLS, int32) uintptr
   9976 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxMalloc})).f(tls, int32(n))
   9977 	}
   9978 
   9979 	return *(*uintptr)(unsafe.Pointer(bp))
   9980 }
   9981 
   9982 // This version of the memory allocation is for use by the application.
   9983 // First make sure the memory subsystem is initialized, then do the
   9984 // allocation.
   9985 func Xsqlite3_malloc(tls *libc.TLS, n int32) uintptr {
   9986 	if Xsqlite3_initialize(tls) != 0 {
   9987 		return uintptr(0)
   9988 	}
   9989 	if n <= 0 {
   9990 		return uintptr(0)
   9991 	}
   9992 	return Xsqlite3Malloc(tls, uint64(n))
   9993 }
   9994 
   9995 func Xsqlite3_malloc64(tls *libc.TLS, n Sqlite3_uint64) uintptr {
   9996 	if Xsqlite3_initialize(tls) != 0 {
   9997 		return uintptr(0)
   9998 	}
   9999 	return Xsqlite3Malloc(tls, n)
  10000 }
  10001 
  10002 func isLookaside(tls *libc.TLS, db uintptr, p uintptr) int32 {
  10003 	return libc.Bool32(Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) && Uptr(p) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd))
  10004 }
  10005 
  10006 // Return the size of a memory allocation previously obtained from
  10007 // sqlite3Malloc() or sqlite3_malloc().
  10008 func Xsqlite3MallocSize(tls *libc.TLS, p uintptr) int32 {
  10009 	return (*struct {
  10010 		f func(*libc.TLS, uintptr) int32
  10011 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxSize})).f(tls, p)
  10012 }
  10013 
  10014 func lookasideMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 {
  10015 	if p < (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle {
  10016 		return int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue)
  10017 	}
  10018 	return LOOKASIDE_SMALL
  10019 }
  10020 
  10021 func Xsqlite3DbMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 {
  10022 	if db != 0 {
  10023 		if Uptr(p) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd) {
  10024 			if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) {
  10025 				return LOOKASIDE_SMALL
  10026 			}
  10027 			if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) {
  10028 				return int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue)
  10029 			}
  10030 		}
  10031 	}
  10032 	return (*struct {
  10033 		f func(*libc.TLS, uintptr) int32
  10034 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxSize})).f(tls, p)
  10035 }
  10036 
  10037 func Xsqlite3_msize(tls *libc.TLS, p uintptr) Sqlite3_uint64 {
  10038 	if p != 0 {
  10039 		return uint64((*struct {
  10040 			f func(*libc.TLS, uintptr) int32
  10041 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxSize})).f(tls, p))
  10042 	}
  10043 	return uint64(0)
  10044 }
  10045 
  10046 // Free memory previously obtained from sqlite3Malloc().
  10047 func Xsqlite3_free(tls *libc.TLS, p uintptr) {
  10048 	if p == uintptr(0) {
  10049 		return
  10050 	}
  10051 
  10052 	if Xsqlite3Config.FbMemstat != 0 {
  10053 		Xsqlite3_mutex_enter(tls, mem0.Fmutex)
  10054 		Xsqlite3StatusDown(tls, SQLITE_STATUS_MEMORY_USED, Xsqlite3MallocSize(tls, p))
  10055 		Xsqlite3StatusDown(tls, SQLITE_STATUS_MALLOC_COUNT, 1)
  10056 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxFree})).f(tls, p)
  10057 		Xsqlite3_mutex_leave(tls, mem0.Fmutex)
  10058 	} else {
  10059 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxFree})).f(tls, p)
  10060 	}
  10061 }
  10062 
  10063 func measureAllocationSize(tls *libc.TLS, db uintptr, p uintptr) {
  10064 	*(*int32)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed)) += Xsqlite3DbMallocSize(tls, db, p)
  10065 }
  10066 
  10067 // Free memory that might be associated with a particular database
  10068 // connection.  Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op.
  10069 // The sqlite3DbFreeNN(D,X) version requires that X be non-NULL.
  10070 func Xsqlite3DbFreeNN(tls *libc.TLS, db uintptr, p uintptr) {
  10071 	if db != 0 {
  10072 		if Uptr(p) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) {
  10073 			if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) {
  10074 				var pBuf uintptr = p
  10075 
  10076 				(*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree
  10077 				(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = pBuf
  10078 				return
  10079 			}
  10080 			if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) {
  10081 				var pBuf uintptr = p
  10082 
  10083 				(*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree
  10084 				(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = pBuf
  10085 				return
  10086 			}
  10087 		}
  10088 		if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed != 0 {
  10089 			measureAllocationSize(tls, db, p)
  10090 			return
  10091 		}
  10092 	}
  10093 
  10094 	Xsqlite3_free(tls, p)
  10095 }
  10096 
  10097 func Xsqlite3DbNNFreeNN(tls *libc.TLS, db uintptr, p uintptr) {
  10098 	if Uptr(p) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) {
  10099 		if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) {
  10100 			var pBuf uintptr = p
  10101 
  10102 			(*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree
  10103 			(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = pBuf
  10104 			return
  10105 		}
  10106 		if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) {
  10107 			var pBuf uintptr = p
  10108 
  10109 			(*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree
  10110 			(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = pBuf
  10111 			return
  10112 		}
  10113 	}
  10114 	if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed != 0 {
  10115 		measureAllocationSize(tls, db, p)
  10116 		return
  10117 	}
  10118 
  10119 	Xsqlite3_free(tls, p)
  10120 }
  10121 
  10122 func Xsqlite3DbFree(tls *libc.TLS, db uintptr, p uintptr) {
  10123 	if p != 0 {
  10124 		Xsqlite3DbFreeNN(tls, db, p)
  10125 	}
  10126 }
  10127 
  10128 // Change the size of an existing memory allocation
  10129 func Xsqlite3Realloc(tls *libc.TLS, pOld uintptr, nBytes U64) uintptr {
  10130 	var nOld int32
  10131 	var nNew int32
  10132 	var nDiff int32
  10133 	var pNew uintptr
  10134 
  10135 	if pOld == uintptr(0) {
  10136 		return Xsqlite3Malloc(tls, nBytes)
  10137 	}
  10138 	if nBytes == uint64(0) {
  10139 		Xsqlite3_free(tls, pOld)
  10140 		return uintptr(0)
  10141 	}
  10142 	if nBytes >= uint64(0x7fffff00) {
  10143 		return uintptr(0)
  10144 	}
  10145 	nOld = Xsqlite3MallocSize(tls, pOld)
  10146 
  10147 	nNew = (*struct{ f func(*libc.TLS, int32) int32 })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxRoundup})).f(tls, int32(nBytes))
  10148 	if nOld == nNew {
  10149 		pNew = pOld
  10150 	} else if Xsqlite3Config.FbMemstat != 0 {
  10151 		var nUsed Sqlite3_int64
  10152 		Xsqlite3_mutex_enter(tls, mem0.Fmutex)
  10153 		Xsqlite3StatusHighwater(tls, SQLITE_STATUS_MALLOC_SIZE, int32(nBytes))
  10154 		nDiff = nNew - nOld
  10155 		if nDiff > 0 && libc.AssignInt64(&nUsed, Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED)) >= mem0.FalarmThreshold-Sqlite3_int64(nDiff) {
  10156 			sqlite3MallocAlarm(tls, nDiff)
  10157 			if mem0.FhardLimit > int64(0) && nUsed >= mem0.FhardLimit-Sqlite3_int64(nDiff) {
  10158 				Xsqlite3_mutex_leave(tls, mem0.Fmutex)
  10159 				return uintptr(0)
  10160 			}
  10161 		}
  10162 		pNew = (*struct {
  10163 			f func(*libc.TLS, uintptr, int32) uintptr
  10164 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxRealloc})).f(tls, pOld, nNew)
  10165 		if pNew == uintptr(0) && mem0.FalarmThreshold > int64(0) {
  10166 			sqlite3MallocAlarm(tls, int32(nBytes))
  10167 			pNew = (*struct {
  10168 				f func(*libc.TLS, uintptr, int32) uintptr
  10169 			})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxRealloc})).f(tls, pOld, nNew)
  10170 		}
  10171 		if pNew != 0 {
  10172 			nNew = Xsqlite3MallocSize(tls, pNew)
  10173 			Xsqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, nNew-nOld)
  10174 		}
  10175 		Xsqlite3_mutex_leave(tls, mem0.Fmutex)
  10176 	} else {
  10177 		pNew = (*struct {
  10178 			f func(*libc.TLS, uintptr, int32) uintptr
  10179 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fm.FxRealloc})).f(tls, pOld, nNew)
  10180 	}
  10181 
  10182 	return pNew
  10183 }
  10184 
  10185 // The public interface to sqlite3Realloc.  Make sure that the memory
  10186 // subsystem is initialized prior to invoking sqliteRealloc.
  10187 func Xsqlite3_realloc(tls *libc.TLS, pOld uintptr, n int32) uintptr {
  10188 	if Xsqlite3_initialize(tls) != 0 {
  10189 		return uintptr(0)
  10190 	}
  10191 	if n < 0 {
  10192 		n = 0
  10193 	}
  10194 	return Xsqlite3Realloc(tls, pOld, uint64(n))
  10195 }
  10196 
  10197 func Xsqlite3_realloc64(tls *libc.TLS, pOld uintptr, n Sqlite3_uint64) uintptr {
  10198 	if Xsqlite3_initialize(tls) != 0 {
  10199 		return uintptr(0)
  10200 	}
  10201 	return Xsqlite3Realloc(tls, pOld, n)
  10202 }
  10203 
  10204 // Allocate and zero memory.
  10205 func Xsqlite3MallocZero(tls *libc.TLS, n U64) uintptr {
  10206 	var p uintptr = Xsqlite3Malloc(tls, n)
  10207 	if p != 0 {
  10208 		libc.Xmemset(tls, p, 0, Size_t(n))
  10209 	}
  10210 	return p
  10211 }
  10212 
  10213 // Allocate and zero memory.  If the allocation fails, make
  10214 // the mallocFailed flag in the connection pointer.
  10215 func Xsqlite3DbMallocZero(tls *libc.TLS, db uintptr, n U64) uintptr {
  10216 	var p uintptr
  10217 
  10218 	p = Xsqlite3DbMallocRaw(tls, db, n)
  10219 	if p != 0 {
  10220 		libc.Xmemset(tls, p, 0, Size_t(n))
  10221 	}
  10222 	return p
  10223 }
  10224 
  10225 func dbMallocRawFinish(tls *libc.TLS, db uintptr, n U64) uintptr {
  10226 	var p uintptr
  10227 
  10228 	p = Xsqlite3Malloc(tls, n)
  10229 	if !(p != 0) {
  10230 		Xsqlite3OomFault(tls, db)
  10231 	}
  10232 
  10233 	return p
  10234 }
  10235 
  10236 // Allocate memory, either lookaside (if possible) or heap.
  10237 // If the allocation fails, set the mallocFailed flag in
  10238 // the connection pointer.
  10239 //
  10240 // If db!=0 and db->mallocFailed is true (indicating a prior malloc
  10241 // failure on the same database connection) then always return 0.
  10242 // Hence for a particular database connection, once malloc starts
  10243 // failing, it fails consistently until mallocFailed is reset.
  10244 // This is an important assumption.  There are many places in the
  10245 // code that do things like this:
  10246 //
  10247 //	int *a = (int*)sqlite3DbMallocRaw(db, 100);
  10248 //	int *b = (int*)sqlite3DbMallocRaw(db, 200);
  10249 //	if( b ) a[10] = 9;
  10250 //
  10251 // In other words, if a subsequent malloc (ex: "b") worked, it is assumed
  10252 // that all prior mallocs (ex: "a") worked too.
  10253 //
  10254 // The sqlite3MallocRawNN() variant guarantees that the "db" parameter is
  10255 // not a NULL pointer.
  10256 func Xsqlite3DbMallocRaw(tls *libc.TLS, db uintptr, n U64) uintptr {
  10257 	var p uintptr
  10258 	if db != 0 {
  10259 		return Xsqlite3DbMallocRawNN(tls, db, n)
  10260 	}
  10261 	p = Xsqlite3Malloc(tls, n)
  10262 
  10263 	return p
  10264 }
  10265 
  10266 func Xsqlite3DbMallocRawNN(tls *libc.TLS, db uintptr, n U64) uintptr {
  10267 	var pBuf uintptr
  10268 
  10269 	if n > U64((*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz) {
  10270 		if !(int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable) != 0) {
  10271 			*(*U32)(unsafe.Pointer(db + 320 + 16 + 1*4))++
  10272 		} else if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  10273 			return uintptr(0)
  10274 		}
  10275 		return dbMallocRawFinish(tls, db, n)
  10276 	}
  10277 	if n <= uint64(LOOKASIDE_SMALL) {
  10278 		if libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree) != uintptr(0) {
  10279 			(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext
  10280 			*(*U32)(unsafe.Pointer(db + 320 + 16))++
  10281 			return pBuf
  10282 		} else if libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit) != uintptr(0) {
  10283 			(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext
  10284 			*(*U32)(unsafe.Pointer(db + 320 + 16))++
  10285 			return pBuf
  10286 		}
  10287 	}
  10288 	if libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree) != uintptr(0) {
  10289 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext
  10290 		*(*U32)(unsafe.Pointer(db + 320 + 16))++
  10291 		return pBuf
  10292 	} else if libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit) != uintptr(0) {
  10293 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext
  10294 		*(*U32)(unsafe.Pointer(db + 320 + 16))++
  10295 		return pBuf
  10296 	} else {
  10297 		*(*U32)(unsafe.Pointer(db + 320 + 16 + 2*4))++
  10298 	}
  10299 	return dbMallocRawFinish(tls, db, n)
  10300 }
  10301 
  10302 // Resize the block of memory pointed to by p to n bytes. If the
  10303 // resize fails, set the mallocFailed flag in the connection object.
  10304 func Xsqlite3DbRealloc(tls *libc.TLS, db uintptr, p uintptr, n U64) uintptr {
  10305 	if p == uintptr(0) {
  10306 		return Xsqlite3DbMallocRawNN(tls, db, n)
  10307 	}
  10308 
  10309 	if Uptr(p) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) {
  10310 		if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) {
  10311 			if n <= uint64(LOOKASIDE_SMALL) {
  10312 				return p
  10313 			}
  10314 		} else if Uptr(p) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) {
  10315 			if n <= U64((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) {
  10316 				return p
  10317 			}
  10318 		}
  10319 	}
  10320 	return dbReallocFinish(tls, db, p, n)
  10321 }
  10322 
  10323 func dbReallocFinish(tls *libc.TLS, db uintptr, p uintptr, n U64) uintptr {
  10324 	var pNew uintptr = uintptr(0)
  10325 
  10326 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  10327 		if isLookaside(tls, db, p) != 0 {
  10328 			pNew = Xsqlite3DbMallocRawNN(tls, db, n)
  10329 			if pNew != 0 {
  10330 				libc.Xmemcpy(tls, pNew, p, uint32(lookasideMallocSize(tls, db, p)))
  10331 				Xsqlite3DbFree(tls, db, p)
  10332 			}
  10333 		} else {
  10334 			pNew = Xsqlite3Realloc(tls, p, n)
  10335 			if !(pNew != 0) {
  10336 				Xsqlite3OomFault(tls, db)
  10337 			}
  10338 
  10339 		}
  10340 	}
  10341 	return pNew
  10342 }
  10343 
  10344 // Attempt to reallocate p.  If the reallocation fails, then free p
  10345 // and set the mallocFailed flag in the database connection.
  10346 func Xsqlite3DbReallocOrFree(tls *libc.TLS, db uintptr, p uintptr, n U64) uintptr {
  10347 	var pNew uintptr
  10348 	pNew = Xsqlite3DbRealloc(tls, db, p, n)
  10349 	if !(pNew != 0) {
  10350 		Xsqlite3DbFree(tls, db, p)
  10351 	}
  10352 	return pNew
  10353 }
  10354 
  10355 // Make a copy of a string in memory obtained from sqliteMalloc(). These
  10356 // functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This
  10357 // is because when memory debugging is turned on, these two functions are
  10358 // called via macros that record the current file and line number in the
  10359 // ThreadData structure.
  10360 func Xsqlite3DbStrDup(tls *libc.TLS, db uintptr, z uintptr) uintptr {
  10361 	var zNew uintptr
  10362 	var n Size_t
  10363 	if z == uintptr(0) {
  10364 		return uintptr(0)
  10365 	}
  10366 	n = libc.Xstrlen(tls, z) + Size_t(1)
  10367 	zNew = Xsqlite3DbMallocRaw(tls, db, uint64(n))
  10368 	if zNew != 0 {
  10369 		libc.Xmemcpy(tls, zNew, z, n)
  10370 	}
  10371 	return zNew
  10372 }
  10373 
  10374 func Xsqlite3DbStrNDup(tls *libc.TLS, db uintptr, z uintptr, n U64) uintptr {
  10375 	var zNew uintptr
  10376 
  10377 	if z != 0 {
  10378 		zNew = Xsqlite3DbMallocRawNN(tls, db, n+uint64(1))
  10379 	} else {
  10380 		zNew = uintptr(0)
  10381 	}
  10382 	if zNew != 0 {
  10383 		libc.Xmemcpy(tls, zNew, z, Size_t(n))
  10384 		*(*uint8)(unsafe.Pointer(zNew + uintptr(n))) = uint8(0)
  10385 	}
  10386 	return zNew
  10387 }
  10388 
  10389 // The text between zStart and zEnd represents a phrase within a larger
  10390 // SQL statement.  Make a copy of this phrase in space obtained form
  10391 // sqlite3DbMalloc().  Omit leading and trailing whitespace.
  10392 func Xsqlite3DbSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) uintptr {
  10393 	var n int32
  10394 	for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zStart))])&0x01 != 0 {
  10395 		zStart++
  10396 	}
  10397 	n = (int32(zEnd) - int32(zStart)) / 1
  10398 	for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zStart + uintptr(n-1)))])&0x01 != 0 {
  10399 		n--
  10400 	}
  10401 	return Xsqlite3DbStrNDup(tls, db, zStart, uint64(n))
  10402 }
  10403 
  10404 // Free any prior content in *pz and replace it with a copy of zNew.
  10405 func Xsqlite3SetString(tls *libc.TLS, pz uintptr, db uintptr, zNew uintptr) {
  10406 	var z uintptr = Xsqlite3DbStrDup(tls, db, zNew)
  10407 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pz)))
  10408 	*(*uintptr)(unsafe.Pointer(pz)) = z
  10409 }
  10410 
  10411 // Call this routine to record the fact that an OOM (out-of-memory) error
  10412 // has happened.  This routine will set db->mallocFailed, and also
  10413 // temporarily disable the lookaside memory allocator and interrupt
  10414 // any running VDBEs.
  10415 //
  10416 // Always return a NULL pointer so that this routine can be invoked using
  10417 //
  10418 //	return sqlite3OomFault(db);
  10419 //
  10420 // and thereby avoid unnecessary stack frame allocations for the overwhelmingly
  10421 // common case where no OOM occurs.
  10422 func Xsqlite3OomFault(tls *libc.TLS, db uintptr) uintptr {
  10423 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && int32((*Sqlite3)(unsafe.Pointer(db)).FbBenignMalloc) == 0 {
  10424 		(*Sqlite3)(unsafe.Pointer(db)).FmallocFailed = U8(1)
  10425 		if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec > 0 {
  10426 			libc.AtomicStoreNInt32(db+312, int32(1), 0)
  10427 		}
  10428 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++
  10429 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
  10430 		if (*Sqlite3)(unsafe.Pointer(db)).FpParse != 0 {
  10431 			var pParse uintptr
  10432 			Xsqlite3ErrorMsg(tls, (*Sqlite3)(unsafe.Pointer(db)).FpParse, ts+1490, 0)
  10433 			(*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).Frc = SQLITE_NOMEM
  10434 			for pParse = (*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).FpOuterParse; pParse != 0; pParse = (*Parse)(unsafe.Pointer(pParse)).FpOuterParse {
  10435 				(*Parse)(unsafe.Pointer(pParse)).FnErr++
  10436 				(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
  10437 			}
  10438 		}
  10439 	}
  10440 	return uintptr(0)
  10441 }
  10442 
  10443 // This routine reactivates the memory allocator and clears the
  10444 // db->mallocFailed flag as necessary.
  10445 //
  10446 // The memory allocator is not restarted if there are running
  10447 // VDBEs.
  10448 func Xsqlite3OomClear(tls *libc.TLS, db uintptr) {
  10449 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 && (*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0 {
  10450 		(*Sqlite3)(unsafe.Pointer(db)).FmallocFailed = U8(0)
  10451 		libc.AtomicStoreNInt32(db+312, int32(0), 0)
  10452 
  10453 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable--
  10454 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = func() uint16 {
  10455 			if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 {
  10456 				return uint16(0)
  10457 			}
  10458 			return (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue
  10459 		}()
  10460 	}
  10461 }
  10462 
  10463 func apiHandleError(tls *libc.TLS, db uintptr, rc int32) int32 {
  10464 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || rc == SQLITE_IOERR|int32(12)<<8 {
  10465 		Xsqlite3OomClear(tls, db)
  10466 		Xsqlite3Error(tls, db, SQLITE_NOMEM)
  10467 		return SQLITE_NOMEM
  10468 	}
  10469 	return rc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask
  10470 }
  10471 
  10472 // This function must be called before exiting any API function (i.e.
  10473 // returning control to the user) that has called sqlite3_malloc or
  10474 // sqlite3_realloc.
  10475 //
  10476 // The returned value is normally a copy of the second argument to this
  10477 // function. However, if a malloc() failure has occurred since the previous
  10478 // invocation SQLITE_NOMEM is returned instead.
  10479 //
  10480 // If an OOM as occurred, then the connection error-code (the value
  10481 // returned by sqlite3_errcode()) is set to SQLITE_NOMEM.
  10482 func Xsqlite3ApiExit(tls *libc.TLS, db uintptr, rc int32) int32 {
  10483 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || rc != 0 {
  10484 		return apiHandleError(tls, db, rc)
  10485 	}
  10486 	return rc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask
  10487 }
  10488 
  10489 // An "etByte" is an 8-bit unsigned value.
  10490 type EtByte = uint8
  10491 
  10492 type et_info = struct {
  10493 	Ffmttype uint8
  10494 	Fbase    EtByte
  10495 	Fflags   EtByte
  10496 	Ftype    EtByte
  10497 	Fcharset EtByte
  10498 	Fprefix  EtByte
  10499 }
  10500 
  10501 // Each builtin conversion character (ex: the 'd' in "%d") is described
  10502 // by an instance of the following structure
  10503 type Et_info = et_info
  10504 
  10505 var aDigits = *(*[33]uint8)(unsafe.Pointer(ts + 1504))
  10506 var aPrefix = *(*[7]uint8)(unsafe.Pointer(ts + 1537))
  10507 var fmtinfo = [23]Et_info{
  10508 	{Ffmttype: uint8('d'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtByte(EtDECIMAL)},
  10509 	{Ffmttype: uint8('s'), Fflags: EtByte(4), Ftype: EtByte(EtSTRING)},
  10510 	{Ffmttype: uint8('g'), Fflags: EtByte(1), Ftype: EtByte(EtGENERIC), Fcharset: EtByte(30)},
  10511 	{Ffmttype: uint8('z'), Fflags: EtByte(4), Ftype: EtByte(EtDYNSTRING)},
  10512 	{Ffmttype: uint8('q'), Fflags: EtByte(4), Ftype: EtByte(EtSQLESCAPE)},
  10513 	{Ffmttype: uint8('Q'), Fflags: EtByte(4), Ftype: EtByte(EtSQLESCAPE2)},
  10514 	{Ffmttype: uint8('w'), Fflags: EtByte(4), Ftype: EtByte(EtSQLESCAPE3)},
  10515 	{Ffmttype: uint8('c'), Ftype: EtByte(EtCHARX)},
  10516 	{Ffmttype: uint8('o'), Fbase: EtByte(8), Fprefix: EtByte(2)},
  10517 	{Ffmttype: uint8('u'), Fbase: EtByte(10), Ftype: EtByte(EtDECIMAL)},
  10518 	{Ffmttype: uint8('x'), Fbase: EtByte(16), Fcharset: EtByte(16), Fprefix: EtByte(1)},
  10519 	{Ffmttype: uint8('X'), Fbase: EtByte(16), Fprefix: EtByte(4)},
  10520 	{Ffmttype: uint8('f'), Fflags: EtByte(1), Ftype: EtByte(EtFLOAT)},
  10521 	{Ffmttype: uint8('e'), Fflags: EtByte(1), Ftype: EtByte(EtEXP), Fcharset: EtByte(30)},
  10522 	{Ffmttype: uint8('E'), Fflags: EtByte(1), Ftype: EtByte(EtEXP), Fcharset: EtByte(14)},
  10523 	{Ffmttype: uint8('G'), Fflags: EtByte(1), Ftype: EtByte(EtGENERIC), Fcharset: EtByte(14)},
  10524 	{Ffmttype: uint8('i'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtByte(EtDECIMAL)},
  10525 	{Ffmttype: uint8('n'), Ftype: EtByte(EtSIZE)},
  10526 	{Ffmttype: uint8('%'), Ftype: EtByte(EtPERCENT)},
  10527 	{Ffmttype: uint8('p'), Fbase: EtByte(16), Ftype: EtByte(EtPOINTER), Fprefix: EtByte(1)},
  10528 	{Ffmttype: uint8('T'), Ftype: EtByte(EtTOKEN)},
  10529 	{Ffmttype: uint8('S'), Ftype: EtByte(EtSRCITEM)},
  10530 	{Ffmttype: uint8('r'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtByte(EtORDINAL)},
  10531 }
  10532 
  10533 var arRound = [10]float64{
  10534 	5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05,
  10535 	5.0e-06, 5.0e-07, 5.0e-08, 5.0e-09, 5.0e-10,
  10536 }
  10537 
  10538 func et_getdigit(tls *libc.TLS, val uintptr, cnt uintptr) uint8 {
  10539 	var digit int32
  10540 	var d float64
  10541 	if *(*int32)(unsafe.Pointer(cnt)) <= 0 {
  10542 		return uint8('0')
  10543 	}
  10544 	*(*int32)(unsafe.Pointer(cnt))--
  10545 	digit = int32(*(*float64)(unsafe.Pointer(val)))
  10546 	d = float64(digit)
  10547 	digit = digit + '0'
  10548 	*(*float64)(unsafe.Pointer(val)) = (*(*float64)(unsafe.Pointer(val)) - d) * 10.0
  10549 	return uint8(digit)
  10550 }
  10551 
  10552 // Set the StrAccum object to an error mode.
  10553 func Xsqlite3StrAccumSetError(tls *libc.TLS, p uintptr, eError U8) {
  10554 	(*StrAccum)(unsafe.Pointer(p)).FaccError = eError
  10555 	if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc != 0 {
  10556 		Xsqlite3_str_reset(tls, p)
  10557 	}
  10558 	if int32(eError) == SQLITE_TOOBIG {
  10559 		Xsqlite3ErrorToParser(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, int32(eError))
  10560 	}
  10561 }
  10562 
  10563 func getIntArg(tls *libc.TLS, p uintptr) Sqlite3_int64 {
  10564 	if (*PrintfArguments)(unsafe.Pointer(p)).FnArg <= (*PrintfArguments)(unsafe.Pointer(p)).FnUsed {
  10565 		return int64(0)
  10566 	}
  10567 	return Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer((*PrintfArguments)(unsafe.Pointer(p)).FapArg + uintptr(libc.PostIncInt32(&(*PrintfArguments)(unsafe.Pointer(p)).FnUsed, 1))*4)))
  10568 }
  10569 
  10570 func getDoubleArg(tls *libc.TLS, p uintptr) float64 {
  10571 	if (*PrintfArguments)(unsafe.Pointer(p)).FnArg <= (*PrintfArguments)(unsafe.Pointer(p)).FnUsed {
  10572 		return 0.0
  10573 	}
  10574 	return Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer((*PrintfArguments)(unsafe.Pointer(p)).FapArg + uintptr(libc.PostIncInt32(&(*PrintfArguments)(unsafe.Pointer(p)).FnUsed, 1))*4)))
  10575 }
  10576 
  10577 func getTextArg(tls *libc.TLS, p uintptr) uintptr {
  10578 	if (*PrintfArguments)(unsafe.Pointer(p)).FnArg <= (*PrintfArguments)(unsafe.Pointer(p)).FnUsed {
  10579 		return uintptr(0)
  10580 	}
  10581 	return Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer((*PrintfArguments)(unsafe.Pointer(p)).FapArg + uintptr(libc.PostIncInt32(&(*PrintfArguments)(unsafe.Pointer(p)).FnUsed, 1))*4)))
  10582 }
  10583 
  10584 func printfTempBuf(tls *libc.TLS, pAccum uintptr, n Sqlite3_int64) uintptr {
  10585 	var z uintptr
  10586 	if (*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError != 0 {
  10587 		return uintptr(0)
  10588 	}
  10589 	if n > Sqlite3_int64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc) && n > Sqlite3_int64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc) {
  10590 		Xsqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_TOOBIG))
  10591 		return uintptr(0)
  10592 	}
  10593 	z = Xsqlite3DbMallocRaw(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, uint64(n))
  10594 	if z == uintptr(0) {
  10595 		Xsqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_NOMEM))
  10596 	}
  10597 	return z
  10598 }
  10599 
  10600 // Render a string given by "fmt" into the StrAccum object.
  10601 func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Va_list) {
  10602 	bp := tls.Alloc(116)
  10603 	defer tls.Free(116)
  10604 
  10605 	var c int32
  10606 	var bufpt uintptr
  10607 	var precision int32
  10608 	var length int32
  10609 	var idx int32
  10610 	var width int32
  10611 	var flag_leftjustify EtByte
  10612 	var flag_prefix EtByte
  10613 	var flag_alternateform EtByte
  10614 	var flag_altform2 EtByte
  10615 	var flag_zeropad EtByte
  10616 	var flag_long EtByte
  10617 	var done EtByte
  10618 	var cThousand EtByte
  10619 	var xtype EtByte
  10620 	var bArgList U8
  10621 	var prefix uint8
  10622 	var longvalue Sqlite_uint64
  10623 
  10624 	var infop uintptr
  10625 	var zOut uintptr
  10626 	var nOut int32
  10627 	var zExtra uintptr
  10628 	var exp int32
  10629 	var e2 int32
  10630 
  10631 	var rounder float64
  10632 	var flag_dp EtByte
  10633 	var flag_rtz EtByte
  10634 	var pArgList uintptr
  10635 
  10636 	var wx uint32
  10637 	var px uint32
  10638 	var v I64
  10639 	var n U64
  10640 	var x int32
  10641 	var cset uintptr
  10642 	var base U8
  10643 	var nn int32
  10644 	var ix int32
  10645 	var pre uintptr
  10646 	var x1 uint8
  10647 
  10648 	var ex int32
  10649 	var scale float64
  10650 	var szBufNeeded I64
  10651 	var i int32
  10652 	var nPad int32
  10653 	var ch uint32
  10654 	var nCopyBytes I64
  10655 	var nPrior I64
  10656 
  10657 	var z uintptr
  10658 
  10659 	var ii int32
  10660 	var i1 I64
  10661 	var j I64
  10662 	var k I64
  10663 	var n1 I64
  10664 	var needQuote int32
  10665 	var isnull int32
  10666 	var ch1 uint8
  10667 	var q uint8
  10668 	var escarg uintptr
  10669 
  10670 	var pExpr uintptr
  10671 
  10672 	var pToken uintptr
  10673 	var pSel uintptr
  10674 	var pItem uintptr
  10675 	xtype = EtByte(EtINVALID)
  10676 	zExtra = uintptr(0)
  10677 	pArgList = uintptr(0)
  10678 
  10679 	bufpt = uintptr(0)
  10680 	if !(int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&SQLITE_PRINTF_SQLFUNC != 0) {
  10681 		goto __1
  10682 	}
  10683 	pArgList = libc.VaUintptr(&ap)
  10684 	bArgList = U8(1)
  10685 	goto __2
  10686 __1:
  10687 	bArgList = U8(0)
  10688 __2:
  10689 	;
  10690 __3:
  10691 	if !(libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(fmt)))) != 0) {
  10692 		goto __5
  10693 	}
  10694 	if !(c != '%') {
  10695 		goto __6
  10696 	}
  10697 	bufpt = fmt
  10698 __7:
  10699 	fmt++
  10700 	goto __8
  10701 __8:
  10702 	if *(*uint8)(unsafe.Pointer(fmt)) != 0 && int32(*(*uint8)(unsafe.Pointer(fmt))) != '%' {
  10703 		goto __7
  10704 	}
  10705 	goto __9
  10706 __9:
  10707 	;
  10708 	Xsqlite3_str_append(tls, pAccum, bufpt, (int32(fmt)-int32(bufpt))/1)
  10709 	if !(int32(*(*uint8)(unsafe.Pointer(fmt))) == 0) {
  10710 		goto __10
  10711 	}
  10712 	goto __5
  10713 __10:
  10714 	;
  10715 __6:
  10716 	;
  10717 	if !(libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))) == 0) {
  10718 		goto __11
  10719 	}
  10720 	Xsqlite3_str_append(tls, pAccum, ts+1544, 1)
  10721 	goto __5
  10722 __11:
  10723 	;
  10724 	flag_leftjustify = libc.AssignUint8(&flag_prefix, libc.AssignUint8(&cThousand, libc.AssignUint8(&flag_alternateform, libc.AssignUint8(&flag_altform2, libc.AssignUint8(&flag_zeropad, EtByte(0))))))
  10725 	done = EtByte(0)
  10726 	width = 0
  10727 	flag_long = EtByte(0)
  10728 	precision = -1
  10729 __12:
  10730 	switch c {
  10731 	case '-':
  10732 		goto __16
  10733 	case '+':
  10734 		goto __17
  10735 	case ' ':
  10736 		goto __18
  10737 	case '#':
  10738 		goto __19
  10739 	case '!':
  10740 		goto __20
  10741 	case '0':
  10742 		goto __21
  10743 	case ',':
  10744 		goto __22
  10745 	default:
  10746 		goto __23
  10747 	case 'l':
  10748 		goto __24
  10749 	case '1':
  10750 		goto __25
  10751 	case '2':
  10752 		goto __26
  10753 	case '3':
  10754 		goto __27
  10755 	case '4':
  10756 		goto __28
  10757 	case '5':
  10758 		goto __29
  10759 	case '6':
  10760 		goto __30
  10761 	case '7':
  10762 		goto __31
  10763 	case '8':
  10764 		goto __32
  10765 	case '9':
  10766 		goto __33
  10767 	case '*':
  10768 		goto __34
  10769 	case '.':
  10770 		goto __35
  10771 	}
  10772 	goto __15
  10773 __16:
  10774 	flag_leftjustify = EtByte(1)
  10775 	goto __15
  10776 __17:
  10777 	flag_prefix = EtByte('+')
  10778 	goto __15
  10779 __18:
  10780 	flag_prefix = EtByte(' ')
  10781 	goto __15
  10782 __19:
  10783 	flag_alternateform = EtByte(1)
  10784 	goto __15
  10785 __20:
  10786 	flag_altform2 = EtByte(1)
  10787 	goto __15
  10788 __21:
  10789 	flag_zeropad = EtByte(1)
  10790 	goto __15
  10791 __22:
  10792 	cThousand = EtByte(',')
  10793 	goto __15
  10794 __23:
  10795 	done = EtByte(1)
  10796 	goto __15
  10797 __24:
  10798 	flag_long = EtByte(1)
  10799 	c = int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))
  10800 	if !(c == 'l') {
  10801 		goto __36
  10802 	}
  10803 	c = int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))
  10804 	flag_long = EtByte(2)
  10805 __36:
  10806 	;
  10807 	done = EtByte(1)
  10808 	goto __15
  10809 
  10810 __25:
  10811 __26:
  10812 __27:
  10813 __28:
  10814 __29:
  10815 __30:
  10816 __31:
  10817 __32:
  10818 __33:
  10819 	wx = uint32(c - '0')
  10820 __37:
  10821 	if !(libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))) >= '0' && c <= '9') {
  10822 		goto __38
  10823 	}
  10824 	wx = wx*uint32(10) + uint32(c) - uint32('0')
  10825 	goto __37
  10826 __38:
  10827 	;
  10828 	width = int32(wx & uint32(0x7fffffff))
  10829 	if !(c != '.' && c != 'l') {
  10830 		goto __39
  10831 	}
  10832 	done = EtByte(1)
  10833 	goto __40
  10834 __39:
  10835 	fmt--
  10836 __40:
  10837 	;
  10838 	goto __15
  10839 
  10840 __34:
  10841 	if !(bArgList != 0) {
  10842 		goto __41
  10843 	}
  10844 	width = int32(getIntArg(tls, pArgList))
  10845 	goto __42
  10846 __41:
  10847 	width = libc.VaInt32(&ap)
  10848 __42:
  10849 	;
  10850 	if !(width < 0) {
  10851 		goto __43
  10852 	}
  10853 	flag_leftjustify = EtByte(1)
  10854 	if width >= -2147483647 {
  10855 		width = -width
  10856 	} else {
  10857 		width = 0
  10858 	}
  10859 __43:
  10860 	;
  10861 	if !(libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(fmt + 1)))) != '.' && c != 'l') {
  10862 		goto __44
  10863 	}
  10864 	c = int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))
  10865 	done = EtByte(1)
  10866 __44:
  10867 	;
  10868 	goto __15
  10869 
  10870 __35:
  10871 	c = int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))
  10872 	if !(c == '*') {
  10873 		goto __45
  10874 	}
  10875 	if !(bArgList != 0) {
  10876 		goto __47
  10877 	}
  10878 	precision = int32(getIntArg(tls, pArgList))
  10879 	goto __48
  10880 __47:
  10881 	precision = libc.VaInt32(&ap)
  10882 __48:
  10883 	;
  10884 	if !(precision < 0) {
  10885 		goto __49
  10886 	}
  10887 	if precision >= -2147483647 {
  10888 		precision = -precision
  10889 	} else {
  10890 		precision = -1
  10891 	}
  10892 __49:
  10893 	;
  10894 	c = int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))
  10895 	goto __46
  10896 __45:
  10897 	px = uint32(0)
  10898 __50:
  10899 	if !(c >= '0' && c <= '9') {
  10900 		goto __51
  10901 	}
  10902 	px = px*uint32(10) + uint32(c) - uint32('0')
  10903 	c = int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))
  10904 	goto __50
  10905 __51:
  10906 	;
  10907 	precision = int32(px & uint32(0x7fffffff))
  10908 __46:
  10909 	;
  10910 	if !(c == 'l') {
  10911 		goto __52
  10912 	}
  10913 	fmt--
  10914 	goto __53
  10915 __52:
  10916 	done = EtByte(1)
  10917 __53:
  10918 	;
  10919 	goto __15
  10920 
  10921 __15:
  10922 	;
  10923 	goto __13
  10924 __13:
  10925 	if !(done != 0) && libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1))))) != 0 {
  10926 		goto __12
  10927 	}
  10928 	goto __14
  10929 __14:
  10930 	;
  10931 	infop = uintptr(unsafe.Pointer(&fmtinfo))
  10932 	xtype = EtByte(EtINVALID)
  10933 	idx = 0
  10934 __54:
  10935 	if !(idx < int32(uint32(unsafe.Sizeof(fmtinfo))/uint32(unsafe.Sizeof(Et_info{})))) {
  10936 		goto __56
  10937 	}
  10938 	if !(c == int32(fmtinfo[idx].Ffmttype)) {
  10939 		goto __57
  10940 	}
  10941 	infop = uintptr(unsafe.Pointer(&fmtinfo)) + uintptr(idx)*6
  10942 	xtype = (*Et_info)(unsafe.Pointer(infop)).Ftype
  10943 	goto __56
  10944 __57:
  10945 	;
  10946 	goto __55
  10947 __55:
  10948 	idx++
  10949 	goto __54
  10950 	goto __56
  10951 __56:
  10952 	;
  10953 	switch int32(xtype) {
  10954 	case EtPOINTER:
  10955 		goto __59
  10956 	case EtORDINAL:
  10957 		goto __60
  10958 	case EtRADIX:
  10959 		goto __61
  10960 	case EtDECIMAL:
  10961 		goto __62
  10962 	case EtFLOAT:
  10963 		goto __63
  10964 	case EtEXP:
  10965 		goto __64
  10966 	case EtGENERIC:
  10967 		goto __65
  10968 	case EtSIZE:
  10969 		goto __66
  10970 	case EtPERCENT:
  10971 		goto __67
  10972 	case EtCHARX:
  10973 		goto __68
  10974 	case EtSTRING:
  10975 		goto __69
  10976 	case EtDYNSTRING:
  10977 		goto __70
  10978 	case EtSQLESCAPE:
  10979 		goto __71
  10980 	case EtSQLESCAPE2:
  10981 		goto __72
  10982 	case EtSQLESCAPE3:
  10983 		goto __73
  10984 	case EtTOKEN:
  10985 		goto __74
  10986 	case EtSRCITEM:
  10987 		goto __75
  10988 	default:
  10989 		goto __76
  10990 	}
  10991 	goto __58
  10992 __59:
  10993 	if uint32(unsafe.Sizeof(uintptr(0))) == uint32(unsafe.Sizeof(I64(0))) {
  10994 		flag_long = uint8(2)
  10995 	} else {
  10996 		if uint32(unsafe.Sizeof(uintptr(0))) == uint32(unsafe.Sizeof(int32(0))) {
  10997 			flag_long = uint8(1)
  10998 		} else {
  10999 			flag_long = uint8(0)
  11000 		}
  11001 	}
  11002 __60:
  11003 __61:
  11004 	cThousand = EtByte(0)
  11005 __62:
  11006 	if !(int32((*Et_info)(unsafe.Pointer(infop)).Fflags)&FLAG_SIGNED != 0) {
  11007 		goto __77
  11008 	}
  11009 	if !(bArgList != 0) {
  11010 		goto __79
  11011 	}
  11012 	v = getIntArg(tls, pArgList)
  11013 	goto __80
  11014 __79:
  11015 	if !(flag_long != 0) {
  11016 		goto __81
  11017 	}
  11018 	if !(int32(flag_long) == 2) {
  11019 		goto __83
  11020 	}
  11021 	v = libc.VaInt64(&ap)
  11022 	goto __84
  11023 __83:
  11024 	v = I64(libc.VaInt32(&ap))
  11025 __84:
  11026 	;
  11027 	goto __82
  11028 __81:
  11029 	v = I64(libc.VaInt32(&ap))
  11030 __82:
  11031 	;
  11032 __80:
  11033 	;
  11034 	if !(v < int64(0)) {
  11035 		goto __85
  11036 	}
  11037 
  11038 	longvalue = Sqlite_uint64(^v)
  11039 	longvalue++
  11040 	prefix = uint8('-')
  11041 	goto __86
  11042 __85:
  11043 	longvalue = Sqlite_uint64(v)
  11044 	prefix = flag_prefix
  11045 __86:
  11046 	;
  11047 	goto __78
  11048 __77:
  11049 	if !(bArgList != 0) {
  11050 		goto __87
  11051 	}
  11052 	longvalue = U64(getIntArg(tls, pArgList))
  11053 	goto __88
  11054 __87:
  11055 	if !(flag_long != 0) {
  11056 		goto __89
  11057 	}
  11058 	if !(int32(flag_long) == 2) {
  11059 		goto __91
  11060 	}
  11061 	longvalue = libc.VaUint64(&ap)
  11062 	goto __92
  11063 __91:
  11064 	longvalue = Sqlite_uint64(libc.VaUint32(&ap))
  11065 __92:
  11066 	;
  11067 	goto __90
  11068 __89:
  11069 	longvalue = Sqlite_uint64(libc.VaUint32(&ap))
  11070 __90:
  11071 	;
  11072 __88:
  11073 	;
  11074 	prefix = uint8(0)
  11075 __78:
  11076 	;
  11077 	if !(longvalue == uint64(0)) {
  11078 		goto __93
  11079 	}
  11080 	flag_alternateform = EtByte(0)
  11081 __93:
  11082 	;
  11083 	if !(flag_zeropad != 0 && precision < width-libc.Bool32(int32(prefix) != 0)) {
  11084 		goto __94
  11085 	}
  11086 	precision = width - libc.Bool32(int32(prefix) != 0)
  11087 __94:
  11088 	;
  11089 	if !(precision < SQLITE_PRINT_BUF_SIZE-10-SQLITE_PRINT_BUF_SIZE/3) {
  11090 		goto __95
  11091 	}
  11092 	nOut = SQLITE_PRINT_BUF_SIZE
  11093 	zOut = bp + 16
  11094 	goto __96
  11095 __95:
  11096 	n = U64(precision) + uint64(10)
  11097 	if !(cThousand != 0) {
  11098 		goto __97
  11099 	}
  11100 	n = n + U64(precision/3)
  11101 __97:
  11102 	;
  11103 	zOut = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, int64(n)))
  11104 	if !(zOut == uintptr(0)) {
  11105 		goto __98
  11106 	}
  11107 	return
  11108 __98:
  11109 	;
  11110 	nOut = int32(n)
  11111 __96:
  11112 	;
  11113 	bufpt = zOut + uintptr(nOut-1)
  11114 	if !(int32(xtype) == EtORDINAL) {
  11115 		goto __99
  11116 	}
  11117 	x = int32(longvalue % uint64(10))
  11118 	if !(x >= 4 || longvalue/uint64(10)%uint64(10) == uint64(1)) {
  11119 		goto __100
  11120 	}
  11121 	x = 0
  11122 __100:
  11123 	;
  11124 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = zOrd[x*2+1]
  11125 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = zOrd[x*2]
  11126 __99:
  11127 	;
  11128 	cset = uintptr(unsafe.Pointer(&aDigits)) + uintptr((*Et_info)(unsafe.Pointer(infop)).Fcharset)
  11129 	base = (*Et_info)(unsafe.Pointer(infop)).Fbase
  11130 __101:
  11131 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = *(*uint8)(unsafe.Pointer(cset + uintptr(longvalue%Sqlite_uint64(base))))
  11132 	longvalue = longvalue / Sqlite_uint64(base)
  11133 	goto __102
  11134 __102:
  11135 	if longvalue > uint64(0) {
  11136 		goto __101
  11137 	}
  11138 	goto __103
  11139 __103:
  11140 	;
  11141 	length = (int32(zOut+uintptr(nOut-1)) - int32(bufpt)) / 1
  11142 __104:
  11143 	if !(precision > length) {
  11144 		goto __105
  11145 	}
  11146 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = uint8('0')
  11147 	length++
  11148 	goto __104
  11149 __105:
  11150 	;
  11151 	if !(cThousand != 0) {
  11152 		goto __106
  11153 	}
  11154 	nn = (length - 1) / 3
  11155 	ix = (length-1)%3 + 1
  11156 	bufpt -= uintptr(nn)
  11157 	idx = 0
  11158 __107:
  11159 	if !(nn > 0) {
  11160 		goto __109
  11161 	}
  11162 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(idx))) = *(*uint8)(unsafe.Pointer(bufpt + uintptr(idx+nn)))
  11163 	ix--
  11164 	if !(ix == 0) {
  11165 		goto __110
  11166 	}
  11167 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PreIncInt32(&idx, 1)))) = cThousand
  11168 	nn--
  11169 	ix = 3
  11170 __110:
  11171 	;
  11172 	goto __108
  11173 __108:
  11174 	idx++
  11175 	goto __107
  11176 	goto __109
  11177 __109:
  11178 	;
  11179 __106:
  11180 	;
  11181 	if !(prefix != 0) {
  11182 		goto __111
  11183 	}
  11184 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = prefix
  11185 __111:
  11186 	;
  11187 	if !(flag_alternateform != 0 && (*Et_info)(unsafe.Pointer(infop)).Fprefix != 0) {
  11188 		goto __112
  11189 	}
  11190 	pre = uintptr(unsafe.Pointer(&aPrefix)) + uintptr((*Et_info)(unsafe.Pointer(infop)).Fprefix)
  11191 __113:
  11192 	if !(int32(libc.AssignUint8(&x1, *(*uint8)(unsafe.Pointer(pre)))) != 0) {
  11193 		goto __115
  11194 	}
  11195 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = x1
  11196 	goto __114
  11197 __114:
  11198 	pre++
  11199 	goto __113
  11200 	goto __115
  11201 __115:
  11202 	;
  11203 __112:
  11204 	;
  11205 	length = (int32(zOut+uintptr(nOut-1)) - int32(bufpt)) / 1
  11206 	goto __58
  11207 __63:
  11208 __64:
  11209 __65:
  11210 	if !(bArgList != 0) {
  11211 		goto __116
  11212 	}
  11213 	*(*float64)(unsafe.Pointer(bp + 104)) = getDoubleArg(tls, pArgList)
  11214 	goto __117
  11215 __116:
  11216 	*(*float64)(unsafe.Pointer(bp + 104)) = libc.VaFloat64(&ap)
  11217 __117:
  11218 	;
  11219 	if !(precision < 0) {
  11220 		goto __118
  11221 	}
  11222 	precision = 6
  11223 __118:
  11224 	;
  11225 	if !(precision > SQLITE_FP_PRECISION_LIMIT) {
  11226 		goto __119
  11227 	}
  11228 	precision = SQLITE_FP_PRECISION_LIMIT
  11229 __119:
  11230 	;
  11231 	if !(*(*float64)(unsafe.Pointer(bp + 104)) < 0.0) {
  11232 		goto __120
  11233 	}
  11234 	*(*float64)(unsafe.Pointer(bp + 104)) = -*(*float64)(unsafe.Pointer(bp + 104))
  11235 	prefix = uint8('-')
  11236 	goto __121
  11237 __120:
  11238 	prefix = flag_prefix
  11239 __121:
  11240 	;
  11241 	if !(int32(xtype) == EtGENERIC && precision > 0) {
  11242 		goto __122
  11243 	}
  11244 	precision--
  11245 __122:
  11246 	;
  11247 	idx = precision & 0xfff
  11248 	rounder = arRound[idx%10]
  11249 __123:
  11250 	if !(idx >= 10) {
  11251 		goto __124
  11252 	}
  11253 	rounder = rounder * 1.0e-10
  11254 	idx = idx - 10
  11255 	goto __123
  11256 __124:
  11257 	;
  11258 	if !(int32(xtype) == EtFLOAT) {
  11259 		goto __125
  11260 	}
  11261 	*(*float64)(unsafe.Pointer(bp + 96)) = *(*float64)(unsafe.Pointer(bp + 104))
  11262 	libc.Xmemcpy(tls, bp+88, bp+96, uint32(unsafe.Sizeof(Sqlite3_uint64(0))))
  11263 	ex = -1023 + int32(*(*Sqlite3_uint64)(unsafe.Pointer(bp + 88))>>52&uint64(0x7ff))
  11264 	if !(precision+ex/3 < 15) {
  11265 		goto __126
  11266 	}
  11267 	rounder = rounder + *(*float64)(unsafe.Pointer(bp + 104))*3e-16
  11268 __126:
  11269 	;
  11270 	*(*float64)(unsafe.Pointer(bp + 104)) += rounder
  11271 __125:
  11272 	;
  11273 	exp = 0
  11274 	if !(Xsqlite3IsNaN(tls, *(*float64)(unsafe.Pointer(bp + 104))) != 0) {
  11275 		goto __127
  11276 	}
  11277 	bufpt = ts + 1546
  11278 	length = 3
  11279 	goto __58
  11280 __127:
  11281 	;
  11282 	if !(*(*float64)(unsafe.Pointer(bp + 104)) > 0.0) {
  11283 		goto __128
  11284 	}
  11285 	scale = 1.0
  11286 __129:
  11287 	if !(*(*float64)(unsafe.Pointer(bp + 104)) >= 1e100*scale && exp <= 350) {
  11288 		goto __130
  11289 	}
  11290 	scale = scale * 1e100
  11291 	exp = exp + 100
  11292 	goto __129
  11293 __130:
  11294 	;
  11295 __131:
  11296 	if !(*(*float64)(unsafe.Pointer(bp + 104)) >= 1e10*scale && exp <= 350) {
  11297 		goto __132
  11298 	}
  11299 	scale = scale * 1e10
  11300 	exp = exp + 10
  11301 	goto __131
  11302 __132:
  11303 	;
  11304 __133:
  11305 	if !(*(*float64)(unsafe.Pointer(bp + 104)) >= 10.0*scale && exp <= 350) {
  11306 		goto __134
  11307 	}
  11308 	scale = scale * 10.0
  11309 	exp++
  11310 	goto __133
  11311 __134:
  11312 	;
  11313 	*(*float64)(unsafe.Pointer(bp + 104)) /= scale
  11314 __135:
  11315 	if !(*(*float64)(unsafe.Pointer(bp + 104)) < 1e-8) {
  11316 		goto __136
  11317 	}
  11318 	*(*float64)(unsafe.Pointer(bp + 104)) *= 1e8
  11319 	exp = exp - 8
  11320 	goto __135
  11321 __136:
  11322 	;
  11323 __137:
  11324 	if !(*(*float64)(unsafe.Pointer(bp + 104)) < 1.0) {
  11325 		goto __138
  11326 	}
  11327 	*(*float64)(unsafe.Pointer(bp + 104)) *= 10.0
  11328 	exp--
  11329 	goto __137
  11330 __138:
  11331 	;
  11332 	if !(exp > 350) {
  11333 		goto __139
  11334 	}
  11335 	bufpt = bp + 16
  11336 	*(*uint8)(unsafe.Pointer(bp + 16)) = prefix
  11337 	libc.Xmemcpy(tls, bp+16+uintptr(libc.Bool32(int32(prefix) != 0)), ts+1550, uint32(4))
  11338 	length = 3 + libc.Bool32(int32(prefix) != 0)
  11339 	goto __58
  11340 __139:
  11341 	;
  11342 __128:
  11343 	;
  11344 	bufpt = bp + 16
  11345 
  11346 	if !(int32(xtype) != EtFLOAT) {
  11347 		goto __140
  11348 	}
  11349 	*(*float64)(unsafe.Pointer(bp + 104)) += rounder
  11350 	if !(*(*float64)(unsafe.Pointer(bp + 104)) >= 10.0) {
  11351 		goto __141
  11352 	}
  11353 	*(*float64)(unsafe.Pointer(bp + 104)) *= 0.1
  11354 	exp++
  11355 __141:
  11356 	;
  11357 __140:
  11358 	;
  11359 	if !(int32(xtype) == EtGENERIC) {
  11360 		goto __142
  11361 	}
  11362 	flag_rtz = libc.BoolUint8(!(flag_alternateform != 0))
  11363 	if !(exp < -4 || exp > precision) {
  11364 		goto __144
  11365 	}
  11366 	xtype = EtByte(EtEXP)
  11367 	goto __145
  11368 __144:
  11369 	precision = precision - exp
  11370 	xtype = EtByte(EtFLOAT)
  11371 __145:
  11372 	;
  11373 	goto __143
  11374 __142:
  11375 	flag_rtz = flag_altform2
  11376 __143:
  11377 	;
  11378 	if !(int32(xtype) == EtEXP) {
  11379 		goto __146
  11380 	}
  11381 	e2 = 0
  11382 	goto __147
  11383 __146:
  11384 	e2 = exp
  11385 __147:
  11386 	;
  11387 	szBufNeeded = func() int64 {
  11388 		if e2 > 0 {
  11389 			return int64(e2)
  11390 		}
  11391 		return int64(0)
  11392 	}() + I64(precision) + I64(width) + int64(15)
  11393 	if !(szBufNeeded > int64(SQLITE_PRINT_BUF_SIZE)) {
  11394 		goto __148
  11395 	}
  11396 	bufpt = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, szBufNeeded))
  11397 	if !(bufpt == uintptr(0)) {
  11398 		goto __149
  11399 	}
  11400 	return
  11401 __149:
  11402 	;
  11403 __148:
  11404 	;
  11405 	zOut = bufpt
  11406 	*(*int32)(unsafe.Pointer(bp + 112)) = 16 + int32(flag_altform2)*10
  11407 	flag_dp = EtByte(func() int32 {
  11408 		if precision > 0 {
  11409 			return 1
  11410 		}
  11411 		return 0
  11412 	}() | int32(flag_alternateform) | int32(flag_altform2))
  11413 
  11414 	if !(prefix != 0) {
  11415 		goto __150
  11416 	}
  11417 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = prefix
  11418 __150:
  11419 	;
  11420 	if !(e2 < 0) {
  11421 		goto __151
  11422 	}
  11423 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8('0')
  11424 	goto __152
  11425 __151:
  11426 	;
  11427 __153:
  11428 	if !(e2 >= 0) {
  11429 		goto __155
  11430 	}
  11431 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = et_getdigit(tls, bp+104, bp+112)
  11432 	goto __154
  11433 __154:
  11434 	e2--
  11435 	goto __153
  11436 	goto __155
  11437 __155:
  11438 	;
  11439 __152:
  11440 	;
  11441 	if !(flag_dp != 0) {
  11442 		goto __156
  11443 	}
  11444 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8('.')
  11445 __156:
  11446 	;
  11447 	e2++
  11448 __157:
  11449 	if !(e2 < 0) {
  11450 		goto __159
  11451 	}
  11452 
  11453 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8('0')
  11454 	goto __158
  11455 __158:
  11456 	precision--
  11457 	e2++
  11458 	goto __157
  11459 	goto __159
  11460 __159:
  11461 	;
  11462 __160:
  11463 	if !(libc.PostDecInt32(&precision, 1) > 0) {
  11464 		goto __161
  11465 	}
  11466 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = et_getdigit(tls, bp+104, bp+112)
  11467 	goto __160
  11468 __161:
  11469 	;
  11470 	if !(flag_rtz != 0 && flag_dp != 0) {
  11471 		goto __162
  11472 	}
  11473 __163:
  11474 	if !(int32(*(*uint8)(unsafe.Pointer(bufpt + libc.UintptrFromInt32(-1)))) == '0') {
  11475 		goto __164
  11476 	}
  11477 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = uint8(0)
  11478 	goto __163
  11479 __164:
  11480 	;
  11481 	if !(int32(*(*uint8)(unsafe.Pointer(bufpt + libc.UintptrFromInt32(-1)))) == '.') {
  11482 		goto __165
  11483 	}
  11484 	if !(flag_altform2 != 0) {
  11485 		goto __166
  11486 	}
  11487 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8('0')
  11488 	goto __167
  11489 __166:
  11490 	*(*uint8)(unsafe.Pointer(libc.PreDecUintptr(&bufpt, 1))) = uint8(0)
  11491 __167:
  11492 	;
  11493 __165:
  11494 	;
  11495 __162:
  11496 	;
  11497 	if !(int32(xtype) == EtEXP) {
  11498 		goto __168
  11499 	}
  11500 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = aDigits[(*Et_info)(unsafe.Pointer(infop)).Fcharset]
  11501 	if !(exp < 0) {
  11502 		goto __169
  11503 	}
  11504 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8('-')
  11505 	exp = -exp
  11506 	goto __170
  11507 __169:
  11508 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8('+')
  11509 __170:
  11510 	;
  11511 	if !(exp >= 100) {
  11512 		goto __171
  11513 	}
  11514 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8(exp/100 + '0')
  11515 	exp = exp % 100
  11516 __171:
  11517 	;
  11518 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8(exp/10 + '0')
  11519 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = uint8(exp%10 + '0')
  11520 __168:
  11521 	;
  11522 	*(*uint8)(unsafe.Pointer(bufpt)) = uint8(0)
  11523 
  11524 	length = (int32(bufpt) - int32(zOut)) / 1
  11525 	bufpt = zOut
  11526 
  11527 	if !(flag_zeropad != 0 && !(flag_leftjustify != 0) && length < width) {
  11528 		goto __172
  11529 	}
  11530 	nPad = width - length
  11531 	i = width
  11532 __173:
  11533 	if !(i >= nPad) {
  11534 		goto __175
  11535 	}
  11536 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(i))) = *(*uint8)(unsafe.Pointer(bufpt + uintptr(i-nPad)))
  11537 	goto __174
  11538 __174:
  11539 	i--
  11540 	goto __173
  11541 	goto __175
  11542 __175:
  11543 	;
  11544 	i = libc.Bool32(int32(prefix) != 0)
  11545 __176:
  11546 	if !(libc.PostDecInt32(&nPad, 1) != 0) {
  11547 		goto __177
  11548 	}
  11549 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PostIncInt32(&i, 1)))) = uint8('0')
  11550 	goto __176
  11551 __177:
  11552 	;
  11553 	length = width
  11554 __172:
  11555 	;
  11556 	goto __58
  11557 __66:
  11558 	if !!(bArgList != 0) {
  11559 		goto __178
  11560 	}
  11561 	*(*int32)(unsafe.Pointer(libc.VaUintptr(&ap))) = int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar)
  11562 __178:
  11563 	;
  11564 	length = libc.AssignInt32(&width, 0)
  11565 	goto __58
  11566 __67:
  11567 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8('%')
  11568 	bufpt = bp + 16
  11569 	length = 1
  11570 	goto __58
  11571 __68:
  11572 	if !(bArgList != 0) {
  11573 		goto __179
  11574 	}
  11575 	bufpt = getTextArg(tls, pArgList)
  11576 	length = 1
  11577 	if !(bufpt != 0) {
  11578 		goto __181
  11579 	}
  11580 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8(libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))))))
  11581 	if !(c&0xc0 == 0xc0) {
  11582 		goto __183
  11583 	}
  11584 __184:
  11585 	if !(length < 4 && int32(*(*uint8)(unsafe.Pointer(bufpt)))&0xc0 == 0x80) {
  11586 		goto __185
  11587 	}
  11588 	*(*uint8)(unsafe.Pointer(bp + 16 + uintptr(libc.PostIncInt32(&length, 1)))) = *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1)))
  11589 	goto __184
  11590 __185:
  11591 	;
  11592 __183:
  11593 	;
  11594 	goto __182
  11595 __181:
  11596 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8(0)
  11597 __182:
  11598 	;
  11599 	goto __180
  11600 __179:
  11601 	ch = libc.VaUint32(&ap)
  11602 	if !(ch < uint32(0x00080)) {
  11603 		goto __186
  11604 	}
  11605 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8(ch & uint32(0xff))
  11606 	length = 1
  11607 	goto __187
  11608 __186:
  11609 	if !(ch < uint32(0x00800)) {
  11610 		goto __188
  11611 	}
  11612 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8(0xc0 + int32(U8(ch>>6&uint32(0x1f))))
  11613 	*(*uint8)(unsafe.Pointer(bp + 16 + 1)) = uint8(0x80 + int32(U8(ch&uint32(0x3f))))
  11614 	length = 2
  11615 	goto __189
  11616 __188:
  11617 	if !(ch < uint32(0x10000)) {
  11618 		goto __190
  11619 	}
  11620 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8(0xe0 + int32(U8(ch>>12&uint32(0x0f))))
  11621 	*(*uint8)(unsafe.Pointer(bp + 16 + 1)) = uint8(0x80 + int32(U8(ch>>6&uint32(0x3f))))
  11622 	*(*uint8)(unsafe.Pointer(bp + 16 + 2)) = uint8(0x80 + int32(U8(ch&uint32(0x3f))))
  11623 	length = 3
  11624 	goto __191
  11625 __190:
  11626 	*(*uint8)(unsafe.Pointer(bp + 16)) = uint8(0xf0 + int32(U8(ch>>18&uint32(0x07))))
  11627 	*(*uint8)(unsafe.Pointer(bp + 16 + 1)) = uint8(0x80 + int32(U8(ch>>12&uint32(0x3f))))
  11628 	*(*uint8)(unsafe.Pointer(bp + 16 + 2)) = uint8(0x80 + int32(U8(ch>>6&uint32(0x3f))))
  11629 	*(*uint8)(unsafe.Pointer(bp + 16 + 3)) = uint8(0x80 + int32(U8(ch&uint32(0x3f))))
  11630 	length = 4
  11631 __191:
  11632 	;
  11633 __189:
  11634 	;
  11635 __187:
  11636 	;
  11637 __180:
  11638 	;
  11639 	if !(precision > 1) {
  11640 		goto __192
  11641 	}
  11642 	nPrior = int64(1)
  11643 	width = width - (precision - 1)
  11644 	if !(width > 1 && !(flag_leftjustify != 0)) {
  11645 		goto __193
  11646 	}
  11647 	Xsqlite3_str_appendchar(tls, pAccum, width-1, uint8(' '))
  11648 	width = 0
  11649 __193:
  11650 	;
  11651 	Xsqlite3_str_append(tls, pAccum, bp+16, length)
  11652 	precision--
  11653 __194:
  11654 	if !(precision > 1) {
  11655 		goto __195
  11656 	}
  11657 	if !(nPrior > I64(precision-1)) {
  11658 		goto __196
  11659 	}
  11660 	nPrior = I64(precision - 1)
  11661 __196:
  11662 	;
  11663 	nCopyBytes = I64(length) * nPrior
  11664 	if !(nCopyBytes+I64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar) >= I64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc)) {
  11665 		goto __197
  11666 	}
  11667 	Xsqlite3StrAccumEnlarge(tls, pAccum, nCopyBytes)
  11668 __197:
  11669 	;
  11670 	if !((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError != 0) {
  11671 		goto __198
  11672 	}
  11673 	goto __195
  11674 __198:
  11675 	;
  11676 	Xsqlite3_str_append(tls, pAccum,
  11677 		(*Sqlite3_str)(unsafe.Pointer(pAccum)).FzText+uintptr(I64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar)-nCopyBytes), int32(nCopyBytes))
  11678 	precision = int32(I64(precision) - nPrior)
  11679 	nPrior = nPrior * int64(2)
  11680 	goto __194
  11681 __195:
  11682 	;
  11683 __192:
  11684 	;
  11685 	bufpt = bp + 16
  11686 	flag_altform2 = EtByte(1)
  11687 	goto adjust_width_for_utf8
  11688 __69:
  11689 __70:
  11690 	if !(bArgList != 0) {
  11691 		goto __199
  11692 	}
  11693 	bufpt = getTextArg(tls, pArgList)
  11694 	xtype = EtByte(EtSTRING)
  11695 	goto __200
  11696 __199:
  11697 	bufpt = libc.VaUintptr(&ap)
  11698 __200:
  11699 	;
  11700 	if !(bufpt == uintptr(0)) {
  11701 		goto __201
  11702 	}
  11703 	bufpt = ts + 1554
  11704 	goto __202
  11705 __201:
  11706 	if !(int32(xtype) == EtDYNSTRING) {
  11707 		goto __203
  11708 	}
  11709 	if !((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar == U32(0) &&
  11710 		(*Sqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc != 0 &&
  11711 		width == 0 &&
  11712 		precision < 0 &&
  11713 		int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0) {
  11714 		goto __204
  11715 	}
  11716 
  11717 	(*Sqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt
  11718 	(*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = U32(Xsqlite3DbMallocSize(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt))
  11719 	(*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar = U32(0x7fffffff & int32(libc.Xstrlen(tls, bufpt)))
  11720 	*(*U8)(unsafe.Pointer(pAccum + 21)) |= U8(SQLITE_PRINTF_MALLOCED)
  11721 	length = 0
  11722 	goto __58
  11723 __204:
  11724 	;
  11725 	zExtra = bufpt
  11726 __203:
  11727 	;
  11728 __202:
  11729 	;
  11730 	if !(precision >= 0) {
  11731 		goto __205
  11732 	}
  11733 	if !(flag_altform2 != 0) {
  11734 		goto __207
  11735 	}
  11736 
  11737 	z = bufpt
  11738 __209:
  11739 	if !(libc.PostDecInt32(&precision, 1) > 0 && *(*uint8)(unsafe.Pointer(z)) != 0) {
  11740 		goto __210
  11741 	}
  11742 	if !(int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) >= 0xc0) {
  11743 		goto __211
  11744 	}
  11745 __212:
  11746 	if !(int32(*(*uint8)(unsafe.Pointer(z)))&0xc0 == 0x80) {
  11747 		goto __213
  11748 	}
  11749 	z++
  11750 	goto __212
  11751 __213:
  11752 	;
  11753 __211:
  11754 	;
  11755 	goto __209
  11756 __210:
  11757 	;
  11758 	length = (int32(z) - int32(bufpt)) / 1
  11759 	goto __208
  11760 __207:
  11761 	length = 0
  11762 __214:
  11763 	if !(length < precision && *(*uint8)(unsafe.Pointer(bufpt + uintptr(length))) != 0) {
  11764 		goto __216
  11765 	}
  11766 	goto __215
  11767 __215:
  11768 	length++
  11769 	goto __214
  11770 	goto __216
  11771 __216:
  11772 	;
  11773 __208:
  11774 	;
  11775 	goto __206
  11776 __205:
  11777 	length = 0x7fffffff & int32(libc.Xstrlen(tls, bufpt))
  11778 __206:
  11779 	;
  11780 adjust_width_for_utf8:
  11781 	if !(flag_altform2 != 0 && width > 0) {
  11782 		goto __217
  11783 	}
  11784 
  11785 	ii = length - 1
  11786 __218:
  11787 	if !(ii >= 0) {
  11788 		goto __219
  11789 	}
  11790 	if !(int32(*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PostDecInt32(&ii, 1)))))&0xc0 == 0x80) {
  11791 		goto __220
  11792 	}
  11793 	width++
  11794 __220:
  11795 	;
  11796 	goto __218
  11797 __219:
  11798 	;
  11799 __217:
  11800 	;
  11801 	goto __58
  11802 __71:
  11803 __72:
  11804 __73:
  11805 	q = func() uint8 {
  11806 		if int32(xtype) == EtSQLESCAPE3 {
  11807 			return uint8('"')
  11808 		}
  11809 		return uint8('\'')
  11810 	}()
  11811 
  11812 	if !(bArgList != 0) {
  11813 		goto __221
  11814 	}
  11815 	escarg = getTextArg(tls, pArgList)
  11816 	goto __222
  11817 __221:
  11818 	escarg = libc.VaUintptr(&ap)
  11819 __222:
  11820 	;
  11821 	isnull = libc.Bool32(escarg == uintptr(0))
  11822 	if !(isnull != 0) {
  11823 		goto __223
  11824 	}
  11825 	escarg = func() uintptr {
  11826 		if int32(xtype) == EtSQLESCAPE2 {
  11827 			return ts + 1555
  11828 		}
  11829 		return ts + 1560
  11830 	}()
  11831 __223:
  11832 	;
  11833 	k = I64(precision)
  11834 	i1 = libc.AssignInt64(&n1, int64(0))
  11835 __224:
  11836 	if !(k != int64(0) && int32(libc.AssignUint8(&ch1, *(*uint8)(unsafe.Pointer(escarg + uintptr(i1))))) != 0) {
  11837 		goto __226
  11838 	}
  11839 	if !(int32(ch1) == int32(q)) {
  11840 		goto __227
  11841 	}
  11842 	n1++
  11843 __227:
  11844 	;
  11845 	if !(flag_altform2 != 0 && int32(ch1)&0xc0 == 0xc0) {
  11846 		goto __228
  11847 	}
  11848 __229:
  11849 	if !(int32(*(*uint8)(unsafe.Pointer(escarg + uintptr(i1+int64(1)))))&0xc0 == 0x80) {
  11850 		goto __230
  11851 	}
  11852 	i1++
  11853 	goto __229
  11854 __230:
  11855 	;
  11856 __228:
  11857 	;
  11858 	goto __225
  11859 __225:
  11860 	i1++
  11861 	k--
  11862 	goto __224
  11863 	goto __226
  11864 __226:
  11865 	;
  11866 	needQuote = libc.Bool32(!(isnull != 0) && int32(xtype) == EtSQLESCAPE2)
  11867 	n1 = n1 + (i1 + int64(3))
  11868 	if !(n1 > int64(SQLITE_PRINT_BUF_SIZE)) {
  11869 		goto __231
  11870 	}
  11871 	bufpt = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, n1))
  11872 	if !(bufpt == uintptr(0)) {
  11873 		goto __233
  11874 	}
  11875 	return
  11876 __233:
  11877 	;
  11878 	goto __232
  11879 __231:
  11880 	bufpt = bp + 16
  11881 __232:
  11882 	;
  11883 	j = int64(0)
  11884 	if !(needQuote != 0) {
  11885 		goto __234
  11886 	}
  11887 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PostIncInt64(&j, 1)))) = q
  11888 __234:
  11889 	;
  11890 	k = i1
  11891 	i1 = int64(0)
  11892 __235:
  11893 	if !(i1 < k) {
  11894 		goto __237
  11895 	}
  11896 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PostIncInt64(&j, 1)))) = libc.AssignUint8(&ch1, *(*uint8)(unsafe.Pointer(escarg + uintptr(i1))))
  11897 	if !(int32(ch1) == int32(q)) {
  11898 		goto __238
  11899 	}
  11900 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PostIncInt64(&j, 1)))) = ch1
  11901 __238:
  11902 	;
  11903 	goto __236
  11904 __236:
  11905 	i1++
  11906 	goto __235
  11907 	goto __237
  11908 __237:
  11909 	;
  11910 	if !(needQuote != 0) {
  11911 		goto __239
  11912 	}
  11913 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(libc.PostIncInt64(&j, 1)))) = q
  11914 __239:
  11915 	;
  11916 	*(*uint8)(unsafe.Pointer(bufpt + uintptr(j))) = uint8(0)
  11917 	length = int32(j)
  11918 	goto adjust_width_for_utf8
  11919 
  11920 __74:
  11921 	if !(int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&SQLITE_PRINTF_INTERNAL == 0) {
  11922 		goto __240
  11923 	}
  11924 	return
  11925 __240:
  11926 	;
  11927 	if !(flag_alternateform != 0) {
  11928 		goto __241
  11929 	}
  11930 
  11931 	pExpr = libc.VaUintptr(&ap)
  11932 	if !(pExpr != 0 && !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_IntValue) != U32(0))) {
  11933 		goto __243
  11934 	}
  11935 	Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pExpr + 8)))
  11936 	Xsqlite3RecordErrorOffsetOfExpr(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, pExpr)
  11937 __243:
  11938 	;
  11939 	goto __242
  11940 __241:
  11941 	pToken = libc.VaUintptr(&ap)
  11942 
  11943 	if !(pToken != 0 && (*Token)(unsafe.Pointer(pToken)).Fn != 0) {
  11944 		goto __244
  11945 	}
  11946 	Xsqlite3_str_append(tls, pAccum, (*Token)(unsafe.Pointer(pToken)).Fz, int32((*Token)(unsafe.Pointer(pToken)).Fn))
  11947 	Xsqlite3RecordErrorByteOffset(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, (*Token)(unsafe.Pointer(pToken)).Fz)
  11948 __244:
  11949 	;
  11950 __242:
  11951 	;
  11952 	length = libc.AssignInt32(&width, 0)
  11953 	goto __58
  11954 
  11955 __75:
  11956 	if !(int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&SQLITE_PRINTF_INTERNAL == 0) {
  11957 		goto __245
  11958 	}
  11959 	return
  11960 __245:
  11961 	;
  11962 	pItem = libc.VaUintptr(&ap)
  11963 
  11964 	if !((*SrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 && !(flag_altform2 != 0)) {
  11965 		goto __246
  11966 	}
  11967 	Xsqlite3_str_appendall(tls, pAccum, (*SrcItem)(unsafe.Pointer(pItem)).FzAlias)
  11968 	goto __247
  11969 __246:
  11970 	if !((*SrcItem)(unsafe.Pointer(pItem)).FzName != 0) {
  11971 		goto __248
  11972 	}
  11973 	if !((*SrcItem)(unsafe.Pointer(pItem)).FzDatabase != 0) {
  11974 		goto __250
  11975 	}
  11976 	Xsqlite3_str_appendall(tls, pAccum, (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase)
  11977 	Xsqlite3_str_append(tls, pAccum, ts+1567, 1)
  11978 __250:
  11979 	;
  11980 	Xsqlite3_str_appendall(tls, pAccum, (*SrcItem)(unsafe.Pointer(pItem)).FzName)
  11981 	goto __249
  11982 __248:
  11983 	if !((*SrcItem)(unsafe.Pointer(pItem)).FzAlias != 0) {
  11984 		goto __251
  11985 	}
  11986 	Xsqlite3_str_appendall(tls, pAccum, (*SrcItem)(unsafe.Pointer(pItem)).FzAlias)
  11987 	goto __252
  11988 __251:
  11989 	pSel = (*SrcItem)(unsafe.Pointer(pItem)).FpSelect
  11990 
  11991 	if !((*Select)(unsafe.Pointer(pSel)).FselFlags&U32(SF_NestedFrom) != 0) {
  11992 		goto __253
  11993 	}
  11994 	Xsqlite3_str_appendf(tls, pAccum, ts+1569, libc.VaList(bp, (*Select)(unsafe.Pointer(pSel)).FselId))
  11995 	goto __254
  11996 __253:
  11997 	Xsqlite3_str_appendf(tls, pAccum, ts+1579, libc.VaList(bp+8, (*Select)(unsafe.Pointer(pSel)).FselId))
  11998 __254:
  11999 	;
  12000 __252:
  12001 	;
  12002 __249:
  12003 	;
  12004 __247:
  12005 	;
  12006 	length = libc.AssignInt32(&width, 0)
  12007 	goto __58
  12008 
  12009 __76:
  12010 	;
  12011 	return
  12012 
  12013 __58:
  12014 	;
  12015 	width = width - length
  12016 	if !(width > 0) {
  12017 		goto __255
  12018 	}
  12019 	if !!(flag_leftjustify != 0) {
  12020 		goto __257
  12021 	}
  12022 	Xsqlite3_str_appendchar(tls, pAccum, width, uint8(' '))
  12023 __257:
  12024 	;
  12025 	Xsqlite3_str_append(tls, pAccum, bufpt, length)
  12026 	if !(flag_leftjustify != 0) {
  12027 		goto __258
  12028 	}
  12029 	Xsqlite3_str_appendchar(tls, pAccum, width, uint8(' '))
  12030 __258:
  12031 	;
  12032 	goto __256
  12033 __255:
  12034 	Xsqlite3_str_append(tls, pAccum, bufpt, length)
  12035 __256:
  12036 	;
  12037 	if !(zExtra != 0) {
  12038 		goto __259
  12039 	}
  12040 	Xsqlite3DbFree(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, zExtra)
  12041 	zExtra = uintptr(0)
  12042 __259:
  12043 	;
  12044 	goto __4
  12045 __4:
  12046 	fmt++
  12047 	goto __3
  12048 	goto __5
  12049 __5:
  12050 }
  12051 
  12052 var zOrd = *(*[9]uint8)(unsafe.Pointer(ts + 1593))
  12053 
  12054 // The z string points to the first character of a token that is
  12055 // associated with an error.  If db does not already have an error
  12056 // byte offset recorded, try to compute the error byte offset for
  12057 // z and set the error byte offset in db.
  12058 func Xsqlite3RecordErrorByteOffset(tls *libc.TLS, db uintptr, z uintptr) {
  12059 	var pParse uintptr
  12060 	var zText uintptr
  12061 	var zEnd uintptr
  12062 
  12063 	if db == uintptr(0) {
  12064 		return
  12065 	}
  12066 	if (*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset != -2 {
  12067 		return
  12068 	}
  12069 	pParse = (*Sqlite3)(unsafe.Pointer(db)).FpParse
  12070 	if pParse == uintptr(0) {
  12071 		return
  12072 	}
  12073 	zText = (*Parse)(unsafe.Pointer(pParse)).FzTail
  12074 	if zText == uintptr(0) {
  12075 		return
  12076 	}
  12077 	zEnd = zText + uintptr(libc.Xstrlen(tls, zText))
  12078 	if Uptr(z) >= Uptr(zText) && Uptr(z) < Uptr(zEnd) {
  12079 		(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = (int32(z) - int32(zText)) / 1
  12080 	}
  12081 }
  12082 
  12083 // If pExpr has a byte offset for the start of a token, record that as
  12084 // as the error offset.
  12085 func Xsqlite3RecordErrorOffsetOfExpr(tls *libc.TLS, db uintptr, pExpr uintptr) {
  12086 	for pExpr != 0 &&
  12087 		((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0) || *(*int32)(unsafe.Pointer(pExpr + 36)) <= 0) {
  12088 		pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  12089 	}
  12090 	if pExpr == uintptr(0) {
  12091 		return
  12092 	}
  12093 	(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = *(*int32)(unsafe.Pointer(pExpr + 36))
  12094 }
  12095 
  12096 // Enlarge the memory allocation on a StrAccum object so that it is
  12097 // able to accept at least N more bytes of text.
  12098 //
  12099 // Return the number of bytes of text that StrAccum is able to accept
  12100 // after the attempted enlargement.  The value returned might be zero.
  12101 func Xsqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N I64) int32 {
  12102 	var zNew uintptr
  12103 
  12104 	if (*StrAccum)(unsafe.Pointer(p)).FaccError != 0 {
  12105 		return 0
  12106 	}
  12107 	if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc == U32(0) {
  12108 		Xsqlite3StrAccumSetError(tls, p, uint8(SQLITE_TOOBIG))
  12109 		return int32((*StrAccum)(unsafe.Pointer(p)).FnAlloc - (*StrAccum)(unsafe.Pointer(p)).FnChar - U32(1))
  12110 	} else {
  12111 		var zOld uintptr
  12112 		if int32((*StrAccum)(unsafe.Pointer(p)).FprintfFlags)&SQLITE_PRINTF_MALLOCED != 0 {
  12113 			zOld = (*StrAccum)(unsafe.Pointer(p)).FzText
  12114 		} else {
  12115 			zOld = uintptr(0)
  12116 		}
  12117 		var szNew I64 = I64((*StrAccum)(unsafe.Pointer(p)).FnChar) + N + int64(1)
  12118 		if szNew+I64((*StrAccum)(unsafe.Pointer(p)).FnChar) <= I64((*StrAccum)(unsafe.Pointer(p)).FmxAlloc) {
  12119 			szNew = szNew + I64((*StrAccum)(unsafe.Pointer(p)).FnChar)
  12120 		}
  12121 		if szNew > I64((*StrAccum)(unsafe.Pointer(p)).FmxAlloc) {
  12122 			Xsqlite3_str_reset(tls, p)
  12123 			Xsqlite3StrAccumSetError(tls, p, uint8(SQLITE_TOOBIG))
  12124 			return 0
  12125 		} else {
  12126 			(*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(int32(szNew))
  12127 		}
  12128 		if (*StrAccum)(unsafe.Pointer(p)).Fdb != 0 {
  12129 			zNew = Xsqlite3DbRealloc(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, zOld, uint64((*StrAccum)(unsafe.Pointer(p)).FnAlloc))
  12130 		} else {
  12131 			zNew = Xsqlite3Realloc(tls, zOld, uint64((*StrAccum)(unsafe.Pointer(p)).FnAlloc))
  12132 		}
  12133 		if zNew != 0 {
  12134 			if !(int32((*StrAccum)(unsafe.Pointer(p)).FprintfFlags)&SQLITE_PRINTF_MALLOCED != 0) && (*StrAccum)(unsafe.Pointer(p)).FnChar > U32(0) {
  12135 				libc.Xmemcpy(tls, zNew, (*StrAccum)(unsafe.Pointer(p)).FzText, (*StrAccum)(unsafe.Pointer(p)).FnChar)
  12136 			}
  12137 			(*StrAccum)(unsafe.Pointer(p)).FzText = zNew
  12138 			(*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(Xsqlite3DbMallocSize(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, zNew))
  12139 			*(*U8)(unsafe.Pointer(p + 21)) |= U8(SQLITE_PRINTF_MALLOCED)
  12140 		} else {
  12141 			Xsqlite3_str_reset(tls, p)
  12142 			Xsqlite3StrAccumSetError(tls, p, uint8(SQLITE_NOMEM))
  12143 			return 0
  12144 		}
  12145 	}
  12146 
  12147 	return int32(N)
  12148 }
  12149 
  12150 // Append N copies of character c to the given string buffer.
  12151 func Xsqlite3_str_appendchar(tls *libc.TLS, p uintptr, N int32, c uint8) {
  12152 	if I64((*Sqlite3_str)(unsafe.Pointer(p)).FnChar)+I64(N) >= I64((*Sqlite3_str)(unsafe.Pointer(p)).FnAlloc) && libc.AssignInt32(&N, Xsqlite3StrAccumEnlarge(tls, p, int64(N))) <= 0 {
  12153 		return
  12154 	}
  12155 	for libc.PostDecInt32(&N, 1) > 0 {
  12156 		*(*uint8)(unsafe.Pointer((*Sqlite3_str)(unsafe.Pointer(p)).FzText + uintptr(libc.PostIncUint32(&(*Sqlite3_str)(unsafe.Pointer(p)).FnChar, 1)))) = c
  12157 	}
  12158 }
  12159 
  12160 func enlargeAndAppend(tls *libc.TLS, p uintptr, z uintptr, N int32) {
  12161 	N = Xsqlite3StrAccumEnlarge(tls, p, int64(N))
  12162 	if N > 0 {
  12163 		libc.Xmemcpy(tls, (*StrAccum)(unsafe.Pointer(p)).FzText+uintptr((*StrAccum)(unsafe.Pointer(p)).FnChar), z, uint32(N))
  12164 		*(*U32)(unsafe.Pointer(p + 16)) += U32(N)
  12165 	}
  12166 }
  12167 
  12168 // Append N bytes of text from z to the StrAccum object.  Increase the
  12169 // size of the memory allocation for StrAccum if necessary.
  12170 func Xsqlite3_str_append(tls *libc.TLS, p uintptr, z uintptr, N int32) {
  12171 	if (*Sqlite3_str)(unsafe.Pointer(p)).FnChar+U32(N) >= (*Sqlite3_str)(unsafe.Pointer(p)).FnAlloc {
  12172 		enlargeAndAppend(tls, p, z, N)
  12173 	} else if N != 0 {
  12174 		*(*U32)(unsafe.Pointer(p + 16)) += U32(N)
  12175 		libc.Xmemcpy(tls, (*Sqlite3_str)(unsafe.Pointer(p)).FzText+uintptr((*Sqlite3_str)(unsafe.Pointer(p)).FnChar-U32(N)), z, uint32(N))
  12176 	}
  12177 }
  12178 
  12179 // Append the complete text of zero-terminated string z[] to the p string.
  12180 func Xsqlite3_str_appendall(tls *libc.TLS, p uintptr, z uintptr) {
  12181 	Xsqlite3_str_append(tls, p, z, Xsqlite3Strlen30(tls, z))
  12182 }
  12183 
  12184 func strAccumFinishRealloc(tls *libc.TLS, p uintptr) uintptr {
  12185 	var zText uintptr
  12186 
  12187 	zText = Xsqlite3DbMallocRaw(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, uint64((*StrAccum)(unsafe.Pointer(p)).FnChar+U32(1)))
  12188 	if zText != 0 {
  12189 		libc.Xmemcpy(tls, zText, (*StrAccum)(unsafe.Pointer(p)).FzText, (*StrAccum)(unsafe.Pointer(p)).FnChar+U32(1))
  12190 		*(*U8)(unsafe.Pointer(p + 21)) |= U8(SQLITE_PRINTF_MALLOCED)
  12191 	} else {
  12192 		Xsqlite3StrAccumSetError(tls, p, uint8(SQLITE_NOMEM))
  12193 	}
  12194 	(*StrAccum)(unsafe.Pointer(p)).FzText = zText
  12195 	return zText
  12196 }
  12197 
  12198 func Xsqlite3StrAccumFinish(tls *libc.TLS, p uintptr) uintptr {
  12199 	if (*StrAccum)(unsafe.Pointer(p)).FzText != 0 {
  12200 		*(*uint8)(unsafe.Pointer((*StrAccum)(unsafe.Pointer(p)).FzText + uintptr((*StrAccum)(unsafe.Pointer(p)).FnChar))) = uint8(0)
  12201 		if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc > U32(0) && !(int32((*StrAccum)(unsafe.Pointer(p)).FprintfFlags)&SQLITE_PRINTF_MALLOCED != 0) {
  12202 			return strAccumFinishRealloc(tls, p)
  12203 		}
  12204 	}
  12205 	return (*StrAccum)(unsafe.Pointer(p)).FzText
  12206 }
  12207 
  12208 // Use the content of the StrAccum passed as the second argument
  12209 // as the result of an SQL function.
  12210 func Xsqlite3ResultStrAccum(tls *libc.TLS, pCtx uintptr, p uintptr) {
  12211 	if (*StrAccum)(unsafe.Pointer(p)).FaccError != 0 {
  12212 		Xsqlite3_result_error_code(tls, pCtx, int32((*StrAccum)(unsafe.Pointer(p)).FaccError))
  12213 		Xsqlite3_str_reset(tls, p)
  12214 	} else if int32((*StrAccum)(unsafe.Pointer(p)).FprintfFlags)&SQLITE_PRINTF_MALLOCED != 0 {
  12215 		Xsqlite3_result_text(tls, pCtx, (*StrAccum)(unsafe.Pointer(p)).FzText, int32((*StrAccum)(unsafe.Pointer(p)).FnChar), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  12216 	} else {
  12217 		Xsqlite3_result_text(tls, pCtx, ts+1554, 0, uintptr(0))
  12218 		Xsqlite3_str_reset(tls, p)
  12219 	}
  12220 }
  12221 
  12222 var sqlite3OomStr = Sqlite3_str{FaccError: U8(SQLITE_NOMEM)}
  12223 
  12224 // Finalize a string created using sqlite3_str_new().
  12225 func Xsqlite3_str_finish(tls *libc.TLS, p uintptr) uintptr {
  12226 	var z uintptr
  12227 	if p != uintptr(0) && p != uintptr(unsafe.Pointer(&sqlite3OomStr)) {
  12228 		z = Xsqlite3StrAccumFinish(tls, p)
  12229 		Xsqlite3_free(tls, p)
  12230 	} else {
  12231 		z = uintptr(0)
  12232 	}
  12233 	return z
  12234 }
  12235 
  12236 // Return any error code associated with p
  12237 func Xsqlite3_str_errcode(tls *libc.TLS, p uintptr) int32 {
  12238 	if p != 0 {
  12239 		return int32((*Sqlite3_str)(unsafe.Pointer(p)).FaccError)
  12240 	}
  12241 	return SQLITE_NOMEM
  12242 }
  12243 
  12244 // Return the current length of p in bytes
  12245 func Xsqlite3_str_length(tls *libc.TLS, p uintptr) int32 {
  12246 	if p != 0 {
  12247 		return int32((*Sqlite3_str)(unsafe.Pointer(p)).FnChar)
  12248 	}
  12249 	return 0
  12250 }
  12251 
  12252 // Return the current value for p
  12253 func Xsqlite3_str_value(tls *libc.TLS, p uintptr) uintptr {
  12254 	if p == uintptr(0) || (*Sqlite3_str)(unsafe.Pointer(p)).FnChar == U32(0) {
  12255 		return uintptr(0)
  12256 	}
  12257 	*(*uint8)(unsafe.Pointer((*Sqlite3_str)(unsafe.Pointer(p)).FzText + uintptr((*Sqlite3_str)(unsafe.Pointer(p)).FnChar))) = uint8(0)
  12258 	return (*Sqlite3_str)(unsafe.Pointer(p)).FzText
  12259 }
  12260 
  12261 // Reset an StrAccum string.  Reclaim all malloced memory.
  12262 func Xsqlite3_str_reset(tls *libc.TLS, p uintptr) {
  12263 	if int32((*StrAccum)(unsafe.Pointer(p)).FprintfFlags)&SQLITE_PRINTF_MALLOCED != 0 {
  12264 		Xsqlite3DbFree(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, (*StrAccum)(unsafe.Pointer(p)).FzText)
  12265 		*(*U8)(unsafe.Pointer(p + 21)) &= libc.Uint8FromInt32(libc.CplInt32(SQLITE_PRINTF_MALLOCED))
  12266 	}
  12267 	(*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(0)
  12268 	(*StrAccum)(unsafe.Pointer(p)).FnChar = U32(0)
  12269 	(*StrAccum)(unsafe.Pointer(p)).FzText = uintptr(0)
  12270 }
  12271 
  12272 // Initialize a string accumulator.
  12273 //
  12274 // p:     The accumulator to be initialized.
  12275 // db:    Pointer to a database connection.  May be NULL.  Lookaside
  12276 //
  12277 //	memory is used if not NULL. db->mallocFailed is set appropriately
  12278 //	when not NULL.
  12279 //
  12280 // zBase: An initial buffer.  May be NULL in which case the initial buffer
  12281 //
  12282 //	is malloced.
  12283 //
  12284 // n:     Size of zBase in bytes.  If total space requirements never exceed
  12285 //
  12286 //	n then no memory allocations ever occur.
  12287 //
  12288 // mx:    Maximum number of bytes to accumulate.  If mx==0 then no memory
  12289 //
  12290 //	allocations will ever occur.
  12291 func Xsqlite3StrAccumInit(tls *libc.TLS, p uintptr, db uintptr, zBase uintptr, n int32, mx int32) {
  12292 	(*StrAccum)(unsafe.Pointer(p)).FzText = zBase
  12293 	(*StrAccum)(unsafe.Pointer(p)).Fdb = db
  12294 	(*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(n)
  12295 	(*StrAccum)(unsafe.Pointer(p)).FmxAlloc = U32(mx)
  12296 	(*StrAccum)(unsafe.Pointer(p)).FnChar = U32(0)
  12297 	(*StrAccum)(unsafe.Pointer(p)).FaccError = U8(0)
  12298 	(*StrAccum)(unsafe.Pointer(p)).FprintfFlags = U8(0)
  12299 }
  12300 
  12301 // Allocate and initialize a new dynamic string object
  12302 func Xsqlite3_str_new(tls *libc.TLS, db uintptr) uintptr {
  12303 	var p uintptr = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(Sqlite3_str{})))
  12304 	if p != 0 {
  12305 		Xsqlite3StrAccumInit(tls, p, uintptr(0), uintptr(0), 0,
  12306 			func() int32 {
  12307 				if db != 0 {
  12308 					return *(*int32)(unsafe.Pointer(db + 120))
  12309 				}
  12310 				return SQLITE_MAX_LENGTH
  12311 			}())
  12312 	} else {
  12313 		p = uintptr(unsafe.Pointer(&sqlite3OomStr))
  12314 	}
  12315 	return p
  12316 }
  12317 
  12318 // Print into memory obtained from sqliteMalloc().  Use the internal
  12319 // %-conversion extensions.
  12320 func Xsqlite3VMPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, ap Va_list) uintptr {
  12321 	bp := tls.Alloc(94)
  12322 	defer tls.Free(94)
  12323 
  12324 	var z uintptr
  12325 
  12326 	Xsqlite3StrAccumInit(tls, bp, db, bp+24, int32(unsafe.Sizeof([70]uint8{})),
  12327 		*(*int32)(unsafe.Pointer(db + 120)))
  12328 	(*StrAccum)(unsafe.Pointer(bp)).FprintfFlags = U8(SQLITE_PRINTF_INTERNAL)
  12329 	Xsqlite3_str_vappendf(tls, bp, zFormat, ap)
  12330 	z = Xsqlite3StrAccumFinish(tls, bp)
  12331 	if int32((*StrAccum)(unsafe.Pointer(bp)).FaccError) == SQLITE_NOMEM {
  12332 		Xsqlite3OomFault(tls, db)
  12333 	}
  12334 	return z
  12335 }
  12336 
  12337 // Print into memory obtained from sqliteMalloc().  Use the internal
  12338 // %-conversion extensions.
  12339 func Xsqlite3MPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, va uintptr) uintptr {
  12340 	var ap Va_list
  12341 	_ = ap
  12342 	var z uintptr
  12343 	ap = va
  12344 	z = Xsqlite3VMPrintf(tls, db, zFormat, ap)
  12345 	_ = ap
  12346 	return z
  12347 }
  12348 
  12349 // Print into memory obtained from sqlite3_malloc().  Omit the internal
  12350 // %-conversion extensions.
  12351 func Xsqlite3_vmprintf(tls *libc.TLS, zFormat uintptr, ap Va_list) uintptr {
  12352 	bp := tls.Alloc(94)
  12353 	defer tls.Free(94)
  12354 
  12355 	var z uintptr
  12356 
  12357 	if Xsqlite3_initialize(tls) != 0 {
  12358 		return uintptr(0)
  12359 	}
  12360 	Xsqlite3StrAccumInit(tls, bp, uintptr(0), bp+24, int32(unsafe.Sizeof([70]uint8{})), SQLITE_MAX_LENGTH)
  12361 	Xsqlite3_str_vappendf(tls, bp, zFormat, ap)
  12362 	z = Xsqlite3StrAccumFinish(tls, bp)
  12363 	return z
  12364 }
  12365 
  12366 // Print into memory obtained from sqlite3_malloc()().  Omit the internal
  12367 // %-conversion extensions.
  12368 func Xsqlite3_mprintf(tls *libc.TLS, zFormat uintptr, va uintptr) uintptr {
  12369 	var ap Va_list
  12370 	_ = ap
  12371 	var z uintptr
  12372 	if Xsqlite3_initialize(tls) != 0 {
  12373 		return uintptr(0)
  12374 	}
  12375 	ap = va
  12376 	z = Xsqlite3_vmprintf(tls, zFormat, ap)
  12377 	_ = ap
  12378 	return z
  12379 }
  12380 
  12381 // sqlite3_snprintf() works like snprintf() except that it ignores the
  12382 // current locale settings.  This is important for SQLite because we
  12383 // are not able to use a "," as the decimal point in place of "." as
  12384 // specified by some locales.
  12385 //
  12386 // Oops:  The first two arguments of sqlite3_snprintf() are backwards
  12387 // from the snprintf() standard.  Unfortunately, it is too late to change
  12388 // this without breaking compatibility, so we just have to live with the
  12389 // mistake.
  12390 //
  12391 // sqlite3_vsnprintf() is the varargs version.
  12392 func Xsqlite3_vsnprintf(tls *libc.TLS, n int32, zBuf uintptr, zFormat uintptr, ap Va_list) uintptr {
  12393 	bp := tls.Alloc(24)
  12394 	defer tls.Free(24)
  12395 
  12396 	if n <= 0 {
  12397 		return zBuf
  12398 	}
  12399 	Xsqlite3StrAccumInit(tls, bp, uintptr(0), zBuf, n, 0)
  12400 	Xsqlite3_str_vappendf(tls, bp, zFormat, ap)
  12401 	*(*uint8)(unsafe.Pointer(zBuf + uintptr((*StrAccum)(unsafe.Pointer(bp)).FnChar))) = uint8(0)
  12402 	return zBuf
  12403 }
  12404 
  12405 func Xsqlite3_snprintf(tls *libc.TLS, n int32, zBuf uintptr, zFormat uintptr, va uintptr) uintptr {
  12406 	var z uintptr
  12407 	var ap Va_list
  12408 	_ = ap
  12409 	ap = va
  12410 	z = Xsqlite3_vsnprintf(tls, n, zBuf, zFormat, ap)
  12411 	_ = ap
  12412 	return z
  12413 }
  12414 
  12415 func renderLogMsg(tls *libc.TLS, iErrCode int32, zFormat uintptr, ap Va_list) {
  12416 	bp := tls.Alloc(234)
  12417 	defer tls.Free(234)
  12418 
  12419 	Xsqlite3StrAccumInit(tls, bp, uintptr(0), bp+24, int32(unsafe.Sizeof([210]uint8{})), 0)
  12420 	Xsqlite3_str_vappendf(tls, bp, zFormat, ap)
  12421 	(*struct {
  12422 		f func(*libc.TLS, uintptr, int32, uintptr)
  12423 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.FxLog})).f(tls, Xsqlite3Config.FpLogArg, iErrCode,
  12424 		Xsqlite3StrAccumFinish(tls, bp))
  12425 }
  12426 
  12427 // Format and write a message to the log if logging is enabled.
  12428 func Xsqlite3_log(tls *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) {
  12429 	var ap Va_list
  12430 	_ = ap
  12431 	if Xsqlite3Config.FxLog != 0 {
  12432 		ap = va
  12433 		renderLogMsg(tls, iErrCode, zFormat, ap)
  12434 		_ = ap
  12435 	}
  12436 }
  12437 
  12438 // variable-argument wrapper around sqlite3_str_vappendf(). The bFlags argument
  12439 // can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.
  12440 func Xsqlite3_str_appendf(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) {
  12441 	var ap Va_list
  12442 	_ = ap
  12443 	ap = va
  12444 	Xsqlite3_str_vappendf(tls, p, zFormat, ap)
  12445 	_ = ap
  12446 }
  12447 
  12448 type sqlite3PrngType = struct {
  12449 	Fs           [16]U32
  12450 	Fout         [64]U8
  12451 	Fn           U8
  12452 	F__ccgo_pad1 [3]byte
  12453 }
  12454 
  12455 var sqlite3Prng sqlite3PrngType
  12456 
  12457 func chacha_block(tls *libc.TLS, out uintptr, in uintptr) {
  12458 	bp := tls.Alloc(64)
  12459 	defer tls.Free(64)
  12460 
  12461 	var i int32
  12462 
  12463 	libc.Xmemcpy(tls, bp, in, uint32(64))
  12464 	for i = 0; i < 10; i++ {
  12465 		*(*U32)(unsafe.Pointer(bp)) += *(*U32)(unsafe.Pointer(bp + 4*4))
  12466 		*(*U32)(unsafe.Pointer(bp + 12*4)) ^= *(*U32)(unsafe.Pointer(bp))
  12467 		*(*U32)(unsafe.Pointer(bp + 12*4)) = *(*U32)(unsafe.Pointer(bp + 12*4))<<16 | *(*U32)(unsafe.Pointer(bp + 12*4))>>(32-16)
  12468 		*(*U32)(unsafe.Pointer(bp + 8*4)) += *(*U32)(unsafe.Pointer(bp + 12*4))
  12469 		*(*U32)(unsafe.Pointer(bp + 4*4)) ^= *(*U32)(unsafe.Pointer(bp + 8*4))
  12470 		*(*U32)(unsafe.Pointer(bp + 4*4)) = *(*U32)(unsafe.Pointer(bp + 4*4))<<12 | *(*U32)(unsafe.Pointer(bp + 4*4))>>(32-12)
  12471 		*(*U32)(unsafe.Pointer(bp)) += *(*U32)(unsafe.Pointer(bp + 4*4))
  12472 		*(*U32)(unsafe.Pointer(bp + 12*4)) ^= *(*U32)(unsafe.Pointer(bp))
  12473 		*(*U32)(unsafe.Pointer(bp + 12*4)) = *(*U32)(unsafe.Pointer(bp + 12*4))<<8 | *(*U32)(unsafe.Pointer(bp + 12*4))>>(32-8)
  12474 		*(*U32)(unsafe.Pointer(bp + 8*4)) += *(*U32)(unsafe.Pointer(bp + 12*4))
  12475 		*(*U32)(unsafe.Pointer(bp + 4*4)) ^= *(*U32)(unsafe.Pointer(bp + 8*4))
  12476 		*(*U32)(unsafe.Pointer(bp + 4*4)) = *(*U32)(unsafe.Pointer(bp + 4*4))<<7 | *(*U32)(unsafe.Pointer(bp + 4*4))>>(32-7)
  12477 		*(*U32)(unsafe.Pointer(bp + 1*4)) += *(*U32)(unsafe.Pointer(bp + 5*4))
  12478 		*(*U32)(unsafe.Pointer(bp + 13*4)) ^= *(*U32)(unsafe.Pointer(bp + 1*4))
  12479 		*(*U32)(unsafe.Pointer(bp + 13*4)) = *(*U32)(unsafe.Pointer(bp + 13*4))<<16 | *(*U32)(unsafe.Pointer(bp + 13*4))>>(32-16)
  12480 		*(*U32)(unsafe.Pointer(bp + 9*4)) += *(*U32)(unsafe.Pointer(bp + 13*4))
  12481 		*(*U32)(unsafe.Pointer(bp + 5*4)) ^= *(*U32)(unsafe.Pointer(bp + 9*4))
  12482 		*(*U32)(unsafe.Pointer(bp + 5*4)) = *(*U32)(unsafe.Pointer(bp + 5*4))<<12 | *(*U32)(unsafe.Pointer(bp + 5*4))>>(32-12)
  12483 		*(*U32)(unsafe.Pointer(bp + 1*4)) += *(*U32)(unsafe.Pointer(bp + 5*4))
  12484 		*(*U32)(unsafe.Pointer(bp + 13*4)) ^= *(*U32)(unsafe.Pointer(bp + 1*4))
  12485 		*(*U32)(unsafe.Pointer(bp + 13*4)) = *(*U32)(unsafe.Pointer(bp + 13*4))<<8 | *(*U32)(unsafe.Pointer(bp + 13*4))>>(32-8)
  12486 		*(*U32)(unsafe.Pointer(bp + 9*4)) += *(*U32)(unsafe.Pointer(bp + 13*4))
  12487 		*(*U32)(unsafe.Pointer(bp + 5*4)) ^= *(*U32)(unsafe.Pointer(bp + 9*4))
  12488 		*(*U32)(unsafe.Pointer(bp + 5*4)) = *(*U32)(unsafe.Pointer(bp + 5*4))<<7 | *(*U32)(unsafe.Pointer(bp + 5*4))>>(32-7)
  12489 		*(*U32)(unsafe.Pointer(bp + 2*4)) += *(*U32)(unsafe.Pointer(bp + 6*4))
  12490 		*(*U32)(unsafe.Pointer(bp + 14*4)) ^= *(*U32)(unsafe.Pointer(bp + 2*4))
  12491 		*(*U32)(unsafe.Pointer(bp + 14*4)) = *(*U32)(unsafe.Pointer(bp + 14*4))<<16 | *(*U32)(unsafe.Pointer(bp + 14*4))>>(32-16)
  12492 		*(*U32)(unsafe.Pointer(bp + 10*4)) += *(*U32)(unsafe.Pointer(bp + 14*4))
  12493 		*(*U32)(unsafe.Pointer(bp + 6*4)) ^= *(*U32)(unsafe.Pointer(bp + 10*4))
  12494 		*(*U32)(unsafe.Pointer(bp + 6*4)) = *(*U32)(unsafe.Pointer(bp + 6*4))<<12 | *(*U32)(unsafe.Pointer(bp + 6*4))>>(32-12)
  12495 		*(*U32)(unsafe.Pointer(bp + 2*4)) += *(*U32)(unsafe.Pointer(bp + 6*4))
  12496 		*(*U32)(unsafe.Pointer(bp + 14*4)) ^= *(*U32)(unsafe.Pointer(bp + 2*4))
  12497 		*(*U32)(unsafe.Pointer(bp + 14*4)) = *(*U32)(unsafe.Pointer(bp + 14*4))<<8 | *(*U32)(unsafe.Pointer(bp + 14*4))>>(32-8)
  12498 		*(*U32)(unsafe.Pointer(bp + 10*4)) += *(*U32)(unsafe.Pointer(bp + 14*4))
  12499 		*(*U32)(unsafe.Pointer(bp + 6*4)) ^= *(*U32)(unsafe.Pointer(bp + 10*4))
  12500 		*(*U32)(unsafe.Pointer(bp + 6*4)) = *(*U32)(unsafe.Pointer(bp + 6*4))<<7 | *(*U32)(unsafe.Pointer(bp + 6*4))>>(32-7)
  12501 		*(*U32)(unsafe.Pointer(bp + 3*4)) += *(*U32)(unsafe.Pointer(bp + 7*4))
  12502 		*(*U32)(unsafe.Pointer(bp + 15*4)) ^= *(*U32)(unsafe.Pointer(bp + 3*4))
  12503 		*(*U32)(unsafe.Pointer(bp + 15*4)) = *(*U32)(unsafe.Pointer(bp + 15*4))<<16 | *(*U32)(unsafe.Pointer(bp + 15*4))>>(32-16)
  12504 		*(*U32)(unsafe.Pointer(bp + 11*4)) += *(*U32)(unsafe.Pointer(bp + 15*4))
  12505 		*(*U32)(unsafe.Pointer(bp + 7*4)) ^= *(*U32)(unsafe.Pointer(bp + 11*4))
  12506 		*(*U32)(unsafe.Pointer(bp + 7*4)) = *(*U32)(unsafe.Pointer(bp + 7*4))<<12 | *(*U32)(unsafe.Pointer(bp + 7*4))>>(32-12)
  12507 		*(*U32)(unsafe.Pointer(bp + 3*4)) += *(*U32)(unsafe.Pointer(bp + 7*4))
  12508 		*(*U32)(unsafe.Pointer(bp + 15*4)) ^= *(*U32)(unsafe.Pointer(bp + 3*4))
  12509 		*(*U32)(unsafe.Pointer(bp + 15*4)) = *(*U32)(unsafe.Pointer(bp + 15*4))<<8 | *(*U32)(unsafe.Pointer(bp + 15*4))>>(32-8)
  12510 		*(*U32)(unsafe.Pointer(bp + 11*4)) += *(*U32)(unsafe.Pointer(bp + 15*4))
  12511 		*(*U32)(unsafe.Pointer(bp + 7*4)) ^= *(*U32)(unsafe.Pointer(bp + 11*4))
  12512 		*(*U32)(unsafe.Pointer(bp + 7*4)) = *(*U32)(unsafe.Pointer(bp + 7*4))<<7 | *(*U32)(unsafe.Pointer(bp + 7*4))>>(32-7)
  12513 		*(*U32)(unsafe.Pointer(bp)) += *(*U32)(unsafe.Pointer(bp + 5*4))
  12514 		*(*U32)(unsafe.Pointer(bp + 15*4)) ^= *(*U32)(unsafe.Pointer(bp))
  12515 		*(*U32)(unsafe.Pointer(bp + 15*4)) = *(*U32)(unsafe.Pointer(bp + 15*4))<<16 | *(*U32)(unsafe.Pointer(bp + 15*4))>>(32-16)
  12516 		*(*U32)(unsafe.Pointer(bp + 10*4)) += *(*U32)(unsafe.Pointer(bp + 15*4))
  12517 		*(*U32)(unsafe.Pointer(bp + 5*4)) ^= *(*U32)(unsafe.Pointer(bp + 10*4))
  12518 		*(*U32)(unsafe.Pointer(bp + 5*4)) = *(*U32)(unsafe.Pointer(bp + 5*4))<<12 | *(*U32)(unsafe.Pointer(bp + 5*4))>>(32-12)
  12519 		*(*U32)(unsafe.Pointer(bp)) += *(*U32)(unsafe.Pointer(bp + 5*4))
  12520 		*(*U32)(unsafe.Pointer(bp + 15*4)) ^= *(*U32)(unsafe.Pointer(bp))
  12521 		*(*U32)(unsafe.Pointer(bp + 15*4)) = *(*U32)(unsafe.Pointer(bp + 15*4))<<8 | *(*U32)(unsafe.Pointer(bp + 15*4))>>(32-8)
  12522 		*(*U32)(unsafe.Pointer(bp + 10*4)) += *(*U32)(unsafe.Pointer(bp + 15*4))
  12523 		*(*U32)(unsafe.Pointer(bp + 5*4)) ^= *(*U32)(unsafe.Pointer(bp + 10*4))
  12524 		*(*U32)(unsafe.Pointer(bp + 5*4)) = *(*U32)(unsafe.Pointer(bp + 5*4))<<7 | *(*U32)(unsafe.Pointer(bp + 5*4))>>(32-7)
  12525 		*(*U32)(unsafe.Pointer(bp + 1*4)) += *(*U32)(unsafe.Pointer(bp + 6*4))
  12526 		*(*U32)(unsafe.Pointer(bp + 12*4)) ^= *(*U32)(unsafe.Pointer(bp + 1*4))
  12527 		*(*U32)(unsafe.Pointer(bp + 12*4)) = *(*U32)(unsafe.Pointer(bp + 12*4))<<16 | *(*U32)(unsafe.Pointer(bp + 12*4))>>(32-16)
  12528 		*(*U32)(unsafe.Pointer(bp + 11*4)) += *(*U32)(unsafe.Pointer(bp + 12*4))
  12529 		*(*U32)(unsafe.Pointer(bp + 6*4)) ^= *(*U32)(unsafe.Pointer(bp + 11*4))
  12530 		*(*U32)(unsafe.Pointer(bp + 6*4)) = *(*U32)(unsafe.Pointer(bp + 6*4))<<12 | *(*U32)(unsafe.Pointer(bp + 6*4))>>(32-12)
  12531 		*(*U32)(unsafe.Pointer(bp + 1*4)) += *(*U32)(unsafe.Pointer(bp + 6*4))
  12532 		*(*U32)(unsafe.Pointer(bp + 12*4)) ^= *(*U32)(unsafe.Pointer(bp + 1*4))
  12533 		*(*U32)(unsafe.Pointer(bp + 12*4)) = *(*U32)(unsafe.Pointer(bp + 12*4))<<8 | *(*U32)(unsafe.Pointer(bp + 12*4))>>(32-8)
  12534 		*(*U32)(unsafe.Pointer(bp + 11*4)) += *(*U32)(unsafe.Pointer(bp + 12*4))
  12535 		*(*U32)(unsafe.Pointer(bp + 6*4)) ^= *(*U32)(unsafe.Pointer(bp + 11*4))
  12536 		*(*U32)(unsafe.Pointer(bp + 6*4)) = *(*U32)(unsafe.Pointer(bp + 6*4))<<7 | *(*U32)(unsafe.Pointer(bp + 6*4))>>(32-7)
  12537 		*(*U32)(unsafe.Pointer(bp + 2*4)) += *(*U32)(unsafe.Pointer(bp + 7*4))
  12538 		*(*U32)(unsafe.Pointer(bp + 13*4)) ^= *(*U32)(unsafe.Pointer(bp + 2*4))
  12539 		*(*U32)(unsafe.Pointer(bp + 13*4)) = *(*U32)(unsafe.Pointer(bp + 13*4))<<16 | *(*U32)(unsafe.Pointer(bp + 13*4))>>(32-16)
  12540 		*(*U32)(unsafe.Pointer(bp + 8*4)) += *(*U32)(unsafe.Pointer(bp + 13*4))
  12541 		*(*U32)(unsafe.Pointer(bp + 7*4)) ^= *(*U32)(unsafe.Pointer(bp + 8*4))
  12542 		*(*U32)(unsafe.Pointer(bp + 7*4)) = *(*U32)(unsafe.Pointer(bp + 7*4))<<12 | *(*U32)(unsafe.Pointer(bp + 7*4))>>(32-12)
  12543 		*(*U32)(unsafe.Pointer(bp + 2*4)) += *(*U32)(unsafe.Pointer(bp + 7*4))
  12544 		*(*U32)(unsafe.Pointer(bp + 13*4)) ^= *(*U32)(unsafe.Pointer(bp + 2*4))
  12545 		*(*U32)(unsafe.Pointer(bp + 13*4)) = *(*U32)(unsafe.Pointer(bp + 13*4))<<8 | *(*U32)(unsafe.Pointer(bp + 13*4))>>(32-8)
  12546 		*(*U32)(unsafe.Pointer(bp + 8*4)) += *(*U32)(unsafe.Pointer(bp + 13*4))
  12547 		*(*U32)(unsafe.Pointer(bp + 7*4)) ^= *(*U32)(unsafe.Pointer(bp + 8*4))
  12548 		*(*U32)(unsafe.Pointer(bp + 7*4)) = *(*U32)(unsafe.Pointer(bp + 7*4))<<7 | *(*U32)(unsafe.Pointer(bp + 7*4))>>(32-7)
  12549 		*(*U32)(unsafe.Pointer(bp + 3*4)) += *(*U32)(unsafe.Pointer(bp + 4*4))
  12550 		*(*U32)(unsafe.Pointer(bp + 14*4)) ^= *(*U32)(unsafe.Pointer(bp + 3*4))
  12551 		*(*U32)(unsafe.Pointer(bp + 14*4)) = *(*U32)(unsafe.Pointer(bp + 14*4))<<16 | *(*U32)(unsafe.Pointer(bp + 14*4))>>(32-16)
  12552 		*(*U32)(unsafe.Pointer(bp + 9*4)) += *(*U32)(unsafe.Pointer(bp + 14*4))
  12553 		*(*U32)(unsafe.Pointer(bp + 4*4)) ^= *(*U32)(unsafe.Pointer(bp + 9*4))
  12554 		*(*U32)(unsafe.Pointer(bp + 4*4)) = *(*U32)(unsafe.Pointer(bp + 4*4))<<12 | *(*U32)(unsafe.Pointer(bp + 4*4))>>(32-12)
  12555 		*(*U32)(unsafe.Pointer(bp + 3*4)) += *(*U32)(unsafe.Pointer(bp + 4*4))
  12556 		*(*U32)(unsafe.Pointer(bp + 14*4)) ^= *(*U32)(unsafe.Pointer(bp + 3*4))
  12557 		*(*U32)(unsafe.Pointer(bp + 14*4)) = *(*U32)(unsafe.Pointer(bp + 14*4))<<8 | *(*U32)(unsafe.Pointer(bp + 14*4))>>(32-8)
  12558 		*(*U32)(unsafe.Pointer(bp + 9*4)) += *(*U32)(unsafe.Pointer(bp + 14*4))
  12559 		*(*U32)(unsafe.Pointer(bp + 4*4)) ^= *(*U32)(unsafe.Pointer(bp + 9*4))
  12560 		*(*U32)(unsafe.Pointer(bp + 4*4)) = *(*U32)(unsafe.Pointer(bp + 4*4))<<7 | *(*U32)(unsafe.Pointer(bp + 4*4))>>(32-7)
  12561 	}
  12562 	for i = 0; i < 16; i++ {
  12563 		*(*U32)(unsafe.Pointer(out + uintptr(i)*4)) = *(*U32)(unsafe.Pointer(bp + uintptr(i)*4)) + *(*U32)(unsafe.Pointer(in + uintptr(i)*4))
  12564 	}
  12565 }
  12566 
  12567 // Return N random bytes.
  12568 func Xsqlite3_randomness(tls *libc.TLS, N int32, pBuf uintptr) {
  12569 	var zBuf uintptr = pBuf
  12570 
  12571 	var mutex uintptr
  12572 
  12573 	if Xsqlite3_initialize(tls) != 0 {
  12574 		return
  12575 	}
  12576 
  12577 	mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_PRNG)
  12578 
  12579 	Xsqlite3_mutex_enter(tls, mutex)
  12580 	if N <= 0 || pBuf == uintptr(0) {
  12581 		*(*U32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)))) = U32(0)
  12582 		Xsqlite3_mutex_leave(tls, mutex)
  12583 		return
  12584 	}
  12585 
  12586 	if *(*U32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)))) == U32(0) {
  12587 		var pVfs uintptr = Xsqlite3_vfs_find(tls, uintptr(0))
  12588 		libc.Xmemcpy(tls, uintptr(unsafe.Pointer(&sqlite3Prng)), uintptr(unsafe.Pointer(&chacha20_init)), uint32(16))
  12589 		if pVfs == uintptr(0) {
  12590 			libc.Xmemset(tls, uintptr(unsafe.Pointer(&sqlite3Prng))+4*4, 0, uint32(44))
  12591 		} else {
  12592 			Xsqlite3OsRandomness(tls, pVfs, 44, uintptr(unsafe.Pointer(&sqlite3Prng))+4*4)
  12593 		}
  12594 		*(*U32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)) + 15*4)) = *(*U32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)) + 12*4))
  12595 		*(*U32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)) + 12*4)) = U32(0)
  12596 		sqlite3Prng.Fn = U8(0)
  12597 	}
  12598 
  12599 	for 1 != 0 {
  12600 		if N <= int32(sqlite3Prng.Fn) {
  12601 			libc.Xmemcpy(tls, zBuf, uintptr(unsafe.Pointer(&sqlite3Prng))+64+uintptr(int32(sqlite3Prng.Fn)-N), uint32(N))
  12602 			*(*U8)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)) + 128)) -= U8(N)
  12603 			break
  12604 		}
  12605 		if int32(sqlite3Prng.Fn) > 0 {
  12606 			libc.Xmemcpy(tls, zBuf, uintptr(unsafe.Pointer(&sqlite3Prng))+64, uint32(sqlite3Prng.Fn))
  12607 			N = N - int32(sqlite3Prng.Fn)
  12608 			zBuf += uintptr(sqlite3Prng.Fn)
  12609 		}
  12610 		*(*U32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Prng)) + 12*4))++
  12611 		chacha_block(tls, uintptr(unsafe.Pointer(&sqlite3Prng))+64, uintptr(unsafe.Pointer(&sqlite3Prng)))
  12612 		sqlite3Prng.Fn = U8(64)
  12613 	}
  12614 	Xsqlite3_mutex_leave(tls, mutex)
  12615 }
  12616 
  12617 var chacha20_init = [4]U32{
  12618 	U32(0x61707865), U32(0x3320646e), U32(0x79622d32), U32(0x6b206574),
  12619 }
  12620 
  12621 var sqlite3SavedPrng sqlite3PrngType
  12622 
  12623 func Xsqlite3PrngSaveState(tls *libc.TLS) {
  12624 	libc.Xmemcpy(tls,
  12625 		uintptr(unsafe.Pointer(&sqlite3SavedPrng)),
  12626 		uintptr(unsafe.Pointer(&sqlite3Prng)),
  12627 		uint32(unsafe.Sizeof(sqlite3Prng)))
  12628 }
  12629 
  12630 func Xsqlite3PrngRestoreState(tls *libc.TLS) {
  12631 	libc.Xmemcpy(tls,
  12632 		uintptr(unsafe.Pointer(&sqlite3Prng)),
  12633 		uintptr(unsafe.Pointer(&sqlite3SavedPrng)),
  12634 		uint32(unsafe.Sizeof(sqlite3Prng)))
  12635 }
  12636 
  12637 // Create a new thread
  12638 func Xsqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, xTask uintptr, pIn uintptr) int32 {
  12639 	var p uintptr
  12640 
  12641 	*(*uintptr)(unsafe.Pointer(ppThread)) = uintptr(0)
  12642 	p = Xsqlite3Malloc(tls, uint64(unsafe.Sizeof(SQLiteThread{})))
  12643 	if p == uintptr(0) {
  12644 		return SQLITE_NOMEM
  12645 	}
  12646 	if int32(p)/17&1 != 0 {
  12647 		(*SQLiteThread)(unsafe.Pointer(p)).FxTask = xTask
  12648 		(*SQLiteThread)(unsafe.Pointer(p)).FpIn = pIn
  12649 	} else {
  12650 		(*SQLiteThread)(unsafe.Pointer(p)).FxTask = uintptr(0)
  12651 		(*SQLiteThread)(unsafe.Pointer(p)).FpResult = (*struct {
  12652 			f func(*libc.TLS, uintptr) uintptr
  12653 		})(unsafe.Pointer(&struct{ uintptr }{xTask})).f(tls, pIn)
  12654 	}
  12655 	*(*uintptr)(unsafe.Pointer(ppThread)) = p
  12656 	return SQLITE_OK
  12657 }
  12658 
  12659 // Get the results of the thread
  12660 func Xsqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) int32 {
  12661 	if p == uintptr(0) {
  12662 		return SQLITE_NOMEM
  12663 	}
  12664 	if (*SQLiteThread)(unsafe.Pointer(p)).FxTask != 0 {
  12665 		*(*uintptr)(unsafe.Pointer(ppOut)) = (*struct {
  12666 			f func(*libc.TLS, uintptr) uintptr
  12667 		})(unsafe.Pointer(&struct{ uintptr }{(*SQLiteThread)(unsafe.Pointer(p)).FxTask})).f(tls, (*SQLiteThread)(unsafe.Pointer(p)).FpIn)
  12668 	} else {
  12669 		*(*uintptr)(unsafe.Pointer(ppOut)) = (*SQLiteThread)(unsafe.Pointer(p)).FpResult
  12670 	}
  12671 	Xsqlite3_free(tls, p)
  12672 
  12673 	return SQLITE_OK
  12674 }
  12675 
  12676 var sqlite3Utf8Trans1 = [64]uint8{
  12677 	uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07),
  12678 	uint8(0x08), uint8(0x09), uint8(0x0a), uint8(0x0b), uint8(0x0c), uint8(0x0d), uint8(0x0e), uint8(0x0f),
  12679 	uint8(0x10), uint8(0x11), uint8(0x12), uint8(0x13), uint8(0x14), uint8(0x15), uint8(0x16), uint8(0x17),
  12680 	uint8(0x18), uint8(0x19), uint8(0x1a), uint8(0x1b), uint8(0x1c), uint8(0x1d), uint8(0x1e), uint8(0x1f),
  12681 	uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07),
  12682 	uint8(0x08), uint8(0x09), uint8(0x0a), uint8(0x0b), uint8(0x0c), uint8(0x0d), uint8(0x0e), uint8(0x0f),
  12683 	uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07),
  12684 	uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x00), uint8(0x01), uint8(0x00), uint8(0x00),
  12685 }
  12686 
  12687 // Translate a single UTF-8 character.  Return the unicode value.
  12688 //
  12689 // During translation, assume that the byte that zTerm points
  12690 // is a 0x00.
  12691 //
  12692 // Write a pointer to the next unread byte back into *pzNext.
  12693 //
  12694 // Notes On Invalid UTF-8:
  12695 //
  12696 //   - This routine never allows a 7-bit character (0x00 through 0x7f) to
  12697 //     be encoded as a multi-byte character.  Any multi-byte character that
  12698 //     attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd.
  12699 //
  12700 //   - This routine never allows a UTF16 surrogate value to be encoded.
  12701 //     If a multi-byte character attempts to encode a value between
  12702 //     0xd800 and 0xe000 then it is rendered as 0xfffd.
  12703 //
  12704 //   - Bytes in the range of 0x80 through 0xbf which occur as the first
  12705 //     byte of a character are interpreted as single-byte characters
  12706 //     and rendered as themselves even though they are technically
  12707 //     invalid characters.
  12708 //
  12709 //   - This routine accepts over-length UTF8 encodings
  12710 //     for unicode values 0x80 and greater.  It does not change over-length
  12711 //     encodings to 0xfffd as some systems recommend.
  12712 func Xsqlite3Utf8Read(tls *libc.TLS, pz uintptr) U32 {
  12713 	var c uint32
  12714 
  12715 	c = uint32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(pz)), 1))))
  12716 	if c >= uint32(0xc0) {
  12717 		c = uint32(sqlite3Utf8Trans1[c-uint32(0xc0)])
  12718 		for int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pz)))))&0xc0 == 0x80 {
  12719 			c = c<<6 + uint32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(pz)), 1)))))
  12720 		}
  12721 		if c < uint32(0x80) ||
  12722 			c&0xFFFFF800 == uint32(0xD800) ||
  12723 			c&0xFFFFFFFE == uint32(0xFFFE) {
  12724 			c = uint32(0xFFFD)
  12725 		}
  12726 	}
  12727 	return c
  12728 }
  12729 
  12730 // This routine transforms the internal text encoding used by pMem to
  12731 // desiredEnc. It is an error if the string is already of the desired
  12732 // encoding, or if *pMem does not contain a string value.
  12733 func Xsqlite3VdbeMemTranslate(tls *libc.TLS, pMem uintptr, desiredEnc U8) int32 {
  12734 	var len Sqlite3_int64
  12735 	var zOut uintptr
  12736 	var zIn uintptr
  12737 	var zTerm uintptr
  12738 	var z uintptr
  12739 	var c uint32
  12740 	var temp U8
  12741 	var rc int32
  12742 	var c2 int32
  12743 	var c21 int32
  12744 
  12745 	if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) != SQLITE_UTF8 && int32(desiredEnc) != SQLITE_UTF8) {
  12746 		goto __1
  12747 	}
  12748 	rc = Xsqlite3VdbeMemMakeWriteable(tls, pMem)
  12749 	if !(rc != SQLITE_OK) {
  12750 		goto __2
  12751 	}
  12752 
  12753 	return SQLITE_NOMEM
  12754 __2:
  12755 	;
  12756 	zIn = (*Mem)(unsafe.Pointer(pMem)).Fz
  12757 	zTerm = zIn + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn&libc.CplInt32(1))
  12758 __3:
  12759 	if !(zIn < zTerm) {
  12760 		goto __4
  12761 	}
  12762 	temp = *(*uint8)(unsafe.Pointer(zIn))
  12763 	*(*uint8)(unsafe.Pointer(zIn)) = *(*uint8)(unsafe.Pointer(zIn + uintptr(1)))
  12764 	zIn++
  12765 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))) = temp
  12766 	goto __3
  12767 __4:
  12768 	;
  12769 	(*Mem)(unsafe.Pointer(pMem)).Fenc = desiredEnc
  12770 	goto translate_out
  12771 __1:
  12772 	;
  12773 	if !(int32(desiredEnc) == SQLITE_UTF8) {
  12774 		goto __5
  12775 	}
  12776 
  12777 	*(*int32)(unsafe.Pointer(pMem + 12)) &= libc.CplInt32(1)
  12778 	len = int64(2)*Sqlite3_int64((*Mem)(unsafe.Pointer(pMem)).Fn) + int64(1)
  12779 	goto __6
  12780 __5:
  12781 	len = int64(2)*Sqlite3_int64((*Mem)(unsafe.Pointer(pMem)).Fn) + int64(2)
  12782 __6:
  12783 	;
  12784 	zIn = (*Mem)(unsafe.Pointer(pMem)).Fz
  12785 	zTerm = zIn + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn)
  12786 	zOut = Xsqlite3DbMallocRaw(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, uint64(len))
  12787 	if !!(zOut != 0) {
  12788 		goto __7
  12789 	}
  12790 	return SQLITE_NOMEM
  12791 __7:
  12792 	;
  12793 	z = zOut
  12794 
  12795 	if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == SQLITE_UTF8) {
  12796 		goto __8
  12797 	}
  12798 	if !(int32(desiredEnc) == SQLITE_UTF16LE) {
  12799 		goto __10
  12800 	}
  12801 
  12802 __12:
  12803 	if !(zIn < zTerm) {
  12804 		goto __13
  12805 	}
  12806 	c = uint32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
  12807 	if !(c >= uint32(0xc0)) {
  12808 		goto __14
  12809 	}
  12810 	c = uint32(sqlite3Utf8Trans1[c-uint32(0xc0)])
  12811 __15:
  12812 	if !(zIn != zTerm && int32(*(*uint8)(unsafe.Pointer(zIn)))&0xc0 == 0x80) {
  12813 		goto __16
  12814 	}
  12815 	c = c<<6 + uint32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))))
  12816 	goto __15
  12817 __16:
  12818 	;
  12819 	if !(c < uint32(0x80) || c&0xFFFFF800 == uint32(0xD800) || c&0xFFFFFFFE == uint32(0xFFFE)) {
  12820 		goto __17
  12821 	}
  12822 	c = uint32(0xFFFD)
  12823 __17:
  12824 	;
  12825 __14:
  12826 	;
  12827 	if !(c <= uint32(0xFFFF)) {
  12828 		goto __18
  12829 	}
  12830 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c & uint32(0x00FF))
  12831 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c >> 8 & uint32(0x00FF))
  12832 	goto __19
  12833 __18:
  12834 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c>>10&uint32(0x003F) + (c-uint32(0x10000))>>10&uint32(0x00C0))
  12835 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(uint32(0x00D8) + (c-uint32(0x10000))>>18&uint32(0x03))
  12836 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c & uint32(0x00FF))
  12837 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(uint32(0x00DC) + c>>8&uint32(0x03))
  12838 __19:
  12839 	;
  12840 	goto __12
  12841 __13:
  12842 	;
  12843 	goto __11
  12844 __10:
  12845 	;
  12846 __20:
  12847 	if !(zIn < zTerm) {
  12848 		goto __21
  12849 	}
  12850 	c = uint32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
  12851 	if !(c >= uint32(0xc0)) {
  12852 		goto __22
  12853 	}
  12854 	c = uint32(sqlite3Utf8Trans1[c-uint32(0xc0)])
  12855 __23:
  12856 	if !(zIn != zTerm && int32(*(*uint8)(unsafe.Pointer(zIn)))&0xc0 == 0x80) {
  12857 		goto __24
  12858 	}
  12859 	c = c<<6 + uint32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))))
  12860 	goto __23
  12861 __24:
  12862 	;
  12863 	if !(c < uint32(0x80) || c&0xFFFFF800 == uint32(0xD800) || c&0xFFFFFFFE == uint32(0xFFFE)) {
  12864 		goto __25
  12865 	}
  12866 	c = uint32(0xFFFD)
  12867 __25:
  12868 	;
  12869 __22:
  12870 	;
  12871 	if !(c <= uint32(0xFFFF)) {
  12872 		goto __26
  12873 	}
  12874 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c >> 8 & uint32(0x00FF))
  12875 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c & uint32(0x00FF))
  12876 	goto __27
  12877 __26:
  12878 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(uint32(0x00D8) + (c-uint32(0x10000))>>18&uint32(0x03))
  12879 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c>>10&uint32(0x003F) + (c-uint32(0x10000))>>10&uint32(0x00C0))
  12880 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(uint32(0x00DC) + c>>8&uint32(0x03))
  12881 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c & uint32(0x00FF))
  12882 __27:
  12883 	;
  12884 	goto __20
  12885 __21:
  12886 	;
  12887 __11:
  12888 	;
  12889 	(*Mem)(unsafe.Pointer(pMem)).Fn = (int32(z) - int32(zOut)) / 1
  12890 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0)
  12891 	goto __9
  12892 __8:
  12893 	;
  12894 	if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == SQLITE_UTF16LE) {
  12895 		goto __28
  12896 	}
  12897 
  12898 __30:
  12899 	if !(zIn < zTerm) {
  12900 		goto __31
  12901 	}
  12902 	c = uint32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
  12903 	c = c + uint32(int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))<<8)
  12904 	if !(c >= uint32(0xd800) && c < uint32(0xe000)) {
  12905 		goto __32
  12906 	}
  12907 	if !(zIn < zTerm) {
  12908 		goto __33
  12909 	}
  12910 	c2 = int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
  12911 	c2 = c2 + int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))<<8
  12912 	c = uint32(c2&0x03FF) + c&uint32(0x003F)<<10 + (c&uint32(0x03C0)+uint32(0x0040))<<10
  12913 __33:
  12914 	;
  12915 __32:
  12916 	;
  12917 	if !(c < uint32(0x00080)) {
  12918 		goto __34
  12919 	}
  12920 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c & uint32(0xFF))
  12921 	goto __35
  12922 __34:
  12923 	if !(c < uint32(0x00800)) {
  12924 		goto __36
  12925 	}
  12926 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0xC0 + int32(U8(c>>6&uint32(0x1F))))
  12927 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  12928 	goto __37
  12929 __36:
  12930 	if !(c < uint32(0x10000)) {
  12931 		goto __38
  12932 	}
  12933 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0xE0 + int32(U8(c>>12&uint32(0x0F))))
  12934 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c>>6&uint32(0x3F))))
  12935 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  12936 	goto __39
  12937 __38:
  12938 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0xF0 + int32(U8(c>>18&uint32(0x07))))
  12939 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c>>12&uint32(0x3F))))
  12940 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c>>6&uint32(0x3F))))
  12941 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  12942 __39:
  12943 	;
  12944 __37:
  12945 	;
  12946 __35:
  12947 	;
  12948 	goto __30
  12949 __31:
  12950 	;
  12951 	goto __29
  12952 __28:
  12953 __40:
  12954 	if !(zIn < zTerm) {
  12955 		goto __41
  12956 	}
  12957 	c = uint32(int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))) << 8)
  12958 	c = c + uint32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
  12959 	if !(c >= uint32(0xd800) && c < uint32(0xe000)) {
  12960 		goto __42
  12961 	}
  12962 	if !(zIn < zTerm) {
  12963 		goto __43
  12964 	}
  12965 	c21 = int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))) << 8
  12966 	c21 = c21 + int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
  12967 	c = uint32(c21&0x03FF) + c&uint32(0x003F)<<10 + (c&uint32(0x03C0)+uint32(0x0040))<<10
  12968 __43:
  12969 	;
  12970 __42:
  12971 	;
  12972 	if !(c < uint32(0x00080)) {
  12973 		goto __44
  12974 	}
  12975 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = U8(c & uint32(0xFF))
  12976 	goto __45
  12977 __44:
  12978 	if !(c < uint32(0x00800)) {
  12979 		goto __46
  12980 	}
  12981 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0xC0 + int32(U8(c>>6&uint32(0x1F))))
  12982 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  12983 	goto __47
  12984 __46:
  12985 	if !(c < uint32(0x10000)) {
  12986 		goto __48
  12987 	}
  12988 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0xE0 + int32(U8(c>>12&uint32(0x0F))))
  12989 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c>>6&uint32(0x3F))))
  12990 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  12991 	goto __49
  12992 __48:
  12993 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0xF0 + int32(U8(c>>18&uint32(0x07))))
  12994 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c>>12&uint32(0x3F))))
  12995 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c>>6&uint32(0x3F))))
  12996 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  12997 __49:
  12998 	;
  12999 __47:
  13000 	;
  13001 __45:
  13002 	;
  13003 	goto __40
  13004 __41:
  13005 	;
  13006 __29:
  13007 	;
  13008 	(*Mem)(unsafe.Pointer(pMem)).Fn = (int32(z) - int32(zOut)) / 1
  13009 __9:
  13010 	;
  13011 	*(*uint8)(unsafe.Pointer(z)) = uint8(0)
  13012 
  13013 	c = uint32(MEM_Str | MEM_Term | int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_AffMask|MEM_Subtype))
  13014 	Xsqlite3VdbeMemRelease(tls, pMem)
  13015 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(c)
  13016 	(*Mem)(unsafe.Pointer(pMem)).Fenc = desiredEnc
  13017 	(*Mem)(unsafe.Pointer(pMem)).Fz = zOut
  13018 	(*Mem)(unsafe.Pointer(pMem)).FzMalloc = (*Mem)(unsafe.Pointer(pMem)).Fz
  13019 	(*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).Fz)
  13020 
  13021 translate_out:
  13022 	return SQLITE_OK
  13023 }
  13024 
  13025 // This routine checks for a byte-order mark at the beginning of the
  13026 // UTF-16 string stored in *pMem. If one is present, it is removed and
  13027 // the encoding of the Mem adjusted. This routine does not do any
  13028 // byte-swapping, it just sets Mem.enc appropriately.
  13029 //
  13030 // The allocation (static, dynamic etc.) and encoding of the Mem may be
  13031 // changed by this function.
  13032 func Xsqlite3VdbeMemHandleBom(tls *libc.TLS, pMem uintptr) int32 {
  13033 	var rc int32 = SQLITE_OK
  13034 	var bom U8 = U8(0)
  13035 
  13036 	if (*Mem)(unsafe.Pointer(pMem)).Fn > 1 {
  13037 		var b1 U8 = *(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz))
  13038 		var b2 U8 = *(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(1)))
  13039 		if int32(b1) == 0xFE && int32(b2) == 0xFF {
  13040 			bom = U8(SQLITE_UTF16BE)
  13041 		}
  13042 		if int32(b1) == 0xFF && int32(b2) == 0xFE {
  13043 			bom = U8(SQLITE_UTF16LE)
  13044 		}
  13045 	}
  13046 
  13047 	if bom != 0 {
  13048 		rc = Xsqlite3VdbeMemMakeWriteable(tls, pMem)
  13049 		if rc == SQLITE_OK {
  13050 			*(*int32)(unsafe.Pointer(pMem + 12)) -= 2
  13051 			libc.Xmemmove(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, (*Mem)(unsafe.Pointer(pMem)).Fz+2, uint32((*Mem)(unsafe.Pointer(pMem)).Fn))
  13052 			*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn))) = uint8(0)
  13053 			*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn+1))) = uint8(0)
  13054 			*(*U16)(unsafe.Pointer(pMem + 16)) |= U16(MEM_Term)
  13055 			(*Mem)(unsafe.Pointer(pMem)).Fenc = bom
  13056 		}
  13057 	}
  13058 	return rc
  13059 }
  13060 
  13061 // pZ is a UTF-8 encoded unicode string. If nByte is less than zero,
  13062 // return the number of unicode characters in pZ up to (but not including)
  13063 // the first 0x00 byte. If nByte is not less than zero, return the
  13064 // number of unicode characters in the first nByte of pZ (or up to
  13065 // the first 0x00, whichever comes first).
  13066 func Xsqlite3Utf8CharLen(tls *libc.TLS, zIn uintptr, nByte int32) int32 {
  13067 	var r int32 = 0
  13068 	var z uintptr = zIn
  13069 	var zTerm uintptr
  13070 	if nByte >= 0 {
  13071 		zTerm = z + uintptr(nByte)
  13072 	} else {
  13073 		zTerm = libc.UintptrFromInt32(-1)
  13074 	}
  13075 
  13076 	for int32(*(*U8)(unsafe.Pointer(z))) != 0 && z < zTerm {
  13077 		{
  13078 			if int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) >= 0xc0 {
  13079 				for int32(*(*U8)(unsafe.Pointer(z)))&0xc0 == 0x80 {
  13080 					z++
  13081 				}
  13082 			}
  13083 		}
  13084 
  13085 		r++
  13086 	}
  13087 	return r
  13088 }
  13089 
  13090 // Convert a UTF-16 string in the native encoding into a UTF-8 string.
  13091 // Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must
  13092 // be freed by the calling function.
  13093 //
  13094 // NULL is returned if there is an allocation error.
  13095 func Xsqlite3Utf16to8(tls *libc.TLS, db uintptr, z uintptr, nByte int32, enc U8) uintptr {
  13096 	bp := tls.Alloc(40)
  13097 	defer tls.Free(40)
  13098 
  13099 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Mem{})))
  13100 	(*Mem)(unsafe.Pointer(bp)).Fdb = db
  13101 	Xsqlite3VdbeMemSetStr(tls, bp, z, int64(nByte), enc, uintptr(0))
  13102 	Xsqlite3VdbeChangeEncoding(tls, bp, SQLITE_UTF8)
  13103 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  13104 		Xsqlite3VdbeMemRelease(tls, bp)
  13105 		(*Mem)(unsafe.Pointer(bp)).Fz = uintptr(0)
  13106 	}
  13107 
  13108 	return (*Mem)(unsafe.Pointer(bp)).Fz
  13109 }
  13110 
  13111 // zIn is a UTF-16 encoded unicode string at least nChar characters long.
  13112 // Return the number of bytes in the first nChar unicode characters
  13113 // in pZ.  nChar must be non-negative.
  13114 func Xsqlite3Utf16ByteLen(tls *libc.TLS, zIn uintptr, nChar int32) int32 {
  13115 	var c int32
  13116 	var z uintptr = zIn
  13117 	var n int32 = 0
  13118 
  13119 	if SQLITE_UTF16LE == SQLITE_UTF16LE {
  13120 		z++
  13121 	}
  13122 	for n < nChar {
  13123 		c = int32(*(*uint8)(unsafe.Pointer(z)))
  13124 		z += uintptr(2)
  13125 		if c >= 0xd8 && c < 0xdc && int32(*(*uint8)(unsafe.Pointer(z))) >= 0xdc && int32(*(*uint8)(unsafe.Pointer(z))) < 0xe0 {
  13126 			z += uintptr(2)
  13127 		}
  13128 		n++
  13129 	}
  13130 	return (int32(z)-int32(zIn))/1 -
  13131 		libc.Bool32(SQLITE_UTF16LE == SQLITE_UTF16LE)
  13132 }
  13133 
  13134 // Define the following typedefs.
  13135 //
  13136 //	    float_t	floating-point type at least as wide as `float' used
  13137 //			to evaluate `float' expressions
  13138 //	    double_t	floating-point type at least as wide as `double' used
  13139 //			to evaluate `double' expressions
  13140 type Float_t = float32
  13141 type Double_t = float64
  13142 
  13143 // Calls to sqlite3FaultSim() are used to simulate a failure during testing,
  13144 // or to bypass normal error detection during testing in order to let
  13145 // execute proceed futher downstream.
  13146 //
  13147 // In deployment, sqlite3FaultSim() *always* return SQLITE_OK (0).  The
  13148 // sqlite3FaultSim() function only returns non-zero during testing.
  13149 //
  13150 // During testing, if the test harness has set a fault-sim callback using
  13151 // a call to sqlite3_test_control(SQLITE_TESTCTRL_FAULT_INSTALL), then
  13152 // each call to sqlite3FaultSim() is relayed to that application-supplied
  13153 // callback and the integer return value form the application-supplied
  13154 // callback is returned by sqlite3FaultSim().
  13155 //
  13156 // The integer argument to sqlite3FaultSim() is a code to identify which
  13157 // sqlite3FaultSim() instance is being invoked. Each call to sqlite3FaultSim()
  13158 // should have a unique code.  To prevent legacy testing applications from
  13159 // breaking, the codes should not be changed or reused.
  13160 func Xsqlite3FaultSim(tls *libc.TLS, iTest int32) int32 {
  13161 	var xCallback uintptr = Xsqlite3Config.FxTestCallback
  13162 	if xCallback != 0 {
  13163 		return (*struct{ f func(*libc.TLS, int32) int32 })(unsafe.Pointer(&struct{ uintptr }{xCallback})).f(tls, iTest)
  13164 	}
  13165 	return SQLITE_OK
  13166 }
  13167 
  13168 // Return true if the floating point value is Not a Number (NaN).
  13169 //
  13170 // Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.
  13171 // Otherwise, we have our own implementation that works on most systems.
  13172 func Xsqlite3IsNaN(tls *libc.TLS, x float64) int32 {
  13173 	bp := tls.Alloc(16)
  13174 	defer tls.Free(16)
  13175 	*(*float64)(unsafe.Pointer(bp + 8)) = x
  13176 
  13177 	var rc int32
  13178 
  13179 	libc.Xmemcpy(tls, bp, bp+8, uint32(unsafe.Sizeof(U64(0))))
  13180 	rc = libc.Bool32(*(*U64)(unsafe.Pointer(bp))&(uint64(0x7ff)<<52) == uint64(0x7ff)<<52 && *(*U64)(unsafe.Pointer(bp))&(uint64(1)<<52-uint64(1)) != uint64(0))
  13181 
  13182 	return rc
  13183 }
  13184 
  13185 // Compute a string length that is limited to what can be stored in
  13186 // lower 30 bits of a 32-bit signed integer.
  13187 //
  13188 // The value returned will never be negative.  Nor will it ever be greater
  13189 // than the actual length of the string.  For very long strings (greater
  13190 // than 1GiB) the value returned might be less than the true string length.
  13191 func Xsqlite3Strlen30(tls *libc.TLS, z uintptr) int32 {
  13192 	if z == uintptr(0) {
  13193 		return 0
  13194 	}
  13195 	return 0x3fffffff & int32(libc.Xstrlen(tls, z))
  13196 }
  13197 
  13198 // Return the declared type of a column.  Or return zDflt if the column
  13199 // has no declared type.
  13200 //
  13201 // The column type is an extra string stored after the zero-terminator on
  13202 // the column name if and only if the COLFLAG_HASTYPE flag is set.
  13203 func Xsqlite3ColumnType(tls *libc.TLS, pCol uintptr, zDflt uintptr) uintptr {
  13204 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_HASTYPE != 0 {
  13205 		return (*Column)(unsafe.Pointer(pCol)).FzCnName + uintptr(libc.Xstrlen(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName)) + uintptr(1)
  13206 	} else if uint32(int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf0>>4)) != 0 {
  13207 		return Xsqlite3StdType[(int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf0>>4)-1)&0xf<<28>>28]
  13208 	} else {
  13209 		return zDflt
  13210 	}
  13211 	return uintptr(0)
  13212 }
  13213 
  13214 func sqlite3ErrorFinish(tls *libc.TLS, db uintptr, err_code int32) {
  13215 	if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 {
  13216 		Xsqlite3ValueSetNull(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
  13217 	}
  13218 	Xsqlite3SystemError(tls, db, err_code)
  13219 }
  13220 
  13221 // Set the current error code to err_code and clear any prior error message.
  13222 // Also set iSysErrno (by calling sqlite3System) if the err_code indicates
  13223 // that would be appropriate.
  13224 func Xsqlite3Error(tls *libc.TLS, db uintptr, err_code int32) {
  13225 	(*Sqlite3)(unsafe.Pointer(db)).FerrCode = err_code
  13226 	if err_code != 0 || (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 {
  13227 		sqlite3ErrorFinish(tls, db, err_code)
  13228 	} else {
  13229 		(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = -1
  13230 	}
  13231 }
  13232 
  13233 // The equivalent of sqlite3Error(db, SQLITE_OK).  Clear the error state
  13234 // and error message.
  13235 func Xsqlite3ErrorClear(tls *libc.TLS, db uintptr) {
  13236 	(*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_OK
  13237 	(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = -1
  13238 	if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 {
  13239 		Xsqlite3ValueSetNull(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
  13240 	}
  13241 }
  13242 
  13243 // Load the sqlite3.iSysErrno field if that is an appropriate thing
  13244 // to do based on the SQLite error code in rc.
  13245 func Xsqlite3SystemError(tls *libc.TLS, db uintptr, rc int32) {
  13246 	if rc == SQLITE_IOERR|int32(12)<<8 {
  13247 		return
  13248 	}
  13249 	rc = rc & 0xff
  13250 	if rc == SQLITE_CANTOPEN || rc == SQLITE_IOERR {
  13251 		(*Sqlite3)(unsafe.Pointer(db)).FiSysErrno = Xsqlite3OsGetLastError(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs)
  13252 	}
  13253 }
  13254 
  13255 // Set the most recent error code and error string for the sqlite
  13256 // handle "db". The error code is set to "err_code".
  13257 //
  13258 // If it is not NULL, string zFormat specifies the format of the
  13259 // error string.  zFormat and any string tokens that follow it are
  13260 // assumed to be encoded in UTF-8.
  13261 //
  13262 // To clear the most recent error for sqlite handle "db", sqlite3Error
  13263 // should be called with err_code set to SQLITE_OK and zFormat set
  13264 // to NULL.
  13265 func Xsqlite3ErrorWithMsg(tls *libc.TLS, db uintptr, err_code int32, zFormat uintptr, va uintptr) {
  13266 	(*Sqlite3)(unsafe.Pointer(db)).FerrCode = err_code
  13267 	Xsqlite3SystemError(tls, db, err_code)
  13268 	if zFormat == uintptr(0) {
  13269 		Xsqlite3Error(tls, db, err_code)
  13270 	} else if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 || libc.AssignPtrUintptr(db+304, Xsqlite3ValueNew(tls, db)) != uintptr(0) {
  13271 		var z uintptr
  13272 		var ap Va_list
  13273 		_ = ap
  13274 		ap = va
  13275 		z = Xsqlite3VMPrintf(tls, db, zFormat, ap)
  13276 		_ = ap
  13277 		Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, z, uint8(SQLITE_UTF8), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  13278 	}
  13279 }
  13280 
  13281 // Check for interrupts and invoke progress callback.
  13282 func Xsqlite3ProgressCheck(tls *libc.TLS, p uintptr) {
  13283 	var db uintptr = (*Parse)(unsafe.Pointer(p)).Fdb
  13284 	if libc.AtomicLoadNInt32(db+312, 0) != 0 {
  13285 		(*Parse)(unsafe.Pointer(p)).FnErr++
  13286 		(*Parse)(unsafe.Pointer(p)).Frc = SQLITE_INTERRUPT
  13287 	}
  13288 	if (*Sqlite3)(unsafe.Pointer(db)).FxProgress != 0 && libc.PreIncUint32(&(*Parse)(unsafe.Pointer(p)).FnProgressSteps, 1) >= (*Sqlite3)(unsafe.Pointer(db)).FnProgressOps {
  13289 		if (*struct {
  13290 			f func(*libc.TLS, uintptr) int32
  13291 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxProgress})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 {
  13292 			(*Parse)(unsafe.Pointer(p)).FnErr++
  13293 			(*Parse)(unsafe.Pointer(p)).Frc = SQLITE_INTERRUPT
  13294 		}
  13295 		(*Parse)(unsafe.Pointer(p)).FnProgressSteps = U32(0)
  13296 	}
  13297 }
  13298 
  13299 // Add an error message to pParse->zErrMsg and increment pParse->nErr.
  13300 //
  13301 // This function should be used to report any error that occurs while
  13302 // compiling an SQL statement (i.e. within sqlite3_prepare()). The
  13303 // last thing the sqlite3_prepare() function does is copy the error
  13304 // stored by this function into the database handle using sqlite3Error().
  13305 // Functions sqlite3Error() or sqlite3ErrorWithMsg() should be used
  13306 // during statement execution (sqlite3_step() etc.).
  13307 func Xsqlite3ErrorMsg(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) {
  13308 	var zMsg uintptr
  13309 	var ap Va_list
  13310 	_ = ap
  13311 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  13312 
  13313 	(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = -2
  13314 	ap = va
  13315 	zMsg = Xsqlite3VMPrintf(tls, db, zFormat, ap)
  13316 	_ = ap
  13317 	if (*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset < -1 {
  13318 		(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = -1
  13319 	}
  13320 	if (*Sqlite3)(unsafe.Pointer(db)).FsuppressErr != 0 {
  13321 		Xsqlite3DbFree(tls, db, zMsg)
  13322 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  13323 			(*Parse)(unsafe.Pointer(pParse)).FnErr++
  13324 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
  13325 		}
  13326 	} else {
  13327 		(*Parse)(unsafe.Pointer(pParse)).FnErr++
  13328 		Xsqlite3DbFree(tls, db, (*Parse)(unsafe.Pointer(pParse)).FzErrMsg)
  13329 		(*Parse)(unsafe.Pointer(pParse)).FzErrMsg = zMsg
  13330 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR
  13331 		(*Parse)(unsafe.Pointer(pParse)).FpWith = uintptr(0)
  13332 	}
  13333 }
  13334 
  13335 // If database connection db is currently parsing SQL, then transfer
  13336 // error code errCode to that parser if the parser has not already
  13337 // encountered some other kind of error.
  13338 func Xsqlite3ErrorToParser(tls *libc.TLS, db uintptr, errCode int32) int32 {
  13339 	var pParse uintptr
  13340 	if db == uintptr(0) || libc.AssignUintptr(&pParse, (*Sqlite3)(unsafe.Pointer(db)).FpParse) == uintptr(0) {
  13341 		return errCode
  13342 	}
  13343 	(*Parse)(unsafe.Pointer(pParse)).Frc = errCode
  13344 	(*Parse)(unsafe.Pointer(pParse)).FnErr++
  13345 	return errCode
  13346 }
  13347 
  13348 // Convert an SQL-style quoted string into a normal string by removing
  13349 // the quote characters.  The conversion is done in-place.  If the
  13350 // input does not begin with a quote character, then this routine
  13351 // is a no-op.
  13352 //
  13353 // The input string must be zero-terminated.  A new zero-terminator
  13354 // is added to the dequoted string.
  13355 //
  13356 // The return value is -1 if no dequoting occurs or the length of the
  13357 // dequoted string, exclusive of the zero terminator, if dequoting does
  13358 // occur.
  13359 //
  13360 // 2002-02-14: This routine is extended to remove MS-Access style
  13361 // brackets from around identifiers.  For example:  "[a-b-c]" becomes
  13362 // "a-b-c".
  13363 func Xsqlite3Dequote(tls *libc.TLS, z uintptr) {
  13364 	var quote uint8
  13365 	var i int32
  13366 	var j int32
  13367 	if z == uintptr(0) {
  13368 		return
  13369 	}
  13370 	quote = *(*uint8)(unsafe.Pointer(z))
  13371 	if !(int32(Xsqlite3CtypeMap[quote])&0x80 != 0) {
  13372 		return
  13373 	}
  13374 	if int32(quote) == '[' {
  13375 		quote = uint8(']')
  13376 	}
  13377 	i = 1
  13378 	j = 0
  13379 	for ; ; i++ {
  13380 		if int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == int32(quote) {
  13381 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))) == int32(quote) {
  13382 				*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = quote
  13383 				i++
  13384 			} else {
  13385 				break
  13386 			}
  13387 		} else {
  13388 			*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = *(*uint8)(unsafe.Pointer(z + uintptr(i)))
  13389 		}
  13390 	}
  13391 	*(*uint8)(unsafe.Pointer(z + uintptr(j))) = uint8(0)
  13392 }
  13393 
  13394 func Xsqlite3DequoteExpr(tls *libc.TLS, p uintptr) {
  13395 	*(*U32)(unsafe.Pointer(p + 4)) |= func() uint32 {
  13396 		if int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8))))) == '"' {
  13397 			return uint32(EP_Quoted | EP_DblQuoted)
  13398 		}
  13399 		return uint32(EP_Quoted)
  13400 	}()
  13401 	Xsqlite3Dequote(tls, *(*uintptr)(unsafe.Pointer(p + 8)))
  13402 }
  13403 
  13404 // If the input token p is quoted, try to adjust the token to remove
  13405 // the quotes.  This is not always possible:
  13406 //
  13407 //	"abc"     ->   abc
  13408 //	"ab""cd"  ->   (not possible because of the interior "")
  13409 //
  13410 // Remove the quotes if possible.  This is a optimization.  The overall
  13411 // system should still return the correct answer even if this routine
  13412 // is always a no-op.
  13413 func Xsqlite3DequoteToken(tls *libc.TLS, p uintptr) {
  13414 	var i uint32
  13415 	if (*Token)(unsafe.Pointer(p)).Fn < uint32(2) {
  13416 		return
  13417 	}
  13418 	if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(p)).Fz))])&0x80 != 0) {
  13419 		return
  13420 	}
  13421 	for i = uint32(1); i < (*Token)(unsafe.Pointer(p)).Fn-uint32(1); i++ {
  13422 		if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(p)).Fz + uintptr(i)))])&0x80 != 0 {
  13423 			return
  13424 		}
  13425 	}
  13426 	*(*uint32)(unsafe.Pointer(p + 4)) -= uint32(2)
  13427 	(*Token)(unsafe.Pointer(p)).Fz++
  13428 }
  13429 
  13430 // Generate a Token object from a string
  13431 func Xsqlite3TokenInit(tls *libc.TLS, p uintptr, z uintptr) {
  13432 	(*Token)(unsafe.Pointer(p)).Fz = z
  13433 	(*Token)(unsafe.Pointer(p)).Fn = uint32(Xsqlite3Strlen30(tls, z))
  13434 }
  13435 
  13436 // Some systems have stricmp().  Others have strcasecmp().  Because
  13437 // there is no consistency, we will define our own.
  13438 //
  13439 // IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and
  13440 // sqlite3_strnicmp() APIs allow applications and extensions to compare
  13441 // the contents of two buffers containing UTF-8 strings in a
  13442 // case-independent fashion, using the same definition of "case
  13443 // independence" that SQLite uses internally when comparing identifiers.
  13444 func Xsqlite3_stricmp(tls *libc.TLS, zLeft uintptr, zRight uintptr) int32 {
  13445 	if zLeft == uintptr(0) {
  13446 		if zRight != 0 {
  13447 			return -1
  13448 		}
  13449 		return 0
  13450 	} else if zRight == uintptr(0) {
  13451 		return 1
  13452 	}
  13453 	return Xsqlite3StrICmp(tls, zLeft, zRight)
  13454 }
  13455 
  13456 func Xsqlite3StrICmp(tls *libc.TLS, zLeft uintptr, zRight uintptr) int32 {
  13457 	var a uintptr
  13458 	var b uintptr
  13459 	var c int32
  13460 	var x int32
  13461 	a = zLeft
  13462 	b = zRight
  13463 	for {
  13464 		c = int32(*(*uint8)(unsafe.Pointer(a)))
  13465 		x = int32(*(*uint8)(unsafe.Pointer(b)))
  13466 		if c == x {
  13467 			if c == 0 {
  13468 				break
  13469 			}
  13470 		} else {
  13471 			c = int32(Xsqlite3UpperToLower[c]) - int32(Xsqlite3UpperToLower[x])
  13472 			if c != 0 {
  13473 				break
  13474 			}
  13475 		}
  13476 		a++
  13477 		b++
  13478 	}
  13479 	return c
  13480 }
  13481 
  13482 func Xsqlite3_strnicmp(tls *libc.TLS, zLeft uintptr, zRight uintptr, N int32) int32 {
  13483 	var a uintptr
  13484 	var b uintptr
  13485 	if zLeft == uintptr(0) {
  13486 		if zRight != 0 {
  13487 			return -1
  13488 		}
  13489 		return 0
  13490 	} else if zRight == uintptr(0) {
  13491 		return 1
  13492 	}
  13493 	a = zLeft
  13494 	b = zRight
  13495 	for libc.PostDecInt32(&N, 1) > 0 && int32(*(*uint8)(unsafe.Pointer(a))) != 0 && int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(a))]) == int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(b))]) {
  13496 		a++
  13497 		b++
  13498 	}
  13499 	if N < 0 {
  13500 		return 0
  13501 	}
  13502 	return int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(a))]) - int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(b))])
  13503 }
  13504 
  13505 // Compute an 8-bit hash on a string that is insensitive to case differences
  13506 func Xsqlite3StrIHash(tls *libc.TLS, z uintptr) U8 {
  13507 	var h U8 = U8(0)
  13508 	if z == uintptr(0) {
  13509 		return U8(0)
  13510 	}
  13511 	for *(*uint8)(unsafe.Pointer(z)) != 0 {
  13512 		h = U8(int32(h) + int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(z))]))
  13513 		z++
  13514 	}
  13515 	return h
  13516 }
  13517 
  13518 func sqlite3Pow10(tls *libc.TLS, E int32) float64 {
  13519 	var x float64 = 10.0
  13520 	var r float64 = 1.0
  13521 	for 1 != 0 {
  13522 		if E&1 != 0 {
  13523 			r = r * x
  13524 		}
  13525 		E >>= 1
  13526 		if E == 0 {
  13527 			break
  13528 		}
  13529 		x = x * x
  13530 	}
  13531 	return r
  13532 }
  13533 
  13534 // The string z[] is an text representation of a real number.
  13535 // Convert this string to a double and write it into *pResult.
  13536 //
  13537 // The string z[] is length bytes in length (bytes, not characters) and
  13538 // uses the encoding enc.  The string is not necessarily zero-terminated.
  13539 //
  13540 // Return TRUE if the result is a valid real number (or integer) and FALSE
  13541 // if the string is empty or contains extraneous text.  More specifically
  13542 // return
  13543 //
  13544 //	 1          =>  The input string is a pure integer
  13545 //	 2 or more  =>  The input has a decimal point or eNNN clause
  13546 //	 0 or less  =>  The input string is not a valid number
  13547 //	-1          =>  Not a valid number, but has a valid prefix which
  13548 //	                includes a decimal point and/or an eNNN clause
  13549 //
  13550 // Valid numbers are in one of these formats:
  13551 //
  13552 //	[+-]digits[E[+-]digits]
  13553 //	[+-]digits.[digits][E[+-]digits]
  13554 //	[+-].digits[E[+-]digits]
  13555 //
  13556 // Leading and trailing whitespace is ignored for the purpose of determining
  13557 // validity.
  13558 //
  13559 // If some prefix of the input string is a valid number, this routine
  13560 // returns FALSE but it still converts the prefix and writes the result
  13561 // into *pResult.
  13562 func Xsqlite3AtoF(tls *libc.TLS, z uintptr, pResult uintptr, length int32, enc U8) int32 {
  13563 	var incr int32
  13564 	var zEnd uintptr
  13565 
  13566 	var sign int32
  13567 	var s I64
  13568 	var d int32
  13569 	var esign int32
  13570 	var e int32
  13571 	var eValid int32
  13572 	var result float64
  13573 	var nDigit int32
  13574 	var eType int32
  13575 	var i int32
  13576 	var scale float64
  13577 	var scale1 float64
  13578 	sign = 1
  13579 	s = int64(0)
  13580 	d = 0
  13581 	esign = 1
  13582 	e = 0
  13583 	eValid = 1
  13584 	nDigit = 0
  13585 	eType = 1
  13586 
  13587 	*(*float64)(unsafe.Pointer(pResult)) = 0.0
  13588 	if !(length == 0) {
  13589 		goto __1
  13590 	}
  13591 	return 0
  13592 __1:
  13593 	;
  13594 	if !(int32(enc) == SQLITE_UTF8) {
  13595 		goto __2
  13596 	}
  13597 	incr = 1
  13598 	zEnd = z + uintptr(length)
  13599 	goto __3
  13600 __2:
  13601 	incr = 2
  13602 	length = length & libc.CplInt32(1)
  13603 
  13604 	i = 3 - int32(enc)
  13605 __4:
  13606 	if !(i < length && int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 0) {
  13607 		goto __6
  13608 	}
  13609 	goto __5
  13610 __5:
  13611 	i = i + 2
  13612 	goto __4
  13613 	goto __6
  13614 __6:
  13615 	;
  13616 	if !(i < length) {
  13617 		goto __7
  13618 	}
  13619 	eType = -100
  13620 __7:
  13621 	;
  13622 	zEnd = z + uintptr(i^1)
  13623 	z += uintptr(int32(enc) & 1)
  13624 __3:
  13625 	;
  13626 __8:
  13627 	if !(z < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x01 != 0) {
  13628 		goto __9
  13629 	}
  13630 	z += uintptr(incr)
  13631 	goto __8
  13632 __9:
  13633 	;
  13634 	if !(z >= zEnd) {
  13635 		goto __10
  13636 	}
  13637 	return 0
  13638 __10:
  13639 	;
  13640 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == '-') {
  13641 		goto __11
  13642 	}
  13643 	sign = -1
  13644 	z += uintptr(incr)
  13645 	goto __12
  13646 __11:
  13647 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == '+') {
  13648 		goto __13
  13649 	}
  13650 	z += uintptr(incr)
  13651 __13:
  13652 	;
  13653 __12:
  13654 	;
  13655 __14:
  13656 	if !(z < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x04 != 0) {
  13657 		goto __15
  13658 	}
  13659 	s = s*int64(10) + I64(int32(*(*uint8)(unsafe.Pointer(z)))-'0')
  13660 	z += uintptr(incr)
  13661 	nDigit++
  13662 	if !(s >= (int64(0xffffffff)|int64(0x7fffffff)<<32-int64(9))/int64(10)) {
  13663 		goto __16
  13664 	}
  13665 
  13666 __17:
  13667 	if !(z < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x04 != 0) {
  13668 		goto __18
  13669 	}
  13670 	z += uintptr(incr)
  13671 	d++
  13672 	goto __17
  13673 __18:
  13674 	;
  13675 __16:
  13676 	;
  13677 	goto __14
  13678 __15:
  13679 	;
  13680 	if !(z >= zEnd) {
  13681 		goto __19
  13682 	}
  13683 	goto do_atof_calc
  13684 __19:
  13685 	;
  13686 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == '.') {
  13687 		goto __20
  13688 	}
  13689 	z += uintptr(incr)
  13690 	eType++
  13691 
  13692 __21:
  13693 	if !(z < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x04 != 0) {
  13694 		goto __22
  13695 	}
  13696 	if !(s < (int64(0xffffffff)|int64(0x7fffffff)<<32-int64(9))/int64(10)) {
  13697 		goto __23
  13698 	}
  13699 	s = s*int64(10) + I64(int32(*(*uint8)(unsafe.Pointer(z)))-'0')
  13700 	d--
  13701 	nDigit++
  13702 __23:
  13703 	;
  13704 	z += uintptr(incr)
  13705 	goto __21
  13706 __22:
  13707 	;
  13708 __20:
  13709 	;
  13710 	if !(z >= zEnd) {
  13711 		goto __24
  13712 	}
  13713 	goto do_atof_calc
  13714 __24:
  13715 	;
  13716 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == 'e' || int32(*(*uint8)(unsafe.Pointer(z))) == 'E') {
  13717 		goto __25
  13718 	}
  13719 	z += uintptr(incr)
  13720 	eValid = 0
  13721 	eType++
  13722 
  13723 	if !(z >= zEnd) {
  13724 		goto __26
  13725 	}
  13726 	goto do_atof_calc
  13727 __26:
  13728 	;
  13729 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == '-') {
  13730 		goto __27
  13731 	}
  13732 	esign = -1
  13733 	z += uintptr(incr)
  13734 	goto __28
  13735 __27:
  13736 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == '+') {
  13737 		goto __29
  13738 	}
  13739 	z += uintptr(incr)
  13740 __29:
  13741 	;
  13742 __28:
  13743 	;
  13744 __30:
  13745 	if !(z < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x04 != 0) {
  13746 		goto __31
  13747 	}
  13748 	if e < 10000 {
  13749 		e = e*10 + (int32(*(*uint8)(unsafe.Pointer(z))) - '0')
  13750 	} else {
  13751 		e = 10000
  13752 	}
  13753 	z += uintptr(incr)
  13754 	eValid = 1
  13755 	goto __30
  13756 __31:
  13757 	;
  13758 __25:
  13759 	;
  13760 __32:
  13761 	if !(z < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x01 != 0) {
  13762 		goto __33
  13763 	}
  13764 	z += uintptr(incr)
  13765 	goto __32
  13766 __33:
  13767 	;
  13768 do_atof_calc:
  13769 	e = e*esign + d
  13770 	if !(e < 0) {
  13771 		goto __34
  13772 	}
  13773 	esign = -1
  13774 	e = e * -1
  13775 	goto __35
  13776 __34:
  13777 	esign = 1
  13778 __35:
  13779 	;
  13780 	if !(s == int64(0)) {
  13781 		goto __36
  13782 	}
  13783 
  13784 	if sign < 0 {
  13785 		result = -libc.Float64FromFloat64(float64(0))
  13786 	} else {
  13787 		result = float64(0)
  13788 	}
  13789 	goto __37
  13790 __36:
  13791 __38:
  13792 	if !(e > 0) {
  13793 		goto __39
  13794 	}
  13795 	if !(esign > 0) {
  13796 		goto __40
  13797 	}
  13798 	if !(s >= (int64(0xffffffff)|int64(0x7fffffff)<<32)/int64(10)) {
  13799 		goto __42
  13800 	}
  13801 	goto __39
  13802 __42:
  13803 	;
  13804 	s = s * int64(10)
  13805 	goto __41
  13806 __40:
  13807 	if !(s%int64(10) != int64(0)) {
  13808 		goto __43
  13809 	}
  13810 	goto __39
  13811 __43:
  13812 	;
  13813 	s = s / int64(10)
  13814 __41:
  13815 	;
  13816 	e--
  13817 	goto __38
  13818 __39:
  13819 	;
  13820 	if sign < 0 {
  13821 		s = -s
  13822 	} else {
  13823 		s = s
  13824 	}
  13825 
  13826 	if !(e == 0) {
  13827 		goto __44
  13828 	}
  13829 	result = float64(s)
  13830 	goto __45
  13831 __44:
  13832 	if !(e > 307) {
  13833 		goto __46
  13834 	}
  13835 	if !(e < 342) {
  13836 		goto __48
  13837 	}
  13838 	scale = sqlite3Pow10(tls, e-308)
  13839 	if !(esign < 0) {
  13840 		goto __50
  13841 	}
  13842 	result = float64(s) / scale
  13843 	result = result / 1.0e+308
  13844 	goto __51
  13845 __50:
  13846 	result = float64(s) * scale
  13847 	result = result * 1.0e+308
  13848 __51:
  13849 	;
  13850 	goto __49
  13851 __48:
  13852 	;
  13853 	if !(esign < 0) {
  13854 		goto __52
  13855 	}
  13856 	result = 0.0 * float64(s)
  13857 	goto __53
  13858 __52:
  13859 	result = float64(libc.X__builtin_inff(tls) * float32(s))
  13860 __53:
  13861 	;
  13862 __49:
  13863 	;
  13864 	goto __47
  13865 __46:
  13866 	scale1 = sqlite3Pow10(tls, e)
  13867 	if !(esign < 0) {
  13868 		goto __54
  13869 	}
  13870 	result = float64(s) / scale1
  13871 	goto __55
  13872 __54:
  13873 	result = float64(s) * scale1
  13874 __55:
  13875 	;
  13876 __47:
  13877 	;
  13878 __45:
  13879 	;
  13880 __37:
  13881 	;
  13882 	*(*float64)(unsafe.Pointer(pResult)) = result
  13883 
  13884 	if !(z == zEnd && nDigit > 0 && eValid != 0 && eType > 0) {
  13885 		goto __56
  13886 	}
  13887 	return eType
  13888 	goto __57
  13889 __56:
  13890 	if !(eType >= 2 && (eType == 3 || eValid != 0) && nDigit > 0) {
  13891 		goto __58
  13892 	}
  13893 	return -1
  13894 	goto __59
  13895 __58:
  13896 	return 0
  13897 __59:
  13898 	;
  13899 __57:
  13900 	;
  13901 	return int32(0)
  13902 }
  13903 
  13904 // Render an signed 64-bit integer as text.  Store the result in zOut[] and
  13905 // return the length of the string that was stored, in bytes.  The value
  13906 // returned does not include the zero terminator at the end of the output
  13907 // string.
  13908 //
  13909 // The caller must ensure that zOut[] is at least 21 bytes in size.
  13910 func Xsqlite3Int64ToText(tls *libc.TLS, v I64, zOut uintptr) int32 {
  13911 	bp := tls.Alloc(22)
  13912 	defer tls.Free(22)
  13913 
  13914 	var i int32
  13915 	var x U64
  13916 
  13917 	if v < int64(0) {
  13918 		if v == int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32) {
  13919 			x = uint64(1) << 63
  13920 		} else {
  13921 			x = U64(-v)
  13922 		}
  13923 	} else {
  13924 		x = U64(v)
  13925 	}
  13926 	i = int32(uint32(unsafe.Sizeof([22]uint8{})) - uint32(2))
  13927 	*(*uint8)(unsafe.Pointer(bp + 21)) = uint8(0)
  13928 	for __ccgo := true; __ccgo; __ccgo = x != 0 {
  13929 		*(*uint8)(unsafe.Pointer(bp + uintptr(libc.PostDecInt32(&i, 1)))) = uint8(x%uint64(10) + uint64('0'))
  13930 		x = x / uint64(10)
  13931 	}
  13932 	if v < int64(0) {
  13933 		*(*uint8)(unsafe.Pointer(bp + uintptr(libc.PostDecInt32(&i, 1)))) = uint8('-')
  13934 	}
  13935 	libc.Xmemcpy(tls, zOut, bp+uintptr(i+1), uint32(unsafe.Sizeof([22]uint8{}))-uint32(1)-uint32(i))
  13936 	return int32(uint32(unsafe.Sizeof([22]uint8{})) - uint32(2) - uint32(i))
  13937 }
  13938 
  13939 func compare2pow63(tls *libc.TLS, zNum uintptr, incr int32) int32 {
  13940 	var c int32 = 0
  13941 	var i int32
  13942 
  13943 	var pow63 uintptr = ts + 1602
  13944 	for i = 0; c == 0 && i < 18; i++ {
  13945 		c = (int32(*(*uint8)(unsafe.Pointer(zNum + uintptr(i*incr)))) - int32(*(*uint8)(unsafe.Pointer(pow63 + uintptr(i))))) * 10
  13946 	}
  13947 	if c == 0 {
  13948 		c = int32(*(*uint8)(unsafe.Pointer(zNum + uintptr(18*incr)))) - '8'
  13949 
  13950 	}
  13951 	return c
  13952 }
  13953 
  13954 // Convert zNum to a 64-bit signed integer.  zNum must be decimal. This
  13955 // routine does *not* accept hexadecimal notation.
  13956 //
  13957 // Returns:
  13958 //
  13959 //	-1    Not even a prefix of the input text looks like an integer
  13960 //	 0    Successful transformation.  Fits in a 64-bit signed integer.
  13961 //	 1    Excess non-space text after the integer value
  13962 //	 2    Integer too large for a 64-bit signed integer or is malformed
  13963 //	 3    Special case of 9223372036854775808
  13964 //
  13965 // length is the number of bytes in the string (bytes, not characters).
  13966 // The string is not necessarily zero-terminated.  The encoding is
  13967 // given by enc.
  13968 func Xsqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc U8) int32 {
  13969 	var incr int32
  13970 	var u U64 = uint64(0)
  13971 	var neg int32 = 0
  13972 	var i int32
  13973 	var c int32 = 0
  13974 	var nonNum int32 = 0
  13975 	var rc int32
  13976 	var zStart uintptr
  13977 	var zEnd uintptr = zNum + uintptr(length)
  13978 
  13979 	if int32(enc) == SQLITE_UTF8 {
  13980 		incr = 1
  13981 	} else {
  13982 		incr = 2
  13983 		length = length & libc.CplInt32(1)
  13984 
  13985 		for i = 3 - int32(enc); i < length && int32(*(*uint8)(unsafe.Pointer(zNum + uintptr(i)))) == 0; i = i + 2 {
  13986 		}
  13987 		nonNum = libc.Bool32(i < length)
  13988 		zEnd = zNum + uintptr(i^1)
  13989 		zNum += uintptr(int32(enc) & 1)
  13990 	}
  13991 	for zNum < zEnd && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zNum))])&0x01 != 0 {
  13992 		zNum += uintptr(incr)
  13993 	}
  13994 	if zNum < zEnd {
  13995 		if int32(*(*uint8)(unsafe.Pointer(zNum))) == '-' {
  13996 			neg = 1
  13997 			zNum += uintptr(incr)
  13998 		} else if int32(*(*uint8)(unsafe.Pointer(zNum))) == '+' {
  13999 			zNum += uintptr(incr)
  14000 		}
  14001 	}
  14002 	zStart = zNum
  14003 	for zNum < zEnd && int32(*(*uint8)(unsafe.Pointer(zNum))) == '0' {
  14004 		zNum += uintptr(incr)
  14005 	}
  14006 	for i = 0; zNum+uintptr(i) < zEnd && libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(zNum + uintptr(i))))) >= '0' && c <= '9'; i = i + incr {
  14007 		u = u*uint64(10) + U64(c) - uint64('0')
  14008 	}
  14009 
  14010 	if u > uint64(int64(0xffffffff)|int64(0x7fffffff)<<32) {
  14011 		*(*I64)(unsafe.Pointer(pNum)) = func() int64 {
  14012 			if neg != 0 {
  14013 				return int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
  14014 			}
  14015 			return int64(0xffffffff) | int64(0x7fffffff)<<32
  14016 		}()
  14017 	} else if neg != 0 {
  14018 		*(*I64)(unsafe.Pointer(pNum)) = -I64(u)
  14019 	} else {
  14020 		*(*I64)(unsafe.Pointer(pNum)) = I64(u)
  14021 	}
  14022 	rc = 0
  14023 	if i == 0 && zStart == zNum {
  14024 		rc = -1
  14025 	} else if nonNum != 0 {
  14026 		rc = 1
  14027 	} else if zNum+uintptr(i) < zEnd {
  14028 		var jj int32 = i
  14029 		for __ccgo := true; __ccgo; __ccgo = zNum+uintptr(jj) < zEnd {
  14030 			if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zNum + uintptr(jj)))])&0x01 != 0) {
  14031 				rc = 1
  14032 				break
  14033 			}
  14034 			jj = jj + incr
  14035 		}
  14036 	}
  14037 	if i < 19*incr {
  14038 		return rc
  14039 	} else {
  14040 		if i > 19*incr {
  14041 			c = 1
  14042 		} else {
  14043 			c = compare2pow63(tls, zNum, incr)
  14044 		}
  14045 		if c < 0 {
  14046 			return rc
  14047 		} else {
  14048 			*(*I64)(unsafe.Pointer(pNum)) = func() int64 {
  14049 				if neg != 0 {
  14050 					return int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
  14051 				}
  14052 				return int64(0xffffffff) | int64(0x7fffffff)<<32
  14053 			}()
  14054 			if c > 0 {
  14055 				return 2
  14056 			} else {
  14057 				if neg != 0 {
  14058 					return rc
  14059 				}
  14060 				return 3
  14061 			}
  14062 		}
  14063 	}
  14064 	return int32(0)
  14065 }
  14066 
  14067 // Transform a UTF-8 integer literal, in either decimal or hexadecimal,
  14068 // into a 64-bit signed integer.  This routine accepts hexadecimal literals,
  14069 // whereas sqlite3Atoi64() does not.
  14070 //
  14071 // Returns:
  14072 //
  14073 //	0    Successful transformation.  Fits in a 64-bit signed integer.
  14074 //	1    Excess text after the integer value
  14075 //	2    Integer too large for a 64-bit signed integer or is malformed
  14076 //	3    Special case of 9223372036854775808
  14077 func Xsqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) int32 {
  14078 	bp := tls.Alloc(8)
  14079 	defer tls.Free(8)
  14080 
  14081 	if int32(*(*uint8)(unsafe.Pointer(z))) == '0' &&
  14082 		(int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'x' || int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'X') {
  14083 		*(*U64)(unsafe.Pointer(bp)) = uint64(0)
  14084 		var i int32
  14085 		var k int32
  14086 		for i = 2; int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == '0'; i++ {
  14087 		}
  14088 		for k = i; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(k)))])&0x08 != 0; k++ {
  14089 			*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))*uint64(16) + U64(Xsqlite3HexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z + uintptr(k))))))
  14090 		}
  14091 		libc.Xmemcpy(tls, pOut, bp, uint32(8))
  14092 		if int32(*(*uint8)(unsafe.Pointer(z + uintptr(k)))) == 0 && k-i <= 16 {
  14093 			return 0
  14094 		}
  14095 		return 2
  14096 	} else {
  14097 		return Xsqlite3Atoi64(tls, z, pOut, Xsqlite3Strlen30(tls, z), uint8(SQLITE_UTF8))
  14098 	}
  14099 	return int32(0)
  14100 }
  14101 
  14102 // If zNum represents an integer that will fit in 32-bits, then set
  14103 // *pValue to that integer and return true.  Otherwise return false.
  14104 //
  14105 // This routine accepts both decimal and hexadecimal notation for integers.
  14106 //
  14107 // Any non-numeric characters that following zNum are ignored.
  14108 // This is different from sqlite3Atoi64() which requires the
  14109 // input number to be zero-terminated.
  14110 func Xsqlite3GetInt32(tls *libc.TLS, zNum uintptr, pValue uintptr) int32 {
  14111 	bp := tls.Alloc(4)
  14112 	defer tls.Free(4)
  14113 
  14114 	var v Sqlite_int64 = int64(0)
  14115 	var i int32
  14116 	var c int32
  14117 	var neg int32 = 0
  14118 	if int32(*(*uint8)(unsafe.Pointer(zNum))) == '-' {
  14119 		neg = 1
  14120 		zNum++
  14121 	} else if int32(*(*uint8)(unsafe.Pointer(zNum))) == '+' {
  14122 		zNum++
  14123 	} else if int32(*(*uint8)(unsafe.Pointer(zNum))) == '0' &&
  14124 		(int32(*(*uint8)(unsafe.Pointer(zNum + 1))) == 'x' || int32(*(*uint8)(unsafe.Pointer(zNum + 1))) == 'X') &&
  14125 		int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zNum + 2))])&0x08 != 0 {
  14126 		*(*U32)(unsafe.Pointer(bp)) = U32(0)
  14127 		zNum += uintptr(2)
  14128 		for int32(*(*uint8)(unsafe.Pointer(zNum))) == '0' {
  14129 			zNum++
  14130 		}
  14131 		for i = 0; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zNum + uintptr(i)))])&0x08 != 0 && i < 8; i++ {
  14132 			*(*U32)(unsafe.Pointer(bp)) = *(*U32)(unsafe.Pointer(bp))*U32(16) + U32(Xsqlite3HexToInt(tls, int32(*(*uint8)(unsafe.Pointer(zNum + uintptr(i))))))
  14133 		}
  14134 		if *(*U32)(unsafe.Pointer(bp))&0x80000000 == U32(0) && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zNum + uintptr(i)))])&0x08 == 0 {
  14135 			libc.Xmemcpy(tls, pValue, bp, uint32(4))
  14136 			return 1
  14137 		} else {
  14138 			return 0
  14139 		}
  14140 	}
  14141 	if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zNum))])&0x04 != 0) {
  14142 		return 0
  14143 	}
  14144 	for int32(*(*uint8)(unsafe.Pointer(zNum))) == '0' {
  14145 		zNum++
  14146 	}
  14147 	for i = 0; i < 11 && libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(zNum + uintptr(i))))-'0') >= 0 && c <= 9; i++ {
  14148 		v = v*int64(10) + Sqlite_int64(c)
  14149 	}
  14150 
  14151 	if i > 10 {
  14152 		return 0
  14153 	}
  14154 
  14155 	if v-Sqlite_int64(neg) > int64(2147483647) {
  14156 		return 0
  14157 	}
  14158 	if neg != 0 {
  14159 		v = -v
  14160 	}
  14161 	*(*int32)(unsafe.Pointer(pValue)) = int32(v)
  14162 	return 1
  14163 }
  14164 
  14165 // Return a 32-bit integer value extracted from a string.  If the
  14166 // string is not an integer, just return 0.
  14167 func Xsqlite3Atoi(tls *libc.TLS, z uintptr) int32 {
  14168 	bp := tls.Alloc(4)
  14169 	defer tls.Free(4)
  14170 
  14171 	*(*int32)(unsafe.Pointer(bp)) = 0
  14172 	Xsqlite3GetInt32(tls, z, bp)
  14173 	return *(*int32)(unsafe.Pointer(bp))
  14174 }
  14175 
  14176 // Try to convert z into an unsigned 32-bit integer.  Return true on
  14177 // success and false if there is an error.
  14178 //
  14179 // Only decimal notation is accepted.
  14180 func Xsqlite3GetUInt32(tls *libc.TLS, z uintptr, pI uintptr) int32 {
  14181 	var v U64 = uint64(0)
  14182 	var i int32
  14183 	for i = 0; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x04 != 0; i++ {
  14184 		v = v*uint64(10) + U64(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) - uint64('0')
  14185 		if v > uint64(4294967296) {
  14186 			*(*U32)(unsafe.Pointer(pI)) = U32(0)
  14187 			return 0
  14188 		}
  14189 	}
  14190 	if i == 0 || int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != 0 {
  14191 		*(*U32)(unsafe.Pointer(pI)) = U32(0)
  14192 		return 0
  14193 	}
  14194 	*(*U32)(unsafe.Pointer(pI)) = U32(v)
  14195 	return 1
  14196 }
  14197 
  14198 func putVarint64(tls *libc.TLS, p uintptr, v U64) int32 {
  14199 	bp := tls.Alloc(10)
  14200 	defer tls.Free(10)
  14201 
  14202 	var i int32
  14203 	var j int32
  14204 	var n int32
  14205 
  14206 	if v&(uint64(0xff000000)<<32) != 0 {
  14207 		*(*uint8)(unsafe.Pointer(p + 8)) = U8(v)
  14208 		v >>= 8
  14209 		for i = 7; i >= 0; i-- {
  14210 			*(*uint8)(unsafe.Pointer(p + uintptr(i))) = U8(v&uint64(0x7f) | uint64(0x80))
  14211 			v >>= 7
  14212 		}
  14213 		return 9
  14214 	}
  14215 	n = 0
  14216 	for __ccgo := true; __ccgo; __ccgo = v != uint64(0) {
  14217 		*(*U8)(unsafe.Pointer(bp + uintptr(libc.PostIncInt32(&n, 1)))) = U8(v&uint64(0x7f) | uint64(0x80))
  14218 		v >>= 7
  14219 	}
  14220 	*(*U8)(unsafe.Pointer(bp)) &= U8(0x7f)
  14221 
  14222 	i = 0
  14223 	j = n - 1
  14224 __1:
  14225 	if !(j >= 0) {
  14226 		goto __3
  14227 	}
  14228 	{
  14229 		*(*uint8)(unsafe.Pointer(p + uintptr(i))) = *(*U8)(unsafe.Pointer(bp + uintptr(j)))
  14230 
  14231 	}
  14232 	goto __2
  14233 __2:
  14234 	j--
  14235 	i++
  14236 	goto __1
  14237 	goto __3
  14238 __3:
  14239 	;
  14240 	return n
  14241 }
  14242 
  14243 func Xsqlite3PutVarint(tls *libc.TLS, p uintptr, v U64) int32 {
  14244 	if v <= uint64(0x7f) {
  14245 		*(*uint8)(unsafe.Pointer(p)) = uint8(v & uint64(0x7f))
  14246 		return 1
  14247 	}
  14248 	if v <= uint64(0x3fff) {
  14249 		*(*uint8)(unsafe.Pointer(p)) = uint8(v>>7&uint64(0x7f) | uint64(0x80))
  14250 		*(*uint8)(unsafe.Pointer(p + 1)) = uint8(v & uint64(0x7f))
  14251 		return 2
  14252 	}
  14253 	return putVarint64(tls, p, v)
  14254 }
  14255 
  14256 // Read a 64-bit variable-length integer from memory starting at p[0].
  14257 // Return the number of bytes read.  The value is stored in *v.
  14258 func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 {
  14259 	var a U32
  14260 	var b U32
  14261 	var s U32
  14262 
  14263 	if int32(*(*int8)(unsafe.Pointer(p))) >= 0 {
  14264 		*(*U64)(unsafe.Pointer(v)) = U64(*(*uint8)(unsafe.Pointer(p)))
  14265 		return U8(1)
  14266 	}
  14267 	if int32(*(*int8)(unsafe.Pointer(p + 1))) >= 0 {
  14268 		*(*U64)(unsafe.Pointer(v)) = U64(U32(int32(*(*uint8)(unsafe.Pointer(p)))&0x7f)<<7 | U32(*(*uint8)(unsafe.Pointer(p + 1))))
  14269 		return U8(2)
  14270 	}
  14271 
  14272 	a = U32(*(*uint8)(unsafe.Pointer(p))) << 14
  14273 	b = U32(*(*uint8)(unsafe.Pointer(p + 1)))
  14274 	p += uintptr(2)
  14275 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
  14276 
  14277 	if !(a&U32(0x80) != 0) {
  14278 		a = a & U32(SLOT_2_0)
  14279 		b = b & U32(0x7f)
  14280 		b = b << 7
  14281 		a = a | b
  14282 		*(*U64)(unsafe.Pointer(v)) = U64(a)
  14283 		return U8(3)
  14284 	}
  14285 
  14286 	a = a & U32(SLOT_2_0)
  14287 	p++
  14288 	b = b << 14
  14289 	b = b | U32(*(*uint8)(unsafe.Pointer(p)))
  14290 
  14291 	if !(b&U32(0x80) != 0) {
  14292 		b = b & U32(SLOT_2_0)
  14293 
  14294 		a = a << 7
  14295 		a = a | b
  14296 		*(*U64)(unsafe.Pointer(v)) = U64(a)
  14297 		return U8(4)
  14298 	}
  14299 
  14300 	b = b & U32(SLOT_2_0)
  14301 	s = a
  14302 
  14303 	p++
  14304 	a = a << 14
  14305 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
  14306 
  14307 	if !(a&U32(0x80) != 0) {
  14308 		b = b << 7
  14309 		a = a | b
  14310 		s = s >> 18
  14311 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
  14312 		return U8(5)
  14313 	}
  14314 
  14315 	s = s << 7
  14316 	s = s | b
  14317 
  14318 	p++
  14319 	b = b << 14
  14320 	b = b | U32(*(*uint8)(unsafe.Pointer(p)))
  14321 
  14322 	if !(b&U32(0x80) != 0) {
  14323 		a = a & U32(SLOT_2_0)
  14324 		a = a << 7
  14325 		a = a | b
  14326 		s = s >> 18
  14327 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
  14328 		return U8(6)
  14329 	}
  14330 
  14331 	p++
  14332 	a = a << 14
  14333 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
  14334 
  14335 	if !(a&U32(0x80) != 0) {
  14336 		a = a & SLOT_4_2_0
  14337 		b = b & U32(SLOT_2_0)
  14338 		b = b << 7
  14339 		a = a | b
  14340 		s = s >> 11
  14341 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
  14342 		return U8(7)
  14343 	}
  14344 
  14345 	a = a & U32(SLOT_2_0)
  14346 	p++
  14347 	b = b << 14
  14348 	b = b | U32(*(*uint8)(unsafe.Pointer(p)))
  14349 
  14350 	if !(b&U32(0x80) != 0) {
  14351 		b = b & SLOT_4_2_0
  14352 
  14353 		a = a << 7
  14354 		a = a | b
  14355 		s = s >> 4
  14356 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
  14357 		return U8(8)
  14358 	}
  14359 
  14360 	p++
  14361 	a = a << 15
  14362 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
  14363 
  14364 	b = b & U32(SLOT_2_0)
  14365 	b = b << 8
  14366 	a = a | b
  14367 
  14368 	s = s << 4
  14369 	b = U32(*(*uint8)(unsafe.Pointer(p + libc.UintptrFromInt32(-4))))
  14370 	b = b & U32(0x7f)
  14371 	b = b >> 3
  14372 	s = s | b
  14373 
  14374 	*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
  14375 
  14376 	return U8(9)
  14377 }
  14378 
  14379 // Read a 32-bit variable-length integer from memory starting at p[0].
  14380 // Return the number of bytes read.  The value is stored in *v.
  14381 //
  14382 // If the varint stored in p[0] is larger than can fit in a 32-bit unsigned
  14383 // integer, then set *v to 0xffffffff.
  14384 //
  14385 // A MACRO version, getVarint32, is provided which inlines the
  14386 // single-byte case.  All code should use the MACRO version as
  14387 // this function assumes the single-byte case has already been handled.
  14388 func Xsqlite3GetVarint32(tls *libc.TLS, p uintptr, v uintptr) U8 {
  14389 	bp := tls.Alloc(8)
  14390 	defer tls.Free(8)
  14391 
  14392 	var a U32
  14393 	var b U32
  14394 
  14395 	a = U32(*(*uint8)(unsafe.Pointer(p)))
  14396 
  14397 	p++
  14398 	b = U32(*(*uint8)(unsafe.Pointer(p)))
  14399 
  14400 	if !(b&U32(0x80) != 0) {
  14401 		a = a & U32(0x7f)
  14402 		a = a << 7
  14403 		*(*U32)(unsafe.Pointer(v)) = a | b
  14404 		return U8(2)
  14405 	}
  14406 
  14407 	p++
  14408 	a = a << 14
  14409 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
  14410 
  14411 	if !(a&U32(0x80) != 0) {
  14412 		a = a & U32(int32(0x7f)<<14|0x7f)
  14413 		b = b & U32(0x7f)
  14414 		b = b << 7
  14415 		*(*U32)(unsafe.Pointer(v)) = a | b
  14416 		return U8(3)
  14417 	}
  14418 
  14419 	{
  14420 		var n U8
  14421 
  14422 		n = Xsqlite3GetVarint(tls, p-uintptr(2), bp)
  14423 
  14424 		if *(*U64)(unsafe.Pointer(bp))&(uint64(1)<<32-uint64(1)) != *(*U64)(unsafe.Pointer(bp)) {
  14425 			*(*U32)(unsafe.Pointer(v)) = 0xffffffff
  14426 		} else {
  14427 			*(*U32)(unsafe.Pointer(v)) = U32(*(*U64)(unsafe.Pointer(bp)))
  14428 		}
  14429 		return n
  14430 
  14431 	}
  14432 	return U8(0)
  14433 
  14434 }
  14435 
  14436 // Return the number of bytes that will be needed to store the given
  14437 // 64-bit integer.
  14438 func Xsqlite3VarintLen(tls *libc.TLS, v U64) int32 {
  14439 	var i int32
  14440 	for i = 1; libc.AssignShrUint64(&v, int(uint64(7))) != uint64(0); i++ {
  14441 	}
  14442 	return i
  14443 }
  14444 
  14445 // Read or write a four-byte big-endian integer value.
  14446 func Xsqlite3Get4byte(tls *libc.TLS, p uintptr) U32 {
  14447 	bp := tls.Alloc(4)
  14448 	defer tls.Free(4)
  14449 
  14450 	libc.Xmemcpy(tls, bp, p, uint32(4))
  14451 	return libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(bp)))
  14452 }
  14453 
  14454 func Xsqlite3Put4byte(tls *libc.TLS, p uintptr, v U32) {
  14455 	bp := tls.Alloc(4)
  14456 	defer tls.Free(4)
  14457 
  14458 	*(*U32)(unsafe.Pointer(bp)) = libc.X__builtin_bswap32(tls, v)
  14459 	libc.Xmemcpy(tls, p, bp, uint32(4))
  14460 }
  14461 
  14462 // Translate a single byte of Hex into an integer.
  14463 // This routine only works if h really is a valid hexadecimal
  14464 // character:  0..9a..fA..F
  14465 func Xsqlite3HexToInt(tls *libc.TLS, h int32) U8 {
  14466 	h = h + 9*(1&(h>>6))
  14467 	return U8(h & 0xf)
  14468 }
  14469 
  14470 // Convert a BLOB literal of the form "x'hhhhhh'" into its binary
  14471 // value.  Return a pointer to its binary value.  Space to hold the
  14472 // binary value has been obtained from malloc and must be freed by
  14473 // the calling routine.
  14474 func Xsqlite3HexToBlob(tls *libc.TLS, db uintptr, z uintptr, n int32) uintptr {
  14475 	var zBlob uintptr
  14476 	var i int32
  14477 
  14478 	zBlob = Xsqlite3DbMallocRawNN(tls, db, uint64(n/2+1))
  14479 	n--
  14480 	if zBlob != 0 {
  14481 		for i = 0; i < n; i = i + 2 {
  14482 			*(*uint8)(unsafe.Pointer(zBlob + uintptr(i/2))) = uint8(int32(Xsqlite3HexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))))<<4 | int32(Xsqlite3HexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))))))
  14483 		}
  14484 		*(*uint8)(unsafe.Pointer(zBlob + uintptr(i/2))) = uint8(0)
  14485 	}
  14486 	return zBlob
  14487 }
  14488 
  14489 func logBadConnection(tls *libc.TLS, zType uintptr) {
  14490 	bp := tls.Alloc(8)
  14491 	defer tls.Free(8)
  14492 
  14493 	Xsqlite3_log(tls, SQLITE_MISUSE,
  14494 		ts+1621,
  14495 		libc.VaList(bp, zType))
  14496 }
  14497 
  14498 // Check to make sure we have a valid db pointer.  This test is not
  14499 // foolproof but it does provide some measure of protection against
  14500 // misuse of the interface such as passing in db pointers that are
  14501 // NULL or which have been previously closed.  If this routine returns
  14502 // 1 it means that the db pointer is valid and 0 if it should not be
  14503 // dereferenced for any reason.  The calling function should invoke
  14504 // SQLITE_MISUSE immediately.
  14505 //
  14506 // sqlite3SafetyCheckOk() requires that the db pointer be valid for
  14507 // use.  sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to
  14508 // open properly and is not fit for general use but which can be
  14509 // used as an argument to sqlite3_errmsg() or sqlite3_close().
  14510 func Xsqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) int32 {
  14511 	var eOpenState U8
  14512 	if db == uintptr(0) {
  14513 		logBadConnection(tls, ts+1555)
  14514 		return 0
  14515 	}
  14516 	eOpenState = (*Sqlite3)(unsafe.Pointer(db)).FeOpenState
  14517 	if int32(eOpenState) != SQLITE_STATE_OPEN {
  14518 		if Xsqlite3SafetyCheckSickOrOk(tls, db) != 0 {
  14519 			logBadConnection(tls, ts+1666)
  14520 		}
  14521 		return 0
  14522 	} else {
  14523 		return 1
  14524 	}
  14525 	return int32(0)
  14526 }
  14527 
  14528 func Xsqlite3SafetyCheckSickOrOk(tls *libc.TLS, db uintptr) int32 {
  14529 	var eOpenState U8
  14530 	eOpenState = (*Sqlite3)(unsafe.Pointer(db)).FeOpenState
  14531 	if int32(eOpenState) != SQLITE_STATE_SICK && int32(eOpenState) != SQLITE_STATE_OPEN && int32(eOpenState) != SQLITE_STATE_BUSY {
  14532 		logBadConnection(tls, ts+1675)
  14533 		return 0
  14534 	} else {
  14535 		return 1
  14536 	}
  14537 	return int32(0)
  14538 }
  14539 
  14540 // Attempt to add, substract, or multiply the 64-bit signed value iB against
  14541 // the other 64-bit signed integer at *pA and store the result in *pA.
  14542 // Return 0 on success.  Or if the operation would have resulted in an
  14543 // overflow, leave *pA unchanged and return 1.
  14544 func Xsqlite3AddInt64(tls *libc.TLS, pA uintptr, iB I64) int32 {
  14545 	return libc.X__builtin_add_overflowInt64(tls, *(*I64)(unsafe.Pointer(pA)), iB, pA)
  14546 }
  14547 
  14548 func Xsqlite3SubInt64(tls *libc.TLS, pA uintptr, iB I64) int32 {
  14549 	return libc.X__builtin_sub_overflowInt64(tls, *(*I64)(unsafe.Pointer(pA)), iB, pA)
  14550 }
  14551 
  14552 func Xsqlite3MulInt64(tls *libc.TLS, pA uintptr, iB I64) int32 {
  14553 	return libc.X__builtin_mul_overflowInt64(tls, *(*I64)(unsafe.Pointer(pA)), iB, pA)
  14554 }
  14555 
  14556 // Compute the absolute value of a 32-bit signed integer, of possible.  Or
  14557 // if the integer has a value of -2147483648, return +2147483647
  14558 func Xsqlite3AbsInt32(tls *libc.TLS, x int32) int32 {
  14559 	if x >= 0 {
  14560 		return x
  14561 	}
  14562 	if x == libc.Int32FromUint32(0x80000000) {
  14563 		return 0x7fffffff
  14564 	}
  14565 	return -x
  14566 }
  14567 
  14568 // Find (an approximate) sum of two LogEst values.  This computation is
  14569 // not a simple "+" operator because LogEst is stored as a logarithmic
  14570 // value.
  14571 func Xsqlite3LogEstAdd(tls *libc.TLS, a LogEst, b LogEst) LogEst {
  14572 	if int32(a) >= int32(b) {
  14573 		if int32(a) > int32(b)+49 {
  14574 			return a
  14575 		}
  14576 		if int32(a) > int32(b)+31 {
  14577 			return LogEst(int32(a) + 1)
  14578 		}
  14579 		return LogEst(int32(a) + int32(x[int32(a)-int32(b)]))
  14580 	} else {
  14581 		if int32(b) > int32(a)+49 {
  14582 			return b
  14583 		}
  14584 		if int32(b) > int32(a)+31 {
  14585 			return LogEst(int32(b) + 1)
  14586 		}
  14587 		return LogEst(int32(b) + int32(x[int32(b)-int32(a)]))
  14588 	}
  14589 	return LogEst(0)
  14590 }
  14591 
  14592 var x = [32]uint8{
  14593 	uint8(10), uint8(10),
  14594 	uint8(9), uint8(9),
  14595 	uint8(8), uint8(8),
  14596 	uint8(7), uint8(7), uint8(7),
  14597 	uint8(6), uint8(6), uint8(6),
  14598 	uint8(5), uint8(5), uint8(5),
  14599 	uint8(4), uint8(4), uint8(4), uint8(4),
  14600 	uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(3),
  14601 	uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2),
  14602 }
  14603 
  14604 // Convert an integer into a LogEst.  In other words, compute an
  14605 // approximation for 10*log2(x).
  14606 func Xsqlite3LogEst(tls *libc.TLS, x U64) LogEst {
  14607 	var y LogEst = int16(40)
  14608 	if x < uint64(8) {
  14609 		if x < uint64(2) {
  14610 			return int16(0)
  14611 		}
  14612 		for x < uint64(8) {
  14613 			y = int16(int32(y) - 10)
  14614 			x <<= 1
  14615 		}
  14616 	} else {
  14617 		var i int32 = 60 - libc.X__builtin_clzll(tls, x)
  14618 		y = LogEst(int32(y) + i*10)
  14619 		x >>= i
  14620 	}
  14621 	return LogEst(int32(a[x&uint64(7)]) + int32(y) - 10)
  14622 }
  14623 
  14624 var a = [8]LogEst{int16(0), int16(2), int16(3), int16(5), int16(6), int16(7), int16(8), int16(9)}
  14625 
  14626 // Convert a double into a LogEst
  14627 // In other words, compute an approximation for 10*log2(x).
  14628 func Xsqlite3LogEstFromDouble(tls *libc.TLS, x float64) LogEst {
  14629 	bp := tls.Alloc(16)
  14630 	defer tls.Free(16)
  14631 	*(*float64)(unsafe.Pointer(bp + 8)) = x
  14632 
  14633 	var e LogEst
  14634 
  14635 	if *(*float64)(unsafe.Pointer(bp + 8)) <= float64(1) {
  14636 		return int16(0)
  14637 	}
  14638 	if *(*float64)(unsafe.Pointer(bp + 8)) <= float64(2000000000) {
  14639 		return Xsqlite3LogEst(tls, U64(*(*float64)(unsafe.Pointer(bp + 8))))
  14640 	}
  14641 	libc.Xmemcpy(tls, bp, bp+8, uint32(8))
  14642 	e = LogEst(*(*U64)(unsafe.Pointer(bp))>>52 - uint64(1022))
  14643 	return LogEst(int32(e) * 10)
  14644 }
  14645 
  14646 // Convert a LogEst into an integer.
  14647 func Xsqlite3LogEstToInt(tls *libc.TLS, x LogEst) U64 {
  14648 	var n U64
  14649 	n = U64(int32(x) % 10)
  14650 	x = int16(int32(x) / 10)
  14651 	if n >= uint64(5) {
  14652 		n = n - uint64(2)
  14653 	} else if n >= uint64(1) {
  14654 		n = n - uint64(1)
  14655 	}
  14656 	if int32(x) > 60 {
  14657 		return uint64(int64(0xffffffff) | int64(0x7fffffff)<<32)
  14658 	}
  14659 	if int32(x) >= 3 {
  14660 		return (n + uint64(8)) << (int32(x) - 3)
  14661 	}
  14662 	return (n + uint64(8)) >> (3 - int32(x))
  14663 }
  14664 
  14665 // Add a new name/number pair to a VList.  This might require that the
  14666 // VList object be reallocated, so return the new VList.  If an OOM
  14667 // error occurs, the original VList returned and the
  14668 // db->mallocFailed flag is set.
  14669 //
  14670 // A VList is really just an array of integers.  To destroy a VList,
  14671 // simply pass it to sqlite3DbFree().
  14672 //
  14673 // The first integer is the number of integers allocated for the whole
  14674 // VList.  The second integer is the number of integers actually used.
  14675 // Each name/number pair is encoded by subsequent groups of 3 or more
  14676 // integers.
  14677 //
  14678 // Each name/number pair starts with two integers which are the numeric
  14679 // value for the pair and the size of the name/number pair, respectively.
  14680 // The text name overlays one or more following integers.  The text name
  14681 // is always zero-terminated.
  14682 //
  14683 // Conceptually:
  14684 //
  14685 //	struct VList {
  14686 //	  int nAlloc;   // Number of allocated slots
  14687 //	  int nUsed;    // Number of used slots
  14688 //	  struct VListEntry {
  14689 //	    int iValue;    // Value for this entry
  14690 //	    int nSlot;     // Slots used by this entry
  14691 //	    // ... variable name goes here
  14692 //	  } a[0];
  14693 //	}
  14694 //
  14695 // During code generation, pointers to the variable names within the
  14696 // VList are taken.  When that happens, nAlloc is set to zero as an
  14697 // indication that the VList may never again be enlarged, since the
  14698 // accompanying realloc() would invalidate the pointers.
  14699 func Xsqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nName int32, iVal int32) uintptr {
  14700 	var nInt int32
  14701 	var z uintptr
  14702 	var i int32
  14703 
  14704 	nInt = nName/4 + 3
  14705 
  14706 	if pIn == uintptr(0) || *(*VList)(unsafe.Pointer(pIn + 1*4))+nInt > *(*VList)(unsafe.Pointer(pIn)) {
  14707 		var nAlloc Sqlite3_int64 = func() int64 {
  14708 			if pIn != 0 {
  14709 				return int64(2) * Sqlite3_int64(*(*VList)(unsafe.Pointer(pIn)))
  14710 			}
  14711 			return int64(10)
  14712 		}() + Sqlite3_int64(nInt)
  14713 		var pOut uintptr = Xsqlite3DbRealloc(tls, db, pIn, uint64(nAlloc*Sqlite3_int64(unsafe.Sizeof(int32(0)))))
  14714 		if pOut == uintptr(0) {
  14715 			return pIn
  14716 		}
  14717 		if pIn == uintptr(0) {
  14718 			*(*VList)(unsafe.Pointer(pOut + 1*4)) = 2
  14719 		}
  14720 		pIn = pOut
  14721 		*(*VList)(unsafe.Pointer(pIn)) = VList(nAlloc)
  14722 	}
  14723 	i = *(*VList)(unsafe.Pointer(pIn + 1*4))
  14724 	*(*VList)(unsafe.Pointer(pIn + uintptr(i)*4)) = iVal
  14725 	*(*VList)(unsafe.Pointer(pIn + uintptr(i+1)*4)) = nInt
  14726 	z = pIn + uintptr(i+2)*4
  14727 	*(*VList)(unsafe.Pointer(pIn + 1*4)) = i + nInt
  14728 
  14729 	libc.Xmemcpy(tls, z, zName, uint32(nName))
  14730 	*(*uint8)(unsafe.Pointer(z + uintptr(nName))) = uint8(0)
  14731 	return pIn
  14732 }
  14733 
  14734 // Return a pointer to the name of a variable in the given VList that
  14735 // has the value iVal.  Or return a NULL if there is no such variable in
  14736 // the list
  14737 func Xsqlite3VListNumToName(tls *libc.TLS, pIn uintptr, iVal int32) uintptr {
  14738 	var i int32
  14739 	var mx int32
  14740 	if pIn == uintptr(0) {
  14741 		return uintptr(0)
  14742 	}
  14743 	mx = *(*VList)(unsafe.Pointer(pIn + 1*4))
  14744 	i = 2
  14745 	for __ccgo := true; __ccgo; __ccgo = i < mx {
  14746 		if *(*VList)(unsafe.Pointer(pIn + uintptr(i)*4)) == iVal {
  14747 			return pIn + uintptr(i+2)*4
  14748 		}
  14749 		i = i + *(*VList)(unsafe.Pointer(pIn + uintptr(i+1)*4))
  14750 	}
  14751 	return uintptr(0)
  14752 }
  14753 
  14754 // Return the number of the variable named zName, if it is in VList.
  14755 // or return 0 if there is no such variable.
  14756 func Xsqlite3VListNameToNum(tls *libc.TLS, pIn uintptr, zName uintptr, nName int32) int32 {
  14757 	var i int32
  14758 	var mx int32
  14759 	if pIn == uintptr(0) {
  14760 		return 0
  14761 	}
  14762 	mx = *(*VList)(unsafe.Pointer(pIn + 1*4))
  14763 	i = 2
  14764 	for __ccgo := true; __ccgo; __ccgo = i < mx {
  14765 		var z uintptr = pIn + uintptr(i+2)*4
  14766 		if libc.Xstrncmp(tls, z, zName, uint32(nName)) == 0 && int32(*(*uint8)(unsafe.Pointer(z + uintptr(nName)))) == 0 {
  14767 			return *(*VList)(unsafe.Pointer(pIn + uintptr(i)*4))
  14768 		}
  14769 		i = i + *(*VList)(unsafe.Pointer(pIn + uintptr(i+1)*4))
  14770 	}
  14771 	return 0
  14772 }
  14773 
  14774 // Turn bulk memory into a hash table object by initializing the
  14775 // fields of the Hash structure.
  14776 //
  14777 // "pNew" is a pointer to the hash table that is to be initialized.
  14778 func Xsqlite3HashInit(tls *libc.TLS, pNew uintptr) {
  14779 	(*Hash)(unsafe.Pointer(pNew)).Ffirst = uintptr(0)
  14780 	(*Hash)(unsafe.Pointer(pNew)).Fcount = uint32(0)
  14781 	(*Hash)(unsafe.Pointer(pNew)).Fhtsize = uint32(0)
  14782 	(*Hash)(unsafe.Pointer(pNew)).Fht = uintptr(0)
  14783 }
  14784 
  14785 // Remove all entries from a hash table.  Reclaim all memory.
  14786 // Call this routine to delete a hash table or to reset a hash table
  14787 // to the empty state.
  14788 func Xsqlite3HashClear(tls *libc.TLS, pH uintptr) {
  14789 	var elem uintptr
  14790 
  14791 	elem = (*Hash)(unsafe.Pointer(pH)).Ffirst
  14792 	(*Hash)(unsafe.Pointer(pH)).Ffirst = uintptr(0)
  14793 	Xsqlite3_free(tls, (*Hash)(unsafe.Pointer(pH)).Fht)
  14794 	(*Hash)(unsafe.Pointer(pH)).Fht = uintptr(0)
  14795 	(*Hash)(unsafe.Pointer(pH)).Fhtsize = uint32(0)
  14796 	for elem != 0 {
  14797 		var next_elem uintptr = (*HashElem)(unsafe.Pointer(elem)).Fnext
  14798 		Xsqlite3_free(tls, elem)
  14799 		elem = next_elem
  14800 	}
  14801 	(*Hash)(unsafe.Pointer(pH)).Fcount = uint32(0)
  14802 }
  14803 
  14804 func strHash(tls *libc.TLS, z uintptr) uint32 {
  14805 	var h uint32 = uint32(0)
  14806 	var c uint8
  14807 	for int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) != 0 {
  14808 		h = h + uint32(Xsqlite3UpperToLower[c])
  14809 		h = h * 0x9e3779b1
  14810 	}
  14811 	return h
  14812 }
  14813 
  14814 func insertElement(tls *libc.TLS, pH uintptr, pEntry uintptr, pNew uintptr) {
  14815 	var pHead uintptr
  14816 	if pEntry != 0 {
  14817 		if (*_ht)(unsafe.Pointer(pEntry)).Fcount != 0 {
  14818 			pHead = (*_ht)(unsafe.Pointer(pEntry)).Fchain
  14819 		} else {
  14820 			pHead = uintptr(0)
  14821 		}
  14822 		(*_ht)(unsafe.Pointer(pEntry)).Fcount++
  14823 		(*_ht)(unsafe.Pointer(pEntry)).Fchain = pNew
  14824 	} else {
  14825 		pHead = uintptr(0)
  14826 	}
  14827 	if pHead != 0 {
  14828 		(*HashElem)(unsafe.Pointer(pNew)).Fnext = pHead
  14829 		(*HashElem)(unsafe.Pointer(pNew)).Fprev = (*HashElem)(unsafe.Pointer(pHead)).Fprev
  14830 		if (*HashElem)(unsafe.Pointer(pHead)).Fprev != 0 {
  14831 			(*HashElem)(unsafe.Pointer((*HashElem)(unsafe.Pointer(pHead)).Fprev)).Fnext = pNew
  14832 		} else {
  14833 			(*Hash)(unsafe.Pointer(pH)).Ffirst = pNew
  14834 		}
  14835 		(*HashElem)(unsafe.Pointer(pHead)).Fprev = pNew
  14836 	} else {
  14837 		(*HashElem)(unsafe.Pointer(pNew)).Fnext = (*Hash)(unsafe.Pointer(pH)).Ffirst
  14838 		if (*Hash)(unsafe.Pointer(pH)).Ffirst != 0 {
  14839 			(*HashElem)(unsafe.Pointer((*Hash)(unsafe.Pointer(pH)).Ffirst)).Fprev = pNew
  14840 		}
  14841 		(*HashElem)(unsafe.Pointer(pNew)).Fprev = uintptr(0)
  14842 		(*Hash)(unsafe.Pointer(pH)).Ffirst = pNew
  14843 	}
  14844 }
  14845 
  14846 func rehash(tls *libc.TLS, pH uintptr, new_size uint32) int32 {
  14847 	var new_ht uintptr
  14848 	var elem uintptr
  14849 	var next_elem uintptr
  14850 
  14851 	if new_size*uint32(unsafe.Sizeof(_ht{})) > uint32(SQLITE_MALLOC_SOFT_LIMIT) {
  14852 		new_size = uint32(SQLITE_MALLOC_SOFT_LIMIT) / uint32(unsafe.Sizeof(_ht{}))
  14853 	}
  14854 	if new_size == (*Hash)(unsafe.Pointer(pH)).Fhtsize {
  14855 		return 0
  14856 	}
  14857 
  14858 	Xsqlite3BeginBenignMalloc(tls)
  14859 	new_ht = Xsqlite3Malloc(tls, uint64(new_size*uint32(unsafe.Sizeof(_ht{}))))
  14860 	Xsqlite3EndBenignMalloc(tls)
  14861 
  14862 	if new_ht == uintptr(0) {
  14863 		return 0
  14864 	}
  14865 	Xsqlite3_free(tls, (*Hash)(unsafe.Pointer(pH)).Fht)
  14866 	(*Hash)(unsafe.Pointer(pH)).Fht = new_ht
  14867 	(*Hash)(unsafe.Pointer(pH)).Fhtsize = libc.AssignUint32(&new_size, uint32(Xsqlite3MallocSize(tls, new_ht))/uint32(unsafe.Sizeof(_ht{})))
  14868 	libc.Xmemset(tls, new_ht, 0, new_size*uint32(unsafe.Sizeof(_ht{})))
  14869 	elem = (*Hash)(unsafe.Pointer(pH)).Ffirst
  14870 	(*Hash)(unsafe.Pointer(pH)).Ffirst = uintptr(0)
  14871 	for ; elem != 0; elem = next_elem {
  14872 		var h uint32 = strHash(tls, (*HashElem)(unsafe.Pointer(elem)).FpKey) % new_size
  14873 		next_elem = (*HashElem)(unsafe.Pointer(elem)).Fnext
  14874 		insertElement(tls, pH, new_ht+uintptr(h)*8, elem)
  14875 	}
  14876 	return 1
  14877 }
  14878 
  14879 func findElementWithHash(tls *libc.TLS, pH uintptr, pKey uintptr, pHash uintptr) uintptr {
  14880 	var elem uintptr
  14881 	var count uint32
  14882 	var h uint32
  14883 
  14884 	if (*Hash)(unsafe.Pointer(pH)).Fht != 0 {
  14885 		var pEntry uintptr
  14886 		h = strHash(tls, pKey) % (*Hash)(unsafe.Pointer(pH)).Fhtsize
  14887 		pEntry = (*Hash)(unsafe.Pointer(pH)).Fht + uintptr(h)*8
  14888 		elem = (*_ht)(unsafe.Pointer(pEntry)).Fchain
  14889 		count = (*_ht)(unsafe.Pointer(pEntry)).Fcount
  14890 	} else {
  14891 		h = uint32(0)
  14892 		elem = (*Hash)(unsafe.Pointer(pH)).Ffirst
  14893 		count = (*Hash)(unsafe.Pointer(pH)).Fcount
  14894 	}
  14895 	if pHash != 0 {
  14896 		*(*uint32)(unsafe.Pointer(pHash)) = h
  14897 	}
  14898 	for count != 0 {
  14899 		if Xsqlite3StrICmp(tls, (*HashElem)(unsafe.Pointer(elem)).FpKey, pKey) == 0 {
  14900 			return elem
  14901 		}
  14902 		elem = (*HashElem)(unsafe.Pointer(elem)).Fnext
  14903 		count--
  14904 	}
  14905 	return uintptr(unsafe.Pointer(&nullElement))
  14906 }
  14907 
  14908 var nullElement = HashElem{}
  14909 
  14910 func removeElementGivenHash(tls *libc.TLS, pH uintptr, elem uintptr, h uint32) {
  14911 	var pEntry uintptr
  14912 	if (*HashElem)(unsafe.Pointer(elem)).Fprev != 0 {
  14913 		(*HashElem)(unsafe.Pointer((*HashElem)(unsafe.Pointer(elem)).Fprev)).Fnext = (*HashElem)(unsafe.Pointer(elem)).Fnext
  14914 	} else {
  14915 		(*Hash)(unsafe.Pointer(pH)).Ffirst = (*HashElem)(unsafe.Pointer(elem)).Fnext
  14916 	}
  14917 	if (*HashElem)(unsafe.Pointer(elem)).Fnext != 0 {
  14918 		(*HashElem)(unsafe.Pointer((*HashElem)(unsafe.Pointer(elem)).Fnext)).Fprev = (*HashElem)(unsafe.Pointer(elem)).Fprev
  14919 	}
  14920 	if (*Hash)(unsafe.Pointer(pH)).Fht != 0 {
  14921 		pEntry = (*Hash)(unsafe.Pointer(pH)).Fht + uintptr(h)*8
  14922 		if (*_ht)(unsafe.Pointer(pEntry)).Fchain == elem {
  14923 			(*_ht)(unsafe.Pointer(pEntry)).Fchain = (*HashElem)(unsafe.Pointer(elem)).Fnext
  14924 		}
  14925 
  14926 		(*_ht)(unsafe.Pointer(pEntry)).Fcount--
  14927 	}
  14928 	Xsqlite3_free(tls, elem)
  14929 	(*Hash)(unsafe.Pointer(pH)).Fcount--
  14930 	if (*Hash)(unsafe.Pointer(pH)).Fcount == uint32(0) {
  14931 		Xsqlite3HashClear(tls, pH)
  14932 	}
  14933 }
  14934 
  14935 // Attempt to locate an element of the hash table pH with a key
  14936 // that matches pKey.  Return the data for this element if it is
  14937 // found, or NULL if there is no match.
  14938 func Xsqlite3HashFind(tls *libc.TLS, pH uintptr, pKey uintptr) uintptr {
  14939 	return (*HashElem)(unsafe.Pointer(findElementWithHash(tls, pH, pKey, uintptr(0)))).Fdata
  14940 }
  14941 
  14942 // Insert an element into the hash table pH.  The key is pKey
  14943 // and the data is "data".
  14944 //
  14945 // If no element exists with a matching key, then a new
  14946 // element is created and NULL is returned.
  14947 //
  14948 // If another element already exists with the same key, then the
  14949 // new data replaces the old data and the old data is returned.
  14950 // The key is not copied in this instance.  If a malloc fails, then
  14951 // the new data is returned and the hash table is unchanged.
  14952 //
  14953 // If the "data" parameter to this function is NULL, then the
  14954 // element corresponding to "key" is removed from the hash table.
  14955 func Xsqlite3HashInsert(tls *libc.TLS, pH uintptr, pKey uintptr, data uintptr) uintptr {
  14956 	bp := tls.Alloc(4)
  14957 	defer tls.Free(4)
  14958 
  14959 	var elem uintptr
  14960 	var new_elem uintptr
  14961 
  14962 	elem = findElementWithHash(tls, pH, pKey, bp)
  14963 	if (*HashElem)(unsafe.Pointer(elem)).Fdata != 0 {
  14964 		var old_data uintptr = (*HashElem)(unsafe.Pointer(elem)).Fdata
  14965 		if data == uintptr(0) {
  14966 			removeElementGivenHash(tls, pH, elem, *(*uint32)(unsafe.Pointer(bp)))
  14967 		} else {
  14968 			(*HashElem)(unsafe.Pointer(elem)).Fdata = data
  14969 			(*HashElem)(unsafe.Pointer(elem)).FpKey = pKey
  14970 		}
  14971 		return old_data
  14972 	}
  14973 	if data == uintptr(0) {
  14974 		return uintptr(0)
  14975 	}
  14976 	new_elem = Xsqlite3Malloc(tls, uint64(unsafe.Sizeof(HashElem{})))
  14977 	if new_elem == uintptr(0) {
  14978 		return data
  14979 	}
  14980 	(*HashElem)(unsafe.Pointer(new_elem)).FpKey = pKey
  14981 	(*HashElem)(unsafe.Pointer(new_elem)).Fdata = data
  14982 	(*Hash)(unsafe.Pointer(pH)).Fcount++
  14983 	if (*Hash)(unsafe.Pointer(pH)).Fcount >= uint32(10) && (*Hash)(unsafe.Pointer(pH)).Fcount > uint32(2)*(*Hash)(unsafe.Pointer(pH)).Fhtsize {
  14984 		if rehash(tls, pH, (*Hash)(unsafe.Pointer(pH)).Fcount*uint32(2)) != 0 {
  14985 			*(*uint32)(unsafe.Pointer(bp)) = strHash(tls, pKey) % (*Hash)(unsafe.Pointer(pH)).Fhtsize
  14986 		}
  14987 	}
  14988 	insertElement(tls, pH, func() uintptr {
  14989 		if (*Hash)(unsafe.Pointer(pH)).Fht != 0 {
  14990 			return (*Hash)(unsafe.Pointer(pH)).Fht + uintptr(*(*uint32)(unsafe.Pointer(bp)))*8
  14991 		}
  14992 		return uintptr(0)
  14993 	}(), new_elem)
  14994 	return uintptr(0)
  14995 }
  14996 
  14997 // ************* End of hash.c ***********************************************
  14998 // ************* Begin file opcodes.c ****************************************
  14999 // Automatically generated.  Do not edit
  15000 // See the tool/mkopcodec.tcl script for details.
  15001 func Xsqlite3OpcodeName(tls *libc.TLS, i int32) uintptr {
  15002 	return azName[i]
  15003 }
  15004 
  15005 var azName = [187]uintptr{
  15006 	ts + 1683,
  15007 	ts + 1693,
  15008 	ts + 1704,
  15009 	ts + 1716,
  15010 	ts + 1727,
  15011 	ts + 1739,
  15012 	ts + 1746,
  15013 	ts + 1754,
  15014 	ts + 1762,
  15015 	ts + 1767,
  15016 	ts + 1772,
  15017 	ts + 1778,
  15018 	ts + 1792,
  15019 	ts + 1798,
  15020 	ts + 1808,
  15021 	ts + 1813,
  15022 	ts + 1818,
  15023 	ts + 1821,
  15024 	ts + 1827,
  15025 	ts + 1834,
  15026 	ts + 1838,
  15027 	ts + 1848,
  15028 	ts + 1855,
  15029 	ts + 1862,
  15030 	ts + 1869,
  15031 	ts + 1876,
  15032 	ts + 1886,
  15033 	ts + 1895,
  15034 	ts + 1906,
  15035 	ts + 1915,
  15036 	ts + 1921,
  15037 	ts + 1931,
  15038 	ts + 1941,
  15039 	ts + 1946,
  15040 	ts + 1956,
  15041 	ts + 1967,
  15042 	ts + 1972,
  15043 	ts + 1979,
  15044 	ts + 1990,
  15045 	ts + 1995,
  15046 	ts + 2000,
  15047 	ts + 2006,
  15048 	ts + 2012,
  15049 	ts + 2018,
  15050 	ts + 2021,
  15051 	ts + 2025,
  15052 	ts + 2031,
  15053 	ts + 2042,
  15054 	ts + 2053,
  15055 	ts + 2061,
  15056 	ts + 2070,
  15057 	ts + 2077,
  15058 	ts + 2085,
  15059 	ts + 2088,
  15060 	ts + 2091,
  15061 	ts + 2094,
  15062 	ts + 2097,
  15063 	ts + 2100,
  15064 	ts + 2103,
  15065 	ts + 2110,
  15066 	ts + 2116,
  15067 	ts + 2126,
  15068 	ts + 2139,
  15069 	ts + 2150,
  15070 	ts + 2156,
  15071 	ts + 2163,
  15072 	ts + 2172,
  15073 	ts + 2181,
  15074 	ts + 2188,
  15075 	ts + 2201,
  15076 	ts + 2212,
  15077 	ts + 2217,
  15078 	ts + 2225,
  15079 	ts + 2231,
  15080 	ts + 2238,
  15081 	ts + 2250,
  15082 	ts + 2255,
  15083 	ts + 2264,
  15084 	ts + 2269,
  15085 	ts + 2278,
  15086 	ts + 2283,
  15087 	ts + 2288,
  15088 	ts + 2294,
  15089 	ts + 2302,
  15090 	ts + 2310,
  15091 	ts + 2320,
  15092 	ts + 2328,
  15093 	ts + 2335,
  15094 	ts + 2348,
  15095 	ts + 2353,
  15096 	ts + 2365,
  15097 	ts + 2373,
  15098 	ts + 2380,
  15099 	ts + 2391,
  15100 	ts + 2398,
  15101 	ts + 2405,
  15102 	ts + 2415,
  15103 	ts + 2424,
  15104 	ts + 2435,
  15105 	ts + 2441,
  15106 	ts + 2452,
  15107 	ts + 2462,
  15108 	ts + 2472,
  15109 	ts + 2479,
  15110 	ts + 2485,
  15111 	ts + 2495,
  15112 	ts + 2506,
  15113 	ts + 2510,
  15114 	ts + 2519,
  15115 	ts + 2528,
  15116 	ts + 2535,
  15117 	ts + 2545,
  15118 	ts + 2552,
  15119 	ts + 2561,
  15120 	ts + 2571,
  15121 	ts + 2578,
  15122 	ts + 2586,
  15123 	ts + 2600,
  15124 	ts + 2608,
  15125 	ts + 2622,
  15126 	ts + 2633,
  15127 	ts + 2646,
  15128 	ts + 2657,
  15129 	ts + 2663,
  15130 	ts + 2675,
  15131 	ts + 2684,
  15132 	ts + 2692,
  15133 	ts + 2701,
  15134 	ts + 2710,
  15135 	ts + 2717,
  15136 	ts + 2725,
  15137 	ts + 2732,
  15138 	ts + 2743,
  15139 	ts + 2757,
  15140 	ts + 2768,
  15141 	ts + 2776,
  15142 	ts + 2782,
  15143 	ts + 2790,
  15144 	ts + 2798,
  15145 	ts + 2808,
  15146 	ts + 2821,
  15147 	ts + 2831,
  15148 	ts + 2844,
  15149 	ts + 2853,
  15150 	ts + 2864,
  15151 	ts + 2872,
  15152 	ts + 2878,
  15153 	ts + 2890,
  15154 	ts + 2902,
  15155 	ts + 2910,
  15156 	ts + 2922,
  15157 	ts + 2935,
  15158 	ts + 2945,
  15159 	ts + 2955,
  15160 	ts + 2960,
  15161 	ts + 2972,
  15162 	ts + 2984,
  15163 	ts + 2994,
  15164 	ts + 3000,
  15165 	ts + 3010,
  15166 	ts + 3017,
  15167 	ts + 3029,
  15168 	ts + 3040,
  15169 	ts + 3048,
  15170 	ts + 3057,
  15171 	ts + 3066,
  15172 	ts + 3075,
  15173 	ts + 3082,
  15174 	ts + 3093,
  15175 	ts + 3106,
  15176 	ts + 3116,
  15177 	ts + 3123,
  15178 	ts + 3131,
  15179 	ts + 3140,
  15180 	ts + 3146,
  15181 	ts + 3154,
  15182 	ts + 3162,
  15183 	ts + 3170,
  15184 	ts + 3180,
  15185 	ts + 3189,
  15186 	ts + 3200,
  15187 	ts + 3210,
  15188 	ts + 3216,
  15189 	ts + 3227,
  15190 	ts + 3238,
  15191 	ts + 3243,
  15192 	ts + 3251,
  15193 }
  15194 
  15195 type stat = struct {
  15196 	Fst_dev      X__dev_t
  15197 	F__pad1      uint16
  15198 	F__ccgo_pad1 [2]byte
  15199 	F__st_ino    X__ino_t
  15200 	Fst_mode     X__mode_t
  15201 	Fst_nlink    X__nlink_t
  15202 	Fst_uid      X__uid_t
  15203 	Fst_gid      X__gid_t
  15204 	Fst_rdev     X__dev_t
  15205 	F__pad2      uint16
  15206 	F__ccgo_pad2 [6]byte
  15207 	Fst_size     X__off64_t
  15208 	Fst_blksize  X__blksize_t
  15209 	F__ccgo_pad3 [4]byte
  15210 	Fst_blocks   X__blkcnt64_t
  15211 	Fst_atim     struct {
  15212 		Ftv_sec  X__time_t
  15213 		Ftv_nsec X__syscall_slong_t
  15214 	}
  15215 	Fst_mtim struct {
  15216 		Ftv_sec  X__time_t
  15217 		Ftv_nsec X__syscall_slong_t
  15218 	}
  15219 	Fst_ctim struct {
  15220 		Ftv_sec  X__time_t
  15221 		Ftv_nsec X__syscall_slong_t
  15222 	}
  15223 	Fst_ino X__ino64_t
  15224 }
  15225 
  15226 type stat64 = struct {
  15227 	Fst_dev      X__dev_t
  15228 	F__pad1      uint32
  15229 	F__st_ino    X__ino_t
  15230 	Fst_mode     X__mode_t
  15231 	Fst_nlink    X__nlink_t
  15232 	Fst_uid      X__uid_t
  15233 	Fst_gid      X__gid_t
  15234 	Fst_rdev     X__dev_t
  15235 	F__pad2      uint32
  15236 	F__ccgo_pad1 [4]byte
  15237 	Fst_size     X__off64_t
  15238 	Fst_blksize  X__blksize_t
  15239 	F__ccgo_pad2 [4]byte
  15240 	Fst_blocks   X__blkcnt64_t
  15241 	Fst_atim     struct {
  15242 		Ftv_sec  X__time_t
  15243 		Ftv_nsec X__syscall_slong_t
  15244 	}
  15245 	Fst_mtim struct {
  15246 		Ftv_sec  X__time_t
  15247 		Ftv_nsec X__syscall_slong_t
  15248 	}
  15249 	Fst_ctim struct {
  15250 		Ftv_sec  X__time_t
  15251 		Ftv_nsec X__syscall_slong_t
  15252 	}
  15253 	Fst_ino X__ino64_t
  15254 }
  15255 
  15256 type X__s8 = int8
  15257 type X__u8 = uint8
  15258 
  15259 type X__s16 = int16
  15260 type X__u16 = uint16
  15261 
  15262 type X__s32 = int32
  15263 type X__u32 = uint32
  15264 
  15265 type X__s64 = int64
  15266 type X__u64 = uint64
  15267 
  15268 type X__kernel_fd_set = struct{ Ffds_bits [32]uint32 }
  15269 
  15270 // Type of a signal handler.
  15271 type X__kernel_sighandler_t = uintptr
  15272 
  15273 // Type of a SYSV IPC key.
  15274 type X__kernel_key_t = int32
  15275 type X__kernel_mqd_t = int32
  15276 
  15277 type X__kernel_mode_t = uint16
  15278 
  15279 type X__kernel_ipc_pid_t = uint16
  15280 
  15281 type X__kernel_uid_t = uint16
  15282 type X__kernel_gid_t = uint16
  15283 
  15284 type X__kernel_old_dev_t = uint16
  15285 
  15286 type X__kernel_long_t = int32
  15287 type X__kernel_ulong_t = uint32
  15288 
  15289 type X__kernel_ino_t = X__kernel_ulong_t
  15290 
  15291 type X__kernel_pid_t = int32
  15292 
  15293 type X__kernel_suseconds_t = X__kernel_long_t
  15294 
  15295 type X__kernel_daddr_t = int32
  15296 
  15297 type X__kernel_uid32_t = uint32
  15298 type X__kernel_gid32_t = uint32
  15299 
  15300 type X__kernel_old_uid_t = X__kernel_uid_t
  15301 type X__kernel_old_gid_t = X__kernel_gid_t
  15302 
  15303 // Most 32 bit architectures use "unsigned int" size_t,
  15304 // and all 64 bit architectures use "unsigned long" size_t.
  15305 type X__kernel_size_t = uint32
  15306 type X__kernel_ssize_t = int32
  15307 type X__kernel_ptrdiff_t = int32
  15308 
  15309 type X__kernel_fsid_t = struct{ Fval [2]int32 }
  15310 
  15311 // anything below here should be completely generic
  15312 type X__kernel_off_t = X__kernel_long_t
  15313 type X__kernel_loff_t = int64
  15314 type X__kernel_old_time_t = X__kernel_long_t
  15315 type X__kernel_time_t = X__kernel_long_t
  15316 type X__kernel_time64_t = int64
  15317 type X__kernel_clock_t = X__kernel_long_t
  15318 type X__kernel_timer_t = int32
  15319 type X__kernel_clockid_t = int32
  15320 type X__kernel_caddr_t = uintptr
  15321 type X__kernel_uid16_t = uint16
  15322 type X__kernel_gid16_t = uint16
  15323 
  15324 type X__le16 = X__u16
  15325 type X__be16 = X__u16
  15326 type X__le32 = X__u32
  15327 type X__be32 = X__u32
  15328 type X__le64 = X__u64
  15329 type X__be64 = X__u64
  15330 
  15331 type X__sum16 = X__u16
  15332 type X__wsum = X__u32
  15333 
  15334 type X__poll_t = uint32
  15335 
  15336 type statx_timestamp = struct {
  15337 	Ftv_sec     X__s64
  15338 	Ftv_nsec    X__u32
  15339 	F__reserved X__s32
  15340 }
  15341 
  15342 type statx = struct {
  15343 	Fstx_mask            X__u32
  15344 	Fstx_blksize         X__u32
  15345 	Fstx_attributes      X__u64
  15346 	Fstx_nlink           X__u32
  15347 	Fstx_uid             X__u32
  15348 	Fstx_gid             X__u32
  15349 	Fstx_mode            X__u16
  15350 	F__spare0            [1]X__u16
  15351 	Fstx_ino             X__u64
  15352 	Fstx_size            X__u64
  15353 	Fstx_blocks          X__u64
  15354 	Fstx_attributes_mask X__u64
  15355 	Fstx_atime           struct {
  15356 		Ftv_sec     X__s64
  15357 		Ftv_nsec    X__u32
  15358 		F__reserved X__s32
  15359 	}
  15360 	Fstx_btime struct {
  15361 		Ftv_sec     X__s64
  15362 		Ftv_nsec    X__u32
  15363 		F__reserved X__s32
  15364 	}
  15365 	Fstx_ctime struct {
  15366 		Ftv_sec     X__s64
  15367 		Ftv_nsec    X__u32
  15368 		F__reserved X__s32
  15369 	}
  15370 	Fstx_mtime struct {
  15371 		Ftv_sec     X__s64
  15372 		Ftv_nsec    X__u32
  15373 		F__reserved X__s32
  15374 	}
  15375 	Fstx_rdev_major X__u32
  15376 	Fstx_rdev_minor X__u32
  15377 	Fstx_dev_major  X__u32
  15378 	Fstx_dev_minor  X__u32
  15379 	Fstx_mnt_id     X__u64
  15380 	F__spare2       X__u64
  15381 	F__spare3       [12]X__u64
  15382 }
  15383 
  15384 type flock = struct {
  15385 	Fl_type      int16
  15386 	Fl_whence    int16
  15387 	F__ccgo_pad1 [4]byte
  15388 	Fl_start     X__off64_t
  15389 	Fl_len       X__off64_t
  15390 	Fl_pid       X__pid_t
  15391 	F__ccgo_pad2 [4]byte
  15392 }
  15393 
  15394 type flock64 = struct {
  15395 	Fl_type      int16
  15396 	Fl_whence    int16
  15397 	F__ccgo_pad1 [4]byte
  15398 	Fl_start     X__off64_t
  15399 	Fl_len       X__off64_t
  15400 	Fl_pid       X__pid_t
  15401 	F__ccgo_pad2 [4]byte
  15402 }
  15403 
  15404 type iovec = struct {
  15405 	Fiov_base uintptr
  15406 	Fiov_len  Size_t
  15407 }
  15408 
  15409 type f_owner_ex = struct {
  15410 	Ftype uint32
  15411 	Fpid  X__pid_t
  15412 }
  15413 
  15414 type file_handle = struct {
  15415 	F__ccgo_pad1  [0]uint32
  15416 	Fhandle_bytes uint32
  15417 	Fhandle_type  int32
  15418 }
  15419 
  15420 type winsize = struct {
  15421 	Fws_row    uint16
  15422 	Fws_col    uint16
  15423 	Fws_xpixel uint16
  15424 	Fws_ypixel uint16
  15425 }
  15426 
  15427 type termio = struct {
  15428 	Fc_iflag     uint16
  15429 	Fc_oflag     uint16
  15430 	Fc_cflag     uint16
  15431 	Fc_lflag     uint16
  15432 	Fc_line      uint8
  15433 	Fc_cc        [8]uint8
  15434 	F__ccgo_pad1 [1]byte
  15435 }
  15436 
  15437 type Intptr_t = X__intptr_t
  15438 
  15439 type Socklen_t = X__socklen_t
  15440 
  15441 type timezone = struct {
  15442 	Ftz_minuteswest int32
  15443 	Ftz_dsttime     int32
  15444 }
  15445 
  15446 type itimerval = struct {
  15447 	Fit_interval struct {
  15448 		Ftv_sec  X__time_t
  15449 		Ftv_usec X__suseconds_t
  15450 	}
  15451 	Fit_value struct {
  15452 		Ftv_sec  X__time_t
  15453 		Ftv_usec X__suseconds_t
  15454 	}
  15455 }
  15456 
  15457 // Use the nicer parameter type only in GNU mode and not for C++ since the
  15458 //
  15459 //	strict C++ rules prevent the automatic promotion.
  15460 type X__itimer_which_t = uint32
  15461 
  15462 type Error_t = int32
  15463 
  15464 type unixShm = struct {
  15465 	FpShmNode    uintptr
  15466 	FpNext       uintptr
  15467 	FhasMutex    U8
  15468 	Fid          U8
  15469 	FsharedMask  U16
  15470 	FexclMask    U16
  15471 	F__ccgo_pad1 [2]byte
  15472 }
  15473 
  15474 // Forward references
  15475 type UnixShm = unixShm
  15476 type unixShmNode = struct {
  15477 	FpInode     uintptr
  15478 	FpShmMutex  uintptr
  15479 	FzFilename  uintptr
  15480 	FhShm       int32
  15481 	FszRegion   int32
  15482 	FnRegion    U16
  15483 	FisReadonly U8
  15484 	FisUnlocked U8
  15485 	FapRegion   uintptr
  15486 	FnRef       int32
  15487 	FpFirst     uintptr
  15488 	FaLock      [8]int32
  15489 }
  15490 
  15491 // Connection shared memory
  15492 type UnixShmNode = unixShmNode
  15493 type unixInodeInfo = struct {
  15494 	FfileId struct {
  15495 		Fdev Dev_t
  15496 		Fino U64
  15497 	}
  15498 	FpLockMutex   uintptr
  15499 	FnShared      int32
  15500 	FnLock        int32
  15501 	FeFileLock    uint8
  15502 	FbProcessLock uint8
  15503 	F__ccgo_pad1  [2]byte
  15504 	FpUnused      uintptr
  15505 	FnRef         int32
  15506 	FpShmNode     uintptr
  15507 	FpNext        uintptr
  15508 	FpPrev        uintptr
  15509 	F__ccgo_pad2  [4]byte
  15510 }
  15511 
  15512 // Shared memory instance
  15513 type UnixInodeInfo = unixInodeInfo
  15514 type UnixUnusedFd1 = struct {
  15515 	Ffd    int32
  15516 	Fflags int32
  15517 	FpNext uintptr
  15518 }
  15519 
  15520 // An i-node
  15521 type UnixUnusedFd = UnixUnusedFd1
  15522 
  15523 type unixFile = struct {
  15524 	FpMethod               uintptr
  15525 	FpVfs                  uintptr
  15526 	FpInode                uintptr
  15527 	Fh                     int32
  15528 	FeFileLock             uint8
  15529 	F__ccgo_pad1           [1]byte
  15530 	FctrlFlags             uint16
  15531 	FlastErrno             int32
  15532 	FlockingContext        uintptr
  15533 	FpPreallocatedUnused   uintptr
  15534 	FzPath                 uintptr
  15535 	FpShm                  uintptr
  15536 	FszChunk               int32
  15537 	FnFetchOut             int32
  15538 	FmmapSize              Sqlite3_int64
  15539 	FmmapSizeActual        Sqlite3_int64
  15540 	FmmapSizeMax           Sqlite3_int64
  15541 	FpMapRegion            uintptr
  15542 	FsectorSize            int32
  15543 	FdeviceCharacteristics int32
  15544 	F__ccgo_pad2           [4]byte
  15545 }
  15546 
  15547 // The unixFile structure is subclass of sqlite3_file specific to the unix
  15548 // VFS implementations.
  15549 type UnixFile = unixFile
  15550 
  15551 var randomnessPid Pid_t = 0
  15552 
  15553 func posixOpen(tls *libc.TLS, zFile uintptr, flags int32, mode int32) int32 {
  15554 	bp := tls.Alloc(8)
  15555 	defer tls.Free(8)
  15556 
  15557 	return libc.Xopen(tls, zFile, flags, libc.VaList(bp, mode))
  15558 }
  15559 
  15560 type unix_syscall = struct {
  15561 	FzName    uintptr
  15562 	FpCurrent Sqlite3_syscall_ptr
  15563 	FpDefault Sqlite3_syscall_ptr
  15564 }
  15565 
  15566 var aSyscall = [29]unix_syscall{
  15567 	{FzName: ts + 3261, FpCurrent: 0},
  15568 	{FzName: ts + 3266, FpCurrent: 0},
  15569 	{FzName: ts + 3272, FpCurrent: 0},
  15570 	{FzName: ts + 3279, FpCurrent: 0},
  15571 	{FzName: ts + 3286, FpCurrent: 0},
  15572 	{FzName: ts + 3291, FpCurrent: 0},
  15573 	{FzName: ts + 3297, FpCurrent: 0},
  15574 	{FzName: ts + 3307, FpCurrent: 0},
  15575 	{FzName: ts + 3313, FpCurrent: 0},
  15576 	{FzName: ts + 3318},
  15577 	{FzName: ts + 3324},
  15578 	{FzName: ts + 3332, FpCurrent: 0},
  15579 	{FzName: ts + 3338},
  15580 	{FzName: ts + 3345},
  15581 	{FzName: ts + 3354, FpCurrent: 0},
  15582 	{FzName: ts + 3361},
  15583 	{FzName: ts + 3371, FpCurrent: 0},
  15584 	{FzName: ts + 3378, FpCurrent: 0},
  15585 	{FzName: ts + 3392, FpCurrent: 0},
  15586 	{FzName: ts + 3398, FpCurrent: 0},
  15587 	{FzName: ts + 3404, FpCurrent: 0},
  15588 	{FzName: ts + 3411, FpCurrent: 0},
  15589 	{FzName: ts + 3419, FpCurrent: 0},
  15590 	{FzName: ts + 3424, FpCurrent: 0},
  15591 	{FzName: ts + 3431, FpCurrent: 0},
  15592 	{FzName: ts + 3438, FpCurrent: 0},
  15593 	{FzName: ts + 3450, FpCurrent: 0},
  15594 	{FzName: ts + 3459, FpCurrent: 0},
  15595 	{FzName: ts + 3465},
  15596 }
  15597 
  15598 func robustFchown(tls *libc.TLS, fd int32, uid Uid_t, gid Gid_t) int32 {
  15599 	if (*(*func(*libc.TLS) Uid_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 21*12 + 4)))(tls) != 0 {
  15600 		return 0
  15601 	}
  15602 	return (*(*func(*libc.TLS, int32, Uid_t, Gid_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 20*12 + 4)))(tls, fd, uid, gid)
  15603 }
  15604 
  15605 func unixSetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr, pNewFunc Sqlite3_syscall_ptr) int32 {
  15606 	var i uint32
  15607 	var rc int32 = SQLITE_NOTFOUND
  15608 
  15609 	_ = pNotUsed
  15610 	if zName == uintptr(0) {
  15611 		rc = SQLITE_OK
  15612 		for i = uint32(0); i < uint32(unsafe.Sizeof(aSyscall))/uint32(unsafe.Sizeof(unix_syscall{})); i++ {
  15613 			if aSyscall[i].FpDefault != 0 {
  15614 				aSyscall[i].FpCurrent = aSyscall[i].FpDefault
  15615 			}
  15616 		}
  15617 	} else {
  15618 		for i = uint32(0); i < uint32(unsafe.Sizeof(aSyscall))/uint32(unsafe.Sizeof(unix_syscall{})); i++ {
  15619 			if libc.Xstrcmp(tls, zName, aSyscall[i].FzName) == 0 {
  15620 				if aSyscall[i].FpDefault == uintptr(0) {
  15621 					aSyscall[i].FpDefault = aSyscall[i].FpCurrent
  15622 				}
  15623 				rc = SQLITE_OK
  15624 				if pNewFunc == uintptr(0) {
  15625 					pNewFunc = aSyscall[i].FpDefault
  15626 				}
  15627 				aSyscall[i].FpCurrent = pNewFunc
  15628 				break
  15629 			}
  15630 		}
  15631 	}
  15632 	return rc
  15633 }
  15634 
  15635 func unixGetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr) Sqlite3_syscall_ptr {
  15636 	var i uint32
  15637 
  15638 	_ = pNotUsed
  15639 	for i = uint32(0); i < uint32(unsafe.Sizeof(aSyscall))/uint32(unsafe.Sizeof(unix_syscall{})); i++ {
  15640 		if libc.Xstrcmp(tls, zName, aSyscall[i].FzName) == 0 {
  15641 			return aSyscall[i].FpCurrent
  15642 		}
  15643 	}
  15644 	return uintptr(0)
  15645 }
  15646 
  15647 func unixNextSystemCall(tls *libc.TLS, p uintptr, zName uintptr) uintptr {
  15648 	var i int32 = -1
  15649 
  15650 	_ = p
  15651 	if zName != 0 {
  15652 		for i = 0; i < int32(uint32(unsafe.Sizeof(aSyscall))/uint32(unsafe.Sizeof(unix_syscall{})))-1; i++ {
  15653 			if libc.Xstrcmp(tls, zName, aSyscall[i].FzName) == 0 {
  15654 				break
  15655 			}
  15656 		}
  15657 	}
  15658 	for i++; i < int32(uint32(unsafe.Sizeof(aSyscall))/uint32(unsafe.Sizeof(unix_syscall{}))); i++ {
  15659 		if aSyscall[i].FpCurrent != uintptr(0) {
  15660 			return aSyscall[i].FzName
  15661 		}
  15662 	}
  15663 	return uintptr(0)
  15664 }
  15665 
  15666 func robust_open(tls *libc.TLS, z uintptr, f int32, m Mode_t) int32 {
  15667 	bp := tls.Alloc(120)
  15668 	defer tls.Free(120)
  15669 
  15670 	var fd int32
  15671 	var m2 Mode_t
  15672 	if m != 0 {
  15673 		m2 = m
  15674 	} else {
  15675 		m2 = uint32(SQLITE_DEFAULT_FILE_PERMISSIONS)
  15676 	}
  15677 	for 1 != 0 {
  15678 		fd = (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4)))(tls, z, f|02000000, int32(m2))
  15679 		if fd < 0 {
  15680 			if *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == EINTR {
  15681 				continue
  15682 			}
  15683 			break
  15684 		}
  15685 		if fd >= SQLITE_MINIMUM_FILE_DESCRIPTOR {
  15686 			break
  15687 		}
  15688 		if f&(O_EXCL|O_CREAT) == O_EXCL|O_CREAT {
  15689 			(*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 16*12 + 4)))(tls, z)
  15690 		}
  15691 		(*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 1*12 + 4)))(tls, fd)
  15692 		Xsqlite3_log(tls, SQLITE_WARNING,
  15693 			ts+3471, libc.VaList(bp, z, fd))
  15694 		fd = -1
  15695 		if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4)))(tls, ts+3514, O_RDONLY, int32(m)) < 0 {
  15696 			break
  15697 		}
  15698 	}
  15699 	if fd >= 0 {
  15700 		if m != Mode_t(0) {
  15701 			if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, fd, bp+16) == 0 &&
  15702 				(*stat)(unsafe.Pointer(bp+16)).Fst_size == int64(0) &&
  15703 				(*stat)(unsafe.Pointer(bp+16)).Fst_mode&X__mode_t(0777) != m {
  15704 				(*(*func(*libc.TLS, int32, Mode_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 14*12 + 4)))(tls, fd, m)
  15705 			}
  15706 		}
  15707 	}
  15708 	return fd
  15709 }
  15710 
  15711 var unixBigLock uintptr = uintptr(0)
  15712 
  15713 func unixEnterMutex(tls *libc.TLS) {
  15714 	Xsqlite3_mutex_enter(tls, unixBigLock)
  15715 }
  15716 
  15717 func unixLeaveMutex(tls *libc.TLS) {
  15718 	Xsqlite3_mutex_leave(tls, unixBigLock)
  15719 }
  15720 
  15721 func robust_ftruncate(tls *libc.TLS, h int32, sz Sqlite3_int64) int32 {
  15722 	var rc int32
  15723 	for __ccgo := true; __ccgo; __ccgo = rc < 0 && *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == EINTR {
  15724 		rc = (*(*func(*libc.TLS, int32, Off_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 6*12 + 4)))(tls, h, sz)
  15725 	}
  15726 	return rc
  15727 }
  15728 
  15729 func sqliteErrorFromPosixError(tls *libc.TLS, posixError int32, sqliteIOErr int32) int32 {
  15730 	switch posixError {
  15731 	case EACCES:
  15732 		fallthrough
  15733 	case EAGAIN:
  15734 		fallthrough
  15735 	case ETIMEDOUT:
  15736 		fallthrough
  15737 	case EBUSY:
  15738 		fallthrough
  15739 	case EINTR:
  15740 		fallthrough
  15741 	case ENOLCK:
  15742 		return SQLITE_BUSY
  15743 
  15744 	case EPERM:
  15745 		return SQLITE_PERM
  15746 
  15747 	default:
  15748 		return sqliteIOErr
  15749 	}
  15750 	return int32(0)
  15751 }
  15752 
  15753 type vxworksFileId = struct {
  15754 	FpNext          uintptr
  15755 	FnRef           int32
  15756 	FnName          int32
  15757 	FzCanonicalName uintptr
  15758 }
  15759 
  15760 type unixFileId = struct {
  15761 	Fdev Dev_t
  15762 	Fino U64
  15763 }
  15764 
  15765 var inodeList uintptr = uintptr(0)
  15766 
  15767 func unixLogErrorAtLine(tls *libc.TLS, errcode int32, zFunc uintptr, zPath uintptr, iLine int32) int32 {
  15768 	bp := tls.Alloc(40)
  15769 	defer tls.Free(40)
  15770 
  15771 	var zErr uintptr
  15772 	var iErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  15773 
  15774 	zErr = ts + 1554
  15775 
  15776 	if zPath == uintptr(0) {
  15777 		zPath = ts + 1554
  15778 	}
  15779 	Xsqlite3_log(tls, errcode,
  15780 		ts+3524,
  15781 		libc.VaList(bp, iLine, iErrno, zFunc, zPath, zErr))
  15782 
  15783 	return errcode
  15784 }
  15785 
  15786 func robust_close(tls *libc.TLS, pFile uintptr, h int32, lineno int32) {
  15787 	if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 1*12 + 4)))(tls, h) != 0 {
  15788 		unixLogErrorAtLine(tls, SQLITE_IOERR|int32(16)<<8, ts+3266,
  15789 			func() uintptr {
  15790 				if pFile != 0 {
  15791 					return (*UnixFile)(unsafe.Pointer(pFile)).FzPath
  15792 				}
  15793 				return uintptr(0)
  15794 			}(), lineno)
  15795 	}
  15796 }
  15797 
  15798 func storeLastErrno(tls *libc.TLS, pFile uintptr, error int32) {
  15799 	(*UnixFile)(unsafe.Pointer(pFile)).FlastErrno = error
  15800 }
  15801 
  15802 func closePendingFds(tls *libc.TLS, pFile uintptr) {
  15803 	var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  15804 	var p uintptr
  15805 	var pNext uintptr
  15806 
  15807 	for p = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpUnused; p != 0; p = pNext {
  15808 		pNext = (*UnixUnusedFd)(unsafe.Pointer(p)).FpNext
  15809 		robust_close(tls, pFile, (*UnixUnusedFd)(unsafe.Pointer(p)).Ffd, 38275)
  15810 		Xsqlite3_free(tls, p)
  15811 	}
  15812 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FpUnused = uintptr(0)
  15813 }
  15814 
  15815 func releaseInodeInfo(tls *libc.TLS, pFile uintptr) {
  15816 	var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  15817 
  15818 	if pInode != 0 {
  15819 		(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef--
  15820 		if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef == 0 {
  15821 			Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  15822 			closePendingFds(tls, pFile)
  15823 			Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  15824 			if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpPrev != 0 {
  15825 				(*UnixInodeInfo)(unsafe.Pointer((*UnixInodeInfo)(unsafe.Pointer(pInode)).FpPrev)).FpNext = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext
  15826 			} else {
  15827 				inodeList = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext
  15828 			}
  15829 			if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext != 0 {
  15830 				(*UnixInodeInfo)(unsafe.Pointer((*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext)).FpPrev = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpPrev
  15831 			}
  15832 			Xsqlite3_mutex_free(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  15833 			Xsqlite3_free(tls, pInode)
  15834 		}
  15835 	}
  15836 }
  15837 
  15838 func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 {
  15839 	bp := tls.Alloc(120)
  15840 	defer tls.Free(120)
  15841 
  15842 	var rc int32
  15843 	var fd int32
  15844 
  15845 	var pInode uintptr = uintptr(0)
  15846 
  15847 	fd = (*UnixFile)(unsafe.Pointer(pFile)).Fh
  15848 	rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, fd, bp)
  15849 	if rc != 0 {
  15850 		storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  15851 		return SQLITE_IOERR
  15852 	}
  15853 
  15854 	libc.Xmemset(tls, bp+104, 0, uint32(unsafe.Sizeof(unixFileId{})))
  15855 	(*unixFileId)(unsafe.Pointer(bp + 104)).Fdev = (*stat)(unsafe.Pointer(bp)).Fst_dev
  15856 	(*unixFileId)(unsafe.Pointer(bp + 104)).Fino = (*stat)(unsafe.Pointer(bp)).Fst_ino
  15857 
  15858 	pInode = inodeList
  15859 	for pInode != 0 && libc.Xmemcmp(tls, bp+104, pInode, uint32(unsafe.Sizeof(unixFileId{}))) != 0 {
  15860 		pInode = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext
  15861 	}
  15862 	if pInode == uintptr(0) {
  15863 		pInode = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(UnixInodeInfo{})))
  15864 		if pInode == uintptr(0) {
  15865 			return SQLITE_NOMEM
  15866 		}
  15867 		libc.Xmemset(tls, pInode, 0, uint32(unsafe.Sizeof(UnixInodeInfo{})))
  15868 		libc.Xmemcpy(tls, pInode, bp+104, uint32(unsafe.Sizeof(unixFileId{})))
  15869 		if Xsqlite3Config.FbCoreMutex != 0 {
  15870 			(*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST)
  15871 			if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex == uintptr(0) {
  15872 				Xsqlite3_free(tls, pInode)
  15873 				return SQLITE_NOMEM
  15874 			}
  15875 		}
  15876 		(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef = 1
  15877 
  15878 		(*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext = inodeList
  15879 		(*UnixInodeInfo)(unsafe.Pointer(pInode)).FpPrev = uintptr(0)
  15880 		if inodeList != 0 {
  15881 			(*UnixInodeInfo)(unsafe.Pointer(inodeList)).FpPrev = pInode
  15882 		}
  15883 		inodeList = pInode
  15884 	} else {
  15885 		(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef++
  15886 	}
  15887 	*(*uintptr)(unsafe.Pointer(ppInode)) = pInode
  15888 	return SQLITE_OK
  15889 }
  15890 
  15891 func fileHasMoved(tls *libc.TLS, pFile uintptr) int32 {
  15892 	bp := tls.Alloc(104)
  15893 	defer tls.Free(104)
  15894 
  15895 	return libc.Bool32((*UnixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0) && ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp) != 0 ||
  15896 		(*stat)(unsafe.Pointer(bp)).Fst_ino != (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FfileId.Fino))
  15897 }
  15898 
  15899 func verifyDbFile(tls *libc.TLS, pFile uintptr) {
  15900 	bp := tls.Alloc(136)
  15901 	defer tls.Free(136)
  15902 
  15903 	var rc int32
  15904 
  15905 	if int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags)&UNIXFILE_NOLOCK != 0 {
  15906 		return
  15907 	}
  15908 
  15909 	rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp+32)
  15910 	if rc != 0 {
  15911 		Xsqlite3_log(tls, SQLITE_WARNING, ts+3555, libc.VaList(bp, (*UnixFile)(unsafe.Pointer(pFile)).FzPath))
  15912 		return
  15913 	}
  15914 	if (*stat)(unsafe.Pointer(bp+32)).Fst_nlink == X__nlink_t(0) {
  15915 		Xsqlite3_log(tls, SQLITE_WARNING, ts+3579, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath))
  15916 		return
  15917 	}
  15918 	if (*stat)(unsafe.Pointer(bp+32)).Fst_nlink > X__nlink_t(1) {
  15919 		Xsqlite3_log(tls, SQLITE_WARNING, ts+3608, libc.VaList(bp+16, (*UnixFile)(unsafe.Pointer(pFile)).FzPath))
  15920 		return
  15921 	}
  15922 	if fileHasMoved(tls, pFile) != 0 {
  15923 		Xsqlite3_log(tls, SQLITE_WARNING, ts+3635, libc.VaList(bp+24, (*UnixFile)(unsafe.Pointer(pFile)).FzPath))
  15924 		return
  15925 	}
  15926 }
  15927 
  15928 func unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 {
  15929 	bp := tls.Alloc(40)
  15930 	defer tls.Free(40)
  15931 
  15932 	var rc int32 = SQLITE_OK
  15933 	var reserved int32 = 0
  15934 	var pFile uintptr = id
  15935 
  15936 	Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex)
  15937 
  15938 	if int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > SHARED_LOCK {
  15939 		reserved = 1
  15940 	}
  15941 
  15942 	if !(reserved != 0) && !(int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FbProcessLock) != 0) {
  15943 		(*flock)(unsafe.Pointer(bp + 8)).Fl_whence = int16(SEEK_SET)
  15944 		(*flock)(unsafe.Pointer(bp + 8)).Fl_start = X__off64_t(Xsqlite3PendingByte + 1)
  15945 		(*flock)(unsafe.Pointer(bp + 8)).Fl_len = int64(1)
  15946 		(*flock)(unsafe.Pointer(bp + 8)).Fl_type = int16(F_WRLCK)
  15947 		if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 7*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_GETLK64, libc.VaList(bp, bp+8)) != 0 {
  15948 			rc = SQLITE_IOERR | int32(14)<<8
  15949 			storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  15950 		} else if int32((*flock)(unsafe.Pointer(bp+8)).Fl_type) != F_UNLCK {
  15951 			reserved = 1
  15952 		}
  15953 	}
  15954 
  15955 	Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex)
  15956 
  15957 	*(*int32)(unsafe.Pointer(pResOut)) = reserved
  15958 	return rc
  15959 }
  15960 
  15961 func unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) int32 {
  15962 	bp := tls.Alloc(48)
  15963 	defer tls.Free(48)
  15964 
  15965 	var rc int32
  15966 	var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  15967 
  15968 	if int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags)&(UNIXFILE_EXCL|UNIXFILE_RDONLY) == UNIXFILE_EXCL {
  15969 		if int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock) == 0 {
  15970 			(*flock)(unsafe.Pointer(bp + 16)).Fl_whence = int16(SEEK_SET)
  15971 			(*flock)(unsafe.Pointer(bp + 16)).Fl_start = X__off64_t(Xsqlite3PendingByte + 2)
  15972 			(*flock)(unsafe.Pointer(bp + 16)).Fl_len = int64(SHARED_SIZE)
  15973 			(*flock)(unsafe.Pointer(bp + 16)).Fl_type = int16(F_WRLCK)
  15974 			rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 7*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_SETLK64, libc.VaList(bp, bp+16))
  15975 			if rc < 0 {
  15976 				return rc
  15977 			}
  15978 			(*UnixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock = uint8(1)
  15979 			(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++
  15980 		} else {
  15981 			rc = 0
  15982 		}
  15983 	} else {
  15984 		rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 7*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_SETLK64, libc.VaList(bp+8, pLock))
  15985 	}
  15986 	return rc
  15987 }
  15988 
  15989 func unixLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 {
  15990 	bp := tls.Alloc(32)
  15991 	defer tls.Free(32)
  15992 
  15993 	var rc int32
  15994 	var pFile uintptr
  15995 	var pInode uintptr
  15996 
  15997 	var tErrno int32
  15998 	rc = SQLITE_OK
  15999 	pFile = id
  16000 	tErrno = 0
  16001 
  16002 	if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) >= eFileLock) {
  16003 		goto __1
  16004 	}
  16005 
  16006 	return SQLITE_OK
  16007 __1:
  16008 	;
  16009 	pInode = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  16010 	Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  16011 
  16012 	if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) != int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) && (int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= PENDING_LOCK || eFileLock > SHARED_LOCK)) {
  16013 		goto __2
  16014 	}
  16015 	rc = SQLITE_BUSY
  16016 	goto end_lock
  16017 __2:
  16018 	;
  16019 	if !(eFileLock == SHARED_LOCK && (int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == SHARED_LOCK || int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == RESERVED_LOCK)) {
  16020 		goto __3
  16021 	}
  16022 
  16023 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK)
  16024 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared++
  16025 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++
  16026 	goto end_lock
  16027 __3:
  16028 	;
  16029 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(1)
  16030 	(*flock)(unsafe.Pointer(bp)).Fl_whence = int16(SEEK_SET)
  16031 	if !(eFileLock == SHARED_LOCK ||
  16032 		eFileLock == EXCLUSIVE_LOCK && int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) == RESERVED_LOCK) {
  16033 		goto __4
  16034 	}
  16035 	(*flock)(unsafe.Pointer(bp)).Fl_type = func() int16 {
  16036 		if eFileLock == SHARED_LOCK {
  16037 			return int16(F_RDLCK)
  16038 		}
  16039 		return int16(F_WRLCK)
  16040 	}()
  16041 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte)
  16042 	if !(unixFileLock(tls, pFile, bp) != 0) {
  16043 		goto __5
  16044 	}
  16045 	tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16046 	rc = sqliteErrorFromPosixError(tls, tErrno, SQLITE_IOERR|int32(15)<<8)
  16047 	if !(rc != SQLITE_BUSY) {
  16048 		goto __7
  16049 	}
  16050 	storeLastErrno(tls, pFile, tErrno)
  16051 __7:
  16052 	;
  16053 	goto end_lock
  16054 	goto __6
  16055 __5:
  16056 	if !(eFileLock == EXCLUSIVE_LOCK) {
  16057 		goto __8
  16058 	}
  16059 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(PENDING_LOCK)
  16060 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(PENDING_LOCK)
  16061 __8:
  16062 	;
  16063 __6:
  16064 	;
  16065 __4:
  16066 	;
  16067 	if !(eFileLock == SHARED_LOCK) {
  16068 		goto __9
  16069 	}
  16070 
  16071 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte + 2)
  16072 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(SHARED_SIZE)
  16073 	if !(unixFileLock(tls, pFile, bp) != 0) {
  16074 		goto __11
  16075 	}
  16076 	tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16077 	rc = sqliteErrorFromPosixError(tls, tErrno, SQLITE_IOERR|int32(15)<<8)
  16078 __11:
  16079 	;
  16080 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte)
  16081 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(1)
  16082 	(*flock)(unsafe.Pointer(bp)).Fl_type = int16(F_UNLCK)
  16083 	if !(unixFileLock(tls, pFile, bp) != 0 && rc == SQLITE_OK) {
  16084 		goto __12
  16085 	}
  16086 
  16087 	tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16088 	rc = SQLITE_IOERR | int32(8)<<8
  16089 __12:
  16090 	;
  16091 	if !(rc != 0) {
  16092 		goto __13
  16093 	}
  16094 	if !(rc != SQLITE_BUSY) {
  16095 		goto __15
  16096 	}
  16097 	storeLastErrno(tls, pFile, tErrno)
  16098 __15:
  16099 	;
  16100 	goto end_lock
  16101 	goto __14
  16102 __13:
  16103 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK)
  16104 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++
  16105 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared = 1
  16106 __14:
  16107 	;
  16108 	goto __10
  16109 __9:
  16110 	if !(eFileLock == EXCLUSIVE_LOCK && (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared > 1) {
  16111 		goto __16
  16112 	}
  16113 
  16114 	rc = SQLITE_BUSY
  16115 	goto __17
  16116 __16:
  16117 	;
  16118 	(*flock)(unsafe.Pointer(bp)).Fl_type = int16(F_WRLCK)
  16119 
  16120 	if !(eFileLock == RESERVED_LOCK) {
  16121 		goto __18
  16122 	}
  16123 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte + 1)
  16124 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(1)
  16125 	goto __19
  16126 __18:
  16127 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte + 2)
  16128 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(SHARED_SIZE)
  16129 __19:
  16130 	;
  16131 	if !(unixFileLock(tls, pFile, bp) != 0) {
  16132 		goto __20
  16133 	}
  16134 	tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16135 	rc = sqliteErrorFromPosixError(tls, tErrno, SQLITE_IOERR|int32(15)<<8)
  16136 	if !(rc != SQLITE_BUSY) {
  16137 		goto __21
  16138 	}
  16139 	storeLastErrno(tls, pFile, tErrno)
  16140 __21:
  16141 	;
  16142 __20:
  16143 	;
  16144 __17:
  16145 	;
  16146 __10:
  16147 	;
  16148 	if !(rc == SQLITE_OK) {
  16149 		goto __22
  16150 	}
  16151 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock)
  16152 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(eFileLock)
  16153 __22:
  16154 	;
  16155 end_lock:
  16156 	Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  16157 
  16158 	return rc
  16159 }
  16160 
  16161 func setPendingFd(tls *libc.TLS, pFile uintptr) {
  16162 	var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  16163 	var p uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused
  16164 
  16165 	(*UnixUnusedFd)(unsafe.Pointer(p)).FpNext = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpUnused
  16166 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FpUnused = p
  16167 	(*UnixFile)(unsafe.Pointer(pFile)).Fh = -1
  16168 	(*UnixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused = uintptr(0)
  16169 }
  16170 
  16171 func posixUnlock(tls *libc.TLS, id uintptr, eFileLock int32, handleNFSUnlock int32) int32 {
  16172 	bp := tls.Alloc(32)
  16173 	defer tls.Free(32)
  16174 
  16175 	var pFile uintptr
  16176 	var pInode uintptr
  16177 
  16178 	var rc int32
  16179 	pFile = id
  16180 	rc = SQLITE_OK
  16181 
  16182 	if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) <= eFileLock) {
  16183 		goto __1
  16184 	}
  16185 	return SQLITE_OK
  16186 __1:
  16187 	;
  16188 	pInode = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  16189 	Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  16190 
  16191 	if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > SHARED_LOCK) {
  16192 		goto __2
  16193 	}
  16194 
  16195 	if !(eFileLock == SHARED_LOCK) {
  16196 		goto __3
  16197 	}
  16198 	_ = handleNFSUnlock
  16199 
  16200 	(*flock)(unsafe.Pointer(bp)).Fl_type = int16(F_RDLCK)
  16201 	(*flock)(unsafe.Pointer(bp)).Fl_whence = int16(SEEK_SET)
  16202 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte + 2)
  16203 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(SHARED_SIZE)
  16204 	if !(unixFileLock(tls, pFile, bp) != 0) {
  16205 		goto __4
  16206 	}
  16207 
  16208 	rc = SQLITE_IOERR | int32(9)<<8
  16209 	storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16210 	goto end_unlock
  16211 __4:
  16212 	;
  16213 __3:
  16214 	;
  16215 	(*flock)(unsafe.Pointer(bp)).Fl_type = int16(F_UNLCK)
  16216 	(*flock)(unsafe.Pointer(bp)).Fl_whence = int16(SEEK_SET)
  16217 	(*flock)(unsafe.Pointer(bp)).Fl_start = X__off64_t(Xsqlite3PendingByte)
  16218 	(*flock)(unsafe.Pointer(bp)).Fl_len = int64(2)
  16219 	if !(unixFileLock(tls, pFile, bp) == 0) {
  16220 		goto __5
  16221 	}
  16222 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(SHARED_LOCK)
  16223 	goto __6
  16224 __5:
  16225 	rc = SQLITE_IOERR | int32(8)<<8
  16226 	storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16227 	goto end_unlock
  16228 __6:
  16229 	;
  16230 __2:
  16231 	;
  16232 	if !(eFileLock == NO_LOCK) {
  16233 		goto __7
  16234 	}
  16235 
  16236 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared--
  16237 	if !((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared == 0) {
  16238 		goto __8
  16239 	}
  16240 	(*flock)(unsafe.Pointer(bp)).Fl_type = int16(F_UNLCK)
  16241 	(*flock)(unsafe.Pointer(bp)).Fl_whence = int16(SEEK_SET)
  16242 	(*flock)(unsafe.Pointer(bp)).Fl_start = libc.AssignPtrInt64(bp+16, int64(0))
  16243 	if !(unixFileLock(tls, pFile, bp) == 0) {
  16244 		goto __9
  16245 	}
  16246 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(NO_LOCK)
  16247 	goto __10
  16248 __9:
  16249 	rc = SQLITE_IOERR | int32(8)<<8
  16250 	storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16251 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(NO_LOCK)
  16252 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(NO_LOCK)
  16253 __10:
  16254 	;
  16255 __8:
  16256 	;
  16257 	(*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock--
  16258 
  16259 	if !((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock == 0) {
  16260 		goto __11
  16261 	}
  16262 	closePendingFds(tls, pFile)
  16263 __11:
  16264 	;
  16265 __7:
  16266 	;
  16267 end_unlock:
  16268 	Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  16269 	if !(rc == SQLITE_OK) {
  16270 		goto __12
  16271 	}
  16272 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock)
  16273 __12:
  16274 	;
  16275 	return rc
  16276 }
  16277 
  16278 func unixUnlock(tls *libc.TLS, id uintptr, eFileLock int32) int32 {
  16279 	return posixUnlock(tls, id, eFileLock, 0)
  16280 }
  16281 
  16282 func closeUnixFile(tls *libc.TLS, id uintptr) int32 {
  16283 	var pFile uintptr = id
  16284 	unixUnmapfile(tls, pFile)
  16285 	if (*UnixFile)(unsafe.Pointer(pFile)).Fh >= 0 {
  16286 		robust_close(tls, pFile, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 39059)
  16287 		(*UnixFile)(unsafe.Pointer(pFile)).Fh = -1
  16288 	}
  16289 
  16290 	Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused)
  16291 	libc.Xmemset(tls, pFile, 0, uint32(unsafe.Sizeof(UnixFile{})))
  16292 	return SQLITE_OK
  16293 }
  16294 
  16295 func unixClose(tls *libc.TLS, id uintptr) int32 {
  16296 	var rc int32 = SQLITE_OK
  16297 	var pFile uintptr = id
  16298 	var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode
  16299 
  16300 	verifyDbFile(tls, pFile)
  16301 	unixUnlock(tls, id, NO_LOCK)
  16302 
  16303 	unixEnterMutex(tls)
  16304 
  16305 	Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  16306 	if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock != 0 {
  16307 		setPendingFd(tls, pFile)
  16308 	}
  16309 	Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  16310 	releaseInodeInfo(tls, pFile)
  16311 
  16312 	rc = closeUnixFile(tls, id)
  16313 	unixLeaveMutex(tls)
  16314 	return rc
  16315 }
  16316 
  16317 func nolockCheckReservedLock(tls *libc.TLS, NotUsed uintptr, pResOut uintptr) int32 {
  16318 	_ = NotUsed
  16319 	*(*int32)(unsafe.Pointer(pResOut)) = 0
  16320 	return SQLITE_OK
  16321 }
  16322 
  16323 func nolockLock(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32) int32 {
  16324 	_ = NotUsed
  16325 	_ = NotUsed2
  16326 	return SQLITE_OK
  16327 }
  16328 
  16329 func nolockUnlock(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32) int32 {
  16330 	_ = NotUsed
  16331 	_ = NotUsed2
  16332 	return SQLITE_OK
  16333 }
  16334 
  16335 func nolockClose(tls *libc.TLS, id uintptr) int32 {
  16336 	return closeUnixFile(tls, id)
  16337 }
  16338 
  16339 func dotlockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 {
  16340 	var rc int32 = SQLITE_OK
  16341 	var reserved int32 = 0
  16342 	var pFile uintptr = id
  16343 
  16344 	reserved = libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 2*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext, 0) == 0)
  16345 
  16346 	*(*int32)(unsafe.Pointer(pResOut)) = reserved
  16347 	return rc
  16348 }
  16349 
  16350 func dotlockLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 {
  16351 	var pFile uintptr = id
  16352 	var zLockFile uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext
  16353 	var rc int32 = SQLITE_OK
  16354 
  16355 	if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK {
  16356 		(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock)
  16357 
  16358 		libc.Xutimes(tls, zLockFile, uintptr(0))
  16359 		return SQLITE_OK
  16360 	}
  16361 
  16362 	rc = (*(*func(*libc.TLS, uintptr, Mode_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 18*12 + 4)))(tls, zLockFile, uint32(0777))
  16363 	if rc < 0 {
  16364 		var tErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16365 		if EEXIST == tErrno {
  16366 			rc = SQLITE_BUSY
  16367 		} else {
  16368 			rc = sqliteErrorFromPosixError(tls, tErrno, SQLITE_IOERR|int32(15)<<8)
  16369 			if rc != SQLITE_BUSY {
  16370 				storeLastErrno(tls, pFile, tErrno)
  16371 			}
  16372 		}
  16373 		return rc
  16374 	}
  16375 
  16376 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock)
  16377 	return rc
  16378 }
  16379 
  16380 func dotlockUnlock(tls *libc.TLS, id uintptr, eFileLock int32) int32 {
  16381 	var pFile uintptr = id
  16382 	var zLockFile uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext
  16383 	var rc int32
  16384 
  16385 	if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) == eFileLock {
  16386 		return SQLITE_OK
  16387 	}
  16388 
  16389 	if eFileLock == SHARED_LOCK {
  16390 		(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK)
  16391 		return SQLITE_OK
  16392 	}
  16393 
  16394 	rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 19*12 + 4)))(tls, zLockFile)
  16395 	if rc < 0 {
  16396 		var tErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16397 		if tErrno == ENOENT {
  16398 			rc = SQLITE_OK
  16399 		} else {
  16400 			rc = SQLITE_IOERR | int32(8)<<8
  16401 			storeLastErrno(tls, pFile, tErrno)
  16402 		}
  16403 		return rc
  16404 	}
  16405 	(*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(NO_LOCK)
  16406 	return SQLITE_OK
  16407 }
  16408 
  16409 func dotlockClose(tls *libc.TLS, id uintptr) int32 {
  16410 	var pFile uintptr = id
  16411 
  16412 	dotlockUnlock(tls, id, NO_LOCK)
  16413 	Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext)
  16414 	return closeUnixFile(tls, id)
  16415 }
  16416 
  16417 func seekAndRead(tls *libc.TLS, id uintptr, offset Sqlite3_int64, pBuf uintptr, cnt int32) int32 {
  16418 	var got int32
  16419 	var prior int32 = 0
  16420 	var newOffset I64
  16421 
  16422 	for __ccgo := true; __ccgo; __ccgo = got > 0 {
  16423 		newOffset = libc.Xlseek(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, offset, SEEK_SET)
  16424 
  16425 		if newOffset < int64(0) {
  16426 			storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16427 			return -1
  16428 		}
  16429 		got = (*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 8*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, pBuf, uint32(cnt))
  16430 		if got == cnt {
  16431 			break
  16432 		}
  16433 		if got < 0 {
  16434 			if *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == EINTR {
  16435 				got = 1
  16436 				continue
  16437 			}
  16438 			prior = 0
  16439 			storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16440 			break
  16441 		} else if got > 0 {
  16442 			cnt = cnt - got
  16443 			offset = offset + Sqlite3_int64(got)
  16444 			prior = prior + got
  16445 			pBuf = uintptr(got) + pBuf
  16446 		}
  16447 	}
  16448 
  16449 	return got + prior
  16450 }
  16451 
  16452 func unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite3_int64) int32 {
  16453 	var pFile uintptr = id
  16454 	var got int32
  16455 
  16456 	if offset < (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize {
  16457 		if offset+Sqlite3_int64(amt) <= (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize {
  16458 			libc.Xmemcpy(tls, pBuf, (*UnixFile)(unsafe.Pointer(pFile)).FpMapRegion+uintptr(offset), uint32(amt))
  16459 			return SQLITE_OK
  16460 		} else {
  16461 			var nCopy int32 = int32((*UnixFile)(unsafe.Pointer(pFile)).FmmapSize - offset)
  16462 			libc.Xmemcpy(tls, pBuf, (*UnixFile)(unsafe.Pointer(pFile)).FpMapRegion+uintptr(offset), uint32(nCopy))
  16463 			pBuf = pBuf + uintptr(nCopy)
  16464 			amt = amt - nCopy
  16465 			offset = offset + Sqlite3_int64(nCopy)
  16466 		}
  16467 	}
  16468 
  16469 	got = seekAndRead(tls, pFile, offset, pBuf, amt)
  16470 	if got == amt {
  16471 		return SQLITE_OK
  16472 	} else if got < 0 {
  16473 		switch (*UnixFile)(unsafe.Pointer(pFile)).FlastErrno {
  16474 		case ERANGE:
  16475 			fallthrough
  16476 		case EIO:
  16477 			fallthrough
  16478 		case ENXIO:
  16479 			return SQLITE_IOERR | int32(33)<<8
  16480 		}
  16481 		return SQLITE_IOERR | int32(1)<<8
  16482 	} else {
  16483 		storeLastErrno(tls, pFile, 0)
  16484 
  16485 		libc.Xmemset(tls, pBuf+uintptr(got), 0, uint32(amt-got))
  16486 		return SQLITE_IOERR | int32(2)<<8
  16487 	}
  16488 	return int32(0)
  16489 }
  16490 
  16491 func seekAndWriteFd(tls *libc.TLS, fd int32, iOff I64, pBuf uintptr, nBuf int32, piErrno uintptr) int32 {
  16492 	var rc int32 = 0
  16493 
  16494 	nBuf = nBuf & 0x1ffff
  16495 
  16496 	for __ccgo := true; __ccgo; __ccgo = rc < 0 && *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == EINTR {
  16497 		var iSeek I64 = libc.Xlseek(tls, fd, iOff, SEEK_SET)
  16498 
  16499 		if iSeek < int64(0) {
  16500 			rc = -1
  16501 			break
  16502 		}
  16503 		rc = (*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 11*12 + 4)))(tls, fd, pBuf, uint32(nBuf))
  16504 	}
  16505 
  16506 	if rc < 0 {
  16507 		*(*int32)(unsafe.Pointer(piErrno)) = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  16508 	}
  16509 	return rc
  16510 }
  16511 
  16512 func seekAndWrite(tls *libc.TLS, id uintptr, offset I64, pBuf uintptr, cnt int32) int32 {
  16513 	return seekAndWriteFd(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, offset, pBuf, cnt, id+20)
  16514 }
  16515 
  16516 func unixWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite3_int64) int32 {
  16517 	var pFile uintptr = id
  16518 	var wrote int32 = 0
  16519 
  16520 	for libc.AssignInt32(&wrote, seekAndWrite(tls, pFile, offset, pBuf, amt)) < amt && wrote > 0 {
  16521 		amt = amt - wrote
  16522 		offset = offset + Sqlite3_int64(wrote)
  16523 		pBuf = pBuf + uintptr(wrote)
  16524 	}
  16525 
  16526 	if amt > wrote {
  16527 		if wrote < 0 && (*UnixFile)(unsafe.Pointer(pFile)).FlastErrno != ENOSPC {
  16528 			return SQLITE_IOERR | int32(3)<<8
  16529 		} else {
  16530 			storeLastErrno(tls, pFile, 0)
  16531 			return SQLITE_FULL
  16532 		}
  16533 	}
  16534 
  16535 	return SQLITE_OK
  16536 }
  16537 
  16538 func full_fsync(tls *libc.TLS, fd int32, fullSync int32, dataOnly int32) int32 {
  16539 	var rc int32
  16540 
  16541 	_ = fullSync
  16542 	_ = dataOnly
  16543 
  16544 	rc = libc.Xfsync(tls, fd)
  16545 
  16546 	if 0 != 0 && rc != -1 {
  16547 		rc = 0
  16548 	}
  16549 	return rc
  16550 }
  16551 
  16552 func openDirectory(tls *libc.TLS, zFilename uintptr, pFd uintptr) int32 {
  16553 	bp := tls.Alloc(521)
  16554 	defer tls.Free(521)
  16555 
  16556 	var ii int32
  16557 	var fd int32 = -1
  16558 
  16559 	Xsqlite3_snprintf(tls, MAX_PATHNAME, bp+8, ts+3663, libc.VaList(bp, zFilename))
  16560 	for ii = int32(libc.Xstrlen(tls, bp+8)); ii > 0 && int32(*(*uint8)(unsafe.Pointer(bp + 8 + uintptr(ii)))) != '/'; ii-- {
  16561 	}
  16562 	if ii > 0 {
  16563 		*(*uint8)(unsafe.Pointer(bp + 8 + uintptr(ii))) = uint8(0)
  16564 	} else {
  16565 		if int32(*(*uint8)(unsafe.Pointer(bp + 8))) != '/' {
  16566 			*(*uint8)(unsafe.Pointer(bp + 8)) = uint8('.')
  16567 		}
  16568 		*(*uint8)(unsafe.Pointer(bp + 8 + 1)) = uint8(0)
  16569 	}
  16570 	fd = robust_open(tls, bp+8, O_RDONLY|O_BINARY, uint32(0))
  16571 	if fd >= 0 {
  16572 	}
  16573 	*(*int32)(unsafe.Pointer(pFd)) = fd
  16574 	if fd >= 0 {
  16575 		return SQLITE_OK
  16576 	}
  16577 	return unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 40680), ts+3378, bp+8, 40680)
  16578 }
  16579 
  16580 func unixSync(tls *libc.TLS, id uintptr, flags int32) int32 {
  16581 	bp := tls.Alloc(4)
  16582 	defer tls.Free(4)
  16583 
  16584 	var rc int32
  16585 	var pFile uintptr = id
  16586 
  16587 	var isDataOnly int32 = flags & SQLITE_SYNC_DATAONLY
  16588 	var isFullsync int32 = libc.Bool32(flags&0x0F == SQLITE_SYNC_FULL)
  16589 
  16590 	rc = full_fsync(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, isFullsync, isDataOnly)
  16591 
  16592 	if rc != 0 {
  16593 		storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16594 		return unixLogErrorAtLine(tls, SQLITE_IOERR|int32(4)<<8, ts+3666, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 40721)
  16595 	}
  16596 
  16597 	if int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags)&UNIXFILE_DIRSYNC != 0 {
  16598 		rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 17*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp)
  16599 		if rc == SQLITE_OK {
  16600 			full_fsync(tls, *(*int32)(unsafe.Pointer(bp)), 0, 0)
  16601 			robust_close(tls, pFile, *(*int32)(unsafe.Pointer(bp)), 40735)
  16602 		} else {
  16603 			rc = SQLITE_OK
  16604 		}
  16605 		*(*uint16)(unsafe.Pointer(pFile + 18)) &= libc.Uint16FromInt32(libc.CplInt32(UNIXFILE_DIRSYNC))
  16606 	}
  16607 	return rc
  16608 }
  16609 
  16610 func unixTruncate(tls *libc.TLS, id uintptr, nByte I64) int32 {
  16611 	var pFile uintptr = id
  16612 	var rc int32
  16613 
  16614 	if (*UnixFile)(unsafe.Pointer(pFile)).FszChunk > 0 {
  16615 		nByte = (nByte + I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk) - int64(1)) / I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk) * I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)
  16616 	}
  16617 
  16618 	rc = robust_ftruncate(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, nByte)
  16619 	if rc != 0 {
  16620 		storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16621 		return unixLogErrorAtLine(tls, SQLITE_IOERR|int32(6)<<8, ts+3297, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 40766)
  16622 	} else {
  16623 		if nByte < (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize {
  16624 			(*UnixFile)(unsafe.Pointer(pFile)).FmmapSize = nByte
  16625 		}
  16626 
  16627 		return SQLITE_OK
  16628 	}
  16629 	return int32(0)
  16630 }
  16631 
  16632 func unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 {
  16633 	bp := tls.Alloc(104)
  16634 	defer tls.Free(104)
  16635 
  16636 	var rc int32
  16637 
  16638 	rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, bp)
  16639 
  16640 	if rc != 0 {
  16641 		storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16642 		return SQLITE_IOERR | int32(7)<<8
  16643 	}
  16644 	*(*I64)(unsafe.Pointer(pSize)) = (*stat)(unsafe.Pointer(bp)).Fst_size
  16645 
  16646 	if *(*I64)(unsafe.Pointer(pSize)) == int64(1) {
  16647 		*(*I64)(unsafe.Pointer(pSize)) = int64(0)
  16648 	}
  16649 
  16650 	return SQLITE_OK
  16651 }
  16652 
  16653 func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 {
  16654 	bp := tls.Alloc(104)
  16655 	defer tls.Free(104)
  16656 
  16657 	if (*UnixFile)(unsafe.Pointer(pFile)).FszChunk > 0 {
  16658 		var nSize I64
  16659 
  16660 		if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp) != 0 {
  16661 			return SQLITE_IOERR | int32(7)<<8
  16662 		}
  16663 
  16664 		nSize = (nByte + I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk) - int64(1)) / I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk) * I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)
  16665 		if nSize > (*stat)(unsafe.Pointer(bp)).Fst_size {
  16666 			var nBlk int32 = (*stat)(unsafe.Pointer(bp)).Fst_blksize
  16667 			var nWrite int32 = 0
  16668 			var iWrite I64
  16669 
  16670 			iWrite = (*stat)(unsafe.Pointer(bp)).Fst_size/X__off64_t(nBlk)*X__off64_t(nBlk) + X__off64_t(nBlk) - int64(1)
  16671 
  16672 			for ; iWrite < nSize+I64(nBlk)-int64(1); iWrite = iWrite + I64(nBlk) {
  16673 				if iWrite >= nSize {
  16674 					iWrite = nSize - int64(1)
  16675 				}
  16676 				nWrite = seekAndWrite(tls, pFile, iWrite, ts+1554, 1)
  16677 				if nWrite != 1 {
  16678 					return SQLITE_IOERR | int32(3)<<8
  16679 				}
  16680 			}
  16681 		}
  16682 	}
  16683 
  16684 	if (*UnixFile)(unsafe.Pointer(pFile)).FmmapSizeMax > int64(0) && nByte > (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize {
  16685 		var rc int32
  16686 		if (*UnixFile)(unsafe.Pointer(pFile)).FszChunk <= 0 {
  16687 			if robust_ftruncate(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, nByte) != 0 {
  16688 				storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))))
  16689 				return unixLogErrorAtLine(tls, SQLITE_IOERR|int32(6)<<8, ts+3297, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 40887)
  16690 			}
  16691 		}
  16692 
  16693 		rc = unixMapfile(tls, pFile, nByte)
  16694 		return rc
  16695 	}
  16696 
  16697 	return SQLITE_OK
  16698 }
  16699 
  16700 func unixModeBit(tls *libc.TLS, pFile uintptr, mask uint8, pArg uintptr) {
  16701 	if *(*int32)(unsafe.Pointer(pArg)) < 0 {
  16702 		*(*int32)(unsafe.Pointer(pArg)) = libc.Bool32(int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags)&int32(mask) != 0)
  16703 	} else if *(*int32)(unsafe.Pointer(pArg)) == 0 {
  16704 		*(*uint16)(unsafe.Pointer(pFile + 18)) &= uint16(^int32(mask))
  16705 	} else {
  16706 		*(*uint16)(unsafe.Pointer(pFile + 18)) |= uint16(int32(mask))
  16707 	}
  16708 }
  16709 
  16710 func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 {
  16711 	bp := tls.Alloc(8)
  16712 	defer tls.Free(8)
  16713 
  16714 	var pFile uintptr = id
  16715 	switch op {
  16716 	case SQLITE_FCNTL_LOCKSTATE:
  16717 		{
  16718 			*(*int32)(unsafe.Pointer(pArg)) = int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock)
  16719 			return SQLITE_OK
  16720 
  16721 		}
  16722 	case SQLITE_FCNTL_LAST_ERRNO:
  16723 		{
  16724 			*(*int32)(unsafe.Pointer(pArg)) = (*UnixFile)(unsafe.Pointer(pFile)).FlastErrno
  16725 			return SQLITE_OK
  16726 
  16727 		}
  16728 	case SQLITE_FCNTL_CHUNK_SIZE:
  16729 		{
  16730 			(*UnixFile)(unsafe.Pointer(pFile)).FszChunk = *(*int32)(unsafe.Pointer(pArg))
  16731 			return SQLITE_OK
  16732 
  16733 		}
  16734 	case SQLITE_FCNTL_SIZE_HINT:
  16735 		{
  16736 			var rc int32
  16737 
  16738 			rc = fcntlSizeHint(tls, pFile, *(*I64)(unsafe.Pointer(pArg)))
  16739 
  16740 			return rc
  16741 
  16742 		}
  16743 	case SQLITE_FCNTL_PERSIST_WAL:
  16744 		{
  16745 			unixModeBit(tls, pFile, uint8(UNIXFILE_PERSIST_WAL), pArg)
  16746 			return SQLITE_OK
  16747 
  16748 		}
  16749 	case SQLITE_FCNTL_POWERSAFE_OVERWRITE:
  16750 		{
  16751 			unixModeBit(tls, pFile, uint8(UNIXFILE_PSOW), pArg)
  16752 			return SQLITE_OK
  16753 
  16754 		}
  16755 	case SQLITE_FCNTL_VFSNAME:
  16756 		{
  16757 			*(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, (*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FzName))
  16758 			return SQLITE_OK
  16759 
  16760 		}
  16761 	case SQLITE_FCNTL_TEMPFILENAME:
  16762 		{
  16763 			var zTFile uintptr = Xsqlite3_malloc64(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FmxPathname))
  16764 			if zTFile != 0 {
  16765 				unixGetTempname(tls, (*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FmxPathname, zTFile)
  16766 				*(*uintptr)(unsafe.Pointer(pArg)) = zTFile
  16767 			}
  16768 			return SQLITE_OK
  16769 
  16770 		}
  16771 	case SQLITE_FCNTL_HAS_MOVED:
  16772 		{
  16773 			*(*int32)(unsafe.Pointer(pArg)) = fileHasMoved(tls, pFile)
  16774 			return SQLITE_OK
  16775 
  16776 		}
  16777 	case SQLITE_FCNTL_MMAP_SIZE:
  16778 		{
  16779 			var newLimit I64 = *(*I64)(unsafe.Pointer(pArg))
  16780 			var rc int32 = SQLITE_OK
  16781 			if newLimit > Xsqlite3Config.FmxMmap {
  16782 				newLimit = Xsqlite3Config.FmxMmap
  16783 			}
  16784 
  16785 			if newLimit > int64(0) && uint32(unsafe.Sizeof(Size_t(0))) < uint32(8) {
  16786 				newLimit = newLimit & int64(0x7FFFFFFF)
  16787 			}
  16788 
  16789 			*(*I64)(unsafe.Pointer(pArg)) = (*UnixFile)(unsafe.Pointer(pFile)).FmmapSizeMax
  16790 			if newLimit >= int64(0) && newLimit != (*UnixFile)(unsafe.Pointer(pFile)).FmmapSizeMax && (*UnixFile)(unsafe.Pointer(pFile)).FnFetchOut == 0 {
  16791 				(*UnixFile)(unsafe.Pointer(pFile)).FmmapSizeMax = newLimit
  16792 				if (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize > int64(0) {
  16793 					unixUnmapfile(tls, pFile)
  16794 					rc = unixMapfile(tls, pFile, int64(-1))
  16795 				}
  16796 			}
  16797 			return rc
  16798 
  16799 		}
  16800 
  16801 	case SQLITE_FCNTL_EXTERNAL_READER:
  16802 		{
  16803 			return unixFcntlExternalReader(tls, id, pArg)
  16804 
  16805 		}
  16806 	}
  16807 	return SQLITE_NOTFOUND
  16808 }
  16809 
  16810 func setDeviceCharacteristics(tls *libc.TLS, pFd uintptr) {
  16811 	if (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize == 0 {
  16812 		if int32((*UnixFile)(unsafe.Pointer(pFd)).FctrlFlags)&UNIXFILE_PSOW != 0 {
  16813 			*(*int32)(unsafe.Pointer(pFd + 80)) |= SQLITE_IOCAP_POWERSAFE_OVERWRITE
  16814 		}
  16815 
  16816 		(*UnixFile)(unsafe.Pointer(pFd)).FsectorSize = SQLITE_DEFAULT_SECTOR_SIZE
  16817 	}
  16818 }
  16819 
  16820 func unixSectorSize(tls *libc.TLS, id uintptr) int32 {
  16821 	var pFd uintptr = id
  16822 	setDeviceCharacteristics(tls, pFd)
  16823 	return (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize
  16824 }
  16825 
  16826 func unixDeviceCharacteristics(tls *libc.TLS, id uintptr) int32 {
  16827 	var pFd uintptr = id
  16828 	setDeviceCharacteristics(tls, pFd)
  16829 	return (*UnixFile)(unsafe.Pointer(pFd)).FdeviceCharacteristics
  16830 }
  16831 
  16832 func unixGetpagesize(tls *libc.TLS) int32 {
  16833 	return libc.Xsysconf(tls, X_SC_PAGESIZE)
  16834 }
  16835 
  16836 func unixFcntlExternalReader(tls *libc.TLS, pFile uintptr, piOut uintptr) int32 {
  16837 	bp := tls.Alloc(40)
  16838 	defer tls.Free(40)
  16839 
  16840 	var rc int32 = SQLITE_OK
  16841 	*(*int32)(unsafe.Pointer(piOut)) = 0
  16842 	if (*UnixFile)(unsafe.Pointer(pFile)).FpShm != 0 {
  16843 		var pShmNode uintptr = (*UnixShm)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpShm)).FpShmNode
  16844 
  16845 		libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(flock{})))
  16846 		(*flock)(unsafe.Pointer(bp + 8)).Fl_type = int16(F_WRLCK)
  16847 		(*flock)(unsafe.Pointer(bp + 8)).Fl_whence = int16(SEEK_SET)
  16848 		(*flock)(unsafe.Pointer(bp + 8)).Fl_start = int64((22+SQLITE_SHM_NLOCK)*4 + 3)
  16849 		(*flock)(unsafe.Pointer(bp + 8)).Fl_len = int64(SQLITE_SHM_NLOCK - 3)
  16850 
  16851 		Xsqlite3_mutex_enter(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  16852 		if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 7*12 + 4)))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_GETLK64, libc.VaList(bp, bp+8)) < 0 {
  16853 			rc = SQLITE_IOERR | int32(15)<<8
  16854 		} else {
  16855 			*(*int32)(unsafe.Pointer(piOut)) = libc.Bool32(int32((*flock)(unsafe.Pointer(bp+8)).Fl_type) != F_UNLCK)
  16856 		}
  16857 		Xsqlite3_mutex_leave(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  16858 	}
  16859 
  16860 	return rc
  16861 }
  16862 
  16863 func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, n int32) int32 {
  16864 	bp := tls.Alloc(40)
  16865 	defer tls.Free(40)
  16866 
  16867 	var pShmNode uintptr
  16868 
  16869 	var rc int32 = SQLITE_OK
  16870 
  16871 	pShmNode = (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpShmNode
  16872 
  16873 	if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 {
  16874 		var res int32
  16875 
  16876 		(*flock)(unsafe.Pointer(bp + 8)).Fl_type = int16(lockType)
  16877 		(*flock)(unsafe.Pointer(bp + 8)).Fl_whence = int16(SEEK_SET)
  16878 		(*flock)(unsafe.Pointer(bp + 8)).Fl_start = X__off64_t(ofst)
  16879 		(*flock)(unsafe.Pointer(bp + 8)).Fl_len = X__off64_t(n)
  16880 		res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 7*12 + 4)))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_SETLK64, libc.VaList(bp, bp+8))
  16881 		if res == -1 {
  16882 			rc = SQLITE_BUSY
  16883 		}
  16884 	}
  16885 
  16886 	return rc
  16887 }
  16888 
  16889 func unixShmRegionPerMap(tls *libc.TLS) int32 {
  16890 	var shmsz int32 = 32 * 1024
  16891 	var pgsz int32 = (*(*func(*libc.TLS) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 25*12 + 4)))(tls)
  16892 
  16893 	if pgsz < shmsz {
  16894 		return 1
  16895 	}
  16896 	return pgsz / shmsz
  16897 }
  16898 
  16899 func unixShmPurge(tls *libc.TLS, pFd uintptr) {
  16900 	var p uintptr = (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFd)).FpInode)).FpShmNode
  16901 
  16902 	if p != 0 && (*UnixShmNode)(unsafe.Pointer(p)).FnRef == 0 {
  16903 		var nShmPerMap int32 = unixShmRegionPerMap(tls)
  16904 		var i int32
  16905 
  16906 		Xsqlite3_mutex_free(tls, (*UnixShmNode)(unsafe.Pointer(p)).FpShmMutex)
  16907 		for i = 0; i < int32((*UnixShmNode)(unsafe.Pointer(p)).FnRegion); i = i + nShmPerMap {
  16908 			if (*UnixShmNode)(unsafe.Pointer(p)).FhShm >= 0 {
  16909 				(*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 23*12 + 4)))(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*4)), uint32((*UnixShmNode)(unsafe.Pointer(p)).FszRegion))
  16910 			} else {
  16911 				Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*4)))
  16912 			}
  16913 		}
  16914 		Xsqlite3_free(tls, (*UnixShmNode)(unsafe.Pointer(p)).FapRegion)
  16915 		if (*UnixShmNode)(unsafe.Pointer(p)).FhShm >= 0 {
  16916 			robust_close(tls, pFd, (*UnixShmNode)(unsafe.Pointer(p)).FhShm, 41446)
  16917 			(*UnixShmNode)(unsafe.Pointer(p)).FhShm = -1
  16918 		}
  16919 		(*UnixInodeInfo)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FpInode)).FpShmNode = uintptr(0)
  16920 		Xsqlite3_free(tls, p)
  16921 	}
  16922 }
  16923 
  16924 func unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) int32 {
  16925 	bp := tls.Alloc(40)
  16926 	defer tls.Free(40)
  16927 
  16928 	var rc int32 = SQLITE_OK
  16929 
  16930 	(*flock)(unsafe.Pointer(bp + 8)).Fl_whence = int16(SEEK_SET)
  16931 	(*flock)(unsafe.Pointer(bp + 8)).Fl_start = int64((22+SQLITE_SHM_NLOCK)*4 + SQLITE_SHM_NLOCK)
  16932 	(*flock)(unsafe.Pointer(bp + 8)).Fl_len = int64(1)
  16933 	(*flock)(unsafe.Pointer(bp + 8)).Fl_type = int16(F_WRLCK)
  16934 	if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 7*12 + 4)))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_GETLK64, libc.VaList(bp, bp+8)) != 0 {
  16935 		rc = SQLITE_IOERR | int32(15)<<8
  16936 	} else if int32((*flock)(unsafe.Pointer(bp+8)).Fl_type) == F_UNLCK {
  16937 		if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 {
  16938 			(*UnixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = U8(1)
  16939 			rc = SQLITE_READONLY | int32(5)<<8
  16940 		} else {
  16941 			rc = unixShmSystemLock(tls, pDbFd, F_WRLCK, (22+SQLITE_SHM_NLOCK)*4+SQLITE_SHM_NLOCK, 1)
  16942 
  16943 			if rc == SQLITE_OK && robust_ftruncate(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(3)) != 0 {
  16944 				rc = unixLogErrorAtLine(tls, SQLITE_IOERR|int32(18)<<8, ts+3297, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 41503)
  16945 			}
  16946 		}
  16947 	} else if int32((*flock)(unsafe.Pointer(bp+8)).Fl_type) == F_WRLCK {
  16948 		rc = SQLITE_BUSY
  16949 	}
  16950 
  16951 	if rc == SQLITE_OK {
  16952 		rc = unixShmSystemLock(tls, pDbFd, F_RDLCK, (22+SQLITE_SHM_NLOCK)*4+SQLITE_SHM_NLOCK, 1)
  16953 	}
  16954 	return rc
  16955 }
  16956 
  16957 func unixOpenSharedMemory(tls *libc.TLS, pDbFd uintptr) int32 {
  16958 	bp := tls.Alloc(112)
  16959 	defer tls.Free(112)
  16960 
  16961 	var p uintptr
  16962 	var pShmNode uintptr
  16963 	var rc int32
  16964 	var pInode uintptr
  16965 	var zShm uintptr
  16966 	var nShmFilename int32
  16967 
  16968 	var zBasePath uintptr
  16969 	p = uintptr(0)
  16970 	rc = SQLITE_OK
  16971 
  16972 	p = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(unixShm{})))
  16973 	if !(p == uintptr(0)) {
  16974 		goto __1
  16975 	}
  16976 	return SQLITE_NOMEM
  16977 __1:
  16978 	;
  16979 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(unixShm{})))
  16980 
  16981 	unixEnterMutex(tls)
  16982 	pInode = (*UnixFile)(unsafe.Pointer(pDbFd)).FpInode
  16983 	pShmNode = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpShmNode
  16984 	if !(pShmNode == uintptr(0)) {
  16985 		goto __2
  16986 	}
  16987 	zBasePath = (*UnixFile)(unsafe.Pointer(pDbFd)).FzPath
  16988 
  16989 	if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).Fh, bp+8) != 0) {
  16990 		goto __3
  16991 	}
  16992 	rc = SQLITE_IOERR | int32(7)<<8
  16993 	goto shm_open_err
  16994 __3:
  16995 	;
  16996 	nShmFilename = 6 + int32(libc.Xstrlen(tls, zBasePath))
  16997 	pShmNode = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(unixShmNode{}))+uint32(nShmFilename)))
  16998 	if !(pShmNode == uintptr(0)) {
  16999 		goto __4
  17000 	}
  17001 	rc = SQLITE_NOMEM
  17002 	goto shm_open_err
  17003 __4:
  17004 	;
  17005 	libc.Xmemset(tls, pShmNode, 0, uint32(unsafe.Sizeof(unixShmNode{}))+uint32(nShmFilename))
  17006 	zShm = libc.AssignPtrUintptr(pShmNode+8, pShmNode+1*68)
  17007 	Xsqlite3_snprintf(tls, nShmFilename, zShm, ts+3677, libc.VaList(bp, zBasePath))
  17008 
  17009 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = -1
  17010 	(*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pDbFd)).FpInode)).FpShmNode = pShmNode
  17011 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FpInode = (*UnixFile)(unsafe.Pointer(pDbFd)).FpInode
  17012 	if !(Xsqlite3Config.FbCoreMutex != 0) {
  17013 		goto __5
  17014 	}
  17015 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST)
  17016 	if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex == uintptr(0)) {
  17017 		goto __6
  17018 	}
  17019 	rc = SQLITE_NOMEM
  17020 	goto shm_open_err
  17021 __6:
  17022 	;
  17023 __5:
  17024 	;
  17025 	if !(int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock) == 0) {
  17026 		goto __7
  17027 	}
  17028 	if !(0 == Xsqlite3_uri_boolean(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).FzPath, ts+3684, 0)) {
  17029 		goto __8
  17030 	}
  17031 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, O_RDWR|O_CREAT|0100000,
  17032 		(*stat)(unsafe.Pointer(bp+8)).Fst_mode&X__mode_t(0777))
  17033 __8:
  17034 	;
  17035 	if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm < 0) {
  17036 		goto __9
  17037 	}
  17038 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, O_RDONLY|0100000,
  17039 		(*stat)(unsafe.Pointer(bp+8)).Fst_mode&X__mode_t(0777))
  17040 	if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm < 0) {
  17041 		goto __10
  17042 	}
  17043 	rc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 41628), ts+3261, zShm, 41628)
  17044 	goto shm_open_err
  17045 __10:
  17046 	;
  17047 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly = U8(1)
  17048 __9:
  17049 	;
  17050 	robustFchown(tls, (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (*stat)(unsafe.Pointer(bp+8)).Fst_uid, (*stat)(unsafe.Pointer(bp+8)).Fst_gid)
  17051 
  17052 	rc = unixLockSharedMemory(tls, pDbFd, pShmNode)
  17053 	if !(rc != SQLITE_OK && rc != SQLITE_READONLY|int32(5)<<8) {
  17054 		goto __11
  17055 	}
  17056 	goto shm_open_err
  17057 __11:
  17058 	;
  17059 __7:
  17060 	;
  17061 __2:
  17062 	;
  17063 	(*unixShm)(unsafe.Pointer(p)).FpShmNode = pShmNode
  17064 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FnRef++
  17065 	(*UnixFile)(unsafe.Pointer(pDbFd)).FpShm = p
  17066 	unixLeaveMutex(tls)
  17067 
  17068 	Xsqlite3_mutex_enter(tls, (*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17069 	(*unixShm)(unsafe.Pointer(p)).FpNext = (*unixShmNode)(unsafe.Pointer(pShmNode)).FpFirst
  17070 	(*unixShmNode)(unsafe.Pointer(pShmNode)).FpFirst = p
  17071 	Xsqlite3_mutex_leave(tls, (*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17072 	return rc
  17073 
  17074 shm_open_err:
  17075 	unixShmPurge(tls, pDbFd)
  17076 	Xsqlite3_free(tls, p)
  17077 	unixLeaveMutex(tls)
  17078 	return rc
  17079 }
  17080 
  17081 func unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExtend int32, pp uintptr) int32 {
  17082 	bp := tls.Alloc(108)
  17083 	defer tls.Free(108)
  17084 
  17085 	var pDbFd uintptr
  17086 	var p uintptr
  17087 	var pShmNode uintptr
  17088 	var rc int32
  17089 	var nShmPerMap int32
  17090 	var nReqRegion int32
  17091 	var zFile uintptr
  17092 
  17093 	var iPg int32
  17094 	var nMap int32
  17095 	var i int32
  17096 	var pMem uintptr
  17097 	var apNew uintptr
  17098 	var nByte int32
  17099 
  17100 	pDbFd = fd
  17101 	rc = SQLITE_OK
  17102 	nShmPerMap = unixShmRegionPerMap(tls)
  17103 
  17104 	if !((*UnixFile)(unsafe.Pointer(pDbFd)).FpShm == uintptr(0)) {
  17105 		goto __1
  17106 	}
  17107 	rc = unixOpenSharedMemory(tls, pDbFd)
  17108 	if !(rc != SQLITE_OK) {
  17109 		goto __2
  17110 	}
  17111 	return rc
  17112 __2:
  17113 	;
  17114 __1:
  17115 	;
  17116 	p = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm
  17117 	pShmNode = (*UnixShm)(unsafe.Pointer(p)).FpShmNode
  17118 	Xsqlite3_mutex_enter(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17119 	if !((*UnixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked != 0) {
  17120 		goto __3
  17121 	}
  17122 	rc = unixLockSharedMemory(tls, pDbFd, pShmNode)
  17123 	if !(rc != SQLITE_OK) {
  17124 		goto __4
  17125 	}
  17126 	goto shmpage_out
  17127 __4:
  17128 	;
  17129 	(*UnixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = U8(0)
  17130 __3:
  17131 	;
  17132 	nReqRegion = (iRegion + nShmPerMap) / nShmPerMap * nShmPerMap
  17133 
  17134 	if !(int32((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion) < nReqRegion) {
  17135 		goto __5
  17136 	}
  17137 	nByte = nReqRegion * szRegion
  17138 
  17139 	(*UnixShmNode)(unsafe.Pointer(pShmNode)).FszRegion = szRegion
  17140 
  17141 	if !((*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0) {
  17142 		goto __6
  17143 	}
  17144 
  17145 	if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp) != 0) {
  17146 		goto __7
  17147 	}
  17148 	rc = SQLITE_IOERR | int32(19)<<8
  17149 	goto shmpage_out
  17150 __7:
  17151 	;
  17152 	if !((*stat)(unsafe.Pointer(bp)).Fst_size < X__off64_t(nByte)) {
  17153 		goto __8
  17154 	}
  17155 
  17156 	if !!(bExtend != 0) {
  17157 		goto __9
  17158 	}
  17159 	goto shmpage_out
  17160 	goto __10
  17161 __9:
  17162 	;
  17163 	iPg = int32((*stat)(unsafe.Pointer(bp)).Fst_size / X__off64_t(pgsz))
  17164 __11:
  17165 	if !(iPg < nByte/pgsz) {
  17166 		goto __13
  17167 	}
  17168 	*(*int32)(unsafe.Pointer(bp + 104)) = 0
  17169 	if !(seekAndWriteFd(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(iPg*pgsz+pgsz-1), ts+1554, 1, bp+104) != 1) {
  17170 		goto __14
  17171 	}
  17172 	zFile = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename
  17173 	rc = unixLogErrorAtLine(tls, SQLITE_IOERR|int32(19)<<8, ts+3332, zFile, 41772)
  17174 	goto shmpage_out
  17175 __14:
  17176 	;
  17177 	goto __12
  17178 __12:
  17179 	iPg++
  17180 	goto __11
  17181 	goto __13
  17182 __13:
  17183 	;
  17184 __10:
  17185 	;
  17186 __8:
  17187 	;
  17188 __6:
  17189 	;
  17190 	apNew = Xsqlite3_realloc(tls,
  17191 		(*UnixShmNode)(unsafe.Pointer(pShmNode)).FapRegion, int32(uint32(nReqRegion)*uint32(unsafe.Sizeof(uintptr(0)))))
  17192 	if !!(apNew != 0) {
  17193 		goto __15
  17194 	}
  17195 	rc = SQLITE_IOERR | int32(12)<<8
  17196 	goto shmpage_out
  17197 __15:
  17198 	;
  17199 	(*UnixShmNode)(unsafe.Pointer(pShmNode)).FapRegion = apNew
  17200 __16:
  17201 	if !(int32((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion) < nReqRegion) {
  17202 		goto __17
  17203 	}
  17204 	nMap = szRegion * nShmPerMap
  17205 	if !((*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0) {
  17206 		goto __18
  17207 	}
  17208 	pMem = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 22*12 + 4)))(tls, uintptr(0), uint32(nMap),
  17209 		func() int32 {
  17210 			if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 {
  17211 				return PROT_READ
  17212 			}
  17213 			return PROT_READ | PROT_WRITE
  17214 		}(),
  17215 		MAP_SHARED, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, I64(szRegion)*I64((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion))
  17216 	if !(pMem == libc.UintptrFromInt32(-1)) {
  17217 		goto __20
  17218 	}
  17219 	rc = unixLogErrorAtLine(tls, SQLITE_IOERR|int32(21)<<8, ts+3419, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 41799)
  17220 	goto shmpage_out
  17221 __20:
  17222 	;
  17223 	goto __19
  17224 __18:
  17225 	pMem = Xsqlite3_malloc64(tls, uint64(nMap))
  17226 	if !(pMem == uintptr(0)) {
  17227 		goto __21
  17228 	}
  17229 	rc = SQLITE_NOMEM
  17230 	goto shmpage_out
  17231 __21:
  17232 	;
  17233 	libc.Xmemset(tls, pMem, 0, uint32(nMap))
  17234 __19:
  17235 	;
  17236 	i = 0
  17237 __22:
  17238 	if !(i < nShmPerMap) {
  17239 		goto __24
  17240 	}
  17241 	*(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(pShmNode)).FapRegion + uintptr(int32((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion)+i)*4)) = pMem + uintptr(szRegion*i)
  17242 	goto __23
  17243 __23:
  17244 	i++
  17245 	goto __22
  17246 	goto __24
  17247 __24:
  17248 	;
  17249 	*(*U16)(unsafe.Pointer(pShmNode + 20)) += U16(nShmPerMap)
  17250 	goto __16
  17251 __17:
  17252 	;
  17253 __5:
  17254 	;
  17255 shmpage_out:
  17256 	if !(int32((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion) > iRegion) {
  17257 		goto __25
  17258 	}
  17259 	*(*uintptr)(unsafe.Pointer(pp)) = *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(pShmNode)).FapRegion + uintptr(iRegion)*4))
  17260 	goto __26
  17261 __25:
  17262 	*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
  17263 __26:
  17264 	;
  17265 	if !((*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 && rc == SQLITE_OK) {
  17266 		goto __27
  17267 	}
  17268 	rc = SQLITE_READONLY
  17269 __27:
  17270 	;
  17271 	Xsqlite3_mutex_leave(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17272 	return rc
  17273 }
  17274 
  17275 var pgsz int32 = 4096
  17276 
  17277 func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) int32 {
  17278 	var pDbFd uintptr = fd
  17279 	var p uintptr
  17280 	var pShmNode uintptr
  17281 	var rc int32 = SQLITE_OK
  17282 	var mask U16
  17283 	var aLock uintptr
  17284 
  17285 	p = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm
  17286 	if p == uintptr(0) {
  17287 		return SQLITE_IOERR | int32(20)<<8
  17288 	}
  17289 	pShmNode = (*UnixShm)(unsafe.Pointer(p)).FpShmNode
  17290 	if pShmNode == uintptr(0) {
  17291 		return SQLITE_IOERR | int32(20)<<8
  17292 	}
  17293 	aLock = pShmNode + 36
  17294 
  17295 	mask = U16(int32(1)<<(ofst+n) - int32(1)<<ofst)
  17296 
  17297 	Xsqlite3_mutex_enter(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17298 
  17299 	if flags&SQLITE_SHM_UNLOCK != 0 {
  17300 		if (int32((*UnixShm)(unsafe.Pointer(p)).FexclMask)|int32((*UnixShm)(unsafe.Pointer(p)).FsharedMask))&int32(mask) != 0 {
  17301 			var ii int32
  17302 			var bUnlock int32 = 1
  17303 
  17304 			for ii = ofst; ii < ofst+n; ii++ {
  17305 				if *(*int32)(unsafe.Pointer(aLock + uintptr(ii)*4)) > func() int32 {
  17306 					if int32((*UnixShm)(unsafe.Pointer(p)).FsharedMask)&(int32(1)<<ii) != 0 {
  17307 						return 1
  17308 					}
  17309 					return 0
  17310 				}() {
  17311 					bUnlock = 0
  17312 				}
  17313 			}
  17314 
  17315 			if bUnlock != 0 {
  17316 				rc = unixShmSystemLock(tls, pDbFd, F_UNLCK, ofst+(22+SQLITE_SHM_NLOCK)*4, n)
  17317 				if rc == SQLITE_OK {
  17318 					libc.Xmemset(tls, aLock+uintptr(ofst)*4, 0, uint32(unsafe.Sizeof(int32(0)))*uint32(n))
  17319 				}
  17320 			} else if int32((*UnixShm)(unsafe.Pointer(p)).FsharedMask)&(int32(1)<<ofst) != 0 {
  17321 				*(*int32)(unsafe.Pointer(aLock + uintptr(ofst)*4))--
  17322 			}
  17323 
  17324 			if rc == SQLITE_OK {
  17325 				*(*U16)(unsafe.Pointer(p + 12)) &= U16(^int32(mask))
  17326 				*(*U16)(unsafe.Pointer(p + 10)) &= U16(^int32(mask))
  17327 			}
  17328 		}
  17329 	} else if flags&SQLITE_SHM_SHARED != 0 {
  17330 		if int32((*UnixShm)(unsafe.Pointer(p)).FsharedMask)&int32(mask) == 0 {
  17331 			if *(*int32)(unsafe.Pointer(aLock + uintptr(ofst)*4)) < 0 {
  17332 				rc = SQLITE_BUSY
  17333 			} else if *(*int32)(unsafe.Pointer(aLock + uintptr(ofst)*4)) == 0 {
  17334 				rc = unixShmSystemLock(tls, pDbFd, F_RDLCK, ofst+(22+SQLITE_SHM_NLOCK)*4, n)
  17335 			}
  17336 
  17337 			if rc == SQLITE_OK {
  17338 				*(*U16)(unsafe.Pointer(p + 10)) |= U16(int32(mask))
  17339 				*(*int32)(unsafe.Pointer(aLock + uintptr(ofst)*4))++
  17340 			}
  17341 		}
  17342 	} else {
  17343 		var ii int32
  17344 		for ii = ofst; ii < ofst+n; ii++ {
  17345 			if int32((*UnixShm)(unsafe.Pointer(p)).FexclMask)&(int32(1)<<ii) == 0 && *(*int32)(unsafe.Pointer(aLock + uintptr(ii)*4)) != 0 {
  17346 				rc = SQLITE_BUSY
  17347 				break
  17348 			}
  17349 		}
  17350 
  17351 		if rc == SQLITE_OK {
  17352 			rc = unixShmSystemLock(tls, pDbFd, F_WRLCK, ofst+(22+SQLITE_SHM_NLOCK)*4, n)
  17353 			if rc == SQLITE_OK {
  17354 				*(*U16)(unsafe.Pointer(p + 12)) |= U16(int32(mask))
  17355 				for ii = ofst; ii < ofst+n; ii++ {
  17356 					*(*int32)(unsafe.Pointer(aLock + uintptr(ii)*4)) = -1
  17357 				}
  17358 			}
  17359 		}
  17360 	}
  17361 
  17362 	Xsqlite3_mutex_leave(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17363 
  17364 	return rc
  17365 }
  17366 
  17367 func unixShmBarrier(tls *libc.TLS, fd uintptr) {
  17368 	_ = fd
  17369 
  17370 	unixEnterMutex(tls)
  17371 	unixLeaveMutex(tls)
  17372 }
  17373 
  17374 func unixShmUnmap(tls *libc.TLS, fd uintptr, deleteFlag int32) int32 {
  17375 	var p uintptr
  17376 	var pShmNode uintptr
  17377 	var pp uintptr
  17378 	var pDbFd uintptr
  17379 
  17380 	pDbFd = fd
  17381 	p = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm
  17382 	if p == uintptr(0) {
  17383 		return SQLITE_OK
  17384 	}
  17385 	pShmNode = (*UnixShm)(unsafe.Pointer(p)).FpShmNode
  17386 
  17387 	Xsqlite3_mutex_enter(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17388 	for pp = pShmNode + 32; *(*uintptr)(unsafe.Pointer(pp)) != p; pp = *(*uintptr)(unsafe.Pointer(pp)) + 4 {
  17389 	}
  17390 	*(*uintptr)(unsafe.Pointer(pp)) = (*UnixShm)(unsafe.Pointer(p)).FpNext
  17391 
  17392 	Xsqlite3_free(tls, p)
  17393 	(*UnixFile)(unsafe.Pointer(pDbFd)).FpShm = uintptr(0)
  17394 	Xsqlite3_mutex_leave(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex)
  17395 
  17396 	unixEnterMutex(tls)
  17397 
  17398 	(*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRef--
  17399 	if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRef == 0 {
  17400 		if deleteFlag != 0 && (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0 {
  17401 			(*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 16*12 + 4)))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename)
  17402 		}
  17403 		unixShmPurge(tls, pDbFd)
  17404 	}
  17405 	unixLeaveMutex(tls)
  17406 
  17407 	return SQLITE_OK
  17408 }
  17409 
  17410 func unixUnmapfile(tls *libc.TLS, pFd uintptr) {
  17411 	if (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion != 0 {
  17412 		(*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 23*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion, uint32((*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual))
  17413 		(*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion = uintptr(0)
  17414 		(*UnixFile)(unsafe.Pointer(pFd)).FmmapSize = int64(0)
  17415 		(*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual = int64(0)
  17416 	}
  17417 }
  17418 
  17419 func unixRemapfile(tls *libc.TLS, pFd uintptr, nNew I64) {
  17420 	var zErr uintptr = ts + 3419
  17421 	var h int32 = (*UnixFile)(unsafe.Pointer(pFd)).Fh
  17422 	var pOrig uintptr = (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion
  17423 	var nOrig I64 = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual
  17424 	var pNew uintptr = uintptr(0)
  17425 	var flags int32 = PROT_READ
  17426 
  17427 	if pOrig != 0 {
  17428 		var nReuse I64 = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize
  17429 		var pReq uintptr = pOrig + uintptr(nReuse)
  17430 
  17431 		if nReuse != nOrig {
  17432 			(*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 23*12 + 4)))(tls, pReq, uint32(nOrig-nReuse))
  17433 		}
  17434 
  17435 		pNew = (*(*func(*libc.TLS, uintptr, Size_t, Size_t, int32, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 24*12 + 4)))(tls, pOrig, uint32(nReuse), uint32(nNew), MREMAP_MAYMOVE, 0)
  17436 		zErr = ts + 3431
  17437 
  17438 		if pNew == libc.UintptrFromInt32(-1) || pNew == uintptr(0) {
  17439 			(*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 23*12 + 4)))(tls, pOrig, uint32(nReuse))
  17440 		}
  17441 	}
  17442 
  17443 	if pNew == uintptr(0) {
  17444 		pNew = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 22*12 + 4)))(tls, uintptr(0), uint32(nNew), flags, MAP_SHARED, h, int64(0))
  17445 	}
  17446 
  17447 	if pNew == libc.UintptrFromInt32(-1) {
  17448 		pNew = uintptr(0)
  17449 		nNew = int64(0)
  17450 		unixLogErrorAtLine(tls, SQLITE_OK, zErr, (*UnixFile)(unsafe.Pointer(pFd)).FzPath, 42173)
  17451 
  17452 		(*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeMax = int64(0)
  17453 	}
  17454 	(*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion = pNew
  17455 	(*UnixFile)(unsafe.Pointer(pFd)).FmmapSize = libc.AssignPtrInt64(pFd+56, nNew)
  17456 }
  17457 
  17458 func unixMapfile(tls *libc.TLS, pFd uintptr, nMap I64) int32 {
  17459 	bp := tls.Alloc(104)
  17460 	defer tls.Free(104)
  17461 
  17462 	if (*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut > 0 {
  17463 		return SQLITE_OK
  17464 	}
  17465 
  17466 	if nMap < int64(0) {
  17467 		if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 5*12 + 4)))(tls, (*UnixFile)(unsafe.Pointer(pFd)).Fh, bp) != 0 {
  17468 			return SQLITE_IOERR | int32(7)<<8
  17469 		}
  17470 		nMap = (*stat)(unsafe.Pointer(bp)).Fst_size
  17471 	}
  17472 	if nMap > (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeMax {
  17473 		nMap = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeMax
  17474 	}
  17475 
  17476 	if nMap != (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize {
  17477 		unixRemapfile(tls, pFd, nMap)
  17478 	}
  17479 
  17480 	return SQLITE_OK
  17481 }
  17482 
  17483 func unixFetch(tls *libc.TLS, fd uintptr, iOff I64, nAmt int32, pp uintptr) int32 {
  17484 	var pFd uintptr = fd
  17485 	*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
  17486 
  17487 	if (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeMax > int64(0) {
  17488 		if (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion == uintptr(0) {
  17489 			var rc int32 = unixMapfile(tls, pFd, int64(-1))
  17490 			if rc != SQLITE_OK {
  17491 				return rc
  17492 			}
  17493 		}
  17494 		if (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize >= iOff+I64(nAmt) {
  17495 			*(*uintptr)(unsafe.Pointer(pp)) = (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion + uintptr(iOff)
  17496 			(*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut++
  17497 		}
  17498 	}
  17499 	return SQLITE_OK
  17500 }
  17501 
  17502 func unixUnfetch(tls *libc.TLS, fd uintptr, iOff I64, p uintptr) int32 {
  17503 	var pFd uintptr = fd
  17504 	_ = iOff
  17505 
  17506 	if p != 0 {
  17507 		(*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut--
  17508 	} else {
  17509 		unixUnmapfile(tls, pFd)
  17510 	}
  17511 
  17512 	return SQLITE_OK
  17513 }
  17514 
  17515 var posixIoMethods = Sqlite3_io_methods{FiVersion: 3, FxClose: 0, FxRead: 0, FxWrite: 0, FxTruncate: 0, FxSync: 0, FxFileSize: 0, FxLock: 0, FxUnlock: 0, FxCheckReservedLock: 0, FxFileControl: 0, FxSectorSize: 0, FxDeviceCharacteristics: 0, FxShmMap: 0, FxShmLock: 0, FxShmBarrier: 0, FxShmUnmap: 0, FxFetch: 0, FxUnfetch: 0}
  17516 
  17517 func posixIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr {
  17518 	_ = z
  17519 	_ = p
  17520 	return uintptr(unsafe.Pointer(&posixIoMethods))
  17521 }
  17522 
  17523 var posixIoFinder uintptr = 0
  17524 var nolockIoMethods = Sqlite3_io_methods{FiVersion: 3, FxClose: 0, FxRead: 0, FxWrite: 0, FxTruncate: 0, FxSync: 0, FxFileSize: 0, FxLock: 0, FxUnlock: 0, FxCheckReservedLock: 0, FxFileControl: 0, FxSectorSize: 0, FxDeviceCharacteristics: 0, FxShmLock: 0, FxShmBarrier: 0, FxShmUnmap: 0, FxFetch: 0, FxUnfetch: 0}
  17525 
  17526 func nolockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr {
  17527 	_ = z
  17528 	_ = p
  17529 	return uintptr(unsafe.Pointer(&nolockIoMethods))
  17530 }
  17531 
  17532 var nolockIoFinder uintptr = 0
  17533 var dotlockIoMethods = Sqlite3_io_methods{FiVersion: 1, FxClose: 0, FxRead: 0, FxWrite: 0, FxTruncate: 0, FxSync: 0, FxFileSize: 0, FxLock: 0, FxUnlock: 0, FxCheckReservedLock: 0, FxFileControl: 0, FxSectorSize: 0, FxDeviceCharacteristics: 0, FxShmLock: 0, FxShmBarrier: 0, FxShmUnmap: 0, FxFetch: 0, FxUnfetch: 0}
  17534 
  17535 func dotlockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr {
  17536 	_ = z
  17537 	_ = p
  17538 	return uintptr(unsafe.Pointer(&dotlockIoMethods))
  17539 }
  17540 
  17541 var dotlockIoFinder uintptr = 0
  17542 
  17543 // An abstract type for a pointer to an IO method finder function:
  17544 type Finder_type = uintptr
  17545 
  17546 func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename uintptr, ctrlFlags int32) int32 {
  17547 	bp := tls.Alloc(8)
  17548 	defer tls.Free(8)
  17549 
  17550 	var pLockingStyle uintptr
  17551 	var pNew uintptr = pId
  17552 	var rc int32 = SQLITE_OK
  17553 
  17554 	(*UnixFile)(unsafe.Pointer(pNew)).Fh = h
  17555 	(*UnixFile)(unsafe.Pointer(pNew)).FpVfs = pVfs
  17556 	(*UnixFile)(unsafe.Pointer(pNew)).FzPath = zFilename
  17557 	(*UnixFile)(unsafe.Pointer(pNew)).FctrlFlags = uint16(U8(ctrlFlags))
  17558 	(*UnixFile)(unsafe.Pointer(pNew)).FmmapSizeMax = Xsqlite3Config.FszMmap
  17559 	if Xsqlite3_uri_boolean(tls, func() uintptr {
  17560 		if ctrlFlags&UNIXFILE_URI != 0 {
  17561 			return zFilename
  17562 		}
  17563 		return uintptr(0)
  17564 	}(),
  17565 		ts+3697, SQLITE_POWERSAFE_OVERWRITE) != 0 {
  17566 		*(*uint16)(unsafe.Pointer(pNew + 18)) |= uint16(UNIXFILE_PSOW)
  17567 	}
  17568 	if libc.Xstrcmp(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, ts+3702) == 0 {
  17569 		*(*uint16)(unsafe.Pointer(pNew + 18)) |= uint16(UNIXFILE_EXCL)
  17570 	}
  17571 
  17572 	if ctrlFlags&UNIXFILE_NOLOCK != 0 {
  17573 		pLockingStyle = uintptr(unsafe.Pointer(&nolockIoMethods))
  17574 	} else {
  17575 		pLockingStyle = (*(**struct {
  17576 			f func(*libc.TLS, uintptr, uintptr) uintptr
  17577 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData}))).f(tls, zFilename, pNew)
  17578 	}
  17579 
  17580 	if pLockingStyle == uintptr(unsafe.Pointer(&posixIoMethods)) {
  17581 		unixEnterMutex(tls)
  17582 		rc = findInodeInfo(tls, pNew, pNew+8)
  17583 		if rc != SQLITE_OK {
  17584 			robust_close(tls, pNew, h, 42676)
  17585 			h = -1
  17586 		}
  17587 		unixLeaveMutex(tls)
  17588 	} else if pLockingStyle == uintptr(unsafe.Pointer(&dotlockIoMethods)) {
  17589 		var zLockFile uintptr
  17590 		var nFilename int32
  17591 
  17592 		nFilename = int32(libc.Xstrlen(tls, zFilename)) + 6
  17593 		zLockFile = Xsqlite3_malloc64(tls, uint64(nFilename))
  17594 		if zLockFile == uintptr(0) {
  17595 			rc = SQLITE_NOMEM
  17596 		} else {
  17597 			Xsqlite3_snprintf(tls, nFilename, zLockFile, ts+3712, libc.VaList(bp, zFilename))
  17598 		}
  17599 		(*UnixFile)(unsafe.Pointer(pNew)).FlockingContext = zLockFile
  17600 	}
  17601 
  17602 	storeLastErrno(tls, pNew, 0)
  17603 	if rc != SQLITE_OK {
  17604 		if h >= 0 {
  17605 			robust_close(tls, pNew, h, 42761)
  17606 		}
  17607 	} else {
  17608 		(*Sqlite3_file)(unsafe.Pointer(pId)).FpMethods = pLockingStyle
  17609 
  17610 		verifyDbFile(tls, pNew)
  17611 	}
  17612 	return rc
  17613 }
  17614 
  17615 var azTempDirs = [6]uintptr{
  17616 	uintptr(0),
  17617 	uintptr(0),
  17618 	ts + 3720,
  17619 	ts + 3729,
  17620 	ts + 3738,
  17621 	ts + 1567,
  17622 }
  17623 
  17624 func unixTempFileInit(tls *libc.TLS) {
  17625 	azTempDirs[0] = libc.Xgetenv(tls, ts+3743)
  17626 	azTempDirs[1] = libc.Xgetenv(tls, ts+3757)
  17627 }
  17628 
  17629 func unixTempFileDir(tls *libc.TLS) uintptr {
  17630 	bp := tls.Alloc(104)
  17631 	defer tls.Free(104)
  17632 
  17633 	var i uint32 = uint32(0)
  17634 
  17635 	var zDir uintptr = Xsqlite3_temp_directory
  17636 
  17637 	for 1 != 0 {
  17638 		if zDir != uintptr(0) &&
  17639 			(*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4*12 + 4)))(tls, zDir, bp) == 0 &&
  17640 			(*stat)(unsafe.Pointer(bp)).Fst_mode&X__mode_t(0170000) == X__mode_t(0040000) &&
  17641 			(*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 2*12 + 4)))(tls, zDir, 03) == 0 {
  17642 			return zDir
  17643 		}
  17644 		if i >= uint32(unsafe.Sizeof(azTempDirs))/uint32(unsafe.Sizeof(uintptr(0))) {
  17645 			break
  17646 		}
  17647 		zDir = azTempDirs[libc.PostIncUint32(&i, 1)]
  17648 	}
  17649 	return uintptr(0)
  17650 }
  17651 
  17652 func unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) int32 {
  17653 	bp := tls.Alloc(32)
  17654 	defer tls.Free(32)
  17655 
  17656 	var zDir uintptr
  17657 	var iLimit int32 = 0
  17658 	var rc int32 = SQLITE_OK
  17659 
  17660 	*(*uint8)(unsafe.Pointer(zBuf)) = uint8(0)
  17661 
  17662 	Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1))
  17663 	zDir = unixTempFileDir(tls)
  17664 	if zDir == uintptr(0) {
  17665 		rc = SQLITE_IOERR | int32(25)<<8
  17666 	} else {
  17667 		for __ccgo := true; __ccgo; __ccgo = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 2*12 + 4)))(tls, zBuf, 0) == 0 {
  17668 			Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U64(0))), bp+24)
  17669 
  17670 			*(*uint8)(unsafe.Pointer(zBuf + uintptr(nBuf-2))) = uint8(0)
  17671 			Xsqlite3_snprintf(tls, nBuf, zBuf, ts+3764,
  17672 				libc.VaList(bp, zDir, *(*U64)(unsafe.Pointer(bp + 24)), 0))
  17673 			if int32(*(*uint8)(unsafe.Pointer(zBuf + uintptr(nBuf-2)))) != 0 || libc.PostIncInt32(&iLimit, 1) > 10 {
  17674 				rc = SQLITE_ERROR
  17675 				break
  17676 			}
  17677 		}
  17678 	}
  17679 	Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1))
  17680 	return rc
  17681 }
  17682 
  17683 func findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) uintptr {
  17684 	bp := tls.Alloc(104)
  17685 	defer tls.Free(104)
  17686 
  17687 	var pUnused uintptr = uintptr(0)
  17688 
  17689 	unixEnterMutex(tls)
  17690 
  17691 	if inodeList != uintptr(0) && 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4*12 + 4)))(tls, zPath, bp) {
  17692 		var pInode uintptr
  17693 
  17694 		pInode = inodeList
  17695 		for pInode != 0 && ((*UnixInodeInfo)(unsafe.Pointer(pInode)).FfileId.Fdev != (*stat)(unsafe.Pointer(bp)).Fst_dev ||
  17696 			(*UnixInodeInfo)(unsafe.Pointer(pInode)).FfileId.Fino != (*stat)(unsafe.Pointer(bp)).Fst_ino) {
  17697 			pInode = (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpNext
  17698 		}
  17699 		if pInode != 0 {
  17700 			var pp uintptr
  17701 
  17702 			Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  17703 			flags = flags & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE)
  17704 			for pp = pInode + 32; *(*uintptr)(unsafe.Pointer(pp)) != 0 && (*UnixUnusedFd)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).Fflags != flags; pp = *(*uintptr)(unsafe.Pointer(pp)) + 8 {
  17705 			}
  17706 			pUnused = *(*uintptr)(unsafe.Pointer(pp))
  17707 			if pUnused != 0 {
  17708 				*(*uintptr)(unsafe.Pointer(pp)) = (*UnixUnusedFd)(unsafe.Pointer(pUnused)).FpNext
  17709 			}
  17710 			Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
  17711 		}
  17712 	}
  17713 	unixLeaveMutex(tls)
  17714 	return pUnused
  17715 }
  17716 
  17717 func getFileMode(tls *libc.TLS, zFile uintptr, pMode uintptr, pUid uintptr, pGid uintptr) int32 {
  17718 	bp := tls.Alloc(104)
  17719 	defer tls.Free(104)
  17720 
  17721 	var rc int32 = SQLITE_OK
  17722 	if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4*12 + 4)))(tls, zFile, bp) {
  17723 		*(*Mode_t)(unsafe.Pointer(pMode)) = (*stat)(unsafe.Pointer(bp)).Fst_mode & X__mode_t(0777)
  17724 		*(*Uid_t)(unsafe.Pointer(pUid)) = (*stat)(unsafe.Pointer(bp)).Fst_uid
  17725 		*(*Gid_t)(unsafe.Pointer(pGid)) = (*stat)(unsafe.Pointer(bp)).Fst_gid
  17726 	} else {
  17727 		rc = SQLITE_IOERR | int32(7)<<8
  17728 	}
  17729 	return rc
  17730 }
  17731 
  17732 func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr, pUid uintptr, pGid uintptr) int32 {
  17733 	bp := tls.Alloc(513)
  17734 	defer tls.Free(513)
  17735 
  17736 	var rc int32 = SQLITE_OK
  17737 	*(*Mode_t)(unsafe.Pointer(pMode)) = Mode_t(0)
  17738 	*(*Uid_t)(unsafe.Pointer(pUid)) = Uid_t(0)
  17739 	*(*Gid_t)(unsafe.Pointer(pGid)) = Gid_t(0)
  17740 	if flags&(SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) != 0 {
  17741 		var nDb int32
  17742 
  17743 		nDb = Xsqlite3Strlen30(tls, zPath) - 1
  17744 		for nDb > 0 && int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(nDb)))) != '.' {
  17745 			if int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(nDb)))) == '-' {
  17746 				libc.Xmemcpy(tls, bp, zPath, uint32(nDb))
  17747 				*(*uint8)(unsafe.Pointer(bp + uintptr(nDb))) = uint8(0)
  17748 				rc = getFileMode(tls, bp, pMode, pUid, pGid)
  17749 				break
  17750 			}
  17751 			nDb--
  17752 		}
  17753 	} else if flags&SQLITE_OPEN_DELETEONCLOSE != 0 {
  17754 		*(*Mode_t)(unsafe.Pointer(pMode)) = Mode_t(0600)
  17755 	} else if flags&SQLITE_OPEN_URI != 0 {
  17756 		var z uintptr = Xsqlite3_uri_parameter(tls, zPath, ts+3781)
  17757 		if z != 0 {
  17758 			rc = getFileMode(tls, z, pMode, pUid, pGid)
  17759 		}
  17760 	}
  17761 	return rc
  17762 }
  17763 
  17764 func unixOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 {
  17765 	bp := tls.Alloc(528)
  17766 	defer tls.Free(528)
  17767 
  17768 	var p uintptr
  17769 	var fd int32
  17770 	var openFlags int32
  17771 	var eType int32
  17772 	var noLock int32
  17773 	var rc int32
  17774 	var ctrlFlags int32
  17775 
  17776 	var isExclusive int32
  17777 	var isDelete int32
  17778 	var isCreate int32
  17779 	var isReadonly int32
  17780 	var isReadWrite int32
  17781 
  17782 	var isNewJrnl int32
  17783 
  17784 	var zName uintptr
  17785 	var pUnused uintptr
  17786 	var rc2 int32
  17787 
  17788 	p = pFile
  17789 	fd = -1
  17790 	openFlags = 0
  17791 	eType = flags & 0x0FFF00
  17792 	rc = SQLITE_OK
  17793 	ctrlFlags = 0
  17794 	isExclusive = flags & SQLITE_OPEN_EXCLUSIVE
  17795 	isDelete = flags & SQLITE_OPEN_DELETEONCLOSE
  17796 	isCreate = flags & SQLITE_OPEN_CREATE
  17797 	isReadonly = flags & SQLITE_OPEN_READONLY
  17798 	isReadWrite = flags & SQLITE_OPEN_READWRITE
  17799 	isNewJrnl = libc.Bool32(isCreate != 0 && (eType == SQLITE_OPEN_SUPER_JOURNAL ||
  17800 		eType == SQLITE_OPEN_MAIN_JOURNAL ||
  17801 		eType == SQLITE_OPEN_WAL))
  17802 	zName = zPath
  17803 
  17804 	if !(libc.AtomicLoadInt32(&randomnessPid) != libc.Xgetpid(tls)) {
  17805 		goto __1
  17806 	}
  17807 	libc.AtomicStoreInt32(&randomnessPid, libc.Xgetpid(tls))
  17808 	Xsqlite3_randomness(tls, 0, uintptr(0))
  17809 __1:
  17810 	;
  17811 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(UnixFile{})))
  17812 
  17813 	if !(eType == SQLITE_OPEN_MAIN_DB) {
  17814 		goto __2
  17815 	}
  17816 	pUnused = findReusableFd(tls, zName, flags)
  17817 	if !(pUnused != 0) {
  17818 		goto __4
  17819 	}
  17820 	fd = (*UnixUnusedFd)(unsafe.Pointer(pUnused)).Ffd
  17821 	goto __5
  17822 __4:
  17823 	pUnused = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(UnixUnusedFd{})))
  17824 	if !!(pUnused != 0) {
  17825 		goto __6
  17826 	}
  17827 	return SQLITE_NOMEM
  17828 __6:
  17829 	;
  17830 __5:
  17831 	;
  17832 	(*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused = pUnused
  17833 
  17834 	goto __3
  17835 __2:
  17836 	if !!(zName != 0) {
  17837 		goto __7
  17838 	}
  17839 
  17840 	rc = unixGetTempname(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, bp)
  17841 	if !(rc != SQLITE_OK) {
  17842 		goto __8
  17843 	}
  17844 	return rc
  17845 __8:
  17846 	;
  17847 	zName = bp
  17848 
  17849 __7:
  17850 	;
  17851 __3:
  17852 	;
  17853 	if !(isReadonly != 0) {
  17854 		goto __9
  17855 	}
  17856 	openFlags = openFlags | O_RDONLY
  17857 __9:
  17858 	;
  17859 	if !(isReadWrite != 0) {
  17860 		goto __10
  17861 	}
  17862 	openFlags = openFlags | O_RDWR
  17863 __10:
  17864 	;
  17865 	if !(isCreate != 0) {
  17866 		goto __11
  17867 	}
  17868 	openFlags = openFlags | O_CREAT
  17869 __11:
  17870 	;
  17871 	if !(isExclusive != 0) {
  17872 		goto __12
  17873 	}
  17874 	openFlags = openFlags | (O_EXCL | 0100000)
  17875 __12:
  17876 	;
  17877 	openFlags = openFlags | (0400000 | O_BINARY | 0100000)
  17878 
  17879 	if !(fd < 0) {
  17880 		goto __13
  17881 	}
  17882 	rc = findCreateFileMode(tls, zName, flags, bp+516, bp+520, bp+524)
  17883 	if !(rc != SQLITE_OK) {
  17884 		goto __14
  17885 	}
  17886 
  17887 	return rc
  17888 __14:
  17889 	;
  17890 	fd = robust_open(tls, zName, openFlags, *(*Mode_t)(unsafe.Pointer(bp + 516)))
  17891 
  17892 	if !(fd < 0) {
  17893 		goto __15
  17894 	}
  17895 	if !(isNewJrnl != 0 && *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == EACCES && (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 2*12 + 4)))(tls, zName, F_OK) != 0) {
  17896 		goto __16
  17897 	}
  17898 
  17899 	rc = SQLITE_READONLY | int32(6)<<8
  17900 	goto __17
  17901 __16:
  17902 	if !(*(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) != EISDIR && isReadWrite != 0) {
  17903 		goto __18
  17904 	}
  17905 
  17906 	flags = flags & libc.CplInt32(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE)
  17907 	openFlags = openFlags & libc.CplInt32(O_RDWR|O_CREAT)
  17908 	flags = flags | SQLITE_OPEN_READONLY
  17909 	openFlags = openFlags | O_RDONLY
  17910 	isReadonly = 1
  17911 	fd = robust_open(tls, zName, openFlags, *(*Mode_t)(unsafe.Pointer(bp + 516)))
  17912 __18:
  17913 	;
  17914 __17:
  17915 	;
  17916 __15:
  17917 	;
  17918 	if !(fd < 0) {
  17919 		goto __19
  17920 	}
  17921 	rc2 = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 43202), ts+3261, zName, 43202)
  17922 	if !(rc == SQLITE_OK) {
  17923 		goto __20
  17924 	}
  17925 	rc = rc2
  17926 __20:
  17927 	;
  17928 	goto open_finished
  17929 __19:
  17930 	;
  17931 	if !(*(*Mode_t)(unsafe.Pointer(bp + 516)) != 0 && flags&(SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) != 0) {
  17932 		goto __21
  17933 	}
  17934 	robustFchown(tls, fd, *(*Uid_t)(unsafe.Pointer(bp + 520)), *(*Gid_t)(unsafe.Pointer(bp + 524)))
  17935 __21:
  17936 	;
  17937 __13:
  17938 	;
  17939 	if !(pOutFlags != 0) {
  17940 		goto __22
  17941 	}
  17942 	*(*int32)(unsafe.Pointer(pOutFlags)) = flags
  17943 __22:
  17944 	;
  17945 	if !((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused != 0) {
  17946 		goto __23
  17947 	}
  17948 	(*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Ffd = fd
  17949 	(*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Fflags = flags & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE)
  17950 __23:
  17951 	;
  17952 	if !(isDelete != 0) {
  17953 		goto __24
  17954 	}
  17955 	(*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 16*12 + 4)))(tls, zName)
  17956 __24:
  17957 	;
  17958 	if !(isDelete != 0) {
  17959 		goto __25
  17960 	}
  17961 	ctrlFlags = ctrlFlags | UNIXFILE_DELETE
  17962 __25:
  17963 	;
  17964 	if !(isReadonly != 0) {
  17965 		goto __26
  17966 	}
  17967 	ctrlFlags = ctrlFlags | UNIXFILE_RDONLY
  17968 __26:
  17969 	;
  17970 	noLock = libc.Bool32(eType != SQLITE_OPEN_MAIN_DB)
  17971 	if !(noLock != 0) {
  17972 		goto __27
  17973 	}
  17974 	ctrlFlags = ctrlFlags | UNIXFILE_NOLOCK
  17975 __27:
  17976 	;
  17977 	if !(isNewJrnl != 0) {
  17978 		goto __28
  17979 	}
  17980 	ctrlFlags = ctrlFlags | UNIXFILE_DIRSYNC
  17981 __28:
  17982 	;
  17983 	if !(flags&SQLITE_OPEN_URI != 0) {
  17984 		goto __29
  17985 	}
  17986 	ctrlFlags = ctrlFlags | UNIXFILE_URI
  17987 __29:
  17988 	;
  17989 	rc = fillInUnixFile(tls, pVfs, fd, pFile, zPath, ctrlFlags)
  17990 
  17991 open_finished:
  17992 	if !(rc != SQLITE_OK) {
  17993 		goto __30
  17994 	}
  17995 	Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)
  17996 __30:
  17997 	;
  17998 	return rc
  17999 }
  18000 
  18001 func unixDelete(tls *libc.TLS, NotUsed uintptr, zPath uintptr, dirSync int32) int32 {
  18002 	bp := tls.Alloc(4)
  18003 	defer tls.Free(4)
  18004 
  18005 	var rc int32 = SQLITE_OK
  18006 	_ = NotUsed
  18007 
  18008 	if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 16*12 + 4)))(tls, zPath) == -1 {
  18009 		if *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == ENOENT {
  18010 			rc = SQLITE_IOERR | int32(23)<<8
  18011 		} else {
  18012 			rc = unixLogErrorAtLine(tls, SQLITE_IOERR|int32(10)<<8, ts+3371, zPath, 43341)
  18013 		}
  18014 		return rc
  18015 	}
  18016 	if dirSync&1 != 0 {
  18017 		rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 17*12 + 4)))(tls, zPath, bp)
  18018 		if rc == SQLITE_OK {
  18019 			if full_fsync(tls, *(*int32)(unsafe.Pointer(bp)), 0, 0) != 0 {
  18020 				rc = unixLogErrorAtLine(tls, SQLITE_IOERR|int32(5)<<8, ts+3788, zPath, 43351)
  18021 			}
  18022 			robust_close(tls, uintptr(0), *(*int32)(unsafe.Pointer(bp)), 43353)
  18023 		} else {
  18024 			rc = SQLITE_OK
  18025 		}
  18026 	}
  18027 	return rc
  18028 }
  18029 
  18030 func unixAccess(tls *libc.TLS, NotUsed uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 {
  18031 	bp := tls.Alloc(104)
  18032 	defer tls.Free(104)
  18033 
  18034 	_ = NotUsed
  18035 
  18036 	if flags == SQLITE_ACCESS_EXISTS {
  18037 		*(*int32)(unsafe.Pointer(pResOut)) = libc.Bool32(0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4*12 + 4)))(tls, zPath, bp) && (!((*stat)(unsafe.Pointer(bp)).Fst_mode&X__mode_t(0170000) == X__mode_t(0100000)) || (*stat)(unsafe.Pointer(bp)).Fst_size > int64(0)))
  18038 	} else {
  18039 		*(*int32)(unsafe.Pointer(pResOut)) = libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 2*12 + 4)))(tls, zPath, W_OK|R_OK) == 0)
  18040 	}
  18041 	return SQLITE_OK
  18042 }
  18043 
  18044 // A pathname under construction
  18045 type DbPath1 = struct {
  18046 	Frc       int32
  18047 	FnSymlink int32
  18048 	FzOut     uintptr
  18049 	FnOut     int32
  18050 	FnUsed    int32
  18051 }
  18052 
  18053 // A pathname under construction
  18054 type DbPath = DbPath1
  18055 
  18056 func appendOnePathElement(tls *libc.TLS, pPath uintptr, zName uintptr, nName int32) {
  18057 	bp := tls.Alloc(4202)
  18058 	defer tls.Free(4202)
  18059 
  18060 	if int32(*(*uint8)(unsafe.Pointer(zName))) == '.' {
  18061 		if nName == 1 {
  18062 			return
  18063 		}
  18064 		if int32(*(*uint8)(unsafe.Pointer(zName + 1))) == '.' && nName == 2 {
  18065 			if (*DbPath)(unsafe.Pointer(pPath)).FnUsed > 1 {
  18066 				for int32(*(*uint8)(unsafe.Pointer((*DbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(libc.PreDecInt32(&(*DbPath)(unsafe.Pointer(pPath)).FnUsed, 1))))) != '/' {
  18067 				}
  18068 			}
  18069 			return
  18070 		}
  18071 	}
  18072 	if (*DbPath)(unsafe.Pointer(pPath)).FnUsed+nName+2 >= (*DbPath)(unsafe.Pointer(pPath)).FnOut {
  18073 		(*DbPath)(unsafe.Pointer(pPath)).Frc = SQLITE_ERROR
  18074 		return
  18075 	}
  18076 	*(*uint8)(unsafe.Pointer((*DbPath)(unsafe.Pointer(pPath)).FzOut + uintptr(libc.PostIncInt32(&(*DbPath)(unsafe.Pointer(pPath)).FnUsed, 1)))) = uint8('/')
  18077 	libc.Xmemcpy(tls, (*DbPath)(unsafe.Pointer(pPath)).FzOut+uintptr((*DbPath)(unsafe.Pointer(pPath)).FnUsed), zName, uint32(nName))
  18078 	*(*int32)(unsafe.Pointer(pPath + 16)) += nName
  18079 	if (*DbPath)(unsafe.Pointer(pPath)).Frc == SQLITE_OK {
  18080 		var zIn uintptr
  18081 
  18082 		*(*uint8)(unsafe.Pointer((*DbPath)(unsafe.Pointer(pPath)).FzOut + uintptr((*DbPath)(unsafe.Pointer(pPath)).FnUsed))) = uint8(0)
  18083 		zIn = (*DbPath)(unsafe.Pointer(pPath)).FzOut
  18084 		if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 27*12 + 4)))(tls, zIn, bp) != 0 {
  18085 			if *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) != ENOENT {
  18086 				(*DbPath)(unsafe.Pointer(pPath)).Frc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 43447), ts+3459, zIn, 43447)
  18087 			}
  18088 		} else if (*stat)(unsafe.Pointer(bp)).Fst_mode&X__mode_t(0170000) == X__mode_t(0120000) {
  18089 			var got Ssize_t
  18090 
  18091 			if libc.PostIncInt32(&(*DbPath)(unsafe.Pointer(pPath)).FnSymlink, 1) > SQLITE_MAX_SYMLINK {
  18092 				(*DbPath)(unsafe.Pointer(pPath)).Frc = Xsqlite3CantopenError(tls, 43453)
  18093 				return
  18094 			}
  18095 			got = (*(*func(*libc.TLS, uintptr, uintptr, Size_t) Ssize_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 26*12 + 4)))(tls, zIn, bp+104, uint32(unsafe.Sizeof([4098]uint8{}))-uint32(2))
  18096 			if got <= 0 || got >= Ssize_t(unsafe.Sizeof([4098]uint8{}))-2 {
  18097 				(*DbPath)(unsafe.Pointer(pPath)).Frc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 43458), ts+3450, zIn, 43458)
  18098 				return
  18099 			}
  18100 			*(*uint8)(unsafe.Pointer(bp + 104 + uintptr(got))) = uint8(0)
  18101 			if int32(*(*uint8)(unsafe.Pointer(bp + 104))) == '/' {
  18102 				(*DbPath)(unsafe.Pointer(pPath)).FnUsed = 0
  18103 			} else {
  18104 				*(*int32)(unsafe.Pointer(pPath + 16)) -= nName + 1
  18105 			}
  18106 			appendAllPathElements(tls, pPath, bp+104)
  18107 		}
  18108 	}
  18109 }
  18110 
  18111 func appendAllPathElements(tls *libc.TLS, pPath uintptr, zPath uintptr) {
  18112 	var i int32 = 0
  18113 	var j int32 = 0
  18114 	for __ccgo := true; __ccgo; __ccgo = *(*uint8)(unsafe.Pointer(zPath + uintptr(libc.PostIncInt32(&i, 1)))) != 0 {
  18115 		for *(*uint8)(unsafe.Pointer(zPath + uintptr(i))) != 0 && int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(i)))) != '/' {
  18116 			i++
  18117 		}
  18118 		if i > j {
  18119 			appendOnePathElement(tls, pPath, zPath+uintptr(j), i-j)
  18120 		}
  18121 		j = i + 1
  18122 	}
  18123 }
  18124 
  18125 func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 {
  18126 	bp := tls.Alloc(4120)
  18127 	defer tls.Free(4120)
  18128 
  18129 	_ = pVfs
  18130 	(*DbPath)(unsafe.Pointer(bp + 4100)).Frc = 0
  18131 	(*DbPath)(unsafe.Pointer(bp + 4100)).FnUsed = 0
  18132 	(*DbPath)(unsafe.Pointer(bp + 4100)).FnSymlink = 0
  18133 	(*DbPath)(unsafe.Pointer(bp + 4100)).FnOut = nOut
  18134 	(*DbPath)(unsafe.Pointer(bp + 4100)).FzOut = zOut
  18135 	if int32(*(*uint8)(unsafe.Pointer(zPath))) != '/' {
  18136 		if (*(*func(*libc.TLS, uintptr, Size_t) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 3*12 + 4)))(tls, bp, uint32(unsafe.Sizeof([4098]uint8{}))-uint32(2)) == uintptr(0) {
  18137 			return unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 43516), ts+3279, zPath, 43516)
  18138 		}
  18139 		appendAllPathElements(tls, bp+4100, bp)
  18140 	}
  18141 	appendAllPathElements(tls, bp+4100, zPath)
  18142 	*(*uint8)(unsafe.Pointer(zOut + uintptr((*DbPath)(unsafe.Pointer(bp+4100)).FnUsed))) = uint8(0)
  18143 	if (*DbPath)(unsafe.Pointer(bp+4100)).Frc != 0 || (*DbPath)(unsafe.Pointer(bp+4100)).FnUsed < 2 {
  18144 		return Xsqlite3CantopenError(tls, 43522)
  18145 	}
  18146 	if (*DbPath)(unsafe.Pointer(bp+4100)).FnSymlink != 0 {
  18147 		return SQLITE_OK | int32(2)<<8
  18148 	}
  18149 	return SQLITE_OK
  18150 }
  18151 
  18152 // Type for namespace indeces.
  18153 type Lmid_t = int32
  18154 
  18155 // Structure containing information about object searched using
  18156 //
  18157 //	`dladdr'.
  18158 type Dl_info = struct {
  18159 	Fdli_fname uintptr
  18160 	Fdli_fbase uintptr
  18161 	Fdli_sname uintptr
  18162 	Fdli_saddr uintptr
  18163 }
  18164 
  18165 // This is the type of elements in `Dl_serinfo', below.
  18166 //
  18167 //	The `dls_name' member points to space in the buffer passed to `dlinfo'.
  18168 type Dl_serpath = struct {
  18169 	Fdls_name  uintptr
  18170 	Fdls_flags uint32
  18171 }
  18172 
  18173 // This is the structure that must be passed (by reference) to `dlinfo' for
  18174 //
  18175 //	the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests.
  18176 type Dl_serinfo = struct {
  18177 	Fdls_size Size_t
  18178 	Fdls_cnt  uint32
  18179 	F__8      struct {
  18180 		F__ccgo_pad1 [0]uint32
  18181 		Fdls_serpath [0]Dl_serpath
  18182 		F__ccgo_pad2 [8]byte
  18183 	}
  18184 }
  18185 
  18186 func unixDlOpen(tls *libc.TLS, NotUsed uintptr, zFilename uintptr) uintptr {
  18187 	_ = NotUsed
  18188 	return libc.Xdlopen(tls, zFilename, RTLD_NOW|RTLD_GLOBAL)
  18189 }
  18190 
  18191 func unixDlError(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBufOut uintptr) {
  18192 	bp := tls.Alloc(8)
  18193 	defer tls.Free(8)
  18194 
  18195 	var zErr uintptr
  18196 	_ = NotUsed
  18197 	unixEnterMutex(tls)
  18198 	zErr = libc.Xdlerror(tls)
  18199 	if zErr != 0 {
  18200 		Xsqlite3_snprintf(tls, nBuf, zBufOut, ts+3663, libc.VaList(bp, zErr))
  18201 	}
  18202 	unixLeaveMutex(tls)
  18203 }
  18204 
  18205 func unixDlSym(tls *libc.TLS, NotUsed uintptr, p uintptr, zSym uintptr) uintptr {
  18206 	var x uintptr
  18207 	_ = NotUsed
  18208 	x = *(*uintptr)(unsafe.Pointer(&struct {
  18209 		f func(*libc.TLS, uintptr, uintptr) uintptr
  18210 	}{libc.Xdlsym}))
  18211 	return (*struct {
  18212 		f func(*libc.TLS, uintptr, uintptr) uintptr
  18213 	})(unsafe.Pointer(&struct{ uintptr }{x})).f(tls, p, zSym)
  18214 }
  18215 
  18216 func unixDlClose(tls *libc.TLS, NotUsed uintptr, pHandle uintptr) {
  18217 	_ = NotUsed
  18218 	libc.Xdlclose(tls, pHandle)
  18219 }
  18220 
  18221 func unixRandomness(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBuf uintptr) int32 {
  18222 	bp := tls.Alloc(4)
  18223 	defer tls.Free(4)
  18224 
  18225 	_ = NotUsed
  18226 
  18227 	libc.Xmemset(tls, zBuf, 0, uint32(nBuf))
  18228 	libc.AtomicStoreInt32(&randomnessPid, libc.Xgetpid(tls))
  18229 	{
  18230 		var fd int32
  18231 		var got int32
  18232 		fd = robust_open(tls, ts+3794, O_RDONLY, uint32(0))
  18233 		if fd < 0 {
  18234 			libc.Xtime(tls, bp)
  18235 			libc.Xmemcpy(tls, zBuf, bp, uint32(unsafe.Sizeof(Time_t(0))))
  18236 			libc.Xmemcpy(tls, zBuf+4, uintptr(unsafe.Pointer(&randomnessPid)), uint32(unsafe.Sizeof(randomnessPid)))
  18237 
  18238 			nBuf = int32(uint32(unsafe.Sizeof(Time_t(0))) + uint32(unsafe.Sizeof(randomnessPid)))
  18239 		} else {
  18240 			for __ccgo := true; __ccgo; __ccgo = got < 0 && *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) == EINTR {
  18241 				got = (*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 8*12 + 4)))(tls, fd, zBuf, uint32(nBuf))
  18242 			}
  18243 			robust_close(tls, uintptr(0), fd, 43623)
  18244 		}
  18245 
  18246 	}
  18247 	return nBuf
  18248 }
  18249 
  18250 func unixSleep(tls *libc.TLS, NotUsed uintptr, microseconds int32) int32 {
  18251 	bp := tls.Alloc(8)
  18252 	defer tls.Free(8)
  18253 
  18254 	(*timespec)(unsafe.Pointer(bp)).Ftv_sec = microseconds / 1000000
  18255 	(*timespec)(unsafe.Pointer(bp)).Ftv_nsec = microseconds % 1000000 * 1000
  18256 	libc.Xnanosleep(tls, bp, uintptr(0))
  18257 	_ = NotUsed
  18258 	return microseconds
  18259 }
  18260 
  18261 func unixCurrentTimeInt64(tls *libc.TLS, NotUsed uintptr, piNow uintptr) int32 {
  18262 	bp := tls.Alloc(8)
  18263 	defer tls.Free(8)
  18264 
  18265 	var rc int32 = SQLITE_OK
  18266 
  18267 	libc.Xgettimeofday(tls, bp, uintptr(0))
  18268 	*(*Sqlite3_int64)(unsafe.Pointer(piNow)) = unixEpoch + int64(1000)*Sqlite3_int64((*timeval)(unsafe.Pointer(bp)).Ftv_sec) + Sqlite3_int64((*timeval)(unsafe.Pointer(bp)).Ftv_usec/1000)
  18269 
  18270 	_ = NotUsed
  18271 	return rc
  18272 }
  18273 
  18274 var unixEpoch Sqlite3_int64 = int64(24405875) * int64(8640000)
  18275 
  18276 func unixCurrentTime(tls *libc.TLS, NotUsed uintptr, prNow uintptr) int32 {
  18277 	bp := tls.Alloc(8)
  18278 	defer tls.Free(8)
  18279 
  18280 	*(*Sqlite3_int64)(unsafe.Pointer(bp)) = int64(0)
  18281 	var rc int32
  18282 	_ = NotUsed
  18283 	rc = unixCurrentTimeInt64(tls, uintptr(0), bp)
  18284 	*(*float64)(unsafe.Pointer(prNow)) = float64(*(*Sqlite3_int64)(unsafe.Pointer(bp))) / 86400000.0
  18285 	return rc
  18286 }
  18287 
  18288 func unixGetLastError(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32, NotUsed3 uintptr) int32 {
  18289 	_ = NotUsed
  18290 	_ = NotUsed2
  18291 	_ = NotUsed3
  18292 	return *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))
  18293 }
  18294 
  18295 // Initialize the operating system interface.
  18296 //
  18297 // This routine registers all VFS implementations for unix-like operating
  18298 // systems.  This routine, and the sqlite3_os_end() routine that follows,
  18299 // should be the only routines in this file that are visible from other
  18300 // files.
  18301 //
  18302 // This routine is called once during SQLite initialization and by a
  18303 // single thread.  The memory allocation and mutex subsystems have not
  18304 // necessarily been initialized when this routine is called, and so they
  18305 // should not be used.
  18306 func Xsqlite3_os_init(tls *libc.TLS) int32 {
  18307 	var i uint32
  18308 
  18309 	for i = uint32(0); i < uint32(unsafe.Sizeof(aVfs))/uint32(unsafe.Sizeof(Sqlite3_vfs{})); i++ {
  18310 		Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&aVfs))+uintptr(i)*88, libc.Bool32(i == uint32(0)))
  18311 	}
  18312 	unixBigLock = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1)
  18313 
  18314 	unixTempFileInit(tls)
  18315 
  18316 	return SQLITE_OK
  18317 }
  18318 
  18319 var aVfs = [4]Sqlite3_vfs{
  18320 	{FiVersion: 3, FszOsFile: int32(unsafe.Sizeof(UnixFile{})), FmxPathname: MAX_PATHNAME, FzName: ts + 3807, FpAppData: 0, FxOpen: 0, FxDelete: 0, FxAccess: 0, FxFullPathname: 0, FxDlOpen: 0, FxDlError: 0, FxDlSym: 0, FxDlClose: 0, FxRandomness: 0, FxSleep: 0, FxCurrentTime: 0, FxGetLastError: 0, FxCurrentTimeInt64: 0, FxSetSystemCall: 0, FxGetSystemCall: 0, FxNextSystemCall: 0},
  18321 	{FiVersion: 3, FszOsFile: int32(unsafe.Sizeof(UnixFile{})), FmxPathname: MAX_PATHNAME, FzName: ts + 3812, FpAppData: 0, FxOpen: 0, FxDelete: 0, FxAccess: 0, FxFullPathname: 0, FxDlOpen: 0, FxDlError: 0, FxDlSym: 0, FxDlClose: 0, FxRandomness: 0, FxSleep: 0, FxCurrentTime: 0, FxGetLastError: 0, FxCurrentTimeInt64: 0, FxSetSystemCall: 0, FxGetSystemCall: 0, FxNextSystemCall: 0},
  18322 	{FiVersion: 3, FszOsFile: int32(unsafe.Sizeof(UnixFile{})), FmxPathname: MAX_PATHNAME, FzName: ts + 3822, FpAppData: 0, FxOpen: 0, FxDelete: 0, FxAccess: 0, FxFullPathname: 0, FxDlOpen: 0, FxDlError: 0, FxDlSym: 0, FxDlClose: 0, FxRandomness: 0, FxSleep: 0, FxCurrentTime: 0, FxGetLastError: 0, FxCurrentTimeInt64: 0, FxSetSystemCall: 0, FxGetSystemCall: 0, FxNextSystemCall: 0},
  18323 	{FiVersion: 3, FszOsFile: int32(unsafe.Sizeof(UnixFile{})), FmxPathname: MAX_PATHNAME, FzName: ts + 3702, FpAppData: 0, FxOpen: 0, FxDelete: 0, FxAccess: 0, FxFullPathname: 0, FxDlOpen: 0, FxDlError: 0, FxDlSym: 0, FxDlClose: 0, FxRandomness: 0, FxSleep: 0, FxCurrentTime: 0, FxGetLastError: 0, FxCurrentTimeInt64: 0, FxSetSystemCall: 0, FxGetSystemCall: 0, FxNextSystemCall: 0},
  18324 }
  18325 
  18326 // Shutdown the operating system interface.
  18327 //
  18328 // Some operating systems might need to do some cleanup in this routine,
  18329 // to release dynamically allocated objects.  But not on unix.
  18330 // This routine is a no-op for unix.
  18331 func Xsqlite3_os_end(tls *libc.TLS) int32 {
  18332 	unixBigLock = uintptr(0)
  18333 	return SQLITE_OK
  18334 }
  18335 
  18336 // Forward declaration of objects used by this utility
  18337 type MemVfs = sqlite3_vfs
  18338 type MemFile1 = struct {
  18339 	Fbase   Sqlite3_file
  18340 	FpStore uintptr
  18341 	FeLock  int32
  18342 }
  18343 
  18344 type MemFile = MemFile1
  18345 type MemStore1 = struct {
  18346 	Fsz      Sqlite3_int64
  18347 	FszAlloc Sqlite3_int64
  18348 	FszMax   Sqlite3_int64
  18349 	FaData   uintptr
  18350 	FpMutex  uintptr
  18351 	FnMmap   int32
  18352 	FmFlags  uint32
  18353 	FnRdLock int32
  18354 	FnWrLock int32
  18355 	FnRef    int32
  18356 	FzFName  uintptr
  18357 }
  18358 
  18359 type MemStore = MemStore1
  18360 
  18361 // File-scope variables for holding the memdb files that are accessible
  18362 // to multiple database connections in separate threads.
  18363 //
  18364 // Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object.
  18365 type MemFS = struct {
  18366 	FnMemStore  int32
  18367 	FapMemStore uintptr
  18368 }
  18369 
  18370 var memdb_g MemFS
  18371 
  18372 var memdb_vfs = Sqlite3_vfs{
  18373 	FiVersion:          2,
  18374 	FmxPathname:        1024,
  18375 	FzName:             ts + 3835,
  18376 	FxOpen:             0,
  18377 	FxAccess:           0,
  18378 	FxFullPathname:     0,
  18379 	FxDlOpen:           0,
  18380 	FxDlError:          0,
  18381 	FxDlSym:            0,
  18382 	FxDlClose:          0,
  18383 	FxRandomness:       0,
  18384 	FxSleep:            0,
  18385 	FxGetLastError:     0,
  18386 	FxCurrentTimeInt64: 0,
  18387 }
  18388 
  18389 var memdb_io_methods = Sqlite3_io_methods{
  18390 	FiVersion:               3,
  18391 	FxClose:                 0,
  18392 	FxRead:                  0,
  18393 	FxWrite:                 0,
  18394 	FxTruncate:              0,
  18395 	FxSync:                  0,
  18396 	FxFileSize:              0,
  18397 	FxLock:                  0,
  18398 	FxUnlock:                0,
  18399 	FxFileControl:           0,
  18400 	FxDeviceCharacteristics: 0,
  18401 	FxFetch:                 0,
  18402 	FxUnfetch:               0,
  18403 }
  18404 
  18405 func memdbEnter(tls *libc.TLS, p uintptr) {
  18406 	Xsqlite3_mutex_enter(tls, (*MemStore)(unsafe.Pointer(p)).FpMutex)
  18407 }
  18408 
  18409 func memdbLeave(tls *libc.TLS, p uintptr) {
  18410 	Xsqlite3_mutex_leave(tls, (*MemStore)(unsafe.Pointer(p)).FpMutex)
  18411 }
  18412 
  18413 func memdbClose(tls *libc.TLS, pFile uintptr) int32 {
  18414 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18415 	if (*MemStore)(unsafe.Pointer(p)).FzFName != 0 {
  18416 		var i int32
  18417 		var pVfsMutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1)
  18418 		Xsqlite3_mutex_enter(tls, pVfsMutex)
  18419 		for i = 0; i < memdb_g.FnMemStore; i++ {
  18420 			if *(*uintptr)(unsafe.Pointer(memdb_g.FapMemStore + uintptr(i)*4)) == p {
  18421 				memdbEnter(tls, p)
  18422 				if (*MemStore)(unsafe.Pointer(p)).FnRef == 1 {
  18423 					*(*uintptr)(unsafe.Pointer(memdb_g.FapMemStore + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer(memdb_g.FapMemStore + uintptr(libc.PreDecInt32(&memdb_g.FnMemStore, 1))*4))
  18424 					if memdb_g.FnMemStore == 0 {
  18425 						Xsqlite3_free(tls, memdb_g.FapMemStore)
  18426 						memdb_g.FapMemStore = uintptr(0)
  18427 					}
  18428 				}
  18429 				break
  18430 			}
  18431 		}
  18432 		Xsqlite3_mutex_leave(tls, pVfsMutex)
  18433 	} else {
  18434 		memdbEnter(tls, p)
  18435 	}
  18436 	(*MemStore)(unsafe.Pointer(p)).FnRef--
  18437 	if (*MemStore)(unsafe.Pointer(p)).FnRef <= 0 {
  18438 		if (*MemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_FREEONCLOSE) != 0 {
  18439 			Xsqlite3_free(tls, (*MemStore)(unsafe.Pointer(p)).FaData)
  18440 		}
  18441 		memdbLeave(tls, p)
  18442 		Xsqlite3_mutex_free(tls, (*MemStore)(unsafe.Pointer(p)).FpMutex)
  18443 		Xsqlite3_free(tls, p)
  18444 	} else {
  18445 		memdbLeave(tls, p)
  18446 	}
  18447 	return SQLITE_OK
  18448 }
  18449 
  18450 func memdbRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sqlite_int64) int32 {
  18451 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18452 	memdbEnter(tls, p)
  18453 	if iOfst+Sqlite_int64(iAmt) > (*MemStore)(unsafe.Pointer(p)).Fsz {
  18454 		libc.Xmemset(tls, zBuf, 0, uint32(iAmt))
  18455 		if iOfst < (*MemStore)(unsafe.Pointer(p)).Fsz {
  18456 			libc.Xmemcpy(tls, zBuf, (*MemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), uint32((*MemStore)(unsafe.Pointer(p)).Fsz-iOfst))
  18457 		}
  18458 		memdbLeave(tls, p)
  18459 		return SQLITE_IOERR | int32(2)<<8
  18460 	}
  18461 	libc.Xmemcpy(tls, zBuf, (*MemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), uint32(iAmt))
  18462 	memdbLeave(tls, p)
  18463 	return SQLITE_OK
  18464 }
  18465 
  18466 func memdbEnlarge(tls *libc.TLS, p uintptr, newSz Sqlite3_int64) int32 {
  18467 	var pNew uintptr
  18468 	if (*MemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_RESIZEABLE) == uint32(0) || (*MemStore)(unsafe.Pointer(p)).FnMmap > 0 {
  18469 		return SQLITE_FULL
  18470 	}
  18471 	if newSz > (*MemStore)(unsafe.Pointer(p)).FszMax {
  18472 		return SQLITE_FULL
  18473 	}
  18474 	newSz = newSz * int64(2)
  18475 	if newSz > (*MemStore)(unsafe.Pointer(p)).FszMax {
  18476 		newSz = (*MemStore)(unsafe.Pointer(p)).FszMax
  18477 	}
  18478 	pNew = Xsqlite3Realloc(tls, (*MemStore)(unsafe.Pointer(p)).FaData, uint64(newSz))
  18479 	if pNew == uintptr(0) {
  18480 		return SQLITE_IOERR | int32(12)<<8
  18481 	}
  18482 	(*MemStore)(unsafe.Pointer(p)).FaData = pNew
  18483 	(*MemStore)(unsafe.Pointer(p)).FszAlloc = newSz
  18484 	return SQLITE_OK
  18485 }
  18486 
  18487 func memdbWrite(tls *libc.TLS, pFile uintptr, z uintptr, iAmt int32, iOfst Sqlite_int64) int32 {
  18488 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18489 	memdbEnter(tls, p)
  18490 	if (*MemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_READONLY) != 0 {
  18491 		memdbLeave(tls, p)
  18492 		return SQLITE_IOERR | int32(3)<<8
  18493 	}
  18494 	if iOfst+Sqlite_int64(iAmt) > (*MemStore)(unsafe.Pointer(p)).Fsz {
  18495 		var rc int32
  18496 		if iOfst+Sqlite_int64(iAmt) > (*MemStore)(unsafe.Pointer(p)).FszAlloc &&
  18497 			libc.AssignInt32(&rc, memdbEnlarge(tls, p, iOfst+Sqlite_int64(iAmt))) != SQLITE_OK {
  18498 			memdbLeave(tls, p)
  18499 			return rc
  18500 		}
  18501 		if iOfst > (*MemStore)(unsafe.Pointer(p)).Fsz {
  18502 			libc.Xmemset(tls, (*MemStore)(unsafe.Pointer(p)).FaData+uintptr((*MemStore)(unsafe.Pointer(p)).Fsz), 0, uint32(iOfst-(*MemStore)(unsafe.Pointer(p)).Fsz))
  18503 		}
  18504 		(*MemStore)(unsafe.Pointer(p)).Fsz = iOfst + Sqlite_int64(iAmt)
  18505 	}
  18506 	libc.Xmemcpy(tls, (*MemStore)(unsafe.Pointer(p)).FaData+uintptr(iOfst), z, uint32(iAmt))
  18507 	memdbLeave(tls, p)
  18508 	return SQLITE_OK
  18509 }
  18510 
  18511 func memdbTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 {
  18512 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18513 	var rc int32 = SQLITE_OK
  18514 	memdbEnter(tls, p)
  18515 	if size > (*MemStore)(unsafe.Pointer(p)).Fsz {
  18516 		rc = SQLITE_CORRUPT
  18517 	} else {
  18518 		(*MemStore)(unsafe.Pointer(p)).Fsz = size
  18519 	}
  18520 	memdbLeave(tls, p)
  18521 	return rc
  18522 }
  18523 
  18524 func memdbSync(tls *libc.TLS, pFile uintptr, flags int32) int32 {
  18525 	_ = pFile
  18526 	_ = flags
  18527 	return SQLITE_OK
  18528 }
  18529 
  18530 func memdbFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 {
  18531 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18532 	memdbEnter(tls, p)
  18533 	*(*Sqlite_int64)(unsafe.Pointer(pSize)) = (*MemStore)(unsafe.Pointer(p)).Fsz
  18534 	memdbLeave(tls, p)
  18535 	return SQLITE_OK
  18536 }
  18537 
  18538 func memdbLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 {
  18539 	var pThis uintptr = pFile
  18540 	var p uintptr = (*MemFile)(unsafe.Pointer(pThis)).FpStore
  18541 	var rc int32 = SQLITE_OK
  18542 	if eLock <= (*MemFile)(unsafe.Pointer(pThis)).FeLock {
  18543 		return SQLITE_OK
  18544 	}
  18545 	memdbEnter(tls, p)
  18546 
  18547 	if eLock > SQLITE_LOCK_SHARED && (*MemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_READONLY) != 0 {
  18548 		rc = SQLITE_READONLY
  18549 	} else {
  18550 		switch eLock {
  18551 		case SQLITE_LOCK_SHARED:
  18552 			{
  18553 				if (*MemStore)(unsafe.Pointer(p)).FnWrLock > 0 {
  18554 					rc = SQLITE_BUSY
  18555 				} else {
  18556 					(*MemStore)(unsafe.Pointer(p)).FnRdLock++
  18557 				}
  18558 				break
  18559 
  18560 			}
  18561 
  18562 			fallthrough
  18563 
  18564 		case SQLITE_LOCK_RESERVED:
  18565 			fallthrough
  18566 		case SQLITE_LOCK_PENDING:
  18567 			{
  18568 				if (*MemFile)(unsafe.Pointer(pThis)).FeLock == SQLITE_LOCK_SHARED {
  18569 					if (*MemStore)(unsafe.Pointer(p)).FnWrLock > 0 {
  18570 						rc = SQLITE_BUSY
  18571 					} else {
  18572 						(*MemStore)(unsafe.Pointer(p)).FnWrLock = 1
  18573 					}
  18574 				}
  18575 				break
  18576 
  18577 			}
  18578 			fallthrough
  18579 
  18580 		default:
  18581 			{
  18582 				if (*MemStore)(unsafe.Pointer(p)).FnRdLock > 1 {
  18583 					rc = SQLITE_BUSY
  18584 				} else if (*MemFile)(unsafe.Pointer(pThis)).FeLock == SQLITE_LOCK_SHARED {
  18585 					(*MemStore)(unsafe.Pointer(p)).FnWrLock = 1
  18586 				}
  18587 				break
  18588 
  18589 			}
  18590 		}
  18591 	}
  18592 	if rc == SQLITE_OK {
  18593 		(*MemFile)(unsafe.Pointer(pThis)).FeLock = eLock
  18594 	}
  18595 	memdbLeave(tls, p)
  18596 	return rc
  18597 }
  18598 
  18599 func memdbUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 {
  18600 	var pThis uintptr = pFile
  18601 	var p uintptr = (*MemFile)(unsafe.Pointer(pThis)).FpStore
  18602 	if eLock >= (*MemFile)(unsafe.Pointer(pThis)).FeLock {
  18603 		return SQLITE_OK
  18604 	}
  18605 	memdbEnter(tls, p)
  18606 
  18607 	if eLock == SQLITE_LOCK_SHARED {
  18608 		if (*MemFile)(unsafe.Pointer(pThis)).FeLock > SQLITE_LOCK_SHARED {
  18609 			(*MemStore)(unsafe.Pointer(p)).FnWrLock--
  18610 		}
  18611 	} else {
  18612 		if (*MemFile)(unsafe.Pointer(pThis)).FeLock > SQLITE_LOCK_SHARED {
  18613 			(*MemStore)(unsafe.Pointer(p)).FnWrLock--
  18614 		}
  18615 		(*MemStore)(unsafe.Pointer(p)).FnRdLock--
  18616 	}
  18617 
  18618 	(*MemFile)(unsafe.Pointer(pThis)).FeLock = eLock
  18619 	memdbLeave(tls, p)
  18620 	return SQLITE_OK
  18621 }
  18622 
  18623 func memdbFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 {
  18624 	bp := tls.Alloc(16)
  18625 	defer tls.Free(16)
  18626 
  18627 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18628 	var rc int32 = SQLITE_NOTFOUND
  18629 	memdbEnter(tls, p)
  18630 	if op == SQLITE_FCNTL_VFSNAME {
  18631 		*(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3_mprintf(tls, ts+3841, libc.VaList(bp, (*MemStore)(unsafe.Pointer(p)).FaData, (*MemStore)(unsafe.Pointer(p)).Fsz))
  18632 		rc = SQLITE_OK
  18633 	}
  18634 	if op == SQLITE_FCNTL_SIZE_LIMIT {
  18635 		var iLimit Sqlite3_int64 = *(*Sqlite3_int64)(unsafe.Pointer(pArg))
  18636 		if iLimit < (*MemStore)(unsafe.Pointer(p)).Fsz {
  18637 			if iLimit < int64(0) {
  18638 				iLimit = (*MemStore)(unsafe.Pointer(p)).FszMax
  18639 			} else {
  18640 				iLimit = (*MemStore)(unsafe.Pointer(p)).Fsz
  18641 			}
  18642 		}
  18643 		(*MemStore)(unsafe.Pointer(p)).FszMax = iLimit
  18644 		*(*Sqlite3_int64)(unsafe.Pointer(pArg)) = iLimit
  18645 		rc = SQLITE_OK
  18646 	}
  18647 	memdbLeave(tls, p)
  18648 	return rc
  18649 }
  18650 
  18651 func memdbDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 {
  18652 	_ = pFile
  18653 	return SQLITE_IOCAP_ATOMIC | SQLITE_IOCAP_POWERSAFE_OVERWRITE | SQLITE_IOCAP_SAFE_APPEND | SQLITE_IOCAP_SEQUENTIAL
  18654 }
  18655 
  18656 func memdbFetch(tls *libc.TLS, pFile uintptr, iOfst Sqlite3_int64, iAmt int32, pp uintptr) int32 {
  18657 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18658 	memdbEnter(tls, p)
  18659 	if iOfst+Sqlite3_int64(iAmt) > (*MemStore)(unsafe.Pointer(p)).Fsz || (*MemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_RESIZEABLE) != uint32(0) {
  18660 		*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
  18661 	} else {
  18662 		(*MemStore)(unsafe.Pointer(p)).FnMmap++
  18663 		*(*uintptr)(unsafe.Pointer(pp)) = (*MemStore)(unsafe.Pointer(p)).FaData + uintptr(iOfst)
  18664 	}
  18665 	memdbLeave(tls, p)
  18666 	return SQLITE_OK
  18667 }
  18668 
  18669 func memdbUnfetch(tls *libc.TLS, pFile uintptr, iOfst Sqlite3_int64, pPage uintptr) int32 {
  18670 	var p uintptr = (*MemFile)(unsafe.Pointer(pFile)).FpStore
  18671 	_ = iOfst
  18672 	_ = pPage
  18673 	memdbEnter(tls, p)
  18674 	(*MemStore)(unsafe.Pointer(p)).FnMmap--
  18675 	memdbLeave(tls, p)
  18676 	return SQLITE_OK
  18677 }
  18678 
  18679 func memdbOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFd uintptr, flags int32, pOutFlags uintptr) int32 {
  18680 	var pFile uintptr = pFd
  18681 	var p uintptr = uintptr(0)
  18682 	var szName int32
  18683 	_ = pVfs
  18684 
  18685 	libc.Xmemset(tls, pFile, 0, uint32(unsafe.Sizeof(MemFile{})))
  18686 	szName = Xsqlite3Strlen30(tls, zName)
  18687 	if szName > 1 && (int32(*(*uint8)(unsafe.Pointer(zName))) == '/' || int32(*(*uint8)(unsafe.Pointer(zName))) == '\\') {
  18688 		var i int32
  18689 		var pVfsMutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1)
  18690 		Xsqlite3_mutex_enter(tls, pVfsMutex)
  18691 		for i = 0; i < memdb_g.FnMemStore; i++ {
  18692 			if libc.Xstrcmp(tls, (*MemStore)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(memdb_g.FapMemStore + uintptr(i)*4)))).FzFName, zName) == 0 {
  18693 				p = *(*uintptr)(unsafe.Pointer(memdb_g.FapMemStore + uintptr(i)*4))
  18694 				break
  18695 			}
  18696 		}
  18697 		if p == uintptr(0) {
  18698 			var apNew uintptr
  18699 			p = Xsqlite3Malloc(tls, uint64(uint32(unsafe.Sizeof(MemStore{}))+uint32(szName)+uint32(3)))
  18700 			if p == uintptr(0) {
  18701 				Xsqlite3_mutex_leave(tls, pVfsMutex)
  18702 				return SQLITE_NOMEM
  18703 			}
  18704 			apNew = Xsqlite3Realloc(tls, memdb_g.FapMemStore,
  18705 				uint64(uint32(unsafe.Sizeof(uintptr(0)))*uint32(memdb_g.FnMemStore+1)))
  18706 			if apNew == uintptr(0) {
  18707 				Xsqlite3_free(tls, p)
  18708 				Xsqlite3_mutex_leave(tls, pVfsMutex)
  18709 				return SQLITE_NOMEM
  18710 			}
  18711 			*(*uintptr)(unsafe.Pointer(apNew + uintptr(libc.PostIncInt32(&memdb_g.FnMemStore, 1))*4)) = p
  18712 			memdb_g.FapMemStore = apNew
  18713 			libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(MemStore{})))
  18714 			(*MemStore)(unsafe.Pointer(p)).FmFlags = uint32(SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE)
  18715 			(*MemStore)(unsafe.Pointer(p)).FszMax = Xsqlite3Config.FmxMemdbSize
  18716 			(*MemStore)(unsafe.Pointer(p)).FzFName = p + 1*56
  18717 			libc.Xmemcpy(tls, (*MemStore)(unsafe.Pointer(p)).FzFName, zName, uint32(szName+1))
  18718 			(*MemStore)(unsafe.Pointer(p)).FpMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST)
  18719 			if (*MemStore)(unsafe.Pointer(p)).FpMutex == uintptr(0) {
  18720 				memdb_g.FnMemStore--
  18721 				Xsqlite3_free(tls, p)
  18722 				Xsqlite3_mutex_leave(tls, pVfsMutex)
  18723 				return SQLITE_NOMEM
  18724 			}
  18725 			(*MemStore)(unsafe.Pointer(p)).FnRef = 1
  18726 			memdbEnter(tls, p)
  18727 		} else {
  18728 			memdbEnter(tls, p)
  18729 			(*MemStore)(unsafe.Pointer(p)).FnRef++
  18730 		}
  18731 		Xsqlite3_mutex_leave(tls, pVfsMutex)
  18732 	} else {
  18733 		p = Xsqlite3Malloc(tls, uint64(unsafe.Sizeof(MemStore{})))
  18734 		if p == uintptr(0) {
  18735 			return SQLITE_NOMEM
  18736 		}
  18737 		libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(MemStore{})))
  18738 		(*MemStore)(unsafe.Pointer(p)).FmFlags = uint32(SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE)
  18739 		(*MemStore)(unsafe.Pointer(p)).FszMax = Xsqlite3Config.FmxMemdbSize
  18740 	}
  18741 	(*MemFile)(unsafe.Pointer(pFile)).FpStore = p
  18742 	if pOutFlags != uintptr(0) {
  18743 		*(*int32)(unsafe.Pointer(pOutFlags)) = flags | SQLITE_OPEN_MEMORY
  18744 	}
  18745 	(*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods = uintptr(unsafe.Pointer(&memdb_io_methods))
  18746 	memdbLeave(tls, p)
  18747 	return SQLITE_OK
  18748 }
  18749 
  18750 func memdbAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 {
  18751 	_ = pVfs
  18752 	_ = zPath
  18753 	_ = flags
  18754 	*(*int32)(unsafe.Pointer(pResOut)) = 0
  18755 	return SQLITE_OK
  18756 }
  18757 
  18758 func memdbFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 {
  18759 	bp := tls.Alloc(8)
  18760 	defer tls.Free(8)
  18761 
  18762 	_ = pVfs
  18763 	Xsqlite3_snprintf(tls, nOut, zOut, ts+3663, libc.VaList(bp, zPath))
  18764 	return SQLITE_OK
  18765 }
  18766 
  18767 func memdbDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr {
  18768 	return (*struct {
  18769 		f func(*libc.TLS, uintptr, uintptr) uintptr
  18770 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlOpen})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath)
  18771 }
  18772 
  18773 func memdbDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) {
  18774 	(*struct {
  18775 		f func(*libc.TLS, uintptr, int32, uintptr)
  18776 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlError})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zErrMsg)
  18777 }
  18778 
  18779 func memdbDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) uintptr {
  18780 	return (*struct {
  18781 		f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr
  18782 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlSym})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p, zSym)
  18783 }
  18784 
  18785 func memdbDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) {
  18786 	(*struct {
  18787 		f func(*libc.TLS, uintptr, uintptr)
  18788 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlClose})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pHandle)
  18789 }
  18790 
  18791 func memdbRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 {
  18792 	return (*struct {
  18793 		f func(*libc.TLS, uintptr, int32, uintptr) int32
  18794 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxRandomness})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zBufOut)
  18795 }
  18796 
  18797 func memdbSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 {
  18798 	return (*struct {
  18799 		f func(*libc.TLS, uintptr, int32) int32
  18800 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxSleep})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nMicro)
  18801 }
  18802 
  18803 func memdbGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) int32 {
  18804 	return (*struct {
  18805 		f func(*libc.TLS, uintptr, int32, uintptr) int32
  18806 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxGetLastError})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, a, b)
  18807 }
  18808 
  18809 func memdbCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, p uintptr) int32 {
  18810 	return (*struct {
  18811 		f func(*libc.TLS, uintptr, uintptr) int32
  18812 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxCurrentTimeInt64})).f(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p)
  18813 }
  18814 
  18815 func memdbFromDbSchema(tls *libc.TLS, db uintptr, zSchema uintptr) uintptr {
  18816 	bp := tls.Alloc(4)
  18817 	defer tls.Free(4)
  18818 
  18819 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  18820 	var pStore uintptr
  18821 	var rc int32 = Xsqlite3_file_control(tls, db, zSchema, SQLITE_FCNTL_FILE_POINTER, bp)
  18822 	if rc != 0 {
  18823 		return uintptr(0)
  18824 	}
  18825 	if (*MemFile)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fbase.FpMethods != uintptr(unsafe.Pointer(&memdb_io_methods)) {
  18826 		return uintptr(0)
  18827 	}
  18828 	pStore = (*MemFile)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpStore
  18829 	memdbEnter(tls, pStore)
  18830 	if (*MemStore)(unsafe.Pointer(pStore)).FzFName != uintptr(0) {
  18831 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  18832 	}
  18833 	memdbLeave(tls, pStore)
  18834 	return *(*uintptr)(unsafe.Pointer(bp))
  18835 }
  18836 
  18837 // Return the serialization of a database
  18838 func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintptr, mFlags uint32) uintptr {
  18839 	bp := tls.Alloc(16)
  18840 	defer tls.Free(16)
  18841 
  18842 	var p uintptr
  18843 	var iDb int32
  18844 	var pBt uintptr
  18845 	var sz Sqlite3_int64
  18846 	var szPage int32 = 0
  18847 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  18848 	var pOut uintptr
  18849 	var zSql uintptr
  18850 	var rc int32
  18851 
  18852 	if zSchema == uintptr(0) {
  18853 		zSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName
  18854 	}
  18855 	p = memdbFromDbSchema(tls, db, zSchema)
  18856 	iDb = Xsqlite3FindDbName(tls, db, zSchema)
  18857 	if piSize != 0 {
  18858 		*(*Sqlite3_int64)(unsafe.Pointer(piSize)) = int64(-1)
  18859 	}
  18860 	if iDb < 0 {
  18861 		return uintptr(0)
  18862 	}
  18863 	if p != 0 {
  18864 		var pStore uintptr = (*MemFile)(unsafe.Pointer(p)).FpStore
  18865 
  18866 		if piSize != 0 {
  18867 			*(*Sqlite3_int64)(unsafe.Pointer(piSize)) = (*MemStore)(unsafe.Pointer(pStore)).Fsz
  18868 		}
  18869 		if mFlags&uint32(SQLITE_SERIALIZE_NOCOPY) != 0 {
  18870 			pOut = (*MemStore)(unsafe.Pointer(pStore)).FaData
  18871 		} else {
  18872 			pOut = Xsqlite3_malloc64(tls, uint64((*MemStore)(unsafe.Pointer(pStore)).Fsz))
  18873 			if pOut != 0 {
  18874 				libc.Xmemcpy(tls, pOut, (*MemStore)(unsafe.Pointer(pStore)).FaData, uint32((*MemStore)(unsafe.Pointer(pStore)).Fsz))
  18875 			}
  18876 		}
  18877 		return pOut
  18878 	}
  18879 	pBt = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
  18880 	if pBt == uintptr(0) {
  18881 		return uintptr(0)
  18882 	}
  18883 	szPage = Xsqlite3BtreeGetPageSize(tls, pBt)
  18884 	zSql = Xsqlite3_mprintf(tls, ts+3856, libc.VaList(bp, zSchema))
  18885 	if zSql != 0 {
  18886 		rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8, uintptr(0))
  18887 	} else {
  18888 		rc = SQLITE_NOMEM
  18889 	}
  18890 	Xsqlite3_free(tls, zSql)
  18891 	if rc != 0 {
  18892 		return uintptr(0)
  18893 	}
  18894 	rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  18895 	if rc != SQLITE_ROW {
  18896 		pOut = uintptr(0)
  18897 	} else {
  18898 		sz = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 0) * Sqlite_int64(szPage)
  18899 		if piSize != 0 {
  18900 			*(*Sqlite3_int64)(unsafe.Pointer(piSize)) = sz
  18901 		}
  18902 		if mFlags&uint32(SQLITE_SERIALIZE_NOCOPY) != 0 {
  18903 			pOut = uintptr(0)
  18904 		} else {
  18905 			pOut = Xsqlite3_malloc64(tls, uint64(sz))
  18906 			if pOut != 0 {
  18907 				var nPage int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 0)
  18908 				var pPager uintptr = Xsqlite3BtreePager(tls, pBt)
  18909 				var pgno int32
  18910 				for pgno = 1; pgno <= nPage; pgno++ {
  18911 					*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
  18912 					var pTo uintptr = pOut + uintptr(Sqlite3_int64(szPage)*Sqlite3_int64(pgno-1))
  18913 					rc = Xsqlite3PagerGet(tls, pPager, uint32(pgno), bp+12, 0)
  18914 					if rc == SQLITE_OK {
  18915 						libc.Xmemcpy(tls, pTo, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 12))), uint32(szPage))
  18916 					} else {
  18917 						libc.Xmemset(tls, pTo, 0, uint32(szPage))
  18918 					}
  18919 					Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  18920 				}
  18921 			}
  18922 		}
  18923 	}
  18924 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  18925 	return pOut
  18926 }
  18927 
  18928 // Convert zSchema to a MemDB and initialize its content.
  18929 func Xsqlite3_deserialize(tls *libc.TLS, db uintptr, zSchema uintptr, pData uintptr, szDb Sqlite3_int64, szBuf Sqlite3_int64, mFlags uint32) int32 {
  18930 	bp := tls.Alloc(12)
  18931 	defer tls.Free(12)
  18932 
  18933 	var p uintptr
  18934 	var zSql uintptr
  18935 
  18936 	var rc int32
  18937 	var iDb int32
  18938 	var pStore uintptr
  18939 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  18940 
  18941 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  18942 	if !(zSchema == uintptr(0)) {
  18943 		goto __1
  18944 	}
  18945 	zSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName
  18946 __1:
  18947 	;
  18948 	iDb = Xsqlite3FindDbName(tls, db, zSchema)
  18949 
  18950 	if !(iDb < 2 && iDb != 0) {
  18951 		goto __2
  18952 	}
  18953 	rc = SQLITE_ERROR
  18954 	goto end_deserialize
  18955 __2:
  18956 	;
  18957 	zSql = Xsqlite3_mprintf(tls, ts+3879, libc.VaList(bp, zSchema))
  18958 	if !(zSql == uintptr(0)) {
  18959 		goto __3
  18960 	}
  18961 	rc = SQLITE_NOMEM
  18962 	goto __4
  18963 __3:
  18964 	rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8, uintptr(0))
  18965 	Xsqlite3_free(tls, zSql)
  18966 __4:
  18967 	;
  18968 	if !(rc != 0) {
  18969 		goto __5
  18970 	}
  18971 	goto end_deserialize
  18972 __5:
  18973 	;
  18974 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(iDb)
  18975 	libc.SetBitFieldPtr8Uint32(db+172+8, uint32(1), 2, 0x4)
  18976 	rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  18977 	libc.SetBitFieldPtr8Uint32(db+172+8, uint32(0), 2, 0x4)
  18978 	if !(rc != SQLITE_DONE) {
  18979 		goto __6
  18980 	}
  18981 	rc = SQLITE_ERROR
  18982 	goto end_deserialize
  18983 __6:
  18984 	;
  18985 	p = memdbFromDbSchema(tls, db, zSchema)
  18986 	if !(p == uintptr(0)) {
  18987 		goto __7
  18988 	}
  18989 	rc = SQLITE_ERROR
  18990 	goto __8
  18991 __7:
  18992 	pStore = (*MemFile)(unsafe.Pointer(p)).FpStore
  18993 	(*MemStore)(unsafe.Pointer(pStore)).FaData = pData
  18994 	pData = uintptr(0)
  18995 	(*MemStore)(unsafe.Pointer(pStore)).Fsz = szDb
  18996 	(*MemStore)(unsafe.Pointer(pStore)).FszAlloc = szBuf
  18997 	(*MemStore)(unsafe.Pointer(pStore)).FszMax = szBuf
  18998 	if !((*MemStore)(unsafe.Pointer(pStore)).FszMax < Xsqlite3Config.FmxMemdbSize) {
  18999 		goto __9
  19000 	}
  19001 	(*MemStore)(unsafe.Pointer(pStore)).FszMax = Xsqlite3Config.FmxMemdbSize
  19002 __9:
  19003 	;
  19004 	(*MemStore)(unsafe.Pointer(pStore)).FmFlags = mFlags
  19005 	rc = SQLITE_OK
  19006 __8:
  19007 	;
  19008 end_deserialize:
  19009 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  19010 	if !(pData != 0 && mFlags&uint32(SQLITE_DESERIALIZE_FREEONCLOSE) != uint32(0)) {
  19011 		goto __10
  19012 	}
  19013 	Xsqlite3_free(tls, pData)
  19014 __10:
  19015 	;
  19016 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  19017 	return rc
  19018 }
  19019 
  19020 // Return true if the VFS is the memvfs.
  19021 func Xsqlite3IsMemdb(tls *libc.TLS, pVfs uintptr) int32 {
  19022 	return libc.Bool32(pVfs == uintptr(unsafe.Pointer(&memdb_vfs)))
  19023 }
  19024 
  19025 // This routine is called when the extension is loaded.
  19026 // Register the new VFS.
  19027 func Xsqlite3MemdbInit(tls *libc.TLS) int32 {
  19028 	var pLower uintptr = Xsqlite3_vfs_find(tls, uintptr(0))
  19029 	var sz uint32
  19030 	if pLower == uintptr(0) {
  19031 		return SQLITE_ERROR
  19032 	}
  19033 	sz = uint32((*Sqlite3_vfs)(unsafe.Pointer(pLower)).FszOsFile)
  19034 	memdb_vfs.FpAppData = pLower
  19035 
  19036 	if sz < uint32(unsafe.Sizeof(MemFile{})) {
  19037 		sz = uint32(unsafe.Sizeof(MemFile{}))
  19038 	}
  19039 	memdb_vfs.FszOsFile = int32(sz)
  19040 	return Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&memdb_vfs)), 0)
  19041 }
  19042 
  19043 // Create a new bitmap object able to handle bits between 0 and iSize,
  19044 // inclusive.  Return a pointer to the new object.  Return NULL if
  19045 // malloc fails.
  19046 func Xsqlite3BitvecCreate(tls *libc.TLS, iSize U32) uintptr {
  19047 	var p uintptr
  19048 
  19049 	p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Bitvec{})))
  19050 	if p != 0 {
  19051 		(*Bitvec)(unsafe.Pointer(p)).FiSize = iSize
  19052 	}
  19053 	return p
  19054 }
  19055 
  19056 // Check to see if the i-th bit is set.  Return true or false.
  19057 // If p is NULL (if the bitmap has not been created) or if
  19058 // i is out of range, then return false.
  19059 func Xsqlite3BitvecTestNotNull(tls *libc.TLS, p uintptr, i U32) int32 {
  19060 	i--
  19061 	if i >= (*Bitvec)(unsafe.Pointer(p)).FiSize {
  19062 		return 0
  19063 	}
  19064 	for (*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0 {
  19065 		var bin U32 = i / (*Bitvec)(unsafe.Pointer(p)).FiDivisor
  19066 		i = i % (*Bitvec)(unsafe.Pointer(p)).FiDivisor
  19067 		p = *(*uintptr)(unsafe.Pointer(p + 12 + uintptr(bin)*4))
  19068 		if !(p != 0) {
  19069 			return 0
  19070 		}
  19071 	}
  19072 	if (*Bitvec)(unsafe.Pointer(p)).FiSize <= (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U8(0)))*uint32(BITVEC_SZELEM) {
  19073 		return libc.Bool32(int32(*(*U8)(unsafe.Pointer(p + 12 + uintptr(i/U32(BITVEC_SZELEM)))))&(int32(1)<<(i&U32(BITVEC_SZELEM-1))) != 0)
  19074 	} else {
  19075 		var h U32 = libc.PostIncUint32(&i, 1) * U32(1) % ((uint32(BITVEC_SZ) - uint32(3)*uint32(unsafe.Sizeof(U32(0)))) / uint32(unsafe.Sizeof(uintptr(0))) * uint32(unsafe.Sizeof(uintptr(0))) / uint32(unsafe.Sizeof(U32(0))))
  19076 		for *(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) != 0 {
  19077 			if *(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) == i {
  19078 				return 1
  19079 			}
  19080 			h = (h + U32(1)) % ((uint32(BITVEC_SZ) - uint32(3)*uint32(unsafe.Sizeof(U32(0)))) / uint32(unsafe.Sizeof(uintptr(0))) * uint32(unsafe.Sizeof(uintptr(0))) / uint32(unsafe.Sizeof(U32(0))))
  19081 		}
  19082 		return 0
  19083 	}
  19084 	return int32(0)
  19085 }
  19086 
  19087 func Xsqlite3BitvecTest(tls *libc.TLS, p uintptr, i U32) int32 {
  19088 	return libc.Bool32(p != uintptr(0) && Xsqlite3BitvecTestNotNull(tls, p, i) != 0)
  19089 }
  19090 
  19091 // Set the i-th bit.  Return 0 on success and an error code if
  19092 // anything goes wrong.
  19093 //
  19094 // This routine might cause sub-bitmaps to be allocated.  Failing
  19095 // to get the memory needed to hold the sub-bitmap is the only
  19096 // that can go wrong with an insert, assuming p and i are valid.
  19097 //
  19098 // The calling function must ensure that p is a valid Bitvec object
  19099 // and that the value for "i" is within range of the Bitvec object.
  19100 // Otherwise the behavior is undefined.
  19101 func Xsqlite3BitvecSet(tls *libc.TLS, p uintptr, i U32) int32 {
  19102 	var h U32
  19103 	var bin U32
  19104 	var j uint32
  19105 	var rc int32
  19106 	var aiValues uintptr
  19107 	if !(p == uintptr(0)) {
  19108 		goto __1
  19109 	}
  19110 	return SQLITE_OK
  19111 __1:
  19112 	;
  19113 	i--
  19114 __2:
  19115 	if !((*Bitvec)(unsafe.Pointer(p)).FiSize > (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U8(0)))*uint32(BITVEC_SZELEM) && (*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0) {
  19116 		goto __3
  19117 	}
  19118 	bin = i / (*Bitvec)(unsafe.Pointer(p)).FiDivisor
  19119 	i = i % (*Bitvec)(unsafe.Pointer(p)).FiDivisor
  19120 	if !(*(*uintptr)(unsafe.Pointer(p + 12 + uintptr(bin)*4)) == uintptr(0)) {
  19121 		goto __4
  19122 	}
  19123 	*(*uintptr)(unsafe.Pointer(p + 12 + uintptr(bin)*4)) = Xsqlite3BitvecCreate(tls, (*Bitvec)(unsafe.Pointer(p)).FiDivisor)
  19124 	if !(*(*uintptr)(unsafe.Pointer(p + 12 + uintptr(bin)*4)) == uintptr(0)) {
  19125 		goto __5
  19126 	}
  19127 	return SQLITE_NOMEM
  19128 __5:
  19129 	;
  19130 __4:
  19131 	;
  19132 	p = *(*uintptr)(unsafe.Pointer(p + 12 + uintptr(bin)*4))
  19133 	goto __2
  19134 __3:
  19135 	;
  19136 	if !((*Bitvec)(unsafe.Pointer(p)).FiSize <= (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U8(0)))*uint32(BITVEC_SZELEM)) {
  19137 		goto __6
  19138 	}
  19139 	*(*U8)(unsafe.Pointer(p + 12 + uintptr(i/U32(BITVEC_SZELEM)))) |= U8(int32(1) << (i & U32(BITVEC_SZELEM-1)))
  19140 	return SQLITE_OK
  19141 __6:
  19142 	;
  19143 	h = libc.PostIncUint32(&i, 1) * U32(1) % ((uint32(BITVEC_SZ) - uint32(3)*uint32(unsafe.Sizeof(U32(0)))) / uint32(unsafe.Sizeof(uintptr(0))) * uint32(unsafe.Sizeof(uintptr(0))) / uint32(unsafe.Sizeof(U32(0))))
  19144 
  19145 	if !!(int32(*(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4))) != 0) {
  19146 		goto __7
  19147 	}
  19148 	if !((*Bitvec)(unsafe.Pointer(p)).FnSet < (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U32(0)))-uint32(1)) {
  19149 		goto __8
  19150 	}
  19151 	goto bitvec_set_end
  19152 	goto __9
  19153 __8:
  19154 	goto bitvec_set_rehash
  19155 __9:
  19156 	;
  19157 __7:
  19158 	;
  19159 __10:
  19160 	if !(*(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) == i) {
  19161 		goto __13
  19162 	}
  19163 	return SQLITE_OK
  19164 __13:
  19165 	;
  19166 	h++
  19167 	if !(h >= (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U32(0)))) {
  19168 		goto __14
  19169 	}
  19170 	h = U32(0)
  19171 __14:
  19172 	;
  19173 	goto __11
  19174 __11:
  19175 	if *(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) != 0 {
  19176 		goto __10
  19177 	}
  19178 	goto __12
  19179 __12:
  19180 	;
  19181 bitvec_set_rehash:
  19182 	if !((*Bitvec)(unsafe.Pointer(p)).FnSet >= (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U32(0)))/uint32(2)) {
  19183 		goto __15
  19184 	}
  19185 	aiValues = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(unsafe.Sizeof([125]U32{})))
  19186 	if !(aiValues == uintptr(0)) {
  19187 		goto __16
  19188 	}
  19189 	return SQLITE_NOMEM
  19190 	goto __17
  19191 __16:
  19192 	libc.Xmemcpy(tls, aiValues, p+12, uint32(unsafe.Sizeof([125]U32{})))
  19193 	libc.Xmemset(tls, p+12, 0, uint32(unsafe.Sizeof([125]uintptr{})))
  19194 	(*Bitvec)(unsafe.Pointer(p)).FiDivisor = ((*Bitvec)(unsafe.Pointer(p)).FiSize + (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(uintptr(0))) - U32(1)) / ((uint32(BITVEC_SZ) - uint32(3)*uint32(unsafe.Sizeof(U32(0)))) / uint32(unsafe.Sizeof(uintptr(0))) * uint32(unsafe.Sizeof(uintptr(0))) / uint32(unsafe.Sizeof(uintptr(0))))
  19195 	rc = Xsqlite3BitvecSet(tls, p, i)
  19196 	j = uint32(0)
  19197 __18:
  19198 	if !(j < (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U32(0)))) {
  19199 		goto __20
  19200 	}
  19201 	if !(*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != 0) {
  19202 		goto __21
  19203 	}
  19204 	rc = rc | Xsqlite3BitvecSet(tls, p, *(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)))
  19205 __21:
  19206 	;
  19207 	goto __19
  19208 __19:
  19209 	j++
  19210 	goto __18
  19211 	goto __20
  19212 __20:
  19213 	;
  19214 	Xsqlite3DbFree(tls, uintptr(0), aiValues)
  19215 	return rc
  19216 __17:
  19217 	;
  19218 __15:
  19219 	;
  19220 bitvec_set_end:
  19221 	(*Bitvec)(unsafe.Pointer(p)).FnSet++
  19222 	*(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) = i
  19223 	return SQLITE_OK
  19224 }
  19225 
  19226 // Clear the i-th bit.
  19227 //
  19228 // pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage
  19229 // that BitvecClear can use to rebuilt its hash table.
  19230 func Xsqlite3BitvecClear(tls *libc.TLS, p uintptr, i U32, pBuf uintptr) {
  19231 	if p == uintptr(0) {
  19232 		return
  19233 	}
  19234 
  19235 	i--
  19236 	for (*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0 {
  19237 		var bin U32 = i / (*Bitvec)(unsafe.Pointer(p)).FiDivisor
  19238 		i = i % (*Bitvec)(unsafe.Pointer(p)).FiDivisor
  19239 		p = *(*uintptr)(unsafe.Pointer(p + 12 + uintptr(bin)*4))
  19240 		if !(p != 0) {
  19241 			return
  19242 		}
  19243 	}
  19244 	if (*Bitvec)(unsafe.Pointer(p)).FiSize <= (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U8(0)))*uint32(BITVEC_SZELEM) {
  19245 		*(*U8)(unsafe.Pointer(p + 12 + uintptr(i/U32(BITVEC_SZELEM)))) &= U8(^(int32(1) << (i & U32(BITVEC_SZELEM-1))))
  19246 	} else {
  19247 		var j uint32
  19248 		var aiValues uintptr = pBuf
  19249 		libc.Xmemcpy(tls, aiValues, p+12, uint32(unsafe.Sizeof([125]U32{})))
  19250 		libc.Xmemset(tls, p+12, 0, uint32(unsafe.Sizeof([125]U32{})))
  19251 		(*Bitvec)(unsafe.Pointer(p)).FnSet = U32(0)
  19252 		for j = uint32(0); j < (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U32(0))); j++ {
  19253 			if *(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != 0 && *(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != i+U32(1) {
  19254 				var h U32 = (*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) - U32(1)) * U32(1) % ((uint32(BITVEC_SZ) - uint32(3)*uint32(unsafe.Sizeof(U32(0)))) / uint32(unsafe.Sizeof(uintptr(0))) * uint32(unsafe.Sizeof(uintptr(0))) / uint32(unsafe.Sizeof(U32(0))))
  19255 				(*Bitvec)(unsafe.Pointer(p)).FnSet++
  19256 				for *(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) != 0 {
  19257 					h++
  19258 					if h >= (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(U32(0))) {
  19259 						h = U32(0)
  19260 					}
  19261 				}
  19262 				*(*U32)(unsafe.Pointer(p + 12 + uintptr(h)*4)) = *(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4))
  19263 			}
  19264 		}
  19265 	}
  19266 }
  19267 
  19268 // Destroy a bitmap object.  Reclaim all memory used.
  19269 func Xsqlite3BitvecDestroy(tls *libc.TLS, p uintptr) {
  19270 	if p == uintptr(0) {
  19271 		return
  19272 	}
  19273 	if (*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0 {
  19274 		var i uint32
  19275 		for i = uint32(0); i < (uint32(BITVEC_SZ)-uint32(3)*uint32(unsafe.Sizeof(U32(0))))/uint32(unsafe.Sizeof(uintptr(0)))*uint32(unsafe.Sizeof(uintptr(0)))/uint32(unsafe.Sizeof(uintptr(0))); i++ {
  19276 			Xsqlite3BitvecDestroy(tls, *(*uintptr)(unsafe.Pointer(p + 12 + uintptr(i)*4)))
  19277 		}
  19278 	}
  19279 	Xsqlite3_free(tls, p)
  19280 }
  19281 
  19282 // Return the value of the iSize parameter specified when Bitvec *p
  19283 // was created.
  19284 func Xsqlite3BitvecSize(tls *libc.TLS, p uintptr) U32 {
  19285 	return (*Bitvec)(unsafe.Pointer(p)).FiSize
  19286 }
  19287 
  19288 // This routine runs an extensive test of the Bitvec code.
  19289 //
  19290 // The input is an array of integers that acts as a program
  19291 // to test the Bitvec.  The integers are opcodes followed
  19292 // by 0, 1, or 3 operands, depending on the opcode.  Another
  19293 // opcode follows immediately after the last operand.
  19294 //
  19295 // There are 6 opcodes numbered from 0 through 5.  0 is the
  19296 // "halt" opcode and causes the test to end.
  19297 //
  19298 //	0          Halt and return the number of errors
  19299 //	1 N S X    Set N bits beginning with S and incrementing by X
  19300 //	2 N S X    Clear N bits beginning with S and incrementing by X
  19301 //	3 N        Set N randomly chosen bits
  19302 //	4 N        Clear N randomly chosen bits
  19303 //	5 N S X    Set N bits from S increment X in array only, not in bitvec
  19304 //
  19305 // The opcodes 1 through 4 perform set and clear operations are performed
  19306 // on both a Bitvec object and on a linear array of bits obtained from malloc.
  19307 // Opcode 5 works on the linear array only, not on the Bitvec.
  19308 // Opcode 5 is used to deliberately induce a fault in order to
  19309 // confirm that error detection works.
  19310 //
  19311 // At the conclusion of the test the linear array is compared
  19312 // against the Bitvec object.  If there are any differences,
  19313 // an error is returned.  If they are the same, zero is returned.
  19314 //
  19315 // If a memory allocation error occurs, return -1.
  19316 func Xsqlite3BitvecBuiltinTest(tls *libc.TLS, sz int32, aOp uintptr) int32 {
  19317 	bp := tls.Alloc(4)
  19318 	defer tls.Free(4)
  19319 
  19320 	var pBitvec uintptr
  19321 	var pV uintptr
  19322 	var rc int32
  19323 
  19324 	var nx int32
  19325 	var pc int32
  19326 	var op int32
  19327 	var pTmpSpace uintptr
  19328 	pBitvec = uintptr(0)
  19329 	pV = uintptr(0)
  19330 	rc = -1
  19331 
  19332 	pBitvec = Xsqlite3BitvecCreate(tls, uint32(sz))
  19333 	pV = Xsqlite3MallocZero(tls, uint64((sz+7)/8+1))
  19334 	pTmpSpace = Xsqlite3_malloc64(tls, uint64(BITVEC_SZ))
  19335 	if !(pBitvec == uintptr(0) || pV == uintptr(0) || pTmpSpace == uintptr(0)) {
  19336 		goto __1
  19337 	}
  19338 	goto bitvec_end
  19339 __1:
  19340 	;
  19341 	Xsqlite3BitvecSet(tls, uintptr(0), uint32(1))
  19342 	Xsqlite3BitvecClear(tls, uintptr(0), uint32(1), pTmpSpace)
  19343 
  19344 	pc = libc.AssignPtrInt32(bp, 0)
  19345 __2:
  19346 	if !(libc.AssignInt32(&op, *(*int32)(unsafe.Pointer(aOp + uintptr(pc)*4))) != 0) {
  19347 		goto __3
  19348 	}
  19349 	switch op {
  19350 	case 1:
  19351 		goto __5
  19352 	case 2:
  19353 		goto __6
  19354 	case 5:
  19355 		goto __7
  19356 	case 3:
  19357 		goto __8
  19358 	case 4:
  19359 		goto __9
  19360 	default:
  19361 		goto __10
  19362 	}
  19363 	goto __4
  19364 __5:
  19365 __6:
  19366 __7:
  19367 	nx = 4
  19368 	*(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(aOp + uintptr(pc+2)*4)) - 1
  19369 	*(*int32)(unsafe.Pointer(aOp + uintptr(pc+2)*4)) += *(*int32)(unsafe.Pointer(aOp + uintptr(pc+3)*4))
  19370 	goto __4
  19371 
  19372 __8:
  19373 __9:
  19374 __10:
  19375 	nx = 2
  19376 	Xsqlite3_randomness(tls, int32(unsafe.Sizeof(int32(0))), bp)
  19377 	goto __4
  19378 
  19379 __4:
  19380 	;
  19381 	if !(libc.PreDecInt32(&*(*int32)(unsafe.Pointer(aOp + uintptr(pc+1)*4)), 1) > 0) {
  19382 		goto __11
  19383 	}
  19384 	nx = 0
  19385 __11:
  19386 	;
  19387 	pc = pc + nx
  19388 	*(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(bp)) & 0x7fffffff % sz
  19389 	if !(op&1 != 0) {
  19390 		goto __12
  19391 	}
  19392 	*(*uint8)(unsafe.Pointer(pV + uintptr((*(*int32)(unsafe.Pointer(bp))+1)>>3))) |= uint8(int32(1) << ((*(*int32)(unsafe.Pointer(bp)) + 1) & 7))
  19393 	if !(op != 5) {
  19394 		goto __14
  19395 	}
  19396 	if !(Xsqlite3BitvecSet(tls, pBitvec, uint32(*(*int32)(unsafe.Pointer(bp))+1)) != 0) {
  19397 		goto __15
  19398 	}
  19399 	goto bitvec_end
  19400 __15:
  19401 	;
  19402 __14:
  19403 	;
  19404 	goto __13
  19405 __12:
  19406 	*(*uint8)(unsafe.Pointer(pV + uintptr((*(*int32)(unsafe.Pointer(bp))+1)>>3))) &= uint8(^(int32(1) << ((*(*int32)(unsafe.Pointer(bp)) + 1) & 7)))
  19407 	Xsqlite3BitvecClear(tls, pBitvec, uint32(*(*int32)(unsafe.Pointer(bp))+1), pTmpSpace)
  19408 __13:
  19409 	;
  19410 	goto __2
  19411 __3:
  19412 	;
  19413 	rc = int32(U32(Xsqlite3BitvecTest(tls, uintptr(0), uint32(0))+Xsqlite3BitvecTest(tls, pBitvec, uint32(sz+1))+
  19414 		Xsqlite3BitvecTest(tls, pBitvec, uint32(0))) +
  19415 		(Xsqlite3BitvecSize(tls, pBitvec) - U32(sz)))
  19416 	*(*int32)(unsafe.Pointer(bp)) = 1
  19417 __16:
  19418 	if !(*(*int32)(unsafe.Pointer(bp)) <= sz) {
  19419 		goto __18
  19420 	}
  19421 	if !(libc.Bool32(int32(*(*uint8)(unsafe.Pointer(pV + uintptr(*(*int32)(unsafe.Pointer(bp))>>3))))&(int32(1)<<(*(*int32)(unsafe.Pointer(bp))&7)) != 0) != Xsqlite3BitvecTest(tls, pBitvec, uint32(*(*int32)(unsafe.Pointer(bp))))) {
  19422 		goto __19
  19423 	}
  19424 	rc = *(*int32)(unsafe.Pointer(bp))
  19425 	goto __18
  19426 __19:
  19427 	;
  19428 	goto __17
  19429 __17:
  19430 	*(*int32)(unsafe.Pointer(bp))++
  19431 	goto __16
  19432 	goto __18
  19433 __18:
  19434 	;
  19435 bitvec_end:
  19436 	Xsqlite3_free(tls, pTmpSpace)
  19437 	Xsqlite3_free(tls, pV)
  19438 	Xsqlite3BitvecDestroy(tls, pBitvec)
  19439 	return rc
  19440 }
  19441 
  19442 func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) {
  19443 	var p uintptr = (*PgHdr)(unsafe.Pointer(pPage)).FpCache
  19444 
  19445 	if int32(addRemove)&PCACHE_DIRTYLIST_REMOVE != 0 {
  19446 		if (*PCache)(unsafe.Pointer(p)).FpSynced == pPage {
  19447 			(*PCache)(unsafe.Pointer(p)).FpSynced = (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev
  19448 		}
  19449 
  19450 		if (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext != 0 {
  19451 			(*PgHdr)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext)).FpDirtyPrev = (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev
  19452 		} else {
  19453 			(*PCache)(unsafe.Pointer(p)).FpDirtyTail = (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev
  19454 		}
  19455 		if (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev != 0 {
  19456 			(*PgHdr)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev)).FpDirtyNext = (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext
  19457 		} else {
  19458 			(*PCache)(unsafe.Pointer(p)).FpDirty = (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext
  19459 
  19460 			if (*PCache)(unsafe.Pointer(p)).FpDirty == uintptr(0) {
  19461 				(*PCache)(unsafe.Pointer(p)).FeCreate = U8(2)
  19462 			}
  19463 		}
  19464 	}
  19465 	if int32(addRemove)&PCACHE_DIRTYLIST_ADD != 0 {
  19466 		(*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev = uintptr(0)
  19467 		(*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext = (*PCache)(unsafe.Pointer(p)).FpDirty
  19468 		if (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext != 0 {
  19469 			(*PgHdr)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext)).FpDirtyPrev = pPage
  19470 		} else {
  19471 			(*PCache)(unsafe.Pointer(p)).FpDirtyTail = pPage
  19472 			if (*PCache)(unsafe.Pointer(p)).FbPurgeable != 0 {
  19473 				(*PCache)(unsafe.Pointer(p)).FeCreate = U8(1)
  19474 			}
  19475 		}
  19476 		(*PCache)(unsafe.Pointer(p)).FpDirty = pPage
  19477 
  19478 		if !(int32((*PCache)(unsafe.Pointer(p)).FpSynced) != 0) &&
  19479 			0 == int32((*PgHdr)(unsafe.Pointer(pPage)).Fflags)&PGHDR_NEED_SYNC {
  19480 			(*PCache)(unsafe.Pointer(p)).FpSynced = pPage
  19481 		}
  19482 	}
  19483 
  19484 }
  19485 
  19486 func pcacheUnpin(tls *libc.TLS, p uintptr) {
  19487 	if (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FbPurgeable != 0 {
  19488 		(*struct {
  19489 			f func(*libc.TLS, uintptr, uintptr, int32)
  19490 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxUnpin})).f(tls, (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, 0)
  19491 
  19492 	}
  19493 }
  19494 
  19495 func numberOfCachePages(tls *libc.TLS, p uintptr) int32 {
  19496 	if (*PCache)(unsafe.Pointer(p)).FszCache >= 0 {
  19497 		return (*PCache)(unsafe.Pointer(p)).FszCache
  19498 	} else {
  19499 		var n I64
  19500 
  19501 		n = int64(-1024) * I64((*PCache)(unsafe.Pointer(p)).FszCache) / I64((*PCache)(unsafe.Pointer(p)).FszPage+(*PCache)(unsafe.Pointer(p)).FszExtra)
  19502 		if n > int64(1000000000) {
  19503 			n = int64(1000000000)
  19504 		}
  19505 		return int32(n)
  19506 	}
  19507 	return int32(0)
  19508 }
  19509 
  19510 // ************************************************** General Interfaces ******
  19511 //
  19512 // Initialize and shutdown the page cache subsystem. Neither of these
  19513 // functions are threadsafe.
  19514 func Xsqlite3PcacheInitialize(tls *libc.TLS) int32 {
  19515 	if Xsqlite3Config.Fpcache2.FxInit == uintptr(0) {
  19516 		Xsqlite3PCacheSetDefault(tls)
  19517 
  19518 	}
  19519 	return (*struct {
  19520 		f func(*libc.TLS, uintptr) int32
  19521 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxInit})).f(tls, Xsqlite3Config.Fpcache2.FpArg)
  19522 }
  19523 
  19524 func Xsqlite3PcacheShutdown(tls *libc.TLS) {
  19525 	if Xsqlite3Config.Fpcache2.FxShutdown != 0 {
  19526 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxShutdown})).f(tls, Xsqlite3Config.Fpcache2.FpArg)
  19527 	}
  19528 }
  19529 
  19530 // Return the size in bytes of a PCache object.
  19531 func Xsqlite3PcacheSize(tls *libc.TLS) int32 {
  19532 	return int32(unsafe.Sizeof(PCache{}))
  19533 }
  19534 
  19535 // Create a new PCache object. Storage space to hold the object
  19536 // has already been allocated and is passed in as the p pointer.
  19537 // The caller discovers how much space needs to be allocated by
  19538 // calling sqlite3PcacheSize().
  19539 //
  19540 // szExtra is some extra space allocated for each page.  The first
  19541 // 8 bytes of the extra space will be zeroed as the page is allocated,
  19542 // but remaining content will be uninitialized.  Though it is opaque
  19543 // to this module, the extra space really ends up being the MemPage
  19544 // structure in the pager.
  19545 func Xsqlite3PcacheOpen(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32, xStress uintptr, pStress uintptr, p uintptr) int32 {
  19546 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(PCache{})))
  19547 	(*PCache)(unsafe.Pointer(p)).FszPage = 1
  19548 	(*PCache)(unsafe.Pointer(p)).FszExtra = szExtra
  19549 
  19550 	(*PCache)(unsafe.Pointer(p)).FbPurgeable = U8(bPurgeable)
  19551 	(*PCache)(unsafe.Pointer(p)).FeCreate = U8(2)
  19552 	(*PCache)(unsafe.Pointer(p)).FxStress = xStress
  19553 	(*PCache)(unsafe.Pointer(p)).FpStress = pStress
  19554 	(*PCache)(unsafe.Pointer(p)).FszCache = 100
  19555 	(*PCache)(unsafe.Pointer(p)).FszSpill = 1
  19556 
  19557 	return Xsqlite3PcacheSetPageSize(tls, p, szPage)
  19558 }
  19559 
  19560 // Change the page size for PCache object. The caller must ensure that there
  19561 // are no outstanding page references when this function is called.
  19562 func Xsqlite3PcacheSetPageSize(tls *libc.TLS, pCache uintptr, szPage int32) int32 {
  19563 	if (*PCache)(unsafe.Pointer(pCache)).FszPage != 0 {
  19564 		var pNew uintptr
  19565 		pNew = (*struct {
  19566 			f func(*libc.TLS, int32, int32, int32) uintptr
  19567 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxCreate})).f(tls,
  19568 			szPage, int32(uint32((*PCache)(unsafe.Pointer(pCache)).FszExtra)+(uint32(unsafe.Sizeof(PgHdr{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7))),
  19569 			int32((*PCache)(unsafe.Pointer(pCache)).FbPurgeable))
  19570 		if pNew == uintptr(0) {
  19571 			return SQLITE_NOMEM
  19572 		}
  19573 		(*struct {
  19574 			f func(*libc.TLS, uintptr, int32)
  19575 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxCachesize})).f(tls, pNew, numberOfCachePages(tls, pCache))
  19576 		if (*PCache)(unsafe.Pointer(pCache)).FpCache != 0 {
  19577 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxDestroy})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache)
  19578 		}
  19579 		(*PCache)(unsafe.Pointer(pCache)).FpCache = pNew
  19580 		(*PCache)(unsafe.Pointer(pCache)).FszPage = szPage
  19581 
  19582 	}
  19583 	return SQLITE_OK
  19584 }
  19585 
  19586 // Try to obtain a page from the cache.
  19587 //
  19588 // This routine returns a pointer to an sqlite3_pcache_page object if
  19589 // such an object is already in cache, or if a new one is created.
  19590 // This routine returns a NULL pointer if the object was not in cache
  19591 // and could not be created.
  19592 //
  19593 // The createFlags should be 0 to check for existing pages and should
  19594 // be 3 (not 1, but 3) to try to create a new page.
  19595 //
  19596 // If the createFlag is 0, then NULL is always returned if the page
  19597 // is not already in the cache.  If createFlag is 1, then a new page
  19598 // is created only if that can be done without spilling dirty pages
  19599 // and without exceeding the cache size limit.
  19600 //
  19601 // The caller needs to invoke sqlite3PcacheFetchFinish() to properly
  19602 // initialize the sqlite3_pcache_page object and convert it into a
  19603 // PgHdr object.  The sqlite3PcacheFetch() and sqlite3PcacheFetchFinish()
  19604 // routines are split this way for performance reasons. When separated
  19605 // they can both (usually) operate without having to push values to
  19606 // the stack on entry and pop them back off on exit, which saves a
  19607 // lot of pushing and popping.
  19608 func Xsqlite3PcacheFetch(tls *libc.TLS, pCache uintptr, pgno Pgno, createFlag int32) uintptr {
  19609 	var eCreate int32
  19610 	var pRes uintptr
  19611 
  19612 	eCreate = createFlag & int32((*PCache)(unsafe.Pointer(pCache)).FeCreate)
  19613 
  19614 	pRes = (*struct {
  19615 		f func(*libc.TLS, uintptr, uint32, int32) uintptr
  19616 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxFetch})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, pgno, eCreate)
  19617 
  19618 	return pRes
  19619 }
  19620 
  19621 // If the sqlite3PcacheFetch() routine is unable to allocate a new
  19622 // page because no clean pages are available for reuse and the cache
  19623 // size limit has been reached, then this routine can be invoked to
  19624 // try harder to allocate a page.  This routine might invoke the stress
  19625 // callback to spill dirty pages to the journal.  It will then try to
  19626 // allocate the new page and will only fail to allocate a new page on
  19627 // an OOM error.
  19628 //
  19629 // This routine should be invoked only after sqlite3PcacheFetch() fails.
  19630 func Xsqlite3PcacheFetchStress(tls *libc.TLS, pCache uintptr, pgno Pgno, ppPage uintptr) int32 {
  19631 	var pPg uintptr
  19632 	if int32((*PCache)(unsafe.Pointer(pCache)).FeCreate) == 2 {
  19633 		return 0
  19634 	}
  19635 
  19636 	if Xsqlite3PcachePagecount(tls, pCache) > (*PCache)(unsafe.Pointer(pCache)).FszSpill {
  19637 		for pPg = (*PCache)(unsafe.Pointer(pCache)).FpSynced; pPg != 0 && ((*PgHdr)(unsafe.Pointer(pPg)).FnRef != 0 || int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags)&PGHDR_NEED_SYNC != 0); pPg = (*PgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev {
  19638 		}
  19639 		(*PCache)(unsafe.Pointer(pCache)).FpSynced = pPg
  19640 		if !(pPg != 0) {
  19641 			for pPg = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail; pPg != 0 && (*PgHdr)(unsafe.Pointer(pPg)).FnRef != 0; pPg = (*PgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev {
  19642 			}
  19643 		}
  19644 		if pPg != 0 {
  19645 			var rc int32
  19646 
  19647 			rc = (*struct {
  19648 				f func(*libc.TLS, uintptr, uintptr) int32
  19649 			})(unsafe.Pointer(&struct{ uintptr }{(*PCache)(unsafe.Pointer(pCache)).FxStress})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpStress, pPg)
  19650 
  19651 			if rc != SQLITE_OK && rc != SQLITE_BUSY {
  19652 				return rc
  19653 			}
  19654 		}
  19655 	}
  19656 	*(*uintptr)(unsafe.Pointer(ppPage)) = (*struct {
  19657 		f func(*libc.TLS, uintptr, uint32, int32) uintptr
  19658 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxFetch})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, pgno, 2)
  19659 	if *(*uintptr)(unsafe.Pointer(ppPage)) == uintptr(0) {
  19660 		return SQLITE_NOMEM
  19661 	}
  19662 	return SQLITE_OK
  19663 }
  19664 
  19665 func pcacheFetchFinishWithInit(tls *libc.TLS, pCache uintptr, pgno Pgno, pPage uintptr) uintptr {
  19666 	var pPgHdr uintptr
  19667 
  19668 	pPgHdr = (*Sqlite3_pcache_page)(unsafe.Pointer(pPage)).FpExtra
  19669 
  19670 	libc.Xmemset(tls, pPgHdr+16, 0, uint32(unsafe.Sizeof(PgHdr{}))-uint32(uintptr(0)+16))
  19671 	(*PgHdr)(unsafe.Pointer(pPgHdr)).FpPage = pPage
  19672 	(*PgHdr)(unsafe.Pointer(pPgHdr)).FpData = (*Sqlite3_pcache_page)(unsafe.Pointer(pPage)).FpBuf
  19673 	(*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = pPgHdr + 1*48
  19674 	libc.Xmemset(tls, (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra, 0, uint32(8))
  19675 	(*PgHdr)(unsafe.Pointer(pPgHdr)).FpCache = pCache
  19676 	(*PgHdr)(unsafe.Pointer(pPgHdr)).Fpgno = pgno
  19677 	(*PgHdr)(unsafe.Pointer(pPgHdr)).Fflags = U16(PGHDR_CLEAN)
  19678 	return Xsqlite3PcacheFetchFinish(tls, pCache, pgno, pPage)
  19679 }
  19680 
  19681 // This routine converts the sqlite3_pcache_page object returned by
  19682 // sqlite3PcacheFetch() into an initialized PgHdr object.  This routine
  19683 // must be called after sqlite3PcacheFetch() in order to get a usable
  19684 // result.
  19685 func Xsqlite3PcacheFetchFinish(tls *libc.TLS, pCache uintptr, pgno Pgno, pPage uintptr) uintptr {
  19686 	var pPgHdr uintptr
  19687 
  19688 	pPgHdr = (*Sqlite3_pcache_page)(unsafe.Pointer(pPage)).FpExtra
  19689 
  19690 	if !(int32((*PgHdr)(unsafe.Pointer(pPgHdr)).FpPage) != 0) {
  19691 		return pcacheFetchFinishWithInit(tls, pCache, pgno, pPage)
  19692 	}
  19693 	(*PCache)(unsafe.Pointer(pCache)).FnRefSum++
  19694 	(*PgHdr)(unsafe.Pointer(pPgHdr)).FnRef++
  19695 
  19696 	return pPgHdr
  19697 }
  19698 
  19699 // Decrement the reference count on a page. If the page is clean and the
  19700 // reference count drops to 0, then it is made eligible for recycling.
  19701 func Xsqlite3PcacheRelease(tls *libc.TLS, p uintptr) {
  19702 	(*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum--
  19703 	if libc.PreDecInt64(&(*PgHdr)(unsafe.Pointer(p)).FnRef, 1) == int64(0) {
  19704 		if int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&PGHDR_CLEAN != 0 {
  19705 			pcacheUnpin(tls, p)
  19706 		} else {
  19707 			pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_FRONT))
  19708 
  19709 		}
  19710 	}
  19711 }
  19712 
  19713 // Increase the reference count of a supplied page by 1.
  19714 func Xsqlite3PcacheRef(tls *libc.TLS, p uintptr) {
  19715 	(*PgHdr)(unsafe.Pointer(p)).FnRef++
  19716 	(*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum++
  19717 }
  19718 
  19719 // Drop a page from the cache. There must be exactly one reference to the
  19720 // page. This function deletes that reference, so after it returns the
  19721 // page pointed to by p is invalid.
  19722 func Xsqlite3PcacheDrop(tls *libc.TLS, p uintptr) {
  19723 	if int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&PGHDR_DIRTY != 0 {
  19724 		pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_REMOVE))
  19725 	}
  19726 	(*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum--
  19727 	(*struct {
  19728 		f func(*libc.TLS, uintptr, uintptr, int32)
  19729 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxUnpin})).f(tls, (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, 1)
  19730 }
  19731 
  19732 // Make sure the page is marked as dirty. If it isn't dirty already,
  19733 // make it so.
  19734 func Xsqlite3PcacheMakeDirty(tls *libc.TLS, p uintptr) {
  19735 	if int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&(PGHDR_CLEAN|PGHDR_DONT_WRITE) != 0 {
  19736 		*(*U16)(unsafe.Pointer(p + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_DONT_WRITE))
  19737 		if int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&PGHDR_CLEAN != 0 {
  19738 			*(*U16)(unsafe.Pointer(p + 28)) ^= U16(PGHDR_DIRTY | PGHDR_CLEAN)
  19739 
  19740 			pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_ADD))
  19741 
  19742 		}
  19743 
  19744 	}
  19745 }
  19746 
  19747 // Make sure the page is marked as clean. If it isn't clean already,
  19748 // make it so.
  19749 func Xsqlite3PcacheMakeClean(tls *libc.TLS, p uintptr) {
  19750 	pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_REMOVE))
  19751 	*(*U16)(unsafe.Pointer(p + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_DIRTY | PGHDR_NEED_SYNC | PGHDR_WRITEABLE))
  19752 	*(*U16)(unsafe.Pointer(p + 28)) |= U16(PGHDR_CLEAN)
  19753 
  19754 	if (*PgHdr)(unsafe.Pointer(p)).FnRef == int64(0) {
  19755 		pcacheUnpin(tls, p)
  19756 	}
  19757 }
  19758 
  19759 // Make every page in the cache clean.
  19760 func Xsqlite3PcacheCleanAll(tls *libc.TLS, pCache uintptr) {
  19761 	var p uintptr
  19762 
  19763 	for libc.AssignUintptr(&p, (*PCache)(unsafe.Pointer(pCache)).FpDirty) != uintptr(0) {
  19764 		Xsqlite3PcacheMakeClean(tls, p)
  19765 	}
  19766 }
  19767 
  19768 // Clear the PGHDR_NEED_SYNC and PGHDR_WRITEABLE flag from all dirty pages.
  19769 func Xsqlite3PcacheClearWritable(tls *libc.TLS, pCache uintptr) {
  19770 	var p uintptr
  19771 
  19772 	for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext {
  19773 		*(*U16)(unsafe.Pointer(p + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_NEED_SYNC | PGHDR_WRITEABLE))
  19774 	}
  19775 	(*PCache)(unsafe.Pointer(pCache)).FpSynced = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail
  19776 }
  19777 
  19778 // Clear the PGHDR_NEED_SYNC flag from all dirty pages.
  19779 func Xsqlite3PcacheClearSyncFlags(tls *libc.TLS, pCache uintptr) {
  19780 	var p uintptr
  19781 	for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext {
  19782 		*(*U16)(unsafe.Pointer(p + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_NEED_SYNC))
  19783 	}
  19784 	(*PCache)(unsafe.Pointer(pCache)).FpSynced = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail
  19785 }
  19786 
  19787 // Change the page number of page p to newPgno.
  19788 func Xsqlite3PcacheMove(tls *libc.TLS, p uintptr, newPgno Pgno) {
  19789 	var pCache uintptr = (*PgHdr)(unsafe.Pointer(p)).FpCache
  19790 	var pOther uintptr
  19791 
  19792 	pOther = (*struct {
  19793 		f func(*libc.TLS, uintptr, uint32, int32) uintptr
  19794 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxFetch})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, newPgno, 0)
  19795 	if pOther != 0 {
  19796 		var pXPage uintptr = (*Sqlite3_pcache_page)(unsafe.Pointer(pOther)).FpExtra
  19797 
  19798 		(*PgHdr)(unsafe.Pointer(pXPage)).FnRef++
  19799 		(*PCache)(unsafe.Pointer(pCache)).FnRefSum++
  19800 		Xsqlite3PcacheDrop(tls, pXPage)
  19801 	}
  19802 	(*struct {
  19803 		f func(*libc.TLS, uintptr, uintptr, uint32, uint32)
  19804 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxRekey})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, (*PgHdr)(unsafe.Pointer(p)).Fpgno, newPgno)
  19805 	(*PgHdr)(unsafe.Pointer(p)).Fpgno = newPgno
  19806 	if int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&PGHDR_DIRTY != 0 && int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&PGHDR_NEED_SYNC != 0 {
  19807 		pcacheManageDirtyList(tls, p, uint8(PCACHE_DIRTYLIST_FRONT))
  19808 
  19809 	}
  19810 }
  19811 
  19812 // Drop every cache entry whose page number is greater than "pgno". The
  19813 // caller must ensure that there are no outstanding references to any pages
  19814 // other than page 1 with a page number greater than pgno.
  19815 //
  19816 // If there is a reference to page 1 and the pgno parameter passed to this
  19817 // function is 0, then the data area associated with page 1 is zeroed, but
  19818 // the page object is not dropped.
  19819 func Xsqlite3PcacheTruncate(tls *libc.TLS, pCache uintptr, pgno Pgno) {
  19820 	if (*PCache)(unsafe.Pointer(pCache)).FpCache != 0 {
  19821 		var p uintptr
  19822 		var pNext uintptr
  19823 
  19824 		for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = pNext {
  19825 			pNext = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext
  19826 
  19827 			if (*PgHdr)(unsafe.Pointer(p)).Fpgno > pgno {
  19828 				Xsqlite3PcacheMakeClean(tls, p)
  19829 			}
  19830 		}
  19831 		if pgno == Pgno(0) && (*PCache)(unsafe.Pointer(pCache)).FnRefSum != 0 {
  19832 			var pPage1 uintptr
  19833 			pPage1 = (*struct {
  19834 				f func(*libc.TLS, uintptr, uint32, int32) uintptr
  19835 			})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxFetch})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, uint32(1), 0)
  19836 			if pPage1 != 0 {
  19837 				libc.Xmemset(tls, (*Sqlite3_pcache_page)(unsafe.Pointer(pPage1)).FpBuf, 0, uint32((*PCache)(unsafe.Pointer(pCache)).FszPage))
  19838 				pgno = Pgno(1)
  19839 			}
  19840 		}
  19841 		(*struct {
  19842 			f func(*libc.TLS, uintptr, uint32)
  19843 		})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxTruncate})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, pgno+Pgno(1))
  19844 	}
  19845 }
  19846 
  19847 // Close a cache.
  19848 func Xsqlite3PcacheClose(tls *libc.TLS, pCache uintptr) {
  19849 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxDestroy})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache)
  19850 }
  19851 
  19852 // Discard the contents of the cache.
  19853 func Xsqlite3PcacheClear(tls *libc.TLS, pCache uintptr) {
  19854 	Xsqlite3PcacheTruncate(tls, pCache, uint32(0))
  19855 }
  19856 
  19857 func pcacheMergeDirtyList(tls *libc.TLS, pA uintptr, pB uintptr) uintptr {
  19858 	bp := tls.Alloc(48)
  19859 	defer tls.Free(48)
  19860 
  19861 	var pTail uintptr
  19862 	pTail = bp
  19863 
  19864 	for {
  19865 		if (*PgHdr)(unsafe.Pointer(pA)).Fpgno < (*PgHdr)(unsafe.Pointer(pB)).Fpgno {
  19866 			(*PgHdr)(unsafe.Pointer(pTail)).FpDirty = pA
  19867 			pTail = pA
  19868 			pA = (*PgHdr)(unsafe.Pointer(pA)).FpDirty
  19869 			if pA == uintptr(0) {
  19870 				(*PgHdr)(unsafe.Pointer(pTail)).FpDirty = pB
  19871 				break
  19872 			}
  19873 		} else {
  19874 			(*PgHdr)(unsafe.Pointer(pTail)).FpDirty = pB
  19875 			pTail = pB
  19876 			pB = (*PgHdr)(unsafe.Pointer(pB)).FpDirty
  19877 			if pB == uintptr(0) {
  19878 				(*PgHdr)(unsafe.Pointer(pTail)).FpDirty = pA
  19879 				break
  19880 			}
  19881 		}
  19882 	}
  19883 	return (*PgHdr)(unsafe.Pointer(bp)).FpDirty
  19884 }
  19885 
  19886 func pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) uintptr {
  19887 	bp := tls.Alloc(128)
  19888 	defer tls.Free(128)
  19889 
  19890 	var p uintptr
  19891 	var i int32
  19892 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([32]uintptr{})))
  19893 	for pIn != 0 {
  19894 		p = pIn
  19895 		pIn = (*PgHdr)(unsafe.Pointer(p)).FpDirty
  19896 		(*PgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0)
  19897 		for i = 0; i < N_SORT_BUCKET-1; i++ {
  19898 			if *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) == uintptr(0) {
  19899 				*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = p
  19900 				break
  19901 			} else {
  19902 				p = pcacheMergeDirtyList(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)), p)
  19903 				*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = uintptr(0)
  19904 			}
  19905 		}
  19906 		if i == N_SORT_BUCKET-1 {
  19907 			*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = pcacheMergeDirtyList(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)), p)
  19908 		}
  19909 	}
  19910 	p = *(*uintptr)(unsafe.Pointer(bp))
  19911 	for i = 1; i < N_SORT_BUCKET; i++ {
  19912 		if *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) == uintptr(0) {
  19913 			continue
  19914 		}
  19915 		if p != 0 {
  19916 			p = pcacheMergeDirtyList(tls, p, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)))
  19917 		} else {
  19918 			p = *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4))
  19919 		}
  19920 	}
  19921 	return p
  19922 }
  19923 
  19924 // Return a list of all dirty pages in the cache, sorted by page number.
  19925 func Xsqlite3PcacheDirtyList(tls *libc.TLS, pCache uintptr) uintptr {
  19926 	var p uintptr
  19927 	for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext {
  19928 		(*PgHdr)(unsafe.Pointer(p)).FpDirty = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext
  19929 	}
  19930 	return pcacheSortDirtyList(tls, (*PCache)(unsafe.Pointer(pCache)).FpDirty)
  19931 }
  19932 
  19933 // Return the total number of references to all pages held by the cache.
  19934 //
  19935 // This is not the total number of pages referenced, but the sum of the
  19936 // reference count for all pages.
  19937 func Xsqlite3PcacheRefCount(tls *libc.TLS, pCache uintptr) I64 {
  19938 	return (*PCache)(unsafe.Pointer(pCache)).FnRefSum
  19939 }
  19940 
  19941 // Return the number of references to the page supplied as an argument.
  19942 func Xsqlite3PcachePageRefcount(tls *libc.TLS, p uintptr) I64 {
  19943 	return (*PgHdr)(unsafe.Pointer(p)).FnRef
  19944 }
  19945 
  19946 // Return the total number of pages in the cache.
  19947 func Xsqlite3PcachePagecount(tls *libc.TLS, pCache uintptr) int32 {
  19948 	return (*struct {
  19949 		f func(*libc.TLS, uintptr) int32
  19950 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxPagecount})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache)
  19951 }
  19952 
  19953 // Set the suggested cache-size value.
  19954 func Xsqlite3PcacheSetCachesize(tls *libc.TLS, pCache uintptr, mxPage int32) {
  19955 	(*PCache)(unsafe.Pointer(pCache)).FszCache = mxPage
  19956 	(*struct {
  19957 		f func(*libc.TLS, uintptr, int32)
  19958 	})(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxCachesize})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache,
  19959 		numberOfCachePages(tls, pCache))
  19960 }
  19961 
  19962 // Set the suggested cache-spill value.  Make no changes if if the
  19963 // argument is zero.  Return the effective cache-spill size, which will
  19964 // be the larger of the szSpill and szCache.
  19965 func Xsqlite3PcacheSetSpillsize(tls *libc.TLS, p uintptr, mxPage int32) int32 {
  19966 	var res int32
  19967 
  19968 	if mxPage != 0 {
  19969 		if mxPage < 0 {
  19970 			mxPage = int32(int64(-1024) * I64(mxPage) / I64((*PCache)(unsafe.Pointer(p)).FszPage+(*PCache)(unsafe.Pointer(p)).FszExtra))
  19971 		}
  19972 		(*PCache)(unsafe.Pointer(p)).FszSpill = mxPage
  19973 	}
  19974 	res = numberOfCachePages(tls, p)
  19975 	if res < (*PCache)(unsafe.Pointer(p)).FszSpill {
  19976 		res = (*PCache)(unsafe.Pointer(p)).FszSpill
  19977 	}
  19978 	return res
  19979 }
  19980 
  19981 // Free up as much memory as possible from the page cache.
  19982 func Xsqlite3PcacheShrink(tls *libc.TLS, pCache uintptr) {
  19983 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{Xsqlite3Config.Fpcache2.FxShrink})).f(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache)
  19984 }
  19985 
  19986 // Return the size of the header added by this middleware layer
  19987 // in the page-cache hierarchy.
  19988 func Xsqlite3HeaderSizePcache(tls *libc.TLS) int32 {
  19989 	return int32((uint32(unsafe.Sizeof(PgHdr{})) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  19990 }
  19991 
  19992 // Return the number of dirty pages currently in the cache, as a percentage
  19993 // of the configured cache size.
  19994 func Xsqlite3PCachePercentDirty(tls *libc.TLS, pCache uintptr) int32 {
  19995 	var pDirty uintptr
  19996 	var nDirty int32 = 0
  19997 	var nCache int32 = numberOfCachePages(tls, pCache)
  19998 	for pDirty = (*PCache)(unsafe.Pointer(pCache)).FpDirty; pDirty != 0; pDirty = (*PgHdr)(unsafe.Pointer(pDirty)).FpDirtyNext {
  19999 		nDirty++
  20000 	}
  20001 	if nCache != 0 {
  20002 		return int32(I64(nDirty) * int64(100) / I64(nCache))
  20003 	}
  20004 	return 0
  20005 }
  20006 
  20007 type PCache11 = struct {
  20008 	FpGroup          uintptr
  20009 	FpnPurgeable     uintptr
  20010 	FszPage          int32
  20011 	FszExtra         int32
  20012 	FszAlloc         int32
  20013 	FbPurgeable      int32
  20014 	FnMin            uint32
  20015 	FnMax            uint32
  20016 	Fn90pct          uint32
  20017 	FiMaxKey         uint32
  20018 	FnPurgeableDummy uint32
  20019 	FnRecyclable     uint32
  20020 	FnPage           uint32
  20021 	FnHash           uint32
  20022 	FapHash          uintptr
  20023 	FpFree           uintptr
  20024 	FpBulk           uintptr
  20025 }
  20026 
  20027 type PCache1 = PCache11
  20028 type PgHdr11 = struct {
  20029 	Fpage        Sqlite3_pcache_page
  20030 	FiKey        uint32
  20031 	FisBulkLocal U16
  20032 	FisAnchor    U16
  20033 	FpNext       uintptr
  20034 	FpCache      uintptr
  20035 	FpLruNext    uintptr
  20036 	FpLruPrev    uintptr
  20037 }
  20038 
  20039 type PgHdr1 = PgHdr11
  20040 type PgFreeslot1 = struct{ FpNext uintptr }
  20041 
  20042 type PgFreeslot = PgFreeslot1
  20043 type PGroup1 = struct {
  20044 	Fmutex      uintptr
  20045 	FnMaxPage   uint32
  20046 	FnMinPage   uint32
  20047 	FmxPinned   uint32
  20048 	FnPurgeable uint32
  20049 	Flru        PgHdr1
  20050 }
  20051 
  20052 type PGroup = PGroup1
  20053 
  20054 // Global data used by this cache.
  20055 type PCacheGlobal = struct {
  20056 	Fgrp            PGroup
  20057 	FisInit         int32
  20058 	FseparateCache  int32
  20059 	FnInitPage      int32
  20060 	FszSlot         int32
  20061 	FnSlot          int32
  20062 	FnReserve       int32
  20063 	FpStart         uintptr
  20064 	FpEnd           uintptr
  20065 	Fmutex          uintptr
  20066 	FpFree          uintptr
  20067 	FnFreeSlot      int32
  20068 	FbUnderPressure int32
  20069 }
  20070 
  20071 var pcache1_g PCacheGlobal
  20072 
  20073 // This function is called during initialization if a static buffer is
  20074 // supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE
  20075 // verb to sqlite3_config(). Parameter pBuf points to an allocation large
  20076 // enough to contain 'n' buffers of 'sz' bytes each.
  20077 //
  20078 // This routine is called from sqlite3_initialize() and so it is guaranteed
  20079 // to be serialized already.  There is no need for further mutexing.
  20080 func Xsqlite3PCacheBufferSetup(tls *libc.TLS, pBuf uintptr, sz int32, n int32) {
  20081 	if pcache1_g.FisInit != 0 {
  20082 		var p uintptr
  20083 		if pBuf == uintptr(0) {
  20084 			sz = libc.AssignInt32(&n, 0)
  20085 		}
  20086 		if n == 0 {
  20087 			sz = 0
  20088 		}
  20089 		sz = sz & libc.CplInt32(7)
  20090 		pcache1_g.FszSlot = sz
  20091 		pcache1_g.FnSlot = libc.AssignPtrInt32(uintptr(unsafe.Pointer(&pcache1_g))+92, n)
  20092 		pcache1_g.FnReserve = func() int32 {
  20093 			if n > 90 {
  20094 				return 10
  20095 			}
  20096 			return n/10 + 1
  20097 		}()
  20098 		pcache1_g.FpStart = pBuf
  20099 		pcache1_g.FpFree = uintptr(0)
  20100 		pcache1_g.FbUnderPressure = 0
  20101 		for libc.PostDecInt32(&n, 1) != 0 {
  20102 			p = pBuf
  20103 			(*PgFreeslot)(unsafe.Pointer(p)).FpNext = pcache1_g.FpFree
  20104 			pcache1_g.FpFree = p
  20105 			pBuf = pBuf + uintptr(sz)
  20106 		}
  20107 		pcache1_g.FpEnd = pBuf
  20108 	}
  20109 }
  20110 
  20111 func pcache1InitBulk(tls *libc.TLS, pCache uintptr) int32 {
  20112 	var szBulk I64
  20113 	var zBulk uintptr
  20114 	if pcache1_g.FnInitPage == 0 {
  20115 		return 0
  20116 	}
  20117 
  20118 	if (*PCache1)(unsafe.Pointer(pCache)).FnMax < uint32(3) {
  20119 		return 0
  20120 	}
  20121 	Xsqlite3BeginBenignMalloc(tls)
  20122 	if pcache1_g.FnInitPage > 0 {
  20123 		szBulk = I64((*PCache1)(unsafe.Pointer(pCache)).FszAlloc) * I64(pcache1_g.FnInitPage)
  20124 	} else {
  20125 		szBulk = int64(-1024) * I64(pcache1_g.FnInitPage)
  20126 	}
  20127 	if szBulk > I64((*PCache1)(unsafe.Pointer(pCache)).FszAlloc)*I64((*PCache1)(unsafe.Pointer(pCache)).FnMax) {
  20128 		szBulk = I64((*PCache1)(unsafe.Pointer(pCache)).FszAlloc) * I64((*PCache1)(unsafe.Pointer(pCache)).FnMax)
  20129 	}
  20130 	zBulk = libc.AssignPtrUintptr(pCache+64, Xsqlite3Malloc(tls, uint64(szBulk)))
  20131 	Xsqlite3EndBenignMalloc(tls)
  20132 	if zBulk != 0 {
  20133 		var nBulk int32 = Xsqlite3MallocSize(tls, zBulk) / (*PCache1)(unsafe.Pointer(pCache)).FszAlloc
  20134 		for __ccgo := true; __ccgo; __ccgo = libc.PreDecInt32(&nBulk, 1) != 0 {
  20135 			var pX uintptr = zBulk + uintptr((*PCache1)(unsafe.Pointer(pCache)).FszPage)
  20136 			(*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpBuf = zBulk
  20137 			(*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpExtra = pX + 1*32
  20138 			(*PgHdr1)(unsafe.Pointer(pX)).FisBulkLocal = U16(1)
  20139 			(*PgHdr1)(unsafe.Pointer(pX)).FisAnchor = U16(0)
  20140 			(*PgHdr1)(unsafe.Pointer(pX)).FpNext = (*PCache1)(unsafe.Pointer(pCache)).FpFree
  20141 			(*PgHdr1)(unsafe.Pointer(pX)).FpLruPrev = uintptr(0)
  20142 			(*PCache1)(unsafe.Pointer(pCache)).FpFree = pX
  20143 			zBulk += uintptr((*PCache1)(unsafe.Pointer(pCache)).FszAlloc)
  20144 		}
  20145 	}
  20146 	return libc.Bool32((*PCache1)(unsafe.Pointer(pCache)).FpFree != uintptr(0))
  20147 }
  20148 
  20149 func pcache1Alloc(tls *libc.TLS, nByte int32) uintptr {
  20150 	var p uintptr = uintptr(0)
  20151 
  20152 	if nByte <= pcache1_g.FszSlot {
  20153 		Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex)
  20154 		p = pcache1_g.FpFree
  20155 		if p != 0 {
  20156 			pcache1_g.FpFree = (*PgFreeslot)(unsafe.Pointer(pcache1_g.FpFree)).FpNext
  20157 			pcache1_g.FnFreeSlot--
  20158 			pcache1_g.FbUnderPressure = libc.Bool32(pcache1_g.FnFreeSlot < pcache1_g.FnReserve)
  20159 
  20160 			Xsqlite3StatusHighwater(tls, SQLITE_STATUS_PAGECACHE_SIZE, nByte)
  20161 			Xsqlite3StatusUp(tls, SQLITE_STATUS_PAGECACHE_USED, 1)
  20162 		}
  20163 		Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex)
  20164 	}
  20165 	if p == uintptr(0) {
  20166 		p = Xsqlite3Malloc(tls, uint64(nByte))
  20167 		if p != 0 {
  20168 			var sz int32 = Xsqlite3MallocSize(tls, p)
  20169 			Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex)
  20170 			Xsqlite3StatusHighwater(tls, SQLITE_STATUS_PAGECACHE_SIZE, nByte)
  20171 			Xsqlite3StatusUp(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, sz)
  20172 			Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex)
  20173 		}
  20174 
  20175 	}
  20176 	return p
  20177 }
  20178 
  20179 func pcache1Free(tls *libc.TLS, p uintptr) {
  20180 	if p == uintptr(0) {
  20181 		return
  20182 	}
  20183 	if Uptr(p) >= Uptr(pcache1_g.FpStart) && Uptr(p) < Uptr(pcache1_g.FpEnd) {
  20184 		var pSlot uintptr
  20185 		Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex)
  20186 		Xsqlite3StatusDown(tls, SQLITE_STATUS_PAGECACHE_USED, 1)
  20187 		pSlot = p
  20188 		(*PgFreeslot)(unsafe.Pointer(pSlot)).FpNext = pcache1_g.FpFree
  20189 		pcache1_g.FpFree = pSlot
  20190 		pcache1_g.FnFreeSlot++
  20191 		pcache1_g.FbUnderPressure = libc.Bool32(pcache1_g.FnFreeSlot < pcache1_g.FnReserve)
  20192 
  20193 		Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex)
  20194 	} else {
  20195 		{
  20196 			var nFreed int32 = 0
  20197 			nFreed = Xsqlite3MallocSize(tls, p)
  20198 			Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex)
  20199 			Xsqlite3StatusDown(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed)
  20200 			Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex)
  20201 
  20202 		}
  20203 		Xsqlite3_free(tls, p)
  20204 	}
  20205 }
  20206 
  20207 func pcache1MemSize(tls *libc.TLS, p uintptr) int32 {
  20208 	if p >= pcache1_g.FpStart && p < pcache1_g.FpEnd {
  20209 		return pcache1_g.FszSlot
  20210 	} else {
  20211 		var iSize int32
  20212 
  20213 		iSize = Xsqlite3MallocSize(tls, p)
  20214 
  20215 		return iSize
  20216 	}
  20217 	return int32(0)
  20218 }
  20219 
  20220 func pcache1AllocPage(tls *libc.TLS, pCache uintptr, benignMalloc int32) uintptr {
  20221 	var p uintptr = uintptr(0)
  20222 	var pPg uintptr
  20223 
  20224 	if (*PCache1)(unsafe.Pointer(pCache)).FpFree != 0 || (*PCache1)(unsafe.Pointer(pCache)).FnPage == uint32(0) && pcache1InitBulk(tls, pCache) != 0 {
  20225 		p = (*PCache1)(unsafe.Pointer(pCache)).FpFree
  20226 		(*PCache1)(unsafe.Pointer(pCache)).FpFree = (*PgHdr1)(unsafe.Pointer(p)).FpNext
  20227 		(*PgHdr1)(unsafe.Pointer(p)).FpNext = uintptr(0)
  20228 	} else {
  20229 		Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20230 		if benignMalloc != 0 {
  20231 			Xsqlite3BeginBenignMalloc(tls)
  20232 		}
  20233 		pPg = pcache1Alloc(tls, (*PCache1)(unsafe.Pointer(pCache)).FszAlloc)
  20234 		if benignMalloc != 0 {
  20235 			Xsqlite3EndBenignMalloc(tls)
  20236 		}
  20237 		Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20238 		if pPg == uintptr(0) {
  20239 			return uintptr(0)
  20240 		}
  20241 		p = pPg + uintptr((*PCache1)(unsafe.Pointer(pCache)).FszPage)
  20242 		(*PgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf = pPg
  20243 		(*PgHdr1)(unsafe.Pointer(p)).Fpage.FpExtra = p + 1*32
  20244 		(*PgHdr1)(unsafe.Pointer(p)).FisBulkLocal = U16(0)
  20245 		(*PgHdr1)(unsafe.Pointer(p)).FisAnchor = U16(0)
  20246 		(*PgHdr1)(unsafe.Pointer(p)).FpLruPrev = uintptr(0)
  20247 	}
  20248 	*(*uint32)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpnPurgeable))++
  20249 	return p
  20250 }
  20251 
  20252 func pcache1FreePage(tls *libc.TLS, p uintptr) {
  20253 	var pCache uintptr
  20254 
  20255 	pCache = (*PgHdr1)(unsafe.Pointer(p)).FpCache
  20256 
  20257 	if (*PgHdr1)(unsafe.Pointer(p)).FisBulkLocal != 0 {
  20258 		(*PgHdr1)(unsafe.Pointer(p)).FpNext = (*PCache1)(unsafe.Pointer(pCache)).FpFree
  20259 		(*PCache1)(unsafe.Pointer(pCache)).FpFree = p
  20260 	} else {
  20261 		pcache1Free(tls, (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf)
  20262 	}
  20263 	*(*uint32)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpnPurgeable))--
  20264 }
  20265 
  20266 // Malloc function used by SQLite to obtain space from the buffer configured
  20267 // using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer
  20268 // exists, this function falls back to sqlite3Malloc().
  20269 func Xsqlite3PageMalloc(tls *libc.TLS, sz int32) uintptr {
  20270 	return pcache1Alloc(tls, sz)
  20271 }
  20272 
  20273 // Free an allocated buffer obtained from sqlite3PageMalloc().
  20274 func Xsqlite3PageFree(tls *libc.TLS, p uintptr) {
  20275 	pcache1Free(tls, p)
  20276 }
  20277 
  20278 func pcache1UnderMemoryPressure(tls *libc.TLS, pCache uintptr) int32 {
  20279 	if pcache1_g.FnSlot != 0 && (*PCache1)(unsafe.Pointer(pCache)).FszPage+(*PCache1)(unsafe.Pointer(pCache)).FszExtra <= pcache1_g.FszSlot {
  20280 		return pcache1_g.FbUnderPressure
  20281 	} else {
  20282 		return Xsqlite3HeapNearlyFull(tls)
  20283 	}
  20284 	return int32(0)
  20285 }
  20286 
  20287 func pcache1ResizeHash(tls *libc.TLS, p uintptr) {
  20288 	var apNew uintptr
  20289 	var nNew uint32
  20290 	var i uint32
  20291 
  20292 	nNew = (*PCache1)(unsafe.Pointer(p)).FnHash * uint32(2)
  20293 	if nNew < uint32(256) {
  20294 		nNew = uint32(256)
  20295 	}
  20296 
  20297 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(p)).FpGroup)).Fmutex)
  20298 	if (*PCache1)(unsafe.Pointer(p)).FnHash != 0 {
  20299 		Xsqlite3BeginBenignMalloc(tls)
  20300 	}
  20301 	apNew = Xsqlite3MallocZero(tls, uint64(uint32(unsafe.Sizeof(uintptr(0)))*nNew))
  20302 	if (*PCache1)(unsafe.Pointer(p)).FnHash != 0 {
  20303 		Xsqlite3EndBenignMalloc(tls)
  20304 	}
  20305 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(p)).FpGroup)).Fmutex)
  20306 	if apNew != 0 {
  20307 		for i = uint32(0); i < (*PCache1)(unsafe.Pointer(p)).FnHash; i++ {
  20308 			var pPage uintptr
  20309 			var pNext uintptr = *(*uintptr)(unsafe.Pointer((*PCache1)(unsafe.Pointer(p)).FapHash + uintptr(i)*4))
  20310 			for libc.AssignUintptr(&pPage, pNext) != uintptr(0) {
  20311 				var h uint32 = (*PgHdr1)(unsafe.Pointer(pPage)).FiKey % nNew
  20312 				pNext = (*PgHdr1)(unsafe.Pointer(pPage)).FpNext
  20313 				(*PgHdr1)(unsafe.Pointer(pPage)).FpNext = *(*uintptr)(unsafe.Pointer(apNew + uintptr(h)*4))
  20314 				*(*uintptr)(unsafe.Pointer(apNew + uintptr(h)*4)) = pPage
  20315 			}
  20316 		}
  20317 		Xsqlite3_free(tls, (*PCache1)(unsafe.Pointer(p)).FapHash)
  20318 		(*PCache1)(unsafe.Pointer(p)).FapHash = apNew
  20319 		(*PCache1)(unsafe.Pointer(p)).FnHash = nNew
  20320 	}
  20321 }
  20322 
  20323 func pcache1PinPage(tls *libc.TLS, pPage uintptr) uintptr {
  20324 	(*PgHdr1)(unsafe.Pointer((*PgHdr1)(unsafe.Pointer(pPage)).FpLruPrev)).FpLruNext = (*PgHdr1)(unsafe.Pointer(pPage)).FpLruNext
  20325 	(*PgHdr1)(unsafe.Pointer((*PgHdr1)(unsafe.Pointer(pPage)).FpLruNext)).FpLruPrev = (*PgHdr1)(unsafe.Pointer(pPage)).FpLruPrev
  20326 	(*PgHdr1)(unsafe.Pointer(pPage)).FpLruNext = uintptr(0)
  20327 
  20328 	(*PCache1)(unsafe.Pointer((*PgHdr1)(unsafe.Pointer(pPage)).FpCache)).FnRecyclable--
  20329 	return pPage
  20330 }
  20331 
  20332 func pcache1RemoveFromHash(tls *libc.TLS, pPage uintptr, freeFlag int32) {
  20333 	var h uint32
  20334 	var pCache uintptr = (*PgHdr1)(unsafe.Pointer(pPage)).FpCache
  20335 	var pp uintptr
  20336 
  20337 	h = (*PgHdr1)(unsafe.Pointer(pPage)).FiKey % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20338 	for pp = (*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*4; *(*uintptr)(unsafe.Pointer(pp)) != pPage; pp = *(*uintptr)(unsafe.Pointer(pp)) + 16 {
  20339 	}
  20340 	*(*uintptr)(unsafe.Pointer(pp)) = (*PgHdr1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext
  20341 
  20342 	(*PCache1)(unsafe.Pointer(pCache)).FnPage--
  20343 	if freeFlag != 0 {
  20344 		pcache1FreePage(tls, pPage)
  20345 	}
  20346 }
  20347 
  20348 func pcache1EnforceMaxPage(tls *libc.TLS, pCache uintptr) {
  20349 	var pGroup uintptr = (*PCache1)(unsafe.Pointer(pCache)).FpGroup
  20350 	var p uintptr
  20351 
  20352 	for (*PGroup)(unsafe.Pointer(pGroup)).FnPurgeable > (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage &&
  20353 		int32((*PgHdr1)(unsafe.Pointer(libc.AssignUintptr(&p, (*PGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev))).FisAnchor) == 0 {
  20354 		pcache1PinPage(tls, p)
  20355 		pcache1RemoveFromHash(tls, p, 1)
  20356 	}
  20357 	if (*PCache1)(unsafe.Pointer(pCache)).FnPage == uint32(0) && (*PCache1)(unsafe.Pointer(pCache)).FpBulk != 0 {
  20358 		Xsqlite3_free(tls, (*PCache1)(unsafe.Pointer(pCache)).FpBulk)
  20359 		(*PCache1)(unsafe.Pointer(pCache)).FpBulk = libc.AssignPtrUintptr(pCache+60, uintptr(0))
  20360 	}
  20361 }
  20362 
  20363 func pcache1TruncateUnsafe(tls *libc.TLS, pCache uintptr, iLimit uint32) {
  20364 	var h uint32
  20365 	var iStop uint32
  20366 
  20367 	if (*PCache1)(unsafe.Pointer(pCache)).FiMaxKey-iLimit < (*PCache1)(unsafe.Pointer(pCache)).FnHash {
  20368 		h = iLimit % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20369 		iStop = (*PCache1)(unsafe.Pointer(pCache)).FiMaxKey % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20370 
  20371 	} else {
  20372 		h = (*PCache1)(unsafe.Pointer(pCache)).FnHash / uint32(2)
  20373 		iStop = h - uint32(1)
  20374 	}
  20375 	for {
  20376 		var pp uintptr
  20377 		var pPage uintptr
  20378 
  20379 		pp = (*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*4
  20380 		for libc.AssignUintptr(&pPage, *(*uintptr)(unsafe.Pointer(pp))) != uintptr(0) {
  20381 			if (*PgHdr1)(unsafe.Pointer(pPage)).FiKey >= iLimit {
  20382 				(*PCache1)(unsafe.Pointer(pCache)).FnPage--
  20383 				*(*uintptr)(unsafe.Pointer(pp)) = (*PgHdr1)(unsafe.Pointer(pPage)).FpNext
  20384 				if (*PgHdr1)(unsafe.Pointer(pPage)).FpLruNext != uintptr(0) {
  20385 					pcache1PinPage(tls, pPage)
  20386 				}
  20387 				pcache1FreePage(tls, pPage)
  20388 			} else {
  20389 				pp = pPage + 16
  20390 
  20391 			}
  20392 		}
  20393 		if h == iStop {
  20394 			break
  20395 		}
  20396 		h = (h + uint32(1)) % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20397 	}
  20398 
  20399 }
  20400 
  20401 func pcache1Init(tls *libc.TLS, NotUsed uintptr) int32 {
  20402 	_ = NotUsed
  20403 
  20404 	libc.Xmemset(tls, uintptr(unsafe.Pointer(&pcache1_g)), 0, uint32(unsafe.Sizeof(pcache1_g)))
  20405 
  20406 	pcache1_g.FseparateCache = 0
  20407 
  20408 	if Xsqlite3Config.FbCoreMutex != 0 {
  20409 		pcache1_g.Fgrp.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_LRU)
  20410 		pcache1_g.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_PMEM)
  20411 	}
  20412 	if pcache1_g.FseparateCache != 0 &&
  20413 		Xsqlite3Config.FnPage != 0 &&
  20414 		Xsqlite3Config.FpPage == uintptr(0) {
  20415 		pcache1_g.FnInitPage = Xsqlite3Config.FnPage
  20416 	} else {
  20417 		pcache1_g.FnInitPage = 0
  20418 	}
  20419 	pcache1_g.Fgrp.FmxPinned = uint32(10)
  20420 	pcache1_g.FisInit = 1
  20421 	return SQLITE_OK
  20422 }
  20423 
  20424 func pcache1Shutdown(tls *libc.TLS, NotUsed uintptr) {
  20425 	_ = NotUsed
  20426 
  20427 	libc.Xmemset(tls, uintptr(unsafe.Pointer(&pcache1_g)), 0, uint32(unsafe.Sizeof(pcache1_g)))
  20428 }
  20429 
  20430 func pcache1Create(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) uintptr {
  20431 	var pCache uintptr
  20432 	var pGroup uintptr
  20433 	var sz int32
  20434 
  20435 	sz = int32(uint32(unsafe.Sizeof(PCache1{})) + uint32(unsafe.Sizeof(PGroup{}))*uint32(pcache1_g.FseparateCache))
  20436 	pCache = Xsqlite3MallocZero(tls, uint64(sz))
  20437 	if pCache != 0 {
  20438 		if pcache1_g.FseparateCache != 0 {
  20439 			pGroup = pCache + 1*68
  20440 			(*PGroup)(unsafe.Pointer(pGroup)).FmxPinned = uint32(10)
  20441 		} else {
  20442 			pGroup = uintptr(unsafe.Pointer(&pcache1_g))
  20443 		}
  20444 		Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20445 		if int32((*PGroup)(unsafe.Pointer(pGroup)).Flru.FisAnchor) == 0 {
  20446 			(*PGroup)(unsafe.Pointer(pGroup)).Flru.FisAnchor = U16(1)
  20447 			(*PGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev = libc.AssignPtrUintptr(pGroup+20+24, pGroup+20)
  20448 		}
  20449 		(*PCache1)(unsafe.Pointer(pCache)).FpGroup = pGroup
  20450 		(*PCache1)(unsafe.Pointer(pCache)).FszPage = szPage
  20451 		(*PCache1)(unsafe.Pointer(pCache)).FszExtra = szExtra
  20452 		(*PCache1)(unsafe.Pointer(pCache)).FszAlloc = int32(uint32(szPage+szExtra) + (uint32(unsafe.Sizeof(PgHdr1{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)))
  20453 		(*PCache1)(unsafe.Pointer(pCache)).FbPurgeable = func() int32 {
  20454 			if bPurgeable != 0 {
  20455 				return 1
  20456 			}
  20457 			return 0
  20458 		}()
  20459 		pcache1ResizeHash(tls, pCache)
  20460 		if bPurgeable != 0 {
  20461 			(*PCache1)(unsafe.Pointer(pCache)).FnMin = uint32(10)
  20462 			*(*uint32)(unsafe.Pointer(pGroup + 8)) += (*PCache1)(unsafe.Pointer(pCache)).FnMin
  20463 			(*PGroup)(unsafe.Pointer(pGroup)).FmxPinned = (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage + uint32(10) - (*PGroup)(unsafe.Pointer(pGroup)).FnMinPage
  20464 			(*PCache1)(unsafe.Pointer(pCache)).FpnPurgeable = pGroup + 16
  20465 		} else {
  20466 			(*PCache1)(unsafe.Pointer(pCache)).FpnPurgeable = pCache + 40
  20467 		}
  20468 		Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20469 		if (*PCache1)(unsafe.Pointer(pCache)).FnHash == uint32(0) {
  20470 			pcache1Destroy(tls, pCache)
  20471 			pCache = uintptr(0)
  20472 		}
  20473 	}
  20474 	return pCache
  20475 }
  20476 
  20477 func pcache1Cachesize(tls *libc.TLS, p uintptr, nMax int32) {
  20478 	var pCache uintptr = p
  20479 	var n U32
  20480 
  20481 	if (*PCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 {
  20482 		var pGroup uintptr = (*PCache1)(unsafe.Pointer(pCache)).FpGroup
  20483 		Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20484 		n = U32(nMax)
  20485 		if n > uint32(0x7fff0000)-(*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage+(*PCache1)(unsafe.Pointer(pCache)).FnMax {
  20486 			n = uint32(0x7fff0000) - (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage + (*PCache1)(unsafe.Pointer(pCache)).FnMax
  20487 		}
  20488 		*(*uint32)(unsafe.Pointer(pGroup + 4)) += n - (*PCache1)(unsafe.Pointer(pCache)).FnMax
  20489 		(*PGroup)(unsafe.Pointer(pGroup)).FmxPinned = (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage + uint32(10) - (*PGroup)(unsafe.Pointer(pGroup)).FnMinPage
  20490 		(*PCache1)(unsafe.Pointer(pCache)).FnMax = n
  20491 		(*PCache1)(unsafe.Pointer(pCache)).Fn90pct = (*PCache1)(unsafe.Pointer(pCache)).FnMax * uint32(9) / uint32(10)
  20492 		pcache1EnforceMaxPage(tls, pCache)
  20493 		Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20494 	}
  20495 }
  20496 
  20497 func pcache1Shrink(tls *libc.TLS, p uintptr) {
  20498 	var pCache uintptr = p
  20499 	if (*PCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 {
  20500 		var pGroup uintptr = (*PCache1)(unsafe.Pointer(pCache)).FpGroup
  20501 		var savedMaxPage uint32
  20502 		Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20503 		savedMaxPage = (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage
  20504 		(*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage = uint32(0)
  20505 		pcache1EnforceMaxPage(tls, pCache)
  20506 		(*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage = savedMaxPage
  20507 		Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20508 	}
  20509 }
  20510 
  20511 func pcache1Pagecount(tls *libc.TLS, p uintptr) int32 {
  20512 	var n int32
  20513 	var pCache uintptr = p
  20514 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20515 	n = int32((*PCache1)(unsafe.Pointer(pCache)).FnPage)
  20516 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20517 	return n
  20518 }
  20519 
  20520 func pcache1FetchStage2(tls *libc.TLS, pCache uintptr, iKey uint32, createFlag int32) uintptr {
  20521 	var nPinned uint32
  20522 	var pGroup uintptr = (*PCache1)(unsafe.Pointer(pCache)).FpGroup
  20523 	var pPage uintptr = uintptr(0)
  20524 
  20525 	nPinned = (*PCache1)(unsafe.Pointer(pCache)).FnPage - (*PCache1)(unsafe.Pointer(pCache)).FnRecyclable
  20526 
  20527 	if createFlag == 1 && (nPinned >= (*PGroup)(unsafe.Pointer(pGroup)).FmxPinned ||
  20528 		nPinned >= (*PCache1)(unsafe.Pointer(pCache)).Fn90pct ||
  20529 		pcache1UnderMemoryPressure(tls, pCache) != 0 && (*PCache1)(unsafe.Pointer(pCache)).FnRecyclable < nPinned) {
  20530 		return uintptr(0)
  20531 	}
  20532 
  20533 	if (*PCache1)(unsafe.Pointer(pCache)).FnPage >= (*PCache1)(unsafe.Pointer(pCache)).FnHash {
  20534 		pcache1ResizeHash(tls, pCache)
  20535 	}
  20536 
  20537 	if (*PCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 &&
  20538 		!(int32((*PgHdr1)(unsafe.Pointer((*PGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev)).FisAnchor) != 0) &&
  20539 		((*PCache1)(unsafe.Pointer(pCache)).FnPage+uint32(1) >= (*PCache1)(unsafe.Pointer(pCache)).FnMax || pcache1UnderMemoryPressure(tls, pCache) != 0) {
  20540 		var pOther uintptr
  20541 		pPage = (*PGroup)(unsafe.Pointer(pGroup)).Flru.FpLruPrev
  20542 
  20543 		pcache1RemoveFromHash(tls, pPage, 0)
  20544 		pcache1PinPage(tls, pPage)
  20545 		pOther = (*PgHdr1)(unsafe.Pointer(pPage)).FpCache
  20546 		if (*PCache1)(unsafe.Pointer(pOther)).FszAlloc != (*PCache1)(unsafe.Pointer(pCache)).FszAlloc {
  20547 			pcache1FreePage(tls, pPage)
  20548 			pPage = uintptr(0)
  20549 		} else {
  20550 			*(*uint32)(unsafe.Pointer(pGroup + 16)) -= uint32((*PCache1)(unsafe.Pointer(pOther)).FbPurgeable - (*PCache1)(unsafe.Pointer(pCache)).FbPurgeable)
  20551 		}
  20552 	}
  20553 
  20554 	if !(pPage != 0) {
  20555 		pPage = pcache1AllocPage(tls, pCache, libc.Bool32(createFlag == 1))
  20556 	}
  20557 
  20558 	if pPage != 0 {
  20559 		var h uint32 = iKey % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20560 		(*PCache1)(unsafe.Pointer(pCache)).FnPage++
  20561 		(*PgHdr1)(unsafe.Pointer(pPage)).FiKey = iKey
  20562 		(*PgHdr1)(unsafe.Pointer(pPage)).FpNext = *(*uintptr)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*4))
  20563 		(*PgHdr1)(unsafe.Pointer(pPage)).FpCache = pCache
  20564 		(*PgHdr1)(unsafe.Pointer(pPage)).FpLruNext = uintptr(0)
  20565 
  20566 		*(*uintptr)(unsafe.Pointer((*PgHdr1)(unsafe.Pointer(pPage)).Fpage.FpExtra)) = uintptr(0)
  20567 		*(*uintptr)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(h)*4)) = pPage
  20568 		if iKey > (*PCache1)(unsafe.Pointer(pCache)).FiMaxKey {
  20569 			(*PCache1)(unsafe.Pointer(pCache)).FiMaxKey = iKey
  20570 		}
  20571 	}
  20572 	return pPage
  20573 }
  20574 
  20575 func pcache1FetchNoMutex(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) uintptr {
  20576 	var pCache uintptr = p
  20577 	var pPage uintptr = uintptr(0)
  20578 
  20579 	pPage = *(*uintptr)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(iKey%(*PCache1)(unsafe.Pointer(pCache)).FnHash)*4))
  20580 	for pPage != 0 && (*PgHdr1)(unsafe.Pointer(pPage)).FiKey != iKey {
  20581 		pPage = (*PgHdr1)(unsafe.Pointer(pPage)).FpNext
  20582 	}
  20583 
  20584 	if pPage != 0 {
  20585 		if (*PgHdr1)(unsafe.Pointer(pPage)).FpLruNext != uintptr(0) {
  20586 			return pcache1PinPage(tls, pPage)
  20587 		} else {
  20588 			return pPage
  20589 		}
  20590 	} else if createFlag != 0 {
  20591 		return pcache1FetchStage2(tls, pCache, iKey, createFlag)
  20592 	} else {
  20593 		return uintptr(0)
  20594 	}
  20595 	return uintptr(0)
  20596 }
  20597 
  20598 func pcache1FetchWithMutex(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) uintptr {
  20599 	var pCache uintptr = p
  20600 	var pPage uintptr
  20601 
  20602 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20603 	pPage = pcache1FetchNoMutex(tls, p, iKey, createFlag)
  20604 
  20605 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20606 	return pPage
  20607 }
  20608 
  20609 func pcache1Fetch(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) uintptr {
  20610 	var pCache uintptr = p
  20611 
  20612 	if (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex != 0 {
  20613 		return pcache1FetchWithMutex(tls, p, iKey, createFlag)
  20614 	} else {
  20615 		return pcache1FetchNoMutex(tls, p, iKey, createFlag)
  20616 	}
  20617 	return uintptr(0)
  20618 }
  20619 
  20620 func pcache1Unpin(tls *libc.TLS, p uintptr, pPg uintptr, reuseUnlikely int32) {
  20621 	var pCache uintptr = p
  20622 	var pPage uintptr = pPg
  20623 	var pGroup uintptr = (*PCache1)(unsafe.Pointer(pCache)).FpGroup
  20624 
  20625 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20626 
  20627 	if reuseUnlikely != 0 || (*PGroup)(unsafe.Pointer(pGroup)).FnPurgeable > (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage {
  20628 		pcache1RemoveFromHash(tls, pPage, 1)
  20629 	} else {
  20630 		var ppFirst uintptr = pGroup + 20 + 24
  20631 		(*PgHdr1)(unsafe.Pointer(pPage)).FpLruPrev = pGroup + 20
  20632 		(*PgHdr1)(unsafe.Pointer(libc.AssignPtrUintptr(pPage+24, *(*uintptr)(unsafe.Pointer(ppFirst))))).FpLruPrev = pPage
  20633 		*(*uintptr)(unsafe.Pointer(ppFirst)) = pPage
  20634 		(*PCache1)(unsafe.Pointer(pCache)).FnRecyclable++
  20635 	}
  20636 
  20637 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20638 }
  20639 
  20640 func pcache1Rekey(tls *libc.TLS, p uintptr, pPg uintptr, iOld uint32, iNew uint32) {
  20641 	var pCache uintptr = p
  20642 	var pPage uintptr = pPg
  20643 	var pp uintptr
  20644 	var hOld uint32
  20645 	var hNew uint32
  20646 
  20647 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20648 
  20649 	hOld = iOld % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20650 	pp = (*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(hOld)*4
  20651 	for *(*uintptr)(unsafe.Pointer(pp)) != pPage {
  20652 		pp = *(*uintptr)(unsafe.Pointer(pp)) + 16
  20653 	}
  20654 	*(*uintptr)(unsafe.Pointer(pp)) = (*PgHdr1)(unsafe.Pointer(pPage)).FpNext
  20655 
  20656 	hNew = iNew % (*PCache1)(unsafe.Pointer(pCache)).FnHash
  20657 	(*PgHdr1)(unsafe.Pointer(pPage)).FiKey = iNew
  20658 	(*PgHdr1)(unsafe.Pointer(pPage)).FpNext = *(*uintptr)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(hNew)*4))
  20659 	*(*uintptr)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FapHash + uintptr(hNew)*4)) = pPage
  20660 	if iNew > (*PCache1)(unsafe.Pointer(pCache)).FiMaxKey {
  20661 		(*PCache1)(unsafe.Pointer(pCache)).FiMaxKey = iNew
  20662 	}
  20663 
  20664 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20665 }
  20666 
  20667 func pcache1Truncate(tls *libc.TLS, p uintptr, iLimit uint32) {
  20668 	var pCache uintptr = p
  20669 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20670 	if iLimit <= (*PCache1)(unsafe.Pointer(pCache)).FiMaxKey {
  20671 		pcache1TruncateUnsafe(tls, pCache, iLimit)
  20672 		(*PCache1)(unsafe.Pointer(pCache)).FiMaxKey = iLimit - uint32(1)
  20673 	}
  20674 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer((*PCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
  20675 }
  20676 
  20677 func pcache1Destroy(tls *libc.TLS, p uintptr) {
  20678 	var pCache uintptr = p
  20679 	var pGroup uintptr = (*PCache1)(unsafe.Pointer(pCache)).FpGroup
  20680 
  20681 	Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20682 	if (*PCache1)(unsafe.Pointer(pCache)).FnPage != 0 {
  20683 		pcache1TruncateUnsafe(tls, pCache, uint32(0))
  20684 	}
  20685 
  20686 	*(*uint32)(unsafe.Pointer(pGroup + 4)) -= (*PCache1)(unsafe.Pointer(pCache)).FnMax
  20687 
  20688 	*(*uint32)(unsafe.Pointer(pGroup + 8)) -= (*PCache1)(unsafe.Pointer(pCache)).FnMin
  20689 	(*PGroup)(unsafe.Pointer(pGroup)).FmxPinned = (*PGroup)(unsafe.Pointer(pGroup)).FnMaxPage + uint32(10) - (*PGroup)(unsafe.Pointer(pGroup)).FnMinPage
  20690 	pcache1EnforceMaxPage(tls, pCache)
  20691 	Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer(pGroup)).Fmutex)
  20692 	Xsqlite3_free(tls, (*PCache1)(unsafe.Pointer(pCache)).FpBulk)
  20693 	Xsqlite3_free(tls, (*PCache1)(unsafe.Pointer(pCache)).FapHash)
  20694 	Xsqlite3_free(tls, pCache)
  20695 }
  20696 
  20697 // This function is called during initialization (sqlite3_initialize()) to
  20698 // install the default pluggable cache module, assuming the user has not
  20699 // already provided an alternative.
  20700 func Xsqlite3PCacheSetDefault(tls *libc.TLS) {
  20701 	bp := tls.Alloc(8)
  20702 	defer tls.Free(8)
  20703 
  20704 	Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods1))))
  20705 }
  20706 
  20707 var defaultMethods1 = Sqlite3_pcache_methods2{
  20708 	FiVersion:   1,
  20709 	FxInit:      0,
  20710 	FxShutdown:  0,
  20711 	FxCreate:    0,
  20712 	FxCachesize: 0,
  20713 	FxPagecount: 0,
  20714 	FxFetch:     0,
  20715 	FxUnpin:     0,
  20716 	FxRekey:     0,
  20717 	FxTruncate:  0,
  20718 	FxDestroy:   0,
  20719 	FxShrink:    0,
  20720 }
  20721 
  20722 // Return the size of the header on each page of this PCACHE implementation.
  20723 func Xsqlite3HeaderSizePcache1(tls *libc.TLS) int32 {
  20724 	return int32((uint32(unsafe.Sizeof(PgHdr1{})) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  20725 }
  20726 
  20727 // Return the global mutex used by this PCACHE implementation.  The
  20728 // sqlite3_status() routine needs access to this mutex.
  20729 func Xsqlite3Pcache1Mutex(tls *libc.TLS) uintptr {
  20730 	return pcache1_g.Fmutex
  20731 }
  20732 
  20733 // This function is called to free superfluous dynamically allocated memory
  20734 // held by the pager system. Memory in use by any SQLite pager allocated
  20735 // by the current thread may be sqlite3_free()ed.
  20736 //
  20737 // nReq is the number of bytes of memory required. Once this much has
  20738 // been released, the function returns. The return value is the total number
  20739 // of bytes of memory released.
  20740 func Xsqlite3PcacheReleaseMemory(tls *libc.TLS, nReq int32) int32 {
  20741 	var nFree int32 = 0
  20742 
  20743 	if Xsqlite3Config.FpPage == uintptr(0) {
  20744 		var p uintptr
  20745 		Xsqlite3_mutex_enter(tls, (*PGroup)(unsafe.Pointer(uintptr(unsafe.Pointer(&pcache1_g)))).Fmutex)
  20746 		for (nReq < 0 || nFree < nReq) &&
  20747 			libc.AssignUintptr(&p, pcache1_g.Fgrp.Flru.FpLruPrev) != uintptr(0) &&
  20748 			int32((*PgHdr1)(unsafe.Pointer(p)).FisAnchor) == 0 {
  20749 			nFree = nFree + pcache1MemSize(tls, (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf)
  20750 
  20751 			pcache1PinPage(tls, p)
  20752 			pcache1RemoveFromHash(tls, p, 1)
  20753 		}
  20754 		Xsqlite3_mutex_leave(tls, (*PGroup)(unsafe.Pointer(uintptr(unsafe.Pointer(&pcache1_g)))).Fmutex)
  20755 	}
  20756 	return nFree
  20757 }
  20758 
  20759 // Each entry in a RowSet is an instance of the following object.
  20760 //
  20761 // This same object is reused to store a linked list of trees of RowSetEntry
  20762 // objects.  In that alternative use, pRight points to the next entry
  20763 // in the list, pLeft points to the tree, and v is unused.  The
  20764 // RowSet.pForest value points to the head of this forest list.
  20765 type RowSetEntry = struct {
  20766 	Fv      I64
  20767 	FpRight uintptr
  20768 	FpLeft  uintptr
  20769 }
  20770 
  20771 // RowSetEntry objects are allocated in large chunks (instances of the
  20772 // following structure) to reduce memory allocation overhead.  The
  20773 // chunks are kept on a linked list so that they can be deallocated
  20774 // when the RowSet is destroyed.
  20775 type RowSetChunk = struct {
  20776 	FpNextChunk  uintptr
  20777 	F__ccgo_pad1 [4]byte
  20778 	FaEntry      [63]struct {
  20779 		Fv      I64
  20780 		FpRight uintptr
  20781 		FpLeft  uintptr
  20782 	}
  20783 }
  20784 
  20785 // Allocate a RowSet object.  Return NULL if a memory allocation
  20786 // error occurs.
  20787 func Xsqlite3RowSetInit(tls *libc.TLS, db uintptr) uintptr {
  20788 	var p uintptr = Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(RowSet{})))
  20789 	if p != 0 {
  20790 		var N int32 = Xsqlite3DbMallocSize(tls, db, p)
  20791 		(*RowSet)(unsafe.Pointer(p)).FpChunk = uintptr(0)
  20792 		(*RowSet)(unsafe.Pointer(p)).Fdb = db
  20793 		(*RowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0)
  20794 		(*RowSet)(unsafe.Pointer(p)).FpLast = uintptr(0)
  20795 		(*RowSet)(unsafe.Pointer(p)).FpForest = uintptr(0)
  20796 		(*RowSet)(unsafe.Pointer(p)).FpFresh = uintptr((uint32(unsafe.Sizeof(RowSet{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7))) + p
  20797 		(*RowSet)(unsafe.Pointer(p)).FnFresh = U16((uint32(N) - (uint32(unsafe.Sizeof(RowSet{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7))) / uint32(unsafe.Sizeof(RowSetEntry{})))
  20798 		(*RowSet)(unsafe.Pointer(p)).FrsFlags = U16(ROWSET_SORTED)
  20799 		(*RowSet)(unsafe.Pointer(p)).FiBatch = 0
  20800 	}
  20801 	return p
  20802 }
  20803 
  20804 // Deallocate all chunks from a RowSet.  This frees all memory that
  20805 // the RowSet has allocated over its lifetime.  This routine is
  20806 // the destructor for the RowSet.
  20807 func Xsqlite3RowSetClear(tls *libc.TLS, pArg uintptr) {
  20808 	var p uintptr = pArg
  20809 	var pChunk uintptr
  20810 	var pNextChunk uintptr
  20811 	for pChunk = (*RowSet)(unsafe.Pointer(p)).FpChunk; pChunk != 0; pChunk = pNextChunk {
  20812 		pNextChunk = (*RowSetChunk)(unsafe.Pointer(pChunk)).FpNextChunk
  20813 		Xsqlite3DbFree(tls, (*RowSet)(unsafe.Pointer(p)).Fdb, pChunk)
  20814 	}
  20815 	(*RowSet)(unsafe.Pointer(p)).FpChunk = uintptr(0)
  20816 	(*RowSet)(unsafe.Pointer(p)).FnFresh = U16(0)
  20817 	(*RowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0)
  20818 	(*RowSet)(unsafe.Pointer(p)).FpLast = uintptr(0)
  20819 	(*RowSet)(unsafe.Pointer(p)).FpForest = uintptr(0)
  20820 	(*RowSet)(unsafe.Pointer(p)).FrsFlags = U16(ROWSET_SORTED)
  20821 }
  20822 
  20823 // Deallocate all chunks from a RowSet.  This frees all memory that
  20824 // the RowSet has allocated over its lifetime.  This routine is
  20825 // the destructor for the RowSet.
  20826 func Xsqlite3RowSetDelete(tls *libc.TLS, pArg uintptr) {
  20827 	Xsqlite3RowSetClear(tls, pArg)
  20828 	Xsqlite3DbFree(tls, (*RowSet)(unsafe.Pointer(pArg)).Fdb, pArg)
  20829 }
  20830 
  20831 func rowSetEntryAlloc(tls *libc.TLS, p uintptr) uintptr {
  20832 	if int32((*RowSet)(unsafe.Pointer(p)).FnFresh) == 0 {
  20833 		var pNew uintptr
  20834 		pNew = Xsqlite3DbMallocRawNN(tls, (*RowSet)(unsafe.Pointer(p)).Fdb, uint64(unsafe.Sizeof(RowSetChunk{})))
  20835 		if pNew == uintptr(0) {
  20836 			return uintptr(0)
  20837 		}
  20838 		(*RowSetChunk)(unsafe.Pointer(pNew)).FpNextChunk = (*RowSet)(unsafe.Pointer(p)).FpChunk
  20839 		(*RowSet)(unsafe.Pointer(p)).FpChunk = pNew
  20840 		(*RowSet)(unsafe.Pointer(p)).FpFresh = pNew + 8
  20841 		(*RowSet)(unsafe.Pointer(p)).FnFresh = uint16(uint32(ROWSET_ALLOCATION_SIZE-8) / uint32(unsafe.Sizeof(RowSetEntry{})))
  20842 	}
  20843 	(*RowSet)(unsafe.Pointer(p)).FnFresh--
  20844 	return libc.PostIncUintptr(&(*RowSet)(unsafe.Pointer(p)).FpFresh, 16)
  20845 }
  20846 
  20847 // Insert a new value into a RowSet.
  20848 //
  20849 // The mallocFailed flag of the database connection is set if a
  20850 // memory allocation fails.
  20851 func Xsqlite3RowSetInsert(tls *libc.TLS, p uintptr, rowid I64) {
  20852 	var pEntry uintptr
  20853 	var pLast uintptr
  20854 
  20855 	pEntry = rowSetEntryAlloc(tls, p)
  20856 	if pEntry == uintptr(0) {
  20857 		return
  20858 	}
  20859 	(*RowSetEntry)(unsafe.Pointer(pEntry)).Fv = rowid
  20860 	(*RowSetEntry)(unsafe.Pointer(pEntry)).FpRight = uintptr(0)
  20861 	pLast = (*RowSet)(unsafe.Pointer(p)).FpLast
  20862 	if pLast != 0 {
  20863 		if rowid <= (*RowSetEntry)(unsafe.Pointer(pLast)).Fv {
  20864 			*(*U16)(unsafe.Pointer(p + 26)) &= libc.Uint16FromInt32(libc.CplInt32(ROWSET_SORTED))
  20865 		}
  20866 		(*RowSetEntry)(unsafe.Pointer(pLast)).FpRight = pEntry
  20867 	} else {
  20868 		(*RowSet)(unsafe.Pointer(p)).FpEntry = pEntry
  20869 	}
  20870 	(*RowSet)(unsafe.Pointer(p)).FpLast = pEntry
  20871 }
  20872 
  20873 func rowSetEntryMerge(tls *libc.TLS, pA uintptr, pB uintptr) uintptr {
  20874 	bp := tls.Alloc(16)
  20875 	defer tls.Free(16)
  20876 
  20877 	var pTail uintptr
  20878 
  20879 	pTail = bp
  20880 
  20881 	for {
  20882 		if (*RowSetEntry)(unsafe.Pointer(pA)).Fv <= (*RowSetEntry)(unsafe.Pointer(pB)).Fv {
  20883 			if (*RowSetEntry)(unsafe.Pointer(pA)).Fv < (*RowSetEntry)(unsafe.Pointer(pB)).Fv {
  20884 				pTail = libc.AssignPtrUintptr(pTail+8, pA)
  20885 			}
  20886 			pA = (*RowSetEntry)(unsafe.Pointer(pA)).FpRight
  20887 			if pA == uintptr(0) {
  20888 				(*RowSetEntry)(unsafe.Pointer(pTail)).FpRight = pB
  20889 				break
  20890 			}
  20891 		} else {
  20892 			pTail = libc.AssignPtrUintptr(pTail+8, pB)
  20893 			pB = (*RowSetEntry)(unsafe.Pointer(pB)).FpRight
  20894 			if pB == uintptr(0) {
  20895 				(*RowSetEntry)(unsafe.Pointer(pTail)).FpRight = pA
  20896 				break
  20897 			}
  20898 		}
  20899 	}
  20900 	return (*RowSetEntry)(unsafe.Pointer(bp)).FpRight
  20901 }
  20902 
  20903 func rowSetEntrySort(tls *libc.TLS, pIn uintptr) uintptr {
  20904 	bp := tls.Alloc(160)
  20905 	defer tls.Free(160)
  20906 
  20907 	var i uint32
  20908 	var pNext uintptr
  20909 
  20910 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([40]uintptr{})))
  20911 	for pIn != 0 {
  20912 		pNext = (*RowSetEntry)(unsafe.Pointer(pIn)).FpRight
  20913 		(*RowSetEntry)(unsafe.Pointer(pIn)).FpRight = uintptr(0)
  20914 		for i = uint32(0); *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) != 0; i++ {
  20915 			pIn = rowSetEntryMerge(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)), pIn)
  20916 			*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = uintptr(0)
  20917 		}
  20918 		*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = pIn
  20919 		pIn = pNext
  20920 	}
  20921 	pIn = *(*uintptr)(unsafe.Pointer(bp))
  20922 	for i = uint32(1); i < uint32(unsafe.Sizeof([40]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0))); i++ {
  20923 		if *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) == uintptr(0) {
  20924 			continue
  20925 		}
  20926 		if pIn != 0 {
  20927 			pIn = rowSetEntryMerge(tls, pIn, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)))
  20928 		} else {
  20929 			pIn = *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4))
  20930 		}
  20931 	}
  20932 	return pIn
  20933 }
  20934 
  20935 func rowSetTreeToList(tls *libc.TLS, pIn uintptr, ppFirst uintptr, ppLast uintptr) {
  20936 	bp := tls.Alloc(4)
  20937 	defer tls.Free(4)
  20938 
  20939 	if (*RowSetEntry)(unsafe.Pointer(pIn)).FpLeft != 0 {
  20940 		rowSetTreeToList(tls, (*RowSetEntry)(unsafe.Pointer(pIn)).FpLeft, ppFirst, bp)
  20941 		(*RowSetEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpRight = pIn
  20942 	} else {
  20943 		*(*uintptr)(unsafe.Pointer(ppFirst)) = pIn
  20944 	}
  20945 	if (*RowSetEntry)(unsafe.Pointer(pIn)).FpRight != 0 {
  20946 		rowSetTreeToList(tls, (*RowSetEntry)(unsafe.Pointer(pIn)).FpRight, pIn+8, ppLast)
  20947 	} else {
  20948 		*(*uintptr)(unsafe.Pointer(ppLast)) = pIn
  20949 	}
  20950 
  20951 }
  20952 
  20953 func rowSetNDeepTree(tls *libc.TLS, ppList uintptr, iDepth int32) uintptr {
  20954 	var p uintptr
  20955 	var pLeft uintptr
  20956 	if *(*uintptr)(unsafe.Pointer(ppList)) == uintptr(0) {
  20957 		return uintptr(0)
  20958 	}
  20959 	if iDepth > 1 {
  20960 		pLeft = rowSetNDeepTree(tls, ppList, iDepth-1)
  20961 		p = *(*uintptr)(unsafe.Pointer(ppList))
  20962 		if p == uintptr(0) {
  20963 			return pLeft
  20964 		}
  20965 		(*RowSetEntry)(unsafe.Pointer(p)).FpLeft = pLeft
  20966 		*(*uintptr)(unsafe.Pointer(ppList)) = (*RowSetEntry)(unsafe.Pointer(p)).FpRight
  20967 		(*RowSetEntry)(unsafe.Pointer(p)).FpRight = rowSetNDeepTree(tls, ppList, iDepth-1)
  20968 	} else {
  20969 		p = *(*uintptr)(unsafe.Pointer(ppList))
  20970 		*(*uintptr)(unsafe.Pointer(ppList)) = (*RowSetEntry)(unsafe.Pointer(p)).FpRight
  20971 		(*RowSetEntry)(unsafe.Pointer(p)).FpLeft = libc.AssignPtrUintptr(p+8, uintptr(0))
  20972 	}
  20973 	return p
  20974 }
  20975 
  20976 func rowSetListToTree(tls *libc.TLS, pList uintptr) uintptr {
  20977 	bp := tls.Alloc(4)
  20978 	defer tls.Free(4)
  20979 	*(*uintptr)(unsafe.Pointer(bp)) = pList
  20980 
  20981 	var iDepth int32
  20982 	var p uintptr
  20983 	var pLeft uintptr
  20984 
  20985 	p = *(*uintptr)(unsafe.Pointer(bp))
  20986 	*(*uintptr)(unsafe.Pointer(bp)) = (*RowSetEntry)(unsafe.Pointer(p)).FpRight
  20987 	(*RowSetEntry)(unsafe.Pointer(p)).FpLeft = libc.AssignPtrUintptr(p+8, uintptr(0))
  20988 	for iDepth = 1; *(*uintptr)(unsafe.Pointer(bp)) != 0; iDepth++ {
  20989 		pLeft = p
  20990 		p = *(*uintptr)(unsafe.Pointer(bp))
  20991 		*(*uintptr)(unsafe.Pointer(bp)) = (*RowSetEntry)(unsafe.Pointer(p)).FpRight
  20992 		(*RowSetEntry)(unsafe.Pointer(p)).FpLeft = pLeft
  20993 		(*RowSetEntry)(unsafe.Pointer(p)).FpRight = rowSetNDeepTree(tls, bp, iDepth)
  20994 	}
  20995 	return p
  20996 }
  20997 
  20998 // Extract the smallest element from the RowSet.
  20999 // Write the element into *pRowid.  Return 1 on success.  Return
  21000 // 0 if the RowSet is already empty.
  21001 //
  21002 // After this routine has been called, the sqlite3RowSetInsert()
  21003 // routine may not be called again.
  21004 //
  21005 // This routine may not be called after sqlite3RowSetTest() has
  21006 // been used.  Older versions of RowSet allowed that, but as the
  21007 // capability was not used by the code generator, it was removed
  21008 // for code economy.
  21009 func Xsqlite3RowSetNext(tls *libc.TLS, p uintptr, pRowid uintptr) int32 {
  21010 	if int32((*RowSet)(unsafe.Pointer(p)).FrsFlags)&ROWSET_NEXT == 0 {
  21011 		if int32((*RowSet)(unsafe.Pointer(p)).FrsFlags)&ROWSET_SORTED == 0 {
  21012 			(*RowSet)(unsafe.Pointer(p)).FpEntry = rowSetEntrySort(tls, (*RowSet)(unsafe.Pointer(p)).FpEntry)
  21013 		}
  21014 		*(*U16)(unsafe.Pointer(p + 26)) |= U16(ROWSET_SORTED | ROWSET_NEXT)
  21015 	}
  21016 
  21017 	if (*RowSet)(unsafe.Pointer(p)).FpEntry != 0 {
  21018 		*(*I64)(unsafe.Pointer(pRowid)) = (*RowSetEntry)(unsafe.Pointer((*RowSet)(unsafe.Pointer(p)).FpEntry)).Fv
  21019 		(*RowSet)(unsafe.Pointer(p)).FpEntry = (*RowSetEntry)(unsafe.Pointer((*RowSet)(unsafe.Pointer(p)).FpEntry)).FpRight
  21020 		if (*RowSet)(unsafe.Pointer(p)).FpEntry == uintptr(0) {
  21021 			Xsqlite3RowSetClear(tls, p)
  21022 		}
  21023 		return 1
  21024 	} else {
  21025 		return 0
  21026 	}
  21027 	return int32(0)
  21028 }
  21029 
  21030 // Check to see if element iRowid was inserted into the rowset as
  21031 // part of any insert batch prior to iBatch.  Return 1 or 0.
  21032 //
  21033 // If this is the first test of a new batch and if there exist entries
  21034 // on pRowSet->pEntry, then sort those entries into the forest at
  21035 // pRowSet->pForest so that they can be tested.
  21036 func Xsqlite3RowSetTest(tls *libc.TLS, pRowSet uintptr, iBatch int32, iRowid Sqlite3_int64) int32 {
  21037 	bp := tls.Alloc(8)
  21038 	defer tls.Free(8)
  21039 
  21040 	var p uintptr
  21041 	var pTree uintptr
  21042 
  21043 	if iBatch != (*RowSet)(unsafe.Pointer(pRowSet)).FiBatch {
  21044 		p = (*RowSet)(unsafe.Pointer(pRowSet)).FpEntry
  21045 		if p != 0 {
  21046 			var ppPrevTree uintptr = pRowSet + 20
  21047 			if int32((*RowSet)(unsafe.Pointer(pRowSet)).FrsFlags)&ROWSET_SORTED == 0 {
  21048 				p = rowSetEntrySort(tls, p)
  21049 			}
  21050 			for pTree = (*RowSet)(unsafe.Pointer(pRowSet)).FpForest; pTree != 0; pTree = (*RowSetEntry)(unsafe.Pointer(pTree)).FpRight {
  21051 				ppPrevTree = pTree + 8
  21052 				if (*RowSetEntry)(unsafe.Pointer(pTree)).FpLeft == uintptr(0) {
  21053 					(*RowSetEntry)(unsafe.Pointer(pTree)).FpLeft = rowSetListToTree(tls, p)
  21054 					break
  21055 				} else {
  21056 					rowSetTreeToList(tls, (*RowSetEntry)(unsafe.Pointer(pTree)).FpLeft, bp, bp+4)
  21057 					(*RowSetEntry)(unsafe.Pointer(pTree)).FpLeft = uintptr(0)
  21058 					p = rowSetEntryMerge(tls, *(*uintptr)(unsafe.Pointer(bp)), p)
  21059 				}
  21060 			}
  21061 			if pTree == uintptr(0) {
  21062 				*(*uintptr)(unsafe.Pointer(ppPrevTree)) = libc.AssignUintptr(&pTree, rowSetEntryAlloc(tls, pRowSet))
  21063 				if pTree != 0 {
  21064 					(*RowSetEntry)(unsafe.Pointer(pTree)).Fv = int64(0)
  21065 					(*RowSetEntry)(unsafe.Pointer(pTree)).FpRight = uintptr(0)
  21066 					(*RowSetEntry)(unsafe.Pointer(pTree)).FpLeft = rowSetListToTree(tls, p)
  21067 				}
  21068 			}
  21069 			(*RowSet)(unsafe.Pointer(pRowSet)).FpEntry = uintptr(0)
  21070 			(*RowSet)(unsafe.Pointer(pRowSet)).FpLast = uintptr(0)
  21071 			*(*U16)(unsafe.Pointer(pRowSet + 26)) |= U16(ROWSET_SORTED)
  21072 		}
  21073 		(*RowSet)(unsafe.Pointer(pRowSet)).FiBatch = iBatch
  21074 	}
  21075 
  21076 	for pTree = (*RowSet)(unsafe.Pointer(pRowSet)).FpForest; pTree != 0; pTree = (*RowSetEntry)(unsafe.Pointer(pTree)).FpRight {
  21077 		p = (*RowSetEntry)(unsafe.Pointer(pTree)).FpLeft
  21078 		for p != 0 {
  21079 			if (*RowSetEntry)(unsafe.Pointer(p)).Fv < iRowid {
  21080 				p = (*RowSetEntry)(unsafe.Pointer(p)).FpRight
  21081 			} else if (*RowSetEntry)(unsafe.Pointer(p)).Fv > iRowid {
  21082 				p = (*RowSetEntry)(unsafe.Pointer(p)).FpLeft
  21083 			} else {
  21084 				return 1
  21085 			}
  21086 		}
  21087 	}
  21088 	return 0
  21089 }
  21090 
  21091 // Connection to a write-ahead log (WAL) file.
  21092 // There is one object of this type for each pager.
  21093 type Wal1 = struct {
  21094 	FpVfs                uintptr
  21095 	FpDbFd               uintptr
  21096 	FpWalFd              uintptr
  21097 	FiCallback           U32
  21098 	FmxWalSize           I64
  21099 	FnWiData             int32
  21100 	FszFirstBlock        int32
  21101 	FapWiData            uintptr
  21102 	FszPage              U32
  21103 	FreadLock            I16
  21104 	FsyncFlags           U8
  21105 	FexclusiveMode       U8
  21106 	FwriteLock           U8
  21107 	FckptLock            U8
  21108 	FreadOnly            U8
  21109 	FtruncateOnCommit    U8
  21110 	FsyncHeader          U8
  21111 	FpadToSectorBoundary U8
  21112 	FbShmUnreliable      U8
  21113 	F__ccgo_pad1         [1]byte
  21114 	Fhdr                 WalIndexHdr
  21115 	FminFrame            U32
  21116 	FiReCksum            U32
  21117 	FzWalName            uintptr
  21118 	FnCkpt               U32
  21119 	FpSnapshot           uintptr
  21120 }
  21121 
  21122 // Connection to a write-ahead log (WAL) file.
  21123 // There is one object of this type for each pager.
  21124 type Wal = Wal1
  21125 
  21126 // An instance of the following structure is allocated for each active
  21127 // savepoint and statement transaction in the system. All such structures
  21128 // are stored in the Pager.aSavepoint[] array, which is allocated and
  21129 // resized using sqlite3Realloc().
  21130 //
  21131 // When a savepoint is created, the PagerSavepoint.iHdrOffset field is
  21132 // set to 0. If a journal-header is written into the main journal while
  21133 // the savepoint is active, then iHdrOffset is set to the byte offset
  21134 // immediately following the last journal record written into the main
  21135 // journal before the journal-header. This is required during savepoint
  21136 // rollback (see pagerPlaybackSavepoint()).
  21137 type PagerSavepoint1 = struct {
  21138 	FiOffset            I64
  21139 	FiHdrOffset         I64
  21140 	FpInSavepoint       uintptr
  21141 	FnOrig              Pgno
  21142 	FiSubRec            Pgno
  21143 	FbTruncateOnRelease int32
  21144 	FaWalData           [4]U32
  21145 }
  21146 
  21147 // An instance of the following structure is allocated for each active
  21148 // savepoint and statement transaction in the system. All such structures
  21149 // are stored in the Pager.aSavepoint[] array, which is allocated and
  21150 // resized using sqlite3Realloc().
  21151 //
  21152 // When a savepoint is created, the PagerSavepoint.iHdrOffset field is
  21153 // set to 0. If a journal-header is written into the main journal while
  21154 // the savepoint is active, then iHdrOffset is set to the byte offset
  21155 // immediately following the last journal record written into the main
  21156 // journal before the journal-header. This is required during savepoint
  21157 // rollback (see pagerPlaybackSavepoint()).
  21158 type PagerSavepoint = PagerSavepoint1
  21159 
  21160 var aJournalMagic = [8]uint8{
  21161 	uint8(0xd9), uint8(0xd5), uint8(0x05), uint8(0xf9), uint8(0x20), uint8(0xa1), uint8(0x63), uint8(0xd7),
  21162 }
  21163 
  21164 func setGetterMethod(tls *libc.TLS, pPager uintptr) {
  21165 	if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  21166 		(*Pager)(unsafe.Pointer(pPager)).FxGet = *(*uintptr)(unsafe.Pointer(&struct {
  21167 			f func(*libc.TLS, uintptr, Pgno, uintptr, int32) int32
  21168 		}{getPageError}))
  21169 	} else if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 {
  21170 		(*Pager)(unsafe.Pointer(pPager)).FxGet = *(*uintptr)(unsafe.Pointer(&struct {
  21171 			f func(*libc.TLS, uintptr, Pgno, uintptr, int32) int32
  21172 		}{getPageMMap}))
  21173 	} else {
  21174 		(*Pager)(unsafe.Pointer(pPager)).FxGet = *(*uintptr)(unsafe.Pointer(&struct {
  21175 			f func(*libc.TLS, uintptr, Pgno, uintptr, int32) int32
  21176 		}{getPageNormal}))
  21177 	}
  21178 }
  21179 
  21180 func subjRequiresPage(tls *libc.TLS, pPg uintptr) int32 {
  21181 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  21182 	var p uintptr
  21183 	var pgno Pgno = (*PgHdr)(unsafe.Pointer(pPg)).Fpgno
  21184 	var i int32
  21185 	for i = 0; i < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; i++ {
  21186 		p = (*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(i)*48
  21187 		if (*PagerSavepoint)(unsafe.Pointer(p)).FnOrig >= pgno && 0 == Xsqlite3BitvecTestNotNull(tls, (*PagerSavepoint)(unsafe.Pointer(p)).FpInSavepoint, pgno) {
  21188 			for i = i + 1; i < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; i++ {
  21189 				(*PagerSavepoint)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(i)*48)).FbTruncateOnRelease = 0
  21190 			}
  21191 			return 1
  21192 		}
  21193 	}
  21194 	return 0
  21195 }
  21196 
  21197 func read32bits(tls *libc.TLS, fd uintptr, offset I64, pRes uintptr) int32 {
  21198 	bp := tls.Alloc(4)
  21199 	defer tls.Free(4)
  21200 
  21201 	var rc int32 = Xsqlite3OsRead(tls, fd, bp, int32(unsafe.Sizeof([4]uint8{})), offset)
  21202 	if rc == SQLITE_OK {
  21203 		*(*U32)(unsafe.Pointer(pRes)) = Xsqlite3Get4byte(tls, bp)
  21204 	}
  21205 	return rc
  21206 }
  21207 
  21208 func write32bits(tls *libc.TLS, fd uintptr, offset I64, val U32) int32 {
  21209 	bp := tls.Alloc(4)
  21210 	defer tls.Free(4)
  21211 
  21212 	Xsqlite3Put4byte(tls, bp, val)
  21213 	return Xsqlite3OsWrite(tls, fd, bp, 4, offset)
  21214 }
  21215 
  21216 func pagerUnlockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 {
  21217 	var rc int32 = SQLITE_OK
  21218 
  21219 	if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) {
  21220 		if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 {
  21221 			rc = SQLITE_OK
  21222 		} else {
  21223 			rc = Xsqlite3OsUnlock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, eLock)
  21224 		}
  21225 		if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != EXCLUSIVE_LOCK+1 {
  21226 			(*Pager)(unsafe.Pointer(pPager)).FeLock = U8(eLock)
  21227 		}
  21228 
  21229 	}
  21230 	(*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = (*Pager)(unsafe.Pointer(pPager)).FtempFile
  21231 	return rc
  21232 }
  21233 
  21234 func pagerLockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 {
  21235 	var rc int32 = SQLITE_OK
  21236 
  21237 	if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < eLock || int32((*Pager)(unsafe.Pointer(pPager)).FeLock) == EXCLUSIVE_LOCK+1 {
  21238 		if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 {
  21239 			rc = SQLITE_OK
  21240 		} else {
  21241 			rc = Xsqlite3OsLock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, eLock)
  21242 		}
  21243 		if rc == SQLITE_OK && (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != EXCLUSIVE_LOCK+1 || eLock == EXCLUSIVE_LOCK) {
  21244 			(*Pager)(unsafe.Pointer(pPager)).FeLock = U8(eLock)
  21245 
  21246 		}
  21247 	}
  21248 	return rc
  21249 }
  21250 
  21251 func jrnlBufferSize(tls *libc.TLS, pPager uintptr) int32 {
  21252 	_ = pPager
  21253 
  21254 	return 0
  21255 }
  21256 
  21257 func readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper U32) int32 {
  21258 	bp := tls.Alloc(24)
  21259 	defer tls.Free(24)
  21260 
  21261 	var rc int32
  21262 
  21263 	var u U32
  21264 
  21265 	*(*uint8)(unsafe.Pointer(zSuper)) = uint8(0)
  21266 
  21267 	if SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, pJrnl, bp)) ||
  21268 		*(*I64)(unsafe.Pointer(bp)) < int64(16) ||
  21269 		SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, pJrnl, *(*I64)(unsafe.Pointer(bp))-int64(16), bp+8)) ||
  21270 		*(*U32)(unsafe.Pointer(bp + 8)) >= nSuper ||
  21271 		I64(*(*U32)(unsafe.Pointer(bp + 8))) > *(*I64)(unsafe.Pointer(bp))-int64(16) ||
  21272 		*(*U32)(unsafe.Pointer(bp + 8)) == U32(0) ||
  21273 		SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, pJrnl, *(*I64)(unsafe.Pointer(bp))-int64(12), bp+12)) ||
  21274 		SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, bp+16, 8, *(*I64)(unsafe.Pointer(bp))-int64(8))) ||
  21275 		libc.Xmemcmp(tls, bp+16, uintptr(unsafe.Pointer(&aJournalMagic)), uint32(8)) != 0 ||
  21276 		SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, zSuper, int32(*(*U32)(unsafe.Pointer(bp + 8))), *(*I64)(unsafe.Pointer(bp))-int64(16)-I64(*(*U32)(unsafe.Pointer(bp + 8))))) {
  21277 		return rc
  21278 	}
  21279 
  21280 	for u = U32(0); u < *(*U32)(unsafe.Pointer(bp + 8)); u++ {
  21281 		*(*U32)(unsafe.Pointer(bp + 12)) -= U32(*(*uint8)(unsafe.Pointer(zSuper + uintptr(u))))
  21282 	}
  21283 	if *(*U32)(unsafe.Pointer(bp + 12)) != 0 {
  21284 		*(*U32)(unsafe.Pointer(bp + 8)) = U32(0)
  21285 	}
  21286 	*(*uint8)(unsafe.Pointer(zSuper + uintptr(*(*U32)(unsafe.Pointer(bp + 8))))) = uint8(0)
  21287 	*(*uint8)(unsafe.Pointer(zSuper + uintptr(*(*U32)(unsafe.Pointer(bp + 8))+U32(1)))) = uint8(0)
  21288 
  21289 	return SQLITE_OK
  21290 }
  21291 
  21292 func journalHdrOffset(tls *libc.TLS, pPager uintptr) I64 {
  21293 	var offset I64 = int64(0)
  21294 	var c I64 = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  21295 	if c != 0 {
  21296 		offset = ((c-int64(1))/I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize) + int64(1)) * I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize)
  21297 	}
  21298 
  21299 	return offset
  21300 }
  21301 
  21302 func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 {
  21303 	bp := tls.Alloc(8)
  21304 	defer tls.Free(8)
  21305 
  21306 	var rc int32 = SQLITE_OK
  21307 
  21308 	if (*Pager)(unsafe.Pointer(pPager)).FjournalOff != 0 {
  21309 		var iLimit I64 = (*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit
  21310 
  21311 		if doTruncate != 0 || iLimit == int64(0) {
  21312 			rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int64(0))
  21313 		} else {
  21314 			rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&zeroHdr)), int32(unsafe.Sizeof(zeroHdr)), int64(0))
  21315 		}
  21316 		if rc == SQLITE_OK && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) {
  21317 			rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, SQLITE_SYNC_DATAONLY|int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))
  21318 		}
  21319 
  21320 		if rc == SQLITE_OK && iLimit > int64(0) {
  21321 			rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp)
  21322 			if rc == SQLITE_OK && *(*I64)(unsafe.Pointer(bp)) > iLimit {
  21323 				rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iLimit)
  21324 			}
  21325 		}
  21326 	}
  21327 	return rc
  21328 }
  21329 
  21330 var zeroHdr = [28]uint8{0: uint8(0)}
  21331 
  21332 func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 {
  21333 	var rc int32 = SQLITE_OK
  21334 	var zHeader uintptr = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace
  21335 	var nHeader U32 = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize)
  21336 	var nWrite U32
  21337 	var ii int32
  21338 
  21339 	if nHeader > (*Pager)(unsafe.Pointer(pPager)).FsectorSize {
  21340 		nHeader = (*Pager)(unsafe.Pointer(pPager)).FsectorSize
  21341 	}
  21342 
  21343 	for ii = 0; ii < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; ii++ {
  21344 		if (*PagerSavepoint)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FaSavepoint+uintptr(ii)*48)).FiHdrOffset == int64(0) {
  21345 			(*PagerSavepoint)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*48)).FiHdrOffset = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  21346 		}
  21347 	}
  21348 
  21349 	(*Pager)(unsafe.Pointer(pPager)).FjournalHdr = libc.AssignPtrInt64(pPager+80, journalHdrOffset(tls, pPager))
  21350 
  21351 	if (*Pager)(unsafe.Pointer(pPager)).FnoSync != 0 || int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY ||
  21352 		Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd)&SQLITE_IOCAP_SAFE_APPEND != 0 {
  21353 		libc.Xmemcpy(tls, zHeader, uintptr(unsafe.Pointer(&aJournalMagic)), uint32(unsafe.Sizeof(aJournalMagic)))
  21354 		Xsqlite3Put4byte(tls, zHeader+8, 0xffffffff)
  21355 	} else {
  21356 		libc.Xmemset(tls, zHeader, 0, uint32(unsafe.Sizeof(aJournalMagic))+uint32(4))
  21357 	}
  21358 
  21359 	Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U32(0))), pPager+52)
  21360 	Xsqlite3Put4byte(tls, zHeader+12, (*Pager)(unsafe.Pointer(pPager)).FcksumInit)
  21361 
  21362 	Xsqlite3Put4byte(tls, zHeader+16, (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize)
  21363 
  21364 	Xsqlite3Put4byte(tls, zHeader+20, (*Pager)(unsafe.Pointer(pPager)).FsectorSize)
  21365 
  21366 	Xsqlite3Put4byte(tls, zHeader+24, uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize))
  21367 
  21368 	libc.Xmemset(tls, zHeader+28, 0,
  21369 		nHeader-(uint32(unsafe.Sizeof(aJournalMagic))+uint32(20)))
  21370 
  21371 	for nWrite = U32(0); rc == SQLITE_OK && nWrite < (*Pager)(unsafe.Pointer(pPager)).FsectorSize; nWrite = nWrite + nHeader {
  21372 		rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zHeader, int32(nHeader), (*Pager)(unsafe.Pointer(pPager)).FjournalOff)
  21373 
  21374 		*(*I64)(unsafe.Pointer(pPager + 80)) += I64(nHeader)
  21375 	}
  21376 
  21377 	return rc
  21378 }
  21379 
  21380 func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, pNRec uintptr, pDbSize uintptr) int32 {
  21381 	bp := tls.Alloc(16)
  21382 	defer tls.Free(16)
  21383 
  21384 	var rc int32
  21385 
  21386 	var iHdrOff I64
  21387 
  21388 	(*Pager)(unsafe.Pointer(pPager)).FjournalOff = journalHdrOffset(tls, pPager)
  21389 	if (*Pager)(unsafe.Pointer(pPager)).FjournalOff+I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize) > journalSize {
  21390 		return SQLITE_DONE
  21391 	}
  21392 	iHdrOff = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  21393 
  21394 	if isHot != 0 || iHdrOff != (*Pager)(unsafe.Pointer(pPager)).FjournalHdr {
  21395 		rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp, int32(unsafe.Sizeof([8]uint8{})), iHdrOff)
  21396 		if rc != 0 {
  21397 			return rc
  21398 		}
  21399 		if libc.Xmemcmp(tls, bp, uintptr(unsafe.Pointer(&aJournalMagic)), uint32(unsafe.Sizeof([8]uint8{}))) != 0 {
  21400 			return SQLITE_DONE
  21401 		}
  21402 	}
  21403 
  21404 	if SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(8), pNRec)) ||
  21405 		SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(12), pPager+52)) ||
  21406 		SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(16), pDbSize)) {
  21407 		return rc
  21408 	}
  21409 
  21410 	if (*Pager)(unsafe.Pointer(pPager)).FjournalOff == int64(0) {
  21411 		if SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(20), bp+8)) ||
  21412 			SQLITE_OK != libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(24), bp+12)) {
  21413 			return rc
  21414 		}
  21415 
  21416 		if *(*U32)(unsafe.Pointer(bp + 12)) == U32(0) {
  21417 			*(*U32)(unsafe.Pointer(bp + 12)) = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize)
  21418 		}
  21419 
  21420 		if *(*U32)(unsafe.Pointer(bp + 12)) < U32(512) || *(*U32)(unsafe.Pointer(bp + 8)) < U32(32) ||
  21421 			*(*U32)(unsafe.Pointer(bp + 12)) > U32(SQLITE_MAX_PAGE_SIZE) || *(*U32)(unsafe.Pointer(bp + 8)) > U32(MAX_SECTOR_SIZE) ||
  21422 			(*(*U32)(unsafe.Pointer(bp + 12))-U32(1))&*(*U32)(unsafe.Pointer(bp + 12)) != U32(0) || (*(*U32)(unsafe.Pointer(bp + 8))-U32(1))&*(*U32)(unsafe.Pointer(bp + 8)) != U32(0) {
  21423 			return SQLITE_DONE
  21424 		}
  21425 
  21426 		rc = Xsqlite3PagerSetPagesize(tls, pPager, bp+12, -1)
  21427 
  21428 		(*Pager)(unsafe.Pointer(pPager)).FsectorSize = *(*U32)(unsafe.Pointer(bp + 8))
  21429 	}
  21430 
  21431 	*(*I64)(unsafe.Pointer(pPager + 80)) += I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize)
  21432 	return rc
  21433 }
  21434 
  21435 func writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 {
  21436 	bp := tls.Alloc(8)
  21437 	defer tls.Free(8)
  21438 
  21439 	var rc int32
  21440 	var nSuper int32
  21441 	var iHdrOff I64
  21442 
  21443 	var cksum U32 = U32(0)
  21444 
  21445 	if !(zSuper != 0) ||
  21446 		int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY ||
  21447 		!((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0)) {
  21448 		return SQLITE_OK
  21449 	}
  21450 	(*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(1)
  21451 
  21452 	for nSuper = 0; *(*uint8)(unsafe.Pointer(zSuper + uintptr(nSuper))) != 0; nSuper++ {
  21453 		cksum = cksum + U32(*(*uint8)(unsafe.Pointer(zSuper + uintptr(nSuper))))
  21454 	}
  21455 
  21456 	if (*Pager)(unsafe.Pointer(pPager)).FfullSync != 0 {
  21457 		(*Pager)(unsafe.Pointer(pPager)).FjournalOff = journalHdrOffset(tls, pPager)
  21458 	}
  21459 	iHdrOff = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  21460 
  21461 	if 0 != libc.AssignInt32(&rc, write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff, (*Pager)(unsafe.Pointer(pPager)).FlckPgno)) ||
  21462 		0 != libc.AssignInt32(&rc, Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zSuper, nSuper, iHdrOff+int64(4))) ||
  21463 		0 != libc.AssignInt32(&rc, write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(4)+I64(nSuper), uint32(nSuper))) ||
  21464 		0 != libc.AssignInt32(&rc, write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iHdrOff+int64(4)+I64(nSuper)+int64(4), cksum)) ||
  21465 		0 != libc.AssignInt32(&rc, Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&aJournalMagic)), 8,
  21466 			iHdrOff+int64(4)+I64(nSuper)+int64(8))) {
  21467 		return rc
  21468 	}
  21469 	*(*I64)(unsafe.Pointer(pPager + 80)) += I64(nSuper + 20)
  21470 
  21471 	if SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp)) &&
  21472 		*(*I64)(unsafe.Pointer(bp)) > (*Pager)(unsafe.Pointer(pPager)).FjournalOff {
  21473 		rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (*Pager)(unsafe.Pointer(pPager)).FjournalOff)
  21474 	}
  21475 	return rc
  21476 }
  21477 
  21478 func pager_reset(tls *libc.TLS, pPager uintptr) {
  21479 	(*Pager)(unsafe.Pointer(pPager)).FiDataVersion++
  21480 	Xsqlite3BackupRestart(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup)
  21481 	Xsqlite3PcacheClear(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  21482 }
  21483 
  21484 // Return the pPager->iDataVersion value
  21485 func Xsqlite3PagerDataVersion(tls *libc.TLS, pPager uintptr) U32 {
  21486 	return (*Pager)(unsafe.Pointer(pPager)).FiDataVersion
  21487 }
  21488 
  21489 func releaseAllSavepoints(tls *libc.TLS, pPager uintptr) {
  21490 	var ii int32
  21491 	for ii = 0; ii < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; ii++ {
  21492 		Xsqlite3BitvecDestroy(tls, (*PagerSavepoint)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FaSavepoint+uintptr(ii)*48)).FpInSavepoint)
  21493 	}
  21494 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) || Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd) != 0 {
  21495 		Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd)
  21496 	}
  21497 	Xsqlite3_free(tls, (*Pager)(unsafe.Pointer(pPager)).FaSavepoint)
  21498 	(*Pager)(unsafe.Pointer(pPager)).FaSavepoint = uintptr(0)
  21499 	(*Pager)(unsafe.Pointer(pPager)).FnSavepoint = 0
  21500 	(*Pager)(unsafe.Pointer(pPager)).FnSubRec = U32(0)
  21501 }
  21502 
  21503 func addToSavepointBitvecs(tls *libc.TLS, pPager uintptr, pgno Pgno) int32 {
  21504 	var ii int32
  21505 	var rc int32 = SQLITE_OK
  21506 
  21507 	for ii = 0; ii < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; ii++ {
  21508 		var p uintptr = (*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*48
  21509 		if pgno <= (*PagerSavepoint)(unsafe.Pointer(p)).FnOrig {
  21510 			rc = rc | Xsqlite3BitvecSet(tls, (*PagerSavepoint)(unsafe.Pointer(p)).FpInSavepoint, pgno)
  21511 
  21512 		}
  21513 	}
  21514 	return rc
  21515 }
  21516 
  21517 func pager_unlock(tls *libc.TLS, pPager uintptr) {
  21518 	Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal)
  21519 	(*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0)
  21520 	releaseAllSavepoints(tls, pPager)
  21521 
  21522 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  21523 		Xsqlite3WalEndReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  21524 		(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_OPEN)
  21525 	} else if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) {
  21526 		var rc int32
  21527 		var iDc int32
  21528 		if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) {
  21529 			iDc = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd)
  21530 		} else {
  21531 			iDc = 0
  21532 		}
  21533 
  21534 		if 0 == iDc&SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ||
  21535 			1 != int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode)&5 {
  21536 			Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  21537 		}
  21538 
  21539 		rc = pagerUnlockDb(tls, pPager, NO_LOCK)
  21540 		if rc != SQLITE_OK && int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_ERROR {
  21541 			(*Pager)(unsafe.Pointer(pPager)).FeLock = U8(EXCLUSIVE_LOCK + 1)
  21542 		}
  21543 
  21544 		(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_OPEN)
  21545 	}
  21546 
  21547 	if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  21548 		if int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0 {
  21549 			pager_reset(tls, pPager)
  21550 			(*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(0)
  21551 			(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_OPEN)
  21552 		} else {
  21553 			(*Pager)(unsafe.Pointer(pPager)).FeState = func() uint8 {
  21554 				if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) {
  21555 					return uint8(PAGER_OPEN)
  21556 				}
  21557 				return uint8(PAGER_READER)
  21558 			}()
  21559 		}
  21560 		if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 {
  21561 			Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0))
  21562 		}
  21563 		(*Pager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_OK
  21564 		setGetterMethod(tls, pPager)
  21565 	}
  21566 
  21567 	(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  21568 	(*Pager)(unsafe.Pointer(pPager)).FjournalHdr = int64(0)
  21569 	(*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(0)
  21570 }
  21571 
  21572 func pager_error(tls *libc.TLS, pPager uintptr, rc int32) int32 {
  21573 	var rc2 int32 = rc & 0xff
  21574 
  21575 	if rc2 == SQLITE_FULL || rc2 == SQLITE_IOERR {
  21576 		(*Pager)(unsafe.Pointer(pPager)).FerrCode = rc
  21577 		(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_ERROR)
  21578 		setGetterMethod(tls, pPager)
  21579 	}
  21580 	return rc
  21581 }
  21582 
  21583 func pagerFlushOnCommit(tls *libc.TLS, pPager uintptr, bCommit int32) int32 {
  21584 	if int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0 {
  21585 		return 1
  21586 	}
  21587 	if !(bCommit != 0) {
  21588 		return 0
  21589 	}
  21590 	if !((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0)) {
  21591 		return 0
  21592 	}
  21593 	return libc.Bool32(Xsqlite3PCachePercentDirty(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) >= 25)
  21594 }
  21595 
  21596 func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommit int32) int32 {
  21597 	var rc int32 = SQLITE_OK
  21598 	var rc2 int32 = SQLITE_OK
  21599 
  21600 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) < PAGER_WRITER_LOCKED && int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < RESERVED_LOCK {
  21601 		return SQLITE_OK
  21602 	}
  21603 
  21604 	releaseAllSavepoints(tls, pPager)
  21605 
  21606 	if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) {
  21607 		if Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) != 0 {
  21608 			Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  21609 		} else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_TRUNCATE {
  21610 			if (*Pager)(unsafe.Pointer(pPager)).FjournalOff == int64(0) {
  21611 				rc = SQLITE_OK
  21612 			} else {
  21613 				rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int64(0))
  21614 				if rc == SQLITE_OK && (*Pager)(unsafe.Pointer(pPager)).FfullSync != 0 {
  21615 					rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))
  21616 				}
  21617 			}
  21618 			(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  21619 		} else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_PERSIST ||
  21620 			(*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 && int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_WAL {
  21621 			rc = zeroJournalHdr(tls, pPager, libc.Bool32(hasSuper != 0 || (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0))
  21622 			(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  21623 		} else {
  21624 			var bDelete int32 = libc.BoolInt32(!((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0))
  21625 
  21626 			Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  21627 			if bDelete != 0 {
  21628 				rc = Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, int32((*Pager)(unsafe.Pointer(pPager)).FextraSync))
  21629 			}
  21630 		}
  21631 	}
  21632 
  21633 	Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal)
  21634 	(*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0)
  21635 	(*Pager)(unsafe.Pointer(pPager)).FnRec = 0
  21636 	if rc == SQLITE_OK {
  21637 		if (*Pager)(unsafe.Pointer(pPager)).FmemDb != 0 || pagerFlushOnCommit(tls, pPager, bCommit) != 0 {
  21638 			Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  21639 		} else {
  21640 			Xsqlite3PcacheClearWritable(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  21641 		}
  21642 		Xsqlite3PcacheTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, (*Pager)(unsafe.Pointer(pPager)).FdbSize)
  21643 	}
  21644 
  21645 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  21646 		rc2 = Xsqlite3WalEndWriteTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  21647 
  21648 	} else if rc == SQLITE_OK && bCommit != 0 && (*Pager)(unsafe.Pointer(pPager)).FdbFileSize > (*Pager)(unsafe.Pointer(pPager)).FdbSize {
  21649 		rc = pager_truncate(tls, pPager, (*Pager)(unsafe.Pointer(pPager)).FdbSize)
  21650 	}
  21651 
  21652 	if rc == SQLITE_OK && bCommit != 0 {
  21653 		rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_COMMIT_PHASETWO, uintptr(0))
  21654 		if rc == SQLITE_NOTFOUND {
  21655 			rc = SQLITE_OK
  21656 		}
  21657 	}
  21658 
  21659 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) &&
  21660 		(!((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) || Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, 0) != 0) {
  21661 		rc2 = pagerUnlockDb(tls, pPager, SHARED_LOCK)
  21662 	}
  21663 	(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_READER)
  21664 	(*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(0)
  21665 
  21666 	return func() int32 {
  21667 		if rc == SQLITE_OK {
  21668 			return rc2
  21669 		}
  21670 		return rc
  21671 	}()
  21672 }
  21673 
  21674 func pagerUnlockAndRollback(tls *libc.TLS, pPager uintptr) {
  21675 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_ERROR && int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_OPEN {
  21676 		if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_LOCKED {
  21677 			Xsqlite3BeginBenignMalloc(tls)
  21678 			Xsqlite3PagerRollback(tls, pPager)
  21679 			Xsqlite3EndBenignMalloc(tls)
  21680 		} else if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) {
  21681 			pager_end_transaction(tls, pPager, 0, 0)
  21682 		}
  21683 	}
  21684 	pager_unlock(tls, pPager)
  21685 }
  21686 
  21687 func pager_cksum(tls *libc.TLS, pPager uintptr, aData uintptr) U32 {
  21688 	var cksum U32 = (*Pager)(unsafe.Pointer(pPager)).FcksumInit
  21689 	var i int32 = int32((*Pager)(unsafe.Pointer(pPager)).FpageSize - int64(200))
  21690 	for i > 0 {
  21691 		cksum = cksum + U32(*(*U8)(unsafe.Pointer(aData + uintptr(i))))
  21692 		i = i - 200
  21693 	}
  21694 	return cksum
  21695 }
  21696 
  21697 func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDone uintptr, isMainJrnl int32, isSavepnt int32) int32 {
  21698 	bp := tls.Alloc(12)
  21699 	defer tls.Free(12)
  21700 
  21701 	var rc int32
  21702 
  21703 	var aData uintptr
  21704 	var jfd uintptr
  21705 	var isSynced int32
  21706 
  21707 	aData = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace
  21708 
  21709 	if isMainJrnl != 0 {
  21710 		jfd = (*Pager)(unsafe.Pointer(pPager)).Fjfd
  21711 	} else {
  21712 		jfd = (*Pager)(unsafe.Pointer(pPager)).Fsjfd
  21713 	}
  21714 	rc = read32bits(tls, jfd, *(*I64)(unsafe.Pointer(pOffset)), bp)
  21715 	if rc != SQLITE_OK {
  21716 		return rc
  21717 	}
  21718 	rc = Xsqlite3OsRead(tls, jfd, aData, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), *(*I64)(unsafe.Pointer(pOffset))+int64(4))
  21719 	if rc != SQLITE_OK {
  21720 		return rc
  21721 	}
  21722 	*(*I64)(unsafe.Pointer(pOffset)) += (*Pager)(unsafe.Pointer(pPager)).FpageSize + int64(4) + I64(isMainJrnl*4)
  21723 
  21724 	if *(*Pgno)(unsafe.Pointer(bp)) == Pgno(0) || *(*Pgno)(unsafe.Pointer(bp)) == (*Pager)(unsafe.Pointer(pPager)).FlckPgno {
  21725 		return SQLITE_DONE
  21726 	}
  21727 	if *(*Pgno)(unsafe.Pointer(bp)) > (*Pager)(unsafe.Pointer(pPager)).FdbSize || Xsqlite3BitvecTest(tls, pDone, *(*Pgno)(unsafe.Pointer(bp))) != 0 {
  21728 		return SQLITE_OK
  21729 	}
  21730 	if isMainJrnl != 0 {
  21731 		rc = read32bits(tls, jfd, *(*I64)(unsafe.Pointer(pOffset))-int64(4), bp+4)
  21732 		if rc != 0 {
  21733 			return rc
  21734 		}
  21735 		if !(isSavepnt != 0) && pager_cksum(tls, pPager, aData) != *(*U32)(unsafe.Pointer(bp + 4)) {
  21736 			return SQLITE_DONE
  21737 		}
  21738 	}
  21739 
  21740 	if pDone != 0 && libc.AssignInt32(&rc, Xsqlite3BitvecSet(tls, pDone, *(*Pgno)(unsafe.Pointer(bp)))) != SQLITE_OK {
  21741 		return rc
  21742 	}
  21743 
  21744 	if *(*Pgno)(unsafe.Pointer(bp)) == Pgno(1) && int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) != int32(*(*U8)(unsafe.Pointer(aData + 20))) {
  21745 		(*Pager)(unsafe.Pointer(pPager)).FnReserve = I16(*(*U8)(unsafe.Pointer(aData + 20)))
  21746 	}
  21747 
  21748 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  21749 		*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  21750 	} else {
  21751 		*(*uintptr)(unsafe.Pointer(bp + 8)) = Xsqlite3PagerLookup(tls, pPager, *(*Pgno)(unsafe.Pointer(bp)))
  21752 	}
  21753 
  21754 	if isMainJrnl != 0 {
  21755 		isSynced = libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0 || *(*I64)(unsafe.Pointer(pOffset)) <= (*Pager)(unsafe.Pointer(pPager)).FjournalHdr)
  21756 	} else {
  21757 		isSynced = libc.Bool32(*(*uintptr)(unsafe.Pointer(bp + 8)) == uintptr(0) || 0 == int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).Fflags)&PGHDR_NEED_SYNC)
  21758 	}
  21759 	if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) &&
  21760 		(int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD || int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) &&
  21761 		isSynced != 0 {
  21762 		var ofst I64 = I64(*(*Pgno)(unsafe.Pointer(bp))-Pgno(1)) * (*Pager)(unsafe.Pointer(pPager)).FpageSize
  21763 
  21764 		rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, aData, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), ofst)
  21765 
  21766 		if *(*Pgno)(unsafe.Pointer(bp)) > (*Pager)(unsafe.Pointer(pPager)).FdbFileSize {
  21767 			(*Pager)(unsafe.Pointer(pPager)).FdbFileSize = *(*Pgno)(unsafe.Pointer(bp))
  21768 		}
  21769 		if (*Pager)(unsafe.Pointer(pPager)).FpBackup != 0 {
  21770 			Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, *(*Pgno)(unsafe.Pointer(bp)), aData)
  21771 		}
  21772 	} else if !(isMainJrnl != 0) && *(*uintptr)(unsafe.Pointer(bp + 8)) == uintptr(0) {
  21773 		*(*U8)(unsafe.Pointer(pPager + 21)) |= U8(SPILLFLAG_ROLLBACK)
  21774 		rc = Xsqlite3PagerGet(tls, pPager, *(*Pgno)(unsafe.Pointer(bp)), bp+8, 1)
  21775 
  21776 		*(*U8)(unsafe.Pointer(pPager + 21)) &= libc.Uint8FromInt32(libc.CplInt32(SPILLFLAG_ROLLBACK))
  21777 		if rc != SQLITE_OK {
  21778 			return rc
  21779 		}
  21780 		Xsqlite3PcacheMakeDirty(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  21781 	}
  21782 	if *(*uintptr)(unsafe.Pointer(bp + 8)) != 0 {
  21783 		var pData uintptr
  21784 		pData = (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FpData
  21785 		libc.Xmemcpy(tls, pData, aData, uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize))
  21786 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Pager)(unsafe.Pointer(pPager)).FxReiniter})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  21787 
  21788 		if *(*Pgno)(unsafe.Pointer(bp)) == Pgno(1) {
  21789 			libc.Xmemcpy(tls, pPager+112, pData+24, uint32(unsafe.Sizeof([16]uint8{})))
  21790 		}
  21791 		Xsqlite3PcacheRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  21792 	}
  21793 	return rc
  21794 }
  21795 
  21796 func pager_delsuper(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 {
  21797 	bp := tls.Alloc(12)
  21798 	defer tls.Free(12)
  21799 
  21800 	var pVfs uintptr
  21801 	var rc int32
  21802 	var pSuper uintptr
  21803 	var pJournal uintptr
  21804 	var zSuperJournal uintptr
  21805 
  21806 	var zJournal uintptr
  21807 	var zSuperPtr uintptr
  21808 	var zFree uintptr
  21809 	var nSuperPtr int32
  21810 	var flags int32
  21811 
  21812 	var c int32
  21813 	var flags1 int32
  21814 
  21815 	pVfs = (*Pager)(unsafe.Pointer(pPager)).FpVfs
  21816 	zSuperJournal = uintptr(0)
  21817 	zFree = uintptr(0)
  21818 
  21819 	pSuper = Xsqlite3MallocZero(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile*2))
  21820 	if !!(pSuper != 0) {
  21821 		goto __1
  21822 	}
  21823 	rc = SQLITE_NOMEM
  21824 	pJournal = uintptr(0)
  21825 	goto __2
  21826 __1:
  21827 	flags = SQLITE_OPEN_READONLY | SQLITE_OPEN_SUPER_JOURNAL
  21828 	rc = Xsqlite3OsOpen(tls, pVfs, zSuper, pSuper, flags, uintptr(0))
  21829 	pJournal = pSuper + uintptr((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)
  21830 __2:
  21831 	;
  21832 	if !(rc != SQLITE_OK) {
  21833 		goto __3
  21834 	}
  21835 	goto delsuper_out
  21836 __3:
  21837 	;
  21838 	rc = Xsqlite3OsFileSize(tls, pSuper, bp)
  21839 	if !(rc != SQLITE_OK) {
  21840 		goto __4
  21841 	}
  21842 	goto delsuper_out
  21843 __4:
  21844 	;
  21845 	nSuperPtr = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + 1
  21846 	zFree = Xsqlite3Malloc(tls, uint64(int64(4)+*(*I64)(unsafe.Pointer(bp))+I64(nSuperPtr)+int64(2)))
  21847 	if !!(zFree != 0) {
  21848 		goto __5
  21849 	}
  21850 	rc = SQLITE_NOMEM
  21851 	goto delsuper_out
  21852 __5:
  21853 	;
  21854 	*(*uint8)(unsafe.Pointer(zFree)) = libc.AssignPtrUint8(zFree+1, libc.AssignPtrUint8(zFree+2, libc.AssignPtrUint8(zFree+3, uint8(0))))
  21855 	zSuperJournal = zFree + 4
  21856 	zSuperPtr = zSuperJournal + uintptr(*(*I64)(unsafe.Pointer(bp))+int64(2))
  21857 	rc = Xsqlite3OsRead(tls, pSuper, zSuperJournal, int32(*(*I64)(unsafe.Pointer(bp))), int64(0))
  21858 	if !(rc != SQLITE_OK) {
  21859 		goto __6
  21860 	}
  21861 	goto delsuper_out
  21862 __6:
  21863 	;
  21864 	*(*uint8)(unsafe.Pointer(zSuperJournal + uintptr(*(*I64)(unsafe.Pointer(bp))))) = uint8(0)
  21865 	*(*uint8)(unsafe.Pointer(zSuperJournal + uintptr(*(*I64)(unsafe.Pointer(bp))+int64(1)))) = uint8(0)
  21866 
  21867 	zJournal = zSuperJournal
  21868 __7:
  21869 	if !(I64((int32(zJournal)-int32(zSuperJournal))/1) < *(*I64)(unsafe.Pointer(bp))) {
  21870 		goto __8
  21871 	}
  21872 	rc = Xsqlite3OsAccess(tls, pVfs, zJournal, SQLITE_ACCESS_EXISTS, bp+8)
  21873 	if !(rc != SQLITE_OK) {
  21874 		goto __9
  21875 	}
  21876 	goto delsuper_out
  21877 __9:
  21878 	;
  21879 	if !(*(*int32)(unsafe.Pointer(bp + 8)) != 0) {
  21880 		goto __10
  21881 	}
  21882 	flags1 = SQLITE_OPEN_READONLY | SQLITE_OPEN_SUPER_JOURNAL
  21883 	rc = Xsqlite3OsOpen(tls, pVfs, zJournal, pJournal, flags1, uintptr(0))
  21884 	if !(rc != SQLITE_OK) {
  21885 		goto __11
  21886 	}
  21887 	goto delsuper_out
  21888 __11:
  21889 	;
  21890 	rc = readSuperJournal(tls, pJournal, zSuperPtr, uint32(nSuperPtr))
  21891 	Xsqlite3OsClose(tls, pJournal)
  21892 	if !(rc != SQLITE_OK) {
  21893 		goto __12
  21894 	}
  21895 	goto delsuper_out
  21896 __12:
  21897 	;
  21898 	c = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zSuperPtr))) != 0 && libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0)
  21899 	if !(c != 0) {
  21900 		goto __13
  21901 	}
  21902 
  21903 	goto delsuper_out
  21904 __13:
  21905 	;
  21906 __10:
  21907 	;
  21908 	zJournal += uintptr(Xsqlite3Strlen30(tls, zJournal) + 1)
  21909 	goto __7
  21910 __8:
  21911 	;
  21912 	Xsqlite3OsClose(tls, pSuper)
  21913 	rc = Xsqlite3OsDelete(tls, pVfs, zSuper, 0)
  21914 
  21915 delsuper_out:
  21916 	Xsqlite3_free(tls, zFree)
  21917 	if !(pSuper != 0) {
  21918 		goto __14
  21919 	}
  21920 	Xsqlite3OsClose(tls, pSuper)
  21921 
  21922 	Xsqlite3_free(tls, pSuper)
  21923 __14:
  21924 	;
  21925 	return rc
  21926 }
  21927 
  21928 func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 {
  21929 	bp := tls.Alloc(16)
  21930 	defer tls.Free(16)
  21931 
  21932 	var rc int32 = SQLITE_OK
  21933 
  21934 	if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) &&
  21935 		(int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD || int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) {
  21936 		var szPage int32 = int32((*Pager)(unsafe.Pointer(pPager)).FpageSize)
  21937 
  21938 		rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp)
  21939 		*(*I64)(unsafe.Pointer(bp + 8)) = I64(szPage) * I64(nPage)
  21940 		if rc == SQLITE_OK && *(*I64)(unsafe.Pointer(bp)) != *(*I64)(unsafe.Pointer(bp + 8)) {
  21941 			if *(*I64)(unsafe.Pointer(bp)) > *(*I64)(unsafe.Pointer(bp + 8)) {
  21942 				rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, *(*I64)(unsafe.Pointer(bp + 8)))
  21943 			} else if *(*I64)(unsafe.Pointer(bp))+I64(szPage) <= *(*I64)(unsafe.Pointer(bp + 8)) {
  21944 				var pTmp uintptr = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace
  21945 				libc.Xmemset(tls, pTmp, 0, uint32(szPage))
  21946 
  21947 				Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SIZE_HINT, bp+8)
  21948 				rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pTmp, szPage, *(*I64)(unsafe.Pointer(bp + 8))-I64(szPage))
  21949 			}
  21950 			if rc == SQLITE_OK {
  21951 				(*Pager)(unsafe.Pointer(pPager)).FdbFileSize = nPage
  21952 			}
  21953 		}
  21954 	}
  21955 	return rc
  21956 }
  21957 
  21958 // Return a sanitized version of the sector-size of OS file pFile. The
  21959 // return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.
  21960 func Xsqlite3SectorSize(tls *libc.TLS, pFile uintptr) int32 {
  21961 	var iRet int32 = Xsqlite3OsSectorSize(tls, pFile)
  21962 	if iRet < 32 {
  21963 		iRet = 512
  21964 	} else if iRet > MAX_SECTOR_SIZE {
  21965 		iRet = MAX_SECTOR_SIZE
  21966 	}
  21967 	return iRet
  21968 }
  21969 
  21970 func setSectorSize(tls *libc.TLS, pPager uintptr) {
  21971 	if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 ||
  21972 		Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd)&SQLITE_IOCAP_POWERSAFE_OVERWRITE != 0 {
  21973 		(*Pager)(unsafe.Pointer(pPager)).FsectorSize = U32(512)
  21974 	} else {
  21975 		(*Pager)(unsafe.Pointer(pPager)).FsectorSize = U32(Xsqlite3SectorSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd))
  21976 	}
  21977 }
  21978 
  21979 func pager_playback(tls *libc.TLS, pPager uintptr, isHot int32) int32 {
  21980 	bp := tls.Alloc(40)
  21981 	defer tls.Free(40)
  21982 
  21983 	var pVfs uintptr
  21984 
  21985 	var u U32
  21986 
  21987 	var rc int32
  21988 
  21989 	var zSuper uintptr
  21990 	var needPagerReset int32
  21991 	var nPlayback int32
  21992 
  21993 	pVfs = (*Pager)(unsafe.Pointer(pPager)).FpVfs
  21994 	*(*Pgno)(unsafe.Pointer(bp + 32)) = Pgno(0)
  21995 	*(*int32)(unsafe.Pointer(bp + 24)) = 1
  21996 	zSuper = uintptr(0)
  21997 	nPlayback = 0
  21998 	*(*U32)(unsafe.Pointer(bp + 36)) = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize)
  21999 
  22000 	rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+16)
  22001 	if !(rc != SQLITE_OK) {
  22002 		goto __1
  22003 	}
  22004 	goto end_playback
  22005 __1:
  22006 	;
  22007 	zSuper = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace
  22008 	rc = readSuperJournal(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zSuper, uint32((*Sqlite3_vfs)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname+1))
  22009 	if !(rc == SQLITE_OK && *(*uint8)(unsafe.Pointer(zSuper)) != 0) {
  22010 		goto __2
  22011 	}
  22012 	rc = Xsqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+24)
  22013 __2:
  22014 	;
  22015 	zSuper = uintptr(0)
  22016 	if !(rc != SQLITE_OK || !(*(*int32)(unsafe.Pointer(bp + 24)) != 0)) {
  22017 		goto __3
  22018 	}
  22019 	goto end_playback
  22020 __3:
  22021 	;
  22022 	(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  22023 	needPagerReset = isHot
  22024 
  22025 __4:
  22026 	if !(1 != 0) {
  22027 		goto __5
  22028 	}
  22029 
  22030 	rc = readJournalHdr(tls, pPager, isHot, *(*I64)(unsafe.Pointer(bp + 16)), bp+28, bp+32)
  22031 	if !(rc != SQLITE_OK) {
  22032 		goto __6
  22033 	}
  22034 	if !(rc == SQLITE_DONE) {
  22035 		goto __7
  22036 	}
  22037 	rc = SQLITE_OK
  22038 __7:
  22039 	;
  22040 	goto end_playback
  22041 __6:
  22042 	;
  22043 	if !(*(*U32)(unsafe.Pointer(bp + 28)) == 0xffffffff) {
  22044 		goto __8
  22045 	}
  22046 
  22047 	*(*U32)(unsafe.Pointer(bp + 28)) = U32(int32((*(*I64)(unsafe.Pointer(bp + 16)) - I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize)) / ((*Pager)(unsafe.Pointer(pPager)).FpageSize + int64(8))))
  22048 __8:
  22049 	;
  22050 	if !(*(*U32)(unsafe.Pointer(bp + 28)) == U32(0) && !(isHot != 0) && (*Pager)(unsafe.Pointer(pPager)).FjournalHdr+I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize) == (*Pager)(unsafe.Pointer(pPager)).FjournalOff) {
  22051 		goto __9
  22052 	}
  22053 	*(*U32)(unsafe.Pointer(bp + 28)) = U32(int32((*(*I64)(unsafe.Pointer(bp + 16)) - (*Pager)(unsafe.Pointer(pPager)).FjournalOff) / ((*Pager)(unsafe.Pointer(pPager)).FpageSize + int64(8))))
  22054 __9:
  22055 	;
  22056 	if !((*Pager)(unsafe.Pointer(pPager)).FjournalOff == I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize)) {
  22057 		goto __10
  22058 	}
  22059 	rc = pager_truncate(tls, pPager, *(*Pgno)(unsafe.Pointer(bp + 32)))
  22060 	if !(rc != SQLITE_OK) {
  22061 		goto __11
  22062 	}
  22063 	goto end_playback
  22064 __11:
  22065 	;
  22066 	(*Pager)(unsafe.Pointer(pPager)).FdbSize = *(*Pgno)(unsafe.Pointer(bp + 32))
  22067 	if !((*Pager)(unsafe.Pointer(pPager)).FmxPgno < *(*Pgno)(unsafe.Pointer(bp + 32))) {
  22068 		goto __12
  22069 	}
  22070 	(*Pager)(unsafe.Pointer(pPager)).FmxPgno = *(*Pgno)(unsafe.Pointer(bp + 32))
  22071 __12:
  22072 	;
  22073 __10:
  22074 	;
  22075 	u = U32(0)
  22076 __13:
  22077 	if !(u < *(*U32)(unsafe.Pointer(bp + 28))) {
  22078 		goto __15
  22079 	}
  22080 	if !(needPagerReset != 0) {
  22081 		goto __16
  22082 	}
  22083 	pager_reset(tls, pPager)
  22084 	needPagerReset = 0
  22085 __16:
  22086 	;
  22087 	rc = pager_playback_one_page(tls, pPager, pPager+80, uintptr(0), 1, 0)
  22088 	if !(rc == SQLITE_OK) {
  22089 		goto __17
  22090 	}
  22091 	nPlayback++
  22092 	goto __18
  22093 __17:
  22094 	if !(rc == SQLITE_DONE) {
  22095 		goto __19
  22096 	}
  22097 	(*Pager)(unsafe.Pointer(pPager)).FjournalOff = *(*I64)(unsafe.Pointer(bp + 16))
  22098 	goto __15
  22099 	goto __20
  22100 __19:
  22101 	if !(rc == SQLITE_IOERR|int32(2)<<8) {
  22102 		goto __21
  22103 	}
  22104 
  22105 	rc = SQLITE_OK
  22106 	goto end_playback
  22107 	goto __22
  22108 __21:
  22109 	goto end_playback
  22110 __22:
  22111 	;
  22112 __20:
  22113 	;
  22114 __18:
  22115 	;
  22116 	goto __14
  22117 __14:
  22118 	u++
  22119 	goto __13
  22120 	goto __15
  22121 __15:
  22122 	;
  22123 	goto __4
  22124 __5:
  22125 	;
  22126 end_playback:
  22127 	if !(rc == SQLITE_OK) {
  22128 		goto __23
  22129 	}
  22130 	rc = Xsqlite3PagerSetPagesize(tls, pPager, bp+36, -1)
  22131 __23:
  22132 	;
  22133 	(*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = (*Pager)(unsafe.Pointer(pPager)).FtempFile
  22134 
  22135 	if !(rc == SQLITE_OK) {
  22136 		goto __24
  22137 	}
  22138 
  22139 	zSuper = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace + 4
  22140 	rc = readSuperJournal(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zSuper, uint32((*Sqlite3_vfs)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname+1))
  22141 
  22142 __24:
  22143 	;
  22144 	if !(rc == SQLITE_OK &&
  22145 		(int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD || int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) {
  22146 		goto __25
  22147 	}
  22148 	rc = Xsqlite3PagerSync(tls, pPager, uintptr(0))
  22149 __25:
  22150 	;
  22151 	if !(rc == SQLITE_OK) {
  22152 		goto __26
  22153 	}
  22154 	rc = pager_end_transaction(tls, pPager, libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zSuper))) != 0), 0)
  22155 
  22156 __26:
  22157 	;
  22158 	if !(rc == SQLITE_OK && *(*uint8)(unsafe.Pointer(zSuper)) != 0 && *(*int32)(unsafe.Pointer(bp + 24)) != 0) {
  22159 		goto __27
  22160 	}
  22161 
  22162 	libc.Xmemset(tls, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace, 0, uint32(4))
  22163 	rc = pager_delsuper(tls, pPager, zSuper)
  22164 
  22165 __27:
  22166 	;
  22167 	if !(isHot != 0 && nPlayback != 0) {
  22168 		goto __28
  22169 	}
  22170 	Xsqlite3_log(tls, SQLITE_NOTICE|int32(2)<<8, ts+3894,
  22171 		libc.VaList(bp, nPlayback, (*Pager)(unsafe.Pointer(pPager)).FzJournal))
  22172 __28:
  22173 	;
  22174 	setSectorSize(tls, pPager)
  22175 	return rc
  22176 }
  22177 
  22178 func readDbPage(tls *libc.TLS, pPg uintptr) int32 {
  22179 	bp := tls.Alloc(4)
  22180 	defer tls.Free(4)
  22181 
  22182 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  22183 	var rc int32 = SQLITE_OK
  22184 
  22185 	*(*U32)(unsafe.Pointer(bp)) = U32(0)
  22186 
  22187 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  22188 		rc = Xsqlite3WalFindFrame(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno, bp)
  22189 		if rc != 0 {
  22190 			return rc
  22191 		}
  22192 	}
  22193 	if *(*U32)(unsafe.Pointer(bp)) != 0 {
  22194 		rc = Xsqlite3WalReadFrame(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, *(*U32)(unsafe.Pointer(bp)), int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), (*PgHdr)(unsafe.Pointer(pPg)).FpData)
  22195 	} else {
  22196 		var iOffset I64 = I64((*PgHdr)(unsafe.Pointer(pPg)).Fpgno-Pgno(1)) * (*Pager)(unsafe.Pointer(pPager)).FpageSize
  22197 		rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, (*PgHdr)(unsafe.Pointer(pPg)).FpData, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), iOffset)
  22198 		if rc == SQLITE_IOERR|int32(2)<<8 {
  22199 			rc = SQLITE_OK
  22200 		}
  22201 	}
  22202 
  22203 	if (*PgHdr)(unsafe.Pointer(pPg)).Fpgno == Pgno(1) {
  22204 		if rc != 0 {
  22205 			libc.Xmemset(tls, pPager+112, 0xff, uint32(unsafe.Sizeof([16]uint8{})))
  22206 		} else {
  22207 			var dbFileVers uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpData + 24
  22208 			libc.Xmemcpy(tls, pPager+112, dbFileVers, uint32(unsafe.Sizeof([16]uint8{})))
  22209 		}
  22210 	}
  22211 
  22212 	return rc
  22213 }
  22214 
  22215 func pager_write_changecounter(tls *libc.TLS, pPg uintptr) {
  22216 	var change_counter U32
  22217 	if pPg == uintptr(0) {
  22218 		return
  22219 	}
  22220 
  22221 	change_counter = Xsqlite3Get4byte(tls, (*PgHdr)(unsafe.Pointer(pPg)).FpPager+112) + U32(1)
  22222 	Xsqlite3Put4byte(tls, (*PgHdr)(unsafe.Pointer(pPg)).FpData+uintptr(24), change_counter)
  22223 
  22224 	Xsqlite3Put4byte(tls, (*PgHdr)(unsafe.Pointer(pPg)).FpData+uintptr(92), change_counter)
  22225 	Xsqlite3Put4byte(tls, (*PgHdr)(unsafe.Pointer(pPg)).FpData+uintptr(96), uint32(SQLITE_VERSION_NUMBER))
  22226 }
  22227 
  22228 func pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg Pgno) int32 {
  22229 	var rc int32 = SQLITE_OK
  22230 	var pPager uintptr = pCtx
  22231 	var pPg uintptr
  22232 
  22233 	pPg = Xsqlite3PagerLookup(tls, pPager, iPg)
  22234 	if pPg != 0 {
  22235 		if Xsqlite3PcachePageRefcount(tls, pPg) == int64(1) {
  22236 			Xsqlite3PcacheDrop(tls, pPg)
  22237 		} else {
  22238 			rc = readDbPage(tls, pPg)
  22239 			if rc == SQLITE_OK {
  22240 				(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Pager)(unsafe.Pointer(pPager)).FxReiniter})).f(tls, pPg)
  22241 			}
  22242 			Xsqlite3PagerUnrefNotNull(tls, pPg)
  22243 		}
  22244 	}
  22245 
  22246 	Xsqlite3BackupRestart(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup)
  22247 
  22248 	return rc
  22249 }
  22250 
  22251 func pagerRollbackWal(tls *libc.TLS, pPager uintptr) int32 {
  22252 	var rc int32
  22253 	var pList uintptr
  22254 
  22255 	(*Pager)(unsafe.Pointer(pPager)).FdbSize = (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize
  22256 	rc = Xsqlite3WalUndo(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, *(*uintptr)(unsafe.Pointer(&struct {
  22257 		f func(*libc.TLS, uintptr, Pgno) int32
  22258 	}{pagerUndoCallback})), pPager)
  22259 	pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  22260 	for pList != 0 && rc == SQLITE_OK {
  22261 		var pNext uintptr = (*PgHdr)(unsafe.Pointer(pList)).FpDirty
  22262 		rc = pagerUndoCallback(tls, pPager, (*PgHdr)(unsafe.Pointer(pList)).Fpgno)
  22263 		pList = pNext
  22264 	}
  22265 
  22266 	return rc
  22267 }
  22268 
  22269 func pagerWalFrames(tls *libc.TLS, pPager uintptr, pList uintptr, nTruncate Pgno, isCommit int32) int32 {
  22270 	bp := tls.Alloc(4)
  22271 	defer tls.Free(4)
  22272 	*(*uintptr)(unsafe.Pointer(bp)) = pList
  22273 
  22274 	var rc int32
  22275 	var nList int32
  22276 	var p uintptr
  22277 
  22278 	if isCommit != 0 {
  22279 		var ppNext uintptr = bp
  22280 		nList = 0
  22281 		for p = *(*uintptr)(unsafe.Pointer(bp)); libc.AssignPtrUintptr(ppNext, p) != uintptr(0); p = (*PgHdr)(unsafe.Pointer(p)).FpDirty {
  22282 			if (*PgHdr)(unsafe.Pointer(p)).Fpgno <= nTruncate {
  22283 				ppNext = p + 16
  22284 				nList++
  22285 			}
  22286 		}
  22287 
  22288 	} else {
  22289 		nList = 1
  22290 	}
  22291 	*(*int32)(unsafe.Pointer(pPager + 200 + 2*4)) += nList
  22292 
  22293 	if (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fpgno == Pgno(1) {
  22294 		pager_write_changecounter(tls, *(*uintptr)(unsafe.Pointer(bp)))
  22295 	}
  22296 	rc = Xsqlite3WalFrames(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal,
  22297 		int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), *(*uintptr)(unsafe.Pointer(bp)), nTruncate, isCommit, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags))
  22298 	if rc == SQLITE_OK && (*Pager)(unsafe.Pointer(pPager)).FpBackup != 0 {
  22299 		for p = *(*uintptr)(unsafe.Pointer(bp)); p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty {
  22300 			Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, (*PgHdr)(unsafe.Pointer(p)).Fpgno, (*PgHdr)(unsafe.Pointer(p)).FpData)
  22301 		}
  22302 	}
  22303 
  22304 	return rc
  22305 }
  22306 
  22307 func pagerBeginReadTransaction(tls *libc.TLS, pPager uintptr) int32 {
  22308 	bp := tls.Alloc(4)
  22309 	defer tls.Free(4)
  22310 
  22311 	var rc int32
  22312 	*(*int32)(unsafe.Pointer(bp)) = 0
  22313 
  22314 	Xsqlite3WalEndReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  22315 
  22316 	rc = Xsqlite3WalBeginReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, bp)
  22317 	if rc != SQLITE_OK || *(*int32)(unsafe.Pointer(bp)) != 0 {
  22318 		pager_reset(tls, pPager)
  22319 		if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 {
  22320 			Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0))
  22321 		}
  22322 	}
  22323 
  22324 	return rc
  22325 }
  22326 
  22327 func pagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) int32 {
  22328 	bp := tls.Alloc(8)
  22329 	defer tls.Free(8)
  22330 
  22331 	var nPage Pgno
  22332 
  22333 	nPage = Xsqlite3WalDbsize(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  22334 
  22335 	if nPage == Pgno(0) && (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) {
  22336 		*(*I64)(unsafe.Pointer(bp)) = int64(0)
  22337 		var rc int32 = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp)
  22338 		if rc != SQLITE_OK {
  22339 			return rc
  22340 		}
  22341 		nPage = Pgno((*(*I64)(unsafe.Pointer(bp)) + (*Pager)(unsafe.Pointer(pPager)).FpageSize - int64(1)) / (*Pager)(unsafe.Pointer(pPager)).FpageSize)
  22342 	}
  22343 
  22344 	if nPage > (*Pager)(unsafe.Pointer(pPager)).FmxPgno {
  22345 		(*Pager)(unsafe.Pointer(pPager)).FmxPgno = nPage
  22346 	}
  22347 
  22348 	*(*Pgno)(unsafe.Pointer(pnPage)) = nPage
  22349 	return SQLITE_OK
  22350 }
  22351 
  22352 func pagerOpenWalIfPresent(tls *libc.TLS, pPager uintptr) int32 {
  22353 	bp := tls.Alloc(8)
  22354 	defer tls.Free(8)
  22355 
  22356 	var rc int32 = SQLITE_OK
  22357 
  22358 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) {
  22359 		rc = Xsqlite3OsAccess(tls,
  22360 			(*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp)
  22361 		if rc == SQLITE_OK {
  22362 			if *(*int32)(unsafe.Pointer(bp)) != 0 {
  22363 				rc = pagerPagecount(tls, pPager, bp+4)
  22364 				if rc != 0 {
  22365 					return rc
  22366 				}
  22367 				if *(*Pgno)(unsafe.Pointer(bp + 4)) == Pgno(0) {
  22368 					rc = Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, 0)
  22369 				} else {
  22370 					rc = Xsqlite3PagerOpenWal(tls, pPager, uintptr(0))
  22371 				}
  22372 			} else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_WAL {
  22373 				(*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(PAGER_JOURNALMODE_DELETE)
  22374 			}
  22375 		}
  22376 	}
  22377 	return rc
  22378 }
  22379 
  22380 func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) int32 {
  22381 	bp := tls.Alloc(16)
  22382 	defer tls.Free(16)
  22383 
  22384 	var szJ I64
  22385 	var iHdrOff I64
  22386 	var rc int32 = SQLITE_OK
  22387 	var pDone uintptr = uintptr(0)
  22388 
  22389 	if pSavepoint != 0 {
  22390 		pDone = Xsqlite3BitvecCreate(tls, (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FnOrig)
  22391 		if !(pDone != 0) {
  22392 			return SQLITE_NOMEM
  22393 		}
  22394 	}
  22395 
  22396 	(*Pager)(unsafe.Pointer(pPager)).FdbSize = func() uint32 {
  22397 		if pSavepoint != 0 {
  22398 			return (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FnOrig
  22399 		}
  22400 		return (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize
  22401 	}()
  22402 	(*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = (*Pager)(unsafe.Pointer(pPager)).FtempFile
  22403 
  22404 	if !(pSavepoint != 0) && (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  22405 		return pagerRollbackWal(tls, pPager)
  22406 	}
  22407 
  22408 	szJ = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  22409 
  22410 	if pSavepoint != 0 && !((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) {
  22411 		if (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiHdrOffset != 0 {
  22412 			iHdrOff = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiHdrOffset
  22413 		} else {
  22414 			iHdrOff = szJ
  22415 		}
  22416 		(*Pager)(unsafe.Pointer(pPager)).FjournalOff = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiOffset
  22417 		for rc == SQLITE_OK && (*Pager)(unsafe.Pointer(pPager)).FjournalOff < iHdrOff {
  22418 			rc = pager_playback_one_page(tls, pPager, pPager+80, pDone, 1, 1)
  22419 		}
  22420 
  22421 	} else {
  22422 		(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  22423 	}
  22424 
  22425 	for rc == SQLITE_OK && (*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ {
  22426 		var ii U32
  22427 		*(*U32)(unsafe.Pointer(bp)) = U32(0)
  22428 
  22429 		rc = readJournalHdr(tls, pPager, 0, szJ, bp, bp+4)
  22430 
  22431 		if *(*U32)(unsafe.Pointer(bp)) == U32(0) &&
  22432 			(*Pager)(unsafe.Pointer(pPager)).FjournalHdr+I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize) == (*Pager)(unsafe.Pointer(pPager)).FjournalOff {
  22433 			*(*U32)(unsafe.Pointer(bp)) = U32((szJ - (*Pager)(unsafe.Pointer(pPager)).FjournalOff) / ((*Pager)(unsafe.Pointer(pPager)).FpageSize + int64(8)))
  22434 		}
  22435 		for ii = U32(0); rc == SQLITE_OK && ii < *(*U32)(unsafe.Pointer(bp)) && (*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ; ii++ {
  22436 			rc = pager_playback_one_page(tls, pPager, pPager+80, pDone, 1, 1)
  22437 		}
  22438 
  22439 	}
  22440 
  22441 	if pSavepoint != 0 {
  22442 		var ii U32
  22443 		*(*I64)(unsafe.Pointer(bp + 8)) = I64((*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec) * (int64(4) + (*Pager)(unsafe.Pointer(pPager)).FpageSize)
  22444 
  22445 		if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  22446 			rc = Xsqlite3WalSavepointUndo(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSavepoint+32)
  22447 		}
  22448 		for ii = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec; rc == SQLITE_OK && ii < (*Pager)(unsafe.Pointer(pPager)).FnSubRec; ii++ {
  22449 			rc = pager_playback_one_page(tls, pPager, bp+8, pDone, 0, 1)
  22450 		}
  22451 
  22452 	}
  22453 
  22454 	Xsqlite3BitvecDestroy(tls, pDone)
  22455 	if rc == SQLITE_OK {
  22456 		(*Pager)(unsafe.Pointer(pPager)).FjournalOff = szJ
  22457 	}
  22458 
  22459 	return rc
  22460 }
  22461 
  22462 // Change the maximum number of in-memory pages that are allowed
  22463 // before attempting to recycle clean and unused pages.
  22464 func Xsqlite3PagerSetCachesize(tls *libc.TLS, pPager uintptr, mxPage int32) {
  22465 	Xsqlite3PcacheSetCachesize(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, mxPage)
  22466 }
  22467 
  22468 // Change the maximum number of in-memory pages that are allowed
  22469 // before attempting to spill pages to journal.
  22470 func Xsqlite3PagerSetSpillsize(tls *libc.TLS, pPager uintptr, mxPage int32) int32 {
  22471 	return Xsqlite3PcacheSetSpillsize(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, mxPage)
  22472 }
  22473 
  22474 func pagerFixMaplimit(tls *libc.TLS, pPager uintptr) {
  22475 	bp := tls.Alloc(8)
  22476 	defer tls.Free(8)
  22477 
  22478 	var fd uintptr = (*Pager)(unsafe.Pointer(pPager)).Ffd
  22479 	if (*Sqlite3_file)(unsafe.Pointer(fd)).FpMethods != uintptr(0) && (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(fd)).FpMethods)).FiVersion >= 3 {
  22480 		*(*Sqlite3_int64)(unsafe.Pointer(bp)) = (*Pager)(unsafe.Pointer(pPager)).FszMmap
  22481 		(*Pager)(unsafe.Pointer(pPager)).FbUseFetch = U8(libc.Bool32(*(*Sqlite3_int64)(unsafe.Pointer(bp)) > int64(0)))
  22482 		setGetterMethod(tls, pPager)
  22483 		Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_MMAP_SIZE, bp)
  22484 	}
  22485 }
  22486 
  22487 // Change the maximum size of any memory mapping made of the database file.
  22488 func Xsqlite3PagerSetMmapLimit(tls *libc.TLS, pPager uintptr, szMmap Sqlite3_int64) {
  22489 	(*Pager)(unsafe.Pointer(pPager)).FszMmap = szMmap
  22490 	pagerFixMaplimit(tls, pPager)
  22491 }
  22492 
  22493 // Free as much memory as possible from the pager.
  22494 func Xsqlite3PagerShrink(tls *libc.TLS, pPager uintptr) {
  22495 	Xsqlite3PcacheShrink(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  22496 }
  22497 
  22498 // Adjust settings of the pager to those specified in the pgFlags parameter.
  22499 //
  22500 // The "level" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness
  22501 // of the database to damage due to OS crashes or power failures by
  22502 // changing the number of syncs()s when writing the journals.
  22503 // There are four levels:
  22504 //
  22505 //	OFF       sqlite3OsSync() is never called.  This is the default
  22506 //	          for temporary and transient files.
  22507 //
  22508 //	NORMAL    The journal is synced once before writes begin on the
  22509 //	          database.  This is normally adequate protection, but
  22510 //	          it is theoretically possible, though very unlikely,
  22511 //	          that an inopertune power failure could leave the journal
  22512 //	          in a state which would cause damage to the database
  22513 //	          when it is rolled back.
  22514 //
  22515 //	FULL      The journal is synced twice before writes begin on the
  22516 //	          database (with some additional information - the nRec field
  22517 //	          of the journal header - being written in between the two
  22518 //	          syncs).  If we assume that writing a
  22519 //	          single disk sector is atomic, then this mode provides
  22520 //	          assurance that the journal will not be corrupted to the
  22521 //	          point of causing damage to the database during rollback.
  22522 //
  22523 //	EXTRA     This is like FULL except that is also syncs the directory
  22524 //	          that contains the rollback journal after the rollback
  22525 //	          journal is unlinked.
  22526 //
  22527 // The above is for a rollback-journal mode.  For WAL mode, OFF continues
  22528 // to mean that no syncs ever occur.  NORMAL means that the WAL is synced
  22529 // prior to the start of checkpoint and that the database file is synced
  22530 // at the conclusion of the checkpoint if the entire content of the WAL
  22531 // was written back into the database.  But no sync operations occur for
  22532 // an ordinary commit in NORMAL mode with WAL.  FULL means that the WAL
  22533 // file is synced following each commit operation, in addition to the
  22534 // syncs associated with NORMAL.  There is no difference between FULL
  22535 // and EXTRA for WAL mode.
  22536 //
  22537 // Do not confuse synchronous=FULL with SQLITE_SYNC_FULL.  The
  22538 // SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync
  22539 // using fcntl(F_FULLFSYNC).  SQLITE_SYNC_NORMAL means to do an
  22540 // ordinary fsync() call.  There is no difference between SQLITE_SYNC_FULL
  22541 // and SQLITE_SYNC_NORMAL on platforms other than MacOSX.  But the
  22542 // synchronous=FULL versus synchronous=NORMAL setting determines when
  22543 // the xSync primitive is called and is relevant to all platforms.
  22544 //
  22545 // Numeric values associated with these states are OFF==1, NORMAL=2,
  22546 // and FULL=3.
  22547 func Xsqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) {
  22548 	var level uint32 = pgFlags & uint32(PAGER_SYNCHRONOUS_MASK)
  22549 	if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 {
  22550 		(*Pager)(unsafe.Pointer(pPager)).FnoSync = U8(1)
  22551 		(*Pager)(unsafe.Pointer(pPager)).FfullSync = U8(0)
  22552 		(*Pager)(unsafe.Pointer(pPager)).FextraSync = U8(0)
  22553 	} else {
  22554 		(*Pager)(unsafe.Pointer(pPager)).FnoSync = func() uint8 {
  22555 			if level == uint32(PAGER_SYNCHRONOUS_OFF) {
  22556 				return uint8(1)
  22557 			}
  22558 			return uint8(0)
  22559 		}()
  22560 		(*Pager)(unsafe.Pointer(pPager)).FfullSync = func() uint8 {
  22561 			if level >= uint32(PAGER_SYNCHRONOUS_FULL) {
  22562 				return uint8(1)
  22563 			}
  22564 			return uint8(0)
  22565 		}()
  22566 		(*Pager)(unsafe.Pointer(pPager)).FextraSync = func() uint8 {
  22567 			if level == uint32(PAGER_SYNCHRONOUS_EXTRA) {
  22568 				return uint8(1)
  22569 			}
  22570 			return uint8(0)
  22571 		}()
  22572 	}
  22573 	if (*Pager)(unsafe.Pointer(pPager)).FnoSync != 0 {
  22574 		(*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0)
  22575 	} else if pgFlags&uint32(PAGER_FULLFSYNC) != 0 {
  22576 		(*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(SQLITE_SYNC_FULL)
  22577 	} else {
  22578 		(*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(SQLITE_SYNC_NORMAL)
  22579 	}
  22580 	(*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags = U8(int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) << 2)
  22581 	if (*Pager)(unsafe.Pointer(pPager)).FfullSync != 0 {
  22582 		*(*U8)(unsafe.Pointer(pPager + 11)) |= U8(int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))
  22583 	}
  22584 	if pgFlags&uint32(PAGER_CKPT_FULLFSYNC) != 0 && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) {
  22585 		*(*U8)(unsafe.Pointer(pPager + 11)) |= U8(int32(SQLITE_SYNC_FULL) << 2)
  22586 	}
  22587 	if pgFlags&uint32(PAGER_CACHESPILL) != 0 {
  22588 		*(*U8)(unsafe.Pointer(pPager + 21)) &= libc.Uint8FromInt32(libc.CplInt32(SPILLFLAG_OFF))
  22589 	} else {
  22590 		*(*U8)(unsafe.Pointer(pPager + 21)) |= U8(SPILLFLAG_OFF)
  22591 	}
  22592 }
  22593 
  22594 func pagerOpentemp(tls *libc.TLS, pPager uintptr, pFile uintptr, vfsFlags int32) int32 {
  22595 	var rc int32
  22596 
  22597 	vfsFlags = vfsFlags | (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE)
  22598 	rc = Xsqlite3OsOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), pFile, vfsFlags, uintptr(0))
  22599 
  22600 	return rc
  22601 }
  22602 
  22603 // Set the busy handler function.
  22604 //
  22605 // The pager invokes the busy-handler if sqlite3OsLock() returns
  22606 // SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock,
  22607 // or when trying to upgrade from a RESERVED lock to an EXCLUSIVE
  22608 // lock. It does *not* invoke the busy handler when upgrading from
  22609 // SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE
  22610 // (which occurs during hot-journal rollback). Summary:
  22611 //
  22612 //	Transition                        | Invokes xBusyHandler
  22613 //	--------------------------------------------------------
  22614 //	NO_LOCK       -> SHARED_LOCK      | Yes
  22615 //	SHARED_LOCK   -> RESERVED_LOCK    | No
  22616 //	SHARED_LOCK   -> EXCLUSIVE_LOCK   | No
  22617 //	RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes
  22618 //
  22619 // If the busy-handler callback returns non-zero, the lock is
  22620 // retried. If it returns zero, then the SQLITE_BUSY error is
  22621 // returned to the caller of the pager API function.
  22622 func Xsqlite3PagerSetBusyHandler(tls *libc.TLS, pPager uintptr, xBusyHandler uintptr, pBusyHandlerArg uintptr) {
  22623 	var ap uintptr
  22624 	(*Pager)(unsafe.Pointer(pPager)).FxBusyHandler = xBusyHandler
  22625 	(*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg = pBusyHandlerArg
  22626 	ap = pPager + 192
  22627 
  22628 	Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_BUSYHANDLER, ap)
  22629 }
  22630 
  22631 // Change the page size used by the Pager object. The new page size
  22632 // is passed in *pPageSize.
  22633 //
  22634 // If the pager is in the error state when this function is called, it
  22635 // is a no-op. The value returned is the error state error code (i.e.
  22636 // one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).
  22637 //
  22638 // Otherwise, if all of the following are true:
  22639 //
  22640 //   - the new page size (value of *pPageSize) is valid (a power
  22641 //     of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and
  22642 //
  22643 //   - there are no outstanding page references, and
  22644 //
  22645 //   - the database is either not an in-memory database or it is
  22646 //     an in-memory database that currently consists of zero pages.
  22647 //
  22648 // then the pager object page size is set to *pPageSize.
  22649 //
  22650 // If the page size is changed, then this function uses sqlite3PagerMalloc()
  22651 // to obtain a new Pager.pTmpSpace buffer. If this allocation attempt
  22652 // fails, SQLITE_NOMEM is returned and the page size remains unchanged.
  22653 // In all other cases, SQLITE_OK is returned.
  22654 //
  22655 // If the page size is not changed, either because one of the enumerated
  22656 // conditions above is not true, the pager was in error state when this
  22657 // function was called, or because the memory allocation attempt failed,
  22658 // then *pPageSize is set to the old, retained page size before returning.
  22659 func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, nReserve int32) int32 {
  22660 	bp := tls.Alloc(8)
  22661 	defer tls.Free(8)
  22662 
  22663 	var rc int32 = SQLITE_OK
  22664 
  22665 	var pageSize U32 = *(*U32)(unsafe.Pointer(pPageSize))
  22666 
  22667 	if (int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) == 0 || (*Pager)(unsafe.Pointer(pPager)).FdbSize == Pgno(0)) &&
  22668 		Xsqlite3PcacheRefCount(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) == int64(0) &&
  22669 		pageSize != 0 && pageSize != U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) {
  22670 		var pNew uintptr = uintptr(0)
  22671 		*(*I64)(unsafe.Pointer(bp)) = int64(0)
  22672 
  22673 		if int32((*Pager)(unsafe.Pointer(pPager)).FeState) > PAGER_OPEN && (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) {
  22674 			rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp)
  22675 		}
  22676 		if rc == SQLITE_OK {
  22677 			pNew = Xsqlite3PageMalloc(tls, int32(pageSize+U32(8)))
  22678 			if !(pNew != 0) {
  22679 				rc = SQLITE_NOMEM
  22680 			} else {
  22681 				libc.Xmemset(tls, pNew+uintptr(pageSize), 0, uint32(8))
  22682 			}
  22683 		}
  22684 
  22685 		if rc == SQLITE_OK {
  22686 			pager_reset(tls, pPager)
  22687 			rc = Xsqlite3PcacheSetPageSize(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, int32(pageSize))
  22688 		}
  22689 		if rc == SQLITE_OK {
  22690 			Xsqlite3PageFree(tls, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace)
  22691 			(*Pager)(unsafe.Pointer(pPager)).FpTmpSpace = pNew
  22692 			(*Pager)(unsafe.Pointer(pPager)).FdbSize = Pgno((*(*I64)(unsafe.Pointer(bp)) + I64(pageSize) - int64(1)) / I64(pageSize))
  22693 			(*Pager)(unsafe.Pointer(pPager)).FpageSize = I64(pageSize)
  22694 			(*Pager)(unsafe.Pointer(pPager)).FlckPgno = U32(Xsqlite3PendingByte)/pageSize + Pgno(1)
  22695 		} else {
  22696 			Xsqlite3PageFree(tls, pNew)
  22697 		}
  22698 	}
  22699 
  22700 	*(*U32)(unsafe.Pointer(pPageSize)) = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize)
  22701 	if rc == SQLITE_OK {
  22702 		if nReserve < 0 {
  22703 			nReserve = int32((*Pager)(unsafe.Pointer(pPager)).FnReserve)
  22704 		}
  22705 
  22706 		(*Pager)(unsafe.Pointer(pPager)).FnReserve = I16(nReserve)
  22707 		pagerFixMaplimit(tls, pPager)
  22708 	}
  22709 	return rc
  22710 }
  22711 
  22712 // Return a pointer to the "temporary page" buffer held internally
  22713 // by the pager.  This is a buffer that is big enough to hold the
  22714 // entire content of a database page.  This buffer is used internally
  22715 // during rollback and will be overwritten whenever a rollback
  22716 // occurs.  But other modules are free to use it too, as long as
  22717 // no rollbacks are happening.
  22718 func Xsqlite3PagerTempSpace(tls *libc.TLS, pPager uintptr) uintptr {
  22719 	return (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace
  22720 }
  22721 
  22722 // Attempt to set the maximum database page count if mxPage is positive.
  22723 // Make no changes if mxPage is zero or negative.  And never reduce the
  22724 // maximum page count below the current size of the database.
  22725 //
  22726 // Regardless of mxPage, return the current maximum page count.
  22727 func Xsqlite3PagerMaxPageCount(tls *libc.TLS, pPager uintptr, mxPage Pgno) Pgno {
  22728 	if mxPage > Pgno(0) {
  22729 		(*Pager)(unsafe.Pointer(pPager)).FmxPgno = mxPage
  22730 	}
  22731 
  22732 	return (*Pager)(unsafe.Pointer(pPager)).FmxPgno
  22733 }
  22734 
  22735 // Read the first N bytes from the beginning of the file into memory
  22736 // that pDest points to.
  22737 //
  22738 // If the pager was opened on a transient file (zFilename==""), or
  22739 // opened on a file less than N bytes in size, the output buffer is
  22740 // zeroed and SQLITE_OK returned. The rationale for this is that this
  22741 // function is used to read database headers, and a new transient or
  22742 // zero sized database has a header than consists entirely of zeroes.
  22743 //
  22744 // If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered,
  22745 // the error code is returned to the caller and the contents of the
  22746 // output buffer undefined.
  22747 func Xsqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest uintptr) int32 {
  22748 	var rc int32 = SQLITE_OK
  22749 	libc.Xmemset(tls, pDest, 0, uint32(N))
  22750 
  22751 	if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0) {
  22752 		rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pDest, N, int64(0))
  22753 		if rc == SQLITE_IOERR|int32(2)<<8 {
  22754 			rc = SQLITE_OK
  22755 		}
  22756 	}
  22757 	return rc
  22758 }
  22759 
  22760 // This function may only be called when a read-transaction is open on
  22761 // the pager. It returns the total number of pages in the database.
  22762 //
  22763 // However, if the file is between 1 and <page-size> bytes in size, then
  22764 // this is considered a 1 page file.
  22765 func Xsqlite3PagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) {
  22766 	*(*int32)(unsafe.Pointer(pnPage)) = int32((*Pager)(unsafe.Pointer(pPager)).FdbSize)
  22767 }
  22768 
  22769 func pager_wait_on_lock(tls *libc.TLS, pPager uintptr, locktype int32) int32 {
  22770 	var rc int32
  22771 
  22772 	for __ccgo := true; __ccgo; __ccgo = rc == SQLITE_BUSY && (*struct {
  22773 		f func(*libc.TLS, uintptr) int32
  22774 	})(unsafe.Pointer(&struct{ uintptr }{(*Pager)(unsafe.Pointer(pPager)).FxBusyHandler})).f(tls, (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0 {
  22775 		rc = pagerLockDb(tls, pPager, locktype)
  22776 	}
  22777 	return rc
  22778 }
  22779 
  22780 // Truncate the in-memory database file image to nPage pages. This
  22781 // function does not actually modify the database file on disk. It
  22782 // just sets the internal state of the pager object so that the
  22783 // truncation will be done when the current transaction is committed.
  22784 //
  22785 // This function is only called right before committing a transaction.
  22786 // Once this function has been called, the transaction must either be
  22787 // rolled back or committed. It is not safe to call this function and
  22788 // then continue writing to the database.
  22789 func Xsqlite3PagerTruncateImage(tls *libc.TLS, pPager uintptr, nPage Pgno) {
  22790 	(*Pager)(unsafe.Pointer(pPager)).FdbSize = nPage
  22791 
  22792 }
  22793 
  22794 func pagerSyncHotJournal(tls *libc.TLS, pPager uintptr) int32 {
  22795 	var rc int32 = SQLITE_OK
  22796 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) {
  22797 		rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, SQLITE_SYNC_NORMAL)
  22798 	}
  22799 	if rc == SQLITE_OK {
  22800 		rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, pPager+88)
  22801 	}
  22802 	return rc
  22803 }
  22804 
  22805 func pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno Pgno, pData uintptr, ppPage uintptr) int32 {
  22806 	var p uintptr
  22807 
  22808 	if (*Pager)(unsafe.Pointer(pPager)).FpMmapFreelist != 0 {
  22809 		*(*uintptr)(unsafe.Pointer(ppPage)) = libc.AssignUintptr(&p, (*Pager)(unsafe.Pointer(pPager)).FpMmapFreelist)
  22810 		(*Pager)(unsafe.Pointer(pPager)).FpMmapFreelist = (*PgHdr)(unsafe.Pointer(p)).FpDirty
  22811 		(*PgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0)
  22812 
  22813 		libc.Xmemset(tls, (*PgHdr)(unsafe.Pointer(p)).FpExtra, 0, uint32(8))
  22814 	} else {
  22815 		*(*uintptr)(unsafe.Pointer(ppPage)) = libc.AssignUintptr(&p, Xsqlite3MallocZero(tls, uint64(uint32(unsafe.Sizeof(PgHdr{}))+uint32((*Pager)(unsafe.Pointer(pPager)).FnExtra))))
  22816 		if p == uintptr(0) {
  22817 			Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, I64(pgno-Pgno(1))*(*Pager)(unsafe.Pointer(pPager)).FpageSize, pData)
  22818 			return SQLITE_NOMEM
  22819 		}
  22820 		(*PgHdr)(unsafe.Pointer(p)).FpExtra = p + 1*48
  22821 		(*PgHdr)(unsafe.Pointer(p)).Fflags = U16(PGHDR_MMAP)
  22822 		(*PgHdr)(unsafe.Pointer(p)).FnRef = int64(1)
  22823 		(*PgHdr)(unsafe.Pointer(p)).FpPager = pPager
  22824 	}
  22825 
  22826 	(*PgHdr)(unsafe.Pointer(p)).Fpgno = pgno
  22827 	(*PgHdr)(unsafe.Pointer(p)).FpData = pData
  22828 	(*Pager)(unsafe.Pointer(pPager)).FnMmapOut++
  22829 
  22830 	return SQLITE_OK
  22831 }
  22832 
  22833 func pagerReleaseMapPage(tls *libc.TLS, pPg uintptr) {
  22834 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  22835 	(*Pager)(unsafe.Pointer(pPager)).FnMmapOut--
  22836 	(*PgHdr)(unsafe.Pointer(pPg)).FpDirty = (*Pager)(unsafe.Pointer(pPager)).FpMmapFreelist
  22837 	(*Pager)(unsafe.Pointer(pPager)).FpMmapFreelist = pPg
  22838 
  22839 	Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, I64((*PgHdr)(unsafe.Pointer(pPg)).Fpgno-Pgno(1))*(*Pager)(unsafe.Pointer(pPager)).FpageSize, (*PgHdr)(unsafe.Pointer(pPg)).FpData)
  22840 }
  22841 
  22842 func pagerFreeMapHdrs(tls *libc.TLS, pPager uintptr) {
  22843 	var p uintptr
  22844 	var pNext uintptr
  22845 	for p = (*Pager)(unsafe.Pointer(pPager)).FpMmapFreelist; p != 0; p = pNext {
  22846 		pNext = (*PgHdr)(unsafe.Pointer(p)).FpDirty
  22847 		Xsqlite3_free(tls, p)
  22848 	}
  22849 }
  22850 
  22851 func databaseIsUnmoved(tls *libc.TLS, pPager uintptr) int32 {
  22852 	bp := tls.Alloc(4)
  22853 	defer tls.Free(4)
  22854 
  22855 	*(*int32)(unsafe.Pointer(bp)) = 0
  22856 	var rc int32
  22857 
  22858 	if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 {
  22859 		return SQLITE_OK
  22860 	}
  22861 	if (*Pager)(unsafe.Pointer(pPager)).FdbSize == Pgno(0) {
  22862 		return SQLITE_OK
  22863 	}
  22864 
  22865 	rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_HAS_MOVED, bp)
  22866 	if rc == SQLITE_NOTFOUND {
  22867 		rc = SQLITE_OK
  22868 	} else if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp)) != 0 {
  22869 		rc = SQLITE_READONLY | int32(4)<<8
  22870 	}
  22871 	return rc
  22872 }
  22873 
  22874 // Shutdown the page cache.  Free all memory and close all files.
  22875 //
  22876 // If a transaction was in progress when this routine is called, that
  22877 // transaction is rolled back.  All outstanding pages are invalidated
  22878 // and their memory is freed.  Any attempt to use a page associated
  22879 // with this page cache after this function returns will likely
  22880 // result in a coredump.
  22881 //
  22882 // This function always succeeds. If a transaction is active an attempt
  22883 // is made to roll it back. If an error occurs during the rollback
  22884 // a hot journal may be left in the filesystem but no error is returned
  22885 // to the caller.
  22886 func Xsqlite3PagerClose(tls *libc.TLS, pPager uintptr, db uintptr) int32 {
  22887 	var pTmp uintptr = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace
  22888 
  22889 	Xsqlite3BeginBenignMalloc(tls)
  22890 	pagerFreeMapHdrs(tls, pPager)
  22891 
  22892 	(*Pager)(unsafe.Pointer(pPager)).FexclusiveMode = U8(0)
  22893 	{
  22894 		var a uintptr = uintptr(0)
  22895 
  22896 		if db != 0 && uint64(0) == (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NoCkptOnClose) &&
  22897 			SQLITE_OK == databaseIsUnmoved(tls, pPager) {
  22898 			a = pTmp
  22899 		}
  22900 		Xsqlite3WalClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), a)
  22901 		(*Pager)(unsafe.Pointer(pPager)).FpWal = uintptr(0)
  22902 
  22903 	}
  22904 	pager_reset(tls, pPager)
  22905 	if (*Pager)(unsafe.Pointer(pPager)).FmemDb != 0 {
  22906 		pager_unlock(tls, pPager)
  22907 	} else {
  22908 		if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) {
  22909 			pager_error(tls, pPager, pagerSyncHotJournal(tls, pPager))
  22910 		}
  22911 		pagerUnlockAndRollback(tls, pPager)
  22912 	}
  22913 	Xsqlite3EndBenignMalloc(tls)
  22914 
  22915 	Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  22916 	Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd)
  22917 	Xsqlite3PageFree(tls, pTmp)
  22918 	Xsqlite3PcacheClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  22919 
  22920 	Xsqlite3_free(tls, pPager)
  22921 	return SQLITE_OK
  22922 }
  22923 
  22924 // Increment the reference count for page pPg.
  22925 func Xsqlite3PagerRef(tls *libc.TLS, pPg uintptr) {
  22926 	Xsqlite3PcacheRef(tls, pPg)
  22927 }
  22928 
  22929 func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 {
  22930 	bp := tls.Alloc(20)
  22931 	defer tls.Free(20)
  22932 
  22933 	var rc int32
  22934 
  22935 	rc = Xsqlite3PagerExclusiveLock(tls, pPager)
  22936 	if rc != SQLITE_OK {
  22937 		return rc
  22938 	}
  22939 
  22940 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) {
  22941 		if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_MEMORY {
  22942 			var iDc int32 = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd)
  22943 
  22944 			if 0 == iDc&SQLITE_IOCAP_SAFE_APPEND {
  22945 				var iNextHdrOffset I64
  22946 
  22947 				libc.Xmemcpy(tls, bp, uintptr(unsafe.Pointer(&aJournalMagic)), uint32(unsafe.Sizeof(aJournalMagic)))
  22948 				Xsqlite3Put4byte(tls, bp+8, uint32((*Pager)(unsafe.Pointer(pPager)).FnRec))
  22949 
  22950 				iNextHdrOffset = journalHdrOffset(tls, pPager)
  22951 				rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+12, 8, iNextHdrOffset)
  22952 				if rc == SQLITE_OK && 0 == libc.Xmemcmp(tls, bp+12, uintptr(unsafe.Pointer(&aJournalMagic)), uint32(8)) {
  22953 					rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&zerobyte)), 1, iNextHdrOffset)
  22954 				}
  22955 				if rc != SQLITE_OK && rc != SQLITE_IOERR|int32(2)<<8 {
  22956 					return rc
  22957 				}
  22958 
  22959 				if (*Pager)(unsafe.Pointer(pPager)).FfullSync != 0 && 0 == iDc&SQLITE_IOCAP_SEQUENTIAL {
  22960 					rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))
  22961 					if rc != SQLITE_OK {
  22962 						return rc
  22963 					}
  22964 				}
  22965 
  22966 				rc = Xsqlite3OsWrite(tls,
  22967 					(*Pager)(unsafe.Pointer(pPager)).Fjfd, bp, int32(unsafe.Sizeof([12]U8{})), (*Pager)(unsafe.Pointer(pPager)).FjournalHdr)
  22968 				if rc != SQLITE_OK {
  22969 					return rc
  22970 				}
  22971 			}
  22972 			if 0 == iDc&SQLITE_IOCAP_SEQUENTIAL {
  22973 				rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags)|func() int32 {
  22974 					if int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) == SQLITE_SYNC_FULL {
  22975 						return SQLITE_SYNC_DATAONLY
  22976 					}
  22977 					return 0
  22978 				}())
  22979 				if rc != SQLITE_OK {
  22980 					return rc
  22981 				}
  22982 			}
  22983 
  22984 			(*Pager)(unsafe.Pointer(pPager)).FjournalHdr = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  22985 			if newHdr != 0 && 0 == iDc&SQLITE_IOCAP_SAFE_APPEND {
  22986 				(*Pager)(unsafe.Pointer(pPager)).FnRec = 0
  22987 				rc = writeJournalHdr(tls, pPager)
  22988 				if rc != SQLITE_OK {
  22989 					return rc
  22990 				}
  22991 			}
  22992 		} else {
  22993 			(*Pager)(unsafe.Pointer(pPager)).FjournalHdr = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  22994 		}
  22995 	}
  22996 
  22997 	Xsqlite3PcacheClearSyncFlags(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  22998 	(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_WRITER_DBMOD)
  22999 
  23000 	return SQLITE_OK
  23001 }
  23002 
  23003 var zerobyte U8 = U8(0)
  23004 
  23005 func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 {
  23006 	bp := tls.Alloc(8)
  23007 	defer tls.Free(8)
  23008 
  23009 	var rc int32 = SQLITE_OK
  23010 
  23011 	if !((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0)) {
  23012 		rc = pagerOpentemp(tls, pPager, (*Pager)(unsafe.Pointer(pPager)).Ffd, int32((*Pager)(unsafe.Pointer(pPager)).FvfsFlags))
  23013 	}
  23014 
  23015 	if rc == SQLITE_OK &&
  23016 		(*Pager)(unsafe.Pointer(pPager)).FdbHintSize < (*Pager)(unsafe.Pointer(pPager)).FdbSize &&
  23017 		((*PgHdr)(unsafe.Pointer(pList)).FpDirty != 0 || (*PgHdr)(unsafe.Pointer(pList)).Fpgno > (*Pager)(unsafe.Pointer(pPager)).FdbHintSize) {
  23018 		*(*Sqlite3_int64)(unsafe.Pointer(bp)) = (*Pager)(unsafe.Pointer(pPager)).FpageSize * Sqlite3_int64((*Pager)(unsafe.Pointer(pPager)).FdbSize)
  23019 		Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SIZE_HINT, bp)
  23020 		(*Pager)(unsafe.Pointer(pPager)).FdbHintSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize
  23021 	}
  23022 
  23023 	for rc == SQLITE_OK && pList != 0 {
  23024 		var pgno Pgno = (*PgHdr)(unsafe.Pointer(pList)).Fpgno
  23025 
  23026 		if pgno <= (*Pager)(unsafe.Pointer(pPager)).FdbSize && 0 == int32((*PgHdr)(unsafe.Pointer(pList)).Fflags)&PGHDR_DONT_WRITE {
  23027 			var offset I64 = I64(pgno-Pgno(1)) * (*Pager)(unsafe.Pointer(pPager)).FpageSize
  23028 			var pData uintptr
  23029 
  23030 			if (*PgHdr)(unsafe.Pointer(pList)).Fpgno == Pgno(1) {
  23031 				pager_write_changecounter(tls, pList)
  23032 			}
  23033 
  23034 			pData = (*PgHdr)(unsafe.Pointer(pList)).FpData
  23035 
  23036 			rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pData, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), offset)
  23037 
  23038 			if pgno == Pgno(1) {
  23039 				libc.Xmemcpy(tls, pPager+112, pData+24, uint32(unsafe.Sizeof([16]uint8{})))
  23040 			}
  23041 			if pgno > (*Pager)(unsafe.Pointer(pPager)).FdbFileSize {
  23042 				(*Pager)(unsafe.Pointer(pPager)).FdbFileSize = pgno
  23043 			}
  23044 			*(*int32)(unsafe.Pointer(pPager + 200 + 2*4))++
  23045 
  23046 			Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, pgno, (*PgHdr)(unsafe.Pointer(pList)).FpData)
  23047 
  23048 		} else {
  23049 		}
  23050 
  23051 		pList = (*PgHdr)(unsafe.Pointer(pList)).FpDirty
  23052 	}
  23053 
  23054 	return rc
  23055 }
  23056 
  23057 func openSubJournal(tls *libc.TLS, pPager uintptr) int32 {
  23058 	var rc int32 = SQLITE_OK
  23059 	if !((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fsjfd)).FpMethods != uintptr(0)) {
  23060 		var flags int32 = SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE |
  23061 			SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE |
  23062 			SQLITE_OPEN_DELETEONCLOSE
  23063 		var nStmtSpill int32 = Xsqlite3Config.FnStmtSpill
  23064 		if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY || (*Pager)(unsafe.Pointer(pPager)).FsubjInMemory != 0 {
  23065 			nStmtSpill = -1
  23066 		}
  23067 		rc = Xsqlite3JournalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), (*Pager)(unsafe.Pointer(pPager)).Fsjfd, flags, nStmtSpill)
  23068 	}
  23069 	return rc
  23070 }
  23071 
  23072 func subjournalPage(tls *libc.TLS, pPg uintptr) int32 {
  23073 	var rc int32 = SQLITE_OK
  23074 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  23075 	if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF {
  23076 		rc = openSubJournal(tls, pPager)
  23077 
  23078 		if rc == SQLITE_OK {
  23079 			var pData uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpData
  23080 			var offset I64 = I64((*Pager)(unsafe.Pointer(pPager)).FnSubRec) * (int64(4) + (*Pager)(unsafe.Pointer(pPager)).FpageSize)
  23081 			var pData2 uintptr
  23082 			pData2 = pData
  23083 
  23084 			rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, offset, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno)
  23085 			if rc == SQLITE_OK {
  23086 				rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, pData2, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), offset+int64(4))
  23087 			}
  23088 		}
  23089 	}
  23090 	if rc == SQLITE_OK {
  23091 		(*Pager)(unsafe.Pointer(pPager)).FnSubRec++
  23092 
  23093 		rc = addToSavepointBitvecs(tls, pPager, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno)
  23094 	}
  23095 	return rc
  23096 }
  23097 
  23098 func subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) int32 {
  23099 	if subjRequiresPage(tls, pPg) != 0 {
  23100 		return subjournalPage(tls, pPg)
  23101 	} else {
  23102 		return SQLITE_OK
  23103 	}
  23104 	return int32(0)
  23105 }
  23106 
  23107 func pagerStress(tls *libc.TLS, p uintptr, pPg uintptr) int32 {
  23108 	var pPager uintptr = p
  23109 	var rc int32 = SQLITE_OK
  23110 
  23111 	if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  23112 		return SQLITE_OK
  23113 	}
  23114 
  23115 	if (*Pager)(unsafe.Pointer(pPager)).FdoNotSpill != 0 &&
  23116 		(int32((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill)&(SPILLFLAG_ROLLBACK|SPILLFLAG_OFF) != 0 ||
  23117 			int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags)&PGHDR_NEED_SYNC != 0) {
  23118 		return SQLITE_OK
  23119 	}
  23120 
  23121 	*(*int32)(unsafe.Pointer(pPager + 200 + 3*4))++
  23122 	(*PgHdr)(unsafe.Pointer(pPg)).FpDirty = uintptr(0)
  23123 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  23124 		rc = subjournalPageIfRequired(tls, pPg)
  23125 		if rc == SQLITE_OK {
  23126 			rc = pagerWalFrames(tls, pPager, pPg, uint32(0), 0)
  23127 		}
  23128 	} else {
  23129 		if int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags)&PGHDR_NEED_SYNC != 0 ||
  23130 			int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_CACHEMOD {
  23131 			rc = syncJournal(tls, pPager, 1)
  23132 		}
  23133 
  23134 		if rc == SQLITE_OK {
  23135 			rc = pager_write_pagelist(tls, pPager, pPg)
  23136 		}
  23137 	}
  23138 
  23139 	if rc == SQLITE_OK {
  23140 		Xsqlite3PcacheMakeClean(tls, pPg)
  23141 	}
  23142 
  23143 	return pager_error(tls, pPager, rc)
  23144 }
  23145 
  23146 // Flush all unreferenced dirty pages to disk.
  23147 func Xsqlite3PagerFlush(tls *libc.TLS, pPager uintptr) int32 {
  23148 	var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode
  23149 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) {
  23150 		var pList uintptr = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  23151 
  23152 		for rc == SQLITE_OK && pList != 0 {
  23153 			var pNext uintptr = (*PgHdr)(unsafe.Pointer(pList)).FpDirty
  23154 			if (*PgHdr)(unsafe.Pointer(pList)).FnRef == int64(0) {
  23155 				rc = pagerStress(tls, pPager, pList)
  23156 			}
  23157 			pList = pNext
  23158 		}
  23159 	}
  23160 
  23161 	return rc
  23162 }
  23163 
  23164 // Allocate and initialize a new Pager object and put a pointer to it
  23165 // in *ppPager. The pager should eventually be freed by passing it
  23166 // to sqlite3PagerClose().
  23167 //
  23168 // The zFilename argument is the path to the database file to open.
  23169 // If zFilename is NULL then a randomly-named temporary file is created
  23170 // and used as the file to be cached. Temporary files are be deleted
  23171 // automatically when they are closed. If zFilename is ":memory:" then
  23172 // all information is held in cache. It is never written to disk.
  23173 // This can be used to implement an in-memory database.
  23174 //
  23175 // The nExtra parameter specifies the number of bytes of space allocated
  23176 // along with each page reference. This space is available to the user
  23177 // via the sqlite3PagerGetExtra() API.  When a new page is allocated, the
  23178 // first 8 bytes of this space are zeroed but the remainder is uninitialized.
  23179 // (The extra space is used by btree as the MemPage object.)
  23180 //
  23181 // The flags argument is used to specify properties that affect the
  23182 // operation of the pager. It should be passed some bitwise combination
  23183 // of the PAGER_* flags.
  23184 //
  23185 // The vfsFlags parameter is a bitmask to pass to the flags parameter
  23186 // of the xOpen() method of the supplied VFS when opening files.
  23187 //
  23188 // If the pager object is allocated and the specified file opened
  23189 // successfully, SQLITE_OK is returned and *ppPager set to point to
  23190 // the new pager object. If an error occurs, *ppPager is set to NULL
  23191 // and error code returned. This function may return SQLITE_NOMEM
  23192 // (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or
  23193 // various SQLITE_IO_XXX errors.
  23194 func Xsqlite3PagerOpen(tls *libc.TLS, pVfs uintptr, ppPager uintptr, zFilename uintptr, nExtra int32, flags int32, vfsFlags int32, xReinit uintptr) int32 {
  23195 	bp := tls.Alloc(12)
  23196 	defer tls.Free(12)
  23197 
  23198 	var pPtr uintptr
  23199 	_ = pPtr
  23200 
  23201 	var rc int32
  23202 	var tempFile int32
  23203 	var memDb int32
  23204 	var memJM int32
  23205 	var readOnly int32
  23206 	var journalFileSize int32
  23207 	var zPathname uintptr
  23208 	var nPathname int32
  23209 	var useJournal int32
  23210 	var pcacheSize int32
  23211 
  23212 	var zUri uintptr
  23213 	var nUriByte int32
  23214 	var z uintptr
  23215 	var iDc int32
  23216 
  23217 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  23218 	rc = SQLITE_OK
  23219 	tempFile = 0
  23220 	memDb = 0
  23221 	memJM = 0
  23222 	readOnly = 0
  23223 	zPathname = uintptr(0)
  23224 	nPathname = 0
  23225 	useJournal = libc.Bool32(flags&PAGER_OMIT_JOURNAL == 0)
  23226 	pcacheSize = Xsqlite3PcacheSize(tls)
  23227 	*(*U32)(unsafe.Pointer(bp + 8)) = U32(SQLITE_DEFAULT_PAGE_SIZE)
  23228 	zUri = uintptr(0)
  23229 	nUriByte = 1
  23230 
  23231 	journalFileSize = (Xsqlite3JournalSize(tls, pVfs) + 7) & libc.CplInt32(7)
  23232 
  23233 	*(*uintptr)(unsafe.Pointer(ppPager)) = uintptr(0)
  23234 
  23235 	if !(flags&PAGER_MEMORY != 0) {
  23236 		goto __1
  23237 	}
  23238 	memDb = 1
  23239 	if !(zFilename != 0 && *(*uint8)(unsafe.Pointer(zFilename)) != 0) {
  23240 		goto __2
  23241 	}
  23242 	zPathname = Xsqlite3DbStrDup(tls, uintptr(0), zFilename)
  23243 	if !(zPathname == uintptr(0)) {
  23244 		goto __3
  23245 	}
  23246 	return SQLITE_NOMEM
  23247 __3:
  23248 	;
  23249 	nPathname = Xsqlite3Strlen30(tls, zPathname)
  23250 	zFilename = uintptr(0)
  23251 __2:
  23252 	;
  23253 __1:
  23254 	;
  23255 	if !(zFilename != 0 && *(*uint8)(unsafe.Pointer(zFilename)) != 0) {
  23256 		goto __4
  23257 	}
  23258 	nPathname = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + 1
  23259 	zPathname = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(nPathname*2))
  23260 	if !(zPathname == uintptr(0)) {
  23261 		goto __5
  23262 	}
  23263 	return SQLITE_NOMEM
  23264 __5:
  23265 	;
  23266 	*(*uint8)(unsafe.Pointer(zPathname)) = uint8(0)
  23267 	rc = Xsqlite3OsFullPathname(tls, pVfs, zFilename, nPathname, zPathname)
  23268 	if !(rc != SQLITE_OK) {
  23269 		goto __6
  23270 	}
  23271 	if !(rc == SQLITE_OK|int32(2)<<8) {
  23272 		goto __7
  23273 	}
  23274 	if !(vfsFlags&SQLITE_OPEN_NOFOLLOW != 0) {
  23275 		goto __8
  23276 	}
  23277 	rc = SQLITE_CANTOPEN | int32(6)<<8
  23278 	goto __9
  23279 __8:
  23280 	rc = SQLITE_OK
  23281 __9:
  23282 	;
  23283 __7:
  23284 	;
  23285 __6:
  23286 	;
  23287 	nPathname = Xsqlite3Strlen30(tls, zPathname)
  23288 	z = libc.AssignUintptr(&zUri, zFilename+uintptr(Xsqlite3Strlen30(tls, zFilename)+1))
  23289 __10:
  23290 	if !(*(*uint8)(unsafe.Pointer(z)) != 0) {
  23291 		goto __11
  23292 	}
  23293 	z += uintptr(libc.Xstrlen(tls, z) + Size_t(1))
  23294 	z += uintptr(libc.Xstrlen(tls, z) + Size_t(1))
  23295 	goto __10
  23296 __11:
  23297 	;
  23298 	nUriByte = (int32(z+1) - int32(zUri)) / 1
  23299 
  23300 	if !(rc == SQLITE_OK && nPathname+8 > (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname) {
  23301 		goto __12
  23302 	}
  23303 
  23304 	rc = Xsqlite3CantopenError(tls, 60239)
  23305 __12:
  23306 	;
  23307 	if !(rc != SQLITE_OK) {
  23308 		goto __13
  23309 	}
  23310 	Xsqlite3DbFree(tls, uintptr(0), zPathname)
  23311 	return rc
  23312 __13:
  23313 	;
  23314 __4:
  23315 	;
  23316 	pPtr = Xsqlite3MallocZero(tls,
  23317 		uint64((uint32(unsafe.Sizeof(Pager{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7))+uint32((pcacheSize+7)&libc.CplInt32(7))+uint32(((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile+7)&libc.CplInt32(7))+uint32(journalFileSize*2)+uint32(unsafe.Sizeof(uintptr(0)))+uint32(4)+uint32(nPathname)+uint32(1)+uint32(nUriByte)+uint32(nPathname)+uint32(8)+uint32(1)+uint32(nPathname)+uint32(4)+uint32(1)+uint32(3)))
  23318 
  23319 	if !!(pPtr != 0) {
  23320 		goto __14
  23321 	}
  23322 	Xsqlite3DbFree(tls, uintptr(0), zPathname)
  23323 	return SQLITE_NOMEM
  23324 __14:
  23325 	;
  23326 	*(*uintptr)(unsafe.Pointer(bp)) = pPtr
  23327 	pPtr += uintptr((uint32(unsafe.Sizeof(Pager{})) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  23328 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpPCache = pPtr
  23329 	pPtr += uintptr((pcacheSize + 7) & libc.CplInt32(7))
  23330 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ffd = pPtr
  23331 	pPtr += uintptr(((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile + 7) & libc.CplInt32(7))
  23332 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fsjfd = pPtr
  23333 	pPtr += uintptr(journalFileSize)
  23334 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fjfd = pPtr
  23335 	pPtr += uintptr(journalFileSize)
  23336 
  23337 	libc.Xmemcpy(tls, pPtr, bp, uint32(unsafe.Sizeof(uintptr(0))))
  23338 	pPtr += unsafe.Sizeof(uintptr(0))
  23339 
  23340 	pPtr += uintptr(4)
  23341 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzFilename = pPtr
  23342 	if !(nPathname > 0) {
  23343 		goto __15
  23344 	}
  23345 	libc.Xmemcpy(tls, pPtr, zPathname, uint32(nPathname))
  23346 	pPtr += uintptr(nPathname + 1)
  23347 	if !(zUri != 0) {
  23348 		goto __16
  23349 	}
  23350 	libc.Xmemcpy(tls, pPtr, zUri, uint32(nUriByte))
  23351 	pPtr += uintptr(nUriByte)
  23352 	goto __17
  23353 __16:
  23354 	pPtr++
  23355 __17:
  23356 	;
  23357 __15:
  23358 	;
  23359 	if !(nPathname > 0) {
  23360 		goto __18
  23361 	}
  23362 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzJournal = pPtr
  23363 	libc.Xmemcpy(tls, pPtr, zPathname, uint32(nPathname))
  23364 	pPtr += uintptr(nPathname)
  23365 	libc.Xmemcpy(tls, pPtr, ts+3921, uint32(8))
  23366 	pPtr += uintptr(8 + 1)
  23367 	goto __19
  23368 __18:
  23369 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzJournal = uintptr(0)
  23370 __19:
  23371 	;
  23372 	if !(nPathname > 0) {
  23373 		goto __20
  23374 	}
  23375 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzWal = pPtr
  23376 	libc.Xmemcpy(tls, pPtr, zPathname, uint32(nPathname))
  23377 	pPtr += uintptr(nPathname)
  23378 	libc.Xmemcpy(tls, pPtr, ts+3930, uint32(4))
  23379 	pPtr += uintptr(4 + 1)
  23380 	goto __21
  23381 __20:
  23382 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzWal = uintptr(0)
  23383 __21:
  23384 	;
  23385 	_ = pPtr
  23386 
  23387 	if !(nPathname != 0) {
  23388 		goto __22
  23389 	}
  23390 	Xsqlite3DbFree(tls, uintptr(0), zPathname)
  23391 __22:
  23392 	;
  23393 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpVfs = pVfs
  23394 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FvfsFlags = U32(vfsFlags)
  23395 
  23396 	if !(zFilename != 0 && *(*uint8)(unsafe.Pointer(zFilename)) != 0) {
  23397 		goto __23
  23398 	}
  23399 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
  23400 	rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzFilename, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ffd, vfsFlags, bp+4)
  23401 
  23402 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FmemVfs = U8(libc.AssignInt32(&memJM, libc.Bool32(*(*int32)(unsafe.Pointer(bp + 4))&SQLITE_OPEN_MEMORY != 0)))
  23403 	readOnly = libc.Bool32(*(*int32)(unsafe.Pointer(bp + 4))&SQLITE_OPEN_READONLY != 0)
  23404 
  23405 	if !(rc == SQLITE_OK) {
  23406 		goto __25
  23407 	}
  23408 	iDc = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ffd)
  23409 	if !!(readOnly != 0) {
  23410 		goto __26
  23411 	}
  23412 	setSectorSize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  23413 
  23414 	if !(*(*U32)(unsafe.Pointer(bp + 8)) < (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FsectorSize) {
  23415 		goto __27
  23416 	}
  23417 	if !((*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FsectorSize > U32(SQLITE_MAX_DEFAULT_PAGE_SIZE)) {
  23418 		goto __28
  23419 	}
  23420 	*(*U32)(unsafe.Pointer(bp + 8)) = U32(SQLITE_MAX_DEFAULT_PAGE_SIZE)
  23421 	goto __29
  23422 __28:
  23423 	*(*U32)(unsafe.Pointer(bp + 8)) = (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FsectorSize
  23424 __29:
  23425 	;
  23426 __27:
  23427 	;
  23428 __26:
  23429 	;
  23430 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnoLock = U8(Xsqlite3_uri_boolean(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzFilename, ts+3935, 0))
  23431 	if !(iDc&SQLITE_IOCAP_IMMUTABLE != 0 ||
  23432 		Xsqlite3_uri_boolean(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzFilename, ts+3942, 0) != 0) {
  23433 		goto __30
  23434 	}
  23435 	vfsFlags = vfsFlags | SQLITE_OPEN_READONLY
  23436 	goto act_like_temp_file
  23437 __30:
  23438 	;
  23439 __25:
  23440 	;
  23441 	goto __24
  23442 __23:
  23443 act_like_temp_file:
  23444 	tempFile = 1
  23445 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FeState = U8(PAGER_READER)
  23446 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FeLock = U8(EXCLUSIVE_LOCK)
  23447 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnoLock = U8(1)
  23448 	readOnly = vfsFlags & SQLITE_OPEN_READONLY
  23449 __24:
  23450 	;
  23451 	if !(rc == SQLITE_OK) {
  23452 		goto __31
  23453 	}
  23454 
  23455 	rc = Xsqlite3PagerSetPagesize(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+8, -1)
  23456 
  23457 __31:
  23458 	;
  23459 	if !(rc == SQLITE_OK) {
  23460 		goto __32
  23461 	}
  23462 	nExtra = (nExtra + 7) & libc.CplInt32(7)
  23463 
  23464 	rc = Xsqlite3PcacheOpen(tls, int32(*(*U32)(unsafe.Pointer(bp + 8))), nExtra, libc.BoolInt32(!(memDb != 0)),
  23465 		func() uintptr {
  23466 			if !(memDb != 0) {
  23467 				return *(*uintptr)(unsafe.Pointer(&struct {
  23468 					f func(*libc.TLS, uintptr, uintptr) int32
  23469 				}{pagerStress}))
  23470 			}
  23471 			return uintptr(0)
  23472 		}(), *(*uintptr)(unsafe.Pointer(bp)), (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpPCache)
  23473 __32:
  23474 	;
  23475 	if !(rc != SQLITE_OK) {
  23476 		goto __33
  23477 	}
  23478 	Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ffd)
  23479 	Xsqlite3PageFree(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpTmpSpace)
  23480 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp)))
  23481 	return rc
  23482 __33:
  23483 	;
  23484 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FuseJournal = U8(useJournal)
  23485 
  23486 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FmxPgno = Pgno(SQLITE_MAX_PAGE_COUNT)
  23487 
  23488 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FtempFile = U8(tempFile)
  23489 
  23490 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FexclusiveMode = U8(tempFile)
  23491 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FchangeCountDone = (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FtempFile
  23492 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FmemDb = U8(memDb)
  23493 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FreadOnly = U8(readOnly)
  23494 
  23495 	Xsqlite3PagerSetFlags(tls, *(*uintptr)(unsafe.Pointer(bp)), uint32(SQLITE_DEFAULT_SYNCHRONOUS+1|PAGER_CACHESPILL))
  23496 
  23497 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnExtra = U16(nExtra)
  23498 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FjournalSizeLimit = int64(-1)
  23499 
  23500 	setSectorSize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  23501 	if !!(useJournal != 0) {
  23502 		goto __34
  23503 	}
  23504 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FjournalMode = U8(PAGER_JOURNALMODE_OFF)
  23505 	goto __35
  23506 __34:
  23507 	if !(memDb != 0 || memJM != 0) {
  23508 		goto __36
  23509 	}
  23510 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FjournalMode = U8(PAGER_JOURNALMODE_MEMORY)
  23511 __36:
  23512 	;
  23513 __35:
  23514 	;
  23515 	(*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FxReiniter = xReinit
  23516 	setGetterMethod(tls, *(*uintptr)(unsafe.Pointer(bp)))
  23517 
  23518 	*(*uintptr)(unsafe.Pointer(ppPager)) = *(*uintptr)(unsafe.Pointer(bp))
  23519 	return SQLITE_OK
  23520 }
  23521 
  23522 // Return the sqlite3_file for the main database given the name
  23523 // of the corresonding WAL or Journal name as passed into
  23524 // xOpen.
  23525 func Xsqlite3_database_file_object(tls *libc.TLS, zName uintptr) uintptr {
  23526 	var pPager uintptr
  23527 	for int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-1)))) != 0 || int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-2)))) != 0 || int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-3)))) != 0 || int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-4)))) != 0 {
  23528 		zName--
  23529 	}
  23530 	pPager = *(*uintptr)(unsafe.Pointer(zName - uintptr(4) - uintptr(uint32(unsafe.Sizeof(uintptr(0))))))
  23531 	return (*Pager)(unsafe.Pointer(pPager)).Ffd
  23532 }
  23533 
  23534 func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 {
  23535 	bp := tls.Alloc(17)
  23536 	defer tls.Free(17)
  23537 
  23538 	var pVfs uintptr = (*Pager)(unsafe.Pointer(pPager)).FpVfs
  23539 	var rc int32 = SQLITE_OK
  23540 	*(*int32)(unsafe.Pointer(bp)) = 1
  23541 	var jrnlOpen int32 = libc.BoolInt32(!!((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0)))
  23542 
  23543 	*(*int32)(unsafe.Pointer(pExists)) = 0
  23544 	if !(jrnlOpen != 0) {
  23545 		rc = Xsqlite3OsAccess(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp)
  23546 	}
  23547 	if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp)) != 0 {
  23548 		*(*int32)(unsafe.Pointer(bp + 4)) = 0
  23549 
  23550 		rc = Xsqlite3OsCheckReservedLock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp+4)
  23551 		if rc == SQLITE_OK && !(*(*int32)(unsafe.Pointer(bp + 4)) != 0) {
  23552 			rc = pagerPagecount(tls, pPager, bp+8)
  23553 			if rc == SQLITE_OK {
  23554 				if *(*Pgno)(unsafe.Pointer(bp + 8)) == Pgno(0) && !(jrnlOpen != 0) {
  23555 					Xsqlite3BeginBenignMalloc(tls)
  23556 					if pagerLockDb(tls, pPager, RESERVED_LOCK) == SQLITE_OK {
  23557 						Xsqlite3OsDelete(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0)
  23558 						if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) {
  23559 							pagerUnlockDb(tls, pPager, SHARED_LOCK)
  23560 						}
  23561 					}
  23562 					Xsqlite3EndBenignMalloc(tls)
  23563 				} else {
  23564 					if !(jrnlOpen != 0) {
  23565 						*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL
  23566 						rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, *(*int32)(unsafe.Pointer(bp + 12)), bp+12)
  23567 					}
  23568 					if rc == SQLITE_OK {
  23569 						*(*U8)(unsafe.Pointer(bp + 16)) = U8(0)
  23570 						rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+16, 1, int64(0))
  23571 						if rc == SQLITE_IOERR|int32(2)<<8 {
  23572 							rc = SQLITE_OK
  23573 						}
  23574 						if !(jrnlOpen != 0) {
  23575 							Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  23576 						}
  23577 						*(*int32)(unsafe.Pointer(pExists)) = libc.Bool32(int32(*(*U8)(unsafe.Pointer(bp + 16))) != 0)
  23578 					} else if rc == SQLITE_CANTOPEN {
  23579 						*(*int32)(unsafe.Pointer(pExists)) = 1
  23580 						rc = SQLITE_OK
  23581 					}
  23582 				}
  23583 			}
  23584 		}
  23585 	}
  23586 
  23587 	return rc
  23588 }
  23589 
  23590 // This function is called to obtain a shared lock on the database file.
  23591 // It is illegal to call sqlite3PagerGet() until after this function
  23592 // has been successfully called. If a shared-lock is already held when
  23593 // this function is called, it is a no-op.
  23594 //
  23595 // The following operations are also performed by this function.
  23596 //
  23597 //  1. If the pager is currently in PAGER_OPEN state (no lock held
  23598 //     on the database file), then an attempt is made to obtain a
  23599 //     SHARED lock on the database file. Immediately after obtaining
  23600 //     the SHARED lock, the file-system is checked for a hot-journal,
  23601 //     which is played back if present. Following any hot-journal
  23602 //     rollback, the contents of the cache are validated by checking
  23603 //     the 'change-counter' field of the database file header and
  23604 //     discarded if they are found to be invalid.
  23605 //
  23606 //  2. If the pager is running in exclusive-mode, and there are currently
  23607 //     no outstanding references to any pages, and is in the error state,
  23608 //     then an attempt is made to clear the error state by discarding
  23609 //     the contents of the page cache and rolling back any open journal
  23610 //     file.
  23611 //
  23612 // If everything is successful, SQLITE_OK is returned. If an IO error
  23613 // occurs while locking the database, checking for a hot-journal file or
  23614 // rolling back a journal file, the IO error code is returned.
  23615 func Xsqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) int32 {
  23616 	bp := tls.Alloc(28)
  23617 	defer tls.Free(28)
  23618 
  23619 	var rc int32
  23620 
  23621 	var f int32
  23622 	var pVfs uintptr
  23623 
  23624 	rc = SQLITE_OK
  23625 
  23626 	if !(!((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) && int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN) {
  23627 		goto __1
  23628 	}
  23629 	*(*int32)(unsafe.Pointer(bp)) = 1
  23630 
  23631 	rc = pager_wait_on_lock(tls, pPager, SHARED_LOCK)
  23632 	if !(rc != SQLITE_OK) {
  23633 		goto __2
  23634 	}
  23635 
  23636 	goto failed
  23637 __2:
  23638 	;
  23639 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FeLock) <= SHARED_LOCK) {
  23640 		goto __3
  23641 	}
  23642 	rc = hasHotJournal(tls, pPager, bp)
  23643 __3:
  23644 	;
  23645 	if !(rc != SQLITE_OK) {
  23646 		goto __4
  23647 	}
  23648 	goto failed
  23649 __4:
  23650 	;
  23651 	if !(*(*int32)(unsafe.Pointer(bp)) != 0) {
  23652 		goto __5
  23653 	}
  23654 	if !((*Pager)(unsafe.Pointer(pPager)).FreadOnly != 0) {
  23655 		goto __6
  23656 	}
  23657 	rc = SQLITE_READONLY | int32(3)<<8
  23658 	goto failed
  23659 __6:
  23660 	;
  23661 	rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK)
  23662 	if !(rc != SQLITE_OK) {
  23663 		goto __7
  23664 	}
  23665 	goto failed
  23666 __7:
  23667 	;
  23668 	if !(!((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0)) && int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF) {
  23669 		goto __8
  23670 	}
  23671 	pVfs = (*Pager)(unsafe.Pointer(pPager)).FpVfs
  23672 	rc = Xsqlite3OsAccess(tls,
  23673 		pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp+4)
  23674 	if !(rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 4)) != 0) {
  23675 		goto __9
  23676 	}
  23677 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
  23678 	f = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL
  23679 
  23680 	rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, f, bp+8)
  23681 
  23682 	if !(rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 8))&SQLITE_OPEN_READONLY != 0) {
  23683 		goto __10
  23684 	}
  23685 	rc = Xsqlite3CantopenError(tls, 60758)
  23686 	Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  23687 __10:
  23688 	;
  23689 __9:
  23690 	;
  23691 __8:
  23692 	;
  23693 	if !((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0)) {
  23694 		goto __11
  23695 	}
  23696 
  23697 	rc = pagerSyncHotJournal(tls, pPager)
  23698 	if !(rc == SQLITE_OK) {
  23699 		goto __13
  23700 	}
  23701 	rc = pager_playback(tls, pPager, libc.BoolInt32(!((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0)))
  23702 	(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_OPEN)
  23703 __13:
  23704 	;
  23705 	goto __12
  23706 __11:
  23707 	if !!(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) {
  23708 		goto __14
  23709 	}
  23710 	pagerUnlockDb(tls, pPager, SHARED_LOCK)
  23711 __14:
  23712 	;
  23713 __12:
  23714 	;
  23715 	if !(rc != SQLITE_OK) {
  23716 		goto __15
  23717 	}
  23718 
  23719 	pager_error(tls, pPager, rc)
  23720 	goto failed
  23721 __15:
  23722 	;
  23723 __5:
  23724 	;
  23725 	if !(!(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && (*Pager)(unsafe.Pointer(pPager)).FhasHeldSharedLock != 0) {
  23726 		goto __16
  23727 	}
  23728 
  23729 	rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp+12, int32(unsafe.Sizeof([16]uint8{})), int64(24))
  23730 	if !(rc != SQLITE_OK) {
  23731 		goto __17
  23732 	}
  23733 	if !(rc != SQLITE_IOERR|int32(2)<<8) {
  23734 		goto __18
  23735 	}
  23736 	goto failed
  23737 __18:
  23738 	;
  23739 	libc.Xmemset(tls, bp+12, 0, uint32(unsafe.Sizeof([16]uint8{})))
  23740 __17:
  23741 	;
  23742 	if !(libc.Xmemcmp(tls, pPager+112, bp+12, uint32(unsafe.Sizeof([16]uint8{}))) != 0) {
  23743 		goto __19
  23744 	}
  23745 	pager_reset(tls, pPager)
  23746 
  23747 	if !((*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0) {
  23748 		goto __20
  23749 	}
  23750 	Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0))
  23751 __20:
  23752 	;
  23753 __19:
  23754 	;
  23755 __16:
  23756 	;
  23757 	rc = pagerOpenWalIfPresent(tls, pPager)
  23758 
  23759 __1:
  23760 	;
  23761 	if !((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) {
  23762 		goto __21
  23763 	}
  23764 
  23765 	rc = pagerBeginReadTransaction(tls, pPager)
  23766 __21:
  23767 	;
  23768 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0 && int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN && rc == SQLITE_OK) {
  23769 		goto __22
  23770 	}
  23771 	rc = pagerPagecount(tls, pPager, pPager+28)
  23772 __22:
  23773 	;
  23774 failed:
  23775 	if !(rc != SQLITE_OK) {
  23776 		goto __23
  23777 	}
  23778 
  23779 	pager_unlock(tls, pPager)
  23780 
  23781 	goto __24
  23782 __23:
  23783 	(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_READER)
  23784 	(*Pager)(unsafe.Pointer(pPager)).FhasHeldSharedLock = U8(1)
  23785 __24:
  23786 	;
  23787 	return rc
  23788 }
  23789 
  23790 func pagerUnlockIfUnused(tls *libc.TLS, pPager uintptr) {
  23791 	if Xsqlite3PcacheRefCount(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) == int64(0) {
  23792 		pagerUnlockAndRollback(tls, pPager)
  23793 	}
  23794 }
  23795 
  23796 func getPageNormal(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 {
  23797 	bp := tls.Alloc(4)
  23798 	defer tls.Free(4)
  23799 
  23800 	var rc int32
  23801 	var pPg uintptr
  23802 	var noContent U8
  23803 
  23804 	rc = SQLITE_OK
  23805 
  23806 	if !(pgno == Pgno(0)) {
  23807 		goto __1
  23808 	}
  23809 	return Xsqlite3CorruptError(tls, 60971)
  23810 __1:
  23811 	;
  23812 	*(*uintptr)(unsafe.Pointer(bp)) = Xsqlite3PcacheFetch(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, 3)
  23813 	if !(*(*uintptr)(unsafe.Pointer(bp)) == uintptr(0)) {
  23814 		goto __2
  23815 	}
  23816 	pPg = uintptr(0)
  23817 	rc = Xsqlite3PcacheFetchStress(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, bp)
  23818 	if !(rc != SQLITE_OK) {
  23819 		goto __3
  23820 	}
  23821 	goto pager_acquire_err
  23822 __3:
  23823 	;
  23824 	if !(*(*uintptr)(unsafe.Pointer(bp)) == uintptr(0)) {
  23825 		goto __4
  23826 	}
  23827 	rc = SQLITE_NOMEM
  23828 	goto pager_acquire_err
  23829 __4:
  23830 	;
  23831 __2:
  23832 	;
  23833 	pPg = libc.AssignPtrUintptr(ppPage, Xsqlite3PcacheFetchFinish(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, *(*uintptr)(unsafe.Pointer(bp))))
  23834 
  23835 	noContent = U8(libc.Bool32(flags&PAGER_GET_NOCONTENT != 0))
  23836 	if !((*PgHdr)(unsafe.Pointer(pPg)).FpPager != 0 && !(noContent != 0)) {
  23837 		goto __5
  23838 	}
  23839 
  23840 	*(*int32)(unsafe.Pointer(pPager + 200))++
  23841 	return SQLITE_OK
  23842 
  23843 	goto __6
  23844 __5:
  23845 	if !(pgno == (*Pager)(unsafe.Pointer(pPager)).FlckPgno) {
  23846 		goto __7
  23847 	}
  23848 	rc = Xsqlite3CorruptError(tls, 61003)
  23849 	goto pager_acquire_err
  23850 __7:
  23851 	;
  23852 	(*PgHdr)(unsafe.Pointer(pPg)).FpPager = pPager
  23853 
  23854 	if !(!((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods != uintptr(0)) || (*Pager)(unsafe.Pointer(pPager)).FdbSize < pgno || noContent != 0) {
  23855 		goto __8
  23856 	}
  23857 	if !(pgno > (*Pager)(unsafe.Pointer(pPager)).FmxPgno) {
  23858 		goto __10
  23859 	}
  23860 	rc = SQLITE_FULL
  23861 	goto pager_acquire_err
  23862 __10:
  23863 	;
  23864 	if !(noContent != 0) {
  23865 		goto __11
  23866 	}
  23867 
  23868 	Xsqlite3BeginBenignMalloc(tls)
  23869 	if !(pgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize) {
  23870 		goto __12
  23871 	}
  23872 	Xsqlite3BitvecSet(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, pgno)
  23873 
  23874 __12:
  23875 	;
  23876 	addToSavepointBitvecs(tls, pPager, pgno)
  23877 
  23878 	Xsqlite3EndBenignMalloc(tls)
  23879 __11:
  23880 	;
  23881 	libc.Xmemset(tls, (*PgHdr)(unsafe.Pointer(pPg)).FpData, 0, uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize))
  23882 
  23883 	goto __9
  23884 __8:
  23885 	;
  23886 	*(*int32)(unsafe.Pointer(pPager + 200 + 1*4))++
  23887 	rc = readDbPage(tls, pPg)
  23888 	if !(rc != SQLITE_OK) {
  23889 		goto __13
  23890 	}
  23891 	goto pager_acquire_err
  23892 __13:
  23893 	;
  23894 __9:
  23895 	;
  23896 __6:
  23897 	;
  23898 	return SQLITE_OK
  23899 
  23900 pager_acquire_err:
  23901 	;
  23902 	if !(pPg != 0) {
  23903 		goto __14
  23904 	}
  23905 	Xsqlite3PcacheDrop(tls, pPg)
  23906 __14:
  23907 	;
  23908 	pagerUnlockIfUnused(tls, pPager)
  23909 	*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  23910 	return rc
  23911 }
  23912 
  23913 func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 {
  23914 	bp := tls.Alloc(12)
  23915 	defer tls.Free(12)
  23916 
  23917 	var rc int32 = SQLITE_OK
  23918 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  23919 	*(*U32)(unsafe.Pointer(bp)) = U32(0)
  23920 
  23921 	var bMmapOk int32 = libc.Bool32(pgno > Pgno(1) &&
  23922 		(int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER || flags&PAGER_GET_READONLY != 0))
  23923 
  23924 	if pgno <= Pgno(1) && pgno == Pgno(0) {
  23925 		return Xsqlite3CorruptError(tls, 61082)
  23926 	}
  23927 
  23928 	if bMmapOk != 0 && (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  23929 		rc = Xsqlite3WalFindFrame(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pgno, bp)
  23930 		if rc != SQLITE_OK {
  23931 			*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  23932 			return rc
  23933 		}
  23934 	}
  23935 	if bMmapOk != 0 && *(*U32)(unsafe.Pointer(bp)) == U32(0) {
  23936 		*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  23937 		rc = Xsqlite3OsFetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd,
  23938 			I64(pgno-Pgno(1))*(*Pager)(unsafe.Pointer(pPager)).FpageSize, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), bp+4)
  23939 		if rc == SQLITE_OK && *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
  23940 			if int32((*Pager)(unsafe.Pointer(pPager)).FeState) > PAGER_READER || (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 {
  23941 				*(*uintptr)(unsafe.Pointer(bp + 8)) = Xsqlite3PagerLookup(tls, pPager, pgno)
  23942 			}
  23943 			if *(*uintptr)(unsafe.Pointer(bp + 8)) == uintptr(0) {
  23944 				rc = pagerAcquireMapPage(tls, pPager, pgno, *(*uintptr)(unsafe.Pointer(bp + 4)), bp+8)
  23945 			} else {
  23946 				Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, I64(pgno-Pgno(1))*(*Pager)(unsafe.Pointer(pPager)).FpageSize, *(*uintptr)(unsafe.Pointer(bp + 4)))
  23947 			}
  23948 			if *(*uintptr)(unsafe.Pointer(bp + 8)) != 0 {
  23949 				*(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 8))
  23950 				return SQLITE_OK
  23951 			}
  23952 		}
  23953 		if rc != SQLITE_OK {
  23954 			*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  23955 			return rc
  23956 		}
  23957 	}
  23958 	return getPageNormal(tls, pPager, pgno, ppPage, flags)
  23959 }
  23960 
  23961 func getPageError(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 {
  23962 	_ = pgno
  23963 	_ = flags
  23964 
  23965 	*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  23966 	return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  23967 }
  23968 
  23969 // Dispatch all page fetch requests to the appropriate getter method.
  23970 func Xsqlite3PagerGet(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 {
  23971 	return (*struct {
  23972 		f func(*libc.TLS, uintptr, Pgno, uintptr, int32) int32
  23973 	})(unsafe.Pointer(&struct{ uintptr }{(*Pager)(unsafe.Pointer(pPager)).FxGet})).f(tls, pPager, pgno, ppPage, flags)
  23974 }
  23975 
  23976 // Acquire a page if it is already in the in-memory cache.  Do
  23977 // not read the page from disk.  Return a pointer to the page,
  23978 // or 0 if the page is not in cache.
  23979 //
  23980 // See also sqlite3PagerGet().  The difference between this routine
  23981 // and sqlite3PagerGet() is that _get() will go to the disk and read
  23982 // in the page if the page is not already in cache.  This routine
  23983 // returns NULL if the page is not in cache or if a disk I/O error
  23984 // has ever happened.
  23985 func Xsqlite3PagerLookup(tls *libc.TLS, pPager uintptr, pgno Pgno) uintptr {
  23986 	var pPage uintptr
  23987 
  23988 	pPage = Xsqlite3PcacheFetch(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, 0)
  23989 
  23990 	if pPage == uintptr(0) {
  23991 		return uintptr(0)
  23992 	}
  23993 	return Xsqlite3PcacheFetchFinish(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, pPage)
  23994 }
  23995 
  23996 // Release a page reference.
  23997 //
  23998 // The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be
  23999 // used if we know that the page being released is not the last page.
  24000 // The btree layer always holds page1 open until the end, so these first
  24001 // to routines can be used to release any page other than BtShared.pPage1.
  24002 //
  24003 // Use sqlite3PagerUnrefPageOne() to release page1.  This latter routine
  24004 // checks the total number of outstanding pages and if the number of
  24005 // pages reaches zero it drops the database lock.
  24006 func Xsqlite3PagerUnrefNotNull(tls *libc.TLS, pPg uintptr) {
  24007 	if int32((*DbPage)(unsafe.Pointer(pPg)).Fflags)&PGHDR_MMAP != 0 {
  24008 		pagerReleaseMapPage(tls, pPg)
  24009 	} else {
  24010 		Xsqlite3PcacheRelease(tls, pPg)
  24011 	}
  24012 
  24013 }
  24014 
  24015 func Xsqlite3PagerUnref(tls *libc.TLS, pPg uintptr) {
  24016 	if pPg != 0 {
  24017 		Xsqlite3PagerUnrefNotNull(tls, pPg)
  24018 	}
  24019 }
  24020 
  24021 func Xsqlite3PagerUnrefPageOne(tls *libc.TLS, pPg uintptr) {
  24022 	var pPager uintptr
  24023 
  24024 	pPager = (*DbPage)(unsafe.Pointer(pPg)).FpPager
  24025 	Xsqlite3PcacheRelease(tls, pPg)
  24026 	pagerUnlockIfUnused(tls, pPager)
  24027 }
  24028 
  24029 func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 {
  24030 	var rc int32 = SQLITE_OK
  24031 	var pVfs uintptr = (*Pager)(unsafe.Pointer(pPager)).FpVfs
  24032 
  24033 	if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  24034 		return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24035 	}
  24036 
  24037 	if !((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) && int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF {
  24038 		(*Pager)(unsafe.Pointer(pPager)).FpInJournal = Xsqlite3BitvecCreate(tls, (*Pager)(unsafe.Pointer(pPager)).FdbSize)
  24039 		if (*Pager)(unsafe.Pointer(pPager)).FpInJournal == uintptr(0) {
  24040 			return SQLITE_NOMEM
  24041 		}
  24042 
  24043 		if !((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0)) {
  24044 			if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY {
  24045 				Xsqlite3MemJournalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  24046 			} else {
  24047 				var flags int32 = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
  24048 				var nSpill int32
  24049 
  24050 				if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 {
  24051 					flags = flags | (SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL)
  24052 					flags = flags | SQLITE_OPEN_EXCLUSIVE
  24053 					nSpill = Xsqlite3Config.FnStmtSpill
  24054 				} else {
  24055 					flags = flags | SQLITE_OPEN_MAIN_JOURNAL
  24056 					nSpill = jrnlBufferSize(tls, pPager)
  24057 				}
  24058 
  24059 				rc = databaseIsUnmoved(tls, pPager)
  24060 				if rc == SQLITE_OK {
  24061 					rc = Xsqlite3JournalOpen(tls,
  24062 						pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, flags, nSpill)
  24063 				}
  24064 			}
  24065 
  24066 		}
  24067 
  24068 		if rc == SQLITE_OK {
  24069 			(*Pager)(unsafe.Pointer(pPager)).FnRec = 0
  24070 			(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  24071 			(*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(0)
  24072 			(*Pager)(unsafe.Pointer(pPager)).FjournalHdr = int64(0)
  24073 			rc = writeJournalHdr(tls, pPager)
  24074 		}
  24075 	}
  24076 
  24077 	if rc != SQLITE_OK {
  24078 		Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal)
  24079 		(*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0)
  24080 		(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  24081 	} else {
  24082 		(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_WRITER_CACHEMOD)
  24083 	}
  24084 
  24085 	return rc
  24086 }
  24087 
  24088 // Begin a write-transaction on the specified pager object. If a
  24089 // write-transaction has already been opened, this function is a no-op.
  24090 //
  24091 // If the exFlag argument is false, then acquire at least a RESERVED
  24092 // lock on the database file. If exFlag is true, then acquire at least
  24093 // an EXCLUSIVE lock. If such a lock is already held, no locking
  24094 // functions need be called.
  24095 //
  24096 // If the subjInMemory argument is non-zero, then any sub-journal opened
  24097 // within this transaction will be opened as an in-memory file. This
  24098 // has no effect if the sub-journal is already opened (as it may be when
  24099 // running in exclusive mode) or if the transaction does not require a
  24100 // sub-journal. If the subjInMemory argument is zero, then any required
  24101 // sub-journal is implemented in-memory if pPager is an in-memory database,
  24102 // or using a temporary file otherwise.
  24103 func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemory int32) int32 {
  24104 	var rc int32 = SQLITE_OK
  24105 
  24106 	if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  24107 		return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24108 	}
  24109 
  24110 	(*Pager)(unsafe.Pointer(pPager)).FsubjInMemory = U8(subjInMemory)
  24111 
  24112 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER {
  24113 		if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  24114 			if (*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 && Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, -1) != 0 {
  24115 				rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK)
  24116 				if rc != SQLITE_OK {
  24117 					return rc
  24118 				}
  24119 				Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, 1)
  24120 			}
  24121 
  24122 			rc = Xsqlite3WalBeginWriteTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  24123 		} else {
  24124 			rc = pagerLockDb(tls, pPager, RESERVED_LOCK)
  24125 			if rc == SQLITE_OK && exFlag != 0 {
  24126 				rc = pager_wait_on_lock(tls, pPager, EXCLUSIVE_LOCK)
  24127 			}
  24128 		}
  24129 
  24130 		if rc == SQLITE_OK {
  24131 			(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_WRITER_LOCKED)
  24132 			(*Pager)(unsafe.Pointer(pPager)).FdbHintSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize
  24133 			(*Pager)(unsafe.Pointer(pPager)).FdbFileSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize
  24134 			(*Pager)(unsafe.Pointer(pPager)).FdbOrigSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize
  24135 			(*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0)
  24136 		}
  24137 
  24138 	}
  24139 
  24140 	return rc
  24141 }
  24142 
  24143 func pagerAddPageToRollbackJournal(tls *libc.TLS, pPg uintptr) int32 {
  24144 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  24145 	var rc int32
  24146 	var cksum U32
  24147 	var pData2 uintptr
  24148 	var iOff I64 = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  24149 
  24150 	pData2 = (*PgHdr)(unsafe.Pointer(pPg)).FpData
  24151 	cksum = pager_cksum(tls, pPager, pData2)
  24152 
  24153 	*(*U16)(unsafe.Pointer(pPg + 28)) |= U16(PGHDR_NEED_SYNC)
  24154 
  24155 	rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iOff, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno)
  24156 	if rc != SQLITE_OK {
  24157 		return rc
  24158 	}
  24159 	rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, pData2, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), iOff+int64(4))
  24160 	if rc != SQLITE_OK {
  24161 		return rc
  24162 	}
  24163 	rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iOff+(*Pager)(unsafe.Pointer(pPager)).FpageSize+int64(4), cksum)
  24164 	if rc != SQLITE_OK {
  24165 		return rc
  24166 	}
  24167 
  24168 	*(*I64)(unsafe.Pointer(pPager + 80)) += int64(8) + (*Pager)(unsafe.Pointer(pPager)).FpageSize
  24169 	(*Pager)(unsafe.Pointer(pPager)).FnRec++
  24170 
  24171 	rc = Xsqlite3BitvecSet(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno)
  24172 
  24173 	rc = rc | addToSavepointBitvecs(tls, pPager, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno)
  24174 
  24175 	return rc
  24176 }
  24177 
  24178 func pager_write(tls *libc.TLS, pPg uintptr) int32 {
  24179 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  24180 	var rc int32 = SQLITE_OK
  24181 
  24182 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED {
  24183 		rc = pager_open_journal(tls, pPager)
  24184 		if rc != SQLITE_OK {
  24185 			return rc
  24186 		}
  24187 	}
  24188 
  24189 	Xsqlite3PcacheMakeDirty(tls, pPg)
  24190 
  24191 	if (*Pager)(unsafe.Pointer(pPager)).FpInJournal != uintptr(0) &&
  24192 		Xsqlite3BitvecTestNotNull(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) == 0 {
  24193 		if (*PgHdr)(unsafe.Pointer(pPg)).Fpgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize {
  24194 			rc = pagerAddPageToRollbackJournal(tls, pPg)
  24195 			if rc != SQLITE_OK {
  24196 				return rc
  24197 			}
  24198 		} else {
  24199 			if int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_WRITER_DBMOD {
  24200 				*(*U16)(unsafe.Pointer(pPg + 28)) |= U16(PGHDR_NEED_SYNC)
  24201 			}
  24202 
  24203 		}
  24204 	}
  24205 
  24206 	*(*U16)(unsafe.Pointer(pPg + 28)) |= U16(PGHDR_WRITEABLE)
  24207 
  24208 	if (*Pager)(unsafe.Pointer(pPager)).FnSavepoint > 0 {
  24209 		rc = subjournalPageIfRequired(tls, pPg)
  24210 	}
  24211 
  24212 	if (*Pager)(unsafe.Pointer(pPager)).FdbSize < (*PgHdr)(unsafe.Pointer(pPg)).Fpgno {
  24213 		(*Pager)(unsafe.Pointer(pPager)).FdbSize = (*PgHdr)(unsafe.Pointer(pPg)).Fpgno
  24214 	}
  24215 	return rc
  24216 }
  24217 
  24218 func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 {
  24219 	bp := tls.Alloc(4)
  24220 	defer tls.Free(4)
  24221 
  24222 	var rc int32 = SQLITE_OK
  24223 	var nPageCount Pgno
  24224 	var pg1 Pgno
  24225 	var nPage int32 = 0
  24226 	var ii int32
  24227 	var needSync int32 = 0
  24228 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  24229 	var nPagePerSector Pgno = Pgno(I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize) / (*Pager)(unsafe.Pointer(pPager)).FpageSize)
  24230 
  24231 	*(*U8)(unsafe.Pointer(pPager + 21)) |= U8(SPILLFLAG_NOSYNC)
  24232 
  24233 	pg1 = ((*PgHdr)(unsafe.Pointer(pPg)).Fpgno-Pgno(1)) & ^(nPagePerSector-Pgno(1)) + Pgno(1)
  24234 
  24235 	nPageCount = (*Pager)(unsafe.Pointer(pPager)).FdbSize
  24236 	if (*PgHdr)(unsafe.Pointer(pPg)).Fpgno > nPageCount {
  24237 		nPage = int32((*PgHdr)(unsafe.Pointer(pPg)).Fpgno - pg1 + Pgno(1))
  24238 	} else if pg1+nPagePerSector-Pgno(1) > nPageCount {
  24239 		nPage = int32(nPageCount + Pgno(1) - pg1)
  24240 	} else {
  24241 		nPage = int32(nPagePerSector)
  24242 	}
  24243 
  24244 	for ii = 0; ii < nPage && rc == SQLITE_OK; ii++ {
  24245 		var pg Pgno = pg1 + Pgno(ii)
  24246 
  24247 		if pg == (*PgHdr)(unsafe.Pointer(pPg)).Fpgno || !(Xsqlite3BitvecTest(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, pg) != 0) {
  24248 			if pg != (*Pager)(unsafe.Pointer(pPager)).FlckPgno {
  24249 				rc = Xsqlite3PagerGet(tls, pPager, pg, bp, 0)
  24250 				if rc == SQLITE_OK {
  24251 					rc = pager_write(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24252 					if int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fflags)&PGHDR_NEED_SYNC != 0 {
  24253 						needSync = 1
  24254 					}
  24255 					Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24256 				}
  24257 			}
  24258 		} else if libc.AssignPtrUintptr(bp, Xsqlite3PagerLookup(tls, pPager, pg)) != uintptr(0) {
  24259 			if int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fflags)&PGHDR_NEED_SYNC != 0 {
  24260 				needSync = 1
  24261 			}
  24262 			Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24263 		}
  24264 	}
  24265 
  24266 	if rc == SQLITE_OK && needSync != 0 {
  24267 		for ii = 0; ii < nPage; ii++ {
  24268 			var pPage uintptr = Xsqlite3PagerLookup(tls, pPager, pg1+Pgno(ii))
  24269 			if pPage != 0 {
  24270 				*(*U16)(unsafe.Pointer(pPage + 28)) |= U16(PGHDR_NEED_SYNC)
  24271 				Xsqlite3PagerUnrefNotNull(tls, pPage)
  24272 			}
  24273 		}
  24274 	}
  24275 
  24276 	*(*U8)(unsafe.Pointer(pPager + 21)) &= libc.Uint8FromInt32(libc.CplInt32(SPILLFLAG_NOSYNC))
  24277 	return rc
  24278 }
  24279 
  24280 // Mark a data page as writeable. This routine must be called before
  24281 // making changes to a page. The caller must check the return value
  24282 // of this function and be careful not to change any page data unless
  24283 // this routine returns SQLITE_OK.
  24284 //
  24285 // The difference between this function and pager_write() is that this
  24286 // function also deals with the special case where 2 or more pages
  24287 // fit on a single disk sector. In this case all co-resident pages
  24288 // must have been written to the journal file before returning.
  24289 //
  24290 // If an error occurs, SQLITE_NOMEM or an IO error code is returned
  24291 // as appropriate. Otherwise, SQLITE_OK.
  24292 func Xsqlite3PagerWrite(tls *libc.TLS, pPg uintptr) int32 {
  24293 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  24294 
  24295 	if int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags)&PGHDR_WRITEABLE != 0 && (*Pager)(unsafe.Pointer(pPager)).FdbSize >= (*PgHdr)(unsafe.Pointer(pPg)).Fpgno {
  24296 		if (*Pager)(unsafe.Pointer(pPager)).FnSavepoint != 0 {
  24297 			return subjournalPageIfRequired(tls, pPg)
  24298 		}
  24299 		return SQLITE_OK
  24300 	} else if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  24301 		return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24302 	} else if (*Pager)(unsafe.Pointer(pPager)).FsectorSize > U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) {
  24303 		return pagerWriteLargeSector(tls, pPg)
  24304 	} else {
  24305 		return pager_write(tls, pPg)
  24306 	}
  24307 	return int32(0)
  24308 }
  24309 
  24310 // A call to this routine tells the pager that it is not necessary to
  24311 // write the information on page pPg back to the disk, even though
  24312 // that page might be marked as dirty.  This happens, for example, when
  24313 // the page has been added as a leaf of the freelist and so its
  24314 // content no longer matters.
  24315 //
  24316 // The overlying software layer calls this routine when all of the data
  24317 // on the given page is unused. The pager marks the page as clean so
  24318 // that it does not get written to disk.
  24319 //
  24320 // Tests show that this optimization can quadruple the speed of large
  24321 // DELETE operations.
  24322 //
  24323 // This optimization cannot be used with a temp-file, as the page may
  24324 // have been dirty at the start of the transaction. In that case, if
  24325 // memory pressure forces page pPg out of the cache, the data does need
  24326 // to be written out to disk so that it may be read back in if the
  24327 // current transaction is rolled back.
  24328 func Xsqlite3PagerDontWrite(tls *libc.TLS, pPg uintptr) {
  24329 	var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager
  24330 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags)&PGHDR_DIRTY != 0 && (*Pager)(unsafe.Pointer(pPager)).FnSavepoint == 0 {
  24331 		*(*U16)(unsafe.Pointer(pPg + 28)) |= U16(PGHDR_DONT_WRITE)
  24332 		*(*U16)(unsafe.Pointer(pPg + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_WRITEABLE))
  24333 
  24334 	}
  24335 }
  24336 
  24337 func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) int32 {
  24338 	bp := tls.Alloc(4)
  24339 	defer tls.Free(4)
  24340 
  24341 	var rc int32 = SQLITE_OK
  24342 
  24343 	_ = isDirectMode
  24344 
  24345 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FchangeCountDone) != 0) && (*Pager)(unsafe.Pointer(pPager)).FdbSize > Pgno(0) {
  24346 		rc = Xsqlite3PagerGet(tls, pPager, uint32(1), bp, 0)
  24347 
  24348 		if !(0 != 0) && rc == SQLITE_OK {
  24349 			rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24350 		}
  24351 
  24352 		if rc == SQLITE_OK {
  24353 			pager_write_changecounter(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24354 
  24355 			if 0 != 0 {
  24356 				var zBuf uintptr
  24357 
  24358 				zBuf = (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpData
  24359 				if rc == SQLITE_OK {
  24360 					rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, zBuf, int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), int64(0))
  24361 					*(*int32)(unsafe.Pointer(pPager + 200 + 2*4))++
  24362 				}
  24363 				if rc == SQLITE_OK {
  24364 					var pCopy uintptr = zBuf + 24
  24365 					libc.Xmemcpy(tls, pPager+112, pCopy, uint32(unsafe.Sizeof([16]uint8{})))
  24366 					(*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(1)
  24367 				}
  24368 			} else {
  24369 				(*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(1)
  24370 			}
  24371 		}
  24372 
  24373 		Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24374 	}
  24375 	return rc
  24376 }
  24377 
  24378 // Sync the database file to disk. This is a no-op for in-memory databases
  24379 // or pages with the Pager.noSync flag set.
  24380 //
  24381 // If successful, or if called on a pager for which it is a no-op, this
  24382 // function returns SQLITE_OK. Otherwise, an IO error code is returned.
  24383 func Xsqlite3PagerSync(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 {
  24384 	var rc int32 = SQLITE_OK
  24385 	var pArg uintptr = zSuper
  24386 	rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SYNC, pArg)
  24387 	if rc == SQLITE_NOTFOUND {
  24388 		rc = SQLITE_OK
  24389 	}
  24390 	if rc == SQLITE_OK && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) {
  24391 		rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))
  24392 	}
  24393 	return rc
  24394 }
  24395 
  24396 // This function may only be called while a write-transaction is active in
  24397 // rollback. If the connection is in WAL mode, this call is a no-op.
  24398 // Otherwise, if the connection does not already have an EXCLUSIVE lock on
  24399 // the database file, an attempt is made to obtain one.
  24400 //
  24401 // If the EXCLUSIVE lock is already held or the attempt to obtain it is
  24402 // successful, or the connection is in WAL mode, SQLITE_OK is returned.
  24403 // Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is
  24404 // returned.
  24405 func Xsqlite3PagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 {
  24406 	var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24407 
  24408 	if rc == SQLITE_OK {
  24409 		if 0 == libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) {
  24410 			rc = pager_wait_on_lock(tls, pPager, EXCLUSIVE_LOCK)
  24411 		}
  24412 	}
  24413 	return rc
  24414 }
  24415 
  24416 // Sync the database file for the pager pPager. zSuper points to the name
  24417 // of a super-journal file that should be written into the individual
  24418 // journal file. zSuper may be NULL, which is interpreted as no
  24419 // super-journal (a single database transaction).
  24420 //
  24421 // This routine ensures that:
  24422 //
  24423 //   - The database file change-counter is updated,
  24424 //   - the journal is synced (unless the atomic-write optimization is used),
  24425 //   - all dirty pages are written to the database file,
  24426 //   - the database file is truncated (if required), and
  24427 //   - the database file synced.
  24428 //
  24429 // The only thing that remains to commit the transaction is to finalize
  24430 // (delete, truncate or zero the first part of) the journal file (or
  24431 // delete the super-journal file if specified).
  24432 //
  24433 // Note that if zSuper==NULL, this does not overwrite a previous value
  24434 // passed to an sqlite3PagerCommitPhaseOne() call.
  24435 //
  24436 // If the final parameter - noSync - is true, then the database file itself
  24437 // is not synced. The caller must call sqlite3PagerSync() directly to
  24438 // sync the database file before calling CommitPhaseTwo() to delete the
  24439 // journal file in this case.
  24440 func Xsqlite3PagerCommitPhaseOne(tls *libc.TLS, pPager uintptr, zSuper uintptr, noSync int32) int32 {
  24441 	bp := tls.Alloc(4)
  24442 	defer tls.Free(4)
  24443 
  24444 	var rc int32
  24445 
  24446 	var nNew Pgno
  24447 	var pList uintptr
  24448 	rc = SQLITE_OK
  24449 
  24450 	if !((*Pager)(unsafe.Pointer(pPager)).FerrCode != 0) {
  24451 		goto __1
  24452 	}
  24453 	return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24454 __1:
  24455 	;
  24456 	if !(Xsqlite3FaultSim(tls, 400) != 0) {
  24457 		goto __2
  24458 	}
  24459 	return SQLITE_IOERR
  24460 __2:
  24461 	;
  24462 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FeState) < PAGER_WRITER_CACHEMOD) {
  24463 		goto __3
  24464 	}
  24465 	return SQLITE_OK
  24466 __3:
  24467 	;
  24468 	if !(0 == pagerFlushOnCommit(tls, pPager, 1)) {
  24469 		goto __4
  24470 	}
  24471 
  24472 	Xsqlite3BackupRestart(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup)
  24473 	goto __5
  24474 __4:
  24475 	if !((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) {
  24476 		goto __6
  24477 	}
  24478 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  24479 	pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  24480 	if !(pList == uintptr(0)) {
  24481 		goto __8
  24482 	}
  24483 
  24484 	rc = Xsqlite3PagerGet(tls, pPager, uint32(1), bp, 0)
  24485 	pList = *(*uintptr)(unsafe.Pointer(bp))
  24486 	(*PgHdr)(unsafe.Pointer(pList)).FpDirty = uintptr(0)
  24487 __8:
  24488 	;
  24489 	if !(pList != 0) {
  24490 		goto __9
  24491 	}
  24492 	rc = pagerWalFrames(tls, pPager, pList, (*Pager)(unsafe.Pointer(pPager)).FdbSize, 1)
  24493 __9:
  24494 	;
  24495 	Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24496 	if !(rc == SQLITE_OK) {
  24497 		goto __10
  24498 	}
  24499 	Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  24500 __10:
  24501 	;
  24502 	goto __7
  24503 __6:
  24504 	rc = pager_incr_changecounter(tls, pPager, 0)
  24505 	if !(rc != SQLITE_OK) {
  24506 		goto __11
  24507 	}
  24508 	goto commit_phase_one_exit
  24509 __11:
  24510 	;
  24511 	rc = writeSuperJournal(tls, pPager, zSuper)
  24512 	if !(rc != SQLITE_OK) {
  24513 		goto __12
  24514 	}
  24515 	goto commit_phase_one_exit
  24516 __12:
  24517 	;
  24518 	rc = syncJournal(tls, pPager, 0)
  24519 	if !(rc != SQLITE_OK) {
  24520 		goto __13
  24521 	}
  24522 	goto commit_phase_one_exit
  24523 __13:
  24524 	;
  24525 	pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  24526 
  24527 	if !(BBatch == 0) {
  24528 		goto __14
  24529 	}
  24530 	rc = pager_write_pagelist(tls, pPager, pList)
  24531 __14:
  24532 	;
  24533 	if !(rc != SQLITE_OK) {
  24534 		goto __15
  24535 	}
  24536 
  24537 	goto commit_phase_one_exit
  24538 __15:
  24539 	;
  24540 	Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)
  24541 
  24542 	if !((*Pager)(unsafe.Pointer(pPager)).FdbSize > (*Pager)(unsafe.Pointer(pPager)).FdbFileSize) {
  24543 		goto __16
  24544 	}
  24545 	nNew = (*Pager)(unsafe.Pointer(pPager)).FdbSize - Pgno(libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FdbSize == (*Pager)(unsafe.Pointer(pPager)).FlckPgno))
  24546 
  24547 	rc = pager_truncate(tls, pPager, nNew)
  24548 	if !(rc != SQLITE_OK) {
  24549 		goto __17
  24550 	}
  24551 	goto commit_phase_one_exit
  24552 __17:
  24553 	;
  24554 __16:
  24555 	;
  24556 	if !!(noSync != 0) {
  24557 		goto __18
  24558 	}
  24559 	rc = Xsqlite3PagerSync(tls, pPager, zSuper)
  24560 __18:
  24561 	;
  24562 __7:
  24563 	;
  24564 __5:
  24565 	;
  24566 commit_phase_one_exit:
  24567 	if !(rc == SQLITE_OK && !((*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0))) {
  24568 		goto __19
  24569 	}
  24570 	(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_WRITER_FINISHED)
  24571 __19:
  24572 	;
  24573 	return rc
  24574 }
  24575 
  24576 // When this function is called, the database file has been completely
  24577 // updated to reflect the changes made by the current transaction and
  24578 // synced to disk. The journal file still exists in the file-system
  24579 // though, and if a failure occurs at this point it will eventually
  24580 // be used as a hot-journal and the current transaction rolled back.
  24581 //
  24582 // This function finalizes the journal file, either by deleting,
  24583 // truncating or partially zeroing it, so that it cannot be used
  24584 // for hot-journal rollback. Once this is done the transaction is
  24585 // irrevocably committed.
  24586 //
  24587 // If an error occurs, an IO error code is returned and the pager
  24588 // moves into the error state. Otherwise, SQLITE_OK is returned.
  24589 func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 {
  24590 	var rc int32 = SQLITE_OK
  24591 
  24592 	if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 {
  24593 		return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24594 	}
  24595 	(*Pager)(unsafe.Pointer(pPager)).FiDataVersion++
  24596 
  24597 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED &&
  24598 		(*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 &&
  24599 		int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_PERSIST {
  24600 		(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_READER)
  24601 		return SQLITE_OK
  24602 	}
  24603 
  24604 	rc = pager_end_transaction(tls, pPager, int32((*Pager)(unsafe.Pointer(pPager)).FsetSuper), 1)
  24605 	return pager_error(tls, pPager, rc)
  24606 }
  24607 
  24608 // If a write transaction is open, then all changes made within the
  24609 // transaction are reverted and the current write-transaction is closed.
  24610 // The pager falls back to PAGER_READER state if successful, or PAGER_ERROR
  24611 // state if an error occurs.
  24612 //
  24613 // If the pager is already in PAGER_ERROR state when this function is called,
  24614 // it returns Pager.errCode immediately. No work is performed in this case.
  24615 //
  24616 // Otherwise, in rollback mode, this function performs two functions:
  24617 //
  24618 //  1. It rolls back the journal file, restoring all database file and
  24619 //     in-memory cache pages to the state they were in when the transaction
  24620 //     was opened, and
  24621 //
  24622 //  2. It finalizes the journal file, so that it is not used for hot
  24623 //     rollback at any point in the future.
  24624 //
  24625 // Finalization of the journal file (task 2) is only performed if the
  24626 // rollback is successful.
  24627 //
  24628 // In WAL mode, all cache-entries containing data modified within the
  24629 // current transaction are either expelled from the cache or reverted to
  24630 // their pre-transaction state by re-reading data from the database or
  24631 // WAL files. The WAL transaction is then closed.
  24632 func Xsqlite3PagerRollback(tls *libc.TLS, pPager uintptr) int32 {
  24633 	var rc int32 = SQLITE_OK
  24634 
  24635 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_ERROR {
  24636 		return (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24637 	}
  24638 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) <= PAGER_READER {
  24639 		return SQLITE_OK
  24640 	}
  24641 
  24642 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  24643 		var rc2 int32
  24644 		rc = Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_ROLLBACK, -1)
  24645 		rc2 = pager_end_transaction(tls, pPager, int32((*Pager)(unsafe.Pointer(pPager)).FsetSuper), 0)
  24646 		if rc == SQLITE_OK {
  24647 			rc = rc2
  24648 		}
  24649 	} else if !((*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0)) || int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED {
  24650 		var eState int32 = int32((*Pager)(unsafe.Pointer(pPager)).FeState)
  24651 		rc = pager_end_transaction(tls, pPager, 0, 0)
  24652 		if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) && eState > PAGER_WRITER_LOCKED {
  24653 			(*Pager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_ABORT
  24654 			(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_ERROR)
  24655 			setGetterMethod(tls, pPager)
  24656 			return rc
  24657 		}
  24658 	} else {
  24659 		rc = pager_playback(tls, pPager, 0)
  24660 	}
  24661 
  24662 	return pager_error(tls, pPager, rc)
  24663 }
  24664 
  24665 // Return TRUE if the database file is opened read-only.  Return FALSE
  24666 // if the database is (in theory) writable.
  24667 func Xsqlite3PagerIsreadonly(tls *libc.TLS, pPager uintptr) U8 {
  24668 	return (*Pager)(unsafe.Pointer(pPager)).FreadOnly
  24669 }
  24670 
  24671 // Return the approximate number of bytes of memory currently
  24672 // used by the pager and its associated cache.
  24673 func Xsqlite3PagerMemUsed(tls *libc.TLS, pPager uintptr) int32 {
  24674 	var perPageSize int32 = int32((*Pager)(unsafe.Pointer(pPager)).FpageSize + I64((*Pager)(unsafe.Pointer(pPager)).FnExtra) +
  24675 		I64(int32(uint32(unsafe.Sizeof(PgHdr{}))+uint32(5)*uint32(unsafe.Sizeof(uintptr(0))))))
  24676 	return int32(I64(perPageSize*Xsqlite3PcachePagecount(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache)+
  24677 		Xsqlite3MallocSize(tls, pPager)) +
  24678 		(*Pager)(unsafe.Pointer(pPager)).FpageSize)
  24679 }
  24680 
  24681 // Return the number of references to the specified page.
  24682 func Xsqlite3PagerPageRefcount(tls *libc.TLS, pPage uintptr) int32 {
  24683 	return int32(Xsqlite3PcachePageRefcount(tls, pPage))
  24684 }
  24685 
  24686 // Parameter eStat must be one of SQLITE_DBSTATUS_CACHE_HIT, _MISS, _WRITE,
  24687 // or _WRITE+1.  The SQLITE_DBSTATUS_CACHE_WRITE+1 case is a translation
  24688 // of SQLITE_DBSTATUS_CACHE_SPILL.  The _SPILL case is not contiguous because
  24689 // it was added later.
  24690 //
  24691 // Before returning, *pnVal is incremented by the
  24692 // current cache hit or miss count, according to the value of eStat. If the
  24693 // reset parameter is non-zero, the cache hit or miss count is zeroed before
  24694 // returning.
  24695 func Xsqlite3PagerCacheStat(tls *libc.TLS, pPager uintptr, eStat int32, reset int32, pnVal uintptr) {
  24696 	eStat = eStat - SQLITE_DBSTATUS_CACHE_HIT
  24697 	*(*int32)(unsafe.Pointer(pnVal)) += *(*int32)(unsafe.Pointer(pPager + 200 + uintptr(eStat)*4))
  24698 	if reset != 0 {
  24699 		*(*int32)(unsafe.Pointer(pPager + 200 + uintptr(eStat)*4)) = 0
  24700 	}
  24701 }
  24702 
  24703 // Return true if this is an in-memory or temp-file backed pager.
  24704 func Xsqlite3PagerIsMemdb(tls *libc.TLS, pPager uintptr) int32 {
  24705 	return libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 || (*Pager)(unsafe.Pointer(pPager)).FmemVfs != 0)
  24706 }
  24707 
  24708 func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 {
  24709 	var rc int32 = SQLITE_OK
  24710 	var nCurrent int32 = (*Pager)(unsafe.Pointer(pPager)).FnSavepoint
  24711 	var ii int32
  24712 	var aNew uintptr
  24713 
  24714 	aNew = Xsqlite3Realloc(tls,
  24715 		(*Pager)(unsafe.Pointer(pPager)).FaSavepoint, uint64(uint32(unsafe.Sizeof(PagerSavepoint{}))*uint32(nSavepoint)))
  24716 	if !(aNew != 0) {
  24717 		return SQLITE_NOMEM
  24718 	}
  24719 	libc.Xmemset(tls, aNew+uintptr(nCurrent)*48, 0, uint32(nSavepoint-nCurrent)*uint32(unsafe.Sizeof(PagerSavepoint{})))
  24720 	(*Pager)(unsafe.Pointer(pPager)).FaSavepoint = aNew
  24721 
  24722 	for ii = nCurrent; ii < nSavepoint; ii++ {
  24723 		(*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FnOrig = (*Pager)(unsafe.Pointer(pPager)).FdbSize
  24724 		if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && (*Pager)(unsafe.Pointer(pPager)).FjournalOff > int64(0) {
  24725 			(*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FiOffset = (*Pager)(unsafe.Pointer(pPager)).FjournalOff
  24726 		} else {
  24727 			(*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FiOffset = I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize)
  24728 		}
  24729 		(*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FiSubRec = (*Pager)(unsafe.Pointer(pPager)).FnSubRec
  24730 		(*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FpInSavepoint = Xsqlite3BitvecCreate(tls, (*Pager)(unsafe.Pointer(pPager)).FdbSize)
  24731 		(*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FbTruncateOnRelease = 1
  24732 		if !(int32((*PagerSavepoint)(unsafe.Pointer(aNew+uintptr(ii)*48)).FpInSavepoint) != 0) {
  24733 			return SQLITE_NOMEM
  24734 		}
  24735 		if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) {
  24736 			Xsqlite3WalSavepoint(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, aNew+uintptr(ii)*48+32)
  24737 		}
  24738 		(*Pager)(unsafe.Pointer(pPager)).FnSavepoint = ii + 1
  24739 	}
  24740 
  24741 	return rc
  24742 }
  24743 
  24744 func Xsqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 {
  24745 	if nSavepoint > (*Pager)(unsafe.Pointer(pPager)).FnSavepoint && (*Pager)(unsafe.Pointer(pPager)).FuseJournal != 0 {
  24746 		return pagerOpenSavepoint(tls, pPager, nSavepoint)
  24747 	} else {
  24748 		return SQLITE_OK
  24749 	}
  24750 	return int32(0)
  24751 }
  24752 
  24753 // This function is called to rollback or release (commit) a savepoint.
  24754 // The savepoint to release or rollback need not be the most recently
  24755 // created savepoint.
  24756 //
  24757 // Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.
  24758 // If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with
  24759 // index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes
  24760 // that have occurred since the specified savepoint was created.
  24761 //
  24762 // The savepoint to rollback or release is identified by parameter
  24763 // iSavepoint. A value of 0 means to operate on the outermost savepoint
  24764 // (the first created). A value of (Pager.nSavepoint-1) means operate
  24765 // on the most recently created savepoint. If iSavepoint is greater than
  24766 // (Pager.nSavepoint-1), then this function is a no-op.
  24767 //
  24768 // If a negative value is passed to this function, then the current
  24769 // transaction is rolled back. This is different to calling
  24770 // sqlite3PagerRollback() because this function does not terminate
  24771 // the transaction or unlock the database, it just restores the
  24772 // contents of the database to its original state.
  24773 //
  24774 // In any case, all savepoints with an index greater than iSavepoint
  24775 // are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),
  24776 // then savepoint iSavepoint is also destroyed.
  24777 //
  24778 // This function may return SQLITE_NOMEM if a memory allocation fails,
  24779 // or an IO error code if an IO error occurs while rolling back a
  24780 // savepoint. If no errors occur, SQLITE_OK is returned.
  24781 func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint int32) int32 {
  24782 	var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode
  24783 
  24784 	if rc == SQLITE_OK && iSavepoint < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint {
  24785 		var ii int32
  24786 		var nNew int32
  24787 
  24788 		nNew = iSavepoint + func() int32 {
  24789 			if op == SAVEPOINT_RELEASE {
  24790 				return 0
  24791 			}
  24792 			return 1
  24793 		}()
  24794 		for ii = nNew; ii < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; ii++ {
  24795 			Xsqlite3BitvecDestroy(tls, (*PagerSavepoint)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FaSavepoint+uintptr(ii)*48)).FpInSavepoint)
  24796 		}
  24797 		(*Pager)(unsafe.Pointer(pPager)).FnSavepoint = nNew
  24798 
  24799 		if op == SAVEPOINT_RELEASE {
  24800 			var pRel uintptr = (*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(nNew)*48
  24801 			if (*PagerSavepoint)(unsafe.Pointer(pRel)).FbTruncateOnRelease != 0 && (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fsjfd)).FpMethods != uintptr(0) {
  24802 				if Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd) != 0 {
  24803 					var sz I64 = ((*Pager)(unsafe.Pointer(pPager)).FpageSize + int64(4)) * I64((*PagerSavepoint)(unsafe.Pointer(pRel)).FiSubRec)
  24804 					rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, sz)
  24805 
  24806 				}
  24807 				(*Pager)(unsafe.Pointer(pPager)).FnSubRec = (*PagerSavepoint)(unsafe.Pointer(pRel)).FiSubRec
  24808 			}
  24809 		} else if (*Pager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) || (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) {
  24810 			var pSavepoint uintptr
  24811 			if nNew == 0 {
  24812 				pSavepoint = uintptr(0)
  24813 			} else {
  24814 				pSavepoint = (*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(nNew-1)*48
  24815 			}
  24816 			rc = pagerPlaybackSavepoint(tls, pPager, pSavepoint)
  24817 
  24818 		}
  24819 
  24820 	}
  24821 
  24822 	return rc
  24823 }
  24824 
  24825 // Return the full pathname of the database file.
  24826 //
  24827 // Except, if the pager is in-memory only, then return an empty string if
  24828 // nullIfMemDb is true.  This routine is called with nullIfMemDb==1 when
  24829 // used to report the filename to the user, for compatibility with legacy
  24830 // behavior.  But when the Btree needs to know the filename for matching to
  24831 // shared cache, it uses nullIfMemDb==0 so that in-memory databases can
  24832 // participate in shared-cache.
  24833 //
  24834 // The return value to this routine is always safe to use with
  24835 // sqlite3_uri_parameter() and sqlite3_filename_database() and friends.
  24836 func Xsqlite3PagerFilename(tls *libc.TLS, pPager uintptr, nullIfMemDb int32) uintptr {
  24837 	if nullIfMemDb != 0 && ((*Pager)(unsafe.Pointer(pPager)).FmemDb != 0 || Xsqlite3IsMemdb(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs) != 0) {
  24838 		return uintptr(unsafe.Pointer(&zFake)) + 4
  24839 	} else {
  24840 		return (*Pager)(unsafe.Pointer(pPager)).FzFilename
  24841 	}
  24842 	return uintptr(0)
  24843 }
  24844 
  24845 var zFake = [8]uint8{uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0)}
  24846 
  24847 // Return the VFS structure for the pager.
  24848 func Xsqlite3PagerVfs(tls *libc.TLS, pPager uintptr) uintptr {
  24849 	return (*Pager)(unsafe.Pointer(pPager)).FpVfs
  24850 }
  24851 
  24852 // Return the file handle for the database file associated
  24853 // with the pager.  This might return NULL if the file has
  24854 // not yet been opened.
  24855 func Xsqlite3PagerFile(tls *libc.TLS, pPager uintptr) uintptr {
  24856 	return (*Pager)(unsafe.Pointer(pPager)).Ffd
  24857 }
  24858 
  24859 // Return the file handle for the journal file (if it exists).
  24860 // This will be either the rollback journal or the WAL file.
  24861 func Xsqlite3PagerJrnlFile(tls *libc.TLS, pPager uintptr) uintptr {
  24862 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  24863 		return Xsqlite3WalFile(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  24864 	}
  24865 	return (*Pager)(unsafe.Pointer(pPager)).Fjfd
  24866 }
  24867 
  24868 // Return the full pathname of the journal file.
  24869 func Xsqlite3PagerJournalname(tls *libc.TLS, pPager uintptr) uintptr {
  24870 	return (*Pager)(unsafe.Pointer(pPager)).FzJournal
  24871 }
  24872 
  24873 // Move the page pPg to location pgno in the file.
  24874 //
  24875 // There must be no references to the page previously located at
  24876 // pgno (which we call pPgOld) though that page is allowed to be
  24877 // in cache.  If the page previously located at pgno is not already
  24878 // in the rollback journal, it is not put there by by this routine.
  24879 //
  24880 // References to the page pPg remain valid. Updating any
  24881 // meta-data associated with pPg (i.e. data stored in the nExtra bytes
  24882 // allocated along with the page) is the responsibility of the caller.
  24883 //
  24884 // A transaction must be active when this routine is called. It used to be
  24885 // required that a statement transaction was not active, but this restriction
  24886 // has been removed (CREATE INDEX needs to move a page when a statement
  24887 // transaction is active).
  24888 //
  24889 // If the fourth argument, isCommit, is non-zero, then this page is being
  24890 // moved as part of a database reorganization just before the transaction
  24891 // is being committed. In this case, it is guaranteed that the database page
  24892 // pPg refers to will not be written to again within this transaction.
  24893 //
  24894 // This function may return SQLITE_NOMEM or an IO error code if an error
  24895 // occurs. Otherwise, it returns SQLITE_OK.
  24896 func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno, isCommit int32) int32 {
  24897 	bp := tls.Alloc(4)
  24898 	defer tls.Free(4)
  24899 
  24900 	var pPgOld uintptr
  24901 	var needSyncPgno Pgno = Pgno(0)
  24902 	var rc int32
  24903 	var origPgno Pgno
  24904 
  24905 	if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 {
  24906 		rc = Xsqlite3PagerWrite(tls, pPg)
  24907 		if rc != 0 {
  24908 			return rc
  24909 		}
  24910 	}
  24911 
  24912 	if int32((*DbPage)(unsafe.Pointer(pPg)).Fflags)&PGHDR_DIRTY != 0 &&
  24913 		SQLITE_OK != libc.AssignInt32(&rc, subjournalPageIfRequired(tls, pPg)) {
  24914 		return rc
  24915 	}
  24916 
  24917 	if int32((*DbPage)(unsafe.Pointer(pPg)).Fflags)&PGHDR_NEED_SYNC != 0 && !(isCommit != 0) {
  24918 		needSyncPgno = (*DbPage)(unsafe.Pointer(pPg)).Fpgno
  24919 
  24920 	}
  24921 
  24922 	*(*U16)(unsafe.Pointer(pPg + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_NEED_SYNC))
  24923 	pPgOld = Xsqlite3PagerLookup(tls, pPager, pgno)
  24924 
  24925 	if pPgOld != 0 {
  24926 		if (*PgHdr)(unsafe.Pointer(pPgOld)).FnRef > int64(1) {
  24927 			Xsqlite3PagerUnrefNotNull(tls, pPgOld)
  24928 			return Xsqlite3CorruptError(tls, 62627)
  24929 		}
  24930 		*(*U16)(unsafe.Pointer(pPg + 28)) |= U16(int32((*PgHdr)(unsafe.Pointer(pPgOld)).Fflags) & PGHDR_NEED_SYNC)
  24931 		if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 {
  24932 			Xsqlite3PcacheMove(tls, pPgOld, (*Pager)(unsafe.Pointer(pPager)).FdbSize+Pgno(1))
  24933 		} else {
  24934 			Xsqlite3PcacheDrop(tls, pPgOld)
  24935 		}
  24936 	}
  24937 
  24938 	origPgno = (*DbPage)(unsafe.Pointer(pPg)).Fpgno
  24939 	Xsqlite3PcacheMove(tls, pPg, pgno)
  24940 	Xsqlite3PcacheMakeDirty(tls, pPg)
  24941 
  24942 	if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 && pPgOld != 0 {
  24943 		Xsqlite3PcacheMove(tls, pPgOld, origPgno)
  24944 		Xsqlite3PagerUnrefNotNull(tls, pPgOld)
  24945 	}
  24946 
  24947 	if needSyncPgno != 0 {
  24948 		rc = Xsqlite3PagerGet(tls, pPager, needSyncPgno, bp, 0)
  24949 		if rc != SQLITE_OK {
  24950 			if needSyncPgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize {
  24951 				Xsqlite3BitvecClear(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, needSyncPgno, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace)
  24952 			}
  24953 			return rc
  24954 		}
  24955 		*(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + 28)) |= U16(PGHDR_NEED_SYNC)
  24956 		Xsqlite3PcacheMakeDirty(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24957 		Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp)))
  24958 	}
  24959 
  24960 	return SQLITE_OK
  24961 }
  24962 
  24963 // The page handle passed as the first argument refers to a dirty page
  24964 // with a page number other than iNew. This function changes the page's
  24965 // page number to iNew and sets the value of the PgHdr.flags field to
  24966 // the value passed as the third parameter.
  24967 func Xsqlite3PagerRekey(tls *libc.TLS, pPg uintptr, iNew Pgno, flags U16) {
  24968 	(*DbPage)(unsafe.Pointer(pPg)).Fflags = flags
  24969 	Xsqlite3PcacheMove(tls, pPg, iNew)
  24970 }
  24971 
  24972 // Return a pointer to the data for the specified page.
  24973 func Xsqlite3PagerGetData(tls *libc.TLS, pPg uintptr) uintptr {
  24974 	return (*DbPage)(unsafe.Pointer(pPg)).FpData
  24975 }
  24976 
  24977 // Return a pointer to the Pager.nExtra bytes of "extra" space
  24978 // allocated along with the specified page.
  24979 func Xsqlite3PagerGetExtra(tls *libc.TLS, pPg uintptr) uintptr {
  24980 	return (*DbPage)(unsafe.Pointer(pPg)).FpExtra
  24981 }
  24982 
  24983 // Get/set the locking-mode for this pager. Parameter eMode must be one
  24984 // of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or
  24985 // PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then
  24986 // the locking-mode is set to the value specified.
  24987 //
  24988 // The returned value is either PAGER_LOCKINGMODE_NORMAL or
  24989 // PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated)
  24990 // locking-mode.
  24991 func Xsqlite3PagerLockingMode(tls *libc.TLS, pPager uintptr, eMode int32) int32 {
  24992 	if eMode >= 0 && !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && !(Xsqlite3WalHeapMemory(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) {
  24993 		(*Pager)(unsafe.Pointer(pPager)).FexclusiveMode = U8(eMode)
  24994 	}
  24995 	return int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode)
  24996 }
  24997 
  24998 // Set the journal-mode for this pager. Parameter eMode must be one of:
  24999 //
  25000 //	PAGER_JOURNALMODE_DELETE
  25001 //	PAGER_JOURNALMODE_TRUNCATE
  25002 //	PAGER_JOURNALMODE_PERSIST
  25003 //	PAGER_JOURNALMODE_OFF
  25004 //	PAGER_JOURNALMODE_MEMORY
  25005 //	PAGER_JOURNALMODE_WAL
  25006 //
  25007 // The journalmode is set to the value specified if the change is allowed.
  25008 // The change may be disallowed for the following reasons:
  25009 //
  25010 //   - An in-memory database can only have its journal_mode set to _OFF
  25011 //     or _MEMORY.
  25012 //
  25013 //   - Temporary databases cannot have _WAL journalmode.
  25014 //
  25015 // The returned indicate the current (possibly updated) journal-mode.
  25016 func Xsqlite3PagerSetJournalMode(tls *libc.TLS, pPager uintptr, eMode int32) int32 {
  25017 	var eOld U8 = (*Pager)(unsafe.Pointer(pPager)).FjournalMode
  25018 
  25019 	if (*Pager)(unsafe.Pointer(pPager)).FmemDb != 0 {
  25020 		if eMode != PAGER_JOURNALMODE_MEMORY && eMode != PAGER_JOURNALMODE_OFF {
  25021 			eMode = int32(eOld)
  25022 		}
  25023 	}
  25024 
  25025 	if eMode != int32(eOld) {
  25026 		(*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(eMode)
  25027 
  25028 		if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) && int32(eOld)&5 == 1 && eMode&1 == 0 {
  25029 			Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  25030 			if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) >= RESERVED_LOCK {
  25031 				Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0)
  25032 			} else {
  25033 				var rc int32 = SQLITE_OK
  25034 				var state int32 = int32((*Pager)(unsafe.Pointer(pPager)).FeState)
  25035 
  25036 				if state == PAGER_OPEN {
  25037 					rc = Xsqlite3PagerSharedLock(tls, pPager)
  25038 				}
  25039 				if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER {
  25040 					rc = pagerLockDb(tls, pPager, RESERVED_LOCK)
  25041 				}
  25042 				if rc == SQLITE_OK {
  25043 					Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0)
  25044 				}
  25045 				if rc == SQLITE_OK && state == PAGER_READER {
  25046 					pagerUnlockDb(tls, pPager, SHARED_LOCK)
  25047 				} else if state == PAGER_OPEN {
  25048 					pager_unlock(tls, pPager)
  25049 				}
  25050 
  25051 			}
  25052 		} else if eMode == PAGER_JOURNALMODE_OFF {
  25053 			Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  25054 		}
  25055 	}
  25056 
  25057 	return int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode)
  25058 }
  25059 
  25060 // Return the current journal mode.
  25061 func Xsqlite3PagerGetJournalMode(tls *libc.TLS, pPager uintptr) int32 {
  25062 	return int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode)
  25063 }
  25064 
  25065 // Return TRUE if the pager is in a state where it is OK to change the
  25066 // journalmode.  Journalmode changes can only happen when the database
  25067 // is unmodified.
  25068 func Xsqlite3PagerOkToChangeJournalMode(tls *libc.TLS, pPager uintptr) int32 {
  25069 	if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_CACHEMOD {
  25070 		return 0
  25071 	}
  25072 	if (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Fjfd)).FpMethods != uintptr(0) && (*Pager)(unsafe.Pointer(pPager)).FjournalOff > int64(0) {
  25073 		return 0
  25074 	}
  25075 	return 1
  25076 }
  25077 
  25078 // Get/set the size-limit used for persistent journal files.
  25079 //
  25080 // Setting the size limit to -1 means no limit is enforced.
  25081 // An attempt to set a limit smaller than -1 is a no-op.
  25082 func Xsqlite3PagerJournalSizeLimit(tls *libc.TLS, pPager uintptr, iLimit I64) I64 {
  25083 	if iLimit >= int64(-1) {
  25084 		(*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit = iLimit
  25085 		Xsqlite3WalLimit(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, iLimit)
  25086 	}
  25087 	return (*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit
  25088 }
  25089 
  25090 // Return a pointer to the pPager->pBackup variable. The backup module
  25091 // in backup.c maintains the content of this variable. This module
  25092 // uses it opaquely as an argument to sqlite3BackupRestart() and
  25093 // sqlite3BackupUpdate() only.
  25094 func Xsqlite3PagerBackupPtr(tls *libc.TLS, pPager uintptr) uintptr {
  25095 	return pPager + 96
  25096 }
  25097 
  25098 // Unless this is an in-memory or temporary database, clear the pager cache.
  25099 func Xsqlite3PagerClearCache(tls *libc.TLS, pPager uintptr) {
  25100 	if int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0 {
  25101 		pager_reset(tls, pPager)
  25102 	}
  25103 }
  25104 
  25105 // This function is called when the user invokes "PRAGMA wal_checkpoint",
  25106 // "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
  25107 // or wal_blocking_checkpoint() API functions.
  25108 //
  25109 // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.
  25110 func Xsqlite3PagerCheckpoint(tls *libc.TLS, pPager uintptr, db uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 {
  25111 	var rc int32 = SQLITE_OK
  25112 	if (*Pager)(unsafe.Pointer(pPager)).FpWal == uintptr(0) && int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_WAL {
  25113 		Xsqlite3_exec(tls, db, ts+3952, uintptr(0), uintptr(0), uintptr(0))
  25114 	}
  25115 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  25116 		rc = Xsqlite3WalCheckpoint(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, eMode,
  25117 			func() uintptr {
  25118 				if eMode == SQLITE_CHECKPOINT_PASSIVE {
  25119 					return uintptr(0)
  25120 				}
  25121 				return (*Pager)(unsafe.Pointer(pPager)).FxBusyHandler
  25122 			}(),
  25123 			(*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg,
  25124 			int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace,
  25125 			pnLog, pnCkpt)
  25126 	}
  25127 	return rc
  25128 }
  25129 
  25130 func Xsqlite3PagerWalCallback(tls *libc.TLS, pPager uintptr) int32 {
  25131 	return Xsqlite3WalCallback(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  25132 }
  25133 
  25134 // Return true if the underlying VFS for the given pager supports the
  25135 // primitives necessary for write-ahead logging.
  25136 func Xsqlite3PagerWalSupported(tls *libc.TLS, pPager uintptr) int32 {
  25137 	var pMethods uintptr = (*Sqlite3_file)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).Ffd)).FpMethods
  25138 	if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 {
  25139 		return 0
  25140 	}
  25141 	return libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 || (*Sqlite3_io_methods)(unsafe.Pointer(pMethods)).FiVersion >= 2 && (*Sqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmMap != 0)
  25142 }
  25143 
  25144 func pagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 {
  25145 	var rc int32
  25146 
  25147 	rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK)
  25148 	if rc != SQLITE_OK {
  25149 		pagerUnlockDb(tls, pPager, SHARED_LOCK)
  25150 	}
  25151 
  25152 	return rc
  25153 }
  25154 
  25155 func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 {
  25156 	var rc int32 = SQLITE_OK
  25157 
  25158 	if (*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 {
  25159 		rc = pagerExclusiveLock(tls, pPager)
  25160 	}
  25161 
  25162 	if rc == SQLITE_OK {
  25163 		rc = Xsqlite3WalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs,
  25164 			(*Pager)(unsafe.Pointer(pPager)).Ffd, (*Pager)(unsafe.Pointer(pPager)).FzWal, int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode),
  25165 			(*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit, pPager+232)
  25166 	}
  25167 	pagerFixMaplimit(tls, pPager)
  25168 
  25169 	return rc
  25170 }
  25171 
  25172 // The caller must be holding a SHARED lock on the database file to call
  25173 // this function.
  25174 //
  25175 // If the pager passed as the first argument is open on a real database
  25176 // file (not a temp file or an in-memory database), and the WAL file
  25177 // is not already open, make an attempt to open it now. If successful,
  25178 // return SQLITE_OK. If an error occurs or the VFS used by the pager does
  25179 // not support the xShmXXX() methods, return an error code. *pbOpen is
  25180 // not modified in either case.
  25181 //
  25182 // If the pager is open on a temp-file (or in-memory database), or if
  25183 // the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK
  25184 // without doing anything.
  25185 func Xsqlite3PagerOpenWal(tls *libc.TLS, pPager uintptr, pbOpen uintptr) int32 {
  25186 	var rc int32 = SQLITE_OK
  25187 
  25188 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) {
  25189 		if !(Xsqlite3PagerWalSupported(tls, pPager) != 0) {
  25190 			return SQLITE_CANTOPEN
  25191 		}
  25192 
  25193 		Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd)
  25194 
  25195 		rc = pagerOpenWal(tls, pPager)
  25196 		if rc == SQLITE_OK {
  25197 			(*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(PAGER_JOURNALMODE_WAL)
  25198 			(*Pager)(unsafe.Pointer(pPager)).FeState = U8(PAGER_OPEN)
  25199 		}
  25200 	} else {
  25201 		*(*int32)(unsafe.Pointer(pbOpen)) = 1
  25202 	}
  25203 
  25204 	return rc
  25205 }
  25206 
  25207 // This function is called to close the connection to the log file prior
  25208 // to switching from WAL to rollback mode.
  25209 //
  25210 // Before closing the log file, this function attempts to take an
  25211 // EXCLUSIVE lock on the database file. If this cannot be obtained, an
  25212 // error (SQLITE_BUSY) is returned and the log connection is not closed.
  25213 // If successful, the EXCLUSIVE lock is not released before returning.
  25214 func Xsqlite3PagerCloseWal(tls *libc.TLS, pPager uintptr, db uintptr) int32 {
  25215 	bp := tls.Alloc(4)
  25216 	defer tls.Free(4)
  25217 
  25218 	var rc int32 = SQLITE_OK
  25219 
  25220 	if !(int32((*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) {
  25221 		*(*int32)(unsafe.Pointer(bp)) = 0
  25222 		rc = pagerLockDb(tls, pPager, SHARED_LOCK)
  25223 		if rc == SQLITE_OK {
  25224 			rc = Xsqlite3OsAccess(tls,
  25225 				(*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp)
  25226 		}
  25227 		if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp)) != 0 {
  25228 			rc = pagerOpenWal(tls, pPager)
  25229 		}
  25230 	}
  25231 
  25232 	if rc == SQLITE_OK && (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  25233 		rc = pagerExclusiveLock(tls, pPager)
  25234 		if rc == SQLITE_OK {
  25235 			rc = Xsqlite3WalClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags),
  25236 				int32((*Pager)(unsafe.Pointer(pPager)).FpageSize), (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace)
  25237 			(*Pager)(unsafe.Pointer(pPager)).FpWal = uintptr(0)
  25238 			pagerFixMaplimit(tls, pPager)
  25239 			if rc != 0 && !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) {
  25240 				pagerUnlockDb(tls, pPager, SHARED_LOCK)
  25241 			}
  25242 		}
  25243 	}
  25244 	return rc
  25245 }
  25246 
  25247 // If this is a WAL database, obtain a snapshot handle for the snapshot
  25248 // currently open. Otherwise, return an error.
  25249 func Xsqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) int32 {
  25250 	var rc int32 = SQLITE_ERROR
  25251 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  25252 		rc = Xsqlite3WalSnapshotGet(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, ppSnapshot)
  25253 	}
  25254 	return rc
  25255 }
  25256 
  25257 // If this is a WAL database, store a pointer to pSnapshot. Next time a
  25258 // read transaction is opened, attempt to read from the snapshot it
  25259 // identifies. If this is not a WAL database, return an error.
  25260 func Xsqlite3PagerSnapshotOpen(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) int32 {
  25261 	var rc int32 = SQLITE_OK
  25262 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  25263 		Xsqlite3WalSnapshotOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSnapshot)
  25264 	} else {
  25265 		rc = SQLITE_ERROR
  25266 	}
  25267 	return rc
  25268 }
  25269 
  25270 // If this is a WAL database, call sqlite3WalSnapshotRecover(). If this
  25271 // is not a WAL database, return an error.
  25272 func Xsqlite3PagerSnapshotRecover(tls *libc.TLS, pPager uintptr) int32 {
  25273 	var rc int32
  25274 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  25275 		rc = Xsqlite3WalSnapshotRecover(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  25276 	} else {
  25277 		rc = SQLITE_ERROR
  25278 	}
  25279 	return rc
  25280 }
  25281 
  25282 // The caller currently has a read transaction open on the database.
  25283 // If this is not a WAL database, SQLITE_ERROR is returned. Otherwise,
  25284 // this function takes a SHARED lock on the CHECKPOINTER slot and then
  25285 // checks if the snapshot passed as the second argument is still
  25286 // available. If so, SQLITE_OK is returned.
  25287 //
  25288 // If the snapshot is not available, SQLITE_ERROR is returned. Or, if
  25289 // the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
  25290 // occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
  25291 // lock is released before returning.
  25292 func Xsqlite3PagerSnapshotCheck(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) int32 {
  25293 	var rc int32
  25294 	if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 {
  25295 		rc = Xsqlite3WalSnapshotCheck(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSnapshot)
  25296 	} else {
  25297 		rc = SQLITE_ERROR
  25298 	}
  25299 	return rc
  25300 }
  25301 
  25302 // Release a lock obtained by an earlier successful call to
  25303 // sqlite3PagerSnapshotCheck().
  25304 func Xsqlite3PagerSnapshotUnlock(tls *libc.TLS, pPager uintptr) {
  25305 	Xsqlite3WalSnapshotUnlock(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal)
  25306 }
  25307 
  25308 // Object declarations
  25309 type WalIndexHdr1 = struct {
  25310 	FiVersion    U32
  25311 	Funused      U32
  25312 	FiChange     U32
  25313 	FisInit      U8
  25314 	FbigEndCksum U8
  25315 	FszPage      U16
  25316 	FmxFrame     U32
  25317 	FnPage       U32
  25318 	FaFrameCksum [2]U32
  25319 	FaSalt       [2]U32
  25320 	FaCksum      [2]U32
  25321 }
  25322 
  25323 // Object declarations
  25324 type WalIndexHdr = WalIndexHdr1
  25325 type WalIterator1 = struct {
  25326 	FiPrior   U32
  25327 	FnSegment int32
  25328 	FaSegment [1]struct {
  25329 		FiNext  int32
  25330 		FaIndex uintptr
  25331 		FaPgno  uintptr
  25332 		FnEntry int32
  25333 		FiZero  int32
  25334 	}
  25335 }
  25336 
  25337 type WalIterator = WalIterator1
  25338 type WalCkptInfo1 = struct {
  25339 	FnBackfill          U32
  25340 	FaReadMark          [5]U32
  25341 	FaLock              [8]U8
  25342 	FnBackfillAttempted U32
  25343 	FnotUsed0           U32
  25344 }
  25345 
  25346 type WalCkptInfo = WalCkptInfo1
  25347 
  25348 // Each page of the wal-index mapping contains a hash-table made up of
  25349 // an array of HASHTABLE_NSLOT elements of the following type.
  25350 type Ht_slot = U16
  25351 
  25352 // This structure is used to implement an iterator that loops through
  25353 // all frames in the WAL in database page order. Where two or more frames
  25354 // correspond to the same database page, the iterator visits only the
  25355 // frame most recently written to the WAL (in other words, the frame with
  25356 // the largest index).
  25357 //
  25358 // The internals of this structure are only accessed by:
  25359 //
  25360 //	walIteratorInit() - Create a new iterator,
  25361 //	walIteratorNext() - Step an iterator,
  25362 //	walIteratorFree() - Free an iterator.
  25363 //
  25364 // This functionality is used by the checkpoint code (see walCheckpoint()).
  25365 type WalSegment = struct {
  25366 	FiNext  int32
  25367 	FaIndex uintptr
  25368 	FaPgno  uintptr
  25369 	FnEntry int32
  25370 	FiZero  int32
  25371 }
  25372 
  25373 func walIndexPageRealloc(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) int32 {
  25374 	var rc int32 = SQLITE_OK
  25375 
  25376 	if (*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage {
  25377 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(uintptr(0))) * uint32(iPage+1))
  25378 		var apNew uintptr
  25379 		libc.AtomicStoreUintptr(&apNew, Xsqlite3Realloc(tls, (*Wal)(unsafe.Pointer(pWal)).FapWiData, uint64(nByte)))
  25380 		if !(apNew != 0) {
  25381 			*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  25382 			return SQLITE_NOMEM
  25383 		}
  25384 		libc.Xmemset(tls, apNew+uintptr((*Wal)(unsafe.Pointer(pWal)).FnWiData)*4, 0,
  25385 			uint32(unsafe.Sizeof(uintptr(0)))*uint32(iPage+1-(*Wal)(unsafe.Pointer(pWal)).FnWiData))
  25386 		(*Wal)(unsafe.Pointer(pWal)).FapWiData = apNew
  25387 		(*Wal)(unsafe.Pointer(pWal)).FnWiData = iPage + 1
  25388 	}
  25389 
  25390 	if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE {
  25391 		*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*4)) = Xsqlite3MallocZero(tls, uint64(uint32(unsafe.Sizeof(Ht_slot(0)))*uint32(HASHTABLE_NPAGE*2)+uint32(HASHTABLE_NPAGE)*uint32(unsafe.Sizeof(U32(0)))))
  25392 		if !(int32(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*4))) != 0) {
  25393 			rc = SQLITE_NOMEM
  25394 		}
  25395 	} else {
  25396 		rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, iPage, int32(uint32(unsafe.Sizeof(Ht_slot(0)))*uint32(HASHTABLE_NPAGE*2)+uint32(HASHTABLE_NPAGE)*uint32(unsafe.Sizeof(U32(0)))),
  25397 			int32((*Wal)(unsafe.Pointer(pWal)).FwriteLock), (*Wal)(unsafe.Pointer(pWal)).FapWiData+uintptr(iPage)*4)
  25398 
  25399 		if rc == SQLITE_OK {
  25400 			if iPage > 0 && Xsqlite3FaultSim(tls, 600) != 0 {
  25401 				rc = SQLITE_NOMEM
  25402 			}
  25403 		} else if rc&0xff == SQLITE_READONLY {
  25404 			*(*U8)(unsafe.Pointer(pWal + 46)) |= U8(WAL_SHM_RDONLY)
  25405 			if rc == SQLITE_READONLY {
  25406 				rc = SQLITE_OK
  25407 			}
  25408 		}
  25409 	}
  25410 
  25411 	*(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*4))
  25412 
  25413 	return rc
  25414 }
  25415 
  25416 func walIndexPage(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) int32 {
  25417 	if (*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage || libc.AssignPtrUintptr(ppPage, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*4))) == uintptr(0) {
  25418 		return walIndexPageRealloc(tls, pWal, iPage, ppPage)
  25419 	}
  25420 	return SQLITE_OK
  25421 }
  25422 
  25423 func walCkptInfo(tls *libc.TLS, pWal uintptr) uintptr {
  25424 	return *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) + 24*4
  25425 }
  25426 
  25427 func walIndexHdr(tls *libc.TLS, pWal uintptr) uintptr {
  25428 	return *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData))
  25429 }
  25430 
  25431 func walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, aIn uintptr, aOut uintptr) {
  25432 	var s1 U32
  25433 	var s2 U32
  25434 	var aData uintptr = a
  25435 	var aEnd uintptr = a + uintptr(nByte)
  25436 
  25437 	if aIn != 0 {
  25438 		s1 = *(*U32)(unsafe.Pointer(aIn))
  25439 		s2 = *(*U32)(unsafe.Pointer(aIn + 1*4))
  25440 	} else {
  25441 		s1 = libc.AssignUint32(&s2, U32(0))
  25442 	}
  25443 
  25444 	if nativeCksum != 0 {
  25445 		for __ccgo := true; __ccgo; __ccgo = aData < aEnd {
  25446 			s1 = s1 + (*(*U32)(unsafe.Pointer(libc.PostIncUintptr(&aData, 4))) + s2)
  25447 			s2 = s2 + (*(*U32)(unsafe.Pointer(libc.PostIncUintptr(&aData, 4))) + s1)
  25448 		}
  25449 	} else {
  25450 		for __ccgo1 := true; __ccgo1; __ccgo1 = aData < aEnd {
  25451 			s1 = s1 + (*(*U32)(unsafe.Pointer(aData))&U32(0x000000FF)<<24 + *(*U32)(unsafe.Pointer(aData))&U32(0x0000FF00)<<8 + *(*U32)(unsafe.Pointer(aData))&U32(0x00FF0000)>>8 + *(*U32)(unsafe.Pointer(aData))&0xFF000000>>24 + s2)
  25452 			s2 = s2 + (*(*U32)(unsafe.Pointer(aData + 1*4))&U32(0x000000FF)<<24 + *(*U32)(unsafe.Pointer(aData + 1*4))&U32(0x0000FF00)<<8 + *(*U32)(unsafe.Pointer(aData + 1*4))&U32(0x00FF0000)>>8 + *(*U32)(unsafe.Pointer(aData + 1*4))&0xFF000000>>24 + s1)
  25453 			aData += 4 * uintptr(2)
  25454 		}
  25455 	}
  25456 
  25457 	*(*U32)(unsafe.Pointer(aOut)) = s1
  25458 	*(*U32)(unsafe.Pointer(aOut + 1*4)) = s2
  25459 }
  25460 
  25461 func walShmBarrier(tls *libc.TLS, pWal uintptr) {
  25462 	if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_HEAPMEMORY_MODE {
  25463 		Xsqlite3OsShmBarrier(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd)
  25464 	}
  25465 }
  25466 
  25467 func walIndexWriteHdr(tls *libc.TLS, pWal uintptr) {
  25468 	var aHdr uintptr = walIndexHdr(tls, pWal)
  25469 	var nCksum int32 = int32(uintptr(0) + 40)
  25470 
  25471 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FisInit = U8(1)
  25472 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = U32(WALINDEX_MAX_VERSION)
  25473 	walChecksumBytes(tls, 1, pWal+52, nCksum, uintptr(0), pWal+52+40)
  25474 
  25475 	libc.Xmemcpy(tls, aHdr+1*48, pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{})))
  25476 	walShmBarrier(tls, pWal)
  25477 	libc.Xmemcpy(tls, aHdr, pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{})))
  25478 }
  25479 
  25480 func walEncodeFrame(tls *libc.TLS, pWal uintptr, iPage U32, nTruncate U32, aData uintptr, aFrame uintptr) {
  25481 	var nativeCksum int32
  25482 	var aCksum uintptr = pWal + 52 + 24
  25483 
  25484 	Xsqlite3Put4byte(tls, aFrame, iPage)
  25485 	Xsqlite3Put4byte(tls, aFrame+4, nTruncate)
  25486 	if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(0) {
  25487 		libc.Xmemcpy(tls, aFrame+8, pWal+52+32, uint32(8))
  25488 
  25489 		nativeCksum = libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)
  25490 		walChecksumBytes(tls, nativeCksum, aFrame, 8, aCksum, aCksum)
  25491 		walChecksumBytes(tls, nativeCksum, aData, int32((*Wal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum)
  25492 
  25493 		Xsqlite3Put4byte(tls, aFrame+16, *(*U32)(unsafe.Pointer(aCksum)))
  25494 		Xsqlite3Put4byte(tls, aFrame+20, *(*U32)(unsafe.Pointer(aCksum + 1*4)))
  25495 	} else {
  25496 		libc.Xmemset(tls, aFrame+8, 0, uint32(16))
  25497 	}
  25498 }
  25499 
  25500 func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uintptr, aData uintptr, aFrame uintptr) int32 {
  25501 	var nativeCksum int32
  25502 	var aCksum uintptr = pWal + 52 + 24
  25503 	var pgno U32
  25504 
  25505 	if libc.Xmemcmp(tls, pWal+52+32, aFrame+8, uint32(8)) != 0 {
  25506 		return 0
  25507 	}
  25508 
  25509 	pgno = Xsqlite3Get4byte(tls, aFrame)
  25510 	if pgno == U32(0) {
  25511 		return 0
  25512 	}
  25513 
  25514 	nativeCksum = libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)
  25515 	walChecksumBytes(tls, nativeCksum, aFrame, 8, aCksum, aCksum)
  25516 	walChecksumBytes(tls, nativeCksum, aData, int32((*Wal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum)
  25517 	if *(*U32)(unsafe.Pointer(aCksum)) != Xsqlite3Get4byte(tls, aFrame+16) ||
  25518 		*(*U32)(unsafe.Pointer(aCksum + 1*4)) != Xsqlite3Get4byte(tls, aFrame+20) {
  25519 		return 0
  25520 	}
  25521 
  25522 	*(*U32)(unsafe.Pointer(piPage)) = pgno
  25523 	*(*U32)(unsafe.Pointer(pnTruncate)) = Xsqlite3Get4byte(tls, aFrame+4)
  25524 	return 1
  25525 }
  25526 
  25527 func walLockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) int32 {
  25528 	var rc int32
  25529 	if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
  25530 		return SQLITE_OK
  25531 	}
  25532 	rc = Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, 1,
  25533 		SQLITE_SHM_LOCK|SQLITE_SHM_SHARED)
  25534 
  25535 	return rc
  25536 }
  25537 
  25538 func walUnlockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) {
  25539 	if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
  25540 		return
  25541 	}
  25542 	Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, 1,
  25543 		SQLITE_SHM_UNLOCK|SQLITE_SHM_SHARED)
  25544 
  25545 }
  25546 
  25547 func walLockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) int32 {
  25548 	var rc int32
  25549 	if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
  25550 		return SQLITE_OK
  25551 	}
  25552 	rc = Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n,
  25553 		SQLITE_SHM_LOCK|SQLITE_SHM_EXCLUSIVE)
  25554 
  25555 	return rc
  25556 }
  25557 
  25558 func walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) {
  25559 	if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
  25560 		return
  25561 	}
  25562 	Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n,
  25563 		SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE)
  25564 
  25565 }
  25566 
  25567 func walHash(tls *libc.TLS, iPage U32) int32 {
  25568 	return int32(iPage * U32(HASHTABLE_HASH_1) & U32(HASHTABLE_NPAGE*2-1))
  25569 }
  25570 
  25571 func walNextHash(tls *libc.TLS, iPriorHash int32) int32 {
  25572 	return (iPriorHash + 1) & (HASHTABLE_NPAGE*2 - 1)
  25573 }
  25574 
  25575 // An instance of the WalHashLoc object is used to describe the location
  25576 // of a page hash table in the wal-index.  This becomes the return value
  25577 // from walHashGet().
  25578 type WalHashLoc1 = struct {
  25579 	FaHash uintptr
  25580 	FaPgno uintptr
  25581 	FiZero U32
  25582 }
  25583 
  25584 // An instance of the WalHashLoc object is used to describe the location
  25585 // of a page hash table in the wal-index.  This becomes the return value
  25586 // from walHashGet().
  25587 type WalHashLoc = WalHashLoc1
  25588 
  25589 func walHashGet(tls *libc.TLS, pWal uintptr, iHash int32, pLoc uintptr) int32 {
  25590 	var rc int32
  25591 
  25592 	rc = walIndexPage(tls, pWal, iHash, pLoc+4)
  25593 
  25594 	if (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno != 0 {
  25595 		(*WalHashLoc)(unsafe.Pointer(pLoc)).FaHash = (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 4096*4
  25596 		if iHash == 0 {
  25597 			(*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 34*4
  25598 			(*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = U32(0)
  25599 		} else {
  25600 			(*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = uint32(HASHTABLE_NPAGE) - (uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0))) + uint32((iHash-1)*HASHTABLE_NPAGE)
  25601 		}
  25602 	} else if rc == SQLITE_OK {
  25603 		rc = SQLITE_ERROR
  25604 	}
  25605 	return rc
  25606 }
  25607 
  25608 func walFramePage(tls *libc.TLS, iFrame U32) int32 {
  25609 	var iHash int32 = int32((iFrame + U32(HASHTABLE_NPAGE) - (uint32(HASHTABLE_NPAGE) - (uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0)))) - U32(1)) / U32(HASHTABLE_NPAGE))
  25610 
  25611 	return iHash
  25612 }
  25613 
  25614 func walFramePgno(tls *libc.TLS, pWal uintptr, iFrame U32) U32 {
  25615 	var iHash int32 = walFramePage(tls, iFrame)
  25616 	if iHash == 0 {
  25617 		return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) + uintptr((uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0)))+iFrame-uint32(1))*4))
  25618 	}
  25619 	return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iHash)*4)) + uintptr((iFrame-U32(1)-(uint32(HASHTABLE_NPAGE)-(uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0)))))%U32(HASHTABLE_NPAGE))*4))
  25620 }
  25621 
  25622 func walCleanupHash(tls *libc.TLS, pWal uintptr) {
  25623 	bp := tls.Alloc(12)
  25624 	defer tls.Free(12)
  25625 
  25626 	var iLimit int32 = 0
  25627 	var nByte int32
  25628 	var i int32
  25629 
  25630 	if (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0) {
  25631 		return
  25632 	}
  25633 
  25634 	i = walHashGet(tls, pWal, walFramePage(tls, (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame), bp)
  25635 	if i != 0 {
  25636 		return
  25637 	}
  25638 
  25639 	iLimit = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - (*WalHashLoc)(unsafe.Pointer(bp)).FiZero)
  25640 
  25641 	for i = 0; i < HASHTABLE_NPAGE*2; i++ {
  25642 		if int32(*(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp)).FaHash + uintptr(i)*2))) > iLimit {
  25643 			*(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp)).FaHash + uintptr(i)*2)) = Ht_slot(0)
  25644 		}
  25645 	}
  25646 
  25647 	nByte = (int32((*WalHashLoc)(unsafe.Pointer(bp)).FaHash) - int32((*WalHashLoc)(unsafe.Pointer(bp)).FaPgno+uintptr(iLimit)*4)) / 1
  25648 
  25649 	libc.Xmemset(tls, (*WalHashLoc)(unsafe.Pointer(bp)).FaPgno+uintptr(iLimit)*4, 0, uint32(nByte))
  25650 
  25651 }
  25652 
  25653 func walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame U32, iPage U32) int32 {
  25654 	bp := tls.Alloc(12)
  25655 	defer tls.Free(12)
  25656 
  25657 	var rc int32
  25658 
  25659 	rc = walHashGet(tls, pWal, walFramePage(tls, iFrame), bp)
  25660 
  25661 	if rc == SQLITE_OK {
  25662 		var iKey int32
  25663 		var idx int32
  25664 		var nCollide int32
  25665 
  25666 		idx = int32(iFrame - (*WalHashLoc)(unsafe.Pointer(bp)).FiZero)
  25667 
  25668 		if idx == 1 {
  25669 			var nByte int32 = (int32((*WalHashLoc)(unsafe.Pointer(bp)).FaHash+8192*2) - int32((*WalHashLoc)(unsafe.Pointer(bp)).FaPgno)) / 1
  25670 
  25671 			libc.Xmemset(tls, (*WalHashLoc)(unsafe.Pointer(bp)).FaPgno, 0, uint32(nByte))
  25672 		}
  25673 
  25674 		if *(*U32)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp)).FaPgno + uintptr(idx-1)*4)) != 0 {
  25675 			walCleanupHash(tls, pWal)
  25676 
  25677 		}
  25678 
  25679 		nCollide = idx
  25680 		for iKey = walHash(tls, iPage); *(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp)).FaHash + uintptr(iKey)*2)) != 0; iKey = walNextHash(tls, iKey) {
  25681 			if libc.PostDecInt32(&nCollide, 1) == 0 {
  25682 				return Xsqlite3CorruptError(tls, 64391)
  25683 			}
  25684 		}
  25685 		*(*U32)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp)).FaPgno + uintptr(idx-1)*4)) = iPage
  25686 		libc.AtomicStoreNUint16((*WalHashLoc)(unsafe.Pointer(bp)).FaHash+uintptr(iKey)*2, Ht_slot(idx), 0)
  25687 
  25688 	}
  25689 
  25690 	return rc
  25691 }
  25692 
  25693 func walIndexRecover(tls *libc.TLS, pWal uintptr) int32 {
  25694 	bp := tls.Alloc(76)
  25695 	defer tls.Free(76)
  25696 
  25697 	var rc int32
  25698 
  25699 	var iLock int32
  25700 	var iOffset I64
  25701 
  25702 	var iFrame U32
  25703 	var iLast U32
  25704 	var iFirst U32
  25705 	var nHdr U32
  25706 	var nHdr32 U32
  25707 
  25708 	var aPrivate uintptr
  25709 	var aFrame uintptr
  25710 	var szFrame int32
  25711 	var aData uintptr
  25712 	var szPage int32
  25713 	var magic U32
  25714 	var version U32
  25715 	var isValid int32
  25716 	var iPg U32
  25717 	var iLastFrame U32
  25718 	var pInfo uintptr
  25719 	var i int32
  25720 	*(*[2]U32)(unsafe.Pointer(bp + 68)) = [2]U32{U32(0), U32(0)}
  25721 
  25722 	iLock = WAL_ALL_BUT_WRITE + int32((*Wal)(unsafe.Pointer(pWal)).FckptLock)
  25723 	rc = walLockExclusive(tls, pWal, iLock, 3+0-iLock)
  25724 	if !(rc != 0) {
  25725 		goto __1
  25726 	}
  25727 	return rc
  25728 __1:
  25729 	;
  25730 	libc.Xmemset(tls, pWal+52, 0, uint32(unsafe.Sizeof(WalIndexHdr{})))
  25731 
  25732 	rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16)
  25733 	if !(rc != SQLITE_OK) {
  25734 		goto __2
  25735 	}
  25736 	goto recovery_error
  25737 __2:
  25738 	;
  25739 	if !(*(*I64)(unsafe.Pointer(bp + 16)) > int64(WAL_HDRSIZE)) {
  25740 		goto __3
  25741 	}
  25742 	aPrivate = uintptr(0)
  25743 	aFrame = uintptr(0)
  25744 
  25745 	rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+24, WAL_HDRSIZE, int64(0))
  25746 	if !(rc != SQLITE_OK) {
  25747 		goto __4
  25748 	}
  25749 	goto recovery_error
  25750 __4:
  25751 	;
  25752 	magic = Xsqlite3Get4byte(tls, bp+24)
  25753 	szPage = int32(Xsqlite3Get4byte(tls, bp+24+8))
  25754 	if !(magic&0xFFFFFFFE != U32(WAL_MAGIC) ||
  25755 		szPage&(szPage-1) != 0 ||
  25756 		szPage > SQLITE_MAX_PAGE_SIZE ||
  25757 		szPage < 512) {
  25758 		goto __5
  25759 	}
  25760 	goto finished
  25761 __5:
  25762 	;
  25763 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = U8(magic & U32(0x00000001))
  25764 	(*Wal)(unsafe.Pointer(pWal)).FszPage = U32(szPage)
  25765 	(*Wal)(unsafe.Pointer(pWal)).FnCkpt = Xsqlite3Get4byte(tls, bp+24+12)
  25766 	libc.Xmemcpy(tls, pWal+52+32, bp+24+16, uint32(8))
  25767 
  25768 	walChecksumBytes(tls, libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN),
  25769 		bp+24, WAL_HDRSIZE-2*4, uintptr(0), pWal+52+24)
  25770 	if !(*(*U32)(unsafe.Pointer(pWal + 52 + 24)) != Xsqlite3Get4byte(tls, bp+24+24) ||
  25771 		*(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4)) != Xsqlite3Get4byte(tls, bp+24+28)) {
  25772 		goto __6
  25773 	}
  25774 	goto finished
  25775 __6:
  25776 	;
  25777 	version = Xsqlite3Get4byte(tls, bp+24+4)
  25778 	if !(version != U32(WAL_MAX_VERSION)) {
  25779 		goto __7
  25780 	}
  25781 	rc = Xsqlite3CantopenError(tls, 64523)
  25782 	goto finished
  25783 __7:
  25784 	;
  25785 	szFrame = szPage + WAL_FRAME_HDRSIZE
  25786 	aFrame = Xsqlite3_malloc64(tls, uint64(uint32(szFrame)+(uint32(unsafe.Sizeof(Ht_slot(0)))*uint32(HASHTABLE_NPAGE*2)+uint32(HASHTABLE_NPAGE)*uint32(unsafe.Sizeof(U32(0))))))
  25787 	if !!(aFrame != 0) {
  25788 		goto __8
  25789 	}
  25790 	rc = SQLITE_NOMEM
  25791 	goto recovery_error
  25792 __8:
  25793 	;
  25794 	aData = aFrame + 24
  25795 	aPrivate = aData + uintptr(szPage)
  25796 
  25797 	iLastFrame = U32((*(*I64)(unsafe.Pointer(bp + 16)) - int64(WAL_HDRSIZE)) / I64(szFrame))
  25798 	iPg = U32(0)
  25799 __9:
  25800 	if !(iPg <= U32(walFramePage(tls, iLastFrame))) {
  25801 		goto __11
  25802 	}
  25803 	iLast = func() uint32 {
  25804 		if iLastFrame < uint32(HASHTABLE_NPAGE)-(uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0)))+iPg*U32(HASHTABLE_NPAGE) {
  25805 			return iLastFrame
  25806 		}
  25807 		return uint32(HASHTABLE_NPAGE) - (uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0))) + iPg*U32(HASHTABLE_NPAGE)
  25808 	}()
  25809 	iFirst = uint32(1) + func() uint32 {
  25810 		if iPg == U32(0) {
  25811 			return uint32(0)
  25812 		}
  25813 		return uint32(HASHTABLE_NPAGE) - (uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2)+uint32(unsafe.Sizeof(WalCkptInfo{})))/uint32(unsafe.Sizeof(U32(0))) + (iPg-U32(1))*U32(HASHTABLE_NPAGE)
  25814 	}()
  25815 	rc = walIndexPage(tls, pWal, int32(iPg), bp+56)
  25816 
  25817 	if !(*(*uintptr)(unsafe.Pointer(bp + 56)) == uintptr(0)) {
  25818 		goto __12
  25819 	}
  25820 	goto __11
  25821 __12:
  25822 	;
  25823 	*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPg)*4)) = aPrivate
  25824 
  25825 	iFrame = iFirst
  25826 __13:
  25827 	if !(iFrame <= iLast) {
  25828 		goto __15
  25829 	}
  25830 	iOffset = int64(WAL_HDRSIZE) + I64(iFrame-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE)
  25831 
  25832 	rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset)
  25833 	if !(rc != SQLITE_OK) {
  25834 		goto __16
  25835 	}
  25836 	goto __15
  25837 __16:
  25838 	;
  25839 	isValid = walDecodeFrame(tls, pWal, bp+60, bp+64, aData, aFrame)
  25840 	if !!(isValid != 0) {
  25841 		goto __17
  25842 	}
  25843 	goto __15
  25844 __17:
  25845 	;
  25846 	rc = walIndexAppend(tls, pWal, iFrame, *(*U32)(unsafe.Pointer(bp + 60)))
  25847 	if !(rc != SQLITE_OK) {
  25848 		goto __18
  25849 	}
  25850 	goto __15
  25851 __18:
  25852 	;
  25853 	if !(*(*U32)(unsafe.Pointer(bp + 64)) != 0) {
  25854 		goto __19
  25855 	}
  25856 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = iFrame
  25857 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage = *(*U32)(unsafe.Pointer(bp + 64))
  25858 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage = U16(szPage&0xff00 | szPage>>16)
  25859 
  25860 	*(*U32)(unsafe.Pointer(bp + 68)) = *(*U32)(unsafe.Pointer(pWal + 52 + 24))
  25861 	*(*U32)(unsafe.Pointer(bp + 68 + 1*4)) = *(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4))
  25862 __19:
  25863 	;
  25864 	goto __14
  25865 __14:
  25866 	iFrame++
  25867 	goto __13
  25868 	goto __15
  25869 __15:
  25870 	;
  25871 	*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPg)*4)) = *(*uintptr)(unsafe.Pointer(bp + 56))
  25872 	nHdr = func() uint32 {
  25873 		if iPg == U32(0) {
  25874 			return uint32(unsafe.Sizeof(WalIndexHdr{}))*uint32(2) + uint32(unsafe.Sizeof(WalCkptInfo{}))
  25875 		}
  25876 		return uint32(0)
  25877 	}()
  25878 	nHdr32 = nHdr / U32(unsafe.Sizeof(U32(0)))
  25879 
  25880 	libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp + 56))+uintptr(nHdr32)*4, aPrivate+uintptr(nHdr32)*4, uint32(unsafe.Sizeof(Ht_slot(0)))*uint32(HASHTABLE_NPAGE*2)+uint32(HASHTABLE_NPAGE)*uint32(unsafe.Sizeof(U32(0)))-nHdr)
  25881 	if !(iFrame <= iLast) {
  25882 		goto __20
  25883 	}
  25884 	goto __11
  25885 __20:
  25886 	;
  25887 	goto __10
  25888 __10:
  25889 	iPg++
  25890 	goto __9
  25891 	goto __11
  25892 __11:
  25893 	;
  25894 	Xsqlite3_free(tls, aFrame)
  25895 __3:
  25896 	;
  25897 finished:
  25898 	if !(rc == SQLITE_OK) {
  25899 		goto __21
  25900 	}
  25901 	*(*U32)(unsafe.Pointer(pWal + 52 + 24)) = *(*U32)(unsafe.Pointer(bp + 68))
  25902 	*(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4)) = *(*U32)(unsafe.Pointer(bp + 68 + 1*4))
  25903 	walIndexWriteHdr(tls, pWal)
  25904 
  25905 	libc.AtomicStoreUintptr(&pInfo, walCkptInfo(tls, pWal))
  25906 	(*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill = U32(0)
  25907 	(*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  25908 	*(*U32)(unsafe.Pointer(pInfo + 4)) = U32(0)
  25909 	i = 1
  25910 __22:
  25911 	if !(i < SQLITE_SHM_NLOCK-3) {
  25912 		goto __24
  25913 	}
  25914 	rc = walLockExclusive(tls, pWal, 3+i, 1)
  25915 	if !(rc == SQLITE_OK) {
  25916 		goto __25
  25917 	}
  25918 	if !(i == 1 && (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0) {
  25919 		goto __27
  25920 	}
  25921 	*(*U32)(unsafe.Pointer(pInfo + 4 + uintptr(i)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  25922 	goto __28
  25923 __27:
  25924 	*(*U32)(unsafe.Pointer(pInfo + 4 + uintptr(i)*4)) = READMARK_NOT_USED
  25925 __28:
  25926 	;
  25927 	walUnlockExclusive(tls, pWal, 3+i, 1)
  25928 	goto __26
  25929 __25:
  25930 	if !(rc != SQLITE_BUSY) {
  25931 		goto __29
  25932 	}
  25933 	goto recovery_error
  25934 __29:
  25935 	;
  25936 __26:
  25937 	;
  25938 	goto __23
  25939 __23:
  25940 	i++
  25941 	goto __22
  25942 	goto __24
  25943 __24:
  25944 	;
  25945 	if !((*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage != 0) {
  25946 		goto __30
  25947 	}
  25948 	Xsqlite3_log(tls, SQLITE_NOTICE|int32(1)<<8,
  25949 		ts+3970,
  25950 		libc.VaList(bp, (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame, (*Wal)(unsafe.Pointer(pWal)).FzWalName))
  25951 __30:
  25952 	;
  25953 __21:
  25954 	;
  25955 recovery_error:
  25956 	;
  25957 	walUnlockExclusive(tls, pWal, iLock, 3+0-iLock)
  25958 	return rc
  25959 }
  25960 
  25961 func walIndexClose(tls *libc.TLS, pWal uintptr, isDelete int32) {
  25962 	if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE || (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 {
  25963 		var i int32
  25964 		for i = 0; i < (*Wal)(unsafe.Pointer(pWal)).FnWiData; i++ {
  25965 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*4)))
  25966 			*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*4)) = uintptr(0)
  25967 		}
  25968 	}
  25969 	if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_HEAPMEMORY_MODE {
  25970 		Xsqlite3OsShmUnmap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, isDelete)
  25971 	}
  25972 }
  25973 
  25974 // Open a connection to the WAL file zWalName. The database file must
  25975 // already be opened on connection pDbFd. The buffer that zWalName points
  25976 // to must remain valid for the lifetime of the returned Wal* handle.
  25977 //
  25978 // A SHARED lock should be held on the database file when this function
  25979 // is called. The purpose of this SHARED lock is to prevent any other
  25980 // client from unlinking the WAL or wal-index file. If another process
  25981 // were to do this just after this client opened one of these files, the
  25982 // system would be badly broken.
  25983 //
  25984 // If the log file is successfully opened, SQLITE_OK is returned and
  25985 // *ppWal is set to point to a new WAL handle. If an error occurs,
  25986 // an SQLite error code is returned and *ppWal is left unmodified.
  25987 func Xsqlite3WalOpen(tls *libc.TLS, pVfs uintptr, pDbFd uintptr, zWalName uintptr, bNoShm int32, mxWalSize I64, ppWal uintptr) int32 {
  25988 	bp := tls.Alloc(4)
  25989 	defer tls.Free(4)
  25990 
  25991 	var rc int32
  25992 	var pRet uintptr
  25993 
  25994 	*(*uintptr)(unsafe.Pointer(ppWal)) = uintptr(0)
  25995 	pRet = Xsqlite3MallocZero(tls, uint64(uint32(unsafe.Sizeof(Wal{}))+uint32((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)))
  25996 	if !(pRet != 0) {
  25997 		return SQLITE_NOMEM
  25998 	}
  25999 
  26000 	(*Wal)(unsafe.Pointer(pRet)).FpVfs = pVfs
  26001 	(*Wal)(unsafe.Pointer(pRet)).FpWalFd = pRet + 1*120
  26002 	(*Wal)(unsafe.Pointer(pRet)).FpDbFd = pDbFd
  26003 	(*Wal)(unsafe.Pointer(pRet)).FreadLock = int16(-1)
  26004 	(*Wal)(unsafe.Pointer(pRet)).FmxWalSize = mxWalSize
  26005 	(*Wal)(unsafe.Pointer(pRet)).FzWalName = zWalName
  26006 	(*Wal)(unsafe.Pointer(pRet)).FsyncHeader = U8(1)
  26007 	(*Wal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = U8(1)
  26008 	(*Wal)(unsafe.Pointer(pRet)).FexclusiveMode = func() uint8 {
  26009 		if bNoShm != 0 {
  26010 			return uint8(WAL_HEAPMEMORY_MODE)
  26011 		}
  26012 		return uint8(WAL_NORMAL_MODE)
  26013 	}()
  26014 
  26015 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_WAL
  26016 	rc = Xsqlite3OsOpen(tls, pVfs, zWalName, (*Wal)(unsafe.Pointer(pRet)).FpWalFd, *(*int32)(unsafe.Pointer(bp)), bp)
  26017 	if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp))&SQLITE_OPEN_READONLY != 0 {
  26018 		(*Wal)(unsafe.Pointer(pRet)).FreadOnly = U8(WAL_RDONLY)
  26019 	}
  26020 
  26021 	if rc != SQLITE_OK {
  26022 		walIndexClose(tls, pRet, 0)
  26023 		Xsqlite3OsClose(tls, (*Wal)(unsafe.Pointer(pRet)).FpWalFd)
  26024 		Xsqlite3_free(tls, pRet)
  26025 	} else {
  26026 		var iDC int32 = Xsqlite3OsDeviceCharacteristics(tls, pDbFd)
  26027 		if iDC&SQLITE_IOCAP_SEQUENTIAL != 0 {
  26028 			(*Wal)(unsafe.Pointer(pRet)).FsyncHeader = U8(0)
  26029 		}
  26030 		if iDC&SQLITE_IOCAP_POWERSAFE_OVERWRITE != 0 {
  26031 			(*Wal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = U8(0)
  26032 		}
  26033 		*(*uintptr)(unsafe.Pointer(ppWal)) = pRet
  26034 
  26035 	}
  26036 	return rc
  26037 }
  26038 
  26039 // Change the size to which the WAL file is trucated on each reset.
  26040 func Xsqlite3WalLimit(tls *libc.TLS, pWal uintptr, iLimit I64) {
  26041 	if pWal != 0 {
  26042 		(*Wal)(unsafe.Pointer(pWal)).FmxWalSize = iLimit
  26043 	}
  26044 }
  26045 
  26046 func walIteratorNext(tls *libc.TLS, p uintptr, piPage uintptr, piFrame uintptr) int32 {
  26047 	var iMin U32
  26048 	var iRet U32 = 0xFFFFFFFF
  26049 	var i int32
  26050 
  26051 	iMin = (*WalIterator)(unsafe.Pointer(p)).FiPrior
  26052 
  26053 	for i = (*WalIterator)(unsafe.Pointer(p)).FnSegment - 1; i >= 0; i-- {
  26054 		var pSegment uintptr = p + 8 + uintptr(i)*20
  26055 		for (*WalSegment)(unsafe.Pointer(pSegment)).FiNext < (*WalSegment)(unsafe.Pointer(pSegment)).FnEntry {
  26056 			var iPg U32 = *(*U32)(unsafe.Pointer((*WalSegment)(unsafe.Pointer(pSegment)).FaPgno + uintptr(*(*Ht_slot)(unsafe.Pointer((*WalSegment)(unsafe.Pointer(pSegment)).FaIndex + uintptr((*WalSegment)(unsafe.Pointer(pSegment)).FiNext)*2)))*4))
  26057 			if iPg > iMin {
  26058 				if iPg < iRet {
  26059 					iRet = iPg
  26060 					*(*U32)(unsafe.Pointer(piFrame)) = U32((*WalSegment)(unsafe.Pointer(pSegment)).FiZero + int32(*(*Ht_slot)(unsafe.Pointer((*WalSegment)(unsafe.Pointer(pSegment)).FaIndex + uintptr((*WalSegment)(unsafe.Pointer(pSegment)).FiNext)*2))))
  26061 				}
  26062 				break
  26063 			}
  26064 			(*WalSegment)(unsafe.Pointer(pSegment)).FiNext++
  26065 		}
  26066 	}
  26067 
  26068 	*(*U32)(unsafe.Pointer(piPage)) = libc.AssignPtrUint32(p, iRet)
  26069 	return libc.Bool32(iRet == 0xFFFFFFFF)
  26070 }
  26071 
  26072 func walMerge(tls *libc.TLS, aContent uintptr, aLeft uintptr, nLeft int32, paRight uintptr, pnRight uintptr, aTmp uintptr) {
  26073 	var iLeft int32 = 0
  26074 	var iRight int32 = 0
  26075 	var iOut int32 = 0
  26076 	var nRight int32 = *(*int32)(unsafe.Pointer(pnRight))
  26077 	var aRight uintptr = *(*uintptr)(unsafe.Pointer(paRight))
  26078 
  26079 	for iRight < nRight || iLeft < nLeft {
  26080 		var logpage Ht_slot
  26081 		var dbpage Pgno
  26082 
  26083 		if iLeft < nLeft &&
  26084 			(iRight >= nRight || *(*U32)(unsafe.Pointer(aContent + uintptr(*(*Ht_slot)(unsafe.Pointer(aLeft + uintptr(iLeft)*2)))*4)) < *(*U32)(unsafe.Pointer(aContent + uintptr(*(*Ht_slot)(unsafe.Pointer(aRight + uintptr(iRight)*2)))*4))) {
  26085 			logpage = *(*Ht_slot)(unsafe.Pointer(aLeft + uintptr(libc.PostIncInt32(&iLeft, 1))*2))
  26086 		} else {
  26087 			logpage = *(*Ht_slot)(unsafe.Pointer(aRight + uintptr(libc.PostIncInt32(&iRight, 1))*2))
  26088 		}
  26089 		dbpage = *(*U32)(unsafe.Pointer(aContent + uintptr(logpage)*4))
  26090 
  26091 		*(*Ht_slot)(unsafe.Pointer(aTmp + uintptr(libc.PostIncInt32(&iOut, 1))*2)) = logpage
  26092 		if iLeft < nLeft && *(*U32)(unsafe.Pointer(aContent + uintptr(*(*Ht_slot)(unsafe.Pointer(aLeft + uintptr(iLeft)*2)))*4)) == dbpage {
  26093 			iLeft++
  26094 		}
  26095 
  26096 	}
  26097 
  26098 	*(*uintptr)(unsafe.Pointer(paRight)) = aLeft
  26099 	*(*int32)(unsafe.Pointer(pnRight)) = iOut
  26100 	libc.Xmemcpy(tls, aLeft, aTmp, uint32(unsafe.Sizeof(Ht_slot(0)))*uint32(iOut))
  26101 }
  26102 
  26103 func walMergesort(tls *libc.TLS, aContent uintptr, aBuffer uintptr, aList uintptr, pnList uintptr) {
  26104 	bp := tls.Alloc(112)
  26105 	defer tls.Free(112)
  26106 
  26107 	var nList int32 = *(*int32)(unsafe.Pointer(pnList))
  26108 	*(*int32)(unsafe.Pointer(bp + 108)) = 0
  26109 	*(*uintptr)(unsafe.Pointer(bp + 104)) = uintptr(0)
  26110 	var iList int32
  26111 	var iSub U32 = U32(0)
  26112 
  26113 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([13]Sublist{})))
  26114 
  26115 	for iList = 0; iList < nList; iList++ {
  26116 		*(*int32)(unsafe.Pointer(bp + 108)) = 1
  26117 		*(*uintptr)(unsafe.Pointer(bp + 104)) = aList + uintptr(iList)*2
  26118 		for iSub = U32(0); iList&(int32(1)<<iSub) != 0; iSub++ {
  26119 			var p uintptr
  26120 
  26121 			p = bp + uintptr(iSub)*8
  26122 
  26123 			walMerge(tls, aContent, (*Sublist)(unsafe.Pointer(p)).FaList, (*Sublist)(unsafe.Pointer(p)).FnList, bp+104, bp+108, aBuffer)
  26124 		}
  26125 		(*Sublist)(unsafe.Pointer(bp + uintptr(iSub)*8)).FaList = *(*uintptr)(unsafe.Pointer(bp + 104))
  26126 		(*Sublist)(unsafe.Pointer(bp + uintptr(iSub)*8)).FnList = *(*int32)(unsafe.Pointer(bp + 108))
  26127 	}
  26128 
  26129 	for iSub++; iSub < U32(int32(uint32(unsafe.Sizeof([13]Sublist{}))/uint32(unsafe.Sizeof(Sublist{})))); iSub++ {
  26130 		if nList&(int32(1)<<iSub) != 0 {
  26131 			var p uintptr
  26132 
  26133 			p = bp + uintptr(iSub)*8
  26134 
  26135 			walMerge(tls, aContent, (*Sublist)(unsafe.Pointer(p)).FaList, (*Sublist)(unsafe.Pointer(p)).FnList, bp+104, bp+108, aBuffer)
  26136 		}
  26137 	}
  26138 
  26139 	*(*int32)(unsafe.Pointer(pnList)) = *(*int32)(unsafe.Pointer(bp + 108))
  26140 
  26141 }
  26142 
  26143 type Sublist = struct {
  26144 	FnList int32
  26145 	FaList uintptr
  26146 }
  26147 
  26148 func walIteratorFree(tls *libc.TLS, p uintptr) {
  26149 	Xsqlite3_free(tls, p)
  26150 }
  26151 
  26152 func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int32 {
  26153 	bp := tls.Alloc(16)
  26154 	defer tls.Free(16)
  26155 
  26156 	var p uintptr
  26157 	var nSegment int32
  26158 	var iLast U32
  26159 	var nByte Sqlite3_int64
  26160 	var i int32
  26161 	var aTmp uintptr
  26162 	var rc int32 = SQLITE_OK
  26163 
  26164 	iLast = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  26165 
  26166 	nSegment = walFramePage(tls, iLast) + 1
  26167 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(WalIterator{})) +
  26168 		uint32(nSegment-1)*uint32(unsafe.Sizeof(WalSegment{})) +
  26169 		iLast*U32(unsafe.Sizeof(Ht_slot(0))))
  26170 	p = Xsqlite3_malloc64(tls, uint64(nByte))
  26171 	if !(p != 0) {
  26172 		return SQLITE_NOMEM
  26173 	}
  26174 	libc.Xmemset(tls, p, 0, uint32(nByte))
  26175 	(*WalIterator)(unsafe.Pointer(p)).FnSegment = nSegment
  26176 
  26177 	aTmp = Xsqlite3_malloc64(tls,
  26178 		uint64(uint32(unsafe.Sizeof(Ht_slot(0)))*func() uint32 {
  26179 			if iLast > U32(HASHTABLE_NPAGE) {
  26180 				return uint32(HASHTABLE_NPAGE)
  26181 			}
  26182 			return iLast
  26183 		}()))
  26184 	if !(aTmp != 0) {
  26185 		rc = SQLITE_NOMEM
  26186 	}
  26187 
  26188 	for i = walFramePage(tls, nBackfill+U32(1)); rc == SQLITE_OK && i < nSegment; i++ {
  26189 		rc = walHashGet(tls, pWal, i, bp)
  26190 		if rc == SQLITE_OK {
  26191 			var j int32
  26192 
  26193 			var aIndex uintptr
  26194 
  26195 			if i+1 == nSegment {
  26196 				*(*int32)(unsafe.Pointer(bp + 12)) = int32(iLast - (*WalHashLoc)(unsafe.Pointer(bp)).FiZero)
  26197 			} else {
  26198 				*(*int32)(unsafe.Pointer(bp + 12)) = (int32((*WalHashLoc)(unsafe.Pointer(bp)).FaHash) - int32((*WalHashLoc)(unsafe.Pointer(bp)).FaPgno)) / 4
  26199 			}
  26200 			aIndex = p + 8 + uintptr((*WalIterator)(unsafe.Pointer(p)).FnSegment)*20 + uintptr((*WalHashLoc)(unsafe.Pointer(bp)).FiZero)*2
  26201 			(*WalHashLoc)(unsafe.Pointer(bp)).FiZero++
  26202 
  26203 			for j = 0; j < *(*int32)(unsafe.Pointer(bp + 12)); j++ {
  26204 				*(*Ht_slot)(unsafe.Pointer(aIndex + uintptr(j)*2)) = Ht_slot(j)
  26205 			}
  26206 			walMergesort(tls, (*WalHashLoc)(unsafe.Pointer(bp)).FaPgno, aTmp, aIndex, bp+12)
  26207 			(*WalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*20)).FiZero = int32((*WalHashLoc)(unsafe.Pointer(bp)).FiZero)
  26208 			(*WalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*20)).FnEntry = *(*int32)(unsafe.Pointer(bp + 12))
  26209 			(*WalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*20)).FaIndex = aIndex
  26210 			(*WalSegment)(unsafe.Pointer(p + 8 + uintptr(i)*20)).FaPgno = (*WalHashLoc)(unsafe.Pointer(bp)).FaPgno
  26211 		}
  26212 	}
  26213 	Xsqlite3_free(tls, aTmp)
  26214 
  26215 	if rc != SQLITE_OK {
  26216 		walIteratorFree(tls, p)
  26217 		p = uintptr(0)
  26218 	}
  26219 	*(*uintptr)(unsafe.Pointer(pp)) = p
  26220 	return rc
  26221 }
  26222 
  26223 func walBusyLock(tls *libc.TLS, pWal uintptr, xBusy uintptr, pBusyArg uintptr, lockIdx int32, n int32) int32 {
  26224 	var rc int32
  26225 	for __ccgo := true; __ccgo; __ccgo = xBusy != 0 && rc == SQLITE_BUSY && (*struct {
  26226 		f func(*libc.TLS, uintptr) int32
  26227 	})(unsafe.Pointer(&struct{ uintptr }{xBusy})).f(tls, pBusyArg) != 0 {
  26228 		rc = walLockExclusive(tls, pWal, lockIdx, n)
  26229 	}
  26230 	return rc
  26231 }
  26232 
  26233 func walPagesize(tls *libc.TLS, pWal uintptr) int32 {
  26234 	return int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&0xfe00 + int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&0x0001<<16
  26235 }
  26236 
  26237 func walRestartHdr(tls *libc.TLS, pWal uintptr, salt1 U32) {
  26238 	bp := tls.Alloc(4)
  26239 	defer tls.Free(4)
  26240 	*(*U32)(unsafe.Pointer(bp)) = salt1
  26241 
  26242 	var pInfo uintptr = walCkptInfo(tls, pWal)
  26243 	var i int32
  26244 	var aSalt uintptr = pWal + 52 + 32
  26245 	(*Wal)(unsafe.Pointer(pWal)).FnCkpt++
  26246 	(*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = U32(0)
  26247 	Xsqlite3Put4byte(tls, aSalt, U32(1)+Xsqlite3Get4byte(tls, aSalt))
  26248 	libc.Xmemcpy(tls, pWal+52+32+1*4, bp, uint32(4))
  26249 	walIndexWriteHdr(tls, pWal)
  26250 	libc.AtomicStoreNInt32(pInfo, int32(0), 0)
  26251 	(*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = U32(0)
  26252 	*(*U32)(unsafe.Pointer(pInfo + 4 + 1*4)) = U32(0)
  26253 	for i = 2; i < SQLITE_SHM_NLOCK-3; i++ {
  26254 		*(*U32)(unsafe.Pointer(pInfo + 4 + uintptr(i)*4)) = READMARK_NOT_USED
  26255 	}
  26256 
  26257 }
  26258 
  26259 func walCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, xBusy uintptr, pBusyArg uintptr, sync_flags int32, zBuf uintptr) int32 {
  26260 	bp := tls.Alloc(36)
  26261 	defer tls.Free(36)
  26262 
  26263 	var rc int32
  26264 	var szPage int32
  26265 
  26266 	var mxSafeFrame U32
  26267 	var mxPage U32
  26268 	var i int32
  26269 	var pInfo uintptr
  26270 	var iMark U32
  26271 	var y U32
  26272 
  26273 	var iOffset I64
  26274 	var szDb I64
  26275 	var nBackfill U32
  26276 
  26277 	rc = SQLITE_OK
  26278 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  26279 	*(*U32)(unsafe.Pointer(bp + 24)) = U32(0)
  26280 	*(*U32)(unsafe.Pointer(bp + 28)) = U32(0)
  26281 
  26282 	szPage = walPagesize(tls, pWal)
  26283 
  26284 	libc.AtomicStoreUintptr(&pInfo, walCkptInfo(tls, pWal))
  26285 	if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) {
  26286 		goto __1
  26287 	}
  26288 
  26289 	mxSafeFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  26290 	mxPage = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage
  26291 	i = 1
  26292 __2:
  26293 	if !(i < SQLITE_SHM_NLOCK-3) {
  26294 		goto __4
  26295 	}
  26296 	y = libc.AtomicLoadNUint32(pInfo+4+uintptr(i)*4, 0)
  26297 	if !(mxSafeFrame > y) {
  26298 		goto __5
  26299 	}
  26300 
  26301 	rc = walBusyLock(tls, pWal, xBusy, pBusyArg, 3+i, 1)
  26302 	if !(rc == SQLITE_OK) {
  26303 		goto __6
  26304 	}
  26305 	iMark = func() uint32 {
  26306 		if i == 1 {
  26307 			return mxSafeFrame
  26308 		}
  26309 		return READMARK_NOT_USED
  26310 	}()
  26311 	libc.AtomicStoreNUint32(pInfo+4+uintptr(i)*4, iMark, 0)
  26312 	walUnlockExclusive(tls, pWal, 3+i, 1)
  26313 	goto __7
  26314 __6:
  26315 	if !(rc == SQLITE_BUSY) {
  26316 		goto __8
  26317 	}
  26318 	mxSafeFrame = y
  26319 	xBusy = uintptr(0)
  26320 	goto __9
  26321 __8:
  26322 	goto walcheckpoint_out
  26323 __9:
  26324 	;
  26325 __7:
  26326 	;
  26327 __5:
  26328 	;
  26329 	goto __3
  26330 __3:
  26331 	i++
  26332 	goto __2
  26333 	goto __4
  26334 __4:
  26335 	;
  26336 	if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < mxSafeFrame) {
  26337 		goto __10
  26338 	}
  26339 	rc = walIteratorInit(tls, pWal, (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill, bp)
  26340 
  26341 __10:
  26342 	;
  26343 	if !(*(*uintptr)(unsafe.Pointer(bp)) != 0 &&
  26344 		libc.AssignInt32(&rc, walBusyLock(tls, pWal, xBusy, pBusyArg, 3+0, 1)) == SQLITE_OK) {
  26345 		goto __11
  26346 	}
  26347 	nBackfill = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill
  26348 
  26349 	(*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = mxSafeFrame
  26350 
  26351 	rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, sync_flags>>2&0x03)
  26352 
  26353 	if !(rc == SQLITE_OK) {
  26354 		goto __12
  26355 	}
  26356 	*(*I64)(unsafe.Pointer(bp + 16)) = I64(mxPage) * I64(szPage)
  26357 	Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_CKPT_START, uintptr(0))
  26358 	rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, bp+8)
  26359 	if !(rc == SQLITE_OK && *(*I64)(unsafe.Pointer(bp + 8)) < *(*I64)(unsafe.Pointer(bp + 16))) {
  26360 		goto __13
  26361 	}
  26362 	if !(*(*I64)(unsafe.Pointer(bp + 8))+int64(65536)+I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)*I64(szPage) < *(*I64)(unsafe.Pointer(bp + 16))) {
  26363 		goto __14
  26364 	}
  26365 
  26366 	rc = Xsqlite3CorruptError(tls, 65337)
  26367 	goto __15
  26368 __14:
  26369 	Xsqlite3OsFileControlHint(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_SIZE_HINT, bp+16)
  26370 __15:
  26371 	;
  26372 __13:
  26373 	;
  26374 __12:
  26375 	;
  26376 __16:
  26377 	if !(rc == SQLITE_OK && 0 == walIteratorNext(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+24, bp+28)) {
  26378 		goto __17
  26379 	}
  26380 
  26381 	if !(libc.AtomicLoadNInt32(db+312, 0) != 0) {
  26382 		goto __18
  26383 	}
  26384 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  26385 		rc = SQLITE_NOMEM
  26386 	} else {
  26387 		rc = SQLITE_INTERRUPT
  26388 	}
  26389 	goto __17
  26390 __18:
  26391 	;
  26392 	if !(*(*U32)(unsafe.Pointer(bp + 28)) <= nBackfill || *(*U32)(unsafe.Pointer(bp + 28)) > mxSafeFrame || *(*U32)(unsafe.Pointer(bp + 24)) > mxPage) {
  26393 		goto __19
  26394 	}
  26395 	goto __16
  26396 __19:
  26397 	;
  26398 	iOffset = int64(WAL_HDRSIZE) + I64(*(*U32)(unsafe.Pointer(bp + 28))-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE) + int64(WAL_FRAME_HDRSIZE)
  26399 
  26400 	rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, zBuf, szPage, iOffset)
  26401 	if !(rc != SQLITE_OK) {
  26402 		goto __20
  26403 	}
  26404 	goto __17
  26405 __20:
  26406 	;
  26407 	iOffset = I64(*(*U32)(unsafe.Pointer(bp + 24))-U32(1)) * I64(szPage)
  26408 
  26409 	rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, zBuf, szPage, iOffset)
  26410 	if !(rc != SQLITE_OK) {
  26411 		goto __21
  26412 	}
  26413 	goto __17
  26414 __21:
  26415 	;
  26416 	goto __16
  26417 __17:
  26418 	;
  26419 	Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_CKPT_DONE, uintptr(0))
  26420 
  26421 	if !(rc == SQLITE_OK) {
  26422 		goto __22
  26423 	}
  26424 	if !(mxSafeFrame == (*WalIndexHdr)(unsafe.Pointer(walIndexHdr(tls, pWal))).FmxFrame) {
  26425 		goto __23
  26426 	}
  26427 	szDb = I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage) * I64(szPage)
  26428 
  26429 	rc = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, szDb)
  26430 	if !(rc == SQLITE_OK) {
  26431 		goto __24
  26432 	}
  26433 	rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, sync_flags>>2&0x03)
  26434 __24:
  26435 	;
  26436 __23:
  26437 	;
  26438 	if !(rc == SQLITE_OK) {
  26439 		goto __25
  26440 	}
  26441 	libc.AtomicStoreNUint32(pInfo, mxSafeFrame, 0)
  26442 __25:
  26443 	;
  26444 __22:
  26445 	;
  26446 	walUnlockExclusive(tls, pWal, 3+0, 1)
  26447 __11:
  26448 	;
  26449 	if !(rc == SQLITE_BUSY) {
  26450 		goto __26
  26451 	}
  26452 
  26453 	rc = SQLITE_OK
  26454 __26:
  26455 	;
  26456 __1:
  26457 	;
  26458 	if !(rc == SQLITE_OK && eMode != SQLITE_CHECKPOINT_PASSIVE) {
  26459 		goto __27
  26460 	}
  26461 
  26462 	if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) {
  26463 		goto __28
  26464 	}
  26465 	rc = SQLITE_BUSY
  26466 	goto __29
  26467 __28:
  26468 	if !(eMode >= SQLITE_CHECKPOINT_RESTART) {
  26469 		goto __30
  26470 	}
  26471 	Xsqlite3_randomness(tls, 4, bp+32)
  26472 
  26473 	rc = walBusyLock(tls, pWal, xBusy, pBusyArg, 3+1, SQLITE_SHM_NLOCK-3-1)
  26474 	if !(rc == SQLITE_OK) {
  26475 		goto __31
  26476 	}
  26477 	if !(eMode == SQLITE_CHECKPOINT_TRUNCATE) {
  26478 		goto __32
  26479 	}
  26480 
  26481 	walRestartHdr(tls, pWal, *(*U32)(unsafe.Pointer(bp + 32)))
  26482 	rc = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, int64(0))
  26483 __32:
  26484 	;
  26485 	walUnlockExclusive(tls, pWal, 3+1, SQLITE_SHM_NLOCK-3-1)
  26486 __31:
  26487 	;
  26488 __30:
  26489 	;
  26490 __29:
  26491 	;
  26492 __27:
  26493 	;
  26494 walcheckpoint_out:
  26495 	walIteratorFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
  26496 	return rc
  26497 }
  26498 
  26499 func walLimitSize(tls *libc.TLS, pWal uintptr, nMax I64) {
  26500 	bp := tls.Alloc(16)
  26501 	defer tls.Free(16)
  26502 
  26503 	var rx int32
  26504 	Xsqlite3BeginBenignMalloc(tls)
  26505 	rx = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+8)
  26506 	if rx == SQLITE_OK && *(*I64)(unsafe.Pointer(bp + 8)) > nMax {
  26507 		rx = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, nMax)
  26508 	}
  26509 	Xsqlite3EndBenignMalloc(tls)
  26510 	if rx != 0 {
  26511 		Xsqlite3_log(tls, rx, ts+4007, libc.VaList(bp, (*Wal)(unsafe.Pointer(pWal)).FzWalName))
  26512 	}
  26513 }
  26514 
  26515 // Close a connection to a log file.
  26516 func Xsqlite3WalClose(tls *libc.TLS, pWal uintptr, db uintptr, sync_flags int32, nBuf int32, zBuf uintptr) int32 {
  26517 	bp := tls.Alloc(4)
  26518 	defer tls.Free(4)
  26519 
  26520 	var rc int32 = SQLITE_OK
  26521 	if pWal != 0 {
  26522 		var isDelete int32 = 0
  26523 
  26524 		if zBuf != uintptr(0) &&
  26525 			SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3OsLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_LOCK_EXCLUSIVE)) {
  26526 			if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE {
  26527 				(*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(WAL_EXCLUSIVE_MODE)
  26528 			}
  26529 			rc = Xsqlite3WalCheckpoint(tls, pWal, db,
  26530 				SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0), sync_flags, nBuf, zBuf, uintptr(0), uintptr(0))
  26531 			if rc == SQLITE_OK {
  26532 				*(*int32)(unsafe.Pointer(bp)) = -1
  26533 				Xsqlite3OsFileControlHint(tls,
  26534 					(*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_PERSIST_WAL, bp)
  26535 				if *(*int32)(unsafe.Pointer(bp)) != 1 {
  26536 					isDelete = 1
  26537 				} else if (*Wal)(unsafe.Pointer(pWal)).FmxWalSize >= int64(0) {
  26538 					walLimitSize(tls, pWal, int64(0))
  26539 				}
  26540 			}
  26541 		}
  26542 
  26543 		walIndexClose(tls, pWal, isDelete)
  26544 		Xsqlite3OsClose(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd)
  26545 		if isDelete != 0 {
  26546 			Xsqlite3BeginBenignMalloc(tls)
  26547 			Xsqlite3OsDelete(tls, (*Wal)(unsafe.Pointer(pWal)).FpVfs, (*Wal)(unsafe.Pointer(pWal)).FzWalName, 0)
  26548 			Xsqlite3EndBenignMalloc(tls)
  26549 		}
  26550 
  26551 		Xsqlite3_free(tls, (*Wal)(unsafe.Pointer(pWal)).FapWiData)
  26552 		Xsqlite3_free(tls, pWal)
  26553 	}
  26554 	return rc
  26555 }
  26556 
  26557 func walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 {
  26558 	bp := tls.Alloc(104)
  26559 	defer tls.Free(104)
  26560 
  26561 	var aHdr uintptr
  26562 
  26563 	libc.AtomicStoreUintptr(&aHdr, walIndexHdr(tls, pWal))
  26564 	libc.Xmemcpy(tls, bp, aHdr, uint32(unsafe.Sizeof(WalIndexHdr{})))
  26565 	walShmBarrier(tls, pWal)
  26566 	libc.Xmemcpy(tls, bp+48, aHdr+1*48, uint32(unsafe.Sizeof(WalIndexHdr{})))
  26567 
  26568 	if libc.Xmemcmp(tls, bp, bp+48, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  26569 		return 1
  26570 	}
  26571 	if int32((*WalIndexHdr)(unsafe.Pointer(bp)).FisInit) == 0 {
  26572 		return 1
  26573 	}
  26574 	walChecksumBytes(tls, 1, bp, int32(uint32(unsafe.Sizeof(WalIndexHdr{}))-uint32(unsafe.Sizeof([2]U32{}))), uintptr(0), bp+96)
  26575 	if *(*U32)(unsafe.Pointer(bp + 96)) != *(*U32)(unsafe.Pointer(bp + 40)) || *(*U32)(unsafe.Pointer(bp + 96 + 1*4)) != *(*U32)(unsafe.Pointer(bp + 40 + 1*4)) {
  26576 		return 1
  26577 	}
  26578 
  26579 	if libc.Xmemcmp(tls, pWal+52, bp, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  26580 		*(*int32)(unsafe.Pointer(pChanged)) = 1
  26581 		libc.Xmemcpy(tls, pWal+52, bp, uint32(unsafe.Sizeof(WalIndexHdr{})))
  26582 		(*Wal)(unsafe.Pointer(pWal)).FszPage = U32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&0xfe00 + int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)&0x0001<<16)
  26583 
  26584 	}
  26585 
  26586 	return 0
  26587 }
  26588 
  26589 func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 {
  26590 	bp := tls.Alloc(4)
  26591 	defer tls.Free(4)
  26592 
  26593 	var rc int32
  26594 	var badHdr int32
  26595 
  26596 	rc = walIndexPage(tls, pWal, 0, bp)
  26597 	if rc != SQLITE_OK {
  26598 		if rc == SQLITE_READONLY|int32(5)<<8 {
  26599 			(*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(1)
  26600 			(*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(WAL_HEAPMEMORY_MODE)
  26601 			*(*int32)(unsafe.Pointer(pChanged)) = 1
  26602 		} else {
  26603 			return rc
  26604 		}
  26605 	} else {
  26606 	}
  26607 
  26608 	badHdr = func() int32 {
  26609 		if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  26610 			return walIndexTryHdr(tls, pWal, pChanged)
  26611 		}
  26612 		return 1
  26613 	}()
  26614 
  26615 	if badHdr != 0 {
  26616 		if int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 && int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly)&WAL_SHM_RDONLY != 0 {
  26617 			if SQLITE_OK == libc.AssignInt32(&rc, walLockShared(tls, pWal, WAL_WRITE_LOCK)) {
  26618 				walUnlockShared(tls, pWal, WAL_WRITE_LOCK)
  26619 				rc = SQLITE_READONLY | int32(1)<<8
  26620 			}
  26621 		} else {
  26622 			var bWriteLock int32 = int32((*Wal)(unsafe.Pointer(pWal)).FwriteLock)
  26623 			if bWriteLock != 0 || SQLITE_OK == libc.AssignInt32(&rc, walLockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)) {
  26624 				(*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1)
  26625 				if SQLITE_OK == libc.AssignInt32(&rc, walIndexPage(tls, pWal, 0, bp)) {
  26626 					badHdr = walIndexTryHdr(tls, pWal, pChanged)
  26627 					if badHdr != 0 {
  26628 						rc = walIndexRecover(tls, pWal)
  26629 						*(*int32)(unsafe.Pointer(pChanged)) = 1
  26630 					}
  26631 				}
  26632 				if bWriteLock == 0 {
  26633 					(*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0)
  26634 					walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)
  26635 				}
  26636 			}
  26637 		}
  26638 	}
  26639 
  26640 	if badHdr == 0 && (*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion != U32(WALINDEX_MAX_VERSION) {
  26641 		rc = Xsqlite3CantopenError(tls, 65686)
  26642 	}
  26643 	if (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 {
  26644 		if rc != SQLITE_OK {
  26645 			walIndexClose(tls, pWal, 0)
  26646 			(*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(0)
  26647 
  26648 			if rc == SQLITE_IOERR|int32(2)<<8 {
  26649 				rc = -1
  26650 			}
  26651 		}
  26652 		(*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(WAL_NORMAL_MODE)
  26653 	}
  26654 
  26655 	return rc
  26656 }
  26657 
  26658 func walBeginShmUnreliable(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 {
  26659 	bp := tls.Alloc(64)
  26660 	defer tls.Free(64)
  26661 
  26662 	var iOffset I64
  26663 
  26664 	var aFrame uintptr
  26665 	var szFrame int32
  26666 	var aData uintptr
  26667 
  26668 	var rc int32
  26669 
  26670 	var i int32
  26671 	aFrame = uintptr(0)
  26672 
  26673 	rc = walLockShared(tls, pWal, 3+0)
  26674 	if !(rc != SQLITE_OK) {
  26675 		goto __1
  26676 	}
  26677 	if !(rc == SQLITE_BUSY) {
  26678 		goto __2
  26679 	}
  26680 	rc = -1
  26681 __2:
  26682 	;
  26683 	goto begin_unreliable_shm_out
  26684 __1:
  26685 	;
  26686 	(*Wal)(unsafe.Pointer(pWal)).FreadLock = int16(0)
  26687 
  26688 	rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 0, int32(uint32(unsafe.Sizeof(Ht_slot(0)))*uint32(HASHTABLE_NPAGE*2)+uint32(HASHTABLE_NPAGE)*uint32(unsafe.Sizeof(U32(0)))), 0, bp)
  26689 
  26690 	if !(rc != SQLITE_READONLY|int32(5)<<8) {
  26691 		goto __3
  26692 	}
  26693 	rc = func() int32 {
  26694 		if rc == SQLITE_READONLY {
  26695 			return -1
  26696 		}
  26697 		return rc
  26698 	}()
  26699 	goto begin_unreliable_shm_out
  26700 __3:
  26701 	;
  26702 	libc.Xmemcpy(tls, pWal+52, walIndexHdr(tls, pWal), uint32(unsafe.Sizeof(WalIndexHdr{})))
  26703 
  26704 	rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+8)
  26705 	if !(rc != SQLITE_OK) {
  26706 		goto __4
  26707 	}
  26708 	goto begin_unreliable_shm_out
  26709 __4:
  26710 	;
  26711 	if !(*(*I64)(unsafe.Pointer(bp + 8)) < int64(WAL_HDRSIZE)) {
  26712 		goto __5
  26713 	}
  26714 
  26715 	*(*int32)(unsafe.Pointer(pChanged)) = 1
  26716 	rc = func() int32 {
  26717 		if (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0) {
  26718 			return SQLITE_OK
  26719 		}
  26720 		return -1
  26721 	}()
  26722 	goto begin_unreliable_shm_out
  26723 __5:
  26724 	;
  26725 	rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16, WAL_HDRSIZE, int64(0))
  26726 	if !(rc != SQLITE_OK) {
  26727 		goto __6
  26728 	}
  26729 	goto begin_unreliable_shm_out
  26730 __6:
  26731 	;
  26732 	if !(libc.Xmemcmp(tls, pWal+52+32, bp+16+16, uint32(8)) != 0) {
  26733 		goto __7
  26734 	}
  26735 
  26736 	rc = -1
  26737 	goto begin_unreliable_shm_out
  26738 __7:
  26739 	;
  26740 	szFrame = int32((*Wal)(unsafe.Pointer(pWal)).FszPage + U32(WAL_FRAME_HDRSIZE))
  26741 	aFrame = Xsqlite3_malloc64(tls, uint64(szFrame))
  26742 	if !(aFrame == uintptr(0)) {
  26743 		goto __8
  26744 	}
  26745 	rc = SQLITE_NOMEM
  26746 	goto begin_unreliable_shm_out
  26747 __8:
  26748 	;
  26749 	aData = aFrame + 24
  26750 
  26751 	*(*U32)(unsafe.Pointer(bp + 48)) = *(*U32)(unsafe.Pointer(pWal + 52 + 24))
  26752 	*(*U32)(unsafe.Pointer(bp + 48 + 1*4)) = *(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4))
  26753 	iOffset = int64(WAL_HDRSIZE) + I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame+U32(1)-U32(1))*I64((*Wal)(unsafe.Pointer(pWal)).FszPage+U32(WAL_FRAME_HDRSIZE))
  26754 __9:
  26755 	if !(iOffset+I64(szFrame) <= *(*I64)(unsafe.Pointer(bp + 8))) {
  26756 		goto __11
  26757 	}
  26758 
  26759 	rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset)
  26760 	if !(rc != SQLITE_OK) {
  26761 		goto __12
  26762 	}
  26763 	goto __11
  26764 __12:
  26765 	;
  26766 	if !!(walDecodeFrame(tls, pWal, bp+56, bp+60, aData, aFrame) != 0) {
  26767 		goto __13
  26768 	}
  26769 	goto __11
  26770 __13:
  26771 	;
  26772 	if !(*(*U32)(unsafe.Pointer(bp + 60)) != 0) {
  26773 		goto __14
  26774 	}
  26775 	rc = -1
  26776 	goto __11
  26777 __14:
  26778 	;
  26779 	goto __10
  26780 __10:
  26781 	iOffset = iOffset + I64(szFrame)
  26782 	goto __9
  26783 	goto __11
  26784 __11:
  26785 	;
  26786 	*(*U32)(unsafe.Pointer(pWal + 52 + 24)) = *(*U32)(unsafe.Pointer(bp + 48))
  26787 	*(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4)) = *(*U32)(unsafe.Pointer(bp + 48 + 1*4))
  26788 
  26789 begin_unreliable_shm_out:
  26790 	Xsqlite3_free(tls, aFrame)
  26791 	if !(rc != SQLITE_OK) {
  26792 		goto __15
  26793 	}
  26794 	i = 0
  26795 __16:
  26796 	if !(i < (*Wal)(unsafe.Pointer(pWal)).FnWiData) {
  26797 		goto __18
  26798 	}
  26799 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*4)))
  26800 	*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*4)) = uintptr(0)
  26801 	goto __17
  26802 __17:
  26803 	i++
  26804 	goto __16
  26805 	goto __18
  26806 __18:
  26807 	;
  26808 	(*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(0)
  26809 	Xsqlite3WalEndReadTransaction(tls, pWal)
  26810 	*(*int32)(unsafe.Pointer(pChanged)) = 1
  26811 __15:
  26812 	;
  26813 	return rc
  26814 }
  26815 
  26816 func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32, cnt int32) int32 {
  26817 	var pInfo uintptr
  26818 	var mxReadMark U32
  26819 	var mxI int32
  26820 	var i int32
  26821 	var rc int32 = SQLITE_OK
  26822 	var mxFrame U32
  26823 
  26824 	if cnt > 5 {
  26825 		var nDelay int32 = 1
  26826 		if cnt > 100 {
  26827 			return SQLITE_PROTOCOL
  26828 		}
  26829 		if cnt >= 10 {
  26830 			nDelay = (cnt - 9) * (cnt - 9) * 39
  26831 		}
  26832 		Xsqlite3OsSleep(tls, (*Wal)(unsafe.Pointer(pWal)).FpVfs, nDelay)
  26833 	}
  26834 
  26835 	if !(useWal != 0) {
  26836 		if int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 {
  26837 			rc = walIndexReadHdr(tls, pWal, pChanged)
  26838 		}
  26839 		if rc == SQLITE_BUSY {
  26840 			if *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) == uintptr(0) {
  26841 				rc = -1
  26842 			} else if SQLITE_OK == libc.AssignInt32(&rc, walLockShared(tls, pWal, WAL_RECOVER_LOCK)) {
  26843 				walUnlockShared(tls, pWal, WAL_RECOVER_LOCK)
  26844 				rc = -1
  26845 			} else if rc == SQLITE_BUSY {
  26846 				rc = SQLITE_BUSY | int32(1)<<8
  26847 			}
  26848 		}
  26849 		if rc != SQLITE_OK {
  26850 			return rc
  26851 		} else if (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 {
  26852 			return walBeginShmUnreliable(tls, pWal, pChanged)
  26853 		}
  26854 	}
  26855 
  26856 	libc.AtomicStoreUintptr(&pInfo, walCkptInfo(tls, pWal))
  26857 	if !(useWal != 0) && libc.AtomicLoadNUint32(pInfo, 0) == (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame &&
  26858 		((*Wal)(unsafe.Pointer(pWal)).FpSnapshot == uintptr(0) || (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0)) {
  26859 		rc = walLockShared(tls, pWal, 3+0)
  26860 		walShmBarrier(tls, pWal)
  26861 		if rc == SQLITE_OK {
  26862 			if libc.Xmemcmp(tls, walIndexHdr(tls, pWal), pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  26863 				walUnlockShared(tls, pWal, 3+0)
  26864 				return -1
  26865 			}
  26866 			(*Wal)(unsafe.Pointer(pWal)).FreadLock = int16(0)
  26867 			return SQLITE_OK
  26868 		} else if rc != SQLITE_BUSY {
  26869 			return rc
  26870 		}
  26871 	}
  26872 
  26873 	mxReadMark = U32(0)
  26874 	mxI = 0
  26875 	mxFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  26876 	if (*Wal)(unsafe.Pointer(pWal)).FpSnapshot != 0 && (*WalIndexHdr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame < mxFrame {
  26877 		mxFrame = (*WalIndexHdr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame
  26878 	}
  26879 	for i = 1; i < SQLITE_SHM_NLOCK-3; i++ {
  26880 		var thisMark U32 = libc.AtomicLoadNUint32(pInfo+4+uintptr(i)*4, 0)
  26881 		if mxReadMark <= thisMark && thisMark <= mxFrame {
  26882 			mxReadMark = thisMark
  26883 			mxI = i
  26884 		}
  26885 	}
  26886 	if int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly)&WAL_SHM_RDONLY == 0 &&
  26887 		(mxReadMark < mxFrame || mxI == 0) {
  26888 		for i = 1; i < SQLITE_SHM_NLOCK-3; i++ {
  26889 			rc = walLockExclusive(tls, pWal, 3+i, 1)
  26890 			if rc == SQLITE_OK {
  26891 				libc.AtomicStoreNUint32(pInfo+4+uintptr(i)*4, mxFrame, 0)
  26892 				mxReadMark = mxFrame
  26893 				mxI = i
  26894 				walUnlockExclusive(tls, pWal, 3+i, 1)
  26895 				break
  26896 			} else if rc != SQLITE_BUSY {
  26897 				return rc
  26898 			}
  26899 		}
  26900 	}
  26901 	if mxI == 0 {
  26902 		if rc == SQLITE_BUSY {
  26903 			return -1
  26904 		}
  26905 		return SQLITE_READONLY | int32(5)<<8
  26906 	}
  26907 
  26908 	rc = walLockShared(tls, pWal, 3+mxI)
  26909 	if rc != 0 {
  26910 		if rc == SQLITE_BUSY {
  26911 			return -1
  26912 		}
  26913 		return rc
  26914 	}
  26915 
  26916 	(*Wal)(unsafe.Pointer(pWal)).FminFrame = libc.AtomicLoadNUint32(pInfo, 0) + 1
  26917 	walShmBarrier(tls, pWal)
  26918 	if libc.AtomicLoadNUint32(pInfo+4+uintptr(mxI)*4, 0) != mxReadMark ||
  26919 		libc.Xmemcmp(tls, walIndexHdr(tls, pWal), pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  26920 		walUnlockShared(tls, pWal, 3+mxI)
  26921 		return -1
  26922 	} else {
  26923 		(*Wal)(unsafe.Pointer(pWal)).FreadLock = I16(mxI)
  26924 	}
  26925 	return rc
  26926 }
  26927 
  26928 // Attempt to reduce the value of the WalCkptInfo.nBackfillAttempted
  26929 // variable so that older snapshots can be accessed. To do this, loop
  26930 // through all wal frames from nBackfillAttempted to (nBackfill+1),
  26931 // comparing their content to the corresponding page with the database
  26932 // file, if any. Set nBackfillAttempted to the frame number of the
  26933 // first frame for which the wal file content matches the db file.
  26934 //
  26935 // This is only really safe if the file-system is such that any page
  26936 // writes made by earlier checkpointers were atomic operations, which
  26937 // is not always true. It is also possible that nBackfillAttempted
  26938 // may be left set to a value larger than expected, if a wal frame
  26939 // contains content that duplicate of an earlier version of the same
  26940 // page.
  26941 //
  26942 // SQLITE_OK is returned if successful, or an SQLite error code if an
  26943 // error occurs. It is not an error if nBackfillAttempted cannot be
  26944 // decreased at all.
  26945 func Xsqlite3WalSnapshotRecover(tls *libc.TLS, pWal uintptr) int32 {
  26946 	bp := tls.Alloc(20)
  26947 	defer tls.Free(20)
  26948 
  26949 	var rc int32
  26950 
  26951 	rc = walLockExclusive(tls, pWal, WAL_CKPT_LOCK, 1)
  26952 	if rc == SQLITE_OK {
  26953 		var pInfo uintptr = walCkptInfo(tls, pWal)
  26954 		var szPage int32 = int32((*Wal)(unsafe.Pointer(pWal)).FszPage)
  26955 
  26956 		rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, bp)
  26957 		if rc == SQLITE_OK {
  26958 			var pBuf1 uintptr = Xsqlite3_malloc(tls, szPage)
  26959 			var pBuf2 uintptr = Xsqlite3_malloc(tls, szPage)
  26960 			if pBuf1 == uintptr(0) || pBuf2 == uintptr(0) {
  26961 				rc = SQLITE_NOMEM
  26962 			} else {
  26963 				var i U32 = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted
  26964 				for i = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted; i > libc.AtomicLoadNUint32(pInfo, 0); i-- {
  26965 					var pgno U32
  26966 					var iDbOff I64
  26967 					var iWalOff I64
  26968 
  26969 					rc = walHashGet(tls, pWal, walFramePage(tls, i), bp+8)
  26970 					if rc != SQLITE_OK {
  26971 						break
  26972 					}
  26973 
  26974 					pgno = *(*U32)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp+8)).FaPgno + uintptr(i-(*WalHashLoc)(unsafe.Pointer(bp+8)).FiZero-U32(1))*4))
  26975 					iDbOff = I64(pgno-U32(1)) * I64(szPage)
  26976 
  26977 					if iDbOff+I64(szPage) <= *(*I64)(unsafe.Pointer(bp)) {
  26978 						iWalOff = int64(WAL_HDRSIZE) + I64(i-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE) + int64(WAL_FRAME_HDRSIZE)
  26979 						rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pBuf1, szPage, iWalOff)
  26980 
  26981 						if rc == SQLITE_OK {
  26982 							rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, pBuf2, szPage, iDbOff)
  26983 						}
  26984 
  26985 						if rc != SQLITE_OK || 0 == libc.Xmemcmp(tls, pBuf1, pBuf2, uint32(szPage)) {
  26986 							break
  26987 						}
  26988 					}
  26989 
  26990 					(*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = i - U32(1)
  26991 				}
  26992 			}
  26993 
  26994 			Xsqlite3_free(tls, pBuf1)
  26995 			Xsqlite3_free(tls, pBuf2)
  26996 		}
  26997 		walUnlockExclusive(tls, pWal, WAL_CKPT_LOCK, 1)
  26998 	}
  26999 
  27000 	return rc
  27001 }
  27002 
  27003 // Begin a read transaction on the database.
  27004 //
  27005 // This routine used to be called sqlite3OpenSnapshot() and with good reason:
  27006 // it takes a snapshot of the state of the WAL and wal-index for the current
  27007 // instant in time.  The current thread will continue to use this snapshot.
  27008 // Other threads might append new content to the WAL and wal-index but
  27009 // that extra content is ignored by the current thread.
  27010 //
  27011 // If the database contents have changes since the previous read
  27012 // transaction, then *pChanged is set to 1 before returning.  The
  27013 // Pager layer will use this to know that its cache is stale and
  27014 // needs to be flushed.
  27015 func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 {
  27016 	var rc int32
  27017 	var cnt int32 = 0
  27018 	var bChanged int32 = 0
  27019 	var pSnapshot uintptr = (*Wal)(unsafe.Pointer(pWal)).FpSnapshot
  27020 
  27021 	if pSnapshot != 0 {
  27022 		if libc.Xmemcmp(tls, pSnapshot, pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  27023 			bChanged = 1
  27024 		}
  27025 
  27026 		rc = walLockShared(tls, pWal, WAL_CKPT_LOCK)
  27027 
  27028 		if rc != SQLITE_OK {
  27029 			return rc
  27030 		}
  27031 		(*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(1)
  27032 	}
  27033 
  27034 	for __ccgo := true; __ccgo; __ccgo = rc == -1 {
  27035 		rc = walTryBeginRead(tls, pWal, pChanged, 0, libc.PreIncInt32(&cnt, 1))
  27036 	}
  27037 
  27038 	if rc == SQLITE_OK {
  27039 		if pSnapshot != 0 && libc.Xmemcmp(tls, pSnapshot, pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  27040 			var pInfo uintptr = walCkptInfo(tls, pWal)
  27041 
  27042 			if !(libc.Xmemcmp(tls, pSnapshot+32, pWal+52+32, uint32(unsafe.Sizeof([2]U32{}))) != 0) &&
  27043 				(*WalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted {
  27044 				libc.Xmemcpy(tls, pWal+52, pSnapshot, uint32(unsafe.Sizeof(WalIndexHdr{})))
  27045 				*(*int32)(unsafe.Pointer(pChanged)) = bChanged
  27046 			} else {
  27047 				rc = SQLITE_ERROR | int32(3)<<8
  27048 			}
  27049 
  27050 			(*Wal)(unsafe.Pointer(pWal)).FminFrame = U32(1)
  27051 
  27052 			if rc != SQLITE_OK {
  27053 				Xsqlite3WalEndReadTransaction(tls, pWal)
  27054 			}
  27055 		}
  27056 	}
  27057 
  27058 	if (*Wal)(unsafe.Pointer(pWal)).FckptLock != 0 {
  27059 		walUnlockShared(tls, pWal, WAL_CKPT_LOCK)
  27060 		(*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(0)
  27061 	}
  27062 	return rc
  27063 }
  27064 
  27065 // Finish with a read transaction.  All this does is release the
  27066 // read-lock.
  27067 func Xsqlite3WalEndReadTransaction(tls *libc.TLS, pWal uintptr) {
  27068 	Xsqlite3WalEndWriteTransaction(tls, pWal)
  27069 	if int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) >= 0 {
  27070 		walUnlockShared(tls, pWal, 3+int32((*Wal)(unsafe.Pointer(pWal)).FreadLock))
  27071 		(*Wal)(unsafe.Pointer(pWal)).FreadLock = int16(-1)
  27072 	}
  27073 }
  27074 
  27075 // Search the wal file for page pgno. If found, set *piRead to the frame that
  27076 // contains the page. Otherwise, if pgno is not in the wal file, set *piRead
  27077 // to zero.
  27078 //
  27079 // Return SQLITE_OK if successful, or an error code if an error occurs. If an
  27080 // error does occur, the final value of *piRead is undefined.
  27081 func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr) int32 {
  27082 	bp := tls.Alloc(12)
  27083 	defer tls.Free(12)
  27084 
  27085 	var iRead U32 = U32(0)
  27086 	var iLast U32 = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  27087 	var iHash int32
  27088 	var iMinHash int32
  27089 
  27090 	if iLast == U32(0) || int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) == 0 && int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 {
  27091 		*(*U32)(unsafe.Pointer(piRead)) = U32(0)
  27092 		return SQLITE_OK
  27093 	}
  27094 
  27095 	iMinHash = walFramePage(tls, (*Wal)(unsafe.Pointer(pWal)).FminFrame)
  27096 	for iHash = walFramePage(tls, iLast); iHash >= iMinHash; iHash-- {
  27097 		var iKey int32
  27098 		var nCollide int32
  27099 		var rc int32
  27100 		var iH U32
  27101 
  27102 		rc = walHashGet(tls, pWal, iHash, bp)
  27103 		if rc != SQLITE_OK {
  27104 			return rc
  27105 		}
  27106 		nCollide = HASHTABLE_NPAGE * 2
  27107 		iKey = walHash(tls, pgno)
  27108 		for libc.AssignUint32(&iH, U32(libc.AtomicLoadNUint16((*WalHashLoc)(unsafe.Pointer(bp)).FaHash+uintptr(iKey)*2, 0))) != U32(0) {
  27109 			var iFrame U32 = iH + (*WalHashLoc)(unsafe.Pointer(bp)).FiZero
  27110 			if iFrame <= iLast && iFrame >= (*Wal)(unsafe.Pointer(pWal)).FminFrame && *(*U32)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp)).FaPgno + uintptr(iH-U32(1))*4)) == pgno {
  27111 				iRead = iFrame
  27112 			}
  27113 			if libc.PostDecInt32(&nCollide, 1) == 0 {
  27114 				return Xsqlite3CorruptError(tls, 66423)
  27115 			}
  27116 			iKey = walNextHash(tls, iKey)
  27117 		}
  27118 		if iRead != 0 {
  27119 			break
  27120 		}
  27121 	}
  27122 
  27123 	*(*U32)(unsafe.Pointer(piRead)) = iRead
  27124 	return SQLITE_OK
  27125 }
  27126 
  27127 // Read the contents of frame iRead from the wal file into buffer pOut
  27128 // (which is nOut bytes in size). Return SQLITE_OK if successful, or an
  27129 // error code otherwise.
  27130 func Xsqlite3WalReadFrame(tls *libc.TLS, pWal uintptr, iRead U32, nOut int32, pOut uintptr) int32 {
  27131 	var sz int32
  27132 	var iOffset I64
  27133 	sz = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)
  27134 	sz = sz&0xfe00 + sz&0x0001<<16
  27135 
  27136 	iOffset = int64(WAL_HDRSIZE) + I64(iRead-U32(1))*I64(sz+WAL_FRAME_HDRSIZE) + int64(WAL_FRAME_HDRSIZE)
  27137 
  27138 	return Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pOut, func() int32 {
  27139 		if nOut > sz {
  27140 			return sz
  27141 		}
  27142 		return nOut
  27143 	}(), iOffset)
  27144 }
  27145 
  27146 // Return the size of the database in pages (or zero, if unknown).
  27147 func Xsqlite3WalDbsize(tls *libc.TLS, pWal uintptr) Pgno {
  27148 	if pWal != 0 && int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) >= 0 {
  27149 		return (*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage
  27150 	}
  27151 	return Pgno(0)
  27152 }
  27153 
  27154 // This function starts a write transaction on the WAL.
  27155 //
  27156 // A read transaction must have already been started by a prior call
  27157 // to sqlite3WalBeginReadTransaction().
  27158 //
  27159 // If another thread or process has written into the database since
  27160 // the read transaction was started, then it is not possible for this
  27161 // thread to write as doing so would cause a fork.  So this routine
  27162 // returns SQLITE_BUSY in that case and no write transaction is started.
  27163 //
  27164 // There can only be a single writer active at a time.
  27165 func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 {
  27166 	var rc int32
  27167 
  27168 	if (*Wal)(unsafe.Pointer(pWal)).FreadOnly != 0 {
  27169 		return SQLITE_READONLY
  27170 	}
  27171 
  27172 	rc = walLockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)
  27173 	if rc != 0 {
  27174 		return rc
  27175 	}
  27176 	(*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1)
  27177 
  27178 	if libc.Xmemcmp(tls, pWal+52, walIndexHdr(tls, pWal), uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  27179 		walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)
  27180 		(*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0)
  27181 		rc = SQLITE_BUSY | int32(2)<<8
  27182 	}
  27183 
  27184 	return rc
  27185 }
  27186 
  27187 // End a write transaction.  The commit has already been done.  This
  27188 // routine merely releases the lock.
  27189 func Xsqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) int32 {
  27190 	if (*Wal)(unsafe.Pointer(pWal)).FwriteLock != 0 {
  27191 		walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)
  27192 		(*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0)
  27193 		(*Wal)(unsafe.Pointer(pWal)).FiReCksum = U32(0)
  27194 		(*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(0)
  27195 	}
  27196 	return SQLITE_OK
  27197 }
  27198 
  27199 // If any data has been written (but not committed) to the log file, this
  27200 // function moves the write-pointer back to the start of the transaction.
  27201 //
  27202 // Additionally, the callback function is invoked for each frame written
  27203 // to the WAL since the start of the transaction. If the callback returns
  27204 // other than SQLITE_OK, it is not invoked again and the error code is
  27205 // returned to the caller.
  27206 //
  27207 // Otherwise, if the callback function does not return an error, this
  27208 // function returns SQLITE_OK.
  27209 func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintptr) int32 {
  27210 	var rc int32 = SQLITE_OK
  27211 	if (*Wal)(unsafe.Pointer(pWal)).FwriteLock != 0 {
  27212 		var iMax Pgno = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  27213 		var iFrame Pgno
  27214 
  27215 		libc.Xmemcpy(tls, pWal+52, walIndexHdr(tls, pWal), uint32(unsafe.Sizeof(WalIndexHdr{})))
  27216 
  27217 		for iFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1); rc == SQLITE_OK && iFrame <= iMax; iFrame++ {
  27218 			rc = (*struct {
  27219 				f func(*libc.TLS, uintptr, Pgno) int32
  27220 			})(unsafe.Pointer(&struct{ uintptr }{xUndo})).f(tls, pUndoCtx, walFramePgno(tls, pWal, iFrame))
  27221 		}
  27222 		if iMax != (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame {
  27223 			walCleanupHash(tls, pWal)
  27224 		}
  27225 	}
  27226 	return rc
  27227 }
  27228 
  27229 // Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32
  27230 // values. This function populates the array with values required to
  27231 // "rollback" the write position of the WAL handle back to the current
  27232 // point in the event of a savepoint rollback (via WalSavepointUndo()).
  27233 func Xsqlite3WalSavepoint(tls *libc.TLS, pWal uintptr, aWalData uintptr) {
  27234 	*(*U32)(unsafe.Pointer(aWalData)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  27235 	*(*U32)(unsafe.Pointer(aWalData + 1*4)) = *(*U32)(unsafe.Pointer(pWal + 52 + 24))
  27236 	*(*U32)(unsafe.Pointer(aWalData + 2*4)) = *(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4))
  27237 	*(*U32)(unsafe.Pointer(aWalData + 3*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt
  27238 }
  27239 
  27240 // Move the write position of the WAL back to the point identified by
  27241 // the values in the aWalData[] array. aWalData must point to an array
  27242 // of WAL_SAVEPOINT_NDATA u32 values that has been previously populated
  27243 // by a call to WalSavepoint().
  27244 func Xsqlite3WalSavepointUndo(tls *libc.TLS, pWal uintptr, aWalData uintptr) int32 {
  27245 	var rc int32 = SQLITE_OK
  27246 
  27247 	if *(*U32)(unsafe.Pointer(aWalData + 3*4)) != (*Wal)(unsafe.Pointer(pWal)).FnCkpt {
  27248 		*(*U32)(unsafe.Pointer(aWalData)) = U32(0)
  27249 		*(*U32)(unsafe.Pointer(aWalData + 3*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt
  27250 	}
  27251 
  27252 	if *(*U32)(unsafe.Pointer(aWalData)) < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame {
  27253 		(*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = *(*U32)(unsafe.Pointer(aWalData))
  27254 		*(*U32)(unsafe.Pointer(pWal + 52 + 24)) = *(*U32)(unsafe.Pointer(aWalData + 1*4))
  27255 		*(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4)) = *(*U32)(unsafe.Pointer(aWalData + 2*4))
  27256 		walCleanupHash(tls, pWal)
  27257 	}
  27258 
  27259 	return rc
  27260 }
  27261 
  27262 func walRestartLog(tls *libc.TLS, pWal uintptr) int32 {
  27263 	bp := tls.Alloc(8)
  27264 	defer tls.Free(8)
  27265 
  27266 	var rc int32 = SQLITE_OK
  27267 	var cnt int32
  27268 
  27269 	if int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) == 0 {
  27270 		var pInfo uintptr = walCkptInfo(tls, pWal)
  27271 
  27272 		if (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill > U32(0) {
  27273 			Xsqlite3_randomness(tls, 4, bp)
  27274 			rc = walLockExclusive(tls, pWal, 3+1, SQLITE_SHM_NLOCK-3-1)
  27275 			if rc == SQLITE_OK {
  27276 				walRestartHdr(tls, pWal, *(*U32)(unsafe.Pointer(bp)))
  27277 				walUnlockExclusive(tls, pWal, 3+1, SQLITE_SHM_NLOCK-3-1)
  27278 			} else if rc != SQLITE_BUSY {
  27279 				return rc
  27280 			}
  27281 		}
  27282 		walUnlockShared(tls, pWal, 3+0)
  27283 		(*Wal)(unsafe.Pointer(pWal)).FreadLock = int16(-1)
  27284 		cnt = 0
  27285 		for __ccgo := true; __ccgo; __ccgo = rc == -1 {
  27286 			rc = walTryBeginRead(tls, pWal, bp+4, 1, libc.PreIncInt32(&cnt, 1))
  27287 		}
  27288 
  27289 	}
  27290 	return rc
  27291 }
  27292 
  27293 // Information about the current state of the WAL file and where
  27294 // the next fsync should occur - passed from sqlite3WalFrames() into
  27295 // walWriteToLog().
  27296 type WalWriter1 = struct {
  27297 	FpWal       uintptr
  27298 	FpFd        uintptr
  27299 	FiSyncPoint Sqlite3_int64
  27300 	FsyncFlags  int32
  27301 	FszPage     int32
  27302 }
  27303 
  27304 // Information about the current state of the WAL file and where
  27305 // the next fsync should occur - passed from sqlite3WalFrames() into
  27306 // walWriteToLog().
  27307 type WalWriter = WalWriter1
  27308 
  27309 func walWriteToLog(tls *libc.TLS, p uintptr, pContent uintptr, iAmt int32, iOffset Sqlite3_int64) int32 {
  27310 	var rc int32
  27311 	if iOffset < (*WalWriter)(unsafe.Pointer(p)).FiSyncPoint && iOffset+Sqlite3_int64(iAmt) >= (*WalWriter)(unsafe.Pointer(p)).FiSyncPoint {
  27312 		var iFirstAmt int32 = int32((*WalWriter)(unsafe.Pointer(p)).FiSyncPoint - iOffset)
  27313 		rc = Xsqlite3OsWrite(tls, (*WalWriter)(unsafe.Pointer(p)).FpFd, pContent, iFirstAmt, iOffset)
  27314 		if rc != 0 {
  27315 			return rc
  27316 		}
  27317 		iOffset = iOffset + Sqlite3_int64(iFirstAmt)
  27318 		iAmt = iAmt - iFirstAmt
  27319 		pContent = uintptr(iFirstAmt) + pContent
  27320 
  27321 		rc = Xsqlite3OsSync(tls, (*WalWriter)(unsafe.Pointer(p)).FpFd, (*WalWriter)(unsafe.Pointer(p)).FsyncFlags&0x03)
  27322 		if iAmt == 0 || rc != 0 {
  27323 			return rc
  27324 		}
  27325 	}
  27326 	rc = Xsqlite3OsWrite(tls, (*WalWriter)(unsafe.Pointer(p)).FpFd, pContent, iAmt, iOffset)
  27327 	return rc
  27328 }
  27329 
  27330 func walWriteOneFrame(tls *libc.TLS, p uintptr, pPage uintptr, nTruncate int32, iOffset Sqlite3_int64) int32 {
  27331 	bp := tls.Alloc(24)
  27332 	defer tls.Free(24)
  27333 
  27334 	var rc int32
  27335 	var pData uintptr
  27336 
  27337 	pData = (*PgHdr)(unsafe.Pointer(pPage)).FpData
  27338 	walEncodeFrame(tls, (*WalWriter)(unsafe.Pointer(p)).FpWal, (*PgHdr)(unsafe.Pointer(pPage)).Fpgno, uint32(nTruncate), pData, bp)
  27339 	rc = walWriteToLog(tls, p, bp, int32(unsafe.Sizeof([24]U8{})), iOffset)
  27340 	if rc != 0 {
  27341 		return rc
  27342 	}
  27343 
  27344 	rc = walWriteToLog(tls, p, pData, (*WalWriter)(unsafe.Pointer(p)).FszPage, iOffset+Sqlite3_int64(unsafe.Sizeof([24]U8{})))
  27345 	return rc
  27346 }
  27347 
  27348 func walRewriteChecksums(tls *libc.TLS, pWal uintptr, iLast U32) int32 {
  27349 	bp := tls.Alloc(24)
  27350 	defer tls.Free(24)
  27351 
  27352 	var szPage int32 = int32((*Wal)(unsafe.Pointer(pWal)).FszPage)
  27353 	var rc int32 = SQLITE_OK
  27354 	var aBuf uintptr
  27355 
  27356 	var iRead U32
  27357 	var iCksumOff I64
  27358 
  27359 	aBuf = Xsqlite3_malloc(tls, szPage+WAL_FRAME_HDRSIZE)
  27360 	if aBuf == uintptr(0) {
  27361 		return SQLITE_NOMEM
  27362 	}
  27363 
  27364 	if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(1) {
  27365 		iCksumOff = int64(24)
  27366 	} else {
  27367 		iCksumOff = int64(WAL_HDRSIZE) + I64((*Wal)(unsafe.Pointer(pWal)).FiReCksum-U32(1)-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE) + int64(16)
  27368 	}
  27369 	rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, int32(uint32(unsafe.Sizeof(U32(0)))*uint32(2)), iCksumOff)
  27370 	*(*U32)(unsafe.Pointer(pWal + 52 + 24)) = Xsqlite3Get4byte(tls, aBuf)
  27371 	*(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4)) = Xsqlite3Get4byte(tls, aBuf+4)
  27372 
  27373 	iRead = (*Wal)(unsafe.Pointer(pWal)).FiReCksum
  27374 	(*Wal)(unsafe.Pointer(pWal)).FiReCksum = U32(0)
  27375 	for ; rc == SQLITE_OK && iRead <= iLast; iRead++ {
  27376 		var iOff I64 = int64(WAL_HDRSIZE) + I64(iRead-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE)
  27377 		rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff)
  27378 		if rc == SQLITE_OK {
  27379 			var iPgno U32
  27380 			var nDbSize U32
  27381 			iPgno = Xsqlite3Get4byte(tls, aBuf)
  27382 			nDbSize = Xsqlite3Get4byte(tls, aBuf+4)
  27383 
  27384 			walEncodeFrame(tls, pWal, iPgno, nDbSize, aBuf+24, bp)
  27385 			rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp, int32(unsafe.Sizeof([24]U8{})), iOff)
  27386 		}
  27387 	}
  27388 
  27389 	Xsqlite3_free(tls, aBuf)
  27390 	return rc
  27391 }
  27392 
  27393 // Write a set of frames to the log. The caller must hold the write-lock
  27394 // on the log file (obtained using sqlite3WalBeginWriteTransaction()).
  27395 func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, nTruncate Pgno, isCommit int32, sync_flags int32) int32 {
  27396 	bp := tls.Alloc(72)
  27397 	defer tls.Free(72)
  27398 
  27399 	var rc int32
  27400 	var iFrame U32
  27401 	var p uintptr
  27402 	var pLast uintptr = uintptr(0)
  27403 	var nExtra int32 = 0
  27404 	var szFrame int32
  27405 	var iOffset I64
  27406 
  27407 	var iFirst U32 = U32(0)
  27408 	var pLive uintptr
  27409 
  27410 	pLive = walIndexHdr(tls, pWal)
  27411 	if libc.Xmemcmp(tls, pWal+52, pLive, uint32(unsafe.Sizeof(WalIndexHdr{}))) != 0 {
  27412 		iFirst = (*WalIndexHdr)(unsafe.Pointer(pLive)).FmxFrame + U32(1)
  27413 	}
  27414 
  27415 	if SQLITE_OK != libc.AssignInt32(&rc, walRestartLog(tls, pWal)) {
  27416 		return rc
  27417 	}
  27418 
  27419 	iFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  27420 	if iFrame == U32(0) {
  27421 		Xsqlite3Put4byte(tls, bp, uint32(WAL_MAGIC|SQLITE_BIGENDIAN))
  27422 		Xsqlite3Put4byte(tls, bp+4, uint32(WAL_MAX_VERSION))
  27423 		Xsqlite3Put4byte(tls, bp+8, uint32(szPage))
  27424 		Xsqlite3Put4byte(tls, bp+12, (*Wal)(unsafe.Pointer(pWal)).FnCkpt)
  27425 		if (*Wal)(unsafe.Pointer(pWal)).FnCkpt == U32(0) {
  27426 			Xsqlite3_randomness(tls, 8, pWal+52+32)
  27427 		}
  27428 		libc.Xmemcpy(tls, bp+16, pWal+52+32, uint32(8))
  27429 		walChecksumBytes(tls, 1, bp, WAL_HDRSIZE-2*4, uintptr(0), bp+32)
  27430 		Xsqlite3Put4byte(tls, bp+24, *(*U32)(unsafe.Pointer(bp + 32)))
  27431 		Xsqlite3Put4byte(tls, bp+28, *(*U32)(unsafe.Pointer(bp + 32 + 1*4)))
  27432 
  27433 		(*Wal)(unsafe.Pointer(pWal)).FszPage = U32(szPage)
  27434 		(*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = U8(SQLITE_BIGENDIAN)
  27435 		*(*U32)(unsafe.Pointer(pWal + 52 + 24)) = *(*U32)(unsafe.Pointer(bp + 32))
  27436 		*(*U32)(unsafe.Pointer(pWal + 52 + 24 + 1*4)) = *(*U32)(unsafe.Pointer(bp + 32 + 1*4))
  27437 		(*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(1)
  27438 
  27439 		rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp, int32(unsafe.Sizeof([32]U8{})), int64(0))
  27440 
  27441 		if rc != SQLITE_OK {
  27442 			return rc
  27443 		}
  27444 
  27445 		if (*Wal)(unsafe.Pointer(pWal)).FsyncHeader != 0 {
  27446 			rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, sync_flags>>2&0x03)
  27447 			if rc != 0 {
  27448 				return rc
  27449 			}
  27450 		}
  27451 	}
  27452 
  27453 	(*WalWriter)(unsafe.Pointer(bp + 48)).FpWal = pWal
  27454 	(*WalWriter)(unsafe.Pointer(bp + 48)).FpFd = (*Wal)(unsafe.Pointer(pWal)).FpWalFd
  27455 	(*WalWriter)(unsafe.Pointer(bp + 48)).FiSyncPoint = int64(0)
  27456 	(*WalWriter)(unsafe.Pointer(bp + 48)).FsyncFlags = sync_flags
  27457 	(*WalWriter)(unsafe.Pointer(bp + 48)).FszPage = szPage
  27458 	iOffset = int64(WAL_HDRSIZE) + I64(iFrame+U32(1)-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE)
  27459 	szFrame = szPage + WAL_FRAME_HDRSIZE
  27460 
  27461 	for p = pList; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty {
  27462 		var nDbSize int32
  27463 
  27464 		if iFirst != 0 && ((*PgHdr)(unsafe.Pointer(p)).FpDirty != 0 || isCommit == 0) {
  27465 			*(*U32)(unsafe.Pointer(bp + 40)) = U32(0)
  27466 			Xsqlite3WalFindFrame(tls, pWal, (*PgHdr)(unsafe.Pointer(p)).Fpgno, bp+40)
  27467 
  27468 			if *(*U32)(unsafe.Pointer(bp + 40)) >= iFirst {
  27469 				var iOff I64 = int64(WAL_HDRSIZE) + I64(*(*U32)(unsafe.Pointer(bp + 40))-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE) + int64(WAL_FRAME_HDRSIZE)
  27470 				var pData uintptr
  27471 				if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(0) || *(*U32)(unsafe.Pointer(bp + 40)) < (*Wal)(unsafe.Pointer(pWal)).FiReCksum {
  27472 					(*Wal)(unsafe.Pointer(pWal)).FiReCksum = *(*U32)(unsafe.Pointer(bp + 40))
  27473 				}
  27474 				pData = (*PgHdr)(unsafe.Pointer(p)).FpData
  27475 				rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pData, szPage, iOff)
  27476 				if rc != 0 {
  27477 					return rc
  27478 				}
  27479 				*(*U16)(unsafe.Pointer(p + 28)) &= libc.Uint16FromInt32(libc.CplInt32(PGHDR_WAL_APPEND))
  27480 				continue
  27481 			}
  27482 		}
  27483 
  27484 		iFrame++
  27485 
  27486 		if isCommit != 0 && (*PgHdr)(unsafe.Pointer(p)).FpDirty == uintptr(0) {
  27487 			nDbSize = int32(nTruncate)
  27488 		} else {
  27489 			nDbSize = 0
  27490 		}
  27491 		rc = walWriteOneFrame(tls, bp+48, p, nDbSize, iOffset)
  27492 		if rc != 0 {
  27493 			return rc
  27494 		}
  27495 		pLast = p
  27496 		iOffset = iOffset + I64(szFrame)
  27497 		*(*U16)(unsafe.Pointer(p + 28)) |= U16(PGHDR_WAL_APPEND)
  27498 	}
  27499 
  27500 	if isCommit != 0 && (*Wal)(unsafe.Pointer(pWal)).FiReCksum != 0 {
  27501 		rc = walRewriteChecksums(tls, pWal, iFrame)
  27502 		if rc != 0 {
  27503 			return rc
  27504 		}
  27505 	}
  27506 
  27507 	if isCommit != 0 && sync_flags&0x03 != 0 {
  27508 		var bSync int32 = 1
  27509 		if (*Wal)(unsafe.Pointer(pWal)).FpadToSectorBoundary != 0 {
  27510 			var sectorSize int32 = Xsqlite3SectorSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd)
  27511 			(*WalWriter)(unsafe.Pointer(bp + 48)).FiSyncPoint = (iOffset + I64(sectorSize) - int64(1)) / I64(sectorSize) * I64(sectorSize)
  27512 			bSync = libc.Bool32((*WalWriter)(unsafe.Pointer(bp+48)).FiSyncPoint == iOffset)
  27513 
  27514 			for iOffset < (*WalWriter)(unsafe.Pointer(bp+48)).FiSyncPoint {
  27515 				rc = walWriteOneFrame(tls, bp+48, pLast, int32(nTruncate), iOffset)
  27516 				if rc != 0 {
  27517 					return rc
  27518 				}
  27519 				iOffset = iOffset + I64(szFrame)
  27520 				nExtra++
  27521 
  27522 			}
  27523 		}
  27524 		if bSync != 0 {
  27525 			rc = Xsqlite3OsSync(tls, (*WalWriter)(unsafe.Pointer(bp+48)).FpFd, sync_flags&0x03)
  27526 		}
  27527 	}
  27528 
  27529 	if isCommit != 0 && (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit != 0 && (*Wal)(unsafe.Pointer(pWal)).FmxWalSize >= int64(0) {
  27530 		var sz I64 = (*Wal)(unsafe.Pointer(pWal)).FmxWalSize
  27531 		if int64(WAL_HDRSIZE)+I64(iFrame+U32(nExtra)+U32(1)-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE) > (*Wal)(unsafe.Pointer(pWal)).FmxWalSize {
  27532 			sz = int64(WAL_HDRSIZE) + I64(iFrame+U32(nExtra)+U32(1)-U32(1))*I64(szPage+WAL_FRAME_HDRSIZE)
  27533 		}
  27534 		walLimitSize(tls, pWal, sz)
  27535 		(*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(0)
  27536 	}
  27537 
  27538 	iFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame
  27539 	for p = pList; p != 0 && rc == SQLITE_OK; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty {
  27540 		if int32((*PgHdr)(unsafe.Pointer(p)).Fflags)&PGHDR_WAL_APPEND == 0 {
  27541 			continue
  27542 		}
  27543 		iFrame++
  27544 		rc = walIndexAppend(tls, pWal, iFrame, (*PgHdr)(unsafe.Pointer(p)).Fpgno)
  27545 	}
  27546 
  27547 	for rc == SQLITE_OK && nExtra > 0 {
  27548 		iFrame++
  27549 		nExtra--
  27550 		rc = walIndexAppend(tls, pWal, iFrame, (*PgHdr)(unsafe.Pointer(pLast)).Fpgno)
  27551 	}
  27552 
  27553 	if rc == SQLITE_OK {
  27554 		(*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage = U16(szPage&0xff00 | szPage>>16)
  27555 
  27556 		(*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = iFrame
  27557 		if isCommit != 0 {
  27558 			(*Wal)(unsafe.Pointer(pWal)).Fhdr.FiChange++
  27559 			(*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage = nTruncate
  27560 		}
  27561 
  27562 		if isCommit != 0 {
  27563 			walIndexWriteHdr(tls, pWal)
  27564 			(*Wal)(unsafe.Pointer(pWal)).FiCallback = iFrame
  27565 		}
  27566 	}
  27567 
  27568 	return rc
  27569 }
  27570 
  27571 // This routine is called to implement sqlite3_wal_checkpoint() and
  27572 // related interfaces.
  27573 //
  27574 // Obtain a CHECKPOINT lock and then backfill as much information as
  27575 // we can from WAL into the database.
  27576 //
  27577 // If parameter xBusy is not NULL, it is a pointer to a busy-handler
  27578 // callback. In this case this function runs a blocking checkpoint.
  27579 func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, xBusy uintptr, pBusyArg uintptr, sync_flags int32, nBuf int32, zBuf uintptr, pnLog uintptr, pnCkpt uintptr) int32 {
  27580 	bp := tls.Alloc(4)
  27581 	defer tls.Free(4)
  27582 
  27583 	var rc int32
  27584 	*(*int32)(unsafe.Pointer(bp)) = 0
  27585 	var eMode2 int32 = eMode
  27586 	var xBusy2 uintptr = xBusy
  27587 
  27588 	if (*Wal)(unsafe.Pointer(pWal)).FreadOnly != 0 {
  27589 		return SQLITE_READONLY
  27590 	}
  27591 
  27592 	rc = walLockExclusive(tls, pWal, WAL_CKPT_LOCK, 1)
  27593 
  27594 	if rc == SQLITE_OK {
  27595 		(*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(1)
  27596 
  27597 		if eMode != SQLITE_CHECKPOINT_PASSIVE {
  27598 			rc = walBusyLock(tls, pWal, xBusy2, pBusyArg, WAL_WRITE_LOCK, 1)
  27599 			if rc == SQLITE_OK {
  27600 				(*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1)
  27601 			} else if rc == SQLITE_BUSY {
  27602 				eMode2 = SQLITE_CHECKPOINT_PASSIVE
  27603 				xBusy2 = uintptr(0)
  27604 				rc = SQLITE_OK
  27605 			}
  27606 		}
  27607 	}
  27608 
  27609 	if rc == SQLITE_OK {
  27610 		rc = walIndexReadHdr(tls, pWal, bp)
  27611 
  27612 		if *(*int32)(unsafe.Pointer(bp)) != 0 && (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpDbFd)).FpMethods)).FiVersion >= 3 {
  27613 			Xsqlite3OsUnfetch(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, int64(0), uintptr(0))
  27614 		}
  27615 	}
  27616 
  27617 	if rc == SQLITE_OK {
  27618 		if (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0 && walPagesize(tls, pWal) != nBuf {
  27619 			rc = Xsqlite3CorruptError(tls, 67142)
  27620 		} else {
  27621 			rc = walCheckpoint(tls, pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf)
  27622 		}
  27623 
  27624 		if rc == SQLITE_OK || rc == SQLITE_BUSY {
  27625 			if pnLog != 0 {
  27626 				*(*int32)(unsafe.Pointer(pnLog)) = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)
  27627 			}
  27628 			if pnCkpt != 0 {
  27629 				*(*int32)(unsafe.Pointer(pnCkpt)) = int32((*WalCkptInfo)(unsafe.Pointer(walCkptInfo(tls, pWal))).FnBackfill)
  27630 			}
  27631 		}
  27632 	}
  27633 
  27634 	if *(*int32)(unsafe.Pointer(bp)) != 0 {
  27635 		libc.Xmemset(tls, pWal+52, 0, uint32(unsafe.Sizeof(WalIndexHdr{})))
  27636 	}
  27637 
  27638 	Xsqlite3WalEndWriteTransaction(tls, pWal)
  27639 	if (*Wal)(unsafe.Pointer(pWal)).FckptLock != 0 {
  27640 		walUnlockExclusive(tls, pWal, WAL_CKPT_LOCK, 1)
  27641 		(*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(0)
  27642 	}
  27643 
  27644 	return func() int32 {
  27645 		if rc == SQLITE_OK && eMode != eMode2 {
  27646 			return SQLITE_BUSY
  27647 		}
  27648 		return rc
  27649 	}()
  27650 }
  27651 
  27652 // Return the value to pass to a sqlite3_wal_hook callback, the
  27653 // number of frames in the WAL at the point of the last commit since
  27654 // sqlite3WalCallback() was called.  If no commits have occurred since
  27655 // the last call, then return 0.
  27656 func Xsqlite3WalCallback(tls *libc.TLS, pWal uintptr) int32 {
  27657 	var ret U32 = U32(0)
  27658 	if pWal != 0 {
  27659 		ret = (*Wal)(unsafe.Pointer(pWal)).FiCallback
  27660 		(*Wal)(unsafe.Pointer(pWal)).FiCallback = U32(0)
  27661 	}
  27662 	return int32(ret)
  27663 }
  27664 
  27665 // This function is called to change the WAL subsystem into or out
  27666 // of locking_mode=EXCLUSIVE.
  27667 //
  27668 // If op is zero, then attempt to change from locking_mode=EXCLUSIVE
  27669 // into locking_mode=NORMAL.  This means that we must acquire a lock
  27670 // on the pWal->readLock byte.  If the WAL is already in locking_mode=NORMAL
  27671 // or if the acquisition of the lock fails, then return 0.  If the
  27672 // transition out of exclusive-mode is successful, return 1.  This
  27673 // operation must occur while the pager is still holding the exclusive
  27674 // lock on the main database file.
  27675 //
  27676 // If op is one, then change from locking_mode=NORMAL into
  27677 // locking_mode=EXCLUSIVE.  This means that the pWal->readLock must
  27678 // be released.  Return 1 if the transition is made and 0 if the
  27679 // WAL is already in exclusive-locking mode - meaning that this
  27680 // routine is a no-op.  The pager must already hold the exclusive lock
  27681 // on the main database file before invoking this operation.
  27682 //
  27683 // If op is negative, then do a dry-run of the op==1 case but do
  27684 // not actually change anything. The pager uses this to see if it
  27685 // should acquire the database exclusive lock prior to invoking
  27686 // the op==1 case.
  27687 func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 {
  27688 	var rc int32
  27689 
  27690 	if op == 0 {
  27691 		if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_NORMAL_MODE {
  27692 			(*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(WAL_NORMAL_MODE)
  27693 			if walLockShared(tls, pWal, 3+int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)) != SQLITE_OK {
  27694 				(*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(WAL_EXCLUSIVE_MODE)
  27695 			}
  27696 			rc = libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE)
  27697 		} else {
  27698 			rc = 0
  27699 		}
  27700 	} else if op > 0 {
  27701 		walUnlockShared(tls, pWal, 3+int32((*Wal)(unsafe.Pointer(pWal)).FreadLock))
  27702 		(*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(WAL_EXCLUSIVE_MODE)
  27703 		rc = 1
  27704 	} else {
  27705 		rc = libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE)
  27706 	}
  27707 	return rc
  27708 }
  27709 
  27710 // Return true if the argument is non-NULL and the WAL module is using
  27711 // heap-memory for the wal-index. Otherwise, if the argument is NULL or the
  27712 // WAL module is using shared-memory, return false.
  27713 func Xsqlite3WalHeapMemory(tls *libc.TLS, pWal uintptr) int32 {
  27714 	return libc.Bool32(pWal != 0 && int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE)
  27715 }
  27716 
  27717 // Create a snapshot object.  The content of a snapshot is opaque to
  27718 // every other subsystem, so the WAL module can put whatever it needs
  27719 // in the object.
  27720 func Xsqlite3WalSnapshotGet(tls *libc.TLS, pWal uintptr, ppSnapshot uintptr) int32 {
  27721 	var rc int32 = SQLITE_OK
  27722 	var pRet uintptr
  27723 
  27724 	if libc.Xmemcmp(tls, pWal+52+24, uintptr(unsafe.Pointer(&aZero)), uint32(16)) == 0 {
  27725 		*(*uintptr)(unsafe.Pointer(ppSnapshot)) = uintptr(0)
  27726 		return SQLITE_ERROR
  27727 	}
  27728 	pRet = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(WalIndexHdr{})))
  27729 	if pRet == uintptr(0) {
  27730 		rc = SQLITE_NOMEM
  27731 	} else {
  27732 		libc.Xmemcpy(tls, pRet, pWal+52, uint32(unsafe.Sizeof(WalIndexHdr{})))
  27733 		*(*uintptr)(unsafe.Pointer(ppSnapshot)) = pRet
  27734 	}
  27735 
  27736 	return rc
  27737 }
  27738 
  27739 var aZero = [4]U32{U32(0), U32(0), U32(0), U32(0)}
  27740 
  27741 // Try to open on pSnapshot when the next read-transaction starts
  27742 func Xsqlite3WalSnapshotOpen(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) {
  27743 	(*Wal)(unsafe.Pointer(pWal)).FpSnapshot = pSnapshot
  27744 }
  27745 
  27746 // Return a +ve value if snapshot p1 is newer than p2. A -ve value if
  27747 // p1 is older than p2 and zero if p1 and p2 are the same snapshot.
  27748 func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 {
  27749 	var pHdr1 uintptr = p1
  27750 	var pHdr2 uintptr = p2
  27751 
  27752 	if *(*U32)(unsafe.Pointer(pHdr1 + 32)) < *(*U32)(unsafe.Pointer(pHdr2 + 32)) {
  27753 		return -1
  27754 	}
  27755 	if *(*U32)(unsafe.Pointer(pHdr1 + 32)) > *(*U32)(unsafe.Pointer(pHdr2 + 32)) {
  27756 		return +1
  27757 	}
  27758 	if (*WalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame < (*WalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame {
  27759 		return -1
  27760 	}
  27761 	if (*WalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame > (*WalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame {
  27762 		return +1
  27763 	}
  27764 	return 0
  27765 }
  27766 
  27767 // The caller currently has a read transaction open on the database.
  27768 // This function takes a SHARED lock on the CHECKPOINTER slot and then
  27769 // checks if the snapshot passed as the second argument is still
  27770 // available. If so, SQLITE_OK is returned.
  27771 //
  27772 // If the snapshot is not available, SQLITE_ERROR is returned. Or, if
  27773 // the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
  27774 // occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
  27775 // lock is released before returning.
  27776 func Xsqlite3WalSnapshotCheck(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) int32 {
  27777 	var rc int32
  27778 	rc = walLockShared(tls, pWal, WAL_CKPT_LOCK)
  27779 	if rc == SQLITE_OK {
  27780 		var pNew uintptr = pSnapshot
  27781 		if libc.Xmemcmp(tls, pNew+32, pWal+52+32, uint32(unsafe.Sizeof([2]U32{}))) != 0 ||
  27782 			(*WalIndexHdr)(unsafe.Pointer(pNew)).FmxFrame < (*WalCkptInfo)(unsafe.Pointer(walCkptInfo(tls, pWal))).FnBackfillAttempted {
  27783 			rc = SQLITE_ERROR | int32(3)<<8
  27784 			walUnlockShared(tls, pWal, WAL_CKPT_LOCK)
  27785 		}
  27786 	}
  27787 	return rc
  27788 }
  27789 
  27790 // Release a lock obtained by an earlier successful call to
  27791 // sqlite3WalSnapshotCheck().
  27792 func Xsqlite3WalSnapshotUnlock(tls *libc.TLS, pWal uintptr) {
  27793 	walUnlockShared(tls, pWal, WAL_CKPT_LOCK)
  27794 }
  27795 
  27796 // Return the sqlite3_file object for the WAL file
  27797 func Xsqlite3WalFile(tls *libc.TLS, pWal uintptr) uintptr {
  27798 	return (*Wal)(unsafe.Pointer(pWal)).FpWalFd
  27799 }
  27800 
  27801 // Forward declarations
  27802 type MemPage1 = struct {
  27803 	FisInit          U8
  27804 	FintKey          U8
  27805 	FintKeyLeaf      U8
  27806 	F__ccgo_pad1     [1]byte
  27807 	Fpgno            Pgno
  27808 	Fleaf            U8
  27809 	FhdrOffset       U8
  27810 	FchildPtrSize    U8
  27811 	Fmax1bytePayload U8
  27812 	FnOverflow       U8
  27813 	F__ccgo_pad2     [1]byte
  27814 	FmaxLocal        U16
  27815 	FminLocal        U16
  27816 	FcellOffset      U16
  27817 	FnFree           int32
  27818 	FnCell           U16
  27819 	FmaskPage        U16
  27820 	FaiOvfl          [4]U16
  27821 	FapOvfl          [4]uintptr
  27822 	FpBt             uintptr
  27823 	FaData           uintptr
  27824 	FaDataEnd        uintptr
  27825 	FaCellIdx        uintptr
  27826 	FaDataOfst       uintptr
  27827 	FpDbPage         uintptr
  27828 	FxCellSize       uintptr
  27829 	FxParseCell      uintptr
  27830 }
  27831 
  27832 // Forward declarations
  27833 type MemPage = MemPage1
  27834 type BtLock1 = struct {
  27835 	FpBtree      uintptr
  27836 	FiTable      Pgno
  27837 	FeLock       U8
  27838 	F__ccgo_pad1 [3]byte
  27839 	FpNext       uintptr
  27840 }
  27841 
  27842 type BtLock = BtLock1
  27843 type CellInfo1 = struct {
  27844 	FnKey        I64
  27845 	FpPayload    uintptr
  27846 	FnPayload    U32
  27847 	FnLocal      U16
  27848 	FnSize       U16
  27849 	F__ccgo_pad1 [4]byte
  27850 }
  27851 
  27852 type CellInfo = CellInfo1
  27853 
  27854 // This structure is passed around through all the PRAGMA integrity_check
  27855 // checking routines in order to keep track of some global state information.
  27856 //
  27857 // The aRef[] array is allocated so that there is 1 bit for each page in
  27858 // the database. As the integrity-check proceeds, for each page used in
  27859 // the database the corresponding bit is set. This allows integrity-check to
  27860 // detect pages that are used twice and orphaned pages (both of which
  27861 // indicate corruption).
  27862 type IntegrityCk1 = struct {
  27863 	FpBt    uintptr
  27864 	FpPager uintptr
  27865 	FaPgRef uintptr
  27866 	FnPage  Pgno
  27867 	FmxErr  int32
  27868 	FnErr   int32
  27869 	Frc     int32
  27870 	FnStep  U32
  27871 	FzPfx   uintptr
  27872 	Fv1     Pgno
  27873 	Fv2     int32
  27874 	FerrMsg StrAccum
  27875 	Fheap   uintptr
  27876 	Fdb     uintptr
  27877 }
  27878 
  27879 // This structure is passed around through all the PRAGMA integrity_check
  27880 // checking routines in order to keep track of some global state information.
  27881 //
  27882 // The aRef[] array is allocated so that there is 1 bit for each page in
  27883 // the database. As the integrity-check proceeds, for each page used in
  27884 // the database the corresponding bit is set. This allows integrity-check to
  27885 // detect pages that are used twice and orphaned pages (both of which
  27886 // indicate corruption).
  27887 type IntegrityCk = IntegrityCk1
  27888 
  27889 func lockBtreeMutex(tls *libc.TLS, p uintptr) {
  27890 	Xsqlite3_mutex_enter(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fmutex)
  27891 	(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fdb = (*Btree)(unsafe.Pointer(p)).Fdb
  27892 	(*Btree)(unsafe.Pointer(p)).Flocked = U8(1)
  27893 }
  27894 
  27895 func unlockBtreeMutex(tls *libc.TLS, p uintptr) {
  27896 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  27897 
  27898 	Xsqlite3_mutex_leave(tls, (*BtShared)(unsafe.Pointer(pBt)).Fmutex)
  27899 	(*Btree)(unsafe.Pointer(p)).Flocked = U8(0)
  27900 }
  27901 
  27902 // Enter a mutex on the given BTree object.
  27903 //
  27904 // If the object is not sharable, then no mutex is ever required
  27905 // and this routine is a no-op.  The underlying mutex is non-recursive.
  27906 // But we keep a reference count in Btree.wantToLock so the behavior
  27907 // of this interface is recursive.
  27908 //
  27909 // To avoid deadlocks, multiple Btrees are locked in the same order
  27910 // by all database connections.  The p->pNext is a list of other
  27911 // Btrees belonging to the same database connection as the p Btree
  27912 // which need to be locked after p.  If we cannot get a lock on
  27913 // p, then first unlock all of the others on p->pNext, then wait
  27914 // for the lock to become available on p, then relock all of the
  27915 // subsequent Btrees that desire a lock.
  27916 func Xsqlite3BtreeEnter(tls *libc.TLS, p uintptr) {
  27917 	if !(int32((*Btree)(unsafe.Pointer(p)).Fsharable) != 0) {
  27918 		return
  27919 	}
  27920 	(*Btree)(unsafe.Pointer(p)).FwantToLock++
  27921 	if (*Btree)(unsafe.Pointer(p)).Flocked != 0 {
  27922 		return
  27923 	}
  27924 	btreeLockCarefully(tls, p)
  27925 }
  27926 
  27927 func btreeLockCarefully(tls *libc.TLS, p uintptr) {
  27928 	var pLater uintptr
  27929 
  27930 	if Xsqlite3_mutex_try(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fmutex) == SQLITE_OK {
  27931 		(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fdb = (*Btree)(unsafe.Pointer(p)).Fdb
  27932 		(*Btree)(unsafe.Pointer(p)).Flocked = U8(1)
  27933 		return
  27934 	}
  27935 
  27936 	for pLater = (*Btree)(unsafe.Pointer(p)).FpNext; pLater != 0; pLater = (*Btree)(unsafe.Pointer(pLater)).FpNext {
  27937 		if (*Btree)(unsafe.Pointer(pLater)).Flocked != 0 {
  27938 			unlockBtreeMutex(tls, pLater)
  27939 		}
  27940 	}
  27941 	lockBtreeMutex(tls, p)
  27942 	for pLater = (*Btree)(unsafe.Pointer(p)).FpNext; pLater != 0; pLater = (*Btree)(unsafe.Pointer(pLater)).FpNext {
  27943 		if (*Btree)(unsafe.Pointer(pLater)).FwantToLock != 0 {
  27944 			lockBtreeMutex(tls, pLater)
  27945 		}
  27946 	}
  27947 }
  27948 
  27949 // Exit the recursive mutex on a Btree.
  27950 func Xsqlite3BtreeLeave(tls *libc.TLS, p uintptr) {
  27951 	if (*Btree)(unsafe.Pointer(p)).Fsharable != 0 {
  27952 		(*Btree)(unsafe.Pointer(p)).FwantToLock--
  27953 		if (*Btree)(unsafe.Pointer(p)).FwantToLock == 0 {
  27954 			unlockBtreeMutex(tls, p)
  27955 		}
  27956 	}
  27957 }
  27958 
  27959 func btreeEnterAll(tls *libc.TLS, db uintptr) {
  27960 	var i int32
  27961 	var skipOk int32 = 1
  27962 	var p uintptr
  27963 
  27964 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  27965 		p = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  27966 		if p != 0 && (*Btree)(unsafe.Pointer(p)).Fsharable != 0 {
  27967 			Xsqlite3BtreeEnter(tls, p)
  27968 			skipOk = 0
  27969 		}
  27970 	}
  27971 	(*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache = U8(skipOk)
  27972 }
  27973 
  27974 func Xsqlite3BtreeEnterAll(tls *libc.TLS, db uintptr) {
  27975 	if int32((*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache) == 0 {
  27976 		btreeEnterAll(tls, db)
  27977 	}
  27978 }
  27979 
  27980 func btreeLeaveAll(tls *libc.TLS, db uintptr) {
  27981 	var i int32
  27982 	var p uintptr
  27983 
  27984 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  27985 		p = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  27986 		if p != 0 {
  27987 			Xsqlite3BtreeLeave(tls, p)
  27988 		}
  27989 	}
  27990 }
  27991 
  27992 func Xsqlite3BtreeLeaveAll(tls *libc.TLS, db uintptr) {
  27993 	if int32((*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache) == 0 {
  27994 		btreeLeaveAll(tls, db)
  27995 	}
  27996 }
  27997 
  27998 // Enter a mutex on a Btree given a cursor owned by that Btree.
  27999 //
  28000 // These entry points are used by incremental I/O only. Enter() is required
  28001 // any time OMIT_SHARED_CACHE is not defined, regardless of whether or not
  28002 // the build is threadsafe. Leave() is only required by threadsafe builds.
  28003 func Xsqlite3BtreeEnterCursor(tls *libc.TLS, pCur uintptr) {
  28004 	Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree)
  28005 }
  28006 
  28007 func Xsqlite3BtreeLeaveCursor(tls *libc.TLS, pCur uintptr) {
  28008 	Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree)
  28009 }
  28010 
  28011 var zMagicHeader = *(*[16]uint8)(unsafe.Pointer(ts + 4033))
  28012 
  28013 var sqlite3SharedCacheList uintptr = uintptr(0)
  28014 
  28015 // Enable or disable the shared pager and schema features.
  28016 //
  28017 // This routine has no effect on existing database connections.
  28018 // The shared cache setting effects only future calls to
  28019 // sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
  28020 func Xsqlite3_enable_shared_cache(tls *libc.TLS, enable int32) int32 {
  28021 	Xsqlite3Config.FsharedCacheEnabled = enable
  28022 	return SQLITE_OK
  28023 }
  28024 
  28025 func querySharedCacheTableLock(tls *libc.TLS, p uintptr, iTab Pgno, eLock U8) int32 {
  28026 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  28027 	var pIter uintptr
  28028 
  28029 	if !(int32((*Btree)(unsafe.Pointer(p)).Fsharable) != 0) {
  28030 		return SQLITE_OK
  28031 	}
  28032 
  28033 	if (*BtShared)(unsafe.Pointer(pBt)).FpWriter != p && int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_EXCLUSIVE != 0 {
  28034 		Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, (*Btree)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb)
  28035 		return SQLITE_LOCKED | int32(1)<<8
  28036 	}
  28037 
  28038 	for pIter = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pIter != 0; pIter = (*BtLock)(unsafe.Pointer(pIter)).FpNext {
  28039 		if (*BtLock)(unsafe.Pointer(pIter)).FpBtree != p && (*BtLock)(unsafe.Pointer(pIter)).FiTable == iTab && int32((*BtLock)(unsafe.Pointer(pIter)).FeLock) != int32(eLock) {
  28040 			Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, (*Btree)(unsafe.Pointer((*BtLock)(unsafe.Pointer(pIter)).FpBtree)).Fdb)
  28041 			if int32(eLock) == WRITE_LOCK {
  28042 				*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_PENDING)
  28043 			}
  28044 			return SQLITE_LOCKED | int32(1)<<8
  28045 		}
  28046 	}
  28047 	return SQLITE_OK
  28048 }
  28049 
  28050 func setSharedCacheTableLock(tls *libc.TLS, p uintptr, iTable Pgno, eLock U8) int32 {
  28051 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  28052 	var pLock uintptr = uintptr(0)
  28053 	var pIter uintptr
  28054 
  28055 	for pIter = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pIter != 0; pIter = (*BtLock)(unsafe.Pointer(pIter)).FpNext {
  28056 		if (*BtLock)(unsafe.Pointer(pIter)).FiTable == iTable && (*BtLock)(unsafe.Pointer(pIter)).FpBtree == p {
  28057 			pLock = pIter
  28058 			break
  28059 		}
  28060 	}
  28061 
  28062 	if !(pLock != 0) {
  28063 		pLock = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(BtLock{})))
  28064 		if !(pLock != 0) {
  28065 			return SQLITE_NOMEM
  28066 		}
  28067 		(*BtLock)(unsafe.Pointer(pLock)).FiTable = iTable
  28068 		(*BtLock)(unsafe.Pointer(pLock)).FpBtree = p
  28069 		(*BtLock)(unsafe.Pointer(pLock)).FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpLock
  28070 		(*BtShared)(unsafe.Pointer(pBt)).FpLock = pLock
  28071 	}
  28072 
  28073 	if int32(eLock) > int32((*BtLock)(unsafe.Pointer(pLock)).FeLock) {
  28074 		(*BtLock)(unsafe.Pointer(pLock)).FeLock = eLock
  28075 	}
  28076 
  28077 	return SQLITE_OK
  28078 }
  28079 
  28080 func clearAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) {
  28081 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  28082 	var ppIter uintptr = pBt + 76
  28083 
  28084 	for *(*uintptr)(unsafe.Pointer(ppIter)) != 0 {
  28085 		var pLock uintptr = *(*uintptr)(unsafe.Pointer(ppIter))
  28086 
  28087 		if (*BtLock)(unsafe.Pointer(pLock)).FpBtree == p {
  28088 			*(*uintptr)(unsafe.Pointer(ppIter)) = (*BtLock)(unsafe.Pointer(pLock)).FpNext
  28089 
  28090 			if (*BtLock)(unsafe.Pointer(pLock)).FiTable != Pgno(1) {
  28091 				Xsqlite3_free(tls, pLock)
  28092 			}
  28093 		} else {
  28094 			ppIter = pLock + 12
  28095 		}
  28096 	}
  28097 
  28098 	if (*BtShared)(unsafe.Pointer(pBt)).FpWriter == p {
  28099 		(*BtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0)
  28100 		*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_EXCLUSIVE | BTS_PENDING))
  28101 	} else if (*BtShared)(unsafe.Pointer(pBt)).FnTransaction == 2 {
  28102 		*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_PENDING))
  28103 	}
  28104 }
  28105 
  28106 func downgradeAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) {
  28107 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  28108 	if (*BtShared)(unsafe.Pointer(pBt)).FpWriter == p {
  28109 		var pLock uintptr
  28110 		(*BtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0)
  28111 		*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_EXCLUSIVE | BTS_PENDING))
  28112 		for pLock = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pLock != 0; pLock = (*BtLock)(unsafe.Pointer(pLock)).FpNext {
  28113 			(*BtLock)(unsafe.Pointer(pLock)).FeLock = U8(READ_LOCK)
  28114 		}
  28115 	}
  28116 }
  28117 
  28118 func invalidateAllOverflowCache(tls *libc.TLS, pBt uintptr) {
  28119 	var p uintptr
  28120 
  28121 	for p = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext {
  28122 		*(*U8)(unsafe.Pointer(p + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidOvfl))
  28123 	}
  28124 }
  28125 
  28126 func invalidateIncrblobCursors(tls *libc.TLS, pBtree uintptr, pgnoRoot Pgno, iRow I64, isClearTable int32) {
  28127 	var p uintptr
  28128 
  28129 	(*Btree)(unsafe.Pointer(pBtree)).FhasIncrblobCur = U8(0)
  28130 	for p = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext {
  28131 		if int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags)&BTCF_Incrblob != 0 {
  28132 			(*Btree)(unsafe.Pointer(pBtree)).FhasIncrblobCur = U8(1)
  28133 			if (*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == pgnoRoot && (isClearTable != 0 || (*BtCursor)(unsafe.Pointer(p)).Finfo.FnKey == iRow) {
  28134 				(*BtCursor)(unsafe.Pointer(p)).FeState = U8(CURSOR_INVALID)
  28135 			}
  28136 		}
  28137 	}
  28138 }
  28139 
  28140 func btreeSetHasContent(tls *libc.TLS, pBt uintptr, pgno Pgno) int32 {
  28141 	var rc int32 = SQLITE_OK
  28142 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpHasContent) != 0) {
  28143 		(*BtShared)(unsafe.Pointer(pBt)).FpHasContent = Xsqlite3BitvecCreate(tls, (*BtShared)(unsafe.Pointer(pBt)).FnPage)
  28144 		if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpHasContent) != 0) {
  28145 			rc = SQLITE_NOMEM
  28146 		}
  28147 	}
  28148 	if rc == SQLITE_OK && pgno <= Xsqlite3BitvecSize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent) {
  28149 		rc = Xsqlite3BitvecSet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent, pgno)
  28150 	}
  28151 	return rc
  28152 }
  28153 
  28154 func btreeGetHasContent(tls *libc.TLS, pBt uintptr, pgno Pgno) int32 {
  28155 	var p uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpHasContent
  28156 	return libc.Bool32(p != 0 && (pgno > Xsqlite3BitvecSize(tls, p) || Xsqlite3BitvecTestNotNull(tls, p, pgno) != 0))
  28157 }
  28158 
  28159 func btreeClearHasContent(tls *libc.TLS, pBt uintptr) {
  28160 	Xsqlite3BitvecDestroy(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent)
  28161 	(*BtShared)(unsafe.Pointer(pBt)).FpHasContent = uintptr(0)
  28162 }
  28163 
  28164 func btreeReleaseAllCursorPages(tls *libc.TLS, pCur uintptr) {
  28165 	var i int32
  28166 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= 0 {
  28167 		for i = 0; i < int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage); i++ {
  28168 			releasePageNotNull(tls, *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(i)*4)))
  28169 		}
  28170 		releasePageNotNull(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage)
  28171 		(*BtCursor)(unsafe.Pointer(pCur)).FiPage = int8(-1)
  28172 	}
  28173 }
  28174 
  28175 func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 {
  28176 	var rc int32 = SQLITE_OK
  28177 
  28178 	if (*BtCursor)(unsafe.Pointer(pCur)).FcurIntKey != 0 {
  28179 		(*BtCursor)(unsafe.Pointer(pCur)).FnKey = Xsqlite3BtreeIntegerKey(tls, pCur)
  28180 	} else {
  28181 		var pKey uintptr
  28182 		(*BtCursor)(unsafe.Pointer(pCur)).FnKey = I64(Xsqlite3BtreePayloadSize(tls, pCur))
  28183 		pKey = Xsqlite3Malloc(tls, uint64((*BtCursor)(unsafe.Pointer(pCur)).FnKey+int64(9)+int64(8)))
  28184 		if pKey != 0 {
  28185 			rc = Xsqlite3BtreePayload(tls, pCur, uint32(0), uint32(int32((*BtCursor)(unsafe.Pointer(pCur)).FnKey)), pKey)
  28186 			if rc == SQLITE_OK {
  28187 				libc.Xmemset(tls, pKey+uintptr((*BtCursor)(unsafe.Pointer(pCur)).FnKey), 0, uint32(9+8))
  28188 				(*BtCursor)(unsafe.Pointer(pCur)).FpKey = pKey
  28189 			} else {
  28190 				Xsqlite3_free(tls, pKey)
  28191 			}
  28192 		} else {
  28193 			rc = SQLITE_NOMEM
  28194 		}
  28195 	}
  28196 
  28197 	return rc
  28198 }
  28199 
  28200 func saveCursorPosition(tls *libc.TLS, pCur uintptr) int32 {
  28201 	var rc int32
  28202 
  28203 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_Pinned != 0 {
  28204 		return SQLITE_CONSTRAINT | int32(11)<<8
  28205 	}
  28206 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_SKIPNEXT {
  28207 		(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_VALID)
  28208 	} else {
  28209 		(*BtCursor)(unsafe.Pointer(pCur)).FskipNext = 0
  28210 	}
  28211 
  28212 	rc = saveCursorKey(tls, pCur)
  28213 	if rc == SQLITE_OK {
  28214 		btreeReleaseAllCursorPages(tls, pCur)
  28215 		(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_REQUIRESEEK)
  28216 	}
  28217 
  28218 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidNKey | BTCF_ValidOvfl | BTCF_AtLast))
  28219 	return rc
  28220 }
  28221 
  28222 func saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot Pgno, pExcept uintptr) int32 {
  28223 	var p uintptr
  28224 
  28225 	for p = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext {
  28226 		if p != pExcept && (Pgno(0) == iRoot || (*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == iRoot) {
  28227 			break
  28228 		}
  28229 	}
  28230 	if p != 0 {
  28231 		return saveCursorsOnList(tls, p, iRoot, pExcept)
  28232 	}
  28233 	if pExcept != 0 {
  28234 		*(*U8)(unsafe.Pointer(pExcept + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_Multiple))
  28235 	}
  28236 	return SQLITE_OK
  28237 }
  28238 
  28239 func saveCursorsOnList(tls *libc.TLS, p uintptr, iRoot Pgno, pExcept uintptr) int32 {
  28240 	for __ccgo := true; __ccgo; __ccgo = p != 0 {
  28241 		if p != pExcept && (Pgno(0) == iRoot || (*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == iRoot) {
  28242 			if int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID || int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_SKIPNEXT {
  28243 				var rc int32 = saveCursorPosition(tls, p)
  28244 				if SQLITE_OK != rc {
  28245 					return rc
  28246 				}
  28247 			} else {
  28248 				btreeReleaseAllCursorPages(tls, p)
  28249 			}
  28250 		}
  28251 		p = (*BtCursor)(unsafe.Pointer(p)).FpNext
  28252 	}
  28253 	return SQLITE_OK
  28254 }
  28255 
  28256 // Clear the current cursor position.
  28257 func Xsqlite3BtreeClearCursor(tls *libc.TLS, pCur uintptr) {
  28258 	Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey)
  28259 	(*BtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0)
  28260 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  28261 }
  28262 
  28263 func btreeMoveto(tls *libc.TLS, pCur uintptr, pKey uintptr, nKey I64, bias int32, pRes uintptr) int32 {
  28264 	var rc int32
  28265 	var pIdxKey uintptr
  28266 
  28267 	if pKey != 0 {
  28268 		var pKeyInfo uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo
  28269 
  28270 		pIdxKey = Xsqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo)
  28271 		if pIdxKey == uintptr(0) {
  28272 			return SQLITE_NOMEM
  28273 		}
  28274 		Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, int32(nKey), pKey, pIdxKey)
  28275 		if int32((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FnField) == 0 || int32((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FnField) > int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) {
  28276 			rc = Xsqlite3CorruptError(tls, 69253)
  28277 		} else {
  28278 			rc = Xsqlite3BtreeIndexMoveto(tls, pCur, pIdxKey, pRes)
  28279 		}
  28280 		Xsqlite3DbFree(tls, (*KeyInfo1)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo)).Fdb, pIdxKey)
  28281 	} else {
  28282 		pIdxKey = uintptr(0)
  28283 		rc = Xsqlite3BtreeTableMoveto(tls, pCur, nKey, bias, pRes)
  28284 	}
  28285 	return rc
  28286 }
  28287 
  28288 func btreeRestoreCursorPosition(tls *libc.TLS, pCur uintptr) int32 {
  28289 	bp := tls.Alloc(4)
  28290 	defer tls.Free(4)
  28291 
  28292 	var rc int32
  28293 	*(*int32)(unsafe.Pointer(bp)) = 0
  28294 
  28295 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT {
  28296 		return (*BtCursor)(unsafe.Pointer(pCur)).FskipNext
  28297 	}
  28298 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  28299 	if Xsqlite3FaultSim(tls, 410) != 0 {
  28300 		rc = SQLITE_IOERR
  28301 	} else {
  28302 		rc = btreeMoveto(tls, pCur, (*BtCursor)(unsafe.Pointer(pCur)).FpKey, (*BtCursor)(unsafe.Pointer(pCur)).FnKey, 0, bp)
  28303 	}
  28304 	if rc == SQLITE_OK {
  28305 		Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey)
  28306 		(*BtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0)
  28307 
  28308 		if *(*int32)(unsafe.Pointer(bp)) != 0 {
  28309 			(*BtCursor)(unsafe.Pointer(pCur)).FskipNext = *(*int32)(unsafe.Pointer(bp))
  28310 		}
  28311 		if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext != 0 && int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID {
  28312 			(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_SKIPNEXT)
  28313 		}
  28314 	}
  28315 	return rc
  28316 }
  28317 
  28318 // Determine whether or not a cursor has moved from the position where
  28319 // it was last placed, or has been invalidated for any other reason.
  28320 // Cursors can move when the row they are pointing at is deleted out
  28321 // from under them, for example.  Cursor might also move if a btree
  28322 // is rebalanced.
  28323 //
  28324 // Calling this routine with a NULL cursor pointer returns false.
  28325 //
  28326 // Use the separate sqlite3BtreeCursorRestore() routine to restore a cursor
  28327 // back to where it ought to be if this routine returns true.
  28328 func Xsqlite3BtreeCursorHasMoved(tls *libc.TLS, pCur uintptr) int32 {
  28329 	return libc.Bool32(CURSOR_VALID != int32(*(*U8)(unsafe.Pointer(pCur))))
  28330 }
  28331 
  28332 // Return a pointer to a fake BtCursor object that will always answer
  28333 // false to the sqlite3BtreeCursorHasMoved() routine above.  The fake
  28334 // cursor returned must not be used with any other Btree interface.
  28335 func Xsqlite3BtreeFakeValidCursor(tls *libc.TLS) uintptr {
  28336 	return uintptr(unsafe.Pointer(&fakeCursor))
  28337 }
  28338 
  28339 var fakeCursor U8 = U8(CURSOR_VALID)
  28340 
  28341 // This routine restores a cursor back to its original position after it
  28342 // has been moved by some outside activity (such as a btree rebalance or
  28343 // a row having been deleted out from under the cursor).
  28344 //
  28345 // On success, the *pDifferentRow parameter is false if the cursor is left
  28346 // pointing at exactly the same row.  *pDifferntRow is the row the cursor
  28347 // was pointing to has been deleted, forcing the cursor to point to some
  28348 // nearby row.
  28349 //
  28350 // This routine should only be called for a cursor that just returned
  28351 // TRUE from sqlite3BtreeCursorHasMoved().
  28352 func Xsqlite3BtreeCursorRestore(tls *libc.TLS, pCur uintptr, pDifferentRow uintptr) int32 {
  28353 	var rc int32
  28354 
  28355 	rc = func() int32 {
  28356 		if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK {
  28357 			return btreeRestoreCursorPosition(tls, pCur)
  28358 		}
  28359 		return SQLITE_OK
  28360 	}()
  28361 	if rc != 0 {
  28362 		*(*int32)(unsafe.Pointer(pDifferentRow)) = 1
  28363 		return rc
  28364 	}
  28365 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  28366 		*(*int32)(unsafe.Pointer(pDifferentRow)) = 1
  28367 	} else {
  28368 		*(*int32)(unsafe.Pointer(pDifferentRow)) = 0
  28369 	}
  28370 	return SQLITE_OK
  28371 }
  28372 
  28373 // Provide flag hints to the cursor.
  28374 func Xsqlite3BtreeCursorHintFlags(tls *libc.TLS, pCur uintptr, x uint32) {
  28375 	(*BtCursor)(unsafe.Pointer(pCur)).Fhints = U8(x)
  28376 }
  28377 
  28378 func ptrmapPageno(tls *libc.TLS, pBt uintptr, pgno Pgno) Pgno {
  28379 	var nPagesPerMapPage int32
  28380 	var iPtrMap Pgno
  28381 	var ret Pgno
  28382 
  28383 	if pgno < Pgno(2) {
  28384 		return Pgno(0)
  28385 	}
  28386 	nPagesPerMapPage = int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize/U32(5) + U32(1))
  28387 	iPtrMap = (pgno - Pgno(2)) / Pgno(nPagesPerMapPage)
  28388 	ret = iPtrMap*Pgno(nPagesPerMapPage) + Pgno(2)
  28389 	if ret == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  28390 		ret++
  28391 	}
  28392 	return ret
  28393 }
  28394 
  28395 func ptrmapPut(tls *libc.TLS, pBt uintptr, key Pgno, eType U8, parent Pgno, pRC uintptr) {
  28396 	bp := tls.Alloc(4)
  28397 	defer tls.Free(4)
  28398 
  28399 	var pPtrmap uintptr
  28400 	var iPtrmap Pgno
  28401 	var offset int32
  28402 	var rc int32
  28403 
  28404 	if !(*(*int32)(unsafe.Pointer(pRC)) != 0) {
  28405 		goto __1
  28406 	}
  28407 	return
  28408 __1:
  28409 	;
  28410 	if !(key == Pgno(0)) {
  28411 		goto __2
  28412 	}
  28413 	*(*int32)(unsafe.Pointer(pRC)) = Xsqlite3CorruptError(tls, 69434)
  28414 	return
  28415 __2:
  28416 	;
  28417 	iPtrmap = ptrmapPageno(tls, pBt, key)
  28418 	rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, iPtrmap, bp, 0)
  28419 	if !(rc != SQLITE_OK) {
  28420 		goto __3
  28421 	}
  28422 	*(*int32)(unsafe.Pointer(pRC)) = rc
  28423 	return
  28424 __3:
  28425 	;
  28426 	if !(int32(*(*uint8)(unsafe.Pointer(Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp)))))) != 0) {
  28427 		goto __4
  28428 	}
  28429 
  28430 	*(*int32)(unsafe.Pointer(pRC)) = Xsqlite3CorruptError(tls, 69447)
  28431 	goto ptrmap_exit
  28432 __4:
  28433 	;
  28434 	offset = int32(Pgno(5) * (key - iPtrmap - Pgno(1)))
  28435 	if !(offset < 0) {
  28436 		goto __5
  28437 	}
  28438 	*(*int32)(unsafe.Pointer(pRC)) = Xsqlite3CorruptError(tls, 69452)
  28439 	goto ptrmap_exit
  28440 __5:
  28441 	;
  28442 	pPtrmap = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp)))
  28443 
  28444 	if !(int32(eType) != int32(*(*U8)(unsafe.Pointer(pPtrmap + uintptr(offset)))) || Xsqlite3Get4byte(tls, pPtrmap+uintptr(offset+1)) != parent) {
  28445 		goto __6
  28446 	}
  28447 
  28448 	*(*int32)(unsafe.Pointer(pRC)) = libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp))))
  28449 	if !(rc == SQLITE_OK) {
  28450 		goto __7
  28451 	}
  28452 	*(*U8)(unsafe.Pointer(pPtrmap + uintptr(offset))) = eType
  28453 	Xsqlite3Put4byte(tls, pPtrmap+uintptr(offset+1), parent)
  28454 __7:
  28455 	;
  28456 __6:
  28457 	;
  28458 ptrmap_exit:
  28459 	Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  28460 }
  28461 
  28462 func ptrmapGet(tls *libc.TLS, pBt uintptr, key Pgno, pEType uintptr, pPgno uintptr) int32 {
  28463 	bp := tls.Alloc(4)
  28464 	defer tls.Free(4)
  28465 
  28466 	var iPtrmap int32
  28467 	var pPtrmap uintptr
  28468 	var offset int32
  28469 	var rc int32
  28470 
  28471 	iPtrmap = int32(ptrmapPageno(tls, pBt, key))
  28472 	rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, uint32(iPtrmap), bp, 0)
  28473 	if rc != 0 {
  28474 		return rc
  28475 	}
  28476 	pPtrmap = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp)))
  28477 
  28478 	offset = int32(Pgno(5) * (key - Pgno(iPtrmap) - Pgno(1)))
  28479 	if offset < 0 {
  28480 		Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  28481 		return Xsqlite3CorruptError(tls, 69497)
  28482 	}
  28483 
  28484 	*(*U8)(unsafe.Pointer(pEType)) = *(*U8)(unsafe.Pointer(pPtrmap + uintptr(offset)))
  28485 	if pPgno != 0 {
  28486 		*(*Pgno)(unsafe.Pointer(pPgno)) = Xsqlite3Get4byte(tls, pPtrmap+uintptr(offset+1))
  28487 	}
  28488 
  28489 	Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  28490 	if int32(*(*U8)(unsafe.Pointer(pEType))) < 1 || int32(*(*U8)(unsafe.Pointer(pEType))) > 5 {
  28491 		return Xsqlite3CorruptError(tls, 69505)
  28492 	}
  28493 	return SQLITE_OK
  28494 }
  28495 
  28496 func btreeParseCellAdjustSizeForOverflow(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) {
  28497 	var minLocal int32
  28498 	var maxLocal int32
  28499 	var surplus int32
  28500 
  28501 	minLocal = int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)
  28502 	maxLocal = int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal)
  28503 	surplus = int32(U32(minLocal) + ((*CellInfo)(unsafe.Pointer(pInfo)).FnPayload-U32(minLocal))%((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-U32(4)))
  28504 
  28505 	if surplus <= maxLocal {
  28506 		(*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(surplus)
  28507 	} else {
  28508 		(*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(minLocal)
  28509 	}
  28510 	(*CellInfo)(unsafe.Pointer(pInfo)).FnSize = U16(int32(U16((int32((*CellInfo)(unsafe.Pointer(pInfo)).FpPayload+uintptr((*CellInfo)(unsafe.Pointer(pInfo)).FnLocal))-int32(pCell))/1)) + 4)
  28511 }
  28512 
  28513 func btreePayloadToLocal(tls *libc.TLS, pPage uintptr, nPayload I64) int32 {
  28514 	var maxLocal int32
  28515 	maxLocal = int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal)
  28516 	if nPayload <= I64(maxLocal) {
  28517 		return int32(nPayload)
  28518 	} else {
  28519 		var minLocal int32
  28520 		var surplus int32
  28521 		minLocal = int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)
  28522 		surplus = int32(I64(minLocal) + (nPayload-I64(minLocal))%I64((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-U32(4)))
  28523 		if surplus <= maxLocal {
  28524 			return surplus
  28525 		}
  28526 		return minLocal
  28527 	}
  28528 	return int32(0)
  28529 }
  28530 
  28531 func btreeParseCellPtrNoPayload(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) {
  28532 	_ = pPage
  28533 	(*CellInfo)(unsafe.Pointer(pInfo)).FnSize = U16(4 + int32(Xsqlite3GetVarint(tls, pCell+4, pInfo)))
  28534 	(*CellInfo)(unsafe.Pointer(pInfo)).FnPayload = U32(0)
  28535 	(*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(0)
  28536 	(*CellInfo)(unsafe.Pointer(pInfo)).FpPayload = uintptr(0)
  28537 	return
  28538 }
  28539 
  28540 func btreeParseCellPtr(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) {
  28541 	bp := tls.Alloc(8)
  28542 	defer tls.Free(8)
  28543 
  28544 	var pIter uintptr
  28545 	var nPayload U32
  28546 
  28547 	pIter = pCell
  28548 
  28549 	nPayload = U32(*(*U8)(unsafe.Pointer(pIter)))
  28550 	if nPayload >= U32(0x80) {
  28551 		var pEnd uintptr = pIter + 8
  28552 		nPayload = nPayload & U32(0x7f)
  28553 		for __ccgo := true; __ccgo; __ccgo = int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80 && pIter < pEnd {
  28554 			nPayload = nPayload<<7 | U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1))))&0x7f)
  28555 		}
  28556 	}
  28557 	pIter++
  28558 
  28559 	*(*U64)(unsafe.Pointer(bp)) = U64(*(*U8)(unsafe.Pointer(pIter)))
  28560 	if *(*U64)(unsafe.Pointer(bp)) >= uint64(0x80) {
  28561 		var x U8
  28562 		*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))&uint64(0x7f)<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28563 		if int32(x) >= 0x80 {
  28564 			*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28565 			if int32(x) >= 0x80 {
  28566 				*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28567 				if int32(x) >= 0x80 {
  28568 					*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28569 					if int32(x) >= 0x80 {
  28570 						*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28571 						if int32(x) >= 0x80 {
  28572 							*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28573 							if int32(x) >= 0x80 {
  28574 								*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<7 | U64(int32(libc.AssignUint8(&x, *(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))))&0x7f)
  28575 								if int32(x) >= 0x80 {
  28576 									*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<8 | U64(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1))))
  28577 								}
  28578 							}
  28579 						}
  28580 					}
  28581 				}
  28582 			}
  28583 		}
  28584 	}
  28585 	pIter++
  28586 
  28587 	(*CellInfo)(unsafe.Pointer(pInfo)).FnKey = *(*I64)(unsafe.Pointer(bp))
  28588 	(*CellInfo)(unsafe.Pointer(pInfo)).FnPayload = nPayload
  28589 	(*CellInfo)(unsafe.Pointer(pInfo)).FpPayload = pIter
  28590 
  28591 	if nPayload <= U32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  28592 		(*CellInfo)(unsafe.Pointer(pInfo)).FnSize = U16(nPayload + U32(U16((int32(pIter)-int32(pCell))/1)))
  28593 		if int32((*CellInfo)(unsafe.Pointer(pInfo)).FnSize) < 4 {
  28594 			(*CellInfo)(unsafe.Pointer(pInfo)).FnSize = U16(4)
  28595 		}
  28596 		(*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(nPayload)
  28597 	} else {
  28598 		btreeParseCellAdjustSizeForOverflow(tls, pPage, pCell, pInfo)
  28599 	}
  28600 }
  28601 
  28602 func btreeParseCellPtrIndex(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) {
  28603 	var pIter uintptr
  28604 	var nPayload U32
  28605 
  28606 	pIter = pCell + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)
  28607 	nPayload = U32(*(*U8)(unsafe.Pointer(pIter)))
  28608 	if nPayload >= U32(0x80) {
  28609 		var pEnd uintptr = pIter + 8
  28610 		nPayload = nPayload & U32(0x7f)
  28611 		for __ccgo := true; __ccgo; __ccgo = int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80 && pIter < pEnd {
  28612 			nPayload = nPayload<<7 | U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1))))&0x7f)
  28613 		}
  28614 	}
  28615 	pIter++
  28616 	(*CellInfo)(unsafe.Pointer(pInfo)).FnKey = I64(nPayload)
  28617 	(*CellInfo)(unsafe.Pointer(pInfo)).FnPayload = nPayload
  28618 	(*CellInfo)(unsafe.Pointer(pInfo)).FpPayload = pIter
  28619 
  28620 	if nPayload <= U32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  28621 		(*CellInfo)(unsafe.Pointer(pInfo)).FnSize = U16(nPayload + U32(U16((int32(pIter)-int32(pCell))/1)))
  28622 		if int32((*CellInfo)(unsafe.Pointer(pInfo)).FnSize) < 4 {
  28623 			(*CellInfo)(unsafe.Pointer(pInfo)).FnSize = U16(4)
  28624 		}
  28625 		(*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(nPayload)
  28626 	} else {
  28627 		btreeParseCellAdjustSizeForOverflow(tls, pPage, pCell, pInfo)
  28628 	}
  28629 }
  28630 
  28631 func btreeParseCell(tls *libc.TLS, pPage uintptr, iCell int32, pInfo uintptr) {
  28632 	(*struct {
  28633 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  28634 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*iCell)))))), pInfo)
  28635 }
  28636 
  28637 func cellSizePtr(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 {
  28638 	var pIter uintptr = pCell + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)
  28639 	var pEnd uintptr
  28640 	var nSize U32
  28641 
  28642 	nSize = U32(*(*U8)(unsafe.Pointer(pIter)))
  28643 	if nSize >= U32(0x80) {
  28644 		pEnd = pIter + 8
  28645 		nSize = nSize & U32(0x7f)
  28646 		for __ccgo := true; __ccgo; __ccgo = int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80 && pIter < pEnd {
  28647 			nSize = nSize<<7 | U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1))))&0x7f)
  28648 		}
  28649 	}
  28650 	pIter++
  28651 
  28652 	if nSize <= U32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  28653 		nSize = nSize + U32((int32(pIter)-int32(pCell))/1)
  28654 		if nSize < U32(4) {
  28655 			nSize = U32(4)
  28656 		}
  28657 	} else {
  28658 		var minLocal int32 = int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)
  28659 		nSize = U32(minLocal) + (nSize-U32(minLocal))%((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-U32(4))
  28660 
  28661 		if nSize > U32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  28662 			nSize = U32(minLocal)
  28663 		}
  28664 		nSize = nSize + U32(4+int32(U16((int32(pIter)-int32(pCell))/1)))
  28665 	}
  28666 
  28667 	return U16(nSize)
  28668 }
  28669 
  28670 func cellSizePtrNoPayload(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 {
  28671 	var pIter uintptr = pCell + uintptr(4)
  28672 	var pEnd uintptr
  28673 
  28674 	_ = pPage
  28675 
  28676 	pEnd = pIter + uintptr(9)
  28677 	for int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 && pIter < pEnd {
  28678 	}
  28679 
  28680 	return U16((int32(pIter) - int32(pCell)) / 1)
  28681 }
  28682 
  28683 func cellSizePtrTableLeaf(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 {
  28684 	var pIter uintptr = pCell
  28685 	var pEnd uintptr
  28686 	var nSize U32
  28687 
  28688 	nSize = U32(*(*U8)(unsafe.Pointer(pIter)))
  28689 	if nSize >= U32(0x80) {
  28690 		pEnd = pIter + 8
  28691 		nSize = nSize & U32(0x7f)
  28692 		for __ccgo := true; __ccgo; __ccgo = int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80 && pIter < pEnd {
  28693 			nSize = nSize<<7 | U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1))))&0x7f)
  28694 		}
  28695 	}
  28696 	pIter++
  28697 
  28698 	if int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28699 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28700 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28701 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28702 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28703 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28704 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 &&
  28705 		int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))&0x80 != 0 {
  28706 		pIter++
  28707 	}
  28708 
  28709 	if nSize <= U32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  28710 		nSize = nSize + U32((int32(pIter)-int32(pCell))/1)
  28711 		if nSize < U32(4) {
  28712 			nSize = U32(4)
  28713 		}
  28714 	} else {
  28715 		var minLocal int32 = int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)
  28716 		nSize = U32(minLocal) + (nSize-U32(minLocal))%((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-U32(4))
  28717 
  28718 		if nSize > U32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  28719 			nSize = U32(minLocal)
  28720 		}
  28721 		nSize = nSize + U32(4+int32(U16((int32(pIter)-int32(pCell))/1)))
  28722 	}
  28723 
  28724 	return U16(nSize)
  28725 }
  28726 
  28727 func ptrmapPutOvflPtr(tls *libc.TLS, pPage uintptr, pSrc uintptr, pCell uintptr, pRC uintptr) {
  28728 	bp := tls.Alloc(24)
  28729 	defer tls.Free(24)
  28730 
  28731 	if *(*int32)(unsafe.Pointer(pRC)) != 0 {
  28732 		return
  28733 	}
  28734 
  28735 	(*struct {
  28736 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  28737 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, pCell, bp)
  28738 	if U32((*CellInfo)(unsafe.Pointer(bp)).FnLocal) < (*CellInfo)(unsafe.Pointer(bp)).FnPayload {
  28739 		var ovfl Pgno
  28740 		if Uptr((*MemPage)(unsafe.Pointer(pSrc)).FaDataEnd) >= Uptr(pCell) && Uptr((*MemPage)(unsafe.Pointer(pSrc)).FaDataEnd) < Uptr(pCell+uintptr((*CellInfo)(unsafe.Pointer(bp)).FnLocal)) {
  28741 			*(*int32)(unsafe.Pointer(pRC)) = Xsqlite3CorruptError(tls, 69897)
  28742 			return
  28743 		}
  28744 		ovfl = Xsqlite3Get4byte(tls, pCell+uintptr(int32((*CellInfo)(unsafe.Pointer(bp)).FnSize)-4))
  28745 		ptrmapPut(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, ovfl, uint8(PTRMAP_OVERFLOW1), (*MemPage)(unsafe.Pointer(pPage)).Fpgno, pRC)
  28746 	}
  28747 }
  28748 
  28749 func defragmentPage(tls *libc.TLS, pPage uintptr, nMaxFrag int32) int32 {
  28750 	var i int32
  28751 	var pc int32
  28752 	var hdr int32
  28753 	var size int32
  28754 	var usableSize int32
  28755 	var cellOffset int32
  28756 	var cbrk int32
  28757 	var nCell int32
  28758 	var data uintptr
  28759 	var temp uintptr
  28760 	var src uintptr
  28761 	var iCellFirst int32
  28762 	var iCellLast int32
  28763 	var iCellStart int32
  28764 	var pEnd uintptr
  28765 	var pAddr uintptr
  28766 	var sz2 int32
  28767 	var sz int32
  28768 	var top int32
  28769 	var iFree2 int32
  28770 	var iFree int32
  28771 	var pAddr1 uintptr
  28772 
  28773 	data = (*MemPage)(unsafe.Pointer(pPage)).FaData
  28774 	hdr = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)
  28775 	cellOffset = int32((*MemPage)(unsafe.Pointer(pPage)).FcellOffset)
  28776 	nCell = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  28777 
  28778 	iCellFirst = cellOffset + 2*nCell
  28779 	usableSize = int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize)
  28780 
  28781 	if !(int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+7)))) <= nMaxFrag) {
  28782 		goto __1
  28783 	}
  28784 	iFree = int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+1))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+1) + 1)))
  28785 	if !(iFree > usableSize-4) {
  28786 		goto __2
  28787 	}
  28788 	return Xsqlite3CorruptError(tls, 69955)
  28789 __2:
  28790 	;
  28791 	if !(iFree != 0) {
  28792 		goto __3
  28793 	}
  28794 	iFree2 = int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree) + 1)))
  28795 	if !(iFree2 > usableSize-4) {
  28796 		goto __4
  28797 	}
  28798 	return Xsqlite3CorruptError(tls, 69958)
  28799 __4:
  28800 	;
  28801 	if !(0 == iFree2 || int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree2)))) == 0 && int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree2+1)))) == 0) {
  28802 		goto __5
  28803 	}
  28804 	pEnd = data + uintptr(cellOffset+nCell*2)
  28805 	sz2 = 0
  28806 	sz = int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree+2))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree+2) + 1)))
  28807 	top = int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+5))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)))
  28808 	if !(top >= iFree) {
  28809 		goto __6
  28810 	}
  28811 	return Xsqlite3CorruptError(tls, 69966)
  28812 __6:
  28813 	;
  28814 	if !(iFree2 != 0) {
  28815 		goto __7
  28816 	}
  28817 	if !(iFree+sz > iFree2) {
  28818 		goto __9
  28819 	}
  28820 	return Xsqlite3CorruptError(tls, 69969)
  28821 __9:
  28822 	;
  28823 	sz2 = int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree2+2))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFree2+2) + 1)))
  28824 	if !(iFree2+sz2 > usableSize) {
  28825 		goto __10
  28826 	}
  28827 	return Xsqlite3CorruptError(tls, 69971)
  28828 __10:
  28829 	;
  28830 	libc.Xmemmove(tls, data+uintptr(iFree+sz+sz2), data+uintptr(iFree+sz), uint32(iFree2-(iFree+sz)))
  28831 	sz = sz + sz2
  28832 	goto __8
  28833 __7:
  28834 	if !(iFree+sz > usableSize) {
  28835 		goto __11
  28836 	}
  28837 	return Xsqlite3CorruptError(tls, 69975)
  28838 __11:
  28839 	;
  28840 __8:
  28841 	;
  28842 	cbrk = top + sz
  28843 
  28844 	libc.Xmemmove(tls, data+uintptr(cbrk), data+uintptr(top), uint32(iFree-top))
  28845 	pAddr = data + uintptr(cellOffset)
  28846 __12:
  28847 	if !(pAddr < pEnd) {
  28848 		goto __14
  28849 	}
  28850 	pc = int32(*(*U8)(unsafe.Pointer(pAddr)))<<8 | int32(*(*U8)(unsafe.Pointer(pAddr + 1)))
  28851 	if !(pc < iFree) {
  28852 		goto __15
  28853 	}
  28854 	*(*U8)(unsafe.Pointer(pAddr)) = U8((pc + sz) >> 8)
  28855 	*(*U8)(unsafe.Pointer(pAddr + 1)) = U8(pc + sz)
  28856 	goto __16
  28857 __15:
  28858 	if !(pc < iFree2) {
  28859 		goto __17
  28860 	}
  28861 	*(*U8)(unsafe.Pointer(pAddr)) = U8((pc + sz2) >> 8)
  28862 	*(*U8)(unsafe.Pointer(pAddr + 1)) = U8(pc + sz2)
  28863 __17:
  28864 	;
  28865 __16:
  28866 	;
  28867 	goto __13
  28868 __13:
  28869 	pAddr += uintptr(2)
  28870 	goto __12
  28871 	goto __14
  28872 __14:
  28873 	;
  28874 	goto defragment_out
  28875 __5:
  28876 	;
  28877 __3:
  28878 	;
  28879 __1:
  28880 	;
  28881 	cbrk = usableSize
  28882 	iCellLast = usableSize - 4
  28883 	iCellStart = int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+5))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)))
  28884 	if !(nCell > 0) {
  28885 		goto __18
  28886 	}
  28887 	temp = Xsqlite3PagerTempSpace(tls, (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FpPager)
  28888 	libc.Xmemcpy(tls, temp+uintptr(iCellStart), data+uintptr(iCellStart), uint32(usableSize-iCellStart))
  28889 	src = temp
  28890 	i = 0
  28891 __19:
  28892 	if !(i < nCell) {
  28893 		goto __21
  28894 	}
  28895 	pAddr1 = data + uintptr(cellOffset+i*2)
  28896 	pc = int32(*(*U8)(unsafe.Pointer(pAddr1)))<<8 | int32(*(*U8)(unsafe.Pointer(pAddr1 + 1)))
  28897 
  28898 	if !(pc < iCellStart || pc > iCellLast) {
  28899 		goto __22
  28900 	}
  28901 	return Xsqlite3CorruptError(tls, 70008)
  28902 __22:
  28903 	;
  28904 	size = int32((*struct {
  28905 		f func(*libc.TLS, uintptr, uintptr) U16
  28906 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxCellSize})).f(tls, pPage, src+uintptr(pc)))
  28907 	cbrk = cbrk - size
  28908 	if !(cbrk < iCellStart || pc+size > usableSize) {
  28909 		goto __23
  28910 	}
  28911 	return Xsqlite3CorruptError(tls, 70014)
  28912 __23:
  28913 	;
  28914 	*(*U8)(unsafe.Pointer(pAddr1)) = U8(cbrk >> 8)
  28915 	*(*U8)(unsafe.Pointer(pAddr1 + 1)) = U8(cbrk)
  28916 	libc.Xmemcpy(tls, data+uintptr(cbrk), src+uintptr(pc), uint32(size))
  28917 	goto __20
  28918 __20:
  28919 	i++
  28920 	goto __19
  28921 	goto __21
  28922 __21:
  28923 	;
  28924 __18:
  28925 	;
  28926 	*(*uint8)(unsafe.Pointer(data + uintptr(hdr+7))) = uint8(0)
  28927 
  28928 defragment_out:
  28929 	;
  28930 	if !(int32(*(*uint8)(unsafe.Pointer(data + uintptr(hdr+7))))+cbrk-iCellFirst != (*MemPage)(unsafe.Pointer(pPage)).FnFree) {
  28931 		goto __24
  28932 	}
  28933 	return Xsqlite3CorruptError(tls, 70028)
  28934 __24:
  28935 	;
  28936 	*(*uint8)(unsafe.Pointer(data + uintptr(hdr+5))) = U8(cbrk >> 8)
  28937 	*(*uint8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)) = U8(cbrk)
  28938 	*(*uint8)(unsafe.Pointer(data + uintptr(hdr+1))) = uint8(0)
  28939 	*(*uint8)(unsafe.Pointer(data + uintptr(hdr+2))) = uint8(0)
  28940 	libc.Xmemset(tls, data+uintptr(iCellFirst), 0, uint32(cbrk-iCellFirst))
  28941 
  28942 	return SQLITE_OK
  28943 }
  28944 
  28945 func pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) uintptr {
  28946 	var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset)
  28947 	var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData
  28948 	var iAddr int32 = hdr + 1
  28949 	var pTmp uintptr = aData + uintptr(iAddr)
  28950 	var pc int32 = int32(*(*U8)(unsafe.Pointer(pTmp)))<<8 | int32(*(*U8)(unsafe.Pointer(pTmp + 1)))
  28951 	var x int32
  28952 	var maxPC int32 = int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize - U32(nByte))
  28953 	var size int32
  28954 
  28955 	for pc <= maxPC {
  28956 		pTmp = aData + uintptr(pc+2)
  28957 		size = int32(*(*U8)(unsafe.Pointer(pTmp)))<<8 | int32(*(*U8)(unsafe.Pointer(pTmp + 1)))
  28958 		if libc.AssignInt32(&x, size-nByte) >= 0 {
  28959 			if x < 4 {
  28960 				if int32(*(*U8)(unsafe.Pointer(aData + uintptr(hdr+7)))) > 57 {
  28961 					return uintptr(0)
  28962 				}
  28963 
  28964 				libc.Xmemcpy(tls, aData+uintptr(iAddr), aData+uintptr(pc), uint32(2))
  28965 				*(*U8)(unsafe.Pointer(aData + uintptr(hdr+7))) += U8(int32(U8(x)))
  28966 				return aData + uintptr(pc)
  28967 			} else if x+pc > maxPC {
  28968 				*(*int32)(unsafe.Pointer(pRc)) = Xsqlite3CorruptError(tls, 70085)
  28969 				return uintptr(0)
  28970 			} else {
  28971 				*(*U8)(unsafe.Pointer(aData + uintptr(pc+2))) = U8(x >> 8)
  28972 				*(*U8)(unsafe.Pointer(aData + uintptr(pc+2) + 1)) = U8(x)
  28973 			}
  28974 			return aData + uintptr(pc+x)
  28975 		}
  28976 		iAddr = pc
  28977 		pTmp = aData + uintptr(pc)
  28978 		pc = int32(*(*U8)(unsafe.Pointer(pTmp)))<<8 | int32(*(*U8)(unsafe.Pointer(pTmp + 1)))
  28979 		if pc <= iAddr {
  28980 			if pc != 0 {
  28981 				*(*int32)(unsafe.Pointer(pRc)) = Xsqlite3CorruptError(tls, 70100)
  28982 			}
  28983 			return uintptr(0)
  28984 		}
  28985 	}
  28986 	if pc > maxPC+nByte-4 {
  28987 		*(*int32)(unsafe.Pointer(pRc)) = Xsqlite3CorruptError(tls, 70107)
  28988 	}
  28989 	return uintptr(0)
  28990 }
  28991 
  28992 func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int32 {
  28993 	bp := tls.Alloc(4)
  28994 	defer tls.Free(4)
  28995 
  28996 	var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)
  28997 	var data uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData
  28998 	var top int32
  28999 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
  29000 	var pTmp uintptr
  29001 	var gap int32
  29002 
  29003 	gap = int32((*MemPage)(unsafe.Pointer(pPage)).FcellOffset) + 2*int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  29004 
  29005 	pTmp = data + uintptr(hdr+5)
  29006 	top = int32(*(*U8)(unsafe.Pointer(pTmp)))<<8 | int32(*(*U8)(unsafe.Pointer(pTmp + 1)))
  29007 
  29008 	if gap > top {
  29009 		if top == 0 && (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize == U32(65536) {
  29010 			top = 65536
  29011 		} else {
  29012 			return Xsqlite3CorruptError(tls, 70156)
  29013 		}
  29014 	}
  29015 
  29016 	if (*(*U8)(unsafe.Pointer(data + uintptr(hdr+2))) != 0 || *(*U8)(unsafe.Pointer(data + uintptr(hdr+1))) != 0) && gap+2 <= top {
  29017 		var pSpace uintptr = pageFindSlot(tls, pPage, nByte, bp)
  29018 		if pSpace != 0 {
  29019 			var g2 int32
  29020 
  29021 			*(*int32)(unsafe.Pointer(pIdx)) = libc.AssignInt32(&g2, (int32(pSpace)-int32(data))/1)
  29022 			if g2 <= gap {
  29023 				return Xsqlite3CorruptError(tls, 70174)
  29024 			} else {
  29025 				return SQLITE_OK
  29026 			}
  29027 		} else if *(*int32)(unsafe.Pointer(bp)) != 0 {
  29028 			return *(*int32)(unsafe.Pointer(bp))
  29029 		}
  29030 	}
  29031 
  29032 	if gap+2+nByte > top {
  29033 		*(*int32)(unsafe.Pointer(bp)) = defragmentPage(tls, pPage, func() int32 {
  29034 			if 4 < (*MemPage)(unsafe.Pointer(pPage)).FnFree-(2+nByte) {
  29035 				return 4
  29036 			}
  29037 			return (*MemPage)(unsafe.Pointer(pPage)).FnFree - (2 + nByte)
  29038 		}())
  29039 		if *(*int32)(unsafe.Pointer(bp)) != 0 {
  29040 			return *(*int32)(unsafe.Pointer(bp))
  29041 		}
  29042 		top = (int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+5))))<<8|int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)))-1)&0xffff + 1
  29043 
  29044 	}
  29045 
  29046 	top = top - nByte
  29047 	*(*U8)(unsafe.Pointer(data + uintptr(hdr+5))) = U8(top >> 8)
  29048 	*(*U8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)) = U8(top)
  29049 
  29050 	*(*int32)(unsafe.Pointer(pIdx)) = top
  29051 	return SQLITE_OK
  29052 }
  29053 
  29054 func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 {
  29055 	var iPtr U16
  29056 	var iFreeBlk U16
  29057 	var hdr U8
  29058 	var nFrag U8 = U8(0)
  29059 	var iOrigSize U16 = iSize
  29060 	var x U16
  29061 	var iEnd U32 = U32(int32(iStart) + int32(iSize))
  29062 	var data uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData
  29063 	var pTmp uintptr
  29064 
  29065 	hdr = (*MemPage)(unsafe.Pointer(pPage)).FhdrOffset
  29066 	iPtr = U16(int32(hdr) + 1)
  29067 	if int32(*(*uint8)(unsafe.Pointer(data + uintptr(int32(iPtr)+1)))) == 0 && int32(*(*uint8)(unsafe.Pointer(data + uintptr(iPtr)))) == 0 {
  29068 		iFreeBlk = U16(0)
  29069 	} else {
  29070 		for int32(libc.AssignUint16(&iFreeBlk, U16(int32(*(*uint8)(unsafe.Pointer(data + uintptr(iPtr))))<<8|int32(*(*uint8)(unsafe.Pointer(data + uintptr(iPtr) + 1)))))) < int32(iStart) {
  29071 			if int32(iFreeBlk) <= int32(iPtr) {
  29072 				if int32(iFreeBlk) == 0 {
  29073 					break
  29074 				}
  29075 				return Xsqlite3CorruptError(tls, 70253)
  29076 			}
  29077 			iPtr = iFreeBlk
  29078 		}
  29079 		if U32(iFreeBlk) > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-U32(4) {
  29080 			return Xsqlite3CorruptError(tls, 70258)
  29081 		}
  29082 
  29083 		if iFreeBlk != 0 && iEnd+U32(3) >= U32(iFreeBlk) {
  29084 			nFrag = U8(U32(iFreeBlk) - iEnd)
  29085 			if iEnd > U32(iFreeBlk) {
  29086 				return Xsqlite3CorruptError(tls, 70270)
  29087 			}
  29088 			iEnd = U32(int32(iFreeBlk) + (int32(*(*uint8)(unsafe.Pointer(data + uintptr(int32(iFreeBlk)+2))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(int32(iFreeBlk)+2) + 1)))))
  29089 			if iEnd > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize {
  29090 				return Xsqlite3CorruptError(tls, 70273)
  29091 			}
  29092 			iSize = U16(iEnd - U32(iStart))
  29093 			iFreeBlk = U16(int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFreeBlk))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(iFreeBlk) + 1))))
  29094 		}
  29095 
  29096 		if int32(iPtr) > int32(hdr)+1 {
  29097 			var iPtrEnd int32 = int32(iPtr) + (int32(*(*uint8)(unsafe.Pointer(data + uintptr(int32(iPtr)+2))))<<8 | int32(*(*uint8)(unsafe.Pointer(data + uintptr(int32(iPtr)+2) + 1))))
  29098 			if iPtrEnd+3 >= int32(iStart) {
  29099 				if iPtrEnd > int32(iStart) {
  29100 					return Xsqlite3CorruptError(tls, 70286)
  29101 				}
  29102 				nFrag = U8(int32(nFrag) + (int32(iStart) - iPtrEnd))
  29103 				iSize = U16(iEnd - U32(iPtr))
  29104 				iStart = iPtr
  29105 			}
  29106 		}
  29107 		if int32(nFrag) > int32(*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+7)))) {
  29108 			return Xsqlite3CorruptError(tls, 70292)
  29109 		}
  29110 		*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+7))) -= uint8(int32(nFrag))
  29111 	}
  29112 	pTmp = data + uintptr(int32(hdr)+5)
  29113 	x = U16(int32(*(*U8)(unsafe.Pointer(pTmp)))<<8 | int32(*(*U8)(unsafe.Pointer(pTmp + 1))))
  29114 	if int32(iStart) <= int32(x) {
  29115 		if int32(iStart) < int32(x) {
  29116 			return Xsqlite3CorruptError(tls, 70301)
  29117 		}
  29118 		if int32(iPtr) != int32(hdr)+1 {
  29119 			return Xsqlite3CorruptError(tls, 70302)
  29120 		}
  29121 		*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+1))) = U8(int32(iFreeBlk) >> 8)
  29122 		*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+1) + 1)) = U8(iFreeBlk)
  29123 		*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+5))) = U8(iEnd >> 8)
  29124 		*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+5) + 1)) = U8(iEnd)
  29125 	} else {
  29126 		*(*uint8)(unsafe.Pointer(data + uintptr(iPtr))) = U8(int32(iStart) >> 8)
  29127 		*(*uint8)(unsafe.Pointer(data + uintptr(iPtr) + 1)) = U8(iStart)
  29128 	}
  29129 	if int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FbtsFlags)&BTS_FAST_SECURE != 0 {
  29130 		libc.Xmemset(tls, data+uintptr(iStart), 0, uint32(iSize))
  29131 	}
  29132 	*(*uint8)(unsafe.Pointer(data + uintptr(iStart))) = U8(int32(iFreeBlk) >> 8)
  29133 	*(*uint8)(unsafe.Pointer(data + uintptr(iStart) + 1)) = U8(iFreeBlk)
  29134 	*(*uint8)(unsafe.Pointer(data + uintptr(int32(iStart)+2))) = U8(int32(iSize) >> 8)
  29135 	*(*uint8)(unsafe.Pointer(data + uintptr(int32(iStart)+2) + 1)) = U8(iSize)
  29136 	*(*int32)(unsafe.Pointer(pPage + 20)) += int32(iOrigSize)
  29137 	return SQLITE_OK
  29138 }
  29139 
  29140 func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 {
  29141 	var pBt uintptr
  29142 
  29143 	pBt = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  29144 	(*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload = (*BtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload
  29145 	if flagByte >= PTF_ZERODATA|PTF_LEAF {
  29146 		(*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize = U8(0)
  29147 		(*MemPage)(unsafe.Pointer(pPage)).Fleaf = U8(1)
  29148 		if flagByte == PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF {
  29149 			(*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = U8(1)
  29150 			(*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct {
  29151 				f func(*libc.TLS, uintptr, uintptr) U16
  29152 			}{cellSizePtrTableLeaf}))
  29153 			(*MemPage)(unsafe.Pointer(pPage)).FxParseCell = *(*uintptr)(unsafe.Pointer(&struct {
  29154 				f func(*libc.TLS, uintptr, uintptr, uintptr)
  29155 			}{btreeParseCellPtr}))
  29156 			(*MemPage)(unsafe.Pointer(pPage)).FintKey = U8(1)
  29157 			(*MemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*BtShared)(unsafe.Pointer(pBt)).FmaxLeaf
  29158 			(*MemPage)(unsafe.Pointer(pPage)).FminLocal = (*BtShared)(unsafe.Pointer(pBt)).FminLeaf
  29159 		} else if flagByte == PTF_ZERODATA|PTF_LEAF {
  29160 			(*MemPage)(unsafe.Pointer(pPage)).FintKey = U8(0)
  29161 			(*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = U8(0)
  29162 			(*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct {
  29163 				f func(*libc.TLS, uintptr, uintptr) U16
  29164 			}{cellSizePtr}))
  29165 			(*MemPage)(unsafe.Pointer(pPage)).FxParseCell = *(*uintptr)(unsafe.Pointer(&struct {
  29166 				f func(*libc.TLS, uintptr, uintptr, uintptr)
  29167 			}{btreeParseCellPtrIndex}))
  29168 			(*MemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*BtShared)(unsafe.Pointer(pBt)).FmaxLocal
  29169 			(*MemPage)(unsafe.Pointer(pPage)).FminLocal = (*BtShared)(unsafe.Pointer(pBt)).FminLocal
  29170 		} else {
  29171 			(*MemPage)(unsafe.Pointer(pPage)).FintKey = U8(0)
  29172 			(*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = U8(0)
  29173 			(*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct {
  29174 				f func(*libc.TLS, uintptr, uintptr) U16
  29175 			}{cellSizePtr}))
  29176 			(*MemPage)(unsafe.Pointer(pPage)).FxParseCell = *(*uintptr)(unsafe.Pointer(&struct {
  29177 				f func(*libc.TLS, uintptr, uintptr, uintptr)
  29178 			}{btreeParseCellPtrIndex}))
  29179 			return Xsqlite3CorruptError(tls, 70361)
  29180 		}
  29181 	} else {
  29182 		(*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize = U8(4)
  29183 		(*MemPage)(unsafe.Pointer(pPage)).Fleaf = U8(0)
  29184 		if flagByte == PTF_ZERODATA {
  29185 			(*MemPage)(unsafe.Pointer(pPage)).FintKey = U8(0)
  29186 			(*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = U8(0)
  29187 			(*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct {
  29188 				f func(*libc.TLS, uintptr, uintptr) U16
  29189 			}{cellSizePtr}))
  29190 			(*MemPage)(unsafe.Pointer(pPage)).FxParseCell = *(*uintptr)(unsafe.Pointer(&struct {
  29191 				f func(*libc.TLS, uintptr, uintptr, uintptr)
  29192 			}{btreeParseCellPtrIndex}))
  29193 			(*MemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*BtShared)(unsafe.Pointer(pBt)).FmaxLocal
  29194 			(*MemPage)(unsafe.Pointer(pPage)).FminLocal = (*BtShared)(unsafe.Pointer(pBt)).FminLocal
  29195 		} else if flagByte == PTF_LEAFDATA|PTF_INTKEY {
  29196 			(*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = U8(0)
  29197 			(*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct {
  29198 				f func(*libc.TLS, uintptr, uintptr) U16
  29199 			}{cellSizePtrNoPayload}))
  29200 			(*MemPage)(unsafe.Pointer(pPage)).FxParseCell = *(*uintptr)(unsafe.Pointer(&struct {
  29201 				f func(*libc.TLS, uintptr, uintptr, uintptr)
  29202 			}{btreeParseCellPtrNoPayload}))
  29203 			(*MemPage)(unsafe.Pointer(pPage)).FintKey = U8(1)
  29204 			(*MemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*BtShared)(unsafe.Pointer(pBt)).FmaxLeaf
  29205 			(*MemPage)(unsafe.Pointer(pPage)).FminLocal = (*BtShared)(unsafe.Pointer(pBt)).FminLeaf
  29206 		} else {
  29207 			(*MemPage)(unsafe.Pointer(pPage)).FintKey = U8(0)
  29208 			(*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = U8(0)
  29209 			(*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct {
  29210 				f func(*libc.TLS, uintptr, uintptr) U16
  29211 			}{cellSizePtr}))
  29212 			(*MemPage)(unsafe.Pointer(pPage)).FxParseCell = *(*uintptr)(unsafe.Pointer(&struct {
  29213 				f func(*libc.TLS, uintptr, uintptr, uintptr)
  29214 			}{btreeParseCellPtrIndex}))
  29215 			return Xsqlite3CorruptError(tls, 70385)
  29216 		}
  29217 	}
  29218 	return SQLITE_OK
  29219 }
  29220 
  29221 func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 {
  29222 	var pc int32
  29223 	var hdr U8
  29224 	var data uintptr
  29225 	var usableSize int32
  29226 	var nFree int32
  29227 	var top int32
  29228 	var iCellFirst int32
  29229 	var iCellLast int32
  29230 
  29231 	usableSize = int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize)
  29232 	hdr = (*MemPage)(unsafe.Pointer(pPage)).FhdrOffset
  29233 	data = (*MemPage)(unsafe.Pointer(pPage)).FaData
  29234 
  29235 	top = (int32(*(*U8)(unsafe.Pointer(data + uintptr(int32(hdr)+5))))<<8|int32(*(*U8)(unsafe.Pointer(data + uintptr(int32(hdr)+5) + 1)))-1)&0xffff + 1
  29236 	iCellFirst = int32(hdr) + 8 + int32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + 2*int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  29237 	iCellLast = usableSize - 4
  29238 
  29239 	pc = int32(*(*U8)(unsafe.Pointer(data + uintptr(int32(hdr)+1))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(int32(hdr)+1) + 1)))
  29240 	nFree = int32(*(*U8)(unsafe.Pointer(data + uintptr(int32(hdr)+7)))) + top
  29241 	if pc > 0 {
  29242 		var next U32
  29243 		var size U32
  29244 		if pc < top {
  29245 			return Xsqlite3CorruptError(tls, 70436)
  29246 		}
  29247 		for 1 != 0 {
  29248 			if pc > iCellLast {
  29249 				return Xsqlite3CorruptError(tls, 70441)
  29250 			}
  29251 			next = U32(int32(*(*U8)(unsafe.Pointer(data + uintptr(pc))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(pc) + 1))))
  29252 			size = U32(int32(*(*U8)(unsafe.Pointer(data + uintptr(pc+2))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(pc+2) + 1))))
  29253 			nFree = int32(U32(nFree) + size)
  29254 			if next <= U32(pc)+size+U32(3) {
  29255 				break
  29256 			}
  29257 			pc = int32(next)
  29258 		}
  29259 		if next > U32(0) {
  29260 			return Xsqlite3CorruptError(tls, 70451)
  29261 		}
  29262 		if U32(pc)+size > uint32(usableSize) {
  29263 			return Xsqlite3CorruptError(tls, 70455)
  29264 		}
  29265 	}
  29266 
  29267 	if nFree > usableSize || nFree < iCellFirst {
  29268 		return Xsqlite3CorruptError(tls, 70467)
  29269 	}
  29270 	(*MemPage)(unsafe.Pointer(pPage)).FnFree = int32(U16(nFree - iCellFirst))
  29271 	return SQLITE_OK
  29272 }
  29273 
  29274 func btreeCellSizeCheck(tls *libc.TLS, pPage uintptr) int32 {
  29275 	var iCellFirst int32
  29276 	var iCellLast int32
  29277 	var i int32
  29278 	var sz int32
  29279 	var pc int32
  29280 	var data uintptr
  29281 	var usableSize int32
  29282 	var cellOffset int32
  29283 
  29284 	iCellFirst = int32((*MemPage)(unsafe.Pointer(pPage)).FcellOffset) + 2*int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  29285 	usableSize = int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize)
  29286 	iCellLast = usableSize - 4
  29287 	data = (*MemPage)(unsafe.Pointer(pPage)).FaData
  29288 	cellOffset = int32((*MemPage)(unsafe.Pointer(pPage)).FcellOffset)
  29289 	if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  29290 		iCellLast--
  29291 	}
  29292 	for i = 0; i < int32((*MemPage)(unsafe.Pointer(pPage)).FnCell); i++ {
  29293 		pc = int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(data + uintptr(cellOffset+i*2)))))
  29294 
  29295 		if pc < iCellFirst || pc > iCellLast {
  29296 			return Xsqlite3CorruptError(tls, 70498)
  29297 		}
  29298 		sz = int32((*struct {
  29299 			f func(*libc.TLS, uintptr, uintptr) U16
  29300 		})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxCellSize})).f(tls, pPage, data+uintptr(pc)))
  29301 
  29302 		if pc+sz > usableSize {
  29303 			return Xsqlite3CorruptError(tls, 70503)
  29304 		}
  29305 	}
  29306 	return SQLITE_OK
  29307 }
  29308 
  29309 func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 {
  29310 	var data uintptr
  29311 	var pBt uintptr
  29312 
  29313 	pBt = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  29314 	data = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)
  29315 
  29316 	if decodeFlags(tls, pPage, int32(*(*U8)(unsafe.Pointer(data)))) != 0 {
  29317 		return Xsqlite3CorruptError(tls, 70535)
  29318 	}
  29319 
  29320 	(*MemPage)(unsafe.Pointer(pPage)).FmaskPage = U16((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(1))
  29321 	(*MemPage)(unsafe.Pointer(pPage)).FnOverflow = U8(0)
  29322 	(*MemPage)(unsafe.Pointer(pPage)).FcellOffset = U16(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 8 + int32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize))
  29323 	(*MemPage)(unsafe.Pointer(pPage)).FaCellIdx = data + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize) + uintptr(8)
  29324 	(*MemPage)(unsafe.Pointer(pPage)).FaDataEnd = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*BtShared)(unsafe.Pointer(pBt)).FpageSize)
  29325 	(*MemPage)(unsafe.Pointer(pPage)).FaDataOfst = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)
  29326 
  29327 	(*MemPage)(unsafe.Pointer(pPage)).FnCell = U16(int32(*(*U8)(unsafe.Pointer(data + 3)))<<8 | int32(*(*U8)(unsafe.Pointer(data + 3 + 1))))
  29328 	if U32((*MemPage)(unsafe.Pointer(pPage)).FnCell) > ((*BtShared)(unsafe.Pointer(pBt)).FpageSize-U32(8))/U32(6) {
  29329 		return Xsqlite3CorruptError(tls, 70549)
  29330 	}
  29331 
  29332 	(*MemPage)(unsafe.Pointer(pPage)).FnFree = -1
  29333 	(*MemPage)(unsafe.Pointer(pPage)).FisInit = U8(1)
  29334 	if (*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags&uint64(SQLITE_CellSizeCk) != 0 {
  29335 		return btreeCellSizeCheck(tls, pPage)
  29336 	}
  29337 	return SQLITE_OK
  29338 }
  29339 
  29340 func zeroPage(tls *libc.TLS, pPage uintptr, flags int32) {
  29341 	var data uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData
  29342 	var pBt uintptr = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  29343 	var hdr U8 = (*MemPage)(unsafe.Pointer(pPage)).FhdrOffset
  29344 	var first U16
  29345 
  29346 	if int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_FAST_SECURE != 0 {
  29347 		libc.Xmemset(tls, data+uintptr(hdr), 0, (*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32(hdr))
  29348 	}
  29349 	*(*uint8)(unsafe.Pointer(data + uintptr(hdr))) = uint8(flags)
  29350 	first = U16(int32(hdr) + func() int32 {
  29351 		if flags&PTF_LEAF == 0 {
  29352 			return 12
  29353 		}
  29354 		return 8
  29355 	}())
  29356 	libc.Xmemset(tls, data+uintptr(int32(hdr)+1), 0, uint32(4))
  29357 	*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+7))) = uint8(0)
  29358 	*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+5))) = U8((*BtShared)(unsafe.Pointer(pBt)).FusableSize >> 8)
  29359 	*(*uint8)(unsafe.Pointer(data + uintptr(int32(hdr)+5) + 1)) = U8((*BtShared)(unsafe.Pointer(pBt)).FusableSize)
  29360 	(*MemPage)(unsafe.Pointer(pPage)).FnFree = int32(U16((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(first)))
  29361 	decodeFlags(tls, pPage, flags)
  29362 	(*MemPage)(unsafe.Pointer(pPage)).FcellOffset = first
  29363 	(*MemPage)(unsafe.Pointer(pPage)).FaDataEnd = data + uintptr((*BtShared)(unsafe.Pointer(pBt)).FpageSize)
  29364 	(*MemPage)(unsafe.Pointer(pPage)).FaCellIdx = data + uintptr(first)
  29365 	(*MemPage)(unsafe.Pointer(pPage)).FaDataOfst = data + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)
  29366 	(*MemPage)(unsafe.Pointer(pPage)).FnOverflow = U8(0)
  29367 
  29368 	(*MemPage)(unsafe.Pointer(pPage)).FmaskPage = U16((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(1))
  29369 	(*MemPage)(unsafe.Pointer(pPage)).FnCell = U16(0)
  29370 	(*MemPage)(unsafe.Pointer(pPage)).FisInit = U8(1)
  29371 }
  29372 
  29373 func btreePageFromDbPage(tls *libc.TLS, pDbPage uintptr, pgno Pgno, pBt uintptr) uintptr {
  29374 	var pPage uintptr = Xsqlite3PagerGetExtra(tls, pDbPage)
  29375 	if pgno != (*MemPage)(unsafe.Pointer(pPage)).Fpgno {
  29376 		(*MemPage)(unsafe.Pointer(pPage)).FaData = Xsqlite3PagerGetData(tls, pDbPage)
  29377 		(*MemPage)(unsafe.Pointer(pPage)).FpDbPage = pDbPage
  29378 		(*MemPage)(unsafe.Pointer(pPage)).FpBt = pBt
  29379 		(*MemPage)(unsafe.Pointer(pPage)).Fpgno = pgno
  29380 		(*MemPage)(unsafe.Pointer(pPage)).FhdrOffset = func() uint8 {
  29381 			if pgno == Pgno(1) {
  29382 				return uint8(100)
  29383 			}
  29384 			return uint8(0)
  29385 		}()
  29386 	}
  29387 
  29388 	return pPage
  29389 }
  29390 
  29391 func btreeGetPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 {
  29392 	bp := tls.Alloc(4)
  29393 	defer tls.Free(4)
  29394 
  29395 	var rc int32
  29396 
  29397 	rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pgno, bp, flags)
  29398 	if rc != 0 {
  29399 		return rc
  29400 	}
  29401 	*(*uintptr)(unsafe.Pointer(ppPage)) = btreePageFromDbPage(tls, *(*uintptr)(unsafe.Pointer(bp)), pgno, pBt)
  29402 	return SQLITE_OK
  29403 }
  29404 
  29405 func btreePageLookup(tls *libc.TLS, pBt uintptr, pgno Pgno) uintptr {
  29406 	var pDbPage uintptr
  29407 
  29408 	pDbPage = Xsqlite3PagerLookup(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pgno)
  29409 	if pDbPage != 0 {
  29410 		return btreePageFromDbPage(tls, pDbPage, pgno, pBt)
  29411 	}
  29412 	return uintptr(0)
  29413 }
  29414 
  29415 func btreePagecount(tls *libc.TLS, pBt uintptr) Pgno {
  29416 	return (*BtShared)(unsafe.Pointer(pBt)).FnPage
  29417 }
  29418 
  29419 func Xsqlite3BtreeLastPage(tls *libc.TLS, p uintptr) Pgno {
  29420 	return btreePagecount(tls, (*Btree)(unsafe.Pointer(p)).FpBt)
  29421 }
  29422 
  29423 func getAndInitPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, pCur uintptr, bReadOnly int32) int32 {
  29424 	bp := tls.Alloc(4)
  29425 	defer tls.Free(4)
  29426 
  29427 	var rc int32
  29428 
  29429 	if !(pgno > btreePagecount(tls, pBt)) {
  29430 		goto __1
  29431 	}
  29432 	rc = Xsqlite3CorruptError(tls, 70704)
  29433 	goto getAndInitPage_error1
  29434 __1:
  29435 	;
  29436 	rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pgno, bp, bReadOnly)
  29437 	if !(rc != 0) {
  29438 		goto __2
  29439 	}
  29440 	goto getAndInitPage_error1
  29441 __2:
  29442 	;
  29443 	*(*uintptr)(unsafe.Pointer(ppPage)) = Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp)))
  29444 	if !(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FisInit) == 0) {
  29445 		goto __3
  29446 	}
  29447 	btreePageFromDbPage(tls, *(*uintptr)(unsafe.Pointer(bp)), pgno, pBt)
  29448 	rc = btreeInitPage(tls, *(*uintptr)(unsafe.Pointer(ppPage)))
  29449 	if !(rc != SQLITE_OK) {
  29450 		goto __4
  29451 	}
  29452 	goto getAndInitPage_error2
  29453 __4:
  29454 	;
  29455 __3:
  29456 	;
  29457 	if !(pCur != 0 && (int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FnCell) < 1 || int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FintKey) != int32((*BtCursor)(unsafe.Pointer(pCur)).FcurIntKey))) {
  29458 		goto __5
  29459 	}
  29460 	rc = Xsqlite3CorruptError(tls, 70725)
  29461 	goto getAndInitPage_error2
  29462 __5:
  29463 	;
  29464 	return SQLITE_OK
  29465 
  29466 getAndInitPage_error2:
  29467 	releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage)))
  29468 getAndInitPage_error1:
  29469 	if !(pCur != 0) {
  29470 		goto __6
  29471 	}
  29472 	(*BtCursor)(unsafe.Pointer(pCur)).FiPage--
  29473 	(*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*4))
  29474 __6:
  29475 	;
  29476 	return rc
  29477 }
  29478 
  29479 func releasePageNotNull(tls *libc.TLS, pPage uintptr) {
  29480 	Xsqlite3PagerUnrefNotNull(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  29481 }
  29482 
  29483 func releasePage(tls *libc.TLS, pPage uintptr) {
  29484 	if pPage != 0 {
  29485 		releasePageNotNull(tls, pPage)
  29486 	}
  29487 }
  29488 
  29489 func releasePageOne(tls *libc.TLS, pPage uintptr) {
  29490 	Xsqlite3PagerUnrefPageOne(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  29491 }
  29492 
  29493 func btreeGetUnusedPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 {
  29494 	var rc int32 = btreeGetPage(tls, pBt, pgno, ppPage, flags)
  29495 	if rc == SQLITE_OK {
  29496 		if Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) > 1 {
  29497 			releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage)))
  29498 			*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  29499 			return Xsqlite3CorruptError(tls, 70791)
  29500 		}
  29501 		(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FisInit = U8(0)
  29502 	} else {
  29503 		*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  29504 	}
  29505 	return rc
  29506 }
  29507 
  29508 func pageReinit(tls *libc.TLS, pData uintptr) {
  29509 	var pPage uintptr
  29510 	pPage = Xsqlite3PagerGetExtra(tls, pData)
  29511 
  29512 	if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 {
  29513 		(*MemPage)(unsafe.Pointer(pPage)).FisInit = U8(0)
  29514 		if Xsqlite3PagerPageRefcount(tls, pData) > 1 {
  29515 			btreeInitPage(tls, pPage)
  29516 		}
  29517 	}
  29518 }
  29519 
  29520 func btreeInvokeBusyHandler(tls *libc.TLS, pArg uintptr) int32 {
  29521 	var pBt uintptr = pArg
  29522 
  29523 	return Xsqlite3InvokeBusyHandler(tls, (*BtShared)(unsafe.Pointer(pBt)).Fdb+464)
  29524 }
  29525 
  29526 // Open a database file.
  29527 //
  29528 // zFilename is the name of the database file.  If zFilename is NULL
  29529 // then an ephemeral database is created.  The ephemeral database might
  29530 // be exclusively in memory, or it might use a disk-based memory cache.
  29531 // Either way, the ephemeral database will be automatically deleted
  29532 // when sqlite3BtreeClose() is called.
  29533 //
  29534 // If zFilename is ":memory:" then an in-memory database is created
  29535 // that is automatically destroyed when it is closed.
  29536 //
  29537 // The "flags" parameter is a bitmask that might contain bits like
  29538 // BTREE_OMIT_JOURNAL and/or BTREE_MEMORY.
  29539 //
  29540 // If the database is already opened in the same database connection
  29541 // and we are in shared cache mode, then the open will fail with an
  29542 // SQLITE_CONSTRAINT error.  We cannot allow two or more BtShared
  29543 // objects in the same database connection since doing so will lead
  29544 // to problems with locking.
  29545 func Xsqlite3BtreeOpen(tls *libc.TLS, pVfs uintptr, zFilename uintptr, db uintptr, ppBtree uintptr, flags int32, vfsFlags int32) int32 {
  29546 	bp := tls.Alloc(100)
  29547 	defer tls.Free(100)
  29548 
  29549 	var pBt uintptr
  29550 	var p uintptr
  29551 	var mutexOpen uintptr
  29552 	var rc int32
  29553 	var nReserve U8
  29554 
  29555 	var isTempDb int32
  29556 
  29557 	var isMemdb int32
  29558 	var pExisting uintptr
  29559 	var iDb int32
  29560 	var nFilename int32
  29561 	var nFullPathname int32
  29562 	var zFullPathname uintptr
  29563 	var mutexShared uintptr
  29564 	var mutexShared1 uintptr
  29565 	var i int32
  29566 	var pSib uintptr
  29567 	var pFile uintptr
  29568 	pBt = uintptr(0)
  29569 	mutexOpen = uintptr(0)
  29570 	rc = SQLITE_OK
  29571 	isTempDb = libc.Bool32(zFilename == uintptr(0) || int32(*(*uint8)(unsafe.Pointer(zFilename))) == 0)
  29572 	isMemdb = libc.Bool32(zFilename != 0 && libc.Xstrcmp(tls, zFilename, ts+4049) == 0 ||
  29573 		isTempDb != 0 && Xsqlite3TempInMemory(tls, db) != 0 ||
  29574 		vfsFlags&SQLITE_OPEN_MEMORY != 0)
  29575 
  29576 	if !(isMemdb != 0) {
  29577 		goto __1
  29578 	}
  29579 	flags = flags | BTREE_MEMORY
  29580 __1:
  29581 	;
  29582 	if !(vfsFlags&SQLITE_OPEN_MAIN_DB != 0 && (isMemdb != 0 || isTempDb != 0)) {
  29583 		goto __2
  29584 	}
  29585 	vfsFlags = vfsFlags&libc.CplInt32(SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB
  29586 __2:
  29587 	;
  29588 	p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Btree{})))
  29589 	if !!(p != 0) {
  29590 		goto __3
  29591 	}
  29592 	return SQLITE_NOMEM
  29593 __3:
  29594 	;
  29595 	(*Btree)(unsafe.Pointer(p)).FinTrans = U8(TRANS_NONE)
  29596 	(*Btree)(unsafe.Pointer(p)).Fdb = db
  29597 	(*Btree)(unsafe.Pointer(p)).Flock.FpBtree = p
  29598 	(*Btree)(unsafe.Pointer(p)).Flock.FiTable = Pgno(1)
  29599 
  29600 	if !(isTempDb == 0 && (isMemdb == 0 || vfsFlags&SQLITE_OPEN_URI != 0)) {
  29601 		goto __4
  29602 	}
  29603 	if !(vfsFlags&SQLITE_OPEN_SHAREDCACHE != 0) {
  29604 		goto __5
  29605 	}
  29606 	nFilename = Xsqlite3Strlen30(tls, zFilename) + 1
  29607 	nFullPathname = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + 1
  29608 	zFullPathname = Xsqlite3Malloc(tls, func() uint64 {
  29609 		if nFullPathname > nFilename {
  29610 			return uint64(nFullPathname)
  29611 		}
  29612 		return uint64(nFilename)
  29613 	}())
  29614 
  29615 	(*Btree)(unsafe.Pointer(p)).Fsharable = U8(1)
  29616 	if !!(zFullPathname != 0) {
  29617 		goto __6
  29618 	}
  29619 	Xsqlite3_free(tls, p)
  29620 	return SQLITE_NOMEM
  29621 __6:
  29622 	;
  29623 	if !(isMemdb != 0) {
  29624 		goto __7
  29625 	}
  29626 	libc.Xmemcpy(tls, zFullPathname, zFilename, uint32(nFilename))
  29627 	goto __8
  29628 __7:
  29629 	rc = Xsqlite3OsFullPathname(tls, pVfs, zFilename,
  29630 		nFullPathname, zFullPathname)
  29631 	if !(rc != 0) {
  29632 		goto __9
  29633 	}
  29634 	if !(rc == SQLITE_OK|int32(2)<<8) {
  29635 		goto __10
  29636 	}
  29637 	rc = SQLITE_OK
  29638 	goto __11
  29639 __10:
  29640 	Xsqlite3_free(tls, zFullPathname)
  29641 	Xsqlite3_free(tls, p)
  29642 	return rc
  29643 __11:
  29644 	;
  29645 __9:
  29646 	;
  29647 __8:
  29648 	;
  29649 	mutexOpen = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_OPEN)
  29650 	Xsqlite3_mutex_enter(tls, mutexOpen)
  29651 	mutexShared = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  29652 	Xsqlite3_mutex_enter(tls, mutexShared)
  29653 	pBt = sqlite3SharedCacheList
  29654 __12:
  29655 	if !(pBt != 0) {
  29656 		goto __14
  29657 	}
  29658 
  29659 	if !(0 == libc.Xstrcmp(tls, zFullPathname, Xsqlite3PagerFilename(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, 0)) &&
  29660 		Xsqlite3PagerVfs(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) == pVfs) {
  29661 		goto __15
  29662 	}
  29663 	iDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
  29664 __16:
  29665 	if !(iDb >= 0) {
  29666 		goto __18
  29667 	}
  29668 	pExisting = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
  29669 	if !(pExisting != 0 && (*Btree)(unsafe.Pointer(pExisting)).FpBt == pBt) {
  29670 		goto __19
  29671 	}
  29672 	Xsqlite3_mutex_leave(tls, mutexShared)
  29673 	Xsqlite3_mutex_leave(tls, mutexOpen)
  29674 	Xsqlite3_free(tls, zFullPathname)
  29675 	Xsqlite3_free(tls, p)
  29676 	return SQLITE_CONSTRAINT
  29677 __19:
  29678 	;
  29679 	goto __17
  29680 __17:
  29681 	iDb--
  29682 	goto __16
  29683 	goto __18
  29684 __18:
  29685 	;
  29686 	(*Btree)(unsafe.Pointer(p)).FpBt = pBt
  29687 	(*BtShared)(unsafe.Pointer(pBt)).FnRef++
  29688 	goto __14
  29689 __15:
  29690 	;
  29691 	goto __13
  29692 __13:
  29693 	pBt = (*BtShared)(unsafe.Pointer(pBt)).FpNext
  29694 	goto __12
  29695 	goto __14
  29696 __14:
  29697 	;
  29698 	Xsqlite3_mutex_leave(tls, mutexShared)
  29699 	Xsqlite3_free(tls, zFullPathname)
  29700 __5:
  29701 	;
  29702 __4:
  29703 	;
  29704 	if !(pBt == uintptr(0)) {
  29705 		goto __20
  29706 	}
  29707 
  29708 	pBt = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(BtShared{})))
  29709 	if !(pBt == uintptr(0)) {
  29710 		goto __21
  29711 	}
  29712 	rc = SQLITE_NOMEM
  29713 	goto btree_open_out
  29714 __21:
  29715 	;
  29716 	rc = Xsqlite3PagerOpen(tls, pVfs, pBt, zFilename,
  29717 		int32(unsafe.Sizeof(MemPage{})), flags, vfsFlags, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{pageReinit})))
  29718 	if !(rc == SQLITE_OK) {
  29719 		goto __22
  29720 	}
  29721 	Xsqlite3PagerSetMmapLimit(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Sqlite3)(unsafe.Pointer(db)).FszMmap)
  29722 	rc = Xsqlite3PagerReadFileheader(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, int32(unsafe.Sizeof([100]uint8{})), bp)
  29723 __22:
  29724 	;
  29725 	if !(rc != SQLITE_OK) {
  29726 		goto __23
  29727 	}
  29728 	goto btree_open_out
  29729 __23:
  29730 	;
  29731 	(*BtShared)(unsafe.Pointer(pBt)).FopenFlags = U8(flags)
  29732 	(*BtShared)(unsafe.Pointer(pBt)).Fdb = db
  29733 	Xsqlite3PagerSetBusyHandler(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, *(*uintptr)(unsafe.Pointer(&struct {
  29734 		f func(*libc.TLS, uintptr) int32
  29735 	}{btreeInvokeBusyHandler})), pBt)
  29736 	(*Btree)(unsafe.Pointer(p)).FpBt = pBt
  29737 
  29738 	(*BtShared)(unsafe.Pointer(pBt)).FpCursor = uintptr(0)
  29739 	(*BtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0)
  29740 	if !(Xsqlite3PagerIsreadonly(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) != 0) {
  29741 		goto __24
  29742 	}
  29743 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_READ_ONLY)
  29744 __24:
  29745 	;
  29746 	(*BtShared)(unsafe.Pointer(pBt)).FpageSize = U32(int32(*(*uint8)(unsafe.Pointer(bp + 16)))<<8 | int32(*(*uint8)(unsafe.Pointer(bp + 17)))<<16)
  29747 	if !((*BtShared)(unsafe.Pointer(pBt)).FpageSize < U32(512) || (*BtShared)(unsafe.Pointer(pBt)).FpageSize > U32(SQLITE_MAX_PAGE_SIZE) ||
  29748 		((*BtShared)(unsafe.Pointer(pBt)).FpageSize-U32(1))&(*BtShared)(unsafe.Pointer(pBt)).FpageSize != U32(0)) {
  29749 		goto __25
  29750 	}
  29751 	(*BtShared)(unsafe.Pointer(pBt)).FpageSize = U32(0)
  29752 
  29753 	if !(zFilename != 0 && !(isMemdb != 0)) {
  29754 		goto __27
  29755 	}
  29756 	(*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 {
  29757 		if 0 != 0 {
  29758 			return uint8(1)
  29759 		}
  29760 		return uint8(0)
  29761 	}()
  29762 	(*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 {
  29763 		if SQLITE_DEFAULT_AUTOVACUUM == 2 {
  29764 			return uint8(1)
  29765 		}
  29766 		return uint8(0)
  29767 	}()
  29768 __27:
  29769 	;
  29770 	nReserve = U8(0)
  29771 	goto __26
  29772 __25:
  29773 	nReserve = *(*uint8)(unsafe.Pointer(bp + 20))
  29774 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_PAGESIZE_FIXED)
  29775 	(*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 {
  29776 		if Xsqlite3Get4byte(tls, bp+52) != 0 {
  29777 			return uint8(1)
  29778 		}
  29779 		return uint8(0)
  29780 	}()
  29781 	(*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 {
  29782 		if Xsqlite3Get4byte(tls, bp+64) != 0 {
  29783 			return uint8(1)
  29784 		}
  29785 		return uint8(0)
  29786 	}()
  29787 __26:
  29788 	;
  29789 	rc = Xsqlite3PagerSetPagesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pBt+36, int32(nReserve))
  29790 	if !(rc != 0) {
  29791 		goto __28
  29792 	}
  29793 	goto btree_open_out
  29794 __28:
  29795 	;
  29796 	(*BtShared)(unsafe.Pointer(pBt)).FusableSize = (*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(nReserve)
  29797 
  29798 	(*BtShared)(unsafe.Pointer(pBt)).FnRef = 1
  29799 	if !((*Btree)(unsafe.Pointer(p)).Fsharable != 0) {
  29800 		goto __29
  29801 	}
  29802 	mutexShared1 = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  29803 	if !(1 != 0 && Xsqlite3Config.FbCoreMutex != 0) {
  29804 		goto __30
  29805 	}
  29806 	(*BtShared)(unsafe.Pointer(pBt)).Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_FAST)
  29807 	if !((*BtShared)(unsafe.Pointer(pBt)).Fmutex == uintptr(0)) {
  29808 		goto __31
  29809 	}
  29810 	rc = SQLITE_NOMEM
  29811 	goto btree_open_out
  29812 __31:
  29813 	;
  29814 __30:
  29815 	;
  29816 	Xsqlite3_mutex_enter(tls, mutexShared1)
  29817 	(*BtShared)(unsafe.Pointer(pBt)).FpNext = sqlite3SharedCacheList
  29818 	sqlite3SharedCacheList = pBt
  29819 	Xsqlite3_mutex_leave(tls, mutexShared1)
  29820 __29:
  29821 	;
  29822 __20:
  29823 	;
  29824 	if !((*Btree)(unsafe.Pointer(p)).Fsharable != 0) {
  29825 		goto __32
  29826 	}
  29827 	i = 0
  29828 __33:
  29829 	if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  29830 		goto __35
  29831 	}
  29832 	if !(libc.AssignUintptr(&pSib, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpBt) != uintptr(0) && (*Btree)(unsafe.Pointer(pSib)).Fsharable != 0) {
  29833 		goto __36
  29834 	}
  29835 __37:
  29836 	if !((*Btree)(unsafe.Pointer(pSib)).FpPrev != 0) {
  29837 		goto __38
  29838 	}
  29839 	pSib = (*Btree)(unsafe.Pointer(pSib)).FpPrev
  29840 	goto __37
  29841 __38:
  29842 	;
  29843 	if !(Uptr((*Btree)(unsafe.Pointer(p)).FpBt) < Uptr((*Btree)(unsafe.Pointer(pSib)).FpBt)) {
  29844 		goto __39
  29845 	}
  29846 	(*Btree)(unsafe.Pointer(p)).FpNext = pSib
  29847 	(*Btree)(unsafe.Pointer(p)).FpPrev = uintptr(0)
  29848 	(*Btree)(unsafe.Pointer(pSib)).FpPrev = p
  29849 	goto __40
  29850 __39:
  29851 __41:
  29852 	if !((*Btree)(unsafe.Pointer(pSib)).FpNext != 0 && Uptr((*Btree)(unsafe.Pointer((*Btree)(unsafe.Pointer(pSib)).FpNext)).FpBt) < Uptr((*Btree)(unsafe.Pointer(p)).FpBt)) {
  29853 		goto __42
  29854 	}
  29855 	pSib = (*Btree)(unsafe.Pointer(pSib)).FpNext
  29856 	goto __41
  29857 __42:
  29858 	;
  29859 	(*Btree)(unsafe.Pointer(p)).FpNext = (*Btree)(unsafe.Pointer(pSib)).FpNext
  29860 	(*Btree)(unsafe.Pointer(p)).FpPrev = pSib
  29861 	if !((*Btree)(unsafe.Pointer(p)).FpNext != 0) {
  29862 		goto __43
  29863 	}
  29864 	(*Btree)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpNext)).FpPrev = p
  29865 __43:
  29866 	;
  29867 	(*Btree)(unsafe.Pointer(pSib)).FpNext = p
  29868 __40:
  29869 	;
  29870 	goto __35
  29871 __36:
  29872 	;
  29873 	goto __34
  29874 __34:
  29875 	i++
  29876 	goto __33
  29877 	goto __35
  29878 __35:
  29879 	;
  29880 __32:
  29881 	;
  29882 	*(*uintptr)(unsafe.Pointer(ppBtree)) = p
  29883 
  29884 btree_open_out:
  29885 	if !(rc != SQLITE_OK) {
  29886 		goto __44
  29887 	}
  29888 	if !(pBt != 0 && (*BtShared)(unsafe.Pointer(pBt)).FpPager != 0) {
  29889 		goto __46
  29890 	}
  29891 	Xsqlite3PagerClose(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, uintptr(0))
  29892 __46:
  29893 	;
  29894 	Xsqlite3_free(tls, pBt)
  29895 	Xsqlite3_free(tls, p)
  29896 	*(*uintptr)(unsafe.Pointer(ppBtree)) = uintptr(0)
  29897 	goto __45
  29898 __44:
  29899 	if !(Xsqlite3BtreeSchema(tls, p, 0, uintptr(0)) == uintptr(0)) {
  29900 		goto __47
  29901 	}
  29902 	Xsqlite3BtreeSetCacheSize(tls, p, -2000)
  29903 __47:
  29904 	;
  29905 	pFile = Xsqlite3PagerFile(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager)
  29906 	if !((*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0) {
  29907 		goto __48
  29908 	}
  29909 	Xsqlite3OsFileControlHint(tls, pFile, SQLITE_FCNTL_PDB, pBt+4)
  29910 __48:
  29911 	;
  29912 __45:
  29913 	;
  29914 	if !(mutexOpen != 0) {
  29915 		goto __49
  29916 	}
  29917 
  29918 	Xsqlite3_mutex_leave(tls, mutexOpen)
  29919 __49:
  29920 	;
  29921 	return rc
  29922 }
  29923 
  29924 func removeFromSharingList(tls *libc.TLS, pBt uintptr) int32 {
  29925 	var pMainMtx uintptr
  29926 	var pList uintptr
  29927 	var removed int32 = 0
  29928 
  29929 	pMainMtx = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  29930 	Xsqlite3_mutex_enter(tls, pMainMtx)
  29931 	(*BtShared)(unsafe.Pointer(pBt)).FnRef--
  29932 	if (*BtShared)(unsafe.Pointer(pBt)).FnRef <= 0 {
  29933 		if sqlite3SharedCacheList == pBt {
  29934 			sqlite3SharedCacheList = (*BtShared)(unsafe.Pointer(pBt)).FpNext
  29935 		} else {
  29936 			pList = sqlite3SharedCacheList
  29937 			for pList != 0 && (*BtShared)(unsafe.Pointer(pList)).FpNext != pBt {
  29938 				pList = (*BtShared)(unsafe.Pointer(pList)).FpNext
  29939 			}
  29940 			if pList != 0 {
  29941 				(*BtShared)(unsafe.Pointer(pList)).FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpNext
  29942 			}
  29943 		}
  29944 		if 1 != 0 {
  29945 			Xsqlite3_mutex_free(tls, (*BtShared)(unsafe.Pointer(pBt)).Fmutex)
  29946 		}
  29947 		removed = 1
  29948 	}
  29949 	Xsqlite3_mutex_leave(tls, pMainMtx)
  29950 	return removed
  29951 }
  29952 
  29953 func allocateTempSpace(tls *libc.TLS, pBt uintptr) int32 {
  29954 	(*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace = Xsqlite3PageMalloc(tls, int32((*BtShared)(unsafe.Pointer(pBt)).FpageSize))
  29955 	if (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) {
  29956 		var pCur uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpCursor
  29957 		(*BtShared)(unsafe.Pointer(pBt)).FpCursor = (*BtCursor)(unsafe.Pointer(pCur)).FpNext
  29958 		libc.Xmemset(tls, pCur, 0, uint32(unsafe.Sizeof(BtCursor{})))
  29959 		return SQLITE_NOMEM
  29960 	}
  29961 
  29962 	libc.Xmemset(tls, (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace, 0, uint32(8))
  29963 	*(*uintptr)(unsafe.Pointer(pBt + 84)) += uintptr(4)
  29964 	return SQLITE_OK
  29965 }
  29966 
  29967 func freeTempSpace(tls *libc.TLS, pBt uintptr) {
  29968 	if (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace != 0 {
  29969 		*(*uintptr)(unsafe.Pointer(pBt + 84)) -= uintptr(4)
  29970 		Xsqlite3PageFree(tls, (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace)
  29971 		(*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace = uintptr(0)
  29972 	}
  29973 }
  29974 
  29975 // Close an open database and invalidate all cursors.
  29976 func Xsqlite3BtreeClose(tls *libc.TLS, p uintptr) int32 {
  29977 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  29978 
  29979 	Xsqlite3BtreeEnter(tls, p)
  29980 
  29981 	Xsqlite3BtreeRollback(tls, p, SQLITE_OK, 0)
  29982 	Xsqlite3BtreeLeave(tls, p)
  29983 
  29984 	if !(int32((*Btree)(unsafe.Pointer(p)).Fsharable) != 0) || removeFromSharingList(tls, pBt) != 0 {
  29985 		Xsqlite3PagerClose(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Btree)(unsafe.Pointer(p)).Fdb)
  29986 		if (*BtShared)(unsafe.Pointer(pBt)).FxFreeSchema != 0 && (*BtShared)(unsafe.Pointer(pBt)).FpSchema != 0 {
  29987 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*BtShared)(unsafe.Pointer(pBt)).FxFreeSchema})).f(tls, (*BtShared)(unsafe.Pointer(pBt)).FpSchema)
  29988 		}
  29989 		Xsqlite3DbFree(tls, uintptr(0), (*BtShared)(unsafe.Pointer(pBt)).FpSchema)
  29990 		freeTempSpace(tls, pBt)
  29991 		Xsqlite3_free(tls, pBt)
  29992 	}
  29993 
  29994 	if (*Btree)(unsafe.Pointer(p)).FpPrev != 0 {
  29995 		(*Btree)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpPrev)).FpNext = (*Btree)(unsafe.Pointer(p)).FpNext
  29996 	}
  29997 	if (*Btree)(unsafe.Pointer(p)).FpNext != 0 {
  29998 		(*Btree)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpNext)).FpPrev = (*Btree)(unsafe.Pointer(p)).FpPrev
  29999 	}
  30000 
  30001 	Xsqlite3_free(tls, p)
  30002 	return SQLITE_OK
  30003 }
  30004 
  30005 // Change the "soft" limit on the number of pages in the cache.
  30006 // Unused and unmodified pages will be recycled when the number of
  30007 // pages in the cache exceeds this soft limit.  But the size of the
  30008 // cache is allowed to grow larger than this limit if it contains
  30009 // dirty pages or pages still in active use.
  30010 func Xsqlite3BtreeSetCacheSize(tls *libc.TLS, p uintptr, mxPage int32) int32 {
  30011 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  30012 
  30013 	Xsqlite3BtreeEnter(tls, p)
  30014 	Xsqlite3PagerSetCachesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, mxPage)
  30015 	Xsqlite3BtreeLeave(tls, p)
  30016 	return SQLITE_OK
  30017 }
  30018 
  30019 // Change the "spill" limit on the number of pages in the cache.
  30020 // If the number of pages exceeds this limit during a write transaction,
  30021 // the pager might attempt to "spill" pages to the journal early in
  30022 // order to free up memory.
  30023 //
  30024 // The value returned is the current spill size.  If zero is passed
  30025 // as an argument, no changes are made to the spill size setting, so
  30026 // using mxPage of 0 is a way to query the current spill size.
  30027 func Xsqlite3BtreeSetSpillSize(tls *libc.TLS, p uintptr, mxPage int32) int32 {
  30028 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  30029 	var res int32
  30030 
  30031 	Xsqlite3BtreeEnter(tls, p)
  30032 	res = Xsqlite3PagerSetSpillsize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, mxPage)
  30033 	Xsqlite3BtreeLeave(tls, p)
  30034 	return res
  30035 }
  30036 
  30037 // Change the limit on the amount of the database file that may be
  30038 // memory mapped.
  30039 func Xsqlite3BtreeSetMmapLimit(tls *libc.TLS, p uintptr, szMmap Sqlite3_int64) int32 {
  30040 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  30041 
  30042 	Xsqlite3BtreeEnter(tls, p)
  30043 	Xsqlite3PagerSetMmapLimit(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, szMmap)
  30044 	Xsqlite3BtreeLeave(tls, p)
  30045 	return SQLITE_OK
  30046 }
  30047 
  30048 // Change the way data is synced to disk in order to increase or decrease
  30049 // how well the database resists damage due to OS crashes and power
  30050 // failures.  Level 1 is the same as asynchronous (no syncs() occur and
  30051 // there is a high probability of damage)  Level 2 is the default.  There
  30052 // is a very low but non-zero probability of damage.  Level 3 reduces the
  30053 // probability of damage to near zero but with a write performance reduction.
  30054 func Xsqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) int32 {
  30055 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  30056 
  30057 	Xsqlite3BtreeEnter(tls, p)
  30058 	Xsqlite3PagerSetFlags(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pgFlags)
  30059 	Xsqlite3BtreeLeave(tls, p)
  30060 	return SQLITE_OK
  30061 }
  30062 
  30063 // Change the default pages size and the number of reserved bytes per page.
  30064 // Or, if the page size has already been fixed, return SQLITE_READONLY
  30065 // without changing anything.
  30066 //
  30067 // The page size must be a power of 2 between 512 and 65536.  If the page
  30068 // size supplied does not meet this constraint then the page size is not
  30069 // changed.
  30070 //
  30071 // Page sizes are constrained to be a power of two so that the region
  30072 // of the database file used for locking (beginning at PENDING_BYTE,
  30073 // the first byte past the 1GB boundary, 0x40000000) needs to occur
  30074 // at the beginning of a page.
  30075 //
  30076 // If parameter nReserve is less than zero, then the number of reserved
  30077 // bytes per page is left unchanged.
  30078 //
  30079 // If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size
  30080 // and autovacuum mode can no longer be changed.
  30081 func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve int32, iFix int32) int32 {
  30082 	var rc int32 = SQLITE_OK
  30083 	var x int32
  30084 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  30085 
  30086 	Xsqlite3BtreeEnter(tls, p)
  30087 	(*BtShared)(unsafe.Pointer(pBt)).FnReserveWanted = U8(nReserve)
  30088 	x = int32((*BtShared)(unsafe.Pointer(pBt)).FpageSize - (*BtShared)(unsafe.Pointer(pBt)).FusableSize)
  30089 	if nReserve < x {
  30090 		nReserve = x
  30091 	}
  30092 	if int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_PAGESIZE_FIXED != 0 {
  30093 		Xsqlite3BtreeLeave(tls, p)
  30094 		return SQLITE_READONLY
  30095 	}
  30096 
  30097 	if pageSize >= 512 && pageSize <= SQLITE_MAX_PAGE_SIZE && (pageSize-1)&pageSize == 0 {
  30098 		if nReserve > 32 && pageSize == 512 {
  30099 			pageSize = 1024
  30100 		}
  30101 		(*BtShared)(unsafe.Pointer(pBt)).FpageSize = U32(pageSize)
  30102 		freeTempSpace(tls, pBt)
  30103 	}
  30104 	rc = Xsqlite3PagerSetPagesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pBt+36, nReserve)
  30105 	(*BtShared)(unsafe.Pointer(pBt)).FusableSize = (*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(U16(nReserve))
  30106 	if iFix != 0 {
  30107 		*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_PAGESIZE_FIXED)
  30108 	}
  30109 	Xsqlite3BtreeLeave(tls, p)
  30110 	return rc
  30111 }
  30112 
  30113 // Return the currently defined page size
  30114 func Xsqlite3BtreeGetPageSize(tls *libc.TLS, p uintptr) int32 {
  30115 	return int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpageSize)
  30116 }
  30117 
  30118 // This function is similar to sqlite3BtreeGetReserve(), except that it
  30119 // may only be called if it is guaranteed that the b-tree mutex is already
  30120 // held.
  30121 //
  30122 // This is useful in one special case in the backup API code where it is
  30123 // known that the shared b-tree mutex is held, but the mutex on the
  30124 // database handle that owns *p is not. In this case if sqlite3BtreeEnter()
  30125 // were to be called, it might collide with some other operation on the
  30126 // database handle that owns *p, causing undefined behavior.
  30127 func Xsqlite3BtreeGetReserveNoMutex(tls *libc.TLS, p uintptr) int32 {
  30128 	var n int32
  30129 
  30130 	n = int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpageSize - (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FusableSize)
  30131 	return n
  30132 }
  30133 
  30134 // Return the number of bytes of space at the end of every page that
  30135 // are intentually left unused.  This is the "reserved" space that is
  30136 // sometimes used by extensions.
  30137 //
  30138 // The value returned is the larger of the current reserve size and
  30139 // the latest reserve size requested by SQLITE_FILECTRL_RESERVE_BYTES.
  30140 // The amount of reserve can only grow - never shrink.
  30141 func Xsqlite3BtreeGetRequestedReserve(tls *libc.TLS, p uintptr) int32 {
  30142 	var n1 int32
  30143 	var n2 int32
  30144 	Xsqlite3BtreeEnter(tls, p)
  30145 	n1 = int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FnReserveWanted)
  30146 	n2 = Xsqlite3BtreeGetReserveNoMutex(tls, p)
  30147 	Xsqlite3BtreeLeave(tls, p)
  30148 	if n1 > n2 {
  30149 		return n1
  30150 	}
  30151 	return n2
  30152 }
  30153 
  30154 // Set the maximum page count for a database if mxPage is positive.
  30155 // No changes are made if mxPage is 0 or negative.
  30156 // Regardless of the value of mxPage, return the maximum page count.
  30157 func Xsqlite3BtreeMaxPageCount(tls *libc.TLS, p uintptr, mxPage Pgno) Pgno {
  30158 	var n Pgno
  30159 	Xsqlite3BtreeEnter(tls, p)
  30160 	n = Xsqlite3PagerMaxPageCount(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpPager, mxPage)
  30161 	Xsqlite3BtreeLeave(tls, p)
  30162 	return n
  30163 }
  30164 
  30165 // Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags:
  30166 //
  30167 //	newFlag==0       Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared
  30168 //	newFlag==1       BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared
  30169 //	newFlag==2       BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set
  30170 //	newFlag==(-1)    No changes
  30171 //
  30172 // # This routine acts as a query if newFlag is less than zero
  30173 //
  30174 // With BTS_OVERWRITE set, deleted content is overwritten by zeros, but
  30175 // freelist leaf pages are not written back to the database.  Thus in-page
  30176 // deleted content is cleared, but freelist deleted content is not.
  30177 //
  30178 // With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition
  30179 // that freelist leaf pages are written back into the database, increasing
  30180 // the amount of disk I/O.
  30181 func Xsqlite3BtreeSecureDelete(tls *libc.TLS, p uintptr, newFlag int32) int32 {
  30182 	var b int32
  30183 	if p == uintptr(0) {
  30184 		return 0
  30185 	}
  30186 	Xsqlite3BtreeEnter(tls, p)
  30187 
  30188 	if newFlag >= 0 {
  30189 		*(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_FAST_SECURE))
  30190 		*(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 24)) |= U16(BTS_SECURE_DELETE * newFlag)
  30191 	}
  30192 	b = int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & BTS_FAST_SECURE / BTS_SECURE_DELETE
  30193 	Xsqlite3BtreeLeave(tls, p)
  30194 	return b
  30195 }
  30196 
  30197 // Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
  30198 // parameter is non-zero, then auto-vacuum mode is enabled. If zero, it
  30199 // is disabled. The default value for the auto-vacuum property is
  30200 // determined by the SQLITE_DEFAULT_AUTOVACUUM macro.
  30201 func Xsqlite3BtreeSetAutoVacuum(tls *libc.TLS, p uintptr, autoVacuum int32) int32 {
  30202 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  30203 	var rc int32 = SQLITE_OK
  30204 	var av U8 = U8(autoVacuum)
  30205 
  30206 	Xsqlite3BtreeEnter(tls, p)
  30207 	if int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_PAGESIZE_FIXED != 0 && func() int32 {
  30208 		if av != 0 {
  30209 			return 1
  30210 		}
  30211 		return 0
  30212 	}() != int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) {
  30213 		rc = SQLITE_READONLY
  30214 	} else {
  30215 		(*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 {
  30216 			if av != 0 {
  30217 				return uint8(1)
  30218 			}
  30219 			return uint8(0)
  30220 		}()
  30221 		(*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 {
  30222 			if int32(av) == 2 {
  30223 				return uint8(1)
  30224 			}
  30225 			return uint8(0)
  30226 		}()
  30227 	}
  30228 	Xsqlite3BtreeLeave(tls, p)
  30229 	return rc
  30230 }
  30231 
  30232 // Return the value of the 'auto-vacuum' property. If auto-vacuum is
  30233 // enabled 1 is returned. Otherwise 0.
  30234 func Xsqlite3BtreeGetAutoVacuum(tls *libc.TLS, p uintptr) int32 {
  30235 	var rc int32
  30236 	Xsqlite3BtreeEnter(tls, p)
  30237 	rc = func() int32 {
  30238 		if !(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FautoVacuum) != 0) {
  30239 			return BTREE_AUTOVACUUM_NONE
  30240 		}
  30241 		return func() int32 {
  30242 			if !(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FincrVacuum) != 0) {
  30243 				return BTREE_AUTOVACUUM_FULL
  30244 			}
  30245 			return BTREE_AUTOVACUUM_INCR
  30246 		}()
  30247 	}()
  30248 	Xsqlite3BtreeLeave(tls, p)
  30249 	return rc
  30250 }
  30251 
  30252 func lockBtree(tls *libc.TLS, pBt uintptr) int32 {
  30253 	bp := tls.Alloc(12)
  30254 	defer tls.Free(12)
  30255 
  30256 	var rc int32
  30257 
  30258 	var nPage U32
  30259 
  30260 	var pageSize U32
  30261 	var usableSize U32
  30262 	var page1 uintptr
  30263 	*(*U32)(unsafe.Pointer(bp + 4)) = U32(0)
  30264 
  30265 	rc = Xsqlite3PagerSharedLock(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager)
  30266 	if !(rc != SQLITE_OK) {
  30267 		goto __1
  30268 	}
  30269 	return rc
  30270 __1:
  30271 	;
  30272 	rc = btreeGetPage(tls, pBt, uint32(1), bp, 0)
  30273 	if !(rc != SQLITE_OK) {
  30274 		goto __2
  30275 	}
  30276 	return rc
  30277 __2:
  30278 	;
  30279 	nPage = Xsqlite3Get4byte(tls, uintptr(28)+(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData)
  30280 	Xsqlite3PagerPagecount(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp+4)
  30281 	if !(nPage == U32(0) || libc.Xmemcmp(tls, uintptr(24)+(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData, uintptr(92)+(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData, uint32(4)) != 0) {
  30282 		goto __3
  30283 	}
  30284 	nPage = *(*U32)(unsafe.Pointer(bp + 4))
  30285 __3:
  30286 	;
  30287 	if !((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags&uint64(SQLITE_ResetDatabase) != uint64(0)) {
  30288 		goto __4
  30289 	}
  30290 	nPage = U32(0)
  30291 __4:
  30292 	;
  30293 	if !(nPage > U32(0)) {
  30294 		goto __5
  30295 	}
  30296 	page1 = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData
  30297 	rc = SQLITE_NOTADB
  30298 
  30299 	if !(libc.Xmemcmp(tls, page1, uintptr(unsafe.Pointer(&zMagicHeader)), uint32(16)) != 0) {
  30300 		goto __6
  30301 	}
  30302 	goto page1_init_failed
  30303 __6:
  30304 	;
  30305 	if !(int32(*(*U8)(unsafe.Pointer(page1 + 18))) > 2) {
  30306 		goto __7
  30307 	}
  30308 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_READ_ONLY)
  30309 __7:
  30310 	;
  30311 	if !(int32(*(*U8)(unsafe.Pointer(page1 + 19))) > 2) {
  30312 		goto __8
  30313 	}
  30314 	goto page1_init_failed
  30315 __8:
  30316 	;
  30317 	if !(int32(*(*U8)(unsafe.Pointer(page1 + 19))) == 2 && int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_NO_WAL == 0) {
  30318 		goto __9
  30319 	}
  30320 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
  30321 	rc = Xsqlite3PagerOpenWal(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp+8)
  30322 	if !(rc != SQLITE_OK) {
  30323 		goto __11
  30324 	}
  30325 	goto page1_init_failed
  30326 	goto __12
  30327 __11:
  30328 	;
  30329 	if !(*(*int32)(unsafe.Pointer(bp + 8)) == 0) {
  30330 		goto __13
  30331 	}
  30332 	releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp)))
  30333 	return SQLITE_OK
  30334 __13:
  30335 	;
  30336 __12:
  30337 	;
  30338 	rc = SQLITE_NOTADB
  30339 	goto __10
  30340 __9:
  30341 	;
  30342 __10:
  30343 	;
  30344 	if !(libc.Xmemcmp(tls, page1+21, ts+4058, uint32(3)) != 0) {
  30345 		goto __14
  30346 	}
  30347 	goto page1_init_failed
  30348 __14:
  30349 	;
  30350 	pageSize = U32(int32(*(*U8)(unsafe.Pointer(page1 + 16)))<<8 | int32(*(*U8)(unsafe.Pointer(page1 + 17)))<<16)
  30351 
  30352 	if !((pageSize-U32(1))&pageSize != U32(0) ||
  30353 		pageSize > U32(SQLITE_MAX_PAGE_SIZE) ||
  30354 		pageSize <= U32(256)) {
  30355 		goto __15
  30356 	}
  30357 	goto page1_init_failed
  30358 __15:
  30359 	;
  30360 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_PAGESIZE_FIXED)
  30361 
  30362 	usableSize = pageSize - U32(*(*U8)(unsafe.Pointer(page1 + 20)))
  30363 	if !(pageSize != (*BtShared)(unsafe.Pointer(pBt)).FpageSize) {
  30364 		goto __16
  30365 	}
  30366 
  30367 	releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp)))
  30368 	(*BtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize
  30369 	(*BtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize
  30370 	freeTempSpace(tls, pBt)
  30371 	rc = Xsqlite3PagerSetPagesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pBt+36,
  30372 		int32(pageSize-usableSize))
  30373 	return rc
  30374 __16:
  30375 	;
  30376 	if !(nPage > *(*U32)(unsafe.Pointer(bp + 4))) {
  30377 		goto __17
  30378 	}
  30379 	if !(Xsqlite3WritableSchema(tls, (*BtShared)(unsafe.Pointer(pBt)).Fdb) == 0) {
  30380 		goto __18
  30381 	}
  30382 	rc = Xsqlite3CorruptError(tls, 71726)
  30383 	goto page1_init_failed
  30384 	goto __19
  30385 __18:
  30386 	nPage = *(*U32)(unsafe.Pointer(bp + 4))
  30387 __19:
  30388 	;
  30389 __17:
  30390 	;
  30391 	if !(usableSize < U32(480)) {
  30392 		goto __20
  30393 	}
  30394 	goto page1_init_failed
  30395 __20:
  30396 	;
  30397 	(*BtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize
  30398 	(*BtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize
  30399 	(*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 {
  30400 		if Xsqlite3Get4byte(tls, page1+52) != 0 {
  30401 			return uint8(1)
  30402 		}
  30403 		return uint8(0)
  30404 	}()
  30405 	(*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 {
  30406 		if Xsqlite3Get4byte(tls, page1+64) != 0 {
  30407 			return uint8(1)
  30408 		}
  30409 		return uint8(0)
  30410 	}()
  30411 __5:
  30412 	;
  30413 	(*BtShared)(unsafe.Pointer(pBt)).FmaxLocal = U16(((*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32(12))*U32(64)/U32(255) - U32(23))
  30414 	(*BtShared)(unsafe.Pointer(pBt)).FminLocal = U16(((*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32(12))*U32(32)/U32(255) - U32(23))
  30415 	(*BtShared)(unsafe.Pointer(pBt)).FmaxLeaf = U16((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(35))
  30416 	(*BtShared)(unsafe.Pointer(pBt)).FminLeaf = U16(((*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32(12))*U32(32)/U32(255) - U32(23))
  30417 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FmaxLocal) > 127) {
  30418 		goto __21
  30419 	}
  30420 	(*BtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload = U8(127)
  30421 	goto __22
  30422 __21:
  30423 	(*BtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload = U8((*BtShared)(unsafe.Pointer(pBt)).FmaxLocal)
  30424 __22:
  30425 	;
  30426 	(*BtShared)(unsafe.Pointer(pBt)).FpPage1 = *(*uintptr)(unsafe.Pointer(bp))
  30427 	(*BtShared)(unsafe.Pointer(pBt)).FnPage = nPage
  30428 	return SQLITE_OK
  30429 
  30430 page1_init_failed:
  30431 	releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp)))
  30432 	(*BtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0)
  30433 	return rc
  30434 }
  30435 
  30436 func unlockBtreeIfUnused(tls *libc.TLS, pBt uintptr) {
  30437 	if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE && (*BtShared)(unsafe.Pointer(pBt)).FpPage1 != uintptr(0) {
  30438 		var pPage1 uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpPage1
  30439 
  30440 		(*BtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0)
  30441 		releasePageOne(tls, pPage1)
  30442 	}
  30443 }
  30444 
  30445 func newDatabase(tls *libc.TLS, pBt uintptr) int32 {
  30446 	var pP1 uintptr
  30447 	var data uintptr
  30448 	var rc int32
  30449 
  30450 	if (*BtShared)(unsafe.Pointer(pBt)).FnPage > U32(0) {
  30451 		return SQLITE_OK
  30452 	}
  30453 	pP1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1
  30454 
  30455 	data = (*MemPage)(unsafe.Pointer(pP1)).FaData
  30456 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pP1)).FpDbPage)
  30457 	if rc != 0 {
  30458 		return rc
  30459 	}
  30460 	libc.Xmemcpy(tls, data, uintptr(unsafe.Pointer(&zMagicHeader)), uint32(unsafe.Sizeof(zMagicHeader)))
  30461 
  30462 	*(*uint8)(unsafe.Pointer(data + 16)) = U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 8 & U32(0xff))
  30463 	*(*uint8)(unsafe.Pointer(data + 17)) = U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 16 & U32(0xff))
  30464 	*(*uint8)(unsafe.Pointer(data + 18)) = uint8(1)
  30465 	*(*uint8)(unsafe.Pointer(data + 19)) = uint8(1)
  30466 
  30467 	*(*uint8)(unsafe.Pointer(data + 20)) = U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize - (*BtShared)(unsafe.Pointer(pBt)).FusableSize)
  30468 	*(*uint8)(unsafe.Pointer(data + 21)) = uint8(64)
  30469 	*(*uint8)(unsafe.Pointer(data + 22)) = uint8(32)
  30470 	*(*uint8)(unsafe.Pointer(data + 23)) = uint8(32)
  30471 	libc.Xmemset(tls, data+24, 0, uint32(100-24))
  30472 	zeroPage(tls, pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA)
  30473 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_PAGESIZE_FIXED)
  30474 
  30475 	Xsqlite3Put4byte(tls, data+52, uint32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum))
  30476 	Xsqlite3Put4byte(tls, data+64, uint32((*BtShared)(unsafe.Pointer(pBt)).FincrVacuum))
  30477 	(*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(1)
  30478 	*(*uint8)(unsafe.Pointer(data + 31)) = uint8(1)
  30479 	return SQLITE_OK
  30480 }
  30481 
  30482 // Initialize the first page of the database file (creating a database
  30483 // consisting of a single page and no schema objects). Return SQLITE_OK
  30484 // if successful, or an SQLite error code otherwise.
  30485 func Xsqlite3BtreeNewDb(tls *libc.TLS, p uintptr) int32 {
  30486 	var rc int32
  30487 	Xsqlite3BtreeEnter(tls, p)
  30488 	(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FnPage = U32(0)
  30489 	rc = newDatabase(tls, (*Btree)(unsafe.Pointer(p)).FpBt)
  30490 	Xsqlite3BtreeLeave(tls, p)
  30491 	return rc
  30492 }
  30493 
  30494 // Attempt to start a new transaction. A write-transaction
  30495 // is started if the second argument is nonzero, otherwise a read-
  30496 // transaction.  If the second argument is 2 or more and exclusive
  30497 // transaction is started, meaning that no other process is allowed
  30498 // to access the database.  A preexisting transaction may not be
  30499 // upgraded to exclusive by calling this routine a second time - the
  30500 // exclusivity flag only works for a new transaction.
  30501 //
  30502 // A write-transaction must be started before attempting any
  30503 // changes to the database.  None of the following routines
  30504 // will work unless a transaction is started first:
  30505 //
  30506 //	sqlite3BtreeCreateTable()
  30507 //	sqlite3BtreeCreateIndex()
  30508 //	sqlite3BtreeClearTable()
  30509 //	sqlite3BtreeDropTable()
  30510 //	sqlite3BtreeInsert()
  30511 //	sqlite3BtreeDelete()
  30512 //	sqlite3BtreeUpdateMeta()
  30513 //
  30514 // If an initial attempt to acquire the lock fails because of lock contention
  30515 // and the database was previously unlocked, then invoke the busy handler
  30516 // if there is one.  But if there was previously a read-lock, do not
  30517 // invoke the busy handler - just return SQLITE_BUSY.  SQLITE_BUSY is
  30518 // returned when there is already a read-lock in order to avoid a deadlock.
  30519 //
  30520 // Suppose there are two processes A and B.  A has a read lock and B has
  30521 // a reserved lock.  B tries to promote to exclusive but is blocked because
  30522 // of A's read lock.  A tries to promote to reserved but is blocked by B.
  30523 // One or the other of the two processes must give way or there can be
  30524 // no progress.  By returning SQLITE_BUSY and not invoking the busy callback
  30525 // when A already has a read lock, we encourage A to give up and let B
  30526 // proceed.
  30527 func Xsqlite3BtreeBeginTrans(tls *libc.TLS, p uintptr, wrflag int32, pSchemaVersion uintptr) int32 {
  30528 	var pBt uintptr
  30529 	var pPager uintptr
  30530 	var rc int32
  30531 	var pIter uintptr
  30532 	var pBlock uintptr
  30533 	var pPage1 uintptr
  30534 	pBt = (*Btree)(unsafe.Pointer(p)).FpBt
  30535 	pPager = (*BtShared)(unsafe.Pointer(pBt)).FpPager
  30536 	rc = SQLITE_OK
  30537 
  30538 	Xsqlite3BtreeEnter(tls, p)
  30539 
  30540 	if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE || int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_READ && !(wrflag != 0)) {
  30541 		goto __1
  30542 	}
  30543 	goto trans_begun
  30544 __1:
  30545 	;
  30546 	if !((*Sqlite3)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).Fdb)).Fflags&uint64(SQLITE_ResetDatabase) != 0 &&
  30547 		int32(Xsqlite3PagerIsreadonly(tls, pPager)) == 0) {
  30548 		goto __2
  30549 	}
  30550 	*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_READ_ONLY))
  30551 __2:
  30552 	;
  30553 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_READ_ONLY != 0 && wrflag != 0) {
  30554 		goto __3
  30555 	}
  30556 	rc = SQLITE_READONLY
  30557 	goto trans_begun
  30558 __3:
  30559 	;
  30560 	pBlock = uintptr(0)
  30561 
  30562 	if !(wrflag != 0 && int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_WRITE ||
  30563 		int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_PENDING != 0) {
  30564 		goto __4
  30565 	}
  30566 	pBlock = (*Btree)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb
  30567 	goto __5
  30568 __4:
  30569 	if !(wrflag > 1) {
  30570 		goto __6
  30571 	}
  30572 	pIter = (*BtShared)(unsafe.Pointer(pBt)).FpLock
  30573 __7:
  30574 	if !(pIter != 0) {
  30575 		goto __9
  30576 	}
  30577 	if !((*BtLock)(unsafe.Pointer(pIter)).FpBtree != p) {
  30578 		goto __10
  30579 	}
  30580 	pBlock = (*Btree)(unsafe.Pointer((*BtLock)(unsafe.Pointer(pIter)).FpBtree)).Fdb
  30581 	goto __9
  30582 __10:
  30583 	;
  30584 	goto __8
  30585 __8:
  30586 	pIter = (*BtLock)(unsafe.Pointer(pIter)).FpNext
  30587 	goto __7
  30588 	goto __9
  30589 __9:
  30590 	;
  30591 __6:
  30592 	;
  30593 __5:
  30594 	;
  30595 	if !(pBlock != 0) {
  30596 		goto __11
  30597 	}
  30598 	Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, pBlock)
  30599 	rc = SQLITE_LOCKED | int32(1)<<8
  30600 	goto trans_begun
  30601 __11:
  30602 	;
  30603 	rc = querySharedCacheTableLock(tls, p, uint32(SCHEMA_ROOT), uint8(READ_LOCK))
  30604 	if !(SQLITE_OK != rc) {
  30605 		goto __12
  30606 	}
  30607 	goto trans_begun
  30608 __12:
  30609 	;
  30610 	*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_INITIALLY_EMPTY))
  30611 	if !((*BtShared)(unsafe.Pointer(pBt)).FnPage == U32(0)) {
  30612 		goto __13
  30613 	}
  30614 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_INITIALLY_EMPTY)
  30615 __13:
  30616 	;
  30617 __14:
  30618 	;
  30619 __17:
  30620 	if !((*BtShared)(unsafe.Pointer(pBt)).FpPage1 == uintptr(0) && SQLITE_OK == libc.AssignInt32(&rc, lockBtree(tls, pBt))) {
  30621 		goto __18
  30622 	}
  30623 	goto __17
  30624 __18:
  30625 	;
  30626 	if !(rc == SQLITE_OK && wrflag != 0) {
  30627 		goto __19
  30628 	}
  30629 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_READ_ONLY != 0) {
  30630 		goto __20
  30631 	}
  30632 	rc = SQLITE_READONLY
  30633 	goto __21
  30634 __20:
  30635 	rc = Xsqlite3PagerBegin(tls, pPager, libc.Bool32(wrflag > 1), Xsqlite3TempInMemory(tls, (*Btree)(unsafe.Pointer(p)).Fdb))
  30636 	if !(rc == SQLITE_OK) {
  30637 		goto __22
  30638 	}
  30639 	rc = newDatabase(tls, pBt)
  30640 	goto __23
  30641 __22:
  30642 	if !(rc == SQLITE_BUSY|int32(2)<<8 && int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE) {
  30643 		goto __24
  30644 	}
  30645 
  30646 	rc = SQLITE_BUSY
  30647 __24:
  30648 	;
  30649 __23:
  30650 	;
  30651 __21:
  30652 	;
  30653 __19:
  30654 	;
  30655 	if !(rc != SQLITE_OK) {
  30656 		goto __25
  30657 	}
  30658 
  30659 	unlockBtreeIfUnused(tls, pBt)
  30660 __25:
  30661 	;
  30662 	goto __15
  30663 __15:
  30664 	if rc&0xFF == SQLITE_BUSY && int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE && btreeInvokeBusyHandler(tls, pBt) != 0 {
  30665 		goto __14
  30666 	}
  30667 	goto __16
  30668 __16:
  30669 	;
  30670 	if !(rc == SQLITE_OK) {
  30671 		goto __26
  30672 	}
  30673 	if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE) {
  30674 		goto __27
  30675 	}
  30676 	(*BtShared)(unsafe.Pointer(pBt)).FnTransaction++
  30677 	if !((*Btree)(unsafe.Pointer(p)).Fsharable != 0) {
  30678 		goto __28
  30679 	}
  30680 
  30681 	(*Btree)(unsafe.Pointer(p)).Flock.FeLock = U8(READ_LOCK)
  30682 	(*Btree)(unsafe.Pointer(p)).Flock.FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpLock
  30683 	(*BtShared)(unsafe.Pointer(pBt)).FpLock = p + 32
  30684 __28:
  30685 	;
  30686 __27:
  30687 	;
  30688 	(*Btree)(unsafe.Pointer(p)).FinTrans = func() uint8 {
  30689 		if wrflag != 0 {
  30690 			return uint8(TRANS_WRITE)
  30691 		}
  30692 		return uint8(TRANS_READ)
  30693 	}()
  30694 	if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) > int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction)) {
  30695 		goto __29
  30696 	}
  30697 	(*BtShared)(unsafe.Pointer(pBt)).FinTransaction = (*Btree)(unsafe.Pointer(p)).FinTrans
  30698 __29:
  30699 	;
  30700 	if !(wrflag != 0) {
  30701 		goto __30
  30702 	}
  30703 	pPage1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1
  30704 
  30705 	(*BtShared)(unsafe.Pointer(pBt)).FpWriter = p
  30706 	*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_EXCLUSIVE))
  30707 	if !(wrflag > 1) {
  30708 		goto __31
  30709 	}
  30710 	*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_EXCLUSIVE)
  30711 __31:
  30712 	;
  30713 	if !((*BtShared)(unsafe.Pointer(pBt)).FnPage != Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+28)) {
  30714 		goto __32
  30715 	}
  30716 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage1)).FpDbPage)
  30717 	if !(rc == SQLITE_OK) {
  30718 		goto __33
  30719 	}
  30720 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+28, (*BtShared)(unsafe.Pointer(pBt)).FnPage)
  30721 __33:
  30722 	;
  30723 __32:
  30724 	;
  30725 __30:
  30726 	;
  30727 __26:
  30728 	;
  30729 trans_begun:
  30730 	if !(rc == SQLITE_OK) {
  30731 		goto __34
  30732 	}
  30733 	if !(pSchemaVersion != 0) {
  30734 		goto __35
  30735 	}
  30736 	*(*int32)(unsafe.Pointer(pSchemaVersion)) = int32(Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+40))
  30737 __35:
  30738 	;
  30739 	if !(wrflag != 0) {
  30740 		goto __36
  30741 	}
  30742 
  30743 	rc = Xsqlite3PagerOpenSavepoint(tls, pPager, (*Sqlite3)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).Fdb)).FnSavepoint)
  30744 __36:
  30745 	;
  30746 __34:
  30747 	;
  30748 	Xsqlite3BtreeLeave(tls, p)
  30749 	return rc
  30750 }
  30751 
  30752 func setChildPtrmaps(tls *libc.TLS, pPage uintptr) int32 {
  30753 	bp := tls.Alloc(4)
  30754 	defer tls.Free(4)
  30755 
  30756 	var i int32
  30757 	var nCell int32
  30758 
  30759 	var pBt uintptr = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  30760 	var pgno Pgno = (*MemPage)(unsafe.Pointer(pPage)).Fpgno
  30761 
  30762 	if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 {
  30763 		*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
  30764 	} else {
  30765 		*(*int32)(unsafe.Pointer(bp)) = btreeInitPage(tls, pPage)
  30766 	}
  30767 	if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
  30768 		return *(*int32)(unsafe.Pointer(bp))
  30769 	}
  30770 	nCell = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  30771 
  30772 	for i = 0; i < nCell; i++ {
  30773 		var pCell uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*i))))))
  30774 
  30775 		ptrmapPutOvflPtr(tls, pPage, pPage, pCell, bp)
  30776 
  30777 		if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  30778 			var childPgno Pgno = Xsqlite3Get4byte(tls, pCell)
  30779 			ptrmapPut(tls, pBt, childPgno, uint8(PTRMAP_BTREE), pgno, bp)
  30780 		}
  30781 	}
  30782 
  30783 	if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  30784 		var childPgno Pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8))
  30785 		ptrmapPut(tls, pBt, childPgno, uint8(PTRMAP_BTREE), pgno, bp)
  30786 	}
  30787 
  30788 	return *(*int32)(unsafe.Pointer(bp))
  30789 }
  30790 
  30791 func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType U8) int32 {
  30792 	bp := tls.Alloc(24)
  30793 	defer tls.Free(24)
  30794 
  30795 	if int32(eType) == PTRMAP_OVERFLOW2 {
  30796 		if Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData) != iFrom {
  30797 			return Xsqlite3CorruptError(tls, 72147)
  30798 		}
  30799 		Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData, iTo)
  30800 	} else {
  30801 		var i int32
  30802 		var nCell int32
  30803 		var rc int32
  30804 
  30805 		if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 {
  30806 			rc = SQLITE_OK
  30807 		} else {
  30808 			rc = btreeInitPage(tls, pPage)
  30809 		}
  30810 		if rc != 0 {
  30811 			return rc
  30812 		}
  30813 		nCell = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  30814 
  30815 		for i = 0; i < nCell; i++ {
  30816 			var pCell uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*i))))))
  30817 			if int32(eType) == PTRMAP_OVERFLOW1 {
  30818 				(*struct {
  30819 					f func(*libc.TLS, uintptr, uintptr, uintptr)
  30820 				})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, pCell, bp)
  30821 				if U32((*CellInfo)(unsafe.Pointer(bp)).FnLocal) < (*CellInfo)(unsafe.Pointer(bp)).FnPayload {
  30822 					if pCell+uintptr((*CellInfo)(unsafe.Pointer(bp)).FnSize) > (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) {
  30823 						return Xsqlite3CorruptError(tls, 72166)
  30824 					}
  30825 					if iFrom == Xsqlite3Get4byte(tls, pCell+uintptr((*CellInfo)(unsafe.Pointer(bp)).FnSize)-uintptr(4)) {
  30826 						Xsqlite3Put4byte(tls, pCell+uintptr((*CellInfo)(unsafe.Pointer(bp)).FnSize)-uintptr(4), iTo)
  30827 						break
  30828 					}
  30829 				}
  30830 			} else {
  30831 				if pCell+uintptr(4) > (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) {
  30832 					return Xsqlite3CorruptError(tls, 72175)
  30833 				}
  30834 				if Xsqlite3Get4byte(tls, pCell) == iFrom {
  30835 					Xsqlite3Put4byte(tls, pCell, iTo)
  30836 					break
  30837 				}
  30838 			}
  30839 		}
  30840 
  30841 		if i == nCell {
  30842 			if int32(eType) != PTRMAP_BTREE || Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)) != iFrom {
  30843 				return Xsqlite3CorruptError(tls, 72187)
  30844 			}
  30845 			Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8), iTo)
  30846 		}
  30847 	}
  30848 	return SQLITE_OK
  30849 }
  30850 
  30851 func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPage Pgno, iFreePage Pgno, isCommit int32) int32 {
  30852 	bp := tls.Alloc(8)
  30853 	defer tls.Free(8)
  30854 
  30855 	var iDbPage Pgno = (*MemPage)(unsafe.Pointer(pDbPage)).Fpgno
  30856 	var pPager uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpPager
  30857 
  30858 	if iDbPage < Pgno(3) {
  30859 		return Xsqlite3CorruptError(tls, 72222)
  30860 	}
  30861 
  30862 	*(*int32)(unsafe.Pointer(bp)) = Xsqlite3PagerMovepage(tls, pPager, (*MemPage)(unsafe.Pointer(pDbPage)).FpDbPage, iFreePage, isCommit)
  30863 	if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
  30864 		return *(*int32)(unsafe.Pointer(bp))
  30865 	}
  30866 	(*MemPage)(unsafe.Pointer(pDbPage)).Fpgno = iFreePage
  30867 
  30868 	if int32(eType) == PTRMAP_BTREE || int32(eType) == PTRMAP_ROOTPAGE {
  30869 		*(*int32)(unsafe.Pointer(bp)) = setChildPtrmaps(tls, pDbPage)
  30870 		if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
  30871 			return *(*int32)(unsafe.Pointer(bp))
  30872 		}
  30873 	} else {
  30874 		var nextOvfl Pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pDbPage)).FaData)
  30875 		if nextOvfl != Pgno(0) {
  30876 			ptrmapPut(tls, pBt, nextOvfl, uint8(PTRMAP_OVERFLOW2), iFreePage, bp)
  30877 			if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
  30878 				return *(*int32)(unsafe.Pointer(bp))
  30879 			}
  30880 		}
  30881 	}
  30882 
  30883 	if int32(eType) != PTRMAP_ROOTPAGE {
  30884 		*(*int32)(unsafe.Pointer(bp)) = btreeGetPage(tls, pBt, iPtrPage, bp+4, 0)
  30885 		if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
  30886 			return *(*int32)(unsafe.Pointer(bp))
  30887 		}
  30888 		*(*int32)(unsafe.Pointer(bp)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpDbPage)
  30889 		if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
  30890 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
  30891 			return *(*int32)(unsafe.Pointer(bp))
  30892 		}
  30893 		*(*int32)(unsafe.Pointer(bp)) = modifyPagePointer(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), iDbPage, iFreePage, eType)
  30894 		releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
  30895 		if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
  30896 			ptrmapPut(tls, pBt, iFreePage, eType, iPtrPage, bp)
  30897 		}
  30898 	}
  30899 	return *(*int32)(unsafe.Pointer(bp))
  30900 }
  30901 
  30902 func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit int32) int32 {
  30903 	bp := tls.Alloc(28)
  30904 	defer tls.Free(28)
  30905 
  30906 	var nFreeList Pgno
  30907 	var rc int32
  30908 
  30909 	if !(ptrmapPageno(tls, pBt, iLastPg) == iLastPg) && iLastPg != U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  30910 		nFreeList = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)
  30911 		if nFreeList == Pgno(0) {
  30912 			return SQLITE_DONE
  30913 		}
  30914 
  30915 		rc = ptrmapGet(tls, pBt, iLastPg, bp, bp+4)
  30916 		if rc != SQLITE_OK {
  30917 			return rc
  30918 		}
  30919 		if int32(*(*U8)(unsafe.Pointer(bp))) == PTRMAP_ROOTPAGE {
  30920 			return Xsqlite3CorruptError(tls, 72320)
  30921 		}
  30922 
  30923 		if int32(*(*U8)(unsafe.Pointer(bp))) == PTRMAP_FREEPAGE {
  30924 			if bCommit == 0 {
  30925 				rc = allocateBtreePage(tls, pBt, bp+8, bp+12, iLastPg, uint8(BTALLOC_EXACT))
  30926 				if rc != SQLITE_OK {
  30927 					return rc
  30928 				}
  30929 
  30930 				releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  30931 			}
  30932 		} else {
  30933 			var eMode U8 = U8(BTALLOC_ANY)
  30934 			var iNear Pgno = Pgno(0)
  30935 
  30936 			rc = btreeGetPage(tls, pBt, iLastPg, bp+16, 0)
  30937 			if rc != SQLITE_OK {
  30938 				return rc
  30939 			}
  30940 
  30941 			if bCommit == 0 {
  30942 				eMode = U8(BTALLOC_LE)
  30943 				iNear = nFin
  30944 			}
  30945 			for __ccgo := true; __ccgo; __ccgo = bCommit != 0 && *(*Pgno)(unsafe.Pointer(bp + 24)) > nFin {
  30946 				var dbSize Pgno = btreePagecount(tls, pBt)
  30947 				rc = allocateBtreePage(tls, pBt, bp+20, bp+24, iNear, eMode)
  30948 				if rc != SQLITE_OK {
  30949 					releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  30950 					return rc
  30951 				}
  30952 				releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 20)))
  30953 				if *(*Pgno)(unsafe.Pointer(bp + 24)) > dbSize {
  30954 					releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  30955 					return Xsqlite3CorruptError(tls, 72372)
  30956 				}
  30957 			}
  30958 
  30959 			rc = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 16)), *(*U8)(unsafe.Pointer(bp)), *(*Pgno)(unsafe.Pointer(bp + 4)), *(*Pgno)(unsafe.Pointer(bp + 24)), bCommit)
  30960 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  30961 			if rc != SQLITE_OK {
  30962 				return rc
  30963 			}
  30964 		}
  30965 	}
  30966 
  30967 	if bCommit == 0 {
  30968 		for __ccgo1 := true; __ccgo1; __ccgo1 = iLastPg == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) || ptrmapPageno(tls, pBt, iLastPg) == iLastPg {
  30969 			iLastPg--
  30970 		}
  30971 		(*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(1)
  30972 		(*BtShared)(unsafe.Pointer(pBt)).FnPage = iLastPg
  30973 	}
  30974 	return SQLITE_OK
  30975 }
  30976 
  30977 func finalDbSize(tls *libc.TLS, pBt uintptr, nOrig Pgno, nFree Pgno) Pgno {
  30978 	var nEntry int32
  30979 	var nPtrmap Pgno
  30980 	var nFin Pgno
  30981 
  30982 	nEntry = int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize / U32(5))
  30983 	nPtrmap = (nFree - nOrig + ptrmapPageno(tls, pBt, nOrig) + Pgno(nEntry)) / Pgno(nEntry)
  30984 	nFin = nOrig - nFree - nPtrmap
  30985 	if nOrig > U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) && nFin < U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  30986 		nFin--
  30987 	}
  30988 	for ptrmapPageno(tls, pBt, nFin) == nFin || nFin == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  30989 		nFin--
  30990 	}
  30991 
  30992 	return nFin
  30993 }
  30994 
  30995 // A write-transaction must be opened before calling this function.
  30996 // It performs a single unit of work towards an incremental vacuum.
  30997 //
  30998 // If the incremental vacuum is finished after this function has run,
  30999 // SQLITE_DONE is returned. If it is not finished, but no error occurred,
  31000 // SQLITE_OK is returned. Otherwise an SQLite error code.
  31001 func Xsqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) int32 {
  31002 	var rc int32
  31003 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31004 
  31005 	Xsqlite3BtreeEnter(tls, p)
  31006 
  31007 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) != 0) {
  31008 		rc = SQLITE_DONE
  31009 	} else {
  31010 		var nOrig Pgno = btreePagecount(tls, pBt)
  31011 		var nFree Pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)
  31012 		var nFin Pgno = finalDbSize(tls, pBt, nOrig, nFree)
  31013 
  31014 		if nOrig < nFin || nFree >= nOrig {
  31015 			rc = Xsqlite3CorruptError(tls, 72440)
  31016 		} else if nFree > Pgno(0) {
  31017 			rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0))
  31018 			if rc == SQLITE_OK {
  31019 				invalidateAllOverflowCache(tls, pBt)
  31020 				rc = incrVacuumStep(tls, pBt, nFin, nOrig, 0)
  31021 			}
  31022 			if rc == SQLITE_OK {
  31023 				rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
  31024 				Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+28, (*BtShared)(unsafe.Pointer(pBt)).FnPage)
  31025 			}
  31026 		} else {
  31027 			rc = SQLITE_DONE
  31028 		}
  31029 	}
  31030 	Xsqlite3BtreeLeave(tls, p)
  31031 	return rc
  31032 }
  31033 
  31034 func autoVacuumCommit(tls *libc.TLS, p uintptr) int32 {
  31035 	var rc int32 = SQLITE_OK
  31036 	var pPager uintptr
  31037 	var pBt uintptr
  31038 	var db uintptr
  31039 
  31040 	pBt = (*Btree)(unsafe.Pointer(p)).FpBt
  31041 	pPager = (*BtShared)(unsafe.Pointer(pBt)).FpPager
  31042 
  31043 	invalidateAllOverflowCache(tls, pBt)
  31044 
  31045 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FincrVacuum) != 0) {
  31046 		var nFin Pgno
  31047 		var nFree Pgno
  31048 		var nVac Pgno
  31049 		var iFree Pgno
  31050 		var nOrig Pgno
  31051 
  31052 		nOrig = btreePagecount(tls, pBt)
  31053 		if ptrmapPageno(tls, pBt, nOrig) == nOrig || nOrig == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  31054 			return Xsqlite3CorruptError(tls, 72491)
  31055 		}
  31056 
  31057 		nFree = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)
  31058 		db = (*Btree)(unsafe.Pointer(p)).Fdb
  31059 		if (*Sqlite3)(unsafe.Pointer(db)).FxAutovacPages != 0 {
  31060 			var iDb int32
  31061 			for iDb = 0; iDb < (*Sqlite3)(unsafe.Pointer(db)).FnDb; iDb++ {
  31062 				if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpBt == p {
  31063 					break
  31064 				}
  31065 			}
  31066 			nVac = (*struct {
  31067 				f func(*libc.TLS, uintptr, uintptr, U32, U32, U32) uint32
  31068 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxAutovacPages})).f(tls,
  31069 				(*Sqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg,
  31070 				(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName,
  31071 				nOrig,
  31072 				nFree,
  31073 				(*BtShared)(unsafe.Pointer(pBt)).FpageSize)
  31074 			if nVac > nFree {
  31075 				nVac = nFree
  31076 			}
  31077 			if nVac == Pgno(0) {
  31078 				return SQLITE_OK
  31079 			}
  31080 		} else {
  31081 			nVac = nFree
  31082 		}
  31083 		nFin = finalDbSize(tls, pBt, nOrig, nVac)
  31084 		if nFin > nOrig {
  31085 			return Xsqlite3CorruptError(tls, 72518)
  31086 		}
  31087 		if nFin < nOrig {
  31088 			rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0))
  31089 		}
  31090 		for iFree = nOrig; iFree > nFin && rc == SQLITE_OK; iFree-- {
  31091 			rc = incrVacuumStep(tls, pBt, nFin, iFree, libc.Bool32(nVac == nFree))
  31092 		}
  31093 		if (rc == SQLITE_DONE || rc == SQLITE_OK) && nFree > Pgno(0) {
  31094 			rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
  31095 			if nVac == nFree {
  31096 				Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32, uint32(0))
  31097 				Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36, uint32(0))
  31098 			}
  31099 			Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+28, nFin)
  31100 			(*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(1)
  31101 			(*BtShared)(unsafe.Pointer(pBt)).FnPage = nFin
  31102 		}
  31103 		if rc != SQLITE_OK {
  31104 			Xsqlite3PagerRollback(tls, pPager)
  31105 		}
  31106 	}
  31107 
  31108 	return rc
  31109 }
  31110 
  31111 // This routine does the first phase of a two-phase commit.  This routine
  31112 // causes a rollback journal to be created (if it does not already exist)
  31113 // and populated with enough information so that if a power loss occurs
  31114 // the database can be restored to its original state by playing back
  31115 // the journal.  Then the contents of the journal are flushed out to
  31116 // the disk.  After the journal is safely on oxide, the changes to the
  31117 // database are written into the database file and flushed to oxide.
  31118 // At the end of this call, the rollback journal still exists on the
  31119 // disk and we are still holding all locks, so the transaction has not
  31120 // committed.  See sqlite3BtreeCommitPhaseTwo() for the second phase of the
  31121 // commit process.
  31122 //
  31123 // This call is a no-op if no write-transaction is currently active on pBt.
  31124 //
  31125 // Otherwise, sync the database file for the btree pBt. zSuperJrnl points to
  31126 // the name of a super-journal file that should be written into the
  31127 // individual journal file, or is NULL, indicating no super-journal file
  31128 // (single database transaction).
  31129 //
  31130 // When this is called, the super-journal should already have been
  31131 // created, populated with this journal pointer and synced to disk.
  31132 //
  31133 // Once this is routine has returned, the only thing required to commit
  31134 // the write-transaction for this database file is to delete the journal.
  31135 func Xsqlite3BtreeCommitPhaseOne(tls *libc.TLS, p uintptr, zSuperJrnl uintptr) int32 {
  31136 	var rc int32 = SQLITE_OK
  31137 	if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE {
  31138 		var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31139 		Xsqlite3BtreeEnter(tls, p)
  31140 		if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  31141 			rc = autoVacuumCommit(tls, p)
  31142 			if rc != SQLITE_OK {
  31143 				Xsqlite3BtreeLeave(tls, p)
  31144 				return rc
  31145 			}
  31146 		}
  31147 		if (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate != 0 {
  31148 			Xsqlite3PagerTruncateImage(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*BtShared)(unsafe.Pointer(pBt)).FnPage)
  31149 		}
  31150 		rc = Xsqlite3PagerCommitPhaseOne(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, zSuperJrnl, 0)
  31151 		Xsqlite3BtreeLeave(tls, p)
  31152 	}
  31153 	return rc
  31154 }
  31155 
  31156 func btreeEndTransaction(tls *libc.TLS, p uintptr) {
  31157 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31158 	var db uintptr = (*Btree)(unsafe.Pointer(p)).Fdb
  31159 
  31160 	(*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(0)
  31161 	if int32((*Btree)(unsafe.Pointer(p)).FinTrans) > TRANS_NONE && (*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1 {
  31162 		downgradeAllSharedCacheTableLocks(tls, p)
  31163 		(*Btree)(unsafe.Pointer(p)).FinTrans = U8(TRANS_READ)
  31164 	} else {
  31165 		if int32((*Btree)(unsafe.Pointer(p)).FinTrans) != TRANS_NONE {
  31166 			clearAllSharedCacheTableLocks(tls, p)
  31167 			(*BtShared)(unsafe.Pointer(pBt)).FnTransaction--
  31168 			if 0 == (*BtShared)(unsafe.Pointer(pBt)).FnTransaction {
  31169 				(*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(TRANS_NONE)
  31170 			}
  31171 		}
  31172 
  31173 		(*Btree)(unsafe.Pointer(p)).FinTrans = U8(TRANS_NONE)
  31174 		unlockBtreeIfUnused(tls, pBt)
  31175 	}
  31176 
  31177 }
  31178 
  31179 // Commit the transaction currently in progress.
  31180 //
  31181 // This routine implements the second phase of a 2-phase commit.  The
  31182 // sqlite3BtreeCommitPhaseOne() routine does the first phase and should
  31183 // be invoked prior to calling this routine.  The sqlite3BtreeCommitPhaseOne()
  31184 // routine did all the work of writing information out to disk and flushing the
  31185 // contents so that they are written onto the disk platter.  All this
  31186 // routine has to do is delete or truncate or zero the header in the
  31187 // the rollback journal (which causes the transaction to commit) and
  31188 // drop locks.
  31189 //
  31190 // Normally, if an error occurs while the pager layer is attempting to
  31191 // finalize the underlying journal file, this function returns an error and
  31192 // the upper layer will attempt a rollback. However, if the second argument
  31193 // is non-zero then this b-tree transaction is part of a multi-file
  31194 // transaction. In this case, the transaction has already been committed
  31195 // (by deleting a super-journal file) and the caller will ignore this
  31196 // functions return code. So, even if an error occurs in the pager layer,
  31197 // reset the b-tree objects internal state to indicate that the write
  31198 // transaction has been closed. This is quite safe, as the pager will have
  31199 // transitioned to the error state.
  31200 //
  31201 // This will release the write lock on the database file.  If there
  31202 // are no active cursors, it also releases the read lock.
  31203 func Xsqlite3BtreeCommitPhaseTwo(tls *libc.TLS, p uintptr, bCleanup int32) int32 {
  31204 	if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE {
  31205 		return SQLITE_OK
  31206 	}
  31207 	Xsqlite3BtreeEnter(tls, p)
  31208 
  31209 	if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE {
  31210 		var rc int32
  31211 		var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31212 
  31213 		rc = Xsqlite3PagerCommitPhaseTwo(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager)
  31214 		if rc != SQLITE_OK && bCleanup == 0 {
  31215 			Xsqlite3BtreeLeave(tls, p)
  31216 			return rc
  31217 		}
  31218 		(*Btree)(unsafe.Pointer(p)).FiBDataVersion--
  31219 		(*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(TRANS_READ)
  31220 		btreeClearHasContent(tls, pBt)
  31221 	}
  31222 
  31223 	btreeEndTransaction(tls, p)
  31224 	Xsqlite3BtreeLeave(tls, p)
  31225 	return SQLITE_OK
  31226 }
  31227 
  31228 // Do both phases of a commit.
  31229 func Xsqlite3BtreeCommit(tls *libc.TLS, p uintptr) int32 {
  31230 	var rc int32
  31231 	Xsqlite3BtreeEnter(tls, p)
  31232 	rc = Xsqlite3BtreeCommitPhaseOne(tls, p, uintptr(0))
  31233 	if rc == SQLITE_OK {
  31234 		rc = Xsqlite3BtreeCommitPhaseTwo(tls, p, 0)
  31235 	}
  31236 	Xsqlite3BtreeLeave(tls, p)
  31237 	return rc
  31238 }
  31239 
  31240 // This routine sets the state to CURSOR_FAULT and the error
  31241 // code to errCode for every cursor on any BtShared that pBtree
  31242 // references.  Or if the writeOnly flag is set to 1, then only
  31243 // trip write cursors and leave read cursors unchanged.
  31244 //
  31245 // Every cursor is a candidate to be tripped, including cursors
  31246 // that belong to other database connections that happen to be
  31247 // sharing the cache with pBtree.
  31248 //
  31249 // This routine gets called when a rollback occurs. If the writeOnly
  31250 // flag is true, then only write-cursors need be tripped - read-only
  31251 // cursors save their current positions so that they may continue
  31252 // following the rollback. Or, if writeOnly is false, all cursors are
  31253 // tripped. In general, writeOnly is false if the transaction being
  31254 // rolled back modified the database schema. In this case b-tree root
  31255 // pages may be moved or deleted from the database altogether, making
  31256 // it unsafe for read cursors to continue.
  31257 //
  31258 // If the writeOnly flag is true and an error is encountered while
  31259 // saving the current position of a read-only cursor, all cursors,
  31260 // including all read-cursors are tripped.
  31261 //
  31262 // SQLITE_OK is returned if successful, or if an error occurs while
  31263 // saving a cursor position, an SQLite error code.
  31264 func Xsqlite3BtreeTripAllCursors(tls *libc.TLS, pBtree uintptr, errCode int32, writeOnly int32) int32 {
  31265 	var p uintptr
  31266 	var rc int32 = SQLITE_OK
  31267 
  31268 	if pBtree != 0 {
  31269 		Xsqlite3BtreeEnter(tls, pBtree)
  31270 		for p = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext {
  31271 			if writeOnly != 0 && int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags)&BTCF_WriteFlag == 0 {
  31272 				if int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID || int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_SKIPNEXT {
  31273 					rc = saveCursorPosition(tls, p)
  31274 					if rc != SQLITE_OK {
  31275 						Xsqlite3BtreeTripAllCursors(tls, pBtree, rc, 0)
  31276 						break
  31277 					}
  31278 				}
  31279 			} else {
  31280 				Xsqlite3BtreeClearCursor(tls, p)
  31281 				(*BtCursor)(unsafe.Pointer(p)).FeState = U8(CURSOR_FAULT)
  31282 				(*BtCursor)(unsafe.Pointer(p)).FskipNext = errCode
  31283 			}
  31284 			btreeReleaseAllCursorPages(tls, p)
  31285 		}
  31286 		Xsqlite3BtreeLeave(tls, pBtree)
  31287 	}
  31288 	return rc
  31289 }
  31290 
  31291 func btreeSetNPage(tls *libc.TLS, pBt uintptr, pPage1 uintptr) {
  31292 	bp := tls.Alloc(4)
  31293 	defer tls.Free(4)
  31294 
  31295 	*(*int32)(unsafe.Pointer(bp)) = int32(Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+28))
  31296 
  31297 	if *(*int32)(unsafe.Pointer(bp)) == 0 {
  31298 		Xsqlite3PagerPagecount(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp)
  31299 	}
  31300 
  31301 	(*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(*(*int32)(unsafe.Pointer(bp)))
  31302 }
  31303 
  31304 // Rollback the transaction in progress.
  31305 //
  31306 // If tripCode is not SQLITE_OK then cursors will be invalidated (tripped).
  31307 // Only write cursors are tripped if writeOnly is true but all cursors are
  31308 // tripped if writeOnly is false.  Any attempt to use
  31309 // a tripped cursor will result in an error.
  31310 //
  31311 // This will release the write lock on the database file.  If there
  31312 // are no active cursors, it also releases the read lock.
  31313 func Xsqlite3BtreeRollback(tls *libc.TLS, p uintptr, tripCode int32, writeOnly int32) int32 {
  31314 	bp := tls.Alloc(4)
  31315 	defer tls.Free(4)
  31316 
  31317 	var rc int32
  31318 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31319 
  31320 	Xsqlite3BtreeEnter(tls, p)
  31321 	if tripCode == SQLITE_OK {
  31322 		rc = libc.AssignInt32(&tripCode, saveAllCursors(tls, pBt, uint32(0), uintptr(0)))
  31323 		if rc != 0 {
  31324 			writeOnly = 0
  31325 		}
  31326 	} else {
  31327 		rc = SQLITE_OK
  31328 	}
  31329 	if tripCode != 0 {
  31330 		var rc2 int32 = Xsqlite3BtreeTripAllCursors(tls, p, tripCode, writeOnly)
  31331 
  31332 		if rc2 != SQLITE_OK {
  31333 			rc = rc2
  31334 		}
  31335 	}
  31336 
  31337 	if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE {
  31338 		var rc2 int32
  31339 
  31340 		rc2 = Xsqlite3PagerRollback(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager)
  31341 		if rc2 != SQLITE_OK {
  31342 			rc = rc2
  31343 		}
  31344 
  31345 		if btreeGetPage(tls, pBt, uint32(1), bp, 0) == SQLITE_OK {
  31346 			btreeSetNPage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp)))
  31347 			releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp)))
  31348 		}
  31349 
  31350 		(*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(TRANS_READ)
  31351 		btreeClearHasContent(tls, pBt)
  31352 	}
  31353 
  31354 	btreeEndTransaction(tls, p)
  31355 	Xsqlite3BtreeLeave(tls, p)
  31356 	return rc
  31357 }
  31358 
  31359 // Start a statement subtransaction. The subtransaction can be rolled
  31360 // back independently of the main transaction. You must start a transaction
  31361 // before starting a subtransaction. The subtransaction is ended automatically
  31362 // if the main transaction commits or rolls back.
  31363 //
  31364 // Statement subtransactions are used around individual SQL statements
  31365 // that are contained within a BEGIN...COMMIT block.  If a constraint
  31366 // error occurs within the statement, the effect of that one statement
  31367 // can be rolled back without having to rollback the entire transaction.
  31368 //
  31369 // A statement sub-transaction is implemented as an anonymous savepoint. The
  31370 // value passed as the second parameter is the total number of savepoints,
  31371 // including the new anonymous savepoint, open on the B-Tree. i.e. if there
  31372 // are no active savepoints and no other statement-transactions open,
  31373 // iStatement is 1. This anonymous savepoint can be released or rolled back
  31374 // using the sqlite3BtreeSavepoint() function.
  31375 func Xsqlite3BtreeBeginStmt(tls *libc.TLS, p uintptr, iStatement int32) int32 {
  31376 	var rc int32
  31377 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31378 	Xsqlite3BtreeEnter(tls, p)
  31379 
  31380 	rc = Xsqlite3PagerOpenSavepoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, iStatement)
  31381 	Xsqlite3BtreeLeave(tls, p)
  31382 	return rc
  31383 }
  31384 
  31385 // The second argument to this function, op, is always SAVEPOINT_ROLLBACK
  31386 // or SAVEPOINT_RELEASE. This function either releases or rolls back the
  31387 // savepoint identified by parameter iSavepoint, depending on the value
  31388 // of op.
  31389 //
  31390 // Normally, iSavepoint is greater than or equal to zero. However, if op is
  31391 // SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the
  31392 // contents of the entire transaction are rolled back. This is different
  31393 // from a normal transaction rollback, as no locks are released and the
  31394 // transaction remains open.
  31395 func Xsqlite3BtreeSavepoint(tls *libc.TLS, p uintptr, op int32, iSavepoint int32) int32 {
  31396 	var rc int32 = SQLITE_OK
  31397 	if p != 0 && int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE {
  31398 		var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31399 
  31400 		Xsqlite3BtreeEnter(tls, p)
  31401 		if op == SAVEPOINT_ROLLBACK {
  31402 			rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0))
  31403 		}
  31404 		if rc == SQLITE_OK {
  31405 			rc = Xsqlite3PagerSavepoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, op, iSavepoint)
  31406 		}
  31407 		if rc == SQLITE_OK {
  31408 			if iSavepoint < 0 && int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_INITIALLY_EMPTY != 0 {
  31409 				(*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(0)
  31410 			}
  31411 			rc = newDatabase(tls, pBt)
  31412 			btreeSetNPage(tls, pBt, (*BtShared)(unsafe.Pointer(pBt)).FpPage1)
  31413 
  31414 		}
  31415 		Xsqlite3BtreeLeave(tls, p)
  31416 	}
  31417 	return rc
  31418 }
  31419 
  31420 func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) int32 {
  31421 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  31422 	var pX uintptr
  31423 
  31424 	if iTable <= Pgno(1) {
  31425 		if iTable < Pgno(1) {
  31426 			return Xsqlite3CorruptError(tls, 72982)
  31427 		} else if btreePagecount(tls, pBt) == Pgno(0) {
  31428 			iTable = Pgno(0)
  31429 		}
  31430 	}
  31431 
  31432 	(*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot = iTable
  31433 	(*BtCursor)(unsafe.Pointer(pCur)).FiPage = int8(-1)
  31434 	(*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo = pKeyInfo
  31435 	(*BtCursor)(unsafe.Pointer(pCur)).FpBtree = p
  31436 	(*BtCursor)(unsafe.Pointer(pCur)).FpBt = pBt
  31437 	(*BtCursor)(unsafe.Pointer(pCur)).FcurFlags = U8(0)
  31438 
  31439 	for pX = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; pX != 0; pX = (*BtCursor)(unsafe.Pointer(pX)).FpNext {
  31440 		if (*BtCursor)(unsafe.Pointer(pX)).FpgnoRoot == iTable {
  31441 			*(*U8)(unsafe.Pointer(pX + 1)) |= U8(BTCF_Multiple)
  31442 			(*BtCursor)(unsafe.Pointer(pCur)).FcurFlags = U8(BTCF_Multiple)
  31443 		}
  31444 	}
  31445 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  31446 	(*BtCursor)(unsafe.Pointer(pCur)).FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpCursor
  31447 	(*BtShared)(unsafe.Pointer(pBt)).FpCursor = pCur
  31448 	if wrFlag != 0 {
  31449 		*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_WriteFlag)
  31450 		(*BtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags = U8(0)
  31451 		if (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) {
  31452 			return allocateTempSpace(tls, pBt)
  31453 		}
  31454 	} else {
  31455 		(*BtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags = U8(PAGER_GET_READONLY)
  31456 	}
  31457 	return SQLITE_OK
  31458 }
  31459 
  31460 func btreeCursorWithLock(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) int32 {
  31461 	var rc int32
  31462 	Xsqlite3BtreeEnter(tls, p)
  31463 	rc = btreeCursor(tls, p, iTable, wrFlag, pKeyInfo, pCur)
  31464 	Xsqlite3BtreeLeave(tls, p)
  31465 	return rc
  31466 }
  31467 
  31468 func Xsqlite3BtreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) int32 {
  31469 	if (*Btree)(unsafe.Pointer(p)).Fsharable != 0 {
  31470 		return btreeCursorWithLock(tls, p, iTable, wrFlag, pKeyInfo, pCur)
  31471 	} else {
  31472 		return btreeCursor(tls, p, iTable, wrFlag, pKeyInfo, pCur)
  31473 	}
  31474 	return int32(0)
  31475 }
  31476 
  31477 // Return the size of a BtCursor object in bytes.
  31478 //
  31479 // This interfaces is needed so that users of cursors can preallocate
  31480 // sufficient storage to hold a cursor.  The BtCursor object is opaque
  31481 // to users so they cannot do the sizeof() themselves - they must call
  31482 // this routine.
  31483 func Xsqlite3BtreeCursorSize(tls *libc.TLS) int32 {
  31484 	return int32((uint32(unsafe.Sizeof(BtCursor{})) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  31485 }
  31486 
  31487 // Initialize memory that will be converted into a BtCursor object.
  31488 //
  31489 // The simple approach here would be to memset() the entire object
  31490 // to zero.  But it turns out that the apPage[] and aiIdx[] arrays
  31491 // do not need to be zeroed and they are large, so we can save a lot
  31492 // of run-time by skipping the initialization of those elements.
  31493 func Xsqlite3BtreeCursorZero(tls *libc.TLS, p uintptr) {
  31494 	libc.Xmemset(tls, p, 0, uint32(uintptr(0)+20))
  31495 }
  31496 
  31497 // Close a cursor.  The read lock on the database file is released
  31498 // when the last cursor is closed.
  31499 func Xsqlite3BtreeCloseCursor(tls *libc.TLS, pCur uintptr) int32 {
  31500 	var pBtree uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBtree
  31501 	if pBtree != 0 {
  31502 		var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBt
  31503 		Xsqlite3BtreeEnter(tls, pBtree)
  31504 
  31505 		if (*BtShared)(unsafe.Pointer(pBt)).FpCursor == pCur {
  31506 			(*BtShared)(unsafe.Pointer(pBt)).FpCursor = (*BtCursor)(unsafe.Pointer(pCur)).FpNext
  31507 		} else {
  31508 			var pPrev uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpCursor
  31509 			for __ccgo := true; __ccgo; __ccgo = pPrev != 0 {
  31510 				if (*BtCursor)(unsafe.Pointer(pPrev)).FpNext == pCur {
  31511 					(*BtCursor)(unsafe.Pointer(pPrev)).FpNext = (*BtCursor)(unsafe.Pointer(pCur)).FpNext
  31512 					break
  31513 				}
  31514 				pPrev = (*BtCursor)(unsafe.Pointer(pPrev)).FpNext
  31515 			}
  31516 		}
  31517 		btreeReleaseAllCursorPages(tls, pCur)
  31518 		unlockBtreeIfUnused(tls, pBt)
  31519 		Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow)
  31520 		Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey)
  31521 		if int32((*BtShared)(unsafe.Pointer(pBt)).FopenFlags)&BTREE_SINGLE != 0 && (*BtShared)(unsafe.Pointer(pBt)).FpCursor == uintptr(0) {
  31522 			Xsqlite3BtreeClose(tls, pBtree)
  31523 		} else {
  31524 			Xsqlite3BtreeLeave(tls, pBtree)
  31525 		}
  31526 		(*BtCursor)(unsafe.Pointer(pCur)).FpBtree = uintptr(0)
  31527 	}
  31528 	return SQLITE_OK
  31529 }
  31530 
  31531 func getCellInfo(tls *libc.TLS, pCur uintptr) {
  31532 	if int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) == 0 {
  31533 		*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_ValidNKey)
  31534 		btreeParseCell(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage, int32((*BtCursor)(unsafe.Pointer(pCur)).Fix), pCur+32)
  31535 	} else {
  31536 	}
  31537 }
  31538 
  31539 func Xsqlite3BtreeCursorIsValidNN(tls *libc.TLS, pCur uintptr) int32 {
  31540 	return libc.Bool32(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID)
  31541 }
  31542 
  31543 // Return the value of the integer key or "rowid" for a table btree.
  31544 // This routine is only valid for a cursor that is pointing into a
  31545 // ordinary table btree.  If the cursor points to an index btree or
  31546 // is invalid, the result of this routine is undefined.
  31547 func Xsqlite3BtreeIntegerKey(tls *libc.TLS, pCur uintptr) I64 {
  31548 	getCellInfo(tls, pCur)
  31549 	return (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey
  31550 }
  31551 
  31552 // Pin or unpin a cursor.
  31553 func Xsqlite3BtreeCursorPin(tls *libc.TLS, pCur uintptr) {
  31554 	*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_Pinned)
  31555 }
  31556 
  31557 func Xsqlite3BtreeCursorUnpin(tls *libc.TLS, pCur uintptr) {
  31558 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_Pinned))
  31559 }
  31560 
  31561 // Return the offset into the database file for the start of the
  31562 // payload to which the cursor is pointing.
  31563 func Xsqlite3BtreeOffset(tls *libc.TLS, pCur uintptr) I64 {
  31564 	getCellInfo(tls, pCur)
  31565 	return I64((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize)*(I64((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fpgno)-int64(1)) + I64((int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload)-int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FaData))/1)
  31566 }
  31567 
  31568 // Return the number of bytes of payload for the entry that pCur is
  31569 // currently pointing to.  For table btrees, this will be the amount
  31570 // of data.  For index btrees, this will be the size of the key.
  31571 //
  31572 // The caller must guarantee that the cursor is pointing to a non-NULL
  31573 // valid entry.  In other words, the calling procedure must guarantee
  31574 // that the cursor has Cursor.eState==CURSOR_VALID.
  31575 func Xsqlite3BtreePayloadSize(tls *libc.TLS, pCur uintptr) U32 {
  31576 	getCellInfo(tls, pCur)
  31577 	return (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload
  31578 }
  31579 
  31580 // Return an upper bound on the size of any record for the table
  31581 // that the cursor is pointing into.
  31582 //
  31583 // This is an optimization.  Everything will still work if this
  31584 // routine always returns 2147483647 (which is the largest record
  31585 // that SQLite can handle) or more.  But returning a smaller value might
  31586 // prevent large memory allocations when trying to interpret a
  31587 // corrupt datrabase.
  31588 //
  31589 // The current implementation merely returns the size of the underlying
  31590 // database file.
  31591 func Xsqlite3BtreeMaxRecordSize(tls *libc.TLS, pCur uintptr) Sqlite3_int64 {
  31592 	return Sqlite3_int64((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize) * Sqlite3_int64((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FnPage)
  31593 }
  31594 
  31595 func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgnoNext uintptr) int32 {
  31596 	bp := tls.Alloc(12)
  31597 	defer tls.Free(12)
  31598 
  31599 	var next Pgno = Pgno(0)
  31600 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  31601 	var rc int32 = SQLITE_OK
  31602 
  31603 	if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  31604 		var iGuess Pgno = ovfl + Pgno(1)
  31605 
  31606 		for ptrmapPageno(tls, pBt, iGuess) == iGuess || iGuess == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  31607 			iGuess++
  31608 		}
  31609 
  31610 		if iGuess <= btreePagecount(tls, pBt) {
  31611 			rc = ptrmapGet(tls, pBt, iGuess, bp, bp+4)
  31612 			if rc == SQLITE_OK && int32(*(*U8)(unsafe.Pointer(bp))) == PTRMAP_OVERFLOW2 && *(*Pgno)(unsafe.Pointer(bp + 4)) == ovfl {
  31613 				next = iGuess
  31614 				rc = SQLITE_DONE
  31615 			}
  31616 		}
  31617 	}
  31618 
  31619 	if rc == SQLITE_OK {
  31620 		rc = btreeGetPage(tls, pBt, ovfl, bp+8, func() int32 {
  31621 			if ppPage == uintptr(0) {
  31622 				return PAGER_GET_READONLY
  31623 			}
  31624 			return 0
  31625 		}())
  31626 
  31627 		if rc == SQLITE_OK {
  31628 			next = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData)
  31629 		}
  31630 	}
  31631 
  31632 	*(*Pgno)(unsafe.Pointer(pPgnoNext)) = next
  31633 	if ppPage != 0 {
  31634 		*(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 8))
  31635 	} else {
  31636 		releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  31637 	}
  31638 	return func() int32 {
  31639 		if rc == SQLITE_DONE {
  31640 			return SQLITE_OK
  31641 		}
  31642 		return rc
  31643 	}()
  31644 }
  31645 
  31646 func copyPayload(tls *libc.TLS, pPayload uintptr, pBuf uintptr, nByte int32, eOp int32, pDbPage uintptr) int32 {
  31647 	if eOp != 0 {
  31648 		var rc int32 = Xsqlite3PagerWrite(tls, pDbPage)
  31649 		if rc != SQLITE_OK {
  31650 			return rc
  31651 		}
  31652 		libc.Xmemcpy(tls, pPayload, pBuf, uint32(nByte))
  31653 	} else {
  31654 		libc.Xmemcpy(tls, pBuf, pPayload, uint32(nByte))
  31655 	}
  31656 	return SQLITE_OK
  31657 }
  31658 
  31659 func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr, eOp int32) int32 {
  31660 	bp := tls.Alloc(8)
  31661 	defer tls.Free(8)
  31662 
  31663 	var aPayload uintptr
  31664 	var rc int32 = SQLITE_OK
  31665 	var iIdx int32 = 0
  31666 	var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  31667 	var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBt
  31668 
  31669 	if int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  31670 		return Xsqlite3CorruptError(tls, 73389)
  31671 	}
  31672 
  31673 	getCellInfo(tls, pCur)
  31674 	aPayload = (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload
  31675 
  31676 	if Uptr((int32(aPayload)-int32((*MemPage)(unsafe.Pointer(pPage)).FaData))/1) > (*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) {
  31677 		return Xsqlite3CorruptError(tls, 73404)
  31678 	}
  31679 
  31680 	if offset < U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) {
  31681 		var a int32 = int32(amt)
  31682 		if U32(a)+offset > U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) {
  31683 			a = int32(U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) - offset)
  31684 		}
  31685 		rc = copyPayload(tls, aPayload+uintptr(offset), pBuf, a, eOp, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  31686 		offset = U32(0)
  31687 		pBuf += uintptr(a)
  31688 		amt = amt - U32(a)
  31689 	} else {
  31690 		offset = offset - U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)
  31691 	}
  31692 
  31693 	if rc == SQLITE_OK && amt > U32(0) {
  31694 		var ovflSize U32 = (*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4)
  31695 
  31696 		*(*Pgno)(unsafe.Pointer(bp)) = Xsqlite3Get4byte(tls, aPayload+uintptr((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal))
  31697 
  31698 		if int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_ValidOvfl == 0 {
  31699 			var nOvfl int32 = int32(((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload - U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) + ovflSize - U32(1)) / ovflSize)
  31700 			if (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow == uintptr(0) ||
  31701 				nOvfl*int32(unsafe.Sizeof(Pgno(0))) > Xsqlite3MallocSize(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow) {
  31702 				var aNew uintptr = Xsqlite3Realloc(tls,
  31703 					(*BtCursor)(unsafe.Pointer(pCur)).FaOverflow, uint64(uint32(nOvfl*2)*uint32(unsafe.Sizeof(Pgno(0)))))
  31704 				if aNew == uintptr(0) {
  31705 					return SQLITE_NOMEM
  31706 				} else {
  31707 					(*BtCursor)(unsafe.Pointer(pCur)).FaOverflow = aNew
  31708 				}
  31709 			}
  31710 			libc.Xmemset(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow, 0, uint32(nOvfl)*uint32(unsafe.Sizeof(Pgno(0))))
  31711 			*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_ValidOvfl)
  31712 		} else {
  31713 			if *(*Pgno)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(offset/ovflSize)*4)) != 0 {
  31714 				iIdx = int32(offset / ovflSize)
  31715 				*(*Pgno)(unsafe.Pointer(bp)) = *(*Pgno)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx)*4))
  31716 				offset = offset % ovflSize
  31717 			}
  31718 		}
  31719 
  31720 		for *(*Pgno)(unsafe.Pointer(bp)) != 0 {
  31721 			if *(*Pgno)(unsafe.Pointer(bp)) > (*BtShared)(unsafe.Pointer(pBt)).FnPage {
  31722 				return Xsqlite3CorruptError(tls, 73466)
  31723 			}
  31724 
  31725 			*(*Pgno)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx)*4)) = *(*Pgno)(unsafe.Pointer(bp))
  31726 
  31727 			if offset >= ovflSize {
  31728 				if *(*Pgno)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx+1)*4)) != 0 {
  31729 					*(*Pgno)(unsafe.Pointer(bp)) = *(*Pgno)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow + uintptr(iIdx+1)*4))
  31730 				} else {
  31731 					rc = getOverflowPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp)), uintptr(0), bp)
  31732 				}
  31733 				offset = offset - ovflSize
  31734 			} else {
  31735 				var a int32 = int32(amt)
  31736 				if U32(a)+offset > ovflSize {
  31737 					a = int32(ovflSize - offset)
  31738 				}
  31739 
  31740 				{
  31741 					rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, *(*Pgno)(unsafe.Pointer(bp)), bp+4,
  31742 						func() int32 {
  31743 							if eOp == 0 {
  31744 								return PAGER_GET_READONLY
  31745 							}
  31746 							return 0
  31747 						}())
  31748 					if rc == SQLITE_OK {
  31749 						aPayload = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
  31750 						*(*Pgno)(unsafe.Pointer(bp)) = Xsqlite3Get4byte(tls, aPayload)
  31751 						rc = copyPayload(tls, aPayload+uintptr(offset+U32(4)), pBuf, a, eOp, *(*uintptr)(unsafe.Pointer(bp + 4)))
  31752 						Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
  31753 						offset = U32(0)
  31754 					}
  31755 
  31756 				}
  31757 				amt = amt - U32(a)
  31758 				if amt == U32(0) {
  31759 					return rc
  31760 				}
  31761 				pBuf += uintptr(a)
  31762 			}
  31763 			if rc != 0 {
  31764 				break
  31765 			}
  31766 			iIdx++
  31767 		}
  31768 	}
  31769 
  31770 	if rc == SQLITE_OK && amt > U32(0) {
  31771 		return Xsqlite3CorruptError(tls, 73551)
  31772 	}
  31773 	return rc
  31774 }
  31775 
  31776 // Read part of the payload for the row at which that cursor pCur is currently
  31777 // pointing.  "amt" bytes will be transferred into pBuf[].  The transfer
  31778 // begins at "offset".
  31779 //
  31780 // pCur can be pointing to either a table or an index b-tree.
  31781 // If pointing to a table btree, then the content section is read.  If
  31782 // pCur is pointing to an index b-tree then the key section is read.
  31783 //
  31784 // For sqlite3BtreePayload(), the caller must ensure that pCur is pointing
  31785 // to a valid row in the table.  For sqlite3BtreePayloadChecked(), the
  31786 // cursor might be invalid or might need to be restored before being read.
  31787 //
  31788 // Return SQLITE_OK on success or an error code if anything goes
  31789 // wrong.  An error is returned if "offset+amt" is larger than
  31790 // the available payload.
  31791 func Xsqlite3BtreePayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 {
  31792 	return accessPayload(tls, pCur, offset, amt, pBuf, 0)
  31793 }
  31794 
  31795 func accessPayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 {
  31796 	var rc int32
  31797 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_INVALID {
  31798 		return SQLITE_ABORT
  31799 	}
  31800 
  31801 	rc = btreeRestoreCursorPosition(tls, pCur)
  31802 	if rc != 0 {
  31803 		return rc
  31804 	}
  31805 	return accessPayload(tls, pCur, offset, amt, pBuf, 0)
  31806 }
  31807 
  31808 func Xsqlite3BtreePayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 {
  31809 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID {
  31810 		return accessPayload(tls, pCur, offset, amt, pBuf, 0)
  31811 	} else {
  31812 		return accessPayloadChecked(tls, pCur, offset, amt, pBuf)
  31813 	}
  31814 	return int32(0)
  31815 }
  31816 
  31817 func fetchPayload(tls *libc.TLS, pCur uintptr, pAmt uintptr) uintptr {
  31818 	var amt int32
  31819 
  31820 	amt = int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)
  31821 	if amt > (int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FaDataEnd)-int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload))/1 {
  31822 		amt = func() int32 {
  31823 			if 0 > (int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FaDataEnd)-int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload))/1 {
  31824 				return 0
  31825 			}
  31826 			return (int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FaDataEnd) - int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload)) / 1
  31827 		}()
  31828 	}
  31829 	*(*U32)(unsafe.Pointer(pAmt)) = U32(amt)
  31830 	return (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload
  31831 }
  31832 
  31833 // For the entry that cursor pCur is point to, return as
  31834 // many bytes of the key or data as are available on the local
  31835 // b-tree page.  Write the number of available bytes into *pAmt.
  31836 //
  31837 // The pointer returned is ephemeral.  The key/data may move
  31838 // or be destroyed on the next call to any Btree routine,
  31839 // including calls from other threads against the same cache.
  31840 // Hence, a mutex on the BtShared should be held prior to calling
  31841 // this routine.
  31842 //
  31843 // These routines is used to get quick access to key and data
  31844 // in the common case where no overflow pages are used.
  31845 func Xsqlite3BtreePayloadFetch(tls *libc.TLS, pCur uintptr, pAmt uintptr) uintptr {
  31846 	return fetchPayload(tls, pCur, pAmt)
  31847 }
  31848 
  31849 func moveToChild(tls *libc.TLS, pCur uintptr, newPgno U32) int32 {
  31850 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= BTCURSOR_MAX_DEPTH-1 {
  31851 		return Xsqlite3CorruptError(tls, 73688)
  31852 	}
  31853 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  31854 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidNKey | BTCF_ValidOvfl))
  31855 	*(*U16)(unsafe.Pointer(pCur + 72 + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*2)) = (*BtCursor)(unsafe.Pointer(pCur)).Fix
  31856 	*(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*4)) = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  31857 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0)
  31858 	(*BtCursor)(unsafe.Pointer(pCur)).FiPage++
  31859 	return getAndInitPage(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBt, newPgno, pCur+116, pCur,
  31860 		int32((*BtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags))
  31861 }
  31862 
  31863 func moveToParent(tls *libc.TLS, pCur uintptr) {
  31864 	var pLeaf uintptr
  31865 
  31866 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  31867 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidNKey | BTCF_ValidOvfl))
  31868 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = *(*U16)(unsafe.Pointer(pCur + 72 + uintptr(int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage)-1)*2))
  31869 	pLeaf = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  31870 	(*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(libc.PreDecInt8(&(*BtCursor)(unsafe.Pointer(pCur)).FiPage, 1))*4))
  31871 	releasePageNotNull(tls, pLeaf)
  31872 }
  31873 
  31874 func moveToRoot(tls *libc.TLS, pCur uintptr) int32 {
  31875 	var pRoot uintptr
  31876 	var rc int32
  31877 	var subpage Pgno
  31878 	rc = SQLITE_OK
  31879 
  31880 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= 0) {
  31881 		goto __1
  31882 	}
  31883 	if !((*BtCursor)(unsafe.Pointer(pCur)).FiPage != 0) {
  31884 		goto __3
  31885 	}
  31886 	releasePageNotNull(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage)
  31887 __4:
  31888 	if !(libc.PreDecInt8(&(*BtCursor)(unsafe.Pointer(pCur)).FiPage, 1) != 0) {
  31889 		goto __5
  31890 	}
  31891 	releasePageNotNull(tls, *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*4)))
  31892 	goto __4
  31893 __5:
  31894 	;
  31895 	pRoot = libc.AssignPtrUintptr(pCur+116, *(*uintptr)(unsafe.Pointer(pCur + 120)))
  31896 	goto skip_init
  31897 __3:
  31898 	;
  31899 	goto __2
  31900 __1:
  31901 	if !((*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot == Pgno(0)) {
  31902 		goto __6
  31903 	}
  31904 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  31905 	return SQLITE_EMPTY
  31906 	goto __7
  31907 __6:
  31908 	;
  31909 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK) {
  31910 		goto __8
  31911 	}
  31912 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT) {
  31913 		goto __9
  31914 	}
  31915 
  31916 	return (*BtCursor)(unsafe.Pointer(pCur)).FskipNext
  31917 __9:
  31918 	;
  31919 	Xsqlite3BtreeClearCursor(tls, pCur)
  31920 __8:
  31921 	;
  31922 	rc = getAndInitPage(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur+116,
  31923 		uintptr(0), int32((*BtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags))
  31924 	if !(rc != SQLITE_OK) {
  31925 		goto __10
  31926 	}
  31927 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  31928 	return rc
  31929 __10:
  31930 	;
  31931 	(*BtCursor)(unsafe.Pointer(pCur)).FiPage = int8(0)
  31932 	(*BtCursor)(unsafe.Pointer(pCur)).FcurIntKey = (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FintKey
  31933 __7:
  31934 	;
  31935 __2:
  31936 	;
  31937 	pRoot = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  31938 
  31939 	if !(int32((*MemPage)(unsafe.Pointer(pRoot)).FisInit) == 0 || libc.Bool32((*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0)) != int32((*MemPage)(unsafe.Pointer(pRoot)).FintKey)) {
  31940 		goto __11
  31941 	}
  31942 	return Xsqlite3CorruptError(tls, 73827)
  31943 __11:
  31944 	;
  31945 skip_init:
  31946 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0)
  31947 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  31948 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_AtLast | BTCF_ValidNKey | BTCF_ValidOvfl))
  31949 
  31950 	if !(int32((*MemPage)(unsafe.Pointer(pRoot)).FnCell) > 0) {
  31951 		goto __12
  31952 	}
  31953 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_VALID)
  31954 	goto __13
  31955 __12:
  31956 	if !!(int32((*MemPage)(unsafe.Pointer(pRoot)).Fleaf) != 0) {
  31957 		goto __14
  31958 	}
  31959 	if !((*MemPage)(unsafe.Pointer(pRoot)).Fpgno != Pgno(1)) {
  31960 		goto __16
  31961 	}
  31962 	return Xsqlite3CorruptError(tls, 73839)
  31963 __16:
  31964 	;
  31965 	subpage = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pRoot)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pRoot)).FhdrOffset)+8))
  31966 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_VALID)
  31967 	rc = moveToChild(tls, pCur, subpage)
  31968 	goto __15
  31969 __14:
  31970 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  31971 	rc = SQLITE_EMPTY
  31972 __15:
  31973 	;
  31974 __13:
  31975 	;
  31976 	return rc
  31977 }
  31978 
  31979 func moveToLeftmost(tls *libc.TLS, pCur uintptr) int32 {
  31980 	var pgno Pgno
  31981 	var rc int32 = SQLITE_OK
  31982 	var pPage uintptr
  31983 
  31984 	for rc == SQLITE_OK && !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) {
  31985 		pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*int32((*BtCursor)(unsafe.Pointer(pCur)).Fix))))))))
  31986 		rc = moveToChild(tls, pCur, pgno)
  31987 	}
  31988 	return rc
  31989 }
  31990 
  31991 func moveToRightmost(tls *libc.TLS, pCur uintptr) int32 {
  31992 	var pgno Pgno
  31993 	var rc int32 = SQLITE_OK
  31994 	var pPage uintptr = uintptr(0)
  31995 
  31996 	for !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) {
  31997 		pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8))
  31998 		(*BtCursor)(unsafe.Pointer(pCur)).Fix = (*MemPage)(unsafe.Pointer(pPage)).FnCell
  31999 		rc = moveToChild(tls, pCur, pgno)
  32000 		if rc != 0 {
  32001 			return rc
  32002 		}
  32003 	}
  32004 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1)
  32005 
  32006 	return SQLITE_OK
  32007 }
  32008 
  32009 // Move the cursor to the first entry in the table.  Return SQLITE_OK
  32010 // on success.  Set *pRes to 0 if the cursor actually points to something
  32011 // or set *pRes to 1 if the table is empty.
  32012 func Xsqlite3BtreeFirst(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 {
  32013 	var rc int32
  32014 
  32015 	rc = moveToRoot(tls, pCur)
  32016 	if rc == SQLITE_OK {
  32017 		*(*int32)(unsafe.Pointer(pRes)) = 0
  32018 		rc = moveToLeftmost(tls, pCur)
  32019 	} else if rc == SQLITE_EMPTY {
  32020 		*(*int32)(unsafe.Pointer(pRes)) = 1
  32021 		rc = SQLITE_OK
  32022 	}
  32023 	return rc
  32024 }
  32025 
  32026 func btreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 {
  32027 	var rc int32 = moveToRoot(tls, pCur)
  32028 	if rc == SQLITE_OK {
  32029 		*(*int32)(unsafe.Pointer(pRes)) = 0
  32030 		rc = moveToRightmost(tls, pCur)
  32031 		if rc == SQLITE_OK {
  32032 			*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_AtLast)
  32033 		} else {
  32034 			*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_AtLast))
  32035 		}
  32036 	} else if rc == SQLITE_EMPTY {
  32037 		*(*int32)(unsafe.Pointer(pRes)) = 1
  32038 		rc = SQLITE_OK
  32039 	}
  32040 	return rc
  32041 }
  32042 
  32043 func Xsqlite3BtreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 {
  32044 	if CURSOR_VALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) && int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_AtLast != 0 {
  32045 		*(*int32)(unsafe.Pointer(pRes)) = 0
  32046 		return SQLITE_OK
  32047 	}
  32048 	return btreeLast(tls, pCur, pRes)
  32049 }
  32050 
  32051 // Move the cursor so that it points to an entry in a table (a.k.a INTKEY)
  32052 // table near the key intKey.   Return a success code.
  32053 //
  32054 // If an exact match is not found, then the cursor is always
  32055 // left pointing at a leaf page which would hold the entry if it
  32056 // were present.  The cursor might point to an entry that comes
  32057 // before or after the key.
  32058 //
  32059 // An integer is written into *pRes which is the result of
  32060 // comparing the key with the entry to which the cursor is
  32061 // pointing.  The meaning of the integer written into
  32062 // *pRes is as follows:
  32063 //
  32064 //	*pRes<0      The cursor is left pointing at an entry that
  32065 //	             is smaller than intKey or if the table is empty
  32066 //	             and the cursor is therefore left point to nothing.
  32067 //
  32068 //	*pRes==0     The cursor is left pointing at an entry that
  32069 //	             exactly matches intKey.
  32070 //
  32071 //	*pRes>0      The cursor is left pointing at an entry that
  32072 //	             is larger than intKey.
  32073 func Xsqlite3BtreeTableMoveto(tls *libc.TLS, pCur uintptr, intKey I64, biasRight int32, pRes uintptr) int32 {
  32074 	bp := tls.Alloc(8)
  32075 	defer tls.Free(8)
  32076 
  32077 	var rc int32
  32078 
  32079 	var lwr int32
  32080 	var upr int32
  32081 	var idx int32
  32082 	var c int32
  32083 	var chldPg Pgno
  32084 	var pPage uintptr
  32085 	var pCell uintptr
  32086 
  32087 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID && int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_ValidNKey != 0) {
  32088 		goto __1
  32089 	}
  32090 	if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey) {
  32091 		goto __2
  32092 	}
  32093 	*(*int32)(unsafe.Pointer(pRes)) = 0
  32094 	return SQLITE_OK
  32095 __2:
  32096 	;
  32097 	if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey < intKey) {
  32098 		goto __3
  32099 	}
  32100 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_AtLast != 0) {
  32101 		goto __4
  32102 	}
  32103 	*(*int32)(unsafe.Pointer(pRes)) = -1
  32104 	return SQLITE_OK
  32105 __4:
  32106 	;
  32107 	if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey+int64(1) == intKey) {
  32108 		goto __5
  32109 	}
  32110 	*(*int32)(unsafe.Pointer(pRes)) = 0
  32111 	rc = Xsqlite3BtreeNext(tls, pCur, 0)
  32112 	if !(rc == SQLITE_OK) {
  32113 		goto __6
  32114 	}
  32115 	getCellInfo(tls, pCur)
  32116 	if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey) {
  32117 		goto __8
  32118 	}
  32119 	return SQLITE_OK
  32120 __8:
  32121 	;
  32122 	goto __7
  32123 __6:
  32124 	if !(rc != SQLITE_DONE) {
  32125 		goto __9
  32126 	}
  32127 	return rc
  32128 __9:
  32129 	;
  32130 __7:
  32131 	;
  32132 __5:
  32133 	;
  32134 __3:
  32135 	;
  32136 __1:
  32137 	;
  32138 	rc = moveToRoot(tls, pCur)
  32139 	if !(rc != 0) {
  32140 		goto __10
  32141 	}
  32142 	if !(rc == SQLITE_EMPTY) {
  32143 		goto __11
  32144 	}
  32145 
  32146 	*(*int32)(unsafe.Pointer(pRes)) = -1
  32147 	return SQLITE_OK
  32148 __11:
  32149 	;
  32150 	return rc
  32151 __10:
  32152 	;
  32153 __12:
  32154 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32155 
  32156 	lwr = 0
  32157 	upr = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1
  32158 
  32159 	idx = upr >> (1 - biasRight)
  32160 __15:
  32161 	pCell = (*MemPage)(unsafe.Pointer(pPage)).FaDataOfst + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*idx))))))
  32162 	if !((*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf != 0) {
  32163 		goto __18
  32164 	}
  32165 __19:
  32166 	if !(0x80 <= int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pCell, 1))))) {
  32167 		goto __20
  32168 	}
  32169 	if !(pCell >= (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd) {
  32170 		goto __21
  32171 	}
  32172 	return Xsqlite3CorruptError(tls, 74081)
  32173 __21:
  32174 	;
  32175 	goto __19
  32176 __20:
  32177 	;
  32178 __18:
  32179 	;
  32180 	Xsqlite3GetVarint(tls, pCell, bp)
  32181 	if !(*(*I64)(unsafe.Pointer(bp)) < intKey) {
  32182 		goto __22
  32183 	}
  32184 	lwr = idx + 1
  32185 	if !(lwr > upr) {
  32186 		goto __24
  32187 	}
  32188 	c = -1
  32189 	goto __17
  32190 __24:
  32191 	;
  32192 	goto __23
  32193 __22:
  32194 	if !(*(*I64)(unsafe.Pointer(bp)) > intKey) {
  32195 		goto __25
  32196 	}
  32197 	upr = idx - 1
  32198 	if !(lwr > upr) {
  32199 		goto __27
  32200 	}
  32201 	c = +1
  32202 	goto __17
  32203 __27:
  32204 	;
  32205 	goto __26
  32206 __25:
  32207 	;
  32208 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx)
  32209 	if !!(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  32210 		goto __28
  32211 	}
  32212 	lwr = idx
  32213 	goto moveto_table_next_layer
  32214 	goto __29
  32215 __28:
  32216 	*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_ValidNKey)
  32217 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey = *(*I64)(unsafe.Pointer(bp))
  32218 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  32219 	*(*int32)(unsafe.Pointer(pRes)) = 0
  32220 	return SQLITE_OK
  32221 __29:
  32222 	;
  32223 __26:
  32224 	;
  32225 __23:
  32226 	;
  32227 	idx = (lwr + upr) >> 1
  32228 	goto __16
  32229 __16:
  32230 	goto __15
  32231 	goto __17
  32232 __17:
  32233 	;
  32234 	if !((*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0) {
  32235 		goto __30
  32236 	}
  32237 
  32238 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx)
  32239 	*(*int32)(unsafe.Pointer(pRes)) = c
  32240 	rc = SQLITE_OK
  32241 	goto moveto_table_finish
  32242 __30:
  32243 	;
  32244 moveto_table_next_layer:
  32245 	if !(lwr >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) {
  32246 		goto __31
  32247 	}
  32248 	chldPg = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8))
  32249 	goto __32
  32250 __31:
  32251 	chldPg = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*lwr)))))))
  32252 __32:
  32253 	;
  32254 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(lwr)
  32255 	rc = moveToChild(tls, pCur, chldPg)
  32256 	if !(rc != 0) {
  32257 		goto __33
  32258 	}
  32259 	goto __14
  32260 __33:
  32261 	;
  32262 	goto __13
  32263 __13:
  32264 	goto __12
  32265 	goto __14
  32266 __14:
  32267 	;
  32268 moveto_table_finish:
  32269 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  32270 
  32271 	return rc
  32272 }
  32273 
  32274 func indexCellCompare(tls *libc.TLS, pCur uintptr, idx int32, pIdxKey uintptr, xRecordCompare RecordCompare) int32 {
  32275 	var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32276 	var c int32
  32277 	var nCell int32
  32278 	var pCell uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaDataOfst + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*idx))))))
  32279 
  32280 	nCell = int32(*(*U8)(unsafe.Pointer(pCell)))
  32281 	if nCell <= int32((*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload) {
  32282 		c = (*struct {
  32283 			f func(*libc.TLS, int32, uintptr, uintptr) int32
  32284 		})(unsafe.Pointer(&struct{ uintptr }{xRecordCompare})).f(tls, nCell, pCell+1, pIdxKey)
  32285 	} else if !(int32(*(*U8)(unsafe.Pointer(pCell + 1)))&0x80 != 0) &&
  32286 		libc.AssignInt32(&nCell, nCell&0x7f<<7+int32(*(*U8)(unsafe.Pointer(pCell + 1)))) <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  32287 		c = (*struct {
  32288 			f func(*libc.TLS, int32, uintptr, uintptr) int32
  32289 		})(unsafe.Pointer(&struct{ uintptr }{xRecordCompare})).f(tls, nCell, pCell+2, pIdxKey)
  32290 	} else {
  32291 		c = 99
  32292 	}
  32293 	return c
  32294 }
  32295 
  32296 func cursorOnLastPage(tls *libc.TLS, pCur uintptr) int32 {
  32297 	var i int32
  32298 
  32299 	for i = 0; i < int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage); i++ {
  32300 		var pPage uintptr = *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(i)*4))
  32301 		if int32(*(*U16)(unsafe.Pointer(pCur + 72 + uintptr(i)*2))) < int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  32302 			return 0
  32303 		}
  32304 	}
  32305 	return 1
  32306 }
  32307 
  32308 // Move the cursor so that it points to an entry in an index table
  32309 // near the key pIdxKey.   Return a success code.
  32310 //
  32311 // If an exact match is not found, then the cursor is always
  32312 // left pointing at a leaf page which would hold the entry if it
  32313 // were present.  The cursor might point to an entry that comes
  32314 // before or after the key.
  32315 //
  32316 // An integer is written into *pRes which is the result of
  32317 // comparing the key with the entry to which the cursor is
  32318 // pointing.  The meaning of the integer written into
  32319 // *pRes is as follows:
  32320 //
  32321 //	*pRes<0      The cursor is left pointing at an entry that
  32322 //	             is smaller than pIdxKey or if the table is empty
  32323 //	             and the cursor is therefore left point to nothing.
  32324 //
  32325 //	*pRes==0     The cursor is left pointing at an entry that
  32326 //	             exactly matches pIdxKey.
  32327 //
  32328 //	*pRes>0      The cursor is left pointing at an entry that
  32329 //	             is larger than pIdxKey.
  32330 //
  32331 // The pIdxKey->eqSeen field is set to 1 if there
  32332 // exists an entry in the table that exactly matches pIdxKey.
  32333 func Xsqlite3BtreeIndexMoveto(tls *libc.TLS, pCur uintptr, pIdxKey uintptr, pRes uintptr) int32 {
  32334 	var rc int32
  32335 	var xRecordCompare RecordCompare
  32336 	var c int32
  32337 
  32338 	var pCellKey uintptr
  32339 	var pCellBody uintptr
  32340 	var nOverrun int32
  32341 	var nCell int32
  32342 	var lwr int32
  32343 	var upr int32
  32344 	var idx int32
  32345 	var c1 int32
  32346 	var chldPg Pgno
  32347 	var pPage uintptr
  32348 	var pCell uintptr
  32349 
  32350 	xRecordCompare = Xsqlite3VdbeFindCompare(tls, pIdxKey)
  32351 	(*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode = U8(0)
  32352 
  32353 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID &&
  32354 		(*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf != 0 &&
  32355 		cursorOnLastPage(tls, pCur) != 0) {
  32356 		goto __1
  32357 	}
  32358 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell)-1 &&
  32359 		libc.AssignInt32(&c, indexCellCompare(tls, pCur, int32((*BtCursor)(unsafe.Pointer(pCur)).Fix), pIdxKey, xRecordCompare)) <= 0 &&
  32360 		int32((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode) == SQLITE_OK) {
  32361 		goto __2
  32362 	}
  32363 	*(*int32)(unsafe.Pointer(pRes)) = c
  32364 	return SQLITE_OK
  32365 __2:
  32366 	;
  32367 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > 0 &&
  32368 		indexCellCompare(tls, pCur, 0, pIdxKey, xRecordCompare) <= 0 &&
  32369 		int32((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode) == SQLITE_OK) {
  32370 		goto __3
  32371 	}
  32372 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidOvfl))
  32373 	if !!(int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FisInit) != 0) {
  32374 		goto __4
  32375 	}
  32376 	return Xsqlite3CorruptError(tls, 74277)
  32377 __4:
  32378 	;
  32379 	goto bypass_moveto_root
  32380 __3:
  32381 	;
  32382 	(*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode = U8(SQLITE_OK)
  32383 __1:
  32384 	;
  32385 	rc = moveToRoot(tls, pCur)
  32386 	if !(rc != 0) {
  32387 		goto __5
  32388 	}
  32389 	if !(rc == SQLITE_EMPTY) {
  32390 		goto __6
  32391 	}
  32392 
  32393 	*(*int32)(unsafe.Pointer(pRes)) = -1
  32394 	return SQLITE_OK
  32395 __6:
  32396 	;
  32397 	return rc
  32398 __5:
  32399 	;
  32400 bypass_moveto_root:
  32401 	;
  32402 __7:
  32403 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32404 
  32405 	lwr = 0
  32406 	upr = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1
  32407 	idx = upr >> 1
  32408 __10:
  32409 	pCell = (*MemPage)(unsafe.Pointer(pPage)).FaDataOfst + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*idx))))))
  32410 
  32411 	nCell = int32(*(*U8)(unsafe.Pointer(pCell)))
  32412 	if !(nCell <= int32((*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload)) {
  32413 		goto __13
  32414 	}
  32415 
  32416 	c1 = (*struct {
  32417 		f func(*libc.TLS, int32, uintptr, uintptr) int32
  32418 	})(unsafe.Pointer(&struct{ uintptr }{xRecordCompare})).f(tls, nCell, pCell+1, pIdxKey)
  32419 	goto __14
  32420 __13:
  32421 	if !(!(int32(*(*U8)(unsafe.Pointer(pCell + 1)))&0x80 != 0) &&
  32422 		libc.AssignInt32(&nCell, nCell&0x7f<<7+int32(*(*U8)(unsafe.Pointer(pCell + 1)))) <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal)) {
  32423 		goto __15
  32424 	}
  32425 
  32426 	c1 = (*struct {
  32427 		f func(*libc.TLS, int32, uintptr, uintptr) int32
  32428 	})(unsafe.Pointer(&struct{ uintptr }{xRecordCompare})).f(tls, nCell, pCell+2, pIdxKey)
  32429 	goto __16
  32430 __15:
  32431 	pCellBody = pCell - uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)
  32432 	nOverrun = 18
  32433 	(*struct {
  32434 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  32435 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, pCellBody, pCur+32)
  32436 	nCell = int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey)
  32437 
  32438 	if !(nCell < 2 || U32(nCell)/(*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FusableSize > (*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FnPage) {
  32439 		goto __17
  32440 	}
  32441 	rc = Xsqlite3CorruptError(tls, 74364)
  32442 	goto moveto_index_finish
  32443 __17:
  32444 	;
  32445 	pCellKey = Xsqlite3Malloc(tls, uint64(nCell+nOverrun))
  32446 	if !(pCellKey == uintptr(0)) {
  32447 		goto __18
  32448 	}
  32449 	rc = SQLITE_NOMEM
  32450 	goto moveto_index_finish
  32451 __18:
  32452 	;
  32453 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx)
  32454 	rc = accessPayload(tls, pCur, uint32(0), uint32(nCell), pCellKey, 0)
  32455 	libc.Xmemset(tls, pCellKey+uintptr(nCell), 0, uint32(nOverrun))
  32456 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidOvfl))
  32457 	if !(rc != 0) {
  32458 		goto __19
  32459 	}
  32460 	Xsqlite3_free(tls, pCellKey)
  32461 	goto moveto_index_finish
  32462 __19:
  32463 	;
  32464 	c1 = Xsqlite3VdbeRecordCompare(tls, nCell, pCellKey, pIdxKey)
  32465 	Xsqlite3_free(tls, pCellKey)
  32466 __16:
  32467 	;
  32468 __14:
  32469 	;
  32470 	if !(c1 < 0) {
  32471 		goto __20
  32472 	}
  32473 	lwr = idx + 1
  32474 	goto __21
  32475 __20:
  32476 	if !(c1 > 0) {
  32477 		goto __22
  32478 	}
  32479 	upr = idx - 1
  32480 	goto __23
  32481 __22:
  32482 	;
  32483 	*(*int32)(unsafe.Pointer(pRes)) = 0
  32484 	rc = SQLITE_OK
  32485 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx)
  32486 	if !((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode != 0) {
  32487 		goto __24
  32488 	}
  32489 	rc = Xsqlite3CorruptError(tls, 74396)
  32490 __24:
  32491 	;
  32492 	goto moveto_index_finish
  32493 __23:
  32494 	;
  32495 __21:
  32496 	;
  32497 	if !(lwr > upr) {
  32498 		goto __25
  32499 	}
  32500 	goto __12
  32501 __25:
  32502 	;
  32503 	idx = (lwr + upr) >> 1
  32504 	goto __11
  32505 __11:
  32506 	goto __10
  32507 	goto __12
  32508 __12:
  32509 	;
  32510 	if !((*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0) {
  32511 		goto __26
  32512 	}
  32513 
  32514 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx)
  32515 	*(*int32)(unsafe.Pointer(pRes)) = c1
  32516 	rc = SQLITE_OK
  32517 	goto moveto_index_finish
  32518 __26:
  32519 	;
  32520 	if !(lwr >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) {
  32521 		goto __27
  32522 	}
  32523 	chldPg = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8))
  32524 	goto __28
  32525 __27:
  32526 	chldPg = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*lwr)))))))
  32527 __28:
  32528 	;
  32529 	(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(lwr)
  32530 	rc = moveToChild(tls, pCur, chldPg)
  32531 	if !(rc != 0) {
  32532 		goto __29
  32533 	}
  32534 	goto __9
  32535 __29:
  32536 	;
  32537 	goto __8
  32538 __8:
  32539 	goto __7
  32540 	goto __9
  32541 __9:
  32542 	;
  32543 moveto_index_finish:
  32544 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  32545 
  32546 	return rc
  32547 }
  32548 
  32549 // Return TRUE if the cursor is not pointing at an entry of the table.
  32550 //
  32551 // TRUE will be returned after a call to sqlite3BtreeNext() moves
  32552 // past the last entry in the table or sqlite3BtreePrev() moves past
  32553 // the first entry.  TRUE is also returned if the table is empty.
  32554 func Xsqlite3BtreeEof(tls *libc.TLS, pCur uintptr) int32 {
  32555 	return libc.Bool32(CURSOR_VALID != int32((*BtCursor)(unsafe.Pointer(pCur)).FeState))
  32556 }
  32557 
  32558 // Return an estimate for the number of rows in the table that pCur is
  32559 // pointing to.  Return a negative number if no estimate is currently
  32560 // available.
  32561 func Xsqlite3BtreeRowCountEst(tls *libc.TLS, pCur uintptr) I64 {
  32562 	var n I64
  32563 	var i U8
  32564 
  32565 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  32566 		return int64(-1)
  32567 	}
  32568 	if int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0 {
  32569 		return int64(-1)
  32570 	}
  32571 
  32572 	n = I64((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell)
  32573 	for i = U8(0); int32(i) < int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage); i++ {
  32574 		n = n * I64((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(i)*4)))).FnCell)
  32575 	}
  32576 	return n
  32577 }
  32578 
  32579 func btreeNext(tls *libc.TLS, pCur uintptr) int32 {
  32580 	var rc int32
  32581 	var idx int32
  32582 	var pPage uintptr
  32583 
  32584 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  32585 		rc = func() int32 {
  32586 			if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK {
  32587 				return btreeRestoreCursorPosition(tls, pCur)
  32588 			}
  32589 			return SQLITE_OK
  32590 		}()
  32591 		if rc != SQLITE_OK {
  32592 			return rc
  32593 		}
  32594 		if CURSOR_INVALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) {
  32595 			return SQLITE_DONE
  32596 		}
  32597 		if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_SKIPNEXT {
  32598 			(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_VALID)
  32599 			if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext > 0 {
  32600 				return SQLITE_OK
  32601 			}
  32602 		}
  32603 	}
  32604 
  32605 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32606 	idx = int32(libc.PreIncUint16(&(*BtCursor)(unsafe.Pointer(pCur)).Fix, 1))
  32607 	if !(int32((*MemPage)(unsafe.Pointer(pPage)).FisInit) != 0) || Xsqlite3FaultSim(tls, 412) != 0 {
  32608 		return Xsqlite3CorruptError(tls, 74512)
  32609 	}
  32610 
  32611 	if idx >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  32612 		if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  32613 			rc = moveToChild(tls, pCur, Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)))
  32614 			if rc != 0 {
  32615 				return rc
  32616 			}
  32617 			return moveToLeftmost(tls, pCur)
  32618 		}
  32619 		for __ccgo := true; __ccgo; __ccgo = int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  32620 			if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 {
  32621 				(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  32622 				return SQLITE_DONE
  32623 			}
  32624 			moveToParent(tls, pCur)
  32625 			pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32626 		}
  32627 		if (*MemPage)(unsafe.Pointer(pPage)).FintKey != 0 {
  32628 			return Xsqlite3BtreeNext(tls, pCur, 0)
  32629 		} else {
  32630 			return SQLITE_OK
  32631 		}
  32632 	}
  32633 	if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 {
  32634 		return SQLITE_OK
  32635 	} else {
  32636 		return moveToLeftmost(tls, pCur)
  32637 	}
  32638 	return int32(0)
  32639 }
  32640 
  32641 func Xsqlite3BtreeNext(tls *libc.TLS, pCur uintptr, flags int32) int32 {
  32642 	var pPage uintptr
  32643 	_ = flags
  32644 
  32645 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  32646 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidNKey | BTCF_ValidOvfl))
  32647 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  32648 		return btreeNext(tls, pCur)
  32649 	}
  32650 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32651 	if int32(libc.PreIncUint16(&(*BtCursor)(unsafe.Pointer(pCur)).Fix, 1)) >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  32652 		(*BtCursor)(unsafe.Pointer(pCur)).Fix--
  32653 		return btreeNext(tls, pCur)
  32654 	}
  32655 	if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 {
  32656 		return SQLITE_OK
  32657 	} else {
  32658 		return moveToLeftmost(tls, pCur)
  32659 	}
  32660 	return int32(0)
  32661 }
  32662 
  32663 func btreePrevious(tls *libc.TLS, pCur uintptr) int32 {
  32664 	var rc int32
  32665 	var pPage uintptr
  32666 
  32667 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  32668 		rc = func() int32 {
  32669 			if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK {
  32670 				return btreeRestoreCursorPosition(tls, pCur)
  32671 			}
  32672 			return SQLITE_OK
  32673 		}()
  32674 		if rc != SQLITE_OK {
  32675 			return rc
  32676 		}
  32677 		if CURSOR_INVALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) {
  32678 			return SQLITE_DONE
  32679 		}
  32680 		if CURSOR_SKIPNEXT == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) {
  32681 			(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_VALID)
  32682 			if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext < 0 {
  32683 				return SQLITE_OK
  32684 			}
  32685 		}
  32686 	}
  32687 
  32688 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32689 
  32690 	if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  32691 		var idx int32 = int32((*BtCursor)(unsafe.Pointer(pCur)).Fix)
  32692 		rc = moveToChild(tls, pCur, Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*idx))))))))
  32693 		if rc != 0 {
  32694 			return rc
  32695 		}
  32696 		rc = moveToRightmost(tls, pCur)
  32697 	} else {
  32698 		for int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == 0 {
  32699 			if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 {
  32700 				(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  32701 				return SQLITE_DONE
  32702 			}
  32703 			moveToParent(tls, pCur)
  32704 		}
  32705 
  32706 		(*BtCursor)(unsafe.Pointer(pCur)).Fix--
  32707 		pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  32708 		if (*MemPage)(unsafe.Pointer(pPage)).FintKey != 0 && !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  32709 			rc = Xsqlite3BtreePrevious(tls, pCur, 0)
  32710 		} else {
  32711 			rc = SQLITE_OK
  32712 		}
  32713 	}
  32714 	return rc
  32715 }
  32716 
  32717 func Xsqlite3BtreePrevious(tls *libc.TLS, pCur uintptr, flags int32) int32 {
  32718 	_ = flags
  32719 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_AtLast | BTCF_ValidOvfl | BTCF_ValidNKey))
  32720 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  32721 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID ||
  32722 		int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == 0 ||
  32723 		int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0 {
  32724 		return btreePrevious(tls, pCur)
  32725 	}
  32726 	(*BtCursor)(unsafe.Pointer(pCur)).Fix--
  32727 	return SQLITE_OK
  32728 }
  32729 
  32730 func allocateBtreePage(tls *libc.TLS, pBt uintptr, ppPage uintptr, pPgno uintptr, nearby Pgno, eMode U8) int32 {
  32731 	bp := tls.Alloc(16)
  32732 	defer tls.Free(16)
  32733 
  32734 	var pPage1 uintptr
  32735 	var rc int32
  32736 	var n U32
  32737 	var k U32
  32738 
  32739 	var pPrevTrunk uintptr
  32740 	var mxPage Pgno
  32741 
  32742 	var iNewTrunk Pgno
  32743 	var d2 int32
  32744 	var dist int32
  32745 	var i U32
  32746 	var noContent int32
  32747 
  32748 	var closest U32
  32749 	var iPage Pgno
  32750 	var aData uintptr
  32751 
  32752 	var iTrunk Pgno
  32753 	var searchList U8
  32754 	var nSearch U32
  32755 
  32756 	var bNoContent int32
  32757 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  32758 	pPrevTrunk = uintptr(0)
  32759 
  32760 	pPage1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1
  32761 	mxPage = btreePagecount(tls, pBt)
  32762 
  32763 	n = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+36)
  32764 
  32765 	if !(n >= mxPage) {
  32766 		goto __1
  32767 	}
  32768 	return Xsqlite3CorruptError(tls, 74692)
  32769 __1:
  32770 	;
  32771 	if !(n > U32(0)) {
  32772 		goto __2
  32773 	}
  32774 	searchList = U8(0)
  32775 	nSearch = U32(0)
  32776 
  32777 	if !(int32(eMode) == BTALLOC_EXACT) {
  32778 		goto __4
  32779 	}
  32780 	if !(nearby <= mxPage) {
  32781 		goto __6
  32782 	}
  32783 
  32784 	rc = ptrmapGet(tls, pBt, nearby, bp, uintptr(0))
  32785 	if !(rc != 0) {
  32786 		goto __7
  32787 	}
  32788 	return rc
  32789 __7:
  32790 	;
  32791 	if !(int32(*(*U8)(unsafe.Pointer(bp))) == PTRMAP_FREEPAGE) {
  32792 		goto __8
  32793 	}
  32794 	searchList = U8(1)
  32795 __8:
  32796 	;
  32797 __6:
  32798 	;
  32799 	goto __5
  32800 __4:
  32801 	if !(int32(eMode) == BTALLOC_LE) {
  32802 		goto __9
  32803 	}
  32804 	searchList = U8(1)
  32805 __9:
  32806 	;
  32807 __5:
  32808 	;
  32809 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage1)).FpDbPage)
  32810 	if !(rc != 0) {
  32811 		goto __10
  32812 	}
  32813 	return rc
  32814 __10:
  32815 	;
  32816 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+36, n-U32(1))
  32817 
  32818 __11:
  32819 	pPrevTrunk = *(*uintptr)(unsafe.Pointer(bp + 4))
  32820 	if !(pPrevTrunk != 0) {
  32821 		goto __14
  32822 	}
  32823 
  32824 	iTrunk = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData)
  32825 	goto __15
  32826 __14:
  32827 	iTrunk = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+32)
  32828 __15:
  32829 	;
  32830 	if !(iTrunk > mxPage || libc.PostIncUint32(&nSearch, 1) > n) {
  32831 		goto __16
  32832 	}
  32833 	rc = Xsqlite3CorruptError(tls, 74748)
  32834 	goto __17
  32835 __16:
  32836 	rc = btreeGetUnusedPage(tls, pBt, iTrunk, bp+4, 0)
  32837 __17:
  32838 	;
  32839 	if !(rc != 0) {
  32840 		goto __18
  32841 	}
  32842 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  32843 	goto end_allocate_page
  32844 __18:
  32845 	;
  32846 	k = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData+4)
  32847 	if !(k == U32(0) && !(searchList != 0)) {
  32848 		goto __19
  32849 	}
  32850 
  32851 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpDbPage)
  32852 	if !(rc != 0) {
  32853 		goto __21
  32854 	}
  32855 	goto end_allocate_page
  32856 __21:
  32857 	;
  32858 	*(*Pgno)(unsafe.Pointer(pPgno)) = iTrunk
  32859 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+32, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData, uint32(4))
  32860 	*(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 4))
  32861 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  32862 
  32863 	goto __20
  32864 __19:
  32865 	if !(k > (*BtShared)(unsafe.Pointer(pBt)).FusableSize/U32(4)-U32(2)) {
  32866 		goto __22
  32867 	}
  32868 
  32869 	rc = Xsqlite3CorruptError(tls, 74777)
  32870 	goto end_allocate_page
  32871 	goto __23
  32872 __22:
  32873 	if !(searchList != 0 &&
  32874 		(nearby == iTrunk || iTrunk < nearby && int32(eMode) == BTALLOC_LE)) {
  32875 		goto __24
  32876 	}
  32877 
  32878 	*(*Pgno)(unsafe.Pointer(pPgno)) = iTrunk
  32879 	*(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 4))
  32880 	searchList = U8(0)
  32881 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpDbPage)
  32882 	if !(rc != 0) {
  32883 		goto __26
  32884 	}
  32885 	goto end_allocate_page
  32886 __26:
  32887 	;
  32888 	if !(k == U32(0)) {
  32889 		goto __27
  32890 	}
  32891 	if !!(pPrevTrunk != 0) {
  32892 		goto __29
  32893 	}
  32894 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+32, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData, uint32(4))
  32895 	goto __30
  32896 __29:
  32897 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage)
  32898 	if !(rc != SQLITE_OK) {
  32899 		goto __31
  32900 	}
  32901 	goto end_allocate_page
  32902 __31:
  32903 	;
  32904 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData, uint32(4))
  32905 __30:
  32906 	;
  32907 	goto __28
  32908 __27:
  32909 	iNewTrunk = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData+8)
  32910 	if !(iNewTrunk > mxPage) {
  32911 		goto __32
  32912 	}
  32913 	rc = Xsqlite3CorruptError(tls, 74811)
  32914 	goto end_allocate_page
  32915 __32:
  32916 	;
  32917 	rc = btreeGetUnusedPage(tls, pBt, iNewTrunk, bp+8, 0)
  32918 	if !(rc != SQLITE_OK) {
  32919 		goto __33
  32920 	}
  32921 	goto end_allocate_page
  32922 __33:
  32923 	;
  32924 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FpDbPage)
  32925 	if !(rc != SQLITE_OK) {
  32926 		goto __34
  32927 	}
  32928 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  32929 	goto end_allocate_page
  32930 __34:
  32931 	;
  32932 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData, uint32(4))
  32933 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData+4, k-U32(1))
  32934 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData+8, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData+12, (k-U32(1))*U32(4))
  32935 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  32936 	if !!(pPrevTrunk != 0) {
  32937 		goto __35
  32938 	}
  32939 
  32940 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+32, iNewTrunk)
  32941 	goto __36
  32942 __35:
  32943 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage)
  32944 	if !(rc != 0) {
  32945 		goto __37
  32946 	}
  32947 	goto end_allocate_page
  32948 __37:
  32949 	;
  32950 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData, iNewTrunk)
  32951 __36:
  32952 	;
  32953 __28:
  32954 	;
  32955 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  32956 
  32957 	goto __25
  32958 __24:
  32959 	if !(k > U32(0)) {
  32960 		goto __38
  32961 	}
  32962 	aData = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FaData
  32963 	if !(nearby > Pgno(0)) {
  32964 		goto __39
  32965 	}
  32966 	closest = U32(0)
  32967 	if !(int32(eMode) == BTALLOC_LE) {
  32968 		goto __41
  32969 	}
  32970 	i = U32(0)
  32971 __43:
  32972 	if !(i < k) {
  32973 		goto __45
  32974 	}
  32975 	iPage = Xsqlite3Get4byte(tls, aData+uintptr(U32(8)+i*U32(4)))
  32976 	if !(iPage <= nearby) {
  32977 		goto __46
  32978 	}
  32979 	closest = i
  32980 	goto __45
  32981 __46:
  32982 	;
  32983 	goto __44
  32984 __44:
  32985 	i++
  32986 	goto __43
  32987 	goto __45
  32988 __45:
  32989 	;
  32990 	goto __42
  32991 __41:
  32992 	dist = Xsqlite3AbsInt32(tls, int32(Xsqlite3Get4byte(tls, aData+8)-nearby))
  32993 	i = U32(1)
  32994 __47:
  32995 	if !(i < k) {
  32996 		goto __49
  32997 	}
  32998 	d2 = Xsqlite3AbsInt32(tls, int32(Xsqlite3Get4byte(tls, aData+uintptr(U32(8)+i*U32(4)))-nearby))
  32999 	if !(d2 < dist) {
  33000 		goto __50
  33001 	}
  33002 	closest = i
  33003 	dist = d2
  33004 __50:
  33005 	;
  33006 	goto __48
  33007 __48:
  33008 	i++
  33009 	goto __47
  33010 	goto __49
  33011 __49:
  33012 	;
  33013 __42:
  33014 	;
  33015 	goto __40
  33016 __39:
  33017 	closest = U32(0)
  33018 __40:
  33019 	;
  33020 	iPage = Xsqlite3Get4byte(tls, aData+uintptr(U32(8)+closest*U32(4)))
  33021 
  33022 	if !(iPage > mxPage || iPage < Pgno(2)) {
  33023 		goto __51
  33024 	}
  33025 	rc = Xsqlite3CorruptError(tls, 74876)
  33026 	goto end_allocate_page
  33027 __51:
  33028 	;
  33029 	if !(!(searchList != 0) ||
  33030 		(iPage == nearby || iPage < nearby && int32(eMode) == BTALLOC_LE)) {
  33031 		goto __52
  33032 	}
  33033 	*(*Pgno)(unsafe.Pointer(pPgno)) = iPage
  33034 
  33035 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpDbPage)
  33036 	if !(rc != 0) {
  33037 		goto __53
  33038 	}
  33039 	goto end_allocate_page
  33040 __53:
  33041 	;
  33042 	if !(closest < k-U32(1)) {
  33043 		goto __54
  33044 	}
  33045 	libc.Xmemcpy(tls, aData+uintptr(U32(8)+closest*U32(4)), aData+uintptr(U32(4)+k*U32(4)), uint32(4))
  33046 __54:
  33047 	;
  33048 	Xsqlite3Put4byte(tls, aData+4, k-U32(1))
  33049 	if !(btreeGetHasContent(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno))) != 0) {
  33050 		noContent = PAGER_GET_NOCONTENT
  33051 	} else {
  33052 		noContent = 0
  33053 	}
  33054 	rc = btreeGetUnusedPage(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno)), ppPage, noContent)
  33055 	if !(rc == SQLITE_OK) {
  33056 		goto __55
  33057 	}
  33058 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage)
  33059 	if !(rc != SQLITE_OK) {
  33060 		goto __56
  33061 	}
  33062 	releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage)))
  33063 	*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  33064 __56:
  33065 	;
  33066 __55:
  33067 	;
  33068 	searchList = U8(0)
  33069 __52:
  33070 	;
  33071 __38:
  33072 	;
  33073 __25:
  33074 	;
  33075 __23:
  33076 	;
  33077 __20:
  33078 	;
  33079 	releasePage(tls, pPrevTrunk)
  33080 	pPrevTrunk = uintptr(0)
  33081 	goto __12
  33082 __12:
  33083 	if searchList != 0 {
  33084 		goto __11
  33085 	}
  33086 	goto __13
  33087 __13:
  33088 	;
  33089 	goto __3
  33090 __2:
  33091 	if 0 == int32((*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate) {
  33092 		bNoContent = PAGER_GET_NOCONTENT
  33093 	} else {
  33094 		bNoContent = 0
  33095 	}
  33096 
  33097 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
  33098 	if !(rc != 0) {
  33099 		goto __57
  33100 	}
  33101 	return rc
  33102 __57:
  33103 	;
  33104 	(*BtShared)(unsafe.Pointer(pBt)).FnPage++
  33105 	if !((*BtShared)(unsafe.Pointer(pBt)).FnPage == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1)) {
  33106 		goto __58
  33107 	}
  33108 	(*BtShared)(unsafe.Pointer(pBt)).FnPage++
  33109 __58:
  33110 	;
  33111 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && ptrmapPageno(tls, pBt, (*BtShared)(unsafe.Pointer(pBt)).FnPage) == (*BtShared)(unsafe.Pointer(pBt)).FnPage) {
  33112 		goto __59
  33113 	}
  33114 
  33115 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
  33116 
  33117 	rc = btreeGetUnusedPage(tls, pBt, (*BtShared)(unsafe.Pointer(pBt)).FnPage, bp+12, bNoContent)
  33118 	if !(rc == SQLITE_OK) {
  33119 		goto __60
  33120 	}
  33121 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FpDbPage)
  33122 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  33123 __60:
  33124 	;
  33125 	if !(rc != 0) {
  33126 		goto __61
  33127 	}
  33128 	return rc
  33129 __61:
  33130 	;
  33131 	(*BtShared)(unsafe.Pointer(pBt)).FnPage++
  33132 	if !((*BtShared)(unsafe.Pointer(pBt)).FnPage == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1)) {
  33133 		goto __62
  33134 	}
  33135 	(*BtShared)(unsafe.Pointer(pBt)).FnPage++
  33136 __62:
  33137 	;
  33138 __59:
  33139 	;
  33140 	Xsqlite3Put4byte(tls, uintptr(28)+(*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData, (*BtShared)(unsafe.Pointer(pBt)).FnPage)
  33141 	*(*Pgno)(unsafe.Pointer(pPgno)) = (*BtShared)(unsafe.Pointer(pBt)).FnPage
  33142 
  33143 	rc = btreeGetUnusedPage(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno)), ppPage, bNoContent)
  33144 	if !(rc != 0) {
  33145 		goto __63
  33146 	}
  33147 	return rc
  33148 __63:
  33149 	;
  33150 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage)
  33151 	if !(rc != SQLITE_OK) {
  33152 		goto __64
  33153 	}
  33154 	releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage)))
  33155 	*(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0)
  33156 __64:
  33157 	;
  33158 __3:
  33159 	;
  33160 end_allocate_page:
  33161 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
  33162 	releasePage(tls, pPrevTrunk)
  33163 
  33164 	return rc
  33165 }
  33166 
  33167 func freePage2(tls *libc.TLS, pBt uintptr, pMemPage uintptr, iPage Pgno) int32 {
  33168 	bp := tls.Alloc(12)
  33169 	defer tls.Free(12)
  33170 
  33171 	var iTrunk Pgno
  33172 	var pPage1 uintptr
  33173 
  33174 	var nFree U32
  33175 	var nLeaf U32
  33176 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  33177 	iTrunk = Pgno(0)
  33178 	pPage1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1
  33179 
  33180 	if !(iPage < Pgno(2) || iPage > (*BtShared)(unsafe.Pointer(pBt)).FnPage) {
  33181 		goto __1
  33182 	}
  33183 	return Xsqlite3CorruptError(tls, 75003)
  33184 __1:
  33185 	;
  33186 	if !(pMemPage != 0) {
  33187 		goto __2
  33188 	}
  33189 	*(*uintptr)(unsafe.Pointer(bp)) = pMemPage
  33190 	Xsqlite3PagerRef(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)
  33191 	goto __3
  33192 __2:
  33193 	*(*uintptr)(unsafe.Pointer(bp)) = btreePageLookup(tls, pBt, iPage)
  33194 __3:
  33195 	;
  33196 	*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage1)).FpDbPage)
  33197 	if !(*(*int32)(unsafe.Pointer(bp + 4)) != 0) {
  33198 		goto __4
  33199 	}
  33200 	goto freepage_out
  33201 __4:
  33202 	;
  33203 	nFree = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+36)
  33204 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+36, nFree+U32(1))
  33205 
  33206 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_SECURE_DELETE != 0) {
  33207 		goto __5
  33208 	}
  33209 
  33210 	if !(!(*(*uintptr)(unsafe.Pointer(bp)) != 0) && libc.AssignPtrInt32(bp+4, btreeGetPage(tls, pBt, iPage, bp, 0)) != 0 ||
  33211 		libc.AssignPtrInt32(bp+4, Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)) != 0) {
  33212 		goto __6
  33213 	}
  33214 	goto freepage_out
  33215 __6:
  33216 	;
  33217 	libc.Xmemset(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData, 0, (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpBt)).FpageSize)
  33218 __5:
  33219 	;
  33220 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  33221 		goto __7
  33222 	}
  33223 	ptrmapPut(tls, pBt, iPage, uint8(PTRMAP_FREEPAGE), uint32(0), bp+4)
  33224 	if !(*(*int32)(unsafe.Pointer(bp + 4)) != 0) {
  33225 		goto __8
  33226 	}
  33227 	goto freepage_out
  33228 __8:
  33229 	;
  33230 __7:
  33231 	;
  33232 	if !(nFree != U32(0)) {
  33233 		goto __9
  33234 	}
  33235 
  33236 	iTrunk = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+32)
  33237 	if !(iTrunk > btreePagecount(tls, pBt)) {
  33238 		goto __10
  33239 	}
  33240 	*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3CorruptError(tls, 75050)
  33241 	goto freepage_out
  33242 __10:
  33243 	;
  33244 	*(*int32)(unsafe.Pointer(bp + 4)) = btreeGetPage(tls, pBt, iTrunk, bp+8, 0)
  33245 	if !(*(*int32)(unsafe.Pointer(bp + 4)) != SQLITE_OK) {
  33246 		goto __11
  33247 	}
  33248 	goto freepage_out
  33249 __11:
  33250 	;
  33251 	nLeaf = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData+4)
  33252 
  33253 	if !(nLeaf > (*BtShared)(unsafe.Pointer(pBt)).FusableSize/U32(4)-U32(2)) {
  33254 		goto __12
  33255 	}
  33256 	*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3CorruptError(tls, 75061)
  33257 	goto freepage_out
  33258 __12:
  33259 	;
  33260 	if !(nLeaf < (*BtShared)(unsafe.Pointer(pBt)).FusableSize/U32(4)-U32(8)) {
  33261 		goto __13
  33262 	}
  33263 
  33264 	*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FpDbPage)
  33265 	if !(*(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK) {
  33266 		goto __14
  33267 	}
  33268 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData+4, nLeaf+U32(1))
  33269 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FaData+uintptr(U32(8)+nLeaf*U32(4)), iPage)
  33270 	if !(*(*uintptr)(unsafe.Pointer(bp)) != 0 && int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_SECURE_DELETE == 0) {
  33271 		goto __15
  33272 	}
  33273 	Xsqlite3PagerDontWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)
  33274 __15:
  33275 	;
  33276 	*(*int32)(unsafe.Pointer(bp + 4)) = btreeSetHasContent(tls, pBt, iPage)
  33277 __14:
  33278 	;
  33279 	goto freepage_out
  33280 __13:
  33281 	;
  33282 __9:
  33283 	;
  33284 	if !(*(*uintptr)(unsafe.Pointer(bp)) == uintptr(0) && SQLITE_OK != libc.AssignPtrInt32(bp+4, btreeGetPage(tls, pBt, iPage, bp, 0))) {
  33285 		goto __16
  33286 	}
  33287 	goto freepage_out
  33288 __16:
  33289 	;
  33290 	*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)
  33291 	if !(*(*int32)(unsafe.Pointer(bp + 4)) != SQLITE_OK) {
  33292 		goto __17
  33293 	}
  33294 	goto freepage_out
  33295 __17:
  33296 	;
  33297 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData, iTrunk)
  33298 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData+4, uint32(0))
  33299 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pPage1)).FaData+32, iPage)
  33300 
  33301 freepage_out:
  33302 	if !(*(*uintptr)(unsafe.Pointer(bp)) != 0) {
  33303 		goto __18
  33304 	}
  33305 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FisInit = U8(0)
  33306 __18:
  33307 	;
  33308 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  33309 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  33310 	return *(*int32)(unsafe.Pointer(bp + 4))
  33311 }
  33312 
  33313 func freePage(tls *libc.TLS, pPage uintptr, pRC uintptr) {
  33314 	if *(*int32)(unsafe.Pointer(pRC)) == SQLITE_OK {
  33315 		*(*int32)(unsafe.Pointer(pRC)) = freePage2(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, pPage, (*MemPage)(unsafe.Pointer(pPage)).Fpgno)
  33316 	}
  33317 }
  33318 
  33319 func clearCellOverflow(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) int32 {
  33320 	bp := tls.Alloc(8)
  33321 	defer tls.Free(8)
  33322 
  33323 	var pBt uintptr
  33324 	var ovflPgno Pgno
  33325 	var rc int32
  33326 	var nOvfl int32
  33327 	var ovflPageSize U32
  33328 
  33329 	if pCell+uintptr((*CellInfo)(unsafe.Pointer(pInfo)).FnSize) > (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd {
  33330 		return Xsqlite3CorruptError(tls, 75150)
  33331 	}
  33332 	ovflPgno = Xsqlite3Get4byte(tls, pCell+uintptr((*CellInfo)(unsafe.Pointer(pInfo)).FnSize)-uintptr(4))
  33333 	pBt = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  33334 
  33335 	ovflPageSize = (*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4)
  33336 	nOvfl = int32(((*CellInfo)(unsafe.Pointer(pInfo)).FnPayload - U32((*CellInfo)(unsafe.Pointer(pInfo)).FnLocal) + ovflPageSize - U32(1)) / ovflPageSize)
  33337 
  33338 	for libc.PostDecInt32(&nOvfl, 1) != 0 {
  33339 		*(*Pgno)(unsafe.Pointer(bp + 4)) = Pgno(0)
  33340 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  33341 		if ovflPgno < Pgno(2) || ovflPgno > btreePagecount(tls, pBt) {
  33342 			return Xsqlite3CorruptError(tls, 75167)
  33343 		}
  33344 		if nOvfl != 0 {
  33345 			rc = getOverflowPage(tls, pBt, ovflPgno, bp, bp+4)
  33346 			if rc != 0 {
  33347 				return rc
  33348 			}
  33349 		}
  33350 
  33351 		if (*(*uintptr)(unsafe.Pointer(bp)) != 0 || libc.AssignPtrUintptr(bp, btreePageLookup(tls, pBt, ovflPgno)) != uintptr(0)) &&
  33352 			Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage) != 1 {
  33353 			rc = Xsqlite3CorruptError(tls, 75187)
  33354 		} else {
  33355 			rc = freePage2(tls, pBt, *(*uintptr)(unsafe.Pointer(bp)), ovflPgno)
  33356 		}
  33357 
  33358 		if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  33359 			Xsqlite3PagerUnref(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)
  33360 		}
  33361 		if rc != 0 {
  33362 			return rc
  33363 		}
  33364 		ovflPgno = *(*Pgno)(unsafe.Pointer(bp + 4))
  33365 	}
  33366 	return SQLITE_OK
  33367 }
  33368 
  33369 func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize uintptr) int32 {
  33370 	bp := tls.Alloc(12)
  33371 	defer tls.Free(12)
  33372 
  33373 	var nPayload int32
  33374 	var pSrc uintptr
  33375 	var nSrc int32
  33376 	var n int32
  33377 
  33378 	var mn int32
  33379 	var spaceLeft int32
  33380 	var pToRelease uintptr
  33381 	var pPrior uintptr
  33382 	var pPayload uintptr
  33383 	var pBt uintptr
  33384 
  33385 	var nHeader int32
  33386 
  33387 	nHeader = int32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)
  33388 	if (*MemPage)(unsafe.Pointer(pPage)).FintKey != 0 {
  33389 		nPayload = (*BtreePayload)(unsafe.Pointer(pX)).FnData + (*BtreePayload)(unsafe.Pointer(pX)).FnZero
  33390 		pSrc = (*BtreePayload)(unsafe.Pointer(pX)).FpData
  33391 		nSrc = (*BtreePayload)(unsafe.Pointer(pX)).FnData
  33392 
  33393 		nHeader = nHeader + int32(func() uint8 {
  33394 			if U32(nPayload) < U32(0x80) {
  33395 				return uint8(func() int32 { *(*uint8)(unsafe.Pointer(pCell + uintptr(nHeader))) = uint8(nPayload); return 1 }())
  33396 			}
  33397 			return uint8(Xsqlite3PutVarint(tls, pCell+uintptr(nHeader), uint64(nPayload)))
  33398 		}())
  33399 		nHeader = nHeader + Xsqlite3PutVarint(tls, pCell+uintptr(nHeader), *(*U64)(unsafe.Pointer(pX + 8)))
  33400 	} else {
  33401 		nSrc = libc.AssignInt32(&nPayload, int32((*BtreePayload)(unsafe.Pointer(pX)).FnKey))
  33402 		pSrc = (*BtreePayload)(unsafe.Pointer(pX)).FpKey
  33403 		nHeader = nHeader + int32(func() uint8 {
  33404 			if U32(nPayload) < U32(0x80) {
  33405 				return uint8(func() int32 { *(*uint8)(unsafe.Pointer(pCell + uintptr(nHeader))) = uint8(nPayload); return 1 }())
  33406 			}
  33407 			return uint8(Xsqlite3PutVarint(tls, pCell+uintptr(nHeader), uint64(nPayload)))
  33408 		}())
  33409 	}
  33410 
  33411 	pPayload = pCell + uintptr(nHeader)
  33412 	if nPayload <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  33413 		n = nHeader + nPayload
  33414 
  33415 		if n < 4 {
  33416 			n = 4
  33417 		}
  33418 		*(*int32)(unsafe.Pointer(pnSize)) = n
  33419 
  33420 		libc.Xmemcpy(tls, pPayload, pSrc, uint32(nSrc))
  33421 		libc.Xmemset(tls, pPayload+uintptr(nSrc), 0, uint32(nPayload-nSrc))
  33422 		return SQLITE_OK
  33423 	}
  33424 
  33425 	mn = int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)
  33426 	n = int32(U32(mn) + U32(nPayload-mn)%((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize-U32(4)))
  33427 
  33428 	if n > int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal) {
  33429 		n = mn
  33430 	}
  33431 	spaceLeft = n
  33432 	*(*int32)(unsafe.Pointer(pnSize)) = n + nHeader + 4
  33433 	pPrior = pCell + uintptr(nHeader+n)
  33434 	pToRelease = uintptr(0)
  33435 	*(*Pgno)(unsafe.Pointer(bp + 4)) = Pgno(0)
  33436 	pBt = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  33437 
  33438 	for 1 != 0 {
  33439 		n = nPayload
  33440 		if n > spaceLeft {
  33441 			n = spaceLeft
  33442 		}
  33443 
  33444 		if nSrc >= n {
  33445 			libc.Xmemcpy(tls, pPayload, pSrc, uint32(n))
  33446 		} else if nSrc > 0 {
  33447 			n = nSrc
  33448 			libc.Xmemcpy(tls, pPayload, pSrc, uint32(n))
  33449 		} else {
  33450 			libc.Xmemset(tls, pPayload, 0, uint32(n))
  33451 		}
  33452 		nPayload = nPayload - n
  33453 		if nPayload <= 0 {
  33454 			break
  33455 		}
  33456 		pPayload += uintptr(n)
  33457 		pSrc += uintptr(n)
  33458 		nSrc = nSrc - n
  33459 		spaceLeft = spaceLeft - n
  33460 		if spaceLeft == 0 {
  33461 			*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  33462 			var pgnoPtrmap Pgno = *(*Pgno)(unsafe.Pointer(bp + 4))
  33463 			if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  33464 				for __ccgo := true; __ccgo; __ccgo = ptrmapPageno(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4))) == *(*Pgno)(unsafe.Pointer(bp + 4)) || *(*Pgno)(unsafe.Pointer(bp + 4)) == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  33465 					*(*Pgno)(unsafe.Pointer(bp + 4))++
  33466 				}
  33467 			}
  33468 			*(*int32)(unsafe.Pointer(bp + 8)) = allocateBtreePage(tls, pBt, bp, bp+4, *(*Pgno)(unsafe.Pointer(bp + 4)), uint8(0))
  33469 
  33470 			if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
  33471 				var eType U8 = func() uint8 {
  33472 					if pgnoPtrmap != 0 {
  33473 						return uint8(PTRMAP_OVERFLOW2)
  33474 					}
  33475 					return uint8(PTRMAP_OVERFLOW1)
  33476 				}()
  33477 				ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4)), eType, pgnoPtrmap, bp+8)
  33478 				if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
  33479 					releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  33480 				}
  33481 			}
  33482 			if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
  33483 				releasePage(tls, pToRelease)
  33484 				return *(*int32)(unsafe.Pointer(bp + 8))
  33485 			}
  33486 
  33487 			Xsqlite3Put4byte(tls, pPrior, *(*Pgno)(unsafe.Pointer(bp + 4)))
  33488 			releasePage(tls, pToRelease)
  33489 			pToRelease = *(*uintptr)(unsafe.Pointer(bp))
  33490 			pPrior = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData
  33491 			Xsqlite3Put4byte(tls, pPrior, uint32(0))
  33492 			pPayload = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData + 4
  33493 			spaceLeft = int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4))
  33494 		}
  33495 	}
  33496 	releasePage(tls, pToRelease)
  33497 	return SQLITE_OK
  33498 }
  33499 
  33500 func dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) {
  33501 	var pc U32
  33502 	var data uintptr
  33503 	var ptr uintptr
  33504 	var rc int32
  33505 	var hdr int32
  33506 
  33507 	if *(*int32)(unsafe.Pointer(pRC)) != 0 {
  33508 		return
  33509 	}
  33510 
  33511 	data = (*MemPage)(unsafe.Pointer(pPage)).FaData
  33512 	ptr = (*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*idx)
  33513 
  33514 	pc = U32(int32(*(*U8)(unsafe.Pointer(ptr)))<<8 | int32(*(*U8)(unsafe.Pointer(ptr + 1))))
  33515 	hdr = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)
  33516 
  33517 	if pc+U32(sz) > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize {
  33518 		*(*int32)(unsafe.Pointer(pRC)) = Xsqlite3CorruptError(tls, 75440)
  33519 		return
  33520 	}
  33521 	rc = freeSpace(tls, pPage, uint16(pc), uint16(sz))
  33522 	if rc != 0 {
  33523 		*(*int32)(unsafe.Pointer(pRC)) = rc
  33524 		return
  33525 	}
  33526 	(*MemPage)(unsafe.Pointer(pPage)).FnCell--
  33527 	if int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) == 0 {
  33528 		libc.Xmemset(tls, data+uintptr(hdr+1), 0, uint32(4))
  33529 		*(*U8)(unsafe.Pointer(data + uintptr(hdr+7))) = U8(0)
  33530 		*(*U8)(unsafe.Pointer(data + uintptr(hdr+5))) = U8((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize >> 8)
  33531 		*(*U8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)) = U8((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize)
  33532 		(*MemPage)(unsafe.Pointer(pPage)).FnFree = int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize - U32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) -
  33533 			U32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize) - U32(8))
  33534 	} else {
  33535 		libc.Xmemmove(tls, ptr, ptr+uintptr(2), uint32(2*(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)-idx)))
  33536 		*(*U8)(unsafe.Pointer(data + uintptr(hdr+3))) = U8(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) >> 8)
  33537 		*(*U8)(unsafe.Pointer(data + uintptr(hdr+3) + 1)) = U8((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  33538 		*(*int32)(unsafe.Pointer(pPage + 20)) += 2
  33539 	}
  33540 }
  33541 
  33542 func insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, pTemp uintptr, iChild Pgno) int32 {
  33543 	bp := tls.Alloc(8)
  33544 	defer tls.Free(8)
  33545 
  33546 	*(*int32)(unsafe.Pointer(bp)) = 0
  33547 	var j int32
  33548 	var data uintptr
  33549 	var pIns uintptr
  33550 
  33551 	if (*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0 || sz+2 > (*MemPage)(unsafe.Pointer(pPage)).FnFree {
  33552 		if pTemp != 0 {
  33553 			libc.Xmemcpy(tls, pTemp, pCell, uint32(sz))
  33554 			pCell = pTemp
  33555 		}
  33556 		if iChild != 0 {
  33557 			Xsqlite3Put4byte(tls, pCell, iChild)
  33558 		}
  33559 		j = int32(libc.PostIncUint8(&(*MemPage)(unsafe.Pointer(pPage)).FnOverflow, 1))
  33560 
  33561 		*(*uintptr)(unsafe.Pointer(pPage + 36 + uintptr(j)*4)) = pCell
  33562 		*(*U16)(unsafe.Pointer(pPage + 28 + uintptr(j)*2)) = U16(i)
  33563 
  33564 	} else {
  33565 		var rc int32 = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  33566 		if rc != SQLITE_OK {
  33567 			return rc
  33568 		}
  33569 
  33570 		data = (*MemPage)(unsafe.Pointer(pPage)).FaData
  33571 
  33572 		rc = allocateSpace(tls, pPage, sz, bp)
  33573 		if rc != 0 {
  33574 			return rc
  33575 		}
  33576 
  33577 		*(*int32)(unsafe.Pointer(pPage + 20)) -= int32(U16(2 + sz))
  33578 		if iChild != 0 {
  33579 			libc.Xmemcpy(tls, data+uintptr(*(*int32)(unsafe.Pointer(bp))+4), pCell+uintptr(4), uint32(sz-4))
  33580 			Xsqlite3Put4byte(tls, data+uintptr(*(*int32)(unsafe.Pointer(bp))), iChild)
  33581 		} else {
  33582 			libc.Xmemcpy(tls, data+uintptr(*(*int32)(unsafe.Pointer(bp))), pCell, uint32(sz))
  33583 		}
  33584 		pIns = (*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(i*2)
  33585 		libc.Xmemmove(tls, pIns+uintptr(2), pIns, uint32(2*(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)-i)))
  33586 		*(*U8)(unsafe.Pointer(pIns)) = U8(*(*int32)(unsafe.Pointer(bp)) >> 8)
  33587 		*(*U8)(unsafe.Pointer(pIns + 1)) = U8(*(*int32)(unsafe.Pointer(bp)))
  33588 		(*MemPage)(unsafe.Pointer(pPage)).FnCell++
  33589 
  33590 		if int32(libc.PreIncUint8(&*(*U8)(unsafe.Pointer(data + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+4))), 1)) == 0 {
  33591 			*(*U8)(unsafe.Pointer(data + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+3)))++
  33592 		}
  33593 
  33594 		if (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FautoVacuum != 0 {
  33595 			*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_OK
  33596 
  33597 			ptrmapPutOvflPtr(tls, pPage, pPage, pCell, bp+4)
  33598 			if *(*int32)(unsafe.Pointer(bp + 4)) != 0 {
  33599 				return *(*int32)(unsafe.Pointer(bp + 4))
  33600 			}
  33601 		}
  33602 	}
  33603 	return SQLITE_OK
  33604 }
  33605 
  33606 // A CellArray object contains a cache of pointers and sizes for a
  33607 // consecutive sequence of cells that might be held on multiple pages.
  33608 //
  33609 // The cells in this array are the divider cell or cells from the pParent
  33610 // page plus up to three child pages.  There are a total of nCell cells.
  33611 //
  33612 // pRef is a pointer to one of the pages that contributes cells.  This is
  33613 // used to access information such as MemPage.intKey and MemPage.pBt->pageSize
  33614 // which should be common to all pages that contribute cells to this array.
  33615 //
  33616 // apCell[] and szCell[] hold, respectively, pointers to the start of each
  33617 // cell and the size of each cell.  Some of the apCell[] pointers might refer
  33618 // to overflow cells.  In other words, some apCel[] pointers might not point
  33619 // to content area of the pages.
  33620 //
  33621 // A szCell[] of zero means the size of that cell has not yet been computed.
  33622 //
  33623 // The cells come from as many as four different pages:
  33624 //
  33625 //	           -----------
  33626 //	           | Parent  |
  33627 //	           -----------
  33628 //	          /     |     **           /      |      **  ---------   ---------   ---------
  33629 //	|Child-1|   |Child-2|   |Child-3|
  33630 //	---------   ---------   ---------
  33631 //
  33632 // The order of cells is in the array is for an index btree is:
  33633 //
  33634 //  1. All cells from Child-1 in order
  33635 //  2. The first divider cell from Parent
  33636 //  3. All cells from Child-2 in order
  33637 //  4. The second divider cell from Parent
  33638 //  5. All cells from Child-3 in order
  33639 //
  33640 // For a table-btree (with rowids) the items 2 and 4 are empty because
  33641 // content exists only in leaves and there are no divider cells.
  33642 //
  33643 // For an index btree, the apEnd[] array holds pointer to the end of page
  33644 // for Child-1, the Parent, Child-2, the Parent (again), and Child-3,
  33645 // respectively. The ixNx[] array holds the number of cells contained in
  33646 // each of these 5 stages, and all stages to the left.  Hence:
  33647 //
  33648 //	ixNx[0] = Number of cells in Child-1.
  33649 //	ixNx[1] = Number of cells in Child-1 plus 1 for first divider.
  33650 //	ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
  33651 //	ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells
  33652 //	ixNx[4] = Total number of cells.
  33653 //
  33654 // For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
  33655 // are used and they point to the leaf pages only, and the ixNx value are:
  33656 //
  33657 //	ixNx[0] = Number of cells in Child-1.
  33658 //	ixNx[1] = Number of cells in Child-1 and Child-2.
  33659 //	ixNx[2] = Total number of cells.
  33660 //
  33661 // Sometimes when deleting, a child page can have zero cells.  In those
  33662 // cases, ixNx[] entries with higher indexes, and the corresponding apEnd[]
  33663 // entries, shift down.  The end result is that each ixNx[] entry should
  33664 // be larger than the previous
  33665 type CellArray1 = struct {
  33666 	FnCell  int32
  33667 	FpRef   uintptr
  33668 	FapCell uintptr
  33669 	FszCell uintptr
  33670 	FapEnd  [6]uintptr
  33671 	FixNx   [6]int32
  33672 }
  33673 
  33674 // A CellArray object contains a cache of pointers and sizes for a
  33675 // consecutive sequence of cells that might be held on multiple pages.
  33676 //
  33677 // The cells in this array are the divider cell or cells from the pParent
  33678 // page plus up to three child pages.  There are a total of nCell cells.
  33679 //
  33680 // pRef is a pointer to one of the pages that contributes cells.  This is
  33681 // used to access information such as MemPage.intKey and MemPage.pBt->pageSize
  33682 // which should be common to all pages that contribute cells to this array.
  33683 //
  33684 // apCell[] and szCell[] hold, respectively, pointers to the start of each
  33685 // cell and the size of each cell.  Some of the apCell[] pointers might refer
  33686 // to overflow cells.  In other words, some apCel[] pointers might not point
  33687 // to content area of the pages.
  33688 //
  33689 // A szCell[] of zero means the size of that cell has not yet been computed.
  33690 //
  33691 // The cells come from as many as four different pages:
  33692 //
  33693 //	           -----------
  33694 //	           | Parent  |
  33695 //	           -----------
  33696 //	          /     |     **           /      |      **  ---------   ---------   ---------
  33697 //	|Child-1|   |Child-2|   |Child-3|
  33698 //	---------   ---------   ---------
  33699 //
  33700 // The order of cells is in the array is for an index btree is:
  33701 //
  33702 //  1. All cells from Child-1 in order
  33703 //  2. The first divider cell from Parent
  33704 //  3. All cells from Child-2 in order
  33705 //  4. The second divider cell from Parent
  33706 //  5. All cells from Child-3 in order
  33707 //
  33708 // For a table-btree (with rowids) the items 2 and 4 are empty because
  33709 // content exists only in leaves and there are no divider cells.
  33710 //
  33711 // For an index btree, the apEnd[] array holds pointer to the end of page
  33712 // for Child-1, the Parent, Child-2, the Parent (again), and Child-3,
  33713 // respectively. The ixNx[] array holds the number of cells contained in
  33714 // each of these 5 stages, and all stages to the left.  Hence:
  33715 //
  33716 //	ixNx[0] = Number of cells in Child-1.
  33717 //	ixNx[1] = Number of cells in Child-1 plus 1 for first divider.
  33718 //	ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
  33719 //	ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells
  33720 //	ixNx[4] = Total number of cells.
  33721 //
  33722 // For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
  33723 // are used and they point to the leaf pages only, and the ixNx value are:
  33724 //
  33725 //	ixNx[0] = Number of cells in Child-1.
  33726 //	ixNx[1] = Number of cells in Child-1 and Child-2.
  33727 //	ixNx[2] = Total number of cells.
  33728 //
  33729 // Sometimes when deleting, a child page can have zero cells.  In those
  33730 // cases, ixNx[] entries with higher indexes, and the corresponding apEnd[]
  33731 // entries, shift down.  The end result is that each ixNx[] entry should
  33732 // be larger than the previous
  33733 type CellArray = CellArray1
  33734 
  33735 func populateCellCache(tls *libc.TLS, p uintptr, idx int32, N int32) {
  33736 	var pRef uintptr = (*CellArray)(unsafe.Pointer(p)).FpRef
  33737 	var szCell uintptr = (*CellArray)(unsafe.Pointer(p)).FszCell
  33738 
  33739 	for N > 0 {
  33740 		if int32(*(*U16)(unsafe.Pointer(szCell + uintptr(idx)*2))) == 0 {
  33741 			*(*U16)(unsafe.Pointer(szCell + uintptr(idx)*2)) = (*struct {
  33742 				f func(*libc.TLS, uintptr, uintptr) U16
  33743 			})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pRef)).FxCellSize})).f(tls, pRef, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FapCell + uintptr(idx)*4)))
  33744 		} else {
  33745 		}
  33746 		idx++
  33747 		N--
  33748 	}
  33749 }
  33750 
  33751 func computeCellSize(tls *libc.TLS, p uintptr, N int32) U16 {
  33752 	*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) = (*struct {
  33753 		f func(*libc.TLS, uintptr, uintptr) U16
  33754 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FpRef)).FxCellSize})).f(tls, (*CellArray)(unsafe.Pointer(p)).FpRef, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FapCell + uintptr(N)*4)))
  33755 	return *(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2))
  33756 }
  33757 
  33758 func cachedCellSize(tls *libc.TLS, p uintptr, N int32) U16 {
  33759 	if *(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) != 0 {
  33760 		return *(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2))
  33761 	}
  33762 	return computeCellSize(tls, p, N)
  33763 }
  33764 
  33765 func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg uintptr) int32 {
  33766 	var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset)
  33767 	var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData
  33768 	var usableSize int32 = int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize)
  33769 	var pEnd uintptr = aData + uintptr(usableSize)
  33770 	var i int32 = iFirst
  33771 	var j U32
  33772 	var iEnd int32 = i + nCell
  33773 	var pCellptr uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx
  33774 	var pTmp uintptr = Xsqlite3PagerTempSpace(tls, (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FpPager)
  33775 	var pData uintptr
  33776 	var k int32
  33777 	var pSrcEnd uintptr
  33778 
  33779 	j = U32(int32(*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5))))<<8 | int32(*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5) + 1))))
  33780 	if j > U32(usableSize) {
  33781 		j = U32(0)
  33782 	}
  33783 	libc.Xmemcpy(tls, pTmp+uintptr(j), aData+uintptr(j), U32(usableSize)-j)
  33784 
  33785 	for k = 0; *(*int32)(unsafe.Pointer(pCArray + 40 + uintptr(k)*4)) <= i && k < NB*2; k++ {
  33786 	}
  33787 	pSrcEnd = *(*uintptr)(unsafe.Pointer(pCArray + 16 + uintptr(k)*4))
  33788 
  33789 	pData = pEnd
  33790 	for 1 != 0 {
  33791 		var pCell uintptr = *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*4))
  33792 		var sz U16 = *(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2))
  33793 
  33794 		if Uptr(pCell) >= Uptr(aData+uintptr(j)) && Uptr(pCell) < Uptr(pEnd) {
  33795 			if Uptr(pCell+uintptr(sz)) > Uptr(pEnd) {
  33796 				return Xsqlite3CorruptError(tls, 75741)
  33797 			}
  33798 			pCell = pTmp + uintptr((int32(pCell)-int32(aData))/1)
  33799 		} else if Uptr(pCell+uintptr(sz)) > Uptr(pSrcEnd) &&
  33800 			Uptr(pCell) < Uptr(pSrcEnd) {
  33801 			return Xsqlite3CorruptError(tls, 75746)
  33802 		}
  33803 
  33804 		pData -= uintptr(sz)
  33805 		*(*U8)(unsafe.Pointer(pCellptr)) = U8((int32(pData) - int32(aData)) / 1 >> 8)
  33806 		*(*U8)(unsafe.Pointer(pCellptr + 1)) = U8((int32(pData) - int32(aData)) / 1)
  33807 		pCellptr += uintptr(2)
  33808 		if pData < pCellptr {
  33809 			return Xsqlite3CorruptError(tls, 75752)
  33810 		}
  33811 		libc.Xmemmove(tls, pData, pCell, uint32(sz))
  33812 
  33813 		i++
  33814 		if i >= iEnd {
  33815 			break
  33816 		}
  33817 		if *(*int32)(unsafe.Pointer(pCArray + 40 + uintptr(k)*4)) <= i {
  33818 			k++
  33819 			pSrcEnd = *(*uintptr)(unsafe.Pointer(pCArray + 16 + uintptr(k)*4))
  33820 		}
  33821 	}
  33822 
  33823 	(*MemPage)(unsafe.Pointer(pPg)).FnCell = U16(nCell)
  33824 	(*MemPage)(unsafe.Pointer(pPg)).FnOverflow = U8(0)
  33825 
  33826 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+1))) = U8(int32(0) >> 8)
  33827 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+1) + 1)) = U8(0)
  33828 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+3))) = U8(int32((*MemPage)(unsafe.Pointer(pPg)).FnCell) >> 8)
  33829 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+3) + 1)) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell)
  33830 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5))) = U8((int32(pData) - int32(aData)) / 1 >> 8)
  33831 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5) + 1)) = U8((int32(pData) - int32(aData)) / 1)
  33832 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+7))) = U8(0x00)
  33833 	return SQLITE_OK
  33834 }
  33835 
  33836 func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, pCellptr uintptr, iFirst int32, nCell int32, pCArray uintptr) int32 {
  33837 	bp := tls.Alloc(4)
  33838 	defer tls.Free(4)
  33839 
  33840 	var i int32 = iFirst
  33841 	var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData
  33842 	var pData uintptr = *(*uintptr)(unsafe.Pointer(ppData))
  33843 	var iEnd int32 = iFirst + nCell
  33844 	var k int32
  33845 	var pEnd uintptr
  33846 
  33847 	if iEnd <= iFirst {
  33848 		return 0
  33849 	}
  33850 	for k = 0; *(*int32)(unsafe.Pointer(pCArray + 40 + uintptr(k)*4)) <= i && k < NB*2; k++ {
  33851 	}
  33852 	pEnd = *(*uintptr)(unsafe.Pointer(pCArray + 16 + uintptr(k)*4))
  33853 	for 1 != 0 {
  33854 		var sz int32
  33855 
  33856 		var pSlot uintptr
  33857 
  33858 		sz = int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2)))
  33859 		if int32(*(*U8)(unsafe.Pointer(aData + 1))) == 0 && int32(*(*U8)(unsafe.Pointer(aData + 2))) == 0 || libc.AssignUintptr(&pSlot, pageFindSlot(tls, pPg, sz, bp)) == uintptr(0) {
  33860 			if (int32(pData)-int32(pBegin))/1 < sz {
  33861 				return 1
  33862 			}
  33863 			pData -= uintptr(sz)
  33864 			pSlot = pData
  33865 		}
  33866 
  33867 		if Uptr(*(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*4))+uintptr(sz)) > Uptr(pEnd) &&
  33868 			Uptr(*(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*4))) < Uptr(pEnd) {
  33869 			Xsqlite3CorruptError(tls, 75837)
  33870 			return 1
  33871 		}
  33872 		libc.Xmemmove(tls, pSlot, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*4)), uint32(sz))
  33873 		*(*U8)(unsafe.Pointer(pCellptr)) = U8((int32(pSlot) - int32(aData)) / 1 >> 8)
  33874 		*(*U8)(unsafe.Pointer(pCellptr + 1)) = U8((int32(pSlot) - int32(aData)) / 1)
  33875 		pCellptr += uintptr(2)
  33876 		i++
  33877 		if i >= iEnd {
  33878 			break
  33879 		}
  33880 		if *(*int32)(unsafe.Pointer(pCArray + 40 + uintptr(k)*4)) <= i {
  33881 			k++
  33882 			pEnd = *(*uintptr)(unsafe.Pointer(pCArray + 16 + uintptr(k)*4))
  33883 		}
  33884 	}
  33885 	*(*uintptr)(unsafe.Pointer(ppData)) = pData
  33886 	return 0
  33887 }
  33888 
  33889 func pageFreeArray(tls *libc.TLS, pPg uintptr, iFirst int32, nCell int32, pCArray uintptr) int32 {
  33890 	var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData
  33891 	var pEnd uintptr = aData + uintptr((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize)
  33892 	var pStart uintptr = aData + uintptr(int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset)+8+int32((*MemPage)(unsafe.Pointer(pPg)).FchildPtrSize))
  33893 	var nRet int32 = 0
  33894 	var i int32
  33895 	var iEnd int32 = iFirst + nCell
  33896 	var pFree uintptr = uintptr(0)
  33897 	var szFree int32 = 0
  33898 
  33899 	for i = iFirst; i < iEnd; i++ {
  33900 		var pCell uintptr = *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*4))
  33901 		if Uptr(pCell) >= Uptr(pStart) && Uptr(pCell) < Uptr(pEnd) {
  33902 			var sz int32
  33903 
  33904 			sz = int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2)))
  33905 			if pFree != pCell+uintptr(sz) {
  33906 				if pFree != 0 {
  33907 					freeSpace(tls, pPg, U16((int32(pFree)-int32(aData))/1), uint16(szFree))
  33908 				}
  33909 				pFree = pCell
  33910 				szFree = sz
  33911 				if pFree+uintptr(sz) > pEnd {
  33912 					return 0
  33913 				}
  33914 			} else {
  33915 				pFree = pCell
  33916 				szFree = szFree + sz
  33917 			}
  33918 			nRet++
  33919 		}
  33920 	}
  33921 	if pFree != 0 {
  33922 		freeSpace(tls, pPg, U16((int32(pFree)-int32(aData))/1), uint16(szFree))
  33923 	}
  33924 	return nRet
  33925 }
  33926 
  33927 func editPage(tls *libc.TLS, pPg uintptr, iOld int32, iNew int32, nNew int32, pCArray uintptr) int32 {
  33928 	bp := tls.Alloc(4)
  33929 	defer tls.Free(4)
  33930 
  33931 	var aData uintptr
  33932 	var hdr int32
  33933 	var pBegin uintptr
  33934 	var nCell int32
  33935 
  33936 	var pCellptr uintptr
  33937 	var i int32
  33938 	var iOldEnd int32
  33939 	var iNewEnd int32
  33940 	var nShift int32
  33941 	var nTail int32
  33942 	var nAdd int32
  33943 	var iCell int32
  33944 	aData = (*MemPage)(unsafe.Pointer(pPg)).FaData
  33945 	hdr = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset)
  33946 	pBegin = (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(nNew*2)
  33947 	nCell = int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)
  33948 	iOldEnd = iOld + int32((*MemPage)(unsafe.Pointer(pPg)).FnCell) + int32((*MemPage)(unsafe.Pointer(pPg)).FnOverflow)
  33949 	iNewEnd = iNew + nNew
  33950 
  33951 	if !(iOld < iNew) {
  33952 		goto __1
  33953 	}
  33954 	nShift = pageFreeArray(tls, pPg, iOld, iNew-iOld, pCArray)
  33955 	if !(nShift > nCell) {
  33956 		goto __2
  33957 	}
  33958 	return Xsqlite3CorruptError(tls, 75951)
  33959 __2:
  33960 	;
  33961 	libc.Xmemmove(tls, (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx, (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx+uintptr(nShift*2), uint32(nCell*2))
  33962 	nCell = nCell - nShift
  33963 __1:
  33964 	;
  33965 	if !(iNewEnd < iOldEnd) {
  33966 		goto __3
  33967 	}
  33968 	nTail = pageFreeArray(tls, pPg, iNewEnd, iOldEnd-iNewEnd, pCArray)
  33969 
  33970 	nCell = nCell - nTail
  33971 __3:
  33972 	;
  33973 	*(*uintptr)(unsafe.Pointer(bp)) = aData + uintptr((int32(*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5))))<<8|int32(*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5) + 1)))-1)&0xffff+1)
  33974 	if !(*(*uintptr)(unsafe.Pointer(bp)) < pBegin) {
  33975 		goto __4
  33976 	}
  33977 	goto editpage_fail
  33978 __4:
  33979 	;
  33980 	if !(*(*uintptr)(unsafe.Pointer(bp)) > (*MemPage)(unsafe.Pointer(pPg)).FaDataEnd) {
  33981 		goto __5
  33982 	}
  33983 	goto editpage_fail
  33984 __5:
  33985 	;
  33986 	if !(iNew < iOld) {
  33987 		goto __6
  33988 	}
  33989 	nAdd = func() int32 {
  33990 		if nNew < iOld-iNew {
  33991 			return nNew
  33992 		}
  33993 		return iOld - iNew
  33994 	}()
  33995 
  33996 	pCellptr = (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx
  33997 	libc.Xmemmove(tls, pCellptr+uintptr(nAdd*2), pCellptr, uint32(nCell*2))
  33998 	if !(pageInsertArray(tls,
  33999 		pPg, pBegin, bp, pCellptr,
  34000 		iNew, nAdd, pCArray) != 0) {
  34001 		goto __7
  34002 	}
  34003 	goto editpage_fail
  34004 __7:
  34005 	;
  34006 	nCell = nCell + nAdd
  34007 __6:
  34008 	;
  34009 	i = 0
  34010 __8:
  34011 	if !(i < int32((*MemPage)(unsafe.Pointer(pPg)).FnOverflow)) {
  34012 		goto __10
  34013 	}
  34014 	iCell = iOld + int32(*(*U16)(unsafe.Pointer(pPg + 28 + uintptr(i)*2))) - iNew
  34015 	if !(iCell >= 0 && iCell < nNew) {
  34016 		goto __11
  34017 	}
  34018 	pCellptr = (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(iCell*2)
  34019 	if !(nCell > iCell) {
  34020 		goto __12
  34021 	}
  34022 	libc.Xmemmove(tls, pCellptr+2, pCellptr, uint32((nCell-iCell)*2))
  34023 __12:
  34024 	;
  34025 	nCell++
  34026 	cachedCellSize(tls, pCArray, iCell+iNew)
  34027 	if !(pageInsertArray(tls,
  34028 		pPg, pBegin, bp, pCellptr,
  34029 		iCell+iNew, 1, pCArray) != 0) {
  34030 		goto __13
  34031 	}
  34032 	goto editpage_fail
  34033 __13:
  34034 	;
  34035 __11:
  34036 	;
  34037 	goto __9
  34038 __9:
  34039 	i++
  34040 	goto __8
  34041 	goto __10
  34042 __10:
  34043 	;
  34044 	pCellptr = (*MemPage)(unsafe.Pointer(pPg)).FaCellIdx + uintptr(nCell*2)
  34045 	if !(pageInsertArray(tls,
  34046 		pPg, pBegin, bp, pCellptr,
  34047 		iNew+nCell, nNew-nCell, pCArray) != 0) {
  34048 		goto __14
  34049 	}
  34050 	goto editpage_fail
  34051 __14:
  34052 	;
  34053 	(*MemPage)(unsafe.Pointer(pPg)).FnCell = U16(nNew)
  34054 	(*MemPage)(unsafe.Pointer(pPg)).FnOverflow = U8(0)
  34055 
  34056 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+3))) = U8(int32((*MemPage)(unsafe.Pointer(pPg)).FnCell) >> 8)
  34057 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+3) + 1)) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell)
  34058 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5))) = U8((int32(*(*uintptr)(unsafe.Pointer(bp))) - int32(aData)) / 1 >> 8)
  34059 	*(*U8)(unsafe.Pointer(aData + uintptr(hdr+5) + 1)) = U8((int32(*(*uintptr)(unsafe.Pointer(bp))) - int32(aData)) / 1)
  34060 
  34061 	return SQLITE_OK
  34062 editpage_fail:
  34063 	populateCellCache(tls, pCArray, iNew, nNew)
  34064 	return rebuildPage(tls, pCArray, iNew, nNew, pPg)
  34065 }
  34066 
  34067 func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr) int32 {
  34068 	bp := tls.Alloc(84)
  34069 	defer tls.Free(84)
  34070 
  34071 	var pBt uintptr = (*MemPage)(unsafe.Pointer(pPage)).FpBt
  34072 
  34073 	if int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) == 0 {
  34074 		return Xsqlite3CorruptError(tls, 76064)
  34075 	}
  34076 
  34077 	*(*int32)(unsafe.Pointer(bp + 80)) = allocateBtreePage(tls, pBt, bp, bp+4, uint32(0), uint8(0))
  34078 
  34079 	if *(*int32)(unsafe.Pointer(bp + 80)) == SQLITE_OK {
  34080 		var pOut uintptr = pSpace + 4
  34081 		*(*uintptr)(unsafe.Pointer(bp + 8)) = *(*uintptr)(unsafe.Pointer(pPage + 36))
  34082 		*(*U16)(unsafe.Pointer(bp + 12)) = (*struct {
  34083 			f func(*libc.TLS, uintptr, uintptr) U16
  34084 		})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxCellSize})).f(tls, pPage, *(*uintptr)(unsafe.Pointer(bp + 8)))
  34085 		var pStop uintptr
  34086 
  34087 		zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp)), PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF)
  34088 		(*CellArray)(unsafe.Pointer(bp + 16)).FnCell = 1
  34089 		(*CellArray)(unsafe.Pointer(bp + 16)).FpRef = pPage
  34090 		(*CellArray)(unsafe.Pointer(bp + 16)).FapCell = bp + 8
  34091 		(*CellArray)(unsafe.Pointer(bp + 16)).FszCell = bp + 12
  34092 		*(*uintptr)(unsafe.Pointer(bp + 16 + 16)) = (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd
  34093 		*(*int32)(unsafe.Pointer(bp + 16 + 40)) = 2
  34094 		*(*int32)(unsafe.Pointer(bp + 80)) = rebuildPage(tls, bp+16, 0, 1, *(*uintptr)(unsafe.Pointer(bp)))
  34095 		if *(*int32)(unsafe.Pointer(bp + 80)) != 0 {
  34096 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  34097 			return *(*int32)(unsafe.Pointer(bp + 80))
  34098 		}
  34099 		(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnFree = int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FcellOffset) - U32(2) - U32(*(*U16)(unsafe.Pointer(bp + 12))))
  34100 
  34101 		if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  34102 			ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4)), uint8(PTRMAP_BTREE), (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+80)
  34103 			if int32(*(*U16)(unsafe.Pointer(bp + 12))) > int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FminLocal) {
  34104 				ptrmapPutOvflPtr(tls, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 8)), bp+80)
  34105 			}
  34106 		}
  34107 
  34108 		*(*uintptr)(unsafe.Pointer(bp + 8)) = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)-1)))))))
  34109 		pStop = *(*uintptr)(unsafe.Pointer(bp + 8)) + 9
  34110 		for int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 8)), 1))))&0x80 != 0 && *(*uintptr)(unsafe.Pointer(bp + 8)) < pStop {
  34111 		}
  34112 		pStop = *(*uintptr)(unsafe.Pointer(bp + 8)) + 9
  34113 		for int32(libc.AssignPtrUint8(libc.PostIncUintptr(&pOut, 1), *(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 8)), 1)))))&0x80 != 0 && *(*uintptr)(unsafe.Pointer(bp + 8)) < pStop {
  34114 		}
  34115 
  34116 		if *(*int32)(unsafe.Pointer(bp + 80)) == SQLITE_OK {
  34117 			*(*int32)(unsafe.Pointer(bp + 80)) = insertCell(tls, pParent, int32((*MemPage)(unsafe.Pointer(pParent)).FnCell), pSpace, (int32(pOut)-int32(pSpace))/1,
  34118 				uintptr(0), (*MemPage)(unsafe.Pointer(pPage)).Fpgno)
  34119 		}
  34120 
  34121 		Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pParent)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset)+8), *(*Pgno)(unsafe.Pointer(bp + 4)))
  34122 
  34123 		releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  34124 	}
  34125 
  34126 	return *(*int32)(unsafe.Pointer(bp + 80))
  34127 }
  34128 
  34129 func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) {
  34130 	if *(*int32)(unsafe.Pointer(pRC)) == SQLITE_OK {
  34131 		var pBt uintptr = (*MemPage)(unsafe.Pointer(pFrom)).FpBt
  34132 		var aFrom uintptr = (*MemPage)(unsafe.Pointer(pFrom)).FaData
  34133 		var aTo uintptr = (*MemPage)(unsafe.Pointer(pTo)).FaData
  34134 		var iFromHdr int32 = int32((*MemPage)(unsafe.Pointer(pFrom)).FhdrOffset)
  34135 		var iToHdr int32 = func() int32 {
  34136 			if (*MemPage)(unsafe.Pointer(pTo)).Fpgno == Pgno(1) {
  34137 				return 100
  34138 			}
  34139 			return 0
  34140 		}()
  34141 		var rc int32
  34142 		var iData int32
  34143 
  34144 		iData = int32(*(*U8)(unsafe.Pointer(aFrom + uintptr(iFromHdr+5))))<<8 | int32(*(*U8)(unsafe.Pointer(aFrom + uintptr(iFromHdr+5) + 1)))
  34145 		libc.Xmemcpy(tls, aTo+uintptr(iData), aFrom+uintptr(iData), (*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32(iData))
  34146 		libc.Xmemcpy(tls, aTo+uintptr(iToHdr), aFrom+uintptr(iFromHdr), uint32(int32((*MemPage)(unsafe.Pointer(pFrom)).FcellOffset)+2*int32((*MemPage)(unsafe.Pointer(pFrom)).FnCell)))
  34147 
  34148 		(*MemPage)(unsafe.Pointer(pTo)).FisInit = U8(0)
  34149 		rc = btreeInitPage(tls, pTo)
  34150 		if rc == SQLITE_OK {
  34151 			rc = btreeComputeFreeSpace(tls, pTo)
  34152 		}
  34153 		if rc != SQLITE_OK {
  34154 			*(*int32)(unsafe.Pointer(pRC)) = rc
  34155 			return
  34156 		}
  34157 
  34158 		if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  34159 			*(*int32)(unsafe.Pointer(pRC)) = setChildPtrmaps(tls, pTo)
  34160 		}
  34161 	}
  34162 }
  34163 
  34164 func balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpace uintptr, isRoot int32, bBulk int32) int32 {
  34165 	bp := tls.Alloc(232)
  34166 	defer tls.Free(232)
  34167 
  34168 	var pBt uintptr
  34169 	var nMaxCells int32
  34170 	var nNew int32
  34171 	var nOld int32
  34172 	var i int32
  34173 	var j int32
  34174 	var k int32
  34175 	var nxDiv int32
  34176 
  34177 	var leafCorrection U16
  34178 	var leafData int32
  34179 	var usableSpace int32
  34180 	var pageFlags int32
  34181 	var iSpace1 int32
  34182 	var iOvflSpace int32
  34183 	var szScratch int32
  34184 
  34185 	var pRight uintptr
  34186 
  34187 	var aSpace1 uintptr
  34188 
  34189 	var iOff int32
  34190 	var sz U16
  34191 	var pTemp uintptr
  34192 	var pOld uintptr
  34193 	var limit int32
  34194 	var aData uintptr
  34195 	var maskPage U16
  34196 	var piCell uintptr
  34197 	var piEnd uintptr
  34198 	var p uintptr
  34199 	var sz1 int32
  34200 	var szR int32
  34201 	var szD int32
  34202 	var szRight int32
  34203 	var szLeft int32
  34204 	var r int32
  34205 	var d int32
  34206 
  34207 	var pgnoA Pgno
  34208 	var pgnoB Pgno
  34209 	var pgnoTemp Pgno
  34210 	var fgA U16
  34211 	var fgB U16
  34212 	var iB int32
  34213 	var pOld1 uintptr
  34214 	var pCell uintptr
  34215 	var pOld2 uintptr
  34216 	var pNew1 uintptr
  34217 	var cntOldNext int32
  34218 	var iNew int32
  34219 	var iOld int32
  34220 
  34221 	var pCell1 uintptr
  34222 	var pTemp1 uintptr
  34223 	var sz2 int32
  34224 	var pSrcEnd uintptr
  34225 	var pNew2 uintptr
  34226 	var iNew1 int32
  34227 	var iOld1 int32
  34228 	var nNewCell int32
  34229 	var iPg int32
  34230 	var key U32
  34231 	nMaxCells = 0
  34232 	nNew = 0
  34233 	*(*int32)(unsafe.Pointer(bp + 112)) = SQLITE_OK
  34234 	iSpace1 = 0
  34235 	iOvflSpace = 0
  34236 
  34237 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([5]U8{})))
  34238 	libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(CellArray{})))
  34239 	pBt = (*MemPage)(unsafe.Pointer(pParent)).FpBt
  34240 
  34241 	if !!(aOvflSpace != 0) {
  34242 		goto __1
  34243 	}
  34244 	return SQLITE_NOMEM
  34245 __1:
  34246 	;
  34247 	i = int32((*MemPage)(unsafe.Pointer(pParent)).FnOverflow) + int32((*MemPage)(unsafe.Pointer(pParent)).FnCell)
  34248 	if !(i < 2) {
  34249 		goto __2
  34250 	}
  34251 	nxDiv = 0
  34252 	goto __3
  34253 __2:
  34254 	;
  34255 	if !(iParentIdx == 0) {
  34256 		goto __4
  34257 	}
  34258 	nxDiv = 0
  34259 	goto __5
  34260 __4:
  34261 	if !(iParentIdx == i) {
  34262 		goto __6
  34263 	}
  34264 	nxDiv = i - 2 + bBulk
  34265 	goto __7
  34266 __6:
  34267 	nxDiv = iParentIdx - 1
  34268 __7:
  34269 	;
  34270 __5:
  34271 	;
  34272 	i = 2 - bBulk
  34273 __3:
  34274 	;
  34275 	nOld = i + 1
  34276 	if !(i+nxDiv-int32((*MemPage)(unsafe.Pointer(pParent)).FnOverflow) == int32((*MemPage)(unsafe.Pointer(pParent)).FnCell)) {
  34277 		goto __8
  34278 	}
  34279 	pRight = (*MemPage)(unsafe.Pointer(pParent)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset)+8)
  34280 	goto __9
  34281 __8:
  34282 	pRight = (*MemPage)(unsafe.Pointer(pParent)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pParent)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pParent)).FaCellIdx + uintptr(2*(i+nxDiv-int32((*MemPage)(unsafe.Pointer(pParent)).FnOverflow))))))))
  34283 __9:
  34284 	;
  34285 	*(*Pgno)(unsafe.Pointer(bp + 180)) = Xsqlite3Get4byte(tls, pRight)
  34286 __10:
  34287 	if !(1 != 0) {
  34288 		goto __11
  34289 	}
  34290 	if !(*(*int32)(unsafe.Pointer(bp + 112)) == SQLITE_OK) {
  34291 		goto __12
  34292 	}
  34293 	*(*int32)(unsafe.Pointer(bp + 112)) = getAndInitPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 180)), bp+72+uintptr(i)*4, uintptr(0), 0)
  34294 __12:
  34295 	;
  34296 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != 0) {
  34297 		goto __13
  34298 	}
  34299 	libc.Xmemset(tls, bp+72, 0, uint32(i+1)*uint32(unsafe.Sizeof(uintptr(0))))
  34300 	goto balance_cleanup
  34301 __13:
  34302 	;
  34303 	if !((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)))).FnFree < 0) {
  34304 		goto __14
  34305 	}
  34306 	*(*int32)(unsafe.Pointer(bp + 112)) = btreeComputeFreeSpace(tls, *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)))
  34307 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != 0) {
  34308 		goto __15
  34309 	}
  34310 	libc.Xmemset(tls, bp+72, 0, uint32(i)*uint32(unsafe.Sizeof(uintptr(0))))
  34311 	goto balance_cleanup
  34312 __15:
  34313 	;
  34314 __14:
  34315 	;
  34316 	nMaxCells = nMaxCells + (int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)))).FnCell) + int32(uint32(unsafe.Sizeof([4]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))))
  34317 	if !(libc.PostDecInt32(&i, 1) == 0) {
  34318 		goto __16
  34319 	}
  34320 	goto __11
  34321 __16:
  34322 	;
  34323 	if !((*MemPage)(unsafe.Pointer(pParent)).FnOverflow != 0 && i+nxDiv == int32(*(*U16)(unsafe.Pointer(pParent + 28)))) {
  34324 		goto __17
  34325 	}
  34326 	*(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer(pParent + 36))
  34327 	*(*Pgno)(unsafe.Pointer(bp + 180)) = Xsqlite3Get4byte(tls, *(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)))
  34328 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) = int32((*struct {
  34329 		f func(*libc.TLS, uintptr, uintptr) U16
  34330 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pParent)).FxCellSize})).f(tls, pParent, *(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4))))
  34331 	(*MemPage)(unsafe.Pointer(pParent)).FnOverflow = U8(0)
  34332 	goto __18
  34333 __17:
  34334 	*(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)) = (*MemPage)(unsafe.Pointer(pParent)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pParent)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pParent)).FaCellIdx + uintptr(2*(i+nxDiv-int32((*MemPage)(unsafe.Pointer(pParent)).FnOverflow))))))))
  34335 	*(*Pgno)(unsafe.Pointer(bp + 180)) = Xsqlite3Get4byte(tls, *(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)))
  34336 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) = int32((*struct {
  34337 		f func(*libc.TLS, uintptr, uintptr) U16
  34338 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pParent)).FxCellSize})).f(tls, pParent, *(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4))))
  34339 
  34340 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags)&BTS_FAST_SECURE != 0) {
  34341 		goto __19
  34342 	}
  34343 
  34344 	iOff = int32(*(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4))) - int32((*MemPage)(unsafe.Pointer(pParent)).FaData)
  34345 	if !(iOff+*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) <= int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize)) {
  34346 		goto __20
  34347 	}
  34348 	libc.Xmemcpy(tls, aOvflSpace+uintptr(iOff), *(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)), uint32(*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4))))
  34349 	*(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)) = aOvflSpace + uintptr((int32(*(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)))-int32((*MemPage)(unsafe.Pointer(pParent)).FaData))/1)
  34350 __20:
  34351 	;
  34352 __19:
  34353 	;
  34354 	dropCell(tls, pParent, i+nxDiv-int32((*MemPage)(unsafe.Pointer(pParent)).FnOverflow), *(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)), bp+112)
  34355 __18:
  34356 	;
  34357 	goto __10
  34358 __11:
  34359 	;
  34360 	nMaxCells = (nMaxCells + 3) & libc.CplInt32(3)
  34361 
  34362 	szScratch = int32(uint32(nMaxCells)*uint32(unsafe.Sizeof(uintptr(0))) +
  34363 		uint32(nMaxCells)*uint32(unsafe.Sizeof(U16(0))) +
  34364 		(*BtShared)(unsafe.Pointer(pBt)).FpageSize)
  34365 
  34366 	(*CellArray)(unsafe.Pointer(bp + 8)).FapCell = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(szScratch))
  34367 	if !((*CellArray)(unsafe.Pointer(bp+8)).FapCell == uintptr(0)) {
  34368 		goto __21
  34369 	}
  34370 	*(*int32)(unsafe.Pointer(bp + 112)) = SQLITE_NOMEM
  34371 	goto balance_cleanup
  34372 __21:
  34373 	;
  34374 	(*CellArray)(unsafe.Pointer(bp + 8)).FszCell = (*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr(nMaxCells)*4
  34375 	aSpace1 = (*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr(nMaxCells)*2
  34376 
  34377 	(*CellArray)(unsafe.Pointer(bp + 8)).FpRef = *(*uintptr)(unsafe.Pointer(bp + 72))
  34378 	leafCorrection = U16(int32((*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FpRef)).Fleaf) * 4)
  34379 	leafData = int32((*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp + 8)).FpRef)).FintKeyLeaf)
  34380 	i = 0
  34381 __22:
  34382 	if !(i < nOld) {
  34383 		goto __24
  34384 	}
  34385 	pOld = *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4))
  34386 	limit = int32((*MemPage)(unsafe.Pointer(pOld)).FnCell)
  34387 	aData = (*MemPage)(unsafe.Pointer(pOld)).FaData
  34388 	maskPage = (*MemPage)(unsafe.Pointer(pOld)).FmaskPage
  34389 	piCell = aData + uintptr((*MemPage)(unsafe.Pointer(pOld)).FcellOffset)
  34390 
  34391 	if !(int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pOld)).FaData))) != int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72)))).FaData)))) {
  34392 		goto __25
  34393 	}
  34394 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76485)
  34395 	goto balance_cleanup
  34396 __25:
  34397 	;
  34398 	libc.Xmemset(tls, (*CellArray)(unsafe.Pointer(bp+8)).FszCell+uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*2, 0, uint32(unsafe.Sizeof(U16(0)))*uint32(limit+int32((*MemPage)(unsafe.Pointer(pOld)).FnOverflow)))
  34399 	if !(int32((*MemPage)(unsafe.Pointer(pOld)).FnOverflow) > 0) {
  34400 		goto __26
  34401 	}
  34402 	if !(limit < int32(*(*U16)(unsafe.Pointer(pOld + 28)))) {
  34403 		goto __27
  34404 	}
  34405 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76509)
  34406 	goto balance_cleanup
  34407 __27:
  34408 	;
  34409 	limit = int32(*(*U16)(unsafe.Pointer(pOld + 28)))
  34410 	j = 0
  34411 __28:
  34412 	if !(j < limit) {
  34413 		goto __30
  34414 	}
  34415 	*(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*4)) = aData + uintptr(int32(maskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(piCell)))))
  34416 	piCell += uintptr(2)
  34417 	(*CellArray)(unsafe.Pointer(bp+8)).FnCell++
  34418 	goto __29
  34419 __29:
  34420 	j++
  34421 	goto __28
  34422 	goto __30
  34423 __30:
  34424 	;
  34425 	k = 0
  34426 __31:
  34427 	if !(k < int32((*MemPage)(unsafe.Pointer(pOld)).FnOverflow)) {
  34428 		goto __33
  34429 	}
  34430 
  34431 	*(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*4)) = *(*uintptr)(unsafe.Pointer(pOld + 36 + uintptr(k)*4))
  34432 	(*CellArray)(unsafe.Pointer(bp+8)).FnCell++
  34433 	goto __32
  34434 __32:
  34435 	k++
  34436 	goto __31
  34437 	goto __33
  34438 __33:
  34439 	;
  34440 __26:
  34441 	;
  34442 	piEnd = aData + uintptr((*MemPage)(unsafe.Pointer(pOld)).FcellOffset) + uintptr(2*int32((*MemPage)(unsafe.Pointer(pOld)).FnCell))
  34443 __34:
  34444 	if !(piCell < piEnd) {
  34445 		goto __35
  34446 	}
  34447 
  34448 	*(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*4)) = aData + uintptr(int32(maskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(piCell)))))
  34449 	piCell += uintptr(2)
  34450 	(*CellArray)(unsafe.Pointer(bp+8)).FnCell++
  34451 	goto __34
  34452 __35:
  34453 	;
  34454 	*(*int32)(unsafe.Pointer(bp + 116 + uintptr(i)*4)) = (*CellArray)(unsafe.Pointer(bp + 8)).FnCell
  34455 	if !(i < nOld-1 && !(leafData != 0)) {
  34456 		goto __36
  34457 	}
  34458 	sz = U16(*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)))
  34459 
  34460 	*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*2)) = sz
  34461 	pTemp = aSpace1 + uintptr(iSpace1)
  34462 	iSpace1 = iSpace1 + int32(sz)
  34463 
  34464 	libc.Xmemcpy(tls, pTemp, *(*uintptr)(unsafe.Pointer(bp + 84 + uintptr(i)*4)), uint32(sz))
  34465 	*(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*4)) = pTemp + uintptr(leafCorrection)
  34466 
  34467 	*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*2)) = U16(int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*2))) - int32(leafCorrection))
  34468 	if !!(int32((*MemPage)(unsafe.Pointer(pOld)).Fleaf) != 0) {
  34469 		goto __37
  34470 	}
  34471 
  34472 	libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*4)), (*MemPage)(unsafe.Pointer(pOld)).FaData+8, uint32(4))
  34473 	goto __38
  34474 __37:
  34475 	;
  34476 __39:
  34477 	if !(int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*2))) < 4) {
  34478 		goto __40
  34479 	}
  34480 
  34481 	*(*U8)(unsafe.Pointer(aSpace1 + uintptr(libc.PostIncInt32(&iSpace1, 1)))) = U8(0x00)
  34482 	*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr((*CellArray)(unsafe.Pointer(bp+8)).FnCell)*2))++
  34483 	goto __39
  34484 __40:
  34485 	;
  34486 __38:
  34487 	;
  34488 	(*CellArray)(unsafe.Pointer(bp+8)).FnCell++
  34489 __36:
  34490 	;
  34491 	goto __23
  34492 __23:
  34493 	i++
  34494 	goto __22
  34495 	goto __24
  34496 __24:
  34497 	;
  34498 	usableSpace = int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(12) + U32(leafCorrection))
  34499 	i = libc.AssignInt32(&k, 0)
  34500 __41:
  34501 	if !(i < nOld) {
  34502 		goto __43
  34503 	}
  34504 	p = *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4))
  34505 	*(*uintptr)(unsafe.Pointer(bp + 8 + 16 + uintptr(k)*4)) = (*MemPage)(unsafe.Pointer(p)).FaDataEnd
  34506 	*(*int32)(unsafe.Pointer(bp + 8 + 40 + uintptr(k)*4)) = *(*int32)(unsafe.Pointer(bp + 116 + uintptr(i)*4))
  34507 	if !(k != 0 && *(*int32)(unsafe.Pointer(bp + 8 + 40 + uintptr(k)*4)) == *(*int32)(unsafe.Pointer(bp + 8 + 40 + uintptr(k-1)*4))) {
  34508 		goto __44
  34509 	}
  34510 	k--
  34511 __44:
  34512 	;
  34513 	if !!(leafData != 0) {
  34514 		goto __45
  34515 	}
  34516 	k++
  34517 	*(*uintptr)(unsafe.Pointer(bp + 8 + 16 + uintptr(k)*4)) = (*MemPage)(unsafe.Pointer(pParent)).FaDataEnd
  34518 	*(*int32)(unsafe.Pointer(bp + 8 + 40 + uintptr(k)*4)) = *(*int32)(unsafe.Pointer(bp + 116 + uintptr(i)*4)) + 1
  34519 __45:
  34520 	;
  34521 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) = usableSpace - (*MemPage)(unsafe.Pointer(p)).FnFree
  34522 	j = 0
  34523 __46:
  34524 	if !(j < int32((*MemPage)(unsafe.Pointer(p)).FnOverflow)) {
  34525 		goto __48
  34526 	}
  34527 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) += 2 + int32((*struct {
  34528 		f func(*libc.TLS, uintptr, uintptr) U16
  34529 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(p)).FxCellSize})).f(tls, p, *(*uintptr)(unsafe.Pointer(p + 36 + uintptr(j)*4))))
  34530 	goto __47
  34531 __47:
  34532 	j++
  34533 	goto __46
  34534 	goto __48
  34535 __48:
  34536 	;
  34537 	*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4)) = *(*int32)(unsafe.Pointer(bp + 116 + uintptr(i)*4))
  34538 	goto __42
  34539 __42:
  34540 	i++
  34541 	k++
  34542 	goto __41
  34543 	goto __43
  34544 __43:
  34545 	;
  34546 	k = nOld
  34547 	i = 0
  34548 __49:
  34549 	if !(i < k) {
  34550 		goto __51
  34551 	}
  34552 __52:
  34553 	if !(*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) > usableSpace) {
  34554 		goto __53
  34555 	}
  34556 	if !(i+1 >= k) {
  34557 		goto __54
  34558 	}
  34559 	k = i + 2
  34560 	if !(k > NB+2) {
  34561 		goto __55
  34562 	}
  34563 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76610)
  34564 	goto balance_cleanup
  34565 __55:
  34566 	;
  34567 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(k-1)*4)) = 0
  34568 	*(*int32)(unsafe.Pointer(bp + 136 + uintptr(k-1)*4)) = (*CellArray)(unsafe.Pointer(bp + 8)).FnCell
  34569 __54:
  34570 	;
  34571 	sz1 = 2 + int32(cachedCellSize(tls, bp+8, *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))-1))
  34572 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) -= sz1
  34573 	if !!(leafData != 0) {
  34574 		goto __56
  34575 	}
  34576 	if !(*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4)) < (*CellArray)(unsafe.Pointer(bp+8)).FnCell) {
  34577 		goto __57
  34578 	}
  34579 	sz1 = 2 + int32(cachedCellSize(tls, bp+8, *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))))
  34580 	goto __58
  34581 __57:
  34582 	sz1 = 0
  34583 __58:
  34584 	;
  34585 __56:
  34586 	;
  34587 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i+1)*4)) += sz1
  34588 	*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))--
  34589 	goto __52
  34590 __53:
  34591 	;
  34592 __59:
  34593 	if !(*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4)) < (*CellArray)(unsafe.Pointer(bp+8)).FnCell) {
  34594 		goto __60
  34595 	}
  34596 	sz1 = 2 + int32(cachedCellSize(tls, bp+8, *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))))
  34597 	if !(*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4))+sz1 > usableSpace) {
  34598 		goto __61
  34599 	}
  34600 	goto __60
  34601 __61:
  34602 	;
  34603 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) += sz1
  34604 	*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))++
  34605 	if !!(leafData != 0) {
  34606 		goto __62
  34607 	}
  34608 	if !(*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4)) < (*CellArray)(unsafe.Pointer(bp+8)).FnCell) {
  34609 		goto __63
  34610 	}
  34611 	sz1 = 2 + int32(cachedCellSize(tls, bp+8, *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))))
  34612 	goto __64
  34613 __63:
  34614 	sz1 = 0
  34615 __64:
  34616 	;
  34617 __62:
  34618 	;
  34619 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i+1)*4)) -= sz1
  34620 	goto __59
  34621 __60:
  34622 	;
  34623 	if !(*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4)) >= (*CellArray)(unsafe.Pointer(bp+8)).FnCell) {
  34624 		goto __65
  34625 	}
  34626 	k = i + 1
  34627 	goto __66
  34628 __65:
  34629 	if !(*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4)) <= func() int32 {
  34630 		if i > 0 {
  34631 			return *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i-1)*4))
  34632 		}
  34633 		return 0
  34634 	}()) {
  34635 		goto __67
  34636 	}
  34637 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76643)
  34638 	goto balance_cleanup
  34639 __67:
  34640 	;
  34641 __66:
  34642 	;
  34643 	goto __50
  34644 __50:
  34645 	i++
  34646 	goto __49
  34647 	goto __51
  34648 __51:
  34649 	;
  34650 	i = k - 1
  34651 __68:
  34652 	if !(i > 0) {
  34653 		goto __70
  34654 	}
  34655 	szRight = *(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4))
  34656 	szLeft = *(*int32)(unsafe.Pointer(bp + 92 + uintptr(i-1)*4))
  34657 
  34658 	r = *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i-1)*4)) - 1
  34659 	d = r + 1 - leafData
  34660 	cachedCellSize(tls, bp+8, d)
  34661 __71:
  34662 	;
  34663 	szR = int32(cachedCellSize(tls, bp+8, r))
  34664 	szD = int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr(d)*2)))
  34665 	if !(szRight != 0 &&
  34666 		(bBulk != 0 || szRight+szD+2 > szLeft-(szR+func() int32 {
  34667 			if i == k-1 {
  34668 				return 0
  34669 			}
  34670 			return 2
  34671 		}()))) {
  34672 		goto __74
  34673 	}
  34674 	goto __73
  34675 __74:
  34676 	;
  34677 	szRight = szRight + (szD + 2)
  34678 	szLeft = szLeft - (szR + 2)
  34679 	*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i-1)*4)) = r
  34680 	r--
  34681 	d--
  34682 	goto __72
  34683 __72:
  34684 	if r >= 0 {
  34685 		goto __71
  34686 	}
  34687 	goto __73
  34688 __73:
  34689 	;
  34690 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i)*4)) = szRight
  34691 	*(*int32)(unsafe.Pointer(bp + 92 + uintptr(i-1)*4)) = szLeft
  34692 	if !(*(*int32)(unsafe.Pointer(bp + 136 + uintptr(i-1)*4)) <= func() int32 {
  34693 		if i > 1 {
  34694 			return *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i-2)*4))
  34695 		}
  34696 		return 0
  34697 	}()) {
  34698 		goto __75
  34699 	}
  34700 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76687)
  34701 	goto balance_cleanup
  34702 __75:
  34703 	;
  34704 	goto __69
  34705 __69:
  34706 	i--
  34707 	goto __68
  34708 	goto __70
  34709 __70:
  34710 	;
  34711 	pageFlags = int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72)))).FaData)))
  34712 	i = 0
  34713 __76:
  34714 	if !(i < k) {
  34715 		goto __78
  34716 	}
  34717 	if !(i < nOld) {
  34718 		goto __79
  34719 	}
  34720 	*(*uintptr)(unsafe.Pointer(bp + 176)) = libc.AssignPtrUintptr(bp+156+uintptr(i)*4, *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)))
  34721 	*(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)) = uintptr(0)
  34722 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 176)))).FpDbPage)
  34723 	nNew++
  34724 	if !(Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 176)))).FpDbPage) != 1+libc.Bool32(i == iParentIdx-nxDiv) &&
  34725 		*(*int32)(unsafe.Pointer(bp + 112)) == SQLITE_OK) {
  34726 		goto __81
  34727 	}
  34728 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76720)
  34729 __81:
  34730 	;
  34731 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != 0) {
  34732 		goto __82
  34733 	}
  34734 	goto balance_cleanup
  34735 __82:
  34736 	;
  34737 	goto __80
  34738 __79:
  34739 	;
  34740 	*(*int32)(unsafe.Pointer(bp + 112)) = allocateBtreePage(tls, pBt, bp+176, bp+180, func() uint32 {
  34741 		if bBulk != 0 {
  34742 			return uint32(1)
  34743 		}
  34744 		return *(*Pgno)(unsafe.Pointer(bp + 180))
  34745 	}(), uint8(0))
  34746 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != 0) {
  34747 		goto __83
  34748 	}
  34749 	goto balance_cleanup
  34750 __83:
  34751 	;
  34752 	zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp + 176)), pageFlags)
  34753 	*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer(bp + 176))
  34754 	nNew++
  34755 	*(*int32)(unsafe.Pointer(bp + 116 + uintptr(i)*4)) = (*CellArray)(unsafe.Pointer(bp + 8)).FnCell
  34756 
  34757 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  34758 		goto __84
  34759 	}
  34760 	ptrmapPut(tls, pBt, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 176)))).Fpgno, uint8(PTRMAP_BTREE), (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+112)
  34761 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != SQLITE_OK) {
  34762 		goto __85
  34763 	}
  34764 	goto balance_cleanup
  34765 __85:
  34766 	;
  34767 __84:
  34768 	;
  34769 __80:
  34770 	;
  34771 	goto __77
  34772 __77:
  34773 	i++
  34774 	goto __76
  34775 	goto __78
  34776 __78:
  34777 	;
  34778 	i = 0
  34779 __86:
  34780 	if !(i < nNew) {
  34781 		goto __88
  34782 	}
  34783 	*(*Pgno)(unsafe.Pointer(bp + 184 + uintptr(i)*4)) = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).Fpgno
  34784 
  34785 	goto __87
  34786 __87:
  34787 	i++
  34788 	goto __86
  34789 	goto __88
  34790 __88:
  34791 	;
  34792 	i = 0
  34793 __89:
  34794 	if !(i < nNew-1) {
  34795 		goto __91
  34796 	}
  34797 	iB = i
  34798 	j = i + 1
  34799 __92:
  34800 	if !(j < nNew) {
  34801 		goto __94
  34802 	}
  34803 	if !((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(j)*4)))).Fpgno < (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iB)*4)))).Fpgno) {
  34804 		goto __95
  34805 	}
  34806 	iB = j
  34807 __95:
  34808 	;
  34809 	goto __93
  34810 __93:
  34811 	j++
  34812 	goto __92
  34813 	goto __94
  34814 __94:
  34815 	;
  34816 	if !(iB != i) {
  34817 		goto __96
  34818 	}
  34819 	pgnoA = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).Fpgno
  34820 	pgnoB = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iB)*4)))).Fpgno
  34821 	pgnoTemp = U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize + U32(1)
  34822 	fgA = (*DbPage)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).FpDbPage)).Fflags
  34823 	fgB = (*DbPage)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iB)*4)))).FpDbPage)).Fflags
  34824 	Xsqlite3PagerRekey(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).FpDbPage, pgnoTemp, fgB)
  34825 	Xsqlite3PagerRekey(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iB)*4)))).FpDbPage, pgnoA, fgA)
  34826 	Xsqlite3PagerRekey(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).FpDbPage, pgnoB, fgB)
  34827 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).Fpgno = pgnoB
  34828 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iB)*4)))).Fpgno = pgnoA
  34829 __96:
  34830 	;
  34831 	goto __90
  34832 __90:
  34833 	i++
  34834 	goto __89
  34835 	goto __91
  34836 __91:
  34837 	;
  34838 	Xsqlite3Put4byte(tls, pRight, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(nNew-1)*4)))).Fpgno)
  34839 
  34840 	if !(pageFlags&PTF_LEAF == 0 && nOld != nNew) {
  34841 		goto __97
  34842 	}
  34843 	pOld1 = *(*uintptr)(unsafe.Pointer(func() uintptr {
  34844 		if nNew > nOld {
  34845 			return bp + 156
  34846 		}
  34847 		return bp + 72
  34848 	}() + uintptr(nOld-1)*4))
  34849 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(nNew-1)*4)))).FaData+8, (*MemPage)(unsafe.Pointer(pOld1)).FaData+8, uint32(4))
  34850 __97:
  34851 	;
  34852 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  34853 		goto __98
  34854 	}
  34855 	pNew1 = libc.AssignUintptr(&pOld2, *(*uintptr)(unsafe.Pointer(bp + 156)))
  34856 	cntOldNext = int32((*MemPage)(unsafe.Pointer(pNew1)).FnCell) + int32((*MemPage)(unsafe.Pointer(pNew1)).FnOverflow)
  34857 	iNew = 0
  34858 	iOld = 0
  34859 
  34860 	i = 0
  34861 __99:
  34862 	if !(i < (*CellArray)(unsafe.Pointer(bp+8)).FnCell) {
  34863 		goto __101
  34864 	}
  34865 	pCell = *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr(i)*4))
  34866 __102:
  34867 	if !(i == cntOldNext) {
  34868 		goto __103
  34869 	}
  34870 	iOld++
  34871 
  34872 	if iOld < nNew {
  34873 		pOld2 = *(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iOld)*4))
  34874 	} else {
  34875 		pOld2 = *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(iOld)*4))
  34876 	}
  34877 	cntOldNext = cntOldNext + (int32((*MemPage)(unsafe.Pointer(pOld2)).FnCell) + int32((*MemPage)(unsafe.Pointer(pOld2)).FnOverflow) + libc.BoolInt32(!(leafData != 0)))
  34878 	goto __102
  34879 __103:
  34880 	;
  34881 	if !(i == *(*int32)(unsafe.Pointer(bp + 136 + uintptr(iNew)*4))) {
  34882 		goto __104
  34883 	}
  34884 	pNew1 = *(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(libc.PreIncInt32(&iNew, 1))*4))
  34885 	if !!(leafData != 0) {
  34886 		goto __105
  34887 	}
  34888 	goto __100
  34889 __105:
  34890 	;
  34891 __104:
  34892 	;
  34893 	if !(iOld >= nNew ||
  34894 		(*MemPage)(unsafe.Pointer(pNew1)).Fpgno != *(*Pgno)(unsafe.Pointer(bp + 184 + uintptr(iOld)*4)) ||
  34895 		!(Uptr(pCell) >= Uptr((*MemPage)(unsafe.Pointer(pOld2)).FaData) && Uptr(pCell) < Uptr((*MemPage)(unsafe.Pointer(pOld2)).FaDataEnd))) {
  34896 		goto __106
  34897 	}
  34898 	if !!(leafCorrection != 0) {
  34899 		goto __107
  34900 	}
  34901 	ptrmapPut(tls, pBt, Xsqlite3Get4byte(tls, pCell), uint8(PTRMAP_BTREE), (*MemPage)(unsafe.Pointer(pNew1)).Fpgno, bp+112)
  34902 __107:
  34903 	;
  34904 	if !(int32(cachedCellSize(tls, bp+8, i)) > int32((*MemPage)(unsafe.Pointer(pNew1)).FminLocal)) {
  34905 		goto __108
  34906 	}
  34907 	ptrmapPutOvflPtr(tls, pNew1, pOld2, pCell, bp+112)
  34908 __108:
  34909 	;
  34910 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != 0) {
  34911 		goto __109
  34912 	}
  34913 	goto balance_cleanup
  34914 __109:
  34915 	;
  34916 __106:
  34917 	;
  34918 	goto __100
  34919 __100:
  34920 	i++
  34921 	goto __99
  34922 	goto __101
  34923 __101:
  34924 	;
  34925 __98:
  34926 	;
  34927 	i = 0
  34928 __110:
  34929 	if !(i < nNew-1) {
  34930 		goto __112
  34931 	}
  34932 	pNew2 = *(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4))
  34933 	j = *(*int32)(unsafe.Pointer(bp + 136 + uintptr(i)*4))
  34934 
  34935 	pCell1 = *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr(j)*4))
  34936 	sz2 = int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr(j)*2))) + int32(leafCorrection)
  34937 	pTemp1 = aOvflSpace + uintptr(iOvflSpace)
  34938 	if !!(int32((*MemPage)(unsafe.Pointer(pNew2)).Fleaf) != 0) {
  34939 		goto __113
  34940 	}
  34941 	libc.Xmemcpy(tls, (*MemPage)(unsafe.Pointer(pNew2)).FaData+8, pCell1, uint32(4))
  34942 	goto __114
  34943 __113:
  34944 	if !(leafData != 0) {
  34945 		goto __115
  34946 	}
  34947 	j--
  34948 	(*struct {
  34949 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  34950 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pNew2)).FxParseCell})).f(tls, pNew2, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FapCell + uintptr(j)*4)), bp+208)
  34951 	pCell1 = pTemp1
  34952 	sz2 = 4 + Xsqlite3PutVarint(tls, pCell1+4, uint64((*CellInfo)(unsafe.Pointer(bp+208)).FnKey))
  34953 	pTemp1 = uintptr(0)
  34954 	goto __116
  34955 __115:
  34956 	pCell1 -= uintptr(4)
  34957 
  34958 	if !(int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+8)).FszCell + uintptr(j)*2))) == 4) {
  34959 		goto __117
  34960 	}
  34961 
  34962 	sz2 = int32((*struct {
  34963 		f func(*libc.TLS, uintptr, uintptr) U16
  34964 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pParent)).FxCellSize})).f(tls, pParent, pCell1))
  34965 __117:
  34966 	;
  34967 __116:
  34968 	;
  34969 __114:
  34970 	;
  34971 	iOvflSpace = iOvflSpace + sz2
  34972 
  34973 	k = 0
  34974 __118:
  34975 	if !(*(*int32)(unsafe.Pointer(bp + 8 + 40 + uintptr(k)*4)) <= j && k < NB*2) {
  34976 		goto __120
  34977 	}
  34978 	goto __119
  34979 __119:
  34980 	k++
  34981 	goto __118
  34982 	goto __120
  34983 __120:
  34984 	;
  34985 	pSrcEnd = *(*uintptr)(unsafe.Pointer(bp + 8 + 16 + uintptr(k)*4))
  34986 	if !(Uptr(pSrcEnd) >= Uptr(pCell1) && Uptr(pSrcEnd) < Uptr(pCell1+uintptr(sz2))) {
  34987 		goto __121
  34988 	}
  34989 	*(*int32)(unsafe.Pointer(bp + 112)) = Xsqlite3CorruptError(tls, 76920)
  34990 	goto balance_cleanup
  34991 __121:
  34992 	;
  34993 	*(*int32)(unsafe.Pointer(bp + 112)) = insertCell(tls, pParent, nxDiv+i, pCell1, sz2, pTemp1, (*MemPage)(unsafe.Pointer(pNew2)).Fpgno)
  34994 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != SQLITE_OK) {
  34995 		goto __122
  34996 	}
  34997 	goto balance_cleanup
  34998 __122:
  34999 	;
  35000 	goto __111
  35001 __111:
  35002 	i++
  35003 	goto __110
  35004 	goto __112
  35005 __112:
  35006 	;
  35007 	i = 1 - nNew
  35008 __123:
  35009 	if !(i < nNew) {
  35010 		goto __125
  35011 	}
  35012 	if i < 0 {
  35013 		iPg = -i
  35014 	} else {
  35015 		iPg = i
  35016 	}
  35017 
  35018 	if !(*(*U8)(unsafe.Pointer(bp + uintptr(iPg))) != 0) {
  35019 		goto __126
  35020 	}
  35021 	goto __124
  35022 __126:
  35023 	;
  35024 	if !(i >= 0 ||
  35025 		*(*int32)(unsafe.Pointer(bp + 116 + uintptr(iPg-1)*4)) >= *(*int32)(unsafe.Pointer(bp + 136 + uintptr(iPg-1)*4))) {
  35026 		goto __127
  35027 	}
  35028 
  35029 	if !(iPg == 0) {
  35030 		goto __128
  35031 	}
  35032 	iNew1 = libc.AssignInt32(&iOld1, 0)
  35033 	nNewCell = *(*int32)(unsafe.Pointer(bp + 136))
  35034 	goto __129
  35035 __128:
  35036 	if iPg < nOld {
  35037 		iOld1 = *(*int32)(unsafe.Pointer(bp + 116 + uintptr(iPg-1)*4)) + libc.BoolInt32(!(leafData != 0))
  35038 	} else {
  35039 		iOld1 = (*CellArray)(unsafe.Pointer(bp + 8)).FnCell
  35040 	}
  35041 	iNew1 = *(*int32)(unsafe.Pointer(bp + 136 + uintptr(iPg-1)*4)) + libc.BoolInt32(!(leafData != 0))
  35042 	nNewCell = *(*int32)(unsafe.Pointer(bp + 136 + uintptr(iPg)*4)) - iNew1
  35043 __129:
  35044 	;
  35045 	*(*int32)(unsafe.Pointer(bp + 112)) = editPage(tls, *(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iPg)*4)), iOld1, iNew1, nNewCell, bp+8)
  35046 	if !(*(*int32)(unsafe.Pointer(bp + 112)) != 0) {
  35047 		goto __130
  35048 	}
  35049 	goto balance_cleanup
  35050 __130:
  35051 	;
  35052 	*(*U8)(unsafe.Pointer(bp + uintptr(iPg)))++
  35053 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(iPg)*4)))).FnFree = usableSpace - *(*int32)(unsafe.Pointer(bp + 92 + uintptr(iPg)*4))
  35054 
  35055 __127:
  35056 	;
  35057 	goto __124
  35058 __124:
  35059 	i++
  35060 	goto __123
  35061 	goto __125
  35062 __125:
  35063 	;
  35064 	if !(isRoot != 0 && int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == 0 && int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156)))).FnFree) {
  35065 		goto __131
  35066 	}
  35067 
  35068 	*(*int32)(unsafe.Pointer(bp + 112)) = defragmentPage(tls, *(*uintptr)(unsafe.Pointer(bp + 156)), -1)
  35069 
  35070 	copyNodeContent(tls, *(*uintptr)(unsafe.Pointer(bp + 156)), pParent, bp+112)
  35071 	freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 156)), bp+112)
  35072 	goto __132
  35073 __131:
  35074 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && !(leafCorrection != 0)) {
  35075 		goto __133
  35076 	}
  35077 
  35078 	i = 0
  35079 __134:
  35080 	if !(i < nNew) {
  35081 		goto __136
  35082 	}
  35083 	key = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).FaData+8)
  35084 	ptrmapPut(tls, pBt, key, uint8(PTRMAP_BTREE), (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))).Fpgno, bp+112)
  35085 	goto __135
  35086 __135:
  35087 	i++
  35088 	goto __134
  35089 	goto __136
  35090 __136:
  35091 	;
  35092 __133:
  35093 	;
  35094 __132:
  35095 	;
  35096 	i = nNew
  35097 __137:
  35098 	if !(i < nOld) {
  35099 		goto __139
  35100 	}
  35101 	freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)), bp+112)
  35102 	goto __138
  35103 __138:
  35104 	i++
  35105 	goto __137
  35106 	goto __139
  35107 __139:
  35108 	;
  35109 balance_cleanup:
  35110 	Xsqlite3DbFree(tls, uintptr(0), (*CellArray)(unsafe.Pointer(bp+8)).FapCell)
  35111 	i = 0
  35112 __140:
  35113 	if !(i < nOld) {
  35114 		goto __142
  35115 	}
  35116 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 72 + uintptr(i)*4)))
  35117 	goto __141
  35118 __141:
  35119 	i++
  35120 	goto __140
  35121 	goto __142
  35122 __142:
  35123 	;
  35124 	i = 0
  35125 __143:
  35126 	if !(i < nNew) {
  35127 		goto __145
  35128 	}
  35129 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 156 + uintptr(i)*4)))
  35130 	goto __144
  35131 __144:
  35132 	i++
  35133 	goto __143
  35134 	goto __145
  35135 __145:
  35136 	;
  35137 	return *(*int32)(unsafe.Pointer(bp + 112))
  35138 }
  35139 
  35140 func balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) int32 {
  35141 	bp := tls.Alloc(12)
  35142 	defer tls.Free(12)
  35143 
  35144 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  35145 	*(*Pgno)(unsafe.Pointer(bp + 4)) = Pgno(0)
  35146 	var pBt uintptr = (*MemPage)(unsafe.Pointer(pRoot)).FpBt
  35147 
  35148 	*(*int32)(unsafe.Pointer(bp + 8)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pRoot)).FpDbPage)
  35149 	if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
  35150 		*(*int32)(unsafe.Pointer(bp + 8)) = allocateBtreePage(tls, pBt, bp, bp+4, (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, uint8(0))
  35151 		copyNodeContent(tls, pRoot, *(*uintptr)(unsafe.Pointer(bp)), bp+8)
  35152 		if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  35153 			ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4)), uint8(PTRMAP_BTREE), (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, bp+8)
  35154 		}
  35155 	}
  35156 	if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
  35157 		*(*uintptr)(unsafe.Pointer(ppChild)) = uintptr(0)
  35158 		releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  35159 		return *(*int32)(unsafe.Pointer(bp + 8))
  35160 	}
  35161 
  35162 	libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp))+28, pRoot+28,
  35163 		uint32((*MemPage)(unsafe.Pointer(pRoot)).FnOverflow)*uint32(unsafe.Sizeof(U16(0))))
  35164 	libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp))+36, pRoot+36,
  35165 		uint32((*MemPage)(unsafe.Pointer(pRoot)).FnOverflow)*uint32(unsafe.Sizeof(uintptr(0))))
  35166 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnOverflow = (*MemPage)(unsafe.Pointer(pRoot)).FnOverflow
  35167 
  35168 	zeroPage(tls, pRoot, int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData)))&libc.CplInt32(PTF_LEAF))
  35169 	Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(pRoot)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pRoot)).FhdrOffset)+8), *(*Pgno)(unsafe.Pointer(bp + 4)))
  35170 
  35171 	*(*uintptr)(unsafe.Pointer(ppChild)) = *(*uintptr)(unsafe.Pointer(bp))
  35172 	return SQLITE_OK
  35173 }
  35174 
  35175 func anotherValidCursor(tls *libc.TLS, pCur uintptr) int32 {
  35176 	var pOther uintptr
  35177 	for pOther = (*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpCursor; pOther != 0; pOther = (*BtCursor)(unsafe.Pointer(pOther)).FpNext {
  35178 		if pOther != pCur &&
  35179 			int32((*BtCursor)(unsafe.Pointer(pOther)).FeState) == CURSOR_VALID &&
  35180 			(*BtCursor)(unsafe.Pointer(pOther)).FpPage == (*BtCursor)(unsafe.Pointer(pCur)).FpPage {
  35181 			return Xsqlite3CorruptError(tls, 77150)
  35182 		}
  35183 	}
  35184 	return SQLITE_OK
  35185 }
  35186 
  35187 func balance(tls *libc.TLS, pCur uintptr) int32 {
  35188 	bp := tls.Alloc(13)
  35189 	defer tls.Free(13)
  35190 
  35191 	var rc int32 = SQLITE_OK
  35192 
  35193 	var pFree uintptr = uintptr(0)
  35194 
  35195 	for __ccgo := true; __ccgo; __ccgo = rc == SQLITE_OK {
  35196 		var iPage int32
  35197 		var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  35198 
  35199 		if (*MemPage)(unsafe.Pointer(pPage)).FnFree < 0 && btreeComputeFreeSpace(tls, pPage) != 0 {
  35200 			break
  35201 		}
  35202 		if int32((*MemPage)(unsafe.Pointer(pPage)).FnOverflow) == 0 && (*MemPage)(unsafe.Pointer(pPage)).FnFree*3 <= int32((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FusableSize)*2 {
  35203 			break
  35204 		} else if libc.AssignInt32(&iPage, int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage)) == 0 {
  35205 			if (*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0 && libc.AssignInt32(&rc, anotherValidCursor(tls, pCur)) == SQLITE_OK {
  35206 				rc = balance_deeper(tls, pPage, pCur+120+1*4)
  35207 				if rc == SQLITE_OK {
  35208 					(*BtCursor)(unsafe.Pointer(pCur)).FiPage = int8(1)
  35209 					(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0)
  35210 					*(*U16)(unsafe.Pointer(pCur + 72)) = U16(0)
  35211 					*(*uintptr)(unsafe.Pointer(pCur + 120)) = pPage
  35212 					(*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer(pCur + 120 + 1*4))
  35213 
  35214 				}
  35215 			} else {
  35216 				break
  35217 			}
  35218 		} else if Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage) > 1 {
  35219 			rc = Xsqlite3CorruptError(tls, 77210)
  35220 		} else {
  35221 			var pParent uintptr = *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(iPage-1)*4))
  35222 			var iIdx int32 = int32(*(*U16)(unsafe.Pointer(pCur + 72 + uintptr(iPage-1)*2)))
  35223 
  35224 			rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pParent)).FpDbPage)
  35225 			if rc == SQLITE_OK && (*MemPage)(unsafe.Pointer(pParent)).FnFree < 0 {
  35226 				rc = btreeComputeFreeSpace(tls, pParent)
  35227 			}
  35228 			if rc == SQLITE_OK {
  35229 				if (*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf != 0 &&
  35230 					int32((*MemPage)(unsafe.Pointer(pPage)).FnOverflow) == 1 &&
  35231 					int32(*(*U16)(unsafe.Pointer(pPage + 28))) == int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) &&
  35232 					(*MemPage)(unsafe.Pointer(pParent)).Fpgno != Pgno(1) &&
  35233 					int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == iIdx {
  35234 					rc = balance_quick(tls, pParent, pPage, bp)
  35235 				} else {
  35236 					var pSpace uintptr = Xsqlite3PageMalloc(tls, int32((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize))
  35237 					rc = balance_nonroot(tls, pParent, iIdx, pSpace, libc.Bool32(iPage == 1),
  35238 						int32((*BtCursor)(unsafe.Pointer(pCur)).Fhints)&BTREE_BULKLOAD)
  35239 					if pFree != 0 {
  35240 						Xsqlite3PageFree(tls, pFree)
  35241 					}
  35242 
  35243 					pFree = pSpace
  35244 				}
  35245 			}
  35246 
  35247 			(*MemPage)(unsafe.Pointer(pPage)).FnOverflow = U8(0)
  35248 
  35249 			releasePage(tls, pPage)
  35250 			(*BtCursor)(unsafe.Pointer(pCur)).FiPage--
  35251 
  35252 			(*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*4))
  35253 		}
  35254 	}
  35255 
  35256 	if pFree != 0 {
  35257 		Xsqlite3PageFree(tls, pFree)
  35258 	}
  35259 	return rc
  35260 }
  35261 
  35262 func btreeOverwriteContent(tls *libc.TLS, pPage uintptr, pDest uintptr, pX uintptr, iOffset int32, iAmt int32) int32 {
  35263 	var nData int32 = (*BtreePayload)(unsafe.Pointer(pX)).FnData - iOffset
  35264 	if nData <= 0 {
  35265 		var i int32
  35266 		for i = 0; i < iAmt && int32(*(*U8)(unsafe.Pointer(pDest + uintptr(i)))) == 0; i++ {
  35267 		}
  35268 		if i < iAmt {
  35269 			var rc int32 = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  35270 			if rc != 0 {
  35271 				return rc
  35272 			}
  35273 			libc.Xmemset(tls, pDest+uintptr(i), 0, uint32(iAmt-i))
  35274 		}
  35275 	} else {
  35276 		if nData < iAmt {
  35277 			var rc int32 = btreeOverwriteContent(tls, pPage, pDest+uintptr(nData), pX, iOffset+nData,
  35278 				iAmt-nData)
  35279 			if rc != 0 {
  35280 				return rc
  35281 			}
  35282 			iAmt = nData
  35283 		}
  35284 		if libc.Xmemcmp(tls, pDest, (*BtreePayload)(unsafe.Pointer(pX)).FpData+uintptr(iOffset), uint32(iAmt)) != 0 {
  35285 			var rc int32 = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  35286 			if rc != 0 {
  35287 				return rc
  35288 			}
  35289 
  35290 			libc.Xmemmove(tls, pDest, (*BtreePayload)(unsafe.Pointer(pX)).FpData+uintptr(iOffset), uint32(iAmt))
  35291 		}
  35292 	}
  35293 	return SQLITE_OK
  35294 }
  35295 
  35296 func btreeOverwriteOverflowCell(tls *libc.TLS, pCur uintptr, pX uintptr) int32 {
  35297 	bp := tls.Alloc(4)
  35298 	defer tls.Free(4)
  35299 
  35300 	var iOffset int32
  35301 	var nTotal int32 = (*BtreePayload)(unsafe.Pointer(pX)).FnData + (*BtreePayload)(unsafe.Pointer(pX)).FnZero
  35302 	var rc int32
  35303 	*(*uintptr)(unsafe.Pointer(bp)) = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  35304 	var pBt uintptr
  35305 	var ovflPgno Pgno
  35306 	var ovflPageSize U32
  35307 
  35308 	rc = btreeOverwriteContent(tls, *(*uintptr)(unsafe.Pointer(bp)), (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload, pX,
  35309 		0, int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal))
  35310 	if rc != 0 {
  35311 		return rc
  35312 	}
  35313 
  35314 	iOffset = int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)
  35315 
  35316 	ovflPgno = Xsqlite3Get4byte(tls, (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload+uintptr(iOffset))
  35317 	pBt = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpBt
  35318 	ovflPageSize = (*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4)
  35319 	for __ccgo := true; __ccgo; __ccgo = iOffset < nTotal {
  35320 		rc = btreeGetPage(tls, pBt, ovflPgno, bp, 0)
  35321 		if rc != 0 {
  35322 			return rc
  35323 		}
  35324 		if Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage) != 1 || (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FisInit != 0 {
  35325 			rc = Xsqlite3CorruptError(tls, 77374)
  35326 		} else {
  35327 			if U32(iOffset)+ovflPageSize < U32(nTotal) {
  35328 				ovflPgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData)
  35329 			} else {
  35330 				ovflPageSize = U32(nTotal - iOffset)
  35331 			}
  35332 			rc = btreeOverwriteContent(tls, *(*uintptr)(unsafe.Pointer(bp)), (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData+uintptr(4), pX,
  35333 				iOffset, int32(ovflPageSize))
  35334 		}
  35335 		Xsqlite3PagerUnref(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)
  35336 		if rc != 0 {
  35337 			return rc
  35338 		}
  35339 		iOffset = int32(U32(iOffset) + ovflPageSize)
  35340 	}
  35341 	return SQLITE_OK
  35342 }
  35343 
  35344 func btreeOverwriteCell(tls *libc.TLS, pCur uintptr, pX uintptr) int32 {
  35345 	var nTotal int32 = (*BtreePayload)(unsafe.Pointer(pX)).FnData + (*BtreePayload)(unsafe.Pointer(pX)).FnZero
  35346 	var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  35347 
  35348 	if (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload+uintptr((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) > (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd ||
  35349 		(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload < (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*MemPage)(unsafe.Pointer(pPage)).FcellOffset) {
  35350 		return Xsqlite3CorruptError(tls, 77402)
  35351 	}
  35352 	if int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) == nTotal {
  35353 		return btreeOverwriteContent(tls, pPage, (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FpPayload, pX,
  35354 			0, int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal))
  35355 	} else {
  35356 		return btreeOverwriteOverflowCell(tls, pCur, pX)
  35357 	}
  35358 	return int32(0)
  35359 }
  35360 
  35361 // Insert a new record into the BTree.  The content of the new record
  35362 // is described by the pX object.  The pCur cursor is used only to
  35363 // define what table the record should be inserted into, and is left
  35364 // pointing at a random location.
  35365 //
  35366 // For a table btree (used for rowid tables), only the pX.nKey value of
  35367 // the key is used. The pX.pKey value must be NULL.  The pX.nKey is the
  35368 // rowid or INTEGER PRIMARY KEY of the row.  The pX.nData,pData,nZero fields
  35369 // hold the content of the row.
  35370 //
  35371 // For an index btree (used for indexes and WITHOUT ROWID tables), the
  35372 // key is an arbitrary byte sequence stored in pX.pKey,nKey.  The
  35373 // pX.pData,nData,nZero fields must be zero.
  35374 //
  35375 // If the seekResult parameter is non-zero, then a successful call to
  35376 // sqlite3BtreeIndexMoveto() to seek cursor pCur to (pKey,nKey) has already
  35377 // been performed.  In other words, if seekResult!=0 then the cursor
  35378 // is currently pointing to a cell that will be adjacent to the cell
  35379 // to be inserted.  If seekResult<0 then pCur points to a cell that is
  35380 // smaller then (pKey,nKey).  If seekResult>0 then pCur points to a cell
  35381 // that is larger than (pKey,nKey).
  35382 //
  35383 // If seekResult==0, that means pCur is pointing at some unknown location.
  35384 // In that case, this routine must seek the cursor to the correct insertion
  35385 // point for (pKey,nKey) before doing the insertion.  For index btrees,
  35386 // if pX->nMem is non-zero, then pX->aMem contains pointers to the unpacked
  35387 // key values and pX->aMem can be used instead of pX->pKey to avoid having
  35388 // to decode the key.
  35389 func Xsqlite3BtreeInsert(tls *libc.TLS, pCur uintptr, pX uintptr, flags int32, seekResult int32) int32 {
  35390 	bp := tls.Alloc(136)
  35391 	defer tls.Free(136)
  35392 
  35393 	var idx int32
  35394 	var pPage uintptr
  35395 	var p uintptr
  35396 	var oldCell uintptr
  35397 	var newCell uintptr
  35398 
  35399 	var ovfl Pgno
  35400 
  35401 	*(*int32)(unsafe.Pointer(bp)) = seekResult
  35402 	*(*int32)(unsafe.Pointer(bp + 108)) = 0
  35403 	p = (*BtCursor)(unsafe.Pointer(pCur)).FpBtree
  35404 	newCell = uintptr(0)
  35405 
  35406 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_Multiple != 0) {
  35407 		goto __1
  35408 	}
  35409 	*(*int32)(unsafe.Pointer(bp + 104)) = saveAllCursors(tls, (*Btree)(unsafe.Pointer(p)).FpBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur)
  35410 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35411 		goto __2
  35412 	}
  35413 	return *(*int32)(unsafe.Pointer(bp + 104))
  35414 __2:
  35415 	;
  35416 	if !(*(*int32)(unsafe.Pointer(bp)) != 0 && int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) < 0) {
  35417 		goto __3
  35418 	}
  35419 
  35420 	return Xsqlite3CorruptError(tls, 77483)
  35421 __3:
  35422 	;
  35423 __1:
  35424 	;
  35425 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK) {
  35426 		goto __4
  35427 	}
  35428 
  35429 	*(*int32)(unsafe.Pointer(bp + 104)) = moveToRoot(tls, pCur)
  35430 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0 && *(*int32)(unsafe.Pointer(bp + 104)) != SQLITE_EMPTY) {
  35431 		goto __5
  35432 	}
  35433 	return *(*int32)(unsafe.Pointer(bp + 104))
  35434 __5:
  35435 	;
  35436 __4:
  35437 	;
  35438 	if !((*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0)) {
  35439 		goto __6
  35440 	}
  35441 
  35442 	if !((*Btree)(unsafe.Pointer(p)).FhasIncrblobCur != 0) {
  35443 		goto __8
  35444 	}
  35445 	invalidateIncrblobCursors(tls, p, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (*BtreePayload)(unsafe.Pointer(pX)).FnKey, 0)
  35446 __8:
  35447 	;
  35448 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_ValidNKey != 0 && (*BtreePayload)(unsafe.Pointer(pX)).FnKey == (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey) {
  35449 		goto __9
  35450 	}
  35451 
  35452 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) != 0 &&
  35453 		(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload == U32((*BtreePayload)(unsafe.Pointer(pX)).FnData)+U32((*BtreePayload)(unsafe.Pointer(pX)).FnZero)) {
  35454 		goto __11
  35455 	}
  35456 
  35457 	return btreeOverwriteCell(tls, pCur, pX)
  35458 __11:
  35459 	;
  35460 	goto __10
  35461 __9:
  35462 	if !(*(*int32)(unsafe.Pointer(bp)) == 0) {
  35463 		goto __12
  35464 	}
  35465 
  35466 	*(*int32)(unsafe.Pointer(bp + 104)) = Xsqlite3BtreeTableMoveto(tls, pCur, (*BtreePayload)(unsafe.Pointer(pX)).FnKey,
  35467 		libc.Bool32(flags&BTREE_APPEND != 0), bp)
  35468 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35469 		goto __13
  35470 	}
  35471 	return *(*int32)(unsafe.Pointer(bp + 104))
  35472 __13:
  35473 	;
  35474 __12:
  35475 	;
  35476 __10:
  35477 	;
  35478 	goto __7
  35479 __6:
  35480 	;
  35481 	if !(*(*int32)(unsafe.Pointer(bp)) == 0 && flags&BTREE_SAVEPOSITION == 0) {
  35482 		goto __14
  35483 	}
  35484 	if !((*BtreePayload)(unsafe.Pointer(pX)).FnMem != 0) {
  35485 		goto __15
  35486 	}
  35487 	(*UnpackedRecord)(unsafe.Pointer(bp + 8)).FpKeyInfo = (*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo
  35488 	(*UnpackedRecord)(unsafe.Pointer(bp + 8)).FaMem = (*BtreePayload)(unsafe.Pointer(pX)).FaMem
  35489 	(*UnpackedRecord)(unsafe.Pointer(bp + 8)).FnField = (*BtreePayload)(unsafe.Pointer(pX)).FnMem
  35490 	(*UnpackedRecord)(unsafe.Pointer(bp + 8)).Fdefault_rc = int8(0)
  35491 	(*UnpackedRecord)(unsafe.Pointer(bp + 8)).FeqSeen = U8(0)
  35492 	*(*int32)(unsafe.Pointer(bp + 104)) = Xsqlite3BtreeIndexMoveto(tls, pCur, bp+8, bp)
  35493 	goto __16
  35494 __15:
  35495 	*(*int32)(unsafe.Pointer(bp + 104)) = btreeMoveto(tls, pCur, (*BtreePayload)(unsafe.Pointer(pX)).FpKey, (*BtreePayload)(unsafe.Pointer(pX)).FnKey,
  35496 		libc.Bool32(flags&BTREE_APPEND != 0), bp)
  35497 __16:
  35498 	;
  35499 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35500 		goto __17
  35501 	}
  35502 	return *(*int32)(unsafe.Pointer(bp + 104))
  35503 __17:
  35504 	;
  35505 __14:
  35506 	;
  35507 	if !(*(*int32)(unsafe.Pointer(bp)) == 0) {
  35508 		goto __18
  35509 	}
  35510 	getCellInfo(tls, pCur)
  35511 	if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == (*BtreePayload)(unsafe.Pointer(pX)).FnKey) {
  35512 		goto __19
  35513 	}
  35514 	(*BtreePayload)(unsafe.Pointer(bp + 40)).FpData = (*BtreePayload)(unsafe.Pointer(pX)).FpKey
  35515 	(*BtreePayload)(unsafe.Pointer(bp + 40)).FnData = int32((*BtreePayload)(unsafe.Pointer(pX)).FnKey)
  35516 	(*BtreePayload)(unsafe.Pointer(bp + 40)).FnZero = 0
  35517 	return btreeOverwriteCell(tls, pCur, bp+40)
  35518 __19:
  35519 	;
  35520 __18:
  35521 	;
  35522 __7:
  35523 	;
  35524 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  35525 
  35526 	if !((*MemPage)(unsafe.Pointer(pPage)).FnFree < 0) {
  35527 		goto __20
  35528 	}
  35529 	if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) > CURSOR_INVALID) {
  35530 		goto __21
  35531 	}
  35532 
  35533 	*(*int32)(unsafe.Pointer(bp + 104)) = Xsqlite3CorruptError(tls, 77606)
  35534 	goto __22
  35535 __21:
  35536 	*(*int32)(unsafe.Pointer(bp + 104)) = btreeComputeFreeSpace(tls, pPage)
  35537 __22:
  35538 	;
  35539 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35540 		goto __23
  35541 	}
  35542 	return *(*int32)(unsafe.Pointer(bp + 104))
  35543 __23:
  35544 	;
  35545 __20:
  35546 	;
  35547 	newCell = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpTmpSpace
  35548 
  35549 	if !(flags&BTREE_PREFORMAT != 0) {
  35550 		goto __24
  35551 	}
  35552 	*(*int32)(unsafe.Pointer(bp + 104)) = SQLITE_OK
  35553 	*(*int32)(unsafe.Pointer(bp + 108)) = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FnPreformatSize
  35554 	if !(*(*int32)(unsafe.Pointer(bp + 108)) < 4) {
  35555 		goto __26
  35556 	}
  35557 	*(*int32)(unsafe.Pointer(bp + 108)) = 4
  35558 __26:
  35559 	;
  35560 	if !((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FautoVacuum != 0 && *(*int32)(unsafe.Pointer(bp + 108)) > int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal)) {
  35561 		goto __27
  35562 	}
  35563 	(*struct {
  35564 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  35565 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, newCell, bp+80)
  35566 	if !((*CellInfo)(unsafe.Pointer(bp+80)).FnPayload != U32((*CellInfo)(unsafe.Pointer(bp+80)).FnLocal)) {
  35567 		goto __28
  35568 	}
  35569 	ovfl = Xsqlite3Get4byte(tls, newCell+uintptr(*(*int32)(unsafe.Pointer(bp + 108))-4))
  35570 	ptrmapPut(tls, (*Btree)(unsafe.Pointer(p)).FpBt, ovfl, uint8(PTRMAP_OVERFLOW1), (*MemPage)(unsafe.Pointer(pPage)).Fpgno, bp+104)
  35571 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35572 		goto __29
  35573 	}
  35574 	goto end_insert
  35575 __29:
  35576 	;
  35577 __28:
  35578 	;
  35579 __27:
  35580 	;
  35581 	goto __25
  35582 __24:
  35583 	*(*int32)(unsafe.Pointer(bp + 104)) = fillInCell(tls, pPage, newCell, pX, bp+108)
  35584 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35585 		goto __30
  35586 	}
  35587 	goto end_insert
  35588 __30:
  35589 	;
  35590 __25:
  35591 	;
  35592 	idx = int32((*BtCursor)(unsafe.Pointer(pCur)).Fix)
  35593 	(*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0)
  35594 	if !(*(*int32)(unsafe.Pointer(bp)) == 0) {
  35595 		goto __31
  35596 	}
  35597 
  35598 	if !(idx >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) {
  35599 		goto __33
  35600 	}
  35601 	return Xsqlite3CorruptError(tls, 77645)
  35602 __33:
  35603 	;
  35604 	*(*int32)(unsafe.Pointer(bp + 104)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  35605 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35606 		goto __34
  35607 	}
  35608 	goto end_insert
  35609 __34:
  35610 	;
  35611 	oldCell = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*idx))))))
  35612 	if !!(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  35613 		goto __35
  35614 	}
  35615 	libc.Xmemcpy(tls, newCell, oldCell, uint32(4))
  35616 __35:
  35617 	;
  35618 	(*struct {
  35619 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  35620 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, oldCell, bp+112)
  35621 	if !(U32((*CellInfo)(unsafe.Pointer(bp+112)).FnLocal) != (*CellInfo)(unsafe.Pointer(bp+112)).FnPayload) {
  35622 		goto __36
  35623 	}
  35624 	*(*int32)(unsafe.Pointer(bp + 104)) = clearCellOverflow(tls, pPage, oldCell, bp+112)
  35625 	goto __37
  35626 __36:
  35627 	*(*int32)(unsafe.Pointer(bp + 104)) = SQLITE_OK
  35628 __37:
  35629 	;
  35630 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidOvfl))
  35631 	if !(int32((*CellInfo)(unsafe.Pointer(bp+112)).FnSize) == *(*int32)(unsafe.Pointer(bp + 108)) && U32((*CellInfo)(unsafe.Pointer(bp+112)).FnLocal) == (*CellInfo)(unsafe.Pointer(bp+112)).FnPayload &&
  35632 		(!(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FautoVacuum) != 0) || *(*int32)(unsafe.Pointer(bp + 108)) < int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal))) {
  35633 		goto __38
  35634 	}
  35635 
  35636 	if !(oldCell < (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+uintptr(10)) {
  35637 		goto __39
  35638 	}
  35639 	return Xsqlite3CorruptError(tls, 77672)
  35640 __39:
  35641 	;
  35642 	if !(oldCell+uintptr(*(*int32)(unsafe.Pointer(bp + 108))) > (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd) {
  35643 		goto __40
  35644 	}
  35645 	return Xsqlite3CorruptError(tls, 77675)
  35646 __40:
  35647 	;
  35648 	libc.Xmemcpy(tls, oldCell, newCell, uint32(*(*int32)(unsafe.Pointer(bp + 108))))
  35649 	return SQLITE_OK
  35650 __38:
  35651 	;
  35652 	dropCell(tls, pPage, idx, int32((*CellInfo)(unsafe.Pointer(bp+112)).FnSize), bp+104)
  35653 	if !(*(*int32)(unsafe.Pointer(bp + 104)) != 0) {
  35654 		goto __41
  35655 	}
  35656 	goto end_insert
  35657 __41:
  35658 	;
  35659 	goto __32
  35660 __31:
  35661 	if !(*(*int32)(unsafe.Pointer(bp)) < 0 && int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) > 0) {
  35662 		goto __42
  35663 	}
  35664 
  35665 	idx = int32(libc.PreIncUint16(&(*BtCursor)(unsafe.Pointer(pCur)).Fix, 1))
  35666 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidNKey))
  35667 	goto __43
  35668 __42:
  35669 	;
  35670 __43:
  35671 	;
  35672 __32:
  35673 	;
  35674 	*(*int32)(unsafe.Pointer(bp + 104)) = insertCell(tls, pPage, idx, newCell, *(*int32)(unsafe.Pointer(bp + 108)), uintptr(0), uint32(0))
  35675 
  35676 	if !((*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0) {
  35677 		goto __44
  35678 	}
  35679 
  35680 	*(*U8)(unsafe.Pointer(pCur + 1)) &= libc.Uint8FromInt32(libc.CplInt32(BTCF_ValidNKey))
  35681 	*(*int32)(unsafe.Pointer(bp + 104)) = balance(tls, pCur)
  35682 
  35683 	(*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnOverflow = U8(0)
  35684 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_INVALID)
  35685 	if !(flags&BTREE_SAVEPOSITION != 0 && *(*int32)(unsafe.Pointer(bp + 104)) == SQLITE_OK) {
  35686 		goto __45
  35687 	}
  35688 	btreeReleaseAllCursorPages(tls, pCur)
  35689 	if !((*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo != 0) {
  35690 		goto __46
  35691 	}
  35692 
  35693 	(*BtCursor)(unsafe.Pointer(pCur)).FpKey = Xsqlite3Malloc(tls, uint64((*BtreePayload)(unsafe.Pointer(pX)).FnKey))
  35694 	if !((*BtCursor)(unsafe.Pointer(pCur)).FpKey == uintptr(0)) {
  35695 		goto __47
  35696 	}
  35697 	*(*int32)(unsafe.Pointer(bp + 104)) = SQLITE_NOMEM
  35698 	goto __48
  35699 __47:
  35700 	libc.Xmemcpy(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey, (*BtreePayload)(unsafe.Pointer(pX)).FpKey, uint32((*BtreePayload)(unsafe.Pointer(pX)).FnKey))
  35701 __48:
  35702 	;
  35703 __46:
  35704 	;
  35705 	(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_REQUIRESEEK)
  35706 	(*BtCursor)(unsafe.Pointer(pCur)).FnKey = (*BtreePayload)(unsafe.Pointer(pX)).FnKey
  35707 __45:
  35708 	;
  35709 __44:
  35710 	;
  35711 end_insert:
  35712 	return *(*int32)(unsafe.Pointer(bp + 104))
  35713 }
  35714 
  35715 // This function is used as part of copying the current row from cursor
  35716 // pSrc into cursor pDest. If the cursors are open on intkey tables, then
  35717 // parameter iKey is used as the rowid value when the record is copied
  35718 // into pDest. Otherwise, the record is copied verbatim.
  35719 //
  35720 // This function does not actually write the new value to cursor pDest.
  35721 // Instead, it creates and populates any required overflow pages and
  35722 // writes the data for the new cell into the BtShared.pTmpSpace buffer
  35723 // for the destination database. The size of the cell, in bytes, is left
  35724 // in BtShared.nPreformatSize. The caller completes the insertion by
  35725 // calling sqlite3BtreeInsert() with the BTREE_PREFORMAT flag specified.
  35726 //
  35727 // SQLITE_OK is returned if successful, or an SQLite error code otherwise.
  35728 func Xsqlite3BtreeTransferRow(tls *libc.TLS, pDest uintptr, pSrc uintptr, iKey I64) int32 {
  35729 	bp := tls.Alloc(16)
  35730 	defer tls.Free(16)
  35731 
  35732 	var pBt uintptr = (*BtCursor)(unsafe.Pointer(pDest)).FpBt
  35733 	var aOut uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace
  35734 	var aIn uintptr
  35735 	var nIn U32
  35736 	var nRem U32
  35737 
  35738 	getCellInfo(tls, pSrc)
  35739 	if (*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload < U32(0x80) {
  35740 		*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&aOut, 1))) = U8((*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload)
  35741 	} else {
  35742 		aOut += uintptr(Xsqlite3PutVarint(tls, aOut, uint64((*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload)))
  35743 	}
  35744 	if (*BtCursor)(unsafe.Pointer(pDest)).FpKeyInfo == uintptr(0) {
  35745 		aOut += uintptr(Xsqlite3PutVarint(tls, aOut, uint64(iKey)))
  35746 	}
  35747 	nIn = U32((*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnLocal)
  35748 	aIn = (*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FpPayload
  35749 	if aIn+uintptr(nIn) > (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pSrc)).FpPage)).FaDataEnd {
  35750 		return Xsqlite3CorruptError(tls, 77777)
  35751 	}
  35752 	nRem = (*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload
  35753 	if nIn == nRem && nIn < U32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pDest)).FpPage)).FmaxLocal) {
  35754 		libc.Xmemcpy(tls, aOut, aIn, nIn)
  35755 		(*BtShared)(unsafe.Pointer(pBt)).FnPreformatSize = int32(nIn + U32((int32(aOut)-int32((*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace))/1))
  35756 		return SQLITE_OK
  35757 	} else {
  35758 		*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
  35759 		var pSrcPager uintptr = (*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pSrc)).FpBt)).FpPager
  35760 		var pPgnoOut uintptr = uintptr(0)
  35761 		var ovflIn Pgno = Pgno(0)
  35762 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  35763 		var pPageOut uintptr = uintptr(0)
  35764 		var nOut U32
  35765 
  35766 		nOut = U32(btreePayloadToLocal(tls, (*BtCursor)(unsafe.Pointer(pDest)).FpPage, int64((*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload)))
  35767 		(*BtShared)(unsafe.Pointer(pBt)).FnPreformatSize = int32(nOut + U32((int32(aOut)-int32((*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace))/1))
  35768 		if nOut < (*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FnPayload {
  35769 			pPgnoOut = aOut + uintptr(nOut)
  35770 			*(*int32)(unsafe.Pointer(pBt + 88)) += 4
  35771 		}
  35772 
  35773 		if nRem > nIn {
  35774 			if aIn+uintptr(nIn)+uintptr(4) > (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pSrc)).FpPage)).FaDataEnd {
  35775 				return Xsqlite3CorruptError(tls, 77802)
  35776 			}
  35777 			ovflIn = Xsqlite3Get4byte(tls, (*BtCursor)(unsafe.Pointer(pSrc)).Finfo.FpPayload+uintptr(nIn))
  35778 		}
  35779 
  35780 		for __ccgo := true; __ccgo; __ccgo = nRem > U32(0) && *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
  35781 			nRem = nRem - nOut
  35782 			for __ccgo1 := true; __ccgo1; __ccgo1 = *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK && nOut > U32(0) {
  35783 				if nIn > U32(0) {
  35784 					var nCopy int32 = func() int32 {
  35785 						if nOut < nIn {
  35786 							return int32(nOut)
  35787 						}
  35788 						return int32(nIn)
  35789 					}()
  35790 					libc.Xmemcpy(tls, aOut, aIn, uint32(nCopy))
  35791 					nOut = nOut - U32(nCopy)
  35792 					nIn = nIn - U32(nCopy)
  35793 					aOut += uintptr(nCopy)
  35794 					aIn += uintptr(nCopy)
  35795 				}
  35796 				if nOut > U32(0) {
  35797 					Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  35798 					*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  35799 					*(*int32)(unsafe.Pointer(bp + 12)) = Xsqlite3PagerGet(tls, pSrcPager, ovflIn, bp, PAGER_GET_READONLY)
  35800 					if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
  35801 						aIn = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp)))
  35802 						ovflIn = Xsqlite3Get4byte(tls, aIn)
  35803 						aIn += uintptr(4)
  35804 						nIn = (*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pSrc)).FpBt)).FusableSize - U32(4)
  35805 					}
  35806 				}
  35807 			}
  35808 
  35809 			if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK && nRem > U32(0) && pPgnoOut != 0 {
  35810 				*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  35811 				*(*int32)(unsafe.Pointer(bp + 12)) = allocateBtreePage(tls, pBt, bp+4, bp+8, uint32(0), uint8(0))
  35812 				Xsqlite3Put4byte(tls, pPgnoOut, *(*Pgno)(unsafe.Pointer(bp + 8)))
  35813 				if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && pPageOut != 0 {
  35814 					ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8)), uint8(PTRMAP_OVERFLOW2), (*MemPage)(unsafe.Pointer(pPageOut)).Fpgno, bp+12)
  35815 				}
  35816 				releasePage(tls, pPageOut)
  35817 				pPageOut = *(*uintptr)(unsafe.Pointer(bp + 4))
  35818 				if pPageOut != 0 {
  35819 					pPgnoOut = (*MemPage)(unsafe.Pointer(pPageOut)).FaData
  35820 					Xsqlite3Put4byte(tls, pPgnoOut, uint32(0))
  35821 					aOut = pPgnoOut + 4
  35822 					nOut = func() uint32 {
  35823 						if (*BtShared)(unsafe.Pointer(pBt)).FusableSize-U32(4) < nRem {
  35824 							return (*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4)
  35825 						}
  35826 						return nRem
  35827 					}()
  35828 				}
  35829 			}
  35830 		}
  35831 
  35832 		releasePage(tls, pPageOut)
  35833 		Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  35834 		return *(*int32)(unsafe.Pointer(bp + 12))
  35835 	}
  35836 	return int32(0)
  35837 }
  35838 
  35839 // Delete the entry that the cursor is pointing to.
  35840 //
  35841 // If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then
  35842 // the cursor is left pointing at an arbitrary location after the delete.
  35843 // But if that bit is set, then the cursor is left in a state such that
  35844 // the next call to BtreeNext() or BtreePrev() moves it to the same row
  35845 // as it would have been on if the call to BtreeDelete() had been omitted.
  35846 //
  35847 // The BTREE_AUXDELETE bit of flags indicates that is one of several deletes
  35848 // associated with a single table entry and its indexes.  Only one of those
  35849 // deletes is considered the "primary" delete.  The primary delete occurs
  35850 // on a cursor that is not a BTREE_FORDELETE cursor.  All but one delete
  35851 // operation on non-FORDELETE cursors is tagged with the AUXDELETE flag.
  35852 // The BTREE_AUXDELETE bit is a hint that is not used by this implementation,
  35853 // but which might be used by alternative storage engines.
  35854 func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 {
  35855 	bp := tls.Alloc(28)
  35856 	defer tls.Free(28)
  35857 
  35858 	var p uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBtree
  35859 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  35860 
  35861 	var pPage uintptr
  35862 	var pCell uintptr
  35863 	var iCellIdx int32
  35864 	var iCellDepth int32
  35865 
  35866 	var bPreserve U8
  35867 
  35868 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  35869 		if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK {
  35870 			*(*int32)(unsafe.Pointer(bp + 24)) = btreeRestoreCursorPosition(tls, pCur)
  35871 
  35872 			if *(*int32)(unsafe.Pointer(bp + 24)) != 0 || int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID {
  35873 				return *(*int32)(unsafe.Pointer(bp + 24))
  35874 			}
  35875 		} else {
  35876 			return Xsqlite3CorruptError(tls, 77898)
  35877 		}
  35878 	}
  35879 
  35880 	iCellDepth = int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage)
  35881 	iCellIdx = int32((*BtCursor)(unsafe.Pointer(pCur)).Fix)
  35882 	pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  35883 	if int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) <= iCellIdx {
  35884 		return Xsqlite3CorruptError(tls, 77907)
  35885 	}
  35886 	pCell = (*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*iCellIdx))))))
  35887 	if (*MemPage)(unsafe.Pointer(pPage)).FnFree < 0 && btreeComputeFreeSpace(tls, pPage) != 0 {
  35888 		return Xsqlite3CorruptError(tls, 77911)
  35889 	}
  35890 
  35891 	bPreserve = U8(libc.Bool32(int32(flags)&BTREE_SAVEPOSITION != 0))
  35892 	if bPreserve != 0 {
  35893 		if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) ||
  35894 			(*MemPage)(unsafe.Pointer(pPage)).FnFree+int32((*struct {
  35895 				f func(*libc.TLS, uintptr, uintptr) U16
  35896 			})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxCellSize})).f(tls, pPage, pCell))+2 > int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize*U32(2)/U32(3)) ||
  35897 			int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) == 1 {
  35898 			*(*int32)(unsafe.Pointer(bp + 24)) = saveCursorKey(tls, pCur)
  35899 			if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35900 				return *(*int32)(unsafe.Pointer(bp + 24))
  35901 			}
  35902 		} else {
  35903 			bPreserve = U8(2)
  35904 		}
  35905 	}
  35906 
  35907 	if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  35908 		*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3BtreePrevious(tls, pCur, 0)
  35909 
  35910 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35911 			return *(*int32)(unsafe.Pointer(bp + 24))
  35912 		}
  35913 	}
  35914 
  35915 	if int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags)&BTCF_Multiple != 0 {
  35916 		*(*int32)(unsafe.Pointer(bp + 24)) = saveAllCursors(tls, pBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur)
  35917 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35918 			return *(*int32)(unsafe.Pointer(bp + 24))
  35919 		}
  35920 	}
  35921 
  35922 	if (*BtCursor)(unsafe.Pointer(pCur)).FpKeyInfo == uintptr(0) && (*Btree)(unsafe.Pointer(p)).FhasIncrblobCur != 0 {
  35923 		invalidateIncrblobCursors(tls, p, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey, 0)
  35924 	}
  35925 
  35926 	*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage)
  35927 	if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35928 		return *(*int32)(unsafe.Pointer(bp + 24))
  35929 	}
  35930 	(*struct {
  35931 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  35932 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pPage)).FxParseCell})).f(tls, pPage, pCell, bp)
  35933 	if U32((*CellInfo)(unsafe.Pointer(bp)).FnLocal) != (*CellInfo)(unsafe.Pointer(bp)).FnPayload {
  35934 		*(*int32)(unsafe.Pointer(bp + 24)) = clearCellOverflow(tls, pPage, pCell, bp)
  35935 	} else {
  35936 		*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_OK
  35937 	}
  35938 
  35939 	dropCell(tls, pPage, iCellIdx, int32((*CellInfo)(unsafe.Pointer(bp)).FnSize), bp+24)
  35940 	if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35941 		return *(*int32)(unsafe.Pointer(bp + 24))
  35942 	}
  35943 
  35944 	if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) {
  35945 		var pLeaf uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  35946 		var nCell int32
  35947 		var n Pgno
  35948 		var pTmp uintptr
  35949 
  35950 		if (*MemPage)(unsafe.Pointer(pLeaf)).FnFree < 0 {
  35951 			*(*int32)(unsafe.Pointer(bp + 24)) = btreeComputeFreeSpace(tls, pLeaf)
  35952 			if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35953 				return *(*int32)(unsafe.Pointer(bp + 24))
  35954 			}
  35955 		}
  35956 		if iCellDepth < int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage)-1 {
  35957 			n = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(iCellDepth+1)*4)))).Fpgno
  35958 		} else {
  35959 			n = (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fpgno
  35960 		}
  35961 		pCell = (*MemPage)(unsafe.Pointer(pLeaf)).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(pLeaf)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pLeaf)).FaCellIdx + uintptr(2*(int32((*MemPage)(unsafe.Pointer(pLeaf)).FnCell)-1)))))))
  35962 		if pCell < (*MemPage)(unsafe.Pointer(pLeaf)).FaData+4 {
  35963 			return Xsqlite3CorruptError(tls, 78002)
  35964 		}
  35965 		nCell = int32((*struct {
  35966 			f func(*libc.TLS, uintptr, uintptr) U16
  35967 		})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(pLeaf)).FxCellSize})).f(tls, pLeaf, pCell))
  35968 
  35969 		pTmp = (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace
  35970 
  35971 		*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pLeaf)).FpDbPage)
  35972 		if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
  35973 			*(*int32)(unsafe.Pointer(bp + 24)) = insertCell(tls, pPage, iCellIdx, pCell-uintptr(4), nCell+4, pTmp, n)
  35974 		}
  35975 		dropCell(tls, pLeaf, int32((*MemPage)(unsafe.Pointer(pLeaf)).FnCell)-1, nCell, bp+24)
  35976 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  35977 			return *(*int32)(unsafe.Pointer(bp + 24))
  35978 		}
  35979 	}
  35980 
  35981 	if (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnFree*3 <= int32((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FusableSize)*2 {
  35982 		*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_OK
  35983 	} else {
  35984 		*(*int32)(unsafe.Pointer(bp + 24)) = balance(tls, pCur)
  35985 	}
  35986 	if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK && int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth {
  35987 		releasePageNotNull(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage)
  35988 		(*BtCursor)(unsafe.Pointer(pCur)).FiPage--
  35989 		for int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth {
  35990 			releasePage(tls, *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr(libc.PostDecInt8(&(*BtCursor)(unsafe.Pointer(pCur)).FiPage, 1))*4)))
  35991 		}
  35992 		(*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer(pCur + 120 + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*4))
  35993 		*(*int32)(unsafe.Pointer(bp + 24)) = balance(tls, pCur)
  35994 	}
  35995 
  35996 	if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
  35997 		if int32(bPreserve) > 1 {
  35998 			(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_SKIPNEXT)
  35999 			if iCellIdx >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  36000 				(*BtCursor)(unsafe.Pointer(pCur)).FskipNext = -1
  36001 				(*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1)
  36002 			} else {
  36003 				(*BtCursor)(unsafe.Pointer(pCur)).FskipNext = 1
  36004 			}
  36005 		} else {
  36006 			*(*int32)(unsafe.Pointer(bp + 24)) = moveToRoot(tls, pCur)
  36007 			if bPreserve != 0 {
  36008 				btreeReleaseAllCursorPages(tls, pCur)
  36009 				(*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(CURSOR_REQUIRESEEK)
  36010 			}
  36011 			if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_EMPTY {
  36012 				*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_OK
  36013 			}
  36014 		}
  36015 	}
  36016 	return *(*int32)(unsafe.Pointer(bp + 24))
  36017 }
  36018 
  36019 func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags int32) int32 {
  36020 	bp := tls.Alloc(28)
  36021 	defer tls.Free(28)
  36022 
  36023 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  36024 
  36025 	var ptfFlags int32
  36026 
  36027 	if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  36028 		invalidateAllOverflowCache(tls, pBt)
  36029 
  36030 		Xsqlite3BtreeGetMeta(tls, p, BTREE_LARGEST_ROOT_PAGE, bp)
  36031 		if *(*Pgno)(unsafe.Pointer(bp)) > btreePagecount(tls, pBt) {
  36032 			return Xsqlite3CorruptError(tls, 78118)
  36033 		}
  36034 		*(*Pgno)(unsafe.Pointer(bp))++
  36035 
  36036 		for *(*Pgno)(unsafe.Pointer(bp)) == ptrmapPageno(tls, pBt, *(*Pgno)(unsafe.Pointer(bp))) || *(*Pgno)(unsafe.Pointer(bp)) == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) {
  36037 			*(*Pgno)(unsafe.Pointer(bp))++
  36038 		}
  36039 
  36040 		*(*int32)(unsafe.Pointer(bp + 24)) = allocateBtreePage(tls, pBt, bp+4, bp+8, *(*Pgno)(unsafe.Pointer(bp)), uint8(BTALLOC_EXACT))
  36041 		if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36042 			return *(*int32)(unsafe.Pointer(bp + 24))
  36043 		}
  36044 
  36045 		if *(*Pgno)(unsafe.Pointer(bp + 8)) != *(*Pgno)(unsafe.Pointer(bp)) {
  36046 			*(*U8)(unsafe.Pointer(bp + 16)) = U8(0)
  36047 			*(*Pgno)(unsafe.Pointer(bp + 20)) = Pgno(0)
  36048 
  36049 			*(*int32)(unsafe.Pointer(bp + 24)) = saveAllCursors(tls, pBt, uint32(0), uintptr(0))
  36050 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
  36051 			if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36052 				return *(*int32)(unsafe.Pointer(bp + 24))
  36053 			}
  36054 
  36055 			*(*int32)(unsafe.Pointer(bp + 24)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp)), bp+12, 0)
  36056 			if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36057 				return *(*int32)(unsafe.Pointer(bp + 24))
  36058 			}
  36059 			*(*int32)(unsafe.Pointer(bp + 24)) = ptrmapGet(tls, pBt, *(*Pgno)(unsafe.Pointer(bp)), bp+16, bp+20)
  36060 			if int32(*(*U8)(unsafe.Pointer(bp + 16))) == PTRMAP_ROOTPAGE || int32(*(*U8)(unsafe.Pointer(bp + 16))) == PTRMAP_FREEPAGE {
  36061 				*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3CorruptError(tls, 78166)
  36062 			}
  36063 			if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36064 				releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36065 				return *(*int32)(unsafe.Pointer(bp + 24))
  36066 			}
  36067 
  36068 			*(*int32)(unsafe.Pointer(bp + 24)) = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 12)), *(*U8)(unsafe.Pointer(bp + 16)), *(*Pgno)(unsafe.Pointer(bp + 20)), *(*Pgno)(unsafe.Pointer(bp + 8)), 0)
  36069 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36070 
  36071 			if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36072 				return *(*int32)(unsafe.Pointer(bp + 24))
  36073 			}
  36074 			*(*int32)(unsafe.Pointer(bp + 24)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp)), bp+12, 0)
  36075 			if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36076 				return *(*int32)(unsafe.Pointer(bp + 24))
  36077 			}
  36078 			*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FpDbPage)
  36079 			if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
  36080 				releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36081 				return *(*int32)(unsafe.Pointer(bp + 24))
  36082 			}
  36083 		} else {
  36084 			*(*uintptr)(unsafe.Pointer(bp + 12)) = *(*uintptr)(unsafe.Pointer(bp + 4))
  36085 		}
  36086 
  36087 		ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp)), uint8(PTRMAP_ROOTPAGE), uint32(0), bp+24)
  36088 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  36089 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36090 			return *(*int32)(unsafe.Pointer(bp + 24))
  36091 		}
  36092 
  36093 		*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3BtreeUpdateMeta(tls, p, 4, *(*Pgno)(unsafe.Pointer(bp)))
  36094 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  36095 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36096 			return *(*int32)(unsafe.Pointer(bp + 24))
  36097 		}
  36098 
  36099 	} else {
  36100 		*(*int32)(unsafe.Pointer(bp + 24)) = allocateBtreePage(tls, pBt, bp+12, bp, uint32(1), uint8(0))
  36101 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
  36102 			return *(*int32)(unsafe.Pointer(bp + 24))
  36103 		}
  36104 	}
  36105 
  36106 	if createTabFlags&BTREE_INTKEY != 0 {
  36107 		ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF
  36108 	} else {
  36109 		ptfFlags = PTF_ZERODATA | PTF_LEAF
  36110 	}
  36111 	zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), ptfFlags)
  36112 	Xsqlite3PagerUnref(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FpDbPage)
  36113 
  36114 	*(*Pgno)(unsafe.Pointer(piTable)) = *(*Pgno)(unsafe.Pointer(bp))
  36115 	return SQLITE_OK
  36116 }
  36117 
  36118 func Xsqlite3BtreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, flags int32) int32 {
  36119 	var rc int32
  36120 	Xsqlite3BtreeEnter(tls, p)
  36121 	rc = btreeCreateTable(tls, p, piTable, flags)
  36122 	Xsqlite3BtreeLeave(tls, p)
  36123 	return rc
  36124 }
  36125 
  36126 func clearDatabasePage(tls *libc.TLS, pBt uintptr, pgno Pgno, freePageFlag int32, pnChange uintptr) int32 {
  36127 	bp := tls.Alloc(36)
  36128 	defer tls.Free(36)
  36129 
  36130 	var pCell uintptr
  36131 	var i int32
  36132 	var hdr int32
  36133 
  36134 	if !(pgno > btreePagecount(tls, pBt)) {
  36135 		goto __1
  36136 	}
  36137 	return Xsqlite3CorruptError(tls, 78256)
  36138 __1:
  36139 	;
  36140 	*(*int32)(unsafe.Pointer(bp + 32)) = getAndInitPage(tls, pBt, pgno, bp, uintptr(0), 0)
  36141 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) {
  36142 		goto __2
  36143 	}
  36144 	return *(*int32)(unsafe.Pointer(bp + 32))
  36145 __2:
  36146 	;
  36147 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FopenFlags)&BTREE_SINGLE == 0 &&
  36148 		Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage) != 1+libc.Bool32(pgno == Pgno(1))) {
  36149 		goto __3
  36150 	}
  36151 	*(*int32)(unsafe.Pointer(bp + 32)) = Xsqlite3CorruptError(tls, 78263)
  36152 	goto cleardatabasepage_out
  36153 __3:
  36154 	;
  36155 	hdr = int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FhdrOffset)
  36156 	i = 0
  36157 __4:
  36158 	if !(i < int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnCell)) {
  36159 		goto __6
  36160 	}
  36161 	pCell = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData + uintptr(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaCellIdx + uintptr(2*i))))))
  36162 	if !!(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fleaf) != 0) {
  36163 		goto __7
  36164 	}
  36165 	*(*int32)(unsafe.Pointer(bp + 32)) = clearDatabasePage(tls, pBt, Xsqlite3Get4byte(tls, pCell), 1, pnChange)
  36166 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) {
  36167 		goto __8
  36168 	}
  36169 	goto cleardatabasepage_out
  36170 __8:
  36171 	;
  36172 __7:
  36173 	;
  36174 	(*struct {
  36175 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  36176 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FxParseCell})).f(tls, *(*uintptr)(unsafe.Pointer(bp)), pCell, bp+8)
  36177 	if !(U32((*CellInfo)(unsafe.Pointer(bp+8)).FnLocal) != (*CellInfo)(unsafe.Pointer(bp+8)).FnPayload) {
  36178 		goto __9
  36179 	}
  36180 	*(*int32)(unsafe.Pointer(bp + 32)) = clearCellOverflow(tls, *(*uintptr)(unsafe.Pointer(bp)), pCell, bp+8)
  36181 	goto __10
  36182 __9:
  36183 	*(*int32)(unsafe.Pointer(bp + 32)) = SQLITE_OK
  36184 __10:
  36185 	;
  36186 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) {
  36187 		goto __11
  36188 	}
  36189 	goto cleardatabasepage_out
  36190 __11:
  36191 	;
  36192 	goto __5
  36193 __5:
  36194 	i++
  36195 	goto __4
  36196 	goto __6
  36197 __6:
  36198 	;
  36199 	if !!(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fleaf) != 0) {
  36200 		goto __12
  36201 	}
  36202 	*(*int32)(unsafe.Pointer(bp + 32)) = clearDatabasePage(tls, pBt, Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData+uintptr(hdr+8)), 1, pnChange)
  36203 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) {
  36204 		goto __13
  36205 	}
  36206 	goto cleardatabasepage_out
  36207 __13:
  36208 	;
  36209 	if !((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FintKey != 0) {
  36210 		goto __14
  36211 	}
  36212 	pnChange = uintptr(0)
  36213 __14:
  36214 	;
  36215 __12:
  36216 	;
  36217 	if !(pnChange != 0) {
  36218 		goto __15
  36219 	}
  36220 
  36221 	*(*I64)(unsafe.Pointer(pnChange)) += I64((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnCell)
  36222 __15:
  36223 	;
  36224 	if !(freePageFlag != 0) {
  36225 		goto __16
  36226 	}
  36227 	freePage(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+32)
  36228 	goto __17
  36229 __16:
  36230 	if !(libc.AssignPtrInt32(bp+32, Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpDbPage)) == 0) {
  36231 		goto __18
  36232 	}
  36233 	zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp)), int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaData + uintptr(hdr))))|PTF_LEAF)
  36234 __18:
  36235 	;
  36236 __17:
  36237 	;
  36238 cleardatabasepage_out:
  36239 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  36240 	return *(*int32)(unsafe.Pointer(bp + 32))
  36241 }
  36242 
  36243 // Delete all information from a single table in the database.  iTable is
  36244 // the page number of the root of the table.  After this routine returns,
  36245 // the root page is empty, but still exists.
  36246 //
  36247 // This routine will fail with SQLITE_LOCKED if there are any open
  36248 // read cursors on the table.  Open write cursors are moved to the
  36249 // root of the table.
  36250 //
  36251 // If pnChange is not NULL, then the integer value pointed to by pnChange
  36252 // is incremented by the number of entries in the table.
  36253 func Xsqlite3BtreeClearTable(tls *libc.TLS, p uintptr, iTable int32, pnChange uintptr) int32 {
  36254 	var rc int32
  36255 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  36256 	Xsqlite3BtreeEnter(tls, p)
  36257 
  36258 	rc = saveAllCursors(tls, pBt, Pgno(iTable), uintptr(0))
  36259 
  36260 	if SQLITE_OK == rc {
  36261 		if (*Btree)(unsafe.Pointer(p)).FhasIncrblobCur != 0 {
  36262 			invalidateIncrblobCursors(tls, p, Pgno(iTable), int64(0), 1)
  36263 		}
  36264 		rc = clearDatabasePage(tls, pBt, Pgno(iTable), 0, pnChange)
  36265 	}
  36266 	Xsqlite3BtreeLeave(tls, p)
  36267 	return rc
  36268 }
  36269 
  36270 // Delete all information from the single table that pCur is open on.
  36271 //
  36272 // This routine only work for pCur on an ephemeral table.
  36273 func Xsqlite3BtreeClearTableOfCursor(tls *libc.TLS, pCur uintptr) int32 {
  36274 	return Xsqlite3BtreeClearTable(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree, int32((*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot), uintptr(0))
  36275 }
  36276 
  36277 func btreeDropTable(tls *libc.TLS, p uintptr, iTable Pgno, piMoved uintptr) int32 {
  36278 	bp := tls.Alloc(16)
  36279 	defer tls.Free(16)
  36280 
  36281 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  36282 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  36283 
  36284 	if iTable > btreePagecount(tls, pBt) {
  36285 		return Xsqlite3CorruptError(tls, 78367)
  36286 	}
  36287 
  36288 	*(*int32)(unsafe.Pointer(bp + 8)) = Xsqlite3BtreeClearTable(tls, p, int32(iTable), uintptr(0))
  36289 	if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
  36290 		return *(*int32)(unsafe.Pointer(bp + 8))
  36291 	}
  36292 	*(*int32)(unsafe.Pointer(bp + 8)) = btreeGetPage(tls, pBt, iTable, bp, 0)
  36293 	if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
  36294 		releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  36295 		return *(*int32)(unsafe.Pointer(bp + 8))
  36296 	}
  36297 
  36298 	*(*int32)(unsafe.Pointer(piMoved)) = 0
  36299 
  36300 	if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 {
  36301 		Xsqlite3BtreeGetMeta(tls, p, BTREE_LARGEST_ROOT_PAGE, bp+4)
  36302 
  36303 		if iTable == *(*Pgno)(unsafe.Pointer(bp + 4)) {
  36304 			freePage(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+8)
  36305 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  36306 			if *(*int32)(unsafe.Pointer(bp + 8)) != SQLITE_OK {
  36307 				return *(*int32)(unsafe.Pointer(bp + 8))
  36308 			}
  36309 		} else {
  36310 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  36311 			*(*int32)(unsafe.Pointer(bp + 8)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4)), bp+12, 0)
  36312 			if *(*int32)(unsafe.Pointer(bp + 8)) != SQLITE_OK {
  36313 				return *(*int32)(unsafe.Pointer(bp + 8))
  36314 			}
  36315 			*(*int32)(unsafe.Pointer(bp + 8)) = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 12)), uint8(PTRMAP_ROOTPAGE), uint32(0), iTable, 0)
  36316 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36317 			if *(*int32)(unsafe.Pointer(bp + 8)) != SQLITE_OK {
  36318 				return *(*int32)(unsafe.Pointer(bp + 8))
  36319 			}
  36320 			*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
  36321 			*(*int32)(unsafe.Pointer(bp + 8)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4)), bp+12, 0)
  36322 			freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), bp+8)
  36323 			releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  36324 			if *(*int32)(unsafe.Pointer(bp + 8)) != SQLITE_OK {
  36325 				return *(*int32)(unsafe.Pointer(bp + 8))
  36326 			}
  36327 			*(*int32)(unsafe.Pointer(piMoved)) = int32(*(*Pgno)(unsafe.Pointer(bp + 4)))
  36328 		}
  36329 
  36330 		*(*Pgno)(unsafe.Pointer(bp + 4))--
  36331 		for *(*Pgno)(unsafe.Pointer(bp + 4)) == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize+U32(1) ||
  36332 			ptrmapPageno(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 4))) == *(*Pgno)(unsafe.Pointer(bp + 4)) {
  36333 			*(*Pgno)(unsafe.Pointer(bp + 4))--
  36334 		}
  36335 
  36336 		*(*int32)(unsafe.Pointer(bp + 8)) = Xsqlite3BtreeUpdateMeta(tls, p, 4, *(*Pgno)(unsafe.Pointer(bp + 4)))
  36337 	} else {
  36338 		freePage(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+8)
  36339 		releasePage(tls, *(*uintptr)(unsafe.Pointer(bp)))
  36340 	}
  36341 	return *(*int32)(unsafe.Pointer(bp + 8))
  36342 }
  36343 
  36344 func Xsqlite3BtreeDropTable(tls *libc.TLS, p uintptr, iTable int32, piMoved uintptr) int32 {
  36345 	var rc int32
  36346 	Xsqlite3BtreeEnter(tls, p)
  36347 	rc = btreeDropTable(tls, p, uint32(iTable), piMoved)
  36348 	Xsqlite3BtreeLeave(tls, p)
  36349 	return rc
  36350 }
  36351 
  36352 // This function may only be called if the b-tree connection already
  36353 // has a read or write transaction open on the database.
  36354 //
  36355 // Read the meta-information out of a database file.  Meta[0]
  36356 // is the number of free pages currently in the database.  Meta[1]
  36357 // through meta[15] are available for use by higher layers.  Meta[0]
  36358 // is read-only, the others are read/write.
  36359 //
  36360 // The schema layer numbers meta values differently.  At the schema
  36361 // layer (and the SetCookie and ReadCookie opcodes) the number of
  36362 // free pages is not visible.  So Cookie[0] is the same as Meta[1].
  36363 //
  36364 // This routine treats Meta[BTREE_DATA_VERSION] as a special case.  Instead
  36365 // of reading the value out of the header, it instead loads the "DataVersion"
  36366 // from the pager.  The BTREE_DATA_VERSION value is not actually stored in the
  36367 // database file.  It is a number computed by the pager.  But its access
  36368 // pattern is the same as header meta values, and so it is convenient to
  36369 // read it from this routine.
  36370 func Xsqlite3BtreeGetMeta(tls *libc.TLS, p uintptr, idx int32, pMeta uintptr) {
  36371 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  36372 
  36373 	Xsqlite3BtreeEnter(tls, p)
  36374 
  36375 	if idx == BTREE_DATA_VERSION {
  36376 		*(*U32)(unsafe.Pointer(pMeta)) = Xsqlite3PagerDataVersion(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) + (*Btree)(unsafe.Pointer(p)).FiBDataVersion
  36377 	} else {
  36378 		*(*U32)(unsafe.Pointer(pMeta)) = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(36+idx*4))
  36379 	}
  36380 
  36381 	Xsqlite3BtreeLeave(tls, p)
  36382 }
  36383 
  36384 // Write meta-information back into the database.  Meta[0] is
  36385 // read-only and may not be written.
  36386 func Xsqlite3BtreeUpdateMeta(tls *libc.TLS, p uintptr, idx int32, iMeta U32) int32 {
  36387 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  36388 	var pP1 uintptr
  36389 	var rc int32
  36390 
  36391 	Xsqlite3BtreeEnter(tls, p)
  36392 
  36393 	pP1 = (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData
  36394 	rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
  36395 	if rc == SQLITE_OK {
  36396 		Xsqlite3Put4byte(tls, pP1+uintptr(36+idx*4), iMeta)
  36397 		if idx == BTREE_INCR_VACUUM {
  36398 			(*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = U8(iMeta)
  36399 		}
  36400 	}
  36401 	Xsqlite3BtreeLeave(tls, p)
  36402 	return rc
  36403 }
  36404 
  36405 // The first argument, pCur, is a cursor opened on some b-tree. Count the
  36406 // number of entries in the b-tree and write the result to *pnEntry.
  36407 //
  36408 // SQLITE_OK is returned if the operation is successfully executed.
  36409 // Otherwise, if an error is encountered (i.e. an IO error or database
  36410 // corruption) an SQLite error code is returned.
  36411 func Xsqlite3BtreeCount(tls *libc.TLS, db uintptr, pCur uintptr, pnEntry uintptr) int32 {
  36412 	var nEntry I64 = int64(0)
  36413 	var rc int32
  36414 
  36415 	rc = moveToRoot(tls, pCur)
  36416 	if rc == SQLITE_EMPTY {
  36417 		*(*I64)(unsafe.Pointer(pnEntry)) = int64(0)
  36418 		return SQLITE_OK
  36419 	}
  36420 
  36421 	for rc == SQLITE_OK && !(libc.AtomicLoadNInt32(db+312, 0) != 0) {
  36422 		var iIdx int32
  36423 		var pPage uintptr
  36424 
  36425 		pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  36426 		if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 || !(int32((*MemPage)(unsafe.Pointer(pPage)).FintKey) != 0) {
  36427 			nEntry = nEntry + I64((*MemPage)(unsafe.Pointer(pPage)).FnCell)
  36428 		}
  36429 
  36430 		if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 {
  36431 			for __ccgo := true; __ccgo; __ccgo = int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) >= int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnCell) {
  36432 				if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 {
  36433 					*(*I64)(unsafe.Pointer(pnEntry)) = nEntry
  36434 					return moveToRoot(tls, pCur)
  36435 				}
  36436 				moveToParent(tls, pCur)
  36437 			}
  36438 
  36439 			(*BtCursor)(unsafe.Pointer(pCur)).Fix++
  36440 			pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage
  36441 		}
  36442 
  36443 		iIdx = int32((*BtCursor)(unsafe.Pointer(pCur)).Fix)
  36444 		if iIdx == int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) {
  36445 			rc = moveToChild(tls, pCur, Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)))
  36446 		} else {
  36447 			rc = moveToChild(tls, pCur, Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr(int32((*MemPage)(unsafe.Pointer(pPage)).FmaskPage)&int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr(2*iIdx))))))))
  36448 		}
  36449 	}
  36450 
  36451 	return rc
  36452 }
  36453 
  36454 // Return the pager associated with a BTree.  This routine is used for
  36455 // testing and debugging only.
  36456 func Xsqlite3BtreePager(tls *libc.TLS, p uintptr) uintptr {
  36457 	return (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpPager
  36458 }
  36459 
  36460 func checkOom(tls *libc.TLS, pCheck uintptr) {
  36461 	(*IntegrityCk)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM
  36462 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0
  36463 	if (*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr == 0 {
  36464 		(*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr++
  36465 	}
  36466 }
  36467 
  36468 func checkProgress(tls *libc.TLS, pCheck uintptr) {
  36469 	var db uintptr = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fdb
  36470 	if libc.AtomicLoadNInt32(db+312, 0) != 0 {
  36471 		(*IntegrityCk)(unsafe.Pointer(pCheck)).Frc = SQLITE_INTERRUPT
  36472 		(*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr++
  36473 		(*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0
  36474 	}
  36475 	if (*Sqlite3)(unsafe.Pointer(db)).FxProgress != 0 {
  36476 		(*IntegrityCk)(unsafe.Pointer(pCheck)).FnStep++
  36477 		if (*IntegrityCk)(unsafe.Pointer(pCheck)).FnStep%(*Sqlite3)(unsafe.Pointer(db)).FnProgressOps == U32(0) &&
  36478 			(*struct {
  36479 				f func(*libc.TLS, uintptr) int32
  36480 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxProgress})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 {
  36481 			(*IntegrityCk)(unsafe.Pointer(pCheck)).Frc = SQLITE_INTERRUPT
  36482 			(*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr++
  36483 			(*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0
  36484 		}
  36485 	}
  36486 }
  36487 
  36488 func checkAppendMsg(tls *libc.TLS, pCheck uintptr, zFormat uintptr, va uintptr) {
  36489 	bp := tls.Alloc(16)
  36490 	defer tls.Free(16)
  36491 
  36492 	var ap Va_list
  36493 	_ = ap
  36494 	checkProgress(tls, pCheck)
  36495 	if !((*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0) {
  36496 		return
  36497 	}
  36498 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr--
  36499 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr++
  36500 	ap = va
  36501 	if (*IntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FnChar != 0 {
  36502 		Xsqlite3_str_append(tls, pCheck+44, ts+4062, 1)
  36503 	}
  36504 	if (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx != 0 {
  36505 		Xsqlite3_str_appendf(tls, pCheck+44, (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx, libc.VaList(bp, (*IntegrityCk)(unsafe.Pointer(pCheck)).Fv1, (*IntegrityCk)(unsafe.Pointer(pCheck)).Fv2))
  36506 	}
  36507 	Xsqlite3_str_vappendf(tls, pCheck+44, zFormat, ap)
  36508 	_ = ap
  36509 	if int32((*IntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == SQLITE_NOMEM {
  36510 		checkOom(tls, pCheck)
  36511 	}
  36512 }
  36513 
  36514 func getPageReferenced(tls *libc.TLS, pCheck uintptr, iPg Pgno) int32 {
  36515 	return int32(*(*U8)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FaPgRef + uintptr(iPg/Pgno(8))))) & (int32(1) << (iPg & Pgno(0x07)))
  36516 }
  36517 
  36518 func setPageReferenced(tls *libc.TLS, pCheck uintptr, iPg Pgno) {
  36519 	*(*U8)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FaPgRef + uintptr(iPg/Pgno(8)))) |= U8(int32(1) << (iPg & Pgno(0x07)))
  36520 }
  36521 
  36522 func checkRef(tls *libc.TLS, pCheck uintptr, iPage Pgno) int32 {
  36523 	bp := tls.Alloc(16)
  36524 	defer tls.Free(16)
  36525 
  36526 	if iPage > (*IntegrityCk)(unsafe.Pointer(pCheck)).FnPage || iPage == Pgno(0) {
  36527 		checkAppendMsg(tls, pCheck, ts+4064, libc.VaList(bp, iPage))
  36528 		return 1
  36529 	}
  36530 	if getPageReferenced(tls, pCheck, iPage) != 0 {
  36531 		checkAppendMsg(tls, pCheck, ts+4087, libc.VaList(bp+8, iPage))
  36532 		return 1
  36533 	}
  36534 	setPageReferenced(tls, pCheck, iPage)
  36535 	return 0
  36536 }
  36537 
  36538 func checkPtrmap(tls *libc.TLS, pCheck uintptr, iChild Pgno, eType U8, iParent Pgno) {
  36539 	bp := tls.Alloc(56)
  36540 	defer tls.Free(56)
  36541 
  36542 	var rc int32
  36543 
  36544 	rc = ptrmapGet(tls, (*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt, iChild, bp+48, bp+52)
  36545 	if rc != SQLITE_OK {
  36546 		if rc == SQLITE_NOMEM || rc == SQLITE_IOERR|int32(12)<<8 {
  36547 			checkOom(tls, pCheck)
  36548 		}
  36549 		checkAppendMsg(tls, pCheck, ts+4112, libc.VaList(bp, iChild))
  36550 		return
  36551 	}
  36552 
  36553 	if int32(*(*U8)(unsafe.Pointer(bp + 48))) != int32(eType) || *(*Pgno)(unsafe.Pointer(bp + 52)) != iParent {
  36554 		checkAppendMsg(tls, pCheck,
  36555 			ts+4141,
  36556 			libc.VaList(bp+8, iChild, int32(eType), iParent, int32(*(*U8)(unsafe.Pointer(bp + 48))), *(*Pgno)(unsafe.Pointer(bp + 52))))
  36557 	}
  36558 }
  36559 
  36560 func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U32) {
  36561 	bp := tls.Alloc(44)
  36562 	defer tls.Free(44)
  36563 
  36564 	var i int32
  36565 	var expected U32 = N
  36566 	var nErrAtStart int32 = (*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr
  36567 	for iPage != Pgno(0) && (*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0 {
  36568 		var pOvflData uintptr
  36569 		if checkRef(tls, pCheck, iPage) != 0 {
  36570 			break
  36571 		}
  36572 		N--
  36573 		if Xsqlite3PagerGet(tls, (*IntegrityCk)(unsafe.Pointer(pCheck)).FpPager, iPage, bp+40, 0) != 0 {
  36574 			checkAppendMsg(tls, pCheck, ts+4195, libc.VaList(bp, iPage))
  36575 			break
  36576 		}
  36577 		pOvflData = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 40)))
  36578 		if isFreeList != 0 {
  36579 			var n U32 = Xsqlite3Get4byte(tls, pOvflData+4)
  36580 			if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 {
  36581 				checkPtrmap(tls, pCheck, iPage, uint8(PTRMAP_FREEPAGE), uint32(0))
  36582 			}
  36583 			if n > (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FusableSize/U32(4)-U32(2) {
  36584 				checkAppendMsg(tls, pCheck,
  36585 					ts+4217, libc.VaList(bp+8, iPage))
  36586 				N--
  36587 			} else {
  36588 				for i = 0; i < int32(n); i++ {
  36589 					var iFreePage Pgno = Xsqlite3Get4byte(tls, pOvflData+uintptr(8+i*4))
  36590 					if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 {
  36591 						checkPtrmap(tls, pCheck, iFreePage, uint8(PTRMAP_FREEPAGE), uint32(0))
  36592 					}
  36593 					checkRef(tls, pCheck, iFreePage)
  36594 				}
  36595 				N = N - n
  36596 			}
  36597 		} else {
  36598 			if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 && N > U32(0) {
  36599 				i = int32(Xsqlite3Get4byte(tls, pOvflData))
  36600 				checkPtrmap(tls, pCheck, uint32(i), uint8(PTRMAP_OVERFLOW2), iPage)
  36601 			}
  36602 		}
  36603 		iPage = Xsqlite3Get4byte(tls, pOvflData)
  36604 		Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 40)))
  36605 	}
  36606 	if N != 0 && nErrAtStart == (*IntegrityCk)(unsafe.Pointer(pCheck)).FnErr {
  36607 		checkAppendMsg(tls, pCheck,
  36608 			ts+4256,
  36609 			libc.VaList(bp+16, func() uintptr {
  36610 				if isFreeList != 0 {
  36611 					return ts + 4282
  36612 				}
  36613 				return ts + 4287
  36614 			}(),
  36615 				expected-N, expected))
  36616 	}
  36617 }
  36618 
  36619 func btreeHeapInsert(tls *libc.TLS, aHeap uintptr, x U32) {
  36620 	var j U32
  36621 	var i U32
  36622 
  36623 	i = libc.PreIncUint32(&*(*U32)(unsafe.Pointer(aHeap)), 1)
  36624 	*(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) = x
  36625 	for libc.AssignUint32(&j, i/U32(2)) > U32(0) && *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) > *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) {
  36626 		x = *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4))
  36627 		*(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4))
  36628 		*(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) = x
  36629 		i = j
  36630 	}
  36631 }
  36632 
  36633 func btreeHeapPull(tls *libc.TLS, aHeap uintptr, pOut uintptr) int32 {
  36634 	var j U32
  36635 	var i U32
  36636 	var x U32
  36637 	if libc.AssignUint32(&x, *(*U32)(unsafe.Pointer(aHeap))) == U32(0) {
  36638 		return 0
  36639 	}
  36640 	*(*U32)(unsafe.Pointer(pOut)) = *(*U32)(unsafe.Pointer(aHeap + 1*4))
  36641 	*(*U32)(unsafe.Pointer(aHeap + 1*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4))
  36642 	*(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) = 0xffffffff
  36643 	*(*U32)(unsafe.Pointer(aHeap))--
  36644 	i = U32(1)
  36645 	for libc.AssignUint32(&j, i*U32(2)) <= *(*U32)(unsafe.Pointer(aHeap)) {
  36646 		if *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) > *(*U32)(unsafe.Pointer(aHeap + uintptr(j+U32(1))*4)) {
  36647 			j++
  36648 		}
  36649 		if *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) < *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) {
  36650 			break
  36651 		}
  36652 		x = *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4))
  36653 		*(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4))
  36654 		*(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) = x
  36655 		i = j
  36656 	}
  36657 	return 1
  36658 }
  36659 
  36660 func checkTreePage(tls *libc.TLS, pCheck uintptr, iPage Pgno, piMinKey uintptr, maxKey I64) int32 {
  36661 	bp := tls.Alloc(140)
  36662 	defer tls.Free(140)
  36663 	*(*I64)(unsafe.Pointer(bp + 104)) = maxKey
  36664 
  36665 	var i int32
  36666 	var rc int32
  36667 	var depth int32
  36668 	var d2 int32
  36669 	var pgno int32
  36670 	var nFrag int32
  36671 	var hdr int32
  36672 	var cellStart int32
  36673 	var nCell int32
  36674 	var doCoverageCheck int32
  36675 	var keyCanBeEqual int32
  36676 
  36677 	var data uintptr
  36678 	var pCell uintptr
  36679 	var pCellIdx uintptr
  36680 	var pBt uintptr
  36681 	var pc U32
  36682 	var usableSize U32
  36683 	var contentOffset U32
  36684 	var heap uintptr
  36685 
  36686 	var prev U32
  36687 	var saved_zPfx uintptr
  36688 	var saved_v1 int32
  36689 	var saved_v2 int32
  36690 	var savedIsInit U8
  36691 	var nPage U32
  36692 	var pgnoOvfl Pgno
  36693 
  36694 	var size U32
  36695 	var size1 int32
  36696 	var j int32
  36697 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  36698 	depth = -1
  36699 	doCoverageCheck = 1
  36700 	keyCanBeEqual = 1
  36701 	heap = uintptr(0)
  36702 	prev = U32(0)
  36703 	saved_zPfx = (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx
  36704 	saved_v1 = int32((*IntegrityCk)(unsafe.Pointer(pCheck)).Fv1)
  36705 	saved_v2 = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fv2
  36706 	savedIsInit = U8(0)
  36707 
  36708 	checkProgress(tls, pCheck)
  36709 	if !((*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr == 0) {
  36710 		goto __1
  36711 	}
  36712 	goto end_of_check
  36713 __1:
  36714 	;
  36715 	pBt = (*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt
  36716 	usableSize = (*BtShared)(unsafe.Pointer(pBt)).FusableSize
  36717 	if !(iPage == Pgno(0)) {
  36718 		goto __2
  36719 	}
  36720 	return 0
  36721 __2:
  36722 	;
  36723 	if !(checkRef(tls, pCheck, iPage) != 0) {
  36724 		goto __3
  36725 	}
  36726 	return 0
  36727 __3:
  36728 	;
  36729 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 4308
  36730 	(*IntegrityCk)(unsafe.Pointer(pCheck)).Fv1 = iPage
  36731 	if !(libc.AssignInt32(&rc, btreeGetPage(tls, pBt, iPage, bp+96, 0)) != 0) {
  36732 		goto __4
  36733 	}
  36734 	checkAppendMsg(tls, pCheck,
  36735 		ts+4318, libc.VaList(bp, rc))
  36736 	goto end_of_check
  36737 __4:
  36738 	;
  36739 	savedIsInit = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FisInit
  36740 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FisInit = U8(0)
  36741 	if !(libc.AssignInt32(&rc, btreeInitPage(tls, *(*uintptr)(unsafe.Pointer(bp + 96)))) != 0) {
  36742 		goto __5
  36743 	}
  36744 
  36745 	checkAppendMsg(tls, pCheck,
  36746 		ts+4356, libc.VaList(bp+8, rc))
  36747 	goto end_of_check
  36748 __5:
  36749 	;
  36750 	if !(libc.AssignInt32(&rc, btreeComputeFreeSpace(tls, *(*uintptr)(unsafe.Pointer(bp + 96)))) != 0) {
  36751 		goto __6
  36752 	}
  36753 
  36754 	checkAppendMsg(tls, pCheck, ts+4394, libc.VaList(bp+16, rc))
  36755 	goto end_of_check
  36756 __6:
  36757 	;
  36758 	data = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FaData
  36759 	hdr = int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FhdrOffset)
  36760 
  36761 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 4416
  36762 	contentOffset = U32((int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+5))))<<8|int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+5) + 1)))-1)&0xffff + 1)
  36763 
  36764 	nCell = int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+3))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+3) + 1)))
  36765 
  36766 	cellStart = hdr + 12 - 4*int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).Fleaf)
  36767 
  36768 	pCellIdx = data + uintptr(cellStart+2*(nCell-1))
  36769 
  36770 	if !!(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).Fleaf) != 0) {
  36771 		goto __7
  36772 	}
  36773 
  36774 	pgno = int32(Xsqlite3Get4byte(tls, data+uintptr(hdr+8)))
  36775 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  36776 		goto __9
  36777 	}
  36778 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 4442
  36779 	checkPtrmap(tls, pCheck, uint32(pgno), uint8(PTRMAP_BTREE), iPage)
  36780 __9:
  36781 	;
  36782 	depth = checkTreePage(tls, pCheck, uint32(pgno), bp+104, *(*I64)(unsafe.Pointer(bp + 104)))
  36783 	keyCanBeEqual = 0
  36784 	goto __8
  36785 __7:
  36786 	heap = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fheap
  36787 	*(*U32)(unsafe.Pointer(heap)) = U32(0)
  36788 __8:
  36789 	;
  36790 	i = nCell - 1
  36791 __10:
  36792 	if !(i >= 0 && (*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0) {
  36793 		goto __12
  36794 	}
  36795 
  36796 	(*IntegrityCk)(unsafe.Pointer(pCheck)).Fv2 = i
  36797 
  36798 	pc = U32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(pCellIdx))))
  36799 	pCellIdx -= uintptr(2)
  36800 	if !(pc < contentOffset || pc > usableSize-U32(4)) {
  36801 		goto __13
  36802 	}
  36803 	checkAppendMsg(tls, pCheck, ts+4470,
  36804 		libc.VaList(bp+24, pc, contentOffset, usableSize-U32(4)))
  36805 	doCoverageCheck = 0
  36806 	goto __11
  36807 __13:
  36808 	;
  36809 	pCell = data + uintptr(pc)
  36810 	(*struct {
  36811 		f func(*libc.TLS, uintptr, uintptr, uintptr)
  36812 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FxParseCell})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 96)), pCell, bp+112)
  36813 	if !(pc+U32((*CellInfo)(unsafe.Pointer(bp+112)).FnSize) > usableSize) {
  36814 		goto __14
  36815 	}
  36816 	checkAppendMsg(tls, pCheck, ts+4500, 0)
  36817 	doCoverageCheck = 0
  36818 	goto __11
  36819 __14:
  36820 	;
  36821 	if !((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FintKey != 0) {
  36822 		goto __15
  36823 	}
  36824 	if !(func() int32 {
  36825 		if keyCanBeEqual != 0 {
  36826 			return libc.Bool32((*CellInfo)(unsafe.Pointer(bp+112)).FnKey > *(*I64)(unsafe.Pointer(bp + 104)))
  36827 		}
  36828 		return libc.Bool32((*CellInfo)(unsafe.Pointer(bp+112)).FnKey >= *(*I64)(unsafe.Pointer(bp + 104)))
  36829 	}() != 0) {
  36830 		goto __16
  36831 	}
  36832 	checkAppendMsg(tls, pCheck, ts+4524, libc.VaList(bp+48, (*CellInfo)(unsafe.Pointer(bp+112)).FnKey))
  36833 __16:
  36834 	;
  36835 	*(*I64)(unsafe.Pointer(bp + 104)) = (*CellInfo)(unsafe.Pointer(bp + 112)).FnKey
  36836 	keyCanBeEqual = 0
  36837 __15:
  36838 	;
  36839 	if !((*CellInfo)(unsafe.Pointer(bp+112)).FnPayload > U32((*CellInfo)(unsafe.Pointer(bp+112)).FnLocal)) {
  36840 		goto __17
  36841 	}
  36842 
  36843 	nPage = ((*CellInfo)(unsafe.Pointer(bp+112)).FnPayload - U32((*CellInfo)(unsafe.Pointer(bp+112)).FnLocal) + usableSize - U32(5)) / (usableSize - U32(4))
  36844 	pgnoOvfl = Xsqlite3Get4byte(tls, pCell+uintptr(int32((*CellInfo)(unsafe.Pointer(bp+112)).FnSize)-4))
  36845 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  36846 		goto __18
  36847 	}
  36848 	checkPtrmap(tls, pCheck, pgnoOvfl, uint8(PTRMAP_OVERFLOW1), iPage)
  36849 __18:
  36850 	;
  36851 	checkList(tls, pCheck, 0, pgnoOvfl, nPage)
  36852 __17:
  36853 	;
  36854 	if !!(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).Fleaf) != 0) {
  36855 		goto __19
  36856 	}
  36857 
  36858 	pgno = int32(Xsqlite3Get4byte(tls, pCell))
  36859 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  36860 		goto __21
  36861 	}
  36862 	checkPtrmap(tls, pCheck, uint32(pgno), uint8(PTRMAP_BTREE), iPage)
  36863 __21:
  36864 	;
  36865 	d2 = checkTreePage(tls, pCheck, uint32(pgno), bp+104, *(*I64)(unsafe.Pointer(bp + 104)))
  36866 	keyCanBeEqual = 0
  36867 	if !(d2 != depth) {
  36868 		goto __22
  36869 	}
  36870 	checkAppendMsg(tls, pCheck, ts+4548, 0)
  36871 	depth = d2
  36872 __22:
  36873 	;
  36874 	goto __20
  36875 __19:
  36876 	btreeHeapInsert(tls, heap, pc<<16|(pc+U32((*CellInfo)(unsafe.Pointer(bp+112)).FnSize)-U32(1)))
  36877 __20:
  36878 	;
  36879 	goto __11
  36880 __11:
  36881 	i--
  36882 	goto __10
  36883 	goto __12
  36884 __12:
  36885 	;
  36886 	*(*I64)(unsafe.Pointer(piMinKey)) = *(*I64)(unsafe.Pointer(bp + 104))
  36887 
  36888 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = uintptr(0)
  36889 	if !(doCoverageCheck != 0 && (*IntegrityCk)(unsafe.Pointer(pCheck)).FmxErr > 0) {
  36890 		goto __23
  36891 	}
  36892 
  36893 	if !!(int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).Fleaf) != 0) {
  36894 		goto __24
  36895 	}
  36896 	heap = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fheap
  36897 	*(*U32)(unsafe.Pointer(heap)) = U32(0)
  36898 	i = nCell - 1
  36899 __25:
  36900 	if !(i >= 0) {
  36901 		goto __27
  36902 	}
  36903 	pc = U32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(data + uintptr(cellStart+i*2)))))
  36904 	size = U32((*struct {
  36905 		f func(*libc.TLS, uintptr, uintptr) U16
  36906 	})(unsafe.Pointer(&struct{ uintptr }{(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FxCellSize})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 96)), data+uintptr(pc)))
  36907 	btreeHeapInsert(tls, heap, pc<<16|(pc+size-U32(1)))
  36908 	goto __26
  36909 __26:
  36910 	i--
  36911 	goto __25
  36912 	goto __27
  36913 __27:
  36914 	;
  36915 __24:
  36916 	;
  36917 	i = int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+1))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+1) + 1)))
  36918 __28:
  36919 	if !(i > 0) {
  36920 		goto __29
  36921 	}
  36922 
  36923 	size1 = int32(*(*U8)(unsafe.Pointer(data + uintptr(i+2))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(i+2) + 1)))
  36924 
  36925 	btreeHeapInsert(tls, heap, U32(i)<<16|U32(i+size1-1))
  36926 
  36927 	j = int32(*(*U8)(unsafe.Pointer(data + uintptr(i))))<<8 | int32(*(*U8)(unsafe.Pointer(data + uintptr(i) + 1)))
  36928 
  36929 	i = j
  36930 	goto __28
  36931 __29:
  36932 	;
  36933 	nFrag = 0
  36934 	prev = contentOffset - U32(1)
  36935 __30:
  36936 	if !(btreeHeapPull(tls, heap, bp+136) != 0) {
  36937 		goto __31
  36938 	}
  36939 	if !(prev&U32(0xffff) >= *(*U32)(unsafe.Pointer(bp + 136))>>16) {
  36940 		goto __32
  36941 	}
  36942 	checkAppendMsg(tls, pCheck,
  36943 		ts+4573, libc.VaList(bp+56, *(*U32)(unsafe.Pointer(bp + 136))>>16, iPage))
  36944 	goto __31
  36945 	goto __33
  36946 __32:
  36947 	nFrag = int32(U32(nFrag) + (*(*U32)(unsafe.Pointer(bp + 136))>>16 - prev&U32(0xffff) - U32(1)))
  36948 	prev = *(*U32)(unsafe.Pointer(bp + 136))
  36949 __33:
  36950 	;
  36951 	goto __30
  36952 __31:
  36953 	;
  36954 	nFrag = int32(U32(nFrag) + (usableSize - prev&U32(0xffff) - U32(1)))
  36955 
  36956 	if !(*(*U32)(unsafe.Pointer(heap)) == U32(0) && nFrag != int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+7))))) {
  36957 		goto __34
  36958 	}
  36959 	checkAppendMsg(tls, pCheck,
  36960 		ts+4610,
  36961 		libc.VaList(bp+72, nFrag, int32(*(*U8)(unsafe.Pointer(data + uintptr(hdr+7)))), iPage))
  36962 __34:
  36963 	;
  36964 __23:
  36965 	;
  36966 end_of_check:
  36967 	if !!(doCoverageCheck != 0) {
  36968 		goto __35
  36969 	}
  36970 	(*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FisInit = savedIsInit
  36971 __35:
  36972 	;
  36973 	releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 96)))
  36974 	(*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = saved_zPfx
  36975 	(*IntegrityCk)(unsafe.Pointer(pCheck)).Fv1 = Pgno(saved_v1)
  36976 	(*IntegrityCk)(unsafe.Pointer(pCheck)).Fv2 = saved_v2
  36977 	return depth + 1
  36978 }
  36979 
  36980 // This routine does a complete check of the given BTree file.  aRoot[] is
  36981 // an array of pages numbers were each page number is the root page of
  36982 // a table.  nRoot is the number of entries in aRoot.
  36983 //
  36984 // A read-only or read-write transaction must be opened before calling
  36985 // this function.
  36986 //
  36987 // Write the number of error seen in *pnErr.  Except for some memory
  36988 // allocation errors,  an error message held in memory obtained from
  36989 // malloc is returned if *pnErr is non-zero.  If *pnErr==0 then NULL is
  36990 // returned.  If a memory allocation error occurs, NULL is returned.
  36991 //
  36992 // If the first entry in aRoot[] is 0, that indicates that the list of
  36993 // root pages is incomplete.  This is a "partial integrity-check".  This
  36994 // happens when performing an integrity check on a single table.  The
  36995 // zero is skipped, of course.  But in addition, the freelist checks
  36996 // and the checks to make sure every page is referenced are also skipped,
  36997 // since obviously it is not possible to know which pages are covered by
  36998 // the unverified btrees.  Except, if aRoot[1] is 1, then the freelist
  36999 // checks are still performed.
  37000 func Xsqlite3BtreeIntegrityCheck(tls *libc.TLS, db uintptr, p uintptr, aRoot uintptr, nRoot int32, mxErr int32, pnErr uintptr, pzOut uintptr) int32 {
  37001 	bp := tls.Alloc(216)
  37002 	defer tls.Free(216)
  37003 
  37004 	var i Pgno
  37005 
  37006 	var pBt uintptr
  37007 	var savedDbFlags U64
  37008 
  37009 	var bPartial int32
  37010 	var bCkFreelist int32
  37011 	var mx Pgno
  37012 	var mxInHdr Pgno
  37013 
  37014 	pBt = (*Btree)(unsafe.Pointer(p)).FpBt
  37015 	savedDbFlags = (*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags
  37016 	bPartial = 0
  37017 	bCkFreelist = 1
  37018 
  37019 	if !(*(*Pgno)(unsafe.Pointer(aRoot)) == Pgno(0)) {
  37020 		goto __1
  37021 	}
  37022 
  37023 	bPartial = 1
  37024 	if !(*(*Pgno)(unsafe.Pointer(aRoot + 1*4)) != Pgno(1)) {
  37025 		goto __2
  37026 	}
  37027 	bCkFreelist = 0
  37028 __2:
  37029 	;
  37030 __1:
  37031 	;
  37032 	Xsqlite3BtreeEnter(tls, p)
  37033 
  37034 	libc.Xmemset(tls, bp+32, 0, uint32(unsafe.Sizeof(IntegrityCk{})))
  37035 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).Fdb = db
  37036 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FpBt = pBt
  37037 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FpPager = (*BtShared)(unsafe.Pointer(pBt)).FpPager
  37038 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FnPage = btreePagecount(tls, (*IntegrityCk)(unsafe.Pointer(bp+32)).FpBt)
  37039 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FmxErr = mxErr
  37040 	Xsqlite3StrAccumInit(tls, bp+32+44, uintptr(0), bp+108, int32(unsafe.Sizeof([100]uint8{})), SQLITE_MAX_LENGTH)
  37041 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FerrMsg.FprintfFlags = U8(SQLITE_PRINTF_INTERNAL)
  37042 	if !((*IntegrityCk)(unsafe.Pointer(bp+32)).FnPage == Pgno(0)) {
  37043 		goto __3
  37044 	}
  37045 	goto integrity_ck_cleanup
  37046 __3:
  37047 	;
  37048 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FaPgRef = Xsqlite3MallocZero(tls, uint64((*IntegrityCk)(unsafe.Pointer(bp+32)).FnPage/Pgno(8)+Pgno(1)))
  37049 	if !!(int32((*IntegrityCk)(unsafe.Pointer(bp+32)).FaPgRef) != 0) {
  37050 		goto __4
  37051 	}
  37052 	checkOom(tls, bp+32)
  37053 	goto integrity_ck_cleanup
  37054 __4:
  37055 	;
  37056 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).Fheap = Xsqlite3PageMalloc(tls, int32((*BtShared)(unsafe.Pointer(pBt)).FpageSize))
  37057 	if !((*IntegrityCk)(unsafe.Pointer(bp+32)).Fheap == uintptr(0)) {
  37058 		goto __5
  37059 	}
  37060 	checkOom(tls, bp+32)
  37061 	goto integrity_ck_cleanup
  37062 __5:
  37063 	;
  37064 	i = U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer(pBt)).FpageSize + U32(1)
  37065 	if !(i <= (*IntegrityCk)(unsafe.Pointer(bp+32)).FnPage) {
  37066 		goto __6
  37067 	}
  37068 	setPageReferenced(tls, bp+32, i)
  37069 __6:
  37070 	;
  37071 	if !(bCkFreelist != 0) {
  37072 		goto __7
  37073 	}
  37074 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FzPfx = ts + 4662
  37075 	checkList(tls, bp+32, 1, Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32),
  37076 		Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36))
  37077 	(*IntegrityCk)(unsafe.Pointer(bp + 32)).FzPfx = uintptr(0)
  37078 __7:
  37079 	;
  37080 	if !!(bPartial != 0) {
  37081 		goto __8
  37082 	}
  37083 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
  37084 		goto __9
  37085 	}
  37086 	mx = Pgno(0)
  37087 	i = Pgno(0)
  37088 __11:
  37089 	if !(int32(i) < nRoot) {
  37090 		goto __13
  37091 	}
  37092 	if !(mx < *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4))) {
  37093 		goto __14
  37094 	}
  37095 	mx = *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4))
  37096 __14:
  37097 	;
  37098 	goto __12
  37099 __12:
  37100 	i++
  37101 	goto __11
  37102 	goto __13
  37103 __13:
  37104 	;
  37105 	mxInHdr = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+52)
  37106 	if !(mx != mxInHdr) {
  37107 		goto __15
  37108 	}
  37109 	checkAppendMsg(tls, bp+32,
  37110 		ts+4678,
  37111 		libc.VaList(bp, mx, mxInHdr))
  37112 __15:
  37113 	;
  37114 	goto __10
  37115 __9:
  37116 	if !(Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+64) != U32(0)) {
  37117 		goto __16
  37118 	}
  37119 	checkAppendMsg(tls, bp+32,
  37120 		ts+4723, 0)
  37121 __16:
  37122 	;
  37123 __10:
  37124 	;
  37125 __8:
  37126 	;
  37127 	*(*U64)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb + 32)) &= libc.CplUint64(uint64(SQLITE_CellSizeCk))
  37128 	i = Pgno(0)
  37129 __17:
  37130 	if !(int32(i) < nRoot && (*IntegrityCk)(unsafe.Pointer(bp+32)).FmxErr != 0) {
  37131 		goto __19
  37132 	}
  37133 	if !(*(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)) == Pgno(0)) {
  37134 		goto __20
  37135 	}
  37136 	goto __18
  37137 __20:
  37138 	;
  37139 	if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 && *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)) > Pgno(1) && !(bPartial != 0)) {
  37140 		goto __21
  37141 	}
  37142 	checkPtrmap(tls, bp+32, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), uint8(PTRMAP_ROOTPAGE), uint32(0))
  37143 __21:
  37144 	;
  37145 	checkTreePage(tls, bp+32, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), bp+208, int64(0xffffffff)|int64(0x7fffffff)<<32)
  37146 	goto __18
  37147 __18:
  37148 	i++
  37149 	goto __17
  37150 	goto __19
  37151 __19:
  37152 	;
  37153 	(*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags = savedDbFlags
  37154 
  37155 	if !!(bPartial != 0) {
  37156 		goto __22
  37157 	}
  37158 	i = Pgno(1)
  37159 __23:
  37160 	if !(i <= (*IntegrityCk)(unsafe.Pointer(bp+32)).FnPage && (*IntegrityCk)(unsafe.Pointer(bp+32)).FmxErr != 0) {
  37161 		goto __25
  37162 	}
  37163 
  37164 	if !(getPageReferenced(tls, bp+32, i) == 0 && (ptrmapPageno(tls, pBt, i) != i || !(int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) != 0))) {
  37165 		goto __26
  37166 	}
  37167 	checkAppendMsg(tls, bp+32, ts+4778, libc.VaList(bp+16, i))
  37168 __26:
  37169 	;
  37170 	if !(getPageReferenced(tls, bp+32, i) != 0 && (ptrmapPageno(tls, pBt, i) == i && (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0)) {
  37171 		goto __27
  37172 	}
  37173 	checkAppendMsg(tls, bp+32, ts+4800, libc.VaList(bp+24, i))
  37174 __27:
  37175 	;
  37176 	goto __24
  37177 __24:
  37178 	i++
  37179 	goto __23
  37180 	goto __25
  37181 __25:
  37182 	;
  37183 __22:
  37184 	;
  37185 integrity_ck_cleanup:
  37186 	Xsqlite3PageFree(tls, (*IntegrityCk)(unsafe.Pointer(bp+32)).Fheap)
  37187 	Xsqlite3_free(tls, (*IntegrityCk)(unsafe.Pointer(bp+32)).FaPgRef)
  37188 	*(*int32)(unsafe.Pointer(pnErr)) = (*IntegrityCk)(unsafe.Pointer(bp + 32)).FnErr
  37189 	if !((*IntegrityCk)(unsafe.Pointer(bp+32)).FnErr == 0) {
  37190 		goto __28
  37191 	}
  37192 	Xsqlite3_str_reset(tls, bp+32+44)
  37193 	*(*uintptr)(unsafe.Pointer(pzOut)) = uintptr(0)
  37194 	goto __29
  37195 __28:
  37196 	*(*uintptr)(unsafe.Pointer(pzOut)) = Xsqlite3StrAccumFinish(tls, bp+32+44)
  37197 __29:
  37198 	;
  37199 	Xsqlite3BtreeLeave(tls, p)
  37200 	return (*IntegrityCk)(unsafe.Pointer(bp + 32)).Frc
  37201 }
  37202 
  37203 // Return the full pathname of the underlying database file.  Return
  37204 // an empty string if the database is in-memory or a TEMP database.
  37205 //
  37206 // The pager filename is invariant as long as the pager is
  37207 // open so it is safe to access without the BtShared mutex.
  37208 func Xsqlite3BtreeGetFilename(tls *libc.TLS, p uintptr) uintptr {
  37209 	return Xsqlite3PagerFilename(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpPager, 1)
  37210 }
  37211 
  37212 // Return the pathname of the journal file for this database. The return
  37213 // value of this routine is the same regardless of whether the journal file
  37214 // has been created or not.
  37215 //
  37216 // The pager journal filename is invariant as long as the pager is
  37217 // open so it is safe to access without the BtShared mutex.
  37218 func Xsqlite3BtreeGetJournalname(tls *libc.TLS, p uintptr) uintptr {
  37219 	return Xsqlite3PagerJournalname(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FpPager)
  37220 }
  37221 
  37222 // Return one of SQLITE_TXN_NONE, SQLITE_TXN_READ, or SQLITE_TXN_WRITE
  37223 // to describe the current transaction state of Btree p.
  37224 func Xsqlite3BtreeTxnState(tls *libc.TLS, p uintptr) int32 {
  37225 	if p != 0 {
  37226 		return int32((*Btree)(unsafe.Pointer(p)).FinTrans)
  37227 	}
  37228 	return 0
  37229 }
  37230 
  37231 // Run a checkpoint on the Btree passed as the first argument.
  37232 //
  37233 // Return SQLITE_LOCKED if this or any other connection has an open
  37234 // transaction on the shared-cache the argument Btree is connected to.
  37235 //
  37236 // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.
  37237 func Xsqlite3BtreeCheckpoint(tls *libc.TLS, p uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 {
  37238 	var rc int32 = SQLITE_OK
  37239 	if p != 0 {
  37240 		var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  37241 		Xsqlite3BtreeEnter(tls, p)
  37242 		if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) != TRANS_NONE {
  37243 			rc = SQLITE_LOCKED
  37244 		} else {
  37245 			rc = Xsqlite3PagerCheckpoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Btree)(unsafe.Pointer(p)).Fdb, eMode, pnLog, pnCkpt)
  37246 		}
  37247 		Xsqlite3BtreeLeave(tls, p)
  37248 	}
  37249 	return rc
  37250 }
  37251 
  37252 // Return true if there is currently a backup running on Btree p.
  37253 func Xsqlite3BtreeIsInBackup(tls *libc.TLS, p uintptr) int32 {
  37254 	return libc.Bool32((*Btree)(unsafe.Pointer(p)).FnBackup != 0)
  37255 }
  37256 
  37257 // This function returns a pointer to a blob of memory associated with
  37258 // a single shared-btree. The memory is used by client code for its own
  37259 // purposes (for example, to store a high-level schema associated with
  37260 // the shared-btree). The btree layer manages reference counting issues.
  37261 //
  37262 // The first time this is called on a shared-btree, nBytes bytes of memory
  37263 // are allocated, zeroed, and returned to the caller. For each subsequent
  37264 // call the nBytes parameter is ignored and a pointer to the same blob
  37265 // of memory returned.
  37266 //
  37267 // If the nBytes parameter is 0 and the blob of memory has not yet been
  37268 // allocated, a null pointer is returned. If the blob has already been
  37269 // allocated, it is returned as normal.
  37270 //
  37271 // Just before the shared-btree is closed, the function passed as the
  37272 // xFree argument when the memory allocation was made is invoked on the
  37273 // blob of allocated memory. The xFree function should not call sqlite3_free()
  37274 // on the memory, the btree layer does that.
  37275 func Xsqlite3BtreeSchema(tls *libc.TLS, p uintptr, nBytes int32, xFree uintptr) uintptr {
  37276 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  37277 	Xsqlite3BtreeEnter(tls, p)
  37278 	if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpSchema) != 0) && nBytes != 0 {
  37279 		(*BtShared)(unsafe.Pointer(pBt)).FpSchema = Xsqlite3DbMallocZero(tls, uintptr(0), uint64(nBytes))
  37280 		(*BtShared)(unsafe.Pointer(pBt)).FxFreeSchema = xFree
  37281 	}
  37282 	Xsqlite3BtreeLeave(tls, p)
  37283 	return (*BtShared)(unsafe.Pointer(pBt)).FpSchema
  37284 }
  37285 
  37286 // Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared
  37287 // btree as the argument handle holds an exclusive lock on the
  37288 // sqlite_schema table. Otherwise SQLITE_OK.
  37289 func Xsqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) int32 {
  37290 	var rc int32
  37291 
  37292 	Xsqlite3BtreeEnter(tls, p)
  37293 	rc = querySharedCacheTableLock(tls, p, uint32(SCHEMA_ROOT), uint8(READ_LOCK))
  37294 
  37295 	Xsqlite3BtreeLeave(tls, p)
  37296 	return rc
  37297 }
  37298 
  37299 // Obtain a lock on the table whose root page is iTab.  The
  37300 // lock is a write lock if isWritelock is true or a read lock
  37301 // if it is false.
  37302 func Xsqlite3BtreeLockTable(tls *libc.TLS, p uintptr, iTab int32, isWriteLock U8) int32 {
  37303 	var rc int32 = SQLITE_OK
  37304 
  37305 	if (*Btree)(unsafe.Pointer(p)).Fsharable != 0 {
  37306 		var lockType U8 = U8(READ_LOCK + int32(isWriteLock))
  37307 
  37308 		Xsqlite3BtreeEnter(tls, p)
  37309 		rc = querySharedCacheTableLock(tls, p, uint32(iTab), lockType)
  37310 		if rc == SQLITE_OK {
  37311 			rc = setSharedCacheTableLock(tls, p, uint32(iTab), lockType)
  37312 		}
  37313 		Xsqlite3BtreeLeave(tls, p)
  37314 	}
  37315 	return rc
  37316 }
  37317 
  37318 // Argument pCsr must be a cursor opened for writing on an
  37319 // INTKEY table currently pointing at a valid table entry.
  37320 // This function modifies the data stored as part of that entry.
  37321 //
  37322 // Only the data content may only be modified, it is not possible to
  37323 // change the length of the data stored. If this function is called with
  37324 // parameters that attempt to write past the end of the existing data,
  37325 // no modifications are made and SQLITE_CORRUPT is returned.
  37326 func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z uintptr) int32 {
  37327 	var rc int32
  37328 
  37329 	rc = func() int32 {
  37330 		if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) >= CURSOR_REQUIRESEEK {
  37331 			return btreeRestoreCursorPosition(tls, pCsr)
  37332 		}
  37333 		return SQLITE_OK
  37334 	}()
  37335 	if rc != SQLITE_OK {
  37336 		return rc
  37337 	}
  37338 
  37339 	if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) != CURSOR_VALID {
  37340 		return SQLITE_ABORT
  37341 	}
  37342 
  37343 	saveAllCursors(tls, (*BtCursor)(unsafe.Pointer(pCsr)).FpBt, (*BtCursor)(unsafe.Pointer(pCsr)).FpgnoRoot, pCsr)
  37344 
  37345 	if int32((*BtCursor)(unsafe.Pointer(pCsr)).FcurFlags)&BTCF_WriteFlag == 0 {
  37346 		return SQLITE_READONLY
  37347 	}
  37348 
  37349 	return accessPayload(tls, pCsr, offset, amt, z, 1)
  37350 }
  37351 
  37352 // Mark this cursor as an incremental blob cursor.
  37353 func Xsqlite3BtreeIncrblobCursor(tls *libc.TLS, pCur uintptr) {
  37354 	*(*U8)(unsafe.Pointer(pCur + 1)) |= U8(BTCF_Incrblob)
  37355 	(*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).FhasIncrblobCur = U8(1)
  37356 }
  37357 
  37358 // Set both the "read version" (single byte at byte offset 18) and
  37359 // "write version" (single byte at byte offset 19) fields in the database
  37360 // header to iVersion.
  37361 func Xsqlite3BtreeSetVersion(tls *libc.TLS, pBtree uintptr, iVersion int32) int32 {
  37362 	var pBt uintptr = (*Btree)(unsafe.Pointer(pBtree)).FpBt
  37363 	var rc int32
  37364 
  37365 	*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_NO_WAL))
  37366 	if iVersion == 1 {
  37367 		*(*U16)(unsafe.Pointer(pBt + 24)) |= U16(BTS_NO_WAL)
  37368 	}
  37369 
  37370 	rc = Xsqlite3BtreeBeginTrans(tls, pBtree, 0, uintptr(0))
  37371 	if rc == SQLITE_OK {
  37372 		var aData uintptr = (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData
  37373 		if int32(*(*U8)(unsafe.Pointer(aData + 18))) != int32(U8(iVersion)) || int32(*(*U8)(unsafe.Pointer(aData + 19))) != int32(U8(iVersion)) {
  37374 			rc = Xsqlite3BtreeBeginTrans(tls, pBtree, 2, uintptr(0))
  37375 			if rc == SQLITE_OK {
  37376 				rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
  37377 				if rc == SQLITE_OK {
  37378 					*(*U8)(unsafe.Pointer(aData + 18)) = U8(iVersion)
  37379 					*(*U8)(unsafe.Pointer(aData + 19)) = U8(iVersion)
  37380 				}
  37381 			}
  37382 		}
  37383 	}
  37384 
  37385 	*(*U16)(unsafe.Pointer(pBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_NO_WAL))
  37386 	return rc
  37387 }
  37388 
  37389 // Return true if the cursor has a hint specified.  This routine is
  37390 // only used from within assert() statements
  37391 func Xsqlite3BtreeCursorHasHint(tls *libc.TLS, pCsr uintptr, mask uint32) int32 {
  37392 	return libc.Bool32(uint32((*BtCursor)(unsafe.Pointer(pCsr)).Fhints)&mask != uint32(0))
  37393 }
  37394 
  37395 // Return true if the given Btree is read-only.
  37396 func Xsqlite3BtreeIsReadonly(tls *libc.TLS, p uintptr) int32 {
  37397 	return libc.Bool32(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags)&BTS_READ_ONLY != 0)
  37398 }
  37399 
  37400 // Return the size of the header added to each page by this module.
  37401 func Xsqlite3HeaderSizeBtree(tls *libc.TLS) int32 {
  37402 	return int32((uint32(unsafe.Sizeof(MemPage{})) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  37403 }
  37404 
  37405 // If no transaction is active and the database is not a temp-db, clear
  37406 // the in-memory pager cache.
  37407 func Xsqlite3BtreeClearCache(tls *libc.TLS, p uintptr) {
  37408 	var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt
  37409 	if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE {
  37410 		Xsqlite3PagerClearCache(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager)
  37411 	}
  37412 }
  37413 
  37414 // Return true if the Btree passed as the only argument is sharable.
  37415 func Xsqlite3BtreeSharable(tls *libc.TLS, p uintptr) int32 {
  37416 	return int32((*Btree)(unsafe.Pointer(p)).Fsharable)
  37417 }
  37418 
  37419 // Return the number of connections to the BtShared object accessed by
  37420 // the Btree handle passed as the only argument. For private caches
  37421 // this is always 1. For shared caches it may be 1 or greater.
  37422 func Xsqlite3BtreeConnectionCount(tls *libc.TLS, p uintptr) int32 {
  37423 	return (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FnRef
  37424 }
  37425 
  37426 func findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) uintptr {
  37427 	bp := tls.Alloc(296)
  37428 	defer tls.Free(296)
  37429 
  37430 	var i int32 = Xsqlite3FindDbName(tls, pDb, zDb)
  37431 
  37432 	if i == 1 {
  37433 		var rc int32 = 0
  37434 		Xsqlite3ParseObjectInit(tls, bp+16, pDb)
  37435 		if Xsqlite3OpenTempDatabase(tls, bp+16) != 0 {
  37436 			Xsqlite3ErrorWithMsg(tls, pErrorDb, (*Parse)(unsafe.Pointer(bp+16)).Frc, ts+3663, libc.VaList(bp, (*Parse)(unsafe.Pointer(bp+16)).FzErrMsg))
  37437 			rc = SQLITE_ERROR
  37438 		}
  37439 		Xsqlite3DbFree(tls, pErrorDb, (*Parse)(unsafe.Pointer(bp+16)).FzErrMsg)
  37440 		Xsqlite3ParseObjectReset(tls, bp+16)
  37441 		if rc != 0 {
  37442 			return uintptr(0)
  37443 		}
  37444 	}
  37445 
  37446 	if i < 0 {
  37447 		Xsqlite3ErrorWithMsg(tls, pErrorDb, SQLITE_ERROR, ts+4834, libc.VaList(bp+8, zDb))
  37448 		return uintptr(0)
  37449 	}
  37450 
  37451 	return (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(pDb)).FaDb + uintptr(i)*16)).FpBt
  37452 }
  37453 
  37454 func setDestPgsz(tls *libc.TLS, p uintptr) int32 {
  37455 	var rc int32
  37456 	rc = Xsqlite3BtreeSetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc), 0, 0)
  37457 	return rc
  37458 }
  37459 
  37460 func checkReadTransaction(tls *libc.TLS, db uintptr, p uintptr) int32 {
  37461 	if Xsqlite3BtreeTxnState(tls, p) != SQLITE_TXN_NONE {
  37462 		Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, ts+4854, 0)
  37463 		return SQLITE_ERROR
  37464 	}
  37465 	return SQLITE_OK
  37466 }
  37467 
  37468 // Create an sqlite3_backup process to copy the contents of zSrcDb from
  37469 // connection handle pSrcDb to zDestDb in pDestDb. If successful, return
  37470 // a pointer to the new sqlite3_backup object.
  37471 //
  37472 // If an error occurs, NULL is returned and an error code and error message
  37473 // stored in database handle pDestDb.
  37474 func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcDb uintptr, zSrcDb uintptr) uintptr {
  37475 	var p uintptr
  37476 
  37477 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(pSrcDb)).Fmutex)
  37478 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(pDestDb)).Fmutex)
  37479 
  37480 	if pSrcDb == pDestDb {
  37481 		Xsqlite3ErrorWithMsg(tls,
  37482 			pDestDb, SQLITE_ERROR, ts+4885, 0)
  37483 		p = uintptr(0)
  37484 	} else {
  37485 		p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Sqlite3_backup{})))
  37486 		if !(p != 0) {
  37487 			Xsqlite3Error(tls, pDestDb, SQLITE_NOMEM)
  37488 		}
  37489 	}
  37490 
  37491 	if p != 0 {
  37492 		(*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc = findBtree(tls, pDestDb, pSrcDb, zSrcDb)
  37493 		(*Sqlite3_backup)(unsafe.Pointer(p)).FpDest = findBtree(tls, pDestDb, pDestDb, zDestDb)
  37494 		(*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb = pDestDb
  37495 		(*Sqlite3_backup)(unsafe.Pointer(p)).FpSrcDb = pSrcDb
  37496 		(*Sqlite3_backup)(unsafe.Pointer(p)).FiNext = Pgno(1)
  37497 		(*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached = 0
  37498 
  37499 		if uintptr(0) == (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc || uintptr(0) == (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest ||
  37500 			checkReadTransaction(tls, pDestDb, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) != SQLITE_OK {
  37501 			Xsqlite3_free(tls, p)
  37502 			p = uintptr(0)
  37503 		}
  37504 	}
  37505 	if p != 0 {
  37506 		(*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FnBackup++
  37507 	}
  37508 
  37509 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(pDestDb)).Fmutex)
  37510 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(pSrcDb)).Fmutex)
  37511 	return p
  37512 }
  37513 
  37514 func isFatalError(tls *libc.TLS, rc int32) int32 {
  37515 	return libc.Bool32(rc != SQLITE_OK && rc != SQLITE_BUSY && rc != SQLITE_LOCKED)
  37516 }
  37517 
  37518 func backupOnePage(tls *libc.TLS, p uintptr, iSrcPg Pgno, zSrcData uintptr, bUpdate int32) int32 {
  37519 	bp := tls.Alloc(4)
  37520 	defer tls.Free(4)
  37521 
  37522 	var pDestPager uintptr = Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)
  37523 	var nSrcPgsz int32 = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37524 	var nDestPgsz int32 = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)
  37525 	var nCopy int32 = func() int32 {
  37526 		if nSrcPgsz < nDestPgsz {
  37527 			return nSrcPgsz
  37528 		}
  37529 		return nDestPgsz
  37530 	}()
  37531 	var iEnd I64 = I64(iSrcPg) * I64(nSrcPgsz)
  37532 	var rc int32 = SQLITE_OK
  37533 	var iOff I64
  37534 
  37535 	if nSrcPgsz != nDestPgsz && Xsqlite3PagerIsMemdb(tls, pDestPager) != 0 {
  37536 		rc = SQLITE_READONLY
  37537 	}
  37538 
  37539 	for iOff = iEnd - I64(nSrcPgsz); rc == SQLITE_OK && iOff < iEnd; iOff = iOff + I64(nDestPgsz) {
  37540 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  37541 		var iDest Pgno = Pgno(iOff/I64(nDestPgsz)) + Pgno(1)
  37542 		if iDest == U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+U32(1) {
  37543 			continue
  37544 		}
  37545 		if SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3PagerGet(tls, pDestPager, iDest, bp, 0)) &&
  37546 			SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp)))) {
  37547 			var zIn uintptr = zSrcData + uintptr(iOff%I64(nSrcPgsz))
  37548 			var zDestData uintptr = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp)))
  37549 			var zOut uintptr = zDestData + uintptr(iOff%I64(nDestPgsz))
  37550 
  37551 			libc.Xmemcpy(tls, zOut, zIn, uint32(nCopy))
  37552 			*(*U8)(unsafe.Pointer(Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp))))) = U8(0)
  37553 			if iOff == int64(0) && bUpdate == 0 {
  37554 				Xsqlite3Put4byte(tls, zOut+28, Xsqlite3BtreeLastPage(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc))
  37555 			}
  37556 		}
  37557 		Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  37558 	}
  37559 
  37560 	return rc
  37561 }
  37562 
  37563 func backupTruncateFile(tls *libc.TLS, pFile uintptr, iSize I64) int32 {
  37564 	bp := tls.Alloc(8)
  37565 	defer tls.Free(8)
  37566 
  37567 	var rc int32 = Xsqlite3OsFileSize(tls, pFile, bp)
  37568 	if rc == SQLITE_OK && *(*I64)(unsafe.Pointer(bp)) > iSize {
  37569 		rc = Xsqlite3OsTruncate(tls, pFile, iSize)
  37570 	}
  37571 	return rc
  37572 }
  37573 
  37574 func attachBackupObject(tls *libc.TLS, p uintptr) {
  37575 	var pp uintptr
  37576 
  37577 	pp = Xsqlite3PagerBackupPtr(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc))
  37578 	(*Sqlite3_backup)(unsafe.Pointer(p)).FpNext = *(*uintptr)(unsafe.Pointer(pp))
  37579 	*(*uintptr)(unsafe.Pointer(pp)) = p
  37580 	(*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached = 1
  37581 }
  37582 
  37583 // Copy nPage pages from the source b-tree to the destination.
  37584 func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 {
  37585 	bp := tls.Alloc(16)
  37586 	defer tls.Free(16)
  37587 
  37588 	var rc int32
  37589 	var destMode int32
  37590 	var pgszSrc int32 = 0
  37591 	var pgszDest int32 = 0
  37592 
  37593 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrcDb)).Fmutex)
  37594 	Xsqlite3BtreeEnter(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37595 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37596 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
  37597 	}
  37598 
  37599 	rc = (*Sqlite3_backup)(unsafe.Pointer(p)).Frc
  37600 	if !(isFatalError(tls, rc) != 0) {
  37601 		var pSrcPager uintptr = Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37602 		var pDestPager uintptr = Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)
  37603 		var ii int32
  37604 		var nSrcPage int32 = -1
  37605 		var bCloseTrans int32 = 0
  37606 
  37607 		if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 && int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FinTransaction) == TRANS_WRITE {
  37608 			rc = SQLITE_BUSY
  37609 		} else {
  37610 			rc = SQLITE_OK
  37611 		}
  37612 
  37613 		if rc == SQLITE_OK && SQLITE_TXN_NONE == Xsqlite3BtreeTxnState(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc) {
  37614 			rc = Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc, 0, uintptr(0))
  37615 			bCloseTrans = 1
  37616 		}
  37617 
  37618 		if (*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0 && rc == SQLITE_OK && setDestPgsz(tls, p) == SQLITE_NOMEM {
  37619 			rc = SQLITE_NOMEM
  37620 		}
  37621 
  37622 		if SQLITE_OK == rc && (*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0 &&
  37623 			SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2,
  37624 				p+8)) {
  37625 			(*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked = 1
  37626 		}
  37627 
  37628 		pgszSrc = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37629 		pgszDest = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)
  37630 		destMode = Xsqlite3PagerGetJournalMode(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest))
  37631 		if SQLITE_OK == rc && destMode == PAGER_JOURNALMODE_WAL && pgszSrc != pgszDest {
  37632 			rc = SQLITE_READONLY
  37633 		}
  37634 
  37635 		nSrcPage = int32(Xsqlite3BtreeLastPage(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc))
  37636 
  37637 		for ii = 0; (nPage < 0 || ii < nPage) && (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext <= Pgno(nSrcPage) && !(rc != 0); ii++ {
  37638 			var iSrcPg Pgno = (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext
  37639 			if iSrcPg != U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FpageSize+U32(1) {
  37640 				rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp, PAGER_GET_READONLY)
  37641 				if rc == SQLITE_OK {
  37642 					rc = backupOnePage(tls, p, iSrcPg, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp))), 0)
  37643 					Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp)))
  37644 				}
  37645 			}
  37646 			(*Sqlite3_backup)(unsafe.Pointer(p)).FiNext++
  37647 		}
  37648 		if rc == SQLITE_OK {
  37649 			(*Sqlite3_backup)(unsafe.Pointer(p)).FnPagecount = Pgno(nSrcPage)
  37650 			(*Sqlite3_backup)(unsafe.Pointer(p)).FnRemaining = Pgno(nSrcPage+1) - (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext
  37651 			if (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext > Pgno(nSrcPage) {
  37652 				rc = SQLITE_DONE
  37653 			} else if !((*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached != 0) {
  37654 				attachBackupObject(tls, p)
  37655 			}
  37656 		}
  37657 
  37658 		if rc == SQLITE_DONE {
  37659 			if nSrcPage == 0 {
  37660 				rc = Xsqlite3BtreeNewDb(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)
  37661 				nSrcPage = 1
  37662 			}
  37663 			if rc == SQLITE_OK || rc == SQLITE_DONE {
  37664 				rc = Xsqlite3BtreeUpdateMeta(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 1, (*Sqlite3_backup)(unsafe.Pointer(p)).FiDestSchema+U32(1))
  37665 			}
  37666 			if rc == SQLITE_OK {
  37667 				if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37668 					Xsqlite3ResetAllSchemasOfConnection(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)
  37669 				}
  37670 				if destMode == PAGER_JOURNALMODE_WAL {
  37671 					rc = Xsqlite3BtreeSetVersion(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2)
  37672 				}
  37673 			}
  37674 			if rc == SQLITE_OK {
  37675 				var nDestTruncate int32
  37676 
  37677 				if pgszSrc < pgszDest {
  37678 					var ratio int32 = pgszDest / pgszSrc
  37679 					nDestTruncate = (nSrcPage + ratio - 1) / ratio
  37680 					if nDestTruncate == int32(U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+U32(1)) {
  37681 						nDestTruncate--
  37682 					}
  37683 				} else {
  37684 					nDestTruncate = nSrcPage * (pgszSrc / pgszDest)
  37685 				}
  37686 
  37687 				if pgszSrc < pgszDest {
  37688 					var iSize I64 = I64(pgszSrc) * I64(nSrcPage)
  37689 					var pFile uintptr = Xsqlite3PagerFile(tls, pDestPager)
  37690 					var iPg Pgno
  37691 
  37692 					var iOff I64
  37693 					var iEnd I64
  37694 
  37695 					Xsqlite3PagerPagecount(tls, pDestPager, bp+4)
  37696 					for iPg = Pgno(nDestTruncate); rc == SQLITE_OK && iPg <= Pgno(*(*int32)(unsafe.Pointer(bp + 4))); iPg++ {
  37697 						if iPg != U32(Xsqlite3PendingByte)/(*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize+U32(1) {
  37698 							rc = Xsqlite3PagerGet(tls, pDestPager, iPg, bp+8, 0)
  37699 							if rc == SQLITE_OK {
  37700 								rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  37701 								Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  37702 							}
  37703 						}
  37704 					}
  37705 					if rc == SQLITE_OK {
  37706 						rc = Xsqlite3PagerCommitPhaseOne(tls, pDestPager, uintptr(0), 1)
  37707 					}
  37708 
  37709 					iEnd = func() int64 {
  37710 						if I64(Xsqlite3PendingByte+pgszDest) < iSize {
  37711 							return int64(Xsqlite3PendingByte + pgszDest)
  37712 						}
  37713 						return iSize
  37714 					}()
  37715 					for iOff = I64(Xsqlite3PendingByte + pgszSrc); rc == SQLITE_OK && iOff < iEnd; iOff = iOff + I64(pgszSrc) {
  37716 						*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
  37717 						var iSrcPg Pgno = Pgno(iOff/I64(pgszSrc) + int64(1))
  37718 						rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp+12, 0)
  37719 						if rc == SQLITE_OK {
  37720 							var zData uintptr = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  37721 							rc = Xsqlite3OsWrite(tls, pFile, zData, pgszSrc, iOff)
  37722 						}
  37723 						Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
  37724 					}
  37725 					if rc == SQLITE_OK {
  37726 						rc = backupTruncateFile(tls, pFile, iSize)
  37727 					}
  37728 
  37729 					if rc == SQLITE_OK {
  37730 						rc = Xsqlite3PagerSync(tls, pDestPager, uintptr(0))
  37731 					}
  37732 				} else {
  37733 					Xsqlite3PagerTruncateImage(tls, pDestPager, uint32(nDestTruncate))
  37734 					rc = Xsqlite3PagerCommitPhaseOne(tls, pDestPager, uintptr(0), 0)
  37735 				}
  37736 
  37737 				if SQLITE_OK == rc &&
  37738 					SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3BtreeCommitPhaseTwo(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0)) {
  37739 					rc = SQLITE_DONE
  37740 				}
  37741 			}
  37742 		}
  37743 
  37744 		if bCloseTrans != 0 {
  37745 			Xsqlite3BtreeCommitPhaseOne(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc, uintptr(0))
  37746 			Xsqlite3BtreeCommitPhaseTwo(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc, 0)
  37747 
  37748 		}
  37749 
  37750 		if rc == SQLITE_IOERR|int32(12)<<8 {
  37751 			rc = SQLITE_NOMEM
  37752 		}
  37753 		(*Sqlite3_backup)(unsafe.Pointer(p)).Frc = rc
  37754 	}
  37755 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37756 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
  37757 	}
  37758 	Xsqlite3BtreeLeave(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37759 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrcDb)).Fmutex)
  37760 	return rc
  37761 }
  37762 
  37763 // Release all resources associated with an sqlite3_backup* handle.
  37764 func Xsqlite3_backup_finish(tls *libc.TLS, p uintptr) int32 {
  37765 	var pp uintptr
  37766 	var pSrcDb uintptr
  37767 	var rc int32
  37768 
  37769 	if p == uintptr(0) {
  37770 		return SQLITE_OK
  37771 	}
  37772 	pSrcDb = (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrcDb
  37773 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(pSrcDb)).Fmutex)
  37774 	Xsqlite3BtreeEnter(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37775 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37776 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
  37777 	}
  37778 
  37779 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37780 		(*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FnBackup--
  37781 	}
  37782 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached != 0 {
  37783 		pp = Xsqlite3PagerBackupPtr(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc))
  37784 
  37785 		for *(*uintptr)(unsafe.Pointer(pp)) != p {
  37786 			pp = *(*uintptr)(unsafe.Pointer(pp)) + 44
  37787 
  37788 		}
  37789 		*(*uintptr)(unsafe.Pointer(pp)) = (*Sqlite3_backup)(unsafe.Pointer(p)).FpNext
  37790 	}
  37791 
  37792 	Xsqlite3BtreeRollback(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, SQLITE_OK, 0)
  37793 
  37794 	if (*Sqlite3_backup)(unsafe.Pointer(p)).Frc == SQLITE_DONE {
  37795 		rc = SQLITE_OK
  37796 	} else {
  37797 		rc = (*Sqlite3_backup)(unsafe.Pointer(p)).Frc
  37798 	}
  37799 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37800 		Xsqlite3Error(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb, rc)
  37801 
  37802 		Xsqlite3LeaveMutexAndCloseZombie(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)
  37803 	}
  37804 	Xsqlite3BtreeLeave(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)
  37805 	if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 {
  37806 		Xsqlite3_free(tls, p)
  37807 	}
  37808 	Xsqlite3LeaveMutexAndCloseZombie(tls, pSrcDb)
  37809 	return rc
  37810 }
  37811 
  37812 // Return the number of pages still to be backed up as of the most recent
  37813 // call to sqlite3_backup_step().
  37814 func Xsqlite3_backup_remaining(tls *libc.TLS, p uintptr) int32 {
  37815 	return int32((*Sqlite3_backup)(unsafe.Pointer(p)).FnRemaining)
  37816 }
  37817 
  37818 // Return the total number of pages in the source database as of the most
  37819 // recent call to sqlite3_backup_step().
  37820 func Xsqlite3_backup_pagecount(tls *libc.TLS, p uintptr) int32 {
  37821 	return int32((*Sqlite3_backup)(unsafe.Pointer(p)).FnPagecount)
  37822 }
  37823 
  37824 func backupUpdate(tls *libc.TLS, p uintptr, iPage Pgno, aData uintptr) {
  37825 	for __ccgo := true; __ccgo; __ccgo = libc.AssignUintptr(&p, (*Sqlite3_backup)(unsafe.Pointer(p)).FpNext) != uintptr(0) {
  37826 		if !(isFatalError(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).Frc) != 0) && iPage < (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext {
  37827 			var rc int32
  37828 
  37829 			Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
  37830 			rc = backupOnePage(tls, p, iPage, aData, 1)
  37831 			Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
  37832 
  37833 			if rc != SQLITE_OK {
  37834 				(*Sqlite3_backup)(unsafe.Pointer(p)).Frc = rc
  37835 			}
  37836 		}
  37837 	}
  37838 }
  37839 
  37840 func Xsqlite3BackupUpdate(tls *libc.TLS, pBackup uintptr, iPage Pgno, aData uintptr) {
  37841 	if pBackup != 0 {
  37842 		backupUpdate(tls, pBackup, iPage, aData)
  37843 	}
  37844 }
  37845 
  37846 // Restart the backup process. This is called when the pager layer
  37847 // detects that the database has been modified by an external database
  37848 // connection. In this case there is no way of knowing which of the
  37849 // pages that have been copied into the destination database are still
  37850 // valid and which are not, so the entire process needs to be restarted.
  37851 //
  37852 // It is assumed that the mutex associated with the BtShared object
  37853 // corresponding to the source database is held when this function is
  37854 // called.
  37855 func Xsqlite3BackupRestart(tls *libc.TLS, pBackup uintptr) {
  37856 	var p uintptr
  37857 	for p = pBackup; p != 0; p = (*Sqlite3_backup)(unsafe.Pointer(p)).FpNext {
  37858 		(*Sqlite3_backup)(unsafe.Pointer(p)).FiNext = Pgno(1)
  37859 	}
  37860 }
  37861 
  37862 // Copy the complete content of pBtFrom into pBtTo.  A transaction
  37863 // must be active for both files.
  37864 //
  37865 // The size of file pTo may be reduced by this operation. If anything
  37866 // goes wrong, the transaction on pTo is rolled back. If successful, the
  37867 // transaction is committed before returning.
  37868 func Xsqlite3BtreeCopyFile(tls *libc.TLS, pTo uintptr, pFrom uintptr) int32 {
  37869 	bp := tls.Alloc(56)
  37870 	defer tls.Free(56)
  37871 
  37872 	var rc int32
  37873 	var pFd uintptr
  37874 
  37875 	Xsqlite3BtreeEnter(tls, pTo)
  37876 	Xsqlite3BtreeEnter(tls, pFrom)
  37877 
  37878 	pFd = Xsqlite3PagerFile(tls, Xsqlite3BtreePager(tls, pTo))
  37879 	if !((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods != 0) {
  37880 		goto __1
  37881 	}
  37882 	*(*I64)(unsafe.Pointer(bp)) = I64(Xsqlite3BtreeGetPageSize(tls, pFrom)) * I64(Xsqlite3BtreeLastPage(tls, pFrom))
  37883 	rc = Xsqlite3OsFileControl(tls, pFd, SQLITE_FCNTL_OVERWRITE, bp)
  37884 	if !(rc == SQLITE_NOTFOUND) {
  37885 		goto __2
  37886 	}
  37887 	rc = SQLITE_OK
  37888 __2:
  37889 	;
  37890 	if !(rc != 0) {
  37891 		goto __3
  37892 	}
  37893 	goto copy_finished
  37894 __3:
  37895 	;
  37896 __1:
  37897 	;
  37898 	libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(Sqlite3_backup{})))
  37899 	(*Sqlite3_backup)(unsafe.Pointer(bp + 8)).FpSrcDb = (*Btree)(unsafe.Pointer(pFrom)).Fdb
  37900 	(*Sqlite3_backup)(unsafe.Pointer(bp + 8)).FpSrc = pFrom
  37901 	(*Sqlite3_backup)(unsafe.Pointer(bp + 8)).FpDest = pTo
  37902 	(*Sqlite3_backup)(unsafe.Pointer(bp + 8)).FiNext = Pgno(1)
  37903 
  37904 	Xsqlite3_backup_step(tls, bp+8, 0x7FFFFFFF)
  37905 
  37906 	rc = Xsqlite3_backup_finish(tls, bp+8)
  37907 	if !(rc == SQLITE_OK) {
  37908 		goto __4
  37909 	}
  37910 	*(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(pTo)).FpBt + 24)) &= libc.Uint16FromInt32(libc.CplInt32(BTS_PAGESIZE_FIXED))
  37911 	goto __5
  37912 __4:
  37913 	Xsqlite3PagerClearCache(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(bp+8)).FpDest))
  37914 __5:
  37915 	;
  37916 copy_finished:
  37917 	Xsqlite3BtreeLeave(tls, pFrom)
  37918 	Xsqlite3BtreeLeave(tls, pTo)
  37919 	return rc
  37920 }
  37921 
  37922 func vdbeMemRenderNum(tls *libc.TLS, sz int32, zBuf uintptr, p uintptr) {
  37923 	bp := tls.Alloc(40)
  37924 	defer tls.Free(40)
  37925 
  37926 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Int != 0 {
  37927 		libc.Xmemcpy(tls, bp+8, p, uint32(int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Int*2))
  37928 		(*Mem)(unsafe.Pointer(p)).Fn = Xsqlite3Int64ToText(tls, *(*I64)(unsafe.Pointer(bp + 8)), zBuf)
  37929 	} else {
  37930 		Xsqlite3StrAccumInit(tls, bp+16, uintptr(0), zBuf, sz, 0)
  37931 		Xsqlite3_str_appendf(tls, bp+16, ts+4925,
  37932 			libc.VaList(bp, func() float64 {
  37933 				if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_IntReal != 0 {
  37934 					return float64(*(*I64)(unsafe.Pointer(p)))
  37935 				}
  37936 				return *(*float64)(unsafe.Pointer(p))
  37937 			}()))
  37938 
  37939 		*(*uint8)(unsafe.Pointer(zBuf + uintptr((*StrAccum)(unsafe.Pointer(bp+16)).FnChar))) = uint8(0)
  37940 		(*Mem)(unsafe.Pointer(p)).Fn = int32((*StrAccum)(unsafe.Pointer(bp + 16)).FnChar)
  37941 	}
  37942 }
  37943 
  37944 // If pMem is an object with a valid string representation, this routine
  37945 // ensures the internal encoding for the string representation is
  37946 // 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.
  37947 //
  37948 // If pMem is not a string object, or the encoding of the string
  37949 // representation is already stored using the requested encoding, then this
  37950 // routine is a no-op.
  37951 //
  37952 // SQLITE_OK is returned if the conversion is successful (or not required).
  37953 // SQLITE_NOMEM may be returned if a malloc() fails during conversion
  37954 // between formats.
  37955 func Xsqlite3VdbeChangeEncoding(tls *libc.TLS, pMem uintptr, desiredEnc int32) int32 {
  37956 	var rc int32
  37957 
  37958 	if !(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Str != 0) {
  37959 		(*Mem)(unsafe.Pointer(pMem)).Fenc = U8(desiredEnc)
  37960 		return SQLITE_OK
  37961 	}
  37962 	if int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == desiredEnc {
  37963 		return SQLITE_OK
  37964 	}
  37965 
  37966 	rc = Xsqlite3VdbeMemTranslate(tls, pMem, U8(desiredEnc))
  37967 
  37968 	return rc
  37969 }
  37970 
  37971 // Make sure pMem->z points to a writable allocation of at least n bytes.
  37972 //
  37973 // If the bPreserve argument is true, then copy of the content of
  37974 // pMem->z into the new allocation.  pMem must be either a string or
  37975 // blob if bPreserve is true.  If bPreserve is false, any prior content
  37976 // in pMem->z is discarded.
  37977 func Xsqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) int32 {
  37978 	if (*Mem)(unsafe.Pointer(pMem)).FszMalloc > 0 && bPreserve != 0 && (*Mem)(unsafe.Pointer(pMem)).Fz == (*Mem)(unsafe.Pointer(pMem)).FzMalloc {
  37979 		if (*Mem)(unsafe.Pointer(pMem)).Fdb != 0 {
  37980 			(*Mem)(unsafe.Pointer(pMem)).Fz = libc.AssignPtrUintptr(pMem+32, Xsqlite3DbReallocOrFree(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).Fz, uint64(n)))
  37981 		} else {
  37982 			(*Mem)(unsafe.Pointer(pMem)).FzMalloc = Xsqlite3Realloc(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, uint64(n))
  37983 			if (*Mem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) {
  37984 				Xsqlite3_free(tls, (*Mem)(unsafe.Pointer(pMem)).Fz)
  37985 			}
  37986 			(*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc
  37987 		}
  37988 		bPreserve = 0
  37989 	} else {
  37990 		if (*Mem)(unsafe.Pointer(pMem)).FszMalloc > 0 {
  37991 			Xsqlite3DbFreeNN(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc)
  37992 		}
  37993 		(*Mem)(unsafe.Pointer(pMem)).FzMalloc = Xsqlite3DbMallocRaw(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, uint64(n))
  37994 	}
  37995 	if (*Mem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) {
  37996 		Xsqlite3VdbeMemSetNull(tls, pMem)
  37997 		(*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0)
  37998 		(*Mem)(unsafe.Pointer(pMem)).FszMalloc = 0
  37999 		return SQLITE_NOMEM
  38000 	} else {
  38001 		(*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc)
  38002 	}
  38003 
  38004 	if bPreserve != 0 && (*Mem)(unsafe.Pointer(pMem)).Fz != 0 {
  38005 		libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pMem)).FzMalloc, (*Mem)(unsafe.Pointer(pMem)).Fz, uint32((*Mem)(unsafe.Pointer(pMem)).Fn))
  38006 	}
  38007 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Dyn != 0 {
  38008 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Mem)(unsafe.Pointer(pMem)).FxDel})).f(tls, (*Mem)(unsafe.Pointer(pMem)).Fz)
  38009 	}
  38010 
  38011 	(*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc
  38012 	*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Dyn | MEM_Ephem | MEM_Static))
  38013 	return SQLITE_OK
  38014 }
  38015 
  38016 // Change the pMem->zMalloc allocation to be at least szNew bytes.
  38017 // If pMem->zMalloc already meets or exceeds the requested size, this
  38018 // routine is a no-op.
  38019 //
  38020 // Any prior string or blob content in the pMem object may be discarded.
  38021 // The pMem->xDel destructor is called, if it exists.  Though MEM_Str
  38022 // and MEM_Blob values may be discarded, MEM_Int, MEM_Real, MEM_IntReal,
  38023 // and MEM_Null values are preserved.
  38024 //
  38025 // Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM)
  38026 // if unable to complete the resizing.
  38027 func Xsqlite3VdbeMemClearAndResize(tls *libc.TLS, pMem uintptr, szNew int32) int32 {
  38028 	if (*Mem)(unsafe.Pointer(pMem)).FszMalloc < szNew {
  38029 		return Xsqlite3VdbeMemGrow(tls, pMem, szNew, 0)
  38030 	}
  38031 
  38032 	(*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc
  38033 	*(*U16)(unsafe.Pointer(pMem + 16)) &= U16(MEM_Null | MEM_Int | MEM_Real | MEM_IntReal)
  38034 	return SQLITE_OK
  38035 }
  38036 
  38037 func vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) int32 {
  38038 	if Xsqlite3VdbeMemGrow(tls, pMem, (*Mem)(unsafe.Pointer(pMem)).Fn+3, 1) != 0 {
  38039 		return SQLITE_NOMEM
  38040 	}
  38041 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn))) = uint8(0)
  38042 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn+1))) = uint8(0)
  38043 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn+2))) = uint8(0)
  38044 	*(*U16)(unsafe.Pointer(pMem + 16)) |= U16(MEM_Term)
  38045 	return SQLITE_OK
  38046 }
  38047 
  38048 // Change pMem so that its MEM_Str or MEM_Blob value is stored in
  38049 // MEM.zMalloc, where it can be safely written.
  38050 //
  38051 // Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.
  38052 func Xsqlite3VdbeMemMakeWriteable(tls *libc.TLS, pMem uintptr) int32 {
  38053 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Str|MEM_Blob) != 0 {
  38054 		if func() int32 {
  38055 			if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Zero != 0 {
  38056 				return Xsqlite3VdbeMemExpandBlob(tls, pMem)
  38057 			}
  38058 			return 0
  38059 		}() != 0 {
  38060 			return SQLITE_NOMEM
  38061 		}
  38062 		if (*Mem)(unsafe.Pointer(pMem)).FszMalloc == 0 || (*Mem)(unsafe.Pointer(pMem)).Fz != (*Mem)(unsafe.Pointer(pMem)).FzMalloc {
  38063 			var rc int32 = vdbeMemAddTerminator(tls, pMem)
  38064 			if rc != 0 {
  38065 				return rc
  38066 			}
  38067 		}
  38068 	}
  38069 	*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Ephem))
  38070 
  38071 	return SQLITE_OK
  38072 }
  38073 
  38074 // If the given Mem* has a zero-filled tail, turn it into an ordinary
  38075 // blob stored in dynamically allocated space.
  38076 func Xsqlite3VdbeMemExpandBlob(tls *libc.TLS, pMem uintptr) int32 {
  38077 	var nByte int32
  38078 
  38079 	nByte = (*Mem)(unsafe.Pointer(pMem)).Fn + *(*int32)(unsafe.Pointer(pMem))
  38080 	if nByte <= 0 {
  38081 		if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Blob == 0 {
  38082 			return SQLITE_OK
  38083 		}
  38084 		nByte = 1
  38085 	}
  38086 	if Xsqlite3VdbeMemGrow(tls, pMem, nByte, 1) != 0 {
  38087 		return SQLITE_NOMEM
  38088 	}
  38089 
  38090 	libc.Xmemset(tls, (*Mem)(unsafe.Pointer(pMem)).Fz+uintptr((*Mem)(unsafe.Pointer(pMem)).Fn), 0, uint32(*(*int32)(unsafe.Pointer(pMem))))
  38091 	*(*int32)(unsafe.Pointer(pMem + 12)) += *(*int32)(unsafe.Pointer(pMem))
  38092 	*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Zero | MEM_Term))
  38093 	return SQLITE_OK
  38094 }
  38095 
  38096 // Make sure the given Mem is \u0000 terminated.
  38097 func Xsqlite3VdbeMemNulTerminate(tls *libc.TLS, pMem uintptr) int32 {
  38098 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Term|MEM_Str) != MEM_Str {
  38099 		return SQLITE_OK
  38100 	} else {
  38101 		return vdbeMemAddTerminator(tls, pMem)
  38102 	}
  38103 	return int32(0)
  38104 }
  38105 
  38106 // Add MEM_Str to the set of representations for the given Mem.  This
  38107 // routine is only called if pMem is a number of some kind, not a NULL
  38108 // or a BLOB.
  38109 //
  38110 // Existing representations MEM_Int, MEM_Real, or MEM_IntReal are invalidated
  38111 // if bForce is true but are retained if bForce is false.
  38112 //
  38113 // A MEM_Null value will never be passed to this function. This function is
  38114 // used for converting values to text for returning to the user (i.e. via
  38115 // sqlite3_value_text()), or for ensuring that values to be used as btree
  38116 // keys are strings. In the former case a NULL pointer is returned the
  38117 // user and the latter is an internal programming error.
  38118 func Xsqlite3VdbeMemStringify(tls *libc.TLS, pMem uintptr, enc U8, bForce U8) int32 {
  38119 	var nByte int32 = 32
  38120 
  38121 	if Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) != 0 {
  38122 		(*Mem)(unsafe.Pointer(pMem)).Fenc = U8(0)
  38123 		return SQLITE_NOMEM
  38124 	}
  38125 
  38126 	vdbeMemRenderNum(tls, nByte, (*Mem)(unsafe.Pointer(pMem)).Fz, pMem)
  38127 
  38128 	(*Mem)(unsafe.Pointer(pMem)).Fenc = U8(SQLITE_UTF8)
  38129 	*(*U16)(unsafe.Pointer(pMem + 16)) |= U16(MEM_Str | MEM_Term)
  38130 	if bForce != 0 {
  38131 		*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int | MEM_Real | MEM_IntReal))
  38132 	}
  38133 	Xsqlite3VdbeChangeEncoding(tls, pMem, int32(enc))
  38134 	return SQLITE_OK
  38135 }
  38136 
  38137 // Memory cell pMem contains the context of an aggregate function.
  38138 // This routine calls the finalize method for that function.  The
  38139 // result of the aggregate is stored back into pMem.
  38140 //
  38141 // Return SQLITE_ERROR if the finalizer reports an error.  SQLITE_OK
  38142 // otherwise.
  38143 func Xsqlite3VdbeMemFinalize(tls *libc.TLS, pMem uintptr, pFunc uintptr) int32 {
  38144 	bp := tls.Alloc(72)
  38145 	defer tls.Free(72)
  38146 
  38147 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Sqlite3_context{})))
  38148 	libc.Xmemset(tls, bp+32, 0, uint32(unsafe.Sizeof(Mem{})))
  38149 	(*Mem)(unsafe.Pointer(bp + 32)).Fflags = U16(MEM_Null)
  38150 	(*Mem)(unsafe.Pointer(bp + 32)).Fdb = (*Mem)(unsafe.Pointer(pMem)).Fdb
  38151 	(*Sqlite3_context)(unsafe.Pointer(bp)).FpOut = bp + 32
  38152 	(*Sqlite3_context)(unsafe.Pointer(bp)).FpMem = pMem
  38153 	(*Sqlite3_context)(unsafe.Pointer(bp)).FpFunc = pFunc
  38154 	(*Sqlite3_context)(unsafe.Pointer(bp)).Fenc = (*Sqlite3)(unsafe.Pointer((*Mem)(unsafe.Pointer(bp + 32)).Fdb)).Fenc
  38155 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*FuncDef)(unsafe.Pointer(pFunc)).FxFinalize})).f(tls, bp)
  38156 
  38157 	if (*Mem)(unsafe.Pointer(pMem)).FszMalloc > 0 {
  38158 		Xsqlite3DbFreeNN(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc)
  38159 	}
  38160 	libc.Xmemcpy(tls, pMem, bp+32, uint32(unsafe.Sizeof(Mem{})))
  38161 	return (*Sqlite3_context)(unsafe.Pointer(bp)).FisError
  38162 }
  38163 
  38164 // Memory cell pAccum contains the context of an aggregate function.
  38165 // This routine calls the xValue method for that function and stores
  38166 // the results in memory cell pMem.
  38167 //
  38168 // SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK
  38169 // otherwise.
  38170 func Xsqlite3VdbeMemAggValue(tls *libc.TLS, pAccum uintptr, pOut uintptr, pFunc uintptr) int32 {
  38171 	bp := tls.Alloc(32)
  38172 	defer tls.Free(32)
  38173 
  38174 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Sqlite3_context{})))
  38175 	Xsqlite3VdbeMemSetNull(tls, pOut)
  38176 	(*Sqlite3_context)(unsafe.Pointer(bp)).FpOut = pOut
  38177 	(*Sqlite3_context)(unsafe.Pointer(bp)).FpMem = pAccum
  38178 	(*Sqlite3_context)(unsafe.Pointer(bp)).FpFunc = pFunc
  38179 	(*Sqlite3_context)(unsafe.Pointer(bp)).Fenc = (*Sqlite3)(unsafe.Pointer((*Mem)(unsafe.Pointer(pAccum)).Fdb)).Fenc
  38180 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*FuncDef)(unsafe.Pointer(pFunc)).FxValue})).f(tls, bp)
  38181 	return (*Sqlite3_context)(unsafe.Pointer(bp)).FisError
  38182 }
  38183 
  38184 func vdbeMemClearExternAndSetNull(tls *libc.TLS, p uintptr) {
  38185 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Agg != 0 {
  38186 		Xsqlite3VdbeMemFinalize(tls, p, *(*uintptr)(unsafe.Pointer(p)))
  38187 
  38188 	}
  38189 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Dyn != 0 {
  38190 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Mem)(unsafe.Pointer(p)).FxDel})).f(tls, (*Mem)(unsafe.Pointer(p)).Fz)
  38191 	}
  38192 	(*Mem)(unsafe.Pointer(p)).Fflags = U16(MEM_Null)
  38193 }
  38194 
  38195 func vdbeMemClear(tls *libc.TLS, p uintptr) {
  38196 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  38197 		vdbeMemClearExternAndSetNull(tls, p)
  38198 	}
  38199 	if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 {
  38200 		Xsqlite3DbFreeNN(tls, (*Mem)(unsafe.Pointer(p)).Fdb, (*Mem)(unsafe.Pointer(p)).FzMalloc)
  38201 		(*Mem)(unsafe.Pointer(p)).FszMalloc = 0
  38202 	}
  38203 	(*Mem)(unsafe.Pointer(p)).Fz = uintptr(0)
  38204 }
  38205 
  38206 // Release any memory resources held by the Mem.  Both the memory that is
  38207 // free by Mem.xDel and the Mem.zMalloc allocation are freed.
  38208 //
  38209 // Use this routine prior to clean up prior to abandoning a Mem, or to
  38210 // reset a Mem back to its minimum memory utilization.
  38211 //
  38212 // Use sqlite3VdbeMemSetNull() to release just the Mem.xDel space
  38213 // prior to inserting new content into the Mem.
  38214 func Xsqlite3VdbeMemRelease(tls *libc.TLS, p uintptr) {
  38215 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 || (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 {
  38216 		vdbeMemClear(tls, p)
  38217 	}
  38218 }
  38219 
  38220 // Like sqlite3VdbeMemRelease() but faster for cases where we
  38221 // know in advance that the Mem is not MEM_Dyn or MEM_Agg.
  38222 func Xsqlite3VdbeMemReleaseMalloc(tls *libc.TLS, p uintptr) {
  38223 	if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 {
  38224 		vdbeMemClear(tls, p)
  38225 	}
  38226 }
  38227 
  38228 func doubleToInt64(tls *libc.TLS, r float64) I64 {
  38229 	if r <= float64(minInt) {
  38230 		return minInt
  38231 	} else if r >= float64(maxInt) {
  38232 		return maxInt
  38233 	} else {
  38234 		return I64(r)
  38235 	}
  38236 	return I64(0)
  38237 }
  38238 
  38239 var maxInt I64 = int64(0xffffffff) | int64(0x7fffffff)<<32
  38240 var minInt I64 = int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
  38241 
  38242 func memIntValue(tls *libc.TLS, pMem uintptr) I64 {
  38243 	bp := tls.Alloc(8)
  38244 	defer tls.Free(8)
  38245 
  38246 	*(*I64)(unsafe.Pointer(bp)) = int64(0)
  38247 	Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc)
  38248 	return *(*I64)(unsafe.Pointer(bp))
  38249 }
  38250 
  38251 func Xsqlite3VdbeIntValue(tls *libc.TLS, pMem uintptr) I64 {
  38252 	var flags int32
  38253 
  38254 	flags = int32((*Mem)(unsafe.Pointer(pMem)).Fflags)
  38255 	if flags&(MEM_Int|MEM_IntReal) != 0 {
  38256 		return *(*I64)(unsafe.Pointer(pMem))
  38257 	} else if flags&MEM_Real != 0 {
  38258 		return doubleToInt64(tls, *(*float64)(unsafe.Pointer(pMem)))
  38259 	} else if flags&(MEM_Str|MEM_Blob) != 0 && (*Mem)(unsafe.Pointer(pMem)).Fz != uintptr(0) {
  38260 		return memIntValue(tls, pMem)
  38261 	} else {
  38262 		return int64(0)
  38263 	}
  38264 	return I64(0)
  38265 }
  38266 
  38267 func memRealValue(tls *libc.TLS, pMem uintptr) float64 {
  38268 	bp := tls.Alloc(8)
  38269 	defer tls.Free(8)
  38270 
  38271 	*(*float64)(unsafe.Pointer(bp)) = float64(0)
  38272 	Xsqlite3AtoF(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc)
  38273 	return *(*float64)(unsafe.Pointer(bp))
  38274 }
  38275 
  38276 func Xsqlite3VdbeRealValue(tls *libc.TLS, pMem uintptr) float64 {
  38277 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Real != 0 {
  38278 		return *(*float64)(unsafe.Pointer(pMem))
  38279 	} else if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Int|MEM_IntReal) != 0 {
  38280 		return float64(*(*I64)(unsafe.Pointer(pMem)))
  38281 	} else if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Str|MEM_Blob) != 0 {
  38282 		return memRealValue(tls, pMem)
  38283 	} else {
  38284 		return float64(0)
  38285 	}
  38286 	return float64(0)
  38287 }
  38288 
  38289 // Return 1 if pMem represents true, and return 0 if pMem represents false.
  38290 // Return the value ifNull if pMem is NULL.
  38291 func Xsqlite3VdbeBooleanValue(tls *libc.TLS, pMem uintptr, ifNull int32) int32 {
  38292 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Int|MEM_IntReal) != 0 {
  38293 		return libc.Bool32(*(*I64)(unsafe.Pointer(pMem)) != int64(0))
  38294 	}
  38295 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Null != 0 {
  38296 		return ifNull
  38297 	}
  38298 	return libc.Bool32(Xsqlite3VdbeRealValue(tls, pMem) != 0.0)
  38299 }
  38300 
  38301 // The MEM structure is already a MEM_Real or MEM_IntReal. Try to
  38302 // make it a MEM_Int if we can.
  38303 func Xsqlite3VdbeIntegerAffinity(tls *libc.TLS, pMem uintptr) {
  38304 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_IntReal != 0 {
  38305 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  38306 	} else {
  38307 		var ix I64 = doubleToInt64(tls, *(*float64)(unsafe.Pointer(pMem)))
  38308 
  38309 		if *(*float64)(unsafe.Pointer(pMem)) == float64(ix) && ix > int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32) && ix < int64(0xffffffff)|int64(0x7fffffff)<<32 {
  38310 			*(*I64)(unsafe.Pointer(pMem)) = ix
  38311 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  38312 		}
  38313 	}
  38314 }
  38315 
  38316 // Convert pMem to type integer.  Invalidate any prior representations.
  38317 func Xsqlite3VdbeMemIntegerify(tls *libc.TLS, pMem uintptr) int32 {
  38318 	*(*I64)(unsafe.Pointer(pMem)) = Xsqlite3VdbeIntValue(tls, pMem)
  38319 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  38320 	return SQLITE_OK
  38321 }
  38322 
  38323 // Convert pMem so that it is of type MEM_Real.
  38324 // Invalidate any prior representations.
  38325 func Xsqlite3VdbeMemRealify(tls *libc.TLS, pMem uintptr) int32 {
  38326 	*(*float64)(unsafe.Pointer(pMem)) = Xsqlite3VdbeRealValue(tls, pMem)
  38327 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Real)
  38328 	return SQLITE_OK
  38329 }
  38330 
  38331 // Compare a floating point value to an integer.  Return true if the two
  38332 // values are the same within the precision of the floating point value.
  38333 //
  38334 // This function assumes that i was obtained by assignment from r1.
  38335 //
  38336 // For some versions of GCC on 32-bit machines, if you do the more obvious
  38337 // comparison of "r1==(double)i" you sometimes get an answer of false even
  38338 // though the r1 and (double)i values are bit-for-bit the same.
  38339 func Xsqlite3RealSameAsInt(tls *libc.TLS, r1 float64, i Sqlite3_int64) int32 {
  38340 	bp := tls.Alloc(16)
  38341 	defer tls.Free(16)
  38342 	*(*float64)(unsafe.Pointer(bp)) = r1
  38343 
  38344 	*(*float64)(unsafe.Pointer(bp + 8)) = float64(i)
  38345 	return libc.Bool32(*(*float64)(unsafe.Pointer(bp)) == 0.0 ||
  38346 		libc.Xmemcmp(tls, bp, bp+8, uint32(unsafe.Sizeof(float64(0)))) == 0 &&
  38347 			i >= -2251799813685248 && i < 2251799813685248)
  38348 }
  38349 
  38350 // Convert a floating point value to its closest integer.  Do so in
  38351 // a way that avoids 'outside the range of representable values' warnings
  38352 // from UBSAN.
  38353 func Xsqlite3RealToI64(tls *libc.TLS, r float64) I64 {
  38354 	if r <= float64(int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32)) {
  38355 		return int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
  38356 	}
  38357 	if r >= float64(int64(0xffffffff)|int64(0x7fffffff)<<32) {
  38358 		return int64(0xffffffff) | int64(0x7fffffff)<<32
  38359 	}
  38360 	return I64(r)
  38361 }
  38362 
  38363 // Convert pMem so that it has type MEM_Real or MEM_Int.
  38364 // Invalidate any prior representations.
  38365 //
  38366 // Every effort is made to force the conversion, even if the input
  38367 // is a string that does not look completely like a number.  Convert
  38368 // as much of the string as we can and ignore the rest.
  38369 func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 {
  38370 	bp := tls.Alloc(8)
  38371 	defer tls.Free(8)
  38372 
  38373 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Int|MEM_Real|MEM_IntReal|MEM_Null) == 0 {
  38374 		var rc int32
  38375 
  38376 		rc = Xsqlite3AtoF(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, pMem, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc)
  38377 		if (rc == 0 || rc == 1) && Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) <= 1 ||
  38378 			Xsqlite3RealSameAsInt(tls, *(*float64)(unsafe.Pointer(pMem)), libc.AssignPtrInt64(bp, Xsqlite3RealToI64(tls, *(*float64)(unsafe.Pointer(pMem))))) != 0 {
  38379 			*(*I64)(unsafe.Pointer(pMem)) = *(*Sqlite3_int64)(unsafe.Pointer(bp))
  38380 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  38381 		} else {
  38382 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Real)
  38383 		}
  38384 	}
  38385 
  38386 	*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Str | MEM_Blob | MEM_Zero))
  38387 	return SQLITE_OK
  38388 }
  38389 
  38390 // Cast the datatype of the value in pMem according to the affinity
  38391 // "aff".  Casting is different from applying affinity in that a cast
  38392 // is forced.  In other words, the value is converted into the desired
  38393 // affinity even if that results in loss of data.  This routine is
  38394 // used (for example) to implement the SQL "cast()" operator.
  38395 func Xsqlite3VdbeMemCast(tls *libc.TLS, pMem uintptr, aff U8, encoding U8) int32 {
  38396 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Null != 0 {
  38397 		return SQLITE_OK
  38398 	}
  38399 	switch int32(aff) {
  38400 	case SQLITE_AFF_BLOB:
  38401 		{
  38402 			if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Blob == 0 {
  38403 				Xsqlite3ValueApplyAffinity(tls, pMem, uint8(SQLITE_AFF_TEXT), encoding)
  38404 
  38405 				if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Str != 0 {
  38406 					(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Blob)
  38407 				}
  38408 			} else {
  38409 				*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_TypeMask & libc.CplInt32(MEM_Blob)))
  38410 			}
  38411 			break
  38412 
  38413 		}
  38414 	case SQLITE_AFF_NUMERIC:
  38415 		{
  38416 			Xsqlite3VdbeMemNumerify(tls, pMem)
  38417 			break
  38418 
  38419 		}
  38420 	case SQLITE_AFF_INTEGER:
  38421 		{
  38422 			Xsqlite3VdbeMemIntegerify(tls, pMem)
  38423 			break
  38424 
  38425 		}
  38426 	case SQLITE_AFF_REAL:
  38427 		{
  38428 			Xsqlite3VdbeMemRealify(tls, pMem)
  38429 			break
  38430 
  38431 		}
  38432 	default:
  38433 		{
  38434 			*(*U16)(unsafe.Pointer(pMem + 16)) |= U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob >> 3)
  38435 			Xsqlite3ValueApplyAffinity(tls, pMem, uint8(SQLITE_AFF_TEXT), encoding)
  38436 
  38437 			*(*U16)(unsafe.Pointer(pMem + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int | MEM_Real | MEM_IntReal | MEM_Blob | MEM_Zero))
  38438 			if int32(encoding) != SQLITE_UTF8 {
  38439 				*(*int32)(unsafe.Pointer(pMem + 12)) &= libc.CplInt32(1)
  38440 			}
  38441 			return Xsqlite3VdbeChangeEncoding(tls, pMem, int32(encoding))
  38442 
  38443 		}
  38444 	}
  38445 	return SQLITE_OK
  38446 }
  38447 
  38448 // Initialize bulk memory to be a consistent Mem object.
  38449 //
  38450 // The minimum amount of initialization feasible is performed.
  38451 func Xsqlite3VdbeMemInit(tls *libc.TLS, pMem uintptr, db uintptr, flags U16) {
  38452 	(*Mem)(unsafe.Pointer(pMem)).Fflags = flags
  38453 	(*Mem)(unsafe.Pointer(pMem)).Fdb = db
  38454 	(*Mem)(unsafe.Pointer(pMem)).FszMalloc = 0
  38455 }
  38456 
  38457 // Delete any previous value and set the value stored in *pMem to NULL.
  38458 //
  38459 // This routine calls the Mem.xDel destructor to dispose of values that
  38460 // require the destructor.  But it preserves the Mem.zMalloc memory allocation.
  38461 // To free all resources, use sqlite3VdbeMemRelease(), which both calls this
  38462 // routine to invoke the destructor and deallocates Mem.zMalloc.
  38463 //
  38464 // Use this routine to reset the Mem prior to insert a new value.
  38465 //
  38466 // Use sqlite3VdbeMemRelease() to complete erase the Mem prior to abandoning it.
  38467 func Xsqlite3VdbeMemSetNull(tls *libc.TLS, pMem uintptr) {
  38468 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  38469 		vdbeMemClearExternAndSetNull(tls, pMem)
  38470 	} else {
  38471 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Null)
  38472 	}
  38473 }
  38474 
  38475 func Xsqlite3ValueSetNull(tls *libc.TLS, p uintptr) {
  38476 	Xsqlite3VdbeMemSetNull(tls, p)
  38477 }
  38478 
  38479 // Delete any previous value and set the value to be a BLOB of length
  38480 // n containing all zeros.
  38481 func Xsqlite3VdbeMemSetZeroBlob(tls *libc.TLS, pMem uintptr, n int32) {
  38482 	Xsqlite3VdbeMemRelease(tls, pMem)
  38483 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Blob | MEM_Zero)
  38484 	(*Mem)(unsafe.Pointer(pMem)).Fn = 0
  38485 	if n < 0 {
  38486 		n = 0
  38487 	}
  38488 	*(*int32)(unsafe.Pointer(pMem)) = n
  38489 	(*Mem)(unsafe.Pointer(pMem)).Fenc = U8(SQLITE_UTF8)
  38490 	(*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0)
  38491 }
  38492 
  38493 func vdbeReleaseAndSetInt64(tls *libc.TLS, pMem uintptr, val I64) {
  38494 	Xsqlite3VdbeMemSetNull(tls, pMem)
  38495 	*(*I64)(unsafe.Pointer(pMem)) = val
  38496 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  38497 }
  38498 
  38499 // Delete any previous value and set the value stored in *pMem to val,
  38500 // manifest type INTEGER.
  38501 func Xsqlite3VdbeMemSetInt64(tls *libc.TLS, pMem uintptr, val I64) {
  38502 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  38503 		vdbeReleaseAndSetInt64(tls, pMem, val)
  38504 	} else {
  38505 		*(*I64)(unsafe.Pointer(pMem)) = val
  38506 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  38507 	}
  38508 }
  38509 
  38510 // A no-op destructor
  38511 func Xsqlite3NoopDestructor(tls *libc.TLS, p uintptr) {
  38512 	_ = p
  38513 }
  38514 
  38515 // Set the value stored in *pMem should already be a NULL.
  38516 // Also store a pointer to go with it.
  38517 func Xsqlite3VdbeMemSetPointer(tls *libc.TLS, pMem uintptr, pPtr uintptr, zPType uintptr, xDestructor uintptr) {
  38518 	vdbeMemClear(tls, pMem)
  38519 	*(*uintptr)(unsafe.Pointer(pMem)) = func() uintptr {
  38520 		if zPType != 0 {
  38521 			return zPType
  38522 		}
  38523 		return ts + 1554
  38524 	}()
  38525 	(*Mem)(unsafe.Pointer(pMem)).Fz = pPtr
  38526 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Null | MEM_Dyn | MEM_Subtype | MEM_Term)
  38527 	(*Mem)(unsafe.Pointer(pMem)).FeSubtype = U8('p')
  38528 	(*Mem)(unsafe.Pointer(pMem)).FxDel = func() uintptr {
  38529 		if xDestructor != 0 {
  38530 			return xDestructor
  38531 		}
  38532 		return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3NoopDestructor}))
  38533 	}()
  38534 }
  38535 
  38536 // Delete any previous value and set the value stored in *pMem to val,
  38537 // manifest type REAL.
  38538 func Xsqlite3VdbeMemSetDouble(tls *libc.TLS, pMem uintptr, val float64) {
  38539 	Xsqlite3VdbeMemSetNull(tls, pMem)
  38540 	if !(Xsqlite3IsNaN(tls, val) != 0) {
  38541 		*(*float64)(unsafe.Pointer(pMem)) = val
  38542 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Real)
  38543 	}
  38544 }
  38545 
  38546 // Delete any previous value and set the value of pMem to be an
  38547 // empty boolean index.
  38548 //
  38549 // Return SQLITE_OK on success and SQLITE_NOMEM if a memory allocation
  38550 // error occurs.
  38551 func Xsqlite3VdbeMemSetRowSet(tls *libc.TLS, pMem uintptr) int32 {
  38552 	var db uintptr = (*Mem)(unsafe.Pointer(pMem)).Fdb
  38553 	var p uintptr
  38554 
  38555 	Xsqlite3VdbeMemRelease(tls, pMem)
  38556 	p = Xsqlite3RowSetInit(tls, db)
  38557 	if p == uintptr(0) {
  38558 		return SQLITE_NOMEM
  38559 	}
  38560 	(*Mem)(unsafe.Pointer(pMem)).Fz = p
  38561 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Blob | MEM_Dyn)
  38562 	(*Mem)(unsafe.Pointer(pMem)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3RowSetDelete}))
  38563 	return SQLITE_OK
  38564 }
  38565 
  38566 // Return true if the Mem object contains a TEXT or BLOB that is
  38567 // too large - whose size exceeds SQLITE_MAX_LENGTH.
  38568 func Xsqlite3VdbeMemTooBig(tls *libc.TLS, p uintptr) int32 {
  38569 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Str|MEM_Blob) != 0 {
  38570 		var n int32 = (*Mem)(unsafe.Pointer(p)).Fn
  38571 		if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Zero != 0 {
  38572 			n = n + *(*int32)(unsafe.Pointer(p))
  38573 		}
  38574 		return libc.Bool32(n > *(*int32)(unsafe.Pointer((*Mem)(unsafe.Pointer(p)).Fdb + 120)))
  38575 	}
  38576 	return 0
  38577 }
  38578 
  38579 func vdbeClrCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, eType int32) {
  38580 	vdbeMemClearExternAndSetNull(tls, pTo)
  38581 
  38582 	Xsqlite3VdbeMemShallowCopy(tls, pTo, pFrom, eType)
  38583 }
  38584 
  38585 func Xsqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcType int32) {
  38586 	if int32((*Mem)(unsafe.Pointer(pTo)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  38587 		vdbeClrCopy(tls, pTo, pFrom, srcType)
  38588 		return
  38589 	}
  38590 	libc.Xmemcpy(tls, pTo, pFrom, uint32(uintptr(0)+20))
  38591 	if int32((*Mem)(unsafe.Pointer(pFrom)).Fflags)&MEM_Static == 0 {
  38592 		*(*U16)(unsafe.Pointer(pTo + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Dyn | MEM_Static | MEM_Ephem))
  38593 
  38594 		*(*U16)(unsafe.Pointer(pTo + 16)) |= U16(srcType)
  38595 	}
  38596 }
  38597 
  38598 // Make a full copy of pFrom into pTo.  Prior contents of pTo are
  38599 // freed before the copy is made.
  38600 func Xsqlite3VdbeMemCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr) int32 {
  38601 	var rc int32 = SQLITE_OK
  38602 
  38603 	if int32((*Mem)(unsafe.Pointer(pTo)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  38604 		vdbeMemClearExternAndSetNull(tls, pTo)
  38605 	}
  38606 	libc.Xmemcpy(tls, pTo, pFrom, uint32(uintptr(0)+20))
  38607 	*(*U16)(unsafe.Pointer(pTo + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Dyn))
  38608 	if int32((*Mem)(unsafe.Pointer(pTo)).Fflags)&(MEM_Str|MEM_Blob) != 0 {
  38609 		if 0 == int32((*Mem)(unsafe.Pointer(pFrom)).Fflags)&MEM_Static {
  38610 			*(*U16)(unsafe.Pointer(pTo + 16)) |= U16(MEM_Ephem)
  38611 			rc = Xsqlite3VdbeMemMakeWriteable(tls, pTo)
  38612 		}
  38613 	}
  38614 
  38615 	return rc
  38616 }
  38617 
  38618 // Transfer the contents of pFrom to pTo. Any existing value in pTo is
  38619 // freed. If pFrom contains ephemeral data, a copy is made.
  38620 //
  38621 // pFrom contains an SQL NULL when this routine returns.
  38622 func Xsqlite3VdbeMemMove(tls *libc.TLS, pTo uintptr, pFrom uintptr) {
  38623 	Xsqlite3VdbeMemRelease(tls, pTo)
  38624 	libc.Xmemcpy(tls, pTo, pFrom, uint32(unsafe.Sizeof(Mem{})))
  38625 	(*Mem)(unsafe.Pointer(pFrom)).Fflags = U16(MEM_Null)
  38626 	(*Mem)(unsafe.Pointer(pFrom)).FszMalloc = 0
  38627 }
  38628 
  38629 // Change the value of a Mem to be a string or a BLOB.
  38630 //
  38631 // The memory management strategy depends on the value of the xDel
  38632 // parameter. If the value passed is SQLITE_TRANSIENT, then the
  38633 // string is copied into a (possibly existing) buffer managed by the
  38634 // Mem structure. Otherwise, any existing buffer is freed and the
  38635 // pointer copied.
  38636 //
  38637 // If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH
  38638 // size limit) then no memory allocation occurs.  If the string can be
  38639 // stored without allocating memory, then it is.  If a memory allocation
  38640 // is required to store the string, then value of pMem is unchanged.  In
  38641 // either case, SQLITE_TOOBIG is returned.
  38642 //
  38643 // The "enc" parameter is the text encoding for the string, or zero
  38644 // to store a blob.
  38645 //
  38646 // If n is negative, then the string consists of all bytes up to but
  38647 // excluding the first zero character.  The n parameter must be
  38648 // non-negative for blobs.
  38649 func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n I64, enc U8, xDel uintptr) int32 {
  38650 	var nByte I64 = n
  38651 	var iLimit int32
  38652 	var flags U16
  38653 
  38654 	if !(z != 0) {
  38655 		Xsqlite3VdbeMemSetNull(tls, pMem)
  38656 		return SQLITE_OK
  38657 	}
  38658 
  38659 	if (*Mem)(unsafe.Pointer(pMem)).Fdb != 0 {
  38660 		iLimit = *(*int32)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fdb + 120))
  38661 	} else {
  38662 		iLimit = SQLITE_MAX_LENGTH
  38663 	}
  38664 	if nByte < int64(0) {
  38665 		if int32(enc) == SQLITE_UTF8 {
  38666 			nByte = I64(libc.Xstrlen(tls, z))
  38667 		} else {
  38668 			for nByte = int64(0); nByte <= I64(iLimit) && int32(*(*uint8)(unsafe.Pointer(z + uintptr(nByte))))|int32(*(*uint8)(unsafe.Pointer(z + uintptr(nByte+int64(1))))) != 0; nByte = nByte + int64(2) {
  38669 			}
  38670 		}
  38671 		flags = U16(MEM_Str | MEM_Term)
  38672 	} else if int32(enc) == 0 {
  38673 		flags = U16(MEM_Blob)
  38674 		enc = U8(SQLITE_UTF8)
  38675 	} else {
  38676 		flags = U16(MEM_Str)
  38677 	}
  38678 	if nByte > I64(iLimit) {
  38679 		if xDel != 0 && xDel != libc.UintptrFromInt32(-1) {
  38680 			if xDel == *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})) {
  38681 				Xsqlite3DbFree(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, z)
  38682 			} else {
  38683 				(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDel})).f(tls, z)
  38684 			}
  38685 		}
  38686 		Xsqlite3VdbeMemSetNull(tls, pMem)
  38687 		return Xsqlite3ErrorToParser(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, SQLITE_TOOBIG)
  38688 	}
  38689 
  38690 	if xDel == libc.UintptrFromInt32(-1) {
  38691 		var nAlloc I64 = nByte
  38692 		if int32(flags)&MEM_Term != 0 {
  38693 			nAlloc = nAlloc + func() int64 {
  38694 				if int32(enc) == SQLITE_UTF8 {
  38695 					return int64(1)
  38696 				}
  38697 				return int64(2)
  38698 			}()
  38699 		}
  38700 
  38701 		if Xsqlite3VdbeMemClearAndResize(tls, pMem, func() int32 {
  38702 			if nAlloc > int64(32) {
  38703 				return int32(nAlloc)
  38704 			}
  38705 			return 32
  38706 		}()) != 0 {
  38707 			return SQLITE_NOMEM
  38708 		}
  38709 		libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, z, uint32(nAlloc))
  38710 	} else {
  38711 		Xsqlite3VdbeMemRelease(tls, pMem)
  38712 		(*Mem)(unsafe.Pointer(pMem)).Fz = z
  38713 		if xDel == *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})) {
  38714 			(*Mem)(unsafe.Pointer(pMem)).FzMalloc = (*Mem)(unsafe.Pointer(pMem)).Fz
  38715 			(*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc)
  38716 		} else {
  38717 			(*Mem)(unsafe.Pointer(pMem)).FxDel = xDel
  38718 			flags = U16(int32(flags) | func() int32 {
  38719 				if xDel == uintptr(0) {
  38720 					return MEM_Static
  38721 				}
  38722 				return MEM_Dyn
  38723 			}())
  38724 		}
  38725 	}
  38726 
  38727 	(*Mem)(unsafe.Pointer(pMem)).Fn = int32(nByte & int64(0x7fffffff))
  38728 	(*Mem)(unsafe.Pointer(pMem)).Fflags = flags
  38729 	(*Mem)(unsafe.Pointer(pMem)).Fenc = enc
  38730 
  38731 	if int32(enc) > SQLITE_UTF8 && Xsqlite3VdbeMemHandleBom(tls, pMem) != 0 {
  38732 		return SQLITE_NOMEM
  38733 	}
  38734 
  38735 	return SQLITE_OK
  38736 }
  38737 
  38738 // Move data out of a btree key or data field and into a Mem structure.
  38739 // The data is payload from the entry that pCur is currently pointing
  38740 // to.  offset and amt determine what portion of the data or key to retrieve.
  38741 // The result is written into the pMem element.
  38742 //
  38743 // The pMem object must have been initialized.  This routine will use
  38744 // pMem->zMalloc to hold the content from the btree, if possible.  New
  38745 // pMem->zMalloc space will be allocated if necessary.  The calling routine
  38746 // is responsible for making sure that the pMem object is eventually
  38747 // destroyed.
  38748 //
  38749 // If this routine fails for any reason (malloc returns NULL or unable
  38750 // to read from the disk) then the pMem is left in an inconsistent state.
  38751 func Xsqlite3VdbeMemFromBtree(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pMem uintptr) int32 {
  38752 	var rc int32
  38753 	(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Null)
  38754 	if Xsqlite3BtreeMaxRecordSize(tls, pCur) < Sqlite3_int64(offset+amt) {
  38755 		return Xsqlite3CorruptError(tls, 81634)
  38756 	}
  38757 	if SQLITE_OK == libc.AssignInt32(&rc, Xsqlite3VdbeMemClearAndResize(tls, pMem, int32(amt+U32(1)))) {
  38758 		rc = Xsqlite3BtreePayload(tls, pCur, offset, amt, (*Mem)(unsafe.Pointer(pMem)).Fz)
  38759 		if rc == SQLITE_OK {
  38760 			*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(amt))) = uint8(0)
  38761 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Blob)
  38762 			(*Mem)(unsafe.Pointer(pMem)).Fn = int32(amt)
  38763 		} else {
  38764 			Xsqlite3VdbeMemRelease(tls, pMem)
  38765 		}
  38766 	}
  38767 	return rc
  38768 }
  38769 
  38770 func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pMem uintptr) int32 {
  38771 	bp := tls.Alloc(4)
  38772 	defer tls.Free(4)
  38773 
  38774 	*(*U32)(unsafe.Pointer(bp)) = U32(0)
  38775 	var rc int32 = SQLITE_OK
  38776 
  38777 	(*Mem)(unsafe.Pointer(pMem)).Fz = Xsqlite3BtreePayloadFetch(tls, pCur, bp)
  38778 
  38779 	if amt <= *(*U32)(unsafe.Pointer(bp)) {
  38780 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Blob | MEM_Ephem)
  38781 		(*Mem)(unsafe.Pointer(pMem)).Fn = int32(amt)
  38782 	} else {
  38783 		rc = Xsqlite3VdbeMemFromBtree(tls, pCur, uint32(0), amt, pMem)
  38784 	}
  38785 
  38786 	return rc
  38787 }
  38788 
  38789 func valueToText(tls *libc.TLS, pVal uintptr, enc U8) uintptr {
  38790 	if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&(MEM_Blob|MEM_Str) != 0 {
  38791 		if func() int32 {
  38792 			if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&MEM_Zero != 0 {
  38793 				return Xsqlite3VdbeMemExpandBlob(tls, pVal)
  38794 			}
  38795 			return 0
  38796 		}() != 0 {
  38797 			return uintptr(0)
  38798 		}
  38799 		*(*U16)(unsafe.Pointer(pVal + 16)) |= U16(MEM_Str)
  38800 		if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) != int32(enc)&libc.CplInt32(SQLITE_UTF16_ALIGNED) {
  38801 			Xsqlite3VdbeChangeEncoding(tls, pVal, int32(enc)&libc.CplInt32(SQLITE_UTF16_ALIGNED))
  38802 		}
  38803 		if int32(enc)&SQLITE_UTF16_ALIGNED != 0 && 1 == 1&int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fz) {
  38804 			if Xsqlite3VdbeMemMakeWriteable(tls, pVal) != SQLITE_OK {
  38805 				return uintptr(0)
  38806 			}
  38807 		}
  38808 		Xsqlite3VdbeMemNulTerminate(tls, pVal)
  38809 	} else {
  38810 		Xsqlite3VdbeMemStringify(tls, pVal, enc, uint8(0))
  38811 
  38812 	}
  38813 
  38814 	if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)&libc.CplInt32(SQLITE_UTF16_ALIGNED) {
  38815 		return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz
  38816 	} else {
  38817 		return uintptr(0)
  38818 	}
  38819 	return uintptr(0)
  38820 }
  38821 
  38822 // This function is only available internally, it is not part of the
  38823 // external API. It works in a similar way to sqlite3_value_text(),
  38824 // except the data returned is in the encoding specified by the second
  38825 // parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or
  38826 // SQLITE_UTF8.
  38827 //
  38828 // (2006-02-16:)  The enc value can be or-ed with SQLITE_UTF16_ALIGNED.
  38829 // If that is the case, then the result must be aligned on an even byte
  38830 // boundary.
  38831 func Xsqlite3ValueText(tls *libc.TLS, pVal uintptr, enc U8) uintptr {
  38832 	if !(pVal != 0) {
  38833 		return uintptr(0)
  38834 	}
  38835 
  38836 	if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&(MEM_Str|MEM_Term) == MEM_Str|MEM_Term && int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc) {
  38837 		return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz
  38838 	}
  38839 	if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&MEM_Null != 0 {
  38840 		return uintptr(0)
  38841 	}
  38842 	return valueToText(tls, pVal, enc)
  38843 }
  38844 
  38845 // Create a new sqlite3_value object.
  38846 func Xsqlite3ValueNew(tls *libc.TLS, db uintptr) uintptr {
  38847 	var p uintptr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Mem{})))
  38848 	if p != 0 {
  38849 		(*Mem)(unsafe.Pointer(p)).Fflags = U16(MEM_Null)
  38850 		(*Mem)(unsafe.Pointer(p)).Fdb = db
  38851 	}
  38852 	return p
  38853 }
  38854 
  38855 // Context object passed by sqlite3Stat4ProbeSetValue() through to
  38856 // valueNew(). See comments above valueNew() for details.
  38857 type ValueNewStat4Ctx = struct {
  38858 	FpParse uintptr
  38859 	FpIdx   uintptr
  38860 	FppRec  uintptr
  38861 	FiVal   int32
  38862 }
  38863 
  38864 func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr {
  38865 	if p != 0 {
  38866 		var pRec uintptr = *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec))
  38867 
  38868 		if pRec == uintptr(0) {
  38869 			var pIdx uintptr = (*ValueNewStat4Ctx)(unsafe.Pointer(p)).FpIdx
  38870 			var nByte int32
  38871 			var i int32
  38872 			var nCol int32 = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  38873 
  38874 			nByte = int32(uint32(unsafe.Sizeof(Mem{}))*uint32(nCol) + (uint32(unsafe.Sizeof(UnpackedRecord{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)))
  38875 			pRec = Xsqlite3DbMallocZero(tls, db, uint64(nByte))
  38876 			if pRec != 0 {
  38877 				(*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo = Xsqlite3KeyInfoOfIndex(tls, (*ValueNewStat4Ctx)(unsafe.Pointer(p)).FpParse, pIdx)
  38878 				if (*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo != 0 {
  38879 					(*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem = pRec + uintptr((uint32(unsafe.Sizeof(UnpackedRecord{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)))
  38880 					for i = 0; i < nCol; i++ {
  38881 						(*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*40)).Fflags = U16(MEM_Null)
  38882 						(*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*40)).Fdb = db
  38883 					}
  38884 				} else {
  38885 					Xsqlite3DbFreeNN(tls, db, pRec)
  38886 					pRec = uintptr(0)
  38887 				}
  38888 			}
  38889 			if pRec == uintptr(0) {
  38890 				return uintptr(0)
  38891 			}
  38892 			*(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) = pRec
  38893 		}
  38894 
  38895 		(*UnpackedRecord)(unsafe.Pointer(pRec)).FnField = U16((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal + 1)
  38896 		return (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal)*40
  38897 	}
  38898 	return Xsqlite3ValueNew(tls, db)
  38899 }
  38900 
  38901 func valueFromFunction(tls *libc.TLS, db uintptr, p uintptr, enc U8, aff U8, ppVal uintptr, pCtx uintptr) int32 {
  38902 	bp := tls.Alloc(40)
  38903 	defer tls.Free(40)
  38904 
  38905 	var apVal uintptr
  38906 	var nVal int32
  38907 	var pFunc uintptr
  38908 	var pVal uintptr
  38909 	var rc int32
  38910 	var pList uintptr
  38911 	var i int32
  38912 	apVal = uintptr(0)
  38913 	nVal = 0
  38914 	pFunc = uintptr(0)
  38915 	pVal = uintptr(0)
  38916 	rc = SQLITE_OK
  38917 	pList = uintptr(0)
  38918 
  38919 	pList = *(*uintptr)(unsafe.Pointer(p + 20))
  38920 	if !(pList != 0) {
  38921 		goto __1
  38922 	}
  38923 	nVal = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  38924 __1:
  38925 	;
  38926 	pFunc = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(p + 8)), nVal, enc, uint8(0))
  38927 
  38928 	if !((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&U32(SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) == U32(0) ||
  38929 		(*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != 0) {
  38930 		goto __2
  38931 	}
  38932 	return SQLITE_OK
  38933 __2:
  38934 	;
  38935 	if !(pList != 0) {
  38936 		goto __3
  38937 	}
  38938 	apVal = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(uintptr(0)))*uint32(nVal)))
  38939 	if !(apVal == uintptr(0)) {
  38940 		goto __4
  38941 	}
  38942 	rc = SQLITE_NOMEM
  38943 	goto value_from_function_out
  38944 __4:
  38945 	;
  38946 	i = 0
  38947 __5:
  38948 	if !(i < nVal) {
  38949 		goto __7
  38950 	}
  38951 	rc = Xsqlite3ValueFromExpr(tls, db, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr, enc, aff, apVal+uintptr(i)*4)
  38952 	if !(*(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4)) == uintptr(0) || rc != SQLITE_OK) {
  38953 		goto __8
  38954 	}
  38955 	goto value_from_function_out
  38956 __8:
  38957 	;
  38958 	goto __6
  38959 __6:
  38960 	i++
  38961 	goto __5
  38962 	goto __7
  38963 __7:
  38964 	;
  38965 __3:
  38966 	;
  38967 	pVal = valueNew(tls, db, pCtx)
  38968 	if !(pVal == uintptr(0)) {
  38969 		goto __9
  38970 	}
  38971 	rc = SQLITE_NOMEM
  38972 	goto value_from_function_out
  38973 __9:
  38974 	;
  38975 	libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(Sqlite3_context{})))
  38976 	(*Sqlite3_context)(unsafe.Pointer(bp + 8)).FpOut = pVal
  38977 	(*Sqlite3_context)(unsafe.Pointer(bp + 8)).FpFunc = pFunc
  38978 	(*Sqlite3_context)(unsafe.Pointer(bp + 8)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  38979 	(*struct {
  38980 		f func(*libc.TLS, uintptr, int32, uintptr)
  38981 	})(unsafe.Pointer(&struct{ uintptr }{(*FuncDef)(unsafe.Pointer(pFunc)).FxSFunc})).f(tls, bp+8, nVal, apVal)
  38982 	if !((*Sqlite3_context)(unsafe.Pointer(bp+8)).FisError != 0) {
  38983 		goto __10
  38984 	}
  38985 	rc = (*Sqlite3_context)(unsafe.Pointer(bp + 8)).FisError
  38986 	Xsqlite3ErrorMsg(tls, (*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse, ts+3663, libc.VaList(bp, Xsqlite3_value_text(tls, pVal)))
  38987 	goto __11
  38988 __10:
  38989 	Xsqlite3ValueApplyAffinity(tls, pVal, aff, uint8(SQLITE_UTF8))
  38990 
  38991 __11:
  38992 	;
  38993 value_from_function_out:
  38994 	if !(rc != SQLITE_OK) {
  38995 		goto __12
  38996 	}
  38997 	pVal = uintptr(0)
  38998 	(*Parse)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse)).Frc = rc
  38999 __12:
  39000 	;
  39001 	if !(apVal != 0) {
  39002 		goto __13
  39003 	}
  39004 	i = 0
  39005 __14:
  39006 	if !(i < nVal) {
  39007 		goto __16
  39008 	}
  39009 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4)))
  39010 	goto __15
  39011 __15:
  39012 	i++
  39013 	goto __14
  39014 	goto __16
  39015 __16:
  39016 	;
  39017 	Xsqlite3DbFreeNN(tls, db, apVal)
  39018 __13:
  39019 	;
  39020 	*(*uintptr)(unsafe.Pointer(ppVal)) = pVal
  39021 	return rc
  39022 }
  39023 
  39024 func valueFromExpr(tls *libc.TLS, db uintptr, pExpr uintptr, enc U8, affinity U8, ppVal uintptr, pCtx uintptr) int32 {
  39025 	bp := tls.Alloc(20)
  39026 	defer tls.Free(20)
  39027 
  39028 	var op int32
  39029 	var zVal uintptr
  39030 
  39031 	var negInt int32
  39032 	var zNeg uintptr
  39033 	var rc int32
  39034 	var aff U8
  39035 	var nVal int32
  39036 	zVal = uintptr(0)
  39037 	*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
  39038 	negInt = 1
  39039 	zNeg = ts + 1554
  39040 	rc = SQLITE_OK
  39041 
  39042 __1:
  39043 	if !(libc.AssignInt32(&op, int32((*Expr)(unsafe.Pointer(pExpr)).Fop)) == TK_UPLUS || op == TK_SPAN) {
  39044 		goto __2
  39045 	}
  39046 	pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  39047 	goto __1
  39048 __2:
  39049 	;
  39050 	if !(op == TK_REGISTER) {
  39051 		goto __3
  39052 	}
  39053 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop2)
  39054 __3:
  39055 	;
  39056 	if !(op == TK_CAST) {
  39057 		goto __4
  39058 	}
  39059 
  39060 	aff = Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0))
  39061 	rc = valueFromExpr(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, enc, aff, ppVal, pCtx)
  39062 
  39063 	if !(*(*uintptr)(unsafe.Pointer(ppVal)) != 0) {
  39064 		goto __5
  39065 	}
  39066 	Xsqlite3VdbeMemCast(tls, *(*uintptr)(unsafe.Pointer(ppVal)), aff, enc)
  39067 	Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(ppVal)), affinity, enc)
  39068 __5:
  39069 	;
  39070 	return rc
  39071 __4:
  39072 	;
  39073 	if !(op == TK_UMINUS &&
  39074 		(int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_INTEGER || int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_FLOAT)) {
  39075 		goto __6
  39076 	}
  39077 	pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  39078 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
  39079 	negInt = -1
  39080 	zNeg = ts + 4932
  39081 __6:
  39082 	;
  39083 	if !(op == TK_STRING || op == TK_FLOAT || op == TK_INTEGER) {
  39084 		goto __7
  39085 	}
  39086 	*(*uintptr)(unsafe.Pointer(bp + 16)) = valueNew(tls, db, pCtx)
  39087 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) == uintptr(0)) {
  39088 		goto __9
  39089 	}
  39090 	goto no_mem
  39091 __9:
  39092 	;
  39093 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_IntValue) != U32(0)) {
  39094 		goto __10
  39095 	}
  39096 	Xsqlite3VdbeMemSetInt64(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), I64(*(*int32)(unsafe.Pointer(pExpr + 8)))*I64(negInt))
  39097 	goto __11
  39098 __10:
  39099 	zVal = Xsqlite3MPrintf(tls, db, ts+4934, libc.VaList(bp, zNeg, *(*uintptr)(unsafe.Pointer(pExpr + 8))))
  39100 	if !(zVal == uintptr(0)) {
  39101 		goto __12
  39102 	}
  39103 	goto no_mem
  39104 __12:
  39105 	;
  39106 	Xsqlite3ValueSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), -1, zVal, uint8(SQLITE_UTF8), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  39107 __11:
  39108 	;
  39109 	if !((op == TK_INTEGER || op == TK_FLOAT) && int32(affinity) == SQLITE_AFF_BLOB) {
  39110 		goto __13
  39111 	}
  39112 	Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), uint8(SQLITE_AFF_NUMERIC), uint8(SQLITE_UTF8))
  39113 	goto __14
  39114 __13:
  39115 	Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), affinity, uint8(SQLITE_UTF8))
  39116 __14:
  39117 	;
  39118 	if !(int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fflags)&(MEM_Int|MEM_IntReal|MEM_Real) != 0) {
  39119 		goto __15
  39120 	}
  39121 
  39122 	*(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Str))
  39123 __15:
  39124 	;
  39125 	if !(int32(enc) != SQLITE_UTF8) {
  39126 		goto __16
  39127 	}
  39128 	rc = Xsqlite3VdbeChangeEncoding(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), int32(enc))
  39129 __16:
  39130 	;
  39131 	goto __8
  39132 __7:
  39133 	if !(op == TK_UMINUS) {
  39134 		goto __17
  39135 	}
  39136 
  39137 	if !(SQLITE_OK == valueFromExpr(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, enc, affinity, bp+16, pCtx) &&
  39138 		*(*uintptr)(unsafe.Pointer(bp + 16)) != uintptr(0)) {
  39139 		goto __19
  39140 	}
  39141 	Xsqlite3VdbeMemNumerify(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  39142 	if !(int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fflags)&MEM_Real != 0) {
  39143 		goto __20
  39144 	}
  39145 	*(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))) = -*(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16))))
  39146 	goto __21
  39147 __20:
  39148 	if !(*(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))) == int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32)) {
  39149 		goto __22
  39150 	}
  39151 	*(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))) = -float64(int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32))
  39152 	(*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fflags = U16(int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Real)
  39153 	goto __23
  39154 __22:
  39155 	*(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))) = -*(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16))))
  39156 __23:
  39157 	;
  39158 __21:
  39159 	;
  39160 	Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), affinity, enc)
  39161 __19:
  39162 	;
  39163 	goto __18
  39164 __17:
  39165 	if !(op == TK_NULL) {
  39166 		goto __24
  39167 	}
  39168 	*(*uintptr)(unsafe.Pointer(bp + 16)) = valueNew(tls, db, pCtx)
  39169 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) == uintptr(0)) {
  39170 		goto __26
  39171 	}
  39172 	goto no_mem
  39173 __26:
  39174 	;
  39175 	Xsqlite3VdbeMemSetNull(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  39176 	goto __25
  39177 __24:
  39178 	if !(op == TK_BLOB) {
  39179 		goto __27
  39180 	}
  39181 
  39182 	*(*uintptr)(unsafe.Pointer(bp + 16)) = valueNew(tls, db, pCtx)
  39183 	if !!(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) {
  39184 		goto __29
  39185 	}
  39186 	goto no_mem
  39187 __29:
  39188 	;
  39189 	zVal = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + 2
  39190 	nVal = Xsqlite3Strlen30(tls, zVal) - 1
  39191 
  39192 	Xsqlite3VdbeMemSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), Xsqlite3HexToBlob(tls, db, zVal, nVal), int64(nVal/2),
  39193 		uint8(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  39194 	goto __28
  39195 __27:
  39196 	if !(op == TK_FUNCTION && pCtx != uintptr(0)) {
  39197 		goto __30
  39198 	}
  39199 	rc = valueFromFunction(tls, db, pExpr, enc, affinity, bp+16, pCtx)
  39200 	goto __31
  39201 __30:
  39202 	if !(op == TK_TRUEFALSE) {
  39203 		goto __32
  39204 	}
  39205 
  39206 	*(*uintptr)(unsafe.Pointer(bp + 16)) = valueNew(tls, db, pCtx)
  39207 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) {
  39208 		goto __33
  39209 	}
  39210 	(*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).Fflags = U16(MEM_Int)
  39211 	*(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))) = I64(libc.Bool32(int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8)) + 4))) == 0))
  39212 __33:
  39213 	;
  39214 __32:
  39215 	;
  39216 __31:
  39217 	;
  39218 __28:
  39219 	;
  39220 __25:
  39221 	;
  39222 __18:
  39223 	;
  39224 __8:
  39225 	;
  39226 	*(*uintptr)(unsafe.Pointer(ppVal)) = *(*uintptr)(unsafe.Pointer(bp + 16))
  39227 	return rc
  39228 
  39229 no_mem:
  39230 	if !(pCtx == uintptr(0) || (*Parse)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse)).FnErr == 0) {
  39231 		goto __34
  39232 	}
  39233 	Xsqlite3OomFault(tls, db)
  39234 __34:
  39235 	;
  39236 	Xsqlite3DbFree(tls, db, zVal)
  39237 
  39238 	if !(pCtx == uintptr(0)) {
  39239 		goto __35
  39240 	}
  39241 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  39242 __35:
  39243 	;
  39244 	return SQLITE_NOMEM
  39245 }
  39246 
  39247 // Create a new sqlite3_value object, containing the value of pExpr.
  39248 //
  39249 // This only works for very simple expressions that consist of one constant
  39250 // token (i.e. "5", "5.1", "'a string'"). If the expression can
  39251 // be converted directly into a value, then the value is allocated and
  39252 // a pointer written to *ppVal. The caller is responsible for deallocating
  39253 // the value by passing it to sqlite3ValueFree() later on. If the expression
  39254 // cannot be converted to a value, then *ppVal is set to NULL.
  39255 func Xsqlite3ValueFromExpr(tls *libc.TLS, db uintptr, pExpr uintptr, enc U8, affinity U8, ppVal uintptr) int32 {
  39256 	if pExpr != 0 {
  39257 		return valueFromExpr(tls, db, pExpr, enc, affinity, ppVal, uintptr(0))
  39258 	}
  39259 	return 0
  39260 }
  39261 
  39262 func stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity U8, pAlloc uintptr, ppVal uintptr) int32 {
  39263 	bp := tls.Alloc(4)
  39264 	defer tls.Free(4)
  39265 
  39266 	var rc int32 = SQLITE_OK
  39267 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  39268 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  39269 
  39270 	pExpr = Xsqlite3ExprSkipCollate(tls, pExpr)
  39271 
  39272 	if !(pExpr != 0) {
  39273 		*(*uintptr)(unsafe.Pointer(bp)) = valueNew(tls, db, pAlloc)
  39274 		if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  39275 			Xsqlite3VdbeMemSetNull(tls, *(*uintptr)(unsafe.Pointer(bp)))
  39276 		}
  39277 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VARIABLE && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableQPSG) == uint64(0) {
  39278 		var v uintptr
  39279 		var iBindVar int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  39280 		Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iBindVar)
  39281 		if libc.AssignUintptr(&v, (*Parse)(unsafe.Pointer(pParse)).FpReprepare) != uintptr(0) {
  39282 			*(*uintptr)(unsafe.Pointer(bp)) = valueNew(tls, db, pAlloc)
  39283 			if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  39284 				rc = Xsqlite3VdbeMemCopy(tls, *(*uintptr)(unsafe.Pointer(bp)), (*Vdbe)(unsafe.Pointer(v)).FaVar+uintptr(iBindVar-1)*40)
  39285 				Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp)), affinity, (*Sqlite3)(unsafe.Pointer(db)).Fenc)
  39286 				(*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fdb = (*Parse)(unsafe.Pointer(pParse)).Fdb
  39287 			}
  39288 		}
  39289 	} else {
  39290 		rc = valueFromExpr(tls, db, pExpr, (*Sqlite3)(unsafe.Pointer(db)).Fenc, affinity, bp, pAlloc)
  39291 	}
  39292 
  39293 	*(*uintptr)(unsafe.Pointer(ppVal)) = *(*uintptr)(unsafe.Pointer(bp))
  39294 	return rc
  39295 }
  39296 
  39297 // This function is used to allocate and populate UnpackedRecord
  39298 // structures intended to be compared against sample index keys stored
  39299 // in the sqlite_stat4 table.
  39300 //
  39301 // A single call to this function populates zero or more fields of the
  39302 // record starting with field iVal (fields are numbered from left to
  39303 // right starting with 0). A single field is populated if:
  39304 //
  39305 //   - (pExpr==0). In this case the value is assumed to be an SQL NULL,
  39306 //
  39307 //   - The expression is a bound variable, and this is a reprepare, or
  39308 //
  39309 //   - The sqlite3ValueFromExpr() function is able to extract a value
  39310 //     from the expression (i.e. the expression is a literal value).
  39311 //
  39312 // Or, if pExpr is a TK_VECTOR, one field is populated for each of the
  39313 // vector components that match either of the two latter criteria listed
  39314 // above.
  39315 //
  39316 // Before any value is appended to the record, the affinity of the
  39317 // corresponding column within index pIdx is applied to it. Before
  39318 // this function returns, output parameter *pnExtract is set to the
  39319 // number of values appended to the record.
  39320 //
  39321 // When this function is called, *ppRec must either point to an object
  39322 // allocated by an earlier call to this function, or must be NULL. If it
  39323 // is NULL and a value can be successfully extracted, a new UnpackedRecord
  39324 // is allocated (and *ppRec set to point to it) before returning.
  39325 //
  39326 // Unless an error is encountered, SQLITE_OK is returned. It is not an
  39327 // error if a value cannot be extracted from pExpr. If an error does
  39328 // occur, an SQLite error code is returned.
  39329 func Xsqlite3Stat4ProbeSetValue(tls *libc.TLS, pParse uintptr, pIdx uintptr, ppRec uintptr, pExpr uintptr, nElem int32, iVal int32, pnExtract uintptr) int32 {
  39330 	bp := tls.Alloc(20)
  39331 	defer tls.Free(20)
  39332 
  39333 	var rc int32 = SQLITE_OK
  39334 	var nExtract int32 = 0
  39335 
  39336 	if pExpr == uintptr(0) || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_SELECT {
  39337 		var i int32
  39338 
  39339 		(*ValueNewStat4Ctx)(unsafe.Pointer(bp)).FpParse = pParse
  39340 		(*ValueNewStat4Ctx)(unsafe.Pointer(bp)).FpIdx = pIdx
  39341 		(*ValueNewStat4Ctx)(unsafe.Pointer(bp)).FppRec = ppRec
  39342 
  39343 		for i = 0; i < nElem; i++ {
  39344 			*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
  39345 			var pElem uintptr = func() uintptr {
  39346 				if pExpr != 0 {
  39347 					return Xsqlite3VectorFieldSubexpr(tls, pExpr, i)
  39348 				}
  39349 				return uintptr(0)
  39350 			}()
  39351 			var aff U8 = Xsqlite3IndexColumnAffinity(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx, iVal+i)
  39352 			(*ValueNewStat4Ctx)(unsafe.Pointer(bp)).FiVal = iVal + i
  39353 			rc = stat4ValueFromExpr(tls, pParse, pElem, aff, bp, bp+16)
  39354 			if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) {
  39355 				break
  39356 			}
  39357 			nExtract++
  39358 		}
  39359 	}
  39360 
  39361 	*(*int32)(unsafe.Pointer(pnExtract)) = nExtract
  39362 	return rc
  39363 }
  39364 
  39365 // Attempt to extract a value from expression pExpr using the methods
  39366 // as described for sqlite3Stat4ProbeSetValue() above.
  39367 //
  39368 // If successful, set *ppVal to point to a new value object and return
  39369 // SQLITE_OK. If no value can be extracted, but no other error occurs
  39370 // (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error
  39371 // does occur, return an SQLite error code. The final value of *ppVal
  39372 // is undefined in this case.
  39373 func Xsqlite3Stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity U8, ppVal uintptr) int32 {
  39374 	return stat4ValueFromExpr(tls, pParse, pExpr, affinity, uintptr(0), ppVal)
  39375 }
  39376 
  39377 // Extract the iCol-th column from the nRec-byte record in pRec.  Write
  39378 // the column value into *ppVal.  If *ppVal is initially NULL then a new
  39379 // sqlite3_value object is allocated.
  39380 //
  39381 // If *ppVal is initially NULL then the caller is responsible for
  39382 // ensuring that the value written into *ppVal is eventually freed.
  39383 func Xsqlite3Stat4Column(tls *libc.TLS, db uintptr, pRec uintptr, nRec int32, iCol int32, ppVal uintptr) int32 {
  39384 	bp := tls.Alloc(8)
  39385 	defer tls.Free(8)
  39386 
  39387 	*(*U32)(unsafe.Pointer(bp + 4)) = U32(0)
  39388 
  39389 	var iHdr int32
  39390 	var iField int32
  39391 	var szField int32 = 0
  39392 	var i int32
  39393 	var a uintptr = pRec
  39394 	var pMem uintptr = *(*uintptr)(unsafe.Pointer(ppVal))
  39395 
  39396 	iHdr = int32(func() uint8 {
  39397 		if int32(*(*U8)(unsafe.Pointer(a))) < int32(U8(0x80)) {
  39398 			return uint8(func() int32 { *(*int32)(unsafe.Pointer(bp)) = int32(U32(*(*U8)(unsafe.Pointer(a)))); return 1 }())
  39399 		}
  39400 		return Xsqlite3GetVarint32(tls, a, bp)
  39401 	}())
  39402 	if *(*int32)(unsafe.Pointer(bp)) > nRec || iHdr >= *(*int32)(unsafe.Pointer(bp)) {
  39403 		return Xsqlite3CorruptError(tls, 82274)
  39404 	}
  39405 	iField = *(*int32)(unsafe.Pointer(bp))
  39406 	for i = 0; i <= iCol; i++ {
  39407 		iHdr = iHdr + int32(func() uint8 {
  39408 			if int32(*(*U8)(unsafe.Pointer(a + uintptr(iHdr)))) < int32(U8(0x80)) {
  39409 				return uint8(func() int32 {
  39410 					*(*U32)(unsafe.Pointer(bp + 4)) = U32(*(*U8)(unsafe.Pointer(a + uintptr(iHdr))))
  39411 					return 1
  39412 				}())
  39413 			}
  39414 			return Xsqlite3GetVarint32(tls, a+uintptr(iHdr), bp+4)
  39415 		}())
  39416 
  39417 		if iHdr > *(*int32)(unsafe.Pointer(bp)) {
  39418 			return Xsqlite3CorruptError(tls, 82280)
  39419 		}
  39420 		szField = int32(Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 4))))
  39421 		iField = iField + szField
  39422 	}
  39423 
  39424 	if iField > nRec {
  39425 		return Xsqlite3CorruptError(tls, 82286)
  39426 	}
  39427 	if pMem == uintptr(0) {
  39428 		pMem = libc.AssignPtrUintptr(ppVal, Xsqlite3ValueNew(tls, db))
  39429 		if pMem == uintptr(0) {
  39430 			return SQLITE_NOMEM
  39431 		}
  39432 	}
  39433 	Xsqlite3VdbeSerialGet(tls, a+uintptr(iField-szField), *(*U32)(unsafe.Pointer(bp + 4)), pMem)
  39434 	(*Mem)(unsafe.Pointer(pMem)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  39435 	return SQLITE_OK
  39436 }
  39437 
  39438 // Unless it is NULL, the argument must be an UnpackedRecord object returned
  39439 // by an earlier call to sqlite3Stat4ProbeSetValue(). This call deletes
  39440 // the object.
  39441 func Xsqlite3Stat4ProbeFree(tls *libc.TLS, pRec uintptr) {
  39442 	if pRec != 0 {
  39443 		var i int32
  39444 		var nCol int32 = int32((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo)).FnAllField)
  39445 		var aMem uintptr = (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem
  39446 		var db uintptr = (*Mem)(unsafe.Pointer(aMem)).Fdb
  39447 		for i = 0; i < nCol; i++ {
  39448 			Xsqlite3VdbeMemRelease(tls, aMem+uintptr(i)*40)
  39449 		}
  39450 		Xsqlite3KeyInfoUnref(tls, (*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo)
  39451 		Xsqlite3DbFreeNN(tls, db, pRec)
  39452 	}
  39453 }
  39454 
  39455 // Change the string value of an sqlite3_value object
  39456 func Xsqlite3ValueSetStr(tls *libc.TLS, v uintptr, n int32, z uintptr, enc U8, xDel uintptr) {
  39457 	if v != 0 {
  39458 		Xsqlite3VdbeMemSetStr(tls, v, z, int64(n), enc, xDel)
  39459 	}
  39460 }
  39461 
  39462 // Free an sqlite3_value object
  39463 func Xsqlite3ValueFree(tls *libc.TLS, v uintptr) {
  39464 	if !(v != 0) {
  39465 		return
  39466 	}
  39467 	Xsqlite3VdbeMemRelease(tls, v)
  39468 	Xsqlite3DbFreeNN(tls, (*Mem)(unsafe.Pointer(v)).Fdb, v)
  39469 }
  39470 
  39471 func valueBytes(tls *libc.TLS, pVal uintptr, enc U8) int32 {
  39472 	if valueToText(tls, pVal, enc) != uintptr(0) {
  39473 		return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fn
  39474 	}
  39475 	return 0
  39476 }
  39477 
  39478 func Xsqlite3ValueBytes(tls *libc.TLS, pVal uintptr, enc U8) int32 {
  39479 	var p uintptr = pVal
  39480 
  39481 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Str != 0 && int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc) {
  39482 		return (*Mem)(unsafe.Pointer(p)).Fn
  39483 	}
  39484 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Str != 0 && int32(enc) != SQLITE_UTF8 && int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) != SQLITE_UTF8 {
  39485 		return (*Mem)(unsafe.Pointer(p)).Fn
  39486 	}
  39487 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Blob != 0 {
  39488 		if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Zero != 0 {
  39489 			return (*Mem)(unsafe.Pointer(p)).Fn + *(*int32)(unsafe.Pointer(p))
  39490 		} else {
  39491 			return (*Mem)(unsafe.Pointer(p)).Fn
  39492 		}
  39493 	}
  39494 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Null != 0 {
  39495 		return 0
  39496 	}
  39497 	return valueBytes(tls, pVal, enc)
  39498 }
  39499 
  39500 // Create a new virtual database engine.
  39501 func Xsqlite3VdbeCreate(tls *libc.TLS, pParse uintptr) uintptr {
  39502 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  39503 	var p uintptr
  39504 	p = Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(Vdbe{})))
  39505 	if p == uintptr(0) {
  39506 		return uintptr(0)
  39507 	}
  39508 	libc.Xmemset(tls, p+104, 0, uint32(unsafe.Sizeof(Vdbe{}))-uint32(uintptr(0)+104))
  39509 	(*Vdbe)(unsafe.Pointer(p)).Fdb = db
  39510 	if (*Sqlite3)(unsafe.Pointer(db)).FpVdbe != 0 {
  39511 		(*Vdbe1)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpVdbe)).FppVPrev = p + 8
  39512 	}
  39513 	(*Vdbe)(unsafe.Pointer(p)).FpVNext = (*Sqlite3)(unsafe.Pointer(db)).FpVdbe
  39514 	(*Vdbe)(unsafe.Pointer(p)).FppVPrev = db + 4
  39515 	(*Sqlite3)(unsafe.Pointer(db)).FpVdbe = p
  39516 
  39517 	(*Vdbe)(unsafe.Pointer(p)).FpParse = pParse
  39518 	(*Parse)(unsafe.Pointer(pParse)).FpVdbe = p
  39519 
  39520 	Xsqlite3VdbeAddOp2(tls, p, OP_Init, 0, 1)
  39521 	return p
  39522 }
  39523 
  39524 // Return the Parse object that owns a Vdbe object.
  39525 func Xsqlite3VdbeParser(tls *libc.TLS, p uintptr) uintptr {
  39526 	return (*Vdbe)(unsafe.Pointer(p)).FpParse
  39527 }
  39528 
  39529 // Change the error string stored in Vdbe.zErrMsg
  39530 func Xsqlite3VdbeError(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) {
  39531 	var ap Va_list
  39532 	_ = ap
  39533 	Xsqlite3DbFree(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)
  39534 	ap = va
  39535 	(*Vdbe)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3VMPrintf(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, zFormat, ap)
  39536 	_ = ap
  39537 }
  39538 
  39539 // Remember the SQL string for a prepared statement.
  39540 func Xsqlite3VdbeSetSql(tls *libc.TLS, p uintptr, z uintptr, n int32, prepFlags U8) {
  39541 	if p == uintptr(0) {
  39542 		return
  39543 	}
  39544 	(*Vdbe)(unsafe.Pointer(p)).FprepFlags = prepFlags
  39545 	if int32(prepFlags)&SQLITE_PREPARE_SAVESQL == 0 {
  39546 		(*Vdbe)(unsafe.Pointer(p)).Fexpmask = U32(0)
  39547 	}
  39548 
  39549 	(*Vdbe)(unsafe.Pointer(p)).FzSql = Xsqlite3DbStrNDup(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, z, uint64(n))
  39550 }
  39551 
  39552 // Swap byte-code between two VDBE structures.
  39553 //
  39554 // This happens after pB was previously run and returned
  39555 // SQLITE_SCHEMA.  The statement was then reprepared in pA.
  39556 // This routine transfers the new bytecode in pA over to pB
  39557 // so that pB can be run again.  The old pB byte code is
  39558 // moved back to pA so that it will be cleaned up when pA is
  39559 // finalized.
  39560 func Xsqlite3VdbeSwap(tls *libc.TLS, pA uintptr, pB uintptr) {
  39561 	var tmp Vdbe
  39562 	var pTmp uintptr
  39563 	var ppTmp uintptr
  39564 	var zTmp uintptr
  39565 
  39566 	tmp = *(*Vdbe)(unsafe.Pointer(pA))
  39567 	*(*Vdbe)(unsafe.Pointer(pA)) = *(*Vdbe)(unsafe.Pointer(pB))
  39568 	*(*Vdbe)(unsafe.Pointer(pB)) = tmp
  39569 	pTmp = (*Vdbe)(unsafe.Pointer(pA)).FpVNext
  39570 	(*Vdbe)(unsafe.Pointer(pA)).FpVNext = (*Vdbe)(unsafe.Pointer(pB)).FpVNext
  39571 	(*Vdbe)(unsafe.Pointer(pB)).FpVNext = pTmp
  39572 	ppTmp = (*Vdbe)(unsafe.Pointer(pA)).FppVPrev
  39573 	(*Vdbe)(unsafe.Pointer(pA)).FppVPrev = (*Vdbe)(unsafe.Pointer(pB)).FppVPrev
  39574 	(*Vdbe)(unsafe.Pointer(pB)).FppVPrev = ppTmp
  39575 	zTmp = (*Vdbe)(unsafe.Pointer(pA)).FzSql
  39576 	(*Vdbe)(unsafe.Pointer(pA)).FzSql = (*Vdbe)(unsafe.Pointer(pB)).FzSql
  39577 	(*Vdbe)(unsafe.Pointer(pB)).FzSql = zTmp
  39578 	(*Vdbe)(unsafe.Pointer(pB)).Fexpmask = (*Vdbe)(unsafe.Pointer(pA)).Fexpmask
  39579 	(*Vdbe)(unsafe.Pointer(pB)).FprepFlags = (*Vdbe)(unsafe.Pointer(pA)).FprepFlags
  39580 	libc.Xmemcpy(tls, pB+164, pA+164, uint32(unsafe.Sizeof([9]U32{})))
  39581 	*(*U32)(unsafe.Pointer(pB + 164 + 5*4))++
  39582 }
  39583 
  39584 func growOpArray(tls *libc.TLS, v uintptr, nOp int32) int32 {
  39585 	var pNew uintptr
  39586 	var p uintptr = (*Vdbe)(unsafe.Pointer(v)).FpParse
  39587 
  39588 	var nNew Sqlite3_int64 = func() int64 {
  39589 		if (*Vdbe)(unsafe.Pointer(v)).FnOpAlloc != 0 {
  39590 			return int64(2) * Sqlite3_int64((*Vdbe)(unsafe.Pointer(v)).FnOpAlloc)
  39591 		}
  39592 		return int64(uint32(1024) / uint32(unsafe.Sizeof(Op{})))
  39593 	}()
  39594 	_ = nOp
  39595 
  39596 	if nNew > Sqlite3_int64(*(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(p)).Fdb + 120 + 5*4))) {
  39597 		Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(p)).Fdb)
  39598 		return SQLITE_NOMEM
  39599 	}
  39600 
  39601 	pNew = Xsqlite3DbRealloc(tls, (*Parse)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(v)).FaOp, uint64(nNew*Sqlite3_int64(unsafe.Sizeof(Op{}))))
  39602 	if pNew != 0 {
  39603 		(*Parse)(unsafe.Pointer(p)).FszOpAlloc = Xsqlite3DbMallocSize(tls, (*Parse)(unsafe.Pointer(p)).Fdb, pNew)
  39604 		(*Vdbe)(unsafe.Pointer(v)).FnOpAlloc = int32(uint32((*Parse)(unsafe.Pointer(p)).FszOpAlloc) / uint32(unsafe.Sizeof(Op{})))
  39605 		(*Vdbe)(unsafe.Pointer(v)).FaOp = pNew
  39606 	}
  39607 	return func() int32 {
  39608 		if pNew != 0 {
  39609 			return SQLITE_OK
  39610 		}
  39611 		return SQLITE_NOMEM
  39612 	}()
  39613 }
  39614 
  39615 func growOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32) int32 {
  39616 	if growOpArray(tls, p, 1) != 0 {
  39617 		return 1
  39618 	}
  39619 
  39620 	return Xsqlite3VdbeAddOp3(tls, p, op, p1, p2, p3)
  39621 }
  39622 
  39623 func Xsqlite3VdbeAddOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32) int32 {
  39624 	var i int32
  39625 	var pOp uintptr
  39626 
  39627 	i = (*Vdbe)(unsafe.Pointer(p)).FnOp
  39628 
  39629 	if (*Vdbe)(unsafe.Pointer(p)).FnOpAlloc <= i {
  39630 		return growOp3(tls, p, op, p1, p2, p3)
  39631 	}
  39632 
  39633 	(*Vdbe)(unsafe.Pointer(p)).FnOp++
  39634 	pOp = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(i)*20
  39635 
  39636 	(*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(op)
  39637 	(*VdbeOp)(unsafe.Pointer(pOp)).Fp5 = U16(0)
  39638 	(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = p1
  39639 	(*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = p2
  39640 	(*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = p3
  39641 	*(*uintptr)(unsafe.Pointer(pOp + 16)) = uintptr(0)
  39642 	(*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(P4_NOTUSED)
  39643 	return i
  39644 }
  39645 
  39646 func Xsqlite3VdbeAddOp0(tls *libc.TLS, p uintptr, op int32) int32 {
  39647 	return Xsqlite3VdbeAddOp3(tls, p, op, 0, 0, 0)
  39648 }
  39649 
  39650 func Xsqlite3VdbeAddOp1(tls *libc.TLS, p uintptr, op int32, p1 int32) int32 {
  39651 	return Xsqlite3VdbeAddOp3(tls, p, op, p1, 0, 0)
  39652 }
  39653 
  39654 func Xsqlite3VdbeAddOp2(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32) int32 {
  39655 	return Xsqlite3VdbeAddOp3(tls, p, op, p1, p2, 0)
  39656 }
  39657 
  39658 // Generate code for an unconditional jump to instruction iDest
  39659 func Xsqlite3VdbeGoto(tls *libc.TLS, p uintptr, iDest int32) int32 {
  39660 	return Xsqlite3VdbeAddOp3(tls, p, OP_Goto, 0, iDest, 0)
  39661 }
  39662 
  39663 // Generate code to cause the string zStr to be loaded into
  39664 // register iDest
  39665 func Xsqlite3VdbeLoadString(tls *libc.TLS, p uintptr, iDest int32, zStr uintptr) int32 {
  39666 	return Xsqlite3VdbeAddOp4(tls, p, OP_String8, 0, iDest, 0, zStr, 0)
  39667 }
  39668 
  39669 // Generate code that initializes multiple registers to string or integer
  39670 // constants.  The registers begin with iDest and increase consecutively.
  39671 // One register is initialized for each characgter in zTypes[].  For each
  39672 // "s" character in zTypes[], the register is a string if the argument is
  39673 // not NULL, or OP_Null if the value is a null pointer.  For each "i" character
  39674 // in zTypes[], the register is initialized to an integer.
  39675 //
  39676 // If the input string does not end with "X" then an OP_ResultRow instruction
  39677 // is generated for the values inserted.
  39678 func Xsqlite3VdbeMultiLoad(tls *libc.TLS, p uintptr, iDest int32, zTypes uintptr, va uintptr) {
  39679 	var ap Va_list
  39680 	_ = ap
  39681 	var i int32
  39682 	var c uint8
  39683 	var z uintptr
  39684 	ap = va
  39685 	i = 0
  39686 __1:
  39687 	if !(int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(zTypes + uintptr(i))))) != 0) {
  39688 		goto __3
  39689 	}
  39690 	if !(int32(c) == 's') {
  39691 		goto __4
  39692 	}
  39693 	z = libc.VaUintptr(&ap)
  39694 	Xsqlite3VdbeAddOp4(tls, p, func() int32 {
  39695 		if z == uintptr(0) {
  39696 			return OP_Null
  39697 		}
  39698 		return OP_String8
  39699 	}(), 0, iDest+i, 0, z, 0)
  39700 	goto __5
  39701 __4:
  39702 	if !(int32(c) == 'i') {
  39703 		goto __6
  39704 	}
  39705 	Xsqlite3VdbeAddOp2(tls, p, OP_Integer, libc.VaInt32(&ap), iDest+i)
  39706 	goto __7
  39707 __6:
  39708 	goto skip_op_resultrow
  39709 __7:
  39710 	;
  39711 __5:
  39712 	;
  39713 	goto __2
  39714 __2:
  39715 	i++
  39716 	goto __1
  39717 	goto __3
  39718 __3:
  39719 	;
  39720 	Xsqlite3VdbeAddOp2(tls, p, OP_ResultRow, iDest, i)
  39721 skip_op_resultrow:
  39722 	_ = ap
  39723 }
  39724 
  39725 // Add an opcode that includes the p4 value as a pointer.
  39726 func Xsqlite3VdbeAddOp4(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, zP4 uintptr, p4type int32) int32 {
  39727 	var addr int32 = Xsqlite3VdbeAddOp3(tls, p, op, p1, p2, p3)
  39728 	Xsqlite3VdbeChangeP4(tls, p, addr, zP4, p4type)
  39729 	return addr
  39730 }
  39731 
  39732 // Add an OP_Function or OP_PureFunc opcode.
  39733 //
  39734 // The eCallCtx argument is information (typically taken from Expr.op2)
  39735 // that describes the calling context of the function.  0 means a general
  39736 // function call.  NC_IsCheck means called by a check constraint,
  39737 // NC_IdxExpr means called as part of an index expression.  NC_PartIdx
  39738 // means in the WHERE clause of a partial index.  NC_GenCol means called
  39739 // while computing a generated column value.  0 is the usual case.
  39740 func Xsqlite3VdbeAddFunctionCall(tls *libc.TLS, pParse uintptr, p1 int32, p2 int32, p3 int32, nArg int32, pFunc uintptr, eCallCtx int32) int32 {
  39741 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  39742 	var nByte int32
  39743 	var addr int32
  39744 	var pCtx uintptr
  39745 
  39746 	nByte = int32(uint32(unsafe.Sizeof(Sqlite3_context{})) + uint32(nArg-1)*uint32(unsafe.Sizeof(uintptr(0))))
  39747 	pCtx = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(nByte))
  39748 	if pCtx == uintptr(0) {
  39749 		freeEphemeralFunction(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pFunc)
  39750 		return 0
  39751 	}
  39752 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut = uintptr(0)
  39753 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpFunc = pFunc
  39754 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe = uintptr(0)
  39755 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 0
  39756 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).Fargc = U8(nArg)
  39757 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp = Xsqlite3VdbeCurrentAddr(tls, v)
  39758 	addr = Xsqlite3VdbeAddOp4(tls, v, func() int32 {
  39759 		if eCallCtx != 0 {
  39760 			return OP_PureFunc
  39761 		}
  39762 		return OP_Function
  39763 	}(),
  39764 		p1, p2, p3, pCtx, -15)
  39765 	Xsqlite3VdbeChangeP5(tls, v, uint16(eCallCtx&NC_SelfRef))
  39766 	Xsqlite3MayAbort(tls, pParse)
  39767 	return addr
  39768 }
  39769 
  39770 // Add an opcode that includes the p4 value with a P4_INT64 or
  39771 // P4_REAL type.
  39772 func Xsqlite3VdbeAddOp4Dup8(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, zP4 uintptr, p4type int32) int32 {
  39773 	var p4copy uintptr = Xsqlite3DbMallocRawNN(tls, Xsqlite3VdbeDb(tls, p), uint64(8))
  39774 	if p4copy != 0 {
  39775 		libc.Xmemcpy(tls, p4copy, zP4, uint32(8))
  39776 	}
  39777 	return Xsqlite3VdbeAddOp4(tls, p, op, p1, p2, p3, p4copy, p4type)
  39778 }
  39779 
  39780 // Return the address of the current EXPLAIN QUERY PLAN baseline.
  39781 // 0 means "none".
  39782 func Xsqlite3VdbeExplainParent(tls *libc.TLS, pParse uintptr) int32 {
  39783 	var pOp uintptr
  39784 	if (*Parse)(unsafe.Pointer(pParse)).FaddrExplain == 0 {
  39785 		return 0
  39786 	}
  39787 	pOp = Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, (*Parse)(unsafe.Pointer(pParse)).FaddrExplain)
  39788 	return (*VdbeOp)(unsafe.Pointer(pOp)).Fp2
  39789 }
  39790 
  39791 // Add a new OP_Explain opcode.
  39792 //
  39793 // If the bPush flag is true, then make this opcode the parent for
  39794 // subsequent Explains until sqlite3VdbeExplainPop() is called.
  39795 func Xsqlite3VdbeExplain(tls *libc.TLS, pParse uintptr, bPush U8, zFmt uintptr, va uintptr) int32 {
  39796 	var addr int32 = 0
  39797 
  39798 	if int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) == 2 {
  39799 		var zMsg uintptr
  39800 		var v uintptr
  39801 		var ap Va_list
  39802 		_ = ap
  39803 		var iThis int32
  39804 		ap = va
  39805 		zMsg = Xsqlite3VMPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zFmt, ap)
  39806 		_ = ap
  39807 		v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  39808 		iThis = (*Vdbe)(unsafe.Pointer(v)).FnOp
  39809 		addr = Xsqlite3VdbeAddOp4(tls, v, OP_Explain, iThis, (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0,
  39810 			zMsg, -6)
  39811 
  39812 		if bPush != 0 {
  39813 			(*Parse)(unsafe.Pointer(pParse)).FaddrExplain = iThis
  39814 		}
  39815 
  39816 	}
  39817 	return addr
  39818 }
  39819 
  39820 // Pop the EXPLAIN QUERY PLAN stack one level.
  39821 func Xsqlite3VdbeExplainPop(tls *libc.TLS, pParse uintptr) {
  39822 	(*Parse)(unsafe.Pointer(pParse)).FaddrExplain = Xsqlite3VdbeExplainParent(tls, pParse)
  39823 }
  39824 
  39825 // Add an OP_ParseSchema opcode.  This routine is broken out from
  39826 // sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees
  39827 // as having been used.
  39828 //
  39829 // The zWhere string must have been obtained from sqlite3_malloc().
  39830 // This routine will take ownership of the allocated memory.
  39831 func Xsqlite3VdbeAddParseSchemaOp(tls *libc.TLS, p uintptr, iDb int32, zWhere uintptr, p5 U16) {
  39832 	var j int32
  39833 	Xsqlite3VdbeAddOp4(tls, p, OP_ParseSchema, iDb, 0, 0, zWhere, -6)
  39834 	Xsqlite3VdbeChangeP5(tls, p, p5)
  39835 	for j = 0; j < (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnDb; j++ {
  39836 		Xsqlite3VdbeUsesBtree(tls, p, j)
  39837 	}
  39838 	Xsqlite3MayAbort(tls, (*Vdbe)(unsafe.Pointer(p)).FpParse)
  39839 }
  39840 
  39841 // Add an opcode that includes the p4 value as an integer.
  39842 func Xsqlite3VdbeAddOp4Int(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, p4 int32) int32 {
  39843 	var addr int32 = Xsqlite3VdbeAddOp3(tls, p, op, p1, p2, p3)
  39844 	if int32((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed) == 0 {
  39845 		var pOp uintptr = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*20
  39846 		(*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-3)
  39847 		*(*int32)(unsafe.Pointer(pOp + 16)) = p4
  39848 	}
  39849 	return addr
  39850 }
  39851 
  39852 // Insert the end of a co-routine
  39853 func Xsqlite3VdbeEndCoroutine(tls *libc.TLS, v uintptr, regYield int32) {
  39854 	Xsqlite3VdbeAddOp1(tls, v, OP_EndCoroutine, regYield)
  39855 
  39856 	(*Parse)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FpParse)).FnTempReg = U8(0)
  39857 	(*Parse)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FpParse)).FnRangeReg = 0
  39858 }
  39859 
  39860 // Create a new symbolic label for an instruction that has yet to be
  39861 // coded.  The symbolic label is really just a negative number.  The
  39862 // label can be used as the P2 value of an operation.  Later, when
  39863 // the label is resolved to a specific address, the VDBE will scan
  39864 // through its operation list and change all values of P2 which match
  39865 // the label into the resolved address.
  39866 //
  39867 // The VDBE knows that a P2 value is a label because labels are
  39868 // always negative and P2 values are suppose to be non-negative.
  39869 // Hence, a negative P2 value is a label that has yet to be resolved.
  39870 // (Later:) This is only true for opcodes that have the OPFLG_JUMP
  39871 // property.
  39872 //
  39873 // Variable usage notes:
  39874 //
  39875 //	Parse.aLabel[x]     Stores the address that the x-th label resolves
  39876 //	                    into.  For testing (SQLITE_DEBUG), unresolved
  39877 //	                    labels stores -1, but that is not required.
  39878 //	Parse.nLabelAlloc   Number of slots allocated to Parse.aLabel[]
  39879 //	Parse.nLabel        The *negative* of the number of labels that have
  39880 //	                    been issued.  The negative is stored because
  39881 //	                    that gives a performance improvement over storing
  39882 //	                    the equivalent positive value.
  39883 func Xsqlite3VdbeMakeLabel(tls *libc.TLS, pParse uintptr) int32 {
  39884 	return libc.PreDecInt32(&(*Parse)(unsafe.Pointer(pParse)).FnLabel, 1)
  39885 }
  39886 
  39887 func resizeResolveLabel(tls *libc.TLS, p uintptr, v uintptr, j int32) {
  39888 	var nNewSize int32 = 10 - (*Parse)(unsafe.Pointer(p)).FnLabel
  39889 	(*Parse)(unsafe.Pointer(p)).FaLabel = Xsqlite3DbReallocOrFree(tls, (*Parse)(unsafe.Pointer(p)).Fdb, (*Parse)(unsafe.Pointer(p)).FaLabel,
  39890 		uint64(uint32(nNewSize)*uint32(unsafe.Sizeof(int32(0)))))
  39891 	if (*Parse)(unsafe.Pointer(p)).FaLabel == uintptr(0) {
  39892 		(*Parse)(unsafe.Pointer(p)).FnLabelAlloc = 0
  39893 	} else {
  39894 		if nNewSize >= 100 && nNewSize/100 > (*Parse)(unsafe.Pointer(p)).FnLabelAlloc/100 {
  39895 			Xsqlite3ProgressCheck(tls, p)
  39896 		}
  39897 		(*Parse)(unsafe.Pointer(p)).FnLabelAlloc = nNewSize
  39898 		*(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(p)).FaLabel + uintptr(j)*4)) = (*Vdbe)(unsafe.Pointer(v)).FnOp
  39899 	}
  39900 }
  39901 
  39902 func Xsqlite3VdbeResolveLabel(tls *libc.TLS, v uintptr, x int32) {
  39903 	var p uintptr = (*Vdbe)(unsafe.Pointer(v)).FpParse
  39904 	var j int32 = ^x
  39905 
  39906 	if (*Parse)(unsafe.Pointer(p)).FnLabelAlloc+(*Parse)(unsafe.Pointer(p)).FnLabel < 0 {
  39907 		resizeResolveLabel(tls, p, v, j)
  39908 	} else {
  39909 		*(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(p)).FaLabel + uintptr(j)*4)) = (*Vdbe)(unsafe.Pointer(v)).FnOp
  39910 	}
  39911 }
  39912 
  39913 // Mark the VDBE as one that can only be run one time.
  39914 func Xsqlite3VdbeRunOnlyOnce(tls *libc.TLS, p uintptr) {
  39915 	Xsqlite3VdbeAddOp2(tls, p, OP_Expire, 1, 1)
  39916 }
  39917 
  39918 // Mark the VDBE as one that can be run multiple times.
  39919 func Xsqlite3VdbeReusable(tls *libc.TLS, p uintptr) {
  39920 	var i int32
  39921 	for i = 1; i < (*Vdbe)(unsafe.Pointer(p)).FnOp; i++ {
  39922 		if int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(i)*20)).Fopcode) == OP_Expire {
  39923 			(*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + 1*20)).Fopcode = U8(OP_Noop)
  39924 			break
  39925 		}
  39926 	}
  39927 }
  39928 
  39929 func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) {
  39930 	var nMaxArgs int32
  39931 	var pOp uintptr
  39932 	var pParse uintptr
  39933 	var aLabel uintptr
  39934 	var n int32
  39935 	nMaxArgs = *(*int32)(unsafe.Pointer(pMaxFuncArgs))
  39936 	pParse = (*Vdbe)(unsafe.Pointer(p)).FpParse
  39937 	aLabel = (*Parse)(unsafe.Pointer(pParse)).FaLabel
  39938 	libc.SetBitFieldPtr8Uint32(p+152, Bft(1), 6, 0x40)
  39939 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 7, 0x80)
  39940 	pOp = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr((*Vdbe)(unsafe.Pointer(p)).FnOp-1)*20
  39941 
  39942 __1:
  39943 	if !(1 != 0) {
  39944 		goto __2
  39945 	}
  39946 
  39947 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) <= SQLITE_MX_JUMP_OPCODE) {
  39948 		goto __3
  39949 	}
  39950 
  39951 	switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) {
  39952 	case OP_Transaction:
  39953 		goto __5
  39954 	case OP_AutoCommit:
  39955 		goto __6
  39956 	case OP_Savepoint:
  39957 		goto __7
  39958 	case OP_Checkpoint:
  39959 		goto __8
  39960 	case OP_Vacuum:
  39961 		goto __9
  39962 	case OP_JournalMode:
  39963 		goto __10
  39964 	case OP_Init:
  39965 		goto __11
  39966 	case OP_VUpdate:
  39967 		goto __12
  39968 	case OP_VFilter:
  39969 		goto __13
  39970 	default:
  39971 		goto __14
  39972 	}
  39973 	goto __4
  39974 __5:
  39975 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) {
  39976 		goto __15
  39977 	}
  39978 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 6, 0x40)
  39979 __15:
  39980 	;
  39981 __6:
  39982 __7:
  39983 	libc.SetBitFieldPtr8Uint32(p+152, Bft(1), 7, 0x80)
  39984 	goto __4
  39985 
  39986 __8:
  39987 __9:
  39988 __10:
  39989 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 6, 0x40)
  39990 	libc.SetBitFieldPtr8Uint32(p+152, Bft(1), 7, 0x80)
  39991 	goto __4
  39992 
  39993 __11:
  39994 	;
  39995 	goto resolve_p2_values_loop_exit
  39996 
  39997 __12:
  39998 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 > nMaxArgs) {
  39999 		goto __16
  40000 	}
  40001 	nMaxArgs = (*Op)(unsafe.Pointer(pOp)).Fp2
  40002 __16:
  40003 	;
  40004 	goto __4
  40005 
  40006 __13:
  40007 	;
  40008 	n = (*Op)(unsafe.Pointer(pOp + libc.UintptrFromInt32(-1)*20)).Fp1
  40009 	if !(n > nMaxArgs) {
  40010 		goto __17
  40011 	}
  40012 	nMaxArgs = n
  40013 __17:
  40014 	;
  40015 __14:
  40016 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 < 0) {
  40017 		goto __18
  40018 	}
  40019 
  40020 	(*Op)(unsafe.Pointer(pOp)).Fp2 = *(*int32)(unsafe.Pointer(aLabel + uintptr(^(*Op)(unsafe.Pointer(pOp)).Fp2)*4))
  40021 __18:
  40022 	;
  40023 	goto __4
  40024 
  40025 __4:
  40026 	;
  40027 __3:
  40028 	;
  40029 	pOp -= 20
  40030 	goto __1
  40031 __2:
  40032 	;
  40033 resolve_p2_values_loop_exit:
  40034 	if !(aLabel != 0) {
  40035 		goto __19
  40036 	}
  40037 	Xsqlite3DbNNFreeNN(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Parse)(unsafe.Pointer(pParse)).FaLabel)
  40038 	(*Parse)(unsafe.Pointer(pParse)).FaLabel = uintptr(0)
  40039 __19:
  40040 	;
  40041 	(*Parse)(unsafe.Pointer(pParse)).FnLabel = 0
  40042 	*(*int32)(unsafe.Pointer(pMaxFuncArgs)) = nMaxArgs
  40043 
  40044 }
  40045 
  40046 // Return the address of the next instruction to be inserted.
  40047 func Xsqlite3VdbeCurrentAddr(tls *libc.TLS, p uintptr) int32 {
  40048 	return (*Vdbe)(unsafe.Pointer(p)).FnOp
  40049 }
  40050 
  40051 // This function returns a pointer to the array of opcodes associated with
  40052 // the Vdbe passed as the first argument. It is the callers responsibility
  40053 // to arrange for the returned array to be eventually freed using the
  40054 // vdbeFreeOpArray() function.
  40055 //
  40056 // Before returning, *pnOp is set to the number of entries in the returned
  40057 // array. Also, *pnMaxArg is set to the larger of its current value and
  40058 // the number of entries in the Vdbe.apArg[] array required to execute the
  40059 // returned program.
  40060 func Xsqlite3VdbeTakeOpArray(tls *libc.TLS, p uintptr, pnOp uintptr, pnMaxArg uintptr) uintptr {
  40061 	var aOp uintptr = (*Vdbe)(unsafe.Pointer(p)).FaOp
  40062 
  40063 	resolveP2Values(tls, p, pnMaxArg)
  40064 	*(*int32)(unsafe.Pointer(pnOp)) = (*Vdbe)(unsafe.Pointer(p)).FnOp
  40065 	(*Vdbe)(unsafe.Pointer(p)).FaOp = uintptr(0)
  40066 	return aOp
  40067 }
  40068 
  40069 // Add a whole list of operations to the operation stack.  Return a
  40070 // pointer to the first operation inserted.
  40071 //
  40072 // Non-zero P2 arguments to jump instructions are automatically adjusted
  40073 // so that the jump target is relative to the first operation inserted.
  40074 func Xsqlite3VdbeAddOpList(tls *libc.TLS, p uintptr, nOp int32, aOp uintptr, iLineno int32) uintptr {
  40075 	var i int32
  40076 	var pOut uintptr
  40077 	var pFirst uintptr
  40078 
  40079 	if (*Vdbe)(unsafe.Pointer(p)).FnOp+nOp > (*Vdbe)(unsafe.Pointer(p)).FnOpAlloc && growOpArray(tls, p, nOp) != 0 {
  40080 		return uintptr(0)
  40081 	}
  40082 	pFirst = libc.AssignUintptr(&pOut, (*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr((*Vdbe)(unsafe.Pointer(p)).FnOp)*20)
  40083 	i = 0
  40084 __1:
  40085 	if !(i < nOp) {
  40086 		goto __3
  40087 	}
  40088 	{
  40089 		(*VdbeOp)(unsafe.Pointer(pOut)).Fopcode = (*VdbeOpList)(unsafe.Pointer(aOp)).Fopcode
  40090 		(*VdbeOp)(unsafe.Pointer(pOut)).Fp1 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp1)
  40091 		(*VdbeOp)(unsafe.Pointer(pOut)).Fp2 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2)
  40092 
  40093 		if int32(Xsqlite3OpcodeProperty[(*VdbeOpList)(unsafe.Pointer(aOp)).Fopcode])&OPFLG_JUMP != 0 && int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) > 0 {
  40094 			*(*int32)(unsafe.Pointer(pOut + 8)) += (*Vdbe)(unsafe.Pointer(p)).FnOp
  40095 		}
  40096 		(*VdbeOp)(unsafe.Pointer(pOut)).Fp3 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp3)
  40097 		(*VdbeOp)(unsafe.Pointer(pOut)).Fp4type = int8(P4_NOTUSED)
  40098 		*(*uintptr)(unsafe.Pointer(pOut + 16)) = uintptr(0)
  40099 		(*VdbeOp)(unsafe.Pointer(pOut)).Fp5 = U16(0)
  40100 		_ = iLineno
  40101 
  40102 	}
  40103 	goto __2
  40104 __2:
  40105 	i++
  40106 	aOp += 4
  40107 	pOut += 20
  40108 	goto __1
  40109 	goto __3
  40110 __3:
  40111 	;
  40112 	*(*int32)(unsafe.Pointer(p + 108)) += nOp
  40113 	return pFirst
  40114 }
  40115 
  40116 // Change the value of the opcode, or P1, P2, P3, or P5 operands
  40117 // for a specific instruction.
  40118 func Xsqlite3VdbeChangeOpcode(tls *libc.TLS, p uintptr, addr int32, iNewOpcode U8) {
  40119 	(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, p, addr))).Fopcode = iNewOpcode
  40120 }
  40121 
  40122 func Xsqlite3VdbeChangeP1(tls *libc.TLS, p uintptr, addr int32, val int32) {
  40123 	(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, p, addr))).Fp1 = val
  40124 }
  40125 
  40126 func Xsqlite3VdbeChangeP2(tls *libc.TLS, p uintptr, addr int32, val int32) {
  40127 	(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, p, addr))).Fp2 = val
  40128 }
  40129 
  40130 func Xsqlite3VdbeChangeP3(tls *libc.TLS, p uintptr, addr int32, val int32) {
  40131 	(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, p, addr))).Fp3 = val
  40132 }
  40133 
  40134 func Xsqlite3VdbeChangeP5(tls *libc.TLS, p uintptr, p5 U16) {
  40135 	if (*Vdbe)(unsafe.Pointer(p)).FnOp > 0 {
  40136 		(*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr((*Vdbe)(unsafe.Pointer(p)).FnOp-1)*20)).Fp5 = p5
  40137 	}
  40138 }
  40139 
  40140 // If the previous opcode is an OP_Column that delivers results
  40141 // into register iDest, then add the OPFLAG_TYPEOFARG flag to that
  40142 // opcode.
  40143 func Xsqlite3VdbeTypeofColumn(tls *libc.TLS, p uintptr, iDest int32) {
  40144 	var pOp uintptr = Xsqlite3VdbeGetLastOp(tls, p)
  40145 	if (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDest && int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column {
  40146 		*(*U16)(unsafe.Pointer(pOp + 2)) |= U16(OPFLAG_TYPEOFARG)
  40147 	}
  40148 }
  40149 
  40150 // Change the P2 operand of instruction addr so that it points to
  40151 // the address of the next instruction to be coded.
  40152 func Xsqlite3VdbeJumpHere(tls *libc.TLS, p uintptr, addr int32) {
  40153 	Xsqlite3VdbeChangeP2(tls, p, addr, (*Vdbe)(unsafe.Pointer(p)).FnOp)
  40154 }
  40155 
  40156 // Change the P2 operand of the jump instruction at addr so that
  40157 // the jump lands on the next opcode.  Or if the jump instruction was
  40158 // the previous opcode (and is thus a no-op) then simply back up
  40159 // the next instruction counter by one slot so that the jump is
  40160 // overwritten by the next inserted opcode.
  40161 //
  40162 // This routine is an optimization of sqlite3VdbeJumpHere() that
  40163 // strives to omit useless byte-code like this:
  40164 //
  40165 //	7   Once 0 8 0
  40166 //	8   ...
  40167 func Xsqlite3VdbeJumpHereOrPopInst(tls *libc.TLS, p uintptr, addr int32) {
  40168 	if addr == (*Vdbe)(unsafe.Pointer(p)).FnOp-1 {
  40169 		(*Vdbe)(unsafe.Pointer(p)).FnOp--
  40170 	} else {
  40171 		Xsqlite3VdbeChangeP2(tls, p, addr, (*Vdbe)(unsafe.Pointer(p)).FnOp)
  40172 	}
  40173 }
  40174 
  40175 func freeEphemeralFunction(tls *libc.TLS, db uintptr, pDef uintptr) {
  40176 	if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_EPHEM) != U32(0) {
  40177 		Xsqlite3DbNNFreeNN(tls, db, pDef)
  40178 	}
  40179 }
  40180 
  40181 func freeP4Mem(tls *libc.TLS, db uintptr, p uintptr) {
  40182 	if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 {
  40183 		Xsqlite3DbFree(tls, db, (*Mem)(unsafe.Pointer(p)).FzMalloc)
  40184 	}
  40185 	Xsqlite3DbNNFreeNN(tls, db, p)
  40186 }
  40187 
  40188 func freeP4FuncCtx(tls *libc.TLS, db uintptr, p uintptr) {
  40189 	freeEphemeralFunction(tls, db, (*Sqlite3_context)(unsafe.Pointer(p)).FpFunc)
  40190 	Xsqlite3DbNNFreeNN(tls, db, p)
  40191 }
  40192 
  40193 func freeP4(tls *libc.TLS, db uintptr, p4type int32, p4 uintptr) {
  40194 	switch p4type {
  40195 	case -15:
  40196 		{
  40197 			freeP4FuncCtx(tls, db, p4)
  40198 			break
  40199 
  40200 		}
  40201 	case -12:
  40202 		fallthrough
  40203 	case -13:
  40204 		fallthrough
  40205 	case -6:
  40206 		fallthrough
  40207 	case -14:
  40208 		{
  40209 			if p4 != 0 {
  40210 				Xsqlite3DbNNFreeNN(tls, db, p4)
  40211 			}
  40212 			break
  40213 
  40214 		}
  40215 	case -8:
  40216 		{
  40217 			if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  40218 				Xsqlite3KeyInfoUnref(tls, p4)
  40219 			}
  40220 			break
  40221 
  40222 		}
  40223 	case -7:
  40224 		{
  40225 			freeEphemeralFunction(tls, db, p4)
  40226 			break
  40227 
  40228 		}
  40229 	case -10:
  40230 		{
  40231 			if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  40232 				Xsqlite3ValueFree(tls, p4)
  40233 			} else {
  40234 				freeP4Mem(tls, db, p4)
  40235 			}
  40236 			break
  40237 
  40238 		}
  40239 	case -11:
  40240 		{
  40241 			if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  40242 				Xsqlite3VtabUnlock(tls, p4)
  40243 			}
  40244 			break
  40245 
  40246 		}
  40247 	}
  40248 }
  40249 
  40250 func vdbeFreeOpArray(tls *libc.TLS, db uintptr, aOp uintptr, nOp int32) {
  40251 	if aOp != 0 {
  40252 		var pOp uintptr = aOp + uintptr(nOp-1)*20
  40253 		for 1 != 0 {
  40254 			if int32((*Op)(unsafe.Pointer(pOp)).Fp4type) <= -6 {
  40255 				freeP4(tls, db, int32((*Op)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16)))
  40256 			}
  40257 			if pOp == aOp {
  40258 				break
  40259 			}
  40260 			pOp -= 20
  40261 		}
  40262 		Xsqlite3DbNNFreeNN(tls, db, aOp)
  40263 	}
  40264 }
  40265 
  40266 // Link the SubProgram object passed as the second argument into the linked
  40267 // list at Vdbe.pSubProgram. This list is used to delete all sub-program
  40268 // objects when the VM is no longer required.
  40269 func Xsqlite3VdbeLinkSubProgram(tls *libc.TLS, pVdbe uintptr, p uintptr) {
  40270 	(*SubProgram)(unsafe.Pointer(p)).FpNext = (*Vdbe)(unsafe.Pointer(pVdbe)).FpProgram
  40271 	(*Vdbe)(unsafe.Pointer(pVdbe)).FpProgram = p
  40272 }
  40273 
  40274 // Return true if the given Vdbe has any SubPrograms.
  40275 func Xsqlite3VdbeHasSubProgram(tls *libc.TLS, pVdbe uintptr) int32 {
  40276 	return libc.Bool32((*Vdbe)(unsafe.Pointer(pVdbe)).FpProgram != uintptr(0))
  40277 }
  40278 
  40279 // Change the opcode at addr into OP_Noop
  40280 func Xsqlite3VdbeChangeToNoop(tls *libc.TLS, p uintptr, addr int32) int32 {
  40281 	var pOp uintptr
  40282 	if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 {
  40283 		return 0
  40284 	}
  40285 
  40286 	pOp = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*20
  40287 	freeP4(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16)))
  40288 	(*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(P4_NOTUSED)
  40289 	*(*uintptr)(unsafe.Pointer(pOp + 16)) = uintptr(0)
  40290 	(*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(OP_Noop)
  40291 	return 1
  40292 }
  40293 
  40294 // If the last opcode is "op" and it is not a jump destination,
  40295 // then remove it.  Return true if and only if an opcode was removed.
  40296 func Xsqlite3VdbeDeletePriorOpcode(tls *libc.TLS, p uintptr, op U8) int32 {
  40297 	if (*Vdbe)(unsafe.Pointer(p)).FnOp > 0 && int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr((*Vdbe)(unsafe.Pointer(p)).FnOp-1)*20)).Fopcode) == int32(op) {
  40298 		return Xsqlite3VdbeChangeToNoop(tls, p, (*Vdbe)(unsafe.Pointer(p)).FnOp-1)
  40299 	} else {
  40300 		return 0
  40301 	}
  40302 	return int32(0)
  40303 }
  40304 
  40305 func vdbeChangeP4Full(tls *libc.TLS, p uintptr, pOp uintptr, zP4 uintptr, n int32) {
  40306 	if (*Op)(unsafe.Pointer(pOp)).Fp4type != 0 {
  40307 		freeP4(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, int32((*Op)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16)))
  40308 		(*Op)(unsafe.Pointer(pOp)).Fp4type = int8(0)
  40309 		*(*uintptr)(unsafe.Pointer(pOp + 16)) = uintptr(0)
  40310 	}
  40311 	if n < 0 {
  40312 		Xsqlite3VdbeChangeP4(tls, p, (int32(pOp)-int32((*Vdbe)(unsafe.Pointer(p)).FaOp))/20, zP4, n)
  40313 	} else {
  40314 		if n == 0 {
  40315 			n = Xsqlite3Strlen30(tls, zP4)
  40316 		}
  40317 		*(*uintptr)(unsafe.Pointer(pOp + 16)) = Xsqlite3DbStrNDup(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, zP4, uint64(n))
  40318 		(*Op)(unsafe.Pointer(pOp)).Fp4type = int8(-6)
  40319 	}
  40320 }
  40321 
  40322 func Xsqlite3VdbeChangeP4(tls *libc.TLS, p uintptr, addr int32, zP4 uintptr, n int32) {
  40323 	bp := tls.Alloc(4)
  40324 	defer tls.Free(4)
  40325 	*(*uintptr)(unsafe.Pointer(bp)) = zP4
  40326 
  40327 	var pOp uintptr
  40328 	var db uintptr
  40329 
  40330 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  40331 
  40332 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  40333 		if n != -11 {
  40334 			freeP4(tls, db, n, *(*uintptr)(unsafe.Pointer(bp)))
  40335 		}
  40336 		return
  40337 	}
  40338 
  40339 	if addr < 0 {
  40340 		addr = (*Vdbe)(unsafe.Pointer(p)).FnOp - 1
  40341 	}
  40342 	pOp = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*20
  40343 	if n >= 0 || (*Op)(unsafe.Pointer(pOp)).Fp4type != 0 {
  40344 		vdbeChangeP4Full(tls, p, pOp, *(*uintptr)(unsafe.Pointer(bp)), n)
  40345 		return
  40346 	}
  40347 	if n == -3 {
  40348 		*(*int32)(unsafe.Pointer(pOp + 16)) = int32(*(*uintptr)(unsafe.Pointer(bp)))
  40349 		(*Op)(unsafe.Pointer(pOp)).Fp4type = int8(-3)
  40350 	} else if *(*uintptr)(unsafe.Pointer(bp)) != uintptr(0) {
  40351 		*(*uintptr)(unsafe.Pointer(pOp + 16)) = *(*uintptr)(unsafe.Pointer(bp))
  40352 		(*Op)(unsafe.Pointer(pOp)).Fp4type = int8(n)
  40353 		if n == -11 {
  40354 			Xsqlite3VtabLock(tls, *(*uintptr)(unsafe.Pointer(bp)))
  40355 		}
  40356 	}
  40357 }
  40358 
  40359 // Change the P4 operand of the most recently coded instruction
  40360 // to the value defined by the arguments.  This is a high-speed
  40361 // version of sqlite3VdbeChangeP4().
  40362 //
  40363 // The P4 operand must not have been previously defined.  And the new
  40364 // P4 must not be P4_INT32.  Use sqlite3VdbeChangeP4() in either of
  40365 // those cases.
  40366 func Xsqlite3VdbeAppendP4(tls *libc.TLS, p uintptr, pP4 uintptr, n int32) {
  40367 	var pOp uintptr
  40368 
  40369 	if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 {
  40370 		freeP4(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, n, pP4)
  40371 	} else {
  40372 		pOp = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr((*Vdbe)(unsafe.Pointer(p)).FnOp-1)*20
  40373 
  40374 		(*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(n)
  40375 		*(*uintptr)(unsafe.Pointer(pOp + 16)) = pP4
  40376 	}
  40377 }
  40378 
  40379 // Set the P4 on the most recently added opcode to the KeyInfo for the
  40380 // index given.
  40381 func Xsqlite3VdbeSetP4KeyInfo(tls *libc.TLS, pParse uintptr, pIdx uintptr) {
  40382 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  40383 	var pKeyInfo uintptr
  40384 
  40385 	pKeyInfo = Xsqlite3KeyInfoOfIndex(tls, pParse, pIdx)
  40386 	if pKeyInfo != 0 {
  40387 		Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -8)
  40388 	}
  40389 }
  40390 
  40391 // Return the opcode for a given address.  The address must be non-negative.
  40392 // See sqlite3VdbeGetLastOp() to get the most recently added opcode.
  40393 //
  40394 // If a memory allocation error has occurred prior to the calling of this
  40395 // routine, then a pointer to a dummy VdbeOp will be returned.  That opcode
  40396 // is readable but not writable, though it is cast to a writable value.
  40397 // The return of a dummy opcode allows the call to continue functioning
  40398 // after an OOM fault without having to check to see if the return from
  40399 // this routine is a valid pointer.  But because the dummy.opcode is 0,
  40400 // dummy will never be written to.  This is verified by code inspection and
  40401 // by running with Valgrind.
  40402 func Xsqlite3VdbeGetOp(tls *libc.TLS, p uintptr, addr int32) uintptr {
  40403 	if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 {
  40404 		return uintptr(unsafe.Pointer(&dummy))
  40405 	} else {
  40406 		return (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*20
  40407 	}
  40408 	return uintptr(0)
  40409 }
  40410 
  40411 var dummy VdbeOp
  40412 
  40413 // Return the most recently added opcode
  40414 func Xsqlite3VdbeGetLastOp(tls *libc.TLS, p uintptr) uintptr {
  40415 	return Xsqlite3VdbeGetOp(tls, p, (*Vdbe)(unsafe.Pointer(p)).FnOp-1)
  40416 }
  40417 
  40418 // Compute a string that describes the P4 parameter for an opcode.
  40419 // Use zTemp for any required temporary buffer space.
  40420 func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr {
  40421 	bp := tls.Alloc(168)
  40422 	defer tls.Free(168)
  40423 
  40424 	var zP4 uintptr = uintptr(0)
  40425 
  40426 	Xsqlite3StrAccumInit(tls, bp+144, uintptr(0), uintptr(0), 0, SQLITE_MAX_LENGTH)
  40427 	switch int32((*Op)(unsafe.Pointer(pOp)).Fp4type) {
  40428 	case -8:
  40429 		{
  40430 			var j int32
  40431 			var pKeyInfo uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16))
  40432 
  40433 			Xsqlite3_str_appendf(tls, bp+144, ts+4939, libc.VaList(bp, int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)))
  40434 			for j = 0; j < int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField); j++ {
  40435 				var pColl uintptr = *(*uintptr)(unsafe.Pointer(pKeyInfo + 20 + uintptr(j)*4))
  40436 				var zColl uintptr
  40437 				if pColl != 0 {
  40438 					zColl = (*CollSeq)(unsafe.Pointer(pColl)).FzName
  40439 				} else {
  40440 					zColl = ts + 1554
  40441 				}
  40442 				if libc.Xstrcmp(tls, zColl, ts+1099) == 0 {
  40443 					zColl = ts + 4944
  40444 				}
  40445 				Xsqlite3_str_appendf(tls, bp+144, ts+4946,
  40446 					libc.VaList(bp+8, func() uintptr {
  40447 						if int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j))))&KEYINFO_ORDER_DESC != 0 {
  40448 							return ts + 4932
  40449 						}
  40450 						return ts + 1554
  40451 					}(),
  40452 						func() uintptr {
  40453 							if int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j))))&KEYINFO_ORDER_BIGNULL != 0 {
  40454 								return ts + 4954
  40455 							}
  40456 							return ts + 1554
  40457 						}(),
  40458 						zColl))
  40459 			}
  40460 			Xsqlite3_str_append(tls, bp+144, ts+4957, 1)
  40461 			break
  40462 
  40463 		}
  40464 	case -2:
  40465 		{
  40466 			var pColl uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16))
  40467 
  40468 			Xsqlite3_str_appendf(tls, bp+144, ts+4959, libc.VaList(bp+32, (*CollSeq)(unsafe.Pointer(pColl)).FzName,
  40469 				encnames[(*CollSeq)(unsafe.Pointer(pColl)).Fenc]))
  40470 			break
  40471 
  40472 		}
  40473 	case -7:
  40474 		{
  40475 			var pDef uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16))
  40476 			Xsqlite3_str_appendf(tls, bp+144, ts+4968, libc.VaList(bp+48, (*FuncDef)(unsafe.Pointer(pDef)).FzName, int32((*FuncDef)(unsafe.Pointer(pDef)).FnArg)))
  40477 			break
  40478 
  40479 		}
  40480 	case -15:
  40481 		{
  40482 			var pDef uintptr = (*Sqlite3_context)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpFunc
  40483 			Xsqlite3_str_appendf(tls, bp+144, ts+4968, libc.VaList(bp+64, (*FuncDef)(unsafe.Pointer(pDef)).FzName, int32((*FuncDef)(unsafe.Pointer(pDef)).FnArg)))
  40484 			break
  40485 
  40486 		}
  40487 	case -13:
  40488 		{
  40489 			Xsqlite3_str_appendf(tls, bp+144, ts+1334, libc.VaList(bp+80, *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16))))))
  40490 			break
  40491 
  40492 		}
  40493 	case -3:
  40494 		{
  40495 			Xsqlite3_str_appendf(tls, bp+144, ts+4975, libc.VaList(bp+88, *(*int32)(unsafe.Pointer(pOp + 16))))
  40496 			break
  40497 
  40498 		}
  40499 	case -12:
  40500 		{
  40501 			Xsqlite3_str_appendf(tls, bp+144, ts+1328, libc.VaList(bp+96, *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16))))))
  40502 			break
  40503 
  40504 		}
  40505 	case -10:
  40506 		{
  40507 			var pMem uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16))
  40508 			if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Str != 0 {
  40509 				zP4 = (*Mem)(unsafe.Pointer(pMem)).Fz
  40510 			} else if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Int|MEM_IntReal) != 0 {
  40511 				Xsqlite3_str_appendf(tls, bp+144, ts+1334, libc.VaList(bp+104, *(*I64)(unsafe.Pointer(pMem))))
  40512 			} else if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Real != 0 {
  40513 				Xsqlite3_str_appendf(tls, bp+144, ts+1328, libc.VaList(bp+112, *(*float64)(unsafe.Pointer(pMem))))
  40514 			} else if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Null != 0 {
  40515 				zP4 = ts + 1555
  40516 			} else {
  40517 				zP4 = ts + 4978
  40518 			}
  40519 			break
  40520 
  40521 		}
  40522 	case -11:
  40523 		{
  40524 			var pVtab uintptr = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab
  40525 			Xsqlite3_str_appendf(tls, bp+144, ts+4985, libc.VaList(bp+120, pVtab))
  40526 			break
  40527 
  40528 		}
  40529 	case -14:
  40530 		{
  40531 			var i U32
  40532 			var ai uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16))
  40533 			var n U32 = *(*U32)(unsafe.Pointer(ai))
  40534 
  40535 			for i = U32(1); i <= n; i++ {
  40536 				Xsqlite3_str_appendf(tls, bp+144, ts+4993, libc.VaList(bp+128, func() int32 {
  40537 					if i == U32(1) {
  40538 						return '['
  40539 					}
  40540 					return ','
  40541 				}(), *(*U32)(unsafe.Pointer(ai + uintptr(i)*4))))
  40542 			}
  40543 			Xsqlite3_str_append(tls, bp+144, ts+4998, 1)
  40544 			break
  40545 
  40546 		}
  40547 	case -4:
  40548 		{
  40549 			zP4 = ts + 5000
  40550 			break
  40551 
  40552 		}
  40553 	case -5:
  40554 		{
  40555 			zP4 = (*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FzName
  40556 			break
  40557 
  40558 		}
  40559 	default:
  40560 		{
  40561 			zP4 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  40562 
  40563 		}
  40564 	}
  40565 	if zP4 != 0 {
  40566 		Xsqlite3_str_appendall(tls, bp+144, zP4)
  40567 	}
  40568 	if int32((*StrAccum)(unsafe.Pointer(bp+144)).FaccError)&SQLITE_NOMEM != 0 {
  40569 		Xsqlite3OomFault(tls, db)
  40570 	}
  40571 	return Xsqlite3StrAccumFinish(tls, bp+144)
  40572 }
  40573 
  40574 var encnames = [4]uintptr{ts + 5008, ts + 5010, ts + 5012, ts + 5017}
  40575 
  40576 // Declare to the Vdbe that the BTree object at db->aDb[i] is used.
  40577 //
  40578 // The prepared statements need to know in advance the complete set of
  40579 // attached databases that will be use.  A mask of these databases
  40580 // is maintained in p->btreeMask.  The p->lockMask value is the subset of
  40581 // p->btreeMask of databases that will require a lock.
  40582 func Xsqlite3VdbeUsesBtree(tls *libc.TLS, p uintptr, i int32) {
  40583 	*(*YDbMask)(unsafe.Pointer(p + 156)) |= YDbMask(1) << i
  40584 	if i != 1 && Xsqlite3BtreeSharable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FaDb+uintptr(i)*16)).FpBt) != 0 {
  40585 		*(*YDbMask)(unsafe.Pointer(p + 160)) |= YDbMask(1) << i
  40586 	}
  40587 }
  40588 
  40589 // If SQLite is compiled to support shared-cache mode and to be threadsafe,
  40590 // this routine obtains the mutex associated with each BtShared structure
  40591 // that may be accessed by the VM passed as an argument. In doing so it also
  40592 // sets the BtShared.db member of each of the BtShared structures, ensuring
  40593 // that the correct busy-handler callback is invoked if required.
  40594 //
  40595 // If SQLite is not threadsafe but does support shared-cache mode, then
  40596 // sqlite3BtreeEnter() is invoked to set the BtShared.db variables
  40597 // of all of BtShared structures accessible via the database handle
  40598 // associated with the VM.
  40599 //
  40600 // If SQLite is not threadsafe and does not support shared-cache mode, this
  40601 // function is a no-op.
  40602 //
  40603 // The p->btreeMask field is a bitmask of all btrees that the prepared
  40604 // statement p will ever use.  Let N be the number of bits in p->btreeMask
  40605 // corresponding to btrees that use shared cache.  Then the runtime of
  40606 // this routine is N*N.  But as N is rarely more than 1, this should not
  40607 // be a problem.
  40608 func Xsqlite3VdbeEnter(tls *libc.TLS, p uintptr) {
  40609 	var i int32
  40610 	var db uintptr
  40611 	var aDb uintptr
  40612 	var nDb int32
  40613 	if (*Vdbe)(unsafe.Pointer(p)).FlockMask == YDbMask(0) {
  40614 		return
  40615 	}
  40616 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  40617 	aDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb
  40618 	nDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb
  40619 	for i = 0; i < nDb; i++ {
  40620 		if i != 1 && (*Vdbe)(unsafe.Pointer(p)).FlockMask&(YDbMask(1)<<i) != YDbMask(0) && (*Db)(unsafe.Pointer(aDb+uintptr(i)*16)).FpBt != uintptr(0) {
  40621 			Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer(aDb+uintptr(i)*16)).FpBt)
  40622 		}
  40623 	}
  40624 }
  40625 
  40626 func vdbeLeave(tls *libc.TLS, p uintptr) {
  40627 	var i int32
  40628 	var db uintptr
  40629 	var aDb uintptr
  40630 	var nDb int32
  40631 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  40632 	aDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb
  40633 	nDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb
  40634 	for i = 0; i < nDb; i++ {
  40635 		if i != 1 && (*Vdbe)(unsafe.Pointer(p)).FlockMask&(YDbMask(1)<<i) != YDbMask(0) && (*Db)(unsafe.Pointer(aDb+uintptr(i)*16)).FpBt != uintptr(0) {
  40636 			Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer(aDb+uintptr(i)*16)).FpBt)
  40637 		}
  40638 	}
  40639 }
  40640 
  40641 func Xsqlite3VdbeLeave(tls *libc.TLS, p uintptr) {
  40642 	if (*Vdbe)(unsafe.Pointer(p)).FlockMask == YDbMask(0) {
  40643 		return
  40644 	}
  40645 	vdbeLeave(tls, p)
  40646 }
  40647 
  40648 func initMemArray(tls *libc.TLS, p uintptr, N int32, db uintptr, flags U16) {
  40649 	if N > 0 {
  40650 		for __ccgo := true; __ccgo; __ccgo = libc.PreDecInt32(&N, 1) > 0 {
  40651 			(*Mem)(unsafe.Pointer(p)).Fflags = flags
  40652 			(*Mem)(unsafe.Pointer(p)).Fdb = db
  40653 			(*Mem)(unsafe.Pointer(p)).FszMalloc = 0
  40654 			p += 40
  40655 		}
  40656 	}
  40657 }
  40658 
  40659 func releaseMemArray(tls *libc.TLS, p uintptr, N int32) {
  40660 	if p != 0 && N != 0 {
  40661 		var pEnd uintptr = p + uintptr(N)*40
  40662 		var db uintptr = (*Mem)(unsafe.Pointer(p)).Fdb
  40663 		if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed != 0 {
  40664 			for __ccgo := true; __ccgo; __ccgo = libc.PreIncUintptr(&p, 40) < pEnd {
  40665 				if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 {
  40666 					Xsqlite3DbFree(tls, db, (*Mem)(unsafe.Pointer(p)).FzMalloc)
  40667 				}
  40668 			}
  40669 			return
  40670 		}
  40671 		for __ccgo1 := true; __ccgo1; __ccgo1 = libc.PreIncUintptr(&p, 40) < pEnd {
  40672 			if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  40673 				Xsqlite3VdbeMemRelease(tls, p)
  40674 				(*Mem)(unsafe.Pointer(p)).Fflags = U16(MEM_Undefined)
  40675 			} else if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 {
  40676 				Xsqlite3DbNNFreeNN(tls, db, (*Mem)(unsafe.Pointer(p)).FzMalloc)
  40677 				(*Mem)(unsafe.Pointer(p)).FszMalloc = 0
  40678 				(*Mem)(unsafe.Pointer(p)).Fflags = U16(MEM_Undefined)
  40679 			}
  40680 		}
  40681 	}
  40682 }
  40683 
  40684 // This is a destructor on a Mem object (which is really an sqlite3_value)
  40685 // that deletes the Frame object that is attached to it as a blob.
  40686 //
  40687 // This routine does not delete the Frame right away.  It merely adds the
  40688 // frame to a list of frames to be deleted when the Vdbe halts.
  40689 func Xsqlite3VdbeFrameMemDel(tls *libc.TLS, pArg uintptr) {
  40690 	var pFrame uintptr = pArg
  40691 
  40692 	(*VdbeFrame)(unsafe.Pointer(pFrame)).FpParent = (*Vdbe)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(pFrame)).Fv)).FpDelFrame
  40693 	(*Vdbe)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(pFrame)).Fv)).FpDelFrame = pFrame
  40694 }
  40695 
  40696 // Locate the next opcode to be displayed in EXPLAIN or EXPLAIN
  40697 // QUERY PLAN output.
  40698 //
  40699 // Return SQLITE_ROW on success.  Return SQLITE_DONE if there are no
  40700 // more opcodes to be displayed.
  40701 func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, piPc uintptr, piAddr uintptr, paOp uintptr) int32 {
  40702 	var nRow int32
  40703 	var nSub int32 = 0
  40704 	var apSub uintptr = uintptr(0)
  40705 	var i int32
  40706 	var rc int32 = SQLITE_OK
  40707 	var aOp uintptr = uintptr(0)
  40708 	var iPc int32
  40709 
  40710 	nRow = (*Vdbe)(unsafe.Pointer(p)).FnOp
  40711 	if pSub != uintptr(0) {
  40712 		if int32((*Mem)(unsafe.Pointer(pSub)).Fflags)&MEM_Blob != 0 {
  40713 			nSub = int32(uint32((*Mem)(unsafe.Pointer(pSub)).Fn) / uint32(unsafe.Sizeof(uintptr(0))))
  40714 			apSub = (*Mem)(unsafe.Pointer(pSub)).Fz
  40715 		}
  40716 		for i = 0; i < nSub; i++ {
  40717 			nRow = nRow + (*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(apSub + uintptr(i)*4)))).FnOp
  40718 		}
  40719 	}
  40720 	iPc = *(*int32)(unsafe.Pointer(piPc))
  40721 	for 1 != 0 {
  40722 		i = libc.PostIncInt32(&iPc, 1)
  40723 		if i >= nRow {
  40724 			(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
  40725 			rc = SQLITE_DONE
  40726 			break
  40727 		}
  40728 		if i < (*Vdbe)(unsafe.Pointer(p)).FnOp {
  40729 			aOp = (*Vdbe)(unsafe.Pointer(p)).FaOp
  40730 		} else {
  40731 			var j int32
  40732 			i = i - (*Vdbe)(unsafe.Pointer(p)).FnOp
  40733 
  40734 			for j = 0; i >= (*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(apSub + uintptr(j)*4)))).FnOp; j++ {
  40735 				i = i - (*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(apSub + uintptr(j)*4)))).FnOp
  40736 
  40737 			}
  40738 			aOp = (*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(apSub + uintptr(j)*4)))).FaOp
  40739 		}
  40740 
  40741 		if pSub != uintptr(0) && int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*20)).Fp4type) == -4 {
  40742 			var nByte int32 = int32(uint32(nSub+1) * uint32(unsafe.Sizeof(uintptr(0))))
  40743 			var j int32
  40744 			for j = 0; j < nSub; j++ {
  40745 				if *(*uintptr)(unsafe.Pointer(apSub + uintptr(j)*4)) == *(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*20 + 16)) {
  40746 					break
  40747 				}
  40748 			}
  40749 			if j == nSub {
  40750 				(*Vdbe)(unsafe.Pointer(p)).Frc = Xsqlite3VdbeMemGrow(tls, pSub, nByte, libc.Bool32(nSub != 0))
  40751 				if (*Vdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK {
  40752 					rc = SQLITE_ERROR
  40753 					break
  40754 				}
  40755 				apSub = (*Mem)(unsafe.Pointer(pSub)).Fz
  40756 				*(*uintptr)(unsafe.Pointer(apSub + uintptr(libc.PostIncInt32(&nSub, 1))*4)) = *(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*20 + 16))
  40757 				(*Mem)(unsafe.Pointer(pSub)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pSub)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Blob)
  40758 				(*Mem)(unsafe.Pointer(pSub)).Fn = int32(uint32(nSub) * uint32(unsafe.Sizeof(uintptr(0))))
  40759 				nRow = nRow + (*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*20 + 16)))).FnOp
  40760 			}
  40761 		}
  40762 		if eMode == 0 {
  40763 			break
  40764 		}
  40765 		{
  40766 			if int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*20)).Fopcode) == OP_Explain {
  40767 				break
  40768 			}
  40769 			if int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*20)).Fopcode) == OP_Init && iPc > 1 {
  40770 				break
  40771 			}
  40772 
  40773 		}
  40774 	}
  40775 	*(*int32)(unsafe.Pointer(piPc)) = iPc
  40776 	*(*int32)(unsafe.Pointer(piAddr)) = i
  40777 	*(*uintptr)(unsafe.Pointer(paOp)) = aOp
  40778 	return rc
  40779 }
  40780 
  40781 // Delete a VdbeFrame object and its contents. VdbeFrame objects are
  40782 // allocated by the OP_Program opcode in sqlite3VdbeExec().
  40783 func Xsqlite3VdbeFrameDelete(tls *libc.TLS, p uintptr) {
  40784 	var i int32
  40785 	var aMem uintptr = p + 88
  40786 	var apCsr uintptr = aMem + uintptr((*VdbeFrame)(unsafe.Pointer(p)).FnChildMem)*40
  40787 
  40788 	for i = 0; i < (*VdbeFrame)(unsafe.Pointer(p)).FnChildCsr; i++ {
  40789 		if *(*uintptr)(unsafe.Pointer(apCsr + uintptr(i)*4)) != 0 {
  40790 			Xsqlite3VdbeFreeCursorNN(tls, (*VdbeFrame)(unsafe.Pointer(p)).Fv, *(*uintptr)(unsafe.Pointer(apCsr + uintptr(i)*4)))
  40791 		}
  40792 	}
  40793 	releaseMemArray(tls, aMem, (*VdbeFrame)(unsafe.Pointer(p)).FnChildMem)
  40794 	Xsqlite3VdbeDeleteAuxData(tls, (*Vdbe)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(p)).Fv)).Fdb, p+40, -1, 0)
  40795 	Xsqlite3DbFree(tls, (*Vdbe)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(p)).Fv)).Fdb, p)
  40796 }
  40797 
  40798 // Give a listing of the program in the virtual machine.
  40799 //
  40800 // The interface is the same as sqlite3VdbeExec().  But instead of
  40801 // running the code, it invokes the callback once for each instruction.
  40802 // This feature is used to implement "EXPLAIN".
  40803 //
  40804 // When p->explain==1, each instruction is listed.  When
  40805 // p->explain==2, only OP_Explain instructions are listed and these
  40806 // are shown in a different format.  p->explain==2 is used to implement
  40807 // EXPLAIN QUERY PLAN.
  40808 // 2018-04-24:  In p->explain==2 mode, the OP_Init opcodes of triggers
  40809 // are also shown, so that the boundaries between the main program and
  40810 // each trigger are clear.
  40811 //
  40812 // When p->explain==1, first the main program is listed, then each of
  40813 // the trigger subprograms are listed one by one.
  40814 func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 {
  40815 	bp := tls.Alloc(8)
  40816 	defer tls.Free(8)
  40817 
  40818 	var pSub uintptr = uintptr(0)
  40819 	var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  40820 
  40821 	var rc int32 = SQLITE_OK
  40822 	var pMem uintptr = (*Vdbe)(unsafe.Pointer(p)).FaMem + 1*40
  40823 	var bListSubprogs int32 = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(p + 152))&0xc>>2) == 1 || (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_TriggerEQP) != uint64(0))
  40824 
  40825 	var pOp uintptr
  40826 
  40827 	releaseMemArray(tls, pMem, 8)
  40828 
  40829 	if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_NOMEM {
  40830 		Xsqlite3OomFault(tls, db)
  40831 		return SQLITE_ERROR
  40832 	}
  40833 
  40834 	if bListSubprogs != 0 {
  40835 		pSub = (*Vdbe)(unsafe.Pointer(p)).FaMem + 9*40
  40836 	} else {
  40837 		pSub = uintptr(0)
  40838 	}
  40839 
  40840 	rc = Xsqlite3VdbeNextOpcode(tls, p, pSub, libc.Bool32(int32(*(*uint8)(unsafe.Pointer(p + 152))&0xc>>2) == 2), p+32, bp, bp+4)
  40841 
  40842 	if rc == SQLITE_OK {
  40843 		pOp = *(*uintptr)(unsafe.Pointer(bp + 4)) + uintptr(*(*int32)(unsafe.Pointer(bp)))*20
  40844 		if libc.AtomicLoadNInt32(db+312, 0) != 0 {
  40845 			(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_INTERRUPT
  40846 			rc = SQLITE_ERROR
  40847 			Xsqlite3VdbeError(tls, p, Xsqlite3ErrStr(tls, (*Vdbe)(unsafe.Pointer(p)).Frc), 0)
  40848 		} else {
  40849 			var zP4 uintptr = Xsqlite3VdbeDisplayP4(tls, db, pOp)
  40850 			if int32(*(*uint8)(unsafe.Pointer(p + 152))&0xc>>2) == 2 {
  40851 				Xsqlite3VdbeMemSetInt64(tls, pMem, int64((*Op)(unsafe.Pointer(pOp)).Fp1))
  40852 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(1)*40, int64((*Op)(unsafe.Pointer(pOp)).Fp2))
  40853 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(2)*40, int64((*Op)(unsafe.Pointer(pOp)).Fp3))
  40854 				Xsqlite3VdbeMemSetStr(tls, pMem+uintptr(3)*40, zP4, int64(-1), uint8(SQLITE_UTF8), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  40855 				(*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(4)
  40856 			} else {
  40857 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(0)*40, int64(*(*int32)(unsafe.Pointer(bp))))
  40858 				Xsqlite3VdbeMemSetStr(tls, pMem+uintptr(1)*40, Xsqlite3OpcodeName(tls, int32((*Op)(unsafe.Pointer(pOp)).Fopcode)),
  40859 					int64(-1), uint8(SQLITE_UTF8), uintptr(0))
  40860 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(2)*40, int64((*Op)(unsafe.Pointer(pOp)).Fp1))
  40861 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(3)*40, int64((*Op)(unsafe.Pointer(pOp)).Fp2))
  40862 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(4)*40, int64((*Op)(unsafe.Pointer(pOp)).Fp3))
  40863 
  40864 				Xsqlite3VdbeMemSetInt64(tls, pMem+uintptr(6)*40, int64((*Op)(unsafe.Pointer(pOp)).Fp5))
  40865 				Xsqlite3VdbeMemSetNull(tls, pMem+uintptr(7)*40)
  40866 				Xsqlite3VdbeMemSetStr(tls, pMem+uintptr(5)*40, zP4, int64(-1), uint8(SQLITE_UTF8), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  40867 				(*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(8)
  40868 			}
  40869 			(*Vdbe)(unsafe.Pointer(p)).FpResultRow = pMem
  40870 			if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  40871 				(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
  40872 				rc = SQLITE_ERROR
  40873 			} else {
  40874 				(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
  40875 				rc = SQLITE_ROW
  40876 			}
  40877 		}
  40878 	}
  40879 	return rc
  40880 }
  40881 
  40882 // An instance of this object describes bulk memory available for use
  40883 // by subcomponents of a prepared statement.  Space is allocated out
  40884 // of a ReusableSpace object by the allocSpace() routine below.
  40885 type ReusableSpace = struct {
  40886 	FpSpace      uintptr
  40887 	F__ccgo_pad1 [4]byte
  40888 	FnFree       Sqlite3_int64
  40889 	FnNeeded     Sqlite3_int64
  40890 }
  40891 
  40892 func allocSpace(tls *libc.TLS, p uintptr, pBuf uintptr, nByte Sqlite3_int64) uintptr {
  40893 	if pBuf == uintptr(0) {
  40894 		nByte = (nByte + int64(7)) & int64(libc.CplInt32(7))
  40895 		if nByte <= (*ReusableSpace)(unsafe.Pointer(p)).FnFree {
  40896 			*(*Sqlite3_int64)(unsafe.Pointer(p + 8)) -= nByte
  40897 			pBuf = (*ReusableSpace)(unsafe.Pointer(p)).FpSpace + uintptr((*ReusableSpace)(unsafe.Pointer(p)).FnFree)
  40898 		} else {
  40899 			*(*Sqlite3_int64)(unsafe.Pointer(p + 16)) += nByte
  40900 		}
  40901 	}
  40902 
  40903 	return pBuf
  40904 }
  40905 
  40906 // Rewind the VDBE back to the beginning in preparation for
  40907 // running it.
  40908 func Xsqlite3VdbeRewind(tls *libc.TLS, p uintptr) {
  40909 	(*Vdbe)(unsafe.Pointer(p)).FeVdbeState = U8(VDBE_READY_STATE)
  40910 
  40911 	(*Vdbe)(unsafe.Pointer(p)).Fpc = -1
  40912 	(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
  40913 	(*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(OE_Abort)
  40914 	(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  40915 	(*Vdbe)(unsafe.Pointer(p)).FcacheCtr = U32(1)
  40916 	(*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat = U8(255)
  40917 	(*Vdbe)(unsafe.Pointer(p)).FiStatement = 0
  40918 	(*Vdbe)(unsafe.Pointer(p)).FnFkConstraint = int64(0)
  40919 }
  40920 
  40921 // Prepare a virtual machine for execution for the first time after
  40922 // creating the virtual machine.  This involves things such
  40923 // as allocating registers and initializing the program counter.
  40924 // After the VDBE has be prepped, it can be executed by one or more
  40925 // calls to sqlite3VdbeExec().
  40926 //
  40927 // This function may be called exactly once on each virtual machine.
  40928 // After this routine is called the VM has been "packaged" and is ready
  40929 // to run.  After this routine is called, further calls to
  40930 // sqlite3VdbeAddOp() functions are prohibited.  This routine disconnects
  40931 // the Vdbe from the Parse object that helped generate it so that the
  40932 // the Vdbe becomes an independent entity and the Parse object can be
  40933 // destroyed.
  40934 //
  40935 // Use the sqlite3VdbeRewind() procedure to restore a virtual machine back
  40936 // to its initial state after it has been run.
  40937 func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) {
  40938 	bp := tls.Alloc(32)
  40939 	defer tls.Free(32)
  40940 
  40941 	var db uintptr
  40942 	var nVar int32
  40943 	var nMem int32
  40944 	var nCursor int32
  40945 
  40946 	var n int32
  40947 
  40948 	(*Vdbe)(unsafe.Pointer(p)).FpVList = (*Parse)(unsafe.Pointer(pParse)).FpVList
  40949 	(*Parse)(unsafe.Pointer(pParse)).FpVList = uintptr(0)
  40950 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  40951 
  40952 	nVar = int32((*Parse)(unsafe.Pointer(pParse)).FnVar)
  40953 	nMem = (*Parse)(unsafe.Pointer(pParse)).FnMem
  40954 	nCursor = (*Parse)(unsafe.Pointer(pParse)).FnTab
  40955 	*(*int32)(unsafe.Pointer(bp)) = (*Parse)(unsafe.Pointer(pParse)).FnMaxArg
  40956 
  40957 	nMem = nMem + nCursor
  40958 	if nCursor == 0 && nMem > 0 {
  40959 		nMem++
  40960 	}
  40961 
  40962 	n = int32((uint32(unsafe.Sizeof(Op{}))*uint32((*Vdbe)(unsafe.Pointer(p)).FnOp) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  40963 	(*ReusableSpace)(unsafe.Pointer(bp + 8)).FpSpace = (*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(n)
  40964 
  40965 	(*ReusableSpace)(unsafe.Pointer(bp + 8)).FnFree = Sqlite3_int64(((*Parse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & libc.CplInt32(7))
  40966 
  40967 	resolveP2Values(tls, p, bp)
  40968 	libc.SetBitFieldPtr8Uint32(p+152, Bft(U8(libc.Bool32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite != 0 && (*Parse)(unsafe.Pointer(pParse)).FmayAbort != 0))), 5, 0x20)
  40969 	if (*Parse)(unsafe.Pointer(pParse)).Fexplain != 0 {
  40970 		var iFirst int32
  40971 		var mx int32
  40972 		var i int32
  40973 		if nMem < 10 {
  40974 			nMem = 10
  40975 		}
  40976 		libc.SetBitFieldPtr8Uint32(p+152, Bft((*Parse)(unsafe.Pointer(pParse)).Fexplain), 2, 0xc)
  40977 		if int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) == 2 {
  40978 			Xsqlite3VdbeSetNumCols(tls, p, 4)
  40979 			iFirst = 8
  40980 			mx = 12
  40981 		} else {
  40982 			Xsqlite3VdbeSetNumCols(tls, p, 8)
  40983 			iFirst = 0
  40984 			mx = 8
  40985 		}
  40986 		for i = iFirst; i < mx; i++ {
  40987 			Xsqlite3VdbeSetColName(tls, p, i-iFirst, COLNAME_NAME,
  40988 				azColName[i], uintptr(0))
  40989 		}
  40990 	}
  40991 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 0, 0x3)
  40992 
  40993 	(*ReusableSpace)(unsafe.Pointer(bp + 8)).FnNeeded = int64(0)
  40994 	(*Vdbe)(unsafe.Pointer(p)).FaMem = allocSpace(tls, bp+8, uintptr(0), int64(uint32(nMem)*uint32(unsafe.Sizeof(Mem{}))))
  40995 	(*Vdbe)(unsafe.Pointer(p)).FaVar = allocSpace(tls, bp+8, uintptr(0), int64(uint32(nVar)*uint32(unsafe.Sizeof(Mem{}))))
  40996 	(*Vdbe)(unsafe.Pointer(p)).FapArg = allocSpace(tls, bp+8, uintptr(0), int64(uint32(*(*int32)(unsafe.Pointer(bp)))*uint32(unsafe.Sizeof(uintptr(0)))))
  40997 	(*Vdbe)(unsafe.Pointer(p)).FapCsr = allocSpace(tls, bp+8, uintptr(0), int64(uint32(nCursor)*uint32(unsafe.Sizeof(uintptr(0)))))
  40998 	if (*ReusableSpace)(unsafe.Pointer(bp+8)).FnNeeded != 0 {
  40999 		(*ReusableSpace)(unsafe.Pointer(bp + 8)).FpSpace = libc.AssignPtrUintptr(p+204, Xsqlite3DbMallocRawNN(tls, db, uint64((*ReusableSpace)(unsafe.Pointer(bp+8)).FnNeeded)))
  41000 		(*ReusableSpace)(unsafe.Pointer(bp + 8)).FnFree = (*ReusableSpace)(unsafe.Pointer(bp + 8)).FnNeeded
  41001 		if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  41002 			(*Vdbe)(unsafe.Pointer(p)).FaMem = allocSpace(tls, bp+8, (*Vdbe)(unsafe.Pointer(p)).FaMem, int64(uint32(nMem)*uint32(unsafe.Sizeof(Mem{}))))
  41003 			(*Vdbe)(unsafe.Pointer(p)).FaVar = allocSpace(tls, bp+8, (*Vdbe)(unsafe.Pointer(p)).FaVar, int64(uint32(nVar)*uint32(unsafe.Sizeof(Mem{}))))
  41004 			(*Vdbe)(unsafe.Pointer(p)).FapArg = allocSpace(tls, bp+8, (*Vdbe)(unsafe.Pointer(p)).FapArg, int64(uint32(*(*int32)(unsafe.Pointer(bp)))*uint32(unsafe.Sizeof(uintptr(0)))))
  41005 			(*Vdbe)(unsafe.Pointer(p)).FapCsr = allocSpace(tls, bp+8, (*Vdbe)(unsafe.Pointer(p)).FapCsr, int64(uint32(nCursor)*uint32(unsafe.Sizeof(uintptr(0)))))
  41006 		}
  41007 	}
  41008 
  41009 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  41010 		(*Vdbe)(unsafe.Pointer(p)).FnVar = int16(0)
  41011 		(*Vdbe)(unsafe.Pointer(p)).FnCursor = 0
  41012 		(*Vdbe)(unsafe.Pointer(p)).FnMem = 0
  41013 	} else {
  41014 		(*Vdbe)(unsafe.Pointer(p)).FnCursor = nCursor
  41015 		(*Vdbe)(unsafe.Pointer(p)).FnVar = YnVar(nVar)
  41016 		initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, nVar, db, uint16(MEM_Null))
  41017 		(*Vdbe)(unsafe.Pointer(p)).FnMem = nMem
  41018 		initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaMem, nMem, db, uint16(MEM_Undefined))
  41019 		libc.Xmemset(tls, (*Vdbe)(unsafe.Pointer(p)).FapCsr, 0, uint32(nCursor)*uint32(unsafe.Sizeof(uintptr(0))))
  41020 	}
  41021 	Xsqlite3VdbeRewind(tls, p)
  41022 }
  41023 
  41024 var azColName = [12]uintptr{
  41025 	ts + 5022, ts + 5027, ts + 5034, ts + 5037, ts + 5040, ts + 5043, ts + 5046, ts + 5049,
  41026 	ts + 5057, ts + 5060, ts + 5067, ts + 5075,
  41027 }
  41028 
  41029 // Close a VDBE cursor and release all the resources that cursor
  41030 // happens to hold.
  41031 func Xsqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) {
  41032 	if pCx != 0 {
  41033 		Xsqlite3VdbeFreeCursorNN(tls, p, pCx)
  41034 	}
  41035 }
  41036 
  41037 func Xsqlite3VdbeFreeCursorNN(tls *libc.TLS, p uintptr, pCx uintptr) {
  41038 	switch int32((*VdbeCursor)(unsafe.Pointer(pCx)).FeCurType) {
  41039 	case CURTYPE_SORTER:
  41040 		{
  41041 			Xsqlite3VdbeSorterClose(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, pCx)
  41042 			break
  41043 
  41044 		}
  41045 	case CURTYPE_BTREE:
  41046 		{
  41047 			Xsqlite3BtreeCloseCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 36)))
  41048 			break
  41049 
  41050 		}
  41051 	case CURTYPE_VTAB:
  41052 		{
  41053 			var pVCur uintptr = *(*uintptr)(unsafe.Pointer(pCx + 36))
  41054 			var pModule uintptr = (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FpModule
  41055 
  41056 			(*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FnRef--
  41057 			(*struct {
  41058 				f func(*libc.TLS, uintptr) int32
  41059 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule)).FxClose})).f(tls, pVCur)
  41060 			break
  41061 
  41062 		}
  41063 	}
  41064 }
  41065 
  41066 func closeCursorsInFrame(tls *libc.TLS, p uintptr) {
  41067 	var i int32
  41068 	for i = 0; i < (*Vdbe)(unsafe.Pointer(p)).FnCursor; i++ {
  41069 		var pC uintptr = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(i)*4))
  41070 		if pC != 0 {
  41071 			Xsqlite3VdbeFreeCursorNN(tls, p, pC)
  41072 			*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(i)*4)) = uintptr(0)
  41073 		}
  41074 	}
  41075 }
  41076 
  41077 // Copy the values stored in the VdbeFrame structure to its Vdbe. This
  41078 // is used, for example, when a trigger sub-program is halted to restore
  41079 // control to the main program.
  41080 func Xsqlite3VdbeFrameRestore(tls *libc.TLS, pFrame uintptr) int32 {
  41081 	var v uintptr = (*VdbeFrame)(unsafe.Pointer(pFrame)).Fv
  41082 	closeCursorsInFrame(tls, v)
  41083 	(*Vdbe)(unsafe.Pointer(v)).FaOp = (*VdbeFrame)(unsafe.Pointer(pFrame)).FaOp
  41084 	(*Vdbe)(unsafe.Pointer(v)).FnOp = (*VdbeFrame)(unsafe.Pointer(pFrame)).FnOp
  41085 	(*Vdbe)(unsafe.Pointer(v)).FaMem = (*VdbeFrame)(unsafe.Pointer(pFrame)).FaMem
  41086 	(*Vdbe)(unsafe.Pointer(v)).FnMem = (*VdbeFrame)(unsafe.Pointer(pFrame)).FnMem
  41087 	(*Vdbe)(unsafe.Pointer(v)).FapCsr = (*VdbeFrame)(unsafe.Pointer(pFrame)).FapCsr
  41088 	(*Vdbe)(unsafe.Pointer(v)).FnCursor = (*VdbeFrame)(unsafe.Pointer(pFrame)).FnCursor
  41089 	(*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).Fdb)).FlastRowid = (*VdbeFrame)(unsafe.Pointer(pFrame)).FlastRowid
  41090 	(*Vdbe)(unsafe.Pointer(v)).FnChange = (*VdbeFrame)(unsafe.Pointer(pFrame)).FnChange
  41091 	(*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).Fdb)).FnChange = (*VdbeFrame)(unsafe.Pointer(pFrame)).FnDbChange
  41092 	Xsqlite3VdbeDeleteAuxData(tls, (*Vdbe)(unsafe.Pointer(v)).Fdb, v+228, -1, 0)
  41093 	(*Vdbe)(unsafe.Pointer(v)).FpAuxData = (*VdbeFrame)(unsafe.Pointer(pFrame)).FpAuxData
  41094 	(*VdbeFrame)(unsafe.Pointer(pFrame)).FpAuxData = uintptr(0)
  41095 	return (*VdbeFrame)(unsafe.Pointer(pFrame)).Fpc
  41096 }
  41097 
  41098 func closeAllCursors(tls *libc.TLS, p uintptr) {
  41099 	if (*Vdbe)(unsafe.Pointer(p)).FpFrame != 0 {
  41100 		var pFrame uintptr
  41101 		for pFrame = (*Vdbe)(unsafe.Pointer(p)).FpFrame; (*VdbeFrame)(unsafe.Pointer(pFrame)).FpParent != 0; pFrame = (*VdbeFrame)(unsafe.Pointer(pFrame)).FpParent {
  41102 		}
  41103 		Xsqlite3VdbeFrameRestore(tls, pFrame)
  41104 		(*Vdbe)(unsafe.Pointer(p)).FpFrame = uintptr(0)
  41105 		(*Vdbe)(unsafe.Pointer(p)).FnFrame = 0
  41106 	}
  41107 
  41108 	closeCursorsInFrame(tls, p)
  41109 	releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaMem, (*Vdbe)(unsafe.Pointer(p)).FnMem)
  41110 	for (*Vdbe)(unsafe.Pointer(p)).FpDelFrame != 0 {
  41111 		var pDel uintptr = (*Vdbe)(unsafe.Pointer(p)).FpDelFrame
  41112 		(*Vdbe)(unsafe.Pointer(p)).FpDelFrame = (*VdbeFrame)(unsafe.Pointer(pDel)).FpParent
  41113 		Xsqlite3VdbeFrameDelete(tls, pDel)
  41114 	}
  41115 
  41116 	if (*Vdbe)(unsafe.Pointer(p)).FpAuxData != 0 {
  41117 		Xsqlite3VdbeDeleteAuxData(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, p+228, -1, 0)
  41118 	}
  41119 
  41120 }
  41121 
  41122 // Set the number of result columns that will be returned by this SQL
  41123 // statement. This is now set at compile time, rather than during
  41124 // execution of the vdbe program so that sqlite3_column_count() can
  41125 // be called on an SQL statement before sqlite3_step().
  41126 func Xsqlite3VdbeSetNumCols(tls *libc.TLS, p uintptr, nResColumn int32) {
  41127 	var n int32
  41128 	var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41129 
  41130 	if (*Vdbe)(unsafe.Pointer(p)).FnResColumn != 0 {
  41131 		releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn)*COLNAME_N)
  41132 		Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FaColName)
  41133 	}
  41134 	n = nResColumn * COLNAME_N
  41135 	(*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(nResColumn)
  41136 	(*Vdbe)(unsafe.Pointer(p)).FaColName = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(Mem{}))*uint32(n)))
  41137 	if (*Vdbe)(unsafe.Pointer(p)).FaColName == uintptr(0) {
  41138 		return
  41139 	}
  41140 	initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, n, db, uint16(MEM_Null))
  41141 }
  41142 
  41143 // Set the name of the idx'th column to be returned by the SQL statement.
  41144 // zName must be a pointer to a nul terminated string.
  41145 //
  41146 // This call must be made after a call to sqlite3VdbeSetNumCols().
  41147 //
  41148 // The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC
  41149 // or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed
  41150 // to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed.
  41151 func Xsqlite3VdbeSetColName(tls *libc.TLS, p uintptr, idx int32, var1 int32, zName uintptr, xDel uintptr) int32 {
  41152 	var rc int32
  41153 	var pColName uintptr
  41154 
  41155 	if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 {
  41156 		return SQLITE_NOMEM
  41157 	}
  41158 
  41159 	pColName = (*Vdbe)(unsafe.Pointer(p)).FaColName + uintptr(idx+var1*int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn))*40
  41160 	rc = Xsqlite3VdbeMemSetStr(tls, pColName, zName, int64(-1), uint8(SQLITE_UTF8), xDel)
  41161 
  41162 	return rc
  41163 }
  41164 
  41165 func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 {
  41166 	bp := tls.Alloc(68)
  41167 	defer tls.Free(68)
  41168 
  41169 	var i int32
  41170 	var nTrans int32 = 0
  41171 
  41172 	var rc int32 = SQLITE_OK
  41173 	var needXcommit int32 = 0
  41174 
  41175 	rc = Xsqlite3VtabSync(tls, db, p)
  41176 
  41177 	for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41178 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41179 		if Xsqlite3BtreeTxnState(tls, pBt) == SQLITE_TXN_WRITE {
  41180 			var pPager uintptr
  41181 			needXcommit = 1
  41182 			Xsqlite3BtreeEnter(tls, pBt)
  41183 			pPager = Xsqlite3BtreePager(tls, pBt)
  41184 			if int32((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).Fsafety_level) != PAGER_SYNCHRONOUS_OFF &&
  41185 				aMJNeeded[Xsqlite3PagerGetJournalMode(tls, pPager)] != 0 &&
  41186 				Xsqlite3PagerIsMemdb(tls, pPager) == 0 {
  41187 				nTrans++
  41188 			}
  41189 			rc = Xsqlite3PagerExclusiveLock(tls, pPager)
  41190 			Xsqlite3BtreeLeave(tls, pBt)
  41191 		}
  41192 	}
  41193 	if rc != SQLITE_OK {
  41194 		return rc
  41195 	}
  41196 
  41197 	if needXcommit != 0 && (*Sqlite3)(unsafe.Pointer(db)).FxCommitCallback != 0 {
  41198 		rc = (*struct {
  41199 			f func(*libc.TLS, uintptr) int32
  41200 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxCommitCallback})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCommitArg)
  41201 		if rc != 0 {
  41202 			return SQLITE_CONSTRAINT | int32(2)<<8
  41203 		}
  41204 	}
  41205 
  41206 	if 0 == Xsqlite3Strlen30(tls, Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)) ||
  41207 		nTrans <= 1 {
  41208 		for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41209 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41210 			if pBt != 0 {
  41211 				rc = Xsqlite3BtreeCommitPhaseOne(tls, pBt, uintptr(0))
  41212 			}
  41213 		}
  41214 
  41215 		for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41216 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41217 			if pBt != 0 {
  41218 				rc = Xsqlite3BtreeCommitPhaseTwo(tls, pBt, 0)
  41219 			}
  41220 		}
  41221 		if rc == SQLITE_OK {
  41222 			Xsqlite3VtabCommit(tls, db)
  41223 		}
  41224 	} else {
  41225 		var pVfs uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpVfs
  41226 		var zSuper uintptr = uintptr(0)
  41227 		var zMainFile uintptr = Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)
  41228 		*(*uintptr)(unsafe.Pointer(bp + 64)) = uintptr(0)
  41229 		var offset I64 = int64(0)
  41230 
  41231 		var retryCount int32 = 0
  41232 		var nMainFile int32
  41233 
  41234 		nMainFile = Xsqlite3Strlen30(tls, zMainFile)
  41235 		zSuper = Xsqlite3MPrintf(tls, db, ts+5082, libc.VaList(bp, 0, zMainFile, 0))
  41236 		if zSuper == uintptr(0) {
  41237 			return SQLITE_NOMEM
  41238 		}
  41239 		zSuper += uintptr(4)
  41240 		for __ccgo := true; __ccgo; __ccgo = rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 60)) != 0 {
  41241 			if retryCount != 0 {
  41242 				if retryCount > 100 {
  41243 					Xsqlite3_log(tls, SQLITE_FULL, ts+5094, libc.VaList(bp+24, zSuper))
  41244 					Xsqlite3OsDelete(tls, pVfs, zSuper, 0)
  41245 					break
  41246 				} else if retryCount == 1 {
  41247 					Xsqlite3_log(tls, SQLITE_FULL, ts+5108, libc.VaList(bp+32, zSuper))
  41248 				}
  41249 			}
  41250 			retryCount++
  41251 			Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U32(0))), bp+56)
  41252 			Xsqlite3_snprintf(tls, 13, zSuper+uintptr(nMainFile), ts+5123,
  41253 				libc.VaList(bp+40, *(*U32)(unsafe.Pointer(bp + 56))>>8&U32(0xffffff), *(*U32)(unsafe.Pointer(bp + 56))&U32(0xff)))
  41254 
  41255 			rc = Xsqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+60)
  41256 		}
  41257 		if rc == SQLITE_OK {
  41258 			rc = Xsqlite3OsOpenMalloc(tls, pVfs, zSuper, bp+64,
  41259 				SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_SUPER_JOURNAL, uintptr(0))
  41260 		}
  41261 		if rc != SQLITE_OK {
  41262 			Xsqlite3DbFree(tls, db, zSuper-uintptr(4))
  41263 			return rc
  41264 		}
  41265 
  41266 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41267 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41268 			if Xsqlite3BtreeTxnState(tls, pBt) == SQLITE_TXN_WRITE {
  41269 				var zFile uintptr = Xsqlite3BtreeGetJournalname(tls, pBt)
  41270 				if zFile == uintptr(0) {
  41271 					continue
  41272 				}
  41273 
  41274 				rc = Xsqlite3OsWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 64)), zFile, Xsqlite3Strlen30(tls, zFile)+1, offset)
  41275 				offset = offset + I64(Xsqlite3Strlen30(tls, zFile)+1)
  41276 				if rc != SQLITE_OK {
  41277 					Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64)))
  41278 					Xsqlite3OsDelete(tls, pVfs, zSuper, 0)
  41279 					Xsqlite3DbFree(tls, db, zSuper-uintptr(4))
  41280 					return rc
  41281 				}
  41282 			}
  41283 		}
  41284 
  41285 		if 0 == Xsqlite3OsDeviceCharacteristics(tls, *(*uintptr)(unsafe.Pointer(bp + 64)))&SQLITE_IOCAP_SEQUENTIAL &&
  41286 			SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3OsSync(tls, *(*uintptr)(unsafe.Pointer(bp + 64)), SQLITE_SYNC_NORMAL)) {
  41287 			Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64)))
  41288 			Xsqlite3OsDelete(tls, pVfs, zSuper, 0)
  41289 			Xsqlite3DbFree(tls, db, zSuper-uintptr(4))
  41290 			return rc
  41291 		}
  41292 
  41293 		for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41294 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41295 			if pBt != 0 {
  41296 				rc = Xsqlite3BtreeCommitPhaseOne(tls, pBt, zSuper)
  41297 			}
  41298 		}
  41299 		Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64)))
  41300 
  41301 		if rc != SQLITE_OK {
  41302 			Xsqlite3DbFree(tls, db, zSuper-uintptr(4))
  41303 			return rc
  41304 		}
  41305 
  41306 		rc = Xsqlite3OsDelete(tls, pVfs, zSuper, 1)
  41307 		Xsqlite3DbFree(tls, db, zSuper-uintptr(4))
  41308 		zSuper = uintptr(0)
  41309 		if rc != 0 {
  41310 			return rc
  41311 		}
  41312 
  41313 		Xsqlite3BeginBenignMalloc(tls)
  41314 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41315 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41316 			if pBt != 0 {
  41317 				Xsqlite3BtreeCommitPhaseTwo(tls, pBt, 1)
  41318 			}
  41319 		}
  41320 		Xsqlite3EndBenignMalloc(tls)
  41321 
  41322 		Xsqlite3VtabCommit(tls, db)
  41323 	}
  41324 
  41325 	return rc
  41326 }
  41327 
  41328 var aMJNeeded = [6]U8{
  41329 	U8(1),
  41330 	U8(1),
  41331 	U8(0),
  41332 	U8(1),
  41333 	U8(0),
  41334 	U8(0),
  41335 }
  41336 
  41337 func vdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 {
  41338 	var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41339 	var rc int32 = SQLITE_OK
  41340 	var i int32
  41341 	var iSavepoint int32 = (*Vdbe)(unsafe.Pointer(p)).FiStatement - 1
  41342 
  41343 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  41344 		var rc2 int32 = SQLITE_OK
  41345 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  41346 		if pBt != 0 {
  41347 			if eOp == SAVEPOINT_ROLLBACK {
  41348 				rc2 = Xsqlite3BtreeSavepoint(tls, pBt, SAVEPOINT_ROLLBACK, iSavepoint)
  41349 			}
  41350 			if rc2 == SQLITE_OK {
  41351 				rc2 = Xsqlite3BtreeSavepoint(tls, pBt, SAVEPOINT_RELEASE, iSavepoint)
  41352 			}
  41353 			if rc == SQLITE_OK {
  41354 				rc = rc2
  41355 			}
  41356 		}
  41357 	}
  41358 	(*Sqlite3)(unsafe.Pointer(db)).FnStatement--
  41359 	(*Vdbe)(unsafe.Pointer(p)).FiStatement = 0
  41360 
  41361 	if rc == SQLITE_OK {
  41362 		if eOp == SAVEPOINT_ROLLBACK {
  41363 			rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_ROLLBACK, iSavepoint)
  41364 		}
  41365 		if rc == SQLITE_OK {
  41366 			rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_RELEASE, iSavepoint)
  41367 		}
  41368 	}
  41369 
  41370 	if eOp == SAVEPOINT_ROLLBACK {
  41371 		(*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = (*Vdbe)(unsafe.Pointer(p)).FnStmtDefCons
  41372 		(*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = (*Vdbe)(unsafe.Pointer(p)).FnStmtDefImmCons
  41373 	}
  41374 	return rc
  41375 }
  41376 
  41377 func Xsqlite3VdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 {
  41378 	if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnStatement != 0 && (*Vdbe)(unsafe.Pointer(p)).FiStatement != 0 {
  41379 		return vdbeCloseStatement(tls, p, eOp)
  41380 	}
  41381 	return SQLITE_OK
  41382 }
  41383 
  41384 // This function is called when a transaction opened by the database
  41385 // handle associated with the VM passed as an argument is about to be
  41386 // committed. If there are outstanding deferred foreign key constraint
  41387 // violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.
  41388 //
  41389 // If there are outstanding FK violations and this function returns
  41390 // SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY
  41391 // and write an error message to it. Then return SQLITE_ERROR.
  41392 func Xsqlite3VdbeCheckFk(tls *libc.TLS, p uintptr, deferred int32) int32 {
  41393 	var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41394 	if deferred != 0 && (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons+(*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons > int64(0) ||
  41395 		!(deferred != 0) && (*Vdbe)(unsafe.Pointer(p)).FnFkConstraint > int64(0) {
  41396 		(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_CONSTRAINT | int32(3)<<8
  41397 		(*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(OE_Abort)
  41398 		Xsqlite3VdbeError(tls, p, ts+5136, 0)
  41399 		if int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags)&SQLITE_PREPARE_SAVESQL == 0 {
  41400 			return SQLITE_ERROR
  41401 		}
  41402 		return SQLITE_CONSTRAINT | int32(3)<<8
  41403 	}
  41404 	return SQLITE_OK
  41405 }
  41406 
  41407 // This routine is called the when a VDBE tries to halt.  If the VDBE
  41408 // has made changes and is in autocommit mode, then commit those
  41409 // changes.  If a rollback is needed, then do the rollback.
  41410 //
  41411 // This routine is the only way to move the sqlite3eOpenState of a VM from
  41412 // SQLITE_STATE_RUN to SQLITE_STATE_HALT.  It is harmless to
  41413 // call this on a VM that is in the SQLITE_STATE_HALT state.
  41414 //
  41415 // Return an error code.  If the commit could not complete because of
  41416 // lock contention, return SQLITE_BUSY.  If SQLITE_BUSY is returned, it
  41417 // means the close did not happen and needs to be repeated.
  41418 func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 {
  41419 	var rc int32
  41420 	var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41421 
  41422 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  41423 		(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
  41424 	}
  41425 	closeAllCursors(tls, p)
  41426 
  41427 	if Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x80>>7)) != 0 {
  41428 		var mrc int32
  41429 		var eStatementOp int32 = 0
  41430 		var isSpecialError int32
  41431 
  41432 		Xsqlite3VdbeEnter(tls, p)
  41433 
  41434 		if (*Vdbe)(unsafe.Pointer(p)).Frc != 0 {
  41435 			mrc = (*Vdbe)(unsafe.Pointer(p)).Frc & 0xff
  41436 			isSpecialError = libc.Bool32(mrc == SQLITE_NOMEM ||
  41437 				mrc == SQLITE_IOERR ||
  41438 				mrc == SQLITE_INTERRUPT ||
  41439 				mrc == SQLITE_FULL)
  41440 		} else {
  41441 			mrc = libc.AssignInt32(&isSpecialError, 0)
  41442 		}
  41443 		if isSpecialError != 0 {
  41444 			if !(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x40>>6) != 0) || mrc != SQLITE_INTERRUPT {
  41445 				if (mrc == SQLITE_NOMEM || mrc == SQLITE_FULL) && Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x20>>5)) != 0 {
  41446 					eStatementOp = SAVEPOINT_ROLLBACK
  41447 				} else {
  41448 					Xsqlite3RollbackAll(tls, db, SQLITE_ABORT|int32(2)<<8)
  41449 					Xsqlite3CloseSavepoints(tls, db)
  41450 					(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
  41451 					(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  41452 				}
  41453 			}
  41454 		}
  41455 
  41456 		if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK || int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail && !(isSpecialError != 0) {
  41457 			Xsqlite3VdbeCheckFk(tls, p, 0)
  41458 		}
  41459 
  41460 		if !((*Sqlite3)(unsafe.Pointer(db)).FnVTrans > 0 && (*Sqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0)) &&
  41461 			(*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0 &&
  41462 			(*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite == libc.Bool32(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x40>>6) == 0) {
  41463 			if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK || int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail && !(isSpecialError != 0) {
  41464 				rc = Xsqlite3VdbeCheckFk(tls, p, 1)
  41465 				if rc != SQLITE_OK {
  41466 					if Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x40>>6)) != 0 {
  41467 						Xsqlite3VdbeLeave(tls, p)
  41468 						return SQLITE_ERROR
  41469 					}
  41470 					rc = SQLITE_CONSTRAINT | int32(3)<<8
  41471 				} else if (*Sqlite3)(unsafe.Pointer(db)).Fflags&(uint64(0x00002)<<32) != 0 {
  41472 					rc = SQLITE_CORRUPT
  41473 					*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(0x00002) << 32)
  41474 				} else {
  41475 					rc = vdbeCommit(tls, db, p)
  41476 				}
  41477 				if rc == SQLITE_BUSY && Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x40>>6)) != 0 {
  41478 					Xsqlite3VdbeLeave(tls, p)
  41479 					return SQLITE_BUSY
  41480 				} else if rc != SQLITE_OK {
  41481 					(*Vdbe)(unsafe.Pointer(p)).Frc = rc
  41482 					Xsqlite3RollbackAll(tls, db, SQLITE_OK)
  41483 					(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  41484 				} else {
  41485 					(*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = int64(0)
  41486 					(*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0)
  41487 					*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_DeferFKs))
  41488 					Xsqlite3CommitInternalChanges(tls, db)
  41489 				}
  41490 			} else {
  41491 				Xsqlite3RollbackAll(tls, db, SQLITE_OK)
  41492 				(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  41493 			}
  41494 			(*Sqlite3)(unsafe.Pointer(db)).FnStatement = 0
  41495 		} else if eStatementOp == 0 {
  41496 			if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK || int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail {
  41497 				eStatementOp = SAVEPOINT_RELEASE
  41498 			} else if int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Abort {
  41499 				eStatementOp = SAVEPOINT_ROLLBACK
  41500 			} else {
  41501 				Xsqlite3RollbackAll(tls, db, SQLITE_ABORT|int32(2)<<8)
  41502 				Xsqlite3CloseSavepoints(tls, db)
  41503 				(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
  41504 				(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  41505 			}
  41506 		}
  41507 
  41508 		if eStatementOp != 0 {
  41509 			rc = Xsqlite3VdbeCloseStatement(tls, p, eStatementOp)
  41510 			if rc != 0 {
  41511 				if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK || (*Vdbe)(unsafe.Pointer(p)).Frc&0xff == SQLITE_CONSTRAINT {
  41512 					(*Vdbe)(unsafe.Pointer(p)).Frc = rc
  41513 					Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)
  41514 					(*Vdbe)(unsafe.Pointer(p)).FzErrMsg = uintptr(0)
  41515 				}
  41516 				Xsqlite3RollbackAll(tls, db, SQLITE_ABORT|int32(2)<<8)
  41517 				Xsqlite3CloseSavepoints(tls, db)
  41518 				(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
  41519 				(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  41520 			}
  41521 		}
  41522 
  41523 		if Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x10>>4)) != 0 {
  41524 			if eStatementOp != SAVEPOINT_ROLLBACK {
  41525 				Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange)
  41526 			} else {
  41527 				Xsqlite3VdbeSetChanges(tls, db, int64(0))
  41528 			}
  41529 			(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  41530 		}
  41531 
  41532 		Xsqlite3VdbeLeave(tls, p)
  41533 	}
  41534 
  41535 	(*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive--
  41536 	if !(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x40>>6) != 0) {
  41537 		(*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite--
  41538 	}
  41539 	if Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x80>>7)) != 0 {
  41540 		(*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead--
  41541 	}
  41542 
  41543 	(*Vdbe)(unsafe.Pointer(p)).FeVdbeState = U8(VDBE_HALT_STATE)
  41544 
  41545 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  41546 		(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
  41547 	}
  41548 
  41549 	if (*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0 {
  41550 		Xsqlite3ConnectionUnlocked(tls, db)
  41551 	}
  41552 
  41553 	return func() int32 {
  41554 		if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_BUSY {
  41555 			return SQLITE_BUSY
  41556 		}
  41557 		return SQLITE_OK
  41558 	}()
  41559 }
  41560 
  41561 // Each VDBE holds the result of the most recent sqlite3_step() call
  41562 // in p->rc.  This routine sets that result back to SQLITE_OK.
  41563 func Xsqlite3VdbeResetStepResult(tls *libc.TLS, p uintptr) {
  41564 	(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
  41565 }
  41566 
  41567 // Copy the error code and error message belonging to the VDBE passed
  41568 // as the first argument to its database handle (so that they will be
  41569 // returned by calls to sqlite3_errcode() and sqlite3_errmsg()).
  41570 //
  41571 // This function does not clear the VDBE error code or message, just
  41572 // copies them to the database handle.
  41573 func Xsqlite3VdbeTransferError(tls *libc.TLS, p uintptr) int32 {
  41574 	var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41575 	var rc int32 = (*Vdbe)(unsafe.Pointer(p)).Frc
  41576 	if (*Vdbe)(unsafe.Pointer(p)).FzErrMsg != 0 {
  41577 		(*Sqlite3)(unsafe.Pointer(db)).FbBenignMalloc++
  41578 		Xsqlite3BeginBenignMalloc(tls)
  41579 		if (*Sqlite3)(unsafe.Pointer(db)).FpErr == uintptr(0) {
  41580 			(*Sqlite3)(unsafe.Pointer(db)).FpErr = Xsqlite3ValueNew(tls, db)
  41581 		}
  41582 		Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg, uint8(SQLITE_UTF8), libc.UintptrFromInt32(-1))
  41583 		Xsqlite3EndBenignMalloc(tls)
  41584 		(*Sqlite3)(unsafe.Pointer(db)).FbBenignMalloc--
  41585 	} else if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 {
  41586 		Xsqlite3ValueSetNull(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
  41587 	}
  41588 	(*Sqlite3)(unsafe.Pointer(db)).FerrCode = rc
  41589 	(*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset = -1
  41590 	return rc
  41591 }
  41592 
  41593 // Clean up a VDBE after execution but do not delete the VDBE just yet.
  41594 // Write any error messages into *pzErrMsg.  Return the result code.
  41595 //
  41596 // After this routine is run, the VDBE should be ready to be executed
  41597 // again.
  41598 //
  41599 // To look at it another way, this routine resets the state of the
  41600 // virtual machine from VDBE_RUN_STATE or VDBE_HALT_STATE back to
  41601 // VDBE_READY_STATE.
  41602 func Xsqlite3VdbeReset(tls *libc.TLS, p uintptr) int32 {
  41603 	var db uintptr
  41604 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41605 
  41606 	if int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) == VDBE_RUN_STATE {
  41607 		Xsqlite3VdbeHalt(tls, p)
  41608 	}
  41609 
  41610 	if (*Vdbe)(unsafe.Pointer(p)).Fpc >= 0 {
  41611 		if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 || (*Vdbe)(unsafe.Pointer(p)).FzErrMsg != 0 {
  41612 			Xsqlite3VdbeTransferError(tls, p)
  41613 		} else {
  41614 			(*Sqlite3)(unsafe.Pointer(db)).FerrCode = (*Vdbe)(unsafe.Pointer(p)).Frc
  41615 		}
  41616 	}
  41617 
  41618 	if (*Vdbe)(unsafe.Pointer(p)).FzErrMsg != 0 {
  41619 		Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)
  41620 		(*Vdbe)(unsafe.Pointer(p)).FzErrMsg = uintptr(0)
  41621 	}
  41622 	(*Vdbe)(unsafe.Pointer(p)).FpResultRow = uintptr(0)
  41623 
  41624 	return (*Vdbe)(unsafe.Pointer(p)).Frc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask
  41625 }
  41626 
  41627 // Clean up and delete a VDBE after execution.  Return an integer which is
  41628 // the result code.  Write any error message text into *pzErrMsg.
  41629 func Xsqlite3VdbeFinalize(tls *libc.TLS, p uintptr) int32 {
  41630 	var rc int32 = SQLITE_OK
  41631 
  41632 	if int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) >= VDBE_READY_STATE {
  41633 		rc = Xsqlite3VdbeReset(tls, p)
  41634 
  41635 	}
  41636 	Xsqlite3VdbeDelete(tls, p)
  41637 	return rc
  41638 }
  41639 
  41640 // If parameter iOp is less than zero, then invoke the destructor for
  41641 // all auxiliary data pointers currently cached by the VM passed as
  41642 // the first argument.
  41643 //
  41644 // Or, if iOp is greater than or equal to zero, then the destructor is
  41645 // only invoked for those auxiliary data pointers created by the user
  41646 // function invoked by the OP_Function opcode at instruction iOp of
  41647 // VM pVdbe, and only then if:
  41648 //
  41649 //   - the associated function parameter is the 32nd or later (counting
  41650 //     from left to right), or
  41651 //
  41652 //   - the corresponding bit in argument mask is clear (where the first
  41653 //     function parameter corresponds to bit 0 etc.).
  41654 func Xsqlite3VdbeDeleteAuxData(tls *libc.TLS, db uintptr, pp uintptr, iOp int32, mask int32) {
  41655 	for *(*uintptr)(unsafe.Pointer(pp)) != 0 {
  41656 		var pAux uintptr = *(*uintptr)(unsafe.Pointer(pp))
  41657 		if iOp < 0 ||
  41658 			(*AuxData)(unsafe.Pointer(pAux)).FiAuxOp == iOp &&
  41659 				(*AuxData)(unsafe.Pointer(pAux)).FiAuxArg >= 0 &&
  41660 				((*AuxData)(unsafe.Pointer(pAux)).FiAuxArg > 31 || !(uint32(mask)&(uint32(1)<<(*AuxData)(unsafe.Pointer(pAux)).FiAuxArg) != 0)) {
  41661 			if (*AuxData)(unsafe.Pointer(pAux)).FxDeleteAux != 0 {
  41662 				(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*AuxData)(unsafe.Pointer(pAux)).FxDeleteAux})).f(tls, (*AuxData)(unsafe.Pointer(pAux)).FpAux)
  41663 			}
  41664 			*(*uintptr)(unsafe.Pointer(pp)) = (*AuxData)(unsafe.Pointer(pAux)).FpNextAux
  41665 			Xsqlite3DbFree(tls, db, pAux)
  41666 		} else {
  41667 			pp = pAux + 16
  41668 		}
  41669 	}
  41670 }
  41671 
  41672 func sqlite3VdbeClearObject(tls *libc.TLS, db uintptr, p uintptr) {
  41673 	var pSub uintptr
  41674 	var pNext uintptr
  41675 
  41676 	if (*Vdbe)(unsafe.Pointer(p)).FaColName != 0 {
  41677 		releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn)*COLNAME_N)
  41678 		Xsqlite3DbNNFreeNN(tls, db, (*Vdbe)(unsafe.Pointer(p)).FaColName)
  41679 	}
  41680 	for pSub = (*Vdbe)(unsafe.Pointer(p)).FpProgram; pSub != 0; pSub = pNext {
  41681 		pNext = (*SubProgram)(unsafe.Pointer(pSub)).FpNext
  41682 		vdbeFreeOpArray(tls, db, (*SubProgram)(unsafe.Pointer(pSub)).FaOp, (*SubProgram)(unsafe.Pointer(pSub)).FnOp)
  41683 		Xsqlite3DbFree(tls, db, pSub)
  41684 	}
  41685 	if int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) != VDBE_INIT_STATE {
  41686 		releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, int32((*Vdbe)(unsafe.Pointer(p)).FnVar))
  41687 		if (*Vdbe)(unsafe.Pointer(p)).FpVList != 0 {
  41688 			Xsqlite3DbNNFreeNN(tls, db, (*Vdbe)(unsafe.Pointer(p)).FpVList)
  41689 		}
  41690 		if (*Vdbe)(unsafe.Pointer(p)).FpFree != 0 {
  41691 			Xsqlite3DbNNFreeNN(tls, db, (*Vdbe)(unsafe.Pointer(p)).FpFree)
  41692 		}
  41693 	}
  41694 	vdbeFreeOpArray(tls, db, (*Vdbe)(unsafe.Pointer(p)).FaOp, (*Vdbe)(unsafe.Pointer(p)).FnOp)
  41695 	if (*Vdbe)(unsafe.Pointer(p)).FzSql != 0 {
  41696 		Xsqlite3DbNNFreeNN(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzSql)
  41697 	}
  41698 }
  41699 
  41700 // Delete an entire VDBE.
  41701 func Xsqlite3VdbeDelete(tls *libc.TLS, p uintptr) {
  41702 	var db uintptr
  41703 
  41704 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  41705 
  41706 	sqlite3VdbeClearObject(tls, db, p)
  41707 	if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  41708 		*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FppVPrev)) = (*Vdbe)(unsafe.Pointer(p)).FpVNext
  41709 		if (*Vdbe)(unsafe.Pointer(p)).FpVNext != 0 {
  41710 			(*Vdbe)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpVNext)).FppVPrev = (*Vdbe)(unsafe.Pointer(p)).FppVPrev
  41711 		}
  41712 	}
  41713 	Xsqlite3DbNNFreeNN(tls, db, p)
  41714 }
  41715 
  41716 // The cursor "p" has a pending seek operation that has not yet been
  41717 // carried out.  Seek the cursor now.  If an error occurs, return
  41718 // the appropriate error code.
  41719 func Xsqlite3VdbeFinishMoveto(tls *libc.TLS, p uintptr) int32 {
  41720 	bp := tls.Alloc(4)
  41721 	defer tls.Free(4)
  41722 
  41723 	var rc int32
  41724 
  41725 	rc = Xsqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(p + 36)), (*VdbeCursor)(unsafe.Pointer(p)).FmovetoTarget, 0, bp)
  41726 	if rc != 0 {
  41727 		return rc
  41728 	}
  41729 	if *(*int32)(unsafe.Pointer(bp)) != 0 {
  41730 		return Xsqlite3CorruptError(tls, 86062)
  41731 	}
  41732 	(*VdbeCursor)(unsafe.Pointer(p)).FdeferredMoveto = U8(0)
  41733 	(*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = U32(CACHE_STALE)
  41734 	return SQLITE_OK
  41735 }
  41736 
  41737 // Something has moved cursor "p" out of place.  Maybe the row it was
  41738 // pointed to was deleted out from under it.  Or maybe the btree was
  41739 // rebalanced.  Whatever the cause, try to restore "p" to the place it
  41740 // is supposed to be pointing.  If the row was deleted out from under the
  41741 // cursor, set the cursor to point to a NULL row.
  41742 func Xsqlite3VdbeHandleMovedCursor(tls *libc.TLS, p uintptr) int32 {
  41743 	bp := tls.Alloc(4)
  41744 	defer tls.Free(4)
  41745 
  41746 	var rc int32
  41747 
  41748 	rc = Xsqlite3BtreeCursorRestore(tls, *(*uintptr)(unsafe.Pointer(p + 36)), bp)
  41749 	(*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = U32(CACHE_STALE)
  41750 	if *(*int32)(unsafe.Pointer(bp)) != 0 {
  41751 		(*VdbeCursor)(unsafe.Pointer(p)).FnullRow = U8(1)
  41752 	}
  41753 	return rc
  41754 }
  41755 
  41756 // Check to ensure that the cursor is valid.  Restore the cursor
  41757 // if need be.  Return any I/O error from the restore operation.
  41758 func Xsqlite3VdbeCursorRestore(tls *libc.TLS, p uintptr) int32 {
  41759 	if Xsqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(p + 36))) != 0 {
  41760 		return Xsqlite3VdbeHandleMovedCursor(tls, p)
  41761 	}
  41762 	return SQLITE_OK
  41763 }
  41764 
  41765 // The sizes for serial types less than 128
  41766 var Xsqlite3SmallTypeSizes = [128]U8{
  41767 	U8(0), U8(1), U8(2), U8(3), U8(4), U8(6), U8(8), U8(8), U8(0), U8(0),
  41768 	U8(0), U8(0), U8(0), U8(0), U8(1), U8(1), U8(2), U8(2), U8(3), U8(3),
  41769 	U8(4), U8(4), U8(5), U8(5), U8(6), U8(6), U8(7), U8(7), U8(8), U8(8),
  41770 	U8(9), U8(9), U8(10), U8(10), U8(11), U8(11), U8(12), U8(12), U8(13), U8(13),
  41771 	U8(14), U8(14), U8(15), U8(15), U8(16), U8(16), U8(17), U8(17), U8(18), U8(18),
  41772 	U8(19), U8(19), U8(20), U8(20), U8(21), U8(21), U8(22), U8(22), U8(23), U8(23),
  41773 	U8(24), U8(24), U8(25), U8(25), U8(26), U8(26), U8(27), U8(27), U8(28), U8(28),
  41774 	U8(29), U8(29), U8(30), U8(30), U8(31), U8(31), U8(32), U8(32), U8(33), U8(33),
  41775 	U8(34), U8(34), U8(35), U8(35), U8(36), U8(36), U8(37), U8(37), U8(38), U8(38),
  41776 	U8(39), U8(39), U8(40), U8(40), U8(41), U8(41), U8(42), U8(42), U8(43), U8(43),
  41777 	U8(44), U8(44), U8(45), U8(45), U8(46), U8(46), U8(47), U8(47), U8(48), U8(48),
  41778 	U8(49), U8(49), U8(50), U8(50), U8(51), U8(51), U8(52), U8(52), U8(53), U8(53),
  41779 	U8(54), U8(54), U8(55), U8(55), U8(56), U8(56), U8(57), U8(57),
  41780 }
  41781 
  41782 // Return the length of the data corresponding to the supplied serial-type.
  41783 func Xsqlite3VdbeSerialTypeLen(tls *libc.TLS, serial_type U32) U32 {
  41784 	if serial_type >= U32(128) {
  41785 		return (serial_type - U32(12)) / U32(2)
  41786 	} else {
  41787 		return U32(Xsqlite3SmallTypeSizes[serial_type])
  41788 	}
  41789 	return U32(0)
  41790 }
  41791 
  41792 func Xsqlite3VdbeOneByteSerialTypeLen(tls *libc.TLS, serial_type U8) U8 {
  41793 	return Xsqlite3SmallTypeSizes[serial_type]
  41794 }
  41795 
  41796 func serialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uintptr) {
  41797 	bp := tls.Alloc(8)
  41798 	defer tls.Free(8)
  41799 
  41800 	*(*U64)(unsafe.Pointer(bp)) = U64(U32(*(*uint8)(unsafe.Pointer(buf)))<<24 | U32(int32(*(*uint8)(unsafe.Pointer(buf + 1)))<<16) | U32(int32(*(*uint8)(unsafe.Pointer(buf + 2)))<<8) | U32(*(*uint8)(unsafe.Pointer(buf + 3))))
  41801 	var y U32 = U32(*(*uint8)(unsafe.Pointer(buf + uintptr(4))))<<24 | U32(int32(*(*uint8)(unsafe.Pointer(buf + uintptr(4) + 1)))<<16) | U32(int32(*(*uint8)(unsafe.Pointer(buf + uintptr(4) + 2)))<<8) | U32(*(*uint8)(unsafe.Pointer(buf + uintptr(4) + 3)))
  41802 	*(*U64)(unsafe.Pointer(bp)) = *(*U64)(unsafe.Pointer(bp))<<32 + U64(y)
  41803 	if serial_type == U32(6) {
  41804 		*(*I64)(unsafe.Pointer(pMem)) = *(*I64)(unsafe.Pointer(bp))
  41805 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41806 
  41807 	} else {
  41808 		libc.Xmemcpy(tls, pMem, bp, uint32(unsafe.Sizeof(U64(0))))
  41809 		(*Mem)(unsafe.Pointer(pMem)).Fflags = func() uint16 {
  41810 			if *(*U64)(unsafe.Pointer(bp))&(uint64(0x7ff)<<52) == uint64(0x7ff)<<52 && *(*U64)(unsafe.Pointer(bp))&(uint64(1)<<52-uint64(1)) != uint64(0) {
  41811 				return uint16(MEM_Null)
  41812 			}
  41813 			return uint16(MEM_Real)
  41814 		}()
  41815 	}
  41816 }
  41817 
  41818 func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uintptr) {
  41819 	switch serial_type {
  41820 	case U32(10):
  41821 		{
  41822 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Null | MEM_Zero)
  41823 			(*Mem)(unsafe.Pointer(pMem)).Fn = 0
  41824 			*(*int32)(unsafe.Pointer(pMem)) = 0
  41825 			return
  41826 
  41827 		}
  41828 	case U32(11):
  41829 		fallthrough
  41830 	case U32(0):
  41831 		{
  41832 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Null)
  41833 			return
  41834 
  41835 		}
  41836 	case U32(1):
  41837 		{
  41838 			*(*I64)(unsafe.Pointer(pMem)) = I64(I8(*(*uint8)(unsafe.Pointer(buf))))
  41839 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41840 
  41841 			return
  41842 
  41843 		}
  41844 	case U32(2):
  41845 		{
  41846 			*(*I64)(unsafe.Pointer(pMem)) = I64(256*int32(I8(*(*uint8)(unsafe.Pointer(buf)))) | int32(*(*uint8)(unsafe.Pointer(buf + 1))))
  41847 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41848 
  41849 			return
  41850 
  41851 		}
  41852 	case U32(3):
  41853 		{
  41854 			*(*I64)(unsafe.Pointer(pMem)) = I64(65536*int32(I8(*(*uint8)(unsafe.Pointer(buf)))) | int32(*(*uint8)(unsafe.Pointer(buf + 1)))<<8 | int32(*(*uint8)(unsafe.Pointer(buf + 2))))
  41855 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41856 
  41857 			return
  41858 
  41859 		}
  41860 	case U32(4):
  41861 		{
  41862 			*(*I64)(unsafe.Pointer(pMem)) = I64(16777216*int32(I8(*(*uint8)(unsafe.Pointer(buf)))) | int32(*(*uint8)(unsafe.Pointer(buf + 1)))<<16 | int32(*(*uint8)(unsafe.Pointer(buf + 2)))<<8 | int32(*(*uint8)(unsafe.Pointer(buf + 3))))
  41863 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41864 
  41865 			return
  41866 
  41867 		}
  41868 	case U32(5):
  41869 		{
  41870 			*(*I64)(unsafe.Pointer(pMem)) = I64(U32(*(*uint8)(unsafe.Pointer(buf + uintptr(2))))<<24|U32(int32(*(*uint8)(unsafe.Pointer(buf + uintptr(2) + 1)))<<16)|U32(int32(*(*uint8)(unsafe.Pointer(buf + uintptr(2) + 2)))<<8)|U32(*(*uint8)(unsafe.Pointer(buf + uintptr(2) + 3)))) + int64(1)<<32*I64(256*int32(I8(*(*uint8)(unsafe.Pointer(buf))))|int32(*(*uint8)(unsafe.Pointer(buf + 1))))
  41871 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41872 
  41873 			return
  41874 
  41875 		}
  41876 	case U32(6):
  41877 		fallthrough
  41878 	case U32(7):
  41879 		{
  41880 			serialGet(tls, buf, serial_type, pMem)
  41881 			return
  41882 
  41883 		}
  41884 	case U32(8):
  41885 		fallthrough
  41886 	case U32(9):
  41887 		{
  41888 			*(*I64)(unsafe.Pointer(pMem)) = I64(serial_type - U32(8))
  41889 			(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Int)
  41890 			return
  41891 
  41892 		}
  41893 	default:
  41894 		{
  41895 			(*Mem)(unsafe.Pointer(pMem)).Fz = buf
  41896 			(*Mem)(unsafe.Pointer(pMem)).Fn = int32((serial_type - U32(12)) / U32(2))
  41897 			(*Mem)(unsafe.Pointer(pMem)).Fflags = aFlag[serial_type&U32(1)]
  41898 			return
  41899 
  41900 		}
  41901 	}
  41902 	return
  41903 }
  41904 
  41905 var aFlag = [2]U16{U16(MEM_Blob | MEM_Ephem), U16(MEM_Str | MEM_Ephem)}
  41906 
  41907 // This routine is used to allocate sufficient space for an UnpackedRecord
  41908 // structure large enough to be used with sqlite3VdbeRecordUnpack() if
  41909 // the first argument is a pointer to KeyInfo structure pKeyInfo.
  41910 //
  41911 // The space is either allocated using sqlite3DbMallocRaw() or from within
  41912 // the unaligned buffer passed via the second and third arguments (presumably
  41913 // stack space). If the former, then *ppFree is set to a pointer that should
  41914 // be eventually freed by the caller using sqlite3DbFree(). Or, if the
  41915 // allocation comes from the pSpace/szSpace buffer, *ppFree is set to NULL
  41916 // before returning.
  41917 //
  41918 // If an OOM error occurs, NULL is returned.
  41919 func Xsqlite3VdbeAllocUnpackedRecord(tls *libc.TLS, pKeyInfo uintptr) uintptr {
  41920 	var p uintptr
  41921 	var nByte int32
  41922 	nByte = int32((uint32(unsafe.Sizeof(UnpackedRecord{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)) + uint32(unsafe.Sizeof(Mem{}))*uint32(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)+1))
  41923 	p = Xsqlite3DbMallocRaw(tls, (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb, uint64(nByte))
  41924 	if !(p != 0) {
  41925 		return uintptr(0)
  41926 	}
  41927 	(*UnpackedRecord)(unsafe.Pointer(p)).FaMem = p + 32
  41928 
  41929 	(*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo = pKeyInfo
  41930 	(*UnpackedRecord)(unsafe.Pointer(p)).FnField = U16(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1)
  41931 	return p
  41932 }
  41933 
  41934 // Given the nKey-byte encoding of a record in pKey[], populate the
  41935 // UnpackedRecord structure indicated by the fourth argument with the
  41936 // contents of the decoded record.
  41937 func Xsqlite3VdbeRecordUnpack(tls *libc.TLS, pKeyInfo uintptr, nKey int32, pKey uintptr, p uintptr) {
  41938 	bp := tls.Alloc(8)
  41939 	defer tls.Free(8)
  41940 
  41941 	var aKey uintptr = pKey
  41942 	var d U32
  41943 	var idx U32
  41944 	var u U16
  41945 
  41946 	var pMem uintptr = (*UnpackedRecord)(unsafe.Pointer(p)).FaMem
  41947 
  41948 	(*UnpackedRecord)(unsafe.Pointer(p)).Fdefault_rc = int8(0)
  41949 
  41950 	idx = U32(func() uint8 {
  41951 		if int32(*(*uint8)(unsafe.Pointer(aKey))) < int32(U8(0x80)) {
  41952 			return uint8(func() int32 { *(*U32)(unsafe.Pointer(bp)) = U32(*(*uint8)(unsafe.Pointer(aKey))); return 1 }())
  41953 		}
  41954 		return Xsqlite3GetVarint32(tls, aKey, bp)
  41955 	}())
  41956 	d = *(*U32)(unsafe.Pointer(bp))
  41957 	u = U16(0)
  41958 	for idx < *(*U32)(unsafe.Pointer(bp)) && d <= U32(nKey) {
  41959 		idx = idx + U32(func() uint8 {
  41960 			if int32(*(*uint8)(unsafe.Pointer(aKey + uintptr(idx)))) < int32(U8(0x80)) {
  41961 				return uint8(func() int32 {
  41962 					*(*U32)(unsafe.Pointer(bp + 4)) = U32(*(*uint8)(unsafe.Pointer(aKey + uintptr(idx))))
  41963 					return 1
  41964 				}())
  41965 			}
  41966 			return Xsqlite3GetVarint32(tls, aKey+uintptr(idx), bp+4)
  41967 		}())
  41968 		(*Mem)(unsafe.Pointer(pMem)).Fenc = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fenc
  41969 		(*Mem)(unsafe.Pointer(pMem)).Fdb = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb
  41970 
  41971 		(*Mem)(unsafe.Pointer(pMem)).FszMalloc = 0
  41972 		(*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0)
  41973 		Xsqlite3VdbeSerialGet(tls, aKey+uintptr(d), *(*U32)(unsafe.Pointer(bp + 4)), pMem)
  41974 		d = d + Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 4)))
  41975 		pMem += 40
  41976 		if int32(libc.PreIncUint16(&u, 1)) >= int32((*UnpackedRecord)(unsafe.Pointer(p)).FnField) {
  41977 			break
  41978 		}
  41979 	}
  41980 	if d > U32(nKey) && u != 0 {
  41981 		Xsqlite3VdbeMemSetNull(tls, pMem-uintptr(1)*40)
  41982 	}
  41983 
  41984 	(*UnpackedRecord)(unsafe.Pointer(p)).FnField = u
  41985 }
  41986 
  41987 func vdbeCompareMemString(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintptr, prcErr uintptr) int32 {
  41988 	bp := tls.Alloc(80)
  41989 	defer tls.Free(80)
  41990 
  41991 	if int32((*Mem)(unsafe.Pointer(pMem1)).Fenc) == int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc) {
  41992 		return (*struct {
  41993 			f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
  41994 		})(unsafe.Pointer(&struct{ uintptr }{(*CollSeq)(unsafe.Pointer(pColl)).FxCmp})).f(tls, (*CollSeq)(unsafe.Pointer(pColl)).FpUser, (*Mem)(unsafe.Pointer(pMem1)).Fn, (*Mem)(unsafe.Pointer(pMem1)).Fz, (*Mem)(unsafe.Pointer(pMem2)).Fn, (*Mem)(unsafe.Pointer(pMem2)).Fz)
  41995 	} else {
  41996 		var rc int32
  41997 		var v1 uintptr
  41998 		var v2 uintptr
  41999 
  42000 		Xsqlite3VdbeMemInit(tls, bp, (*Mem)(unsafe.Pointer(pMem1)).Fdb, uint16(MEM_Null))
  42001 		Xsqlite3VdbeMemInit(tls, bp+40, (*Mem)(unsafe.Pointer(pMem1)).Fdb, uint16(MEM_Null))
  42002 		Xsqlite3VdbeMemShallowCopy(tls, bp, pMem1, MEM_Ephem)
  42003 		Xsqlite3VdbeMemShallowCopy(tls, bp+40, pMem2, MEM_Ephem)
  42004 		v1 = Xsqlite3ValueText(tls, bp, (*CollSeq)(unsafe.Pointer(pColl)).Fenc)
  42005 		v2 = Xsqlite3ValueText(tls, bp+40, (*CollSeq)(unsafe.Pointer(pColl)).Fenc)
  42006 		if v1 == uintptr(0) || v2 == uintptr(0) {
  42007 			if prcErr != 0 {
  42008 				*(*U8)(unsafe.Pointer(prcErr)) = U8(SQLITE_NOMEM)
  42009 			}
  42010 			rc = 0
  42011 		} else {
  42012 			rc = (*struct {
  42013 				f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
  42014 			})(unsafe.Pointer(&struct{ uintptr }{(*CollSeq)(unsafe.Pointer(pColl)).FxCmp})).f(tls, (*CollSeq)(unsafe.Pointer(pColl)).FpUser, (*Mem)(unsafe.Pointer(bp)).Fn, v1, (*Mem)(unsafe.Pointer(bp+40)).Fn, v2)
  42015 		}
  42016 		Xsqlite3VdbeMemReleaseMalloc(tls, bp)
  42017 		Xsqlite3VdbeMemReleaseMalloc(tls, bp+40)
  42018 		return rc
  42019 	}
  42020 	return int32(0)
  42021 }
  42022 
  42023 func isAllZero(tls *libc.TLS, z uintptr, n int32) int32 {
  42024 	var i int32
  42025 	for i = 0; i < n; i++ {
  42026 		if *(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0 {
  42027 			return 0
  42028 		}
  42029 	}
  42030 	return 1
  42031 }
  42032 
  42033 // Compare two blobs.  Return negative, zero, or positive if the first
  42034 // is less than, equal to, or greater than the second, respectively.
  42035 // If one blob is a prefix of the other, then the shorter is the lessor.
  42036 func Xsqlite3BlobCompare(tls *libc.TLS, pB1 uintptr, pB2 uintptr) int32 {
  42037 	var c int32
  42038 	var n1 int32 = (*Mem)(unsafe.Pointer(pB1)).Fn
  42039 	var n2 int32 = (*Mem)(unsafe.Pointer(pB2)).Fn
  42040 
  42041 	if (int32((*Mem)(unsafe.Pointer(pB1)).Fflags)|int32((*Mem)(unsafe.Pointer(pB2)).Fflags))&MEM_Zero != 0 {
  42042 		if int32((*Mem)(unsafe.Pointer(pB1)).Fflags)&int32((*Mem)(unsafe.Pointer(pB2)).Fflags)&MEM_Zero != 0 {
  42043 			return *(*int32)(unsafe.Pointer(pB1)) - *(*int32)(unsafe.Pointer(pB2))
  42044 		} else if int32((*Mem)(unsafe.Pointer(pB1)).Fflags)&MEM_Zero != 0 {
  42045 			if !(isAllZero(tls, (*Mem)(unsafe.Pointer(pB2)).Fz, (*Mem)(unsafe.Pointer(pB2)).Fn) != 0) {
  42046 				return -1
  42047 			}
  42048 			return *(*int32)(unsafe.Pointer(pB1)) - n2
  42049 		} else {
  42050 			if !(isAllZero(tls, (*Mem)(unsafe.Pointer(pB1)).Fz, (*Mem)(unsafe.Pointer(pB1)).Fn) != 0) {
  42051 				return +1
  42052 			}
  42053 			return n1 - *(*int32)(unsafe.Pointer(pB2))
  42054 		}
  42055 	}
  42056 	c = libc.Xmemcmp(tls, (*Mem)(unsafe.Pointer(pB1)).Fz, (*Mem)(unsafe.Pointer(pB2)).Fz, func() uint32 {
  42057 		if n1 > n2 {
  42058 			return uint32(n2)
  42059 		}
  42060 		return uint32(n1)
  42061 	}())
  42062 	if c != 0 {
  42063 		return c
  42064 	}
  42065 	return n1 - n2
  42066 }
  42067 
  42068 // Do a comparison between a 64-bit signed integer and a 64-bit floating-point
  42069 // number.  Return negative, zero, or positive if the first (i64) is less than,
  42070 // equal to, or greater than the second (double).
  42071 func Xsqlite3IntFloatCompare(tls *libc.TLS, i I64, r float64) int32 {
  42072 	if uint32(unsafe.Sizeof(float64(0))) > uint32(8) {
  42073 		var x float64 = float64(i)
  42074 
  42075 		if x < r {
  42076 			return -1
  42077 		}
  42078 		if x > r {
  42079 			return +1
  42080 		}
  42081 		return 0
  42082 	} else {
  42083 		var y I64
  42084 		var s float64
  42085 		if r < -9223372036854775808.0 {
  42086 			return +1
  42087 		}
  42088 		if r >= 9223372036854775808.0 {
  42089 			return -1
  42090 		}
  42091 		y = I64(r)
  42092 		if i < y {
  42093 			return -1
  42094 		}
  42095 		if i > y {
  42096 			return +1
  42097 		}
  42098 		s = float64(i)
  42099 		if s < r {
  42100 			return -1
  42101 		}
  42102 		if s > r {
  42103 			return +1
  42104 		}
  42105 		return 0
  42106 	}
  42107 	return int32(0)
  42108 }
  42109 
  42110 // Compare the values contained by the two memory cells, returning
  42111 // negative, zero or positive if pMem1 is less than, equal to, or greater
  42112 // than pMem2. Sorting order is NULL's first, followed by numbers (integers
  42113 // and reals) sorted numerically, followed by text ordered by the collating
  42114 // sequence pColl and finally blob's ordered by memcmp().
  42115 //
  42116 // Two NULL values are considered equal by this function.
  42117 func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintptr) int32 {
  42118 	var f1 int32
  42119 	var f2 int32
  42120 	var combined_flags int32
  42121 
  42122 	f1 = int32((*Mem)(unsafe.Pointer(pMem1)).Fflags)
  42123 	f2 = int32((*Mem)(unsafe.Pointer(pMem2)).Fflags)
  42124 	combined_flags = f1 | f2
  42125 
  42126 	if combined_flags&MEM_Null != 0 {
  42127 		return f2&MEM_Null - f1&MEM_Null
  42128 	}
  42129 
  42130 	if combined_flags&(MEM_Int|MEM_Real|MEM_IntReal) != 0 {
  42131 		if f1&f2&(MEM_Int|MEM_IntReal) != 0 {
  42132 			if *(*I64)(unsafe.Pointer(pMem1)) < *(*I64)(unsafe.Pointer(pMem2)) {
  42133 				return -1
  42134 			}
  42135 			if *(*I64)(unsafe.Pointer(pMem1)) > *(*I64)(unsafe.Pointer(pMem2)) {
  42136 				return +1
  42137 			}
  42138 			return 0
  42139 		}
  42140 		if f1&f2&MEM_Real != 0 {
  42141 			if *(*float64)(unsafe.Pointer(pMem1)) < *(*float64)(unsafe.Pointer(pMem2)) {
  42142 				return -1
  42143 			}
  42144 			if *(*float64)(unsafe.Pointer(pMem1)) > *(*float64)(unsafe.Pointer(pMem2)) {
  42145 				return +1
  42146 			}
  42147 			return 0
  42148 		}
  42149 		if f1&(MEM_Int|MEM_IntReal) != 0 {
  42150 			if f2&MEM_Real != 0 {
  42151 				return Xsqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pMem1)), *(*float64)(unsafe.Pointer(pMem2)))
  42152 			} else if f2&(MEM_Int|MEM_IntReal) != 0 {
  42153 				if *(*I64)(unsafe.Pointer(pMem1)) < *(*I64)(unsafe.Pointer(pMem2)) {
  42154 					return -1
  42155 				}
  42156 				if *(*I64)(unsafe.Pointer(pMem1)) > *(*I64)(unsafe.Pointer(pMem2)) {
  42157 					return +1
  42158 				}
  42159 				return 0
  42160 			} else {
  42161 				return -1
  42162 			}
  42163 		}
  42164 		if f1&MEM_Real != 0 {
  42165 			if f2&(MEM_Int|MEM_IntReal) != 0 {
  42166 				return -Xsqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pMem2)), *(*float64)(unsafe.Pointer(pMem1)))
  42167 			} else {
  42168 				return -1
  42169 			}
  42170 		}
  42171 		return +1
  42172 	}
  42173 
  42174 	if combined_flags&MEM_Str != 0 {
  42175 		if f1&MEM_Str == 0 {
  42176 			return 1
  42177 		}
  42178 		if f2&MEM_Str == 0 {
  42179 			return -1
  42180 		}
  42181 
  42182 		if pColl != 0 {
  42183 			return vdbeCompareMemString(tls, pMem1, pMem2, pColl, uintptr(0))
  42184 		}
  42185 
  42186 	}
  42187 
  42188 	return Xsqlite3BlobCompare(tls, pMem1, pMem2)
  42189 }
  42190 
  42191 func vdbeRecordDecodeInt(tls *libc.TLS, serial_type U32, aKey uintptr) I64 {
  42192 	bp := tls.Alloc(16)
  42193 	defer tls.Free(16)
  42194 
  42195 	switch serial_type {
  42196 	case U32(0):
  42197 		fallthrough
  42198 	case U32(1):
  42199 		return I64(I8(*(*U8)(unsafe.Pointer(aKey))))
  42200 	case U32(2):
  42201 		return I64(256*int32(I8(*(*U8)(unsafe.Pointer(aKey)))) | int32(*(*U8)(unsafe.Pointer(aKey + 1))))
  42202 	case U32(3):
  42203 		return I64(65536*int32(I8(*(*U8)(unsafe.Pointer(aKey)))) | int32(*(*U8)(unsafe.Pointer(aKey + 1)))<<8 | int32(*(*U8)(unsafe.Pointer(aKey + 2))))
  42204 	case U32(4):
  42205 		{
  42206 			*(*U32)(unsafe.Pointer(bp)) = U32(*(*U8)(unsafe.Pointer(aKey)))<<24 | U32(int32(*(*U8)(unsafe.Pointer(aKey + 1)))<<16) | U32(int32(*(*U8)(unsafe.Pointer(aKey + 2)))<<8) | U32(*(*U8)(unsafe.Pointer(aKey + 3)))
  42207 			return I64(*(*int32)(unsafe.Pointer(bp)))
  42208 
  42209 		}
  42210 	case U32(5):
  42211 		{
  42212 			return I64(U32(*(*U8)(unsafe.Pointer(aKey + uintptr(2))))<<24|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(2) + 1)))<<16)|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(2) + 2)))<<8)|U32(*(*U8)(unsafe.Pointer(aKey + uintptr(2) + 3)))) + int64(1)<<32*I64(256*int32(I8(*(*U8)(unsafe.Pointer(aKey))))|int32(*(*U8)(unsafe.Pointer(aKey + 1))))
  42213 
  42214 		}
  42215 	case U32(6):
  42216 		{
  42217 			*(*U64)(unsafe.Pointer(bp + 8)) = U64(U32(*(*U8)(unsafe.Pointer(aKey)))<<24 | U32(int32(*(*U8)(unsafe.Pointer(aKey + 1)))<<16) | U32(int32(*(*U8)(unsafe.Pointer(aKey + 2)))<<8) | U32(*(*U8)(unsafe.Pointer(aKey + 3))))
  42218 
  42219 			*(*U64)(unsafe.Pointer(bp + 8)) = *(*U64)(unsafe.Pointer(bp + 8))<<32 | U64(U32(*(*U8)(unsafe.Pointer(aKey + uintptr(4))))<<24|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(4) + 1)))<<16)|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(4) + 2)))<<8)|U32(*(*U8)(unsafe.Pointer(aKey + uintptr(4) + 3))))
  42220 			return *(*I64)(unsafe.Pointer(bp + 8))
  42221 
  42222 		}
  42223 	}
  42224 
  42225 	return I64(serial_type - U32(8))
  42226 }
  42227 
  42228 // This function compares the two table rows or index records
  42229 // specified by {nKey1, pKey1} and pPKey2.  It returns a negative, zero
  42230 // or positive integer if key1 is less than, equal to or
  42231 // greater than key2.  The {nKey1, pKey1} key must be a blob
  42232 // created by the OP_MakeRecord opcode of the VDBE.  The pPKey2
  42233 // key must be a parsed key such as obtained from
  42234 // sqlite3VdbeParseRecord.
  42235 //
  42236 // If argument bSkip is non-zero, it is assumed that the caller has already
  42237 // determined that the first fields of the keys are equal.
  42238 //
  42239 // Key1 and Key2 do not have to contain the same number of fields. If all
  42240 // fields that appear in both keys are equal, then pPKey2->default_rc is
  42241 // returned.
  42242 //
  42243 // If database corruption is discovered, set pPKey2->errCode to
  42244 // SQLITE_CORRUPT and return 0. If an OOM error is encountered,
  42245 // pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the
  42246 // malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).
  42247 func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr, bSkip int32) int32 {
  42248 	bp := tls.Alloc(52)
  42249 	defer tls.Free(52)
  42250 
  42251 	var d1 U32
  42252 	var i int32
  42253 
  42254 	var idx1 U32
  42255 	var rc int32 = 0
  42256 	var pRhs uintptr = (*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem
  42257 	var pKeyInfo uintptr
  42258 	var aKey1 uintptr = pKey1
  42259 
  42260 	if bSkip != 0 {
  42261 		*(*U32)(unsafe.Pointer(bp)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + 1)))
  42262 		if *(*U32)(unsafe.Pointer(bp)) < U32(0x80) {
  42263 			idx1 = U32(2)
  42264 		} else {
  42265 			idx1 = U32(1 + int32(Xsqlite3GetVarint32(tls, aKey1+1, bp)))
  42266 		}
  42267 		*(*U32)(unsafe.Pointer(bp + 4)) = U32(*(*uint8)(unsafe.Pointer(aKey1)))
  42268 		d1 = *(*U32)(unsafe.Pointer(bp + 4)) + Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp)))
  42269 		i = 1
  42270 		pRhs += 40
  42271 	} else {
  42272 		if libc.AssignPtrUint32(bp+4, U32(*(*uint8)(unsafe.Pointer(aKey1)))) < U32(0x80) {
  42273 			idx1 = U32(1)
  42274 		} else {
  42275 			idx1 = U32(Xsqlite3GetVarint32(tls, aKey1, bp+4))
  42276 		}
  42277 		d1 = *(*U32)(unsafe.Pointer(bp + 4))
  42278 		i = 0
  42279 	}
  42280 	if d1 > uint32(nKey1) {
  42281 		(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 86989))
  42282 		return 0
  42283 	}
  42284 
  42285 	for 1 != 0 {
  42286 		if int32((*Mem)(unsafe.Pointer(pRhs)).Fflags)&(MEM_Int|MEM_IntReal) != 0 {
  42287 			*(*U32)(unsafe.Pointer(bp + 48)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1))))
  42288 
  42289 			if *(*U32)(unsafe.Pointer(bp + 48)) >= U32(10) {
  42290 				if *(*U32)(unsafe.Pointer(bp + 48)) == U32(10) {
  42291 					rc = -1
  42292 				} else {
  42293 					rc = +1
  42294 				}
  42295 			} else if *(*U32)(unsafe.Pointer(bp + 48)) == U32(0) {
  42296 				rc = -1
  42297 			} else if *(*U32)(unsafe.Pointer(bp + 48)) == U32(7) {
  42298 				Xsqlite3VdbeSerialGet(tls, aKey1+uintptr(d1), *(*U32)(unsafe.Pointer(bp + 48)), bp+8)
  42299 				rc = -Xsqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pRhs)), *(*float64)(unsafe.Pointer(bp + 8)))
  42300 			} else {
  42301 				var lhs I64 = vdbeRecordDecodeInt(tls, *(*U32)(unsafe.Pointer(bp + 48)), aKey1+uintptr(d1))
  42302 				var rhs I64 = *(*I64)(unsafe.Pointer(pRhs))
  42303 				if lhs < rhs {
  42304 					rc = -1
  42305 				} else if lhs > rhs {
  42306 					rc = +1
  42307 				}
  42308 			}
  42309 		} else if int32((*Mem)(unsafe.Pointer(pRhs)).Fflags)&MEM_Real != 0 {
  42310 			*(*U32)(unsafe.Pointer(bp + 48)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1))))
  42311 			if *(*U32)(unsafe.Pointer(bp + 48)) >= U32(10) {
  42312 				if *(*U32)(unsafe.Pointer(bp + 48)) == U32(10) {
  42313 					rc = -1
  42314 				} else {
  42315 					rc = +1
  42316 				}
  42317 			} else if *(*U32)(unsafe.Pointer(bp + 48)) == U32(0) {
  42318 				rc = -1
  42319 			} else {
  42320 				Xsqlite3VdbeSerialGet(tls, aKey1+uintptr(d1), *(*U32)(unsafe.Pointer(bp + 48)), bp+8)
  42321 				if *(*U32)(unsafe.Pointer(bp + 48)) == U32(7) {
  42322 					if *(*float64)(unsafe.Pointer(bp + 8)) < *(*float64)(unsafe.Pointer(pRhs)) {
  42323 						rc = -1
  42324 					} else if *(*float64)(unsafe.Pointer(bp + 8)) > *(*float64)(unsafe.Pointer(pRhs)) {
  42325 						rc = +1
  42326 					}
  42327 				} else {
  42328 					rc = Xsqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(bp + 8)), *(*float64)(unsafe.Pointer(pRhs)))
  42329 				}
  42330 			}
  42331 		} else if int32((*Mem)(unsafe.Pointer(pRhs)).Fflags)&MEM_Str != 0 {
  42332 			*(*U32)(unsafe.Pointer(bp + 48)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1))))
  42333 			if *(*U32)(unsafe.Pointer(bp + 48)) >= U32(0x80) {
  42334 				Xsqlite3GetVarint32(tls, aKey1+uintptr(idx1), bp+48)
  42335 			}
  42336 
  42337 			if *(*U32)(unsafe.Pointer(bp + 48)) < U32(12) {
  42338 				rc = -1
  42339 			} else if !(*(*U32)(unsafe.Pointer(bp + 48))&U32(0x01) != 0) {
  42340 				rc = +1
  42341 			} else {
  42342 				(*Mem)(unsafe.Pointer(bp + 8)).Fn = int32((*(*U32)(unsafe.Pointer(bp + 48)) - U32(12)) / U32(2))
  42343 
  42344 				if d1+U32((*Mem)(unsafe.Pointer(bp+8)).Fn) > uint32(nKey1) ||
  42345 					int32((*KeyInfo)(unsafe.Pointer(libc.AssignUintptr(&pKeyInfo, (*UnpackedRecord)(unsafe.Pointer(pPKey2)).FpKeyInfo))).FnAllField) <= i {
  42346 					(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 87066))
  42347 					return 0
  42348 				} else if *(*uintptr)(unsafe.Pointer(pKeyInfo + 20 + uintptr(i)*4)) != 0 {
  42349 					(*Mem)(unsafe.Pointer(bp + 8)).Fenc = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fenc
  42350 					(*Mem)(unsafe.Pointer(bp + 8)).Fdb = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb
  42351 					(*Mem)(unsafe.Pointer(bp + 8)).Fflags = U16(MEM_Str)
  42352 					(*Mem)(unsafe.Pointer(bp + 8)).Fz = aKey1 + uintptr(d1)
  42353 					rc = vdbeCompareMemString(tls,
  42354 						bp+8, pRhs, *(*uintptr)(unsafe.Pointer(pKeyInfo + 20 + uintptr(i)*4)), pPKey2+23)
  42355 				} else {
  42356 					var nCmp int32 = func() int32 {
  42357 						if (*Mem)(unsafe.Pointer(bp+8)).Fn < (*Mem)(unsafe.Pointer(pRhs)).Fn {
  42358 							return (*Mem)(unsafe.Pointer(bp + 8)).Fn
  42359 						}
  42360 						return (*Mem)(unsafe.Pointer(pRhs)).Fn
  42361 					}()
  42362 					rc = libc.Xmemcmp(tls, aKey1+uintptr(d1), (*Mem)(unsafe.Pointer(pRhs)).Fz, uint32(nCmp))
  42363 					if rc == 0 {
  42364 						rc = (*Mem)(unsafe.Pointer(bp+8)).Fn - (*Mem)(unsafe.Pointer(pRhs)).Fn
  42365 					}
  42366 				}
  42367 			}
  42368 		} else if int32((*Mem)(unsafe.Pointer(pRhs)).Fflags)&MEM_Blob != 0 {
  42369 			*(*U32)(unsafe.Pointer(bp + 48)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1))))
  42370 			if *(*U32)(unsafe.Pointer(bp + 48)) >= U32(0x80) {
  42371 				Xsqlite3GetVarint32(tls, aKey1+uintptr(idx1), bp+48)
  42372 			}
  42373 
  42374 			if *(*U32)(unsafe.Pointer(bp + 48)) < U32(12) || *(*U32)(unsafe.Pointer(bp + 48))&U32(0x01) != 0 {
  42375 				rc = -1
  42376 			} else {
  42377 				var nStr int32 = int32((*(*U32)(unsafe.Pointer(bp + 48)) - U32(12)) / U32(2))
  42378 
  42379 				if d1+U32(nStr) > uint32(nKey1) {
  42380 					(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 87096))
  42381 					return 0
  42382 				} else if int32((*Mem)(unsafe.Pointer(pRhs)).Fflags)&MEM_Zero != 0 {
  42383 					if !(isAllZero(tls, aKey1+uintptr(d1), nStr) != 0) {
  42384 						rc = 1
  42385 					} else {
  42386 						rc = nStr - *(*int32)(unsafe.Pointer(pRhs))
  42387 					}
  42388 				} else {
  42389 					var nCmp int32 = func() int32 {
  42390 						if nStr < (*Mem)(unsafe.Pointer(pRhs)).Fn {
  42391 							return nStr
  42392 						}
  42393 						return (*Mem)(unsafe.Pointer(pRhs)).Fn
  42394 					}()
  42395 					rc = libc.Xmemcmp(tls, aKey1+uintptr(d1), (*Mem)(unsafe.Pointer(pRhs)).Fz, uint32(nCmp))
  42396 					if rc == 0 {
  42397 						rc = nStr - (*Mem)(unsafe.Pointer(pRhs)).Fn
  42398 					}
  42399 				}
  42400 			}
  42401 		} else {
  42402 			*(*U32)(unsafe.Pointer(bp + 48)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1))))
  42403 			rc = libc.Bool32(*(*U32)(unsafe.Pointer(bp + 48)) != U32(0) && *(*U32)(unsafe.Pointer(bp + 48)) != U32(10))
  42404 		}
  42405 
  42406 		if rc != 0 {
  42407 			var sortFlags int32 = int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FpKeyInfo)).FaSortFlags + uintptr(i))))
  42408 			if sortFlags != 0 {
  42409 				if sortFlags&KEYINFO_ORDER_BIGNULL == 0 ||
  42410 					sortFlags&KEYINFO_ORDER_DESC !=
  42411 						libc.Bool32(*(*U32)(unsafe.Pointer(bp + 48)) == U32(0) || int32((*Mem)(unsafe.Pointer(pRhs)).Fflags)&MEM_Null != 0) {
  42412 					rc = -rc
  42413 				}
  42414 			}
  42415 
  42416 			return rc
  42417 		}
  42418 
  42419 		i++
  42420 		if i == int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) {
  42421 			break
  42422 		}
  42423 		pRhs += 40
  42424 		d1 = d1 + Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 48)))
  42425 		if d1 > uint32(nKey1) {
  42426 			break
  42427 		}
  42428 		idx1 = idx1 + U32(Xsqlite3VarintLen(tls, uint64(*(*U32)(unsafe.Pointer(bp + 48)))))
  42429 		if idx1 >= *(*U32)(unsafe.Pointer(bp + 4)) {
  42430 			(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 87140))
  42431 			return 0
  42432 		}
  42433 	}
  42434 
  42435 	(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FeqSeen = U8(1)
  42436 	return int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fdefault_rc)
  42437 }
  42438 
  42439 func Xsqlite3VdbeRecordCompare(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) int32 {
  42440 	return Xsqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 0)
  42441 }
  42442 
  42443 func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) int32 {
  42444 	bp := tls.Alloc(16)
  42445 	defer tls.Free(16)
  42446 
  42447 	var aKey uintptr = pKey1 + uintptr(int32(*(*U8)(unsafe.Pointer(pKey1)))&0x3F)
  42448 	var serial_type int32 = int32(*(*U8)(unsafe.Pointer(pKey1 + 1)))
  42449 	var res int32
  42450 
  42451 	var v I64
  42452 	var lhs I64
  42453 
  42454 	switch serial_type {
  42455 	case 1:
  42456 		{
  42457 			lhs = I64(I8(*(*U8)(unsafe.Pointer(aKey))))
  42458 
  42459 			break
  42460 
  42461 		}
  42462 	case 2:
  42463 		{
  42464 			lhs = I64(256*int32(I8(*(*U8)(unsafe.Pointer(aKey)))) | int32(*(*U8)(unsafe.Pointer(aKey + 1))))
  42465 
  42466 			break
  42467 
  42468 		}
  42469 	case 3:
  42470 		{
  42471 			lhs = I64(65536*int32(I8(*(*U8)(unsafe.Pointer(aKey)))) | int32(*(*U8)(unsafe.Pointer(aKey + 1)))<<8 | int32(*(*U8)(unsafe.Pointer(aKey + 2))))
  42472 
  42473 			break
  42474 
  42475 		}
  42476 	case 4:
  42477 		{
  42478 			*(*U32)(unsafe.Pointer(bp)) = U32(*(*U8)(unsafe.Pointer(aKey)))<<24 | U32(int32(*(*U8)(unsafe.Pointer(aKey + 1)))<<16) | U32(int32(*(*U8)(unsafe.Pointer(aKey + 2)))<<8) | U32(*(*U8)(unsafe.Pointer(aKey + 3)))
  42479 			lhs = I64(*(*int32)(unsafe.Pointer(bp)))
  42480 
  42481 			break
  42482 
  42483 		}
  42484 	case 5:
  42485 		{
  42486 			lhs = I64(U32(*(*U8)(unsafe.Pointer(aKey + uintptr(2))))<<24|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(2) + 1)))<<16)|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(2) + 2)))<<8)|U32(*(*U8)(unsafe.Pointer(aKey + uintptr(2) + 3)))) + int64(1)<<32*I64(256*int32(I8(*(*U8)(unsafe.Pointer(aKey))))|int32(*(*U8)(unsafe.Pointer(aKey + 1))))
  42487 
  42488 			break
  42489 
  42490 		}
  42491 	case 6:
  42492 		{
  42493 			*(*U64)(unsafe.Pointer(bp + 8)) = U64(U32(*(*U8)(unsafe.Pointer(aKey)))<<24 | U32(int32(*(*U8)(unsafe.Pointer(aKey + 1)))<<16) | U32(int32(*(*U8)(unsafe.Pointer(aKey + 2)))<<8) | U32(*(*U8)(unsafe.Pointer(aKey + 3))))
  42494 			*(*U64)(unsafe.Pointer(bp + 8)) = *(*U64)(unsafe.Pointer(bp + 8))<<32 | U64(U32(*(*U8)(unsafe.Pointer(aKey + uintptr(4))))<<24|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(4) + 1)))<<16)|U32(int32(*(*U8)(unsafe.Pointer(aKey + uintptr(4) + 2)))<<8)|U32(*(*U8)(unsafe.Pointer(aKey + uintptr(4) + 3))))
  42495 			lhs = *(*I64)(unsafe.Pointer(bp + 8))
  42496 
  42497 			break
  42498 
  42499 		}
  42500 	case 8:
  42501 		lhs = int64(0)
  42502 		break
  42503 	case 9:
  42504 		lhs = int64(1)
  42505 		break
  42506 
  42507 	case 0:
  42508 		fallthrough
  42509 	case 7:
  42510 		return Xsqlite3VdbeRecordCompare(tls, nKey1, pKey1, pPKey2)
  42511 
  42512 	default:
  42513 		return Xsqlite3VdbeRecordCompare(tls, nKey1, pKey1, pPKey2)
  42514 	}
  42515 
  42516 	v = *(*I64)(unsafe.Pointer(pPKey2 + 8))
  42517 	if v > lhs {
  42518 		res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1)
  42519 	} else if v < lhs {
  42520 		res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2)
  42521 	} else if int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) > 1 {
  42522 		res = Xsqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 1)
  42523 	} else {
  42524 		res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fdefault_rc)
  42525 		(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FeqSeen = U8(1)
  42526 	}
  42527 
  42528 	return res
  42529 }
  42530 
  42531 func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) int32 {
  42532 	bp := tls.Alloc(4)
  42533 	defer tls.Free(4)
  42534 
  42535 	var aKey1 uintptr
  42536 
  42537 	var res int32
  42538 	var nCmp int32
  42539 	var nStr int32
  42540 	var szHdr int32
  42541 	aKey1 = pKey1
  42542 
  42543 	*(*int32)(unsafe.Pointer(bp)) = int32(int8(*(*U8)(unsafe.Pointer(aKey1 + 1))))
  42544 
  42545 vrcs_restart:
  42546 	if !(*(*int32)(unsafe.Pointer(bp)) < 12) {
  42547 		goto __1
  42548 	}
  42549 	if !(*(*int32)(unsafe.Pointer(bp)) < 0) {
  42550 		goto __3
  42551 	}
  42552 	Xsqlite3GetVarint32(tls, aKey1+1, bp)
  42553 	if !(*(*int32)(unsafe.Pointer(bp)) >= 12) {
  42554 		goto __4
  42555 	}
  42556 	goto vrcs_restart
  42557 __4:
  42558 	;
  42559 __3:
  42560 	;
  42561 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1)
  42562 	goto __2
  42563 __1:
  42564 	if !!(*(*int32)(unsafe.Pointer(bp))&0x01 != 0) {
  42565 		goto __5
  42566 	}
  42567 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2)
  42568 	goto __6
  42569 __5:
  42570 	szHdr = int32(*(*U8)(unsafe.Pointer(aKey1)))
  42571 
  42572 	nStr = (*(*int32)(unsafe.Pointer(bp)) - 12) / 2
  42573 	if !(szHdr+nStr > nKey1) {
  42574 		goto __7
  42575 	}
  42576 	(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 87303))
  42577 	return 0
  42578 __7:
  42579 	;
  42580 	nCmp = func() int32 {
  42581 		if (*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fn < nStr {
  42582 			return (*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fn
  42583 		}
  42584 		return nStr
  42585 	}()
  42586 	res = libc.Xmemcmp(tls, aKey1+uintptr(szHdr), *(*uintptr)(unsafe.Pointer(pPKey2 + 8)), uint32(nCmp))
  42587 
  42588 	if !(res > 0) {
  42589 		goto __8
  42590 	}
  42591 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2)
  42592 	goto __9
  42593 __8:
  42594 	if !(res < 0) {
  42595 		goto __10
  42596 	}
  42597 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1)
  42598 	goto __11
  42599 __10:
  42600 	res = nStr - (*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fn
  42601 	if !(res == 0) {
  42602 		goto __12
  42603 	}
  42604 	if !(int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) > 1) {
  42605 		goto __14
  42606 	}
  42607 	res = Xsqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 1)
  42608 	goto __15
  42609 __14:
  42610 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fdefault_rc)
  42611 	(*UnpackedRecord)(unsafe.Pointer(pPKey2)).FeqSeen = U8(1)
  42612 __15:
  42613 	;
  42614 	goto __13
  42615 __12:
  42616 	if !(res > 0) {
  42617 		goto __16
  42618 	}
  42619 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2)
  42620 	goto __17
  42621 __16:
  42622 	res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1)
  42623 __17:
  42624 	;
  42625 __13:
  42626 	;
  42627 __11:
  42628 	;
  42629 __9:
  42630 	;
  42631 __6:
  42632 	;
  42633 __2:
  42634 	;
  42635 	return res
  42636 }
  42637 
  42638 // Return a pointer to an sqlite3VdbeRecordCompare() compatible function
  42639 // suitable for comparing serialized records to the unpacked record passed
  42640 // as the only argument.
  42641 func Xsqlite3VdbeFindCompare(tls *libc.TLS, p uintptr) RecordCompare {
  42642 	if int32((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FnAllField) <= 13 {
  42643 		var flags int32 = int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem)).Fflags)
  42644 		if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags)) != 0 {
  42645 			if int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags)))&KEYINFO_ORDER_BIGNULL != 0 {
  42646 				return *(*uintptr)(unsafe.Pointer(&struct {
  42647 					f func(*libc.TLS, int32, uintptr, uintptr) int32
  42648 				}{Xsqlite3VdbeRecordCompare}))
  42649 			}
  42650 			(*UnpackedRecord)(unsafe.Pointer(p)).Fr1 = int8(1)
  42651 			(*UnpackedRecord)(unsafe.Pointer(p)).Fr2 = int8(-1)
  42652 		} else {
  42653 			(*UnpackedRecord)(unsafe.Pointer(p)).Fr1 = int8(-1)
  42654 			(*UnpackedRecord)(unsafe.Pointer(p)).Fr2 = int8(1)
  42655 		}
  42656 		if flags&MEM_Int != 0 {
  42657 			*(*I64)(unsafe.Pointer(p + 8)) = *(*I64)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem))
  42658 			return *(*uintptr)(unsafe.Pointer(&struct {
  42659 				f func(*libc.TLS, int32, uintptr, uintptr) int32
  42660 			}{vdbeRecordCompareInt}))
  42661 		}
  42662 
  42663 		if flags&(MEM_Real|MEM_IntReal|MEM_Null|MEM_Blob) == 0 &&
  42664 			*(*uintptr)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 20)) == uintptr(0) {
  42665 			*(*uintptr)(unsafe.Pointer(p + 8)) = (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem)).Fz
  42666 			(*UnpackedRecord)(unsafe.Pointer(p)).Fn = (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem)).Fn
  42667 			return *(*uintptr)(unsafe.Pointer(&struct {
  42668 				f func(*libc.TLS, int32, uintptr, uintptr) int32
  42669 			}{vdbeRecordCompareString}))
  42670 		}
  42671 	}
  42672 
  42673 	return *(*uintptr)(unsafe.Pointer(&struct {
  42674 		f func(*libc.TLS, int32, uintptr, uintptr) int32
  42675 	}{Xsqlite3VdbeRecordCompare}))
  42676 }
  42677 
  42678 // pCur points at an index entry created using the OP_MakeRecord opcode.
  42679 // Read the rowid (the last field in the record) and store it in *rowid.
  42680 // Return SQLITE_OK if everything works, or an error code otherwise.
  42681 //
  42682 // pCur might be pointing to text obtained from a corrupt database file.
  42683 // So the content cannot be trusted.  Do appropriate checks on the content.
  42684 func Xsqlite3VdbeIdxRowid(tls *libc.TLS, db uintptr, pCur uintptr, rowid uintptr) int32 {
  42685 	bp := tls.Alloc(88)
  42686 	defer tls.Free(88)
  42687 
  42688 	var nCellKey I64
  42689 	var rc int32
  42690 
  42691 	var lenRowid U32
  42692 
  42693 	nCellKey = int64(0)
  42694 
  42695 	nCellKey = I64(Xsqlite3BtreePayloadSize(tls, pCur))
  42696 
  42697 	Xsqlite3VdbeMemInit(tls, bp, db, uint16(0))
  42698 	rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, pCur, U32(nCellKey), bp)
  42699 	if !(rc != 0) {
  42700 		goto __1
  42701 	}
  42702 	return rc
  42703 __1:
  42704 	;
  42705 	*(*U32)(unsafe.Pointer(bp + 40)) = U32(*(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(bp)).Fz)))
  42706 	if !(*(*U32)(unsafe.Pointer(bp + 40)) >= U32(0x80)) {
  42707 		goto __2
  42708 	}
  42709 	Xsqlite3GetVarint32(tls, (*Mem)(unsafe.Pointer(bp)).Fz, bp+40)
  42710 __2:
  42711 	;
  42712 	if !(*(*U32)(unsafe.Pointer(bp + 40)) < U32(3) || *(*U32)(unsafe.Pointer(bp + 40)) > uint32((*Mem)(unsafe.Pointer(bp)).Fn)) {
  42713 		goto __3
  42714 	}
  42715 	goto idx_rowid_corruption
  42716 __3:
  42717 	;
  42718 	*(*U32)(unsafe.Pointer(bp + 44)) = U32(*(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(bp)).Fz + uintptr(*(*U32)(unsafe.Pointer(bp + 40))-U32(1)))))
  42719 	if !(*(*U32)(unsafe.Pointer(bp + 44)) >= U32(0x80)) {
  42720 		goto __4
  42721 	}
  42722 	Xsqlite3GetVarint32(tls, (*Mem)(unsafe.Pointer(bp)).Fz+uintptr(*(*U32)(unsafe.Pointer(bp + 40))-U32(1)), bp+44)
  42723 __4:
  42724 	;
  42725 	if !(*(*U32)(unsafe.Pointer(bp + 44)) < U32(1) || *(*U32)(unsafe.Pointer(bp + 44)) > U32(9) || *(*U32)(unsafe.Pointer(bp + 44)) == U32(7)) {
  42726 		goto __5
  42727 	}
  42728 	goto idx_rowid_corruption
  42729 __5:
  42730 	;
  42731 	lenRowid = U32(Xsqlite3SmallTypeSizes[*(*U32)(unsafe.Pointer(bp + 44))])
  42732 
  42733 	if !(U32((*Mem)(unsafe.Pointer(bp)).Fn) < *(*U32)(unsafe.Pointer(bp + 40))+lenRowid) {
  42734 		goto __6
  42735 	}
  42736 	goto idx_rowid_corruption
  42737 __6:
  42738 	;
  42739 	Xsqlite3VdbeSerialGet(tls, (*Mem)(unsafe.Pointer(bp)).Fz+uintptr(U32((*Mem)(unsafe.Pointer(bp)).Fn)-lenRowid), *(*U32)(unsafe.Pointer(bp + 44)), bp+48)
  42740 	*(*I64)(unsafe.Pointer(rowid)) = *(*I64)(unsafe.Pointer(bp + 48))
  42741 	Xsqlite3VdbeMemReleaseMalloc(tls, bp)
  42742 	return SQLITE_OK
  42743 
  42744 idx_rowid_corruption:
  42745 	;
  42746 	Xsqlite3VdbeMemReleaseMalloc(tls, bp)
  42747 	return Xsqlite3CorruptError(tls, 87461)
  42748 }
  42749 
  42750 // Compare the key of the index entry that cursor pC is pointing to against
  42751 // the key string in pUnpacked.  Write into *pRes a number
  42752 // that is negative, zero, or positive if pC is less than, equal to,
  42753 // or greater than pUnpacked.  Return SQLITE_OK on success.
  42754 //
  42755 // pUnpacked is either created without a rowid or is truncated so that it
  42756 // omits the rowid at the end.  The rowid at the end of the index entry
  42757 // is ignored as well.  Hence, this routine only compares the prefixes
  42758 // of the keys prior to the final rowid, not the entire key.
  42759 func Xsqlite3VdbeIdxKeyCompare(tls *libc.TLS, db uintptr, pC uintptr, pUnpacked uintptr, res uintptr) int32 {
  42760 	bp := tls.Alloc(40)
  42761 	defer tls.Free(40)
  42762 
  42763 	var nCellKey I64 = int64(0)
  42764 	var rc int32
  42765 	var pCur uintptr
  42766 
  42767 	pCur = *(*uintptr)(unsafe.Pointer(pC + 36))
  42768 
  42769 	nCellKey = I64(Xsqlite3BtreePayloadSize(tls, pCur))
  42770 
  42771 	if nCellKey <= int64(0) || nCellKey > int64(0x7fffffff) {
  42772 		*(*int32)(unsafe.Pointer(res)) = 0
  42773 		return Xsqlite3CorruptError(tls, 87494)
  42774 	}
  42775 	Xsqlite3VdbeMemInit(tls, bp, db, uint16(0))
  42776 	rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, pCur, U32(nCellKey), bp)
  42777 	if rc != 0 {
  42778 		return rc
  42779 	}
  42780 	*(*int32)(unsafe.Pointer(res)) = Xsqlite3VdbeRecordCompareWithSkip(tls, (*Mem)(unsafe.Pointer(bp)).Fn, (*Mem)(unsafe.Pointer(bp)).Fz, pUnpacked, 0)
  42781 	Xsqlite3VdbeMemReleaseMalloc(tls, bp)
  42782 	return SQLITE_OK
  42783 }
  42784 
  42785 // This routine sets the value to be returned by subsequent calls to
  42786 // sqlite3_changes() on the database handle 'db'.
  42787 func Xsqlite3VdbeSetChanges(tls *libc.TLS, db uintptr, nChange I64) {
  42788 	(*Sqlite3)(unsafe.Pointer(db)).FnChange = nChange
  42789 	*(*I64)(unsafe.Pointer(db + 112)) += nChange
  42790 }
  42791 
  42792 // Set a flag in the vdbe to update the change counter when it is finalised
  42793 // or reset.
  42794 func Xsqlite3VdbeCountChanges(tls *libc.TLS, v uintptr) {
  42795 	libc.SetBitFieldPtr8Uint32(v+152, Bft(1), 4, 0x10)
  42796 }
  42797 
  42798 // Mark every prepared statement associated with a database connection
  42799 // as expired.
  42800 //
  42801 // An expired statement means that recompilation of the statement is
  42802 // recommend.  Statements expire when things happen that make their
  42803 // programs obsolete.  Removing user-defined functions or collating
  42804 // sequences, or changing an authorization function are the types of
  42805 // things that make prepared statements obsolete.
  42806 //
  42807 // If iCode is 1, then expiration is advisory.  The statement should
  42808 // be reprepared before being restarted, but if it is already running
  42809 // it is allowed to run to completion.
  42810 //
  42811 // Internally, this function just sets the Vdbe.expired flag on all
  42812 // prepared statements.  The flag is set to 1 for an immediate expiration
  42813 // and set to 2 for an advisory expiration.
  42814 func Xsqlite3ExpirePreparedStatements(tls *libc.TLS, db uintptr, iCode int32) {
  42815 	var p uintptr
  42816 	for p = (*Sqlite3)(unsafe.Pointer(db)).FpVdbe; p != 0; p = (*Vdbe)(unsafe.Pointer(p)).FpVNext {
  42817 		libc.SetBitFieldPtr8Uint32(p+152, Bft(iCode+1), 0, 0x3)
  42818 	}
  42819 }
  42820 
  42821 // Return the database associated with the Vdbe.
  42822 func Xsqlite3VdbeDb(tls *libc.TLS, v uintptr) uintptr {
  42823 	return (*Vdbe)(unsafe.Pointer(v)).Fdb
  42824 }
  42825 
  42826 // Return the SQLITE_PREPARE flags for a Vdbe.
  42827 func Xsqlite3VdbePrepareFlags(tls *libc.TLS, v uintptr) U8 {
  42828 	return (*Vdbe)(unsafe.Pointer(v)).FprepFlags
  42829 }
  42830 
  42831 // Return a pointer to an sqlite3_value structure containing the value bound
  42832 // parameter iVar of VM v. Except, if the value is an SQL NULL, return
  42833 // 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
  42834 // constants) to the value before returning it.
  42835 //
  42836 // The returned value must be freed by the caller using sqlite3ValueFree().
  42837 func Xsqlite3VdbeGetBoundValue(tls *libc.TLS, v uintptr, iVar int32, aff U8) uintptr {
  42838 	if v != 0 {
  42839 		var pMem uintptr = (*Vdbe)(unsafe.Pointer(v)).FaVar + uintptr(iVar-1)*40
  42840 
  42841 		if 0 == int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Null {
  42842 			var pRet uintptr = Xsqlite3ValueNew(tls, (*Vdbe)(unsafe.Pointer(v)).Fdb)
  42843 			if pRet != 0 {
  42844 				Xsqlite3VdbeMemCopy(tls, pRet, pMem)
  42845 				Xsqlite3ValueApplyAffinity(tls, pRet, aff, uint8(SQLITE_UTF8))
  42846 			}
  42847 			return pRet
  42848 		}
  42849 	}
  42850 	return uintptr(0)
  42851 }
  42852 
  42853 // Configure SQL variable iVar so that binding a new value to it signals
  42854 // to sqlite3_reoptimize() that re-preparing the statement may result
  42855 // in a better query plan.
  42856 func Xsqlite3VdbeSetVarmask(tls *libc.TLS, v uintptr, iVar int32) {
  42857 	if iVar >= 32 {
  42858 		*(*U32)(unsafe.Pointer(v + 220)) |= 0x80000000
  42859 	} else {
  42860 		*(*U32)(unsafe.Pointer(v + 220)) |= U32(1) << (iVar - 1)
  42861 	}
  42862 }
  42863 
  42864 // Cause a function to throw an error if it was call from OP_PureFunc
  42865 // rather than OP_Function.
  42866 //
  42867 // OP_PureFunc means that the function must be deterministic, and should
  42868 // throw an error if it is given inputs that would make it non-deterministic.
  42869 // This routine is invoked by date/time functions that use non-deterministic
  42870 // features such as 'now'.
  42871 func Xsqlite3NotPureFunc(tls *libc.TLS, pCtx uintptr) int32 {
  42872 	bp := tls.Alloc(16)
  42873 	defer tls.Free(16)
  42874 
  42875 	var pOp uintptr
  42876 	if (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe == uintptr(0) {
  42877 		return 1
  42878 	}
  42879 	pOp = (*Vdbe)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FaOp + uintptr((*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp)*20
  42880 	if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_PureFunc {
  42881 		var zContext uintptr
  42882 		var zMsg uintptr
  42883 		if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5)&NC_IsCheck != 0 {
  42884 			zContext = ts + 5166
  42885 		} else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5)&NC_GenCol != 0 {
  42886 			zContext = ts + 5185
  42887 		} else {
  42888 			zContext = ts + 5204
  42889 		}
  42890 		zMsg = Xsqlite3_mprintf(tls, ts+5213,
  42891 			libc.VaList(bp, (*FuncDef)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpFunc)).FzName, zContext))
  42892 		Xsqlite3_result_error(tls, pCtx, zMsg, -1)
  42893 		Xsqlite3_free(tls, zMsg)
  42894 		return 0
  42895 	}
  42896 	return 1
  42897 }
  42898 
  42899 // Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
  42900 // in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
  42901 // in memory obtained from sqlite3DbMalloc).
  42902 func Xsqlite3VtabImportErrmsg(tls *libc.TLS, p uintptr, pVtab uintptr) {
  42903 	if (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg != 0 {
  42904 		var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb
  42905 		Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)
  42906 		(*Vdbe)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3DbStrDup(tls, db, (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg)
  42907 		Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg)
  42908 		(*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = uintptr(0)
  42909 	}
  42910 }
  42911 
  42912 func vdbeFreeUnpacked(tls *libc.TLS, db uintptr, nField int32, p uintptr) {
  42913 	if p != 0 {
  42914 		var i int32
  42915 		for i = 0; i < nField; i++ {
  42916 			var pMem uintptr = (*UnpackedRecord)(unsafe.Pointer(p)).FaMem + uintptr(i)*40
  42917 			if (*Mem)(unsafe.Pointer(pMem)).FzMalloc != 0 {
  42918 				Xsqlite3VdbeMemReleaseMalloc(tls, pMem)
  42919 			}
  42920 		}
  42921 		Xsqlite3DbNNFreeNN(tls, db, p)
  42922 	}
  42923 }
  42924 
  42925 // Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,
  42926 // then cursor passed as the second argument should point to the row about
  42927 // to be update or deleted. If the application calls sqlite3_preupdate_old(),
  42928 // the required value will be read from the row the cursor points to.
  42929 func Xsqlite3VdbePreUpdateHook(tls *libc.TLS, v uintptr, pCsr uintptr, op int32, zDb uintptr, pTab uintptr, iKey1 I64, iReg int32, iBlobWrite int32) {
  42930 	bp := tls.Alloc(88)
  42931 	defer tls.Free(88)
  42932 
  42933 	var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb
  42934 	var iKey2 I64
  42935 
  42936 	var zTbl uintptr = (*Table)(unsafe.Pointer(pTab)).FzName
  42937 
  42938 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(PreUpdate{})))
  42939 	if libc.Bool32((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) == 0 {
  42940 		iKey1 = libc.AssignInt64(&iKey2, int64(0))
  42941 		(*PreUpdate)(unsafe.Pointer(bp)).FpPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  42942 	} else {
  42943 		if op == SQLITE_UPDATE {
  42944 			iKey2 = *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(iReg)*40))
  42945 		} else {
  42946 			iKey2 = iKey1
  42947 		}
  42948 	}
  42949 
  42950 	(*PreUpdate)(unsafe.Pointer(bp)).Fv = v
  42951 	(*PreUpdate)(unsafe.Pointer(bp)).FpCsr = pCsr
  42952 	(*PreUpdate)(unsafe.Pointer(bp)).Fop = op
  42953 	(*PreUpdate)(unsafe.Pointer(bp)).FiNewReg = iReg
  42954 	(*PreUpdate)(unsafe.Pointer(bp)).Fkeyinfo.Fdb = db
  42955 	(*PreUpdate)(unsafe.Pointer(bp)).Fkeyinfo.Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  42956 	(*PreUpdate)(unsafe.Pointer(bp)).Fkeyinfo.FnKeyField = U16((*Table)(unsafe.Pointer(pTab)).FnCol)
  42957 	(*PreUpdate)(unsafe.Pointer(bp)).Fkeyinfo.FaSortFlags = uintptr(unsafe.Pointer(&fakeSortOrder))
  42958 	(*PreUpdate)(unsafe.Pointer(bp)).FiKey1 = iKey1
  42959 	(*PreUpdate)(unsafe.Pointer(bp)).FiKey2 = iKey2
  42960 	(*PreUpdate)(unsafe.Pointer(bp)).FpTab = pTab
  42961 	(*PreUpdate)(unsafe.Pointer(bp)).FiBlobWrite = iBlobWrite
  42962 
  42963 	(*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate = bp
  42964 	(*struct {
  42965 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, Sqlite3_int64, Sqlite3_int64)
  42966 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2)
  42967 	(*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate = uintptr(0)
  42968 	Xsqlite3DbFree(tls, db, (*PreUpdate)(unsafe.Pointer(bp)).FaRecord)
  42969 	vdbeFreeUnpacked(tls, db, int32((*PreUpdate)(unsafe.Pointer(bp)).Fkeyinfo.FnKeyField)+1, (*PreUpdate)(unsafe.Pointer(bp)).FpUnpacked)
  42970 	vdbeFreeUnpacked(tls, db, int32((*PreUpdate)(unsafe.Pointer(bp)).Fkeyinfo.FnKeyField)+1, (*PreUpdate)(unsafe.Pointer(bp)).FpNewUnpacked)
  42971 	if (*PreUpdate)(unsafe.Pointer(bp)).FaNew != 0 {
  42972 		var i int32
  42973 		for i = 0; i < int32((*VdbeCursor)(unsafe.Pointer(pCsr)).FnField); i++ {
  42974 			Xsqlite3VdbeMemRelease(tls, (*PreUpdate)(unsafe.Pointer(bp)).FaNew+uintptr(i)*40)
  42975 		}
  42976 		Xsqlite3DbNNFreeNN(tls, db, (*PreUpdate)(unsafe.Pointer(bp)).FaNew)
  42977 	}
  42978 }
  42979 
  42980 var fakeSortOrder U8 = U8(0)
  42981 
  42982 // Return TRUE (non-zero) of the statement supplied as an argument needs
  42983 // to be recompiled.  A statement needs to be recompiled whenever the
  42984 // execution environment changes in a way that would alter the program
  42985 // that sqlite3_prepare() generates.  For example, if new functions or
  42986 // collating sequences are registered or if an authorizer function is
  42987 // added or changed.
  42988 func Xsqlite3_expired(tls *libc.TLS, pStmt uintptr) int32 {
  42989 	var p uintptr = pStmt
  42990 	return libc.Bool32(p == uintptr(0) || Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x3>>0)) != 0)
  42991 }
  42992 
  42993 func vdbeSafety(tls *libc.TLS, p uintptr) int32 {
  42994 	if (*Vdbe)(unsafe.Pointer(p)).Fdb == uintptr(0) {
  42995 		Xsqlite3_log(tls, SQLITE_MISUSE, ts+5249, 0)
  42996 		return 1
  42997 	} else {
  42998 		return 0
  42999 	}
  43000 	return int32(0)
  43001 }
  43002 
  43003 func vdbeSafetyNotNull(tls *libc.TLS, p uintptr) int32 {
  43004 	if p == uintptr(0) {
  43005 		Xsqlite3_log(tls, SQLITE_MISUSE, ts+5294, 0)
  43006 		return 1
  43007 	} else {
  43008 		return vdbeSafety(tls, p)
  43009 	}
  43010 	return int32(0)
  43011 }
  43012 
  43013 func invokeProfileCallback(tls *libc.TLS, db uintptr, p uintptr) {
  43014 	bp := tls.Alloc(16)
  43015 	defer tls.Free(16)
  43016 
  43017 	Xsqlite3OsCurrentTimeInt64(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, bp)
  43018 	*(*Sqlite3_int64)(unsafe.Pointer(bp + 8)) = (*(*Sqlite3_int64)(unsafe.Pointer(bp)) - (*Vdbe)(unsafe.Pointer(p)).FstartTime) * int64(1000000)
  43019 	if (*Sqlite3)(unsafe.Pointer(db)).FxProfile != 0 {
  43020 		(*struct {
  43021 			f func(*libc.TLS, uintptr, uintptr, U64)
  43022 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxProfile})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg, (*Vdbe)(unsafe.Pointer(p)).FzSql, uint64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8))))
  43023 	}
  43024 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace)&SQLITE_TRACE_PROFILE != 0 {
  43025 		(*struct {
  43026 			f func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32
  43027 		})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(db + 216))})).f(tls, uint32(SQLITE_TRACE_PROFILE), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, bp+8)
  43028 	}
  43029 	(*Vdbe)(unsafe.Pointer(p)).FstartTime = int64(0)
  43030 }
  43031 
  43032 // The following routine destroys a virtual machine that is created by
  43033 // the sqlite3_compile() routine. The integer returned is an SQLITE_
  43034 // success/failure code that describes the result of executing the virtual
  43035 // machine.
  43036 //
  43037 // This routine sets the error code and string returned by
  43038 // sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
  43039 func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) int32 {
  43040 	var rc int32
  43041 	if pStmt == uintptr(0) {
  43042 		rc = SQLITE_OK
  43043 	} else {
  43044 		var v uintptr = pStmt
  43045 		var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb
  43046 		if vdbeSafety(tls, v) != 0 {
  43047 			return Xsqlite3MisuseError(tls, 87858)
  43048 		}
  43049 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  43050 		if (*Vdbe)(unsafe.Pointer(v)).FstartTime > int64(0) {
  43051 			invokeProfileCallback(tls, db, v)
  43052 		}
  43053 
  43054 		rc = Xsqlite3VdbeReset(tls, v)
  43055 		Xsqlite3VdbeDelete(tls, v)
  43056 		rc = Xsqlite3ApiExit(tls, db, rc)
  43057 		Xsqlite3LeaveMutexAndCloseZombie(tls, db)
  43058 	}
  43059 	return rc
  43060 }
  43061 
  43062 // Terminate the current execution of an SQL statement and reset it
  43063 // back to its starting state so that it can be reused. A success code from
  43064 // the prior execution is returned.
  43065 //
  43066 // This routine sets the error code and string returned by
  43067 // sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
  43068 func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) int32 {
  43069 	var rc int32
  43070 	if pStmt == uintptr(0) {
  43071 		rc = SQLITE_OK
  43072 	} else {
  43073 		var v uintptr = pStmt
  43074 		var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb
  43075 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  43076 		if (*Vdbe)(unsafe.Pointer(v)).FstartTime > int64(0) {
  43077 			invokeProfileCallback(tls, db, v)
  43078 		}
  43079 
  43080 		rc = Xsqlite3VdbeReset(tls, v)
  43081 		Xsqlite3VdbeRewind(tls, v)
  43082 
  43083 		rc = Xsqlite3ApiExit(tls, db, rc)
  43084 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  43085 	}
  43086 	return rc
  43087 }
  43088 
  43089 // Set all the parameters in the compiled SQL statement to NULL.
  43090 func Xsqlite3_clear_bindings(tls *libc.TLS, pStmt uintptr) int32 {
  43091 	var i int32
  43092 	var rc int32 = SQLITE_OK
  43093 	var p uintptr = pStmt
  43094 	var mutex uintptr = (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pStmt)).Fdb)).Fmutex
  43095 	Xsqlite3_mutex_enter(tls, mutex)
  43096 	for i = 0; i < int32((*Vdbe)(unsafe.Pointer(p)).FnVar); i++ {
  43097 		Xsqlite3VdbeMemRelease(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar+uintptr(i)*40)
  43098 		(*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*40)).Fflags = U16(MEM_Null)
  43099 	}
  43100 
  43101 	if (*Vdbe)(unsafe.Pointer(p)).Fexpmask != 0 {
  43102 		libc.SetBitFieldPtr8Uint32(p+152, Bft(1), 0, 0x3)
  43103 	}
  43104 	Xsqlite3_mutex_leave(tls, mutex)
  43105 	return rc
  43106 }
  43107 
  43108 // *************************** sqlite3_value_  *******************************
  43109 //
  43110 // The following routines extract information from a Mem or sqlite3_value
  43111 // structure.
  43112 func Xsqlite3_value_blob(tls *libc.TLS, pVal uintptr) uintptr {
  43113 	var p uintptr = pVal
  43114 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Blob|MEM_Str) != 0 {
  43115 		if func() int32 {
  43116 			if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Zero != 0 {
  43117 				return Xsqlite3VdbeMemExpandBlob(tls, p)
  43118 			}
  43119 			return 0
  43120 		}() != SQLITE_OK {
  43121 			return uintptr(0)
  43122 		}
  43123 		*(*U16)(unsafe.Pointer(p + 16)) |= U16(MEM_Blob)
  43124 		if (*Mem)(unsafe.Pointer(p)).Fn != 0 {
  43125 			return (*Mem)(unsafe.Pointer(p)).Fz
  43126 		}
  43127 		return uintptr(0)
  43128 	} else {
  43129 		return Xsqlite3_value_text(tls, pVal)
  43130 	}
  43131 	return uintptr(0)
  43132 }
  43133 
  43134 func Xsqlite3_value_bytes(tls *libc.TLS, pVal uintptr) int32 {
  43135 	return Xsqlite3ValueBytes(tls, pVal, uint8(SQLITE_UTF8))
  43136 }
  43137 
  43138 func Xsqlite3_value_bytes16(tls *libc.TLS, pVal uintptr) int32 {
  43139 	return Xsqlite3ValueBytes(tls, pVal, uint8(SQLITE_UTF16LE))
  43140 }
  43141 
  43142 func Xsqlite3_value_double(tls *libc.TLS, pVal uintptr) float64 {
  43143 	return Xsqlite3VdbeRealValue(tls, pVal)
  43144 }
  43145 
  43146 func Xsqlite3_value_int(tls *libc.TLS, pVal uintptr) int32 {
  43147 	return int32(Xsqlite3VdbeIntValue(tls, pVal))
  43148 }
  43149 
  43150 func Xsqlite3_value_int64(tls *libc.TLS, pVal uintptr) Sqlite_int64 {
  43151 	return Xsqlite3VdbeIntValue(tls, pVal)
  43152 }
  43153 
  43154 func Xsqlite3_value_subtype(tls *libc.TLS, pVal uintptr) uint32 {
  43155 	var pMem uintptr = pVal
  43156 	return func() uint32 {
  43157 		if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Subtype != 0 {
  43158 			return uint32((*Mem)(unsafe.Pointer(pMem)).FeSubtype)
  43159 		}
  43160 		return uint32(0)
  43161 	}()
  43162 }
  43163 
  43164 func Xsqlite3_value_pointer(tls *libc.TLS, pVal uintptr, zPType uintptr) uintptr {
  43165 	var p uintptr = pVal
  43166 	if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_TypeMask|MEM_Term|MEM_Subtype) == MEM_Null|MEM_Term|MEM_Subtype &&
  43167 		zPType != uintptr(0) &&
  43168 		int32((*Mem)(unsafe.Pointer(p)).FeSubtype) == 'p' &&
  43169 		libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(p)), zPType) == 0 {
  43170 		return (*Mem)(unsafe.Pointer(p)).Fz
  43171 	} else {
  43172 		return uintptr(0)
  43173 	}
  43174 	return uintptr(0)
  43175 }
  43176 
  43177 func Xsqlite3_value_text(tls *libc.TLS, pVal uintptr) uintptr {
  43178 	return Xsqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8))
  43179 }
  43180 
  43181 func Xsqlite3_value_text16(tls *libc.TLS, pVal uintptr) uintptr {
  43182 	return Xsqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16LE))
  43183 }
  43184 
  43185 func Xsqlite3_value_text16be(tls *libc.TLS, pVal uintptr) uintptr {
  43186 	return Xsqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16BE))
  43187 }
  43188 
  43189 func Xsqlite3_value_text16le(tls *libc.TLS, pVal uintptr) uintptr {
  43190 	return Xsqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16LE))
  43191 }
  43192 
  43193 // EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
  43194 // fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
  43195 // point number string BLOB NULL
  43196 func Xsqlite3_value_type(tls *libc.TLS, pVal uintptr) int32 {
  43197 	return int32(aType[int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&MEM_AffMask])
  43198 }
  43199 
  43200 var aType = [64]U8{
  43201 	U8(SQLITE_BLOB),
  43202 	U8(SQLITE_NULL),
  43203 	U8(SQLITE_TEXT),
  43204 	U8(SQLITE_NULL),
  43205 	U8(SQLITE_INTEGER),
  43206 	U8(SQLITE_NULL),
  43207 	U8(SQLITE_INTEGER),
  43208 	U8(SQLITE_NULL),
  43209 	U8(SQLITE_FLOAT),
  43210 	U8(SQLITE_NULL),
  43211 	U8(SQLITE_FLOAT),
  43212 	U8(SQLITE_NULL),
  43213 	U8(SQLITE_INTEGER),
  43214 	U8(SQLITE_NULL),
  43215 	U8(SQLITE_INTEGER),
  43216 	U8(SQLITE_NULL),
  43217 	U8(SQLITE_BLOB),
  43218 	U8(SQLITE_NULL),
  43219 	U8(SQLITE_TEXT),
  43220 	U8(SQLITE_NULL),
  43221 	U8(SQLITE_INTEGER),
  43222 	U8(SQLITE_NULL),
  43223 	U8(SQLITE_INTEGER),
  43224 	U8(SQLITE_NULL),
  43225 	U8(SQLITE_FLOAT),
  43226 	U8(SQLITE_NULL),
  43227 	U8(SQLITE_FLOAT),
  43228 	U8(SQLITE_NULL),
  43229 	U8(SQLITE_INTEGER),
  43230 	U8(SQLITE_NULL),
  43231 	U8(SQLITE_INTEGER),
  43232 	U8(SQLITE_NULL),
  43233 	U8(SQLITE_FLOAT),
  43234 	U8(SQLITE_NULL),
  43235 	U8(SQLITE_TEXT),
  43236 	U8(SQLITE_NULL),
  43237 	U8(SQLITE_FLOAT),
  43238 	U8(SQLITE_NULL),
  43239 	U8(SQLITE_FLOAT),
  43240 	U8(SQLITE_NULL),
  43241 	U8(SQLITE_FLOAT),
  43242 	U8(SQLITE_NULL),
  43243 	U8(SQLITE_FLOAT),
  43244 	U8(SQLITE_NULL),
  43245 	U8(SQLITE_FLOAT),
  43246 	U8(SQLITE_NULL),
  43247 	U8(SQLITE_FLOAT),
  43248 	U8(SQLITE_NULL),
  43249 	U8(SQLITE_BLOB),
  43250 	U8(SQLITE_NULL),
  43251 	U8(SQLITE_TEXT),
  43252 	U8(SQLITE_NULL),
  43253 	U8(SQLITE_FLOAT),
  43254 	U8(SQLITE_NULL),
  43255 	U8(SQLITE_FLOAT),
  43256 	U8(SQLITE_NULL),
  43257 	U8(SQLITE_FLOAT),
  43258 	U8(SQLITE_NULL),
  43259 	U8(SQLITE_FLOAT),
  43260 	U8(SQLITE_NULL),
  43261 	U8(SQLITE_FLOAT),
  43262 	U8(SQLITE_NULL),
  43263 	U8(SQLITE_FLOAT),
  43264 	U8(SQLITE_NULL),
  43265 }
  43266 
  43267 func Xsqlite3_value_encoding(tls *libc.TLS, pVal uintptr) int32 {
  43268 	return int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc)
  43269 }
  43270 
  43271 // Return true if a parameter to xUpdate represents an unchanged column
  43272 func Xsqlite3_value_nochange(tls *libc.TLS, pVal uintptr) int32 {
  43273 	return libc.Bool32(int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&(MEM_Null|MEM_Zero) == MEM_Null|MEM_Zero)
  43274 }
  43275 
  43276 // Return true if a parameter value originated from an sqlite3_bind()
  43277 func Xsqlite3_value_frombind(tls *libc.TLS, pVal uintptr) int32 {
  43278 	return libc.Bool32(int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&MEM_FromBind != 0)
  43279 }
  43280 
  43281 // Make a copy of an sqlite3_value object
  43282 func Xsqlite3_value_dup(tls *libc.TLS, pOrig uintptr) uintptr {
  43283 	var pNew uintptr
  43284 	if pOrig == uintptr(0) {
  43285 		return uintptr(0)
  43286 	}
  43287 	pNew = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Sqlite3_value{})))
  43288 	if pNew == uintptr(0) {
  43289 		return uintptr(0)
  43290 	}
  43291 	libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Sqlite3_value{})))
  43292 	libc.Xmemcpy(tls, pNew, pOrig, uint32(uintptr(0)+20))
  43293 	*(*U16)(unsafe.Pointer(pNew + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Dyn))
  43294 	(*Sqlite3_value)(unsafe.Pointer(pNew)).Fdb = uintptr(0)
  43295 	if int32((*Sqlite3_value)(unsafe.Pointer(pNew)).Fflags)&(MEM_Str|MEM_Blob) != 0 {
  43296 		*(*U16)(unsafe.Pointer(pNew + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Static | MEM_Dyn))
  43297 		*(*U16)(unsafe.Pointer(pNew + 16)) |= U16(MEM_Ephem)
  43298 		if Xsqlite3VdbeMemMakeWriteable(tls, pNew) != SQLITE_OK {
  43299 			Xsqlite3ValueFree(tls, pNew)
  43300 			pNew = uintptr(0)
  43301 		}
  43302 	} else if int32((*Sqlite3_value)(unsafe.Pointer(pNew)).Fflags)&MEM_Null != 0 {
  43303 		*(*U16)(unsafe.Pointer(pNew + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Term | MEM_Subtype))
  43304 	}
  43305 	return pNew
  43306 }
  43307 
  43308 // Destroy an sqlite3_value object previously obtained from
  43309 // sqlite3_value_dup().
  43310 func Xsqlite3_value_free(tls *libc.TLS, pOld uintptr) {
  43311 	Xsqlite3ValueFree(tls, pOld)
  43312 }
  43313 
  43314 func setResultStrOrError(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, enc U8, xDel uintptr) {
  43315 	var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut
  43316 	var rc int32 = Xsqlite3VdbeMemSetStr(tls, pOut, z, int64(n), enc, xDel)
  43317 	if rc != 0 {
  43318 		if rc == SQLITE_TOOBIG {
  43319 			Xsqlite3_result_error_toobig(tls, pCtx)
  43320 		} else {
  43321 			Xsqlite3_result_error_nomem(tls, pCtx)
  43322 		}
  43323 		return
  43324 	}
  43325 	Xsqlite3VdbeChangeEncoding(tls, pOut, int32((*Sqlite3_context)(unsafe.Pointer(pCtx)).Fenc))
  43326 	if Xsqlite3VdbeMemTooBig(tls, pOut) != 0 {
  43327 		Xsqlite3_result_error_toobig(tls, pCtx)
  43328 	}
  43329 }
  43330 
  43331 func invokeValueDestructor(tls *libc.TLS, p uintptr, xDel uintptr, pCtx uintptr) int32 {
  43332 	if xDel == uintptr(0) {
  43333 	} else if xDel == libc.UintptrFromInt32(-1) {
  43334 	} else {
  43335 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDel})).f(tls, p)
  43336 	}
  43337 	Xsqlite3_result_error_toobig(tls, pCtx)
  43338 	return SQLITE_TOOBIG
  43339 }
  43340 
  43341 func Xsqlite3_result_blob(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) {
  43342 	setResultStrOrError(tls, pCtx, z, n, uint8(0), xDel)
  43343 }
  43344 
  43345 func Xsqlite3_result_blob64(tls *libc.TLS, pCtx uintptr, z uintptr, n Sqlite3_uint64, xDel uintptr) {
  43346 	if n > uint64(0x7fffffff) {
  43347 		invokeValueDestructor(tls, z, xDel, pCtx)
  43348 	} else {
  43349 		setResultStrOrError(tls, pCtx, z, int32(n), uint8(0), xDel)
  43350 	}
  43351 }
  43352 
  43353 func Xsqlite3_result_double(tls *libc.TLS, pCtx uintptr, rVal float64) {
  43354 	Xsqlite3VdbeMemSetDouble(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, rVal)
  43355 }
  43356 
  43357 func Xsqlite3_result_error(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) {
  43358 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_ERROR
  43359 	Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, int64(n), uint8(SQLITE_UTF8), libc.UintptrFromInt32(-1))
  43360 }
  43361 
  43362 func Xsqlite3_result_error16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) {
  43363 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_ERROR
  43364 	Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, int64(n), uint8(SQLITE_UTF16LE), libc.UintptrFromInt32(-1))
  43365 }
  43366 
  43367 func Xsqlite3_result_int(tls *libc.TLS, pCtx uintptr, iVal int32) {
  43368 	Xsqlite3VdbeMemSetInt64(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, I64(iVal))
  43369 }
  43370 
  43371 func Xsqlite3_result_int64(tls *libc.TLS, pCtx uintptr, iVal I64) {
  43372 	Xsqlite3VdbeMemSetInt64(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, iVal)
  43373 }
  43374 
  43375 func Xsqlite3_result_null(tls *libc.TLS, pCtx uintptr) {
  43376 	Xsqlite3VdbeMemSetNull(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)
  43377 }
  43378 
  43379 func Xsqlite3_result_pointer(tls *libc.TLS, pCtx uintptr, pPtr uintptr, zPType uintptr, xDestructor uintptr) {
  43380 	var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut
  43381 
  43382 	Xsqlite3VdbeMemRelease(tls, pOut)
  43383 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Null)
  43384 	Xsqlite3VdbeMemSetPointer(tls, pOut, pPtr, zPType, xDestructor)
  43385 }
  43386 
  43387 func Xsqlite3_result_subtype(tls *libc.TLS, pCtx uintptr, eSubtype uint32) {
  43388 	var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut
  43389 
  43390 	(*Mem)(unsafe.Pointer(pOut)).FeSubtype = U8(eSubtype & uint32(0xff))
  43391 	*(*U16)(unsafe.Pointer(pOut + 16)) |= U16(MEM_Subtype)
  43392 }
  43393 
  43394 func Xsqlite3_result_text(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) {
  43395 	setResultStrOrError(tls, pCtx, z, n, uint8(SQLITE_UTF8), xDel)
  43396 }
  43397 
  43398 func Xsqlite3_result_text64(tls *libc.TLS, pCtx uintptr, z uintptr, n Sqlite3_uint64, xDel uintptr, enc uint8) {
  43399 	if int32(enc) != SQLITE_UTF8 {
  43400 		if int32(enc) == SQLITE_UTF16 {
  43401 			enc = uint8(SQLITE_UTF16LE)
  43402 		}
  43403 		n = n & libc.CplUint64(uint64(1))
  43404 	}
  43405 	if n > uint64(0x7fffffff) {
  43406 		invokeValueDestructor(tls, z, xDel, pCtx)
  43407 	} else {
  43408 		setResultStrOrError(tls, pCtx, z, int32(n), enc, xDel)
  43409 	}
  43410 }
  43411 
  43412 func Xsqlite3_result_text16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) {
  43413 	setResultStrOrError(tls, pCtx, z, int32(U64(n)&libc.CplUint64(uint64(1))), uint8(SQLITE_UTF16LE), xDel)
  43414 }
  43415 
  43416 func Xsqlite3_result_text16be(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) {
  43417 	setResultStrOrError(tls, pCtx, z, int32(U64(n)&libc.CplUint64(uint64(1))), uint8(SQLITE_UTF16BE), xDel)
  43418 }
  43419 
  43420 func Xsqlite3_result_text16le(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) {
  43421 	setResultStrOrError(tls, pCtx, z, int32(U64(n)&libc.CplUint64(uint64(1))), uint8(SQLITE_UTF16LE), xDel)
  43422 }
  43423 
  43424 func Xsqlite3_result_value(tls *libc.TLS, pCtx uintptr, pValue uintptr) {
  43425 	var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut
  43426 
  43427 	Xsqlite3VdbeMemCopy(tls, pOut, pValue)
  43428 	Xsqlite3VdbeChangeEncoding(tls, pOut, int32((*Sqlite3_context)(unsafe.Pointer(pCtx)).Fenc))
  43429 	if Xsqlite3VdbeMemTooBig(tls, pOut) != 0 {
  43430 		Xsqlite3_result_error_toobig(tls, pCtx)
  43431 	}
  43432 }
  43433 
  43434 func Xsqlite3_result_zeroblob(tls *libc.TLS, pCtx uintptr, n int32) {
  43435 	Xsqlite3_result_zeroblob64(tls, pCtx, func() uint64 {
  43436 		if n > 0 {
  43437 			return uint64(n)
  43438 		}
  43439 		return uint64(0)
  43440 	}())
  43441 }
  43442 
  43443 func Xsqlite3_result_zeroblob64(tls *libc.TLS, pCtx uintptr, n U64) int32 {
  43444 	var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut
  43445 
  43446 	if n > U64(*(*int32)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fdb + 120))) {
  43447 		Xsqlite3_result_error_toobig(tls, pCtx)
  43448 		return SQLITE_TOOBIG
  43449 	}
  43450 	Xsqlite3VdbeMemSetZeroBlob(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, int32(n))
  43451 	return SQLITE_OK
  43452 }
  43453 
  43454 func Xsqlite3_result_error_code(tls *libc.TLS, pCtx uintptr, errCode int32) {
  43455 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = func() int32 {
  43456 		if errCode != 0 {
  43457 			return errCode
  43458 		}
  43459 		return -1
  43460 	}()
  43461 	if int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags)&MEM_Null != 0 {
  43462 		setResultStrOrError(tls, pCtx, Xsqlite3ErrStr(tls, errCode), -1, uint8(SQLITE_UTF8),
  43463 			uintptr(0))
  43464 	}
  43465 }
  43466 
  43467 // Force an SQLITE_TOOBIG error.
  43468 func Xsqlite3_result_error_toobig(tls *libc.TLS, pCtx uintptr) {
  43469 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_TOOBIG
  43470 	Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, ts+5334, int64(-1),
  43471 		uint8(SQLITE_UTF8), uintptr(0))
  43472 }
  43473 
  43474 // An SQLITE_NOMEM error.
  43475 func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) {
  43476 	Xsqlite3VdbeMemSetNull(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)
  43477 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_NOMEM
  43478 	Xsqlite3OomFault(tls, (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fdb)
  43479 }
  43480 
  43481 // Force the INT64 value currently stored as the result to be
  43482 // a MEM_IntReal value.  See the SQLITE_TESTCTRL_RESULT_INTREAL
  43483 // test-control.
  43484 func Xsqlite3ResultIntReal(tls *libc.TLS, pCtx uintptr) {
  43485 	if int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags)&MEM_Int != 0 {
  43486 		*(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int))
  43487 		*(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 16)) |= U16(MEM_IntReal)
  43488 	}
  43489 }
  43490 
  43491 func doWalCallbacks(tls *libc.TLS, db uintptr) int32 {
  43492 	var rc int32 = SQLITE_OK
  43493 	var i int32
  43494 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  43495 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  43496 		if pBt != 0 {
  43497 			var nEntry int32
  43498 			Xsqlite3BtreeEnter(tls, pBt)
  43499 			nEntry = Xsqlite3PagerWalCallback(tls, Xsqlite3BtreePager(tls, pBt))
  43500 			Xsqlite3BtreeLeave(tls, pBt)
  43501 			if nEntry > 0 && (*Sqlite3)(unsafe.Pointer(db)).FxWalCallback != 0 && rc == SQLITE_OK {
  43502 				rc = (*struct {
  43503 					f func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32
  43504 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxWalCallback})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpWalArg, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FzDbSName, nEntry)
  43505 			}
  43506 		}
  43507 	}
  43508 	return rc
  43509 }
  43510 
  43511 func sqlite3Step(tls *libc.TLS, p uintptr) int32 {
  43512 	var db uintptr
  43513 	var rc int32
  43514 
  43515 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  43516 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) != VDBE_RUN_STATE) {
  43517 		goto __1
  43518 	}
  43519 restart_step:
  43520 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) == VDBE_READY_STATE) {
  43521 		goto __2
  43522 	}
  43523 	if !(Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x3>>0)) != 0) {
  43524 		goto __4
  43525 	}
  43526 	(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_SCHEMA
  43527 	rc = SQLITE_ERROR
  43528 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags)&SQLITE_PREPARE_SAVESQL != 0) {
  43529 		goto __5
  43530 	}
  43531 
  43532 	rc = Xsqlite3VdbeTransferError(tls, p)
  43533 __5:
  43534 	;
  43535 	goto end_of_step
  43536 __4:
  43537 	;
  43538 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0) {
  43539 		goto __6
  43540 	}
  43541 	libc.AtomicStoreNInt32(db+312, int32(0), 0)
  43542 __6:
  43543 	;
  43544 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace)&(SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE) != 0 &&
  43545 		!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) && (*Vdbe)(unsafe.Pointer(p)).FzSql != 0) {
  43546 		goto __7
  43547 	}
  43548 	Xsqlite3OsCurrentTimeInt64(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, p+136)
  43549 	goto __8
  43550 __7:
  43551 	;
  43552 __8:
  43553 	;
  43554 	(*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive++
  43555 	if !(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x40>>6) == 0) {
  43556 		goto __9
  43557 	}
  43558 	(*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite++
  43559 __9:
  43560 	;
  43561 	if !(Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x80>>7)) != 0) {
  43562 		goto __10
  43563 	}
  43564 	(*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead++
  43565 __10:
  43566 	;
  43567 	(*Vdbe)(unsafe.Pointer(p)).Fpc = 0
  43568 	(*Vdbe)(unsafe.Pointer(p)).FeVdbeState = U8(VDBE_RUN_STATE)
  43569 	goto __3
  43570 __2:
  43571 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) == VDBE_HALT_STATE) {
  43572 		goto __11
  43573 	}
  43574 
  43575 	Xsqlite3_reset(tls, p)
  43576 
  43577 	goto restart_step
  43578 __11:
  43579 	;
  43580 __3:
  43581 	;
  43582 __1:
  43583 	;
  43584 	if !(Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0xc>>2)) != 0) {
  43585 		goto __12
  43586 	}
  43587 	rc = Xsqlite3VdbeList(tls, p)
  43588 	goto __13
  43589 __12:
  43590 	(*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec++
  43591 	rc = Xsqlite3VdbeExec(tls, p)
  43592 	(*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec--
  43593 __13:
  43594 	;
  43595 	if !(rc == SQLITE_ROW) {
  43596 		goto __14
  43597 	}
  43598 
  43599 	(*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_ROW
  43600 	return SQLITE_ROW
  43601 	goto __15
  43602 __14:
  43603 	if !((*Vdbe)(unsafe.Pointer(p)).FstartTime > int64(0)) {
  43604 		goto __16
  43605 	}
  43606 	invokeProfileCallback(tls, db, p)
  43607 __16:
  43608 	;
  43609 	(*Vdbe)(unsafe.Pointer(p)).FpResultRow = uintptr(0)
  43610 	if !(rc == SQLITE_DONE && (*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0) {
  43611 		goto __17
  43612 	}
  43613 
  43614 	(*Vdbe)(unsafe.Pointer(p)).Frc = doWalCallbacks(tls, db)
  43615 	if !((*Vdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK) {
  43616 		goto __19
  43617 	}
  43618 	rc = SQLITE_ERROR
  43619 __19:
  43620 	;
  43621 	goto __18
  43622 __17:
  43623 	if !(rc != SQLITE_DONE && int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags)&SQLITE_PREPARE_SAVESQL != 0) {
  43624 		goto __20
  43625 	}
  43626 
  43627 	rc = Xsqlite3VdbeTransferError(tls, p)
  43628 __20:
  43629 	;
  43630 __18:
  43631 	;
  43632 __15:
  43633 	;
  43634 	(*Sqlite3)(unsafe.Pointer(db)).FerrCode = rc
  43635 	if !(SQLITE_NOMEM == Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).Frc)) {
  43636 		goto __21
  43637 	}
  43638 	(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
  43639 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags)&SQLITE_PREPARE_SAVESQL != 0) {
  43640 		goto __22
  43641 	}
  43642 	rc = (*Vdbe)(unsafe.Pointer(p)).Frc
  43643 __22:
  43644 	;
  43645 __21:
  43646 	;
  43647 end_of_step:
  43648 	;
  43649 	return rc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask
  43650 }
  43651 
  43652 // This is the top-level implementation of sqlite3_step().  Call
  43653 // sqlite3Step() to do most of the work.  If a schema error occurs,
  43654 // call sqlite3Reprepare() and try again.
  43655 func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 {
  43656 	var rc int32 = SQLITE_OK
  43657 	var v uintptr = pStmt
  43658 	var cnt int32 = 0
  43659 	var db uintptr
  43660 
  43661 	if vdbeSafetyNotNull(tls, v) != 0 {
  43662 		return Xsqlite3MisuseError(tls, 88548)
  43663 	}
  43664 	db = (*Vdbe)(unsafe.Pointer(v)).Fdb
  43665 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  43666 	for libc.AssignInt32(&rc, sqlite3Step(tls, v)) == SQLITE_SCHEMA &&
  43667 		libc.PostIncInt32(&cnt, 1) < SQLITE_MAX_SCHEMA_RETRY {
  43668 		var savedPc int32 = (*Vdbe)(unsafe.Pointer(v)).Fpc
  43669 		rc = Xsqlite3Reprepare(tls, v)
  43670 		if rc != SQLITE_OK {
  43671 			var zErr uintptr = Xsqlite3_value_text(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
  43672 			Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(v)).FzErrMsg)
  43673 			if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  43674 				(*Vdbe)(unsafe.Pointer(v)).FzErrMsg = Xsqlite3DbStrDup(tls, db, zErr)
  43675 				(*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, Xsqlite3ApiExit(tls, db, rc))
  43676 			} else {
  43677 				(*Vdbe)(unsafe.Pointer(v)).FzErrMsg = uintptr(0)
  43678 				(*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, SQLITE_NOMEM)
  43679 			}
  43680 			break
  43681 		}
  43682 		Xsqlite3_reset(tls, pStmt)
  43683 		if savedPc >= 0 {
  43684 			(*Vdbe)(unsafe.Pointer(v)).FminWriteFileFormat = U8(254)
  43685 		}
  43686 
  43687 	}
  43688 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  43689 	return rc
  43690 }
  43691 
  43692 // Extract the user data from a sqlite3_context structure and return a
  43693 // pointer to it.
  43694 func Xsqlite3_user_data(tls *libc.TLS, p uintptr) uintptr {
  43695 	return (*FuncDef)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpFunc)).FpUserData
  43696 }
  43697 
  43698 // Extract the user data from a sqlite3_context structure and return a
  43699 // pointer to it.
  43700 //
  43701 // IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface
  43702 // returns a copy of the pointer to the database connection (the 1st
  43703 // parameter) of the sqlite3_create_function() and
  43704 // sqlite3_create_function16() routines that originally registered the
  43705 // application defined function.
  43706 func Xsqlite3_context_db_handle(tls *libc.TLS, p uintptr) uintptr {
  43707 	return (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpOut)).Fdb
  43708 }
  43709 
  43710 // If this routine is invoked from within an xColumn method of a virtual
  43711 // table, then it returns true if and only if the the call is during an
  43712 // UPDATE operation and the value of the column will not be modified
  43713 // by the UPDATE.
  43714 //
  43715 // If this routine is called from any context other than within the
  43716 // xColumn method of a virtual table, then the return value is meaningless
  43717 // and arbitrary.
  43718 //
  43719 // Virtual table implements might use this routine to optimize their
  43720 // performance by substituting a NULL result, or some other light-weight
  43721 // value, as a signal to the xUpdate routine that the column is unchanged.
  43722 func Xsqlite3_vtab_nochange(tls *libc.TLS, p uintptr) int32 {
  43723 	return Xsqlite3_value_nochange(tls, (*Sqlite3_context)(unsafe.Pointer(p)).FpOut)
  43724 }
  43725 
  43726 // The destructor function for a ValueList object.  This needs to be
  43727 // a separate function, unknowable to the application, to ensure that
  43728 // calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not
  43729 // preceeded by activation of IN processing via sqlite3_vtab_int() do not
  43730 // try to access a fake ValueList object inserted by a hostile extension.
  43731 func Xsqlite3VdbeValueListFree(tls *libc.TLS, pToDelete uintptr) {
  43732 	Xsqlite3_free(tls, pToDelete)
  43733 }
  43734 
  43735 func valueFromValueList(tls *libc.TLS, pVal uintptr, ppOut uintptr, bNext int32) int32 {
  43736 	bp := tls.Alloc(52)
  43737 	defer tls.Free(52)
  43738 
  43739 	var rc int32
  43740 	var pRhs uintptr
  43741 
  43742 	*(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0)
  43743 	if pVal == uintptr(0) {
  43744 		return SQLITE_MISUSE
  43745 	}
  43746 	if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags)&MEM_Dyn == 0 || (*Sqlite3_value)(unsafe.Pointer(pVal)).FxDel != *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3VdbeValueListFree})) {
  43747 		return SQLITE_ERROR
  43748 	} else {
  43749 		pRhs = (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz
  43750 	}
  43751 	if bNext != 0 {
  43752 		rc = Xsqlite3BtreeNext(tls, (*ValueList)(unsafe.Pointer(pRhs)).FpCsr, 0)
  43753 	} else {
  43754 		*(*int32)(unsafe.Pointer(bp)) = 0
  43755 		rc = Xsqlite3BtreeFirst(tls, (*ValueList)(unsafe.Pointer(pRhs)).FpCsr, bp)
  43756 
  43757 		if Xsqlite3BtreeEof(tls, (*ValueList)(unsafe.Pointer(pRhs)).FpCsr) != 0 {
  43758 			rc = SQLITE_DONE
  43759 		}
  43760 	}
  43761 	if rc == SQLITE_OK {
  43762 		var sz U32
  43763 
  43764 		libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(Mem{})))
  43765 		sz = Xsqlite3BtreePayloadSize(tls, (*ValueList)(unsafe.Pointer(pRhs)).FpCsr)
  43766 		rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, (*ValueList)(unsafe.Pointer(pRhs)).FpCsr, uint32(int32(sz)), bp+8)
  43767 		if rc == SQLITE_OK {
  43768 			var zBuf uintptr = (*Mem)(unsafe.Pointer(bp + 8)).Fz
  43769 
  43770 			var pOut uintptr = (*ValueList)(unsafe.Pointer(pRhs)).FpOut
  43771 			var iOff int32 = 1 + int32(func() uint8 {
  43772 				if int32(*(*U8)(unsafe.Pointer(zBuf + 1))) < int32(U8(0x80)) {
  43773 					return uint8(func() int32 { *(*U32)(unsafe.Pointer(bp + 48)) = U32(*(*U8)(unsafe.Pointer(zBuf + 1))); return 1 }())
  43774 				}
  43775 				return Xsqlite3GetVarint32(tls, zBuf+1, bp+48)
  43776 			}())
  43777 			Xsqlite3VdbeSerialGet(tls, zBuf+uintptr(iOff), *(*U32)(unsafe.Pointer(bp + 48)), pOut)
  43778 			(*Sqlite3_value)(unsafe.Pointer(pOut)).Fenc = (*Sqlite3)(unsafe.Pointer((*Sqlite3_value)(unsafe.Pointer(pOut)).Fdb)).Fenc
  43779 			if int32((*Sqlite3_value)(unsafe.Pointer(pOut)).Fflags)&MEM_Ephem != 0 && Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0 {
  43780 				rc = SQLITE_NOMEM
  43781 			} else {
  43782 				*(*uintptr)(unsafe.Pointer(ppOut)) = pOut
  43783 			}
  43784 		}
  43785 		Xsqlite3VdbeMemRelease(tls, bp+8)
  43786 	}
  43787 	return rc
  43788 }
  43789 
  43790 // Set the iterator value pVal to point to the first value in the set.
  43791 // Set (*ppOut) to point to this value before returning.
  43792 func Xsqlite3_vtab_in_first(tls *libc.TLS, pVal uintptr, ppOut uintptr) int32 {
  43793 	return valueFromValueList(tls, pVal, ppOut, 0)
  43794 }
  43795 
  43796 // Set the iterator value pVal to point to the next value in the set.
  43797 // Set (*ppOut) to point to this value before returning.
  43798 func Xsqlite3_vtab_in_next(tls *libc.TLS, pVal uintptr, ppOut uintptr) int32 {
  43799 	return valueFromValueList(tls, pVal, ppOut, 1)
  43800 }
  43801 
  43802 // Return the current time for a statement.  If the current time
  43803 // is requested more than once within the same run of a single prepared
  43804 // statement, the exact same time is returned for each invocation regardless
  43805 // of the amount of time that elapses between invocations.  In other words,
  43806 // the time returned is always the time of the first call.
  43807 func Xsqlite3StmtCurrentTime(tls *libc.TLS, p uintptr) Sqlite3_int64 {
  43808 	bp := tls.Alloc(8)
  43809 	defer tls.Free(8)
  43810 
  43811 	var rc int32
  43812 	*(*Sqlite3_int64)(unsafe.Pointer(bp)) = int64(0)
  43813 	var piTime uintptr
  43814 	if (*Sqlite3_context)(unsafe.Pointer(p)).FpVdbe != uintptr(0) {
  43815 		piTime = (*Sqlite3_context)(unsafe.Pointer(p)).FpVdbe + 56
  43816 	} else {
  43817 		piTime = bp
  43818 	}
  43819 	if *(*Sqlite3_int64)(unsafe.Pointer(piTime)) == int64(0) {
  43820 		rc = Xsqlite3OsCurrentTimeInt64(tls, (*Sqlite3)(unsafe.Pointer((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpOut)).Fdb)).FpVfs, piTime)
  43821 		if rc != 0 {
  43822 			*(*Sqlite3_int64)(unsafe.Pointer(piTime)) = int64(0)
  43823 		}
  43824 	}
  43825 	return *(*Sqlite3_int64)(unsafe.Pointer(piTime))
  43826 }
  43827 
  43828 func createAggContext(tls *libc.TLS, p uintptr, nByte int32) uintptr {
  43829 	var pMem uintptr = (*Sqlite3_context)(unsafe.Pointer(p)).FpMem
  43830 
  43831 	if nByte <= 0 {
  43832 		Xsqlite3VdbeMemSetNull(tls, pMem)
  43833 		(*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0)
  43834 	} else {
  43835 		Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte)
  43836 		(*Mem)(unsafe.Pointer(pMem)).Fflags = U16(MEM_Agg)
  43837 		*(*uintptr)(unsafe.Pointer(pMem)) = (*Sqlite3_context)(unsafe.Pointer(p)).FpFunc
  43838 		if (*Mem)(unsafe.Pointer(pMem)).Fz != 0 {
  43839 			libc.Xmemset(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, 0, uint32(nByte))
  43840 		}
  43841 	}
  43842 	return (*Mem)(unsafe.Pointer(pMem)).Fz
  43843 }
  43844 
  43845 // Allocate or return the aggregate context for a user function.  A new
  43846 // context is allocated on the first call.  Subsequent calls return the
  43847 // same context that was returned on prior calls.
  43848 func Xsqlite3_aggregate_context(tls *libc.TLS, p uintptr, nByte int32) uintptr {
  43849 	if int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fflags)&MEM_Agg == 0 {
  43850 		return createAggContext(tls, p, nByte)
  43851 	} else {
  43852 		return (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fz
  43853 	}
  43854 	return uintptr(0)
  43855 }
  43856 
  43857 // Return the auxiliary data pointer, if any, for the iArg'th argument to
  43858 // the user-function defined by pCtx.
  43859 //
  43860 // The left-most argument is 0.
  43861 //
  43862 // Undocumented behavior:  If iArg is negative then access a cache of
  43863 // auxiliary data pointers that is available to all functions within a
  43864 // single prepared statement.  The iArg values must match.
  43865 func Xsqlite3_get_auxdata(tls *libc.TLS, pCtx uintptr, iArg int32) uintptr {
  43866 	var pAuxData uintptr
  43867 
  43868 	if (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe == uintptr(0) {
  43869 		return uintptr(0)
  43870 	}
  43871 	for pAuxData = (*Vdbe)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FpAuxData; pAuxData != 0; pAuxData = (*AuxData)(unsafe.Pointer(pAuxData)).FpNextAux {
  43872 		if (*AuxData)(unsafe.Pointer(pAuxData)).FiAuxArg == iArg && ((*AuxData)(unsafe.Pointer(pAuxData)).FiAuxOp == (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp || iArg < 0) {
  43873 			return (*AuxData)(unsafe.Pointer(pAuxData)).FpAux
  43874 		}
  43875 	}
  43876 	return uintptr(0)
  43877 }
  43878 
  43879 // Set the auxiliary data pointer and delete function, for the iArg'th
  43880 // argument to the user-function defined by pCtx. Any previous value is
  43881 // deleted by calling the delete function specified when it was set.
  43882 //
  43883 // The left-most argument is 0.
  43884 //
  43885 // Undocumented behavior:  If iArg is negative then make the data available
  43886 // to all functions within the current prepared statement using iArg as an
  43887 // access code.
  43888 func Xsqlite3_set_auxdata(tls *libc.TLS, pCtx uintptr, iArg int32, pAux uintptr, xDelete uintptr) {
  43889 	var pAuxData uintptr
  43890 	var pVdbe uintptr
  43891 	pVdbe = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe
  43892 
  43893 	if !(pVdbe == uintptr(0)) {
  43894 		goto __1
  43895 	}
  43896 	goto failed
  43897 __1:
  43898 	;
  43899 	pAuxData = (*Vdbe)(unsafe.Pointer(pVdbe)).FpAuxData
  43900 __2:
  43901 	if !(pAuxData != 0) {
  43902 		goto __4
  43903 	}
  43904 	if !((*AuxData)(unsafe.Pointer(pAuxData)).FiAuxArg == iArg && ((*AuxData)(unsafe.Pointer(pAuxData)).FiAuxOp == (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp || iArg < 0)) {
  43905 		goto __5
  43906 	}
  43907 	goto __4
  43908 __5:
  43909 	;
  43910 	goto __3
  43911 __3:
  43912 	pAuxData = (*AuxData)(unsafe.Pointer(pAuxData)).FpNextAux
  43913 	goto __2
  43914 	goto __4
  43915 __4:
  43916 	;
  43917 	if !(pAuxData == uintptr(0)) {
  43918 		goto __6
  43919 	}
  43920 	pAuxData = Xsqlite3DbMallocZero(tls, (*Vdbe)(unsafe.Pointer(pVdbe)).Fdb, uint64(unsafe.Sizeof(AuxData{})))
  43921 	if !!(pAuxData != 0) {
  43922 		goto __8
  43923 	}
  43924 	goto failed
  43925 __8:
  43926 	;
  43927 	(*AuxData)(unsafe.Pointer(pAuxData)).FiAuxOp = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp
  43928 	(*AuxData)(unsafe.Pointer(pAuxData)).FiAuxArg = iArg
  43929 	(*AuxData)(unsafe.Pointer(pAuxData)).FpNextAux = (*Vdbe)(unsafe.Pointer(pVdbe)).FpAuxData
  43930 	(*Vdbe)(unsafe.Pointer(pVdbe)).FpAuxData = pAuxData
  43931 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError == 0) {
  43932 		goto __9
  43933 	}
  43934 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = -1
  43935 __9:
  43936 	;
  43937 	goto __7
  43938 __6:
  43939 	if !((*AuxData)(unsafe.Pointer(pAuxData)).FxDeleteAux != 0) {
  43940 		goto __10
  43941 	}
  43942 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*AuxData)(unsafe.Pointer(pAuxData)).FxDeleteAux})).f(tls, (*AuxData)(unsafe.Pointer(pAuxData)).FpAux)
  43943 __10:
  43944 	;
  43945 __7:
  43946 	;
  43947 	(*AuxData)(unsafe.Pointer(pAuxData)).FpAux = pAux
  43948 	(*AuxData)(unsafe.Pointer(pAuxData)).FxDeleteAux = xDelete
  43949 	return
  43950 
  43951 failed:
  43952 	if !(xDelete != 0) {
  43953 		goto __11
  43954 	}
  43955 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDelete})).f(tls, pAux)
  43956 __11:
  43957 }
  43958 
  43959 // Return the number of times the Step function of an aggregate has been
  43960 // called.
  43961 //
  43962 // This function is deprecated.  Do not use it for new code.  It is
  43963 // provide only to avoid breaking legacy code.  New aggregate function
  43964 // implementations should keep their own counts within their aggregate
  43965 // context.
  43966 func Xsqlite3_aggregate_count(tls *libc.TLS, p uintptr) int32 {
  43967 	return (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fn
  43968 }
  43969 
  43970 // Return the number of columns in the result set for the statement pStmt.
  43971 func Xsqlite3_column_count(tls *libc.TLS, pStmt uintptr) int32 {
  43972 	var pVm uintptr = pStmt
  43973 	if pVm != 0 {
  43974 		return int32((*Vdbe)(unsafe.Pointer(pVm)).FnResColumn)
  43975 	}
  43976 	return 0
  43977 }
  43978 
  43979 // Return the number of values available from the current row of the
  43980 // currently executing statement pStmt.
  43981 func Xsqlite3_data_count(tls *libc.TLS, pStmt uintptr) int32 {
  43982 	var pVm uintptr = pStmt
  43983 	if pVm == uintptr(0) || (*Vdbe)(unsafe.Pointer(pVm)).FpResultRow == uintptr(0) {
  43984 		return 0
  43985 	}
  43986 	return int32((*Vdbe)(unsafe.Pointer(pVm)).FnResColumn)
  43987 }
  43988 
  43989 func columnNullValue(tls *libc.TLS) uintptr {
  43990 	return uintptr(unsafe.Pointer(&nullMem))
  43991 }
  43992 
  43993 var nullMem = Mem{
  43994 	Fflags: U16(MEM_Null),
  43995 }
  43996 
  43997 func columnMem(tls *libc.TLS, pStmt uintptr, i int32) uintptr {
  43998 	var pVm uintptr
  43999 	var pOut uintptr
  44000 
  44001 	pVm = pStmt
  44002 	if pVm == uintptr(0) {
  44003 		return columnNullValue(tls)
  44004 	}
  44005 
  44006 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pVm)).Fdb)).Fmutex)
  44007 	if (*Vdbe)(unsafe.Pointer(pVm)).FpResultRow != uintptr(0) && i < int32((*Vdbe)(unsafe.Pointer(pVm)).FnResColumn) && i >= 0 {
  44008 		pOut = (*Vdbe)(unsafe.Pointer(pVm)).FpResultRow + uintptr(i)*40
  44009 	} else {
  44010 		Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(pVm)).Fdb, SQLITE_RANGE)
  44011 		pOut = columnNullValue(tls)
  44012 	}
  44013 	return pOut
  44014 }
  44015 
  44016 func columnMallocFailure(tls *libc.TLS, pStmt uintptr) {
  44017 	var p uintptr = pStmt
  44018 	if p != 0 {
  44019 		(*Vdbe)(unsafe.Pointer(p)).Frc = Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).Frc)
  44020 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44021 	}
  44022 }
  44023 
  44024 // *************************** sqlite3_column_  *******************************
  44025 //
  44026 // The following routines are used to access elements of the current row
  44027 // in the result set.
  44028 func Xsqlite3_column_blob(tls *libc.TLS, pStmt uintptr, i int32) uintptr {
  44029 	var val uintptr
  44030 	val = Xsqlite3_value_blob(tls, columnMem(tls, pStmt, i))
  44031 
  44032 	columnMallocFailure(tls, pStmt)
  44033 	return val
  44034 }
  44035 
  44036 func Xsqlite3_column_bytes(tls *libc.TLS, pStmt uintptr, i int32) int32 {
  44037 	var val int32 = Xsqlite3_value_bytes(tls, columnMem(tls, pStmt, i))
  44038 	columnMallocFailure(tls, pStmt)
  44039 	return val
  44040 }
  44041 
  44042 func Xsqlite3_column_bytes16(tls *libc.TLS, pStmt uintptr, i int32) int32 {
  44043 	var val int32 = Xsqlite3_value_bytes16(tls, columnMem(tls, pStmt, i))
  44044 	columnMallocFailure(tls, pStmt)
  44045 	return val
  44046 }
  44047 
  44048 func Xsqlite3_column_double(tls *libc.TLS, pStmt uintptr, i int32) float64 {
  44049 	var val float64 = Xsqlite3_value_double(tls, columnMem(tls, pStmt, i))
  44050 	columnMallocFailure(tls, pStmt)
  44051 	return val
  44052 }
  44053 
  44054 func Xsqlite3_column_int(tls *libc.TLS, pStmt uintptr, i int32) int32 {
  44055 	var val int32 = Xsqlite3_value_int(tls, columnMem(tls, pStmt, i))
  44056 	columnMallocFailure(tls, pStmt)
  44057 	return val
  44058 }
  44059 
  44060 func Xsqlite3_column_int64(tls *libc.TLS, pStmt uintptr, i int32) Sqlite_int64 {
  44061 	var val Sqlite_int64 = Xsqlite3_value_int64(tls, columnMem(tls, pStmt, i))
  44062 	columnMallocFailure(tls, pStmt)
  44063 	return val
  44064 }
  44065 
  44066 func Xsqlite3_column_text(tls *libc.TLS, pStmt uintptr, i int32) uintptr {
  44067 	var val uintptr = Xsqlite3_value_text(tls, columnMem(tls, pStmt, i))
  44068 	columnMallocFailure(tls, pStmt)
  44069 	return val
  44070 }
  44071 
  44072 func Xsqlite3_column_value(tls *libc.TLS, pStmt uintptr, i int32) uintptr {
  44073 	var pOut uintptr = columnMem(tls, pStmt, i)
  44074 	if int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&MEM_Static != 0 {
  44075 		*(*U16)(unsafe.Pointer(pOut + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Static))
  44076 		*(*U16)(unsafe.Pointer(pOut + 16)) |= U16(MEM_Ephem)
  44077 	}
  44078 	columnMallocFailure(tls, pStmt)
  44079 	return pOut
  44080 }
  44081 
  44082 func Xsqlite3_column_text16(tls *libc.TLS, pStmt uintptr, i int32) uintptr {
  44083 	var val uintptr = Xsqlite3_value_text16(tls, columnMem(tls, pStmt, i))
  44084 	columnMallocFailure(tls, pStmt)
  44085 	return val
  44086 }
  44087 
  44088 func Xsqlite3_column_type(tls *libc.TLS, pStmt uintptr, i int32) int32 {
  44089 	var iType int32 = Xsqlite3_value_type(tls, columnMem(tls, pStmt, i))
  44090 	columnMallocFailure(tls, pStmt)
  44091 	return iType
  44092 }
  44093 
  44094 func columnName(tls *libc.TLS, pStmt uintptr, N int32, useUtf16 int32, useType int32) uintptr {
  44095 	var ret uintptr
  44096 	var p uintptr
  44097 	var n int32
  44098 	var db uintptr
  44099 	ret = uintptr(0)
  44100 	p = pStmt
  44101 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  44102 
  44103 	n = Xsqlite3_column_count(tls, pStmt)
  44104 	if N < n && N >= 0 {
  44105 		N = N + useType*n
  44106 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  44107 
  44108 		if useUtf16 != 0 {
  44109 			ret = Xsqlite3_value_text16(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName+uintptr(N)*40)
  44110 		} else {
  44111 			ret = Xsqlite3_value_text(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName+uintptr(N)*40)
  44112 		}
  44113 
  44114 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  44115 			Xsqlite3OomClear(tls, db)
  44116 			ret = uintptr(0)
  44117 		}
  44118 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  44119 	}
  44120 	return ret
  44121 }
  44122 
  44123 // Return the name of the Nth column of the result set returned by SQL
  44124 // statement pStmt.
  44125 func Xsqlite3_column_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44126 	return columnName(tls, pStmt, N, 0, COLNAME_NAME)
  44127 }
  44128 
  44129 func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44130 	return columnName(tls, pStmt, N, 1, COLNAME_NAME)
  44131 }
  44132 
  44133 // Return the column declaration type (if applicable) of the 'i'th column
  44134 // of the result set of SQL statement pStmt.
  44135 func Xsqlite3_column_decltype(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44136 	return columnName(tls, pStmt, N, 0, COLNAME_DECLTYPE)
  44137 }
  44138 
  44139 func Xsqlite3_column_decltype16(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44140 	return columnName(tls, pStmt, N, 1, COLNAME_DECLTYPE)
  44141 }
  44142 
  44143 // Return the name of the database from which a result column derives.
  44144 // NULL is returned if the result column is an expression or constant or
  44145 // anything else which is not an unambiguous reference to a database column.
  44146 func Xsqlite3_column_database_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44147 	return columnName(tls, pStmt, N, 0, COLNAME_DATABASE)
  44148 }
  44149 
  44150 func Xsqlite3_column_database_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44151 	return columnName(tls, pStmt, N, 1, COLNAME_DATABASE)
  44152 }
  44153 
  44154 // Return the name of the table from which a result column derives.
  44155 // NULL is returned if the result column is an expression or constant or
  44156 // anything else which is not an unambiguous reference to a database column.
  44157 func Xsqlite3_column_table_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44158 	return columnName(tls, pStmt, N, 0, COLNAME_TABLE)
  44159 }
  44160 
  44161 func Xsqlite3_column_table_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44162 	return columnName(tls, pStmt, N, 1, COLNAME_TABLE)
  44163 }
  44164 
  44165 // Return the name of the table column from which a result column derives.
  44166 // NULL is returned if the result column is an expression or constant or
  44167 // anything else which is not an unambiguous reference to a database column.
  44168 func Xsqlite3_column_origin_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44169 	return columnName(tls, pStmt, N, 0, COLNAME_COLUMN)
  44170 }
  44171 
  44172 func Xsqlite3_column_origin_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr {
  44173 	return columnName(tls, pStmt, N, 1, COLNAME_COLUMN)
  44174 }
  44175 
  44176 func vdbeUnbind(tls *libc.TLS, p uintptr, i uint32) int32 {
  44177 	bp := tls.Alloc(8)
  44178 	defer tls.Free(8)
  44179 
  44180 	var pVar uintptr
  44181 	if vdbeSafetyNotNull(tls, p) != 0 {
  44182 		return Xsqlite3MisuseError(tls, 89212)
  44183 	}
  44184 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44185 	if int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) != VDBE_READY_STATE {
  44186 		Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, SQLITE_MISUSE)
  44187 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44188 		Xsqlite3_log(tls, SQLITE_MISUSE,
  44189 			ts+5357, libc.VaList(bp, (*Vdbe)(unsafe.Pointer(p)).FzSql))
  44190 		return Xsqlite3MisuseError(tls, 89220)
  44191 	}
  44192 	if i >= uint32((*Vdbe)(unsafe.Pointer(p)).FnVar) {
  44193 		Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, SQLITE_RANGE)
  44194 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44195 		return SQLITE_RANGE
  44196 	}
  44197 	pVar = (*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*40
  44198 	Xsqlite3VdbeMemRelease(tls, pVar)
  44199 	(*Mem)(unsafe.Pointer(pVar)).Fflags = U16(MEM_Null)
  44200 	(*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = SQLITE_OK
  44201 
  44202 	if (*Vdbe)(unsafe.Pointer(p)).Fexpmask != U32(0) && (*Vdbe)(unsafe.Pointer(p)).Fexpmask&func() uint32 {
  44203 		if i >= uint32(31) {
  44204 			return 0x80000000
  44205 		}
  44206 		return U32(1) << i
  44207 	}() != U32(0) {
  44208 		libc.SetBitFieldPtr8Uint32(p+152, Bft(1), 0, 0x3)
  44209 	}
  44210 	return SQLITE_OK
  44211 }
  44212 
  44213 func bindText(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData I64, xDel uintptr, encoding U8) int32 {
  44214 	var p uintptr = pStmt
  44215 	var pVar uintptr
  44216 	var rc int32
  44217 
  44218 	rc = vdbeUnbind(tls, p, U32(i-1))
  44219 	if rc == SQLITE_OK {
  44220 		if zData != uintptr(0) {
  44221 			pVar = (*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i-1)*40
  44222 			rc = Xsqlite3VdbeMemSetStr(tls, pVar, zData, nData, encoding, xDel)
  44223 			if rc == SQLITE_OK && int32(encoding) != 0 {
  44224 				rc = Xsqlite3VdbeChangeEncoding(tls, pVar, int32((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fenc))
  44225 			}
  44226 			if rc != 0 {
  44227 				Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, rc)
  44228 				rc = Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, rc)
  44229 			}
  44230 		}
  44231 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44232 	} else if xDel != uintptr(0) && xDel != libc.UintptrFromInt32(-1) {
  44233 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDel})).f(tls, zData)
  44234 	}
  44235 	return rc
  44236 }
  44237 
  44238 // Bind a blob value to an SQL statement variable.
  44239 func Xsqlite3_bind_blob(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, xDel uintptr) int32 {
  44240 	return bindText(tls, pStmt, i, zData, int64(nData), xDel, uint8(0))
  44241 }
  44242 
  44243 func Xsqlite3_bind_blob64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Sqlite3_uint64, xDel uintptr) int32 {
  44244 	return bindText(tls, pStmt, i, zData, int64(nData), xDel, uint8(0))
  44245 }
  44246 
  44247 func Xsqlite3_bind_double(tls *libc.TLS, pStmt uintptr, i int32, rValue float64) int32 {
  44248 	var rc int32
  44249 	var p uintptr = pStmt
  44250 	rc = vdbeUnbind(tls, p, U32(i-1))
  44251 	if rc == SQLITE_OK {
  44252 		Xsqlite3VdbeMemSetDouble(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar+uintptr(i-1)*40, rValue)
  44253 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44254 	}
  44255 	return rc
  44256 }
  44257 
  44258 func Xsqlite3_bind_int(tls *libc.TLS, p uintptr, i int32, iValue int32) int32 {
  44259 	return Xsqlite3_bind_int64(tls, p, i, I64(iValue))
  44260 }
  44261 
  44262 func Xsqlite3_bind_int64(tls *libc.TLS, pStmt uintptr, i int32, iValue Sqlite_int64) int32 {
  44263 	var rc int32
  44264 	var p uintptr = pStmt
  44265 	rc = vdbeUnbind(tls, p, U32(i-1))
  44266 	if rc == SQLITE_OK {
  44267 		Xsqlite3VdbeMemSetInt64(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar+uintptr(i-1)*40, iValue)
  44268 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44269 	}
  44270 	return rc
  44271 }
  44272 
  44273 func Xsqlite3_bind_null(tls *libc.TLS, pStmt uintptr, i int32) int32 {
  44274 	var rc int32
  44275 	var p uintptr = pStmt
  44276 	rc = vdbeUnbind(tls, p, U32(i-1))
  44277 	if rc == SQLITE_OK {
  44278 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44279 	}
  44280 	return rc
  44281 }
  44282 
  44283 func Xsqlite3_bind_pointer(tls *libc.TLS, pStmt uintptr, i int32, pPtr uintptr, zPTtype uintptr, xDestructor uintptr) int32 {
  44284 	var rc int32
  44285 	var p uintptr = pStmt
  44286 	rc = vdbeUnbind(tls, p, U32(i-1))
  44287 	if rc == SQLITE_OK {
  44288 		Xsqlite3VdbeMemSetPointer(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar+uintptr(i-1)*40, pPtr, zPTtype, xDestructor)
  44289 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44290 	} else if xDestructor != 0 {
  44291 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDestructor})).f(tls, pPtr)
  44292 	}
  44293 	return rc
  44294 }
  44295 
  44296 func Xsqlite3_bind_text(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, xDel uintptr) int32 {
  44297 	return bindText(tls, pStmt, i, zData, int64(nData), xDel, uint8(SQLITE_UTF8))
  44298 }
  44299 
  44300 func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Sqlite3_uint64, xDel uintptr, enc uint8) int32 {
  44301 	if int32(enc) != SQLITE_UTF8 {
  44302 		if int32(enc) == SQLITE_UTF16 {
  44303 			enc = uint8(SQLITE_UTF16LE)
  44304 		}
  44305 		nData = nData & libc.Uint64FromInt32(libc.CplInt32(int32(U16(1))))
  44306 	}
  44307 	return bindText(tls, pStmt, i, zData, int64(nData), xDel, enc)
  44308 }
  44309 
  44310 func Xsqlite3_bind_text16(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, n int32, xDel uintptr) int32 {
  44311 	return bindText(tls, pStmt, i, zData, int64(U64(n)&libc.CplUint64(uint64(1))), xDel, uint8(SQLITE_UTF16LE))
  44312 }
  44313 
  44314 func Xsqlite3_bind_value(tls *libc.TLS, pStmt uintptr, i int32, pValue uintptr) int32 {
  44315 	var rc int32
  44316 	switch Xsqlite3_value_type(tls, pValue) {
  44317 	case SQLITE_INTEGER:
  44318 		{
  44319 			rc = Xsqlite3_bind_int64(tls, pStmt, i, *(*I64)(unsafe.Pointer(pValue)))
  44320 			break
  44321 
  44322 		}
  44323 	case SQLITE_FLOAT:
  44324 		{
  44325 			rc = Xsqlite3_bind_double(tls, pStmt, i,
  44326 				func() float64 {
  44327 					if int32((*Sqlite3_value)(unsafe.Pointer(pValue)).Fflags)&MEM_Real != 0 {
  44328 						return *(*float64)(unsafe.Pointer(pValue))
  44329 					}
  44330 					return float64(*(*I64)(unsafe.Pointer(pValue)))
  44331 				}())
  44332 			break
  44333 
  44334 		}
  44335 	case SQLITE_BLOB:
  44336 		{
  44337 			if int32((*Sqlite3_value)(unsafe.Pointer(pValue)).Fflags)&MEM_Zero != 0 {
  44338 				rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, *(*int32)(unsafe.Pointer(pValue)))
  44339 			} else {
  44340 				rc = Xsqlite3_bind_blob(tls, pStmt, i, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fz, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fn, libc.UintptrFromInt32(-1))
  44341 			}
  44342 			break
  44343 
  44344 		}
  44345 	case SQLITE_TEXT:
  44346 		{
  44347 			rc = bindText(tls, pStmt, i, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fz, int64((*Sqlite3_value)(unsafe.Pointer(pValue)).Fn), libc.UintptrFromInt32(-1),
  44348 				(*Sqlite3_value)(unsafe.Pointer(pValue)).Fenc)
  44349 			break
  44350 
  44351 		}
  44352 	default:
  44353 		{
  44354 			rc = Xsqlite3_bind_null(tls, pStmt, i)
  44355 			break
  44356 
  44357 		}
  44358 	}
  44359 	return rc
  44360 }
  44361 
  44362 func Xsqlite3_bind_zeroblob(tls *libc.TLS, pStmt uintptr, i int32, n int32) int32 {
  44363 	var rc int32
  44364 	var p uintptr = pStmt
  44365 	rc = vdbeUnbind(tls, p, U32(i-1))
  44366 	if rc == SQLITE_OK {
  44367 		Xsqlite3VdbeMemSetZeroBlob(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar+uintptr(i-1)*40, n)
  44368 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44369 	}
  44370 	return rc
  44371 }
  44372 
  44373 func Xsqlite3_bind_zeroblob64(tls *libc.TLS, pStmt uintptr, i int32, n Sqlite3_uint64) int32 {
  44374 	var rc int32
  44375 	var p uintptr = pStmt
  44376 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44377 	if n > U64(*(*int32)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb + 120))) {
  44378 		rc = SQLITE_TOOBIG
  44379 	} else {
  44380 		rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, int32(n))
  44381 	}
  44382 	rc = Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, rc)
  44383 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44384 	return rc
  44385 }
  44386 
  44387 // Return the number of wildcards that can be potentially bound to.
  44388 // This routine is added to support DBD::SQLite.
  44389 func Xsqlite3_bind_parameter_count(tls *libc.TLS, pStmt uintptr) int32 {
  44390 	var p uintptr = pStmt
  44391 	if p != 0 {
  44392 		return int32((*Vdbe)(unsafe.Pointer(p)).FnVar)
  44393 	}
  44394 	return 0
  44395 }
  44396 
  44397 // Return the name of a wildcard parameter.  Return NULL if the index
  44398 // is out of range or if the wildcard is unnamed.
  44399 //
  44400 // The result is always UTF-8.
  44401 func Xsqlite3_bind_parameter_name(tls *libc.TLS, pStmt uintptr, i int32) uintptr {
  44402 	var p uintptr = pStmt
  44403 	if p == uintptr(0) {
  44404 		return uintptr(0)
  44405 	}
  44406 	return Xsqlite3VListNumToName(tls, (*Vdbe)(unsafe.Pointer(p)).FpVList, i)
  44407 }
  44408 
  44409 // Given a wildcard parameter name, return the index of the variable
  44410 // with that name.  If there is no variable with the given name,
  44411 // return 0.
  44412 func Xsqlite3VdbeParameterIndex(tls *libc.TLS, p uintptr, zName uintptr, nName int32) int32 {
  44413 	if p == uintptr(0) || zName == uintptr(0) {
  44414 		return 0
  44415 	}
  44416 	return Xsqlite3VListNameToNum(tls, (*Vdbe)(unsafe.Pointer(p)).FpVList, zName, nName)
  44417 }
  44418 
  44419 func Xsqlite3_bind_parameter_index(tls *libc.TLS, pStmt uintptr, zName uintptr) int32 {
  44420 	return Xsqlite3VdbeParameterIndex(tls, pStmt, zName, Xsqlite3Strlen30(tls, zName))
  44421 }
  44422 
  44423 // Transfer all bindings from the first statement over to the second.
  44424 func Xsqlite3TransferBindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintptr) int32 {
  44425 	var pFrom uintptr = pFromStmt
  44426 	var pTo uintptr = pToStmt
  44427 	var i int32
  44428 
  44429 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pTo)).Fdb)).Fmutex)
  44430 	for i = 0; i < int32((*Vdbe)(unsafe.Pointer(pFrom)).FnVar); i++ {
  44431 		Xsqlite3VdbeMemMove(tls, (*Vdbe)(unsafe.Pointer(pTo)).FaVar+uintptr(i)*40, (*Vdbe)(unsafe.Pointer(pFrom)).FaVar+uintptr(i)*40)
  44432 	}
  44433 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pTo)).Fdb)).Fmutex)
  44434 	return SQLITE_OK
  44435 }
  44436 
  44437 // Deprecated external interface.  Internal/core SQLite code
  44438 // should call sqlite3TransferBindings.
  44439 //
  44440 // It is misuse to call this routine with statements from different
  44441 // database connections.  But as this is a deprecated interface, we
  44442 // will not bother to check for that condition.
  44443 //
  44444 // If the two statements contain a different number of bindings, then
  44445 // an SQLITE_ERROR is returned.  Nothing else can go wrong, so otherwise
  44446 // SQLITE_OK is returned.
  44447 func Xsqlite3_transfer_bindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintptr) int32 {
  44448 	var pFrom uintptr = pFromStmt
  44449 	var pTo uintptr = pToStmt
  44450 	if int32((*Vdbe)(unsafe.Pointer(pFrom)).FnVar) != int32((*Vdbe)(unsafe.Pointer(pTo)).FnVar) {
  44451 		return SQLITE_ERROR
  44452 	}
  44453 
  44454 	if (*Vdbe)(unsafe.Pointer(pTo)).Fexpmask != 0 {
  44455 		libc.SetBitFieldPtr8Uint32(pTo+152, Bft(1), 0, 0x3)
  44456 	}
  44457 
  44458 	if (*Vdbe)(unsafe.Pointer(pFrom)).Fexpmask != 0 {
  44459 		libc.SetBitFieldPtr8Uint32(pFrom+152, Bft(1), 0, 0x3)
  44460 	}
  44461 	return Xsqlite3TransferBindings(tls, pFromStmt, pToStmt)
  44462 }
  44463 
  44464 // Return the sqlite3* database handle to which the prepared statement given
  44465 // in the argument belongs.  This is the same database handle that was
  44466 // the first argument to the sqlite3_prepare() that was used to create
  44467 // the statement in the first place.
  44468 func Xsqlite3_db_handle(tls *libc.TLS, pStmt uintptr) uintptr {
  44469 	if pStmt != 0 {
  44470 		return (*Vdbe)(unsafe.Pointer(pStmt)).Fdb
  44471 	}
  44472 	return uintptr(0)
  44473 }
  44474 
  44475 // Return true if the prepared statement is guaranteed to not modify the
  44476 // database.
  44477 func Xsqlite3_stmt_readonly(tls *libc.TLS, pStmt uintptr) int32 {
  44478 	if pStmt != 0 {
  44479 		return int32(*(*uint8)(unsafe.Pointer(pStmt + 152)) & 0x40 >> 6)
  44480 	}
  44481 	return 1
  44482 }
  44483 
  44484 // Return 1 if the statement is an EXPLAIN and return 2 if the
  44485 // statement is an EXPLAIN QUERY PLAN
  44486 func Xsqlite3_stmt_isexplain(tls *libc.TLS, pStmt uintptr) int32 {
  44487 	if pStmt != 0 {
  44488 		return int32(*(*uint8)(unsafe.Pointer(pStmt + 152)) & 0xc >> 2)
  44489 	}
  44490 	return 0
  44491 }
  44492 
  44493 // Return true if the prepared statement is in need of being reset.
  44494 func Xsqlite3_stmt_busy(tls *libc.TLS, pStmt uintptr) int32 {
  44495 	var v uintptr = pStmt
  44496 	return libc.Bool32(v != uintptr(0) && int32((*Vdbe)(unsafe.Pointer(v)).FeVdbeState) == VDBE_RUN_STATE)
  44497 }
  44498 
  44499 // Return a pointer to the next prepared statement after pStmt associated
  44500 // with database connection pDb.  If pStmt is NULL, return the first
  44501 // prepared statement for the database connection.  Return NULL if there
  44502 // are no more.
  44503 func Xsqlite3_next_stmt(tls *libc.TLS, pDb uintptr, pStmt uintptr) uintptr {
  44504 	var pNext uintptr
  44505 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(pDb)).Fmutex)
  44506 	if pStmt == uintptr(0) {
  44507 		pNext = (*Sqlite3)(unsafe.Pointer(pDb)).FpVdbe
  44508 	} else {
  44509 		pNext = (*Vdbe)(unsafe.Pointer(pStmt)).FpVNext
  44510 	}
  44511 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(pDb)).Fmutex)
  44512 	return pNext
  44513 }
  44514 
  44515 // Return the value of a status counter for a prepared statement
  44516 func Xsqlite3_stmt_status(tls *libc.TLS, pStmt uintptr, op int32, resetFlag int32) int32 {
  44517 	bp := tls.Alloc(4)
  44518 	defer tls.Free(4)
  44519 
  44520 	var pVdbe uintptr = pStmt
  44521 
  44522 	if op == SQLITE_STMTSTATUS_MEMUSED {
  44523 		var db uintptr = (*Vdbe)(unsafe.Pointer(pVdbe)).Fdb
  44524 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  44525 		*(*U32)(unsafe.Pointer(bp)) = U32(0)
  44526 		(*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed = bp
  44527 
  44528 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart
  44529 		Xsqlite3VdbeDelete(tls, pVdbe)
  44530 		(*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed = uintptr(0)
  44531 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd
  44532 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  44533 	} else {
  44534 		*(*U32)(unsafe.Pointer(bp)) = *(*U32)(unsafe.Pointer(pVdbe + 164 + uintptr(op)*4))
  44535 		if resetFlag != 0 {
  44536 			*(*U32)(unsafe.Pointer(pVdbe + 164 + uintptr(op)*4)) = U32(0)
  44537 		}
  44538 	}
  44539 	return int32(*(*U32)(unsafe.Pointer(bp)))
  44540 }
  44541 
  44542 // Return the SQL associated with a prepared statement
  44543 func Xsqlite3_sql(tls *libc.TLS, pStmt uintptr) uintptr {
  44544 	var p uintptr = pStmt
  44545 	if p != 0 {
  44546 		return (*Vdbe)(unsafe.Pointer(p)).FzSql
  44547 	}
  44548 	return uintptr(0)
  44549 }
  44550 
  44551 // Return the SQL associated with a prepared statement with
  44552 // bound parameters expanded.  Space to hold the returned string is
  44553 // obtained from sqlite3_malloc().  The caller is responsible for
  44554 // freeing the returned string by passing it to sqlite3_free().
  44555 //
  44556 // The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of
  44557 // expanded bound parameters.
  44558 func Xsqlite3_expanded_sql(tls *libc.TLS, pStmt uintptr) uintptr {
  44559 	var z uintptr = uintptr(0)
  44560 	var zSql uintptr = Xsqlite3_sql(tls, pStmt)
  44561 	if zSql != 0 {
  44562 		var p uintptr = pStmt
  44563 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44564 		z = Xsqlite3VdbeExpandSql(tls, p, zSql)
  44565 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
  44566 	}
  44567 	return z
  44568 }
  44569 
  44570 func vdbeUnpackRecord(tls *libc.TLS, pKeyInfo uintptr, nKey int32, pKey uintptr) uintptr {
  44571 	var pRet uintptr
  44572 
  44573 	pRet = Xsqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo)
  44574 	if pRet != 0 {
  44575 		libc.Xmemset(tls, (*UnpackedRecord)(unsafe.Pointer(pRet)).FaMem, 0, uint32(unsafe.Sizeof(Mem{}))*uint32(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField)+1))
  44576 		Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, nKey, pKey, pRet)
  44577 	}
  44578 	return pRet
  44579 }
  44580 
  44581 // This function is called from within a pre-update callback to retrieve
  44582 // a field of the row currently being updated or deleted.
  44583 func Xsqlite3_preupdate_old(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintptr) int32 {
  44584 	var p uintptr
  44585 	var pMem uintptr
  44586 	var rc int32
  44587 	var nRec U32
  44588 	var aRec uintptr
  44589 	p = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate
  44590 	rc = SQLITE_OK
  44591 
  44592 	if !(!(p != 0) || (*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_INSERT) {
  44593 		goto __1
  44594 	}
  44595 	rc = Xsqlite3MisuseError(tls, 89711)
  44596 	goto preupdate_old_out
  44597 __1:
  44598 	;
  44599 	if !((*PreUpdate)(unsafe.Pointer(p)).FpPk != 0) {
  44600 		goto __2
  44601 	}
  44602 	iIdx = int32(Xsqlite3TableColumnToIndex(tls, (*PreUpdate)(unsafe.Pointer(p)).FpPk, int16(iIdx)))
  44603 __2:
  44604 	;
  44605 	if !(iIdx >= int32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField) || iIdx < 0) {
  44606 		goto __3
  44607 	}
  44608 	rc = SQLITE_RANGE
  44609 	goto preupdate_old_out
  44610 __3:
  44611 	;
  44612 	if !((*PreUpdate)(unsafe.Pointer(p)).FpUnpacked == uintptr(0)) {
  44613 		goto __4
  44614 	}
  44615 
  44616 	nRec = Xsqlite3BtreePayloadSize(tls, *(*uintptr)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr + 36)))
  44617 	aRec = Xsqlite3DbMallocRaw(tls, db, uint64(nRec))
  44618 	if !!(aRec != 0) {
  44619 		goto __5
  44620 	}
  44621 	goto preupdate_old_out
  44622 __5:
  44623 	;
  44624 	rc = Xsqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr + 36)), uint32(0), nRec, aRec)
  44625 	if !(rc == SQLITE_OK) {
  44626 		goto __6
  44627 	}
  44628 	(*PreUpdate)(unsafe.Pointer(p)).FpUnpacked = vdbeUnpackRecord(tls, p+16, int32(nRec), aRec)
  44629 	if !!(int32((*PreUpdate)(unsafe.Pointer(p)).FpUnpacked) != 0) {
  44630 		goto __7
  44631 	}
  44632 	rc = SQLITE_NOMEM
  44633 __7:
  44634 	;
  44635 __6:
  44636 	;
  44637 	if !(rc != SQLITE_OK) {
  44638 		goto __8
  44639 	}
  44640 	Xsqlite3DbFree(tls, db, aRec)
  44641 	goto preupdate_old_out
  44642 __8:
  44643 	;
  44644 	(*PreUpdate)(unsafe.Pointer(p)).FaRecord = aRec
  44645 __4:
  44646 	;
  44647 	pMem = libc.AssignPtrUintptr(ppValue, (*UnpackedRecord)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpUnpacked)).FaMem+uintptr(iIdx)*40)
  44648 	if !(iIdx == int32((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey)) {
  44649 		goto __9
  44650 	}
  44651 	Xsqlite3VdbeMemSetInt64(tls, pMem, (*PreUpdate)(unsafe.Pointer(p)).FiKey1)
  44652 	goto __10
  44653 __9:
  44654 	if !(iIdx >= int32((*UnpackedRecord)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpUnpacked)).FnField)) {
  44655 		goto __11
  44656 	}
  44657 	*(*uintptr)(unsafe.Pointer(ppValue)) = columnNullValue(tls)
  44658 	goto __12
  44659 __11:
  44660 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr(iIdx)*16)).Faffinity) == SQLITE_AFF_REAL) {
  44661 		goto __13
  44662 	}
  44663 	if !(int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Int|MEM_IntReal) != 0) {
  44664 		goto __14
  44665 	}
  44666 
  44667 	Xsqlite3VdbeMemRealify(tls, pMem)
  44668 __14:
  44669 	;
  44670 __13:
  44671 	;
  44672 __12:
  44673 	;
  44674 __10:
  44675 	;
  44676 preupdate_old_out:
  44677 	Xsqlite3Error(tls, db, rc)
  44678 	return Xsqlite3ApiExit(tls, db, rc)
  44679 }
  44680 
  44681 // This function is called from within a pre-update callback to retrieve
  44682 // the number of columns in the row being updated, deleted or inserted.
  44683 func Xsqlite3_preupdate_count(tls *libc.TLS, db uintptr) int32 {
  44684 	var p uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate
  44685 	return func() int32 {
  44686 		if p != 0 {
  44687 			return int32((*PreUpdate)(unsafe.Pointer(p)).Fkeyinfo.FnKeyField)
  44688 		}
  44689 		return 0
  44690 	}()
  44691 }
  44692 
  44693 // This function is designed to be called from within a pre-update callback
  44694 // only. It returns zero if the change that caused the callback was made
  44695 // immediately by a user SQL statement. Or, if the change was made by a
  44696 // trigger program, it returns the number of trigger programs currently
  44697 // on the stack (1 for a top-level trigger, 2 for a trigger fired by a
  44698 // top-level trigger etc.).
  44699 //
  44700 // For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL
  44701 // or SET DEFAULT action is considered a trigger.
  44702 func Xsqlite3_preupdate_depth(tls *libc.TLS, db uintptr) int32 {
  44703 	var p uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate
  44704 	return func() int32 {
  44705 		if p != 0 {
  44706 			return (*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FnFrame
  44707 		}
  44708 		return 0
  44709 	}()
  44710 }
  44711 
  44712 // This function is designed to be called from within a pre-update callback
  44713 // only.
  44714 func Xsqlite3_preupdate_blobwrite(tls *libc.TLS, db uintptr) int32 {
  44715 	var p uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate
  44716 	return func() int32 {
  44717 		if p != 0 {
  44718 			return (*PreUpdate)(unsafe.Pointer(p)).FiBlobWrite
  44719 		}
  44720 		return -1
  44721 	}()
  44722 }
  44723 
  44724 // This function is called from within a pre-update callback to retrieve
  44725 // a field of the row currently being updated or inserted.
  44726 func Xsqlite3_preupdate_new(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintptr) int32 {
  44727 	var p uintptr
  44728 	var rc int32
  44729 	var pMem uintptr
  44730 	var pData uintptr
  44731 
  44732 	var pUnpack uintptr
  44733 	p = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate
  44734 	rc = SQLITE_OK
  44735 
  44736 	if !(!(p != 0) || (*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_DELETE) {
  44737 		goto __1
  44738 	}
  44739 	rc = Xsqlite3MisuseError(tls, 89813)
  44740 	goto preupdate_new_out
  44741 __1:
  44742 	;
  44743 	if !((*PreUpdate)(unsafe.Pointer(p)).FpPk != 0 && (*PreUpdate)(unsafe.Pointer(p)).Fop != SQLITE_UPDATE) {
  44744 		goto __2
  44745 	}
  44746 	iIdx = int32(Xsqlite3TableColumnToIndex(tls, (*PreUpdate)(unsafe.Pointer(p)).FpPk, int16(iIdx)))
  44747 __2:
  44748 	;
  44749 	if !(iIdx >= int32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField) || iIdx < 0) {
  44750 		goto __3
  44751 	}
  44752 	rc = SQLITE_RANGE
  44753 	goto preupdate_new_out
  44754 __3:
  44755 	;
  44756 	if !((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_INSERT) {
  44757 		goto __4
  44758 	}
  44759 
  44760 	pUnpack = (*PreUpdate)(unsafe.Pointer(p)).FpNewUnpacked
  44761 	if !!(pUnpack != 0) {
  44762 		goto __6
  44763 	}
  44764 	pData = (*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FaMem + uintptr((*PreUpdate)(unsafe.Pointer(p)).FiNewReg)*40
  44765 	rc = func() int32 {
  44766 		if int32((*Mem)(unsafe.Pointer(pData)).Fflags)&MEM_Zero != 0 {
  44767 			return Xsqlite3VdbeMemExpandBlob(tls, pData)
  44768 		}
  44769 		return 0
  44770 	}()
  44771 	if !(rc != SQLITE_OK) {
  44772 		goto __7
  44773 	}
  44774 	goto preupdate_new_out
  44775 __7:
  44776 	;
  44777 	pUnpack = vdbeUnpackRecord(tls, p+16, (*Mem)(unsafe.Pointer(pData)).Fn, (*Mem)(unsafe.Pointer(pData)).Fz)
  44778 	if !!(pUnpack != 0) {
  44779 		goto __8
  44780 	}
  44781 	rc = SQLITE_NOMEM
  44782 	goto preupdate_new_out
  44783 __8:
  44784 	;
  44785 	(*PreUpdate)(unsafe.Pointer(p)).FpNewUnpacked = pUnpack
  44786 __6:
  44787 	;
  44788 	pMem = (*UnpackedRecord)(unsafe.Pointer(pUnpack)).FaMem + uintptr(iIdx)*40
  44789 	if !(iIdx == int32((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey)) {
  44790 		goto __9
  44791 	}
  44792 	Xsqlite3VdbeMemSetInt64(tls, pMem, (*PreUpdate)(unsafe.Pointer(p)).FiKey2)
  44793 	goto __10
  44794 __9:
  44795 	if !(iIdx >= int32((*UnpackedRecord)(unsafe.Pointer(pUnpack)).FnField)) {
  44796 		goto __11
  44797 	}
  44798 	pMem = columnNullValue(tls)
  44799 __11:
  44800 	;
  44801 __10:
  44802 	;
  44803 	goto __5
  44804 __4:
  44805 	;
  44806 	if !!(int32((*PreUpdate)(unsafe.Pointer(p)).FaNew) != 0) {
  44807 		goto __12
  44808 	}
  44809 	(*PreUpdate)(unsafe.Pointer(p)).FaNew = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(Mem{}))*uint32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField)))
  44810 	if !!(int32((*PreUpdate)(unsafe.Pointer(p)).FaNew) != 0) {
  44811 		goto __13
  44812 	}
  44813 	rc = SQLITE_NOMEM
  44814 	goto preupdate_new_out
  44815 __13:
  44816 	;
  44817 __12:
  44818 	;
  44819 	pMem = (*PreUpdate)(unsafe.Pointer(p)).FaNew + uintptr(iIdx)*40
  44820 	if !(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) == 0) {
  44821 		goto __14
  44822 	}
  44823 	if !(iIdx == int32((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FiPKey)) {
  44824 		goto __15
  44825 	}
  44826 	Xsqlite3VdbeMemSetInt64(tls, pMem, (*PreUpdate)(unsafe.Pointer(p)).FiKey2)
  44827 	goto __16
  44828 __15:
  44829 	rc = Xsqlite3VdbeMemCopy(tls, pMem, (*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FaMem+uintptr((*PreUpdate)(unsafe.Pointer(p)).FiNewReg+1+iIdx)*40)
  44830 	if !(rc != SQLITE_OK) {
  44831 		goto __17
  44832 	}
  44833 	goto preupdate_new_out
  44834 __17:
  44835 	;
  44836 __16:
  44837 	;
  44838 __14:
  44839 	;
  44840 __5:
  44841 	;
  44842 	*(*uintptr)(unsafe.Pointer(ppValue)) = pMem
  44843 
  44844 preupdate_new_out:
  44845 	Xsqlite3Error(tls, db, rc)
  44846 	return Xsqlite3ApiExit(tls, db, rc)
  44847 }
  44848 
  44849 func findNextHostParameter(tls *libc.TLS, zSql uintptr, pnToken uintptr) int32 {
  44850 	bp := tls.Alloc(4)
  44851 	defer tls.Free(4)
  44852 
  44853 	var nTotal int32 = 0
  44854 	var n int32
  44855 
  44856 	*(*int32)(unsafe.Pointer(pnToken)) = 0
  44857 	for *(*uint8)(unsafe.Pointer(zSql)) != 0 {
  44858 		n = Xsqlite3GetToken(tls, zSql, bp)
  44859 
  44860 		if *(*int32)(unsafe.Pointer(bp)) == TK_VARIABLE {
  44861 			*(*int32)(unsafe.Pointer(pnToken)) = n
  44862 			break
  44863 		}
  44864 		nTotal = nTotal + n
  44865 		zSql += uintptr(n)
  44866 	}
  44867 	return nTotal
  44868 }
  44869 
  44870 // This function returns a pointer to a nul-terminated string in memory
  44871 // obtained from sqlite3DbMalloc(). If sqlite3.nVdbeExec is 1, then the
  44872 // string contains a copy of zRawSql but with host parameters expanded to
  44873 // their current bindings. Or, if sqlite3.nVdbeExec is greater than 1,
  44874 // then the returned string holds a copy of zRawSql with "-- " prepended
  44875 // to each line of text.
  44876 //
  44877 // If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then
  44878 // then long strings and blobs are truncated to that many bytes.  This
  44879 // can be used to prevent unreasonably large trace strings when dealing
  44880 // with large (multi-megabyte) strings and blobs.
  44881 //
  44882 // The calling function is responsible for making sure the memory returned
  44883 // is eventually freed.
  44884 //
  44885 // ALGORITHM:  Scan the input string looking for host parameters in any of
  44886 // these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within
  44887 // string literals, quoted identifier names, and comments.  For text forms,
  44888 // the host parameter index is found by scanning the prepared
  44889 // statement for the corresponding OP_Variable opcode.  Once the host
  44890 // parameter index is known, locate the value in p->aVar[].  Then render
  44891 // the value as a literal in place of the host parameter name.
  44892 func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr {
  44893 	bp := tls.Alloc(120)
  44894 	defer tls.Free(120)
  44895 
  44896 	var db uintptr
  44897 	*(*int32)(unsafe.Pointer(bp + 76)) = 0
  44898 	var nextIndex int32 = 1
  44899 	var n int32
  44900 
  44901 	var i int32
  44902 	var pVar uintptr
  44903 
  44904 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  44905 	Xsqlite3StrAccumInit(tls, bp+48, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer(db + 120)))
  44906 	if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec > 1 {
  44907 		for *(*uint8)(unsafe.Pointer(zRawSql)) != 0 {
  44908 			var zStart uintptr = zRawSql
  44909 			for int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zRawSql, 1)))) != '\n' && *(*uint8)(unsafe.Pointer(zRawSql)) != 0 {
  44910 			}
  44911 			Xsqlite3_str_append(tls, bp+48, ts+5397, 3)
  44912 
  44913 			Xsqlite3_str_append(tls, bp+48, zStart, (int32(zRawSql)-int32(zStart))/1)
  44914 		}
  44915 	} else if int32((*Vdbe)(unsafe.Pointer(p)).FnVar) == 0 {
  44916 		Xsqlite3_str_append(tls, bp+48, zRawSql, Xsqlite3Strlen30(tls, zRawSql))
  44917 	} else {
  44918 		for *(*uint8)(unsafe.Pointer(zRawSql)) != 0 {
  44919 			n = findNextHostParameter(tls, zRawSql, bp+72)
  44920 
  44921 			Xsqlite3_str_append(tls, bp+48, zRawSql, n)
  44922 			zRawSql += uintptr(n)
  44923 
  44924 			if *(*int32)(unsafe.Pointer(bp + 72)) == 0 {
  44925 				break
  44926 			}
  44927 			if int32(*(*uint8)(unsafe.Pointer(zRawSql))) == '?' {
  44928 				if *(*int32)(unsafe.Pointer(bp + 72)) > 1 {
  44929 					Xsqlite3GetInt32(tls, zRawSql+1, bp+76)
  44930 				} else {
  44931 					*(*int32)(unsafe.Pointer(bp + 76)) = nextIndex
  44932 				}
  44933 			} else {
  44934 				*(*int32)(unsafe.Pointer(bp + 76)) = Xsqlite3VdbeParameterIndex(tls, p, zRawSql, *(*int32)(unsafe.Pointer(bp + 72)))
  44935 
  44936 			}
  44937 			zRawSql += uintptr(*(*int32)(unsafe.Pointer(bp + 72)))
  44938 			nextIndex = func() int32 {
  44939 				if *(*int32)(unsafe.Pointer(bp + 76))+1 > nextIndex {
  44940 					return *(*int32)(unsafe.Pointer(bp + 76)) + 1
  44941 				}
  44942 				return nextIndex
  44943 			}()
  44944 
  44945 			pVar = (*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(*(*int32)(unsafe.Pointer(bp + 76))-1)*40
  44946 			if int32((*Mem)(unsafe.Pointer(pVar)).Fflags)&MEM_Null != 0 {
  44947 				Xsqlite3_str_append(tls, bp+48, ts+1555, 4)
  44948 			} else if int32((*Mem)(unsafe.Pointer(pVar)).Fflags)&(MEM_Int|MEM_IntReal) != 0 {
  44949 				Xsqlite3_str_appendf(tls, bp+48, ts+1334, libc.VaList(bp, *(*I64)(unsafe.Pointer(pVar))))
  44950 			} else if int32((*Mem)(unsafe.Pointer(pVar)).Fflags)&MEM_Real != 0 {
  44951 				Xsqlite3_str_appendf(tls, bp+48, ts+4925, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(pVar))))
  44952 			} else if int32((*Mem)(unsafe.Pointer(pVar)).Fflags)&MEM_Str != 0 {
  44953 				var nOut int32
  44954 				var enc U8 = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  44955 				if int32(enc) != SQLITE_UTF8 {
  44956 					libc.Xmemset(tls, bp+80, 0, uint32(unsafe.Sizeof(Mem{})))
  44957 					(*Mem)(unsafe.Pointer(bp + 80)).Fdb = db
  44958 					Xsqlite3VdbeMemSetStr(tls, bp+80, (*Mem)(unsafe.Pointer(pVar)).Fz, int64((*Mem)(unsafe.Pointer(pVar)).Fn), enc, uintptr(0))
  44959 					if SQLITE_NOMEM == Xsqlite3VdbeChangeEncoding(tls, bp+80, SQLITE_UTF8) {
  44960 						(*StrAccum)(unsafe.Pointer(bp + 48)).FaccError = U8(SQLITE_NOMEM)
  44961 						(*StrAccum)(unsafe.Pointer(bp + 48)).FnAlloc = U32(0)
  44962 					}
  44963 					pVar = bp + 80
  44964 				}
  44965 				nOut = (*Mem)(unsafe.Pointer(pVar)).Fn
  44966 				Xsqlite3_str_appendf(tls, bp+48, ts+5401, libc.VaList(bp+16, nOut, (*Mem)(unsafe.Pointer(pVar)).Fz))
  44967 				if int32(enc) != SQLITE_UTF8 {
  44968 					Xsqlite3VdbeMemRelease(tls, bp+80)
  44969 				}
  44970 			} else if int32((*Mem)(unsafe.Pointer(pVar)).Fflags)&MEM_Zero != 0 {
  44971 				Xsqlite3_str_appendf(tls, bp+48, ts+5408, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(pVar))))
  44972 			} else {
  44973 				var nOut int32
  44974 
  44975 				Xsqlite3_str_append(tls, bp+48, ts+5421, 2)
  44976 				nOut = (*Mem)(unsafe.Pointer(pVar)).Fn
  44977 				for i = 0; i < nOut; i++ {
  44978 					Xsqlite3_str_appendf(tls, bp+48, ts+5424, libc.VaList(bp+40, int32(*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pVar)).Fz + uintptr(i))))&0xff))
  44979 				}
  44980 				Xsqlite3_str_append(tls, bp+48, ts+5429, 1)
  44981 			}
  44982 		}
  44983 	}
  44984 	if (*StrAccum)(unsafe.Pointer(bp+48)).FaccError != 0 {
  44985 		Xsqlite3_str_reset(tls, bp+48)
  44986 	}
  44987 	return Xsqlite3StrAccumFinish(tls, bp+48)
  44988 }
  44989 
  44990 func allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, eCurType U8) uintptr {
  44991 	var pMem uintptr
  44992 	if iCur > 0 {
  44993 		pMem = (*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*Vdbe)(unsafe.Pointer(p)).FnMem-iCur)*40
  44994 	} else {
  44995 		pMem = (*Vdbe)(unsafe.Pointer(p)).FaMem
  44996 	}
  44997 	var nByte int32
  44998 	var pCx uintptr = uintptr(0)
  44999 	nByte = int32((uint32(unsafe.Sizeof(VdbeCursor{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)) + uint32(2)*uint32(unsafe.Sizeof(U32(0)))*uint32(nField) + func() uint32 {
  45000 		if int32(eCurType) == CURTYPE_BTREE {
  45001 			return uint32(Xsqlite3BtreeCursorSize(tls))
  45002 		}
  45003 		return uint32(0)
  45004 	}())
  45005 
  45006 	if *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*4)) != 0 {
  45007 		Xsqlite3VdbeFreeCursorNN(tls, p, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*4)))
  45008 		*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*4)) = uintptr(0)
  45009 	}
  45010 
  45011 	if (*Mem)(unsafe.Pointer(pMem)).FszMalloc < nByte {
  45012 		if (*Mem)(unsafe.Pointer(pMem)).FszMalloc > 0 {
  45013 			Xsqlite3DbFreeNN(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc)
  45014 		}
  45015 		(*Mem)(unsafe.Pointer(pMem)).Fz = libc.AssignPtrUintptr(pMem+32, Xsqlite3DbMallocRaw(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, uint64(nByte)))
  45016 		if (*Mem)(unsafe.Pointer(pMem)).FzMalloc == uintptr(0) {
  45017 			(*Mem)(unsafe.Pointer(pMem)).FszMalloc = 0
  45018 			return uintptr(0)
  45019 		}
  45020 		(*Mem)(unsafe.Pointer(pMem)).FszMalloc = nByte
  45021 	}
  45022 
  45023 	*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*4)) = libc.AssignUintptr(&pCx, (*Mem)(unsafe.Pointer(pMem)).FzMalloc)
  45024 	libc.Xmemset(tls, pCx, 0, uint32(uintptr(0)+32))
  45025 	(*VdbeCursor)(unsafe.Pointer(pCx)).FeCurType = eCurType
  45026 	(*VdbeCursor)(unsafe.Pointer(pCx)).FnField = I16(nField)
  45027 	(*VdbeCursor)(unsafe.Pointer(pCx)).FaOffset = pCx + 80 + uintptr(nField)*4
  45028 	if int32(eCurType) == CURTYPE_BTREE {
  45029 		*(*uintptr)(unsafe.Pointer(pCx + 36)) = (*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((uint32(unsafe.Sizeof(VdbeCursor{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7))+uint32(2)*uint32(unsafe.Sizeof(U32(0)))*uint32(nField))
  45030 		Xsqlite3BtreeCursorZero(tls, *(*uintptr)(unsafe.Pointer(pCx + 36)))
  45031 	}
  45032 	return pCx
  45033 }
  45034 
  45035 func alsoAnInt(tls *libc.TLS, pRec uintptr, rValue float64, piValue uintptr) int32 {
  45036 	var iValue I64
  45037 	iValue = Xsqlite3RealToI64(tls, rValue)
  45038 	if Xsqlite3RealSameAsInt(tls, rValue, iValue) != 0 {
  45039 		*(*I64)(unsafe.Pointer(piValue)) = iValue
  45040 		return 1
  45041 	}
  45042 	return libc.Bool32(0 == Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pRec)).Fz, piValue, (*Mem)(unsafe.Pointer(pRec)).Fn, (*Mem)(unsafe.Pointer(pRec)).Fenc))
  45043 }
  45044 
  45045 func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) {
  45046 	bp := tls.Alloc(8)
  45047 	defer tls.Free(8)
  45048 
  45049 	var enc U8 = (*Mem)(unsafe.Pointer(pRec)).Fenc
  45050 	var rc int32
  45051 
  45052 	rc = Xsqlite3AtoF(tls, (*Mem)(unsafe.Pointer(pRec)).Fz, bp, (*Mem)(unsafe.Pointer(pRec)).Fn, enc)
  45053 	if rc <= 0 {
  45054 		return
  45055 	}
  45056 	if rc == 1 && alsoAnInt(tls, pRec, *(*float64)(unsafe.Pointer(bp)), pRec) != 0 {
  45057 		*(*U16)(unsafe.Pointer(pRec + 16)) |= U16(MEM_Int)
  45058 	} else {
  45059 		*(*float64)(unsafe.Pointer(pRec)) = *(*float64)(unsafe.Pointer(bp))
  45060 		*(*U16)(unsafe.Pointer(pRec + 16)) |= U16(MEM_Real)
  45061 		if bTryForInt != 0 {
  45062 			Xsqlite3VdbeIntegerAffinity(tls, pRec)
  45063 		}
  45064 	}
  45065 
  45066 	*(*U16)(unsafe.Pointer(pRec + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Str))
  45067 }
  45068 
  45069 func applyAffinity(tls *libc.TLS, pRec uintptr, affinity uint8, enc U8) {
  45070 	if int32(affinity) >= SQLITE_AFF_NUMERIC {
  45071 		if int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Int == 0 {
  45072 			if int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&(MEM_Real|MEM_IntReal) == 0 {
  45073 				if int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Str != 0 {
  45074 					applyNumericAffinity(tls, pRec, 1)
  45075 				}
  45076 			} else if int32(affinity) <= SQLITE_AFF_REAL {
  45077 				Xsqlite3VdbeIntegerAffinity(tls, pRec)
  45078 			}
  45079 		}
  45080 	} else if int32(affinity) == SQLITE_AFF_TEXT {
  45081 		if 0 == int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Str {
  45082 			if int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&(MEM_Real|MEM_Int|MEM_IntReal) != 0 {
  45083 				Xsqlite3VdbeMemStringify(tls, pRec, enc, uint8(1))
  45084 			}
  45085 		}
  45086 		*(*U16)(unsafe.Pointer(pRec + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Real | MEM_Int | MEM_IntReal))
  45087 	}
  45088 }
  45089 
  45090 // Try to convert the type of a function argument or a result column
  45091 // into a numeric representation.  Use either INTEGER or REAL whichever
  45092 // is appropriate.  But only do the conversion if it is possible without
  45093 // loss of information and return the revised type of the argument.
  45094 func Xsqlite3_value_numeric_type(tls *libc.TLS, pVal uintptr) int32 {
  45095 	var eType int32 = Xsqlite3_value_type(tls, pVal)
  45096 	if eType == SQLITE_TEXT {
  45097 		var pMem uintptr = pVal
  45098 		applyNumericAffinity(tls, pMem, 0)
  45099 		eType = Xsqlite3_value_type(tls, pVal)
  45100 	}
  45101 	return eType
  45102 }
  45103 
  45104 // Exported version of applyAffinity(). This one works on sqlite3_value*,
  45105 // not the internal Mem* type.
  45106 func Xsqlite3ValueApplyAffinity(tls *libc.TLS, pVal uintptr, affinity U8, enc U8) {
  45107 	applyAffinity(tls, pVal, affinity, enc)
  45108 }
  45109 
  45110 func computeNumericType(tls *libc.TLS, pMem uintptr) U16 {
  45111 	bp := tls.Alloc(8)
  45112 	defer tls.Free(8)
  45113 
  45114 	var rc int32
  45115 
  45116 	if func() int32 {
  45117 		if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&MEM_Zero != 0 {
  45118 			return Xsqlite3VdbeMemExpandBlob(tls, pMem)
  45119 		}
  45120 		return 0
  45121 	}() != 0 {
  45122 		*(*I64)(unsafe.Pointer(pMem)) = int64(0)
  45123 		return U16(MEM_Int)
  45124 	}
  45125 	rc = Xsqlite3AtoF(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, pMem, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc)
  45126 	if rc <= 0 {
  45127 		if rc == 0 && Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) <= 1 {
  45128 			*(*I64)(unsafe.Pointer(pMem)) = *(*Sqlite3_int64)(unsafe.Pointer(bp))
  45129 			return U16(MEM_Int)
  45130 		} else {
  45131 			return U16(MEM_Real)
  45132 		}
  45133 	} else if rc == 1 && Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) == 0 {
  45134 		*(*I64)(unsafe.Pointer(pMem)) = *(*Sqlite3_int64)(unsafe.Pointer(bp))
  45135 		return U16(MEM_Int)
  45136 	}
  45137 	return U16(MEM_Real)
  45138 }
  45139 
  45140 func numericType(tls *libc.TLS, pMem uintptr) U16 {
  45141 	if int32((*Mem)(unsafe.Pointer(pMem)).Fflags)&(MEM_Int|MEM_Real|MEM_IntReal|MEM_Null) != 0 {
  45142 		return U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_Real | MEM_IntReal | MEM_Null))
  45143 	}
  45144 
  45145 	return computeNumericType(tls, pMem)
  45146 	return U16(0)
  45147 }
  45148 
  45149 func out2PrereleaseWithClear(tls *libc.TLS, pOut uintptr) uintptr {
  45150 	Xsqlite3VdbeMemSetNull(tls, pOut)
  45151 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Int)
  45152 	return pOut
  45153 }
  45154 
  45155 func out2Prerelease(tls *libc.TLS, p uintptr, pOp uintptr) uintptr {
  45156 	var pOut uintptr
  45157 
  45158 	pOut = (*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*VdbeOp)(unsafe.Pointer(pOp)).Fp2)*40
  45159 
  45160 	if int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&(MEM_Agg|MEM_Dyn) != 0 {
  45161 		return out2PrereleaseWithClear(tls, pOut)
  45162 	} else {
  45163 		(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Int)
  45164 		return pOut
  45165 	}
  45166 	return uintptr(0)
  45167 }
  45168 
  45169 func filterHash(tls *libc.TLS, aMem uintptr, pOp uintptr) U64 {
  45170 	var i int32
  45171 	var mx int32
  45172 	var h U64 = uint64(0)
  45173 
  45174 	i = (*Op)(unsafe.Pointer(pOp)).Fp3
  45175 	mx = i + *(*int32)(unsafe.Pointer(pOp + 16))
  45176 	for ; i < mx; i++ {
  45177 		var p uintptr = aMem + uintptr(i)*40
  45178 		if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Int|MEM_IntReal) != 0 {
  45179 			h = h + U64(*(*I64)(unsafe.Pointer(p)))
  45180 		} else if int32((*Mem)(unsafe.Pointer(p)).Fflags)&MEM_Real != 0 {
  45181 			h = h + U64(Xsqlite3VdbeIntValue(tls, p))
  45182 		} else if int32((*Mem)(unsafe.Pointer(p)).Fflags)&(MEM_Str|MEM_Blob) != 0 {
  45183 		}
  45184 	}
  45185 	return h
  45186 }
  45187 
  45188 func vdbeMemTypeName(tls *libc.TLS, pMem uintptr) uintptr {
  45189 	return azTypes[Xsqlite3_value_type(tls, pMem)-1]
  45190 }
  45191 
  45192 var azTypes = [5]uintptr{
  45193 	ts + 1115,
  45194 	ts + 1127,
  45195 	ts + 1132,
  45196 	ts + 1110,
  45197 	ts + 1555,
  45198 }
  45199 
  45200 // Execute as much of a VDBE program as we can.
  45201 // This is the core of sqlite3_step().
  45202 func Xsqlite3VdbeExec(tls *libc.TLS, p uintptr) int32 {
  45203 	bp := tls.Alloc(880)
  45204 	defer tls.Free(880)
  45205 
  45206 	var aOp uintptr
  45207 	var pOp uintptr
  45208 	var rc int32
  45209 	var db uintptr
  45210 	var resetSchemaOnFault U8
  45211 	var encoding U8
  45212 	var iCompare int32
  45213 	var nVmStep U64
  45214 	var nProgressLimit U64
  45215 	var aMem uintptr
  45216 	var pIn1 uintptr
  45217 	var pIn2 uintptr
  45218 	var pIn3 uintptr
  45219 	var pOut uintptr
  45220 	var iPrior U32
  45221 	var pCaller uintptr
  45222 	var pcDest int32
  45223 	var pFrame uintptr
  45224 	var pcx int32
  45225 	var cnt int32
  45226 	var nullFlag U16
  45227 	var pVar uintptr
  45228 	var n int32
  45229 	var p1 int32
  45230 	var p2 int32
  45231 	var n1 int32
  45232 	var nByte I64
  45233 	var flags1 U16
  45234 	var flags2 U16
  45235 	var type1 U16
  45236 	var type2 U16
  45237 	var iA I64
  45238 
  45239 	var rA float64
  45240 	var rB float64
  45241 
  45242 	var iB1 I64
  45243 	var op U8
  45244 	var res int32
  45245 	var res2 int32
  45246 	var affinity uint8
  45247 	var flags11 U16
  45248 	var flags3 U16
  45249 	var n2 int32
  45250 	var i int32
  45251 	var p11 int32
  45252 	var p21 int32
  45253 	var pKeyInfo uintptr
  45254 	var idx U32
  45255 	var pColl uintptr
  45256 	var bRev int32
  45257 	var aPermute uintptr
  45258 	var v1 int32
  45259 	var v2 int32
  45260 	var iAddr U32
  45261 	var c int32
  45262 	var c1 int32
  45263 	var pC uintptr
  45264 	var typeMask U16
  45265 	var serialType U32
  45266 	var pC1 uintptr
  45267 	var pC2 uintptr
  45268 	var iMap U32
  45269 	var p22 U32
  45270 	var pC3 uintptr
  45271 	var pCrsr uintptr
  45272 	var aOffset uintptr
  45273 	var len int32
  45274 	var i1 int32
  45275 	var pDest uintptr
  45276 
  45277 	var zData uintptr
  45278 	var zHdr uintptr
  45279 	var zEndHdr uintptr
  45280 	var offset64 U64
  45281 
  45282 	var pReg uintptr
  45283 	var pTab uintptr
  45284 	var aCol uintptr
  45285 	var i2 int32
  45286 	var zAffinity uintptr
  45287 
  45288 	var i3 I64
  45289 	var uu U64
  45290 
  45291 	var i4 U32
  45292 	var pRec uintptr
  45293 	var nData U64
  45294 	var nHdr int32
  45295 	var nByte1 I64
  45296 	var nZero I64
  45297 	var nVarint int32
  45298 	var serial_type U32
  45299 	var pData0 uintptr
  45300 	var pLast uintptr
  45301 	var nField int32
  45302 	var zAffinity1 uintptr
  45303 	var len1 U32
  45304 	var zHdr1 uintptr
  45305 	var zPayload uintptr
  45306 
  45307 	var pCrsr1 uintptr
  45308 	var isSchemaChange int32
  45309 
  45310 	var isTransaction int32
  45311 	var p12 int32
  45312 	var zName uintptr
  45313 	var nName int32
  45314 	var pNew uintptr
  45315 	var pSavepoint uintptr
  45316 	var pTmp uintptr
  45317 	var iSavepoint int32
  45318 	var ii int32
  45319 	var desiredAutoCommit int32
  45320 	var iRollback int32
  45321 	var pBt uintptr
  45322 	var pDb uintptr
  45323 
  45324 	var iDb int32
  45325 	var iCookie int32
  45326 	var pDb1 uintptr
  45327 	var nField1 int32
  45328 	var pKeyInfo1 uintptr
  45329 	var p23 U32
  45330 	var iDb1 int32
  45331 	var wrFlag int32
  45332 	var pX uintptr
  45333 	var pCur uintptr
  45334 	var pDb2 uintptr
  45335 	var pOrig uintptr
  45336 	var pCx uintptr
  45337 	var pCx1 uintptr
  45338 	var pKeyInfo2 uintptr
  45339 	var pCx2 uintptr
  45340 	var pC4 uintptr
  45341 	var pCx3 uintptr
  45342 	var c2 int32
  45343 	var flags31 U16
  45344 	var newType U16
  45345 
  45346 	var oc int32
  45347 	var pC5 uintptr
  45348 
  45349 	var nField2 int32
  45350 	var iKey I64
  45351 	var eqOnly int32
  45352 	var pC6 uintptr
  45353 
  45354 	var nStep int32
  45355 
  45356 	var pC7 uintptr
  45357 	var pCur1 uintptr
  45358 	var pC8 uintptr
  45359 	var alreadyExists int32
  45360 	var ii1 int32
  45361 	var pC9 uintptr
  45362 	var pIdxKey uintptr
  45363 
  45364 	var pC10 uintptr
  45365 	var pCrsr2 uintptr
  45366 
  45367 	var iKey1 U64
  45368 
  45369 	var pC11 uintptr
  45370 
  45371 	var cnt1 int32
  45372 	var pMem uintptr
  45373 	var pFrame1 uintptr
  45374 	var pData uintptr
  45375 	var pKey uintptr
  45376 	var pC12 uintptr
  45377 	var seekResult int32
  45378 	var zDb uintptr
  45379 	var pTab1 uintptr
  45380 
  45381 	var pDest1 uintptr
  45382 	var pSrc uintptr
  45383 	var iKey2 I64
  45384 	var pC13 uintptr
  45385 	var zDb1 uintptr
  45386 	var pTab2 uintptr
  45387 	var opflags int32
  45388 	var pC14 uintptr
  45389 
  45390 	var nKeyCol int32
  45391 	var pC15 uintptr
  45392 	var pC16 uintptr
  45393 	var pCrsr3 uintptr
  45394 	var n3 U32
  45395 	var pC17 uintptr
  45396 
  45397 	var pVtab uintptr
  45398 	var pModule uintptr
  45399 	var pC18 uintptr
  45400 	var pC19 uintptr
  45401 	var pCrsr4 uintptr
  45402 
  45403 	var pC20 uintptr
  45404 	var pCrsr5 uintptr
  45405 
  45406 	var sz I64
  45407 	var pC21 uintptr
  45408 	var pCrsr6 uintptr
  45409 
  45410 	var pC22 uintptr
  45411 	var pC23 uintptr
  45412 
  45413 	var pC24 uintptr
  45414 	var pC25 uintptr
  45415 	var pCrsr7 uintptr
  45416 
  45417 	var pC26 uintptr
  45418 	var pTabCur uintptr
  45419 
  45420 	var pC27 uintptr
  45421 	var nCellKey I64
  45422 	var pCur2 uintptr
  45423 
  45424 	var pC28 uintptr
  45425 	var res11 int32
  45426 
  45427 	var iDb2 int32
  45428 
  45429 	var pC29 uintptr
  45430 
  45431 	var pDb3 uintptr
  45432 	var iDb3 int32
  45433 	var zSchema uintptr
  45434 	var zSql uintptr
  45435 
  45436 	var nRoot int32
  45437 	var aRoot uintptr
  45438 
  45439 	var pnErr uintptr
  45440 
  45441 	var iSet int32
  45442 	var exists int32
  45443 	var nMem int32
  45444 	var nByte2 int32
  45445 	var pRt uintptr
  45446 	var pMem1 uintptr
  45447 	var pEnd uintptr
  45448 	var pFrame2 uintptr
  45449 	var pProgram uintptr
  45450 	var t1 uintptr
  45451 	var pFrame3 uintptr
  45452 	var pIn uintptr
  45453 	var pFrame4 uintptr
  45454 
  45455 	var n4 int32
  45456 	var pCtx uintptr
  45457 	var i5 int32
  45458 	var pCtx1 uintptr
  45459 	var pMem2 uintptr
  45460 	var pMem3 uintptr
  45461 	var i6 int32
  45462 
  45463 	var pMem4 uintptr
  45464 	var pBt1 uintptr
  45465 	var pPager uintptr
  45466 	var eNew int32
  45467 	var eOld int32
  45468 	var zFilename uintptr
  45469 	var pBt2 uintptr
  45470 	var pC30 uintptr
  45471 	var pC31 uintptr
  45472 	var z1 uintptr
  45473 	var p13 int32
  45474 	var isWriteLock U8
  45475 	var pVTab uintptr
  45476 
  45477 	var zTab uintptr
  45478 	var pCur3 uintptr
  45479 
  45480 	var pVtab1 uintptr
  45481 	var pModule1 uintptr
  45482 	var pC32 uintptr
  45483 	var pRhs uintptr
  45484 	var nArg int32
  45485 	var iQuery int32
  45486 	var pModule2 uintptr
  45487 	var pQuery uintptr
  45488 	var pArgc uintptr
  45489 	var pVCur1 uintptr
  45490 	var pVtab2 uintptr
  45491 	var pCur4 uintptr
  45492 	var res12 int32
  45493 	var i7 int32
  45494 	var apArg uintptr
  45495 	var pVtab3 uintptr
  45496 	var pModule3 uintptr
  45497 	var pDest2 uintptr
  45498 
  45499 	var pCur5 uintptr
  45500 	var pVtab4 uintptr
  45501 	var pModule4 uintptr
  45502 	var res13 int32
  45503 	var pCur6 uintptr
  45504 	var pVtab5 uintptr
  45505 	var pName uintptr
  45506 	var isLegacy int32
  45507 	var vtabOnConflict U8
  45508 	var pVtab6 uintptr
  45509 	var pModule5 uintptr
  45510 	var nArg1 int32
  45511 	var i8 int32
  45512 
  45513 	var apArg1 uintptr
  45514 	var pX1 uintptr
  45515 	var newMax uint32
  45516 	var pBt3 uintptr
  45517 	var i9 int32
  45518 	var pCtx2 uintptr
  45519 	var h U64
  45520 	var h1 U64
  45521 	var z2 uintptr
  45522 	var z3 uintptr
  45523 	var i10 int32
  45524 	var zTrace uintptr
  45525 	aOp = (*Vdbe)(unsafe.Pointer(p)).FaOp
  45526 	pOp = aOp
  45527 	rc = SQLITE_OK
  45528 	db = (*Vdbe)(unsafe.Pointer(p)).Fdb
  45529 	resetSchemaOnFault = U8(0)
  45530 	encoding = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  45531 	iCompare = 0
  45532 	nVmStep = uint64(0)
  45533 	aMem = (*Vdbe)(unsafe.Pointer(p)).FaMem
  45534 	pIn1 = uintptr(0)
  45535 	pIn2 = uintptr(0)
  45536 	pIn3 = uintptr(0)
  45537 	pOut = uintptr(0)
  45538 
  45539 	if !((*Vdbe)(unsafe.Pointer(p)).FlockMask != YDbMask(0)) {
  45540 		goto __1
  45541 	}
  45542 	Xsqlite3VdbeEnter(tls, p)
  45543 __1:
  45544 	;
  45545 	if !((*Sqlite3)(unsafe.Pointer(db)).FxProgress != 0) {
  45546 		goto __2
  45547 	}
  45548 	iPrior = *(*U32)(unsafe.Pointer(p + 164 + 4*4))
  45549 
  45550 	nProgressLimit = U64((*Sqlite3)(unsafe.Pointer(db)).FnProgressOps - iPrior%(*Sqlite3)(unsafe.Pointer(db)).FnProgressOps)
  45551 	goto __3
  45552 __2:
  45553 	nProgressLimit = uint64(0xffffffff) | uint64(0xffffffff)<<32
  45554 __3:
  45555 	;
  45556 	if !((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_NOMEM) {
  45557 		goto __4
  45558 	}
  45559 
  45560 	goto no_mem
  45561 __4:
  45562 	;
  45563 	(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
  45564 
  45565 	(*Vdbe)(unsafe.Pointer(p)).FiCurrentTime = int64(0)
  45566 
  45567 	(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
  45568 	if !(libc.AtomicLoadNInt32(db+312, 0) != 0) {
  45569 		goto __5
  45570 	}
  45571 	goto abort_due_to_interrupt
  45572 __5:
  45573 	;
  45574 	pOp = aOp + uintptr((*Vdbe)(unsafe.Pointer(p)).Fpc)*20
  45575 __6:
  45576 	if !(1 != 0) {
  45577 		goto __8
  45578 	}
  45579 
  45580 	nVmStep++
  45581 
  45582 	switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) {
  45583 	case OP_Goto:
  45584 		goto __10
  45585 
  45586 	case OP_Gosub:
  45587 		goto __11
  45588 
  45589 	case OP_Return:
  45590 		goto __12
  45591 
  45592 	case OP_InitCoroutine:
  45593 		goto __13
  45594 
  45595 	case OP_EndCoroutine:
  45596 		goto __14
  45597 
  45598 	case OP_Yield:
  45599 		goto __15
  45600 
  45601 	case OP_HaltIfNull:
  45602 		goto __16
  45603 
  45604 	case OP_Halt:
  45605 		goto __17
  45606 
  45607 	case OP_Integer:
  45608 		goto __18
  45609 
  45610 	case OP_Int64:
  45611 		goto __19
  45612 
  45613 	case OP_Real:
  45614 		goto __20
  45615 
  45616 	case OP_String8:
  45617 		goto __21
  45618 
  45619 	case OP_String:
  45620 		goto __22
  45621 
  45622 	case OP_BeginSubrtn:
  45623 		goto __23
  45624 	case OP_Null:
  45625 		goto __24
  45626 
  45627 	case OP_SoftNull:
  45628 		goto __25
  45629 
  45630 	case OP_Blob:
  45631 		goto __26
  45632 
  45633 	case OP_Variable:
  45634 		goto __27
  45635 
  45636 	case OP_Move:
  45637 		goto __28
  45638 
  45639 	case OP_Copy:
  45640 		goto __29
  45641 
  45642 	case OP_SCopy:
  45643 		goto __30
  45644 
  45645 	case OP_IntCopy:
  45646 		goto __31
  45647 
  45648 	case OP_FkCheck:
  45649 		goto __32
  45650 
  45651 	case OP_ResultRow:
  45652 		goto __33
  45653 
  45654 	case OP_Concat:
  45655 		goto __34
  45656 
  45657 	case OP_Add:
  45658 		goto __35
  45659 	case OP_Subtract:
  45660 		goto __36
  45661 	case OP_Multiply:
  45662 		goto __37
  45663 	case OP_Divide:
  45664 		goto __38
  45665 	case OP_Remainder:
  45666 		goto __39
  45667 
  45668 	case OP_CollSeq:
  45669 		goto __40
  45670 
  45671 	case OP_BitAnd:
  45672 		goto __41
  45673 	case OP_BitOr:
  45674 		goto __42
  45675 	case OP_ShiftLeft:
  45676 		goto __43
  45677 	case OP_ShiftRight:
  45678 		goto __44
  45679 
  45680 	case OP_AddImm:
  45681 		goto __45
  45682 
  45683 	case OP_MustBeInt:
  45684 		goto __46
  45685 
  45686 	case OP_RealAffinity:
  45687 		goto __47
  45688 
  45689 	case OP_Cast:
  45690 		goto __48
  45691 
  45692 	case OP_Eq:
  45693 		goto __49
  45694 	case OP_Ne:
  45695 		goto __50
  45696 	case OP_Lt:
  45697 		goto __51
  45698 	case OP_Le:
  45699 		goto __52
  45700 	case OP_Gt:
  45701 		goto __53
  45702 	case OP_Ge:
  45703 		goto __54
  45704 
  45705 	case OP_ElseEq:
  45706 		goto __55
  45707 
  45708 	case OP_Permutation:
  45709 		goto __56
  45710 
  45711 	case OP_Compare:
  45712 		goto __57
  45713 
  45714 	case OP_Jump:
  45715 		goto __58
  45716 
  45717 	case OP_And:
  45718 		goto __59
  45719 	case OP_Or:
  45720 		goto __60
  45721 
  45722 	case OP_IsTrue:
  45723 		goto __61
  45724 
  45725 	case OP_Not:
  45726 		goto __62
  45727 
  45728 	case OP_BitNot:
  45729 		goto __63
  45730 
  45731 	case OP_Once:
  45732 		goto __64
  45733 
  45734 	case OP_If:
  45735 		goto __65
  45736 
  45737 	case OP_IfNot:
  45738 		goto __66
  45739 
  45740 	case OP_IsNull:
  45741 		goto __67
  45742 
  45743 	case OP_IsType:
  45744 		goto __68
  45745 
  45746 	case OP_ZeroOrNull:
  45747 		goto __69
  45748 
  45749 	case OP_NotNull:
  45750 		goto __70
  45751 
  45752 	case OP_IfNullRow:
  45753 		goto __71
  45754 
  45755 	case OP_Offset:
  45756 		goto __72
  45757 
  45758 	case OP_Column:
  45759 		goto __73
  45760 
  45761 	case OP_TypeCheck:
  45762 		goto __74
  45763 
  45764 	case OP_Affinity:
  45765 		goto __75
  45766 
  45767 	case OP_MakeRecord:
  45768 		goto __76
  45769 
  45770 	case OP_Count:
  45771 		goto __77
  45772 
  45773 	case OP_Savepoint:
  45774 		goto __78
  45775 
  45776 	case OP_AutoCommit:
  45777 		goto __79
  45778 
  45779 	case OP_Transaction:
  45780 		goto __80
  45781 
  45782 	case OP_ReadCookie:
  45783 		goto __81
  45784 
  45785 	case OP_SetCookie:
  45786 		goto __82
  45787 
  45788 	case OP_ReopenIdx:
  45789 		goto __83
  45790 
  45791 	case OP_OpenRead:
  45792 		goto __84
  45793 	case OP_OpenWrite:
  45794 		goto __85
  45795 
  45796 	case OP_OpenDup:
  45797 		goto __86
  45798 
  45799 	case OP_OpenAutoindex:
  45800 		goto __87
  45801 	case OP_OpenEphemeral:
  45802 		goto __88
  45803 
  45804 	case OP_SorterOpen:
  45805 		goto __89
  45806 
  45807 	case OP_SequenceTest:
  45808 		goto __90
  45809 
  45810 	case OP_OpenPseudo:
  45811 		goto __91
  45812 
  45813 	case OP_Close:
  45814 		goto __92
  45815 
  45816 	case OP_SeekLT:
  45817 		goto __93
  45818 	case OP_SeekLE:
  45819 		goto __94
  45820 	case OP_SeekGE:
  45821 		goto __95
  45822 	case OP_SeekGT:
  45823 		goto __96
  45824 
  45825 	case OP_SeekScan:
  45826 		goto __97
  45827 
  45828 	case OP_SeekHit:
  45829 		goto __98
  45830 
  45831 	case OP_IfNotOpen:
  45832 		goto __99
  45833 
  45834 	case OP_IfNoHope:
  45835 		goto __100
  45836 	case OP_NoConflict:
  45837 		goto __101
  45838 	case OP_NotFound:
  45839 		goto __102
  45840 	case OP_Found:
  45841 		goto __103
  45842 
  45843 	case OP_SeekRowid:
  45844 		goto __104
  45845 	case OP_NotExists:
  45846 		goto __105
  45847 
  45848 	case OP_Sequence:
  45849 		goto __106
  45850 
  45851 	case OP_NewRowid:
  45852 		goto __107
  45853 
  45854 	case OP_Insert:
  45855 		goto __108
  45856 
  45857 	case OP_RowCell:
  45858 		goto __109
  45859 
  45860 	case OP_Delete:
  45861 		goto __110
  45862 
  45863 	case OP_ResetCount:
  45864 		goto __111
  45865 
  45866 	case OP_SorterCompare:
  45867 		goto __112
  45868 
  45869 	case OP_SorterData:
  45870 		goto __113
  45871 
  45872 	case OP_RowData:
  45873 		goto __114
  45874 
  45875 	case OP_Rowid:
  45876 		goto __115
  45877 
  45878 	case OP_NullRow:
  45879 		goto __116
  45880 
  45881 	case OP_SeekEnd:
  45882 		goto __117
  45883 	case OP_Last:
  45884 		goto __118
  45885 
  45886 	case OP_IfSmaller:
  45887 		goto __119
  45888 
  45889 	case OP_SorterSort:
  45890 		goto __120
  45891 	case OP_Sort:
  45892 		goto __121
  45893 
  45894 	case OP_Rewind:
  45895 		goto __122
  45896 
  45897 	case OP_SorterNext:
  45898 		goto __123
  45899 
  45900 	case OP_Prev:
  45901 		goto __124
  45902 
  45903 	case OP_Next:
  45904 		goto __125
  45905 
  45906 	case OP_IdxInsert:
  45907 		goto __126
  45908 
  45909 	case OP_SorterInsert:
  45910 		goto __127
  45911 
  45912 	case OP_IdxDelete:
  45913 		goto __128
  45914 
  45915 	case OP_DeferredSeek:
  45916 		goto __129
  45917 	case OP_IdxRowid:
  45918 		goto __130
  45919 
  45920 	case OP_FinishSeek:
  45921 		goto __131
  45922 
  45923 	case OP_IdxLE:
  45924 		goto __132
  45925 	case OP_IdxGT:
  45926 		goto __133
  45927 	case OP_IdxLT:
  45928 		goto __134
  45929 	case OP_IdxGE:
  45930 		goto __135
  45931 
  45932 	case OP_Destroy:
  45933 		goto __136
  45934 
  45935 	case OP_Clear:
  45936 		goto __137
  45937 
  45938 	case OP_ResetSorter:
  45939 		goto __138
  45940 
  45941 	case OP_CreateBtree:
  45942 		goto __139
  45943 
  45944 	case OP_SqlExec:
  45945 		goto __140
  45946 
  45947 	case OP_ParseSchema:
  45948 		goto __141
  45949 
  45950 	case OP_LoadAnalysis:
  45951 		goto __142
  45952 
  45953 	case OP_DropTable:
  45954 		goto __143
  45955 
  45956 	case OP_DropIndex:
  45957 		goto __144
  45958 
  45959 	case OP_DropTrigger:
  45960 		goto __145
  45961 
  45962 	case OP_IntegrityCk:
  45963 		goto __146
  45964 
  45965 	case OP_RowSetAdd:
  45966 		goto __147
  45967 
  45968 	case OP_RowSetRead:
  45969 		goto __148
  45970 
  45971 	case OP_RowSetTest:
  45972 		goto __149
  45973 
  45974 	case OP_Program:
  45975 		goto __150
  45976 
  45977 	case OP_Param:
  45978 		goto __151
  45979 
  45980 	case OP_FkCounter:
  45981 		goto __152
  45982 
  45983 	case OP_FkIfZero:
  45984 		goto __153
  45985 
  45986 	case OP_MemMax:
  45987 		goto __154
  45988 
  45989 	case OP_IfPos:
  45990 		goto __155
  45991 
  45992 	case OP_OffsetLimit:
  45993 		goto __156
  45994 
  45995 	case OP_IfNotZero:
  45996 		goto __157
  45997 
  45998 	case OP_DecrJumpZero:
  45999 		goto __158
  46000 
  46001 	case OP_AggInverse:
  46002 		goto __159
  46003 	case OP_AggStep:
  46004 		goto __160
  46005 	case OP_AggStep1:
  46006 		goto __161
  46007 
  46008 	case OP_AggValue:
  46009 		goto __162
  46010 	case OP_AggFinal:
  46011 		goto __163
  46012 
  46013 	case OP_Checkpoint:
  46014 		goto __164
  46015 
  46016 	case OP_JournalMode:
  46017 		goto __165
  46018 
  46019 	case OP_Vacuum:
  46020 		goto __166
  46021 
  46022 	case OP_IncrVacuum:
  46023 		goto __167
  46024 
  46025 	case OP_Expire:
  46026 		goto __168
  46027 
  46028 	case OP_CursorLock:
  46029 		goto __169
  46030 
  46031 	case OP_CursorUnlock:
  46032 		goto __170
  46033 
  46034 	case OP_TableLock:
  46035 		goto __171
  46036 
  46037 	case OP_VBegin:
  46038 		goto __172
  46039 
  46040 	case OP_VCreate:
  46041 		goto __173
  46042 
  46043 	case OP_VDestroy:
  46044 		goto __174
  46045 
  46046 	case OP_VOpen:
  46047 		goto __175
  46048 
  46049 	case OP_VInitIn:
  46050 		goto __176
  46051 
  46052 	case OP_VFilter:
  46053 		goto __177
  46054 
  46055 	case OP_VColumn:
  46056 		goto __178
  46057 
  46058 	case OP_VNext:
  46059 		goto __179
  46060 
  46061 	case OP_VRename:
  46062 		goto __180
  46063 
  46064 	case OP_VUpdate:
  46065 		goto __181
  46066 
  46067 	case OP_Pagecount:
  46068 		goto __182
  46069 
  46070 	case OP_MaxPgcnt:
  46071 		goto __183
  46072 
  46073 	case OP_PureFunc:
  46074 		goto __184
  46075 	case OP_Function:
  46076 		goto __185
  46077 
  46078 	case OP_ClrSubtype:
  46079 		goto __186
  46080 
  46081 	case OP_FilterAdd:
  46082 		goto __187
  46083 
  46084 	case OP_Filter:
  46085 		goto __188
  46086 
  46087 	case OP_Trace:
  46088 		goto __189
  46089 	case OP_Init:
  46090 		goto __190
  46091 
  46092 	default:
  46093 		goto __191
  46094 	}
  46095 	goto __9
  46096 
  46097 __10:
  46098 jump_to_p2_and_check_for_interrupt:
  46099 	pOp = aOp + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2-1)*20
  46100 
  46101 check_for_interrupt:
  46102 	if !(libc.AtomicLoadNInt32(db+312, 0) != 0) {
  46103 		goto __192
  46104 	}
  46105 	goto abort_due_to_interrupt
  46106 __192:
  46107 	;
  46108 __193:
  46109 	if !(nVmStep >= nProgressLimit && (*Sqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0)) {
  46110 		goto __194
  46111 	}
  46112 
  46113 	nProgressLimit = nProgressLimit + U64((*Sqlite3)(unsafe.Pointer(db)).FnProgressOps)
  46114 	if !((*struct {
  46115 		f func(*libc.TLS, uintptr) int32
  46116 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxProgress})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0) {
  46117 		goto __195
  46118 	}
  46119 	nProgressLimit = uint64(0xffffffff) | uint64(0xffffffff)<<32
  46120 	rc = SQLITE_INTERRUPT
  46121 	goto abort_due_to_error
  46122 __195:
  46123 	;
  46124 	goto __193
  46125 __194:
  46126 	;
  46127 	goto __9
  46128 
  46129 __11:
  46130 	;
  46131 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46132 
  46133 	(*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(MEM_Int)
  46134 	*(*I64)(unsafe.Pointer(pIn1)) = I64((int32(pOp) - int32(aOp)) / 20)
  46135 
  46136 	goto jump_to_p2_and_check_for_interrupt
  46137 
  46138 __12:
  46139 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46140 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Int != 0) {
  46141 		goto __196
  46142 	}
  46143 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  46144 		goto __198
  46145 	}
  46146 __198:
  46147 	;
  46148 	pOp = aOp + uintptr(*(*I64)(unsafe.Pointer(pIn1)))*20
  46149 	goto __197
  46150 __196:
  46151 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  46152 		goto __199
  46153 	}
  46154 
  46155 __199:
  46156 	;
  46157 __197:
  46158 	;
  46159 	goto __9
  46160 
  46161 __13:
  46162 	;
  46163 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46164 
  46165 	*(*I64)(unsafe.Pointer(pOut)) = I64((*Op)(unsafe.Pointer(pOp)).Fp3 - 1)
  46166 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Int)
  46167 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 0) {
  46168 		goto __200
  46169 	}
  46170 	goto __9
  46171 __200:
  46172 	;
  46173 jump_to_p2:
  46174 	;
  46175 	pOp = aOp + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2-1)*20
  46176 	goto __9
  46177 
  46178 __14:
  46179 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46180 
  46181 	pCaller = aOp + uintptr(*(*I64)(unsafe.Pointer(pIn1)))*20
  46182 
  46183 	pOp = aOp + uintptr((*VdbeOp)(unsafe.Pointer(pCaller)).Fp2-1)*20
  46184 	(*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(MEM_Undefined)
  46185 	goto __9
  46186 
  46187 __15:
  46188 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46189 
  46190 	(*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(MEM_Int)
  46191 	pcDest = int32(*(*I64)(unsafe.Pointer(pIn1)))
  46192 	*(*I64)(unsafe.Pointer(pIn1)) = I64((int32(pOp) - int32(aOp)) / 20)
  46193 
  46194 	pOp = aOp + uintptr(pcDest)*20
  46195 	goto __9
  46196 
  46197 __16:
  46198 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  46199 	if !(int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)&MEM_Null == 0) {
  46200 		goto __201
  46201 	}
  46202 	goto __9
  46203 __201:
  46204 	;
  46205 __17:
  46206 	;
  46207 	if !((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0 && (*Op)(unsafe.Pointer(pOp)).Fp1 == SQLITE_OK) {
  46208 		goto __202
  46209 	}
  46210 
  46211 	pFrame = (*Vdbe)(unsafe.Pointer(p)).FpFrame
  46212 	(*Vdbe)(unsafe.Pointer(p)).FpFrame = (*VdbeFrame)(unsafe.Pointer(pFrame)).FpParent
  46213 	(*Vdbe)(unsafe.Pointer(p)).FnFrame--
  46214 	Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange)
  46215 	pcx = Xsqlite3VdbeFrameRestore(tls, pFrame)
  46216 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 == OE_Ignore) {
  46217 		goto __203
  46218 	}
  46219 
  46220 	pcx = (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(pcx)*20)).Fp2 - 1
  46221 __203:
  46222 	;
  46223 	aOp = (*Vdbe)(unsafe.Pointer(p)).FaOp
  46224 	aMem = (*Vdbe)(unsafe.Pointer(p)).FaMem
  46225 	pOp = aOp + uintptr(pcx)*20
  46226 	goto __9
  46227 __202:
  46228 	;
  46229 	(*Vdbe)(unsafe.Pointer(p)).Frc = (*Op)(unsafe.Pointer(pOp)).Fp1
  46230 	(*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8((*Op)(unsafe.Pointer(pOp)).Fp2)
  46231 
  46232 	if !((*Vdbe)(unsafe.Pointer(p)).Frc != 0) {
  46233 		goto __204
  46234 	}
  46235 	if !((*Op)(unsafe.Pointer(pOp)).Fp5 != 0) {
  46236 		goto __205
  46237 	}
  46238 
  46239 	Xsqlite3VdbeError(tls, p, ts+5431, libc.VaList(bp, azType[int32((*Op)(unsafe.Pointer(pOp)).Fp5)-1]))
  46240 	if !(*(*uintptr)(unsafe.Pointer(pOp + 16)) != 0) {
  46241 		goto __207
  46242 	}
  46243 	(*Vdbe)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3MPrintf(tls, db, ts+5452, libc.VaList(bp+8, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg, *(*uintptr)(unsafe.Pointer(pOp + 16))))
  46244 __207:
  46245 	;
  46246 	goto __206
  46247 __205:
  46248 	Xsqlite3VdbeError(tls, p, ts+3663, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(pOp + 16))))
  46249 __206:
  46250 	;
  46251 	pcx = (int32(pOp) - int32(aOp)) / 20
  46252 	Xsqlite3_log(tls, (*Op)(unsafe.Pointer(pOp)).Fp1, ts+5459, libc.VaList(bp+32, pcx, (*Vdbe)(unsafe.Pointer(p)).FzSql, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg))
  46253 __204:
  46254 	;
  46255 	rc = Xsqlite3VdbeHalt(tls, p)
  46256 
  46257 	if !(rc == SQLITE_BUSY) {
  46258 		goto __208
  46259 	}
  46260 	(*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_BUSY
  46261 	goto __209
  46262 __208:
  46263 	;
  46264 	if (*Vdbe)(unsafe.Pointer(p)).Frc != 0 {
  46265 		rc = SQLITE_ERROR
  46266 	} else {
  46267 		rc = SQLITE_DONE
  46268 	}
  46269 __209:
  46270 	;
  46271 	goto vdbe_return
  46272 
  46273 __18:
  46274 	pOut = out2Prerelease(tls, p, pOp)
  46275 	*(*I64)(unsafe.Pointer(pOut)) = I64((*Op)(unsafe.Pointer(pOp)).Fp1)
  46276 	goto __9
  46277 
  46278 __19:
  46279 	pOut = out2Prerelease(tls, p, pOp)
  46280 
  46281 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16))))
  46282 	goto __9
  46283 
  46284 __20:
  46285 	pOut = out2Prerelease(tls, p, pOp)
  46286 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Real)
  46287 
  46288 	*(*float64)(unsafe.Pointer(pOut)) = *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16))))
  46289 	goto __9
  46290 
  46291 __21:
  46292 	;
  46293 	pOut = out2Prerelease(tls, p, pOp)
  46294 	(*Op)(unsafe.Pointer(pOp)).Fp1 = Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  46295 
  46296 	if !(int32(encoding) != SQLITE_UTF8) {
  46297 		goto __210
  46298 	}
  46299 	rc = Xsqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64(-1), uint8(SQLITE_UTF8), uintptr(0))
  46300 
  46301 	if !(rc != 0) {
  46302 		goto __211
  46303 	}
  46304 	goto too_big
  46305 __211:
  46306 	;
  46307 	if !(SQLITE_OK != Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding))) {
  46308 		goto __212
  46309 	}
  46310 	goto no_mem
  46311 __212:
  46312 	;
  46313 	(*Mem)(unsafe.Pointer(pOut)).FszMalloc = 0
  46314 	*(*U16)(unsafe.Pointer(pOut + 16)) |= U16(MEM_Static)
  46315 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == -6) {
  46316 		goto __213
  46317 	}
  46318 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  46319 __213:
  46320 	;
  46321 	(*Op)(unsafe.Pointer(pOp)).Fp4type = int8(-6)
  46322 	*(*uintptr)(unsafe.Pointer(pOp + 16)) = (*Mem)(unsafe.Pointer(pOut)).Fz
  46323 	(*Op)(unsafe.Pointer(pOp)).Fp1 = (*Mem)(unsafe.Pointer(pOut)).Fn
  46324 __210:
  46325 	;
  46326 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 > *(*int32)(unsafe.Pointer(db + 120))) {
  46327 		goto __214
  46328 	}
  46329 	goto too_big
  46330 __214:
  46331 	;
  46332 	(*Op)(unsafe.Pointer(pOp)).Fopcode = U8(OP_String)
  46333 
  46334 __22:
  46335 	;
  46336 	pOut = out2Prerelease(tls, p, pOp)
  46337 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Str | MEM_Static | MEM_Term)
  46338 	(*Mem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16))
  46339 	(*Mem)(unsafe.Pointer(pOut)).Fn = (*Op)(unsafe.Pointer(pOp)).Fp1
  46340 	(*Mem)(unsafe.Pointer(pOut)).Fenc = encoding
  46341 
  46342 	goto __9
  46343 
  46344 __23:
  46345 __24:
  46346 	pOut = out2Prerelease(tls, p, pOp)
  46347 	cnt = (*Op)(unsafe.Pointer(pOp)).Fp3 - (*Op)(unsafe.Pointer(pOp)).Fp2
  46348 
  46349 	(*Mem)(unsafe.Pointer(pOut)).Fflags = libc.AssignUint16(&nullFlag, func() uint16 {
  46350 		if (*Op)(unsafe.Pointer(pOp)).Fp1 != 0 {
  46351 			return uint16(MEM_Null | MEM_Cleared)
  46352 		}
  46353 		return uint16(MEM_Null)
  46354 	}())
  46355 	(*Mem)(unsafe.Pointer(pOut)).Fn = 0
  46356 __215:
  46357 	if !(cnt > 0) {
  46358 		goto __216
  46359 	}
  46360 	pOut += 40
  46361 
  46362 	Xsqlite3VdbeMemSetNull(tls, pOut)
  46363 	(*Mem)(unsafe.Pointer(pOut)).Fflags = nullFlag
  46364 	(*Mem)(unsafe.Pointer(pOut)).Fn = 0
  46365 	cnt--
  46366 	goto __215
  46367 __216:
  46368 	;
  46369 	goto __9
  46370 
  46371 __25:
  46372 	;
  46373 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46374 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_Undefined|MEM_AffMask) | MEM_Null)
  46375 	goto __9
  46376 
  46377 __26:
  46378 	;
  46379 	pOut = out2Prerelease(tls, p, pOp)
  46380 	if !(*(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0)) {
  46381 		goto __217
  46382 	}
  46383 	Xsqlite3VdbeMemSetZeroBlob(tls, pOut, (*Op)(unsafe.Pointer(pOp)).Fp1)
  46384 	if !(Xsqlite3VdbeMemExpandBlob(tls, pOut) != 0) {
  46385 		goto __219
  46386 	}
  46387 	goto no_mem
  46388 __219:
  46389 	;
  46390 	goto __218
  46391 __217:
  46392 	Xsqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64((*Op)(unsafe.Pointer(pOp)).Fp1), uint8(0), uintptr(0))
  46393 __218:
  46394 	;
  46395 	(*Mem)(unsafe.Pointer(pOut)).Fenc = encoding
  46396 
  46397 	goto __9
  46398 
  46399 __27:
  46400 	;
  46401 	pVar = (*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1-1)*40
  46402 	if !(Xsqlite3VdbeMemTooBig(tls, pVar) != 0) {
  46403 		goto __220
  46404 	}
  46405 	goto too_big
  46406 __220:
  46407 	;
  46408 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46409 	if !(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&(MEM_Agg|MEM_Dyn) != 0) {
  46410 		goto __221
  46411 	}
  46412 	Xsqlite3VdbeMemSetNull(tls, pOut)
  46413 __221:
  46414 	;
  46415 	libc.Xmemcpy(tls, pOut, pVar, uint32(uintptr(0)+20))
  46416 	*(*U16)(unsafe.Pointer(pOut + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Dyn | MEM_Ephem))
  46417 	*(*U16)(unsafe.Pointer(pOut + 16)) |= U16(MEM_Static | MEM_FromBind)
  46418 
  46419 	goto __9
  46420 
  46421 __28:
  46422 	n = (*Op)(unsafe.Pointer(pOp)).Fp3
  46423 	p1 = (*Op)(unsafe.Pointer(pOp)).Fp1
  46424 	p2 = (*Op)(unsafe.Pointer(pOp)).Fp2
  46425 
  46426 	pIn1 = aMem + uintptr(p1)*40
  46427 	pOut = aMem + uintptr(p2)*40
  46428 __222:
  46429 	;
  46430 	Xsqlite3VdbeMemMove(tls, pOut, pIn1)
  46431 	if !(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&MEM_Ephem != 0 && Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0) {
  46432 		goto __225
  46433 	}
  46434 	goto no_mem
  46435 __225:
  46436 	;
  46437 	pIn1 += 40
  46438 	pOut += 40
  46439 	goto __223
  46440 __223:
  46441 	if libc.PreDecInt32(&n, 1) != 0 {
  46442 		goto __222
  46443 	}
  46444 	goto __224
  46445 __224:
  46446 	;
  46447 	goto __9
  46448 
  46449 __29:
  46450 	n1 = (*Op)(unsafe.Pointer(pOp)).Fp3
  46451 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46452 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46453 
  46454 __226:
  46455 	if !(1 != 0) {
  46456 		goto __227
  46457 	}
  46458 
  46459 	Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, MEM_Ephem)
  46460 	if !(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&MEM_Ephem != 0 && Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0) {
  46461 		goto __228
  46462 	}
  46463 	goto no_mem
  46464 __228:
  46465 	;
  46466 	if !(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&MEM_Subtype != 0 && int32((*Op)(unsafe.Pointer(pOp)).Fp5)&0x0002 != 0) {
  46467 		goto __229
  46468 	}
  46469 	*(*U16)(unsafe.Pointer(pOut + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Subtype))
  46470 __229:
  46471 	;
  46472 	if !(libc.PostDecInt32(&n1, 1) == 0) {
  46473 		goto __230
  46474 	}
  46475 	goto __227
  46476 __230:
  46477 	;
  46478 	pOut += 40
  46479 	pIn1 += 40
  46480 	goto __226
  46481 __227:
  46482 	;
  46483 	goto __9
  46484 
  46485 __30:
  46486 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46487 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46488 
  46489 	Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, MEM_Ephem)
  46490 	goto __9
  46491 
  46492 __31:
  46493 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46494 
  46495 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46496 	Xsqlite3VdbeMemSetInt64(tls, pOut, *(*I64)(unsafe.Pointer(pIn1)))
  46497 	goto __9
  46498 
  46499 __32:
  46500 	if !(libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 0)) != SQLITE_OK) {
  46501 		goto __231
  46502 	}
  46503 	goto abort_due_to_error
  46504 __231:
  46505 	;
  46506 	goto __9
  46507 
  46508 __33:
  46509 	;
  46510 	(*Vdbe)(unsafe.Pointer(p)).FcacheCtr = (*Vdbe)(unsafe.Pointer(p)).FcacheCtr + U32(2) | U32(1)
  46511 	(*Vdbe)(unsafe.Pointer(p)).FpResultRow = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46512 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  46513 		goto __232
  46514 	}
  46515 	goto no_mem
  46516 __232:
  46517 	;
  46518 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace)&SQLITE_TRACE_ROW != 0) {
  46519 		goto __233
  46520 	}
  46521 	(*struct {
  46522 		f func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32
  46523 	})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(db + 216))})).f(tls, uint32(SQLITE_TRACE_ROW), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0))
  46524 __233:
  46525 	;
  46526 	(*Vdbe)(unsafe.Pointer(p)).Fpc = (int32(pOp)-int32(aOp))/20 + 1
  46527 	rc = SQLITE_ROW
  46528 	goto vdbe_return
  46529 
  46530 __34:
  46531 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46532 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46533 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  46534 
  46535 	flags1 = (*Mem)(unsafe.Pointer(pIn1)).Fflags
  46536 
  46537 	if !((int32(flags1)|int32((*Mem)(unsafe.Pointer(pIn2)).Fflags))&MEM_Null != 0) {
  46538 		goto __234
  46539 	}
  46540 	Xsqlite3VdbeMemSetNull(tls, pOut)
  46541 	goto __9
  46542 __234:
  46543 	;
  46544 	if !(int32(flags1)&(MEM_Str|MEM_Blob) == 0) {
  46545 		goto __235
  46546 	}
  46547 	if !(Xsqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0) {
  46548 		goto __237
  46549 	}
  46550 	goto no_mem
  46551 __237:
  46552 	;
  46553 	flags1 = U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_Str))
  46554 	goto __236
  46555 __235:
  46556 	if !(int32(flags1)&MEM_Zero != 0) {
  46557 		goto __238
  46558 	}
  46559 	if !(Xsqlite3VdbeMemExpandBlob(tls, pIn1) != 0) {
  46560 		goto __239
  46561 	}
  46562 	goto no_mem
  46563 __239:
  46564 	;
  46565 	flags1 = U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_Str))
  46566 __238:
  46567 	;
  46568 __236:
  46569 	;
  46570 	flags2 = (*Mem)(unsafe.Pointer(pIn2)).Fflags
  46571 	if !(int32(flags2)&(MEM_Str|MEM_Blob) == 0) {
  46572 		goto __240
  46573 	}
  46574 	if !(Xsqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0) {
  46575 		goto __242
  46576 	}
  46577 	goto no_mem
  46578 __242:
  46579 	;
  46580 	flags2 = U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & libc.CplInt32(MEM_Str))
  46581 	goto __241
  46582 __240:
  46583 	if !(int32(flags2)&MEM_Zero != 0) {
  46584 		goto __243
  46585 	}
  46586 	if !(Xsqlite3VdbeMemExpandBlob(tls, pIn2) != 0) {
  46587 		goto __244
  46588 	}
  46589 	goto no_mem
  46590 __244:
  46591 	;
  46592 	flags2 = U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & libc.CplInt32(MEM_Str))
  46593 __243:
  46594 	;
  46595 __241:
  46596 	;
  46597 	nByte = I64((*Mem)(unsafe.Pointer(pIn1)).Fn + (*Mem)(unsafe.Pointer(pIn2)).Fn)
  46598 	if !(nByte > I64(*(*int32)(unsafe.Pointer(db + 120)))) {
  46599 		goto __245
  46600 	}
  46601 	goto too_big
  46602 __245:
  46603 	;
  46604 	if !(Xsqlite3VdbeMemGrow(tls, pOut, int32(nByte)+2, libc.Bool32(pOut == pIn2)) != 0) {
  46605 		goto __246
  46606 	}
  46607 	goto no_mem
  46608 __246:
  46609 	;
  46610 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Str)
  46611 	if !(pOut != pIn2) {
  46612 		goto __247
  46613 	}
  46614 	libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pOut)).Fz, (*Mem)(unsafe.Pointer(pIn2)).Fz, uint32((*Mem)(unsafe.Pointer(pIn2)).Fn))
  46615 
  46616 	(*Mem)(unsafe.Pointer(pIn2)).Fflags = flags2
  46617 __247:
  46618 	;
  46619 	libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pOut)).Fz+uintptr((*Mem)(unsafe.Pointer(pIn2)).Fn), (*Mem)(unsafe.Pointer(pIn1)).Fz, uint32((*Mem)(unsafe.Pointer(pIn1)).Fn))
  46620 
  46621 	(*Mem)(unsafe.Pointer(pIn1)).Fflags = flags1
  46622 	if !(int32(encoding) > SQLITE_UTF8) {
  46623 		goto __248
  46624 	}
  46625 	nByte = nByte & int64(libc.CplInt32(1))
  46626 __248:
  46627 	;
  46628 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = uint8(0)
  46629 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte+int64(1)))) = uint8(0)
  46630 	*(*U16)(unsafe.Pointer(pOut + 16)) |= U16(MEM_Term)
  46631 	(*Mem)(unsafe.Pointer(pOut)).Fn = int32(nByte)
  46632 	(*Mem)(unsafe.Pointer(pOut)).Fenc = encoding
  46633 
  46634 	goto __9
  46635 
  46636 __35:
  46637 __36:
  46638 __37:
  46639 __38:
  46640 __39:
  46641 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46642 	type1 = (*Mem)(unsafe.Pointer(pIn1)).Fflags
  46643 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46644 	type2 = (*Mem)(unsafe.Pointer(pIn2)).Fflags
  46645 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  46646 	if !(int32(type1)&int32(type2)&MEM_Int != 0) {
  46647 		goto __249
  46648 	}
  46649 int_math:
  46650 	iA = *(*I64)(unsafe.Pointer(pIn1))
  46651 	*(*I64)(unsafe.Pointer(bp + 208)) = *(*I64)(unsafe.Pointer(pIn2))
  46652 	switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) {
  46653 	case OP_Add:
  46654 		goto __252
  46655 	case OP_Subtract:
  46656 		goto __253
  46657 	case OP_Multiply:
  46658 		goto __254
  46659 	case OP_Divide:
  46660 		goto __255
  46661 	default:
  46662 		goto __256
  46663 	}
  46664 	goto __251
  46665 __252:
  46666 	if !(Xsqlite3AddInt64(tls, bp+208, iA) != 0) {
  46667 		goto __257
  46668 	}
  46669 	goto fp_math
  46670 __257:
  46671 	;
  46672 	goto __251
  46673 __253:
  46674 	if !(Xsqlite3SubInt64(tls, bp+208, iA) != 0) {
  46675 		goto __258
  46676 	}
  46677 	goto fp_math
  46678 __258:
  46679 	;
  46680 	goto __251
  46681 __254:
  46682 	if !(Xsqlite3MulInt64(tls, bp+208, iA) != 0) {
  46683 		goto __259
  46684 	}
  46685 	goto fp_math
  46686 __259:
  46687 	;
  46688 	goto __251
  46689 __255:
  46690 	if !(iA == int64(0)) {
  46691 		goto __260
  46692 	}
  46693 	goto arithmetic_result_is_null
  46694 __260:
  46695 	;
  46696 	if !(iA == int64(-1) && *(*I64)(unsafe.Pointer(bp + 208)) == int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32)) {
  46697 		goto __261
  46698 	}
  46699 	goto fp_math
  46700 __261:
  46701 	;
  46702 	*(*I64)(unsafe.Pointer(bp + 208)) /= iA
  46703 	goto __251
  46704 
  46705 __256:
  46706 	if !(iA == int64(0)) {
  46707 		goto __262
  46708 	}
  46709 	goto arithmetic_result_is_null
  46710 __262:
  46711 	;
  46712 	if !(iA == int64(-1)) {
  46713 		goto __263
  46714 	}
  46715 	iA = int64(1)
  46716 __263:
  46717 	;
  46718 	*(*I64)(unsafe.Pointer(bp + 208)) %= iA
  46719 	goto __251
  46720 
  46721 __251:
  46722 	;
  46723 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 208))
  46724 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  46725 	goto __250
  46726 __249:
  46727 	if !((int32(type1)|int32(type2))&MEM_Null != 0) {
  46728 		goto __264
  46729 	}
  46730 	goto arithmetic_result_is_null
  46731 	goto __265
  46732 __264:
  46733 	type1 = numericType(tls, pIn1)
  46734 	type2 = numericType(tls, pIn2)
  46735 	if !(int32(type1)&int32(type2)&MEM_Int != 0) {
  46736 		goto __266
  46737 	}
  46738 	goto int_math
  46739 __266:
  46740 	;
  46741 fp_math:
  46742 	rA = Xsqlite3VdbeRealValue(tls, pIn1)
  46743 	rB = Xsqlite3VdbeRealValue(tls, pIn2)
  46744 	switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) {
  46745 	case OP_Add:
  46746 		goto __268
  46747 	case OP_Subtract:
  46748 		goto __269
  46749 	case OP_Multiply:
  46750 		goto __270
  46751 	case OP_Divide:
  46752 		goto __271
  46753 	default:
  46754 		goto __272
  46755 	}
  46756 	goto __267
  46757 __268:
  46758 	rB = rB + rA
  46759 	goto __267
  46760 __269:
  46761 	rB = rB - rA
  46762 	goto __267
  46763 __270:
  46764 	rB = rB * rA
  46765 	goto __267
  46766 __271:
  46767 	if !(rA == float64(0)) {
  46768 		goto __273
  46769 	}
  46770 	goto arithmetic_result_is_null
  46771 __273:
  46772 	;
  46773 	rB = rB / rA
  46774 	goto __267
  46775 
  46776 __272:
  46777 	iA = Xsqlite3VdbeIntValue(tls, pIn1)
  46778 	*(*I64)(unsafe.Pointer(bp + 208)) = Xsqlite3VdbeIntValue(tls, pIn2)
  46779 	if !(iA == int64(0)) {
  46780 		goto __274
  46781 	}
  46782 	goto arithmetic_result_is_null
  46783 __274:
  46784 	;
  46785 	if !(iA == int64(-1)) {
  46786 		goto __275
  46787 	}
  46788 	iA = int64(1)
  46789 __275:
  46790 	;
  46791 	rB = float64(*(*I64)(unsafe.Pointer(bp + 208)) % iA)
  46792 	goto __267
  46793 
  46794 __267:
  46795 	;
  46796 	if !(Xsqlite3IsNaN(tls, rB) != 0) {
  46797 		goto __276
  46798 	}
  46799 	goto arithmetic_result_is_null
  46800 __276:
  46801 	;
  46802 	*(*float64)(unsafe.Pointer(pOut)) = rB
  46803 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Real)
  46804 __265:
  46805 	;
  46806 __250:
  46807 	;
  46808 	goto __9
  46809 
  46810 arithmetic_result_is_null:
  46811 	Xsqlite3VdbeMemSetNull(tls, pOut)
  46812 	goto __9
  46813 
  46814 __40:
  46815 	;
  46816 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 != 0) {
  46817 		goto __277
  46818 	}
  46819 	Xsqlite3VdbeMemSetInt64(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40, int64(0))
  46820 __277:
  46821 	;
  46822 	goto __9
  46823 
  46824 __41:
  46825 __42:
  46826 __43:
  46827 __44:
  46828 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46829 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  46830 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  46831 	if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)|int32((*Mem)(unsafe.Pointer(pIn2)).Fflags))&MEM_Null != 0) {
  46832 		goto __278
  46833 	}
  46834 	Xsqlite3VdbeMemSetNull(tls, pOut)
  46835 	goto __9
  46836 __278:
  46837 	;
  46838 	*(*I64)(unsafe.Pointer(bp + 224)) = Xsqlite3VdbeIntValue(tls, pIn2)
  46839 	iB1 = Xsqlite3VdbeIntValue(tls, pIn1)
  46840 	op = (*Op)(unsafe.Pointer(pOp)).Fopcode
  46841 	if !(int32(op) == OP_BitAnd) {
  46842 		goto __279
  46843 	}
  46844 	*(*I64)(unsafe.Pointer(bp + 224)) &= iB1
  46845 	goto __280
  46846 __279:
  46847 	if !(int32(op) == OP_BitOr) {
  46848 		goto __281
  46849 	}
  46850 	*(*I64)(unsafe.Pointer(bp + 224)) |= iB1
  46851 	goto __282
  46852 __281:
  46853 	if !(iB1 != int64(0)) {
  46854 		goto __283
  46855 	}
  46856 
  46857 	if !(iB1 < int64(0)) {
  46858 		goto __284
  46859 	}
  46860 
  46861 	op = U8(2*OP_ShiftLeft + 1 - int32(op))
  46862 	if iB1 > int64(-64) {
  46863 		iB1 = -iB1
  46864 	} else {
  46865 		iB1 = int64(64)
  46866 	}
  46867 __284:
  46868 	;
  46869 	if !(iB1 >= int64(64)) {
  46870 		goto __285
  46871 	}
  46872 	if *(*I64)(unsafe.Pointer(bp + 224)) >= int64(0) || int32(op) == OP_ShiftLeft {
  46873 		*(*I64)(unsafe.Pointer(bp + 224)) = int64(0)
  46874 	} else {
  46875 		*(*I64)(unsafe.Pointer(bp + 224)) = int64(-1)
  46876 	}
  46877 	goto __286
  46878 __285:
  46879 	libc.Xmemcpy(tls, bp+216, bp+224, uint32(unsafe.Sizeof(U64(0))))
  46880 	if !(int32(op) == OP_ShiftLeft) {
  46881 		goto __287
  46882 	}
  46883 	*(*U64)(unsafe.Pointer(bp + 216)) <<= iB1
  46884 	goto __288
  46885 __287:
  46886 	*(*U64)(unsafe.Pointer(bp + 216)) >>= iB1
  46887 
  46888 	if !(*(*I64)(unsafe.Pointer(bp + 224)) < int64(0)) {
  46889 		goto __289
  46890 	}
  46891 	*(*U64)(unsafe.Pointer(bp + 216)) |= (uint64(0xffffffff)<<32 | uint64(0xffffffff)) << (int64(64) - iB1)
  46892 __289:
  46893 	;
  46894 __288:
  46895 	;
  46896 	libc.Xmemcpy(tls, bp+224, bp+216, uint32(unsafe.Sizeof(I64(0))))
  46897 __286:
  46898 	;
  46899 __283:
  46900 	;
  46901 __282:
  46902 	;
  46903 __280:
  46904 	;
  46905 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 224))
  46906 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  46907 	goto __9
  46908 
  46909 __45:
  46910 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46911 
  46912 	Xsqlite3VdbeMemIntegerify(tls, pIn1)
  46913 	*(*I64)(unsafe.Pointer(pIn1)) += I64((*Op)(unsafe.Pointer(pOp)).Fp2)
  46914 	goto __9
  46915 
  46916 __46:
  46917 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46918 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Int == 0) {
  46919 		goto __290
  46920 	}
  46921 	applyAffinity(tls, pIn1, uint8(SQLITE_AFF_NUMERIC), encoding)
  46922 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Int == 0) {
  46923 		goto __291
  46924 	}
  46925 
  46926 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 0) {
  46927 		goto __292
  46928 	}
  46929 	rc = SQLITE_MISMATCH
  46930 	goto abort_due_to_error
  46931 	goto __293
  46932 __292:
  46933 	goto jump_to_p2
  46934 __293:
  46935 	;
  46936 __291:
  46937 	;
  46938 __290:
  46939 	;
  46940 	(*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  46941 	goto __9
  46942 
  46943 __47:
  46944 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46945 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&(MEM_Int|MEM_IntReal) != 0) {
  46946 		goto __294
  46947 	}
  46948 
  46949 	Xsqlite3VdbeMemRealify(tls, pIn1)
  46950 
  46951 __294:
  46952 	;
  46953 	goto __9
  46954 
  46955 __48:
  46956 	;
  46957 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46958 
  46959 	rc = func() int32 {
  46960 		if int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Zero != 0 {
  46961 			return Xsqlite3VdbeMemExpandBlob(tls, pIn1)
  46962 		}
  46963 		return 0
  46964 	}()
  46965 	if !(rc != 0) {
  46966 		goto __295
  46967 	}
  46968 	goto abort_due_to_error
  46969 __295:
  46970 	;
  46971 	rc = Xsqlite3VdbeMemCast(tls, pIn1, uint8((*Op)(unsafe.Pointer(pOp)).Fp2), encoding)
  46972 	if !(rc != 0) {
  46973 		goto __296
  46974 	}
  46975 	goto abort_due_to_error
  46976 __296:
  46977 	;
  46978 	goto __9
  46979 
  46980 __49:
  46981 __50:
  46982 __51:
  46983 __52:
  46984 __53:
  46985 __54:
  46986 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  46987 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  46988 	flags11 = (*Mem)(unsafe.Pointer(pIn1)).Fflags
  46989 	flags3 = (*Mem)(unsafe.Pointer(pIn3)).Fflags
  46990 	if !(int32(flags11)&int32(flags3)&MEM_Int != 0) {
  46991 		goto __297
  46992 	}
  46993 
  46994 	if !(*(*I64)(unsafe.Pointer(pIn3)) > *(*I64)(unsafe.Pointer(pIn1))) {
  46995 		goto __298
  46996 	}
  46997 	if !(*(*uint8)(unsafe.Pointer(Xsqlite3aGTb + uintptr((*Op)(unsafe.Pointer(pOp)).Fopcode))) != 0) {
  46998 		goto __300
  46999 	}
  47000 
  47001 	goto jump_to_p2
  47002 __300:
  47003 	;
  47004 	iCompare = +1
  47005 
  47006 	goto __299
  47007 __298:
  47008 	if !(*(*I64)(unsafe.Pointer(pIn3)) < *(*I64)(unsafe.Pointer(pIn1))) {
  47009 		goto __301
  47010 	}
  47011 	if !(*(*uint8)(unsafe.Pointer(Xsqlite3aLTb + uintptr((*Op)(unsafe.Pointer(pOp)).Fopcode))) != 0) {
  47012 		goto __303
  47013 	}
  47014 
  47015 	goto jump_to_p2
  47016 __303:
  47017 	;
  47018 	iCompare = -1
  47019 
  47020 	goto __302
  47021 __301:
  47022 	if !(*(*uint8)(unsafe.Pointer(Xsqlite3aEQb + uintptr((*Op)(unsafe.Pointer(pOp)).Fopcode))) != 0) {
  47023 		goto __304
  47024 	}
  47025 
  47026 	goto jump_to_p2
  47027 __304:
  47028 	;
  47029 	iCompare = 0
  47030 
  47031 __302:
  47032 	;
  47033 __299:
  47034 	;
  47035 	goto __9
  47036 __297:
  47037 	;
  47038 	if !((int32(flags11)|int32(flags3))&MEM_Null != 0) {
  47039 		goto __305
  47040 	}
  47041 
  47042 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&SQLITE_NULLEQ != 0) {
  47043 		goto __307
  47044 	}
  47045 
  47046 	if !(int32(flags11)&int32(flags3)&MEM_Null != 0 &&
  47047 		int32(flags3)&MEM_Cleared == 0) {
  47048 		goto __309
  47049 	}
  47050 	res = 0
  47051 	goto __310
  47052 __309:
  47053 	res = func() int32 {
  47054 		if int32(flags3)&MEM_Null != 0 {
  47055 			return -1
  47056 		}
  47057 		return +1
  47058 	}()
  47059 __310:
  47060 	;
  47061 	goto __308
  47062 __307:
  47063 	;
  47064 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&SQLITE_JUMPIFNULL != 0) {
  47065 		goto __311
  47066 	}
  47067 	goto jump_to_p2
  47068 __311:
  47069 	;
  47070 	iCompare = 1
  47071 
  47072 	goto __9
  47073 __308:
  47074 	;
  47075 	goto __306
  47076 __305:
  47077 	affinity = uint8(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_AFF_MASK)
  47078 	if !(int32(affinity) >= SQLITE_AFF_NUMERIC) {
  47079 		goto __312
  47080 	}
  47081 	if !((int32(flags11)|int32(flags3))&MEM_Str != 0) {
  47082 		goto __314
  47083 	}
  47084 	if !(int32(flags11)&(MEM_Int|MEM_IntReal|MEM_Real|MEM_Str) == MEM_Str) {
  47085 		goto __315
  47086 	}
  47087 	applyNumericAffinity(tls, pIn1, 0)
  47088 
  47089 	flags3 = (*Mem)(unsafe.Pointer(pIn3)).Fflags
  47090 __315:
  47091 	;
  47092 	if !(int32(flags3)&(MEM_Int|MEM_IntReal|MEM_Real|MEM_Str) == MEM_Str) {
  47093 		goto __316
  47094 	}
  47095 	applyNumericAffinity(tls, pIn3, 0)
  47096 __316:
  47097 	;
  47098 __314:
  47099 	;
  47100 	goto __313
  47101 __312:
  47102 	if !(int32(affinity) == SQLITE_AFF_TEXT && (int32(flags11)|int32(flags3))&MEM_Str != 0) {
  47103 		goto __317
  47104 	}
  47105 	if !(int32(flags11)&MEM_Str == 0 && int32(flags11)&(MEM_Int|MEM_Real|MEM_IntReal) != 0) {
  47106 		goto __318
  47107 	}
  47108 
  47109 	Xsqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1))
  47110 
  47111 	flags11 = U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&libc.CplInt32(MEM_TypeMask) | int32(flags11)&MEM_TypeMask)
  47112 	if !(pIn1 == pIn3) {
  47113 		goto __319
  47114 	}
  47115 	flags3 = U16(int32(flags11) | MEM_Str)
  47116 __319:
  47117 	;
  47118 __318:
  47119 	;
  47120 	if !(int32(flags3)&MEM_Str == 0 && int32(flags3)&(MEM_Int|MEM_Real|MEM_IntReal) != 0) {
  47121 		goto __320
  47122 	}
  47123 
  47124 	Xsqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1))
  47125 
  47126 	flags3 = U16(int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)&libc.CplInt32(MEM_TypeMask) | int32(flags3)&MEM_TypeMask)
  47127 __320:
  47128 	;
  47129 __317:
  47130 	;
  47131 __313:
  47132 	;
  47133 	res = Xsqlite3MemCompare(tls, pIn3, pIn1, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  47134 __306:
  47135 	;
  47136 	if !(res < 0) {
  47137 		goto __321
  47138 	}
  47139 	res2 = int32(*(*uint8)(unsafe.Pointer(Xsqlite3aLTb + uintptr((*Op)(unsafe.Pointer(pOp)).Fopcode))))
  47140 	goto __322
  47141 __321:
  47142 	if !(res == 0) {
  47143 		goto __323
  47144 	}
  47145 	res2 = int32(*(*uint8)(unsafe.Pointer(Xsqlite3aEQb + uintptr((*Op)(unsafe.Pointer(pOp)).Fopcode))))
  47146 	goto __324
  47147 __323:
  47148 	res2 = int32(*(*uint8)(unsafe.Pointer(Xsqlite3aGTb + uintptr((*Op)(unsafe.Pointer(pOp)).Fopcode))))
  47149 __324:
  47150 	;
  47151 __322:
  47152 	;
  47153 	iCompare = res
  47154 
  47155 	(*Mem)(unsafe.Pointer(pIn3)).Fflags = flags3
  47156 
  47157 	(*Mem)(unsafe.Pointer(pIn1)).Fflags = flags11
  47158 
  47159 	if !(res2 != 0) {
  47160 		goto __325
  47161 	}
  47162 	goto jump_to_p2
  47163 __325:
  47164 	;
  47165 	goto __9
  47166 
  47167 __55:
  47168 	;
  47169 	if !(iCompare == 0) {
  47170 		goto __326
  47171 	}
  47172 	goto jump_to_p2
  47173 __326:
  47174 	;
  47175 	goto __9
  47176 
  47177 __56:
  47178 	;
  47179 	goto __9
  47180 
  47181 __57:
  47182 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_PERMUTE == 0) {
  47183 		goto __327
  47184 	}
  47185 	aPermute = uintptr(0)
  47186 	goto __328
  47187 __327:
  47188 	;
  47189 	aPermute = *(*uintptr)(unsafe.Pointer(pOp + libc.UintptrFromInt32(-1)*20 + 16)) + uintptr(1)*4
  47190 
  47191 __328:
  47192 	;
  47193 	n2 = (*Op)(unsafe.Pointer(pOp)).Fp3
  47194 	pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16))
  47195 
  47196 	p11 = (*Op)(unsafe.Pointer(pOp)).Fp1
  47197 	p21 = (*Op)(unsafe.Pointer(pOp)).Fp2
  47198 	i = 0
  47199 __329:
  47200 	if !(i < n2) {
  47201 		goto __331
  47202 	}
  47203 	if aPermute != 0 {
  47204 		idx = *(*U32)(unsafe.Pointer(aPermute + uintptr(i)*4))
  47205 	} else {
  47206 		idx = U32(i)
  47207 	}
  47208 
  47209 	pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 20 + uintptr(i)*4))
  47210 	bRev = int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i)))) & KEYINFO_ORDER_DESC
  47211 	iCompare = Xsqlite3MemCompare(tls, aMem+uintptr(U32(p11)+idx)*40, aMem+uintptr(U32(p21)+idx)*40, pColl)
  47212 
  47213 	if !(iCompare != 0) {
  47214 		goto __332
  47215 	}
  47216 	if !(int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i))))&KEYINFO_ORDER_BIGNULL != 0 &&
  47217 		(int32((*Mem)(unsafe.Pointer(aMem+uintptr(U32(p11)+idx)*40)).Fflags)&MEM_Null != 0 || int32((*Mem)(unsafe.Pointer(aMem+uintptr(U32(p21)+idx)*40)).Fflags)&MEM_Null != 0)) {
  47218 		goto __333
  47219 	}
  47220 	iCompare = -iCompare
  47221 __333:
  47222 	;
  47223 	if !(bRev != 0) {
  47224 		goto __334
  47225 	}
  47226 	iCompare = -iCompare
  47227 __334:
  47228 	;
  47229 	goto __331
  47230 __332:
  47231 	;
  47232 	goto __330
  47233 __330:
  47234 	i++
  47235 	goto __329
  47236 	goto __331
  47237 __331:
  47238 	;
  47239 	goto __9
  47240 
  47241 __58:
  47242 	;
  47243 	if !(iCompare < 0) {
  47244 		goto __335
  47245 	}
  47246 	pOp = aOp + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1-1)*20
  47247 	goto __336
  47248 __335:
  47249 	if !(iCompare == 0) {
  47250 		goto __337
  47251 	}
  47252 	pOp = aOp + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2-1)*20
  47253 	goto __338
  47254 __337:
  47255 	;
  47256 	pOp = aOp + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3-1)*20
  47257 __338:
  47258 	;
  47259 __336:
  47260 	;
  47261 	goto __9
  47262 
  47263 __59:
  47264 __60:
  47265 	v1 = Xsqlite3VdbeBooleanValue(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40, 2)
  47266 	v2 = Xsqlite3VdbeBooleanValue(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40, 2)
  47267 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_And) {
  47268 		goto __339
  47269 	}
  47270 	v1 = int32(and_logic[v1*3+v2])
  47271 	goto __340
  47272 __339:
  47273 	v1 = int32(or_logic[v1*3+v2])
  47274 __340:
  47275 	;
  47276 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  47277 	if !(v1 == 2) {
  47278 		goto __341
  47279 	}
  47280 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Null)
  47281 	goto __342
  47282 __341:
  47283 	*(*I64)(unsafe.Pointer(pOut)) = I64(v1)
  47284 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Int)
  47285 __342:
  47286 	;
  47287 	goto __9
  47288 
  47289 __61:
  47290 	;
  47291 	Xsqlite3VdbeMemSetInt64(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40,
  47292 		int64(Xsqlite3VdbeBooleanValue(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40, (*Op)(unsafe.Pointer(pOp)).Fp3)^*(*int32)(unsafe.Pointer(pOp + 16))))
  47293 	goto __9
  47294 
  47295 __62:
  47296 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  47297 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  47298 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Null == 0) {
  47299 		goto __343
  47300 	}
  47301 	Xsqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(Xsqlite3VdbeBooleanValue(tls, pIn1, 0) != 0)))
  47302 	goto __344
  47303 __343:
  47304 	Xsqlite3VdbeMemSetNull(tls, pOut)
  47305 __344:
  47306 	;
  47307 	goto __9
  47308 
  47309 __63:
  47310 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  47311 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  47312 	Xsqlite3VdbeMemSetNull(tls, pOut)
  47313 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Null == 0) {
  47314 		goto __345
  47315 	}
  47316 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Int)
  47317 	*(*I64)(unsafe.Pointer(pOut)) = ^Xsqlite3VdbeIntValue(tls, pIn1)
  47318 __345:
  47319 	;
  47320 	goto __9
  47321 
  47322 __64:
  47323 	;
  47324 	if !((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0) {
  47325 		goto __346
  47326 	}
  47327 	iAddr = U32((int32(pOp) - int32((*Vdbe)(unsafe.Pointer(p)).FaOp)) / 20)
  47328 	if !(int32(*(*U8)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/U32(8)))))&(int32(1)<<(iAddr&U32(7))) != 0) {
  47329 		goto __348
  47330 	}
  47331 
  47332 	goto jump_to_p2
  47333 __348:
  47334 	;
  47335 	*(*U8)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/U32(8)))) |= U8(int32(1) << (iAddr & U32(7)))
  47336 	goto __347
  47337 __346:
  47338 	if !((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp)).Fp1 == (*Op)(unsafe.Pointer(pOp)).Fp1) {
  47339 		goto __349
  47340 	}
  47341 
  47342 	goto jump_to_p2
  47343 __349:
  47344 	;
  47345 __347:
  47346 	;
  47347 	(*Op)(unsafe.Pointer(pOp)).Fp1 = (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp)).Fp1
  47348 	goto __9
  47349 
  47350 __65:
  47351 	c = Xsqlite3VdbeBooleanValue(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40, (*Op)(unsafe.Pointer(pOp)).Fp3)
  47352 
  47353 	if !(c != 0) {
  47354 		goto __350
  47355 	}
  47356 	goto jump_to_p2
  47357 __350:
  47358 	;
  47359 	goto __9
  47360 
  47361 __66:
  47362 	c1 = libc.BoolInt32(!(Xsqlite3VdbeBooleanValue(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40, libc.BoolInt32(!((*Op)(unsafe.Pointer(pOp)).Fp3 != 0))) != 0))
  47363 
  47364 	if !(c1 != 0) {
  47365 		goto __351
  47366 	}
  47367 	goto jump_to_p2
  47368 __351:
  47369 	;
  47370 	goto __9
  47371 
  47372 __67:
  47373 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  47374 
  47375 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Null != 0) {
  47376 		goto __352
  47377 	}
  47378 	goto jump_to_p2
  47379 __352:
  47380 	;
  47381 	goto __9
  47382 
  47383 __68:
  47384 	;
  47385 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 >= 0) {
  47386 		goto __353
  47387 	}
  47388 	pC = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  47389 
  47390 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 < int32((*VdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed)) {
  47391 		goto __355
  47392 	}
  47393 	serialType = *(*U32)(unsafe.Pointer(pC + 80 + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*4))
  47394 	if !(serialType >= U32(12)) {
  47395 		goto __357
  47396 	}
  47397 	if !(serialType&U32(1) != 0) {
  47398 		goto __359
  47399 	}
  47400 	typeMask = U16(0x04)
  47401 	goto __360
  47402 __359:
  47403 	typeMask = U16(0x08)
  47404 __360:
  47405 	;
  47406 	goto __358
  47407 __357:
  47408 	;
  47409 	typeMask = U16(aMask[serialType])
  47410 __358:
  47411 	;
  47412 	goto __356
  47413 __355:
  47414 	typeMask = U16(int32(1) << (*(*int32)(unsafe.Pointer(pOp + 16)) - 1))
  47415 
  47416 __356:
  47417 	;
  47418 	goto __354
  47419 __353:
  47420 	;
  47421 	typeMask = U16(int32(1) << (Xsqlite3_value_type(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40) - 1))
  47422 
  47423 __354:
  47424 	;
  47425 	if !(int32(typeMask)&int32((*Op)(unsafe.Pointer(pOp)).Fp5) != 0) {
  47426 		goto __361
  47427 	}
  47428 	goto jump_to_p2
  47429 __361:
  47430 	;
  47431 	goto __9
  47432 
  47433 __69:
  47434 	if !(int32((*Mem)(unsafe.Pointer(aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40)).Fflags)&MEM_Null != 0 ||
  47435 		int32((*Mem)(unsafe.Pointer(aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40)).Fflags)&MEM_Null != 0) {
  47436 		goto __362
  47437 	}
  47438 	Xsqlite3VdbeMemSetNull(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40)
  47439 	goto __363
  47440 __362:
  47441 	Xsqlite3VdbeMemSetInt64(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40, int64(0))
  47442 __363:
  47443 	;
  47444 	goto __9
  47445 
  47446 __70:
  47447 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  47448 
  47449 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Null == 0) {
  47450 		goto __364
  47451 	}
  47452 	goto jump_to_p2
  47453 __364:
  47454 	;
  47455 	goto __9
  47456 
  47457 __71:
  47458 	;
  47459 	pC1 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  47460 	if !(pC1 != 0 && (*VdbeCursor)(unsafe.Pointer(pC1)).FnullRow != 0) {
  47461 		goto __365
  47462 	}
  47463 	Xsqlite3VdbeMemSetNull(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40)
  47464 	goto jump_to_p2
  47465 __365:
  47466 	;
  47467 	goto __9
  47468 
  47469 __72:
  47470 	;
  47471 	pC2 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  47472 	pOut = (*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  47473 	if !(pC2 == uintptr(0) || int32((*VdbeCursor)(unsafe.Pointer(pC2)).FeCurType) != CURTYPE_BTREE) {
  47474 		goto __366
  47475 	}
  47476 	Xsqlite3VdbeMemSetNull(tls, pOut)
  47477 	goto __367
  47478 __366:
  47479 	if !((*VdbeCursor)(unsafe.Pointer(pC2)).FdeferredMoveto != 0) {
  47480 		goto __368
  47481 	}
  47482 	rc = Xsqlite3VdbeFinishMoveto(tls, pC2)
  47483 	if !(rc != 0) {
  47484 		goto __369
  47485 	}
  47486 	goto abort_due_to_error
  47487 __369:
  47488 	;
  47489 __368:
  47490 	;
  47491 	if !(Xsqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC2 + 36))) != 0) {
  47492 		goto __370
  47493 	}
  47494 	Xsqlite3VdbeMemSetNull(tls, pOut)
  47495 	goto __371
  47496 __370:
  47497 	Xsqlite3VdbeMemSetInt64(tls, pOut, Xsqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC2 + 36))))
  47498 __371:
  47499 	;
  47500 __367:
  47501 	;
  47502 	goto __9
  47503 
  47504 __73:
  47505 	;
  47506 	pC3 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  47507 	p22 = U32((*Op)(unsafe.Pointer(pOp)).Fp2)
  47508 
  47509 op_column_restart:
  47510 	;
  47511 	aOffset = (*VdbeCursor)(unsafe.Pointer(pC3)).FaOffset
  47512 
  47513 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus != (*Vdbe)(unsafe.Pointer(p)).FcacheCtr) {
  47514 		goto __372
  47515 	}
  47516 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FnullRow != 0) {
  47517 		goto __374
  47518 	}
  47519 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC3)).FeCurType) == CURTYPE_PSEUDO && (*VdbeCursor)(unsafe.Pointer(pC3)).FseekResult > 0) {
  47520 		goto __376
  47521 	}
  47522 
  47523 	pReg = aMem + uintptr((*VdbeCursor)(unsafe.Pointer(pC3)).FseekResult)*40
  47524 
  47525 	(*VdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = libc.AssignPtrUint32(pC3+76, U32((*Mem)(unsafe.Pointer(pReg)).Fn))
  47526 	(*VdbeCursor)(unsafe.Pointer(pC3)).FaRow = (*Mem)(unsafe.Pointer(pReg)).Fz
  47527 	goto __377
  47528 __376:
  47529 	pDest = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  47530 
  47531 	Xsqlite3VdbeMemSetNull(tls, pDest)
  47532 	goto op_column_out
  47533 __377:
  47534 	;
  47535 	goto __375
  47536 __374:
  47537 	pCrsr = *(*uintptr)(unsafe.Pointer(pC3 + 36))
  47538 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto != 0) {
  47539 		goto __378
  47540 	}
  47541 
  47542 	if !(*(*uintptr)(unsafe.Pointer(pC3 + 12)) != 0 && libc.AssignUint32(&iMap, *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pC3 + 12)) + uintptr(U32(1)+p22)*4))) > U32(0)) {
  47543 		goto __380
  47544 	}
  47545 	pC3 = (*VdbeCursor)(unsafe.Pointer(pC3)).FpAltCursor
  47546 	p22 = iMap - U32(1)
  47547 	goto op_column_restart
  47548 __380:
  47549 	;
  47550 	rc = Xsqlite3VdbeFinishMoveto(tls, pC3)
  47551 	if !(rc != 0) {
  47552 		goto __381
  47553 	}
  47554 	goto abort_due_to_error
  47555 __381:
  47556 	;
  47557 	goto __379
  47558 __378:
  47559 	if !(Xsqlite3BtreeCursorHasMoved(tls, pCrsr) != 0) {
  47560 		goto __382
  47561 	}
  47562 	rc = Xsqlite3VdbeHandleMovedCursor(tls, pC3)
  47563 	if !(rc != 0) {
  47564 		goto __383
  47565 	}
  47566 	goto abort_due_to_error
  47567 __383:
  47568 	;
  47569 	goto op_column_restart
  47570 __382:
  47571 	;
  47572 __379:
  47573 	;
  47574 	(*VdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = Xsqlite3BtreePayloadSize(tls, pCrsr)
  47575 	(*VdbeCursor)(unsafe.Pointer(pC3)).FaRow = Xsqlite3BtreePayloadFetch(tls, pCrsr, pC3+76)
  47576 
  47577 __375:
  47578 	;
  47579 	(*VdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = (*Vdbe)(unsafe.Pointer(p)).FcacheCtr
  47580 	if !(libc.AssignPtrUint32(aOffset, U32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(pC3)).FaRow)))) < U32(0x80)) {
  47581 		goto __384
  47582 	}
  47583 	(*VdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = U32(1)
  47584 	goto __385
  47585 __384:
  47586 	(*VdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = U32(Xsqlite3GetVarint32(tls, (*VdbeCursor)(unsafe.Pointer(pC3)).FaRow, aOffset))
  47587 __385:
  47588 	;
  47589 	(*VdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = U16(0)
  47590 
  47591 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FszRow < *(*U32)(unsafe.Pointer(aOffset))) {
  47592 		goto __386
  47593 	}
  47594 
  47595 	(*VdbeCursor)(unsafe.Pointer(pC3)).FaRow = uintptr(0)
  47596 	(*VdbeCursor)(unsafe.Pointer(pC3)).FszRow = U32(0)
  47597 
  47598 	if !(*(*U32)(unsafe.Pointer(aOffset)) > U32(98307) || *(*U32)(unsafe.Pointer(aOffset)) > (*VdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize) {
  47599 		goto __388
  47600 	}
  47601 	goto op_column_corrupt
  47602 __388:
  47603 	;
  47604 	goto __387
  47605 __386:
  47606 	zData = (*VdbeCursor)(unsafe.Pointer(pC3)).FaRow
  47607 
  47608 	goto op_column_read_header
  47609 __387:
  47610 	;
  47611 	goto __373
  47612 __372:
  47613 	if !(Xsqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(pC3 + 36))) != 0) {
  47614 		goto __389
  47615 	}
  47616 	rc = Xsqlite3VdbeHandleMovedCursor(tls, pC3)
  47617 	if !(rc != 0) {
  47618 		goto __390
  47619 	}
  47620 	goto abort_due_to_error
  47621 __390:
  47622 	;
  47623 	goto op_column_restart
  47624 __389:
  47625 	;
  47626 __373:
  47627 	;
  47628 	if !(U32((*VdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22) {
  47629 		goto __391
  47630 	}
  47631 
  47632 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset < *(*U32)(unsafe.Pointer(aOffset))) {
  47633 		goto __393
  47634 	}
  47635 
  47636 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0)) {
  47637 		goto __395
  47638 	}
  47639 	libc.Xmemset(tls, bp+232, 0, uint32(unsafe.Sizeof(Mem{})))
  47640 	rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(pC3 + 36)), *(*U32)(unsafe.Pointer(aOffset)), bp+232)
  47641 	if !(rc != SQLITE_OK) {
  47642 		goto __397
  47643 	}
  47644 	goto abort_due_to_error
  47645 __397:
  47646 	;
  47647 	zData = (*Mem)(unsafe.Pointer(bp + 232)).Fz
  47648 	goto __396
  47649 __395:
  47650 	zData = (*VdbeCursor)(unsafe.Pointer(pC3)).FaRow
  47651 __396:
  47652 	;
  47653 op_column_read_header:
  47654 	i1 = int32((*VdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed)
  47655 	offset64 = U64(*(*U32)(unsafe.Pointer(aOffset + uintptr(i1)*4)))
  47656 	zHdr = zData + uintptr((*VdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset)
  47657 	zEndHdr = zData + uintptr(*(*U32)(unsafe.Pointer(aOffset)))
  47658 
  47659 __398:
  47660 	if !(libc.AssignPtrUint32(pC3+80+uintptr(i1)*4, libc.AssignPtrUint32(bp+272, U32(*(*U8)(unsafe.Pointer(zHdr))))) < U32(0x80)) {
  47661 		goto __401
  47662 	}
  47663 	zHdr++
  47664 	offset64 = offset64 + U64(Xsqlite3VdbeOneByteSerialTypeLen(tls, uint8(*(*U32)(unsafe.Pointer(bp + 272)))))
  47665 	goto __402
  47666 __401:
  47667 	zHdr += uintptr(Xsqlite3GetVarint32(tls, zHdr, bp+272))
  47668 	*(*U32)(unsafe.Pointer(pC3 + 80 + uintptr(i1)*4)) = *(*U32)(unsafe.Pointer(bp + 272))
  47669 	offset64 = offset64 + U64(Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 272))))
  47670 __402:
  47671 	;
  47672 	*(*U32)(unsafe.Pointer(aOffset + uintptr(libc.PreIncInt32(&i1, 1))*4)) = U32(offset64 & uint64(0xffffffff))
  47673 	goto __399
  47674 __399:
  47675 	if U32(i1) <= p22 && zHdr < zEndHdr {
  47676 		goto __398
  47677 	}
  47678 	goto __400
  47679 __400:
  47680 	;
  47681 	if !(zHdr >= zEndHdr && (zHdr > zEndHdr || offset64 != U64((*VdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize)) ||
  47682 		offset64 > U64((*VdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize)) {
  47683 		goto __403
  47684 	}
  47685 	if !(*(*U32)(unsafe.Pointer(aOffset)) == U32(0)) {
  47686 		goto __404
  47687 	}
  47688 	i1 = 0
  47689 	zHdr = zEndHdr
  47690 	goto __405
  47691 __404:
  47692 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0)) {
  47693 		goto __406
  47694 	}
  47695 	Xsqlite3VdbeMemRelease(tls, bp+232)
  47696 __406:
  47697 	;
  47698 	goto op_column_corrupt
  47699 __405:
  47700 	;
  47701 __403:
  47702 	;
  47703 	(*VdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = U16(i1)
  47704 	(*VdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = U32((int32(zHdr) - int32(zData)) / 1)
  47705 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0)) {
  47706 		goto __407
  47707 	}
  47708 	Xsqlite3VdbeMemRelease(tls, bp+232)
  47709 __407:
  47710 	;
  47711 	goto __394
  47712 __393:
  47713 	*(*U32)(unsafe.Pointer(bp + 272)) = U32(0)
  47714 __394:
  47715 	;
  47716 	if !(U32((*VdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22) {
  47717 		goto __408
  47718 	}
  47719 	pDest = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  47720 
  47721 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == -10) {
  47722 		goto __409
  47723 	}
  47724 	Xsqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16)), MEM_Static)
  47725 	goto __410
  47726 __409:
  47727 	Xsqlite3VdbeMemSetNull(tls, pDest)
  47728 __410:
  47729 	;
  47730 	goto op_column_out
  47731 __408:
  47732 	;
  47733 	goto __392
  47734 __391:
  47735 	*(*U32)(unsafe.Pointer(bp + 272)) = *(*U32)(unsafe.Pointer(pC3 + 80 + uintptr(p22)*4))
  47736 __392:
  47737 	;
  47738 	pDest = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  47739 
  47740 	if !(int32((*Mem)(unsafe.Pointer(pDest)).Fflags)&(MEM_Agg|MEM_Dyn) != 0) {
  47741 		goto __411
  47742 	}
  47743 	Xsqlite3VdbeMemSetNull(tls, pDest)
  47744 __411:
  47745 	;
  47746 	if !((*VdbeCursor)(unsafe.Pointer(pC3)).FszRow >= *(*U32)(unsafe.Pointer(aOffset + uintptr(p22+U32(1))*4))) {
  47747 		goto __412
  47748 	}
  47749 
  47750 	zData = (*VdbeCursor)(unsafe.Pointer(pC3)).FaRow + uintptr(*(*U32)(unsafe.Pointer(aOffset + uintptr(p22)*4)))
  47751 	if !(*(*U32)(unsafe.Pointer(bp + 272)) < U32(12)) {
  47752 		goto __414
  47753 	}
  47754 	Xsqlite3VdbeSerialGet(tls, zData, *(*U32)(unsafe.Pointer(bp + 272)), pDest)
  47755 	goto __415
  47756 __414:
  47757 	(*Mem)(unsafe.Pointer(pDest)).Fn = libc.AssignInt32(&len, int32((*(*U32)(unsafe.Pointer(bp + 272))-U32(12))/U32(2)))
  47758 	(*Mem)(unsafe.Pointer(pDest)).Fenc = encoding
  47759 	if !((*Mem)(unsafe.Pointer(pDest)).FszMalloc < len+2) {
  47760 		goto __416
  47761 	}
  47762 	if !(len > *(*int32)(unsafe.Pointer(db + 120))) {
  47763 		goto __418
  47764 	}
  47765 	goto too_big
  47766 __418:
  47767 	;
  47768 	(*Mem)(unsafe.Pointer(pDest)).Fflags = U16(MEM_Null)
  47769 	if !(Xsqlite3VdbeMemGrow(tls, pDest, len+2, 0) != 0) {
  47770 		goto __419
  47771 	}
  47772 	goto no_mem
  47773 __419:
  47774 	;
  47775 	goto __417
  47776 __416:
  47777 	(*Mem)(unsafe.Pointer(pDest)).Fz = (*Mem)(unsafe.Pointer(pDest)).FzMalloc
  47778 __417:
  47779 	;
  47780 	libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pDest)).Fz, zData, uint32(len))
  47781 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pDest)).Fz + uintptr(len))) = uint8(0)
  47782 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pDest)).Fz + uintptr(len+1))) = uint8(0)
  47783 	(*Mem)(unsafe.Pointer(pDest)).Fflags = aFlag1[*(*U32)(unsafe.Pointer(bp + 272))&U32(1)]
  47784 __415:
  47785 	;
  47786 	goto __413
  47787 __412:
  47788 	(*Mem)(unsafe.Pointer(pDest)).Fenc = encoding
  47789 
  47790 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&(OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG) != 0 &&
  47791 		(*(*U32)(unsafe.Pointer(bp + 272)) >= U32(12) && *(*U32)(unsafe.Pointer(bp + 272))&U32(1) == U32(0) || int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_TYPEOFARG != 0) ||
  47792 		libc.AssignInt32(&len, int32(Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 272))))) == 0) {
  47793 		goto __420
  47794 	}
  47795 
  47796 	Xsqlite3VdbeSerialGet(tls, uintptr(unsafe.Pointer(&Xsqlite3CtypeMap)), *(*U32)(unsafe.Pointer(bp + 272)), pDest)
  47797 	goto __421
  47798 __420:
  47799 	if !(len > *(*int32)(unsafe.Pointer(db + 120))) {
  47800 		goto __422
  47801 	}
  47802 	goto too_big
  47803 __422:
  47804 	;
  47805 	rc = Xsqlite3VdbeMemFromBtree(tls, *(*uintptr)(unsafe.Pointer(pC3 + 36)), *(*U32)(unsafe.Pointer(aOffset + uintptr(p22)*4)), uint32(len), pDest)
  47806 	if !(rc != SQLITE_OK) {
  47807 		goto __423
  47808 	}
  47809 	goto abort_due_to_error
  47810 __423:
  47811 	;
  47812 	Xsqlite3VdbeSerialGet(tls, (*Mem)(unsafe.Pointer(pDest)).Fz, *(*U32)(unsafe.Pointer(bp + 272)), pDest)
  47813 	*(*U16)(unsafe.Pointer(pDest + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Ephem))
  47814 __421:
  47815 	;
  47816 __413:
  47817 	;
  47818 op_column_out:
  47819 	;
  47820 	goto __9
  47821 
  47822 op_column_corrupt:
  47823 	if !((*Op)(unsafe.Pointer(aOp)).Fp3 > 0) {
  47824 		goto __424
  47825 	}
  47826 	pOp = aOp + uintptr((*Op)(unsafe.Pointer(aOp)).Fp3-1)*20
  47827 	goto __9
  47828 	goto __425
  47829 __424:
  47830 	rc = Xsqlite3CorruptError(tls, 93320)
  47831 	goto abort_due_to_error
  47832 __425:
  47833 	;
  47834 __74:
  47835 	;
  47836 	pTab = *(*uintptr)(unsafe.Pointer(pOp + 16))
  47837 
  47838 	aCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  47839 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  47840 	i2 = 0
  47841 __426:
  47842 	if !(i2 < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  47843 		goto __428
  47844 	}
  47845 	if !(int32((*Column)(unsafe.Pointer(aCol+uintptr(i2)*16)).FcolFlags)&COLFLAG_GENERATED != 0) {
  47846 		goto __429
  47847 	}
  47848 	if !(int32((*Column)(unsafe.Pointer(aCol+uintptr(i2)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0) {
  47849 		goto __430
  47850 	}
  47851 	goto __427
  47852 __430:
  47853 	;
  47854 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  47855 		goto __431
  47856 	}
  47857 	pIn1 += 40
  47858 	goto __427
  47859 __431:
  47860 	;
  47861 __429:
  47862 	;
  47863 	applyAffinity(tls, pIn1, (*Column)(unsafe.Pointer(aCol+uintptr(i2)*16)).Faffinity, encoding)
  47864 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Null == 0) {
  47865 		goto __432
  47866 	}
  47867 	switch int32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 4)) & 0xf0 >> 4) {
  47868 	case COLTYPE_BLOB:
  47869 		goto __434
  47870 	case COLTYPE_INTEGER:
  47871 		goto __435
  47872 	case COLTYPE_INT:
  47873 		goto __436
  47874 	case COLTYPE_TEXT:
  47875 		goto __437
  47876 	case COLTYPE_REAL:
  47877 		goto __438
  47878 	default:
  47879 		goto __439
  47880 	}
  47881 	goto __433
  47882 __434:
  47883 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Blob == 0) {
  47884 		goto __440
  47885 	}
  47886 	goto vdbe_type_error
  47887 __440:
  47888 	;
  47889 	goto __433
  47890 
  47891 __435:
  47892 __436:
  47893 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Int == 0) {
  47894 		goto __441
  47895 	}
  47896 	goto vdbe_type_error
  47897 __441:
  47898 	;
  47899 	goto __433
  47900 
  47901 __437:
  47902 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Str == 0) {
  47903 		goto __442
  47904 	}
  47905 	goto vdbe_type_error
  47906 __442:
  47907 	;
  47908 	goto __433
  47909 
  47910 __438:
  47911 	;
  47912 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Int != 0) {
  47913 		goto __443
  47914 	}
  47915 
  47916 	if !(*(*I64)(unsafe.Pointer(pIn1)) <= 140737488355327 && *(*I64)(unsafe.Pointer(pIn1)) >= -140737488355328) {
  47917 		goto __445
  47918 	}
  47919 	*(*U16)(unsafe.Pointer(pIn1 + 16)) |= U16(MEM_IntReal)
  47920 	*(*U16)(unsafe.Pointer(pIn1 + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int))
  47921 	goto __446
  47922 __445:
  47923 	*(*float64)(unsafe.Pointer(pIn1)) = float64(*(*I64)(unsafe.Pointer(pIn1)))
  47924 	*(*U16)(unsafe.Pointer(pIn1 + 16)) |= U16(MEM_Real)
  47925 	*(*U16)(unsafe.Pointer(pIn1 + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int))
  47926 __446:
  47927 	;
  47928 	goto __444
  47929 __443:
  47930 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&(MEM_Real|MEM_IntReal) == 0) {
  47931 		goto __447
  47932 	}
  47933 	goto vdbe_type_error
  47934 __447:
  47935 	;
  47936 __444:
  47937 	;
  47938 	goto __433
  47939 
  47940 __439:
  47941 	goto __433
  47942 
  47943 __433:
  47944 	;
  47945 __432:
  47946 	;
  47947 	pIn1 += 40
  47948 	goto __427
  47949 __427:
  47950 	i2++
  47951 	goto __426
  47952 	goto __428
  47953 __428:
  47954 	;
  47955 	goto __9
  47956 
  47957 vdbe_type_error:
  47958 	Xsqlite3VdbeError(tls, p, ts+5483,
  47959 		libc.VaList(bp+56, vdbeMemTypeName(tls, pIn1), Xsqlite3StdType[(int32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 4))&0xf0>>4)-1)&0xf<<28>>28],
  47960 			(*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer(aCol+uintptr(i2)*16)).FzCnName))
  47961 	rc = SQLITE_CONSTRAINT | int32(12)<<8
  47962 	goto abort_due_to_error
  47963 
  47964 __75:
  47965 	zAffinity = *(*uintptr)(unsafe.Pointer(pOp + 16))
  47966 
  47967 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  47968 __448:
  47969 	if !(1 != 0) {
  47970 		goto __449
  47971 	}
  47972 
  47973 	applyAffinity(tls, pIn1, *(*uint8)(unsafe.Pointer(zAffinity)), encoding)
  47974 	if !(int32(*(*uint8)(unsafe.Pointer(zAffinity))) == SQLITE_AFF_REAL && int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Int != 0) {
  47975 		goto __450
  47976 	}
  47977 
  47978 	if !(*(*I64)(unsafe.Pointer(pIn1)) <= 140737488355327 && *(*I64)(unsafe.Pointer(pIn1)) >= -140737488355328) {
  47979 		goto __451
  47980 	}
  47981 	*(*U16)(unsafe.Pointer(pIn1 + 16)) |= U16(MEM_IntReal)
  47982 	*(*U16)(unsafe.Pointer(pIn1 + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int))
  47983 	goto __452
  47984 __451:
  47985 	*(*float64)(unsafe.Pointer(pIn1)) = float64(*(*I64)(unsafe.Pointer(pIn1)))
  47986 	*(*U16)(unsafe.Pointer(pIn1 + 16)) |= U16(MEM_Real)
  47987 	*(*U16)(unsafe.Pointer(pIn1 + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int))
  47988 __452:
  47989 	;
  47990 __450:
  47991 	;
  47992 	zAffinity++
  47993 	if !(int32(*(*uint8)(unsafe.Pointer(zAffinity))) == 0) {
  47994 		goto __453
  47995 	}
  47996 	goto __449
  47997 __453:
  47998 	;
  47999 	pIn1 += 40
  48000 	goto __448
  48001 __449:
  48002 	;
  48003 	goto __9
  48004 
  48005 __76:
  48006 	nData = uint64(0)
  48007 	nHdr = 0
  48008 	nZero = int64(0)
  48009 	nField = (*Op)(unsafe.Pointer(pOp)).Fp1
  48010 	zAffinity1 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  48011 
  48012 	pData0 = aMem + uintptr(nField)*40
  48013 	nField = (*Op)(unsafe.Pointer(pOp)).Fp2
  48014 	pLast = pData0 + uintptr(nField-1)*40
  48015 
  48016 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  48017 
  48018 	if !(zAffinity1 != 0) {
  48019 		goto __454
  48020 	}
  48021 	pRec = pData0
  48022 __455:
  48023 	applyAffinity(tls, pRec, *(*uint8)(unsafe.Pointer(zAffinity1)), encoding)
  48024 	if !(int32(*(*uint8)(unsafe.Pointer(zAffinity1))) == SQLITE_AFF_REAL && int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Int != 0) {
  48025 		goto __458
  48026 	}
  48027 	*(*U16)(unsafe.Pointer(pRec + 16)) |= U16(MEM_IntReal)
  48028 	*(*U16)(unsafe.Pointer(pRec + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Int))
  48029 __458:
  48030 	;
  48031 	zAffinity1++
  48032 	pRec += 40
  48033 
  48034 	goto __456
  48035 __456:
  48036 	if *(*uint8)(unsafe.Pointer(zAffinity1)) != 0 {
  48037 		goto __455
  48038 	}
  48039 	goto __457
  48040 __457:
  48041 	;
  48042 __454:
  48043 	;
  48044 	pRec = pLast
  48045 __459:
  48046 	;
  48047 	if !(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Null != 0) {
  48048 		goto __462
  48049 	}
  48050 	if !(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Zero != 0) {
  48051 		goto __464
  48052 	}
  48053 
  48054 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(10)
  48055 	goto __465
  48056 __464:
  48057 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(0)
  48058 __465:
  48059 	;
  48060 	nHdr++
  48061 	goto __463
  48062 __462:
  48063 	if !(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&(MEM_Int|MEM_IntReal) != 0) {
  48064 		goto __466
  48065 	}
  48066 
  48067 	i3 = *(*I64)(unsafe.Pointer(pRec))
  48068 
  48069 	if !(i3 < int64(0)) {
  48070 		goto __468
  48071 	}
  48072 	uu = U64(^i3)
  48073 	goto __469
  48074 __468:
  48075 	uu = U64(i3)
  48076 __469:
  48077 	;
  48078 	nHdr++
  48079 
  48080 	if !(uu <= uint64(127)) {
  48081 		goto __470
  48082 	}
  48083 	if !(i3&int64(1) == i3 && int32((*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat) >= 4) {
  48084 		goto __472
  48085 	}
  48086 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(8) + U32(uu)
  48087 	goto __473
  48088 __472:
  48089 	nData++
  48090 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(1)
  48091 __473:
  48092 	;
  48093 	goto __471
  48094 __470:
  48095 	if !(uu <= uint64(32767)) {
  48096 		goto __474
  48097 	}
  48098 	nData = nData + uint64(2)
  48099 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(2)
  48100 	goto __475
  48101 __474:
  48102 	if !(uu <= uint64(8388607)) {
  48103 		goto __476
  48104 	}
  48105 	nData = nData + uint64(3)
  48106 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(3)
  48107 	goto __477
  48108 __476:
  48109 	if !(uu <= uint64(2147483647)) {
  48110 		goto __478
  48111 	}
  48112 	nData = nData + uint64(4)
  48113 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(4)
  48114 	goto __479
  48115 __478:
  48116 	if !(uu <= uint64(140737488355327)) {
  48117 		goto __480
  48118 	}
  48119 	nData = nData + uint64(6)
  48120 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(5)
  48121 	goto __481
  48122 __480:
  48123 	nData = nData + uint64(8)
  48124 	if !(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_IntReal != 0) {
  48125 		goto __482
  48126 	}
  48127 
  48128 	*(*float64)(unsafe.Pointer(pRec)) = float64(*(*I64)(unsafe.Pointer(pRec)))
  48129 	*(*U16)(unsafe.Pointer(pRec + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_IntReal))
  48130 	*(*U16)(unsafe.Pointer(pRec + 16)) |= U16(MEM_Real)
  48131 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(7)
  48132 	goto __483
  48133 __482:
  48134 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(6)
  48135 __483:
  48136 	;
  48137 __481:
  48138 	;
  48139 __479:
  48140 	;
  48141 __477:
  48142 	;
  48143 __475:
  48144 	;
  48145 __471:
  48146 	;
  48147 	goto __467
  48148 __466:
  48149 	if !(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Real != 0) {
  48150 		goto __484
  48151 	}
  48152 	nHdr++
  48153 	nData = nData + uint64(8)
  48154 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(7)
  48155 	goto __485
  48156 __484:
  48157 	;
  48158 	len1 = U32((*Mem)(unsafe.Pointer(pRec)).Fn)
  48159 	serial_type = len1*U32(2) + U32(12) + U32(libc.Bool32(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Str != 0))
  48160 	if !(int32((*Mem)(unsafe.Pointer(pRec)).Fflags)&MEM_Zero != 0) {
  48161 		goto __486
  48162 	}
  48163 	serial_type = serial_type + U32(*(*int32)(unsafe.Pointer(pRec))*2)
  48164 	if !(nData != 0) {
  48165 		goto __487
  48166 	}
  48167 	if !(Xsqlite3VdbeMemExpandBlob(tls, pRec) != 0) {
  48168 		goto __489
  48169 	}
  48170 	goto no_mem
  48171 __489:
  48172 	;
  48173 	len1 = len1 + U32(*(*int32)(unsafe.Pointer(pRec)))
  48174 	goto __488
  48175 __487:
  48176 	nZero = nZero + I64(*(*int32)(unsafe.Pointer(pRec)))
  48177 __488:
  48178 	;
  48179 __486:
  48180 	;
  48181 	nData = nData + U64(len1)
  48182 	nHdr = nHdr + Xsqlite3VarintLen(tls, uint64(serial_type))
  48183 	(*Mem)(unsafe.Pointer(pRec)).FuTemp = serial_type
  48184 __485:
  48185 	;
  48186 __467:
  48187 	;
  48188 __463:
  48189 	;
  48190 	if !(pRec == pData0) {
  48191 		goto __490
  48192 	}
  48193 	goto __461
  48194 __490:
  48195 	;
  48196 	pRec -= 40
  48197 	goto __460
  48198 __460:
  48199 	if 1 != 0 {
  48200 		goto __459
  48201 	}
  48202 	goto __461
  48203 __461:
  48204 	;
  48205 	if !(nHdr <= 126) {
  48206 		goto __491
  48207 	}
  48208 
  48209 	nHdr = nHdr + 1
  48210 	goto __492
  48211 __491:
  48212 	nVarint = Xsqlite3VarintLen(tls, uint64(nHdr))
  48213 	nHdr = nHdr + nVarint
  48214 	if !(nVarint < Xsqlite3VarintLen(tls, uint64(nHdr))) {
  48215 		goto __493
  48216 	}
  48217 	nHdr++
  48218 __493:
  48219 	;
  48220 __492:
  48221 	;
  48222 	nByte1 = I64(U64(nHdr) + nData)
  48223 
  48224 	if !(nByte1+nZero <= I64((*Mem)(unsafe.Pointer(pOut)).FszMalloc)) {
  48225 		goto __494
  48226 	}
  48227 
  48228 	(*Mem)(unsafe.Pointer(pOut)).Fz = (*Mem)(unsafe.Pointer(pOut)).FzMalloc
  48229 	goto __495
  48230 __494:
  48231 	if !(nByte1+nZero > I64(*(*int32)(unsafe.Pointer(db + 120)))) {
  48232 		goto __496
  48233 	}
  48234 	goto too_big
  48235 __496:
  48236 	;
  48237 	if !(Xsqlite3VdbeMemClearAndResize(tls, pOut, int32(nByte1)) != 0) {
  48238 		goto __497
  48239 	}
  48240 	goto no_mem
  48241 __497:
  48242 	;
  48243 __495:
  48244 	;
  48245 	(*Mem)(unsafe.Pointer(pOut)).Fn = int32(nByte1)
  48246 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Blob)
  48247 	if !(nZero != 0) {
  48248 		goto __498
  48249 	}
  48250 	*(*int32)(unsafe.Pointer(pOut)) = int32(nZero)
  48251 	*(*U16)(unsafe.Pointer(pOut + 16)) |= U16(MEM_Zero)
  48252 __498:
  48253 	;
  48254 	zHdr1 = (*Mem)(unsafe.Pointer(pOut)).Fz
  48255 	zPayload = zHdr1 + uintptr(nHdr)
  48256 
  48257 	if !(nHdr < 0x80) {
  48258 		goto __499
  48259 	}
  48260 	*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&zHdr1, 1))) = U8(nHdr)
  48261 	goto __500
  48262 __499:
  48263 	zHdr1 += uintptr(Xsqlite3PutVarint(tls, zHdr1, uint64(nHdr)))
  48264 __500:
  48265 	;
  48266 	pRec = pData0
  48267 __501:
  48268 	if !(1 != 0) {
  48269 		goto __502
  48270 	}
  48271 	serial_type = (*Mem)(unsafe.Pointer(pRec)).FuTemp
  48272 
  48273 	if !(serial_type <= U32(7)) {
  48274 		goto __503
  48275 	}
  48276 	*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&zHdr1, 1))) = U8(serial_type)
  48277 	if !(serial_type == U32(0)) {
  48278 		goto __505
  48279 	}
  48280 
  48281 	goto __506
  48282 __505:
  48283 	if !(serial_type == U32(7)) {
  48284 		goto __507
  48285 	}
  48286 
  48287 	libc.Xmemcpy(tls, bp+280, pRec, uint32(unsafe.Sizeof(U64(0))))
  48288 
  48289 	goto __508
  48290 __507:
  48291 	*(*U64)(unsafe.Pointer(bp + 280)) = U64(*(*I64)(unsafe.Pointer(pRec)))
  48292 __508:
  48293 	;
  48294 	len1 = libc.AssignUint32(&i4, U32(Xsqlite3SmallTypeSizes[serial_type]))
  48295 
  48296 __509:
  48297 	if !(1 != 0) {
  48298 		goto __510
  48299 	}
  48300 	*(*U8)(unsafe.Pointer(zPayload + uintptr(libc.PreDecUint32(&i4, 1)))) = U8(*(*U64)(unsafe.Pointer(bp + 280)) & uint64(0xFF))
  48301 	if !(i4 == U32(0)) {
  48302 		goto __511
  48303 	}
  48304 	goto __510
  48305 __511:
  48306 	;
  48307 	*(*U64)(unsafe.Pointer(bp + 280)) >>= 8
  48308 	goto __509
  48309 __510:
  48310 	;
  48311 	zPayload += uintptr(len1)
  48312 __506:
  48313 	;
  48314 	goto __504
  48315 __503:
  48316 	if !(serial_type < U32(0x80)) {
  48317 		goto __512
  48318 	}
  48319 	*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&zHdr1, 1))) = U8(serial_type)
  48320 	if !(serial_type >= U32(14) && (*Mem)(unsafe.Pointer(pRec)).Fn > 0) {
  48321 		goto __514
  48322 	}
  48323 
  48324 	libc.Xmemcpy(tls, zPayload, (*Mem)(unsafe.Pointer(pRec)).Fz, uint32((*Mem)(unsafe.Pointer(pRec)).Fn))
  48325 	zPayload += uintptr((*Mem)(unsafe.Pointer(pRec)).Fn)
  48326 __514:
  48327 	;
  48328 	goto __513
  48329 __512:
  48330 	zHdr1 += uintptr(Xsqlite3PutVarint(tls, zHdr1, uint64(serial_type)))
  48331 	if !((*Mem)(unsafe.Pointer(pRec)).Fn != 0) {
  48332 		goto __515
  48333 	}
  48334 
  48335 	libc.Xmemcpy(tls, zPayload, (*Mem)(unsafe.Pointer(pRec)).Fz, uint32((*Mem)(unsafe.Pointer(pRec)).Fn))
  48336 	zPayload += uintptr((*Mem)(unsafe.Pointer(pRec)).Fn)
  48337 __515:
  48338 	;
  48339 __513:
  48340 	;
  48341 __504:
  48342 	;
  48343 	if !(pRec == pLast) {
  48344 		goto __516
  48345 	}
  48346 	goto __502
  48347 __516:
  48348 	;
  48349 	pRec += 40
  48350 	goto __501
  48351 __502:
  48352 	;
  48353 	goto __9
  48354 
  48355 __77:
  48356 	;
  48357 	pCrsr1 = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4)) + 36))
  48358 
  48359 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  48360 		goto __517
  48361 	}
  48362 	*(*I64)(unsafe.Pointer(bp + 288)) = Xsqlite3BtreeRowCountEst(tls, pCrsr1)
  48363 	goto __518
  48364 __517:
  48365 	*(*I64)(unsafe.Pointer(bp + 288)) = int64(0)
  48366 	rc = Xsqlite3BtreeCount(tls, db, pCrsr1, bp+288)
  48367 	if !(rc != 0) {
  48368 		goto __519
  48369 	}
  48370 	goto abort_due_to_error
  48371 __519:
  48372 	;
  48373 __518:
  48374 	;
  48375 	pOut = out2Prerelease(tls, p, pOp)
  48376 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 288))
  48377 	goto check_for_interrupt
  48378 
  48379 __78:
  48380 	p12 = (*Op)(unsafe.Pointer(pOp)).Fp1
  48381 	zName = *(*uintptr)(unsafe.Pointer(pOp + 16))
  48382 
  48383 	if !(p12 == SAVEPOINT_BEGIN) {
  48384 		goto __520
  48385 	}
  48386 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) {
  48387 		goto __522
  48388 	}
  48389 
  48390 	Xsqlite3VdbeError(tls, p, ts+5524, 0)
  48391 	rc = SQLITE_BUSY
  48392 	goto __523
  48393 __522:
  48394 	nName = Xsqlite3Strlen30(tls, zName)
  48395 
  48396 	rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN,
  48397 		(*Sqlite3)(unsafe.Pointer(db)).FnStatement+(*Sqlite3)(unsafe.Pointer(db)).FnSavepoint)
  48398 	if !(rc != SQLITE_OK) {
  48399 		goto __524
  48400 	}
  48401 	goto abort_due_to_error
  48402 __524:
  48403 	;
  48404 	pNew = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(Savepoint{}))+uint32(nName)+uint32(1)))
  48405 	if !(pNew != 0) {
  48406 		goto __525
  48407 	}
  48408 	(*Savepoint)(unsafe.Pointer(pNew)).FzName = pNew + 1*32
  48409 	libc.Xmemcpy(tls, (*Savepoint)(unsafe.Pointer(pNew)).FzName, zName, uint32(nName+1))
  48410 
  48411 	if !((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0) {
  48412 		goto __526
  48413 	}
  48414 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(0)
  48415 	(*Sqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = U8(1)
  48416 	goto __527
  48417 __526:
  48418 	(*Sqlite3)(unsafe.Pointer(db)).FnSavepoint++
  48419 __527:
  48420 	;
  48421 	(*Savepoint)(unsafe.Pointer(pNew)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).FpSavepoint
  48422 	(*Sqlite3)(unsafe.Pointer(db)).FpSavepoint = pNew
  48423 	(*Savepoint)(unsafe.Pointer(pNew)).FnDeferredCons = (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons
  48424 	(*Savepoint)(unsafe.Pointer(pNew)).FnDeferredImmCons = (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons
  48425 __525:
  48426 	;
  48427 __523:
  48428 	;
  48429 	goto __521
  48430 __520:
  48431 	;
  48432 	iSavepoint = 0
  48433 
  48434 	pSavepoint = (*Sqlite3)(unsafe.Pointer(db)).FpSavepoint
  48435 __528:
  48436 	if !(pSavepoint != 0 && Xsqlite3StrICmp(tls, (*Savepoint)(unsafe.Pointer(pSavepoint)).FzName, zName) != 0) {
  48437 		goto __530
  48438 	}
  48439 	iSavepoint++
  48440 	goto __529
  48441 __529:
  48442 	pSavepoint = (*Savepoint)(unsafe.Pointer(pSavepoint)).FpNext
  48443 	goto __528
  48444 	goto __530
  48445 __530:
  48446 	;
  48447 	if !!(pSavepoint != 0) {
  48448 		goto __531
  48449 	}
  48450 	Xsqlite3VdbeError(tls, p, ts+5575, libc.VaList(bp+88, zName))
  48451 	rc = SQLITE_ERROR
  48452 	goto __532
  48453 __531:
  48454 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 && p12 == SAVEPOINT_RELEASE) {
  48455 		goto __533
  48456 	}
  48457 
  48458 	Xsqlite3VdbeError(tls, p,
  48459 		ts+5597, 0)
  48460 	rc = SQLITE_BUSY
  48461 	goto __534
  48462 __533:
  48463 	isTransaction = libc.Bool32((*Savepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0) && (*Sqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0)
  48464 	if !(isTransaction != 0 && p12 == SAVEPOINT_RELEASE) {
  48465 		goto __535
  48466 	}
  48467 	if !(libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1)) != SQLITE_OK) {
  48468 		goto __537
  48469 	}
  48470 	goto vdbe_return
  48471 __537:
  48472 	;
  48473 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
  48474 	if !(Xsqlite3VdbeHalt(tls, p) == SQLITE_BUSY) {
  48475 		goto __538
  48476 	}
  48477 	(*Vdbe)(unsafe.Pointer(p)).Fpc = (int32(pOp) - int32(aOp)) / 20
  48478 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(0)
  48479 	(*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, SQLITE_BUSY)
  48480 	goto vdbe_return
  48481 __538:
  48482 	;
  48483 	rc = (*Vdbe)(unsafe.Pointer(p)).Frc
  48484 	if !(rc != 0) {
  48485 		goto __539
  48486 	}
  48487 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(0)
  48488 	goto __540
  48489 __539:
  48490 	(*Sqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = U8(0)
  48491 __540:
  48492 	;
  48493 	goto __536
  48494 __535:
  48495 	iSavepoint = (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint - 1
  48496 	if !(p12 == SAVEPOINT_ROLLBACK) {
  48497 		goto __541
  48498 	}
  48499 	isSchemaChange = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_SchemaChange) != U32(0))
  48500 	ii = 0
  48501 __543:
  48502 	if !(ii < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  48503 		goto __545
  48504 	}
  48505 	rc = Xsqlite3BtreeTripAllCursors(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*16)).FpBt,
  48506 		SQLITE_ABORT|int32(2)<<8,
  48507 		libc.Bool32(isSchemaChange == 0))
  48508 	if !(rc != SQLITE_OK) {
  48509 		goto __546
  48510 	}
  48511 	goto abort_due_to_error
  48512 __546:
  48513 	;
  48514 	goto __544
  48515 __544:
  48516 	ii++
  48517 	goto __543
  48518 	goto __545
  48519 __545:
  48520 	;
  48521 	goto __542
  48522 __541:
  48523 	;
  48524 	isSchemaChange = 0
  48525 __542:
  48526 	;
  48527 	ii = 0
  48528 __547:
  48529 	if !(ii < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  48530 		goto __549
  48531 	}
  48532 	rc = Xsqlite3BtreeSavepoint(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*16)).FpBt, p12, iSavepoint)
  48533 	if !(rc != SQLITE_OK) {
  48534 		goto __550
  48535 	}
  48536 	goto abort_due_to_error
  48537 __550:
  48538 	;
  48539 	goto __548
  48540 __548:
  48541 	ii++
  48542 	goto __547
  48543 	goto __549
  48544 __549:
  48545 	;
  48546 	if !(isSchemaChange != 0) {
  48547 		goto __551
  48548 	}
  48549 	Xsqlite3ExpirePreparedStatements(tls, db, 0)
  48550 	Xsqlite3ResetAllSchemasOfConnection(tls, db)
  48551 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  48552 __551:
  48553 	;
  48554 __536:
  48555 	;
  48556 	if !(rc != 0) {
  48557 		goto __552
  48558 	}
  48559 	goto abort_due_to_error
  48560 __552:
  48561 	;
  48562 __553:
  48563 	if !((*Sqlite3)(unsafe.Pointer(db)).FpSavepoint != pSavepoint) {
  48564 		goto __554
  48565 	}
  48566 	pTmp = (*Sqlite3)(unsafe.Pointer(db)).FpSavepoint
  48567 	(*Sqlite3)(unsafe.Pointer(db)).FpSavepoint = (*Savepoint)(unsafe.Pointer(pTmp)).FpNext
  48568 	Xsqlite3DbFree(tls, db, pTmp)
  48569 	(*Sqlite3)(unsafe.Pointer(db)).FnSavepoint--
  48570 	goto __553
  48571 __554:
  48572 	;
  48573 	if !(p12 == SAVEPOINT_RELEASE) {
  48574 		goto __555
  48575 	}
  48576 
  48577 	(*Sqlite3)(unsafe.Pointer(db)).FpSavepoint = (*Savepoint)(unsafe.Pointer(pSavepoint)).FpNext
  48578 	Xsqlite3DbFree(tls, db, pSavepoint)
  48579 	if !!(isTransaction != 0) {
  48580 		goto __557
  48581 	}
  48582 	(*Sqlite3)(unsafe.Pointer(db)).FnSavepoint--
  48583 __557:
  48584 	;
  48585 	goto __556
  48586 __555:
  48587 	;
  48588 	(*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = (*Savepoint)(unsafe.Pointer(pSavepoint)).FnDeferredCons
  48589 	(*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = (*Savepoint)(unsafe.Pointer(pSavepoint)).FnDeferredImmCons
  48590 __556:
  48591 	;
  48592 	if !(!(isTransaction != 0) || p12 == SAVEPOINT_ROLLBACK) {
  48593 		goto __558
  48594 	}
  48595 	rc = Xsqlite3VtabSavepoint(tls, db, p12, iSavepoint)
  48596 	if !(rc != SQLITE_OK) {
  48597 		goto __559
  48598 	}
  48599 	goto abort_due_to_error
  48600 __559:
  48601 	;
  48602 __558:
  48603 	;
  48604 __534:
  48605 	;
  48606 __532:
  48607 	;
  48608 __521:
  48609 	;
  48610 	if !(rc != 0) {
  48611 		goto __560
  48612 	}
  48613 	goto abort_due_to_error
  48614 __560:
  48615 	;
  48616 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) == VDBE_HALT_STATE) {
  48617 		goto __561
  48618 	}
  48619 	rc = SQLITE_DONE
  48620 	goto vdbe_return
  48621 __561:
  48622 	;
  48623 	goto __9
  48624 
  48625 __79:
  48626 	desiredAutoCommit = (*Op)(unsafe.Pointer(pOp)).Fp1
  48627 	iRollback = (*Op)(unsafe.Pointer(pOp)).Fp2
  48628 
  48629 	if !(desiredAutoCommit != int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit)) {
  48630 		goto __562
  48631 	}
  48632 	if !(iRollback != 0) {
  48633 		goto __564
  48634 	}
  48635 
  48636 	Xsqlite3RollbackAll(tls, db, SQLITE_ABORT|int32(2)<<8)
  48637 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
  48638 	goto __565
  48639 __564:
  48640 	if !(desiredAutoCommit != 0 && (*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) {
  48641 		goto __566
  48642 	}
  48643 
  48644 	Xsqlite3VdbeError(tls, p,
  48645 		ts+5651, 0)
  48646 	rc = SQLITE_BUSY
  48647 	goto abort_due_to_error
  48648 	goto __567
  48649 __566:
  48650 	if !(libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1)) != SQLITE_OK) {
  48651 		goto __568
  48652 	}
  48653 	goto vdbe_return
  48654 	goto __569
  48655 __568:
  48656 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(desiredAutoCommit)
  48657 __569:
  48658 	;
  48659 __567:
  48660 	;
  48661 __565:
  48662 	;
  48663 	if !(Xsqlite3VdbeHalt(tls, p) == SQLITE_BUSY) {
  48664 		goto __570
  48665 	}
  48666 	(*Vdbe)(unsafe.Pointer(p)).Fpc = (int32(pOp) - int32(aOp)) / 20
  48667 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1 - desiredAutoCommit)
  48668 	(*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, SQLITE_BUSY)
  48669 	goto vdbe_return
  48670 __570:
  48671 	;
  48672 	Xsqlite3CloseSavepoints(tls, db)
  48673 	if !((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
  48674 		goto __571
  48675 	}
  48676 	rc = SQLITE_DONE
  48677 	goto __572
  48678 __571:
  48679 	rc = SQLITE_ERROR
  48680 __572:
  48681 	;
  48682 	goto vdbe_return
  48683 	goto __563
  48684 __562:
  48685 	Xsqlite3VdbeError(tls, p,
  48686 		func() uintptr {
  48687 			if !(desiredAutoCommit != 0) {
  48688 				return ts + 5706
  48689 			}
  48690 			return func() uintptr {
  48691 				if iRollback != 0 {
  48692 					return ts + 5754
  48693 				}
  48694 				return ts + 5797
  48695 			}()
  48696 		}(), 0)
  48697 
  48698 	rc = SQLITE_ERROR
  48699 	goto abort_due_to_error
  48700 __563:
  48701 	;
  48702 __80:
  48703 	*(*int32)(unsafe.Pointer(bp + 296)) = 0
  48704 
  48705 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 != 0 && (*Sqlite3)(unsafe.Pointer(db)).Fflags&(uint64(SQLITE_QueryOnly)|uint64(0x00002)<<32) != uint64(0)) {
  48706 		goto __573
  48707 	}
  48708 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_QueryOnly) != 0) {
  48709 		goto __574
  48710 	}
  48711 
  48712 	rc = SQLITE_READONLY
  48713 	goto __575
  48714 __574:
  48715 	rc = SQLITE_CORRUPT
  48716 __575:
  48717 	;
  48718 	goto abort_due_to_error
  48719 __573:
  48720 	;
  48721 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16
  48722 	pBt = (*Db)(unsafe.Pointer(pDb)).FpBt
  48723 
  48724 	if !(pBt != 0) {
  48725 		goto __576
  48726 	}
  48727 	rc = Xsqlite3BtreeBeginTrans(tls, pBt, (*Op)(unsafe.Pointer(pOp)).Fp2, bp+296)
  48728 
  48729 	if !(rc != SQLITE_OK) {
  48730 		goto __577
  48731 	}
  48732 	if !(rc&0xff == SQLITE_BUSY) {
  48733 		goto __578
  48734 	}
  48735 	(*Vdbe)(unsafe.Pointer(p)).Fpc = (int32(pOp) - int32(aOp)) / 20
  48736 	(*Vdbe)(unsafe.Pointer(p)).Frc = rc
  48737 	goto vdbe_return
  48738 __578:
  48739 	;
  48740 	goto abort_due_to_error
  48741 __577:
  48742 	;
  48743 	if !(Bft(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x20>>5)) != 0 &&
  48744 		(*Op)(unsafe.Pointer(pOp)).Fp2 != 0 &&
  48745 		(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 || (*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1)) {
  48746 		goto __579
  48747 	}
  48748 
  48749 	if !((*Vdbe)(unsafe.Pointer(p)).FiStatement == 0) {
  48750 		goto __580
  48751 	}
  48752 
  48753 	(*Sqlite3)(unsafe.Pointer(db)).FnStatement++
  48754 	(*Vdbe)(unsafe.Pointer(p)).FiStatement = (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint + (*Sqlite3)(unsafe.Pointer(db)).FnStatement
  48755 __580:
  48756 	;
  48757 	rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*Vdbe)(unsafe.Pointer(p)).FiStatement-1)
  48758 	if !(rc == SQLITE_OK) {
  48759 		goto __581
  48760 	}
  48761 	rc = Xsqlite3BtreeBeginStmt(tls, pBt, (*Vdbe)(unsafe.Pointer(p)).FiStatement)
  48762 __581:
  48763 	;
  48764 	(*Vdbe)(unsafe.Pointer(p)).FnStmtDefCons = (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons
  48765 	(*Vdbe)(unsafe.Pointer(p)).FnStmtDefImmCons = (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons
  48766 __579:
  48767 	;
  48768 __576:
  48769 	;
  48770 	if !(rc == SQLITE_OK &&
  48771 		(*Op)(unsafe.Pointer(pOp)).Fp5 != 0 &&
  48772 		(*(*int32)(unsafe.Pointer(bp + 296)) != (*Op)(unsafe.Pointer(pOp)).Fp3 || (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FiGeneration != *(*int32)(unsafe.Pointer(pOp + 16)))) {
  48773 		goto __582
  48774 	}
  48775 
  48776 	Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)
  48777 	(*Vdbe)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3DbStrDup(tls, db, ts+5838)
  48778 
  48779 	if !((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16)).FpSchema)).Fschema_cookie != *(*int32)(unsafe.Pointer(bp + 296))) {
  48780 		goto __583
  48781 	}
  48782 	Xsqlite3ResetOneSchema(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1)
  48783 __583:
  48784 	;
  48785 	libc.SetBitFieldPtr8Uint32(p+152, Bft(1), 0, 0x3)
  48786 	rc = SQLITE_SCHEMA
  48787 
  48788 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 4, 0x10)
  48789 __582:
  48790 	;
  48791 	if !(rc != 0) {
  48792 		goto __584
  48793 	}
  48794 	goto abort_due_to_error
  48795 __584:
  48796 	;
  48797 	goto __9
  48798 
  48799 __81:
  48800 	;
  48801 	iDb = (*Op)(unsafe.Pointer(pOp)).Fp1
  48802 	iCookie = (*Op)(unsafe.Pointer(pOp)).Fp3
  48803 
  48804 	Xsqlite3BtreeGetMeta(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpBt, iCookie, bp+300)
  48805 	pOut = out2Prerelease(tls, p, pOp)
  48806 	*(*I64)(unsafe.Pointer(pOut)) = I64(*(*int32)(unsafe.Pointer(bp + 300)))
  48807 	goto __9
  48808 
  48809 __82:
  48810 	;
  48811 	pDb1 = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16
  48812 
  48813 	rc = Xsqlite3BtreeUpdateMeta(tls, (*Db)(unsafe.Pointer(pDb1)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp2, uint32((*Op)(unsafe.Pointer(pOp)).Fp3))
  48814 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 == BTREE_SCHEMA_VERSION) {
  48815 		goto __585
  48816 	}
  48817 
  48818 	*(*U32)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb1)).FpSchema)) = *(*U32)(unsafe.Pointer(pOp + 12)) - U32((*Op)(unsafe.Pointer(pOp)).Fp5)
  48819 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  48820 	Xsqlite3FkClearTriggerCache(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1)
  48821 	goto __586
  48822 __585:
  48823 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 == BTREE_FILE_FORMAT) {
  48824 		goto __587
  48825 	}
  48826 
  48827 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format = U8((*Op)(unsafe.Pointer(pOp)).Fp3)
  48828 __587:
  48829 	;
  48830 __586:
  48831 	;
  48832 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 == 1) {
  48833 		goto __588
  48834 	}
  48835 
  48836 	Xsqlite3ExpirePreparedStatements(tls, db, 0)
  48837 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 0, 0x3)
  48838 __588:
  48839 	;
  48840 	if !(rc != 0) {
  48841 		goto __589
  48842 	}
  48843 	goto abort_due_to_error
  48844 __589:
  48845 	;
  48846 	goto __9
  48847 
  48848 __83:
  48849 	;
  48850 	pCur = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  48851 	if !(pCur != 0 && (*VdbeCursor)(unsafe.Pointer(pCur)).FpgnoRoot == U32((*Op)(unsafe.Pointer(pOp)).Fp2)) {
  48852 		goto __590
  48853 	}
  48854 
  48855 	Xsqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pCur + 36)))
  48856 	goto open_cursor_set_hints
  48857 __590:
  48858 	;
  48859 __84:
  48860 __85:
  48861 	;
  48862 	if !(int32(*(*uint8)(unsafe.Pointer(p + 152))&0x3>>0) == 1) {
  48863 		goto __591
  48864 	}
  48865 	rc = SQLITE_ABORT | int32(2)<<8
  48866 	goto abort_due_to_error
  48867 __591:
  48868 	;
  48869 	nField1 = 0
  48870 	pKeyInfo1 = uintptr(0)
  48871 	p23 = U32((*Op)(unsafe.Pointer(pOp)).Fp2)
  48872 	iDb1 = (*Op)(unsafe.Pointer(pOp)).Fp3
  48873 
  48874 	pDb2 = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb1)*16
  48875 	pX = (*Db)(unsafe.Pointer(pDb2)).FpBt
  48876 
  48877 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenWrite) {
  48878 		goto __592
  48879 	}
  48880 
  48881 	wrFlag = BTREE_WRCSR | int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_FORDELETE
  48882 
  48883 	if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb2)).FpSchema)).Ffile_format) < int32((*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat)) {
  48884 		goto __594
  48885 	}
  48886 	(*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb2)).FpSchema)).Ffile_format
  48887 __594:
  48888 	;
  48889 	goto __593
  48890 __592:
  48891 	wrFlag = 0
  48892 __593:
  48893 	;
  48894 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_P2ISREG != 0) {
  48895 		goto __595
  48896 	}
  48897 
  48898 	pIn2 = aMem + uintptr(p23)*40
  48899 
  48900 	Xsqlite3VdbeMemIntegerify(tls, pIn2)
  48901 	p23 = U32(int32(*(*I64)(unsafe.Pointer(pIn2))))
  48902 
  48903 __595:
  48904 	;
  48905 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == -8) {
  48906 		goto __596
  48907 	}
  48908 	pKeyInfo1 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  48909 
  48910 	nField1 = int32((*KeyInfo)(unsafe.Pointer(pKeyInfo1)).FnAllField)
  48911 	goto __597
  48912 __596:
  48913 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == -3) {
  48914 		goto __598
  48915 	}
  48916 	nField1 = *(*int32)(unsafe.Pointer(pOp + 16))
  48917 __598:
  48918 	;
  48919 __597:
  48920 	;
  48921 	pCur = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, nField1, uint8(CURTYPE_BTREE))
  48922 	if !(pCur == uintptr(0)) {
  48923 		goto __599
  48924 	}
  48925 	goto no_mem
  48926 __599:
  48927 	;
  48928 	(*VdbeCursor)(unsafe.Pointer(pCur)).FiDb = I8(iDb1)
  48929 	(*VdbeCursor)(unsafe.Pointer(pCur)).FnullRow = U8(1)
  48930 	libc.SetBitFieldPtr8Uint32(pCur+8, Bool(1), 2, 0x4)
  48931 	(*VdbeCursor)(unsafe.Pointer(pCur)).FpgnoRoot = p23
  48932 	rc = Xsqlite3BtreeCursor(tls, pX, p23, wrFlag, pKeyInfo1, *(*uintptr)(unsafe.Pointer(pCur + 36)))
  48933 	(*VdbeCursor)(unsafe.Pointer(pCur)).FpKeyInfo = pKeyInfo1
  48934 
  48935 	(*VdbeCursor)(unsafe.Pointer(pCur)).FisTable = U8(libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) != -8))
  48936 
  48937 open_cursor_set_hints:
  48938 	;
  48939 	Xsqlite3BtreeCursorHintFlags(tls, *(*uintptr)(unsafe.Pointer(pCur + 36)),
  48940 		uint32(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&(OPFLAG_BULKCSR|OPFLAG_SEEKEQ)))
  48941 	if !(rc != 0) {
  48942 		goto __600
  48943 	}
  48944 	goto abort_due_to_error
  48945 __600:
  48946 	;
  48947 	goto __9
  48948 
  48949 __86:
  48950 	pOrig = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*4))
  48951 
  48952 	pCx = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, int32((*VdbeCursor)(unsafe.Pointer(pOrig)).FnField), uint8(CURTYPE_BTREE))
  48953 	if !(pCx == uintptr(0)) {
  48954 		goto __601
  48955 	}
  48956 	goto no_mem
  48957 __601:
  48958 	;
  48959 	(*VdbeCursor)(unsafe.Pointer(pCx)).FnullRow = U8(1)
  48960 	libc.SetBitFieldPtr8Uint32(pCx+8, Bool(1), 0, 0x1)
  48961 	(*VdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pOrig)).FpKeyInfo
  48962 	(*VdbeCursor)(unsafe.Pointer(pCx)).FisTable = (*VdbeCursor)(unsafe.Pointer(pOrig)).FisTable
  48963 	(*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot = (*VdbeCursor)(unsafe.Pointer(pOrig)).FpgnoRoot
  48964 	libc.SetBitFieldPtr8Uint32(pCx+8, Bool(int32(*(*uint8)(unsafe.Pointer(pOrig + 8))&0x4>>2)), 2, 0x4)
  48965 	*(*uintptr)(unsafe.Pointer(pCx + 12)) = *(*uintptr)(unsafe.Pointer(pOrig + 12))
  48966 	libc.SetBitFieldPtr8Uint32(pCx+8, Bool(1), 3, 0x8)
  48967 	libc.SetBitFieldPtr8Uint32(pOrig+8, Bool(1), 3, 0x8)
  48968 	rc = Xsqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 12)), (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, BTREE_WRCSR,
  48969 		(*VdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 36)))
  48970 
  48971 	goto __9
  48972 
  48973 __87:
  48974 __88:
  48975 	;
  48976 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 > 0) {
  48977 		goto __602
  48978 	}
  48979 
  48980 	(*Mem)(unsafe.Pointer(aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40)).Fn = 0
  48981 	(*Mem)(unsafe.Pointer(aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40)).Fz = ts + 1554
  48982 __602:
  48983 	;
  48984 	pCx1 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  48985 	if !(pCx1 != 0 && !(int32(*(*uint8)(unsafe.Pointer(pCx1 + 8))&0x8>>3) != 0) && (*Op)(unsafe.Pointer(pOp)).Fp2 <= int32((*VdbeCursor)(unsafe.Pointer(pCx1)).FnField)) {
  48986 		goto __603
  48987 	}
  48988 
  48989 	(*VdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = int64(0)
  48990 	(*VdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = U32(CACHE_STALE)
  48991 	rc = Xsqlite3BtreeClearTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 12)), int32((*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0))
  48992 	goto __604
  48993 __603:
  48994 	pCx1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_BTREE))
  48995 	if !(pCx1 == uintptr(0)) {
  48996 		goto __605
  48997 	}
  48998 	goto no_mem
  48999 __605:
  49000 	;
  49001 	libc.SetBitFieldPtr8Uint32(pCx1+8, Bool(1), 0, 0x1)
  49002 	rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, pCx1+12,
  49003 		BTREE_OMIT_JOURNAL|BTREE_SINGLE|int32((*Op)(unsafe.Pointer(pOp)).Fp5),
  49004 		vfsFlags)
  49005 	if !(rc == SQLITE_OK) {
  49006 		goto __606
  49007 	}
  49008 	rc = Xsqlite3BtreeBeginTrans(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 12)), 1, uintptr(0))
  49009 	if !(rc == SQLITE_OK) {
  49010 		goto __607
  49011 	}
  49012 
  49013 	if !(libc.AssignPtrUintptr(pCx1+40, libc.AssignUintptr(&pKeyInfo2, *(*uintptr)(unsafe.Pointer(pOp + 16)))) != uintptr(0)) {
  49014 		goto __608
  49015 	}
  49016 
  49017 	rc = Xsqlite3BtreeCreateTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 12)), pCx1+48,
  49018 		BTREE_BLOBKEY|int32((*Op)(unsafe.Pointer(pOp)).Fp5))
  49019 	if !(rc == SQLITE_OK) {
  49020 		goto __610
  49021 	}
  49022 
  49023 	rc = Xsqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 12)), (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, BTREE_WRCSR,
  49024 		pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 36)))
  49025 __610:
  49026 	;
  49027 	(*VdbeCursor)(unsafe.Pointer(pCx1)).FisTable = U8(0)
  49028 	goto __609
  49029 __608:
  49030 	(*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = Pgno(SCHEMA_ROOT)
  49031 	rc = Xsqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 12)), uint32(SCHEMA_ROOT), BTREE_WRCSR,
  49032 		uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 36)))
  49033 	(*VdbeCursor)(unsafe.Pointer(pCx1)).FisTable = U8(1)
  49034 __609:
  49035 	;
  49036 __607:
  49037 	;
  49038 	libc.SetBitFieldPtr8Uint32(pCx1+8, Bool(libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) != BTREE_UNORDERED)), 2, 0x4)
  49039 	if !(rc != 0) {
  49040 		goto __611
  49041 	}
  49042 	Xsqlite3BtreeClose(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 12)))
  49043 __611:
  49044 	;
  49045 __606:
  49046 	;
  49047 __604:
  49048 	;
  49049 	if !(rc != 0) {
  49050 		goto __612
  49051 	}
  49052 	goto abort_due_to_error
  49053 __612:
  49054 	;
  49055 	(*VdbeCursor)(unsafe.Pointer(pCx1)).FnullRow = U8(1)
  49056 	goto __9
  49057 
  49058 __89:
  49059 	;
  49060 	pCx2 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_SORTER))
  49061 	if !(pCx2 == uintptr(0)) {
  49062 		goto __613
  49063 	}
  49064 	goto no_mem
  49065 __613:
  49066 	;
  49067 	(*VdbeCursor)(unsafe.Pointer(pCx2)).FpKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16))
  49068 
  49069 	rc = Xsqlite3VdbeSorterInit(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp3, pCx2)
  49070 	if !(rc != 0) {
  49071 		goto __614
  49072 	}
  49073 	goto abort_due_to_error
  49074 __614:
  49075 	;
  49076 	goto __9
  49077 
  49078 __90:
  49079 	;
  49080 	pC4 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49081 
  49082 	if !(libc.PostIncInt64(&(*VdbeCursor)(unsafe.Pointer(pC4)).FseqCount, 1) == int64(0)) {
  49083 		goto __615
  49084 	}
  49085 	goto jump_to_p2
  49086 __615:
  49087 	;
  49088 	goto __9
  49089 
  49090 __91:
  49091 	;
  49092 	pCx3 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp3, uint8(CURTYPE_PSEUDO))
  49093 	if !(pCx3 == uintptr(0)) {
  49094 		goto __616
  49095 	}
  49096 	goto no_mem
  49097 __616:
  49098 	;
  49099 	(*VdbeCursor)(unsafe.Pointer(pCx3)).FnullRow = U8(1)
  49100 	(*VdbeCursor)(unsafe.Pointer(pCx3)).FseekResult = (*Op)(unsafe.Pointer(pOp)).Fp2
  49101 	(*VdbeCursor)(unsafe.Pointer(pCx3)).FisTable = U8(1)
  49102 
  49103 	*(*uintptr)(unsafe.Pointer(pCx3 + 36)) = Xsqlite3BtreeFakeValidCursor(tls)
  49104 
  49105 	goto __9
  49106 
  49107 __92:
  49108 	;
  49109 	Xsqlite3VdbeFreeCursor(tls, p, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4)))
  49110 	*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4)) = uintptr(0)
  49111 	goto __9
  49112 
  49113 __93:
  49114 __94:
  49115 __95:
  49116 __96:
  49117 	;
  49118 	pC5 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49119 
  49120 	oc = int32((*Op)(unsafe.Pointer(pOp)).Fopcode)
  49121 	eqOnly = 0
  49122 	(*VdbeCursor)(unsafe.Pointer(pC5)).FnullRow = U8(0)
  49123 
  49124 	(*VdbeCursor)(unsafe.Pointer(pC5)).FdeferredMoveto = U8(0)
  49125 	(*VdbeCursor)(unsafe.Pointer(pC5)).FcacheStatus = U32(CACHE_STALE)
  49126 	if !((*VdbeCursor)(unsafe.Pointer(pC5)).FisTable != 0) {
  49127 		goto __617
  49128 	}
  49129 
  49130 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49131 	flags31 = (*Mem)(unsafe.Pointer(pIn3)).Fflags
  49132 	if !(int32(flags31)&(MEM_Int|MEM_Real|MEM_IntReal|MEM_Str) == MEM_Str) {
  49133 		goto __619
  49134 	}
  49135 	applyNumericAffinity(tls, pIn3, 0)
  49136 __619:
  49137 	;
  49138 	iKey = Xsqlite3VdbeIntValue(tls, pIn3)
  49139 	newType = (*Mem)(unsafe.Pointer(pIn3)).Fflags
  49140 	(*Mem)(unsafe.Pointer(pIn3)).Fflags = flags31
  49141 
  49142 	if !(int32(newType)&(MEM_Int|MEM_IntReal) == 0) {
  49143 		goto __620
  49144 	}
  49145 	if !(int32(newType)&MEM_Real == 0) {
  49146 		goto __621
  49147 	}
  49148 	if !(int32(newType)&MEM_Null != 0 || oc >= OP_SeekGE) {
  49149 		goto __622
  49150 	}
  49151 
  49152 	goto jump_to_p2
  49153 	goto __623
  49154 __622:
  49155 	rc = Xsqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)), bp+304)
  49156 	if !(rc != SQLITE_OK) {
  49157 		goto __624
  49158 	}
  49159 	goto abort_due_to_error
  49160 __624:
  49161 	;
  49162 	goto seek_not_found
  49163 __623:
  49164 	;
  49165 __621:
  49166 	;
  49167 	c2 = Xsqlite3IntFloatCompare(tls, iKey, *(*float64)(unsafe.Pointer(pIn3)))
  49168 
  49169 	if !(c2 > 0) {
  49170 		goto __625
  49171 	}
  49172 
  49173 	if !(oc&0x0001 == OP_SeekGT&0x0001) {
  49174 		goto __627
  49175 	}
  49176 	oc--
  49177 __627:
  49178 	;
  49179 	goto __626
  49180 __625:
  49181 	if !(c2 < 0) {
  49182 		goto __628
  49183 	}
  49184 
  49185 	if !(oc&0x0001 == OP_SeekLT&0x0001) {
  49186 		goto __629
  49187 	}
  49188 	oc++
  49189 __629:
  49190 	;
  49191 __628:
  49192 	;
  49193 __626:
  49194 	;
  49195 __620:
  49196 	;
  49197 	rc = Xsqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)), int64(U64(iKey)), 0, bp+304)
  49198 	(*VdbeCursor)(unsafe.Pointer(pC5)).FmovetoTarget = iKey
  49199 	if !(rc != SQLITE_OK) {
  49200 		goto __630
  49201 	}
  49202 	goto abort_due_to_error
  49203 __630:
  49204 	;
  49205 	goto __618
  49206 __617:
  49207 	if !(Xsqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)), uint32(BTREE_SEEK_EQ)) != 0) {
  49208 		goto __631
  49209 	}
  49210 	eqOnly = 1
  49211 
  49212 __631:
  49213 	;
  49214 	nField2 = *(*int32)(unsafe.Pointer(pOp + 16))
  49215 
  49216 	(*UnpackedRecord)(unsafe.Pointer(bp + 312)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC5)).FpKeyInfo
  49217 	(*UnpackedRecord)(unsafe.Pointer(bp + 312)).FnField = U16(nField2)
  49218 
  49219 	(*UnpackedRecord)(unsafe.Pointer(bp + 312)).Fdefault_rc = func() int8 {
  49220 		if 1&(oc-OP_SeekLT) != 0 {
  49221 			return int8(-1)
  49222 		}
  49223 		return +int8(1)
  49224 	}()
  49225 
  49226 	(*UnpackedRecord)(unsafe.Pointer(bp + 312)).FaMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49227 	(*UnpackedRecord)(unsafe.Pointer(bp + 312)).FeqSeen = U8(0)
  49228 	rc = Xsqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)), bp+312, bp+304)
  49229 	if !(rc != SQLITE_OK) {
  49230 		goto __632
  49231 	}
  49232 	goto abort_due_to_error
  49233 __632:
  49234 	;
  49235 	if !(eqOnly != 0 && int32((*UnpackedRecord)(unsafe.Pointer(bp+312)).FeqSeen) == 0) {
  49236 		goto __633
  49237 	}
  49238 
  49239 	goto seek_not_found
  49240 __633:
  49241 	;
  49242 __618:
  49243 	;
  49244 	if !(oc >= OP_SeekGE) {
  49245 		goto __634
  49246 	}
  49247 	if !(*(*int32)(unsafe.Pointer(bp + 304)) < 0 || *(*int32)(unsafe.Pointer(bp + 304)) == 0 && oc == OP_SeekGT) {
  49248 		goto __636
  49249 	}
  49250 	*(*int32)(unsafe.Pointer(bp + 304)) = 0
  49251 	rc = Xsqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)), 0)
  49252 	if !(rc != SQLITE_OK) {
  49253 		goto __638
  49254 	}
  49255 	if !(rc == SQLITE_DONE) {
  49256 		goto __639
  49257 	}
  49258 	rc = SQLITE_OK
  49259 	*(*int32)(unsafe.Pointer(bp + 304)) = 1
  49260 	goto __640
  49261 __639:
  49262 	goto abort_due_to_error
  49263 __640:
  49264 	;
  49265 __638:
  49266 	;
  49267 	goto __637
  49268 __636:
  49269 	*(*int32)(unsafe.Pointer(bp + 304)) = 0
  49270 __637:
  49271 	;
  49272 	goto __635
  49273 __634:
  49274 	;
  49275 	if !(*(*int32)(unsafe.Pointer(bp + 304)) > 0 || *(*int32)(unsafe.Pointer(bp + 304)) == 0 && oc == OP_SeekLT) {
  49276 		goto __641
  49277 	}
  49278 	*(*int32)(unsafe.Pointer(bp + 304)) = 0
  49279 	rc = Xsqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)), 0)
  49280 	if !(rc != SQLITE_OK) {
  49281 		goto __643
  49282 	}
  49283 	if !(rc == SQLITE_DONE) {
  49284 		goto __644
  49285 	}
  49286 	rc = SQLITE_OK
  49287 	*(*int32)(unsafe.Pointer(bp + 304)) = 1
  49288 	goto __645
  49289 __644:
  49290 	goto abort_due_to_error
  49291 __645:
  49292 	;
  49293 __643:
  49294 	;
  49295 	goto __642
  49296 __641:
  49297 	*(*int32)(unsafe.Pointer(bp + 304)) = Xsqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC5 + 36)))
  49298 __642:
  49299 	;
  49300 __635:
  49301 	;
  49302 seek_not_found:
  49303 	;
  49304 	if !(*(*int32)(unsafe.Pointer(bp + 304)) != 0) {
  49305 		goto __646
  49306 	}
  49307 	goto jump_to_p2
  49308 	goto __647
  49309 __646:
  49310 	if !(eqOnly != 0) {
  49311 		goto __648
  49312 	}
  49313 
  49314 	pOp += 20
  49315 __648:
  49316 	;
  49317 __647:
  49318 	;
  49319 	goto __9
  49320 
  49321 __97:
  49322 	;
  49323 	pC6 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp+1*20)).Fp1)*4))
  49324 
  49325 	if !!(Xsqlite3BtreeCursorIsValidNN(tls, *(*uintptr)(unsafe.Pointer(pC6 + 36))) != 0) {
  49326 		goto __649
  49327 	}
  49328 	goto __9
  49329 __649:
  49330 	;
  49331 	nStep = (*Op)(unsafe.Pointer(pOp)).Fp1
  49332 
  49333 	(*UnpackedRecord)(unsafe.Pointer(bp + 344)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC6)).FpKeyInfo
  49334 	(*UnpackedRecord)(unsafe.Pointer(bp + 344)).FnField = U16(*(*int32)(unsafe.Pointer(pOp + 1*20 + 16)))
  49335 	(*UnpackedRecord)(unsafe.Pointer(bp + 344)).Fdefault_rc = int8(0)
  49336 	(*UnpackedRecord)(unsafe.Pointer(bp + 344)).FaMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp+1*20)).Fp3)*40
  49337 	*(*int32)(unsafe.Pointer(bp + 376)) = 0
  49338 __650:
  49339 	if !(1 != 0) {
  49340 		goto __651
  49341 	}
  49342 	rc = Xsqlite3VdbeIdxKeyCompare(tls, db, pC6, bp+344, bp+376)
  49343 	if !(rc != 0) {
  49344 		goto __652
  49345 	}
  49346 	goto abort_due_to_error
  49347 __652:
  49348 	;
  49349 	if !(*(*int32)(unsafe.Pointer(bp + 376)) > 0 && int32((*Op)(unsafe.Pointer(pOp)).Fp5) == 0) {
  49350 		goto __653
  49351 	}
  49352 seekscan_search_fail:
  49353 	;
  49354 	pOp += 20
  49355 	goto jump_to_p2
  49356 __653:
  49357 	;
  49358 	if !(*(*int32)(unsafe.Pointer(bp + 376)) >= 0) {
  49359 		goto __654
  49360 	}
  49361 
  49362 	goto jump_to_p2
  49363 	goto __651
  49364 __654:
  49365 	;
  49366 	if !(nStep <= 0) {
  49367 		goto __655
  49368 	}
  49369 
  49370 	goto __651
  49371 __655:
  49372 	;
  49373 	nStep--
  49374 	rc = Xsqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC6 + 36)), 0)
  49375 	if !(rc != 0) {
  49376 		goto __656
  49377 	}
  49378 	if !(rc == SQLITE_DONE) {
  49379 		goto __657
  49380 	}
  49381 	rc = SQLITE_OK
  49382 	goto seekscan_search_fail
  49383 	goto __658
  49384 __657:
  49385 	goto abort_due_to_error
  49386 __658:
  49387 	;
  49388 __656:
  49389 	;
  49390 	goto __650
  49391 __651:
  49392 	;
  49393 	goto __9
  49394 
  49395 __98:
  49396 	;
  49397 	pC7 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49398 
  49399 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC7)).FseekHit) < (*Op)(unsafe.Pointer(pOp)).Fp2) {
  49400 		goto __659
  49401 	}
  49402 	(*VdbeCursor)(unsafe.Pointer(pC7)).FseekHit = U16((*Op)(unsafe.Pointer(pOp)).Fp2)
  49403 	goto __660
  49404 __659:
  49405 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC7)).FseekHit) > (*Op)(unsafe.Pointer(pOp)).Fp3) {
  49406 		goto __661
  49407 	}
  49408 	(*VdbeCursor)(unsafe.Pointer(pC7)).FseekHit = U16((*Op)(unsafe.Pointer(pOp)).Fp3)
  49409 __661:
  49410 	;
  49411 __660:
  49412 	;
  49413 	goto __9
  49414 
  49415 __99:
  49416 	;
  49417 	pCur1 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49418 
  49419 	if !(pCur1 == uintptr(0) || (*VdbeCursor)(unsafe.Pointer(pCur1)).FnullRow != 0) {
  49420 		goto __662
  49421 	}
  49422 	goto jump_to_p2_and_check_for_interrupt
  49423 __662:
  49424 	;
  49425 	goto __9
  49426 
  49427 __100:
  49428 	;
  49429 	pC8 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49430 
  49431 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC8)).FseekHit) >= *(*int32)(unsafe.Pointer(pOp + 16))) {
  49432 		goto __663
  49433 	}
  49434 	goto __9
  49435 __663:
  49436 	;
  49437 __101:
  49438 __102:
  49439 __103:
  49440 	;
  49441 	pC9 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49442 
  49443 	(*UnpackedRecord)(unsafe.Pointer(bp + 384)).FaMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49444 
  49445 	(*UnpackedRecord)(unsafe.Pointer(bp + 384)).FnField = U16(*(*int32)(unsafe.Pointer(pOp + 16)))
  49446 	if !(int32((*UnpackedRecord)(unsafe.Pointer(bp+384)).FnField) > 0) {
  49447 		goto __664
  49448 	}
  49449 
  49450 	(*UnpackedRecord)(unsafe.Pointer(bp + 384)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo
  49451 	(*UnpackedRecord)(unsafe.Pointer(bp + 384)).Fdefault_rc = int8(0)
  49452 	rc = Xsqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 36)), bp+384, pC9+28)
  49453 	goto __665
  49454 __664:
  49455 	;
  49456 	rc = func() int32 {
  49457 		if int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(bp+384)).FaMem)).Fflags)&MEM_Zero != 0 {
  49458 			return Xsqlite3VdbeMemExpandBlob(tls, (*UnpackedRecord)(unsafe.Pointer(bp+384)).FaMem)
  49459 		}
  49460 		return 0
  49461 	}()
  49462 
  49463 	if !(rc != 0) {
  49464 		goto __666
  49465 	}
  49466 	goto no_mem
  49467 __666:
  49468 	;
  49469 	pIdxKey = Xsqlite3VdbeAllocUnpackedRecord(tls, (*VdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo)
  49470 	if !(pIdxKey == uintptr(0)) {
  49471 		goto __667
  49472 	}
  49473 	goto no_mem
  49474 __667:
  49475 	;
  49476 	Xsqlite3VdbeRecordUnpack(tls, (*VdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo, (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(bp+384)).FaMem)).Fn, (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(bp+384)).FaMem)).Fz, pIdxKey)
  49477 	(*UnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = int8(0)
  49478 	rc = Xsqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 36)), pIdxKey, pC9+28)
  49479 	Xsqlite3DbFreeNN(tls, db, pIdxKey)
  49480 __665:
  49481 	;
  49482 	if !(rc != SQLITE_OK) {
  49483 		goto __668
  49484 	}
  49485 	goto abort_due_to_error
  49486 __668:
  49487 	;
  49488 	alreadyExists = libc.Bool32((*VdbeCursor)(unsafe.Pointer(pC9)).FseekResult == 0)
  49489 	(*VdbeCursor)(unsafe.Pointer(pC9)).FnullRow = U8(1 - alreadyExists)
  49490 	(*VdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = U8(0)
  49491 	(*VdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = U32(CACHE_STALE)
  49492 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Found) {
  49493 		goto __669
  49494 	}
  49495 
  49496 	if !(alreadyExists != 0) {
  49497 		goto __671
  49498 	}
  49499 	goto jump_to_p2
  49500 __671:
  49501 	;
  49502 	goto __670
  49503 __669:
  49504 	if !!(alreadyExists != 0) {
  49505 		goto __672
  49506 	}
  49507 
  49508 	goto jump_to_p2
  49509 __672:
  49510 	;
  49511 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_NoConflict) {
  49512 		goto __673
  49513 	}
  49514 
  49515 	ii1 = 0
  49516 __674:
  49517 	if !(ii1 < int32((*UnpackedRecord)(unsafe.Pointer(bp+384)).FnField)) {
  49518 		goto __676
  49519 	}
  49520 	if !(int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(bp+384)).FaMem+uintptr(ii1)*40)).Fflags)&MEM_Null != 0) {
  49521 		goto __677
  49522 	}
  49523 
  49524 	goto jump_to_p2
  49525 __677:
  49526 	;
  49527 	goto __675
  49528 __675:
  49529 	ii1++
  49530 	goto __674
  49531 	goto __676
  49532 __676:
  49533 	;
  49534 __673:
  49535 	;
  49536 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_IfNoHope) {
  49537 		goto __678
  49538 	}
  49539 	(*VdbeCursor)(unsafe.Pointer(pC9)).FseekHit = U16(*(*int32)(unsafe.Pointer(pOp + 16)))
  49540 __678:
  49541 	;
  49542 __670:
  49543 	;
  49544 	goto __9
  49545 
  49546 __104:
  49547 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49548 
  49549 	if !(int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)&(MEM_Int|MEM_IntReal) == 0) {
  49550 		goto __679
  49551 	}
  49552 
  49553 	*(*Mem)(unsafe.Pointer(bp + 416)) = *(*Mem)(unsafe.Pointer(pIn3))
  49554 	applyAffinity(tls, bp+416, uint8(SQLITE_AFF_NUMERIC), encoding)
  49555 	if !(int32((*Mem)(unsafe.Pointer(bp+416)).Fflags)&MEM_Int == 0) {
  49556 		goto __680
  49557 	}
  49558 	goto jump_to_p2
  49559 __680:
  49560 	;
  49561 	iKey1 = U64(*(*I64)(unsafe.Pointer(bp + 416)))
  49562 	goto notExistsWithKey
  49563 __679:
  49564 	;
  49565 __105:
  49566 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49567 
  49568 	iKey1 = U64(*(*I64)(unsafe.Pointer(pIn3)))
  49569 notExistsWithKey:
  49570 	pC10 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49571 
  49572 	pCrsr2 = *(*uintptr)(unsafe.Pointer(pC10 + 36))
  49573 
  49574 	*(*int32)(unsafe.Pointer(bp + 456)) = 0
  49575 	rc = Xsqlite3BtreeTableMoveto(tls, pCrsr2, int64(iKey1), 0, bp+456)
  49576 
  49577 	(*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = I64(iKey1)
  49578 	(*VdbeCursor)(unsafe.Pointer(pC10)).FnullRow = U8(0)
  49579 	(*VdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = U32(CACHE_STALE)
  49580 	(*VdbeCursor)(unsafe.Pointer(pC10)).FdeferredMoveto = U8(0)
  49581 
  49582 	(*VdbeCursor)(unsafe.Pointer(pC10)).FseekResult = *(*int32)(unsafe.Pointer(bp + 456))
  49583 	if !(*(*int32)(unsafe.Pointer(bp + 456)) != 0) {
  49584 		goto __681
  49585 	}
  49586 
  49587 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 0) {
  49588 		goto __682
  49589 	}
  49590 	rc = Xsqlite3CorruptError(tls, 95563)
  49591 	goto __683
  49592 __682:
  49593 	goto jump_to_p2
  49594 __683:
  49595 	;
  49596 __681:
  49597 	;
  49598 	if !(rc != 0) {
  49599 		goto __684
  49600 	}
  49601 	goto abort_due_to_error
  49602 __684:
  49603 	;
  49604 	goto __9
  49605 
  49606 __106:
  49607 	;
  49608 	pOut = out2Prerelease(tls, p, pOp)
  49609 	*(*I64)(unsafe.Pointer(pOut)) = libc.PostIncInt64(&(*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4)))).FseqCount, 1)
  49610 	goto __9
  49611 
  49612 __107:
  49613 	*(*I64)(unsafe.Pointer(bp + 464)) = int64(0)
  49614 	*(*int32)(unsafe.Pointer(bp + 460)) = 0
  49615 	pOut = out2Prerelease(tls, p, pOp)
  49616 
  49617 	pC11 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49618 
  49619 	if !!(int32(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1) != 0) {
  49620 		goto __685
  49621 	}
  49622 	rc = Xsqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC11 + 36)), bp+460)
  49623 	if !(rc != SQLITE_OK) {
  49624 		goto __686
  49625 	}
  49626 	goto abort_due_to_error
  49627 __686:
  49628 	;
  49629 	if !(*(*int32)(unsafe.Pointer(bp + 460)) != 0) {
  49630 		goto __687
  49631 	}
  49632 	*(*I64)(unsafe.Pointer(bp + 464)) = int64(1)
  49633 	goto __688
  49634 __687:
  49635 	;
  49636 	*(*I64)(unsafe.Pointer(bp + 464)) = Xsqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC11 + 36)))
  49637 	if !(*(*I64)(unsafe.Pointer(bp + 464)) >= int64(uint64(0x7fffffff)<<32|uint64(0xffffffff))) {
  49638 		goto __689
  49639 	}
  49640 	libc.SetBitFieldPtr8Uint32(pC11+8, Bool(1), 1, 0x2)
  49641 	goto __690
  49642 __689:
  49643 	*(*I64)(unsafe.Pointer(bp + 464))++
  49644 __690:
  49645 	;
  49646 __688:
  49647 	;
  49648 __685:
  49649 	;
  49650 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  49651 		goto __691
  49652 	}
  49653 
  49654 	if !((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0) {
  49655 		goto __692
  49656 	}
  49657 	pFrame1 = (*Vdbe)(unsafe.Pointer(p)).FpFrame
  49658 __694:
  49659 	if !((*VdbeFrame)(unsafe.Pointer(pFrame1)).FpParent != 0) {
  49660 		goto __696
  49661 	}
  49662 	goto __695
  49663 __695:
  49664 	pFrame1 = (*VdbeFrame)(unsafe.Pointer(pFrame1)).FpParent
  49665 	goto __694
  49666 	goto __696
  49667 __696:
  49668 	;
  49669 	pMem = (*VdbeFrame)(unsafe.Pointer(pFrame1)).FaMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49670 	goto __693
  49671 __692:
  49672 	;
  49673 	pMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49674 
  49675 __693:
  49676 	;
  49677 	Xsqlite3VdbeMemIntegerify(tls, pMem)
  49678 
  49679 	if !(*(*I64)(unsafe.Pointer(pMem)) == int64(uint64(0x7fffffff)<<32|uint64(0xffffffff)) || Bool(int32(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0) {
  49680 		goto __697
  49681 	}
  49682 	rc = SQLITE_FULL
  49683 	goto abort_due_to_error
  49684 __697:
  49685 	;
  49686 	if !(*(*I64)(unsafe.Pointer(bp + 464)) < *(*I64)(unsafe.Pointer(pMem))+int64(1)) {
  49687 		goto __698
  49688 	}
  49689 	*(*I64)(unsafe.Pointer(bp + 464)) = *(*I64)(unsafe.Pointer(pMem)) + int64(1)
  49690 __698:
  49691 	;
  49692 	*(*I64)(unsafe.Pointer(pMem)) = *(*I64)(unsafe.Pointer(bp + 464))
  49693 __691:
  49694 	;
  49695 	if !(Bool(int32(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0) {
  49696 		goto __699
  49697 	}
  49698 
  49699 	cnt1 = 0
  49700 __700:
  49701 	Xsqlite3_randomness(tls, int32(unsafe.Sizeof(I64(0))), bp+464)
  49702 	*(*I64)(unsafe.Pointer(bp + 464)) &= int64(uint64(0x7fffffff)<<32|uint64(0xffffffff)) >> 1
  49703 	*(*I64)(unsafe.Pointer(bp + 464))++
  49704 	goto __701
  49705 __701:
  49706 	if libc.AssignInt32(&rc, Xsqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC11 + 36)), int64(U64(*(*I64)(unsafe.Pointer(bp + 464)))),
  49707 		0, bp+460)) == SQLITE_OK &&
  49708 		*(*int32)(unsafe.Pointer(bp + 460)) == 0 &&
  49709 		libc.PreIncInt32(&cnt1, 1) < 100 {
  49710 		goto __700
  49711 	}
  49712 	goto __702
  49713 __702:
  49714 	;
  49715 	if !(rc != 0) {
  49716 		goto __703
  49717 	}
  49718 	goto abort_due_to_error
  49719 __703:
  49720 	;
  49721 	if !(*(*int32)(unsafe.Pointer(bp + 460)) == 0) {
  49722 		goto __704
  49723 	}
  49724 	rc = SQLITE_FULL
  49725 	goto abort_due_to_error
  49726 __704:
  49727 	;
  49728 __699:
  49729 	;
  49730 	(*VdbeCursor)(unsafe.Pointer(pC11)).FdeferredMoveto = U8(0)
  49731 	(*VdbeCursor)(unsafe.Pointer(pC11)).FcacheStatus = U32(CACHE_STALE)
  49732 
  49733 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 464))
  49734 	goto __9
  49735 
  49736 __108:
  49737 	pData = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  49738 
  49739 	pC12 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49740 
  49741 	pKey = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49742 
  49743 	(*BtreePayload)(unsafe.Pointer(bp + 472)).FnKey = *(*I64)(unsafe.Pointer(pKey))
  49744 
  49745 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == -5 && ((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0)) {
  49746 		goto __705
  49747 	}
  49748 
  49749 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*VdbeCursor)(unsafe.Pointer(pC12)).FiDb)*16)).FzDbSName
  49750 	pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  49751 
  49752 	goto __706
  49753 __705:
  49754 	pTab1 = uintptr(0)
  49755 	zDb = uintptr(0)
  49756 __706:
  49757 	;
  49758 	if !(pTab1 != 0) {
  49759 		goto __707
  49760 	}
  49761 	if !((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_ISUPDATE != 0)) {
  49762 		goto __708
  49763 	}
  49764 	Xsqlite3VdbePreUpdateHook(tls, p, pC12, SQLITE_INSERT, zDb, pTab1, (*BtreePayload)(unsafe.Pointer(bp+472)).FnKey, (*Op)(unsafe.Pointer(pOp)).Fp2, -1)
  49765 __708:
  49766 	;
  49767 	if !((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0) || (*Table)(unsafe.Pointer(pTab1)).FaCol == uintptr(0)) {
  49768 		goto __709
  49769 	}
  49770 
  49771 	pTab1 = uintptr(0)
  49772 __709:
  49773 	;
  49774 __707:
  49775 	;
  49776 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_ISNOOP != 0) {
  49777 		goto __710
  49778 	}
  49779 	goto __9
  49780 __710:
  49781 	;
  49782 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_NCHANGE != 0) {
  49783 		goto __711
  49784 	}
  49785 	(*Vdbe)(unsafe.Pointer(p)).FnChange++
  49786 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_LASTROWID != 0) {
  49787 		goto __712
  49788 	}
  49789 	(*Sqlite3)(unsafe.Pointer(db)).FlastRowid = (*BtreePayload)(unsafe.Pointer(bp + 472)).FnKey
  49790 __712:
  49791 	;
  49792 __711:
  49793 	;
  49794 	(*BtreePayload)(unsafe.Pointer(bp + 472)).FpData = (*Mem)(unsafe.Pointer(pData)).Fz
  49795 	(*BtreePayload)(unsafe.Pointer(bp + 472)).FnData = (*Mem)(unsafe.Pointer(pData)).Fn
  49796 	seekResult = func() int32 {
  49797 		if int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_USESEEKRESULT != 0 {
  49798 			return (*VdbeCursor)(unsafe.Pointer(pC12)).FseekResult
  49799 		}
  49800 		return 0
  49801 	}()
  49802 	if !(int32((*Mem)(unsafe.Pointer(pData)).Fflags)&MEM_Zero != 0) {
  49803 		goto __713
  49804 	}
  49805 	(*BtreePayload)(unsafe.Pointer(bp + 472)).FnZero = *(*int32)(unsafe.Pointer(pData))
  49806 	goto __714
  49807 __713:
  49808 	(*BtreePayload)(unsafe.Pointer(bp + 472)).FnZero = 0
  49809 __714:
  49810 	;
  49811 	(*BtreePayload)(unsafe.Pointer(bp + 472)).FpKey = uintptr(0)
  49812 
  49813 	rc = Xsqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC12 + 36)), bp+472,
  49814 		int32((*Op)(unsafe.Pointer(pOp)).Fp5)&(OPFLAG_APPEND|OPFLAG_SAVEPOSITION|OPFLAG_PREFORMAT),
  49815 		seekResult)
  49816 	(*VdbeCursor)(unsafe.Pointer(pC12)).FdeferredMoveto = U8(0)
  49817 	(*VdbeCursor)(unsafe.Pointer(pC12)).FcacheStatus = U32(CACHE_STALE)
  49818 
  49819 	if !(rc != 0) {
  49820 		goto __715
  49821 	}
  49822 	goto abort_due_to_error
  49823 __715:
  49824 	;
  49825 	if !(pTab1 != 0) {
  49826 		goto __716
  49827 	}
  49828 
  49829 	(*struct {
  49830 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64)
  49831 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg,
  49832 		func() int32 {
  49833 			if int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_ISUPDATE != 0 {
  49834 				return SQLITE_UPDATE
  49835 			}
  49836 			return SQLITE_INSERT
  49837 		}(),
  49838 		zDb, (*Table)(unsafe.Pointer(pTab1)).FzName, (*BtreePayload)(unsafe.Pointer(bp+472)).FnKey)
  49839 __716:
  49840 	;
  49841 	goto __9
  49842 
  49843 __109:
  49844 	;
  49845 	pDest1 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49846 	pSrc = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*4))
  49847 	if (*Op)(unsafe.Pointer(pOp)).Fp3 != 0 {
  49848 		iKey2 = *(*I64)(unsafe.Pointer(aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40))
  49849 	} else {
  49850 		iKey2 = int64(0)
  49851 	}
  49852 	rc = Xsqlite3BtreeTransferRow(tls, *(*uintptr)(unsafe.Pointer(pDest1 + 36)), *(*uintptr)(unsafe.Pointer(pSrc + 36)), iKey2)
  49853 	if !(rc != SQLITE_OK) {
  49854 		goto __717
  49855 	}
  49856 	goto abort_due_to_error
  49857 __717:
  49858 	;
  49859 	goto __9
  49860 
  49861 __110:
  49862 	opflags = (*Op)(unsafe.Pointer(pOp)).Fp2
  49863 
  49864 	pC13 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49865 
  49866 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == -5 && ((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0)) {
  49867 		goto __718
  49868 	}
  49869 
  49870 	zDb1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*VdbeCursor)(unsafe.Pointer(pC13)).FiDb)*16)).FzDbSName
  49871 	pTab2 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  49872 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_SAVEPOSITION != 0 && (*VdbeCursor)(unsafe.Pointer(pC13)).FisTable != 0) {
  49873 		goto __720
  49874 	}
  49875 	(*VdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget = Xsqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC13 + 36)))
  49876 __720:
  49877 	;
  49878 	goto __719
  49879 __718:
  49880 	zDb1 = uintptr(0)
  49881 	pTab2 = uintptr(0)
  49882 __719:
  49883 	;
  49884 	if !((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && pTab2 != 0) {
  49885 		goto __721
  49886 	}
  49887 
  49888 	Xsqlite3VdbePreUpdateHook(tls, p, pC13,
  49889 		func() int32 {
  49890 			if opflags&OPFLAG_ISUPDATE != 0 {
  49891 				return SQLITE_UPDATE
  49892 			}
  49893 			return SQLITE_DELETE
  49894 		}(),
  49895 		zDb1, pTab2, (*VdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget,
  49896 		(*Op)(unsafe.Pointer(pOp)).Fp3, -1)
  49897 __721:
  49898 	;
  49899 	if !(opflags&OPFLAG_ISNOOP != 0) {
  49900 		goto __722
  49901 	}
  49902 	goto __9
  49903 __722:
  49904 	;
  49905 	rc = Xsqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC13 + 36)), uint8((*Op)(unsafe.Pointer(pOp)).Fp5))
  49906 	(*VdbeCursor)(unsafe.Pointer(pC13)).FcacheStatus = U32(CACHE_STALE)
  49907 	(*VdbeCursor)(unsafe.Pointer(pC13)).FseekResult = 0
  49908 	if !(rc != 0) {
  49909 		goto __723
  49910 	}
  49911 	goto abort_due_to_error
  49912 __723:
  49913 	;
  49914 	if !(opflags&OPFLAG_NCHANGE != 0) {
  49915 		goto __724
  49916 	}
  49917 	(*Vdbe)(unsafe.Pointer(p)).FnChange++
  49918 	if !((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0 && pTab2 != uintptr(0) && (*Table)(unsafe.Pointer(pTab2)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  49919 		goto __725
  49920 	}
  49921 	(*struct {
  49922 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64)
  49923 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, SQLITE_DELETE, zDb1, (*Table)(unsafe.Pointer(pTab2)).FzName,
  49924 		(*VdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget)
  49925 
  49926 __725:
  49927 	;
  49928 __724:
  49929 	;
  49930 	goto __9
  49931 
  49932 __111:
  49933 	Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange)
  49934 	(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  49935 	goto __9
  49936 
  49937 __112:
  49938 	pC14 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49939 
  49940 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  49941 	nKeyCol = *(*int32)(unsafe.Pointer(pOp + 16))
  49942 	*(*int32)(unsafe.Pointer(bp + 512)) = 0
  49943 	rc = Xsqlite3VdbeSorterCompare(tls, pC14, pIn3, nKeyCol, bp+512)
  49944 
  49945 	if !(rc != 0) {
  49946 		goto __726
  49947 	}
  49948 	goto abort_due_to_error
  49949 __726:
  49950 	;
  49951 	if !(*(*int32)(unsafe.Pointer(bp + 512)) != 0) {
  49952 		goto __727
  49953 	}
  49954 	goto jump_to_p2
  49955 __727:
  49956 	;
  49957 	goto __9
  49958 
  49959 __113:
  49960 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  49961 	pC15 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49962 
  49963 	rc = Xsqlite3VdbeSorterRowkey(tls, pC15, pOut)
  49964 
  49965 	if !(rc != 0) {
  49966 		goto __728
  49967 	}
  49968 	goto abort_due_to_error
  49969 __728:
  49970 	;
  49971 	(*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*4)))).FcacheStatus = U32(CACHE_STALE)
  49972 	goto __9
  49973 
  49974 __114:
  49975 	pOut = out2Prerelease(tls, p, pOp)
  49976 
  49977 	pC16 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  49978 
  49979 	pCrsr3 = *(*uintptr)(unsafe.Pointer(pC16 + 36))
  49980 
  49981 	n3 = Xsqlite3BtreePayloadSize(tls, pCrsr3)
  49982 	if !(n3 > U32(*(*int32)(unsafe.Pointer(db + 120)))) {
  49983 		goto __729
  49984 	}
  49985 	goto too_big
  49986 __729:
  49987 	;
  49988 	rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, pCrsr3, n3, pOut)
  49989 	if !(rc != 0) {
  49990 		goto __730
  49991 	}
  49992 	goto abort_due_to_error
  49993 __730:
  49994 	;
  49995 	if !!((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  49996 		goto __731
  49997 	}
  49998 	if !(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&MEM_Ephem != 0 && Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0) {
  49999 		goto __732
  50000 	}
  50001 	goto no_mem
  50002 __732:
  50003 	;
  50004 __731:
  50005 	;
  50006 	goto __9
  50007 
  50008 __115:
  50009 	pOut = out2Prerelease(tls, p, pOp)
  50010 
  50011 	pC17 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50012 
  50013 	if !((*VdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0) {
  50014 		goto __733
  50015 	}
  50016 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Null)
  50017 	goto __9
  50018 	goto __734
  50019 __733:
  50020 	if !((*VdbeCursor)(unsafe.Pointer(pC17)).FdeferredMoveto != 0) {
  50021 		goto __735
  50022 	}
  50023 	*(*I64)(unsafe.Pointer(bp + 520)) = (*VdbeCursor)(unsafe.Pointer(pC17)).FmovetoTarget
  50024 	goto __736
  50025 __735:
  50026 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC17)).FeCurType) == CURTYPE_VTAB) {
  50027 		goto __737
  50028 	}
  50029 
  50030 	pVtab = (*Sqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pC17 + 36)))).FpVtab
  50031 	pModule = (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule
  50032 
  50033 	rc = (*struct {
  50034 		f func(*libc.TLS, uintptr, uintptr) int32
  50035 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule)).FxRowid})).f(tls, *(*uintptr)(unsafe.Pointer(pC17 + 36)), bp+520)
  50036 	Xsqlite3VtabImportErrmsg(tls, p, pVtab)
  50037 	if !(rc != 0) {
  50038 		goto __739
  50039 	}
  50040 	goto abort_due_to_error
  50041 __739:
  50042 	;
  50043 	goto __738
  50044 __737:
  50045 	;
  50046 	rc = Xsqlite3VdbeCursorRestore(tls, pC17)
  50047 	if !(rc != 0) {
  50048 		goto __740
  50049 	}
  50050 	goto abort_due_to_error
  50051 __740:
  50052 	;
  50053 	if !((*VdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0) {
  50054 		goto __741
  50055 	}
  50056 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Null)
  50057 	goto __9
  50058 __741:
  50059 	;
  50060 	*(*I64)(unsafe.Pointer(bp + 520)) = Xsqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC17 + 36)))
  50061 __738:
  50062 	;
  50063 __736:
  50064 	;
  50065 __734:
  50066 	;
  50067 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 520))
  50068 	goto __9
  50069 
  50070 __116:
  50071 	;
  50072 	pC18 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50073 	if !(pC18 == uintptr(0)) {
  50074 		goto __742
  50075 	}
  50076 
  50077 	pC18 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, 1, uint8(CURTYPE_PSEUDO))
  50078 	if !(pC18 == uintptr(0)) {
  50079 		goto __743
  50080 	}
  50081 	goto no_mem
  50082 __743:
  50083 	;
  50084 	(*VdbeCursor)(unsafe.Pointer(pC18)).FseekResult = 0
  50085 	(*VdbeCursor)(unsafe.Pointer(pC18)).FisTable = U8(1)
  50086 	libc.SetBitFieldPtr8Uint32(pC18+8, Bool(1), 3, 0x8)
  50087 	*(*uintptr)(unsafe.Pointer(pC18 + 36)) = Xsqlite3BtreeFakeValidCursor(tls)
  50088 __742:
  50089 	;
  50090 	(*VdbeCursor)(unsafe.Pointer(pC18)).FnullRow = U8(1)
  50091 	(*VdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = U32(CACHE_STALE)
  50092 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC18)).FeCurType) == CURTYPE_BTREE) {
  50093 		goto __744
  50094 	}
  50095 
  50096 	Xsqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pC18 + 36)))
  50097 __744:
  50098 	;
  50099 	goto __9
  50100 
  50101 __117:
  50102 __118:
  50103 	;
  50104 	pC19 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50105 
  50106 	pCrsr4 = *(*uintptr)(unsafe.Pointer(pC19 + 36))
  50107 	*(*int32)(unsafe.Pointer(bp + 528)) = 0
  50108 
  50109 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_SeekEnd) {
  50110 		goto __745
  50111 	}
  50112 
  50113 	(*VdbeCursor)(unsafe.Pointer(pC19)).FseekResult = -1
  50114 	if !(Xsqlite3BtreeCursorIsValidNN(tls, pCrsr4) != 0) {
  50115 		goto __746
  50116 	}
  50117 	goto __9
  50118 __746:
  50119 	;
  50120 __745:
  50121 	;
  50122 	rc = Xsqlite3BtreeLast(tls, pCrsr4, bp+528)
  50123 	(*VdbeCursor)(unsafe.Pointer(pC19)).FnullRow = U8(*(*int32)(unsafe.Pointer(bp + 528)))
  50124 	(*VdbeCursor)(unsafe.Pointer(pC19)).FdeferredMoveto = U8(0)
  50125 	(*VdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = U32(CACHE_STALE)
  50126 	if !(rc != 0) {
  50127 		goto __747
  50128 	}
  50129 	goto abort_due_to_error
  50130 __747:
  50131 	;
  50132 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 > 0) {
  50133 		goto __748
  50134 	}
  50135 
  50136 	if !(*(*int32)(unsafe.Pointer(bp + 528)) != 0) {
  50137 		goto __749
  50138 	}
  50139 	goto jump_to_p2
  50140 __749:
  50141 	;
  50142 __748:
  50143 	;
  50144 	goto __9
  50145 
  50146 __119:
  50147 	;
  50148 	pC20 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50149 
  50150 	pCrsr5 = *(*uintptr)(unsafe.Pointer(pC20 + 36))
  50151 
  50152 	rc = Xsqlite3BtreeFirst(tls, pCrsr5, bp+532)
  50153 	if !(rc != 0) {
  50154 		goto __750
  50155 	}
  50156 	goto abort_due_to_error
  50157 __750:
  50158 	;
  50159 	if !(*(*int32)(unsafe.Pointer(bp + 532)) == 0) {
  50160 		goto __751
  50161 	}
  50162 	sz = Xsqlite3BtreeRowCountEst(tls, pCrsr5)
  50163 	if !(sz >= int64(0) && int32(Xsqlite3LogEst(tls, U64(sz))) < (*Op)(unsafe.Pointer(pOp)).Fp3) {
  50164 		goto __752
  50165 	}
  50166 	*(*int32)(unsafe.Pointer(bp + 532)) = 1
  50167 __752:
  50168 	;
  50169 __751:
  50170 	;
  50171 	if !(*(*int32)(unsafe.Pointer(bp + 532)) != 0) {
  50172 		goto __753
  50173 	}
  50174 	goto jump_to_p2
  50175 __753:
  50176 	;
  50177 	goto __9
  50178 
  50179 __120:
  50180 __121:
  50181 	*(*U32)(unsafe.Pointer(p + 164 + 2*4))++
  50182 
  50183 __122:
  50184 	;
  50185 	pC21 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50186 
  50187 	*(*int32)(unsafe.Pointer(bp + 536)) = 1
  50188 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC21)).FeCurType) == CURTYPE_SORTER) {
  50189 		goto __754
  50190 	}
  50191 	rc = Xsqlite3VdbeSorterRewind(tls, pC21, bp+536)
  50192 	goto __755
  50193 __754:
  50194 	;
  50195 	pCrsr6 = *(*uintptr)(unsafe.Pointer(pC21 + 36))
  50196 
  50197 	rc = Xsqlite3BtreeFirst(tls, pCrsr6, bp+536)
  50198 	(*VdbeCursor)(unsafe.Pointer(pC21)).FdeferredMoveto = U8(0)
  50199 	(*VdbeCursor)(unsafe.Pointer(pC21)).FcacheStatus = U32(CACHE_STALE)
  50200 __755:
  50201 	;
  50202 	if !(rc != 0) {
  50203 		goto __756
  50204 	}
  50205 	goto abort_due_to_error
  50206 __756:
  50207 	;
  50208 	(*VdbeCursor)(unsafe.Pointer(pC21)).FnullRow = U8(*(*int32)(unsafe.Pointer(bp + 536)))
  50209 	if !((*Op)(unsafe.Pointer(pOp)).Fp2 > 0) {
  50210 		goto __757
  50211 	}
  50212 
  50213 	if !(*(*int32)(unsafe.Pointer(bp + 536)) != 0) {
  50214 		goto __758
  50215 	}
  50216 	goto jump_to_p2
  50217 __758:
  50218 	;
  50219 __757:
  50220 	;
  50221 	goto __9
  50222 
  50223 __123:
  50224 	pC22 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50225 
  50226 	rc = Xsqlite3VdbeSorterNext(tls, db, pC22)
  50227 	goto next_tail
  50228 
  50229 __124:
  50230 	;
  50231 	pC22 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50232 
  50233 	rc = Xsqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC22 + 36)), (*Op)(unsafe.Pointer(pOp)).Fp3)
  50234 	goto next_tail
  50235 
  50236 __125:
  50237 	;
  50238 	pC22 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50239 
  50240 	rc = Xsqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC22 + 36)), (*Op)(unsafe.Pointer(pOp)).Fp3)
  50241 
  50242 next_tail:
  50243 	(*VdbeCursor)(unsafe.Pointer(pC22)).FcacheStatus = U32(CACHE_STALE)
  50244 
  50245 	if !(rc == SQLITE_OK) {
  50246 		goto __759
  50247 	}
  50248 	(*VdbeCursor)(unsafe.Pointer(pC22)).FnullRow = U8(0)
  50249 	*(*U32)(unsafe.Pointer(p + 164 + uintptr((*Op)(unsafe.Pointer(pOp)).Fp5)*4))++
  50250 	goto jump_to_p2_and_check_for_interrupt
  50251 __759:
  50252 	;
  50253 	if !(rc != SQLITE_DONE) {
  50254 		goto __760
  50255 	}
  50256 	goto abort_due_to_error
  50257 __760:
  50258 	;
  50259 	rc = SQLITE_OK
  50260 	(*VdbeCursor)(unsafe.Pointer(pC22)).FnullRow = U8(1)
  50261 	goto check_for_interrupt
  50262 
  50263 __126:
  50264 	;
  50265 	pC23 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50266 
  50267 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  50268 
  50269 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_NCHANGE != 0) {
  50270 		goto __761
  50271 	}
  50272 	(*Vdbe)(unsafe.Pointer(p)).FnChange++
  50273 __761:
  50274 	;
  50275 	rc = func() int32 {
  50276 		if int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)&MEM_Zero != 0 {
  50277 			return Xsqlite3VdbeMemExpandBlob(tls, pIn2)
  50278 		}
  50279 		return 0
  50280 	}()
  50281 	if !(rc != 0) {
  50282 		goto __762
  50283 	}
  50284 	goto abort_due_to_error
  50285 __762:
  50286 	;
  50287 	(*BtreePayload)(unsafe.Pointer(bp + 544)).FnKey = Sqlite3_int64((*Mem)(unsafe.Pointer(pIn2)).Fn)
  50288 	(*BtreePayload)(unsafe.Pointer(bp + 544)).FpKey = (*Mem)(unsafe.Pointer(pIn2)).Fz
  50289 	(*BtreePayload)(unsafe.Pointer(bp + 544)).FaMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  50290 	(*BtreePayload)(unsafe.Pointer(bp + 544)).FnMem = U16(*(*int32)(unsafe.Pointer(pOp + 16)))
  50291 	rc = Xsqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC23 + 36)), bp+544,
  50292 		int32((*Op)(unsafe.Pointer(pOp)).Fp5)&(OPFLAG_APPEND|OPFLAG_SAVEPOSITION|OPFLAG_PREFORMAT),
  50293 		func() int32 {
  50294 			if int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_USESEEKRESULT != 0 {
  50295 				return (*VdbeCursor)(unsafe.Pointer(pC23)).FseekResult
  50296 			}
  50297 			return 0
  50298 		}())
  50299 
  50300 	(*VdbeCursor)(unsafe.Pointer(pC23)).FcacheStatus = U32(CACHE_STALE)
  50301 	if !(rc != 0) {
  50302 		goto __763
  50303 	}
  50304 	goto abort_due_to_error
  50305 __763:
  50306 	;
  50307 	goto __9
  50308 
  50309 __127:
  50310 	;
  50311 	pC24 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50312 
  50313 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  50314 
  50315 	rc = func() int32 {
  50316 		if int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)&MEM_Zero != 0 {
  50317 			return Xsqlite3VdbeMemExpandBlob(tls, pIn2)
  50318 		}
  50319 		return 0
  50320 	}()
  50321 	if !(rc != 0) {
  50322 		goto __764
  50323 	}
  50324 	goto abort_due_to_error
  50325 __764:
  50326 	;
  50327 	rc = Xsqlite3VdbeSorterWrite(tls, pC24, pIn2)
  50328 	if !(rc != 0) {
  50329 		goto __765
  50330 	}
  50331 	goto abort_due_to_error
  50332 __765:
  50333 	;
  50334 	goto __9
  50335 
  50336 __128:
  50337 	;
  50338 	pC25 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50339 
  50340 	pCrsr7 = *(*uintptr)(unsafe.Pointer(pC25 + 36))
  50341 
  50342 	(*UnpackedRecord)(unsafe.Pointer(bp + 584)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC25)).FpKeyInfo
  50343 	(*UnpackedRecord)(unsafe.Pointer(bp + 584)).FnField = U16((*Op)(unsafe.Pointer(pOp)).Fp3)
  50344 	(*UnpackedRecord)(unsafe.Pointer(bp + 584)).Fdefault_rc = int8(0)
  50345 	(*UnpackedRecord)(unsafe.Pointer(bp + 584)).FaMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  50346 	rc = Xsqlite3BtreeIndexMoveto(tls, pCrsr7, bp+584, bp+616)
  50347 	if !(rc != 0) {
  50348 		goto __766
  50349 	}
  50350 	goto abort_due_to_error
  50351 __766:
  50352 	;
  50353 	if !(*(*int32)(unsafe.Pointer(bp + 616)) == 0) {
  50354 		goto __767
  50355 	}
  50356 	rc = Xsqlite3BtreeDelete(tls, pCrsr7, uint8(BTREE_AUXDELETE))
  50357 	if !(rc != 0) {
  50358 		goto __769
  50359 	}
  50360 	goto abort_due_to_error
  50361 __769:
  50362 	;
  50363 	goto __768
  50364 __767:
  50365 	if !((*Op)(unsafe.Pointer(pOp)).Fp5 != 0 && !(Xsqlite3WritableSchema(tls, db) != 0)) {
  50366 		goto __770
  50367 	}
  50368 	rc = Xsqlite3ReportError(tls, SQLITE_CORRUPT|int32(3)<<8, 96638, ts+5866)
  50369 	goto abort_due_to_error
  50370 __770:
  50371 	;
  50372 __768:
  50373 	;
  50374 	(*VdbeCursor)(unsafe.Pointer(pC25)).FcacheStatus = U32(CACHE_STALE)
  50375 	(*VdbeCursor)(unsafe.Pointer(pC25)).FseekResult = 0
  50376 	goto __9
  50377 
  50378 __129:
  50379 __130:
  50380 	;
  50381 	pC26 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50382 
  50383 	rc = Xsqlite3VdbeCursorRestore(tls, pC26)
  50384 
  50385 	if !(rc != SQLITE_OK) {
  50386 		goto __771
  50387 	}
  50388 	goto abort_due_to_error
  50389 __771:
  50390 	;
  50391 	if !!(int32((*VdbeCursor)(unsafe.Pointer(pC26)).FnullRow) != 0) {
  50392 		goto __772
  50393 	}
  50394 	*(*I64)(unsafe.Pointer(bp + 624)) = int64(0)
  50395 	rc = Xsqlite3VdbeIdxRowid(tls, db, *(*uintptr)(unsafe.Pointer(pC26 + 36)), bp+624)
  50396 	if !(rc != SQLITE_OK) {
  50397 		goto __774
  50398 	}
  50399 	goto abort_due_to_error
  50400 __774:
  50401 	;
  50402 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_DeferredSeek) {
  50403 		goto __775
  50404 	}
  50405 
  50406 	pTabCur = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*4))
  50407 
  50408 	(*VdbeCursor)(unsafe.Pointer(pTabCur)).FnullRow = U8(0)
  50409 	(*VdbeCursor)(unsafe.Pointer(pTabCur)).FmovetoTarget = *(*I64)(unsafe.Pointer(bp + 624))
  50410 	(*VdbeCursor)(unsafe.Pointer(pTabCur)).FdeferredMoveto = U8(1)
  50411 	(*VdbeCursor)(unsafe.Pointer(pTabCur)).FcacheStatus = U32(CACHE_STALE)
  50412 
  50413 	*(*uintptr)(unsafe.Pointer(pTabCur + 12)) = *(*uintptr)(unsafe.Pointer(pOp + 16))
  50414 
  50415 	(*VdbeCursor)(unsafe.Pointer(pTabCur)).FpAltCursor = pC26
  50416 	goto __776
  50417 __775:
  50418 	pOut = out2Prerelease(tls, p, pOp)
  50419 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 624))
  50420 __776:
  50421 	;
  50422 	goto __773
  50423 __772:
  50424 	;
  50425 	Xsqlite3VdbeMemSetNull(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40)
  50426 __773:
  50427 	;
  50428 	goto __9
  50429 
  50430 __131:
  50431 	;
  50432 	pC27 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50433 	if !((*VdbeCursor)(unsafe.Pointer(pC27)).FdeferredMoveto != 0) {
  50434 		goto __777
  50435 	}
  50436 	rc = Xsqlite3VdbeFinishMoveto(tls, pC27)
  50437 	if !(rc != 0) {
  50438 		goto __778
  50439 	}
  50440 	goto abort_due_to_error
  50441 __778:
  50442 	;
  50443 __777:
  50444 	;
  50445 	goto __9
  50446 
  50447 __132:
  50448 __133:
  50449 __134:
  50450 __135:
  50451 	;
  50452 	pC28 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50453 
  50454 	(*UnpackedRecord)(unsafe.Pointer(bp + 672)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC28)).FpKeyInfo
  50455 	(*UnpackedRecord)(unsafe.Pointer(bp + 672)).FnField = U16(*(*int32)(unsafe.Pointer(pOp + 16)))
  50456 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) < OP_IdxLT) {
  50457 		goto __779
  50458 	}
  50459 
  50460 	(*UnpackedRecord)(unsafe.Pointer(bp + 672)).Fdefault_rc = int8(-1)
  50461 	goto __780
  50462 __779:
  50463 	;
  50464 	(*UnpackedRecord)(unsafe.Pointer(bp + 672)).Fdefault_rc = int8(0)
  50465 __780:
  50466 	;
  50467 	(*UnpackedRecord)(unsafe.Pointer(bp + 672)).FaMem = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  50468 
  50469 	nCellKey = int64(0)
  50470 
  50471 	pCur2 = *(*uintptr)(unsafe.Pointer(pC28 + 36))
  50472 
  50473 	nCellKey = I64(Xsqlite3BtreePayloadSize(tls, pCur2))
  50474 
  50475 	if !(nCellKey <= int64(0) || nCellKey > int64(0x7fffffff)) {
  50476 		goto __781
  50477 	}
  50478 	rc = Xsqlite3CorruptError(tls, 96843)
  50479 	goto abort_due_to_error
  50480 __781:
  50481 	;
  50482 	Xsqlite3VdbeMemInit(tls, bp+632, db, uint16(0))
  50483 	rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, pCur2, U32(nCellKey), bp+632)
  50484 	if !(rc != 0) {
  50485 		goto __782
  50486 	}
  50487 	goto abort_due_to_error
  50488 __782:
  50489 	;
  50490 	res11 = Xsqlite3VdbeRecordCompareWithSkip(tls, (*Mem)(unsafe.Pointer(bp+632)).Fn, (*Mem)(unsafe.Pointer(bp+632)).Fz, bp+672, 0)
  50491 	Xsqlite3VdbeMemReleaseMalloc(tls, bp+632)
  50492 
  50493 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode)&1 == OP_IdxLT&1) {
  50494 		goto __783
  50495 	}
  50496 
  50497 	res11 = -res11
  50498 	goto __784
  50499 __783:
  50500 	;
  50501 	res11++
  50502 __784:
  50503 	;
  50504 	if !(res11 > 0) {
  50505 		goto __785
  50506 	}
  50507 	goto jump_to_p2
  50508 __785:
  50509 	;
  50510 	goto __9
  50511 
  50512 __136:
  50513 	;
  50514 	pOut = out2Prerelease(tls, p, pOp)
  50515 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Null)
  50516 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > (*Sqlite3)(unsafe.Pointer(db)).FnVDestroy+1) {
  50517 		goto __786
  50518 	}
  50519 	rc = SQLITE_LOCKED
  50520 	(*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(OE_Abort)
  50521 	goto abort_due_to_error
  50522 	goto __787
  50523 __786:
  50524 	iDb2 = (*Op)(unsafe.Pointer(pOp)).Fp3
  50525 
  50526 	*(*int32)(unsafe.Pointer(bp + 704)) = 0
  50527 	rc = Xsqlite3BtreeDropTable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb2)*16)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp1, bp+704)
  50528 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Int)
  50529 	*(*I64)(unsafe.Pointer(pOut)) = I64(*(*int32)(unsafe.Pointer(bp + 704)))
  50530 	if !(rc != 0) {
  50531 		goto __788
  50532 	}
  50533 	goto abort_due_to_error
  50534 __788:
  50535 	;
  50536 	if !(*(*int32)(unsafe.Pointer(bp + 704)) != 0) {
  50537 		goto __789
  50538 	}
  50539 	Xsqlite3RootPageMoved(tls, db, iDb2, uint32(*(*int32)(unsafe.Pointer(bp + 704))), uint32((*Op)(unsafe.Pointer(pOp)).Fp1))
  50540 
  50541 	resetSchemaOnFault = U8(iDb2 + 1)
  50542 __789:
  50543 	;
  50544 __787:
  50545 	;
  50546 	goto __9
  50547 
  50548 __137:
  50549 	;
  50550 	*(*I64)(unsafe.Pointer(bp + 712)) = int64(0)
  50551 
  50552 	rc = Xsqlite3BtreeClearTable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*16)).FpBt, int32(U32((*Op)(unsafe.Pointer(pOp)).Fp1)), bp+712)
  50553 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  50554 		goto __790
  50555 	}
  50556 	*(*I64)(unsafe.Pointer(p + 40)) += *(*I64)(unsafe.Pointer(bp + 712))
  50557 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 > 0) {
  50558 		goto __791
  50559 	}
  50560 
  50561 	*(*I64)(unsafe.Pointer(aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40)) += *(*I64)(unsafe.Pointer(bp + 712))
  50562 __791:
  50563 	;
  50564 __790:
  50565 	;
  50566 	if !(rc != 0) {
  50567 		goto __792
  50568 	}
  50569 	goto abort_due_to_error
  50570 __792:
  50571 	;
  50572 	goto __9
  50573 
  50574 __138:
  50575 	;
  50576 	pC29 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  50577 
  50578 	if !(int32((*VdbeCursor)(unsafe.Pointer(pC29)).FeCurType) == CURTYPE_SORTER) {
  50579 		goto __793
  50580 	}
  50581 	Xsqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC29 + 36)))
  50582 	goto __794
  50583 __793:
  50584 	;
  50585 	rc = Xsqlite3BtreeClearTableOfCursor(tls, *(*uintptr)(unsafe.Pointer(pC29 + 36)))
  50586 	if !(rc != 0) {
  50587 		goto __795
  50588 	}
  50589 	goto abort_due_to_error
  50590 __795:
  50591 	;
  50592 __794:
  50593 	;
  50594 	goto __9
  50595 
  50596 __139:
  50597 	;
  50598 	pOut = out2Prerelease(tls, p, pOp)
  50599 	*(*Pgno)(unsafe.Pointer(bp + 720)) = Pgno(0)
  50600 
  50601 	pDb3 = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16
  50602 
  50603 	rc = Xsqlite3BtreeCreateTable(tls, (*Db)(unsafe.Pointer(pDb3)).FpBt, bp+720, (*Op)(unsafe.Pointer(pOp)).Fp3)
  50604 	if !(rc != 0) {
  50605 		goto __796
  50606 	}
  50607 	goto abort_due_to_error
  50608 __796:
  50609 	;
  50610 	*(*I64)(unsafe.Pointer(pOut)) = I64(*(*Pgno)(unsafe.Pointer(bp + 720)))
  50611 	goto __9
  50612 
  50613 __140:
  50614 	;
  50615 	(*Sqlite3)(unsafe.Pointer(db)).FnSqlExec++
  50616 	rc = Xsqlite3_exec(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16)), uintptr(0), uintptr(0), uintptr(0))
  50617 	(*Sqlite3)(unsafe.Pointer(db)).FnSqlExec--
  50618 	if !(rc != 0) {
  50619 		goto __797
  50620 	}
  50621 	goto abort_due_to_error
  50622 __797:
  50623 	;
  50624 	goto __9
  50625 
  50626 __141:
  50627 	iDb3 = (*Op)(unsafe.Pointer(pOp)).Fp1
  50628 
  50629 	if !(*(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0)) {
  50630 		goto __798
  50631 	}
  50632 	Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb3)*16)).FpSchema)
  50633 	*(*U32)(unsafe.Pointer(db + 24)) &= libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))
  50634 	rc = Xsqlite3InitOne(tls, db, iDb3, p+124, uint32((*Op)(unsafe.Pointer(pOp)).Fp5))
  50635 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  50636 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 0, 0x3)
  50637 	goto __799
  50638 __798:
  50639 	zSchema = ts + 5883
  50640 	(*InitData)(unsafe.Pointer(bp + 724)).Fdb = db
  50641 	(*InitData)(unsafe.Pointer(bp + 724)).FiDb = iDb3
  50642 	(*InitData)(unsafe.Pointer(bp + 724)).FpzErrMsg = p + 124
  50643 	(*InitData)(unsafe.Pointer(bp + 724)).FmInitFlags = U32(0)
  50644 	(*InitData)(unsafe.Pointer(bp + 724)).FmxPage = Xsqlite3BtreeLastPage(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb3)*16)).FpBt)
  50645 	zSql = Xsqlite3MPrintf(tls, db,
  50646 		ts+5897,
  50647 		libc.VaList(bp+96, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb3)*16)).FzDbSName, zSchema, *(*uintptr)(unsafe.Pointer(pOp + 16))))
  50648 	if !(zSql == uintptr(0)) {
  50649 		goto __800
  50650 	}
  50651 	rc = SQLITE_NOMEM
  50652 	goto __801
  50653 __800:
  50654 	;
  50655 	(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(1)
  50656 	(*InitData)(unsafe.Pointer(bp + 724)).Frc = SQLITE_OK
  50657 	(*InitData)(unsafe.Pointer(bp + 724)).FnInitRow = U32(0)
  50658 
  50659 	rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct {
  50660 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
  50661 	}{Xsqlite3InitCallback})), bp+724, uintptr(0))
  50662 	if !(rc == SQLITE_OK) {
  50663 		goto __802
  50664 	}
  50665 	rc = (*InitData)(unsafe.Pointer(bp + 724)).Frc
  50666 __802:
  50667 	;
  50668 	if !(rc == SQLITE_OK && (*InitData)(unsafe.Pointer(bp+724)).FnInitRow == U32(0)) {
  50669 		goto __803
  50670 	}
  50671 
  50672 	rc = Xsqlite3CorruptError(tls, 97095)
  50673 __803:
  50674 	;
  50675 	Xsqlite3DbFreeNN(tls, db, zSql)
  50676 	(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(0)
  50677 __801:
  50678 	;
  50679 __799:
  50680 	;
  50681 	if !(rc != 0) {
  50682 		goto __804
  50683 	}
  50684 	Xsqlite3ResetAllSchemasOfConnection(tls, db)
  50685 	if !(rc == SQLITE_NOMEM) {
  50686 		goto __805
  50687 	}
  50688 	goto no_mem
  50689 __805:
  50690 	;
  50691 	goto abort_due_to_error
  50692 __804:
  50693 	;
  50694 	goto __9
  50695 
  50696 __142:
  50697 	;
  50698 	rc = Xsqlite3AnalysisLoad(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1)
  50699 	if !(rc != 0) {
  50700 		goto __806
  50701 	}
  50702 	goto abort_due_to_error
  50703 __806:
  50704 	;
  50705 	goto __9
  50706 
  50707 __143:
  50708 	;
  50709 	Xsqlite3UnlinkAndDeleteTable(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  50710 	goto __9
  50711 
  50712 __144:
  50713 	;
  50714 	Xsqlite3UnlinkAndDeleteIndex(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  50715 	goto __9
  50716 
  50717 __145:
  50718 	;
  50719 	Xsqlite3UnlinkAndDeleteTrigger(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  50720 	goto __9
  50721 
  50722 __146:
  50723 	;
  50724 	nRoot = (*Op)(unsafe.Pointer(pOp)).Fp2
  50725 	aRoot = *(*uintptr)(unsafe.Pointer(pOp + 16))
  50726 
  50727 	pnErr = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  50728 
  50729 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  50730 
  50731 	rc = Xsqlite3BtreeIntegrityCheck(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp5)*16)).FpBt, aRoot+1*4, nRoot,
  50732 		int32(*(*I64)(unsafe.Pointer(pnErr)))+1, bp+752, bp+756)
  50733 	Xsqlite3VdbeMemSetNull(tls, pIn1)
  50734 	if !(*(*int32)(unsafe.Pointer(bp + 752)) == 0) {
  50735 		goto __807
  50736 	}
  50737 
  50738 	goto __808
  50739 __807:
  50740 	if !(rc != 0) {
  50741 		goto __809
  50742 	}
  50743 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 756)))
  50744 	goto abort_due_to_error
  50745 	goto __810
  50746 __809:
  50747 	*(*I64)(unsafe.Pointer(pnErr)) -= I64(*(*int32)(unsafe.Pointer(bp + 752)) - 1)
  50748 	Xsqlite3VdbeMemSetStr(tls, pIn1, *(*uintptr)(unsafe.Pointer(bp + 756)), int64(-1), uint8(SQLITE_UTF8), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  50749 __810:
  50750 	;
  50751 __808:
  50752 	;
  50753 	Xsqlite3VdbeChangeEncoding(tls, pIn1, int32(encoding))
  50754 	goto check_for_interrupt
  50755 
  50756 __147:
  50757 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  50758 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  50759 
  50760 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Blob == 0) {
  50761 		goto __811
  50762 	}
  50763 	if !(Xsqlite3VdbeMemSetRowSet(tls, pIn1) != 0) {
  50764 		goto __812
  50765 	}
  50766 	goto no_mem
  50767 __812:
  50768 	;
  50769 __811:
  50770 	;
  50771 	Xsqlite3RowSetInsert(tls, (*Mem)(unsafe.Pointer(pIn1)).Fz, *(*I64)(unsafe.Pointer(pIn2)))
  50772 	goto __9
  50773 
  50774 __148:
  50775 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  50776 
  50777 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Blob == 0 ||
  50778 		Xsqlite3RowSetNext(tls, (*Mem)(unsafe.Pointer(pIn1)).Fz, bp+760) == 0) {
  50779 		goto __813
  50780 	}
  50781 
  50782 	Xsqlite3VdbeMemSetNull(tls, pIn1)
  50783 
  50784 	goto jump_to_p2_and_check_for_interrupt
  50785 	goto __814
  50786 __813:
  50787 	;
  50788 	Xsqlite3VdbeMemSetInt64(tls, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40, *(*I64)(unsafe.Pointer(bp + 760)))
  50789 __814:
  50790 	;
  50791 	goto check_for_interrupt
  50792 
  50793 __149:
  50794 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  50795 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  50796 	iSet = *(*int32)(unsafe.Pointer(pOp + 16))
  50797 
  50798 	if !(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags)&MEM_Blob == 0) {
  50799 		goto __815
  50800 	}
  50801 	if !(Xsqlite3VdbeMemSetRowSet(tls, pIn1) != 0) {
  50802 		goto __816
  50803 	}
  50804 	goto no_mem
  50805 __816:
  50806 	;
  50807 __815:
  50808 	;
  50809 	if !(iSet != 0) {
  50810 		goto __817
  50811 	}
  50812 	exists = Xsqlite3RowSetTest(tls, (*Mem)(unsafe.Pointer(pIn1)).Fz, iSet, *(*I64)(unsafe.Pointer(pIn3)))
  50813 
  50814 	if !(exists != 0) {
  50815 		goto __818
  50816 	}
  50817 	goto jump_to_p2
  50818 __818:
  50819 	;
  50820 __817:
  50821 	;
  50822 	if !(iSet >= 0) {
  50823 		goto __819
  50824 	}
  50825 	Xsqlite3RowSetInsert(tls, (*Mem)(unsafe.Pointer(pIn1)).Fz, *(*I64)(unsafe.Pointer(pIn3)))
  50826 __819:
  50827 	;
  50828 	goto __9
  50829 
  50830 __150:
  50831 	pProgram = *(*uintptr)(unsafe.Pointer(pOp + 16))
  50832 	pRt = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  50833 
  50834 	if !((*Op)(unsafe.Pointer(pOp)).Fp5 != 0) {
  50835 		goto __820
  50836 	}
  50837 	t1 = (*SubProgram)(unsafe.Pointer(pProgram)).Ftoken
  50838 	pFrame2 = (*Vdbe)(unsafe.Pointer(p)).FpFrame
  50839 __821:
  50840 	if !(pFrame2 != 0 && (*VdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken != t1) {
  50841 		goto __823
  50842 	}
  50843 	goto __822
  50844 __822:
  50845 	pFrame2 = (*VdbeFrame)(unsafe.Pointer(pFrame2)).FpParent
  50846 	goto __821
  50847 	goto __823
  50848 __823:
  50849 	;
  50850 	if !(pFrame2 != 0) {
  50851 		goto __824
  50852 	}
  50853 	goto __9
  50854 __824:
  50855 	;
  50856 __820:
  50857 	;
  50858 	if !((*Vdbe)(unsafe.Pointer(p)).FnFrame >= *(*int32)(unsafe.Pointer(db + 120 + 10*4))) {
  50859 		goto __825
  50860 	}
  50861 	rc = SQLITE_ERROR
  50862 	Xsqlite3VdbeError(tls, p, ts+5940, 0)
  50863 	goto abort_due_to_error
  50864 __825:
  50865 	;
  50866 	if !(int32((*Mem)(unsafe.Pointer(pRt)).Fflags)&MEM_Blob == 0) {
  50867 		goto __826
  50868 	}
  50869 
  50870 	nMem = (*SubProgram)(unsafe.Pointer(pProgram)).FnMem + (*SubProgram)(unsafe.Pointer(pProgram)).FnCsr
  50871 
  50872 	if !((*SubProgram)(unsafe.Pointer(pProgram)).FnCsr == 0) {
  50873 		goto __828
  50874 	}
  50875 	nMem++
  50876 __828:
  50877 	;
  50878 	nByte2 = int32((uint32(unsafe.Sizeof(VdbeFrame{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)) +
  50879 		uint32(nMem)*uint32(unsafe.Sizeof(Mem{})) +
  50880 		uint32((*SubProgram)(unsafe.Pointer(pProgram)).FnCsr)*uint32(unsafe.Sizeof(uintptr(0))) +
  50881 		uint32(((*SubProgram)(unsafe.Pointer(pProgram)).FnOp+7)/8))
  50882 	pFrame2 = Xsqlite3DbMallocZero(tls, db, uint64(nByte2))
  50883 	if !!(pFrame2 != 0) {
  50884 		goto __829
  50885 	}
  50886 	goto no_mem
  50887 __829:
  50888 	;
  50889 	Xsqlite3VdbeMemRelease(tls, pRt)
  50890 	(*Mem)(unsafe.Pointer(pRt)).Fflags = U16(MEM_Blob | MEM_Dyn)
  50891 	(*Mem)(unsafe.Pointer(pRt)).Fz = pFrame2
  50892 	(*Mem)(unsafe.Pointer(pRt)).Fn = nByte2
  50893 	(*Mem)(unsafe.Pointer(pRt)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3VdbeFrameMemDel}))
  50894 
  50895 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).Fv = p
  50896 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem = nMem
  50897 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr = (*SubProgram)(unsafe.Pointer(pProgram)).FnCsr
  50898 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).Fpc = (int32(pOp) - int32(aOp)) / 20
  50899 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FaMem = (*Vdbe)(unsafe.Pointer(p)).FaMem
  50900 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnMem = (*Vdbe)(unsafe.Pointer(p)).FnMem
  50901 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FapCsr = (*Vdbe)(unsafe.Pointer(p)).FapCsr
  50902 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnCursor = (*Vdbe)(unsafe.Pointer(p)).FnCursor
  50903 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FaOp = (*Vdbe)(unsafe.Pointer(p)).FaOp
  50904 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*Vdbe)(unsafe.Pointer(p)).FnOp
  50905 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*SubProgram)(unsafe.Pointer(pProgram)).Ftoken
  50906 
  50907 	pEnd = pFrame2 + 88 + uintptr((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*40
  50908 	pMem1 = pFrame2 + 88
  50909 __830:
  50910 	if !(pMem1 != pEnd) {
  50911 		goto __832
  50912 	}
  50913 	(*Mem)(unsafe.Pointer(pMem1)).Fflags = U16(MEM_Undefined)
  50914 	(*Mem)(unsafe.Pointer(pMem1)).Fdb = db
  50915 	goto __831
  50916 __831:
  50917 	pMem1 += 40
  50918 	goto __830
  50919 	goto __832
  50920 __832:
  50921 	;
  50922 	goto __827
  50923 __826:
  50924 	pFrame2 = (*Mem)(unsafe.Pointer(pRt)).Fz
  50925 
  50926 __827:
  50927 	;
  50928 	(*Vdbe)(unsafe.Pointer(p)).FnFrame++
  50929 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FpParent = (*Vdbe)(unsafe.Pointer(p)).FpFrame
  50930 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FlastRowid = (*Sqlite3)(unsafe.Pointer(db)).FlastRowid
  50931 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChange = (*Vdbe)(unsafe.Pointer(p)).FnChange
  50932 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FnDbChange = (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnChange
  50933 
  50934 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FpAuxData = (*Vdbe)(unsafe.Pointer(p)).FpAuxData
  50935 	(*Vdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0)
  50936 	(*Vdbe)(unsafe.Pointer(p)).FnChange = int64(0)
  50937 	(*Vdbe)(unsafe.Pointer(p)).FpFrame = pFrame2
  50938 	(*Vdbe)(unsafe.Pointer(p)).FaMem = libc.AssignUintptr(&aMem, pFrame2+88)
  50939 	(*Vdbe)(unsafe.Pointer(p)).FnMem = (*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem
  50940 	(*Vdbe)(unsafe.Pointer(p)).FnCursor = int32(U16((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr))
  50941 	(*Vdbe)(unsafe.Pointer(p)).FapCsr = aMem + uintptr((*Vdbe)(unsafe.Pointer(p)).FnMem)*40
  50942 	(*VdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce = (*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*SubProgram)(unsafe.Pointer(pProgram)).FnCsr)*4
  50943 	libc.Xmemset(tls, (*VdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce, 0, uint32(((*SubProgram)(unsafe.Pointer(pProgram)).FnOp+7)/8))
  50944 	(*Vdbe)(unsafe.Pointer(p)).FaOp = libc.AssignUintptr(&aOp, (*SubProgram)(unsafe.Pointer(pProgram)).FaOp)
  50945 	(*Vdbe)(unsafe.Pointer(p)).FnOp = (*SubProgram)(unsafe.Pointer(pProgram)).FnOp
  50946 	pOp = aOp + libc.UintptrFromInt32(-1)*20
  50947 	goto check_for_interrupt
  50948 
  50949 __151:
  50950 	pOut = out2Prerelease(tls, p, pOp)
  50951 	pFrame3 = (*Vdbe)(unsafe.Pointer(p)).FpFrame
  50952 	pIn = (*VdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1+(*Op)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(pFrame3)).FaOp+uintptr((*VdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*20)).Fp1)*40
  50953 	Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn, MEM_Ephem)
  50954 	goto __9
  50955 
  50956 __152:
  50957 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0) {
  50958 		goto __833
  50959 	}
  50960 	*(*I64)(unsafe.Pointer(db + 536)) += I64((*Op)(unsafe.Pointer(pOp)).Fp2)
  50961 	goto __834
  50962 __833:
  50963 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 != 0) {
  50964 		goto __835
  50965 	}
  50966 	*(*I64)(unsafe.Pointer(db + 528)) += I64((*Op)(unsafe.Pointer(pOp)).Fp2)
  50967 	goto __836
  50968 __835:
  50969 	*(*I64)(unsafe.Pointer(p + 64)) += I64((*Op)(unsafe.Pointer(pOp)).Fp2)
  50970 __836:
  50971 	;
  50972 __834:
  50973 	;
  50974 	goto __9
  50975 
  50976 __153:
  50977 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 != 0) {
  50978 		goto __837
  50979 	}
  50980 
  50981 	if !((*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons == int64(0) && (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == int64(0)) {
  50982 		goto __839
  50983 	}
  50984 	goto jump_to_p2
  50985 __839:
  50986 	;
  50987 	goto __838
  50988 __837:
  50989 	;
  50990 	if !((*Vdbe)(unsafe.Pointer(p)).FnFkConstraint == int64(0) && (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == int64(0)) {
  50991 		goto __840
  50992 	}
  50993 	goto jump_to_p2
  50994 __840:
  50995 	;
  50996 __838:
  50997 	;
  50998 	goto __9
  50999 
  51000 __154:
  51001 	if !((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0) {
  51002 		goto __841
  51003 	}
  51004 	pFrame4 = (*Vdbe)(unsafe.Pointer(p)).FpFrame
  51005 __843:
  51006 	if !((*VdbeFrame)(unsafe.Pointer(pFrame4)).FpParent != 0) {
  51007 		goto __845
  51008 	}
  51009 	goto __844
  51010 __844:
  51011 	pFrame4 = (*VdbeFrame)(unsafe.Pointer(pFrame4)).FpParent
  51012 	goto __843
  51013 	goto __845
  51014 __845:
  51015 	;
  51016 	pIn1 = (*VdbeFrame)(unsafe.Pointer(pFrame4)).FaMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51017 	goto __842
  51018 __841:
  51019 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51020 __842:
  51021 	;
  51022 	Xsqlite3VdbeMemIntegerify(tls, pIn1)
  51023 	pIn2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  51024 	Xsqlite3VdbeMemIntegerify(tls, pIn2)
  51025 	if !(*(*I64)(unsafe.Pointer(pIn1)) < *(*I64)(unsafe.Pointer(pIn2))) {
  51026 		goto __846
  51027 	}
  51028 	*(*I64)(unsafe.Pointer(pIn1)) = *(*I64)(unsafe.Pointer(pIn2))
  51029 __846:
  51030 	;
  51031 	goto __9
  51032 
  51033 __155:
  51034 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51035 
  51036 	if !(*(*I64)(unsafe.Pointer(pIn1)) > int64(0)) {
  51037 		goto __847
  51038 	}
  51039 	*(*I64)(unsafe.Pointer(pIn1)) -= I64((*Op)(unsafe.Pointer(pOp)).Fp3)
  51040 	goto jump_to_p2
  51041 __847:
  51042 	;
  51043 	goto __9
  51044 
  51045 __156:
  51046 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51047 	pIn3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51048 	pOut = out2Prerelease(tls, p, pOp)
  51049 
  51050 	*(*I64)(unsafe.Pointer(bp + 768)) = *(*I64)(unsafe.Pointer(pIn1))
  51051 	if !(*(*I64)(unsafe.Pointer(bp + 768)) <= int64(0) || Xsqlite3AddInt64(tls, bp+768, func() int64 {
  51052 		if *(*I64)(unsafe.Pointer(pIn3)) > int64(0) {
  51053 			return *(*I64)(unsafe.Pointer(pIn3))
  51054 		}
  51055 		return int64(0)
  51056 	}()) != 0) {
  51057 		goto __848
  51058 	}
  51059 
  51060 	*(*I64)(unsafe.Pointer(pOut)) = int64(-1)
  51061 	goto __849
  51062 __848:
  51063 	*(*I64)(unsafe.Pointer(pOut)) = *(*I64)(unsafe.Pointer(bp + 768))
  51064 __849:
  51065 	;
  51066 	goto __9
  51067 
  51068 __157:
  51069 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51070 
  51071 	if !(*(*I64)(unsafe.Pointer(pIn1)) != 0) {
  51072 		goto __850
  51073 	}
  51074 	if !(*(*I64)(unsafe.Pointer(pIn1)) > int64(0)) {
  51075 		goto __851
  51076 	}
  51077 	*(*I64)(unsafe.Pointer(pIn1))--
  51078 __851:
  51079 	;
  51080 	goto jump_to_p2
  51081 __850:
  51082 	;
  51083 	goto __9
  51084 
  51085 __158:
  51086 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51087 
  51088 	if !(*(*I64)(unsafe.Pointer(pIn1)) > int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32)) {
  51089 		goto __852
  51090 	}
  51091 	*(*I64)(unsafe.Pointer(pIn1))--
  51092 __852:
  51093 	;
  51094 	if !(*(*I64)(unsafe.Pointer(pIn1)) == int64(0)) {
  51095 		goto __853
  51096 	}
  51097 	goto jump_to_p2
  51098 __853:
  51099 	;
  51100 	goto __9
  51101 
  51102 __159:
  51103 __160:
  51104 	;
  51105 	n4 = int32((*Op)(unsafe.Pointer(pOp)).Fp5)
  51106 
  51107 	pCtx = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(n4)*uint32(unsafe.Sizeof(uintptr(0)))+(uint32(unsafe.Sizeof(Sqlite3_context{}))+uint32(unsafe.Sizeof(Mem{}))-uint32(unsafe.Sizeof(uintptr(0))))))
  51108 	if !(pCtx == uintptr(0)) {
  51109 		goto __854
  51110 	}
  51111 	goto no_mem
  51112 __854:
  51113 	;
  51114 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpMem = uintptr(0)
  51115 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut = pCtx + 28 + uintptr(n4)*4
  51116 	Xsqlite3VdbeMemInit(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, db, uint16(MEM_Null))
  51117 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpFunc = *(*uintptr)(unsafe.Pointer(pOp + 16))
  51118 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp = (int32(pOp) - int32(aOp)) / 20
  51119 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe = p
  51120 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FskipFlag = U8(0)
  51121 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 0
  51122 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).Fenc = encoding
  51123 	(*Sqlite3_context)(unsafe.Pointer(pCtx)).Fargc = U8(n4)
  51124 	(*Op)(unsafe.Pointer(pOp)).Fp4type = int8(-15)
  51125 	*(*uintptr)(unsafe.Pointer(pOp + 16)) = pCtx
  51126 
  51127 	(*Op)(unsafe.Pointer(pOp)).Fopcode = U8(OP_AggStep1)
  51128 
  51129 __161:
  51130 	;
  51131 	pCtx1 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  51132 	pMem2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51133 
  51134 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpMem != pMem2) {
  51135 		goto __855
  51136 	}
  51137 	(*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpMem = pMem2
  51138 	i5 = int32((*Sqlite3_context)(unsafe.Pointer(pCtx1)).Fargc) - 1
  51139 __856:
  51140 	if !(i5 >= 0) {
  51141 		goto __858
  51142 	}
  51143 	*(*uintptr)(unsafe.Pointer(pCtx1 + 28 + uintptr(i5)*4)) = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2+i5)*40
  51144 	goto __857
  51145 __857:
  51146 	i5--
  51147 	goto __856
  51148 	goto __858
  51149 __858:
  51150 	;
  51151 __855:
  51152 	;
  51153 	(*Mem)(unsafe.Pointer(pMem2)).Fn++
  51154 
  51155 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 != 0) {
  51156 		goto __859
  51157 	}
  51158 	(*struct {
  51159 		f func(*libc.TLS, uintptr, int32, uintptr)
  51160 	})(unsafe.Pointer(&struct{ uintptr }{(*FuncDef)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxInverse})).f(tls, pCtx1, int32((*Sqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+28)
  51161 	goto __860
  51162 __859:
  51163 	(*struct {
  51164 		f func(*libc.TLS, uintptr, int32, uintptr)
  51165 	})(unsafe.Pointer(&struct{ uintptr }{(*FuncDef)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxSFunc})).f(tls, pCtx1, int32((*Sqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+28)
  51166 __860:
  51167 	;
  51168 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FisError != 0) {
  51169 		goto __861
  51170 	}
  51171 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FisError > 0) {
  51172 		goto __862
  51173 	}
  51174 	Xsqlite3VdbeError(tls, p, ts+3663, libc.VaList(bp+120, Xsqlite3_value_text(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)))
  51175 	rc = (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FisError
  51176 __862:
  51177 	;
  51178 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag != 0) {
  51179 		goto __863
  51180 	}
  51181 
  51182 	i5 = (*Op)(unsafe.Pointer(pOp + libc.UintptrFromInt32(-1)*20)).Fp1
  51183 	if !(i5 != 0) {
  51184 		goto __864
  51185 	}
  51186 	Xsqlite3VdbeMemSetInt64(tls, aMem+uintptr(i5)*40, int64(1))
  51187 __864:
  51188 	;
  51189 	(*Sqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag = U8(0)
  51190 __863:
  51191 	;
  51192 	Xsqlite3VdbeMemRelease(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)
  51193 	(*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = U16(MEM_Null)
  51194 	(*Sqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0
  51195 	if !(rc != 0) {
  51196 		goto __865
  51197 	}
  51198 	goto abort_due_to_error
  51199 __865:
  51200 	;
  51201 __861:
  51202 	;
  51203 	goto __9
  51204 
  51205 __162:
  51206 __163:
  51207 	;
  51208 	pMem3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51209 
  51210 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  51211 		goto __866
  51212 	}
  51213 
  51214 	rc = Xsqlite3VdbeMemAggValue(tls, pMem3, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  51215 	pMem3 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51216 	goto __867
  51217 __866:
  51218 	rc = Xsqlite3VdbeMemFinalize(tls, pMem3, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  51219 __867:
  51220 	;
  51221 	if !(rc != 0) {
  51222 		goto __868
  51223 	}
  51224 	Xsqlite3VdbeError(tls, p, ts+3663, libc.VaList(bp+128, Xsqlite3_value_text(tls, pMem3)))
  51225 	goto abort_due_to_error
  51226 __868:
  51227 	;
  51228 	Xsqlite3VdbeChangeEncoding(tls, pMem3, int32(encoding))
  51229 
  51230 	goto __9
  51231 
  51232 __164:
  51233 	;
  51234 	*(*int32)(unsafe.Pointer(bp + 776)) = 0
  51235 	*(*int32)(unsafe.Pointer(bp + 776 + 1*4)) = libc.AssignPtrInt32(bp+776+2*4, -1)
  51236 
  51237 	rc = Xsqlite3Checkpoint(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, bp+776+1*4, bp+776+2*4)
  51238 	if !(rc != 0) {
  51239 		goto __869
  51240 	}
  51241 	if !(rc != SQLITE_BUSY) {
  51242 		goto __870
  51243 	}
  51244 	goto abort_due_to_error
  51245 __870:
  51246 	;
  51247 	rc = SQLITE_OK
  51248 	*(*int32)(unsafe.Pointer(bp + 776)) = 1
  51249 __869:
  51250 	;
  51251 	i6 = 0
  51252 	pMem4 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51253 __871:
  51254 	if !(i6 < 3) {
  51255 		goto __873
  51256 	}
  51257 	Xsqlite3VdbeMemSetInt64(tls, pMem4, I64(*(*int32)(unsafe.Pointer(bp + 776 + uintptr(i6)*4))))
  51258 	goto __872
  51259 __872:
  51260 	i6++
  51261 	pMem4 += 40
  51262 	goto __871
  51263 	goto __873
  51264 __873:
  51265 	;
  51266 	goto __9
  51267 
  51268 __165:
  51269 	pOut = out2Prerelease(tls, p, pOp)
  51270 	eNew = (*Op)(unsafe.Pointer(pOp)).Fp3
  51271 
  51272 	pBt1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16)).FpBt
  51273 	pPager = Xsqlite3BtreePager(tls, pBt1)
  51274 	eOld = Xsqlite3PagerGetJournalMode(tls, pPager)
  51275 	if !(eNew == -1) {
  51276 		goto __874
  51277 	}
  51278 	eNew = eOld
  51279 __874:
  51280 	;
  51281 	if !!(Xsqlite3PagerOkToChangeJournalMode(tls, pPager) != 0) {
  51282 		goto __875
  51283 	}
  51284 	eNew = eOld
  51285 __875:
  51286 	;
  51287 	zFilename = Xsqlite3PagerFilename(tls, pPager, 1)
  51288 
  51289 	if !(eNew == PAGER_JOURNALMODE_WAL &&
  51290 		(Xsqlite3Strlen30(tls, zFilename) == 0 ||
  51291 			!(Xsqlite3PagerWalSupported(tls, pPager) != 0))) {
  51292 		goto __876
  51293 	}
  51294 	eNew = eOld
  51295 __876:
  51296 	;
  51297 	if !(eNew != eOld &&
  51298 		(eOld == PAGER_JOURNALMODE_WAL || eNew == PAGER_JOURNALMODE_WAL)) {
  51299 		goto __877
  51300 	}
  51301 	if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || (*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1) {
  51302 		goto __878
  51303 	}
  51304 	rc = SQLITE_ERROR
  51305 	Xsqlite3VdbeError(tls, p,
  51306 		ts+5977,
  51307 		libc.VaList(bp+136, func() uintptr {
  51308 			if eNew == PAGER_JOURNALMODE_WAL {
  51309 				return ts + 6029
  51310 			}
  51311 			return ts + 6034
  51312 		}()))
  51313 	goto abort_due_to_error
  51314 	goto __879
  51315 __878:
  51316 	if !(eOld == PAGER_JOURNALMODE_WAL) {
  51317 		goto __880
  51318 	}
  51319 
  51320 	rc = Xsqlite3PagerCloseWal(tls, pPager, db)
  51321 	if !(rc == SQLITE_OK) {
  51322 		goto __882
  51323 	}
  51324 	Xsqlite3PagerSetJournalMode(tls, pPager, eNew)
  51325 __882:
  51326 	;
  51327 	goto __881
  51328 __880:
  51329 	if !(eOld == PAGER_JOURNALMODE_MEMORY) {
  51330 		goto __883
  51331 	}
  51332 
  51333 	Xsqlite3PagerSetJournalMode(tls, pPager, PAGER_JOURNALMODE_OFF)
  51334 __883:
  51335 	;
  51336 __881:
  51337 	;
  51338 	if !(rc == SQLITE_OK) {
  51339 		goto __884
  51340 	}
  51341 	rc = Xsqlite3BtreeSetVersion(tls, pBt1, func() int32 {
  51342 		if eNew == PAGER_JOURNALMODE_WAL {
  51343 			return 2
  51344 		}
  51345 		return 1
  51346 	}())
  51347 __884:
  51348 	;
  51349 __879:
  51350 	;
  51351 __877:
  51352 	;
  51353 	if !(rc != 0) {
  51354 		goto __885
  51355 	}
  51356 	eNew = eOld
  51357 __885:
  51358 	;
  51359 	eNew = Xsqlite3PagerSetJournalMode(tls, pPager, eNew)
  51360 
  51361 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Str | MEM_Static | MEM_Term)
  51362 	(*Mem)(unsafe.Pointer(pOut)).Fz = Xsqlite3JournalModename(tls, eNew)
  51363 	(*Mem)(unsafe.Pointer(pOut)).Fn = Xsqlite3Strlen30(tls, (*Mem)(unsafe.Pointer(pOut)).Fz)
  51364 	(*Mem)(unsafe.Pointer(pOut)).Fenc = U8(SQLITE_UTF8)
  51365 	Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding))
  51366 	if !(rc != 0) {
  51367 		goto __886
  51368 	}
  51369 	goto abort_due_to_error
  51370 __886:
  51371 	;
  51372 	goto __9
  51373 
  51374 __166:
  51375 	;
  51376 	rc = Xsqlite3RunVacuum(tls, p+124, db, (*Op)(unsafe.Pointer(pOp)).Fp1,
  51377 		func() uintptr {
  51378 			if (*Op)(unsafe.Pointer(pOp)).Fp2 != 0 {
  51379 				return aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40
  51380 			}
  51381 			return uintptr(0)
  51382 		}())
  51383 	if !(rc != 0) {
  51384 		goto __887
  51385 	}
  51386 	goto abort_due_to_error
  51387 __887:
  51388 	;
  51389 	goto __9
  51390 
  51391 __167:
  51392 	;
  51393 	pBt2 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16)).FpBt
  51394 	rc = Xsqlite3BtreeIncrVacuum(tls, pBt2)
  51395 
  51396 	if !(rc != 0) {
  51397 		goto __888
  51398 	}
  51399 	if !(rc != SQLITE_DONE) {
  51400 		goto __889
  51401 	}
  51402 	goto abort_due_to_error
  51403 __889:
  51404 	;
  51405 	rc = SQLITE_OK
  51406 	goto jump_to_p2
  51407 __888:
  51408 	;
  51409 	goto __9
  51410 
  51411 __168:
  51412 	;
  51413 	if !!((*Op)(unsafe.Pointer(pOp)).Fp1 != 0) {
  51414 		goto __890
  51415 	}
  51416 	Xsqlite3ExpirePreparedStatements(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp2)
  51417 	goto __891
  51418 __890:
  51419 	libc.SetBitFieldPtr8Uint32(p+152, Bft((*Op)(unsafe.Pointer(pOp)).Fp2+1), 0, 0x3)
  51420 __891:
  51421 	;
  51422 	goto __9
  51423 
  51424 __169:
  51425 	;
  51426 	pC30 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  51427 
  51428 	Xsqlite3BtreeCursorPin(tls, *(*uintptr)(unsafe.Pointer(pC30 + 36)))
  51429 	goto __9
  51430 
  51431 __170:
  51432 	;
  51433 	pC31 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  51434 
  51435 	Xsqlite3BtreeCursorUnpin(tls, *(*uintptr)(unsafe.Pointer(pC31 + 36)))
  51436 	goto __9
  51437 
  51438 __171:
  51439 	isWriteLock = U8((*Op)(unsafe.Pointer(pOp)).Fp3)
  51440 	if !(isWriteLock != 0 || uint64(0) == (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ReadUncommit)) {
  51441 		goto __892
  51442 	}
  51443 	p13 = (*Op)(unsafe.Pointer(pOp)).Fp1
  51444 
  51445 	rc = Xsqlite3BtreeLockTable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(p13)*16)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp2, isWriteLock)
  51446 	if !(rc != 0) {
  51447 		goto __893
  51448 	}
  51449 	if !(rc&0xFF == SQLITE_LOCKED) {
  51450 		goto __894
  51451 	}
  51452 	z1 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  51453 	Xsqlite3VdbeError(tls, p, ts+6041, libc.VaList(bp+144, z1))
  51454 __894:
  51455 	;
  51456 	goto abort_due_to_error
  51457 __893:
  51458 	;
  51459 __892:
  51460 	;
  51461 	goto __9
  51462 
  51463 __172:
  51464 	pVTab = *(*uintptr)(unsafe.Pointer(pOp + 16))
  51465 	rc = Xsqlite3VtabBegin(tls, db, pVTab)
  51466 	if !(pVTab != 0) {
  51467 		goto __895
  51468 	}
  51469 	Xsqlite3VtabImportErrmsg(tls, p, (*VTable)(unsafe.Pointer(pVTab)).FpVtab)
  51470 __895:
  51471 	;
  51472 	if !(rc != 0) {
  51473 		goto __896
  51474 	}
  51475 	goto abort_due_to_error
  51476 __896:
  51477 	;
  51478 	goto __9
  51479 
  51480 __173:
  51481 	libc.Xmemset(tls, bp+792, 0, uint32(unsafe.Sizeof(Mem{})))
  51482 	(*Mem)(unsafe.Pointer(bp + 792)).Fdb = db
  51483 
  51484 	rc = Xsqlite3VdbeMemCopy(tls, bp+792, aMem+uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*40)
  51485 
  51486 	zTab = Xsqlite3_value_text(tls, bp+792)
  51487 
  51488 	if !(zTab != 0) {
  51489 		goto __897
  51490 	}
  51491 	rc = Xsqlite3VtabCallCreate(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, zTab, p+124)
  51492 __897:
  51493 	;
  51494 	Xsqlite3VdbeMemRelease(tls, bp+792)
  51495 	if !(rc != 0) {
  51496 		goto __898
  51497 	}
  51498 	goto abort_due_to_error
  51499 __898:
  51500 	;
  51501 	goto __9
  51502 
  51503 __174:
  51504 	(*Sqlite3)(unsafe.Pointer(db)).FnVDestroy++
  51505 	rc = Xsqlite3VtabCallDestroy(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16)))
  51506 	(*Sqlite3)(unsafe.Pointer(db)).FnVDestroy--
  51507 
  51508 	if !(rc != 0) {
  51509 		goto __899
  51510 	}
  51511 	goto abort_due_to_error
  51512 __899:
  51513 	;
  51514 	goto __9
  51515 
  51516 __175:
  51517 	;
  51518 	pCur3 = uintptr(0)
  51519 	*(*uintptr)(unsafe.Pointer(bp + 832)) = uintptr(0)
  51520 	pVtab1 = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab
  51521 	if !(pVtab1 == uintptr(0) || (*Sqlite3_vtab)(unsafe.Pointer(pVtab1)).FpModule == uintptr(0)) {
  51522 		goto __900
  51523 	}
  51524 	rc = SQLITE_LOCKED
  51525 	goto abort_due_to_error
  51526 __900:
  51527 	;
  51528 	pModule1 = (*Sqlite3_vtab)(unsafe.Pointer(pVtab1)).FpModule
  51529 	rc = (*struct {
  51530 		f func(*libc.TLS, uintptr, uintptr) int32
  51531 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule1)).FxOpen})).f(tls, pVtab1, bp+832)
  51532 	Xsqlite3VtabImportErrmsg(tls, p, pVtab1)
  51533 	if !(rc != 0) {
  51534 		goto __901
  51535 	}
  51536 	goto abort_due_to_error
  51537 __901:
  51538 	;
  51539 	(*Sqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 832)))).FpVtab = pVtab1
  51540 
  51541 	pCur3 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, 0, uint8(CURTYPE_VTAB))
  51542 	if !(pCur3 != 0) {
  51543 		goto __902
  51544 	}
  51545 	*(*uintptr)(unsafe.Pointer(pCur3 + 36)) = *(*uintptr)(unsafe.Pointer(bp + 832))
  51546 	(*Sqlite3_vtab)(unsafe.Pointer(pVtab1)).FnRef++
  51547 	goto __903
  51548 __902:
  51549 	;
  51550 	(*struct {
  51551 		f func(*libc.TLS, uintptr) int32
  51552 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule1)).FxClose})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 832)))
  51553 	goto no_mem
  51554 __903:
  51555 	;
  51556 	goto __9
  51557 
  51558 __176:
  51559 	pC32 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  51560 	pRhs = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(ValueList{})))
  51561 	if !(pRhs == uintptr(0)) {
  51562 		goto __904
  51563 	}
  51564 	goto no_mem
  51565 __904:
  51566 	;
  51567 	(*ValueList)(unsafe.Pointer(pRhs)).FpCsr = *(*uintptr)(unsafe.Pointer(pC32 + 36))
  51568 	(*ValueList)(unsafe.Pointer(pRhs)).FpOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51569 	pOut = out2Prerelease(tls, p, pOp)
  51570 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(MEM_Null)
  51571 	Xsqlite3VdbeMemSetPointer(tls, pOut, pRhs, ts+6070, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3VdbeValueListFree})))
  51572 	goto __9
  51573 
  51574 __177:
  51575 	pQuery = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51576 	pArgc = pQuery + 1*40
  51577 	pCur4 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  51578 
  51579 	pVCur1 = *(*uintptr)(unsafe.Pointer(pCur4 + 36))
  51580 	pVtab2 = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVCur1)).FpVtab
  51581 	pModule2 = (*Sqlite3_vtab)(unsafe.Pointer(pVtab2)).FpModule
  51582 
  51583 	nArg = int32(*(*I64)(unsafe.Pointer(pArgc)))
  51584 	iQuery = int32(*(*I64)(unsafe.Pointer(pQuery)))
  51585 
  51586 	apArg = (*Vdbe)(unsafe.Pointer(p)).FapArg
  51587 	i7 = 0
  51588 __905:
  51589 	if !(i7 < nArg) {
  51590 		goto __907
  51591 	}
  51592 	*(*uintptr)(unsafe.Pointer(apArg + uintptr(i7)*4)) = pArgc + uintptr(i7+1)*40
  51593 	goto __906
  51594 __906:
  51595 	i7++
  51596 	goto __905
  51597 	goto __907
  51598 __907:
  51599 	;
  51600 	rc = (*struct {
  51601 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
  51602 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule2)).FxFilter})).f(tls, pVCur1, iQuery, *(*uintptr)(unsafe.Pointer(pOp + 16)), nArg, apArg)
  51603 	Xsqlite3VtabImportErrmsg(tls, p, pVtab2)
  51604 	if !(rc != 0) {
  51605 		goto __908
  51606 	}
  51607 	goto abort_due_to_error
  51608 __908:
  51609 	;
  51610 	res12 = (*struct {
  51611 		f func(*libc.TLS, uintptr) int32
  51612 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule2)).FxEof})).f(tls, pVCur1)
  51613 	(*VdbeCursor)(unsafe.Pointer(pCur4)).FnullRow = U8(0)
  51614 
  51615 	if !(res12 != 0) {
  51616 		goto __909
  51617 	}
  51618 	goto jump_to_p2
  51619 __909:
  51620 	;
  51621 	goto __9
  51622 
  51623 __178:
  51624 	pCur5 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  51625 
  51626 	pDest2 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51627 
  51628 	if !((*VdbeCursor)(unsafe.Pointer(pCur5)).FnullRow != 0) {
  51629 		goto __910
  51630 	}
  51631 	Xsqlite3VdbeMemSetNull(tls, pDest2)
  51632 	goto __9
  51633 __910:
  51634 	;
  51635 	pVtab3 = (*Sqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur5 + 36)))).FpVtab
  51636 	pModule3 = (*Sqlite3_vtab)(unsafe.Pointer(pVtab3)).FpModule
  51637 
  51638 	libc.Xmemset(tls, bp+836, 0, uint32(unsafe.Sizeof(Sqlite3_context{})))
  51639 	(*Sqlite3_context)(unsafe.Pointer(bp + 836)).FpOut = pDest2
  51640 	(*Sqlite3_context)(unsafe.Pointer(bp + 836)).Fenc = encoding
  51641 
  51642 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5)&OPFLAG_NOCHNG != 0) {
  51643 		goto __911
  51644 	}
  51645 	Xsqlite3VdbeMemSetNull(tls, pDest2)
  51646 	(*Mem)(unsafe.Pointer(pDest2)).Fflags = U16(MEM_Null | MEM_Zero)
  51647 	*(*int32)(unsafe.Pointer(pDest2)) = 0
  51648 	goto __912
  51649 __911:
  51650 	(*Mem)(unsafe.Pointer(pDest2)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pDest2)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Null)
  51651 __912:
  51652 	;
  51653 	rc = (*struct {
  51654 		f func(*libc.TLS, uintptr, uintptr, int32) int32
  51655 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule3)).FxColumn})).f(tls, *(*uintptr)(unsafe.Pointer(pCur5 + 36)), bp+836, (*Op)(unsafe.Pointer(pOp)).Fp2)
  51656 	Xsqlite3VtabImportErrmsg(tls, p, pVtab3)
  51657 	if !((*Sqlite3_context)(unsafe.Pointer(bp+836)).FisError > 0) {
  51658 		goto __913
  51659 	}
  51660 	Xsqlite3VdbeError(tls, p, ts+3663, libc.VaList(bp+152, Xsqlite3_value_text(tls, pDest2)))
  51661 	rc = (*Sqlite3_context)(unsafe.Pointer(bp + 836)).FisError
  51662 __913:
  51663 	;
  51664 	Xsqlite3VdbeChangeEncoding(tls, pDest2, int32(encoding))
  51665 
  51666 	if !(rc != 0) {
  51667 		goto __914
  51668 	}
  51669 	goto abort_due_to_error
  51670 __914:
  51671 	;
  51672 	goto __9
  51673 
  51674 __179:
  51675 	pCur6 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*4))
  51676 
  51677 	if !((*VdbeCursor)(unsafe.Pointer(pCur6)).FnullRow != 0) {
  51678 		goto __915
  51679 	}
  51680 	goto __9
  51681 __915:
  51682 	;
  51683 	pVtab4 = (*Sqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur6 + 36)))).FpVtab
  51684 	pModule4 = (*Sqlite3_vtab)(unsafe.Pointer(pVtab4)).FpModule
  51685 
  51686 	rc = (*struct {
  51687 		f func(*libc.TLS, uintptr) int32
  51688 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule4)).FxNext})).f(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 36)))
  51689 	Xsqlite3VtabImportErrmsg(tls, p, pVtab4)
  51690 	if !(rc != 0) {
  51691 		goto __916
  51692 	}
  51693 	goto abort_due_to_error
  51694 __916:
  51695 	;
  51696 	res13 = (*struct {
  51697 		f func(*libc.TLS, uintptr) int32
  51698 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule4)).FxEof})).f(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 36)))
  51699 
  51700 	if !!(res13 != 0) {
  51701 		goto __917
  51702 	}
  51703 
  51704 	goto jump_to_p2_and_check_for_interrupt
  51705 __917:
  51706 	;
  51707 	goto check_for_interrupt
  51708 
  51709 __180:
  51710 	isLegacy = int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(SQLITE_LegacyAlter))
  51711 	*(*U64)(unsafe.Pointer(db + 32)) |= uint64(SQLITE_LegacyAlter)
  51712 	pVtab5 = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab
  51713 	pName = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51714 
  51715 	rc = Xsqlite3VdbeChangeEncoding(tls, pName, SQLITE_UTF8)
  51716 	if !(rc != 0) {
  51717 		goto __918
  51718 	}
  51719 	goto abort_due_to_error
  51720 __918:
  51721 	;
  51722 	rc = (*struct {
  51723 		f func(*libc.TLS, uintptr, uintptr) int32
  51724 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(pVtab5)).FpModule)).FxRename})).f(tls, pVtab5, (*Mem)(unsafe.Pointer(pName)).Fz)
  51725 	if !(isLegacy == 0) {
  51726 		goto __919
  51727 	}
  51728 	*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_LegacyAlter))
  51729 __919:
  51730 	;
  51731 	Xsqlite3VtabImportErrmsg(tls, p, pVtab5)
  51732 	libc.SetBitFieldPtr8Uint32(p+152, Bft(0), 0, 0x3)
  51733 	if !(rc != 0) {
  51734 		goto __920
  51735 	}
  51736 	goto abort_due_to_error
  51737 __920:
  51738 	;
  51739 	goto __9
  51740 
  51741 __181:
  51742 	*(*Sqlite_int64)(unsafe.Pointer(bp + 872)) = int64(0)
  51743 
  51744 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  51745 		goto __921
  51746 	}
  51747 	goto no_mem
  51748 __921:
  51749 	;
  51750 	pVtab6 = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab
  51751 	if !(pVtab6 == uintptr(0) || (*Sqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule == uintptr(0)) {
  51752 		goto __922
  51753 	}
  51754 	rc = SQLITE_LOCKED
  51755 	goto abort_due_to_error
  51756 __922:
  51757 	;
  51758 	pModule5 = (*Sqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule
  51759 	nArg1 = (*Op)(unsafe.Pointer(pOp)).Fp2
  51760 
  51761 	if !((*Sqlite3_module)(unsafe.Pointer(pModule5)).FxUpdate != 0) {
  51762 		goto __923
  51763 	}
  51764 	vtabOnConflict = (*Sqlite3)(unsafe.Pointer(db)).FvtabOnConflict
  51765 	apArg1 = (*Vdbe)(unsafe.Pointer(p)).FapArg
  51766 	pX1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51767 	i8 = 0
  51768 __924:
  51769 	if !(i8 < nArg1) {
  51770 		goto __926
  51771 	}
  51772 
  51773 	*(*uintptr)(unsafe.Pointer(apArg1 + uintptr(i8)*4)) = pX1
  51774 	pX1 += 40
  51775 	goto __925
  51776 __925:
  51777 	i8++
  51778 	goto __924
  51779 	goto __926
  51780 __926:
  51781 	;
  51782 	(*Sqlite3)(unsafe.Pointer(db)).FvtabOnConflict = U8((*Op)(unsafe.Pointer(pOp)).Fp5)
  51783 	rc = (*struct {
  51784 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
  51785 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule5)).FxUpdate})).f(tls, pVtab6, nArg1, apArg1, bp+872)
  51786 	(*Sqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict
  51787 	Xsqlite3VtabImportErrmsg(tls, p, pVtab6)
  51788 	if !(rc == SQLITE_OK && (*Op)(unsafe.Pointer(pOp)).Fp1 != 0) {
  51789 		goto __927
  51790 	}
  51791 
  51792 	(*Sqlite3)(unsafe.Pointer(db)).FlastRowid = *(*Sqlite_int64)(unsafe.Pointer(bp + 872))
  51793 __927:
  51794 	;
  51795 	if !(rc&0xff == SQLITE_CONSTRAINT && (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FbConstraint != 0) {
  51796 		goto __928
  51797 	}
  51798 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5) == OE_Ignore) {
  51799 		goto __930
  51800 	}
  51801 	rc = SQLITE_OK
  51802 	goto __931
  51803 __930:
  51804 	(*Vdbe)(unsafe.Pointer(p)).FerrorAction = func() uint8 {
  51805 		if int32((*Op)(unsafe.Pointer(pOp)).Fp5) == OE_Replace {
  51806 			return uint8(OE_Abort)
  51807 		}
  51808 		return uint8((*Op)(unsafe.Pointer(pOp)).Fp5)
  51809 	}()
  51810 __931:
  51811 	;
  51812 	goto __929
  51813 __928:
  51814 	(*Vdbe)(unsafe.Pointer(p)).FnChange++
  51815 __929:
  51816 	;
  51817 	if !(rc != 0) {
  51818 		goto __932
  51819 	}
  51820 	goto abort_due_to_error
  51821 __932:
  51822 	;
  51823 __923:
  51824 	;
  51825 	goto __9
  51826 
  51827 __182:
  51828 	pOut = out2Prerelease(tls, p, pOp)
  51829 	*(*I64)(unsafe.Pointer(pOut)) = I64(Xsqlite3BtreeLastPage(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16)).FpBt))
  51830 	goto __9
  51831 
  51832 __183:
  51833 	pOut = out2Prerelease(tls, p, pOp)
  51834 	pBt3 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*16)).FpBt
  51835 	newMax = uint32(0)
  51836 	if !((*Op)(unsafe.Pointer(pOp)).Fp3 != 0) {
  51837 		goto __933
  51838 	}
  51839 	newMax = Xsqlite3BtreeLastPage(tls, pBt3)
  51840 	if !(newMax < uint32((*Op)(unsafe.Pointer(pOp)).Fp3)) {
  51841 		goto __934
  51842 	}
  51843 	newMax = uint32((*Op)(unsafe.Pointer(pOp)).Fp3)
  51844 __934:
  51845 	;
  51846 __933:
  51847 	;
  51848 	*(*I64)(unsafe.Pointer(pOut)) = I64(Xsqlite3BtreeMaxPageCount(tls, pBt3, newMax))
  51849 	goto __9
  51850 
  51851 __184:
  51852 __185:
  51853 	;
  51854 	pCtx2 = *(*uintptr)(unsafe.Pointer(pOp + 16))
  51855 
  51856 	pOut = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*40
  51857 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx2)).FpOut != pOut) {
  51858 		goto __935
  51859 	}
  51860 	(*Sqlite3_context)(unsafe.Pointer(pCtx2)).FpVdbe = p
  51861 	(*Sqlite3_context)(unsafe.Pointer(pCtx2)).FpOut = pOut
  51862 	(*Sqlite3_context)(unsafe.Pointer(pCtx2)).Fenc = encoding
  51863 	i9 = int32((*Sqlite3_context)(unsafe.Pointer(pCtx2)).Fargc) - 1
  51864 __936:
  51865 	if !(i9 >= 0) {
  51866 		goto __938
  51867 	}
  51868 	*(*uintptr)(unsafe.Pointer(pCtx2 + 28 + uintptr(i9)*4)) = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2+i9)*40
  51869 	goto __937
  51870 __937:
  51871 	i9--
  51872 	goto __936
  51873 	goto __938
  51874 __938:
  51875 	;
  51876 __935:
  51877 	;
  51878 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Null)
  51879 
  51880 	(*struct {
  51881 		f func(*libc.TLS, uintptr, int32, uintptr)
  51882 	})(unsafe.Pointer(&struct{ uintptr }{(*FuncDef)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc)).FxSFunc})).f(tls, pCtx2, int32((*Sqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+28)
  51883 
  51884 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx2)).FisError != 0) {
  51885 		goto __939
  51886 	}
  51887 	if !((*Sqlite3_context)(unsafe.Pointer(pCtx2)).FisError > 0) {
  51888 		goto __940
  51889 	}
  51890 	Xsqlite3VdbeError(tls, p, ts+3663, libc.VaList(bp+160, Xsqlite3_value_text(tls, pOut)))
  51891 	rc = (*Sqlite3_context)(unsafe.Pointer(pCtx2)).FisError
  51892 __940:
  51893 	;
  51894 	Xsqlite3VdbeDeleteAuxData(tls, db, p+228, (*Sqlite3_context)(unsafe.Pointer(pCtx2)).FiOp, (*Op)(unsafe.Pointer(pOp)).Fp1)
  51895 	(*Sqlite3_context)(unsafe.Pointer(pCtx2)).FisError = 0
  51896 	if !(rc != 0) {
  51897 		goto __941
  51898 	}
  51899 	goto abort_due_to_error
  51900 __941:
  51901 	;
  51902 __939:
  51903 	;
  51904 	goto __9
  51905 
  51906 __186:
  51907 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51908 	*(*U16)(unsafe.Pointer(pIn1 + 16)) &= libc.Uint16FromInt32(libc.CplInt32(MEM_Subtype))
  51909 	goto __9
  51910 
  51911 __187:
  51912 	;
  51913 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51914 
  51915 	h = filterHash(tls, aMem, pOp)
  51916 	h = h % U64((*Mem)(unsafe.Pointer(pIn1)).Fn)
  51917 	*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pIn1)).Fz + uintptr(h/uint64(8)))) |= uint8(int32(1) << (h & uint64(7)))
  51918 	goto __9
  51919 
  51920 __188:
  51921 	;
  51922 	pIn1 = aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*40
  51923 
  51924 	h1 = filterHash(tls, aMem, pOp)
  51925 	h1 = h1 % U64((*Mem)(unsafe.Pointer(pIn1)).Fn)
  51926 	if !(int32(*(*uint8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pIn1)).Fz + uintptr(h1/uint64(8)))))&(int32(1)<<(h1&uint64(7))) == 0) {
  51927 		goto __942
  51928 	}
  51929 
  51930 	*(*U32)(unsafe.Pointer(p + 164 + 8*4))++
  51931 	goto jump_to_p2
  51932 	goto __943
  51933 __942:
  51934 	*(*U32)(unsafe.Pointer(p + 164 + 7*4))++
  51935 
  51936 __943:
  51937 	;
  51938 	goto __9
  51939 
  51940 __189:
  51941 __190:
  51942 	;
  51943 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace)&(SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY) != 0 &&
  51944 		int32((*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat) != 254 &&
  51945 		libc.AssignUintptr(&zTrace, func() uintptr {
  51946 			if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 {
  51947 				return *(*uintptr)(unsafe.Pointer(pOp + 16))
  51948 			}
  51949 			return (*Vdbe)(unsafe.Pointer(p)).FzSql
  51950 		}()) != uintptr(0)) {
  51951 		goto __944
  51952 	}
  51953 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace)&SQLITE_TRACE_LEGACY != 0) {
  51954 		goto __945
  51955 	}
  51956 	z2 = Xsqlite3VdbeExpandSql(tls, p, zTrace)
  51957 	(*struct {
  51958 		f func(*libc.TLS, uintptr, uintptr)
  51959 	})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(db + 216))})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, z2)
  51960 	Xsqlite3_free(tls, z2)
  51961 	goto __946
  51962 __945:
  51963 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec > 1) {
  51964 		goto __947
  51965 	}
  51966 	z3 = Xsqlite3MPrintf(tls, db, ts+6080, libc.VaList(bp+168, zTrace))
  51967 	(*struct {
  51968 		f func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32
  51969 	})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(db + 216))})).f(tls, uint32(SQLITE_TRACE_STMT), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3)
  51970 	Xsqlite3DbFree(tls, db, z3)
  51971 	goto __948
  51972 __947:
  51973 	(*struct {
  51974 		f func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32
  51975 	})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(db + 216))})).f(tls, uint32(SQLITE_TRACE_STMT), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace)
  51976 __948:
  51977 	;
  51978 __946:
  51979 	;
  51980 __944:
  51981 	;
  51982 	if !((*Op)(unsafe.Pointer(pOp)).Fp1 >= Xsqlite3Config.FiOnceResetThreshold) {
  51983 		goto __949
  51984 	}
  51985 	if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Trace) {
  51986 		goto __950
  51987 	}
  51988 	goto __9
  51989 __950:
  51990 	;
  51991 	i10 = 1
  51992 __951:
  51993 	if !(i10 < (*Vdbe)(unsafe.Pointer(p)).FnOp) {
  51994 		goto __953
  51995 	}
  51996 	if !(int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(i10)*20)).Fopcode) == OP_Once) {
  51997 		goto __954
  51998 	}
  51999 	(*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(i10)*20)).Fp1 = 0
  52000 __954:
  52001 	;
  52002 	goto __952
  52003 __952:
  52004 	i10++
  52005 	goto __951
  52006 	goto __953
  52007 __953:
  52008 	;
  52009 	(*Op)(unsafe.Pointer(pOp)).Fp1 = 0
  52010 __949:
  52011 	;
  52012 	(*Op)(unsafe.Pointer(pOp)).Fp1++
  52013 	*(*U32)(unsafe.Pointer(p + 164 + 6*4))++
  52014 	goto jump_to_p2
  52015 
  52016 __191:
  52017 	;
  52018 	goto __9
  52019 
  52020 __9:
  52021 	;
  52022 	goto __7
  52023 __7:
  52024 	pOp += 20
  52025 	goto __6
  52026 	goto __8
  52027 __8:
  52028 	;
  52029 abort_due_to_error:
  52030 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  52031 		goto __955
  52032 	}
  52033 	rc = SQLITE_NOMEM
  52034 	goto __956
  52035 __955:
  52036 	if !(rc == SQLITE_IOERR|int32(33)<<8) {
  52037 		goto __957
  52038 	}
  52039 	rc = Xsqlite3CorruptError(tls, 99034)
  52040 __957:
  52041 	;
  52042 __956:
  52043 	;
  52044 	if !((*Vdbe)(unsafe.Pointer(p)).FzErrMsg == uintptr(0) && rc != SQLITE_IOERR|int32(12)<<8) {
  52045 		goto __958
  52046 	}
  52047 	Xsqlite3VdbeError(tls, p, ts+3663, libc.VaList(bp+176, Xsqlite3ErrStr(tls, rc)))
  52048 __958:
  52049 	;
  52050 	(*Vdbe)(unsafe.Pointer(p)).Frc = rc
  52051 	Xsqlite3SystemError(tls, db, rc)
  52052 
  52053 	Xsqlite3_log(tls, rc, ts+6086,
  52054 		libc.VaList(bp+184, (int32(pOp)-int32(aOp))/20, (*Vdbe)(unsafe.Pointer(p)).FzSql, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg))
  52055 	if !(int32((*Vdbe)(unsafe.Pointer(p)).FeVdbeState) == VDBE_RUN_STATE) {
  52056 		goto __959
  52057 	}
  52058 	Xsqlite3VdbeHalt(tls, p)
  52059 __959:
  52060 	;
  52061 	if !(rc == SQLITE_IOERR|int32(12)<<8) {
  52062 		goto __960
  52063 	}
  52064 	Xsqlite3OomFault(tls, db)
  52065 __960:
  52066 	;
  52067 	if !(rc == SQLITE_CORRUPT && int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0) {
  52068 		goto __961
  52069 	}
  52070 	*(*U64)(unsafe.Pointer(db + 32)) |= uint64(0x00002) << 32
  52071 __961:
  52072 	;
  52073 	rc = SQLITE_ERROR
  52074 	if !(int32(resetSchemaOnFault) > 0) {
  52075 		goto __962
  52076 	}
  52077 	Xsqlite3ResetOneSchema(tls, db, int32(resetSchemaOnFault)-1)
  52078 __962:
  52079 	;
  52080 vdbe_return:
  52081 __963:
  52082 	if !(nVmStep >= nProgressLimit && (*Sqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0)) {
  52083 		goto __964
  52084 	}
  52085 	nProgressLimit = nProgressLimit + U64((*Sqlite3)(unsafe.Pointer(db)).FnProgressOps)
  52086 	if !((*struct {
  52087 		f func(*libc.TLS, uintptr) int32
  52088 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxProgress})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0) {
  52089 		goto __965
  52090 	}
  52091 	nProgressLimit = uint64(0xffffffff) | uint64(0xffffffff)<<32
  52092 	rc = SQLITE_INTERRUPT
  52093 	goto abort_due_to_error
  52094 __965:
  52095 	;
  52096 	goto __963
  52097 __964:
  52098 	;
  52099 	*(*U32)(unsafe.Pointer(p + 164 + 4*4)) += U32(int32(nVmStep))
  52100 	if !((*Vdbe)(unsafe.Pointer(p)).FlockMask != YDbMask(0)) {
  52101 		goto __966
  52102 	}
  52103 	Xsqlite3VdbeLeave(tls, p)
  52104 __966:
  52105 	;
  52106 	return rc
  52107 
  52108 too_big:
  52109 	Xsqlite3VdbeError(tls, p, ts+5334, 0)
  52110 	rc = SQLITE_TOOBIG
  52111 	goto abort_due_to_error
  52112 
  52113 no_mem:
  52114 	Xsqlite3OomFault(tls, db)
  52115 	Xsqlite3VdbeError(tls, p, ts+1490, 0)
  52116 	rc = SQLITE_NOMEM
  52117 	goto abort_due_to_error
  52118 
  52119 abort_due_to_interrupt:
  52120 	;
  52121 	rc = SQLITE_INTERRUPT
  52122 	goto abort_due_to_error
  52123 	return int32(0)
  52124 }
  52125 
  52126 var azType = [4]uintptr{ts + 6118, ts + 6127, ts + 6134,
  52127 	ts + 6140}
  52128 var and_logic = [9]uint8{uint8(0), uint8(0), uint8(0), uint8(0), uint8(1), uint8(2), uint8(0), uint8(2), uint8(2)}
  52129 var or_logic = [9]uint8{uint8(0), uint8(1), uint8(2), uint8(1), uint8(1), uint8(1), uint8(2), uint8(1), uint8(2)}
  52130 var aMask = [12]uint8{
  52131 	uint8(0x10), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x2),
  52132 	uint8(0x01), uint8(0x01), uint8(0x10), uint8(0x10),
  52133 }
  52134 var aFlag1 = [2]U16{U16(MEM_Blob), U16(MEM_Str | MEM_Term)}
  52135 var vfsFlags int32 = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TRANSIENT_DB
  52136 
  52137 // Valid sqlite3_blob* handles point to Incrblob structures.
  52138 type Incrblob1 = struct {
  52139 	FnByte       int32
  52140 	FiOffset     int32
  52141 	FiCol        U16
  52142 	F__ccgo_pad1 [2]byte
  52143 	FpCsr        uintptr
  52144 	FpStmt       uintptr
  52145 	Fdb          uintptr
  52146 	FzDb         uintptr
  52147 	FpTab        uintptr
  52148 }
  52149 
  52150 // Valid sqlite3_blob* handles point to Incrblob structures.
  52151 type Incrblob = Incrblob1
  52152 
  52153 func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) int32 {
  52154 	bp := tls.Alloc(24)
  52155 	defer tls.Free(24)
  52156 
  52157 	var rc int32
  52158 	var zErr uintptr = uintptr(0)
  52159 	var v uintptr = (*Incrblob)(unsafe.Pointer(p)).FpStmt
  52160 
  52161 	(*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + 1*40)).Fflags = U16(MEM_Int)
  52162 	*(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + 1*40)) = iRow
  52163 
  52164 	if (*Vdbe)(unsafe.Pointer(v)).Fpc > 4 {
  52165 		(*Vdbe)(unsafe.Pointer(v)).Fpc = 4
  52166 
  52167 		rc = Xsqlite3VdbeExec(tls, v)
  52168 	} else {
  52169 		rc = Xsqlite3_step(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt)
  52170 	}
  52171 	if rc == SQLITE_ROW {
  52172 		var pC uintptr = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr))
  52173 		var type1 U32
  52174 
  52175 		if int32((*VdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) > int32((*Incrblob)(unsafe.Pointer(p)).FiCol) {
  52176 			type1 = *(*U32)(unsafe.Pointer(pC + 80 + uintptr((*Incrblob)(unsafe.Pointer(p)).FiCol)*4))
  52177 		} else {
  52178 			type1 = uint32(0)
  52179 		}
  52180 
  52181 		if type1 < U32(12) {
  52182 			zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+6152,
  52183 				libc.VaList(bp, func() uintptr {
  52184 					if type1 == U32(0) {
  52185 						return ts + 6181
  52186 					}
  52187 					return func() uintptr {
  52188 						if type1 == U32(7) {
  52189 							return ts + 6186
  52190 						}
  52191 						return ts + 6191
  52192 					}()
  52193 				}()))
  52194 			rc = SQLITE_ERROR
  52195 			Xsqlite3_finalize(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt)
  52196 			(*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0)
  52197 		} else {
  52198 			(*Incrblob)(unsafe.Pointer(p)).FiOffset = int32(*(*U32)(unsafe.Pointer(pC + 80 + uintptr(int32((*Incrblob)(unsafe.Pointer(p)).FiCol)+int32((*VdbeCursor)(unsafe.Pointer(pC)).FnField))*4)))
  52199 			(*Incrblob)(unsafe.Pointer(p)).FnByte = int32(Xsqlite3VdbeSerialTypeLen(tls, type1))
  52200 			(*Incrblob)(unsafe.Pointer(p)).FpCsr = *(*uintptr)(unsafe.Pointer(pC + 36))
  52201 			Xsqlite3BtreeIncrblobCursor(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr)
  52202 		}
  52203 	}
  52204 
  52205 	if rc == SQLITE_ROW {
  52206 		rc = SQLITE_OK
  52207 	} else if (*Incrblob)(unsafe.Pointer(p)).FpStmt != 0 {
  52208 		rc = Xsqlite3_finalize(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt)
  52209 		(*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0)
  52210 		if rc == SQLITE_OK {
  52211 			zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+6199, libc.VaList(bp+8, iRow))
  52212 			rc = SQLITE_ERROR
  52213 		} else {
  52214 			zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+3663, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb)))
  52215 		}
  52216 	}
  52217 
  52218 	*(*uintptr)(unsafe.Pointer(pzErr)) = zErr
  52219 	return rc
  52220 }
  52221 
  52222 // Open a blob handle.
  52223 func Xsqlite3_blob_open(tls *libc.TLS, db uintptr, zDb uintptr, zTable uintptr, zColumn uintptr, iRow Sqlite_int64, wrFlag int32, ppBlob uintptr) int32 {
  52224 	bp := tls.Alloc(332)
  52225 	defer tls.Free(332)
  52226 
  52227 	var nAttempt int32
  52228 	var iCol int32
  52229 	var rc int32
  52230 
  52231 	var pTab uintptr
  52232 	var pBlob uintptr
  52233 
  52234 	var j int32
  52235 
  52236 	var pFKey uintptr
  52237 	var j1 int32
  52238 	var zFault uintptr
  52239 	var pIdx uintptr
  52240 	var v uintptr
  52241 	var iDb int32
  52242 	var aOp uintptr
  52243 	nAttempt = 0
  52244 	rc = SQLITE_OK
  52245 	*(*uintptr)(unsafe.Pointer(bp + 328)) = uintptr(0)
  52246 	pBlob = uintptr(0)
  52247 
  52248 	*(*uintptr)(unsafe.Pointer(ppBlob)) = uintptr(0)
  52249 	wrFlag = libc.BoolInt32(!!(wrFlag != 0))
  52250 
  52251 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52252 
  52253 	pBlob = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Incrblob{})))
  52254 __1:
  52255 	if !(1 != 0) {
  52256 		goto __2
  52257 	}
  52258 	Xsqlite3ParseObjectInit(tls, bp+48, db)
  52259 	if !!(pBlob != 0) {
  52260 		goto __3
  52261 	}
  52262 	goto blob_open_out
  52263 __3:
  52264 	;
  52265 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 328)))
  52266 	*(*uintptr)(unsafe.Pointer(bp + 328)) = uintptr(0)
  52267 
  52268 	Xsqlite3BtreeEnterAll(tls, db)
  52269 	pTab = Xsqlite3LocateTable(tls, bp+48, uint32(0), zTable, zDb)
  52270 	if !(pTab != 0 && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  52271 		goto __4
  52272 	}
  52273 	pTab = uintptr(0)
  52274 	Xsqlite3ErrorMsg(tls, bp+48, ts+6219, libc.VaList(bp, zTable))
  52275 __4:
  52276 	;
  52277 	if !(pTab != 0 && !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0))) {
  52278 		goto __5
  52279 	}
  52280 	pTab = uintptr(0)
  52281 	Xsqlite3ErrorMsg(tls, bp+48, ts+6249, libc.VaList(bp+8, zTable))
  52282 __5:
  52283 	;
  52284 	if !(pTab != 0 && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  52285 		goto __6
  52286 	}
  52287 	pTab = uintptr(0)
  52288 	Xsqlite3ErrorMsg(tls, bp+48, ts+6285, libc.VaList(bp+16, zTable))
  52289 __6:
  52290 	;
  52291 	if !!(pTab != 0) {
  52292 		goto __7
  52293 	}
  52294 	if !((*Parse)(unsafe.Pointer(bp+48)).FzErrMsg != 0) {
  52295 		goto __8
  52296 	}
  52297 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 328)))
  52298 	*(*uintptr)(unsafe.Pointer(bp + 328)) = (*Parse)(unsafe.Pointer(bp + 48)).FzErrMsg
  52299 	(*Parse)(unsafe.Pointer(bp + 48)).FzErrMsg = uintptr(0)
  52300 __8:
  52301 	;
  52302 	rc = SQLITE_ERROR
  52303 	Xsqlite3BtreeLeaveAll(tls, db)
  52304 	goto blob_open_out
  52305 __7:
  52306 	;
  52307 	(*Incrblob)(unsafe.Pointer(pBlob)).FpTab = pTab
  52308 	(*Incrblob)(unsafe.Pointer(pBlob)).FzDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema))*16)).FzDbSName
  52309 
  52310 	iCol = 0
  52311 __9:
  52312 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  52313 		goto __11
  52314 	}
  52315 	if !(Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FzCnName, zColumn) == 0) {
  52316 		goto __12
  52317 	}
  52318 	goto __11
  52319 __12:
  52320 	;
  52321 	goto __10
  52322 __10:
  52323 	iCol++
  52324 	goto __9
  52325 	goto __11
  52326 __11:
  52327 	;
  52328 	if !(iCol == int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  52329 		goto __13
  52330 	}
  52331 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 328)))
  52332 	*(*uintptr)(unsafe.Pointer(bp + 328)) = Xsqlite3MPrintf(tls, db, ts+6306, libc.VaList(bp+24, zColumn))
  52333 	rc = SQLITE_ERROR
  52334 	Xsqlite3BtreeLeaveAll(tls, db)
  52335 	goto blob_open_out
  52336 __13:
  52337 	;
  52338 	if !(wrFlag != 0) {
  52339 		goto __14
  52340 	}
  52341 	zFault = uintptr(0)
  52342 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0) {
  52343 		goto __15
  52344 	}
  52345 
  52346 	pFKey = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4))
  52347 __16:
  52348 	if !(pFKey != 0) {
  52349 		goto __18
  52350 	}
  52351 	j = 0
  52352 __19:
  52353 	if !(j < (*FKey)(unsafe.Pointer(pFKey)).FnCol) {
  52354 		goto __21
  52355 	}
  52356 	if !((*sColMap)(unsafe.Pointer(pFKey+36+uintptr(j)*8)).FiFrom == iCol) {
  52357 		goto __22
  52358 	}
  52359 	zFault = ts + 6327
  52360 __22:
  52361 	;
  52362 	goto __20
  52363 __20:
  52364 	j++
  52365 	goto __19
  52366 	goto __21
  52367 __21:
  52368 	;
  52369 	goto __17
  52370 __17:
  52371 	pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom
  52372 	goto __16
  52373 	goto __18
  52374 __18:
  52375 	;
  52376 __15:
  52377 	;
  52378 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  52379 __23:
  52380 	if !(pIdx != 0) {
  52381 		goto __25
  52382 	}
  52383 	j1 = 0
  52384 __26:
  52385 	if !(j1 < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) {
  52386 		goto __28
  52387 	}
  52388 
  52389 	if !(int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j1)*2))) == iCol || int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j1)*2))) == -2) {
  52390 		goto __29
  52391 	}
  52392 	zFault = ts + 6339
  52393 __29:
  52394 	;
  52395 	goto __27
  52396 __27:
  52397 	j1++
  52398 	goto __26
  52399 	goto __28
  52400 __28:
  52401 	;
  52402 	goto __24
  52403 __24:
  52404 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  52405 	goto __23
  52406 	goto __25
  52407 __25:
  52408 	;
  52409 	if !(zFault != 0) {
  52410 		goto __30
  52411 	}
  52412 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 328)))
  52413 	*(*uintptr)(unsafe.Pointer(bp + 328)) = Xsqlite3MPrintf(tls, db, ts+6347, libc.VaList(bp+32, zFault))
  52414 	rc = SQLITE_ERROR
  52415 	Xsqlite3BtreeLeaveAll(tls, db)
  52416 	goto blob_open_out
  52417 __30:
  52418 	;
  52419 __14:
  52420 	;
  52421 	(*Incrblob)(unsafe.Pointer(pBlob)).FpStmt = Xsqlite3VdbeCreate(tls, bp+48)
  52422 
  52423 	if !((*Incrblob)(unsafe.Pointer(pBlob)).FpStmt != 0) {
  52424 		goto __31
  52425 	}
  52426 	v = (*Incrblob)(unsafe.Pointer(pBlob)).FpStmt
  52427 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  52428 
  52429 	Xsqlite3VdbeAddOp4Int(tls, v, OP_Transaction, iDb, wrFlag,
  52430 		(*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema)).Fschema_cookie,
  52431 		(*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema)).FiGeneration)
  52432 	Xsqlite3VdbeChangeP5(tls, v, uint16(1))
  52433 
  52434 	aOp = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(openBlob))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&openBlob)), iLn)
  52435 
  52436 	Xsqlite3VdbeUsesBtree(tls, v, iDb)
  52437 
  52438 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) {
  52439 		goto __32
  52440 	}
  52441 
  52442 	(*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = iDb
  52443 	(*VdbeOp)(unsafe.Pointer(aOp)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum)
  52444 	(*VdbeOp)(unsafe.Pointer(aOp)).Fp3 = wrFlag
  52445 	Xsqlite3VdbeChangeP4(tls, v, 2, (*Table)(unsafe.Pointer(pTab)).FzName, P4_TRANSIENT)
  52446 __32:
  52447 	;
  52448 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) {
  52449 		goto __33
  52450 	}
  52451 
  52452 	if !(wrFlag != 0) {
  52453 		goto __34
  52454 	}
  52455 	(*VdbeOp)(unsafe.Pointer(aOp + 1*20)).Fopcode = U8(OP_OpenWrite)
  52456 __34:
  52457 	;
  52458 	(*VdbeOp)(unsafe.Pointer(aOp + 1*20)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum)
  52459 	(*VdbeOp)(unsafe.Pointer(aOp + 1*20)).Fp3 = iDb
  52460 
  52461 	(*VdbeOp)(unsafe.Pointer(aOp + 1*20)).Fp4type = int8(-3)
  52462 	*(*int32)(unsafe.Pointer(aOp + 1*20 + 16)) = int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1
  52463 	(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  52464 
  52465 	(*Parse)(unsafe.Pointer(bp + 48)).FnVar = int16(0)
  52466 	(*Parse)(unsafe.Pointer(bp + 48)).FnMem = 1
  52467 	(*Parse)(unsafe.Pointer(bp + 48)).FnTab = 1
  52468 	Xsqlite3VdbeMakeReady(tls, v, bp+48)
  52469 __33:
  52470 	;
  52471 __31:
  52472 	;
  52473 	(*Incrblob)(unsafe.Pointer(pBlob)).FiCol = U16(iCol)
  52474 	(*Incrblob)(unsafe.Pointer(pBlob)).Fdb = db
  52475 	Xsqlite3BtreeLeaveAll(tls, db)
  52476 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  52477 		goto __35
  52478 	}
  52479 	goto blob_open_out
  52480 __35:
  52481 	;
  52482 	rc = blobSeekToRow(tls, pBlob, iRow, bp+328)
  52483 	if !(libc.PreIncInt32(&nAttempt, 1) >= SQLITE_MAX_SCHEMA_RETRY || rc != SQLITE_SCHEMA) {
  52484 		goto __36
  52485 	}
  52486 	goto __2
  52487 __36:
  52488 	;
  52489 	Xsqlite3ParseObjectReset(tls, bp+48)
  52490 	goto __1
  52491 __2:
  52492 	;
  52493 blob_open_out:
  52494 	if !(rc == SQLITE_OK && int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) {
  52495 		goto __37
  52496 	}
  52497 	*(*uintptr)(unsafe.Pointer(ppBlob)) = pBlob
  52498 	goto __38
  52499 __37:
  52500 	if !(pBlob != 0 && (*Incrblob)(unsafe.Pointer(pBlob)).FpStmt != 0) {
  52501 		goto __39
  52502 	}
  52503 	Xsqlite3VdbeFinalize(tls, (*Incrblob)(unsafe.Pointer(pBlob)).FpStmt)
  52504 __39:
  52505 	;
  52506 	Xsqlite3DbFree(tls, db, pBlob)
  52507 __38:
  52508 	;
  52509 	Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr {
  52510 		if *(*uintptr)(unsafe.Pointer(bp + 328)) != 0 {
  52511 			return ts + 3663
  52512 		}
  52513 		return uintptr(0)
  52514 	}(), libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 328))))
  52515 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 328)))
  52516 	Xsqlite3ParseObjectReset(tls, bp+48)
  52517 	rc = Xsqlite3ApiExit(tls, db, rc)
  52518 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52519 	return rc
  52520 }
  52521 
  52522 var iLn int32 = 0
  52523 var openBlob = [6]VdbeOpList{
  52524 	{Fopcode: U8(OP_TableLock)},
  52525 	{Fopcode: U8(OP_OpenRead)},
  52526 	{Fopcode: U8(OP_NotExists), Fp2: int8(5), Fp3: int8(1)},
  52527 	{Fopcode: U8(OP_Column), Fp3: int8(1)},
  52528 	{Fopcode: U8(OP_ResultRow), Fp1: int8(1)},
  52529 	{Fopcode: U8(OP_Halt)},
  52530 }
  52531 
  52532 // Close a blob handle that was previously created using
  52533 // sqlite3_blob_open().
  52534 func Xsqlite3_blob_close(tls *libc.TLS, pBlob uintptr) int32 {
  52535 	var p uintptr = pBlob
  52536 	var rc int32
  52537 	var db uintptr
  52538 
  52539 	if p != 0 {
  52540 		var pStmt uintptr = (*Incrblob)(unsafe.Pointer(p)).FpStmt
  52541 		db = (*Incrblob)(unsafe.Pointer(p)).Fdb
  52542 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52543 		Xsqlite3DbFree(tls, db, p)
  52544 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52545 		rc = Xsqlite3_finalize(tls, pStmt)
  52546 	} else {
  52547 		rc = SQLITE_OK
  52548 	}
  52549 	return rc
  52550 }
  52551 
  52552 func blobReadWrite(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32, xCall uintptr) int32 {
  52553 	var rc int32
  52554 	var p uintptr = pBlob
  52555 	var v uintptr
  52556 	var db uintptr
  52557 
  52558 	if p == uintptr(0) {
  52559 		return Xsqlite3MisuseError(tls, 99519)
  52560 	}
  52561 	db = (*Incrblob)(unsafe.Pointer(p)).Fdb
  52562 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52563 	v = (*Incrblob)(unsafe.Pointer(p)).FpStmt
  52564 
  52565 	if n < 0 || iOffset < 0 || Sqlite3_int64(iOffset)+Sqlite3_int64(n) > Sqlite3_int64((*Incrblob)(unsafe.Pointer(p)).FnByte) {
  52566 		rc = SQLITE_ERROR
  52567 	} else if v == uintptr(0) {
  52568 		rc = SQLITE_ABORT
  52569 	} else {
  52570 		Xsqlite3BtreeEnterCursor(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr)
  52571 
  52572 		if xCall == *(*uintptr)(unsafe.Pointer(&struct {
  52573 			f func(*libc.TLS, uintptr, U32, U32, uintptr) int32
  52574 		}{Xsqlite3BtreePutData})) && (*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 {
  52575 			var iKey Sqlite3_int64
  52576 			iKey = Xsqlite3BtreeIntegerKey(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr)
  52577 
  52578 			Xsqlite3VdbePreUpdateHook(tls,
  52579 				v, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr)), SQLITE_DELETE, (*Incrblob)(unsafe.Pointer(p)).FzDb, (*Incrblob)(unsafe.Pointer(p)).FpTab, iKey, -1, int32((*Incrblob)(unsafe.Pointer(p)).FiCol))
  52580 		}
  52581 
  52582 		rc = (*struct {
  52583 			f func(*libc.TLS, uintptr, U32, U32, uintptr) int32
  52584 		})(unsafe.Pointer(&struct{ uintptr }{xCall})).f(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr, uint32(iOffset+(*Incrblob)(unsafe.Pointer(p)).FiOffset), uint32(n), z)
  52585 		Xsqlite3BtreeLeaveCursor(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr)
  52586 		if rc == SQLITE_ABORT {
  52587 			Xsqlite3VdbeFinalize(tls, v)
  52588 			(*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0)
  52589 		} else {
  52590 			(*Vdbe)(unsafe.Pointer(v)).Frc = rc
  52591 		}
  52592 	}
  52593 	Xsqlite3Error(tls, db, rc)
  52594 	rc = Xsqlite3ApiExit(tls, db, rc)
  52595 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52596 	return rc
  52597 }
  52598 
  52599 // Read data from a blob handle.
  52600 func Xsqlite3_blob_read(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32) int32 {
  52601 	return blobReadWrite(tls, pBlob, z, n, iOffset, *(*uintptr)(unsafe.Pointer(&struct {
  52602 		f func(*libc.TLS, uintptr, U32, U32, uintptr) int32
  52603 	}{Xsqlite3BtreePayloadChecked})))
  52604 }
  52605 
  52606 // Write data to a blob handle.
  52607 func Xsqlite3_blob_write(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32) int32 {
  52608 	return blobReadWrite(tls, pBlob, z, n, iOffset, *(*uintptr)(unsafe.Pointer(&struct {
  52609 		f func(*libc.TLS, uintptr, U32, U32, uintptr) int32
  52610 	}{Xsqlite3BtreePutData})))
  52611 }
  52612 
  52613 // Query a blob handle for the size of the data.
  52614 //
  52615 // The Incrblob.nByte field is fixed for the lifetime of the Incrblob
  52616 // so no mutex is required for access.
  52617 func Xsqlite3_blob_bytes(tls *libc.TLS, pBlob uintptr) int32 {
  52618 	var p uintptr = pBlob
  52619 	if p != 0 && (*Incrblob)(unsafe.Pointer(p)).FpStmt != 0 {
  52620 		return (*Incrblob)(unsafe.Pointer(p)).FnByte
  52621 	}
  52622 	return 0
  52623 }
  52624 
  52625 // Move an existing blob handle to point to a different row of the same
  52626 // database table.
  52627 //
  52628 // If an error occurs, or if the specified row does not exist or does not
  52629 // contain a blob or text value, then an error code is returned and the
  52630 // database handle error code and message set. If this happens, then all
  52631 // subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
  52632 // immediately return SQLITE_ABORT.
  52633 func Xsqlite3_blob_reopen(tls *libc.TLS, pBlob uintptr, iRow Sqlite3_int64) int32 {
  52634 	bp := tls.Alloc(12)
  52635 	defer tls.Free(12)
  52636 
  52637 	var rc int32
  52638 	var p uintptr = pBlob
  52639 	var db uintptr
  52640 
  52641 	if p == uintptr(0) {
  52642 		return Xsqlite3MisuseError(tls, 99619)
  52643 	}
  52644 	db = (*Incrblob)(unsafe.Pointer(p)).Fdb
  52645 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52646 
  52647 	if (*Incrblob)(unsafe.Pointer(p)).FpStmt == uintptr(0) {
  52648 		rc = SQLITE_ABORT
  52649 	} else {
  52650 		(*Vdbe)(unsafe.Pointer((*Incrblob)(unsafe.Pointer(p)).FpStmt)).Frc = SQLITE_OK
  52651 		rc = blobSeekToRow(tls, p, iRow, bp+8)
  52652 		if rc != SQLITE_OK {
  52653 			Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr {
  52654 				if *(*uintptr)(unsafe.Pointer(bp + 8)) != 0 {
  52655 					return ts + 3663
  52656 				}
  52657 				return uintptr(0)
  52658 			}(), libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 8))))
  52659 			Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8)))
  52660 		}
  52661 
  52662 	}
  52663 
  52664 	rc = Xsqlite3ApiExit(tls, db, rc)
  52665 
  52666 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  52667 	return rc
  52668 }
  52669 
  52670 // Private objects used by the sorter
  52671 type MergeEngine1 = struct {
  52672 	FnTree  int32
  52673 	FpTask  uintptr
  52674 	FaTree  uintptr
  52675 	FaReadr uintptr
  52676 }
  52677 
  52678 // Private objects used by the sorter
  52679 type MergeEngine = MergeEngine1
  52680 type PmaReader1 = struct {
  52681 	FiReadOff    I64
  52682 	FiEof        I64
  52683 	FnAlloc      int32
  52684 	FnKey        int32
  52685 	FpFd         uintptr
  52686 	FaAlloc      uintptr
  52687 	FaKey        uintptr
  52688 	FaBuffer     uintptr
  52689 	FnBuffer     int32
  52690 	FaMap        uintptr
  52691 	FpIncr       uintptr
  52692 	F__ccgo_pad1 [4]byte
  52693 }
  52694 
  52695 // Merge PMAs together
  52696 type PmaReader = PmaReader1
  52697 type PmaWriter1 = struct {
  52698 	FeFWErr      int32
  52699 	FaBuffer     uintptr
  52700 	FnBuffer     int32
  52701 	FiBufStart   int32
  52702 	FiBufEnd     int32
  52703 	F__ccgo_pad1 [4]byte
  52704 	FiWriteOff   I64
  52705 	FpFd         uintptr
  52706 	F__ccgo_pad2 [4]byte
  52707 }
  52708 
  52709 // Incrementally read one PMA
  52710 type PmaWriter = PmaWriter1
  52711 type SorterRecord1 = struct {
  52712 	FnVal int32
  52713 	Fu    struct{ FpNext uintptr }
  52714 }
  52715 
  52716 // Incrementally write one PMA
  52717 type SorterRecord = SorterRecord1
  52718 type SortSubtask1 = struct {
  52719 	FpThread     uintptr
  52720 	FbDone       int32
  52721 	FpSorter     uintptr
  52722 	FpUnpacked   uintptr
  52723 	Flist        SorterList
  52724 	FnPMA        int32
  52725 	FxCompare    SorterCompare
  52726 	F__ccgo_pad1 [4]byte
  52727 	Ffile        SorterFile
  52728 	Ffile2       SorterFile
  52729 }
  52730 
  52731 // A record being sorted
  52732 type SortSubtask = SortSubtask1
  52733 type SorterFile1 = struct {
  52734 	FpFd         uintptr
  52735 	F__ccgo_pad1 [4]byte
  52736 	FiEof        I64
  52737 }
  52738 
  52739 // A sub-task in the sort process
  52740 type SorterFile = SorterFile1
  52741 type SorterList1 = struct {
  52742 	FpList   uintptr
  52743 	FaMemory uintptr
  52744 	FszPMA   int32
  52745 }
  52746 
  52747 // Temporary file object wrapper
  52748 type SorterList = SorterList1
  52749 type IncrMerger1 = struct {
  52750 	FpTask       uintptr
  52751 	FpMerger     uintptr
  52752 	FiStartOff   I64
  52753 	FmxSz        int32
  52754 	FbEof        int32
  52755 	FbUseThread  int32
  52756 	F__ccgo_pad1 [4]byte
  52757 	FaFile       [2]SorterFile
  52758 }
  52759 
  52760 // In-memory list of records
  52761 type IncrMerger = IncrMerger1
  52762 
  52763 // This object represents a single thread of control in a sort operation.
  52764 // Exactly VdbeSorter.nTask instances of this object are allocated
  52765 // as part of each VdbeSorter object. Instances are never allocated any
  52766 // other way. VdbeSorter.nTask is set to the number of worker threads allowed
  52767 // (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread).  Thus for
  52768 // single-threaded operation, there is exactly one instance of this object
  52769 // and for multi-threaded operation there are two or more instances.
  52770 //
  52771 // Essentially, this structure contains all those fields of the VdbeSorter
  52772 // structure for which each thread requires a separate instance. For example,
  52773 // each thread requries its own UnpackedRecord object to unpack records in
  52774 // as part of comparison operations.
  52775 //
  52776 // Before a background thread is launched, variable bDone is set to 0. Then,
  52777 // right before it exits, the thread itself sets bDone to 1. This is used for
  52778 // two purposes:
  52779 //
  52780 //  1. When flushing the contents of memory to a level-0 PMA on disk, to
  52781 //     attempt to select a SortSubtask for which there is not already an
  52782 //     active background thread (since doing so causes the main thread
  52783 //     to block until it finishes).
  52784 //
  52785 //  2. If SQLITE_DEBUG_SORTER_THREADS is defined, to determine if a call
  52786 //     to sqlite3ThreadJoin() is likely to block. Cases that are likely to
  52787 //     block provoke debugging output.
  52788 //
  52789 // In both cases, the effects of the main thread seeing (bDone==0) even
  52790 // after the thread has finished are not dire. So we don't worry about
  52791 // memory barriers and such here.
  52792 type SorterCompare = uintptr
  52793 
  52794 func vdbePmaReaderClear(tls *libc.TLS, pReadr uintptr) {
  52795 	Xsqlite3_free(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FaAlloc)
  52796 	Xsqlite3_free(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer)
  52797 	if (*PmaReader)(unsafe.Pointer(pReadr)).FaMap != 0 {
  52798 		Xsqlite3OsUnfetch(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpFd, int64(0), (*PmaReader)(unsafe.Pointer(pReadr)).FaMap)
  52799 	}
  52800 	vdbeIncrFree(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr)
  52801 	libc.Xmemset(tls, pReadr, 0, uint32(unsafe.Sizeof(PmaReader{})))
  52802 }
  52803 
  52804 func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 {
  52805 	bp := tls.Alloc(4)
  52806 	defer tls.Free(4)
  52807 
  52808 	var iBuf int32
  52809 	var nAvail int32
  52810 
  52811 	if (*PmaReader)(unsafe.Pointer(p)).FaMap != 0 {
  52812 		*(*uintptr)(unsafe.Pointer(ppOut)) = (*PmaReader)(unsafe.Pointer(p)).FaMap + uintptr((*PmaReader)(unsafe.Pointer(p)).FiReadOff)
  52813 		*(*I64)(unsafe.Pointer(p)) += I64(nByte)
  52814 		return SQLITE_OK
  52815 	}
  52816 
  52817 	iBuf = int32((*PmaReader)(unsafe.Pointer(p)).FiReadOff % I64((*PmaReader)(unsafe.Pointer(p)).FnBuffer))
  52818 	if iBuf == 0 {
  52819 		var nRead int32
  52820 		var rc int32
  52821 
  52822 		if (*PmaReader)(unsafe.Pointer(p)).FiEof-(*PmaReader)(unsafe.Pointer(p)).FiReadOff > I64((*PmaReader)(unsafe.Pointer(p)).FnBuffer) {
  52823 			nRead = (*PmaReader)(unsafe.Pointer(p)).FnBuffer
  52824 		} else {
  52825 			nRead = int32((*PmaReader)(unsafe.Pointer(p)).FiEof - (*PmaReader)(unsafe.Pointer(p)).FiReadOff)
  52826 		}
  52827 
  52828 		rc = Xsqlite3OsRead(tls, (*PmaReader)(unsafe.Pointer(p)).FpFd, (*PmaReader)(unsafe.Pointer(p)).FaBuffer, nRead, (*PmaReader)(unsafe.Pointer(p)).FiReadOff)
  52829 
  52830 		if rc != SQLITE_OK {
  52831 			return rc
  52832 		}
  52833 	}
  52834 	nAvail = (*PmaReader)(unsafe.Pointer(p)).FnBuffer - iBuf
  52835 
  52836 	if nByte <= nAvail {
  52837 		*(*uintptr)(unsafe.Pointer(ppOut)) = (*PmaReader)(unsafe.Pointer(p)).FaBuffer + uintptr(iBuf)
  52838 		*(*I64)(unsafe.Pointer(p)) += I64(nByte)
  52839 	} else {
  52840 		var nRem int32
  52841 
  52842 		if (*PmaReader)(unsafe.Pointer(p)).FnAlloc < nByte {
  52843 			var aNew uintptr
  52844 			var nNew Sqlite3_int64 = func() int64 {
  52845 				if int64(128) > int64(2)*Sqlite3_int64((*PmaReader)(unsafe.Pointer(p)).FnAlloc) {
  52846 					return int64(128)
  52847 				}
  52848 				return int64(2) * Sqlite3_int64((*PmaReader)(unsafe.Pointer(p)).FnAlloc)
  52849 			}()
  52850 			for Sqlite3_int64(nByte) > nNew {
  52851 				nNew = nNew * int64(2)
  52852 			}
  52853 			aNew = Xsqlite3Realloc(tls, (*PmaReader)(unsafe.Pointer(p)).FaAlloc, uint64(nNew))
  52854 			if !(aNew != 0) {
  52855 				return SQLITE_NOMEM
  52856 			}
  52857 			(*PmaReader)(unsafe.Pointer(p)).FnAlloc = int32(nNew)
  52858 			(*PmaReader)(unsafe.Pointer(p)).FaAlloc = aNew
  52859 		}
  52860 
  52861 		libc.Xmemcpy(tls, (*PmaReader)(unsafe.Pointer(p)).FaAlloc, (*PmaReader)(unsafe.Pointer(p)).FaBuffer+uintptr(iBuf), uint32(nAvail))
  52862 		*(*I64)(unsafe.Pointer(p)) += I64(nAvail)
  52863 		nRem = nByte - nAvail
  52864 
  52865 		for nRem > 0 {
  52866 			var rc int32
  52867 			var nCopy int32
  52868 
  52869 			nCopy = nRem
  52870 			if nRem > (*PmaReader)(unsafe.Pointer(p)).FnBuffer {
  52871 				nCopy = (*PmaReader)(unsafe.Pointer(p)).FnBuffer
  52872 			}
  52873 			rc = vdbePmaReadBlob(tls, p, nCopy, bp)
  52874 			if rc != SQLITE_OK {
  52875 				return rc
  52876 			}
  52877 
  52878 			libc.Xmemcpy(tls, (*PmaReader)(unsafe.Pointer(p)).FaAlloc+uintptr(nByte-nRem), *(*uintptr)(unsafe.Pointer(bp)), uint32(nCopy))
  52879 			nRem = nRem - nCopy
  52880 		}
  52881 
  52882 		*(*uintptr)(unsafe.Pointer(ppOut)) = (*PmaReader)(unsafe.Pointer(p)).FaAlloc
  52883 	}
  52884 
  52885 	return SQLITE_OK
  52886 }
  52887 
  52888 func vdbePmaReadVarint(tls *libc.TLS, p uintptr, pnOut uintptr) int32 {
  52889 	bp := tls.Alloc(20)
  52890 	defer tls.Free(20)
  52891 
  52892 	var iBuf int32
  52893 
  52894 	if (*PmaReader)(unsafe.Pointer(p)).FaMap != 0 {
  52895 		*(*I64)(unsafe.Pointer(p)) += I64(Xsqlite3GetVarint(tls, (*PmaReader)(unsafe.Pointer(p)).FaMap+uintptr((*PmaReader)(unsafe.Pointer(p)).FiReadOff), pnOut))
  52896 	} else {
  52897 		iBuf = int32((*PmaReader)(unsafe.Pointer(p)).FiReadOff % I64((*PmaReader)(unsafe.Pointer(p)).FnBuffer))
  52898 		if iBuf != 0 && (*PmaReader)(unsafe.Pointer(p)).FnBuffer-iBuf >= 9 {
  52899 			*(*I64)(unsafe.Pointer(p)) += I64(Xsqlite3GetVarint(tls, (*PmaReader)(unsafe.Pointer(p)).FaBuffer+uintptr(iBuf), pnOut))
  52900 		} else {
  52901 			var i int32 = 0
  52902 			var rc int32
  52903 			for __ccgo := true; __ccgo; __ccgo = int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))))&0x80 != 0 {
  52904 				rc = vdbePmaReadBlob(tls, p, 1, bp)
  52905 				if rc != 0 {
  52906 					return rc
  52907 				}
  52908 				*(*U8)(unsafe.Pointer(bp + 4 + uintptr(libc.PostIncInt32(&i, 1)&0xf))) = *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))
  52909 			}
  52910 			Xsqlite3GetVarint(tls, bp+4, pnOut)
  52911 		}
  52912 	}
  52913 
  52914 	return SQLITE_OK
  52915 }
  52916 
  52917 func vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) int32 {
  52918 	var rc int32 = SQLITE_OK
  52919 	if (*SorterFile)(unsafe.Pointer(pFile)).FiEof <= I64((*Sqlite3)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb)).FnMaxSorterMmap) {
  52920 		var pFd uintptr = (*SorterFile)(unsafe.Pointer(pFile)).FpFd
  52921 		if (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= 3 {
  52922 			rc = Xsqlite3OsFetch(tls, pFd, int64(0), int32((*SorterFile)(unsafe.Pointer(pFile)).FiEof), pp)
  52923 
  52924 		}
  52925 	}
  52926 	return rc
  52927 }
  52928 
  52929 func vdbePmaReaderSeek(tls *libc.TLS, pTask uintptr, pReadr uintptr, pFile uintptr, iOff I64) int32 {
  52930 	var rc int32 = SQLITE_OK
  52931 
  52932 	if Xsqlite3FaultSim(tls, 201) != 0 {
  52933 		return SQLITE_IOERR | int32(1)<<8
  52934 	}
  52935 	if (*PmaReader)(unsafe.Pointer(pReadr)).FaMap != 0 {
  52936 		Xsqlite3OsUnfetch(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpFd, int64(0), (*PmaReader)(unsafe.Pointer(pReadr)).FaMap)
  52937 		(*PmaReader)(unsafe.Pointer(pReadr)).FaMap = uintptr(0)
  52938 	}
  52939 	(*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff = iOff
  52940 	(*PmaReader)(unsafe.Pointer(pReadr)).FiEof = (*SorterFile)(unsafe.Pointer(pFile)).FiEof
  52941 	(*PmaReader)(unsafe.Pointer(pReadr)).FpFd = (*SorterFile)(unsafe.Pointer(pFile)).FpFd
  52942 
  52943 	rc = vdbeSorterMapFile(tls, pTask, pFile, pReadr+44)
  52944 	if rc == SQLITE_OK && (*PmaReader)(unsafe.Pointer(pReadr)).FaMap == uintptr(0) {
  52945 		var pgsz int32 = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz
  52946 		var iBuf int32 = int32((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff % I64(pgsz))
  52947 		if (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer == uintptr(0) {
  52948 			(*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer = Xsqlite3Malloc(tls, uint64(pgsz))
  52949 			if (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer == uintptr(0) {
  52950 				rc = SQLITE_NOMEM
  52951 			}
  52952 			(*PmaReader)(unsafe.Pointer(pReadr)).FnBuffer = pgsz
  52953 		}
  52954 		if rc == SQLITE_OK && iBuf != 0 {
  52955 			var nRead int32 = pgsz - iBuf
  52956 			if (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff+I64(nRead) > (*PmaReader)(unsafe.Pointer(pReadr)).FiEof {
  52957 				nRead = int32((*PmaReader)(unsafe.Pointer(pReadr)).FiEof - (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff)
  52958 			}
  52959 			rc = Xsqlite3OsRead(tls,
  52960 				(*PmaReader)(unsafe.Pointer(pReadr)).FpFd, (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer+uintptr(iBuf), nRead, (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff)
  52961 
  52962 		}
  52963 	}
  52964 
  52965 	return rc
  52966 }
  52967 
  52968 func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 {
  52969 	bp := tls.Alloc(8)
  52970 	defer tls.Free(8)
  52971 
  52972 	var rc int32 = SQLITE_OK
  52973 	*(*U64)(unsafe.Pointer(bp)) = uint64(0)
  52974 
  52975 	if (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff >= (*PmaReader)(unsafe.Pointer(pReadr)).FiEof {
  52976 		var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr
  52977 		var bEof int32 = 1
  52978 		if pIncr != 0 {
  52979 			rc = vdbeIncrSwap(tls, pIncr)
  52980 			if rc == SQLITE_OK && (*IncrMerger)(unsafe.Pointer(pIncr)).FbEof == 0 {
  52981 				rc = vdbePmaReaderSeek(tls,
  52982 					(*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, pReadr, pIncr+32, (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff)
  52983 				bEof = 0
  52984 			}
  52985 		}
  52986 
  52987 		if bEof != 0 {
  52988 			vdbePmaReaderClear(tls, pReadr)
  52989 
  52990 			return rc
  52991 		}
  52992 	}
  52993 
  52994 	if rc == SQLITE_OK {
  52995 		rc = vdbePmaReadVarint(tls, pReadr, bp)
  52996 	}
  52997 	if rc == SQLITE_OK {
  52998 		(*PmaReader)(unsafe.Pointer(pReadr)).FnKey = int32(*(*U64)(unsafe.Pointer(bp)))
  52999 		rc = vdbePmaReadBlob(tls, pReadr, int32(*(*U64)(unsafe.Pointer(bp))), pReadr+32)
  53000 
  53001 	}
  53002 
  53003 	return rc
  53004 }
  53005 
  53006 func vdbePmaReaderInit(tls *libc.TLS, pTask uintptr, pFile uintptr, iStart I64, pReadr uintptr, pnByte uintptr) int32 {
  53007 	bp := tls.Alloc(8)
  53008 	defer tls.Free(8)
  53009 
  53010 	var rc int32
  53011 
  53012 	rc = vdbePmaReaderSeek(tls, pTask, pReadr, pFile, iStart)
  53013 	if rc == SQLITE_OK {
  53014 		*(*U64)(unsafe.Pointer(bp)) = uint64(0)
  53015 		rc = vdbePmaReadVarint(tls, pReadr, bp)
  53016 		(*PmaReader)(unsafe.Pointer(pReadr)).FiEof = I64(U64((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff) + *(*U64)(unsafe.Pointer(bp)))
  53017 		*(*I64)(unsafe.Pointer(pnByte)) += I64(*(*U64)(unsafe.Pointer(bp)))
  53018 	}
  53019 
  53020 	if rc == SQLITE_OK {
  53021 		rc = vdbePmaReaderNext(tls, pReadr)
  53022 	}
  53023 	return rc
  53024 }
  53025 
  53026 func vdbeSorterCompareTail(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) int32 {
  53027 	var r2 uintptr = (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked
  53028 	if *(*int32)(unsafe.Pointer(pbKey2Cached)) == 0 {
  53029 		Xsqlite3VdbeRecordUnpack(tls, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo, nKey2, pKey2, r2)
  53030 		*(*int32)(unsafe.Pointer(pbKey2Cached)) = 1
  53031 	}
  53032 	return Xsqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, r2, 1)
  53033 }
  53034 
  53035 func vdbeSorterCompare(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) int32 {
  53036 	var r2 uintptr = (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked
  53037 	if !(*(*int32)(unsafe.Pointer(pbKey2Cached)) != 0) {
  53038 		Xsqlite3VdbeRecordUnpack(tls, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo, nKey2, pKey2, r2)
  53039 		*(*int32)(unsafe.Pointer(pbKey2Cached)) = 1
  53040 	}
  53041 	return Xsqlite3VdbeRecordCompare(tls, nKey1, pKey1, r2)
  53042 }
  53043 
  53044 func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) int32 {
  53045 	bp := tls.Alloc(8)
  53046 	defer tls.Free(8)
  53047 
  53048 	var p1 uintptr = pKey1
  53049 	var p2 uintptr = pKey2
  53050 	var v1 uintptr = p1 + uintptr(*(*U8)(unsafe.Pointer(p1)))
  53051 	var v2 uintptr = p2 + uintptr(*(*U8)(unsafe.Pointer(p2)))
  53052 
  53053 	var res int32
  53054 
  53055 	*(*int32)(unsafe.Pointer(bp)) = int32(U32(*(*U8)(unsafe.Pointer(p1 + 1))))
  53056 	if *(*int32)(unsafe.Pointer(bp)) >= 0x80 {
  53057 		Xsqlite3GetVarint32(tls, p1+1, bp)
  53058 	}
  53059 	*(*int32)(unsafe.Pointer(bp + 4)) = int32(U32(*(*U8)(unsafe.Pointer(p2 + 1))))
  53060 	if *(*int32)(unsafe.Pointer(bp + 4)) >= 0x80 {
  53061 		Xsqlite3GetVarint32(tls, p2+1, bp+4)
  53062 	}
  53063 	res = libc.Xmemcmp(tls, v1, v2, uint32((func() int32 {
  53064 		if *(*int32)(unsafe.Pointer(bp)) < *(*int32)(unsafe.Pointer(bp + 4)) {
  53065 			return *(*int32)(unsafe.Pointer(bp))
  53066 		}
  53067 		return *(*int32)(unsafe.Pointer(bp + 4))
  53068 	}()-13)/2))
  53069 	if res == 0 {
  53070 		res = *(*int32)(unsafe.Pointer(bp)) - *(*int32)(unsafe.Pointer(bp + 4))
  53071 	}
  53072 
  53073 	if res == 0 {
  53074 		if int32((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField) > 1 {
  53075 			res = vdbeSorterCompareTail(tls,
  53076 				pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2)
  53077 		}
  53078 	} else {
  53079 		if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 {
  53080 			res = res * -1
  53081 		}
  53082 	}
  53083 
  53084 	return res
  53085 }
  53086 
  53087 func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) int32 {
  53088 	var p1 uintptr = pKey1
  53089 	var p2 uintptr = pKey2
  53090 	var s1 int32 = int32(*(*U8)(unsafe.Pointer(p1 + 1)))
  53091 	var s2 int32 = int32(*(*U8)(unsafe.Pointer(p2 + 1)))
  53092 	var v1 uintptr = p1 + uintptr(*(*U8)(unsafe.Pointer(p1)))
  53093 	var v2 uintptr = p2 + uintptr(*(*U8)(unsafe.Pointer(p2)))
  53094 	var res int32
  53095 
  53096 	if s1 == s2 {
  53097 		var n U8 = aLen[s1]
  53098 		var i int32
  53099 		res = 0
  53100 		for i = 0; i < int32(n); i++ {
  53101 			if libc.AssignInt32(&res, int32(*(*U8)(unsafe.Pointer(v1 + uintptr(i))))-int32(*(*U8)(unsafe.Pointer(v2 + uintptr(i))))) != 0 {
  53102 				if (int32(*(*U8)(unsafe.Pointer(v1)))^int32(*(*U8)(unsafe.Pointer(v2))))&0x80 != 0 {
  53103 					if int32(*(*U8)(unsafe.Pointer(v1)))&0x80 != 0 {
  53104 						res = -1
  53105 					} else {
  53106 						res = +1
  53107 					}
  53108 				}
  53109 				break
  53110 			}
  53111 		}
  53112 	} else if s1 > 7 && s2 > 7 {
  53113 		res = s1 - s2
  53114 	} else {
  53115 		if s2 > 7 {
  53116 			res = +1
  53117 		} else if s1 > 7 {
  53118 			res = -1
  53119 		} else {
  53120 			res = s1 - s2
  53121 		}
  53122 
  53123 		if res > 0 {
  53124 			if int32(*(*U8)(unsafe.Pointer(v1)))&0x80 != 0 {
  53125 				res = -1
  53126 			}
  53127 		} else {
  53128 			if int32(*(*U8)(unsafe.Pointer(v2)))&0x80 != 0 {
  53129 				res = +1
  53130 			}
  53131 		}
  53132 	}
  53133 
  53134 	if res == 0 {
  53135 		if int32((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField) > 1 {
  53136 			res = vdbeSorterCompareTail(tls,
  53137 				pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2)
  53138 		}
  53139 	} else if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 {
  53140 		res = res * -1
  53141 	}
  53142 
  53143 	return res
  53144 }
  53145 
  53146 var aLen = [10]U8{U8(0), U8(1), U8(2), U8(3), U8(4), U8(6), U8(8), U8(0), U8(0), U8(0)}
  53147 
  53148 // Initialize the temporary index cursor just opened as a sorter cursor.
  53149 //
  53150 // Usually, the sorter module uses the value of (pCsr->pKeyInfo->nKeyField)
  53151 // to determine the number of fields that should be compared from the
  53152 // records being sorted. However, if the value passed as argument nField
  53153 // is non-zero and the sorter is able to guarantee a stable sort, nField
  53154 // is used instead. This is used when sorting records for a CREATE INDEX
  53155 // statement. In this case, keys are always delivered to the sorter in
  53156 // order of the primary key, which happens to be make up the final part
  53157 // of the records being sorted. So if the sort is stable, there is never
  53158 // any reason to compare PK fields and they can be ignored for a small
  53159 // performance boost.
  53160 //
  53161 // The sorter can guarantee a stable sort when running in single-threaded
  53162 // mode, but not in multi-threaded mode.
  53163 //
  53164 // SQLITE_OK is returned if successful, or an SQLite error code otherwise.
  53165 func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintptr) int32 {
  53166 	var pgsz int32
  53167 	var i int32
  53168 	var pSorter uintptr
  53169 	var pKeyInfo uintptr
  53170 	var szKeyInfo int32
  53171 	var sz int32
  53172 	var rc int32 = SQLITE_OK
  53173 	var nWorker int32
  53174 
  53175 	if Xsqlite3TempInMemory(tls, db) != 0 || int32(Xsqlite3Config.FbCoreMutex) == 0 {
  53176 		nWorker = 0
  53177 	} else {
  53178 		nWorker = *(*int32)(unsafe.Pointer(db + 120 + 11*4))
  53179 	}
  53180 
  53181 	szKeyInfo = int32(uint32(unsafe.Sizeof(KeyInfo{})) + uint32(int32((*KeyInfo)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo)).FnKeyField)-1)*uint32(unsafe.Sizeof(uintptr(0))))
  53182 	sz = int32(uint32(unsafe.Sizeof(VdbeSorter{})) + uint32(nWorker)*uint32(unsafe.Sizeof(SortSubtask{})))
  53183 
  53184 	pSorter = Xsqlite3DbMallocZero(tls, db, uint64(sz+szKeyInfo))
  53185 	*(*uintptr)(unsafe.Pointer(pCsr + 36)) = pSorter
  53186 	if pSorter == uintptr(0) {
  53187 		rc = SQLITE_NOMEM
  53188 	} else {
  53189 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt
  53190 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FpKeyInfo = libc.AssignUintptr(&pKeyInfo, pSorter+uintptr(sz))
  53191 		libc.Xmemcpy(tls, pKeyInfo, (*VdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo, uint32(szKeyInfo))
  53192 		(*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb = uintptr(0)
  53193 		if nField != 0 && nWorker == 0 {
  53194 			(*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField = U16(nField)
  53195 		}
  53196 		Xsqlite3BtreeEnter(tls, pBt)
  53197 		(*VdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = libc.AssignInt32(&pgsz, Xsqlite3BtreeGetPageSize(tls, pBt))
  53198 		Xsqlite3BtreeLeave(tls, pBt)
  53199 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask = U8(nWorker + 1)
  53200 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = U8(nWorker - 1)
  53201 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads = U8(libc.Bool32(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > 1))
  53202 		(*VdbeSorter)(unsafe.Pointer(pSorter)).Fdb = db
  53203 		for i = 0; i < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask); i++ {
  53204 			var pTask uintptr = pSorter + 64 + uintptr(i)*72
  53205 			(*SortSubtask)(unsafe.Pointer(pTask)).FpSorter = pSorter
  53206 		}
  53207 
  53208 		if !(Xsqlite3TempInMemory(tls, db) != 0) {
  53209 			var mxCache I64
  53210 			var szPma U32 = Xsqlite3Config.FszPma
  53211 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize = int32(szPma * U32(pgsz))
  53212 
  53213 			mxCache = I64((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fcache_size)
  53214 			if mxCache < int64(0) {
  53215 				mxCache = mxCache * int64(-1024)
  53216 			} else {
  53217 				mxCache = mxCache * I64(pgsz)
  53218 			}
  53219 			mxCache = func() int64 {
  53220 				if mxCache < int64(int32(1)<<29) {
  53221 					return mxCache
  53222 				}
  53223 				return int64(int32(1) << 29)
  53224 			}()
  53225 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize = func() int32 {
  53226 				if (*VdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize > int32(mxCache) {
  53227 					return (*VdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize
  53228 				}
  53229 				return int32(mxCache)
  53230 			}()
  53231 
  53232 			if int32(Xsqlite3Config.FbSmallMalloc) == 0 {
  53233 				(*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = pgsz
  53234 				(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = Xsqlite3Malloc(tls, uint64(pgsz))
  53235 				if !(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) != 0) {
  53236 					rc = SQLITE_NOMEM
  53237 				}
  53238 			}
  53239 		}
  53240 
  53241 		if int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) < 13 &&
  53242 			(*(*uintptr)(unsafe.Pointer(pKeyInfo + 20)) == uintptr(0) || *(*uintptr)(unsafe.Pointer(pKeyInfo + 20)) == (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl) &&
  53243 			int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)))&KEYINFO_ORDER_BIGNULL == 0 {
  53244 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = U8(SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT)
  53245 		}
  53246 	}
  53247 
  53248 	return rc
  53249 }
  53250 
  53251 func vdbeSorterRecordFree(tls *libc.TLS, db uintptr, pRecord uintptr) {
  53252 	var p uintptr
  53253 	var pNext uintptr
  53254 	for p = pRecord; p != 0; p = pNext {
  53255 		pNext = *(*uintptr)(unsafe.Pointer(p + 4))
  53256 		Xsqlite3DbFree(tls, db, p)
  53257 	}
  53258 }
  53259 
  53260 func vdbeSortSubtaskCleanup(tls *libc.TLS, db uintptr, pTask uintptr) {
  53261 	Xsqlite3DbFree(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)
  53262 
  53263 	if (*SortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory != 0 {
  53264 		Xsqlite3_free(tls, (*SortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory)
  53265 	} else {
  53266 		vdbeSorterRecordFree(tls, uintptr(0), (*SortSubtask)(unsafe.Pointer(pTask)).Flist.FpList)
  53267 	}
  53268 	if (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd != 0 {
  53269 		Xsqlite3OsCloseFree(tls, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd)
  53270 	}
  53271 	if (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd != 0 {
  53272 		Xsqlite3OsCloseFree(tls, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd)
  53273 	}
  53274 	libc.Xmemset(tls, pTask, 0, uint32(unsafe.Sizeof(SortSubtask{})))
  53275 }
  53276 
  53277 func vdbeSorterJoinThread(tls *libc.TLS, pTask uintptr) int32 {
  53278 	bp := tls.Alloc(4)
  53279 	defer tls.Free(4)
  53280 
  53281 	var rc int32 = SQLITE_OK
  53282 	if (*SortSubtask)(unsafe.Pointer(pTask)).FpThread != 0 {
  53283 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(SQLITE_ERROR)
  53284 
  53285 		Xsqlite3ThreadJoin(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FpThread, bp)
  53286 
  53287 		rc = int32(*(*uintptr)(unsafe.Pointer(bp)))
  53288 
  53289 		(*SortSubtask)(unsafe.Pointer(pTask)).FbDone = 0
  53290 		(*SortSubtask)(unsafe.Pointer(pTask)).FpThread = uintptr(0)
  53291 	}
  53292 	return rc
  53293 }
  53294 
  53295 func vdbeSorterCreateThread(tls *libc.TLS, pTask uintptr, xTask uintptr, pIn uintptr) int32 {
  53296 	return Xsqlite3ThreadCreate(tls, pTask, xTask, pIn)
  53297 }
  53298 
  53299 func vdbeSorterJoinAll(tls *libc.TLS, pSorter uintptr, rcin int32) int32 {
  53300 	var rc int32 = rcin
  53301 	var i int32
  53302 
  53303 	for i = int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1; i >= 0; i-- {
  53304 		var pTask uintptr = pSorter + 64 + uintptr(i)*72
  53305 		var rc2 int32 = vdbeSorterJoinThread(tls, pTask)
  53306 		if rc == SQLITE_OK {
  53307 			rc = rc2
  53308 		}
  53309 	}
  53310 	return rc
  53311 }
  53312 
  53313 func vdbeMergeEngineNew(tls *libc.TLS, nReader int32) uintptr {
  53314 	var N int32 = 2
  53315 	var nByte int32
  53316 	var pNew uintptr
  53317 
  53318 	for N < nReader {
  53319 		N = N + N
  53320 	}
  53321 	nByte = int32(uint32(unsafe.Sizeof(MergeEngine{})) + uint32(N)*(uint32(unsafe.Sizeof(int32(0)))+uint32(unsafe.Sizeof(PmaReader{}))))
  53322 
  53323 	if Xsqlite3FaultSim(tls, 100) != 0 {
  53324 		pNew = uintptr(0)
  53325 	} else {
  53326 		pNew = Xsqlite3MallocZero(tls, uint64(nByte))
  53327 	}
  53328 	if pNew != 0 {
  53329 		(*MergeEngine)(unsafe.Pointer(pNew)).FnTree = N
  53330 		(*MergeEngine)(unsafe.Pointer(pNew)).FpTask = uintptr(0)
  53331 		(*MergeEngine)(unsafe.Pointer(pNew)).FaReadr = pNew + 1*16
  53332 		(*MergeEngine)(unsafe.Pointer(pNew)).FaTree = (*MergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(N)*56
  53333 	}
  53334 	return pNew
  53335 }
  53336 
  53337 func vdbeMergeEngineFree(tls *libc.TLS, pMerger uintptr) {
  53338 	var i int32
  53339 	if pMerger != 0 {
  53340 		for i = 0; i < (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree; i++ {
  53341 			vdbePmaReaderClear(tls, (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(i)*56)
  53342 		}
  53343 	}
  53344 	Xsqlite3_free(tls, pMerger)
  53345 }
  53346 
  53347 func vdbeIncrFree(tls *libc.TLS, pIncr uintptr) {
  53348 	if pIncr != 0 {
  53349 		if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 {
  53350 			vdbeSorterJoinThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask)
  53351 			if (*SorterFile)(unsafe.Pointer(pIncr+32)).FpFd != 0 {
  53352 				Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer(pIncr+32)).FpFd)
  53353 			}
  53354 			if (*SorterFile)(unsafe.Pointer(pIncr+32+1*16)).FpFd != 0 {
  53355 				Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer(pIncr+32+1*16)).FpFd)
  53356 			}
  53357 		}
  53358 		vdbeMergeEngineFree(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger)
  53359 		Xsqlite3_free(tls, pIncr)
  53360 	}
  53361 }
  53362 
  53363 // Reset a sorting cursor back to its original empty state.
  53364 func Xsqlite3VdbeSorterReset(tls *libc.TLS, db uintptr, pSorter uintptr) {
  53365 	var i int32
  53366 	vdbeSorterJoinAll(tls, pSorter, SQLITE_OK)
  53367 
  53368 	if (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader != 0 {
  53369 		vdbePmaReaderClear(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)
  53370 		Xsqlite3DbFree(tls, db, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)
  53371 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader = uintptr(0)
  53372 	}
  53373 	vdbeMergeEngineFree(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)
  53374 	(*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger = uintptr(0)
  53375 	for i = 0; i < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask); i++ {
  53376 		var pTask uintptr = pSorter + 64 + uintptr(i)*72
  53377 		vdbeSortSubtaskCleanup(tls, db, pTask)
  53378 		(*SortSubtask)(unsafe.Pointer(pTask)).FpSorter = pSorter
  53379 	}
  53380 	if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory == uintptr(0) {
  53381 		vdbeSorterRecordFree(tls, uintptr(0), (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList)
  53382 	}
  53383 	(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = uintptr(0)
  53384 	(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0
  53385 	(*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA = U8(0)
  53386 	(*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory = 0
  53387 	(*VdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize = 0
  53388 	Xsqlite3DbFree(tls, db, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked)
  53389 	(*VdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked = uintptr(0)
  53390 }
  53391 
  53392 // Free any cursor components allocated by sqlite3VdbeSorterXXX routines.
  53393 func Xsqlite3VdbeSorterClose(tls *libc.TLS, db uintptr, pCsr uintptr) {
  53394 	var pSorter uintptr
  53395 
  53396 	pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 36))
  53397 	if pSorter != 0 {
  53398 		Xsqlite3VdbeSorterReset(tls, db, pSorter)
  53399 		Xsqlite3_free(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)
  53400 		Xsqlite3DbFree(tls, db, pSorter)
  53401 		*(*uintptr)(unsafe.Pointer(pCsr + 36)) = uintptr(0)
  53402 	}
  53403 }
  53404 
  53405 func vdbeSorterExtendFile(tls *libc.TLS, db uintptr, pFd uintptr, nByte I64) {
  53406 	bp := tls.Alloc(20)
  53407 	defer tls.Free(20)
  53408 	*(*I64)(unsafe.Pointer(bp + 8)) = nByte
  53409 
  53410 	if *(*I64)(unsafe.Pointer(bp + 8)) <= I64((*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap) && (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= 3 {
  53411 		*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
  53412 		*(*int32)(unsafe.Pointer(bp)) = 4 * 1024
  53413 		Xsqlite3OsFileControlHint(tls, pFd, SQLITE_FCNTL_CHUNK_SIZE, bp)
  53414 		Xsqlite3OsFileControlHint(tls, pFd, SQLITE_FCNTL_SIZE_HINT, bp+8)
  53415 		Xsqlite3OsFetch(tls, pFd, int64(0), int32(*(*I64)(unsafe.Pointer(bp + 8))), bp+16)
  53416 		if *(*uintptr)(unsafe.Pointer(bp + 16)) != 0 {
  53417 			Xsqlite3OsUnfetch(tls, pFd, int64(0), *(*uintptr)(unsafe.Pointer(bp + 16)))
  53418 		}
  53419 	}
  53420 }
  53421 
  53422 func vdbeSorterOpenTempFile(tls *libc.TLS, db uintptr, nExtend I64, ppFd uintptr) int32 {
  53423 	bp := tls.Alloc(16)
  53424 	defer tls.Free(16)
  53425 
  53426 	if Xsqlite3FaultSim(tls, 202) != 0 {
  53427 		return SQLITE_IOERR | int32(13)<<8
  53428 	}
  53429 	*(*int32)(unsafe.Pointer(bp)) = Xsqlite3OsOpenMalloc(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), ppFd,
  53430 		SQLITE_OPEN_TEMP_JOURNAL|SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_DELETEONCLOSE, bp)
  53431 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
  53432 		*(*I64)(unsafe.Pointer(bp + 8)) = int64(SQLITE_MAX_MMAP_SIZE)
  53433 		Xsqlite3OsFileControlHint(tls, *(*uintptr)(unsafe.Pointer(ppFd)), SQLITE_FCNTL_MMAP_SIZE, bp+8)
  53434 		if nExtend > int64(0) {
  53435 			vdbeSorterExtendFile(tls, db, *(*uintptr)(unsafe.Pointer(ppFd)), nExtend)
  53436 		}
  53437 	}
  53438 	return *(*int32)(unsafe.Pointer(bp))
  53439 }
  53440 
  53441 func vdbeSortAllocUnpacked(tls *libc.TLS, pTask uintptr) int32 {
  53442 	if (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) {
  53443 		(*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked = Xsqlite3VdbeAllocUnpackedRecord(tls, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)
  53444 		if (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) {
  53445 			return SQLITE_NOMEM
  53446 		}
  53447 		(*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FnField = (*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField
  53448 		(*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode = U8(0)
  53449 	}
  53450 	return SQLITE_OK
  53451 }
  53452 
  53453 func vdbeSorterMerge(tls *libc.TLS, pTask uintptr, p1 uintptr, p2 uintptr) uintptr {
  53454 	bp := tls.Alloc(8)
  53455 	defer tls.Free(8)
  53456 
  53457 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  53458 	var pp uintptr = bp
  53459 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
  53460 
  53461 	for {
  53462 		var res int32
  53463 		res = (*struct {
  53464 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32
  53465 		})(unsafe.Pointer(&struct{ uintptr }{(*SortSubtask)(unsafe.Pointer(pTask)).FxCompare})).f(tls,
  53466 			pTask, bp+4, p1+uintptr(1)*8, (*SorterRecord)(unsafe.Pointer(p1)).FnVal, p2+uintptr(1)*8, (*SorterRecord)(unsafe.Pointer(p2)).FnVal)
  53467 
  53468 		if res <= 0 {
  53469 			*(*uintptr)(unsafe.Pointer(pp)) = p1
  53470 			pp = p1 + 4
  53471 			p1 = *(*uintptr)(unsafe.Pointer(p1 + 4))
  53472 			if p1 == uintptr(0) {
  53473 				*(*uintptr)(unsafe.Pointer(pp)) = p2
  53474 				break
  53475 			}
  53476 		} else {
  53477 			*(*uintptr)(unsafe.Pointer(pp)) = p2
  53478 			pp = p2 + 4
  53479 			p2 = *(*uintptr)(unsafe.Pointer(p2 + 4))
  53480 			*(*int32)(unsafe.Pointer(bp + 4)) = 0
  53481 			if p2 == uintptr(0) {
  53482 				*(*uintptr)(unsafe.Pointer(pp)) = p1
  53483 				break
  53484 			}
  53485 		}
  53486 	}
  53487 	return *(*uintptr)(unsafe.Pointer(bp))
  53488 }
  53489 
  53490 func vdbeSorterGetCompare(tls *libc.TLS, p uintptr) SorterCompare {
  53491 	if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == SORTER_TYPE_INTEGER {
  53492 		return *(*uintptr)(unsafe.Pointer(&struct {
  53493 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32
  53494 		}{vdbeSorterCompareInt}))
  53495 	} else if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == SORTER_TYPE_TEXT {
  53496 		return *(*uintptr)(unsafe.Pointer(&struct {
  53497 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32
  53498 		}{vdbeSorterCompareText}))
  53499 	}
  53500 	return *(*uintptr)(unsafe.Pointer(&struct {
  53501 		f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32
  53502 	}{vdbeSorterCompare}))
  53503 }
  53504 
  53505 func vdbeSorterSort(tls *libc.TLS, pTask uintptr, pList uintptr) int32 {
  53506 	bp := tls.Alloc(256)
  53507 	defer tls.Free(256)
  53508 
  53509 	var i int32
  53510 	var p uintptr
  53511 	var rc int32
  53512 
  53513 	rc = vdbeSortAllocUnpacked(tls, pTask)
  53514 	if rc != SQLITE_OK {
  53515 		return rc
  53516 	}
  53517 
  53518 	p = (*SorterList)(unsafe.Pointer(pList)).FpList
  53519 	(*SortSubtask)(unsafe.Pointer(pTask)).FxCompare = vdbeSorterGetCompare(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)
  53520 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([64]uintptr{})))
  53521 
  53522 	for p != 0 {
  53523 		var pNext uintptr
  53524 		if (*SorterList)(unsafe.Pointer(pList)).FaMemory != 0 {
  53525 			if p == (*SorterList)(unsafe.Pointer(pList)).FaMemory {
  53526 				pNext = uintptr(0)
  53527 			} else {
  53528 				pNext = (*SorterList)(unsafe.Pointer(pList)).FaMemory + uintptr(*(*int32)(unsafe.Pointer(p + 4)))
  53529 			}
  53530 		} else {
  53531 			pNext = *(*uintptr)(unsafe.Pointer(p + 4))
  53532 		}
  53533 
  53534 		*(*uintptr)(unsafe.Pointer(p + 4)) = uintptr(0)
  53535 		for i = 0; *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) != 0; i++ {
  53536 			p = vdbeSorterMerge(tls, pTask, p, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)))
  53537 			*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = uintptr(0)
  53538 		}
  53539 		*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = p
  53540 		p = pNext
  53541 	}
  53542 
  53543 	p = uintptr(0)
  53544 	for i = 0; i < int32(uint32(unsafe.Sizeof([64]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))); i++ {
  53545 		if *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) == uintptr(0) {
  53546 			continue
  53547 		}
  53548 		if p != 0 {
  53549 			p = vdbeSorterMerge(tls, pTask, p, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)))
  53550 		} else {
  53551 			p = *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4))
  53552 		}
  53553 	}
  53554 	(*SorterList)(unsafe.Pointer(pList)).FpList = p
  53555 
  53556 	return int32((*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode)
  53557 }
  53558 
  53559 func vdbePmaWriterInit(tls *libc.TLS, pFd uintptr, p uintptr, nBuf int32, iStart I64) {
  53560 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(PmaWriter{})))
  53561 	(*PmaWriter)(unsafe.Pointer(p)).FaBuffer = Xsqlite3Malloc(tls, uint64(nBuf))
  53562 	if !(int32((*PmaWriter)(unsafe.Pointer(p)).FaBuffer) != 0) {
  53563 		(*PmaWriter)(unsafe.Pointer(p)).FeFWErr = SQLITE_NOMEM
  53564 	} else {
  53565 		(*PmaWriter)(unsafe.Pointer(p)).FiBufEnd = libc.AssignPtrInt32(p+12, int32(iStart%I64(nBuf)))
  53566 		(*PmaWriter)(unsafe.Pointer(p)).FiWriteOff = iStart - I64((*PmaWriter)(unsafe.Pointer(p)).FiBufStart)
  53567 		(*PmaWriter)(unsafe.Pointer(p)).FnBuffer = nBuf
  53568 		(*PmaWriter)(unsafe.Pointer(p)).FpFd = pFd
  53569 	}
  53570 }
  53571 
  53572 func vdbePmaWriteBlob(tls *libc.TLS, p uintptr, pData uintptr, nData int32) {
  53573 	var nRem int32 = nData
  53574 	for nRem > 0 && (*PmaWriter)(unsafe.Pointer(p)).FeFWErr == 0 {
  53575 		var nCopy int32 = nRem
  53576 		if nCopy > (*PmaWriter)(unsafe.Pointer(p)).FnBuffer-(*PmaWriter)(unsafe.Pointer(p)).FiBufEnd {
  53577 			nCopy = (*PmaWriter)(unsafe.Pointer(p)).FnBuffer - (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd
  53578 		}
  53579 
  53580 		libc.Xmemcpy(tls, (*PmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*PmaWriter)(unsafe.Pointer(p)).FiBufEnd), pData+uintptr(nData-nRem), uint32(nCopy))
  53581 		*(*int32)(unsafe.Pointer(p + 16)) += nCopy
  53582 		if (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd == (*PmaWriter)(unsafe.Pointer(p)).FnBuffer {
  53583 			(*PmaWriter)(unsafe.Pointer(p)).FeFWErr = Xsqlite3OsWrite(tls, (*PmaWriter)(unsafe.Pointer(p)).FpFd,
  53584 				(*PmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*PmaWriter)(unsafe.Pointer(p)).FiBufStart), (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd-(*PmaWriter)(unsafe.Pointer(p)).FiBufStart,
  53585 				(*PmaWriter)(unsafe.Pointer(p)).FiWriteOff+I64((*PmaWriter)(unsafe.Pointer(p)).FiBufStart))
  53586 			(*PmaWriter)(unsafe.Pointer(p)).FiBufStart = libc.AssignPtrInt32(p+16, 0)
  53587 			*(*I64)(unsafe.Pointer(p + 24)) += I64((*PmaWriter)(unsafe.Pointer(p)).FnBuffer)
  53588 		}
  53589 
  53590 		nRem = nRem - nCopy
  53591 	}
  53592 }
  53593 
  53594 func vdbePmaWriterFinish(tls *libc.TLS, p uintptr, piEof uintptr) int32 {
  53595 	var rc int32
  53596 	if (*PmaWriter)(unsafe.Pointer(p)).FeFWErr == 0 && (*PmaWriter)(unsafe.Pointer(p)).FaBuffer != 0 && (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd > (*PmaWriter)(unsafe.Pointer(p)).FiBufStart {
  53597 		(*PmaWriter)(unsafe.Pointer(p)).FeFWErr = Xsqlite3OsWrite(tls, (*PmaWriter)(unsafe.Pointer(p)).FpFd,
  53598 			(*PmaWriter)(unsafe.Pointer(p)).FaBuffer+uintptr((*PmaWriter)(unsafe.Pointer(p)).FiBufStart), (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd-(*PmaWriter)(unsafe.Pointer(p)).FiBufStart,
  53599 			(*PmaWriter)(unsafe.Pointer(p)).FiWriteOff+I64((*PmaWriter)(unsafe.Pointer(p)).FiBufStart))
  53600 	}
  53601 	*(*I64)(unsafe.Pointer(piEof)) = (*PmaWriter)(unsafe.Pointer(p)).FiWriteOff + I64((*PmaWriter)(unsafe.Pointer(p)).FiBufEnd)
  53602 	Xsqlite3_free(tls, (*PmaWriter)(unsafe.Pointer(p)).FaBuffer)
  53603 	rc = (*PmaWriter)(unsafe.Pointer(p)).FeFWErr
  53604 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(PmaWriter{})))
  53605 	return rc
  53606 }
  53607 
  53608 func vdbePmaWriteVarint(tls *libc.TLS, p uintptr, iVal U64) {
  53609 	bp := tls.Alloc(10)
  53610 	defer tls.Free(10)
  53611 
  53612 	var nByte int32
  53613 
  53614 	nByte = Xsqlite3PutVarint(tls, bp, iVal)
  53615 	vdbePmaWriteBlob(tls, p, bp, nByte)
  53616 }
  53617 
  53618 func vdbeSorterListToPMA(tls *libc.TLS, pTask uintptr, pList uintptr) int32 {
  53619 	bp := tls.Alloc(40)
  53620 	defer tls.Free(40)
  53621 
  53622 	var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb
  53623 	var rc int32 = SQLITE_OK
  53624 
  53625 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(PmaWriter{})))
  53626 
  53627 	if (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd == uintptr(0) {
  53628 		rc = vdbeSorterOpenTempFile(tls, db, int64(0), pTask+40)
  53629 
  53630 	}
  53631 
  53632 	if rc == SQLITE_OK {
  53633 		vdbeSorterExtendFile(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FiEof+I64((*SorterList)(unsafe.Pointer(pList)).FszPMA)+int64(9))
  53634 	}
  53635 
  53636 	if rc == SQLITE_OK {
  53637 		rc = vdbeSorterSort(tls, pTask, pList)
  53638 	}
  53639 
  53640 	if rc == SQLITE_OK {
  53641 		var p uintptr
  53642 		var pNext uintptr = uintptr(0)
  53643 
  53644 		vdbePmaWriterInit(tls, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd, bp, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz,
  53645 			(*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FiEof)
  53646 		(*SortSubtask)(unsafe.Pointer(pTask)).FnPMA++
  53647 		vdbePmaWriteVarint(tls, bp, uint64((*SorterList)(unsafe.Pointer(pList)).FszPMA))
  53648 		for p = (*SorterList)(unsafe.Pointer(pList)).FpList; p != 0; p = pNext {
  53649 			pNext = *(*uintptr)(unsafe.Pointer(p + 4))
  53650 			vdbePmaWriteVarint(tls, bp, uint64((*SorterRecord)(unsafe.Pointer(p)).FnVal))
  53651 			vdbePmaWriteBlob(tls, bp, p+uintptr(1)*8, (*SorterRecord)(unsafe.Pointer(p)).FnVal)
  53652 			if (*SorterList)(unsafe.Pointer(pList)).FaMemory == uintptr(0) {
  53653 				Xsqlite3_free(tls, p)
  53654 			}
  53655 		}
  53656 		(*SorterList)(unsafe.Pointer(pList)).FpList = p
  53657 		rc = vdbePmaWriterFinish(tls, bp, pTask+40+8)
  53658 	}
  53659 
  53660 	return rc
  53661 }
  53662 
  53663 func vdbeMergeEngineStep(tls *libc.TLS, pMerger uintptr, pbEof uintptr) int32 {
  53664 	bp := tls.Alloc(4)
  53665 	defer tls.Free(4)
  53666 
  53667 	var rc int32
  53668 	var iPrev int32 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4))
  53669 	var pTask uintptr = (*MergeEngine)(unsafe.Pointer(pMerger)).FpTask
  53670 
  53671 	rc = vdbePmaReaderNext(tls, (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(iPrev)*56)
  53672 
  53673 	if rc == SQLITE_OK {
  53674 		var i int32
  53675 		var pReadr1 uintptr
  53676 		var pReadr2 uintptr
  53677 		*(*int32)(unsafe.Pointer(bp)) = 0
  53678 
  53679 		pReadr1 = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(iPrev&0xFFFE)*56
  53680 		pReadr2 = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(iPrev|0x0001)*56
  53681 
  53682 		for i = ((*MergeEngine)(unsafe.Pointer(pMerger)).FnTree + iPrev) / 2; i > 0; i = i / 2 {
  53683 			var iRes int32
  53684 			if (*PmaReader)(unsafe.Pointer(pReadr1)).FpFd == uintptr(0) {
  53685 				iRes = +1
  53686 			} else if (*PmaReader)(unsafe.Pointer(pReadr2)).FpFd == uintptr(0) {
  53687 				iRes = -1
  53688 			} else {
  53689 				iRes = (*struct {
  53690 					f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32
  53691 				})(unsafe.Pointer(&struct{ uintptr }{(*SortSubtask)(unsafe.Pointer(pTask)).FxCompare})).f(tls, pTask, bp,
  53692 					(*PmaReader)(unsafe.Pointer(pReadr1)).FaKey, (*PmaReader)(unsafe.Pointer(pReadr1)).FnKey, (*PmaReader)(unsafe.Pointer(pReadr2)).FaKey, (*PmaReader)(unsafe.Pointer(pReadr2)).FnKey)
  53693 			}
  53694 
  53695 			if iRes < 0 || iRes == 0 && pReadr1 < pReadr2 {
  53696 				*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(i)*4)) = (int32(pReadr1) - int32((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr)) / 56
  53697 				pReadr2 = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(i^0x0001)*4)))*56
  53698 				*(*int32)(unsafe.Pointer(bp)) = 0
  53699 			} else {
  53700 				if (*PmaReader)(unsafe.Pointer(pReadr1)).FpFd != 0 {
  53701 					*(*int32)(unsafe.Pointer(bp)) = 0
  53702 				}
  53703 				*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(i)*4)) = (int32(pReadr2) - int32((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr)) / 56
  53704 				pReadr1 = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(i^0x0001)*4)))*56
  53705 			}
  53706 		}
  53707 		*(*int32)(unsafe.Pointer(pbEof)) = libc.Bool32((*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*56)).FpFd == uintptr(0))
  53708 	}
  53709 
  53710 	return func() int32 {
  53711 		if rc == SQLITE_OK {
  53712 			return int32((*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode)
  53713 		}
  53714 		return rc
  53715 	}()
  53716 }
  53717 
  53718 func vdbeSorterFlushThread(tls *libc.TLS, pCtx uintptr) uintptr {
  53719 	var pTask uintptr = pCtx
  53720 	var rc int32
  53721 
  53722 	rc = vdbeSorterListToPMA(tls, pTask, pTask+16)
  53723 	(*SortSubtask)(unsafe.Pointer(pTask)).FbDone = 1
  53724 	return uintptr(rc)
  53725 }
  53726 
  53727 func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 {
  53728 	var rc int32 = SQLITE_OK
  53729 	var i int32
  53730 	var pTask uintptr = uintptr(0)
  53731 	var nWorker int32 = int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1
  53732 
  53733 	(*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA = U8(1)
  53734 
  53735 	for i = 0; i < nWorker; i++ {
  53736 		var iTest int32 = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FiPrev) + i + 1) % nWorker
  53737 		pTask = pSorter + 64 + uintptr(iTest)*72
  53738 		if (*SortSubtask)(unsafe.Pointer(pTask)).FbDone != 0 {
  53739 			rc = vdbeSorterJoinThread(tls, pTask)
  53740 		}
  53741 		if rc != SQLITE_OK || (*SortSubtask)(unsafe.Pointer(pTask)).FpThread == uintptr(0) {
  53742 			break
  53743 		}
  53744 	}
  53745 
  53746 	if rc == SQLITE_OK {
  53747 		if i == nWorker {
  53748 			rc = vdbeSorterListToPMA(tls, pSorter+64+uintptr(nWorker)*72, pSorter+36)
  53749 		} else {
  53750 			var aMem uintptr
  53751 			var pCtx uintptr
  53752 
  53753 			aMem = (*SortSubtask)(unsafe.Pointer(pTask)).Flist.FaMemory
  53754 			pCtx = pTask
  53755 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = U8(int32((pTask - (pSorter + 64)) / 72))
  53756 			(*SortSubtask)(unsafe.Pointer(pTask)).Flist = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist
  53757 			(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = uintptr(0)
  53758 			(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0
  53759 			if aMem != 0 {
  53760 				(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = aMem
  53761 				(*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = Xsqlite3MallocSize(tls, aMem)
  53762 			} else if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 {
  53763 				(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = Xsqlite3Malloc(tls, uint64((*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory))
  53764 				if !(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) != 0) {
  53765 					return SQLITE_NOMEM
  53766 				}
  53767 			}
  53768 
  53769 			rc = vdbeSorterCreateThread(tls, pTask, *(*uintptr)(unsafe.Pointer(&struct {
  53770 				f func(*libc.TLS, uintptr) uintptr
  53771 			}{vdbeSorterFlushThread})), pCtx)
  53772 		}
  53773 	}
  53774 
  53775 	return rc
  53776 }
  53777 
  53778 // Add a record to the sorter.
  53779 func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 {
  53780 	bp := tls.Alloc(4)
  53781 	defer tls.Free(4)
  53782 
  53783 	var pSorter uintptr
  53784 	var rc int32 = SQLITE_OK
  53785 	var pNew uintptr
  53786 	var bFlush int32
  53787 	var nReq int32
  53788 	var nPMA int32
  53789 
  53790 	pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 36))
  53791 	*(*int32)(unsafe.Pointer(bp)) = int32(U32(*(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pVal)).Fz + 1))))
  53792 	if *(*int32)(unsafe.Pointer(bp)) >= 0x80 {
  53793 		Xsqlite3GetVarint32(tls, (*Mem)(unsafe.Pointer(pVal)).Fz+1, bp)
  53794 	}
  53795 	if *(*int32)(unsafe.Pointer(bp)) > 0 && *(*int32)(unsafe.Pointer(bp)) < 10 && *(*int32)(unsafe.Pointer(bp)) != 7 {
  53796 		*(*U8)(unsafe.Pointer(pSorter + 60)) &= U8(SORTER_TYPE_INTEGER)
  53797 	} else if *(*int32)(unsafe.Pointer(bp)) > 10 && *(*int32)(unsafe.Pointer(bp))&0x01 != 0 {
  53798 		*(*U8)(unsafe.Pointer(pSorter + 60)) &= U8(SORTER_TYPE_TEXT)
  53799 	} else {
  53800 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = U8(0)
  53801 	}
  53802 
  53803 	nReq = int32(uint32((*Mem)(unsafe.Pointer(pVal)).Fn) + uint32(unsafe.Sizeof(SorterRecord{})))
  53804 	nPMA = (*Mem)(unsafe.Pointer(pVal)).Fn + Xsqlite3VarintLen(tls, uint64((*Mem)(unsafe.Pointer(pVal)).Fn))
  53805 	if (*VdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize != 0 {
  53806 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 {
  53807 			bFlush = libc.Bool32((*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory != 0 && (*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory+nReq > (*VdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize)
  53808 		} else {
  53809 			bFlush = libc.Bool32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA > (*VdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize ||
  53810 				(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA > (*VdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize && Xsqlite3HeapNearlyFull(tls) != 0)
  53811 		}
  53812 		if bFlush != 0 {
  53813 			rc = vdbeSorterFlushPMA(tls, pSorter)
  53814 			(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FszPMA = 0
  53815 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory = 0
  53816 
  53817 		}
  53818 	}
  53819 
  53820 	*(*int32)(unsafe.Pointer(pSorter + 36 + 8)) += nPMA
  53821 	if nPMA > (*VdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize {
  53822 		(*VdbeSorter)(unsafe.Pointer(pSorter)).FmxKeysize = nPMA
  53823 	}
  53824 
  53825 	if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 {
  53826 		var nMin int32 = (*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory + nReq
  53827 
  53828 		if nMin > (*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory {
  53829 			var aNew uintptr
  53830 			var nNew Sqlite3_int64 = int64(2) * Sqlite3_int64((*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory)
  53831 			var iListOff int32 = -1
  53832 			if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 {
  53833 				iListOff = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) - int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) / 1
  53834 			}
  53835 			for nNew < Sqlite3_int64(nMin) {
  53836 				nNew = nNew * int64(2)
  53837 			}
  53838 			if nNew > Sqlite3_int64((*VdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize) {
  53839 				nNew = Sqlite3_int64((*VdbeSorter)(unsafe.Pointer(pSorter)).FmxPmaSize)
  53840 			}
  53841 			if nNew < Sqlite3_int64(nMin) {
  53842 				nNew = Sqlite3_int64(nMin)
  53843 			}
  53844 			aNew = Xsqlite3Realloc(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory, uint64(nNew))
  53845 			if !(aNew != 0) {
  53846 				return SQLITE_NOMEM
  53847 			}
  53848 			if iListOff >= 0 {
  53849 				(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = aNew + uintptr(iListOff)
  53850 			}
  53851 			(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = aNew
  53852 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = int32(nNew)
  53853 		}
  53854 
  53855 		pNew = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory + uintptr((*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory)
  53856 		*(*int32)(unsafe.Pointer(pSorter + 48)) += (nReq + 7) & libc.CplInt32(7)
  53857 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 {
  53858 			*(*int32)(unsafe.Pointer(pNew + 4)) = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList) - int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) / 1
  53859 		}
  53860 	} else {
  53861 		pNew = Xsqlite3Malloc(tls, uint64(nReq))
  53862 		if pNew == uintptr(0) {
  53863 			return SQLITE_NOMEM
  53864 		}
  53865 		*(*uintptr)(unsafe.Pointer(pNew + 4)) = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList
  53866 	}
  53867 
  53868 	libc.Xmemcpy(tls, pNew+uintptr(1)*8, (*Mem)(unsafe.Pointer(pVal)).Fz, uint32((*Mem)(unsafe.Pointer(pVal)).Fn))
  53869 	(*SorterRecord)(unsafe.Pointer(pNew)).FnVal = (*Mem)(unsafe.Pointer(pVal)).Fn
  53870 	(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = pNew
  53871 
  53872 	return rc
  53873 }
  53874 
  53875 func vdbeIncrPopulate(tls *libc.TLS, pIncr uintptr) int32 {
  53876 	bp := tls.Alloc(44)
  53877 	defer tls.Free(44)
  53878 
  53879 	var rc int32 = SQLITE_OK
  53880 	var rc2 int32
  53881 	var iStart I64 = (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff
  53882 	var pOut uintptr = pIncr + 32 + 1*16
  53883 	var pTask uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask
  53884 	var pMerger uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger
  53885 
  53886 	vdbePmaWriterInit(tls, (*SorterFile)(unsafe.Pointer(pOut)).FpFd, bp, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz, iStart)
  53887 	for rc == SQLITE_OK {
  53888 		var pReader uintptr = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*56
  53889 		var nKey int32 = (*PmaReader)(unsafe.Pointer(pReader)).FnKey
  53890 		var iEof I64 = (*PmaWriter)(unsafe.Pointer(bp)).FiWriteOff + I64((*PmaWriter)(unsafe.Pointer(bp)).FiBufEnd)
  53891 
  53892 		if (*PmaReader)(unsafe.Pointer(pReader)).FpFd == uintptr(0) {
  53893 			break
  53894 		}
  53895 		if iEof+I64(nKey)+I64(Xsqlite3VarintLen(tls, uint64(nKey))) > iStart+I64((*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz) {
  53896 			break
  53897 		}
  53898 
  53899 		vdbePmaWriteVarint(tls, bp, uint64(nKey))
  53900 		vdbePmaWriteBlob(tls, bp, (*PmaReader)(unsafe.Pointer(pReader)).FaKey, nKey)
  53901 
  53902 		rc = vdbeMergeEngineStep(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger, bp+40)
  53903 	}
  53904 
  53905 	rc2 = vdbePmaWriterFinish(tls, bp, pOut+8)
  53906 	if rc == SQLITE_OK {
  53907 		rc = rc2
  53908 	}
  53909 
  53910 	return rc
  53911 }
  53912 
  53913 func vdbeIncrPopulateThread(tls *libc.TLS, pCtx uintptr) uintptr {
  53914 	var pIncr uintptr = pCtx
  53915 	var pRet uintptr = uintptr(vdbeIncrPopulate(tls, pIncr))
  53916 	(*SortSubtask)(unsafe.Pointer((*IncrMerger)(unsafe.Pointer(pIncr)).FpTask)).FbDone = 1
  53917 	return pRet
  53918 }
  53919 
  53920 func vdbeIncrBgPopulate(tls *libc.TLS, pIncr uintptr) int32 {
  53921 	var p uintptr = pIncr
  53922 
  53923 	return vdbeSorterCreateThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, *(*uintptr)(unsafe.Pointer(&struct {
  53924 		f func(*libc.TLS, uintptr) uintptr
  53925 	}{vdbeIncrPopulateThread})), p)
  53926 }
  53927 
  53928 func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 {
  53929 	var rc int32 = SQLITE_OK
  53930 
  53931 	if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 {
  53932 		rc = vdbeSorterJoinThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask)
  53933 
  53934 		if rc == SQLITE_OK {
  53935 			var f0 = *(*SorterFile)(unsafe.Pointer(pIncr + 32))
  53936 			*(*SorterFile)(unsafe.Pointer(pIncr + 32)) = *(*SorterFile)(unsafe.Pointer(pIncr + 32 + 1*16))
  53937 			*(*SorterFile)(unsafe.Pointer(pIncr + 32 + 1*16)) = f0
  53938 		}
  53939 
  53940 		if rc == SQLITE_OK {
  53941 			if (*SorterFile)(unsafe.Pointer(pIncr+32)).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff {
  53942 				(*IncrMerger)(unsafe.Pointer(pIncr)).FbEof = 1
  53943 			} else {
  53944 				rc = vdbeIncrBgPopulate(tls, pIncr)
  53945 			}
  53946 		}
  53947 	} else {
  53948 		rc = vdbeIncrPopulate(tls, pIncr)
  53949 		*(*SorterFile)(unsafe.Pointer(pIncr + 32)) = *(*SorterFile)(unsafe.Pointer(pIncr + 32 + 1*16))
  53950 		if (*SorterFile)(unsafe.Pointer(pIncr+32)).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff {
  53951 			(*IncrMerger)(unsafe.Pointer(pIncr)).FbEof = 1
  53952 		}
  53953 	}
  53954 
  53955 	return rc
  53956 }
  53957 
  53958 func vdbeIncrMergerNew(tls *libc.TLS, pTask uintptr, pMerger uintptr, ppOut uintptr) int32 {
  53959 	var rc int32 = SQLITE_OK
  53960 	var pIncr uintptr = libc.AssignPtrUintptr(ppOut, func() uintptr {
  53961 		if Xsqlite3FaultSim(tls, 100) != 0 {
  53962 			return uintptr(0)
  53963 		}
  53964 		return Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(IncrMerger{})))
  53965 	}())
  53966 	if pIncr != 0 {
  53967 		(*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger = pMerger
  53968 		(*IncrMerger)(unsafe.Pointer(pIncr)).FpTask = pTask
  53969 		(*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz = func() int32 {
  53970 			if (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxKeysize+9 > (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxPmaSize/2 {
  53971 				return (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxKeysize + 9
  53972 			}
  53973 			return (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FmxPmaSize / 2
  53974 		}()
  53975 		*(*I64)(unsafe.Pointer(pTask + 56 + 8)) += I64((*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz)
  53976 	} else {
  53977 		vdbeMergeEngineFree(tls, pMerger)
  53978 		rc = SQLITE_NOMEM
  53979 	}
  53980 
  53981 	return rc
  53982 }
  53983 
  53984 func vdbeIncrMergerSetThreads(tls *libc.TLS, pIncr uintptr) {
  53985 	(*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread = 1
  53986 	*(*I64)(unsafe.Pointer((*IncrMerger)(unsafe.Pointer(pIncr)).FpTask + 56 + 8)) -= I64((*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz)
  53987 }
  53988 
  53989 func vdbeMergeEngineCompare(tls *libc.TLS, pMerger uintptr, iOut int32) {
  53990 	bp := tls.Alloc(4)
  53991 	defer tls.Free(4)
  53992 
  53993 	var i1 int32
  53994 	var i2 int32
  53995 	var iRes int32
  53996 	var p1 uintptr
  53997 	var p2 uintptr
  53998 
  53999 	if iOut >= (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree/2 {
  54000 		i1 = (iOut - (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree/2) * 2
  54001 		i2 = i1 + 1
  54002 	} else {
  54003 		i1 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(iOut*2)*4))
  54004 		i2 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(iOut*2+1)*4))
  54005 	}
  54006 
  54007 	p1 = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i1)*56
  54008 	p2 = (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i2)*56
  54009 
  54010 	if (*PmaReader)(unsafe.Pointer(p1)).FpFd == uintptr(0) {
  54011 		iRes = i2
  54012 	} else if (*PmaReader)(unsafe.Pointer(p2)).FpFd == uintptr(0) {
  54013 		iRes = i1
  54014 	} else {
  54015 		var pTask uintptr = (*MergeEngine)(unsafe.Pointer(pMerger)).FpTask
  54016 		*(*int32)(unsafe.Pointer(bp)) = 0
  54017 		var res int32
  54018 
  54019 		res = (*struct {
  54020 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32
  54021 		})(unsafe.Pointer(&struct{ uintptr }{(*SortSubtask)(unsafe.Pointer(pTask)).FxCompare})).f(tls,
  54022 			pTask, bp, (*PmaReader)(unsafe.Pointer(p1)).FaKey, (*PmaReader)(unsafe.Pointer(p1)).FnKey, (*PmaReader)(unsafe.Pointer(p2)).FaKey, (*PmaReader)(unsafe.Pointer(p2)).FnKey)
  54023 		if res <= 0 {
  54024 			iRes = i1
  54025 		} else {
  54026 			iRes = i2
  54027 		}
  54028 	}
  54029 
  54030 	*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(iOut)*4)) = iRes
  54031 }
  54032 
  54033 func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode int32) int32 {
  54034 	var rc int32 = SQLITE_OK
  54035 	var i int32
  54036 	var nTree int32
  54037 
  54038 	(*MergeEngine)(unsafe.Pointer(pMerger)).FpTask = pTask
  54039 
  54040 	nTree = (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree
  54041 	for i = 0; i < nTree; i++ {
  54042 		if SQLITE_MAX_WORKER_THREADS > 0 && eMode == INCRINIT_ROOT {
  54043 			rc = vdbePmaReaderNext(tls, (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(nTree-i-1)*56)
  54044 		} else {
  54045 			rc = vdbePmaReaderIncrInit(tls, (*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(i)*56, INCRINIT_NORMAL)
  54046 		}
  54047 		if rc != SQLITE_OK {
  54048 			return rc
  54049 		}
  54050 	}
  54051 
  54052 	for i = (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree - 1; i > 0; i-- {
  54053 		vdbeMergeEngineCompare(tls, pMerger, i)
  54054 	}
  54055 	return int32((*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode)
  54056 }
  54057 
  54058 func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int32 {
  54059 	var rc int32 = SQLITE_OK
  54060 	var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr
  54061 	var pTask uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask
  54062 	var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb
  54063 
  54064 	rc = vdbeMergeEngineInit(tls, pTask, (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger, eMode)
  54065 
  54066 	if rc == SQLITE_OK {
  54067 		var mxSz int32 = (*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz
  54068 		if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 {
  54069 			rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), pIncr+32)
  54070 			if rc == SQLITE_OK {
  54071 				rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), pIncr+32+1*16)
  54072 			}
  54073 		} else {
  54074 			if (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd == uintptr(0) {
  54075 				rc = vdbeSorterOpenTempFile(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof, pTask+56)
  54076 				(*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof = int64(0)
  54077 			}
  54078 			if rc == SQLITE_OK {
  54079 				(*SorterFile)(unsafe.Pointer(pIncr + 32 + 1*16)).FpFd = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd
  54080 				(*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof
  54081 				*(*I64)(unsafe.Pointer(pTask + 56 + 8)) += I64(mxSz)
  54082 			}
  54083 		}
  54084 	}
  54085 
  54086 	if rc == SQLITE_OK && (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 {
  54087 		rc = vdbeIncrPopulate(tls, pIncr)
  54088 	}
  54089 
  54090 	if rc == SQLITE_OK && (SQLITE_MAX_WORKER_THREADS == 0 || eMode != INCRINIT_TASK) {
  54091 		rc = vdbePmaReaderNext(tls, pReadr)
  54092 	}
  54093 
  54094 	return rc
  54095 }
  54096 
  54097 func vdbePmaReaderBgIncrInit(tls *libc.TLS, pCtx uintptr) uintptr {
  54098 	var pReader uintptr = pCtx
  54099 	var pRet uintptr = uintptr(vdbePmaReaderIncrMergeInit(tls, pReader, INCRINIT_TASK))
  54100 	(*SortSubtask)(unsafe.Pointer((*IncrMerger)(unsafe.Pointer((*PmaReader)(unsafe.Pointer(pReader)).FpIncr)).FpTask)).FbDone = 1
  54101 	return pRet
  54102 }
  54103 
  54104 func vdbePmaReaderIncrInit(tls *libc.TLS, pReadr uintptr, eMode int32) int32 {
  54105 	var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr
  54106 	var rc int32 = SQLITE_OK
  54107 	if pIncr != 0 {
  54108 		if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 {
  54109 			var pCtx uintptr = pReadr
  54110 			rc = vdbeSorterCreateThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, *(*uintptr)(unsafe.Pointer(&struct {
  54111 				f func(*libc.TLS, uintptr) uintptr
  54112 			}{vdbePmaReaderBgIncrInit})), pCtx)
  54113 		} else {
  54114 			rc = vdbePmaReaderIncrMergeInit(tls, pReadr, eMode)
  54115 		}
  54116 	}
  54117 	return rc
  54118 }
  54119 
  54120 func vdbeMergeEngineLevel0(tls *libc.TLS, pTask uintptr, nPMA int32, piOffset uintptr, ppOut uintptr) int32 {
  54121 	bp := tls.Alloc(8)
  54122 	defer tls.Free(8)
  54123 
  54124 	var pNew uintptr
  54125 	var iOff I64 = *(*I64)(unsafe.Pointer(piOffset))
  54126 	var i int32
  54127 	var rc int32 = SQLITE_OK
  54128 
  54129 	*(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pNew, vdbeMergeEngineNew(tls, nPMA))
  54130 	if pNew == uintptr(0) {
  54131 		rc = SQLITE_NOMEM
  54132 	}
  54133 
  54134 	for i = 0; i < nPMA && rc == SQLITE_OK; i++ {
  54135 		*(*I64)(unsafe.Pointer(bp)) = int64(0)
  54136 		var pReadr uintptr = (*MergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(i)*56
  54137 		rc = vdbePmaReaderInit(tls, pTask, pTask+40, iOff, pReadr, bp)
  54138 		iOff = (*PmaReader)(unsafe.Pointer(pReadr)).FiEof
  54139 	}
  54140 
  54141 	if rc != SQLITE_OK {
  54142 		vdbeMergeEngineFree(tls, pNew)
  54143 		*(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0)
  54144 	}
  54145 	*(*I64)(unsafe.Pointer(piOffset)) = iOff
  54146 	return rc
  54147 }
  54148 
  54149 func vdbeSorterTreeDepth(tls *libc.TLS, nPMA int32) int32 {
  54150 	var nDepth int32 = 0
  54151 	var nDiv I64 = int64(SORTER_MAX_MERGE_COUNT)
  54152 	for nDiv < I64(nPMA) {
  54153 		nDiv = nDiv * int64(SORTER_MAX_MERGE_COUNT)
  54154 		nDepth++
  54155 	}
  54156 	return nDepth
  54157 }
  54158 
  54159 func vdbeSorterAddToTree(tls *libc.TLS, pTask uintptr, nDepth int32, iSeq int32, pRoot uintptr, pLeaf uintptr) int32 {
  54160 	bp := tls.Alloc(4)
  54161 	defer tls.Free(4)
  54162 
  54163 	var rc int32 = SQLITE_OK
  54164 	var nDiv int32 = 1
  54165 	var i int32
  54166 	var p uintptr = pRoot
  54167 
  54168 	rc = vdbeIncrMergerNew(tls, pTask, pLeaf, bp)
  54169 
  54170 	for i = 1; i < nDepth; i++ {
  54171 		nDiv = nDiv * SORTER_MAX_MERGE_COUNT
  54172 	}
  54173 
  54174 	for i = 1; i < nDepth && rc == SQLITE_OK; i++ {
  54175 		var iIter int32 = iSeq / nDiv % SORTER_MAX_MERGE_COUNT
  54176 		var pReadr uintptr = (*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr(iIter)*56
  54177 
  54178 		if (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr == uintptr(0) {
  54179 			var pNew uintptr = vdbeMergeEngineNew(tls, SORTER_MAX_MERGE_COUNT)
  54180 			if pNew == uintptr(0) {
  54181 				rc = SQLITE_NOMEM
  54182 			} else {
  54183 				rc = vdbeIncrMergerNew(tls, pTask, pNew, pReadr+48)
  54184 			}
  54185 		}
  54186 		if rc == SQLITE_OK {
  54187 			p = (*IncrMerger)(unsafe.Pointer((*PmaReader)(unsafe.Pointer(pReadr)).FpIncr)).FpMerger
  54188 			nDiv = nDiv / SORTER_MAX_MERGE_COUNT
  54189 		}
  54190 	}
  54191 
  54192 	if rc == SQLITE_OK {
  54193 		(*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr(iSeq%SORTER_MAX_MERGE_COUNT)*56)).FpIncr = *(*uintptr)(unsafe.Pointer(bp))
  54194 	} else {
  54195 		vdbeIncrFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
  54196 	}
  54197 	return rc
  54198 }
  54199 
  54200 func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int32 {
  54201 	bp := tls.Alloc(16)
  54202 	defer tls.Free(16)
  54203 
  54204 	var pMain uintptr = uintptr(0)
  54205 	var rc int32 = SQLITE_OK
  54206 	var iTask int32
  54207 
  54208 	if int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > 1 {
  54209 		pMain = vdbeMergeEngineNew(tls, int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask))
  54210 		if pMain == uintptr(0) {
  54211 			rc = SQLITE_NOMEM
  54212 		}
  54213 	}
  54214 
  54215 	for iTask = 0; rc == SQLITE_OK && iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask); iTask++ {
  54216 		var pTask uintptr = pSorter + 64 + uintptr(iTask)*72
  54217 
  54218 		if SQLITE_MAX_WORKER_THREADS == 0 || (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA != 0 {
  54219 			*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  54220 			var nDepth int32 = vdbeSorterTreeDepth(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA)
  54221 			*(*I64)(unsafe.Pointer(bp)) = int64(0)
  54222 
  54223 			if (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA <= SORTER_MAX_MERGE_COUNT {
  54224 				rc = vdbeMergeEngineLevel0(tls, pTask, (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA, bp, bp+8)
  54225 			} else {
  54226 				var i int32
  54227 				var iSeq int32 = 0
  54228 				*(*uintptr)(unsafe.Pointer(bp + 8)) = vdbeMergeEngineNew(tls, SORTER_MAX_MERGE_COUNT)
  54229 				if *(*uintptr)(unsafe.Pointer(bp + 8)) == uintptr(0) {
  54230 					rc = SQLITE_NOMEM
  54231 				}
  54232 				for i = 0; i < (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA && rc == SQLITE_OK; i = i + SORTER_MAX_MERGE_COUNT {
  54233 					*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
  54234 					var nReader int32
  54235 
  54236 					nReader = func() int32 {
  54237 						if (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA-i < SORTER_MAX_MERGE_COUNT {
  54238 							return (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i
  54239 						}
  54240 						return SORTER_MAX_MERGE_COUNT
  54241 					}()
  54242 					rc = vdbeMergeEngineLevel0(tls, pTask, nReader, bp, bp+12)
  54243 					if rc == SQLITE_OK {
  54244 						rc = vdbeSorterAddToTree(tls, pTask, nDepth, libc.PostIncInt32(&iSeq, 1), *(*uintptr)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(bp + 12)))
  54245 					}
  54246 				}
  54247 			}
  54248 
  54249 			if rc == SQLITE_OK {
  54250 				if pMain != uintptr(0) {
  54251 					rc = vdbeIncrMergerNew(tls, pTask, *(*uintptr)(unsafe.Pointer(bp + 8)), (*MergeEngine)(unsafe.Pointer(pMain)).FaReadr+uintptr(iTask)*56+48)
  54252 				} else {
  54253 					pMain = *(*uintptr)(unsafe.Pointer(bp + 8))
  54254 				}
  54255 			} else {
  54256 				vdbeMergeEngineFree(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  54257 			}
  54258 		}
  54259 	}
  54260 
  54261 	if rc != SQLITE_OK {
  54262 		vdbeMergeEngineFree(tls, pMain)
  54263 		pMain = uintptr(0)
  54264 	}
  54265 	*(*uintptr)(unsafe.Pointer(ppOut)) = pMain
  54266 	return rc
  54267 }
  54268 
  54269 func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 {
  54270 	bp := tls.Alloc(4)
  54271 	defer tls.Free(4)
  54272 
  54273 	var rc int32
  54274 	var pTask0 uintptr = pSorter + 64
  54275 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  54276 	var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask0)).FpSorter)).Fdb
  54277 	var i int32
  54278 	var xCompare SorterCompare = vdbeSorterGetCompare(tls, pSorter)
  54279 	for i = 0; i < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask); i++ {
  54280 		(*SortSubtask)(unsafe.Pointer(pSorter + 64 + uintptr(i)*72)).FxCompare = xCompare
  54281 	}
  54282 
  54283 	rc = vdbeSorterMergeTreeBuild(tls, pSorter, bp)
  54284 	if rc == SQLITE_OK {
  54285 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 {
  54286 			var iTask int32
  54287 			var pReadr uintptr = uintptr(0)
  54288 			var pLast uintptr = pSorter + 64 + uintptr(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)-1)*72
  54289 			rc = vdbeSortAllocUnpacked(tls, pLast)
  54290 			if rc == SQLITE_OK {
  54291 				pReadr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(PmaReader{})))
  54292 				(*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader = pReadr
  54293 				if pReadr == uintptr(0) {
  54294 					rc = SQLITE_NOMEM
  54295 				}
  54296 			}
  54297 			if rc == SQLITE_OK {
  54298 				rc = vdbeIncrMergerNew(tls, pLast, *(*uintptr)(unsafe.Pointer(bp)), pReadr+48)
  54299 				if rc == SQLITE_OK {
  54300 					vdbeIncrMergerSetThreads(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr)
  54301 					for iTask = 0; iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)-1; iTask++ {
  54302 						var pIncr uintptr
  54303 						if libc.AssignUintptr(&pIncr, (*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaReadr+uintptr(iTask)*56)).FpIncr) != 0 {
  54304 							vdbeIncrMergerSetThreads(tls, pIncr)
  54305 
  54306 						}
  54307 					}
  54308 					for iTask = 0; rc == SQLITE_OK && iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask); iTask++ {
  54309 						var p uintptr = (*MergeEngine)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaReadr + uintptr(iTask)*56
  54310 
  54311 						rc = vdbePmaReaderIncrInit(tls, p, INCRINIT_TASK)
  54312 					}
  54313 				}
  54314 				*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  54315 			}
  54316 			if rc == SQLITE_OK {
  54317 				rc = vdbePmaReaderIncrMergeInit(tls, pReadr, INCRINIT_ROOT)
  54318 			}
  54319 		} else {
  54320 			rc = vdbeMergeEngineInit(tls, pTask0, *(*uintptr)(unsafe.Pointer(bp)), INCRINIT_NORMAL)
  54321 			(*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger = *(*uintptr)(unsafe.Pointer(bp))
  54322 			*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  54323 		}
  54324 	}
  54325 
  54326 	if rc != SQLITE_OK {
  54327 		vdbeMergeEngineFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
  54328 	}
  54329 	return rc
  54330 }
  54331 
  54332 // Once the sorter has been populated by calls to sqlite3VdbeSorterWrite,
  54333 // this function is called to prepare for iterating through the records
  54334 // in sorted order.
  54335 func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 {
  54336 	var pSorter uintptr
  54337 	var rc int32 = SQLITE_OK
  54338 
  54339 	pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 36))
  54340 
  54341 	if int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA) == 0 {
  54342 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 {
  54343 			*(*int32)(unsafe.Pointer(pbEof)) = 0
  54344 			rc = vdbeSorterSort(tls, pSorter+64, pSorter+36)
  54345 		} else {
  54346 			*(*int32)(unsafe.Pointer(pbEof)) = 1
  54347 		}
  54348 		return rc
  54349 	}
  54350 
  54351 	rc = vdbeSorterFlushPMA(tls, pSorter)
  54352 
  54353 	rc = vdbeSorterJoinAll(tls, pSorter, rc)
  54354 
  54355 	if rc == SQLITE_OK {
  54356 		rc = vdbeSorterSetupMerge(tls, pSorter)
  54357 		*(*int32)(unsafe.Pointer(pbEof)) = 0
  54358 	}
  54359 
  54360 	return rc
  54361 }
  54362 
  54363 // Advance to the next element in the sorter.  Return value:
  54364 //
  54365 //	SQLITE_OK     success
  54366 //	SQLITE_DONE   end of data
  54367 //	otherwise     some kind of error.
  54368 func Xsqlite3VdbeSorterNext(tls *libc.TLS, db uintptr, pCsr uintptr) int32 {
  54369 	bp := tls.Alloc(4)
  54370 	defer tls.Free(4)
  54371 
  54372 	var pSorter uintptr
  54373 	var rc int32
  54374 
  54375 	pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 36))
  54376 
  54377 	if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA != 0 {
  54378 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 {
  54379 			rc = vdbePmaReaderNext(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)
  54380 			if rc == SQLITE_OK && (*PmaReader)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)).FpFd == uintptr(0) {
  54381 				rc = SQLITE_DONE
  54382 			}
  54383 		} else {
  54384 			*(*int32)(unsafe.Pointer(bp)) = 0
  54385 
  54386 			rc = vdbeMergeEngineStep(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger, bp)
  54387 			if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp)) != 0 {
  54388 				rc = SQLITE_DONE
  54389 			}
  54390 		}
  54391 	} else {
  54392 		var pFree uintptr = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList
  54393 		(*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = *(*uintptr)(unsafe.Pointer(pFree + 4))
  54394 		*(*uintptr)(unsafe.Pointer(pFree + 4)) = uintptr(0)
  54395 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory == uintptr(0) {
  54396 			vdbeSorterRecordFree(tls, db, pFree)
  54397 		}
  54398 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 {
  54399 			rc = SQLITE_OK
  54400 		} else {
  54401 			rc = SQLITE_DONE
  54402 		}
  54403 	}
  54404 	return rc
  54405 }
  54406 
  54407 func vdbeSorterRowkey(tls *libc.TLS, pSorter uintptr, pnKey uintptr) uintptr {
  54408 	var pKey uintptr
  54409 	if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA != 0 {
  54410 		var pReader uintptr
  54411 		if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 {
  54412 			pReader = (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader
  54413 		} else {
  54414 			pReader = (*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaTree + 1*4)))*56
  54415 		}
  54416 		*(*int32)(unsafe.Pointer(pnKey)) = (*PmaReader)(unsafe.Pointer(pReader)).FnKey
  54417 		pKey = (*PmaReader)(unsafe.Pointer(pReader)).FaKey
  54418 	} else {
  54419 		*(*int32)(unsafe.Pointer(pnKey)) = (*SorterRecord)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList)).FnVal
  54420 		pKey = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList + uintptr(1)*8
  54421 	}
  54422 	return pKey
  54423 }
  54424 
  54425 // Copy the current sorter key into the memory cell pOut.
  54426 func Xsqlite3VdbeSorterRowkey(tls *libc.TLS, pCsr uintptr, pOut uintptr) int32 {
  54427 	bp := tls.Alloc(4)
  54428 	defer tls.Free(4)
  54429 
  54430 	var pSorter uintptr
  54431 	var pKey uintptr
  54432 
  54433 	pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 36))
  54434 	pKey = vdbeSorterRowkey(tls, pSorter, bp)
  54435 	if Xsqlite3VdbeMemClearAndResize(tls, pOut, *(*int32)(unsafe.Pointer(bp))) != 0 {
  54436 		return SQLITE_NOMEM
  54437 	}
  54438 	(*Mem)(unsafe.Pointer(pOut)).Fn = *(*int32)(unsafe.Pointer(bp))
  54439 	(*Mem)(unsafe.Pointer(pOut)).Fflags = U16(int32((*Mem)(unsafe.Pointer(pOut)).Fflags)&libc.CplInt32(MEM_TypeMask|MEM_Zero) | MEM_Blob)
  54440 	libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pOut)).Fz, pKey, uint32(*(*int32)(unsafe.Pointer(bp))))
  54441 
  54442 	return SQLITE_OK
  54443 }
  54444 
  54445 // Compare the key in memory cell pVal with the key that the sorter cursor
  54446 // passed as the first argument currently points to. For the purposes of
  54447 // the comparison, ignore the rowid field at the end of each record.
  54448 //
  54449 // If the sorter cursor key contains any NULL values, consider it to be
  54450 // less than pVal. Even if pVal also contains NULL values.
  54451 //
  54452 // If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).
  54453 // Otherwise, set *pRes to a negative, zero or positive value if the
  54454 // key in pVal is smaller than, equal to or larger than the current sorter
  54455 // key.
  54456 //
  54457 // This routine forms the core of the OP_SorterCompare opcode, which in
  54458 // turn is used to verify uniqueness when constructing a UNIQUE INDEX.
  54459 func Xsqlite3VdbeSorterCompare(tls *libc.TLS, pCsr uintptr, pVal uintptr, nKeyCol int32, pRes uintptr) int32 {
  54460 	bp := tls.Alloc(4)
  54461 	defer tls.Free(4)
  54462 
  54463 	var pSorter uintptr
  54464 	var r2 uintptr
  54465 	var pKeyInfo uintptr
  54466 	var i int32
  54467 	var pKey uintptr
  54468 
  54469 	pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 36))
  54470 	r2 = (*VdbeSorter)(unsafe.Pointer(pSorter)).FpUnpacked
  54471 	pKeyInfo = (*VdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo
  54472 	if r2 == uintptr(0) {
  54473 		r2 = libc.AssignPtrUintptr(pSorter+32, Xsqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo))
  54474 		if r2 == uintptr(0) {
  54475 			return SQLITE_NOMEM
  54476 		}
  54477 		(*UnpackedRecord)(unsafe.Pointer(r2)).FnField = U16(nKeyCol)
  54478 	}
  54479 
  54480 	pKey = vdbeSorterRowkey(tls, pSorter, bp)
  54481 	Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, *(*int32)(unsafe.Pointer(bp)), pKey, r2)
  54482 	for i = 0; i < nKeyCol; i++ {
  54483 		if int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(r2)).FaMem+uintptr(i)*40)).Fflags)&MEM_Null != 0 {
  54484 			*(*int32)(unsafe.Pointer(pRes)) = -1
  54485 			return SQLITE_OK
  54486 		}
  54487 	}
  54488 
  54489 	*(*int32)(unsafe.Pointer(pRes)) = Xsqlite3VdbeRecordCompare(tls, (*Mem)(unsafe.Pointer(pVal)).Fn, (*Mem)(unsafe.Pointer(pVal)).Fz, r2)
  54490 	return SQLITE_OK
  54491 }
  54492 
  54493 // Forward references to internal structures
  54494 type MemJournal1 = struct {
  54495 	FpMethod     uintptr
  54496 	FnChunkSize  int32
  54497 	FnSpill      int32
  54498 	FpFirst      uintptr
  54499 	Fendpoint    FilePoint
  54500 	Freadpoint   FilePoint
  54501 	Fflags       int32
  54502 	FpVfs        uintptr
  54503 	FzJournal    uintptr
  54504 	F__ccgo_pad1 [4]byte
  54505 }
  54506 
  54507 // Forward references to internal structures
  54508 type MemJournal = MemJournal1
  54509 type FilePoint1 = struct {
  54510 	FiOffset     Sqlite3_int64
  54511 	FpChunk      uintptr
  54512 	F__ccgo_pad1 [4]byte
  54513 }
  54514 
  54515 type FilePoint = FilePoint1
  54516 type FileChunk1 = struct {
  54517 	FpNext  uintptr
  54518 	FzChunk [8]U8
  54519 }
  54520 
  54521 type FileChunk = FileChunk1
  54522 
  54523 func memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Sqlite_int64) int32 {
  54524 	var p uintptr = pJfd
  54525 	var zOut uintptr = zBuf
  54526 	var nRead int32 = iAmt
  54527 	var iChunkOffset int32
  54528 	var pChunk uintptr
  54529 
  54530 	if Sqlite_int64(iAmt)+iOfst > (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset {
  54531 		return SQLITE_IOERR | int32(2)<<8
  54532 	}
  54533 
  54534 	if (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset != iOfst || iOfst == int64(0) {
  54535 		var iOff Sqlite3_int64 = int64(0)
  54536 		for pChunk = (*MemJournal)(unsafe.Pointer(p)).FpFirst; pChunk != 0 && iOff+Sqlite3_int64((*MemJournal)(unsafe.Pointer(p)).FnChunkSize) <= iOfst; pChunk = (*FileChunk)(unsafe.Pointer(pChunk)).FpNext {
  54537 			iOff = iOff + Sqlite3_int64((*MemJournal)(unsafe.Pointer(p)).FnChunkSize)
  54538 		}
  54539 	} else {
  54540 		pChunk = (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk
  54541 
  54542 	}
  54543 
  54544 	iChunkOffset = int32(iOfst % Sqlite_int64((*MemJournal)(unsafe.Pointer(p)).FnChunkSize))
  54545 	for __ccgo := true; __ccgo; __ccgo = nRead >= 0 && libc.AssignUintptr(&pChunk, (*FileChunk)(unsafe.Pointer(pChunk)).FpNext) != uintptr(0) && nRead > 0 {
  54546 		var iSpace int32 = (*MemJournal)(unsafe.Pointer(p)).FnChunkSize - iChunkOffset
  54547 		var nCopy int32 = func() int32 {
  54548 			if nRead < (*MemJournal)(unsafe.Pointer(p)).FnChunkSize-iChunkOffset {
  54549 				return nRead
  54550 			}
  54551 			return (*MemJournal)(unsafe.Pointer(p)).FnChunkSize - iChunkOffset
  54552 		}()
  54553 		libc.Xmemcpy(tls, zOut, pChunk+4+uintptr(iChunkOffset), uint32(nCopy))
  54554 		zOut += uintptr(nCopy)
  54555 		nRead = nRead - iSpace
  54556 		iChunkOffset = 0
  54557 	}
  54558 	(*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = func() int64 {
  54559 		if pChunk != 0 {
  54560 			return iOfst + Sqlite_int64(iAmt)
  54561 		}
  54562 		return int64(0)
  54563 	}()
  54564 	(*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = pChunk
  54565 
  54566 	return SQLITE_OK
  54567 }
  54568 
  54569 func memjrnlFreeChunks(tls *libc.TLS, pFirst uintptr) {
  54570 	var pIter uintptr
  54571 	var pNext uintptr
  54572 	for pIter = pFirst; pIter != 0; pIter = pNext {
  54573 		pNext = (*FileChunk)(unsafe.Pointer(pIter)).FpNext
  54574 		Xsqlite3_free(tls, pIter)
  54575 	}
  54576 }
  54577 
  54578 func memjrnlCreateFile(tls *libc.TLS, p uintptr) int32 {
  54579 	var rc int32
  54580 	var pReal uintptr = p
  54581 	var copy = *(*MemJournal)(unsafe.Pointer(p))
  54582 
  54583 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(MemJournal{})))
  54584 	rc = Xsqlite3OsOpen(tls, copy.FpVfs, copy.FzJournal, pReal, copy.Fflags, uintptr(0))
  54585 	if rc == SQLITE_OK {
  54586 		var nChunk int32 = copy.FnChunkSize
  54587 		var iOff I64 = int64(0)
  54588 		var pIter uintptr
  54589 		for pIter = copy.FpFirst; pIter != 0; pIter = (*FileChunk)(unsafe.Pointer(pIter)).FpNext {
  54590 			if iOff+I64(nChunk) > copy.Fendpoint.FiOffset {
  54591 				nChunk = int32(copy.Fendpoint.FiOffset - iOff)
  54592 			}
  54593 			rc = Xsqlite3OsWrite(tls, pReal, pIter+4, nChunk, iOff)
  54594 			if rc != 0 {
  54595 				break
  54596 			}
  54597 			iOff = iOff + I64(nChunk)
  54598 		}
  54599 		if rc == SQLITE_OK {
  54600 			memjrnlFreeChunks(tls, copy.FpFirst)
  54601 		}
  54602 	}
  54603 	if rc != SQLITE_OK {
  54604 		Xsqlite3OsClose(tls, pReal)
  54605 		*(*MemJournal)(unsafe.Pointer(p)) = copy
  54606 	}
  54607 	return rc
  54608 }
  54609 
  54610 func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Sqlite_int64) int32 {
  54611 	var p uintptr = pJfd
  54612 	var nWrite int32 = iAmt
  54613 	var zWrite uintptr = zBuf
  54614 
  54615 	if (*MemJournal)(unsafe.Pointer(p)).FnSpill > 0 && Sqlite_int64(iAmt)+iOfst > Sqlite_int64((*MemJournal)(unsafe.Pointer(p)).FnSpill) {
  54616 		var rc int32 = memjrnlCreateFile(tls, p)
  54617 		if rc == SQLITE_OK {
  54618 			rc = Xsqlite3OsWrite(tls, pJfd, zBuf, iAmt, iOfst)
  54619 		}
  54620 		return rc
  54621 	} else {
  54622 		if iOfst > int64(0) && iOfst != (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset {
  54623 			memjrnlTruncate(tls, pJfd, iOfst)
  54624 		}
  54625 		if iOfst == int64(0) && (*MemJournal)(unsafe.Pointer(p)).FpFirst != 0 {
  54626 			libc.Xmemcpy(tls, (*MemJournal)(unsafe.Pointer(p)).FpFirst+4, zBuf, uint32(iAmt))
  54627 		} else {
  54628 			for nWrite > 0 {
  54629 				var pChunk uintptr = (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FpChunk
  54630 				var iChunkOffset int32 = int32((*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset % Sqlite3_int64((*MemJournal)(unsafe.Pointer(p)).FnChunkSize))
  54631 				var iSpace int32 = func() int32 {
  54632 					if nWrite < (*MemJournal)(unsafe.Pointer(p)).FnChunkSize-iChunkOffset {
  54633 						return nWrite
  54634 					}
  54635 					return (*MemJournal)(unsafe.Pointer(p)).FnChunkSize - iChunkOffset
  54636 				}()
  54637 
  54638 				if iChunkOffset == 0 {
  54639 					var pNew uintptr = Xsqlite3_malloc(tls, int32(uint32(unsafe.Sizeof(FileChunk{}))+uint32((*MemJournal)(unsafe.Pointer(p)).FnChunkSize-8)))
  54640 					if !(pNew != 0) {
  54641 						return SQLITE_IOERR | int32(12)<<8
  54642 					}
  54643 					(*FileChunk)(unsafe.Pointer(pNew)).FpNext = uintptr(0)
  54644 					if pChunk != 0 {
  54645 						(*FileChunk)(unsafe.Pointer(pChunk)).FpNext = pNew
  54646 					} else {
  54647 						(*MemJournal)(unsafe.Pointer(p)).FpFirst = pNew
  54648 					}
  54649 					pChunk = libc.AssignPtrUintptr(p+16+8, pNew)
  54650 				}
  54651 
  54652 				libc.Xmemcpy(tls, pChunk+4+uintptr(iChunkOffset), zWrite, uint32(iSpace))
  54653 				zWrite += uintptr(iSpace)
  54654 				nWrite = nWrite - iSpace
  54655 				*(*Sqlite3_int64)(unsafe.Pointer(p + 16)) += Sqlite3_int64(iSpace)
  54656 			}
  54657 		}
  54658 	}
  54659 
  54660 	return SQLITE_OK
  54661 }
  54662 
  54663 func memjrnlTruncate(tls *libc.TLS, pJfd uintptr, size Sqlite_int64) int32 {
  54664 	var p uintptr = pJfd
  54665 
  54666 	if size < (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset {
  54667 		var pIter uintptr = uintptr(0)
  54668 		if size == int64(0) {
  54669 			memjrnlFreeChunks(tls, (*MemJournal)(unsafe.Pointer(p)).FpFirst)
  54670 			(*MemJournal)(unsafe.Pointer(p)).FpFirst = uintptr(0)
  54671 		} else {
  54672 			var iOff I64 = I64((*MemJournal)(unsafe.Pointer(p)).FnChunkSize)
  54673 			for pIter = (*MemJournal)(unsafe.Pointer(p)).FpFirst; pIter != 0 && iOff < size; pIter = (*FileChunk)(unsafe.Pointer(pIter)).FpNext {
  54674 				iOff = iOff + I64((*MemJournal)(unsafe.Pointer(p)).FnChunkSize)
  54675 			}
  54676 			if pIter != 0 {
  54677 				memjrnlFreeChunks(tls, (*FileChunk)(unsafe.Pointer(pIter)).FpNext)
  54678 				(*FileChunk)(unsafe.Pointer(pIter)).FpNext = uintptr(0)
  54679 			}
  54680 		}
  54681 
  54682 		(*MemJournal)(unsafe.Pointer(p)).Fendpoint.FpChunk = pIter
  54683 		(*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset = size
  54684 		(*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = uintptr(0)
  54685 		(*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = int64(0)
  54686 	}
  54687 	return SQLITE_OK
  54688 }
  54689 
  54690 func memjrnlClose(tls *libc.TLS, pJfd uintptr) int32 {
  54691 	var p uintptr = pJfd
  54692 	memjrnlFreeChunks(tls, (*MemJournal)(unsafe.Pointer(p)).FpFirst)
  54693 	return SQLITE_OK
  54694 }
  54695 
  54696 func memjrnlSync(tls *libc.TLS, pJfd uintptr, flags int32) int32 {
  54697 	_ = pJfd
  54698 	_ = flags
  54699 	return SQLITE_OK
  54700 }
  54701 
  54702 func memjrnlFileSize(tls *libc.TLS, pJfd uintptr, pSize uintptr) int32 {
  54703 	var p uintptr = pJfd
  54704 	*(*Sqlite_int64)(unsafe.Pointer(pSize)) = (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset
  54705 	return SQLITE_OK
  54706 }
  54707 
  54708 var sMemJournalMethods = sqlite3_io_methods{
  54709 	FiVersion:  1,
  54710 	FxClose:    0,
  54711 	FxRead:     0,
  54712 	FxWrite:    0,
  54713 	FxTruncate: 0,
  54714 	FxSync:     0,
  54715 	FxFileSize: 0,
  54716 }
  54717 
  54718 // Open a journal file.
  54719 //
  54720 // The behaviour of the journal file depends on the value of parameter
  54721 // nSpill. If nSpill is 0, then the journal file is always create and
  54722 // accessed using the underlying VFS. If nSpill is less than zero, then
  54723 // all content is always stored in main-memory. Finally, if nSpill is a
  54724 // positive value, then the journal file is initially created in-memory
  54725 // but may be flushed to disk later on. In this case the journal file is
  54726 // flushed to disk either when it grows larger than nSpill bytes in size,
  54727 // or when sqlite3JournalCreate() is called.
  54728 func Xsqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintptr, flags int32, nSpill int32) int32 {
  54729 	var p uintptr = pJfd
  54730 
  54731 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(MemJournal{})))
  54732 	if nSpill == 0 {
  54733 		return Xsqlite3OsOpen(tls, pVfs, zName, pJfd, flags, uintptr(0))
  54734 	}
  54735 
  54736 	if nSpill > 0 {
  54737 		(*MemJournal)(unsafe.Pointer(p)).FnChunkSize = nSpill
  54738 	} else {
  54739 		(*MemJournal)(unsafe.Pointer(p)).FnChunkSize = int32(uint32(8+MEMJOURNAL_DFLT_FILECHUNKSIZE) - uint32(unsafe.Sizeof(FileChunk{})))
  54740 
  54741 	}
  54742 
  54743 	(*Sqlite3_file)(unsafe.Pointer(pJfd)).FpMethods = uintptr(unsafe.Pointer(&sMemJournalMethods))
  54744 	(*MemJournal)(unsafe.Pointer(p)).FnSpill = nSpill
  54745 	(*MemJournal)(unsafe.Pointer(p)).Fflags = flags
  54746 	(*MemJournal)(unsafe.Pointer(p)).FzJournal = zName
  54747 	(*MemJournal)(unsafe.Pointer(p)).FpVfs = pVfs
  54748 	return SQLITE_OK
  54749 }
  54750 
  54751 // Open an in-memory journal file.
  54752 func Xsqlite3MemJournalOpen(tls *libc.TLS, pJfd uintptr) {
  54753 	Xsqlite3JournalOpen(tls, uintptr(0), uintptr(0), pJfd, 0, -1)
  54754 }
  54755 
  54756 // The file-handle passed as the only argument is open on a journal file.
  54757 // Return true if this "journal file" is currently stored in heap memory,
  54758 // or false otherwise.
  54759 func Xsqlite3JournalIsInMemory(tls *libc.TLS, p uintptr) int32 {
  54760 	return libc.Bool32((*Sqlite3_file)(unsafe.Pointer(p)).FpMethods == uintptr(unsafe.Pointer(&sMemJournalMethods)))
  54761 }
  54762 
  54763 // Return the number of bytes required to store a JournalFile that uses vfs
  54764 // pVfs to create the underlying on-disk files.
  54765 func Xsqlite3JournalSize(tls *libc.TLS, pVfs uintptr) int32 {
  54766 	return func() int32 {
  54767 		if (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile > int32(unsafe.Sizeof(MemJournal{})) {
  54768 			return (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile
  54769 		}
  54770 		return int32(unsafe.Sizeof(MemJournal{}))
  54771 	}()
  54772 }
  54773 
  54774 func walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr, bOneOnly int32) int32 {
  54775 	var pWin uintptr
  54776 	for pWin = pList; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
  54777 		var rc int32
  54778 		rc = Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpOrderBy)
  54779 		if rc != 0 {
  54780 			return WRC_Abort
  54781 		}
  54782 		rc = Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpPartition)
  54783 		if rc != 0 {
  54784 			return WRC_Abort
  54785 		}
  54786 		rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpFilter)
  54787 		if rc != 0 {
  54788 			return WRC_Abort
  54789 		}
  54790 		rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpStart)
  54791 		if rc != 0 {
  54792 			return WRC_Abort
  54793 		}
  54794 		rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpEnd)
  54795 		if rc != 0 {
  54796 			return WRC_Abort
  54797 		}
  54798 		if bOneOnly != 0 {
  54799 			break
  54800 		}
  54801 	}
  54802 	return WRC_Continue
  54803 }
  54804 
  54805 func walkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  54806 	var rc int32
  54807 
  54808 	for 1 != 0 {
  54809 		rc = (*struct {
  54810 			f func(*libc.TLS, uintptr, uintptr) int32
  54811 		})(unsafe.Pointer(&struct{ uintptr }{(*Walker)(unsafe.Pointer(pWalker)).FxExprCallback})).f(tls, pWalker, pExpr)
  54812 		if rc != 0 {
  54813 			return rc & WRC_Abort
  54814 		}
  54815 		if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_TokenOnly|EP_Leaf) != U32(0)) {
  54816 			if (*Expr)(unsafe.Pointer(pExpr)).FpLeft != 0 && walkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) != 0 {
  54817 				return WRC_Abort
  54818 			}
  54819 			if (*Expr)(unsafe.Pointer(pExpr)).FpRight != 0 {
  54820 				pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpRight
  54821 				continue
  54822 			} else if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  54823 				if Xsqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 20))) != 0 {
  54824 					return WRC_Abort
  54825 				}
  54826 			} else {
  54827 				if *(*uintptr)(unsafe.Pointer(pExpr + 20)) != 0 {
  54828 					if Xsqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 20))) != 0 {
  54829 						return WRC_Abort
  54830 					}
  54831 				}
  54832 				if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  54833 					if walkWindowList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 44)), 1) != 0 {
  54834 						return WRC_Abort
  54835 					}
  54836 				}
  54837 			}
  54838 		}
  54839 		break
  54840 	}
  54841 	return WRC_Continue
  54842 }
  54843 
  54844 func Xsqlite3WalkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  54845 	if pExpr != 0 {
  54846 		return walkExpr(tls, pWalker, pExpr)
  54847 	}
  54848 	return WRC_Continue
  54849 }
  54850 
  54851 // Call sqlite3WalkExpr() for every expression in list p or until
  54852 // an abort request is seen.
  54853 func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  54854 	var i int32
  54855 	var pItem uintptr
  54856 	if p != 0 {
  54857 		i = (*ExprList)(unsafe.Pointer(p)).FnExpr
  54858 		pItem = p + 8
  54859 	__1:
  54860 		if !(i > 0) {
  54861 			goto __3
  54862 		}
  54863 		{
  54864 			if Xsqlite3WalkExpr(tls, pWalker, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr) != 0 {
  54865 				return WRC_Abort
  54866 			}
  54867 
  54868 		}
  54869 		goto __2
  54870 	__2:
  54871 		i--
  54872 		pItem += 20
  54873 		goto __1
  54874 		goto __3
  54875 	__3:
  54876 	}
  54877 	return WRC_Continue
  54878 }
  54879 
  54880 // This is a no-op callback for Walker->xSelectCallback2.  If this
  54881 // callback is set, then the Select->pWinDefn list is traversed.
  54882 func Xsqlite3WalkWinDefnDummyCallback(tls *libc.TLS, pWalker uintptr, p uintptr) {
  54883 	_ = pWalker
  54884 	_ = p
  54885 
  54886 }
  54887 
  54888 // Walk all expressions associated with SELECT statement p.  Do
  54889 // not invoke the SELECT callback on p, but do (of course) invoke
  54890 // any expr callbacks and SELECT callbacks that come from subqueries.
  54891 // Return WRC_Abort or WRC_Continue.
  54892 func Xsqlite3WalkSelectExpr(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  54893 	if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpEList) != 0 {
  54894 		return WRC_Abort
  54895 	}
  54896 	if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpWhere) != 0 {
  54897 		return WRC_Abort
  54898 	}
  54899 	if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpGroupBy) != 0 {
  54900 		return WRC_Abort
  54901 	}
  54902 	if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpHaving) != 0 {
  54903 		return WRC_Abort
  54904 	}
  54905 	if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpOrderBy) != 0 {
  54906 		return WRC_Abort
  54907 	}
  54908 	if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpLimit) != 0 {
  54909 		return WRC_Abort
  54910 	}
  54911 	if (*Select)(unsafe.Pointer(p)).FpWinDefn != 0 {
  54912 		var pParse uintptr
  54913 		if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback2 == *(*uintptr)(unsafe.Pointer(&struct {
  54914 			f func(*libc.TLS, uintptr, uintptr)
  54915 		}{Xsqlite3WalkWinDefnDummyCallback})) ||
  54916 			libc.AssignUintptr(&pParse, (*Walker)(unsafe.Pointer(pWalker)).FpParse) != uintptr(0) && int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME ||
  54917 			(*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback2 == *(*uintptr)(unsafe.Pointer(&struct {
  54918 				f func(*libc.TLS, uintptr, uintptr)
  54919 			}{Xsqlite3SelectPopWith})) {
  54920 			var rc int32 = walkWindowList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpWinDefn, 0)
  54921 			return rc
  54922 		}
  54923 	}
  54924 	return WRC_Continue
  54925 }
  54926 
  54927 // Walk the parse trees associated with all subqueries in the
  54928 // FROM clause of SELECT statement p.  Do not invoke the select
  54929 // callback on p, but do invoke it on each FROM clause subquery
  54930 // and on any subqueries further down in the tree.  Return
  54931 // WRC_Abort or WRC_Continue;
  54932 func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  54933 	var pSrc uintptr
  54934 	var i int32
  54935 	var pItem uintptr
  54936 
  54937 	pSrc = (*Select)(unsafe.Pointer(p)).FpSrc
  54938 	if pSrc != 0 {
  54939 		i = (*SrcList)(unsafe.Pointer(pSrc)).FnSrc
  54940 		pItem = pSrc + 8
  54941 	__1:
  54942 		if !(i > 0) {
  54943 			goto __3
  54944 		}
  54945 		{
  54946 			if (*SrcItem)(unsafe.Pointer(pItem)).FpSelect != 0 && Xsqlite3WalkSelect(tls, pWalker, (*SrcItem)(unsafe.Pointer(pItem)).FpSelect) != 0 {
  54947 				return WRC_Abort
  54948 			}
  54949 			if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x4>>2)) != 0 &&
  54950 				Xsqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pItem + 64))) != 0 {
  54951 				return WRC_Abort
  54952 			}
  54953 
  54954 		}
  54955 		goto __2
  54956 	__2:
  54957 		i--
  54958 		pItem += 72
  54959 		goto __1
  54960 		goto __3
  54961 	__3:
  54962 	}
  54963 	return WRC_Continue
  54964 }
  54965 
  54966 // Call sqlite3WalkExpr() for every expression in Select statement p.
  54967 // Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
  54968 // on the compound select chain, p->pPrior.
  54969 //
  54970 // If it is not NULL, the xSelectCallback() callback is invoked before
  54971 // the walk of the expressions and FROM clause. The xSelectCallback2()
  54972 // method is invoked following the walk of the expressions and FROM clause,
  54973 // but only if both xSelectCallback and xSelectCallback2 are both non-NULL
  54974 // and if the expressions and FROM clause both return WRC_Continue;
  54975 //
  54976 // Return WRC_Continue under normal conditions.  Return WRC_Abort if
  54977 // there is an abort request.
  54978 //
  54979 // If the Walker does not have an xSelectCallback() then this routine
  54980 // is a no-op returning WRC_Continue.
  54981 func Xsqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  54982 	var rc int32
  54983 	if p == uintptr(0) {
  54984 		return WRC_Continue
  54985 	}
  54986 	if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback == uintptr(0) {
  54987 		return WRC_Continue
  54988 	}
  54989 	for __ccgo := true; __ccgo; __ccgo = p != uintptr(0) {
  54990 		rc = (*struct {
  54991 			f func(*libc.TLS, uintptr, uintptr) int32
  54992 		})(unsafe.Pointer(&struct{ uintptr }{(*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback})).f(tls, pWalker, p)
  54993 		if rc != 0 {
  54994 			return rc & WRC_Abort
  54995 		}
  54996 		if Xsqlite3WalkSelectExpr(tls, pWalker, p) != 0 ||
  54997 			Xsqlite3WalkSelectFrom(tls, pWalker, p) != 0 {
  54998 			return WRC_Abort
  54999 		}
  55000 		if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback2 != 0 {
  55001 			(*struct {
  55002 				f func(*libc.TLS, uintptr, uintptr)
  55003 			})(unsafe.Pointer(&struct{ uintptr }{(*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback2})).f(tls, pWalker, p)
  55004 		}
  55005 		p = (*Select)(unsafe.Pointer(p)).FpPrior
  55006 	}
  55007 	return WRC_Continue
  55008 }
  55009 
  55010 // Increase the walkerDepth when entering a subquery, and
  55011 // descrease when leaving the subquery.
  55012 func Xsqlite3WalkerDepthIncrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 {
  55013 	_ = pSelect
  55014 	(*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth++
  55015 	return WRC_Continue
  55016 }
  55017 
  55018 func Xsqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) {
  55019 	_ = pSelect
  55020 	(*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth--
  55021 }
  55022 
  55023 // No-op routine for the parse-tree walker.
  55024 //
  55025 // When this routine is the Walker.xExprCallback then expression trees
  55026 // are walked without any actions being taken at each node.  Presumably,
  55027 // when this routine is used for Walker.xExprCallback then
  55028 // Walker.xSelectCallback is set to do something useful for every
  55029 // subquery in the parser tree.
  55030 func Xsqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int32 {
  55031 	_ = NotUsed
  55032 	_ = NotUsed2
  55033 	return WRC_Continue
  55034 }
  55035 
  55036 // No-op routine for the parse-tree walker for SELECT statements.
  55037 // subquery in the parser tree.
  55038 func Xsqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int32 {
  55039 	_ = NotUsed
  55040 	_ = NotUsed2
  55041 	return WRC_Continue
  55042 }
  55043 
  55044 func incrAggDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  55045 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION {
  55046 		*(*U8)(unsafe.Pointer(pExpr + 2)) += U8(*(*int32)(unsafe.Pointer(pWalker + 24)))
  55047 	}
  55048 	return WRC_Continue
  55049 }
  55050 
  55051 func incrAggFunctionDepth(tls *libc.TLS, pExpr uintptr, N int32) {
  55052 	bp := tls.Alloc(28)
  55053 	defer tls.Free(28)
  55054 
  55055 	if N > 0 {
  55056 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  55057 		(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  55058 			f func(*libc.TLS, uintptr, uintptr) int32
  55059 		}{incrAggDepth}))
  55060 		*(*int32)(unsafe.Pointer(bp + 24)) = N
  55061 		Xsqlite3WalkExpr(tls, bp, pExpr)
  55062 	}
  55063 }
  55064 
  55065 func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pExpr uintptr, nSubquery int32) {
  55066 	bp := tls.Alloc(52)
  55067 	defer tls.Free(52)
  55068 
  55069 	var pOrig uintptr
  55070 	var pDup uintptr
  55071 	var db uintptr
  55072 
  55073 	pOrig = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(iCol)*20)).FpExpr
  55074 
  55075 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  55076 	pDup = Xsqlite3ExprDup(tls, db, pOrig, 0)
  55077 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  55078 		Xsqlite3ExprDelete(tls, db, pDup)
  55079 		pDup = uintptr(0)
  55080 	} else {
  55081 		incrAggFunctionDepth(tls, pDup, nSubquery)
  55082 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE {
  55083 			pDup = Xsqlite3ExprAddCollateString(tls, pParse, pDup, *(*uintptr)(unsafe.Pointer(pExpr + 8)))
  55084 		}
  55085 		libc.Xmemcpy(tls, bp, pDup, uint32(unsafe.Sizeof(Expr{})))
  55086 		libc.Xmemcpy(tls, pDup, pExpr, uint32(unsafe.Sizeof(Expr{})))
  55087 		libc.Xmemcpy(tls, pExpr, bp, uint32(unsafe.Sizeof(Expr{})))
  55088 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  55089 			if *(*uintptr)(unsafe.Pointer(pExpr + 44)) != uintptr(0) {
  55090 				(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FpOwner = pExpr
  55091 			}
  55092 		}
  55093 		Xsqlite3ExprDeferredDelete(tls, pParse, pDup)
  55094 	}
  55095 }
  55096 
  55097 // Subqueries stores the original database, table and column names for their
  55098 // result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".
  55099 // Check to see if the zSpan given to this routine matches the zDb, zTab,
  55100 // and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will
  55101 // match anything.
  55102 func Xsqlite3MatchEName(tls *libc.TLS, pItem uintptr, zCol uintptr, zTab uintptr, zDb uintptr) int32 {
  55103 	var n int32
  55104 	var zSpan uintptr
  55105 	if int32(*(*uint16)(unsafe.Pointer(pItem + 8 + 4))&0x3>>0) != ENAME_TAB {
  55106 		return 0
  55107 	}
  55108 	zSpan = (*ExprList_item)(unsafe.Pointer(pItem)).FzEName
  55109 	for n = 0; *(*uint8)(unsafe.Pointer(zSpan + uintptr(n))) != 0 && int32(*(*uint8)(unsafe.Pointer(zSpan + uintptr(n)))) != '.'; n++ {
  55110 	}
  55111 	if zDb != 0 && (Xsqlite3_strnicmp(tls, zSpan, zDb, n) != 0 || int32(*(*uint8)(unsafe.Pointer(zDb + uintptr(n)))) != 0) {
  55112 		return 0
  55113 	}
  55114 	zSpan += uintptr(n + 1)
  55115 	for n = 0; *(*uint8)(unsafe.Pointer(zSpan + uintptr(n))) != 0 && int32(*(*uint8)(unsafe.Pointer(zSpan + uintptr(n)))) != '.'; n++ {
  55116 	}
  55117 	if zTab != 0 && (Xsqlite3_strnicmp(tls, zSpan, zTab, n) != 0 || int32(*(*uint8)(unsafe.Pointer(zTab + uintptr(n)))) != 0) {
  55118 		return 0
  55119 	}
  55120 	zSpan += uintptr(n + 1)
  55121 	if zCol != 0 && Xsqlite3StrICmp(tls, zSpan, zCol) != 0 {
  55122 		return 0
  55123 	}
  55124 	return 1
  55125 }
  55126 
  55127 func areDoubleQuotedStringsEnabled(tls *libc.TLS, db uintptr, pTopNC uintptr) int32 {
  55128 	if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  55129 		return 1
  55130 	}
  55131 	if (*NameContext)(unsafe.Pointer(pTopNC)).FncFlags&NC_IsDDL != 0 {
  55132 		if Xsqlite3WritableSchema(tls, db) != 0 && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DqsDML) != uint64(0) {
  55133 			return 1
  55134 		}
  55135 		return libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DqsDDL) != uint64(0))
  55136 	} else {
  55137 		return libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DqsDML) != uint64(0))
  55138 	}
  55139 	return int32(0)
  55140 }
  55141 
  55142 // The argument is guaranteed to be a non-NULL Expr node of type TK_COLUMN.
  55143 // return the appropriate colUsed mask.
  55144 func Xsqlite3ExprColUsed(tls *libc.TLS, pExpr uintptr) Bitmask {
  55145 	var n int32
  55146 	var pExTab uintptr
  55147 
  55148 	n = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  55149 
  55150 	pExTab = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  55151 
  55152 	if (*Table)(unsafe.Pointer(pExTab)).FtabFlags&U32(TF_HasGenerated) != U32(0) &&
  55153 		int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pExTab)).FaCol+uintptr(n)*16)).FcolFlags)&COLFLAG_GENERATED != 0 {
  55154 		if int32((*Table)(unsafe.Pointer(pExTab)).FnCol) >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) {
  55155 			return libc.Uint64(libc.Uint64FromInt32(-1))
  55156 		}
  55157 		return uint64(1)<<int32((*Table)(unsafe.Pointer(pExTab)).FnCol) - uint64(1)
  55158 	} else {
  55159 		if n >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) {
  55160 			n = int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) - 1
  55161 		}
  55162 		return uint64(1) << n
  55163 	}
  55164 	return Bitmask(0)
  55165 }
  55166 
  55167 func extendFJMatch(tls *libc.TLS, pParse uintptr, ppList uintptr, pMatch uintptr, iColumn I16) {
  55168 	var pNew uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLUMN, uintptr(0), 0)
  55169 	if pNew != 0 {
  55170 		(*Expr)(unsafe.Pointer(pNew)).FiTable = (*SrcItem)(unsafe.Pointer(pMatch)).FiCursor
  55171 		(*Expr)(unsafe.Pointer(pNew)).FiColumn = iColumn
  55172 		*(*uintptr)(unsafe.Pointer(pNew + 44)) = (*SrcItem)(unsafe.Pointer(pMatch)).FpTab
  55173 
  55174 		*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_CanBeNull)
  55175 		*(*uintptr)(unsafe.Pointer(ppList)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(ppList)), pNew)
  55176 	}
  55177 }
  55178 
  55179 func isValidSchemaTableName(tls *libc.TLS, zTab uintptr, pTab uintptr, pSchema uintptr) int32 {
  55180 	var zLegacy uintptr
  55181 
  55182 	if Xsqlite3_strnicmp(tls, zTab, ts+6381, 7) != 0 {
  55183 		return 0
  55184 	}
  55185 	zLegacy = (*Table)(unsafe.Pointer(pTab)).FzName
  55186 	if libc.Xstrcmp(tls, zLegacy+uintptr(7), ts+6389+7) == 0 {
  55187 		if Xsqlite3StrICmp(tls, zTab+uintptr(7), ts+6408+7) == 0 {
  55188 			return 1
  55189 		}
  55190 		if pSchema == uintptr(0) {
  55191 			return 0
  55192 		}
  55193 		if Xsqlite3StrICmp(tls, zTab+uintptr(7), ts+5883+7) == 0 {
  55194 			return 1
  55195 		}
  55196 		if Xsqlite3StrICmp(tls, zTab+uintptr(7), ts+6427+7) == 0 {
  55197 			return 1
  55198 		}
  55199 	} else {
  55200 		if Xsqlite3StrICmp(tls, zTab+uintptr(7), ts+6427+7) == 0 {
  55201 			return 1
  55202 		}
  55203 	}
  55204 	return 0
  55205 }
  55206 
  55207 func lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zCol uintptr, pNC uintptr, pExpr uintptr) int32 {
  55208 	bp := tls.Alloc(100)
  55209 	defer tls.Free(100)
  55210 
  55211 	var i int32
  55212 	var j int32
  55213 	var cnt int32
  55214 	var cntTab int32
  55215 	var nSubquery int32
  55216 	var db uintptr
  55217 	var pItem uintptr
  55218 	var pMatch uintptr
  55219 	var pTopNC uintptr
  55220 	var pSchema uintptr
  55221 	var eNewExprOp int32
  55222 	var pTab uintptr
  55223 	var pCol uintptr
  55224 
  55225 	var hit int32
  55226 	var hCol U8
  55227 	var op int32
  55228 	var pUpsert uintptr
  55229 	var iCol int32
  55230 	var hCol1 U8
  55231 	var pOrig uintptr
  55232 	var zAs uintptr
  55233 	var pEList uintptr
  55234 	var pSrcList uintptr
  55235 	var zErr uintptr
  55236 	cnt = 0
  55237 	cntTab = 0
  55238 	nSubquery = 0
  55239 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  55240 	pMatch = uintptr(0)
  55241 	pTopNC = pNC
  55242 	pSchema = uintptr(0)
  55243 	eNewExprOp = TK_COLUMN
  55244 	pTab = uintptr(0)
  55245 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  55246 
  55247 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = -1
  55248 
  55249 	if !(zDb != 0) {
  55250 		goto __1
  55251 	}
  55252 
  55253 	if !((*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_PartIdx|NC_IsCheck) != 0) {
  55254 		goto __2
  55255 	}
  55256 
  55257 	zDb = uintptr(0)
  55258 	goto __3
  55259 __2:
  55260 	i = 0
  55261 __4:
  55262 	if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  55263 		goto __6
  55264 	}
  55265 
  55266 	if !(Xsqlite3StrICmp(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FzDbSName, zDb) == 0) {
  55267 		goto __7
  55268 	}
  55269 	pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpSchema
  55270 	goto __6
  55271 __7:
  55272 	;
  55273 	goto __5
  55274 __5:
  55275 	i++
  55276 	goto __4
  55277 	goto __6
  55278 __6:
  55279 	;
  55280 	if !(i == (*Sqlite3)(unsafe.Pointer(db)).FnDb && Xsqlite3StrICmp(tls, ts+6441, zDb) == 0) {
  55281 		goto __8
  55282 	}
  55283 
  55284 	pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema
  55285 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName
  55286 __8:
  55287 	;
  55288 __3:
  55289 	;
  55290 __1:
  55291 	;
  55292 __9:
  55293 	pSrcList = (*NameContext)(unsafe.Pointer(pNC)).FpSrcList
  55294 
  55295 	if !(pSrcList != 0) {
  55296 		goto __12
  55297 	}
  55298 	i = 0
  55299 	pItem = pSrcList + 8
  55300 __13:
  55301 	if !(i < (*SrcList)(unsafe.Pointer(pSrcList)).FnSrc) {
  55302 		goto __15
  55303 	}
  55304 	pTab = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
  55305 
  55306 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x2000>>13)) != 0) {
  55307 		goto __16
  55308 	}
  55309 
  55310 	hit = 0
  55311 
  55312 	pEList = (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpSelect)).FpEList
  55313 
  55314 	j = 0
  55315 __17:
  55316 	if !(j < (*ExprList)(unsafe.Pointer(pEList)).FnExpr) {
  55317 		goto __19
  55318 	}
  55319 	if !!(Xsqlite3MatchEName(tls, pEList+8+uintptr(j)*20, zCol, zTab, zDb) != 0) {
  55320 		goto __20
  55321 	}
  55322 	goto __18
  55323 __20:
  55324 	;
  55325 	if !(cnt > 0) {
  55326 		goto __21
  55327 	}
  55328 	if !(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x400>>10) == 0 ||
  55329 		Xsqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 48)), zCol) < 0) {
  55330 		goto __22
  55331 	}
  55332 
  55333 	Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96)))
  55334 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  55335 	goto __23
  55336 __22:
  55337 	if !(int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_RIGHT == 0) {
  55338 		goto __24
  55339 	}
  55340 
  55341 	goto __18
  55342 	goto __25
  55343 __24:
  55344 	if !(int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_LEFT == 0) {
  55345 		goto __26
  55346 	}
  55347 
  55348 	cnt = 0
  55349 	Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96)))
  55350 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  55351 	goto __27
  55352 __26:
  55353 	extendFJMatch(tls, pParse, bp+96, pMatch, (*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  55354 __27:
  55355 	;
  55356 __25:
  55357 	;
  55358 __23:
  55359 	;
  55360 __21:
  55361 	;
  55362 	cnt++
  55363 	cntTab = 2
  55364 	pMatch = pItem
  55365 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar(j)
  55366 	libc.SetBitFieldPtr16Uint32(pEList+8+uintptr(j)*20+8+4, uint32(1), 6, 0x40)
  55367 	hit = 1
  55368 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*20 + 8 + 4))&0x80>>7)) != 0) {
  55369 		goto __28
  55370 	}
  55371 	goto __19
  55372 __28:
  55373 	;
  55374 	goto __18
  55375 __18:
  55376 	j++
  55377 	goto __17
  55378 	goto __19
  55379 __19:
  55380 	;
  55381 	if !(hit != 0 || zTab == uintptr(0)) {
  55382 		goto __29
  55383 	}
  55384 	goto __14
  55385 __29:
  55386 	;
  55387 __16:
  55388 	;
  55389 	if !(zTab != 0) {
  55390 		goto __30
  55391 	}
  55392 	if !(zDb != 0) {
  55393 		goto __31
  55394 	}
  55395 	if !((*Table)(unsafe.Pointer(pTab)).FpSchema != pSchema) {
  55396 		goto __32
  55397 	}
  55398 	goto __14
  55399 __32:
  55400 	;
  55401 	if !(pSchema == uintptr(0) && libc.Xstrcmp(tls, zDb, ts+6446) != 0) {
  55402 		goto __33
  55403 	}
  55404 	goto __14
  55405 __33:
  55406 	;
  55407 __31:
  55408 	;
  55409 	if !((*SrcItem)(unsafe.Pointer(pItem)).FzAlias != uintptr(0)) {
  55410 		goto __34
  55411 	}
  55412 	if !(Xsqlite3StrICmp(tls, zTab, (*SrcItem)(unsafe.Pointer(pItem)).FzAlias) != 0) {
  55413 		goto __36
  55414 	}
  55415 	goto __14
  55416 __36:
  55417 	;
  55418 	goto __35
  55419 __34:
  55420 	if !(Xsqlite3StrICmp(tls, zTab, (*Table)(unsafe.Pointer(pTab)).FzName) != 0) {
  55421 		goto __37
  55422 	}
  55423 	if !((*Table)(unsafe.Pointer(pTab)).Ftnum != Pgno(1)) {
  55424 		goto __38
  55425 	}
  55426 	goto __14
  55427 __38:
  55428 	;
  55429 	if !!(isValidSchemaTableName(tls, zTab, pTab, pSchema) != 0) {
  55430 		goto __39
  55431 	}
  55432 	goto __14
  55433 __39:
  55434 	;
  55435 __37:
  55436 	;
  55437 __35:
  55438 	;
  55439 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && (*SrcItem)(unsafe.Pointer(pItem)).FzAlias != 0) {
  55440 		goto __40
  55441 	}
  55442 	Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+44)
  55443 __40:
  55444 	;
  55445 __30:
  55446 	;
  55447 	hCol = Xsqlite3StrIHash(tls, zCol)
  55448 	j = 0
  55449 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  55450 __41:
  55451 	if !(j < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  55452 		goto __43
  55453 	}
  55454 	if !(int32((*Column)(unsafe.Pointer(pCol)).FhName) == int32(hCol) &&
  55455 		Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName, zCol) == 0) {
  55456 		goto __44
  55457 	}
  55458 	if !(cnt > 0) {
  55459 		goto __45
  55460 	}
  55461 	if !(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x400>>10) == 0 ||
  55462 		Xsqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 48)), zCol) < 0) {
  55463 		goto __46
  55464 	}
  55465 
  55466 	Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96)))
  55467 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  55468 	goto __47
  55469 __46:
  55470 	if !(int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_RIGHT == 0) {
  55471 		goto __48
  55472 	}
  55473 
  55474 	goto __42
  55475 	goto __49
  55476 __48:
  55477 	if !(int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_LEFT == 0) {
  55478 		goto __50
  55479 	}
  55480 
  55481 	cnt = 0
  55482 	Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96)))
  55483 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  55484 	goto __51
  55485 __50:
  55486 	extendFJMatch(tls, pParse, bp+96, pMatch, (*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  55487 __51:
  55488 	;
  55489 __49:
  55490 	;
  55491 __47:
  55492 	;
  55493 __45:
  55494 	;
  55495 	cnt++
  55496 	pMatch = pItem
  55497 
  55498 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = func() int16 {
  55499 		if j == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  55500 			return int16(-1)
  55501 		}
  55502 		return I16(j)
  55503 	}()
  55504 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x2000>>13)) != 0) {
  55505 		goto __52
  55506 	}
  55507 	Xsqlite3SrcItemColumnUsed(tls, pItem, j)
  55508 __52:
  55509 	;
  55510 	goto __43
  55511 __44:
  55512 	;
  55513 	goto __42
  55514 __42:
  55515 	j++
  55516 	pCol += 16
  55517 	goto __41
  55518 	goto __43
  55519 __43:
  55520 	;
  55521 	if !(0 == cnt && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_NoVisibleRowid) == U32(0)) {
  55522 		goto __53
  55523 	}
  55524 	cntTab++
  55525 	pMatch = pItem
  55526 __53:
  55527 	;
  55528 	goto __14
  55529 __14:
  55530 	i++
  55531 	pItem += 72
  55532 	goto __13
  55533 	goto __15
  55534 __15:
  55535 	;
  55536 	if !(pMatch != 0) {
  55537 		goto __54
  55538 	}
  55539 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SrcItem)(unsafe.Pointer(pMatch)).FiCursor
  55540 
  55541 	*(*uintptr)(unsafe.Pointer(pExpr + 44)) = (*SrcItem)(unsafe.Pointer(pMatch)).FpTab
  55542 	if !(int32((*SrcItem)(unsafe.Pointer(pMatch)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ) != 0) {
  55543 		goto __55
  55544 	}
  55545 	*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_CanBeNull)
  55546 __55:
  55547 	;
  55548 	pSchema = (*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FpSchema
  55549 __54:
  55550 	;
  55551 __12:
  55552 	;
  55553 	if !(cnt == 0 && zDb == uintptr(0)) {
  55554 		goto __56
  55555 	}
  55556 	pTab = uintptr(0)
  55557 	if !((*Parse)(unsafe.Pointer(pParse)).FpTriggerTab != uintptr(0)) {
  55558 		goto __57
  55559 	}
  55560 	op = int32((*Parse)(unsafe.Pointer(pParse)).FeTriggerOp)
  55561 
  55562 	if !((*Parse)(unsafe.Pointer(pParse)).FbReturning != 0) {
  55563 		goto __58
  55564 	}
  55565 	if !((*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_UBaseReg != 0 &&
  55566 		(zTab == uintptr(0) || Xsqlite3StrICmp(tls, zTab, (*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpTriggerTab)).FzName) == 0)) {
  55567 		goto __60
  55568 	}
  55569 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = libc.Bool32(op != TK_DELETE)
  55570 	pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab
  55571 __60:
  55572 	;
  55573 	goto __59
  55574 __58:
  55575 	if !(op != TK_DELETE && zTab != 0 && Xsqlite3StrICmp(tls, ts+6448, zTab) == 0) {
  55576 		goto __61
  55577 	}
  55578 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = 1
  55579 	pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab
  55580 	goto __62
  55581 __61:
  55582 	if !(op != TK_INSERT && zTab != 0 && Xsqlite3StrICmp(tls, ts+6452, zTab) == 0) {
  55583 		goto __63
  55584 	}
  55585 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = 0
  55586 	pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab
  55587 __63:
  55588 	;
  55589 __62:
  55590 	;
  55591 __59:
  55592 	;
  55593 __57:
  55594 	;
  55595 	if !((*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_UUpsert != 0 && zTab != uintptr(0)) {
  55596 		goto __64
  55597 	}
  55598 	pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 8))
  55599 	if !(pUpsert != 0 && Xsqlite3StrICmp(tls, ts+6456, zTab) == 0) {
  55600 		goto __65
  55601 	}
  55602 	pTab = (*SrcItem)(unsafe.Pointer((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8)).FpTab
  55603 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = EXCLUDED_TABLE_NUMBER
  55604 __65:
  55605 	;
  55606 __64:
  55607 	;
  55608 	if !(pTab != 0) {
  55609 		goto __66
  55610 	}
  55611 	hCol1 = Xsqlite3StrIHash(tls, zCol)
  55612 	pSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema
  55613 	cntTab++
  55614 	iCol = 0
  55615 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  55616 __67:
  55617 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  55618 		goto __69
  55619 	}
  55620 	if !(int32((*Column)(unsafe.Pointer(pCol)).FhName) == int32(hCol1) &&
  55621 		Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName, zCol) == 0) {
  55622 		goto __70
  55623 	}
  55624 	if !(iCol == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  55625 		goto __71
  55626 	}
  55627 	iCol = -1
  55628 __71:
  55629 	;
  55630 	goto __69
  55631 __70:
  55632 	;
  55633 	goto __68
  55634 __68:
  55635 	iCol++
  55636 	pCol += 16
  55637 	goto __67
  55638 	goto __69
  55639 __69:
  55640 	;
  55641 	if !(iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol) && Xsqlite3IsRowid(tls, zCol) != 0 && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_NoVisibleRowid) == U32(0)) {
  55642 		goto __72
  55643 	}
  55644 
  55645 	iCol = -1
  55646 __72:
  55647 	;
  55648 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  55649 		goto __73
  55650 	}
  55651 	cnt++
  55652 	pMatch = uintptr(0)
  55653 	if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == EXCLUDED_TABLE_NUMBER) {
  55654 		goto __74
  55655 	}
  55656 
  55657 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  55658 		goto __76
  55659 	}
  55660 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar(iCol)
  55661 	*(*uintptr)(unsafe.Pointer(pExpr + 44)) = pTab
  55662 	eNewExprOp = TK_COLUMN
  55663 	goto __77
  55664 __76:
  55665 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = (*Upsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 8)))).FregData + int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol)))
  55666 	eNewExprOp = TK_REGISTER
  55667 __77:
  55668 	;
  55669 	goto __75
  55670 __74:
  55671 	;
  55672 	*(*uintptr)(unsafe.Pointer(pExpr + 44)) = pTab
  55673 	if !((*Parse)(unsafe.Pointer(pParse)).FbReturning != 0) {
  55674 		goto __78
  55675 	}
  55676 	eNewExprOp = TK_REGISTER
  55677 	(*Expr)(unsafe.Pointer(pExpr)).Fop2 = U8(TK_COLUMN)
  55678 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar(iCol)
  55679 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = *(*int32)(unsafe.Pointer(pNC + 8)) + (int32((*Table)(unsafe.Pointer(pTab)).FnCol)+1)*(*Expr)(unsafe.Pointer(pExpr)).FiTable + int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + 1
  55680 	goto __79
  55681 __78:
  55682 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = I16(iCol)
  55683 	eNewExprOp = TK_TRIGGER
  55684 	if !(iCol < 0) {
  55685 		goto __80
  55686 	}
  55687 	(*Expr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER)
  55688 	goto __81
  55689 __80:
  55690 	if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == 0) {
  55691 		goto __82
  55692 	}
  55693 
  55694 	*(*U32)(unsafe.Pointer(pParse + 144)) |= func() uint32 {
  55695 		if iCol >= 32 {
  55696 			return 0xffffffff
  55697 		}
  55698 		return U32(1) << iCol
  55699 	}()
  55700 	goto __83
  55701 __82:
  55702 	;
  55703 	*(*U32)(unsafe.Pointer(pParse + 148)) |= func() uint32 {
  55704 		if iCol >= 32 {
  55705 			return 0xffffffff
  55706 		}
  55707 		return U32(1) << iCol
  55708 	}()
  55709 __83:
  55710 	;
  55711 __81:
  55712 	;
  55713 __79:
  55714 	;
  55715 __75:
  55716 	;
  55717 __73:
  55718 	;
  55719 __66:
  55720 	;
  55721 __56:
  55722 	;
  55723 	if !(cnt == 0 &&
  55724 		cntTab == 1 &&
  55725 		pMatch != 0 &&
  55726 		(*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_IdxExpr|NC_GenCol) == 0 &&
  55727 		Xsqlite3IsRowid(tls, zCol) != 0 &&
  55728 		(*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pMatch)).FpTab)).FtabFlags&U32(TF_NoVisibleRowid) == U32(0)) {
  55729 		goto __84
  55730 	}
  55731 	cnt = 1
  55732 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = int16(-1)
  55733 	(*Expr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER)
  55734 __84:
  55735 	;
  55736 	if !(cnt == 0 &&
  55737 		(*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_UEList != 0 &&
  55738 		zTab == uintptr(0)) {
  55739 		goto __85
  55740 	}
  55741 	pEList = *(*uintptr)(unsafe.Pointer(pNC + 8))
  55742 
  55743 	j = 0
  55744 __86:
  55745 	if !(j < (*ExprList)(unsafe.Pointer(pEList)).FnExpr) {
  55746 		goto __88
  55747 	}
  55748 	zAs = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*20)).FzEName
  55749 	if !(int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*20 + 8 + 4))&0x3>>0) == ENAME_NAME &&
  55750 		Xsqlite3_stricmp(tls, zAs, zCol) == 0) {
  55751 		goto __89
  55752 	}
  55753 
  55754 	pOrig = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*20)).FpExpr
  55755 	if !((*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_AllowAgg == 0 && (*Expr)(unsafe.Pointer(pOrig)).Fflags&U32(EP_Agg) != U32(0)) {
  55756 		goto __90
  55757 	}
  55758 	Xsqlite3ErrorMsg(tls, pParse, ts+6465, libc.VaList(bp, zAs))
  55759 	return WRC_Abort
  55760 __90:
  55761 	;
  55762 	if !((*Expr)(unsafe.Pointer(pOrig)).Fflags&U32(EP_Win) != U32(0) &&
  55763 		((*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_AllowWin == 0 || pNC != pTopNC)) {
  55764 		goto __91
  55765 	}
  55766 	Xsqlite3ErrorMsg(tls, pParse, ts+6496, libc.VaList(bp+8, zAs))
  55767 	return WRC_Abort
  55768 __91:
  55769 	;
  55770 	if !(Xsqlite3ExprVectorSize(tls, pOrig) != 1) {
  55771 		goto __92
  55772 	}
  55773 	Xsqlite3ErrorMsg(tls, pParse, ts+6533, 0)
  55774 	return WRC_Abort
  55775 __92:
  55776 	;
  55777 	resolveAlias(tls, pParse, pEList, j, pExpr, nSubquery)
  55778 	cnt = 1
  55779 	pMatch = uintptr(0)
  55780 
  55781 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  55782 		goto __93
  55783 	}
  55784 	Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr)
  55785 __93:
  55786 	;
  55787 	goto lookupname_end
  55788 __89:
  55789 	;
  55790 	goto __87
  55791 __87:
  55792 	j++
  55793 	goto __86
  55794 	goto __88
  55795 __88:
  55796 	;
  55797 __85:
  55798 	;
  55799 	if !(cnt != 0) {
  55800 		goto __94
  55801 	}
  55802 	goto __11
  55803 __94:
  55804 	;
  55805 	pNC = (*NameContext)(unsafe.Pointer(pNC)).FpNext
  55806 	nSubquery++
  55807 	goto __10
  55808 __10:
  55809 	if pNC != 0 {
  55810 		goto __9
  55811 	}
  55812 	goto __11
  55813 __11:
  55814 	;
  55815 	if !(cnt == 0 && zTab == uintptr(0)) {
  55816 		goto __95
  55817 	}
  55818 
  55819 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_DblQuoted) != U32(0) &&
  55820 		areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0) {
  55821 		goto __96
  55822 	}
  55823 
  55824 	Xsqlite3_log(tls, SQLITE_WARNING,
  55825 		ts+6551, libc.VaList(bp+16, zCol))
  55826 	(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_STRING)
  55827 	libc.Xmemset(tls, pExpr+44, 0, uint32(unsafe.Sizeof(struct {
  55828 		FpTab        uintptr
  55829 		F__ccgo_pad1 [4]byte
  55830 	}{})))
  55831 	return WRC_Prune
  55832 __96:
  55833 	;
  55834 	if !(Xsqlite3ExprIdToTrueFalse(tls, pExpr) != 0) {
  55835 		goto __97
  55836 	}
  55837 	return WRC_Prune
  55838 __97:
  55839 	;
  55840 __95:
  55841 	;
  55842 	if !(cnt != 1) {
  55843 		goto __98
  55844 	}
  55845 	if !(*(*uintptr)(unsafe.Pointer(bp + 96)) != 0) {
  55846 		goto __99
  55847 	}
  55848 	if !((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 96)))).FnExpr == cnt-1) {
  55849 		goto __100
  55850 	}
  55851 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Leaf) != U32(0)) {
  55852 		goto __102
  55853 	}
  55854 	*(*U32)(unsafe.Pointer(pExpr + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Leaf))
  55855 	goto __103
  55856 __102:
  55857 	Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  55858 	(*Expr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0)
  55859 	Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  55860 	(*Expr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0)
  55861 __103:
  55862 	;
  55863 	extendFJMatch(tls, pParse, bp+96, pMatch, (*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  55864 	(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_FUNCTION)
  55865 	*(*uintptr)(unsafe.Pointer(pExpr + 8)) = ts + 6586
  55866 	*(*uintptr)(unsafe.Pointer(pExpr + 20)) = *(*uintptr)(unsafe.Pointer(bp + 96))
  55867 	cnt = 1
  55868 	goto lookupname_end
  55869 	goto __101
  55870 __100:
  55871 	Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96)))
  55872 	*(*uintptr)(unsafe.Pointer(bp + 96)) = uintptr(0)
  55873 __101:
  55874 	;
  55875 __99:
  55876 	;
  55877 	if cnt == 0 {
  55878 		zErr = ts + 6595
  55879 	} else {
  55880 		zErr = ts + 6610
  55881 	}
  55882 	if !(zDb != 0) {
  55883 		goto __104
  55884 	}
  55885 	Xsqlite3ErrorMsg(tls, pParse, ts+6632, libc.VaList(bp+24, zErr, zDb, zTab, zCol))
  55886 	goto __105
  55887 __104:
  55888 	if !(zTab != 0) {
  55889 		goto __106
  55890 	}
  55891 	Xsqlite3ErrorMsg(tls, pParse, ts+6645, libc.VaList(bp+56, zErr, zTab, zCol))
  55892 	goto __107
  55893 __106:
  55894 	Xsqlite3ErrorMsg(tls, pParse, ts+6655, libc.VaList(bp+80, zErr, zCol))
  55895 __107:
  55896 	;
  55897 __105:
  55898 	;
  55899 	Xsqlite3RecordErrorOffsetOfExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  55900 	(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  55901 	(*NameContext)(unsafe.Pointer(pTopNC)).FnNcErr++
  55902 __98:
  55903 	;
  55904 	if !!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_TokenOnly|EP_Leaf) != U32(0)) {
  55905 		goto __108
  55906 	}
  55907 	Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  55908 	(*Expr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0)
  55909 	Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  55910 	(*Expr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0)
  55911 	*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_Leaf)
  55912 __108:
  55913 	;
  55914 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 && pMatch != uintptr(0)) {
  55915 		goto __109
  55916 	}
  55917 	*(*Bitmask)(unsafe.Pointer(pMatch + 56)) |= Xsqlite3ExprColUsed(tls, pExpr)
  55918 __109:
  55919 	;
  55920 	(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(eNewExprOp)
  55921 lookupname_end:
  55922 	if !(cnt == 1) {
  55923 		goto __110
  55924 	}
  55925 
  55926 	if !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FxAuth != 0 &&
  55927 		(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER)) {
  55928 		goto __112
  55929 	}
  55930 	Xsqlite3AuthRead(tls, pParse, pExpr, pSchema, (*NameContext)(unsafe.Pointer(pNC)).FpSrcList)
  55931 __112:
  55932 	;
  55933 __113:
  55934 	;
  55935 	(*NameContext)(unsafe.Pointer(pTopNC)).FnRef++
  55936 	if !(pTopNC == pNC) {
  55937 		goto __116
  55938 	}
  55939 	goto __115
  55940 __116:
  55941 	;
  55942 	pTopNC = (*NameContext)(unsafe.Pointer(pTopNC)).FpNext
  55943 	goto __114
  55944 __114:
  55945 	goto __113
  55946 	goto __115
  55947 __115:
  55948 	;
  55949 	return WRC_Prune
  55950 	goto __111
  55951 __110:
  55952 	return WRC_Abort
  55953 __111:
  55954 	;
  55955 	return int32(0)
  55956 }
  55957 
  55958 // Allocate and return a pointer to an expression to load the column iCol
  55959 // from datasource iSrc in SrcList pSrc.
  55960 func Xsqlite3CreateColumnExpr(tls *libc.TLS, db uintptr, pSrc uintptr, iSrc int32, iCol int32) uintptr {
  55961 	var p uintptr = Xsqlite3ExprAlloc(tls, db, TK_COLUMN, uintptr(0), 0)
  55962 	if p != 0 {
  55963 		var pItem uintptr = pSrc + 8 + uintptr(iSrc)*72
  55964 		var pTab uintptr
  55965 
  55966 		pTab = libc.AssignPtrUintptr(p+44, (*SrcItem)(unsafe.Pointer(pItem)).FpTab)
  55967 		(*Expr)(unsafe.Pointer(p)).FiTable = (*SrcItem)(unsafe.Pointer(pItem)).FiCursor
  55968 		if int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FiPKey) == iCol {
  55969 			(*Expr)(unsafe.Pointer(p)).FiColumn = int16(-1)
  55970 		} else {
  55971 			(*Expr)(unsafe.Pointer(p)).FiColumn = YnVar(iCol)
  55972 			if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != U32(0) &&
  55973 				int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FcolFlags)&COLFLAG_GENERATED != 0 {
  55974 				(*SrcItem)(unsafe.Pointer(pItem)).FcolUsed = func() uint64 {
  55975 					if int32((*Table)(unsafe.Pointer(pTab)).FnCol) >= 64 {
  55976 						return libc.Uint64(libc.Uint64FromInt32(-1))
  55977 					}
  55978 					return uint64(1)<<int32((*Table)(unsafe.Pointer(pTab)).FnCol) - uint64(1)
  55979 				}()
  55980 			} else {
  55981 				*(*Bitmask)(unsafe.Pointer(pItem + 56)) |= uint64(1) << func() int32 {
  55982 					if iCol >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) {
  55983 						return int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) - 1
  55984 					}
  55985 					return iCol
  55986 				}()
  55987 			}
  55988 		}
  55989 	}
  55990 	return p
  55991 }
  55992 
  55993 func notValidImpl(tls *libc.TLS, pParse uintptr, pNC uintptr, zMsg uintptr, pExpr uintptr, pError uintptr) {
  55994 	bp := tls.Alloc(16)
  55995 	defer tls.Free(16)
  55996 
  55997 	var zIn uintptr = ts + 6662
  55998 	if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_IdxExpr != 0 {
  55999 		zIn = ts + 6690
  56000 	} else if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_IsCheck != 0 {
  56001 		zIn = ts + 6708
  56002 	} else if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_GenCol != 0 {
  56003 		zIn = ts + 6726
  56004 	}
  56005 	Xsqlite3ErrorMsg(tls, pParse, ts+6744, libc.VaList(bp, zMsg, zIn))
  56006 	if pExpr != 0 {
  56007 		(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_NULL)
  56008 	}
  56009 	Xsqlite3RecordErrorOffsetOfExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pError)
  56010 }
  56011 
  56012 func exprProbability(tls *libc.TLS, p uintptr) int32 {
  56013 	bp := tls.Alloc(8)
  56014 	defer tls.Free(8)
  56015 
  56016 	*(*float64)(unsafe.Pointer(bp)) = -1.0
  56017 	if int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_FLOAT {
  56018 		return -1
  56019 	}
  56020 
  56021 	Xsqlite3AtoF(tls, *(*uintptr)(unsafe.Pointer(p + 8)), bp, Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8))), uint8(SQLITE_UTF8))
  56022 
  56023 	if *(*float64)(unsafe.Pointer(bp)) > 1.0 {
  56024 		return -1
  56025 	}
  56026 	return libc.Int32FromFloat64(*(*float64)(unsafe.Pointer(bp)) * 134217728.0)
  56027 }
  56028 
  56029 func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  56030 	bp := tls.Alloc(96)
  56031 	defer tls.Free(96)
  56032 
  56033 	var pNC uintptr
  56034 	var pParse uintptr
  56035 
  56036 	pNC = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  56037 
  56038 	pParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  56039 
  56040 	switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  56041 	case TK_ROW:
  56042 		{
  56043 			var pSrcList uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpSrcList
  56044 			var pItem uintptr
  56045 
  56046 			pItem = pSrcList + 8
  56047 			(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_COLUMN)
  56048 
  56049 			*(*uintptr)(unsafe.Pointer(pExpr + 44)) = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
  56050 			(*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SrcItem)(unsafe.Pointer(pItem)).FiCursor
  56051 			(*Expr)(unsafe.Pointer(pExpr)).FiColumn--
  56052 			(*Expr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER)
  56053 			break
  56054 
  56055 		}
  56056 
  56057 	case TK_NOTNULL:
  56058 		fallthrough
  56059 	case TK_ISNULL:
  56060 		{
  56061 			var p uintptr
  56062 			var i int32
  56063 			i = 0
  56064 			p = pNC
  56065 		__1:
  56066 			if !(p != 0 && i < int32(uint32(unsafe.Sizeof([8]int32{}))/uint32(unsafe.Sizeof(int32(0))))) {
  56067 				goto __3
  56068 			}
  56069 			{
  56070 				*(*int32)(unsafe.Pointer(bp + 64 + uintptr(i)*4)) = (*NameContext)(unsafe.Pointer(p)).FnRef
  56071 
  56072 			}
  56073 			goto __2
  56074 		__2:
  56075 			p = (*NameContext)(unsafe.Pointer(p)).FpNext
  56076 			i++
  56077 			goto __1
  56078 			goto __3
  56079 		__3:
  56080 			;
  56081 			Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  56082 			if 0 == Xsqlite3ExprCanBeNull(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  56083 				*(*int32)(unsafe.Pointer(pExpr + 8)) = libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL)
  56084 				*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_IntValue)
  56085 				(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_INTEGER)
  56086 
  56087 				i = 0
  56088 				p = pNC
  56089 			__4:
  56090 				if !(p != 0 && i < int32(uint32(unsafe.Sizeof([8]int32{}))/uint32(unsafe.Sizeof(int32(0))))) {
  56091 					goto __6
  56092 				}
  56093 				{
  56094 					(*NameContext)(unsafe.Pointer(p)).FnRef = *(*int32)(unsafe.Pointer(bp + 64 + uintptr(i)*4))
  56095 
  56096 				}
  56097 				goto __5
  56098 			__5:
  56099 				p = (*NameContext)(unsafe.Pointer(p)).FpNext
  56100 				i++
  56101 				goto __4
  56102 				goto __6
  56103 			__6:
  56104 				;
  56105 				Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  56106 				(*Expr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0)
  56107 			}
  56108 			return WRC_Prune
  56109 
  56110 		}
  56111 
  56112 	case TK_ID:
  56113 		fallthrough
  56114 	case TK_DOT:
  56115 		{
  56116 			var zColumn uintptr
  56117 			var zTable uintptr
  56118 			var zDb uintptr
  56119 			var pRight uintptr
  56120 
  56121 			if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ID {
  56122 				zDb = uintptr(0)
  56123 				zTable = uintptr(0)
  56124 
  56125 				zColumn = *(*uintptr)(unsafe.Pointer(pExpr + 8))
  56126 			} else {
  56127 				var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  56128 
  56129 				if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_IdxExpr|NC_GenCol) != 0 {
  56130 					notValidImpl(tls, pParse, pNC, ts+6764, uintptr(0), pExpr)
  56131 				}
  56132 
  56133 				pRight = (*Expr)(unsafe.Pointer(pExpr)).FpRight
  56134 				if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_ID {
  56135 					zDb = uintptr(0)
  56136 				} else {
  56137 					zDb = *(*uintptr)(unsafe.Pointer(pLeft + 8))
  56138 					pLeft = (*Expr)(unsafe.Pointer(pRight)).FpLeft
  56139 					pRight = (*Expr)(unsafe.Pointer(pRight)).FpRight
  56140 				}
  56141 
  56142 				zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8))
  56143 				zColumn = *(*uintptr)(unsafe.Pointer(pRight + 8))
  56144 
  56145 				if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  56146 					Xsqlite3RenameTokenRemap(tls, pParse, pExpr, pRight)
  56147 					Xsqlite3RenameTokenRemap(tls, pParse, pExpr+44, pLeft)
  56148 				}
  56149 			}
  56150 			return lookupName(tls, pParse, zDb, zTable, zColumn, pNC, pExpr)
  56151 
  56152 		}
  56153 
  56154 	case TK_FUNCTION:
  56155 		{
  56156 			var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  56157 			var n int32
  56158 			if pList != 0 {
  56159 				n = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  56160 			} else {
  56161 				n = 0
  56162 			}
  56163 			var no_such_func int32 = 0
  56164 			var wrong_num_args int32 = 0
  56165 			var is_agg int32 = 0
  56166 			var zId uintptr
  56167 			var pDef uintptr
  56168 			var enc U8 = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fenc
  56169 			var savedAllowFlags int32 = (*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_AllowAgg | NC_AllowWin)
  56170 			var pWin uintptr = func() uintptr {
  56171 				if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) && int32((*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FeFrmType) != TK_FILTER {
  56172 					return *(*uintptr)(unsafe.Pointer(pExpr + 44))
  56173 				}
  56174 				return uintptr(0)
  56175 			}()
  56176 
  56177 			zId = *(*uintptr)(unsafe.Pointer(pExpr + 8))
  56178 			pDef = Xsqlite3FindFunction(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zId, n, enc, uint8(0))
  56179 			if pDef == uintptr(0) {
  56180 				pDef = Xsqlite3FindFunction(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zId, -2, enc, uint8(0))
  56181 				if pDef == uintptr(0) {
  56182 					no_such_func = 1
  56183 				} else {
  56184 					wrong_num_args = 1
  56185 				}
  56186 			} else {
  56187 				is_agg = libc.Bool32((*FuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0))
  56188 				if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_UNLIKELY) != 0 {
  56189 					*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_Unlikely)
  56190 					if n == 2 {
  56191 						(*Expr)(unsafe.Pointer(pExpr)).FiTable = exprProbability(tls, (*ExprList_item)(unsafe.Pointer(pList+8+1*20)).FpExpr)
  56192 						if (*Expr)(unsafe.Pointer(pExpr)).FiTable < 0 {
  56193 							Xsqlite3ErrorMsg(tls, pParse,
  56194 								ts+6781, libc.VaList(bp, pExpr))
  56195 							(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56196 						}
  56197 					} else {
  56198 						(*Expr)(unsafe.Pointer(pExpr)).FiTable = func() int32 {
  56199 							if int32(*(*uint8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer(pDef)).FzName))) == 'u' {
  56200 								return 8388608
  56201 							}
  56202 							return 125829120
  56203 						}()
  56204 					}
  56205 				}
  56206 				{
  56207 					var auth int32 = Xsqlite3AuthCheck(tls, pParse, SQLITE_FUNCTION, uintptr(0), (*FuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0))
  56208 					if auth != SQLITE_OK {
  56209 						if auth == SQLITE_DENY {
  56210 							Xsqlite3ErrorMsg(tls, pParse, ts+6845,
  56211 								libc.VaList(bp+8, pExpr))
  56212 							(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56213 						}
  56214 						(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_NULL)
  56215 						return WRC_Prune
  56216 					}
  56217 
  56218 				}
  56219 				if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) != 0 {
  56220 					*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_ConstFunc)
  56221 				}
  56222 				if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_CONSTANT) == U32(0) {
  56223 					if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_IdxExpr|NC_PartIdx|NC_GenCol) != 0 {
  56224 						notValidImpl(tls, pParse, pNC, ts+6881, uintptr(0), pExpr)
  56225 					}
  56226 
  56227 				} else {
  56228 					(*Expr)(unsafe.Pointer(pExpr)).Fop2 = U8((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_SelfRef)
  56229 					if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_FromDDL != 0 {
  56230 						*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_FromDDL)
  56231 					}
  56232 				}
  56233 				if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_INTERNAL) != U32(0) &&
  56234 					int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 &&
  56235 					(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&U32(DBFLAG_InternalFunc) == U32(0) {
  56236 					no_such_func = 1
  56237 					pDef = uintptr(0)
  56238 				} else if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE) != U32(0) &&
  56239 					!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  56240 					Xsqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef)
  56241 				}
  56242 			}
  56243 
  56244 			if 0 == libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  56245 				if pDef != 0 && (*FuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0) && pWin != 0 {
  56246 					Xsqlite3ErrorMsg(tls, pParse,
  56247 						ts+6909, libc.VaList(bp+16, pExpr))
  56248 					(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56249 				} else if is_agg != 0 && (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_AllowAgg == 0 ||
  56250 					is_agg != 0 && (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_WINDOW) != 0 && !(pWin != 0) ||
  56251 					is_agg != 0 && pWin != 0 && (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_AllowWin == 0 {
  56252 					var zType uintptr
  56253 					if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_WINDOW) != 0 || pWin != 0 {
  56254 						zType = ts + 6952
  56255 					} else {
  56256 						zType = ts + 6959
  56257 					}
  56258 					Xsqlite3ErrorMsg(tls, pParse, ts+6969, libc.VaList(bp+24, zType, pExpr))
  56259 					(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56260 					is_agg = 0
  56261 				} else if no_such_func != 0 && int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Finit.Fbusy) == 0 {
  56262 					Xsqlite3ErrorMsg(tls, pParse, ts+6997, libc.VaList(bp+40, pExpr))
  56263 					(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56264 				} else if wrong_num_args != 0 {
  56265 					Xsqlite3ErrorMsg(tls, pParse, ts+7019,
  56266 						libc.VaList(bp+48, pExpr))
  56267 					(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56268 				} else if is_agg == 0 && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  56269 					Xsqlite3ErrorMsg(tls, pParse,
  56270 						ts+7063,
  56271 						libc.VaList(bp+56, pExpr))
  56272 					(*NameContext)(unsafe.Pointer(pNC)).FnNcErr++
  56273 				}
  56274 				if is_agg != 0 {
  56275 					*(*int32)(unsafe.Pointer(pNC + 24)) &= ^(NC_AllowWin | func() int32 {
  56276 						if !(pWin != 0) {
  56277 							return NC_AllowAgg
  56278 						}
  56279 						return 0
  56280 					}())
  56281 				}
  56282 			} else if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  56283 				is_agg = 1
  56284 			}
  56285 			Xsqlite3WalkExprList(tls, pWalker, pList)
  56286 			if is_agg != 0 {
  56287 				if pWin != 0 {
  56288 					var pSel uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpWinSelect
  56289 
  56290 					if libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) == 0 {
  56291 						Xsqlite3WindowUpdate(tls, pParse, func() uintptr {
  56292 							if pSel != 0 {
  56293 								return (*Select)(unsafe.Pointer(pSel)).FpWinDefn
  56294 							}
  56295 							return uintptr(0)
  56296 						}(), pWin, pDef)
  56297 						if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  56298 							break
  56299 						}
  56300 					}
  56301 					Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpPartition)
  56302 					Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpOrderBy)
  56303 					Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpFilter)
  56304 					Xsqlite3WindowLink(tls, pSel, pWin)
  56305 					*(*int32)(unsafe.Pointer(pNC + 24)) |= NC_HasWin
  56306 				} else {
  56307 					var pNC2 uintptr
  56308 					(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_AGG_FUNCTION)
  56309 					(*Expr)(unsafe.Pointer(pExpr)).Fop2 = U8(0)
  56310 					if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  56311 						Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FpFilter)
  56312 					}
  56313 					pNC2 = pNC
  56314 					for pNC2 != 0 &&
  56315 						Xsqlite3ReferencesSrcList(tls, pParse, pExpr, (*NameContext)(unsafe.Pointer(pNC2)).FpSrcList) == 0 {
  56316 						(*Expr)(unsafe.Pointer(pExpr)).Fop2++
  56317 						pNC2 = (*NameContext)(unsafe.Pointer(pNC2)).FpNext
  56318 					}
  56319 
  56320 					if pNC2 != 0 && pDef != 0 {
  56321 						*(*int32)(unsafe.Pointer(pNC2 + 24)) |= int32(U32(NC_HasAgg) |
  56322 							((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags^U32(SQLITE_FUNC_ANYORDER))&
  56323 								U32(SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER))
  56324 					}
  56325 				}
  56326 				*(*int32)(unsafe.Pointer(pNC + 24)) |= savedAllowFlags
  56327 			}
  56328 
  56329 			return WRC_Prune
  56330 
  56331 		}
  56332 	case TK_SELECT:
  56333 		fallthrough
  56334 	case TK_EXISTS:
  56335 		fallthrough
  56336 	case TK_IN:
  56337 		{
  56338 			if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  56339 				var nRef int32 = (*NameContext)(unsafe.Pointer(pNC)).FnRef
  56340 
  56341 				if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_SelfRef != 0 {
  56342 					notValidImpl(tls, pParse, pNC, ts+7111, pExpr, pExpr)
  56343 				} else {
  56344 					Xsqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 20)))
  56345 				}
  56346 
  56347 				if nRef != (*NameContext)(unsafe.Pointer(pNC)).FnRef {
  56348 					*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_VarSelect)
  56349 				}
  56350 				*(*int32)(unsafe.Pointer(pNC + 24)) |= NC_Subquery
  56351 			}
  56352 			break
  56353 
  56354 		}
  56355 	case TK_VARIABLE:
  56356 		{
  56357 			if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol) != 0 {
  56358 				notValidImpl(tls, pParse, pNC, ts+7122, pExpr, pExpr)
  56359 			}
  56360 
  56361 			break
  56362 
  56363 		}
  56364 	case TK_IS:
  56365 		fallthrough
  56366 	case TK_ISNOT:
  56367 		{
  56368 			var pRight uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  56369 
  56370 			if pRight != 0 && (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_ID || int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_TRUEFALSE) {
  56371 				var rc int32 = resolveExprStep(tls, pWalker, pRight)
  56372 				if rc == WRC_Abort {
  56373 					return WRC_Abort
  56374 				}
  56375 				if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_TRUEFALSE {
  56376 					(*Expr)(unsafe.Pointer(pExpr)).Fop2 = (*Expr)(unsafe.Pointer(pExpr)).Fop
  56377 					(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_TRUTH)
  56378 					return WRC_Continue
  56379 				}
  56380 			}
  56381 
  56382 		}
  56383 		fallthrough
  56384 	case TK_BETWEEN:
  56385 		fallthrough
  56386 	case TK_EQ:
  56387 		fallthrough
  56388 	case TK_NE:
  56389 		fallthrough
  56390 	case TK_LT:
  56391 		fallthrough
  56392 	case TK_LE:
  56393 		fallthrough
  56394 	case TK_GT:
  56395 		fallthrough
  56396 	case TK_GE:
  56397 		{
  56398 			var nLeft int32
  56399 			var nRight int32
  56400 			if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  56401 				break
  56402 			}
  56403 
  56404 			nLeft = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  56405 			if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_BETWEEN {
  56406 				nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20))+8)).FpExpr)
  56407 				if nRight == nLeft {
  56408 					nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20))+8+1*20)).FpExpr)
  56409 				}
  56410 			} else {
  56411 				nRight = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  56412 			}
  56413 			if nLeft != nRight {
  56414 				Xsqlite3ErrorMsg(tls, pParse, ts+6533, 0)
  56415 				Xsqlite3RecordErrorOffsetOfExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  56416 			}
  56417 			break
  56418 
  56419 		}
  56420 	}
  56421 
  56422 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  56423 		return WRC_Abort
  56424 	}
  56425 	return WRC_Continue
  56426 }
  56427 
  56428 func resolveAsName(tls *libc.TLS, pParse uintptr, pEList uintptr, pE uintptr) int32 {
  56429 	var i int32
  56430 
  56431 	_ = pParse
  56432 
  56433 	if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_ID {
  56434 		var zCol uintptr
  56435 
  56436 		zCol = *(*uintptr)(unsafe.Pointer(pE + 8))
  56437 		for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  56438 			if int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*20 + 8 + 4))&0x3>>0) == ENAME_NAME &&
  56439 				Xsqlite3_stricmp(tls, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FzEName, zCol) == 0 {
  56440 				return i + 1
  56441 			}
  56442 		}
  56443 	}
  56444 	return 0
  56445 }
  56446 
  56447 func resolveOrderByTermToExprList(tls *libc.TLS, pParse uintptr, pSelect uintptr, pE uintptr) int32 {
  56448 	bp := tls.Alloc(32)
  56449 	defer tls.Free(32)
  56450 
  56451 	var i int32
  56452 	var pEList uintptr
  56453 
  56454 	var db uintptr
  56455 	var rc int32
  56456 	var savedSuppErr U8
  56457 
  56458 	pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList
  56459 
  56460 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  56461 	(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  56462 	(*NameContext)(unsafe.Pointer(bp)).FpSrcList = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  56463 	*(*uintptr)(unsafe.Pointer(bp + 8)) = pEList
  56464 	(*NameContext)(unsafe.Pointer(bp)).FncFlags = NC_AllowAgg | NC_UEList | NC_NoSelect
  56465 	(*NameContext)(unsafe.Pointer(bp)).FnNcErr = 0
  56466 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  56467 	savedSuppErr = (*Sqlite3)(unsafe.Pointer(db)).FsuppressErr
  56468 	(*Sqlite3)(unsafe.Pointer(db)).FsuppressErr = U8(1)
  56469 	rc = Xsqlite3ResolveExprNames(tls, bp, pE)
  56470 	(*Sqlite3)(unsafe.Pointer(db)).FsuppressErr = savedSuppErr
  56471 	if rc != 0 {
  56472 		return 0
  56473 	}
  56474 
  56475 	for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  56476 		if Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FpExpr, pE, -1) < 2 {
  56477 			return i + 1
  56478 		}
  56479 	}
  56480 
  56481 	return 0
  56482 }
  56483 
  56484 func resolveOutOfRangeError(tls *libc.TLS, pParse uintptr, zType uintptr, i int32, mx int32, pError uintptr) {
  56485 	bp := tls.Alloc(24)
  56486 	defer tls.Free(24)
  56487 
  56488 	Xsqlite3ErrorMsg(tls, pParse,
  56489 		ts+7133, libc.VaList(bp, i, zType, mx))
  56490 	Xsqlite3RecordErrorOffsetOfExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pError)
  56491 }
  56492 
  56493 func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int32 {
  56494 	bp := tls.Alloc(12)
  56495 	defer tls.Free(12)
  56496 
  56497 	var i int32
  56498 	var pOrderBy uintptr
  56499 	var pEList uintptr
  56500 	var db uintptr
  56501 	var moreToDo int32 = 1
  56502 
  56503 	pOrderBy = (*Select)(unsafe.Pointer(pSelect)).FpOrderBy
  56504 	if pOrderBy == uintptr(0) {
  56505 		return 0
  56506 	}
  56507 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  56508 	if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer(db + 120 + 2*4)) {
  56509 		Xsqlite3ErrorMsg(tls, pParse, ts+7189, 0)
  56510 		return 1
  56511 	}
  56512 	for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ {
  56513 		libc.SetBitFieldPtr16Uint32(pOrderBy+8+uintptr(i)*20+8+4, uint32(0), 2, 0x4)
  56514 	}
  56515 	(*Select)(unsafe.Pointer(pSelect)).FpNext = uintptr(0)
  56516 	for (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 {
  56517 		(*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpPrior)).FpNext = pSelect
  56518 		pSelect = (*Select)(unsafe.Pointer(pSelect)).FpPrior
  56519 	}
  56520 	for pSelect != 0 && moreToDo != 0 {
  56521 		var pItem uintptr
  56522 		moreToDo = 0
  56523 		pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList
  56524 
  56525 		i = 0
  56526 		pItem = pOrderBy + 8
  56527 	__1:
  56528 		if !(i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr) {
  56529 			goto __3
  56530 		}
  56531 		{
  56532 			*(*int32)(unsafe.Pointer(bp + 8)) = -1
  56533 			var pE uintptr
  56534 			var pDup uintptr
  56535 			if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 8 + 4))&0x4>>2)) != 0 {
  56536 				goto __2
  56537 			}
  56538 			pE = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)
  56539 			if pE == uintptr(0) {
  56540 				goto __2
  56541 			}
  56542 			if Xsqlite3ExprIsInteger(tls, pE, bp+8) != 0 {
  56543 				if *(*int32)(unsafe.Pointer(bp + 8)) <= 0 || *(*int32)(unsafe.Pointer(bp + 8)) > (*ExprList)(unsafe.Pointer(pEList)).FnExpr {
  56544 					resolveOutOfRangeError(tls, pParse, ts+7223, i+1, (*ExprList)(unsafe.Pointer(pEList)).FnExpr, pE)
  56545 					return 1
  56546 				}
  56547 			} else {
  56548 				*(*int32)(unsafe.Pointer(bp + 8)) = resolveAsName(tls, pParse, pEList, pE)
  56549 				if *(*int32)(unsafe.Pointer(bp + 8)) == 0 {
  56550 					pDup = Xsqlite3ExprDup(tls, db, pE, 0)
  56551 					if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  56552 						*(*int32)(unsafe.Pointer(bp + 8)) = resolveOrderByTermToExprList(tls, pParse, pSelect, pDup)
  56553 						if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && *(*int32)(unsafe.Pointer(bp + 8)) > 0 {
  56554 							resolveOrderByTermToExprList(tls, pParse, pSelect, pE)
  56555 						}
  56556 					}
  56557 					Xsqlite3ExprDelete(tls, db, pDup)
  56558 				}
  56559 			}
  56560 			if *(*int32)(unsafe.Pointer(bp + 8)) > 0 {
  56561 				if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  56562 					var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0))
  56563 					if pNew == uintptr(0) {
  56564 						return 1
  56565 					}
  56566 					*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_IntValue)
  56567 					*(*int32)(unsafe.Pointer(pNew + 8)) = *(*int32)(unsafe.Pointer(bp + 8))
  56568 					if (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr == pE {
  56569 						(*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = pNew
  56570 					} else {
  56571 						var pParent uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr
  56572 
  56573 						for int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == TK_COLLATE {
  56574 							pParent = (*Expr)(unsafe.Pointer(pParent)).FpLeft
  56575 						}
  56576 
  56577 						(*Expr)(unsafe.Pointer(pParent)).FpLeft = pNew
  56578 					}
  56579 					Xsqlite3ExprDelete(tls, db, pE)
  56580 					*(*U16)(unsafe.Pointer(pItem + 16)) = U16(*(*int32)(unsafe.Pointer(bp + 8)))
  56581 				}
  56582 				libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(1), 2, 0x4)
  56583 			} else {
  56584 				moreToDo = 1
  56585 			}
  56586 
  56587 		}
  56588 		goto __2
  56589 	__2:
  56590 		i++
  56591 		pItem += 20
  56592 		goto __1
  56593 		goto __3
  56594 	__3:
  56595 		;
  56596 		pSelect = (*Select)(unsafe.Pointer(pSelect)).FpNext
  56597 	}
  56598 	for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ {
  56599 		if int32(*(*uint16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20 + 8 + 4))&0x4>>2) == 0 {
  56600 			Xsqlite3ErrorMsg(tls, pParse,
  56601 				ts+7229, libc.VaList(bp, i+1))
  56602 			return 1
  56603 		}
  56604 	}
  56605 	return 0
  56606 }
  56607 
  56608 // Check every term in the ORDER BY or GROUP BY clause pOrderBy of
  56609 // the SELECT statement pSelect.  If any term is reference to a
  56610 // result set expression (as determined by the ExprList.a.u.x.iOrderByCol
  56611 // field) then convert that term into a copy of the corresponding result set
  56612 // column.
  56613 //
  56614 // If any errors are detected, add an error message to pParse and
  56615 // return non-zero.  Return zero if no errors are seen.
  56616 func Xsqlite3ResolveOrderGroupBy(tls *libc.TLS, pParse uintptr, pSelect uintptr, pOrderBy uintptr, zType uintptr) int32 {
  56617 	bp := tls.Alloc(8)
  56618 	defer tls.Free(8)
  56619 
  56620 	var i int32
  56621 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  56622 	var pEList uintptr
  56623 	var pItem uintptr
  56624 
  56625 	if pOrderBy == uintptr(0) || (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 || int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  56626 		return 0
  56627 	}
  56628 	if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer(db + 120 + 2*4)) {
  56629 		Xsqlite3ErrorMsg(tls, pParse, ts+7290, libc.VaList(bp, zType))
  56630 		return 1
  56631 	}
  56632 	pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList
  56633 
  56634 	i = 0
  56635 	pItem = pOrderBy + 8
  56636 __1:
  56637 	if !(i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr) {
  56638 		goto __3
  56639 	}
  56640 	{
  56641 		if *(*U16)(unsafe.Pointer(pItem + 16)) != 0 {
  56642 			if int32(*(*U16)(unsafe.Pointer(pItem + 16))) > (*ExprList)(unsafe.Pointer(pEList)).FnExpr {
  56643 				resolveOutOfRangeError(tls, pParse, zType, i+1, (*ExprList)(unsafe.Pointer(pEList)).FnExpr, uintptr(0))
  56644 				return 1
  56645 			}
  56646 			resolveAlias(tls, pParse, pEList, int32(*(*U16)(unsafe.Pointer(pItem + 16)))-1, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr, 0)
  56647 		}
  56648 
  56649 	}
  56650 	goto __2
  56651 __2:
  56652 	i++
  56653 	pItem += 20
  56654 	goto __1
  56655 	goto __3
  56656 __3:
  56657 	;
  56658 	return 0
  56659 }
  56660 
  56661 func resolveRemoveWindowsCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  56662 	_ = pWalker
  56663 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  56664 		var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  56665 		Xsqlite3WindowUnlinkFromSelect(tls, pWin)
  56666 	}
  56667 	return WRC_Continue
  56668 }
  56669 
  56670 func windowRemoveExprFromSelect(tls *libc.TLS, pSelect uintptr, pExpr uintptr) {
  56671 	bp := tls.Alloc(28)
  56672 	defer tls.Free(28)
  56673 
  56674 	if (*Select)(unsafe.Pointer(pSelect)).FpWin != 0 {
  56675 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  56676 		(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  56677 			f func(*libc.TLS, uintptr, uintptr) int32
  56678 		}{resolveRemoveWindowsCb}))
  56679 		*(*uintptr)(unsafe.Pointer(bp + 24)) = pSelect
  56680 		Xsqlite3WalkExpr(tls, bp, pExpr)
  56681 	}
  56682 }
  56683 
  56684 func resolveOrderGroupBy(tls *libc.TLS, pNC uintptr, pSelect uintptr, pOrderBy uintptr, zType uintptr) int32 {
  56685 	bp := tls.Alloc(4)
  56686 	defer tls.Free(4)
  56687 
  56688 	var i int32
  56689 	var j int32
  56690 
  56691 	var pItem uintptr
  56692 	var pParse uintptr
  56693 	var nResult int32
  56694 
  56695 	nResult = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpEList)).FnExpr
  56696 	pParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  56697 	i = 0
  56698 	pItem = pOrderBy + 8
  56699 __1:
  56700 	if !(i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr) {
  56701 		goto __3
  56702 	}
  56703 	{
  56704 		var pE uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr
  56705 		var pE2 uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pE)
  56706 		if pE2 == uintptr(0) {
  56707 			goto __2
  56708 		}
  56709 		if int32(*(*uint8)(unsafe.Pointer(zType))) != 'G' {
  56710 			*(*int32)(unsafe.Pointer(bp)) = resolveAsName(tls, pParse, (*Select)(unsafe.Pointer(pSelect)).FpEList, pE2)
  56711 			if *(*int32)(unsafe.Pointer(bp)) > 0 {
  56712 				*(*U16)(unsafe.Pointer(pItem + 16)) = U16(*(*int32)(unsafe.Pointer(bp)))
  56713 				goto __2
  56714 			}
  56715 		}
  56716 		if Xsqlite3ExprIsInteger(tls, pE2, bp) != 0 {
  56717 			if *(*int32)(unsafe.Pointer(bp)) < 1 || *(*int32)(unsafe.Pointer(bp)) > 0xffff {
  56718 				resolveOutOfRangeError(tls, pParse, zType, i+1, nResult, pE2)
  56719 				return 1
  56720 			}
  56721 			*(*U16)(unsafe.Pointer(pItem + 16)) = U16(*(*int32)(unsafe.Pointer(bp)))
  56722 			goto __2
  56723 		}
  56724 
  56725 		*(*U16)(unsafe.Pointer(pItem + 16)) = U16(0)
  56726 		if Xsqlite3ResolveExprNames(tls, pNC, pE) != 0 {
  56727 			return 1
  56728 		}
  56729 		for j = 0; j < (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpEList)).FnExpr; j++ {
  56730 			if Xsqlite3ExprCompare(tls, uintptr(0), pE, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpEList+8+uintptr(j)*20)).FpExpr, -1) == 0 {
  56731 				windowRemoveExprFromSelect(tls, pSelect, pE)
  56732 				*(*U16)(unsafe.Pointer(pItem + 16)) = U16(j + 1)
  56733 			}
  56734 		}
  56735 
  56736 	}
  56737 	goto __2
  56738 __2:
  56739 	i++
  56740 	pItem += 20
  56741 	goto __1
  56742 	goto __3
  56743 __3:
  56744 	;
  56745 	return Xsqlite3ResolveOrderGroupBy(tls, pParse, pSelect, pOrderBy, zType)
  56746 }
  56747 
  56748 func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  56749 	bp := tls.Alloc(32)
  56750 	defer tls.Free(32)
  56751 
  56752 	var pOuterNC uintptr
  56753 
  56754 	var isCompound int32
  56755 	var nCompound int32
  56756 	var pParse uintptr
  56757 	var i int32
  56758 	var pGroupBy uintptr
  56759 	var pLeftmost uintptr
  56760 	var db uintptr
  56761 
  56762 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Resolved) != 0 {
  56763 		return WRC_Prune
  56764 	}
  56765 	pOuterNC = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  56766 	pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  56767 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  56768 
  56769 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Expanded) == U32(0) {
  56770 		Xsqlite3SelectPrep(tls, pParse, p, pOuterNC)
  56771 		if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  56772 			return WRC_Abort
  56773 		}
  56774 		return WRC_Prune
  56775 	}
  56776 
  56777 	isCompound = libc.Bool32((*Select)(unsafe.Pointer(p)).FpPrior != uintptr(0))
  56778 	nCompound = 0
  56779 	pLeftmost = p
  56780 	for p != 0 {
  56781 		*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_Resolved)
  56782 
  56783 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  56784 		(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  56785 		(*NameContext)(unsafe.Pointer(bp)).FpWinSelect = p
  56786 		if Xsqlite3ResolveExprNames(tls, bp, (*Select)(unsafe.Pointer(p)).FpLimit) != 0 {
  56787 			return WRC_Abort
  56788 		}
  56789 
  56790 		if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Converted) != 0 {
  56791 			var pSub uintptr = (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpSelect
  56792 
  56793 			(*Select)(unsafe.Pointer(pSub)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy
  56794 			(*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0)
  56795 		}
  56796 
  56797 		for i = 0; i < (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc; i++ {
  56798 			var pItem uintptr = (*Select)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*72
  56799 			if (*SrcItem)(unsafe.Pointer(pItem)).FpSelect != 0 && (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpSelect)).FselFlags&U32(SF_Resolved) == U32(0) {
  56800 				var nRef int32
  56801 				if pOuterNC != 0 {
  56802 					nRef = (*NameContext)(unsafe.Pointer(pOuterNC)).FnRef
  56803 				} else {
  56804 					nRef = 0
  56805 				}
  56806 				var zSavedContext uintptr = (*Parse)(unsafe.Pointer(pParse)).FzAuthContext
  56807 
  56808 				if (*SrcItem)(unsafe.Pointer(pItem)).FzName != 0 {
  56809 					(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = (*SrcItem)(unsafe.Pointer(pItem)).FzName
  56810 				}
  56811 				Xsqlite3ResolveSelectNames(tls, pParse, (*SrcItem)(unsafe.Pointer(pItem)).FpSelect, pOuterNC)
  56812 				(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedContext
  56813 				if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  56814 					return WRC_Abort
  56815 				}
  56816 
  56817 				if pOuterNC != 0 {
  56818 					libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(libc.Bool32((*NameContext)(unsafe.Pointer(pOuterNC)).FnRef > nRef)), 3, 0x8)
  56819 				}
  56820 			}
  56821 		}
  56822 
  56823 		(*NameContext)(unsafe.Pointer(bp)).FncFlags = NC_AllowAgg | NC_AllowWin
  56824 		(*NameContext)(unsafe.Pointer(bp)).FpSrcList = (*Select)(unsafe.Pointer(p)).FpSrc
  56825 		(*NameContext)(unsafe.Pointer(bp)).FpNext = pOuterNC
  56826 
  56827 		if Xsqlite3ResolveExprListNames(tls, bp, (*Select)(unsafe.Pointer(p)).FpEList) != 0 {
  56828 			return WRC_Abort
  56829 		}
  56830 		*(*int32)(unsafe.Pointer(bp + 24)) &= libc.CplInt32(NC_AllowWin)
  56831 
  56832 		pGroupBy = (*Select)(unsafe.Pointer(p)).FpGroupBy
  56833 		if pGroupBy != 0 || (*NameContext)(unsafe.Pointer(bp)).FncFlags&NC_HasAgg != 0 {
  56834 			*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_Aggregate | (*NameContext)(unsafe.Pointer(bp)).FncFlags&(NC_MinMaxAgg|NC_OrderAgg))
  56835 		} else {
  56836 			*(*int32)(unsafe.Pointer(bp + 24)) &= libc.CplInt32(NC_AllowAgg)
  56837 		}
  56838 
  56839 		*(*uintptr)(unsafe.Pointer(bp + 8)) = (*Select)(unsafe.Pointer(p)).FpEList
  56840 		*(*int32)(unsafe.Pointer(bp + 24)) |= NC_UEList
  56841 		if (*Select)(unsafe.Pointer(p)).FpHaving != 0 {
  56842 			if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Aggregate) == U32(0) {
  56843 				Xsqlite3ErrorMsg(tls, pParse, ts+7321, 0)
  56844 				return WRC_Abort
  56845 			}
  56846 			if Xsqlite3ResolveExprNames(tls, bp, (*Select)(unsafe.Pointer(p)).FpHaving) != 0 {
  56847 				return WRC_Abort
  56848 			}
  56849 		}
  56850 		if Xsqlite3ResolveExprNames(tls, bp, (*Select)(unsafe.Pointer(p)).FpWhere) != 0 {
  56851 			return WRC_Abort
  56852 		}
  56853 
  56854 		for i = 0; i < (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc; i++ {
  56855 			var pItem uintptr = (*Select)(unsafe.Pointer(p)).FpSrc + 8 + uintptr(i)*72
  56856 			if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x4>>2)) != 0 &&
  56857 				Xsqlite3ResolveExprListNames(tls, bp, *(*uintptr)(unsafe.Pointer(pItem + 64))) != 0 {
  56858 				return WRC_Abort
  56859 			}
  56860 		}
  56861 
  56862 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  56863 			var pWin uintptr
  56864 			for pWin = (*Select)(unsafe.Pointer(p)).FpWinDefn; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
  56865 				if Xsqlite3ResolveExprListNames(tls, bp, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) != 0 ||
  56866 					Xsqlite3ResolveExprListNames(tls, bp, (*Window)(unsafe.Pointer(pWin)).FpPartition) != 0 {
  56867 					return WRC_Abort
  56868 				}
  56869 			}
  56870 		}
  56871 
  56872 		(*NameContext)(unsafe.Pointer(bp)).FpNext = uintptr(0)
  56873 		*(*int32)(unsafe.Pointer(bp + 24)) |= NC_AllowAgg | NC_AllowWin
  56874 
  56875 		if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Converted) != 0 {
  56876 			var pSub uintptr = (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpSelect
  56877 			(*Select)(unsafe.Pointer(p)).FpOrderBy = (*Select)(unsafe.Pointer(pSub)).FpOrderBy
  56878 			(*Select)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0)
  56879 		}
  56880 
  56881 		if (*Select)(unsafe.Pointer(p)).FpOrderBy != uintptr(0) &&
  56882 			isCompound <= nCompound &&
  56883 			resolveOrderGroupBy(tls, bp, p, (*Select)(unsafe.Pointer(p)).FpOrderBy, ts+7223) != 0 {
  56884 			return WRC_Abort
  56885 		}
  56886 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  56887 			return WRC_Abort
  56888 		}
  56889 		*(*int32)(unsafe.Pointer(bp + 24)) &= libc.CplInt32(NC_AllowWin)
  56890 
  56891 		if pGroupBy != 0 {
  56892 			var pItem uintptr
  56893 
  56894 			if resolveOrderGroupBy(tls, bp, p, pGroupBy, ts+7360) != 0 || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  56895 				return WRC_Abort
  56896 			}
  56897 			i = 0
  56898 			pItem = pGroupBy + 8
  56899 		__1:
  56900 			if !(i < (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) {
  56901 				goto __3
  56902 			}
  56903 			{
  56904 				if (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)).Fflags&U32(EP_Agg) != U32(0) {
  56905 					Xsqlite3ErrorMsg(tls, pParse,
  56906 						ts+7366, 0)
  56907 					return WRC_Abort
  56908 				}
  56909 
  56910 			}
  56911 			goto __2
  56912 		__2:
  56913 			i++
  56914 			pItem += 20
  56915 			goto __1
  56916 			goto __3
  56917 		__3:
  56918 		}
  56919 
  56920 		if (*Select)(unsafe.Pointer(p)).FpNext != 0 && (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpNext)).FpEList)).FnExpr {
  56921 			Xsqlite3SelectWrongNumTermsError(tls, pParse, (*Select)(unsafe.Pointer(p)).FpNext)
  56922 			return WRC_Abort
  56923 		}
  56924 
  56925 		p = (*Select)(unsafe.Pointer(p)).FpPrior
  56926 		nCompound++
  56927 	}
  56928 
  56929 	if isCompound != 0 && resolveCompoundOrderBy(tls, pParse, pLeftmost) != 0 {
  56930 		return WRC_Abort
  56931 	}
  56932 
  56933 	return WRC_Prune
  56934 }
  56935 
  56936 // This routine walks an expression tree and resolves references to
  56937 // table columns and result-set columns.  At the same time, do error
  56938 // checking on function usage and set a flag if any aggregate functions
  56939 // are seen.
  56940 //
  56941 // To resolve table columns references we look for nodes (or subtrees) of the
  56942 // form X.Y.Z or Y.Z or just Z where
  56943 //
  56944 //	X:   The name of a database.  Ex:  "main" or "temp" or
  56945 //	     the symbolic name assigned to an ATTACH-ed database.
  56946 //
  56947 //	Y:   The name of a table in a FROM clause.  Or in a trigger
  56948 //	     one of the special names "old" or "new".
  56949 //
  56950 //	Z:   The name of a column in table Y.
  56951 //
  56952 // The node at the root of the subtree is modified as follows:
  56953 //
  56954 //	Expr.op        Changed to TK_COLUMN
  56955 //	Expr.pTab      Points to the Table object for X.Y
  56956 //	Expr.iColumn   The column index in X.Y.  -1 for the rowid.
  56957 //	Expr.iTable    The VDBE cursor number for X.Y
  56958 //
  56959 // To resolve result-set references, look for expression nodes of the
  56960 // form Z (with no X and Y prefix) where the Z matches the right-hand
  56961 // size of an AS clause in the result-set of a SELECT.  The Z expression
  56962 // is replaced by a copy of the left-hand side of the result-set expression.
  56963 // Table-name and function resolution occurs on the substituted expression
  56964 // tree.  For example, in:
  56965 //
  56966 //	SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;
  56967 //
  56968 // The "x" term of the order by is replaced by "a+b" to render:
  56969 //
  56970 //	SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;
  56971 //
  56972 // Function calls are checked to make sure that the function is
  56973 // defined and that the correct number of arguments are specified.
  56974 // If the function is an aggregate function, then the NC_HasAgg flag is
  56975 // set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION.
  56976 // If an expression contains aggregate functions then the EP_Agg
  56977 // property on the expression is set.
  56978 //
  56979 // An error message is left in pParse if anything is amiss.  The number
  56980 // if errors is returned.
  56981 func Xsqlite3ResolveExprNames(tls *libc.TLS, pNC uintptr, pExpr uintptr) int32 {
  56982 	bp := tls.Alloc(28)
  56983 	defer tls.Free(28)
  56984 
  56985 	var savedHasAgg int32
  56986 
  56987 	if pExpr == uintptr(0) {
  56988 		return SQLITE_OK
  56989 	}
  56990 	savedHasAgg = (*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_MinMaxAgg | NC_HasWin | NC_OrderAgg)
  56991 	*(*int32)(unsafe.Pointer(pNC + 24)) &= libc.CplInt32(NC_HasAgg | NC_MinMaxAgg | NC_HasWin | NC_OrderAgg)
  56992 	(*Walker)(unsafe.Pointer(bp)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  56993 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  56994 		f func(*libc.TLS, uintptr, uintptr) int32
  56995 	}{resolveExprStep}))
  56996 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = func() uintptr {
  56997 		if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_NoSelect != 0 {
  56998 			return uintptr(0)
  56999 		}
  57000 		return *(*uintptr)(unsafe.Pointer(&struct {
  57001 			f func(*libc.TLS, uintptr, uintptr) int32
  57002 		}{resolveSelectStep}))
  57003 	}()
  57004 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = uintptr(0)
  57005 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pNC
  57006 	*(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse + 224)) += (*Expr)(unsafe.Pointer(pExpr)).FnHeight
  57007 	if Xsqlite3ExprCheckHeight(tls, (*Walker)(unsafe.Pointer(bp)).FpParse, (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse)).FnHeight) != 0 {
  57008 		return SQLITE_ERROR
  57009 	}
  57010 	Xsqlite3WalkExpr(tls, bp, pExpr)
  57011 	*(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse + 224)) -= (*Expr)(unsafe.Pointer(pExpr)).FnHeight
  57012 
  57013 	*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_HasWin))
  57014 	*(*int32)(unsafe.Pointer(pNC + 24)) |= savedHasAgg
  57015 	return libc.Bool32((*NameContext)(unsafe.Pointer(pNC)).FnNcErr > 0 || (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse)).FnErr > 0)
  57016 }
  57017 
  57018 // Resolve all names for all expression in an expression list.  This is
  57019 // just like sqlite3ResolveExprNames() except that it works for an expression
  57020 // list rather than a single expression.
  57021 func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int32 {
  57022 	bp := tls.Alloc(28)
  57023 	defer tls.Free(28)
  57024 
  57025 	var i int32
  57026 	var savedHasAgg int32 = 0
  57027 
  57028 	if pList == uintptr(0) {
  57029 		return WRC_Continue
  57030 	}
  57031 	(*Walker)(unsafe.Pointer(bp)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  57032 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  57033 		f func(*libc.TLS, uintptr, uintptr) int32
  57034 	}{resolveExprStep}))
  57035 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  57036 		f func(*libc.TLS, uintptr, uintptr) int32
  57037 	}{resolveSelectStep}))
  57038 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = uintptr(0)
  57039 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pNC
  57040 	savedHasAgg = (*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_MinMaxAgg | NC_HasWin | NC_OrderAgg)
  57041 	*(*int32)(unsafe.Pointer(pNC + 24)) &= libc.CplInt32(NC_HasAgg | NC_MinMaxAgg | NC_HasWin | NC_OrderAgg)
  57042 	for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
  57043 		var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*20)).FpExpr
  57044 		if pExpr == uintptr(0) {
  57045 			continue
  57046 		}
  57047 		*(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse + 224)) += (*Expr)(unsafe.Pointer(pExpr)).FnHeight
  57048 		if Xsqlite3ExprCheckHeight(tls, (*Walker)(unsafe.Pointer(bp)).FpParse, (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse)).FnHeight) != 0 {
  57049 			return WRC_Abort
  57050 		}
  57051 		Xsqlite3WalkExpr(tls, bp, pExpr)
  57052 		*(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse + 224)) -= (*Expr)(unsafe.Pointer(pExpr)).FnHeight
  57053 
  57054 		if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg) != 0 {
  57055 			*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_HasWin))
  57056 			savedHasAgg = savedHasAgg | (*NameContext)(unsafe.Pointer(pNC)).FncFlags&(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg)
  57057 			*(*int32)(unsafe.Pointer(pNC + 24)) &= libc.CplInt32(NC_HasAgg | NC_MinMaxAgg | NC_HasWin | NC_OrderAgg)
  57058 		}
  57059 		if (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp)).FpParse)).FnErr > 0 {
  57060 			return WRC_Abort
  57061 		}
  57062 	}
  57063 	*(*int32)(unsafe.Pointer(pNC + 24)) |= savedHasAgg
  57064 	return WRC_Continue
  57065 }
  57066 
  57067 // Resolve all names in all expressions of a SELECT and in all
  57068 // decendents of the SELECT, including compounds off of p->pPrior,
  57069 // subqueries in expressions, and subqueries used as FROM clause
  57070 // terms.
  57071 //
  57072 // See sqlite3ResolveExprNames() for a description of the kinds of
  57073 // transformations that occur.
  57074 //
  57075 // All SELECT statements should have been expanded using
  57076 // sqlite3SelectExpand() prior to invoking this routine.
  57077 func Xsqlite3ResolveSelectNames(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintptr) {
  57078 	bp := tls.Alloc(28)
  57079 	defer tls.Free(28)
  57080 
  57081 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  57082 		f func(*libc.TLS, uintptr, uintptr) int32
  57083 	}{resolveExprStep}))
  57084 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  57085 		f func(*libc.TLS, uintptr, uintptr) int32
  57086 	}{resolveSelectStep}))
  57087 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = uintptr(0)
  57088 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  57089 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pOuterNC
  57090 	Xsqlite3WalkSelect(tls, bp, p)
  57091 }
  57092 
  57093 // Resolve names in expressions that can only reference a single table
  57094 // or which cannot reference any tables at all.  Examples:
  57095 //
  57096 //	                                                "type" flag
  57097 //	                                                ------------
  57098 //	(1)   CHECK constraints                         NC_IsCheck
  57099 //	(2)   WHERE clauses on partial indices          NC_PartIdx
  57100 //	(3)   Expressions in indexes on expressions     NC_IdxExpr
  57101 //	(4)   Expression arguments to VACUUM INTO.      0
  57102 //	(5)   GENERATED ALWAYS as expressions           NC_GenCol
  57103 //
  57104 // In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN
  57105 // nodes of the expression is set to -1 and the Expr.iColumn value is
  57106 // set to the column number.  In case (4), TK_COLUMN nodes cause an error.
  57107 //
  57108 // Any errors cause an error message to be set in pParse.
  57109 func Xsqlite3ResolveSelfReference(tls *libc.TLS, pParse uintptr, pTab uintptr, type1 int32, pExpr uintptr, pList uintptr) int32 {
  57110 	bp := tls.Alloc(112)
  57111 	defer tls.Free(112)
  57112 
  57113 	var rc int32
  57114 
  57115 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  57116 	libc.Xmemset(tls, bp+32, 0, uint32(unsafe.Sizeof(SrcList{})))
  57117 	if pTab != 0 {
  57118 		(*SrcList)(unsafe.Pointer(bp + 32)).FnSrc = 1
  57119 		(*SrcItem)(unsafe.Pointer(bp + 32 + 8)).FzName = (*Table)(unsafe.Pointer(pTab)).FzName
  57120 		(*SrcItem)(unsafe.Pointer(bp + 32 + 8)).FpTab = pTab
  57121 		(*SrcItem)(unsafe.Pointer(bp + 32 + 8)).FiCursor = -1
  57122 		if (*Table)(unsafe.Pointer(pTab)).FpSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+1*16)).FpSchema {
  57123 			type1 = type1 | NC_FromDDL
  57124 		}
  57125 	}
  57126 	(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  57127 	(*NameContext)(unsafe.Pointer(bp)).FpSrcList = bp + 32
  57128 	(*NameContext)(unsafe.Pointer(bp)).FncFlags = type1 | NC_IsDDL
  57129 	if libc.AssignInt32(&rc, Xsqlite3ResolveExprNames(tls, bp, pExpr)) != SQLITE_OK {
  57130 		return rc
  57131 	}
  57132 	if pList != 0 {
  57133 		rc = Xsqlite3ResolveExprListNames(tls, bp, pList)
  57134 	}
  57135 	return rc
  57136 }
  57137 
  57138 // Return the affinity character for a single column of a table.
  57139 func Xsqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) uint8 {
  57140 	if iCol < 0 || iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol) {
  57141 		return uint8(SQLITE_AFF_INTEGER)
  57142 	}
  57143 	return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16)).Faffinity
  57144 }
  57145 
  57146 // Return the 'affinity' of the expression pExpr if any.
  57147 //
  57148 // If pExpr is a column, a reference to a column via an 'AS' alias,
  57149 // or a sub-select with a column as the return value, then the
  57150 // affinity of that column is returned. Otherwise, 0x00 is returned,
  57151 // indicating no affinity for the expression.
  57152 //
  57153 // i.e. the WHERE clause expressions in the following statements all
  57154 // have an affinity:
  57155 //
  57156 // CREATE TABLE t1(a);
  57157 // SELECT * FROM t1 WHERE a;
  57158 // SELECT a AS b FROM t1 WHERE b;
  57159 // SELECT * FROM t1 WHERE (select a from t1);
  57160 func Xsqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) uint8 {
  57161 	var op int32
  57162 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
  57163 	for 1 != 0 {
  57164 		if op == TK_COLUMN || op == TK_AGG_COLUMN && *(*uintptr)(unsafe.Pointer(pExpr + 44)) != uintptr(0) {
  57165 			return Xsqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 44)), int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn))
  57166 		}
  57167 		if op == TK_SELECT {
  57168 			return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpEList+8)).FpExpr)
  57169 		}
  57170 		if op == TK_CAST {
  57171 			return Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0))
  57172 		}
  57173 		if op == TK_SELECT_COLUMN {
  57174 			return Xsqlite3ExprAffinity(tls,
  57175 				(*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft + 20)))).FpEList+8+uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*20)).FpExpr)
  57176 		}
  57177 		if op == TK_VECTOR {
  57178 			return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20))+8)).FpExpr)
  57179 		}
  57180 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Skip|EP_IfNullRow) != U32(0) {
  57181 			pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  57182 			op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
  57183 			continue
  57184 		}
  57185 		if op != TK_REGISTER || libc.AssignInt32(&op, int32((*Expr)(unsafe.Pointer(pExpr)).Fop2)) == TK_REGISTER {
  57186 			break
  57187 		}
  57188 	}
  57189 	return (*Expr)(unsafe.Pointer(pExpr)).FaffExpr
  57190 }
  57191 
  57192 // Make a guess at all the possible datatypes of the result that could
  57193 // be returned by an expression.  Return a bitmask indicating the answer:
  57194 //
  57195 //	0x01         Numeric
  57196 //	0x02         Text
  57197 //	0x04         Blob
  57198 //
  57199 // If the expression must return NULL, then 0x00 is returned.
  57200 func Xsqlite3ExprDataType(tls *libc.TLS, pExpr uintptr) int32 {
  57201 	for pExpr != 0 {
  57202 		switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  57203 		case TK_COLLATE:
  57204 			fallthrough
  57205 		case TK_IF_NULL_ROW:
  57206 			fallthrough
  57207 		case TK_UPLUS:
  57208 			{
  57209 				pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  57210 				break
  57211 
  57212 			}
  57213 		case TK_NULL:
  57214 			{
  57215 				pExpr = uintptr(0)
  57216 				break
  57217 
  57218 			}
  57219 		case TK_STRING:
  57220 			{
  57221 				return 0x02
  57222 
  57223 			}
  57224 		case TK_BLOB:
  57225 			{
  57226 				return 0x04
  57227 
  57228 			}
  57229 		case TK_CONCAT:
  57230 			{
  57231 				return 0x06
  57232 
  57233 			}
  57234 		case TK_VARIABLE:
  57235 			fallthrough
  57236 		case TK_AGG_FUNCTION:
  57237 			fallthrough
  57238 		case TK_FUNCTION:
  57239 			{
  57240 				return 0x07
  57241 
  57242 			}
  57243 		case TK_COLUMN:
  57244 			fallthrough
  57245 		case TK_AGG_COLUMN:
  57246 			fallthrough
  57247 		case TK_SELECT:
  57248 			fallthrough
  57249 		case TK_CAST:
  57250 			fallthrough
  57251 		case TK_SELECT_COLUMN:
  57252 			fallthrough
  57253 		case TK_VECTOR:
  57254 			{
  57255 				var aff int32 = int32(Xsqlite3ExprAffinity(tls, pExpr))
  57256 				if aff >= SQLITE_AFF_NUMERIC {
  57257 					return 0x05
  57258 				}
  57259 				if aff == SQLITE_AFF_TEXT {
  57260 					return 0x06
  57261 				}
  57262 				return 0x07
  57263 
  57264 			}
  57265 		case TK_CASE:
  57266 			{
  57267 				var res int32 = 0
  57268 				var ii int32
  57269 				var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  57270 
  57271 				for ii = 1; ii < (*ExprList)(unsafe.Pointer(pList)).FnExpr; ii = ii + 2 {
  57272 					res = res | Xsqlite3ExprDataType(tls, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ii)*20)).FpExpr)
  57273 				}
  57274 				if (*ExprList)(unsafe.Pointer(pList)).FnExpr%2 != 0 {
  57275 					res = res | Xsqlite3ExprDataType(tls, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr((*ExprList)(unsafe.Pointer(pList)).FnExpr-1)*20)).FpExpr)
  57276 				}
  57277 				return res
  57278 
  57279 			}
  57280 		default:
  57281 			{
  57282 				return 0x01
  57283 
  57284 			}
  57285 		}
  57286 	}
  57287 	return 0x00
  57288 }
  57289 
  57290 // Set the collating sequence for expression pExpr to be the collating
  57291 // sequence named by pToken.   Return a pointer to a new Expr node that
  57292 // implements the COLLATE operator.
  57293 //
  57294 // If a memory allocation error occurs, that fact is recorded in pParse->db
  57295 // and the pExpr parameter is returned unchanged.
  57296 func Xsqlite3ExprAddCollateToken(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCollName uintptr, dequote int32) uintptr {
  57297 	if (*Token)(unsafe.Pointer(pCollName)).Fn > uint32(0) {
  57298 		var pNew uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLLATE, pCollName, dequote)
  57299 		if pNew != 0 {
  57300 			(*Expr)(unsafe.Pointer(pNew)).FpLeft = pExpr
  57301 			*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_Collate | EP_Skip)
  57302 			pExpr = pNew
  57303 		}
  57304 	}
  57305 	return pExpr
  57306 }
  57307 
  57308 func Xsqlite3ExprAddCollateString(tls *libc.TLS, pParse uintptr, pExpr uintptr, zC uintptr) uintptr {
  57309 	bp := tls.Alloc(8)
  57310 	defer tls.Free(8)
  57311 
  57312 	Xsqlite3TokenInit(tls, bp, zC)
  57313 	return Xsqlite3ExprAddCollateToken(tls, pParse, pExpr, bp, 0)
  57314 }
  57315 
  57316 // Skip over any TK_COLLATE operators.
  57317 func Xsqlite3ExprSkipCollate(tls *libc.TLS, pExpr uintptr) uintptr {
  57318 	for pExpr != 0 && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Skip) != U32(0) {
  57319 		pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  57320 	}
  57321 	return pExpr
  57322 }
  57323 
  57324 // Skip over any TK_COLLATE operators and/or any unlikely()
  57325 // or likelihood() or likely() functions at the root of an
  57326 // expression.
  57327 func Xsqlite3ExprSkipCollateAndLikely(tls *libc.TLS, pExpr uintptr) uintptr {
  57328 	for pExpr != 0 && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Skip|EP_Unlikely) != U32(0) {
  57329 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Unlikely) != U32(0) {
  57330 			pExpr = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)) + 8)).FpExpr
  57331 		} else {
  57332 			pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  57333 		}
  57334 	}
  57335 	return pExpr
  57336 }
  57337 
  57338 // Return the collation sequence for the expression pExpr. If
  57339 // there is no defined collating sequence, return NULL.
  57340 //
  57341 // See also: sqlite3ExprNNCollSeq()
  57342 //
  57343 // The sqlite3ExprNNCollSeq() works the same exact that it returns the
  57344 // default collation if pExpr has no defined collation.
  57345 //
  57346 // The collating sequence might be determined by a COLLATE operator
  57347 // or by the presence of a column with a defined collating sequence.
  57348 // COLLATE operators take first precedence.  Left operands take
  57349 // precedence over right operands.
  57350 func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr {
  57351 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  57352 	var pColl uintptr = uintptr(0)
  57353 	var p uintptr = pExpr
  57354 	for p != 0 {
  57355 		var op int32 = int32((*Expr)(unsafe.Pointer(p)).Fop)
  57356 		if op == TK_REGISTER {
  57357 			op = int32((*Expr)(unsafe.Pointer(p)).Fop2)
  57358 		}
  57359 		if op == TK_AGG_COLUMN && *(*uintptr)(unsafe.Pointer(p + 44)) != uintptr(0) ||
  57360 			op == TK_COLUMN || op == TK_TRIGGER {
  57361 			var j int32
  57362 
  57363 			if libc.AssignInt32(&j, int32((*Expr)(unsafe.Pointer(p)).FiColumn)) >= 0 {
  57364 				var zColl uintptr = Xsqlite3ColumnColl(tls, (*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FaCol+uintptr(j)*16)
  57365 				pColl = Xsqlite3FindCollSeq(tls, db, (*Sqlite3)(unsafe.Pointer(db)).Fenc, zColl, 0)
  57366 			}
  57367 			break
  57368 		}
  57369 		if op == TK_CAST || op == TK_UPLUS {
  57370 			p = (*Expr)(unsafe.Pointer(p)).FpLeft
  57371 			continue
  57372 		}
  57373 		if op == TK_VECTOR {
  57374 			p = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20)) + 8)).FpExpr
  57375 			continue
  57376 		}
  57377 		if op == TK_COLLATE {
  57378 			pColl = Xsqlite3GetCollSeq(tls, pParse, (*Sqlite3)(unsafe.Pointer(db)).Fenc, uintptr(0), *(*uintptr)(unsafe.Pointer(p + 8)))
  57379 			break
  57380 		}
  57381 		if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_Collate) != 0 {
  57382 			if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 && (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fflags&U32(EP_Collate) != U32(0) {
  57383 				p = (*Expr)(unsafe.Pointer(p)).FpLeft
  57384 			} else {
  57385 				var pNext uintptr = (*Expr)(unsafe.Pointer(p)).FpRight
  57386 
  57387 				if *(*uintptr)(unsafe.Pointer(p + 20)) != uintptr(0) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  57388 					var i int32
  57389 					for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20)))).FnExpr; i++ {
  57390 						if (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20))+8+uintptr(i)*20)).FpExpr)).Fflags&U32(EP_Collate) != U32(0) {
  57391 							pNext = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20)) + 8 + uintptr(i)*20)).FpExpr
  57392 							break
  57393 						}
  57394 					}
  57395 				}
  57396 				p = pNext
  57397 			}
  57398 		} else {
  57399 			break
  57400 		}
  57401 	}
  57402 	if Xsqlite3CheckCollSeq(tls, pParse, pColl) != 0 {
  57403 		pColl = uintptr(0)
  57404 	}
  57405 	return pColl
  57406 }
  57407 
  57408 // Return the collation sequence for the expression pExpr. If
  57409 // there is no defined collating sequence, return a pointer to the
  57410 // defautl collation sequence.
  57411 //
  57412 // See also: sqlite3ExprCollSeq()
  57413 //
  57414 // The sqlite3ExprCollSeq() routine works the same except that it
  57415 // returns NULL if there is no defined collation.
  57416 func Xsqlite3ExprNNCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr {
  57417 	var p uintptr = Xsqlite3ExprCollSeq(tls, pParse, pExpr)
  57418 	if p == uintptr(0) {
  57419 		p = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl
  57420 	}
  57421 
  57422 	return p
  57423 }
  57424 
  57425 // Return TRUE if the two expressions have equivalent collating sequences.
  57426 func Xsqlite3ExprCollSeqMatch(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uintptr) int32 {
  57427 	var pColl1 uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, pE1)
  57428 	var pColl2 uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, pE2)
  57429 	return libc.Bool32(Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pColl1)).FzName, (*CollSeq)(unsafe.Pointer(pColl2)).FzName) == 0)
  57430 }
  57431 
  57432 // pExpr is an operand of a comparison operator.  aff2 is the
  57433 // type affinity of the other operand.  This routine returns the
  57434 // type affinity that should be used for the comparison operator.
  57435 func Xsqlite3CompareAffinity(tls *libc.TLS, pExpr uintptr, aff2 uint8) uint8 {
  57436 	var aff1 uint8 = Xsqlite3ExprAffinity(tls, pExpr)
  57437 	if int32(aff1) > SQLITE_AFF_NONE && int32(aff2) > SQLITE_AFF_NONE {
  57438 		if int32(aff1) >= SQLITE_AFF_NUMERIC || int32(aff2) >= SQLITE_AFF_NUMERIC {
  57439 			return uint8(SQLITE_AFF_NUMERIC)
  57440 		} else {
  57441 			return uint8(SQLITE_AFF_BLOB)
  57442 		}
  57443 	} else {
  57444 		return uint8(func() int32 {
  57445 			if int32(aff1) <= SQLITE_AFF_NONE {
  57446 				return int32(aff2)
  57447 			}
  57448 			return int32(aff1)
  57449 		}() | SQLITE_AFF_NONE)
  57450 	}
  57451 	return uint8(0)
  57452 }
  57453 
  57454 func comparisonAffinity(tls *libc.TLS, pExpr uintptr) uint8 {
  57455 	var aff uint8
  57456 
  57457 	aff = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  57458 	if (*Expr)(unsafe.Pointer(pExpr)).FpRight != 0 {
  57459 		aff = Xsqlite3CompareAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight, aff)
  57460 	} else if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  57461 		aff = Xsqlite3CompareAffinity(tls, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpEList+8)).FpExpr, aff)
  57462 	} else if int32(aff) == 0 {
  57463 		aff = uint8(SQLITE_AFF_BLOB)
  57464 	}
  57465 	return aff
  57466 }
  57467 
  57468 // pExpr is a comparison expression, eg. '=', '<', IN(...) etc.
  57469 // idx_affinity is the affinity of an indexed column. Return true
  57470 // if the index with affinity idx_affinity may be used to implement
  57471 // the comparison in pExpr.
  57472 func Xsqlite3IndexAffinityOk(tls *libc.TLS, pExpr uintptr, idx_affinity uint8) int32 {
  57473 	var aff uint8 = comparisonAffinity(tls, pExpr)
  57474 	if int32(aff) < SQLITE_AFF_TEXT {
  57475 		return 1
  57476 	}
  57477 	if int32(aff) == SQLITE_AFF_TEXT {
  57478 		return libc.Bool32(int32(idx_affinity) == SQLITE_AFF_TEXT)
  57479 	}
  57480 	return libc.Bool32(int32(idx_affinity) >= SQLITE_AFF_NUMERIC)
  57481 }
  57482 
  57483 func binaryCompareP5(tls *libc.TLS, pExpr1 uintptr, pExpr2 uintptr, jumpIfNull int32) U8 {
  57484 	var aff U8 = Xsqlite3ExprAffinity(tls, pExpr2)
  57485 	aff = U8(int32(Xsqlite3CompareAffinity(tls, pExpr1, aff)) | int32(U8(jumpIfNull)))
  57486 	return aff
  57487 }
  57488 
  57489 // Return a pointer to the collation sequence that should be used by
  57490 // a binary comparison operator comparing pLeft and pRight.
  57491 //
  57492 // If the left hand expression has a collating sequence type, then it is
  57493 // used. Otherwise the collation sequence for the right hand expression
  57494 // is used, or the default (BINARY) if neither expression has a collating
  57495 // type.
  57496 //
  57497 // Argument pRight (but not pLeft) may be a null pointer. In this case,
  57498 // it is not considered.
  57499 func Xsqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) uintptr {
  57500 	var pColl uintptr
  57501 
  57502 	if (*Expr)(unsafe.Pointer(pLeft)).Fflags&U32(EP_Collate) != 0 {
  57503 		pColl = Xsqlite3ExprCollSeq(tls, pParse, pLeft)
  57504 	} else if pRight != 0 && (*Expr)(unsafe.Pointer(pRight)).Fflags&U32(EP_Collate) != U32(0) {
  57505 		pColl = Xsqlite3ExprCollSeq(tls, pParse, pRight)
  57506 	} else {
  57507 		pColl = Xsqlite3ExprCollSeq(tls, pParse, pLeft)
  57508 		if !(pColl != 0) {
  57509 			pColl = Xsqlite3ExprCollSeq(tls, pParse, pRight)
  57510 		}
  57511 	}
  57512 	return pColl
  57513 }
  57514 
  57515 // Expresssion p is a comparison operator.  Return a collation sequence
  57516 // appropriate for the comparison operator.
  57517 //
  57518 // This is normally just a wrapper around sqlite3BinaryCompareCollSeq().
  57519 // However, if the OP_Commuted flag is set, then the order of the operands
  57520 // is reversed in the sqlite3BinaryCompareCollSeq() call so that the
  57521 // correct collating sequence is found.
  57522 func Xsqlite3ExprCompareCollSeq(tls *libc.TLS, pParse uintptr, p uintptr) uintptr {
  57523 	if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_Commuted) != U32(0) {
  57524 		return Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpRight, (*Expr)(unsafe.Pointer(p)).FpLeft)
  57525 	} else {
  57526 		return Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, (*Expr)(unsafe.Pointer(p)).FpRight)
  57527 	}
  57528 	return uintptr(0)
  57529 }
  57530 
  57531 func codeCompare(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr, opcode int32, in1 int32, in2 int32, dest int32, jumpIfNull int32, isCommuted int32) int32 {
  57532 	var p5 int32
  57533 	var addr int32
  57534 	var p4 uintptr
  57535 
  57536 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  57537 		return 0
  57538 	}
  57539 	if isCommuted != 0 {
  57540 		p4 = Xsqlite3BinaryCompareCollSeq(tls, pParse, pRight, pLeft)
  57541 	} else {
  57542 		p4 = Xsqlite3BinaryCompareCollSeq(tls, pParse, pLeft, pRight)
  57543 	}
  57544 	p5 = int32(binaryCompareP5(tls, pLeft, pRight, jumpIfNull))
  57545 	addr = Xsqlite3VdbeAddOp4(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, opcode, in2, dest, in1,
  57546 		p4, -2)
  57547 	Xsqlite3VdbeChangeP5(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, uint16(U8(p5)))
  57548 	return addr
  57549 }
  57550 
  57551 // Return true if expression pExpr is a vector, or false otherwise.
  57552 //
  57553 // A vector is defined as any expression that results in two or more
  57554 // columns of result.  Every TK_VECTOR node is an vector because the
  57555 // parser will not generate a TK_VECTOR with fewer than two entries.
  57556 // But a TK_SELECT might be either a vector or a scalar. It is only
  57557 // considered a vector if it has two or more result columns.
  57558 func Xsqlite3ExprIsVector(tls *libc.TLS, pExpr uintptr) int32 {
  57559 	return libc.Bool32(Xsqlite3ExprVectorSize(tls, pExpr) > 1)
  57560 }
  57561 
  57562 // If the expression passed as the only argument is of type TK_VECTOR
  57563 // return the number of expressions in the vector. Or, if the expression
  57564 // is a sub-select, return the number of columns in the sub-select. For
  57565 // any other type of expression, return 1.
  57566 func Xsqlite3ExprVectorSize(tls *libc.TLS, pExpr uintptr) int32 {
  57567 	var op U8 = (*Expr)(unsafe.Pointer(pExpr)).Fop
  57568 	if int32(op) == TK_REGISTER {
  57569 		op = (*Expr)(unsafe.Pointer(pExpr)).Fop2
  57570 	}
  57571 	if int32(op) == TK_VECTOR {
  57572 		return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FnExpr
  57573 	} else if int32(op) == TK_SELECT {
  57574 		return (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpEList)).FnExpr
  57575 	} else {
  57576 		return 1
  57577 	}
  57578 	return int32(0)
  57579 }
  57580 
  57581 // Return a pointer to a subexpression of pVector that is the i-th
  57582 // column of the vector (numbered starting with 0).  The caller must
  57583 // ensure that i is within range.
  57584 //
  57585 // If pVector is really a scalar (and "scalar" here includes subqueries
  57586 // that return a single column!) then return pVector unmodified.
  57587 //
  57588 // pVector retains ownership of the returned subexpression.
  57589 //
  57590 // If the vector is a (SELECT ...) then the expression returned is
  57591 // just the expression for the i-th term of the result set, and may
  57592 // not be ready for evaluation because the table cursor has not yet
  57593 // been positioned.
  57594 func Xsqlite3VectorFieldSubexpr(tls *libc.TLS, pVector uintptr, i int32) uintptr {
  57595 	if Xsqlite3ExprIsVector(tls, pVector) != 0 {
  57596 		if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_SELECT || int32((*Expr)(unsafe.Pointer(pVector)).Fop2) == TK_SELECT {
  57597 			return (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 20)))).FpEList + 8 + uintptr(i)*20)).FpExpr
  57598 		} else {
  57599 			return (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 20)) + 8 + uintptr(i)*20)).FpExpr
  57600 		}
  57601 	}
  57602 	return pVector
  57603 }
  57604 
  57605 // Compute and return a new Expr object which when passed to
  57606 // sqlite3ExprCode() will generate all necessary code to compute
  57607 // the iField-th column of the vector expression pVector.
  57608 //
  57609 // It is ok for pVector to be a scalar (as long as iField==0).
  57610 // In that case, this routine works like sqlite3ExprDup().
  57611 //
  57612 // The caller owns the returned Expr object and is responsible for
  57613 // ensuring that the returned value eventually gets freed.
  57614 //
  57615 // The caller retains ownership of pVector.  If pVector is a TK_SELECT,
  57616 // then the returned object will reference pVector and so pVector must remain
  57617 // valid for the life of the returned object.  If pVector is a TK_VECTOR
  57618 // or a scalar expression, then it can be deleted as soon as this routine
  57619 // returns.
  57620 //
  57621 // A trick to cause a TK_SELECT pVector to be deleted together with
  57622 // the returned Expr object is to attach the pVector to the pRight field
  57623 // of the returned TK_SELECT_COLUMN Expr object.
  57624 func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32, nField int32) uintptr {
  57625 	var pRet uintptr
  57626 	if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_SELECT {
  57627 		pRet = Xsqlite3PExpr(tls, pParse, TK_SELECT_COLUMN, uintptr(0), uintptr(0))
  57628 		if pRet != 0 {
  57629 			(*Expr)(unsafe.Pointer(pRet)).FiTable = nField
  57630 			(*Expr)(unsafe.Pointer(pRet)).FiColumn = YnVar(iField)
  57631 			(*Expr)(unsafe.Pointer(pRet)).FpLeft = pVector
  57632 		}
  57633 	} else {
  57634 		if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_VECTOR {
  57635 			var ppVector uintptr
  57636 
  57637 			ppVector = *(*uintptr)(unsafe.Pointer(pVector + 20)) + 8 + uintptr(iField)*20
  57638 			pVector = *(*uintptr)(unsafe.Pointer(ppVector))
  57639 			if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  57640 				*(*uintptr)(unsafe.Pointer(ppVector)) = uintptr(0)
  57641 				return pVector
  57642 			}
  57643 		}
  57644 		pRet = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pVector, 0)
  57645 	}
  57646 	return pRet
  57647 }
  57648 
  57649 func exprCodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 {
  57650 	var reg int32 = 0
  57651 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT {
  57652 		reg = Xsqlite3CodeSubselect(tls, pParse, pExpr)
  57653 	}
  57654 	return reg
  57655 }
  57656 
  57657 func exprVectorRegister(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32, regSelect int32, ppExpr uintptr, pRegFree uintptr) int32 {
  57658 	var op U8 = (*Expr)(unsafe.Pointer(pVector)).Fop
  57659 
  57660 	if int32(op) == TK_REGISTER {
  57661 		*(*uintptr)(unsafe.Pointer(ppExpr)) = Xsqlite3VectorFieldSubexpr(tls, pVector, iField)
  57662 		return (*Expr)(unsafe.Pointer(pVector)).FiTable + iField
  57663 	}
  57664 	if int32(op) == TK_SELECT {
  57665 		*(*uintptr)(unsafe.Pointer(ppExpr)) = (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 20)))).FpEList + 8 + uintptr(iField)*20)).FpExpr
  57666 		return regSelect + iField
  57667 	}
  57668 	if int32(op) == TK_VECTOR {
  57669 		*(*uintptr)(unsafe.Pointer(ppExpr)) = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 20)) + 8 + uintptr(iField)*20)).FpExpr
  57670 		return Xsqlite3ExprCodeTemp(tls, pParse, *(*uintptr)(unsafe.Pointer(ppExpr)), pRegFree)
  57671 	}
  57672 	return 0
  57673 }
  57674 
  57675 func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, op U8, p5 U8) {
  57676 	bp := tls.Alloc(16)
  57677 	defer tls.Free(16)
  57678 
  57679 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  57680 	var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  57681 	var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight
  57682 	var nLeft int32 = Xsqlite3ExprVectorSize(tls, pLeft)
  57683 	var i int32
  57684 	var regLeft int32 = 0
  57685 	var regRight int32 = 0
  57686 	var opx U8 = op
  57687 	var addrCmp int32 = 0
  57688 	var addrDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
  57689 	var isCommuted int32 = libc.Bool32((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Commuted) != U32(0))
  57690 
  57691 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  57692 		return
  57693 	}
  57694 	if nLeft != Xsqlite3ExprVectorSize(tls, pRight) {
  57695 		Xsqlite3ErrorMsg(tls, pParse, ts+6533, 0)
  57696 		return
  57697 	}
  57698 
  57699 	if int32(op) == TK_LE {
  57700 		opx = U8(TK_LT)
  57701 	}
  57702 	if int32(op) == TK_GE {
  57703 		opx = U8(TK_GT)
  57704 	}
  57705 	if int32(op) == TK_NE {
  57706 		opx = U8(TK_EQ)
  57707 	}
  57708 
  57709 	regLeft = exprCodeSubselect(tls, pParse, pLeft)
  57710 	regRight = exprCodeSubselect(tls, pParse, pRight)
  57711 
  57712 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, dest)
  57713 	for i = 0; 1 != 0; i++ {
  57714 		*(*int32)(unsafe.Pointer(bp + 4)) = 0
  57715 		*(*int32)(unsafe.Pointer(bp + 12)) = 0
  57716 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  57717 		*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  57718 		var r1 int32
  57719 		var r2 int32
  57720 
  57721 		if addrCmp != 0 {
  57722 			Xsqlite3VdbeJumpHere(tls, v, addrCmp)
  57723 		}
  57724 		r1 = exprVectorRegister(tls, pParse, pLeft, i, regLeft, bp, bp+4)
  57725 		r2 = exprVectorRegister(tls, pParse, pRight, i, regRight, bp+8, bp+12)
  57726 		addrCmp = Xsqlite3VdbeCurrentAddr(tls, v)
  57727 		codeCompare(tls, pParse, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 8)), int32(opx), r1, r2, addrDone, int32(p5), isCommuted)
  57728 
  57729 		Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 4)))
  57730 		Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 12)))
  57731 		if (int32(opx) == TK_LT || int32(opx) == TK_GT) && i < nLeft-1 {
  57732 			addrCmp = Xsqlite3VdbeAddOp0(tls, v, OP_ElseEq)
  57733 
  57734 		}
  57735 		if int32(p5) == SQLITE_NULLEQ {
  57736 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, dest)
  57737 		} else {
  57738 			Xsqlite3VdbeAddOp3(tls, v, OP_ZeroOrNull, r1, dest, r2)
  57739 		}
  57740 		if i == nLeft-1 {
  57741 			break
  57742 		}
  57743 		if int32(opx) == TK_EQ {
  57744 			Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, dest, addrDone)
  57745 		} else {
  57746 			Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrDone)
  57747 			if i == nLeft-2 {
  57748 				opx = op
  57749 			}
  57750 		}
  57751 	}
  57752 	Xsqlite3VdbeJumpHere(tls, v, addrCmp)
  57753 	Xsqlite3VdbeResolveLabel(tls, v, addrDone)
  57754 	if int32(op) == TK_NE {
  57755 		Xsqlite3VdbeAddOp2(tls, v, OP_Not, dest, dest)
  57756 	}
  57757 }
  57758 
  57759 // Check that argument nHeight is less than or equal to the maximum
  57760 // expression depth allowed. If it is not, leave an error message in
  57761 // pParse.
  57762 func Xsqlite3ExprCheckHeight(tls *libc.TLS, pParse uintptr, nHeight int32) int32 {
  57763 	bp := tls.Alloc(8)
  57764 	defer tls.Free(8)
  57765 
  57766 	var rc int32 = SQLITE_OK
  57767 	var mxHeight int32 = *(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb + 120 + 3*4))
  57768 	if nHeight > mxHeight {
  57769 		Xsqlite3ErrorMsg(tls, pParse,
  57770 			ts+7425, libc.VaList(bp, mxHeight))
  57771 		rc = SQLITE_ERROR
  57772 	}
  57773 	return rc
  57774 }
  57775 
  57776 func heightOfExpr(tls *libc.TLS, p uintptr, pnHeight uintptr) {
  57777 	if p != 0 {
  57778 		if (*Expr)(unsafe.Pointer(p)).FnHeight > *(*int32)(unsafe.Pointer(pnHeight)) {
  57779 			*(*int32)(unsafe.Pointer(pnHeight)) = (*Expr)(unsafe.Pointer(p)).FnHeight
  57780 		}
  57781 	}
  57782 }
  57783 
  57784 func heightOfExprList(tls *libc.TLS, p uintptr, pnHeight uintptr) {
  57785 	if p != 0 {
  57786 		var i int32
  57787 		for i = 0; i < (*ExprList)(unsafe.Pointer(p)).FnExpr; i++ {
  57788 			heightOfExpr(tls, (*ExprList_item)(unsafe.Pointer(p+8+uintptr(i)*20)).FpExpr, pnHeight)
  57789 		}
  57790 	}
  57791 }
  57792 
  57793 func heightOfSelect(tls *libc.TLS, pSelect uintptr, pnHeight uintptr) {
  57794 	var p uintptr
  57795 	for p = pSelect; p != 0; p = (*Select)(unsafe.Pointer(p)).FpPrior {
  57796 		heightOfExpr(tls, (*Select)(unsafe.Pointer(p)).FpWhere, pnHeight)
  57797 		heightOfExpr(tls, (*Select)(unsafe.Pointer(p)).FpHaving, pnHeight)
  57798 		heightOfExpr(tls, (*Select)(unsafe.Pointer(p)).FpLimit, pnHeight)
  57799 		heightOfExprList(tls, (*Select)(unsafe.Pointer(p)).FpEList, pnHeight)
  57800 		heightOfExprList(tls, (*Select)(unsafe.Pointer(p)).FpGroupBy, pnHeight)
  57801 		heightOfExprList(tls, (*Select)(unsafe.Pointer(p)).FpOrderBy, pnHeight)
  57802 	}
  57803 }
  57804 
  57805 func exprSetHeight(tls *libc.TLS, p uintptr) {
  57806 	bp := tls.Alloc(4)
  57807 	defer tls.Free(4)
  57808 
  57809 	if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 {
  57810 		*(*int32)(unsafe.Pointer(bp)) = (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).FnHeight
  57811 	} else {
  57812 		*(*int32)(unsafe.Pointer(bp)) = 0
  57813 	}
  57814 	if (*Expr)(unsafe.Pointer(p)).FpRight != 0 && (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpRight)).FnHeight > *(*int32)(unsafe.Pointer(bp)) {
  57815 		*(*int32)(unsafe.Pointer(bp)) = (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpRight)).FnHeight
  57816 	}
  57817 	if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_xIsSelect) != U32(0) {
  57818 		heightOfSelect(tls, *(*uintptr)(unsafe.Pointer(p + 20)), bp)
  57819 	} else if *(*uintptr)(unsafe.Pointer(p + 20)) != 0 {
  57820 		heightOfExprList(tls, *(*uintptr)(unsafe.Pointer(p + 20)), bp)
  57821 		*(*U32)(unsafe.Pointer(p + 4)) |= U32(EP_Collate|EP_Subquery|EP_HasFunc) & Xsqlite3ExprListFlags(tls, *(*uintptr)(unsafe.Pointer(p + 20)))
  57822 	}
  57823 	(*Expr)(unsafe.Pointer(p)).FnHeight = *(*int32)(unsafe.Pointer(bp)) + 1
  57824 }
  57825 
  57826 // Set the Expr.nHeight variable using the exprSetHeight() function. If
  57827 // the height is greater than the maximum allowed expression depth,
  57828 // leave an error in pParse.
  57829 //
  57830 // Also propagate all EP_Propagate flags from the Expr.x.pList into
  57831 // Expr.flags.
  57832 func Xsqlite3ExprSetHeightAndFlags(tls *libc.TLS, pParse uintptr, p uintptr) {
  57833 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  57834 		return
  57835 	}
  57836 	exprSetHeight(tls, p)
  57837 	Xsqlite3ExprCheckHeight(tls, pParse, (*Expr)(unsafe.Pointer(p)).FnHeight)
  57838 }
  57839 
  57840 // Return the maximum height of any expression tree referenced
  57841 // by the select statement passed as an argument.
  57842 func Xsqlite3SelectExprHeight(tls *libc.TLS, p uintptr) int32 {
  57843 	bp := tls.Alloc(4)
  57844 	defer tls.Free(4)
  57845 
  57846 	*(*int32)(unsafe.Pointer(bp)) = 0
  57847 	heightOfSelect(tls, p, bp)
  57848 	return *(*int32)(unsafe.Pointer(bp))
  57849 }
  57850 
  57851 // This routine is the core allocator for Expr nodes.
  57852 //
  57853 // Construct a new expression node and return a pointer to it.  Memory
  57854 // for this node and for the pToken argument is a single allocation
  57855 // obtained from sqlite3DbMalloc().  The calling function
  57856 // is responsible for making sure the node eventually gets freed.
  57857 //
  57858 // If dequote is true, then the token (if it exists) is dequoted.
  57859 // If dequote is false, no dequoting is performed.  The deQuote
  57860 // parameter is ignored if pToken is NULL or if the token does not
  57861 // appear to be quoted.  If the quotes were of the form "..." (double-quotes)
  57862 // then the EP_DblQuoted flag is set on the expression node.
  57863 //
  57864 // Special case:  If op==TK_INTEGER and pToken points to a string that
  57865 // can be translated into a 32-bit integer, then the token is not
  57866 // stored in u.zToken.  Instead, the integer values is written
  57867 // into u.iValue and the EP_IntValue flag is set.  No extra storage
  57868 // is allocated to hold the integer text and the dequote flag is ignored.
  57869 func Xsqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequote int32) uintptr {
  57870 	bp := tls.Alloc(4)
  57871 	defer tls.Free(4)
  57872 
  57873 	var pNew uintptr
  57874 	var nExtra int32 = 0
  57875 	*(*int32)(unsafe.Pointer(bp)) = 0
  57876 
  57877 	if pToken != 0 {
  57878 		if op != TK_INTEGER || (*Token)(unsafe.Pointer(pToken)).Fz == uintptr(0) ||
  57879 			Xsqlite3GetInt32(tls, (*Token)(unsafe.Pointer(pToken)).Fz, bp) == 0 {
  57880 			nExtra = int32((*Token)(unsafe.Pointer(pToken)).Fn + uint32(1))
  57881 
  57882 		}
  57883 	}
  57884 	pNew = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(Expr{}))+uint32(nExtra)))
  57885 	if pNew != 0 {
  57886 		libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Expr{})))
  57887 		(*Expr)(unsafe.Pointer(pNew)).Fop = U8(op)
  57888 		(*Expr)(unsafe.Pointer(pNew)).FiAgg = int16(-1)
  57889 		if pToken != 0 {
  57890 			if nExtra == 0 {
  57891 				*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_IntValue | EP_Leaf | func() int32 {
  57892 					if *(*int32)(unsafe.Pointer(bp)) != 0 {
  57893 						return EP_IsTrue
  57894 					}
  57895 					return EP_IsFalse
  57896 				}())
  57897 				*(*int32)(unsafe.Pointer(pNew + 8)) = *(*int32)(unsafe.Pointer(bp))
  57898 			} else {
  57899 				*(*uintptr)(unsafe.Pointer(pNew + 8)) = pNew + 1*52
  57900 
  57901 				if (*Token)(unsafe.Pointer(pToken)).Fn != 0 {
  57902 					libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(pNew + 8)), (*Token)(unsafe.Pointer(pToken)).Fz, (*Token)(unsafe.Pointer(pToken)).Fn)
  57903 				}
  57904 				*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8)) + uintptr((*Token)(unsafe.Pointer(pToken)).Fn))) = uint8(0)
  57905 				if dequote != 0 && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8))))])&0x80 != 0 {
  57906 					Xsqlite3DequoteExpr(tls, pNew)
  57907 				}
  57908 			}
  57909 		}
  57910 		(*Expr)(unsafe.Pointer(pNew)).FnHeight = 1
  57911 	}
  57912 	return pNew
  57913 }
  57914 
  57915 // Allocate a new expression node from a zero-terminated token that has
  57916 // already been dequoted.
  57917 func Xsqlite3Expr(tls *libc.TLS, db uintptr, op int32, zToken uintptr) uintptr {
  57918 	bp := tls.Alloc(8)
  57919 	defer tls.Free(8)
  57920 
  57921 	(*Token)(unsafe.Pointer(bp)).Fz = zToken
  57922 	(*Token)(unsafe.Pointer(bp)).Fn = uint32(Xsqlite3Strlen30(tls, zToken))
  57923 	return Xsqlite3ExprAlloc(tls, db, op, bp, 0)
  57924 }
  57925 
  57926 // Attach subtrees pLeft and pRight to the Expr node pRoot.
  57927 //
  57928 // If pRoot==NULL that means that a memory allocation error has occurred.
  57929 // In that case, delete the subtrees pLeft and pRight.
  57930 func Xsqlite3ExprAttachSubtrees(tls *libc.TLS, db uintptr, pRoot uintptr, pLeft uintptr, pRight uintptr) {
  57931 	if pRoot == uintptr(0) {
  57932 		Xsqlite3ExprDelete(tls, db, pLeft)
  57933 		Xsqlite3ExprDelete(tls, db, pRight)
  57934 	} else {
  57935 		if pRight != 0 {
  57936 			(*Expr)(unsafe.Pointer(pRoot)).FpRight = pRight
  57937 			*(*U32)(unsafe.Pointer(pRoot + 4)) |= U32(EP_Collate|EP_Subquery|EP_HasFunc) & (*Expr)(unsafe.Pointer(pRight)).Fflags
  57938 			(*Expr)(unsafe.Pointer(pRoot)).FnHeight = (*Expr)(unsafe.Pointer(pRight)).FnHeight + 1
  57939 		} else {
  57940 			(*Expr)(unsafe.Pointer(pRoot)).FnHeight = 1
  57941 		}
  57942 		if pLeft != 0 {
  57943 			(*Expr)(unsafe.Pointer(pRoot)).FpLeft = pLeft
  57944 			*(*U32)(unsafe.Pointer(pRoot + 4)) |= U32(EP_Collate|EP_Subquery|EP_HasFunc) & (*Expr)(unsafe.Pointer(pLeft)).Fflags
  57945 			if (*Expr)(unsafe.Pointer(pLeft)).FnHeight >= (*Expr)(unsafe.Pointer(pRoot)).FnHeight {
  57946 				(*Expr)(unsafe.Pointer(pRoot)).FnHeight = (*Expr)(unsafe.Pointer(pLeft)).FnHeight + 1
  57947 			}
  57948 		}
  57949 	}
  57950 }
  57951 
  57952 // Allocate an Expr node which joins as many as two subtrees.
  57953 //
  57954 // One or both of the subtrees can be NULL.  Return a pointer to the new
  57955 // Expr node.  Or, if an OOM error occurs, set pParse->db->mallocFailed,
  57956 // free the subtrees and return NULL.
  57957 func Xsqlite3PExpr(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr, pRight uintptr) uintptr {
  57958 	var p uintptr
  57959 	p = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Expr{})))
  57960 	if p != 0 {
  57961 		libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(Expr{})))
  57962 		(*Expr)(unsafe.Pointer(p)).Fop = U8(op & 0xff)
  57963 		(*Expr)(unsafe.Pointer(p)).FiAgg = int16(-1)
  57964 		Xsqlite3ExprAttachSubtrees(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p, pLeft, pRight)
  57965 		Xsqlite3ExprCheckHeight(tls, pParse, (*Expr)(unsafe.Pointer(p)).FnHeight)
  57966 	} else {
  57967 		Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pLeft)
  57968 		Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pRight)
  57969 	}
  57970 	return p
  57971 }
  57972 
  57973 // Add pSelect to the Expr.x.pSelect field.  Or, if pExpr is NULL (due
  57974 // do a memory allocation failure) then delete the pSelect object.
  57975 func Xsqlite3PExprAddSelect(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSelect uintptr) {
  57976 	if pExpr != 0 {
  57977 		*(*uintptr)(unsafe.Pointer(pExpr + 20)) = pSelect
  57978 		*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_xIsSelect | EP_Subquery)
  57979 		Xsqlite3ExprSetHeightAndFlags(tls, pParse, pExpr)
  57980 	} else {
  57981 		Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pSelect)
  57982 	}
  57983 }
  57984 
  57985 // Expression list pEList is a list of vector values. This function
  57986 // converts the contents of pEList to a VALUES(...) Select statement
  57987 // returning 1 row for each element of the list. For example, the
  57988 // expression list:
  57989 //
  57990 //	( (1,2), (3,4) (5,6) )
  57991 //
  57992 // is translated to the equivalent of:
  57993 //
  57994 //	VALUES(1,2), (3,4), (5,6)
  57995 //
  57996 // Each of the vector values in pEList must contain exactly nElem terms.
  57997 // If a list element that is not a vector or does not contain nElem terms,
  57998 // an error message is left in pParse.
  57999 //
  58000 // This is used as part of processing IN(...) expressions with a list
  58001 // of vectors on the RHS. e.g. "... IN ((1,2), (3,4), (5,6))".
  58002 func Xsqlite3ExprListToValues(tls *libc.TLS, pParse uintptr, nElem int32, pEList uintptr) uintptr {
  58003 	bp := tls.Alloc(24)
  58004 	defer tls.Free(24)
  58005 
  58006 	var ii int32
  58007 	var pRet uintptr = uintptr(0)
  58008 
  58009 	for ii = 0; ii < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; ii++ {
  58010 		var pSel uintptr
  58011 		var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*20)).FpExpr
  58012 		var nExprElem int32
  58013 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VECTOR {
  58014 			nExprElem = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FnExpr
  58015 		} else {
  58016 			nExprElem = 1
  58017 		}
  58018 		if nExprElem != nElem {
  58019 			Xsqlite3ErrorMsg(tls, pParse, ts+7473,
  58020 				libc.VaList(bp, nExprElem, func() uintptr {
  58021 					if nExprElem > 1 {
  58022 						return ts + 7517
  58023 					}
  58024 					return ts + 1554
  58025 				}(), nElem))
  58026 			break
  58027 		}
  58028 
  58029 		pSel = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 20)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0))
  58030 		*(*uintptr)(unsafe.Pointer(pExpr + 20)) = uintptr(0)
  58031 		if pSel != 0 {
  58032 			if pRet != 0 {
  58033 				(*Select)(unsafe.Pointer(pSel)).Fop = U8(TK_ALL)
  58034 				(*Select)(unsafe.Pointer(pSel)).FpPrior = pRet
  58035 			}
  58036 			pRet = pSel
  58037 		}
  58038 	}
  58039 
  58040 	if pRet != 0 && (*Select)(unsafe.Pointer(pRet)).FpPrior != 0 {
  58041 		*(*U32)(unsafe.Pointer(pRet + 4)) |= U32(SF_MultiValue)
  58042 	}
  58043 	Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pEList)
  58044 	return pRet
  58045 }
  58046 
  58047 // Join two expressions using an AND operator.  If either expression is
  58048 // NULL, then just return the other expression.
  58049 //
  58050 // If one side or the other of the AND is known to be false, then instead
  58051 // of returning an AND expression, just return a constant expression with
  58052 // a value of false.
  58053 func Xsqlite3ExprAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) uintptr {
  58054 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  58055 	if pLeft == uintptr(0) {
  58056 		return pRight
  58057 	} else if pRight == uintptr(0) {
  58058 		return pLeft
  58059 	} else if ((*Expr)(unsafe.Pointer(pLeft)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse) || (*Expr)(unsafe.Pointer(pRight)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse)) &&
  58060 		!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  58061 		Xsqlite3ExprDeferredDelete(tls, pParse, pLeft)
  58062 		Xsqlite3ExprDeferredDelete(tls, pParse, pRight)
  58063 		return Xsqlite3Expr(tls, db, TK_INTEGER, ts+7519)
  58064 	} else {
  58065 		return Xsqlite3PExpr(tls, pParse, TK_AND, pLeft, pRight)
  58066 	}
  58067 	return uintptr(0)
  58068 }
  58069 
  58070 // Construct a new expression node for a function with multiple
  58071 // arguments.
  58072 func Xsqlite3ExprFunction(tls *libc.TLS, pParse uintptr, pList uintptr, pToken uintptr, eDistinct int32) uintptr {
  58073 	bp := tls.Alloc(8)
  58074 	defer tls.Free(8)
  58075 
  58076 	var pNew uintptr
  58077 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  58078 
  58079 	pNew = Xsqlite3ExprAlloc(tls, db, TK_FUNCTION, pToken, 1)
  58080 	if pNew == uintptr(0) {
  58081 		Xsqlite3ExprListDelete(tls, db, pList)
  58082 		return uintptr(0)
  58083 	}
  58084 
  58085 	*(*int32)(unsafe.Pointer(pNew + 36)) = (int32((*Token)(unsafe.Pointer(pToken)).Fz) - int32((*Parse)(unsafe.Pointer(pParse)).FzTail)) / 1
  58086 	if pList != 0 &&
  58087 		(*ExprList)(unsafe.Pointer(pList)).FnExpr > *(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb + 120 + 6*4)) &&
  58088 		!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) {
  58089 		Xsqlite3ErrorMsg(tls, pParse, ts+7521, libc.VaList(bp, pToken))
  58090 	}
  58091 	*(*uintptr)(unsafe.Pointer(pNew + 20)) = pList
  58092 	*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_HasFunc)
  58093 
  58094 	Xsqlite3ExprSetHeightAndFlags(tls, pParse, pNew)
  58095 	if eDistinct == SF_Distinct {
  58096 		*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_Distinct)
  58097 	}
  58098 	return pNew
  58099 }
  58100 
  58101 // Check to see if a function is usable according to current access
  58102 // rules:
  58103 //
  58104 //	SQLITE_FUNC_DIRECT    -     Only usable from top-level SQL
  58105 //
  58106 //	SQLITE_FUNC_UNSAFE    -     Usable if TRUSTED_SCHEMA or from
  58107 //	                            top-level SQL
  58108 //
  58109 // If the function is not usable, create an error.
  58110 func Xsqlite3ExprFunctionUsable(tls *libc.TLS, pParse uintptr, pExpr uintptr, pDef uintptr) {
  58111 	bp := tls.Alloc(8)
  58112 	defer tls.Free(8)
  58113 
  58114 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_FromDDL) != U32(0) {
  58115 		if (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_DIRECT) != U32(0) ||
  58116 			(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_TrustedSchema) == uint64(0) {
  58117 			Xsqlite3ErrorMsg(tls, pParse, ts+7555, libc.VaList(bp, pExpr))
  58118 		}
  58119 	}
  58120 }
  58121 
  58122 // Assign a variable number to an expression that encodes a wildcard
  58123 // in the original SQL statement.
  58124 //
  58125 // Wildcards consisting of a single "?" are assigned the next sequential
  58126 // variable number.
  58127 //
  58128 // Wildcards of the form "?nnn" are assigned the number "nnn".  We make
  58129 // sure "nnn" is not too big to avoid a denial of service attack when
  58130 // the SQL statement comes from an external source.
  58131 //
  58132 // Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number
  58133 // as the previous instance of the same wildcard.  Or if this is the first
  58134 // instance of the wildcard, the next sequential variable number is
  58135 // assigned.
  58136 func Xsqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n U32) {
  58137 	bp := tls.Alloc(16)
  58138 	defer tls.Free(16)
  58139 
  58140 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  58141 	var z uintptr
  58142 	var x YnVar
  58143 
  58144 	if pExpr == uintptr(0) {
  58145 		return
  58146 	}
  58147 
  58148 	z = *(*uintptr)(unsafe.Pointer(pExpr + 8))
  58149 
  58150 	if int32(*(*uint8)(unsafe.Pointer(z + 1))) == 0 {
  58151 		x = libc.PreIncInt16(&(*Parse)(unsafe.Pointer(pParse)).FnVar, 1)
  58152 	} else {
  58153 		var doAdd int32 = 0
  58154 		if int32(*(*uint8)(unsafe.Pointer(z))) == '?' {
  58155 			var bOk int32
  58156 			if n == U32(2) {
  58157 				*(*I64)(unsafe.Pointer(bp + 8)) = I64(int32(*(*uint8)(unsafe.Pointer(z + 1))) - '0')
  58158 				bOk = 1
  58159 			} else {
  58160 				bOk = libc.Bool32(0 == Xsqlite3Atoi64(tls, z+1, bp+8, int32(n-U32(1)), uint8(SQLITE_UTF8)))
  58161 			}
  58162 
  58163 			if bOk == 0 || *(*I64)(unsafe.Pointer(bp + 8)) < int64(1) || *(*I64)(unsafe.Pointer(bp + 8)) > I64(*(*int32)(unsafe.Pointer(db + 120 + 9*4))) {
  58164 				Xsqlite3ErrorMsg(tls, pParse, ts+7575,
  58165 					libc.VaList(bp, *(*int32)(unsafe.Pointer(db + 120 + 9*4))))
  58166 				Xsqlite3RecordErrorOffsetOfExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  58167 				return
  58168 			}
  58169 			x = YnVar(*(*I64)(unsafe.Pointer(bp + 8)))
  58170 			if int32(x) > int32((*Parse)(unsafe.Pointer(pParse)).FnVar) {
  58171 				(*Parse)(unsafe.Pointer(pParse)).FnVar = YnVar(int32(x))
  58172 				doAdd = 1
  58173 			} else if Xsqlite3VListNumToName(tls, (*Parse)(unsafe.Pointer(pParse)).FpVList, int32(x)) == uintptr(0) {
  58174 				doAdd = 1
  58175 			}
  58176 		} else {
  58177 			x = YnVar(Xsqlite3VListNameToNum(tls, (*Parse)(unsafe.Pointer(pParse)).FpVList, z, int32(n)))
  58178 			if int32(x) == 0 {
  58179 				x = libc.PreIncInt16(&(*Parse)(unsafe.Pointer(pParse)).FnVar, 1)
  58180 				doAdd = 1
  58181 			}
  58182 		}
  58183 		if doAdd != 0 {
  58184 			(*Parse)(unsafe.Pointer(pParse)).FpVList = Xsqlite3VListAdd(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpVList, z, int32(n), int32(x))
  58185 		}
  58186 	}
  58187 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = x
  58188 	if int32(x) > *(*int32)(unsafe.Pointer(db + 120 + 9*4)) {
  58189 		Xsqlite3ErrorMsg(tls, pParse, ts+7618, 0)
  58190 		Xsqlite3RecordErrorOffsetOfExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  58191 	}
  58192 }
  58193 
  58194 func sqlite3ExprDeleteNN(tls *libc.TLS, db uintptr, p uintptr) {
  58195 	if !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_TokenOnly|EP_Leaf) != U32(0)) {
  58196 		if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 && int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_SELECT_COLUMN {
  58197 			sqlite3ExprDeleteNN(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft)
  58198 		}
  58199 		if (*Expr)(unsafe.Pointer(p)).FpRight != 0 {
  58200 			sqlite3ExprDeleteNN(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight)
  58201 		} else if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_xIsSelect) != U32(0) {
  58202 			Xsqlite3SelectDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 20)))
  58203 		} else {
  58204 			Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 20)))
  58205 			if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_WinFunc) != U32(0) {
  58206 				Xsqlite3WindowDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 44)))
  58207 			}
  58208 		}
  58209 	}
  58210 	if !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_Static) != U32(0)) {
  58211 		Xsqlite3DbNNFreeNN(tls, db, p)
  58212 	}
  58213 }
  58214 
  58215 func Xsqlite3ExprDelete(tls *libc.TLS, db uintptr, p uintptr) {
  58216 	if p != 0 {
  58217 		sqlite3ExprDeleteNN(tls, db, p)
  58218 	}
  58219 }
  58220 
  58221 // Clear both elements of an OnOrUsing object
  58222 func Xsqlite3ClearOnOrUsing(tls *libc.TLS, db uintptr, p uintptr) {
  58223 	if p == uintptr(0) {
  58224 	} else if (*OnOrUsing)(unsafe.Pointer(p)).FpOn != 0 {
  58225 		sqlite3ExprDeleteNN(tls, db, (*OnOrUsing)(unsafe.Pointer(p)).FpOn)
  58226 	} else if (*OnOrUsing)(unsafe.Pointer(p)).FpUsing != 0 {
  58227 		Xsqlite3IdListDelete(tls, db, (*OnOrUsing)(unsafe.Pointer(p)).FpUsing)
  58228 	}
  58229 }
  58230 
  58231 // Arrange to cause pExpr to be deleted when the pParse is deleted.
  58232 // This is similar to sqlite3ExprDelete() except that the delete is
  58233 // deferred untilthe pParse is deleted.
  58234 //
  58235 // The pExpr might be deleted immediately on an OOM error.
  58236 //
  58237 // The deferred delete is (currently) implemented by adding the
  58238 // pExpr to the pParse->pConstExpr list with a register number of 0.
  58239 func Xsqlite3ExprDeferredDelete(tls *libc.TLS, pParse uintptr, pExpr uintptr) {
  58240 	Xsqlite3ParserAddCleanup(tls, pParse,
  58241 		*(*uintptr)(unsafe.Pointer(&struct {
  58242 			f func(*libc.TLS, uintptr, uintptr)
  58243 		}{Xsqlite3ExprDelete})),
  58244 		pExpr)
  58245 }
  58246 
  58247 // Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the
  58248 // expression.
  58249 func Xsqlite3ExprUnmapAndDelete(tls *libc.TLS, pParse uintptr, p uintptr) {
  58250 	if p != 0 {
  58251 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  58252 			Xsqlite3RenameExprUnmap(tls, pParse, p)
  58253 		}
  58254 		sqlite3ExprDeleteNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p)
  58255 	}
  58256 }
  58257 
  58258 func exprStructSize(tls *libc.TLS, p uintptr) int32 {
  58259 	if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_TokenOnly) != U32(0) {
  58260 		return int32(uintptr(0) + 12)
  58261 	}
  58262 	if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_Reduced) != U32(0) {
  58263 		return int32(uintptr(0) + 28)
  58264 	}
  58265 	return int32(unsafe.Sizeof(Expr{}))
  58266 }
  58267 
  58268 func dupedExprStructSize(tls *libc.TLS, p uintptr, flags int32) int32 {
  58269 	var nSize int32
  58270 
  58271 	if 0 == flags || int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_SELECT_COLUMN ||
  58272 		(*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_WinFunc) != U32(0) {
  58273 		nSize = int32(unsafe.Sizeof(Expr{}))
  58274 	} else {
  58275 		if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 || *(*uintptr)(unsafe.Pointer(p + 20)) != 0 {
  58276 			nSize = int32(uint32(uintptr(0)+28) | uint32(EP_Reduced))
  58277 		} else {
  58278 			nSize = int32(uint32(uintptr(0)+12) | uint32(EP_TokenOnly))
  58279 		}
  58280 	}
  58281 	return nSize
  58282 }
  58283 
  58284 func dupedExprNodeSize(tls *libc.TLS, p uintptr, flags int32) int32 {
  58285 	var nByte int32 = dupedExprStructSize(tls, p, flags) & 0xfff
  58286 	if !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_IntValue) != U32(0)) && *(*uintptr)(unsafe.Pointer(p + 8)) != 0 {
  58287 		nByte = int32(Size_t(nByte) + (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(p + 8)))&Size_t(0x3fffffff) + Size_t(1)))
  58288 	}
  58289 	return (nByte + 7) & libc.CplInt32(7)
  58290 }
  58291 
  58292 func dupedExprSize(tls *libc.TLS, p uintptr, flags int32) int32 {
  58293 	var nByte int32 = 0
  58294 	if p != 0 {
  58295 		nByte = dupedExprNodeSize(tls, p, flags)
  58296 		if flags&EXPRDUP_REDUCE != 0 {
  58297 			nByte = nByte + (dupedExprSize(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, flags) + dupedExprSize(tls, (*Expr)(unsafe.Pointer(p)).FpRight, flags))
  58298 		}
  58299 	}
  58300 	return nByte
  58301 }
  58302 
  58303 func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uintptr) uintptr {
  58304 	bp := tls.Alloc(4)
  58305 	defer tls.Free(4)
  58306 
  58307 	var pNew uintptr
  58308 
  58309 	var staticFlag U32
  58310 
  58311 	if pzBuffer != 0 {
  58312 		*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(pzBuffer))
  58313 		staticFlag = U32(EP_Static)
  58314 
  58315 	} else {
  58316 		*(*uintptr)(unsafe.Pointer(bp)) = Xsqlite3DbMallocRawNN(tls, db, uint64(dupedExprSize(tls, p, dupFlags)))
  58317 		staticFlag = U32(0)
  58318 	}
  58319 	pNew = *(*uintptr)(unsafe.Pointer(bp))
  58320 
  58321 	if pNew != 0 {
  58322 		var nStructSize uint32 = uint32(dupedExprStructSize(tls, p, dupFlags))
  58323 		var nNewSize int32 = int32(nStructSize & uint32(0xfff))
  58324 		var nToken int32
  58325 		if !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_IntValue) != U32(0)) && *(*uintptr)(unsafe.Pointer(p + 8)) != 0 {
  58326 			nToken = Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8))) + 1
  58327 		} else {
  58328 			nToken = 0
  58329 		}
  58330 		if dupFlags != 0 {
  58331 			libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp)), p, uint32(nNewSize))
  58332 		} else {
  58333 			var nSize U32 = U32(exprStructSize(tls, p))
  58334 			libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp)), p, nSize)
  58335 			if nSize < U32(unsafe.Sizeof(Expr{})) {
  58336 				libc.Xmemset(tls, *(*uintptr)(unsafe.Pointer(bp))+uintptr(nSize), 0, uint32(unsafe.Sizeof(Expr{}))-nSize)
  58337 			}
  58338 		}
  58339 
  58340 		*(*U32)(unsafe.Pointer(pNew + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Reduced | EP_TokenOnly | EP_Static))
  58341 		*(*U32)(unsafe.Pointer(pNew + 4)) |= nStructSize & uint32(EP_Reduced|EP_TokenOnly)
  58342 		*(*U32)(unsafe.Pointer(pNew + 4)) |= staticFlag
  58343 
  58344 		if dupFlags != 0 {
  58345 		}
  58346 
  58347 		if nToken != 0 {
  58348 			var zToken uintptr = libc.AssignPtrUintptr(pNew+8, *(*uintptr)(unsafe.Pointer(bp))+uintptr(nNewSize))
  58349 			libc.Xmemcpy(tls, zToken, *(*uintptr)(unsafe.Pointer(p + 8)), uint32(nToken))
  58350 		}
  58351 
  58352 		if U32(0) == ((*Expr)(unsafe.Pointer(p)).Fflags|(*Expr)(unsafe.Pointer(pNew)).Fflags)&U32(EP_TokenOnly|EP_Leaf) {
  58353 			if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_xIsSelect) != U32(0) {
  58354 				*(*uintptr)(unsafe.Pointer(pNew + 20)) = Xsqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 20)), dupFlags)
  58355 			} else {
  58356 				*(*uintptr)(unsafe.Pointer(pNew + 20)) = Xsqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 20)), dupFlags)
  58357 			}
  58358 		}
  58359 
  58360 		if (*Expr)(unsafe.Pointer(pNew)).Fflags&U32(EP_Reduced|EP_TokenOnly|EP_WinFunc) != U32(0) {
  58361 			*(*uintptr)(unsafe.Pointer(bp)) += uintptr(dupedExprNodeSize(tls, p, dupFlags))
  58362 			if !((*Expr)(unsafe.Pointer(pNew)).Fflags&U32(EP_TokenOnly|EP_Leaf) != U32(0)) {
  58363 				(*Expr)(unsafe.Pointer(pNew)).FpLeft = func() uintptr {
  58364 					if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 {
  58365 						return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft, EXPRDUP_REDUCE, bp)
  58366 					}
  58367 					return uintptr(0)
  58368 				}()
  58369 				(*Expr)(unsafe.Pointer(pNew)).FpRight = func() uintptr {
  58370 					if (*Expr)(unsafe.Pointer(p)).FpRight != 0 {
  58371 						return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight, EXPRDUP_REDUCE, bp)
  58372 					}
  58373 					return uintptr(0)
  58374 				}()
  58375 			}
  58376 			if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_WinFunc) != U32(0) {
  58377 				*(*uintptr)(unsafe.Pointer(pNew + 44)) = Xsqlite3WindowDup(tls, db, pNew, *(*uintptr)(unsafe.Pointer(p + 44)))
  58378 
  58379 			}
  58380 			if pzBuffer != 0 {
  58381 				*(*uintptr)(unsafe.Pointer(pzBuffer)) = *(*uintptr)(unsafe.Pointer(bp))
  58382 			}
  58383 		} else {
  58384 			if !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_TokenOnly|EP_Leaf) != U32(0)) {
  58385 				if int32((*Expr)(unsafe.Pointer(pNew)).Fop) == TK_SELECT_COLUMN {
  58386 					(*Expr)(unsafe.Pointer(pNew)).FpLeft = (*Expr)(unsafe.Pointer(p)).FpLeft
  58387 
  58388 				} else {
  58389 					(*Expr)(unsafe.Pointer(pNew)).FpLeft = Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft, 0)
  58390 				}
  58391 				(*Expr)(unsafe.Pointer(pNew)).FpRight = Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight, 0)
  58392 			}
  58393 		}
  58394 	}
  58395 	return pNew
  58396 }
  58397 
  58398 // Create and return a deep copy of the object passed as the second
  58399 // argument. If an OOM condition is encountered, NULL is returned
  58400 // and the db->mallocFailed flag set.
  58401 func Xsqlite3WithDup(tls *libc.TLS, db uintptr, p uintptr) uintptr {
  58402 	var pRet uintptr = uintptr(0)
  58403 	if p != 0 {
  58404 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(With{})) + uint32(unsafe.Sizeof(Cte{}))*uint32((*With)(unsafe.Pointer(p)).FnCte-1))
  58405 		pRet = Xsqlite3DbMallocZero(tls, db, uint64(nByte))
  58406 		if pRet != 0 {
  58407 			var i int32
  58408 			(*With)(unsafe.Pointer(pRet)).FnCte = (*With)(unsafe.Pointer(p)).FnCte
  58409 			for i = 0; i < (*With)(unsafe.Pointer(p)).FnCte; i++ {
  58410 				(*Cte)(unsafe.Pointer(pRet + 12 + uintptr(i)*24)).FpSelect = Xsqlite3SelectDup(tls, db, (*Cte)(unsafe.Pointer(p+12+uintptr(i)*24)).FpSelect, 0)
  58411 				(*Cte)(unsafe.Pointer(pRet + 12 + uintptr(i)*24)).FpCols = Xsqlite3ExprListDup(tls, db, (*Cte)(unsafe.Pointer(p+12+uintptr(i)*24)).FpCols, 0)
  58412 				(*Cte)(unsafe.Pointer(pRet + 12 + uintptr(i)*24)).FzName = Xsqlite3DbStrDup(tls, db, (*Cte)(unsafe.Pointer(p+12+uintptr(i)*24)).FzName)
  58413 				(*Cte)(unsafe.Pointer(pRet + 12 + uintptr(i)*24)).FeM10d = (*Cte)(unsafe.Pointer(p + 12 + uintptr(i)*24)).FeM10d
  58414 			}
  58415 		}
  58416 	}
  58417 	return pRet
  58418 }
  58419 
  58420 func gatherSelectWindowsCallback(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  58421 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  58422 		var pSelect uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  58423 		var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  58424 
  58425 		Xsqlite3WindowLink(tls, pSelect, pWin)
  58426 	}
  58427 	return WRC_Continue
  58428 }
  58429 
  58430 func gatherSelectWindowsSelectCallback(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  58431 	if p == *(*uintptr)(unsafe.Pointer(pWalker + 24)) {
  58432 		return WRC_Continue
  58433 	}
  58434 	return WRC_Prune
  58435 }
  58436 
  58437 func gatherSelectWindows(tls *libc.TLS, p uintptr) {
  58438 	bp := tls.Alloc(28)
  58439 	defer tls.Free(28)
  58440 
  58441 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  58442 		f func(*libc.TLS, uintptr, uintptr) int32
  58443 	}{gatherSelectWindowsCallback}))
  58444 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  58445 		f func(*libc.TLS, uintptr, uintptr) int32
  58446 	}{gatherSelectWindowsSelectCallback}))
  58447 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = uintptr(0)
  58448 	(*Walker)(unsafe.Pointer(bp)).FpParse = uintptr(0)
  58449 	*(*uintptr)(unsafe.Pointer(bp + 24)) = p
  58450 	Xsqlite3WalkSelect(tls, bp, p)
  58451 }
  58452 
  58453 // The following group of routines make deep copies of expressions,
  58454 // expression lists, ID lists, and select statements.  The copies can
  58455 // be deleted (by being passed to their respective ...Delete() routines)
  58456 // without effecting the originals.
  58457 //
  58458 // The expression list, ID, and source lists return by sqlite3ExprListDup(),
  58459 // sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded
  58460 // by subsequent calls to sqlite*ListAppend() routines.
  58461 //
  58462 // Any tables that the SrcList might point to are not duplicated.
  58463 //
  58464 // The flags parameter contains a combination of the EXPRDUP_XXX flags.
  58465 // If the EXPRDUP_REDUCE flag is set, then the structure returned is a
  58466 // truncated version of the usual Expr structure that will be stored as
  58467 // part of the in-memory representation of the database schema.
  58468 func Xsqlite3ExprDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) uintptr {
  58469 	if p != 0 {
  58470 		return exprDup(tls, db, p, flags, uintptr(0))
  58471 	}
  58472 	return uintptr(0)
  58473 }
  58474 
  58475 func Xsqlite3ExprListDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) uintptr {
  58476 	var pNew uintptr
  58477 	var pItem uintptr
  58478 	var pOldItem uintptr
  58479 	var i int32
  58480 	var pPriorSelectColOld uintptr = uintptr(0)
  58481 	var pPriorSelectColNew uintptr = uintptr(0)
  58482 
  58483 	if p == uintptr(0) {
  58484 		return uintptr(0)
  58485 	}
  58486 	pNew = Xsqlite3DbMallocRawNN(tls, db, uint64(Xsqlite3DbMallocSize(tls, db, p)))
  58487 	if pNew == uintptr(0) {
  58488 		return uintptr(0)
  58489 	}
  58490 	(*ExprList)(unsafe.Pointer(pNew)).FnExpr = (*ExprList)(unsafe.Pointer(p)).FnExpr
  58491 	(*ExprList)(unsafe.Pointer(pNew)).FnAlloc = (*ExprList)(unsafe.Pointer(p)).FnAlloc
  58492 	pItem = pNew + 8
  58493 	pOldItem = p + 8
  58494 	i = 0
  58495 __1:
  58496 	if !(i < (*ExprList)(unsafe.Pointer(p)).FnExpr) {
  58497 		goto __3
  58498 	}
  58499 	{
  58500 		var pOldExpr uintptr = (*ExprList_item)(unsafe.Pointer(pOldItem)).FpExpr
  58501 		var pNewExpr uintptr
  58502 		(*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = Xsqlite3ExprDup(tls, db, pOldExpr, flags)
  58503 		if pOldExpr != 0 &&
  58504 			int32((*Expr)(unsafe.Pointer(pOldExpr)).Fop) == TK_SELECT_COLUMN &&
  58505 			libc.AssignUintptr(&pNewExpr, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr) != uintptr(0) {
  58506 			if (*Expr)(unsafe.Pointer(pNewExpr)).FpRight != 0 {
  58507 				pPriorSelectColOld = (*Expr)(unsafe.Pointer(pOldExpr)).FpRight
  58508 				pPriorSelectColNew = (*Expr)(unsafe.Pointer(pNewExpr)).FpRight
  58509 				(*Expr)(unsafe.Pointer(pNewExpr)).FpLeft = (*Expr)(unsafe.Pointer(pNewExpr)).FpRight
  58510 			} else {
  58511 				if (*Expr)(unsafe.Pointer(pOldExpr)).FpLeft != pPriorSelectColOld {
  58512 					pPriorSelectColOld = (*Expr)(unsafe.Pointer(pOldExpr)).FpLeft
  58513 					pPriorSelectColNew = Xsqlite3ExprDup(tls, db, pPriorSelectColOld, flags)
  58514 					(*Expr)(unsafe.Pointer(pNewExpr)).FpRight = pPriorSelectColNew
  58515 				}
  58516 				(*Expr)(unsafe.Pointer(pNewExpr)).FpLeft = pPriorSelectColNew
  58517 			}
  58518 		}
  58519 		(*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbStrDup(tls, db, (*ExprList_item)(unsafe.Pointer(pOldItem)).FzEName)
  58520 		(*ExprList_item)(unsafe.Pointer(pItem)).Ffg = (*ExprList_item)(unsafe.Pointer(pOldItem)).Ffg
  58521 		libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(0), 2, 0x4)
  58522 		(*ExprList_item)(unsafe.Pointer(pItem)).Fu = (*ExprList_item)(unsafe.Pointer(pOldItem)).Fu
  58523 
  58524 	}
  58525 	goto __2
  58526 __2:
  58527 	i++
  58528 	pItem += 20
  58529 	pOldItem += 20
  58530 	goto __1
  58531 	goto __3
  58532 __3:
  58533 	;
  58534 	return pNew
  58535 }
  58536 
  58537 // If cursors, triggers, views and subqueries are all omitted from
  58538 // the build, then none of the following routines, except for
  58539 // sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes
  58540 // called with a NULL argument.
  58541 func Xsqlite3SrcListDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) uintptr {
  58542 	var pNew uintptr
  58543 	var i int32
  58544 	var nByte int32
  58545 
  58546 	if p == uintptr(0) {
  58547 		return uintptr(0)
  58548 	}
  58549 	nByte = int32(uint32(unsafe.Sizeof(SrcList{})) + func() uint32 {
  58550 		if (*SrcList)(unsafe.Pointer(p)).FnSrc > 0 {
  58551 			return uint32(unsafe.Sizeof(SrcItem{})) * uint32((*SrcList)(unsafe.Pointer(p)).FnSrc-1)
  58552 		}
  58553 		return uint32(0)
  58554 	}())
  58555 	pNew = Xsqlite3DbMallocRawNN(tls, db, uint64(nByte))
  58556 	if pNew == uintptr(0) {
  58557 		return uintptr(0)
  58558 	}
  58559 	(*SrcList)(unsafe.Pointer(pNew)).FnSrc = int32(libc.AssignPtrUint32(pNew+4, U32((*SrcList)(unsafe.Pointer(p)).FnSrc)))
  58560 	for i = 0; i < (*SrcList)(unsafe.Pointer(p)).FnSrc; i++ {
  58561 		var pNewItem uintptr = pNew + 8 + uintptr(i)*72
  58562 		var pOldItem uintptr = p + 8 + uintptr(i)*72
  58563 		var pTab uintptr
  58564 		(*SrcItem)(unsafe.Pointer(pNewItem)).FpSchema = (*SrcItem)(unsafe.Pointer(pOldItem)).FpSchema
  58565 		(*SrcItem)(unsafe.Pointer(pNewItem)).FzDatabase = Xsqlite3DbStrDup(tls, db, (*SrcItem)(unsafe.Pointer(pOldItem)).FzDatabase)
  58566 		(*SrcItem)(unsafe.Pointer(pNewItem)).FzName = Xsqlite3DbStrDup(tls, db, (*SrcItem)(unsafe.Pointer(pOldItem)).FzName)
  58567 		(*SrcItem)(unsafe.Pointer(pNewItem)).FzAlias = Xsqlite3DbStrDup(tls, db, (*SrcItem)(unsafe.Pointer(pOldItem)).FzAlias)
  58568 		(*SrcItem)(unsafe.Pointer(pNewItem)).Ffg = (*SrcItem)(unsafe.Pointer(pOldItem)).Ffg
  58569 		(*SrcItem)(unsafe.Pointer(pNewItem)).FiCursor = (*SrcItem)(unsafe.Pointer(pOldItem)).FiCursor
  58570 		(*SrcItem)(unsafe.Pointer(pNewItem)).FaddrFillSub = (*SrcItem)(unsafe.Pointer(pOldItem)).FaddrFillSub
  58571 		(*SrcItem)(unsafe.Pointer(pNewItem)).FregReturn = (*SrcItem)(unsafe.Pointer(pOldItem)).FregReturn
  58572 		if uint32(int32(*(*uint16)(unsafe.Pointer(pNewItem + 36 + 4))&0x2>>1)) != 0 {
  58573 			*(*uintptr)(unsafe.Pointer(pNewItem + 64)) = Xsqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 64)))
  58574 		}
  58575 		(*SrcItem)(unsafe.Pointer(pNewItem)).Fu2 = (*SrcItem)(unsafe.Pointer(pOldItem)).Fu2
  58576 		if uint32(int32(*(*uint16)(unsafe.Pointer(pNewItem + 36 + 4))&0x100>>8)) != 0 {
  58577 			(*CteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNewItem + 68)))).FnUse++
  58578 		}
  58579 		if uint32(int32(*(*uint16)(unsafe.Pointer(pNewItem + 36 + 4))&0x4>>2)) != 0 {
  58580 			*(*uintptr)(unsafe.Pointer(pNewItem + 64)) = Xsqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 64)), flags)
  58581 		}
  58582 		pTab = libc.AssignPtrUintptr(pNewItem+16, (*SrcItem)(unsafe.Pointer(pOldItem)).FpTab)
  58583 		if pTab != 0 {
  58584 			(*Table)(unsafe.Pointer(pTab)).FnTabRef++
  58585 		}
  58586 		(*SrcItem)(unsafe.Pointer(pNewItem)).FpSelect = Xsqlite3SelectDup(tls, db, (*SrcItem)(unsafe.Pointer(pOldItem)).FpSelect, flags)
  58587 		if uint32(int32(*(*uint16)(unsafe.Pointer(pOldItem + 36 + 4))&0x400>>10)) != 0 {
  58588 			*(*uintptr)(unsafe.Pointer(pNewItem + 48)) = Xsqlite3IdListDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 48)))
  58589 		} else {
  58590 			*(*uintptr)(unsafe.Pointer(pNewItem + 48)) = Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(pOldItem + 48)), flags)
  58591 		}
  58592 		(*SrcItem)(unsafe.Pointer(pNewItem)).FcolUsed = (*SrcItem)(unsafe.Pointer(pOldItem)).FcolUsed
  58593 	}
  58594 	return pNew
  58595 }
  58596 
  58597 func Xsqlite3IdListDup(tls *libc.TLS, db uintptr, p uintptr) uintptr {
  58598 	var pNew uintptr
  58599 	var i int32
  58600 
  58601 	if p == uintptr(0) {
  58602 		return uintptr(0)
  58603 	}
  58604 
  58605 	pNew = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(IdList{}))+uint32((*IdList)(unsafe.Pointer(p)).FnId-1)*uint32(unsafe.Sizeof(IdList_item{}))))
  58606 	if pNew == uintptr(0) {
  58607 		return uintptr(0)
  58608 	}
  58609 	(*IdList)(unsafe.Pointer(pNew)).FnId = (*IdList)(unsafe.Pointer(p)).FnId
  58610 	(*IdList)(unsafe.Pointer(pNew)).FeU4 = (*IdList)(unsafe.Pointer(p)).FeU4
  58611 	for i = 0; i < (*IdList)(unsafe.Pointer(p)).FnId; i++ {
  58612 		var pNewItem uintptr = pNew + 8 + uintptr(i)*8
  58613 		var pOldItem uintptr = p + 8 + uintptr(i)*8
  58614 		(*IdList_item)(unsafe.Pointer(pNewItem)).FzName = Xsqlite3DbStrDup(tls, db, (*IdList_item)(unsafe.Pointer(pOldItem)).FzName)
  58615 		(*IdList_item)(unsafe.Pointer(pNewItem)).Fu4 = (*IdList_item)(unsafe.Pointer(pOldItem)).Fu4
  58616 	}
  58617 	return pNew
  58618 }
  58619 
  58620 func Xsqlite3SelectDup(tls *libc.TLS, db uintptr, pDup uintptr, flags int32) uintptr {
  58621 	bp := tls.Alloc(4)
  58622 	defer tls.Free(4)
  58623 
  58624 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  58625 	var pNext uintptr = uintptr(0)
  58626 	var pp uintptr = bp
  58627 	var p uintptr
  58628 
  58629 	for p = pDup; p != 0; p = (*Select)(unsafe.Pointer(p)).FpPrior {
  58630 		var pNew uintptr = Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(Select{})))
  58631 		if pNew == uintptr(0) {
  58632 			break
  58633 		}
  58634 		(*Select)(unsafe.Pointer(pNew)).FpEList = Xsqlite3ExprListDup(tls, db, (*Select)(unsafe.Pointer(p)).FpEList, flags)
  58635 		(*Select)(unsafe.Pointer(pNew)).FpSrc = Xsqlite3SrcListDup(tls, db, (*Select)(unsafe.Pointer(p)).FpSrc, flags)
  58636 		(*Select)(unsafe.Pointer(pNew)).FpWhere = Xsqlite3ExprDup(tls, db, (*Select)(unsafe.Pointer(p)).FpWhere, flags)
  58637 		(*Select)(unsafe.Pointer(pNew)).FpGroupBy = Xsqlite3ExprListDup(tls, db, (*Select)(unsafe.Pointer(p)).FpGroupBy, flags)
  58638 		(*Select)(unsafe.Pointer(pNew)).FpHaving = Xsqlite3ExprDup(tls, db, (*Select)(unsafe.Pointer(p)).FpHaving, flags)
  58639 		(*Select)(unsafe.Pointer(pNew)).FpOrderBy = Xsqlite3ExprListDup(tls, db, (*Select)(unsafe.Pointer(p)).FpOrderBy, flags)
  58640 		(*Select)(unsafe.Pointer(pNew)).Fop = (*Select)(unsafe.Pointer(p)).Fop
  58641 		(*Select)(unsafe.Pointer(pNew)).FpNext = pNext
  58642 		(*Select)(unsafe.Pointer(pNew)).FpPrior = uintptr(0)
  58643 		(*Select)(unsafe.Pointer(pNew)).FpLimit = Xsqlite3ExprDup(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit, flags)
  58644 		(*Select)(unsafe.Pointer(pNew)).FiLimit = 0
  58645 		(*Select)(unsafe.Pointer(pNew)).FiOffset = 0
  58646 		(*Select)(unsafe.Pointer(pNew)).FselFlags = (*Select)(unsafe.Pointer(p)).FselFlags & libc.Uint32FromInt32(libc.CplInt32(SF_UsesEphemeral))
  58647 		*(*int32)(unsafe.Pointer(pNew + 20)) = -1
  58648 		*(*int32)(unsafe.Pointer(pNew + 20 + 1*4)) = -1
  58649 		(*Select)(unsafe.Pointer(pNew)).FnSelectRow = (*Select)(unsafe.Pointer(p)).FnSelectRow
  58650 		(*Select)(unsafe.Pointer(pNew)).FpWith = Xsqlite3WithDup(tls, db, (*Select)(unsafe.Pointer(p)).FpWith)
  58651 		(*Select)(unsafe.Pointer(pNew)).FpWin = uintptr(0)
  58652 		(*Select)(unsafe.Pointer(pNew)).FpWinDefn = Xsqlite3WindowListDup(tls, db, (*Select)(unsafe.Pointer(p)).FpWinDefn)
  58653 		if (*Select)(unsafe.Pointer(p)).FpWin != 0 && int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  58654 			gatherSelectWindows(tls, pNew)
  58655 		}
  58656 		(*Select)(unsafe.Pointer(pNew)).FselId = (*Select)(unsafe.Pointer(p)).FselId
  58657 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  58658 			(*Select)(unsafe.Pointer(pNew)).FpNext = uintptr(0)
  58659 			Xsqlite3SelectDelete(tls, db, pNew)
  58660 			break
  58661 		}
  58662 		*(*uintptr)(unsafe.Pointer(pp)) = pNew
  58663 		pp = pNew + 52
  58664 		pNext = pNew
  58665 	}
  58666 
  58667 	return *(*uintptr)(unsafe.Pointer(bp))
  58668 }
  58669 
  58670 var zeroItem = ExprList_item{}
  58671 
  58672 func Xsqlite3ExprListAppendNew(tls *libc.TLS, db uintptr, pExpr uintptr) uintptr {
  58673 	var pItem uintptr
  58674 	var pList uintptr
  58675 
  58676 	pList = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(ExprList{}))+uint32(unsafe.Sizeof(ExprList_item{}))*uint32(4)))
  58677 	if pList == uintptr(0) {
  58678 		Xsqlite3ExprDelete(tls, db, pExpr)
  58679 		return uintptr(0)
  58680 	}
  58681 	(*ExprList)(unsafe.Pointer(pList)).FnAlloc = 4
  58682 	(*ExprList)(unsafe.Pointer(pList)).FnExpr = 1
  58683 	pItem = pList + 8
  58684 	*(*ExprList_item)(unsafe.Pointer(pItem)) = zeroItem
  58685 	(*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = pExpr
  58686 	return pList
  58687 }
  58688 
  58689 func Xsqlite3ExprListAppendGrow(tls *libc.TLS, db uintptr, pList uintptr, pExpr uintptr) uintptr {
  58690 	var pItem uintptr
  58691 	var pNew uintptr
  58692 	*(*int32)(unsafe.Pointer(pList + 4)) *= 2
  58693 	pNew = Xsqlite3DbRealloc(tls, db, pList,
  58694 		uint64(uint32(unsafe.Sizeof(ExprList{}))+uint32((*ExprList)(unsafe.Pointer(pList)).FnAlloc-1)*uint32(unsafe.Sizeof(ExprList_item{}))))
  58695 	if pNew == uintptr(0) {
  58696 		Xsqlite3ExprListDelete(tls, db, pList)
  58697 		Xsqlite3ExprDelete(tls, db, pExpr)
  58698 		return uintptr(0)
  58699 	} else {
  58700 		pList = pNew
  58701 	}
  58702 	pItem = pList + 8 + uintptr(libc.PostIncInt32(&(*ExprList)(unsafe.Pointer(pList)).FnExpr, 1))*20
  58703 	*(*ExprList_item)(unsafe.Pointer(pItem)) = zeroItem
  58704 	(*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = pExpr
  58705 	return pList
  58706 }
  58707 
  58708 func Xsqlite3ExprListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pExpr uintptr) uintptr {
  58709 	var pItem uintptr
  58710 	if pList == uintptr(0) {
  58711 		return Xsqlite3ExprListAppendNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  58712 	}
  58713 	if (*ExprList)(unsafe.Pointer(pList)).FnAlloc < (*ExprList)(unsafe.Pointer(pList)).FnExpr+1 {
  58714 		return Xsqlite3ExprListAppendGrow(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList, pExpr)
  58715 	}
  58716 	pItem = pList + 8 + uintptr(libc.PostIncInt32(&(*ExprList)(unsafe.Pointer(pList)).FnExpr, 1))*20
  58717 	*(*ExprList_item)(unsafe.Pointer(pItem)) = zeroItem
  58718 	(*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = pExpr
  58719 	return pList
  58720 }
  58721 
  58722 // pColumns and pExpr form a vector assignment which is part of the SET
  58723 // clause of an UPDATE statement.  Like this:
  58724 //
  58725 //	(a,b,c) = (expr1,expr2,expr3)
  58726 //
  58727 // Or:    (a,b,c) = (SELECT x,y,z FROM ....)
  58728 //
  58729 // For each term of the vector assignment, append new entries to the
  58730 // expression list pList.  In the case of a subquery on the RHS, append
  58731 // TK_SELECT_COLUMN expressions.
  58732 func Xsqlite3ExprListAppendVector(tls *libc.TLS, pParse uintptr, pList uintptr, pColumns uintptr, pExpr uintptr) uintptr {
  58733 	bp := tls.Alloc(16)
  58734 	defer tls.Free(16)
  58735 
  58736 	var db uintptr
  58737 	var n int32
  58738 	var i int32
  58739 	var iFirst int32
  58740 	var pSubExpr uintptr
  58741 	var pFirst uintptr
  58742 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  58743 	if pList != 0 {
  58744 		iFirst = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  58745 	} else {
  58746 		iFirst = 0
  58747 	}
  58748 
  58749 	if !(pColumns == uintptr(0)) {
  58750 		goto __1
  58751 	}
  58752 	goto vector_append_error
  58753 __1:
  58754 	;
  58755 	if !(pExpr == uintptr(0)) {
  58756 		goto __2
  58757 	}
  58758 	goto vector_append_error
  58759 __2:
  58760 	;
  58761 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_SELECT && (*IdList)(unsafe.Pointer(pColumns)).FnId != libc.AssignInt32(&n, Xsqlite3ExprVectorSize(tls, pExpr))) {
  58762 		goto __3
  58763 	}
  58764 	Xsqlite3ErrorMsg(tls, pParse, ts+7641,
  58765 		libc.VaList(bp, (*IdList)(unsafe.Pointer(pColumns)).FnId, n))
  58766 	goto vector_append_error
  58767 __3:
  58768 	;
  58769 	i = 0
  58770 __4:
  58771 	if !(i < (*IdList)(unsafe.Pointer(pColumns)).FnId) {
  58772 		goto __6
  58773 	}
  58774 	pSubExpr = Xsqlite3ExprForVectorField(tls, pParse, pExpr, i, (*IdList)(unsafe.Pointer(pColumns)).FnId)
  58775 
  58776 	if !(pSubExpr == uintptr(0)) {
  58777 		goto __7
  58778 	}
  58779 	goto __5
  58780 __7:
  58781 	;
  58782 	pList = Xsqlite3ExprListAppend(tls, pParse, pList, pSubExpr)
  58783 	if !(pList != 0) {
  58784 		goto __8
  58785 	}
  58786 
  58787 	(*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr((*ExprList)(unsafe.Pointer(pList)).FnExpr-1)*20)).FzEName = (*IdList_item)(unsafe.Pointer(pColumns + 8 + uintptr(i)*8)).FzName
  58788 	(*IdList_item)(unsafe.Pointer(pColumns + 8 + uintptr(i)*8)).FzName = uintptr(0)
  58789 __8:
  58790 	;
  58791 	goto __5
  58792 __5:
  58793 	i++
  58794 	goto __4
  58795 	goto __6
  58796 __6:
  58797 	;
  58798 	if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT && pList != uintptr(0)) {
  58799 		goto __9
  58800 	}
  58801 	pFirst = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(iFirst)*20)).FpExpr
  58802 
  58803 	(*Expr)(unsafe.Pointer(pFirst)).FpRight = pExpr
  58804 	pExpr = uintptr(0)
  58805 
  58806 	(*Expr)(unsafe.Pointer(pFirst)).FiTable = (*IdList)(unsafe.Pointer(pColumns)).FnId
  58807 __9:
  58808 	;
  58809 vector_append_error:
  58810 	Xsqlite3ExprUnmapAndDelete(tls, pParse, pExpr)
  58811 	Xsqlite3IdListDelete(tls, db, pColumns)
  58812 	return pList
  58813 }
  58814 
  58815 // Set the sort order for the last element on the given ExprList.
  58816 func Xsqlite3ExprListSetSortOrder(tls *libc.TLS, p uintptr, iSortOrder int32, eNulls int32) {
  58817 	var pItem uintptr
  58818 	if p == uintptr(0) {
  58819 		return
  58820 	}
  58821 
  58822 	pItem = p + 8 + uintptr((*ExprList)(unsafe.Pointer(p)).FnExpr-1)*20
  58823 
  58824 	if iSortOrder == -1 {
  58825 		iSortOrder = SQLITE_SO_ASC
  58826 	}
  58827 	(*ExprList_item)(unsafe.Pointer(pItem)).Ffg.FsortFlags = U8(iSortOrder)
  58828 
  58829 	if eNulls != -1 {
  58830 		libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(1), 5, 0x20)
  58831 		if iSortOrder != eNulls {
  58832 			*(*U8)(unsafe.Pointer(pItem + 8)) |= U8(KEYINFO_ORDER_BIGNULL)
  58833 		}
  58834 	}
  58835 }
  58836 
  58837 // Set the ExprList.a[].zEName element of the most recently added item
  58838 // on the expression list.
  58839 //
  58840 // pList might be NULL following an OOM error.  But pName should never be
  58841 // NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag
  58842 // is set.
  58843 func Xsqlite3ExprListSetName(tls *libc.TLS, pParse uintptr, pList uintptr, pName uintptr, dequote int32) {
  58844 	if pList != 0 {
  58845 		var pItem uintptr
  58846 
  58847 		pItem = pList + 8 + uintptr((*ExprList)(unsafe.Pointer(pList)).FnExpr-1)*20
  58848 
  58849 		(*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(pName)).Fz, uint64((*Token)(unsafe.Pointer(pName)).Fn))
  58850 		if dequote != 0 {
  58851 			Xsqlite3Dequote(tls, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName)
  58852 			if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  58853 				Xsqlite3RenameTokenMap(tls, pParse, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName, pName)
  58854 			}
  58855 		}
  58856 	}
  58857 }
  58858 
  58859 // Set the ExprList.a[].zSpan element of the most recently added item
  58860 // on the expression list.
  58861 //
  58862 // pList might be NULL following an OOM error.  But pSpan should never be
  58863 // NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag
  58864 // is set.
  58865 func Xsqlite3ExprListSetSpan(tls *libc.TLS, pParse uintptr, pList uintptr, zStart uintptr, zEnd uintptr) {
  58866 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  58867 
  58868 	if pList != 0 {
  58869 		var pItem uintptr = pList + 8 + uintptr((*ExprList)(unsafe.Pointer(pList)).FnExpr-1)*20
  58870 
  58871 		if (*ExprList_item)(unsafe.Pointer(pItem)).FzEName == uintptr(0) {
  58872 			(*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbSpanDup(tls, db, zStart, zEnd)
  58873 			libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(ENAME_SPAN), 0, 0x3)
  58874 		}
  58875 	}
  58876 }
  58877 
  58878 // If the expression list pEList contains more than iLimit elements,
  58879 // leave an error message in pParse.
  58880 func Xsqlite3ExprListCheckLength(tls *libc.TLS, pParse uintptr, pEList uintptr, zObject uintptr) {
  58881 	bp := tls.Alloc(8)
  58882 	defer tls.Free(8)
  58883 
  58884 	var mx int32 = *(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb + 120 + 2*4))
  58885 
  58886 	if pEList != 0 && (*ExprList)(unsafe.Pointer(pEList)).FnExpr > mx {
  58887 		Xsqlite3ErrorMsg(tls, pParse, ts+7671, libc.VaList(bp, zObject))
  58888 	}
  58889 }
  58890 
  58891 func exprListDeleteNN(tls *libc.TLS, db uintptr, pList uintptr) {
  58892 	var i int32 = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  58893 	var pItem uintptr = pList + 8
  58894 
  58895 	for __ccgo := true; __ccgo; __ccgo = libc.PreDecInt32(&i, 1) > 0 {
  58896 		Xsqlite3ExprDelete(tls, db, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)
  58897 		if (*ExprList_item)(unsafe.Pointer(pItem)).FzEName != 0 {
  58898 			Xsqlite3DbNNFreeNN(tls, db, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName)
  58899 		}
  58900 		pItem += 20
  58901 	}
  58902 	Xsqlite3DbNNFreeNN(tls, db, pList)
  58903 }
  58904 
  58905 func Xsqlite3ExprListDelete(tls *libc.TLS, db uintptr, pList uintptr) {
  58906 	if pList != 0 {
  58907 		exprListDeleteNN(tls, db, pList)
  58908 	}
  58909 }
  58910 
  58911 // Return the bitwise-OR of all Expr.flags fields in the given
  58912 // ExprList.
  58913 func Xsqlite3ExprListFlags(tls *libc.TLS, pList uintptr) U32 {
  58914 	var i int32
  58915 	var m U32 = U32(0)
  58916 
  58917 	for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
  58918 		var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*20)).FpExpr
  58919 
  58920 		m = m | (*Expr)(unsafe.Pointer(pExpr)).Fflags
  58921 	}
  58922 	return m
  58923 }
  58924 
  58925 // This is a SELECT-node callback for the expression walker that
  58926 // always "fails".  By "fail" in this case, we mean set
  58927 // pWalker->eCode to zero and abort.
  58928 //
  58929 // This callback is used by multiple expression walkers.
  58930 func Xsqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) int32 {
  58931 	_ = NotUsed
  58932 	(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  58933 	return WRC_Abort
  58934 }
  58935 
  58936 // Check the input string to see if it is "true" or "false" (in any case).
  58937 //
  58938 //	If the string is....           Return
  58939 //	  "true"                         EP_IsTrue
  58940 //	  "false"                        EP_IsFalse
  58941 //	  anything else                  0
  58942 func Xsqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) U32 {
  58943 	if Xsqlite3StrICmp(tls, zIn, ts+7694) == 0 {
  58944 		return U32(EP_IsTrue)
  58945 	}
  58946 	if Xsqlite3StrICmp(tls, zIn, ts+7699) == 0 {
  58947 		return U32(EP_IsFalse)
  58948 	}
  58949 	return U32(0)
  58950 }
  58951 
  58952 // If the input expression is an ID with the name "true" or "false"
  58953 // then convert it into an TK_TRUEFALSE term.  Return non-zero if
  58954 // the conversion happened, and zero if the expression is unaltered.
  58955 func Xsqlite3ExprIdToTrueFalse(tls *libc.TLS, pExpr uintptr) int32 {
  58956 	var v U32
  58957 
  58958 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Quoted|EP_IntValue) != U32(0)) &&
  58959 		libc.AssignUint32(&v, Xsqlite3IsTrueOrFalse(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) != U32(0) {
  58960 		(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_TRUEFALSE)
  58961 		*(*U32)(unsafe.Pointer(pExpr + 4)) |= v
  58962 		return 1
  58963 	}
  58964 	return 0
  58965 }
  58966 
  58967 // The argument must be a TK_TRUEFALSE Expr node.  Return 1 if it is TRUE
  58968 // and 0 if it is FALSE.
  58969 func Xsqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) int32 {
  58970 	pExpr = Xsqlite3ExprSkipCollate(tls, pExpr)
  58971 
  58972 	return libc.Bool32(int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8)) + 4))) == 0)
  58973 }
  58974 
  58975 // If pExpr is an AND or OR expression, try to simplify it by eliminating
  58976 // terms that are always true or false.  Return the simplified expression.
  58977 // Or return the original expression if no simplification is possible.
  58978 //
  58979 // Examples:
  58980 //
  58981 //	(x<10) AND true                =>   (x<10)
  58982 //	(x<10) AND false               =>   false
  58983 //	(x<10) AND (y=22 OR false)     =>   (x<10) AND (y=22)
  58984 //	(x<10) AND (y=22 OR true)      =>   (x<10)
  58985 //	(y=22) OR true                 =>   true
  58986 func Xsqlite3ExprSimplifiedAndOr(tls *libc.TLS, pExpr uintptr) uintptr {
  58987 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_OR {
  58988 		var pRight uintptr = Xsqlite3ExprSimplifiedAndOr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  58989 		var pLeft uintptr = Xsqlite3ExprSimplifiedAndOr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  58990 		if (*Expr)(unsafe.Pointer(pLeft)).Fflags&U32(EP_OuterON|EP_IsTrue) == U32(EP_IsTrue) || (*Expr)(unsafe.Pointer(pRight)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse) {
  58991 			if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND {
  58992 				pExpr = pRight
  58993 			} else {
  58994 				pExpr = pLeft
  58995 			}
  58996 		} else if (*Expr)(unsafe.Pointer(pRight)).Fflags&U32(EP_OuterON|EP_IsTrue) == U32(EP_IsTrue) || (*Expr)(unsafe.Pointer(pLeft)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse) {
  58997 			if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND {
  58998 				pExpr = pLeft
  58999 			} else {
  59000 				pExpr = pRight
  59001 			}
  59002 		}
  59003 	}
  59004 	return pExpr
  59005 }
  59006 
  59007 func exprNodeIsConstant(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  59008 	if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 2 && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) {
  59009 		(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  59010 		return WRC_Abort
  59011 	}
  59012 
  59013 	{
  59014 		switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  59015 		case TK_FUNCTION:
  59016 			if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) >= 4 || (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_ConstFunc) != U32(0)) &&
  59017 				!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0)) {
  59018 				if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 5 {
  59019 					*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_FromDDL)
  59020 				}
  59021 				return WRC_Continue
  59022 			} else {
  59023 				(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  59024 				return WRC_Abort
  59025 			}
  59026 			fallthrough
  59027 		case TK_ID:
  59028 			if Xsqlite3ExprIdToTrueFalse(tls, pExpr) != 0 {
  59029 				return WRC_Prune
  59030 			}
  59031 			fallthrough
  59032 		case TK_COLUMN:
  59033 			fallthrough
  59034 		case TK_AGG_FUNCTION:
  59035 			fallthrough
  59036 		case TK_AGG_COLUMN:
  59037 			if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_FixedCol) != U32(0) && int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) != 2 {
  59038 				return WRC_Continue
  59039 			}
  59040 			if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 3 && (*Expr)(unsafe.Pointer(pExpr)).FiTable == *(*int32)(unsafe.Pointer(pWalker + 24)) {
  59041 				return WRC_Continue
  59042 			}
  59043 			fallthrough
  59044 		case TK_IF_NULL_ROW:
  59045 			fallthrough
  59046 		case TK_REGISTER:
  59047 			fallthrough
  59048 		case TK_DOT:
  59049 			(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  59050 			return WRC_Abort
  59051 		case TK_VARIABLE:
  59052 			if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 5 {
  59053 				(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_NULL)
  59054 			} else if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 4 {
  59055 				(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  59056 				return WRC_Abort
  59057 			}
  59058 			fallthrough
  59059 		default:
  59060 			return WRC_Continue
  59061 		}
  59062 	}
  59063 	return int32(0)
  59064 }
  59065 
  59066 func exprIsConst(tls *libc.TLS, p uintptr, initFlag int32, iCur int32) int32 {
  59067 	bp := tls.Alloc(28)
  59068 	defer tls.Free(28)
  59069 
  59070 	(*Walker)(unsafe.Pointer(bp)).FeCode = U16(initFlag)
  59071 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  59072 		f func(*libc.TLS, uintptr, uintptr) int32
  59073 	}{exprNodeIsConstant}))
  59074 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  59075 		f func(*libc.TLS, uintptr, uintptr) int32
  59076 	}{Xsqlite3SelectWalkFail}))
  59077 	*(*int32)(unsafe.Pointer(bp + 24)) = iCur
  59078 	Xsqlite3WalkExpr(tls, bp, p)
  59079 	return int32((*Walker)(unsafe.Pointer(bp)).FeCode)
  59080 }
  59081 
  59082 // Walk an expression tree.  Return non-zero if the expression is constant
  59083 // and 0 if it involves variables or function calls.
  59084 //
  59085 // For the purposes of this function, a double-quoted string (ex: "abc")
  59086 // is considered a variable but a single-quoted string (ex: 'abc') is
  59087 // a constant.
  59088 func Xsqlite3ExprIsConstant(tls *libc.TLS, p uintptr) int32 {
  59089 	return exprIsConst(tls, p, 1, 0)
  59090 }
  59091 
  59092 // Walk an expression tree.  Return non-zero if
  59093 //
  59094 //	(1) the expression is constant, and
  59095 //	(2) the expression does originate in the ON or USING clause
  59096 //	    of a LEFT JOIN, and
  59097 //	(3) the expression does not contain any EP_FixedCol TK_COLUMN
  59098 //	    operands created by the constant propagation optimization.
  59099 //
  59100 // When this routine returns true, it indicates that the expression
  59101 // can be added to the pParse->pConstExpr list and evaluated once when
  59102 // the prepared statement starts up.  See sqlite3ExprCodeRunJustOnce().
  59103 func Xsqlite3ExprIsConstantNotJoin(tls *libc.TLS, p uintptr) int32 {
  59104 	return exprIsConst(tls, p, 2, 0)
  59105 }
  59106 
  59107 // Walk an expression tree.  Return non-zero if the expression is constant
  59108 // for any single row of the table with cursor iCur.  In other words, the
  59109 // expression must not refer to any non-deterministic function nor any
  59110 // table other than iCur.
  59111 func Xsqlite3ExprIsTableConstant(tls *libc.TLS, p uintptr, iCur int32) int32 {
  59112 	return exprIsConst(tls, p, 3, iCur)
  59113 }
  59114 
  59115 //	Check pExpr to see if it is an invariant constraint on data source pSrc.
  59116 //	This is an optimization.  False negatives will perhaps cause slower
  59117 //	queries, but false positives will yield incorrect answers.  So when in
  59118 //	doubt, return 0.
  59119 //
  59120 //	To be an invariant constraint, the following must be true:
  59121 //
  59122 //	  (1)  pExpr cannot refer to any table other than pSrc->iCursor.
  59123 //
  59124 //	  (2)  pExpr cannot use subqueries or non-deterministic functions.
  59125 //
  59126 //	  (3)  pSrc cannot be part of the left operand for a RIGHT JOIN.
  59127 //	       (Is there some way to relax this constraint?)
  59128 //
  59129 //	  (4)  If pSrc is the right operand of a LEFT JOIN, then...
  59130 //	        (4a)  pExpr must come from an ON clause..
  59131 //	          (4b)  and specifically the ON clause associated with the LEFT JOIN.
  59132 //
  59133 // **
  59134 // **   (5)  If pSrc is not the right operand of a LEFT JOIN or the left
  59135 // **        operand of a RIGHT JOIN, then pExpr must be from the WHERE
  59136 // **        clause, not an ON clause.
  59137 func Xsqlite3ExprIsTableConstraint(tls *libc.TLS, pExpr uintptr, pSrc uintptr) int32 {
  59138 	if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&JT_LTORJ != 0 {
  59139 		return 0
  59140 	}
  59141 	if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&JT_LEFT != 0 {
  59142 		if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0)) {
  59143 			return 0
  59144 		}
  59145 		if *(*int32)(unsafe.Pointer(pExpr + 36)) != (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor {
  59146 			return 0
  59147 		}
  59148 	} else {
  59149 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) {
  59150 			return 0
  59151 		}
  59152 	}
  59153 	return Xsqlite3ExprIsTableConstant(tls, pExpr, (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor)
  59154 }
  59155 
  59156 func exprNodeIsConstantOrGroupBy(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  59157 	var pGroupBy uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  59158 	var i int32
  59159 
  59160 	for i = 0; i < (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr; i++ {
  59161 		var p uintptr = (*ExprList_item)(unsafe.Pointer(pGroupBy + 8 + uintptr(i)*20)).FpExpr
  59162 		if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, p, -1) < 2 {
  59163 			var pColl uintptr = Xsqlite3ExprNNCollSeq(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p)
  59164 			if Xsqlite3IsBinary(tls, pColl) != 0 {
  59165 				return WRC_Prune
  59166 			}
  59167 		}
  59168 	}
  59169 
  59170 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  59171 		(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  59172 		return WRC_Abort
  59173 	}
  59174 
  59175 	return exprNodeIsConstant(tls, pWalker, pExpr)
  59176 }
  59177 
  59178 // Walk the expression tree passed as the first argument. Return non-zero
  59179 // if the expression consists entirely of constants or copies of terms
  59180 // in pGroupBy that sort with the BINARY collation sequence.
  59181 //
  59182 // This routine is used to determine if a term of the HAVING clause can
  59183 // be promoted into the WHERE clause.  In order for such a promotion to work,
  59184 // the value of the HAVING clause term must be the same for all members of
  59185 // a "group".  The requirement that the GROUP BY term must be BINARY
  59186 // assumes that no other collating sequence will have a finer-grained
  59187 // grouping than binary.  In other words (A=B COLLATE binary) implies
  59188 // A=B in every other collating sequence.  The requirement that the
  59189 // GROUP BY be BINARY is stricter than necessary.  It would also work
  59190 // to promote HAVING clauses that use the same alternative collating
  59191 // sequence as the GROUP BY term, but that is much harder to check,
  59192 // alternative collating sequences are uncommon, and this is only an
  59193 // optimization, so we take the easy way out and simply require the
  59194 // GROUP BY to use the BINARY collating sequence.
  59195 func Xsqlite3ExprIsConstantOrGroupBy(tls *libc.TLS, pParse uintptr, p uintptr, pGroupBy uintptr) int32 {
  59196 	bp := tls.Alloc(28)
  59197 	defer tls.Free(28)
  59198 
  59199 	(*Walker)(unsafe.Pointer(bp)).FeCode = U16(1)
  59200 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  59201 		f func(*libc.TLS, uintptr, uintptr) int32
  59202 	}{exprNodeIsConstantOrGroupBy}))
  59203 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = uintptr(0)
  59204 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pGroupBy
  59205 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  59206 	Xsqlite3WalkExpr(tls, bp, p)
  59207 	return int32((*Walker)(unsafe.Pointer(bp)).FeCode)
  59208 }
  59209 
  59210 // Walk an expression tree for the DEFAULT field of a column definition
  59211 // in a CREATE TABLE statement.  Return non-zero if the expression is
  59212 // acceptable for use as a DEFAULT.  That is to say, return non-zero if
  59213 // the expression is constant or a function call with constant arguments.
  59214 // Return and 0 if there are any variables.
  59215 //
  59216 // isInit is true when parsing from sqlite_schema.  isInit is false when
  59217 // processing a new CREATE TABLE statement.  When isInit is true, parameters
  59218 // (such as ? or $abc) in the expression are converted into NULL.  When
  59219 // isInit is false, parameters raise an error.  Parameters should not be
  59220 // allowed in a CREATE TABLE statement, but some legacy versions of SQLite
  59221 // allowed it, so we need to support it when reading sqlite_schema for
  59222 // backwards compatibility.
  59223 //
  59224 // If isInit is true, set EP_FromDDL on every TK_FUNCTION node.
  59225 //
  59226 // For the purposes of this function, a double-quoted string (ex: "abc")
  59227 // is considered a variable but a single-quoted string (ex: 'abc') is
  59228 // a constant.
  59229 func Xsqlite3ExprIsConstantOrFunction(tls *libc.TLS, p uintptr, isInit U8) int32 {
  59230 	return exprIsConst(tls, p, 4+int32(isInit), 0)
  59231 }
  59232 
  59233 // If the expression p codes a constant integer that is small enough
  59234 // to fit in a 32-bit integer, return 1 and put the value of the integer
  59235 // in *pValue.  If the expression is not an integer or if it is too big
  59236 // to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.
  59237 func Xsqlite3ExprIsInteger(tls *libc.TLS, p uintptr, pValue uintptr) int32 {
  59238 	bp := tls.Alloc(4)
  59239 	defer tls.Free(4)
  59240 
  59241 	var rc int32 = 0
  59242 	if p == uintptr(0) {
  59243 		return 0
  59244 	}
  59245 
  59246 	if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_IntValue) != 0 {
  59247 		*(*int32)(unsafe.Pointer(pValue)) = *(*int32)(unsafe.Pointer(p + 8))
  59248 		return 1
  59249 	}
  59250 	switch int32((*Expr)(unsafe.Pointer(p)).Fop) {
  59251 	case TK_UPLUS:
  59252 		{
  59253 			rc = Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, pValue)
  59254 			break
  59255 
  59256 		}
  59257 	case TK_UMINUS:
  59258 		{
  59259 			*(*int32)(unsafe.Pointer(bp)) = 0
  59260 			if Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, bp) != 0 {
  59261 				*(*int32)(unsafe.Pointer(pValue)) = -*(*int32)(unsafe.Pointer(bp))
  59262 				rc = 1
  59263 			}
  59264 			break
  59265 
  59266 		}
  59267 	default:
  59268 		break
  59269 	}
  59270 	return rc
  59271 }
  59272 
  59273 // Return FALSE if there is no chance that the expression can be NULL.
  59274 //
  59275 // If the expression might be NULL or if the expression is too complex
  59276 // to tell return TRUE.
  59277 //
  59278 // This routine is used as an optimization, to skip OP_IsNull opcodes
  59279 // when we know that a value cannot be NULL.  Hence, a false positive
  59280 // (returning TRUE when in fact the expression can never be NULL) might
  59281 // be a small performance hit but is otherwise harmless.  On the other
  59282 // hand, a false negative (returning FALSE when the result could be NULL)
  59283 // will likely result in an incorrect answer.  So when in doubt, return
  59284 // TRUE.
  59285 func Xsqlite3ExprCanBeNull(tls *libc.TLS, p uintptr) int32 {
  59286 	var op U8
  59287 
  59288 	for int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UPLUS || int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS {
  59289 		p = (*Expr)(unsafe.Pointer(p)).FpLeft
  59290 
  59291 	}
  59292 	op = (*Expr)(unsafe.Pointer(p)).Fop
  59293 	if int32(op) == TK_REGISTER {
  59294 		op = (*Expr)(unsafe.Pointer(p)).Fop2
  59295 	}
  59296 	switch int32(op) {
  59297 	case TK_INTEGER:
  59298 		fallthrough
  59299 	case TK_STRING:
  59300 		fallthrough
  59301 	case TK_FLOAT:
  59302 		fallthrough
  59303 	case TK_BLOB:
  59304 		return 0
  59305 	case TK_COLUMN:
  59306 		return libc.Bool32((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_CanBeNull) != U32(0) || *(*uintptr)(unsafe.Pointer(p + 44)) == uintptr(0) || int32((*Expr)(unsafe.Pointer(p)).FiColumn) >= 0 &&
  59307 			(*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FaCol != uintptr(0) &&
  59308 			int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FaCol + uintptr((*Expr)(unsafe.Pointer(p)).FiColumn)*16 + 4))&0xf>>0) == 0)
  59309 	default:
  59310 		return 1
  59311 	}
  59312 	return int32(0)
  59313 }
  59314 
  59315 // Return TRUE if the given expression is a constant which would be
  59316 // unchanged by OP_Affinity with the affinity given in the second
  59317 // argument.
  59318 //
  59319 // This routine is used to determine if the OP_Affinity operation
  59320 // can be omitted.  When in doubt return FALSE.  A false negative
  59321 // is harmless.  A false positive, however, can result in the wrong
  59322 // answer.
  59323 func Xsqlite3ExprNeedsNoAffinityChange(tls *libc.TLS, p uintptr, aff uint8) int32 {
  59324 	var op U8
  59325 	var unaryMinus int32 = 0
  59326 	if int32(aff) == SQLITE_AFF_BLOB {
  59327 		return 1
  59328 	}
  59329 	for int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UPLUS || int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS {
  59330 		if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS {
  59331 			unaryMinus = 1
  59332 		}
  59333 		p = (*Expr)(unsafe.Pointer(p)).FpLeft
  59334 	}
  59335 	op = (*Expr)(unsafe.Pointer(p)).Fop
  59336 	if int32(op) == TK_REGISTER {
  59337 		op = (*Expr)(unsafe.Pointer(p)).Fop2
  59338 	}
  59339 	switch int32(op) {
  59340 	case TK_INTEGER:
  59341 		{
  59342 			return libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC)
  59343 
  59344 		}
  59345 	case TK_FLOAT:
  59346 		{
  59347 			return libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC)
  59348 
  59349 		}
  59350 	case TK_STRING:
  59351 		{
  59352 			return libc.Bool32(!(unaryMinus != 0) && int32(aff) == SQLITE_AFF_TEXT)
  59353 
  59354 		}
  59355 	case TK_BLOB:
  59356 		{
  59357 			return libc.BoolInt32(!(unaryMinus != 0))
  59358 
  59359 		}
  59360 	case TK_COLUMN:
  59361 		{
  59362 			return libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC && int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0)
  59363 
  59364 		}
  59365 	default:
  59366 		{
  59367 			return 0
  59368 
  59369 		}
  59370 	}
  59371 	return int32(0)
  59372 }
  59373 
  59374 // Return TRUE if the given string is a row-id column name.
  59375 func Xsqlite3IsRowid(tls *libc.TLS, z uintptr) int32 {
  59376 	if Xsqlite3StrICmp(tls, z, ts+7705) == 0 {
  59377 		return 1
  59378 	}
  59379 	if Xsqlite3StrICmp(tls, z, ts+7713) == 0 {
  59380 		return 1
  59381 	}
  59382 	if Xsqlite3StrICmp(tls, z, ts+7719) == 0 {
  59383 		return 1
  59384 	}
  59385 	return 0
  59386 }
  59387 
  59388 func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr {
  59389 	var p uintptr
  59390 	var pSrc uintptr
  59391 	var pEList uintptr
  59392 	var pTab uintptr
  59393 	var i int32
  59394 	if !((*Expr)(unsafe.Pointer(pX)).Fflags&U32(EP_xIsSelect) != U32(0)) {
  59395 		return uintptr(0)
  59396 	}
  59397 	if (*Expr)(unsafe.Pointer(pX)).Fflags&U32(EP_VarSelect) != U32(0) {
  59398 		return uintptr(0)
  59399 	}
  59400 	p = *(*uintptr)(unsafe.Pointer(pX + 20))
  59401 	if (*Select)(unsafe.Pointer(p)).FpPrior != 0 {
  59402 		return uintptr(0)
  59403 	}
  59404 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct|SF_Aggregate) != 0 {
  59405 		return uintptr(0)
  59406 	}
  59407 
  59408 	if (*Select)(unsafe.Pointer(p)).FpLimit != 0 {
  59409 		return uintptr(0)
  59410 	}
  59411 	if (*Select)(unsafe.Pointer(p)).FpWhere != 0 {
  59412 		return uintptr(0)
  59413 	}
  59414 	pSrc = (*Select)(unsafe.Pointer(p)).FpSrc
  59415 
  59416 	if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1 {
  59417 		return uintptr(0)
  59418 	}
  59419 	if (*SrcItem)(unsafe.Pointer(pSrc+8)).FpSelect != 0 {
  59420 		return uintptr(0)
  59421 	}
  59422 	pTab = (*SrcItem)(unsafe.Pointer(pSrc + 8)).FpTab
  59423 
  59424 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  59425 		return uintptr(0)
  59426 	}
  59427 	pEList = (*Select)(unsafe.Pointer(p)).FpEList
  59428 
  59429 	for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  59430 		var pRes uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FpExpr
  59431 		if int32((*Expr)(unsafe.Pointer(pRes)).Fop) != TK_COLUMN {
  59432 			return uintptr(0)
  59433 		}
  59434 
  59435 	}
  59436 	return p
  59437 }
  59438 
  59439 func sqlite3SetHasNullFlag(tls *libc.TLS, v uintptr, iCur int32, regHasNull int32) {
  59440 	var addr1 int32
  59441 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regHasNull)
  59442 	addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iCur)
  59443 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, 0, regHasNull)
  59444 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_TYPEOFARG))
  59445 
  59446 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  59447 }
  59448 
  59449 func sqlite3InRhsIsConstant(tls *libc.TLS, pIn uintptr) int32 {
  59450 	var pLHS uintptr
  59451 	var res int32
  59452 
  59453 	pLHS = (*Expr)(unsafe.Pointer(pIn)).FpLeft
  59454 	(*Expr)(unsafe.Pointer(pIn)).FpLeft = uintptr(0)
  59455 	res = Xsqlite3ExprIsConstant(tls, pIn)
  59456 	(*Expr)(unsafe.Pointer(pIn)).FpLeft = pLHS
  59457 	return res
  59458 }
  59459 
  59460 // This function is used by the implementation of the IN (...) operator.
  59461 // The pX parameter is the expression on the RHS of the IN operator, which
  59462 // might be either a list of expressions or a subquery.
  59463 //
  59464 // The job of this routine is to find or create a b-tree object that can
  59465 // be used either to test for membership in the RHS set or to iterate through
  59466 // all members of the RHS set, skipping duplicates.
  59467 //
  59468 // A cursor is opened on the b-tree object that is the RHS of the IN operator
  59469 // and the *piTab parameter is set to the index of that cursor.
  59470 //
  59471 // The returned value of this function indicates the b-tree type, as follows:
  59472 //
  59473 //	IN_INDEX_ROWID      - The cursor was opened on a database table.
  59474 //	IN_INDEX_INDEX_ASC  - The cursor was opened on an ascending index.
  59475 //	IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.
  59476 //	IN_INDEX_EPH        - The cursor was opened on a specially created and
  59477 //	                      populated epheremal table.
  59478 //	IN_INDEX_NOOP       - No cursor was allocated.  The IN operator must be
  59479 //	                      implemented as a sequence of comparisons.
  59480 //
  59481 // An existing b-tree might be used if the RHS expression pX is a simple
  59482 // subquery such as:
  59483 //
  59484 //	SELECT <column1>, <column2>... FROM <table>
  59485 //
  59486 // If the RHS of the IN operator is a list or a more complex subquery, then
  59487 // an ephemeral table might need to be generated from the RHS and then
  59488 // pX->iTable made to point to the ephemeral table instead of an
  59489 // existing table.  In this case, the creation and initialization of the
  59490 // ephmeral table might be put inside of a subroutine, the EP_Subrtn flag
  59491 // will be set on pX and the pX->y.sub fields will be set to show where
  59492 // the subroutine is coded.
  59493 //
  59494 // The inFlags parameter must contain, at a minimum, one of the bits
  59495 // IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP but not both.  If inFlags contains
  59496 // IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast
  59497 // membership test.  When the IN_INDEX_LOOP bit is set, the IN index will
  59498 // be used to loop over all values of the RHS of the IN operator.
  59499 //
  59500 // When IN_INDEX_LOOP is used (and the b-tree will be used to iterate
  59501 // through the set members) then the b-tree must not contain duplicates.
  59502 // An epheremal table will be created unless the selected columns are guaranteed
  59503 // to be unique - either because it is an INTEGER PRIMARY KEY or due to
  59504 // a UNIQUE constraint or index.
  59505 //
  59506 // When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used
  59507 // for fast set membership tests) then an epheremal table must
  59508 // be used unless <columns> is a single INTEGER PRIMARY KEY column or an
  59509 // index can be found with the specified <columns> as its left-most.
  59510 //
  59511 // If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and
  59512 // if the RHS of the IN operator is a list (not a subquery) then this
  59513 // routine might decide that creating an ephemeral b-tree for membership
  59514 // testing is too expensive and return IN_INDEX_NOOP.  In that case, the
  59515 // calling routine should implement the IN operator using a sequence
  59516 // of Eq or Ne comparison operations.
  59517 //
  59518 // When the b-tree is being used for membership tests, the calling function
  59519 // might need to know whether or not the RHS side of the IN operator
  59520 // contains a NULL.  If prRhsHasNull is not a NULL pointer and
  59521 // if there is any chance that the (...) might contain a NULL value at
  59522 // runtime, then a register is allocated and the register number written
  59523 // to *prRhsHasNull. If there is no chance that the (...) contains a
  59524 // NULL value, then *prRhsHasNull is left unchanged.
  59525 //
  59526 // If a register is allocated and its location stored in *prRhsHasNull, then
  59527 // the value in that register will be NULL if the b-tree contains one or more
  59528 // NULL values, and it will be some non-NULL value if the b-tree contains no
  59529 // NULL values.
  59530 //
  59531 // If the aiMap parameter is not NULL, it must point to an array containing
  59532 // one element for each column returned by the SELECT statement on the RHS
  59533 // of the IN(...) operator. The i'th entry of the array is populated with the
  59534 // offset of the index column that matches the i'th column returned by the
  59535 // SELECT. For example, if the expression and selected index are:
  59536 //
  59537 //	(?,?,?) IN (SELECT a, b, c FROM t1)
  59538 //	CREATE INDEX i1 ON t1(b, c, a);
  59539 //
  59540 // then aiMap[] is populated with {2, 0, 1}.
  59541 func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, prRhsHasNull uintptr, aiMap uintptr, piTab uintptr) int32 {
  59542 	bp := tls.Alloc(16)
  59543 	defer tls.Free(16)
  59544 
  59545 	var p uintptr
  59546 	var eType int32 = 0
  59547 	var iTab int32
  59548 	var mustBeUnique int32
  59549 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  59550 
  59551 	mustBeUnique = libc.Bool32(inFlags&U32(IN_INDEX_LOOP) != U32(0))
  59552 	iTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  59553 
  59554 	if prRhsHasNull != 0 && (*Expr)(unsafe.Pointer(pX)).Fflags&U32(EP_xIsSelect) != U32(0) {
  59555 		var i int32
  59556 		var pEList uintptr = (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 20)))).FpEList
  59557 		for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  59558 			if Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FpExpr) != 0 {
  59559 				break
  59560 			}
  59561 		}
  59562 		if i == (*ExprList)(unsafe.Pointer(pEList)).FnExpr {
  59563 			prRhsHasNull = uintptr(0)
  59564 		}
  59565 	}
  59566 
  59567 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 && libc.AssignUintptr(&p, isCandidateForInOpt(tls, pX)) != uintptr(0) {
  59568 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  59569 		var pTab uintptr
  59570 		var iDb int32
  59571 		var pEList uintptr = (*Select)(unsafe.Pointer(p)).FpEList
  59572 		var nExpr int32 = (*ExprList)(unsafe.Pointer(pEList)).FnExpr
  59573 
  59574 		pTab = (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpTab
  59575 
  59576 		iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  59577 
  59578 		Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  59579 		Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab)).FzName)
  59580 
  59581 		if nExpr == 1 && int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pEList+8)).FpExpr)).FiColumn) < 0 {
  59582 			var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  59583 
  59584 			Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, OP_OpenRead)
  59585 			eType = IN_INDEX_ROWID
  59586 			Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+7723, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  59587 			Xsqlite3VdbeJumpHere(tls, v, iAddr)
  59588 		} else {
  59589 			var pIdx uintptr
  59590 			var affinity_ok int32 = 1
  59591 			var i int32
  59592 
  59593 			for i = 0; i < nExpr && affinity_ok != 0; i++ {
  59594 				var pLhs uintptr = Xsqlite3VectorFieldSubexpr(tls, (*Expr)(unsafe.Pointer(pX)).FpLeft, i)
  59595 				var iCol int32 = int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FpExpr)).FiColumn)
  59596 				var idxaff uint8 = Xsqlite3TableColumnAffinity(tls, pTab, iCol)
  59597 				var cmpaff uint8 = Xsqlite3CompareAffinity(tls, pLhs, idxaff)
  59598 
  59599 				switch int32(cmpaff) {
  59600 				case SQLITE_AFF_BLOB:
  59601 					break
  59602 					fallthrough
  59603 				case SQLITE_AFF_TEXT:
  59604 					break
  59605 					fallthrough
  59606 				default:
  59607 					affinity_ok = libc.Bool32(int32(idxaff) >= SQLITE_AFF_NUMERIC)
  59608 				}
  59609 			}
  59610 
  59611 			if affinity_ok != 0 {
  59612 				for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0 && eType == 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  59613 					var colUsed Bitmask
  59614 					var mCol Bitmask
  59615 					if int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) < nExpr {
  59616 						continue
  59617 					}
  59618 					if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) {
  59619 						continue
  59620 					}
  59621 
  59622 					if int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1 {
  59623 						continue
  59624 					}
  59625 					if mustBeUnique != 0 {
  59626 						if int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) > nExpr ||
  59627 							int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) > nExpr && !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None) {
  59628 							continue
  59629 						}
  59630 					}
  59631 
  59632 					colUsed = uint64(0)
  59633 					for i = 0; i < nExpr; i++ {
  59634 						var pLhs uintptr = Xsqlite3VectorFieldSubexpr(tls, (*Expr)(unsafe.Pointer(pX)).FpLeft, i)
  59635 						var pRhs uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FpExpr
  59636 						var pReq uintptr = Xsqlite3BinaryCompareCollSeq(tls, pParse, pLhs, pRhs)
  59637 						var j int32
  59638 
  59639 						for j = 0; j < nExpr; j++ {
  59640 							if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) != int32((*Expr)(unsafe.Pointer(pRhs)).FiColumn) {
  59641 								continue
  59642 							}
  59643 
  59644 							if pReq != uintptr(0) && Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pReq)).FzName, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*4))) != 0 {
  59645 								continue
  59646 							}
  59647 							break
  59648 						}
  59649 						if j == nExpr {
  59650 							break
  59651 						}
  59652 						mCol = uint64(1) << j
  59653 						if mCol&colUsed != 0 {
  59654 							break
  59655 						}
  59656 						colUsed = colUsed | mCol
  59657 						if aiMap != 0 {
  59658 							*(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4)) = j
  59659 						}
  59660 					}
  59661 
  59662 					if colUsed == uint64(1)<<nExpr-uint64(1) {
  59663 						var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  59664 						Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+7770, libc.VaList(bp+8, (*Index)(unsafe.Pointer(pIdx)).FzName))
  59665 						Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iTab, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb)
  59666 						Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx)
  59667 
  59668 						eType = IN_INDEX_INDEX_ASC + int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder)))
  59669 
  59670 						if prRhsHasNull != 0 {
  59671 							*(*int32)(unsafe.Pointer(prRhsHasNull)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  59672 							if nExpr == 1 {
  59673 								sqlite3SetHasNullFlag(tls, v, iTab, *(*int32)(unsafe.Pointer(prRhsHasNull)))
  59674 							}
  59675 						}
  59676 						Xsqlite3VdbeJumpHere(tls, v, iAddr)
  59677 					}
  59678 				}
  59679 			}
  59680 		}
  59681 	}
  59682 
  59683 	if eType == 0 &&
  59684 		inFlags&U32(IN_INDEX_NOOP_OK) != 0 &&
  59685 		(*Expr)(unsafe.Pointer(pX)).Fflags&U32(EP_xIsSelect) == U32(0) &&
  59686 		(!(sqlite3InRhsIsConstant(tls, pX) != 0) || (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 20)))).FnExpr <= 2) {
  59687 		(*Parse)(unsafe.Pointer(pParse)).FnTab--
  59688 		iTab = -1
  59689 		eType = IN_INDEX_NOOP
  59690 	}
  59691 
  59692 	if eType == 0 {
  59693 		var savedNQueryLoop U32 = (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop
  59694 		var rMayHaveNull int32 = 0
  59695 		eType = IN_INDEX_EPH
  59696 		if inFlags&U32(IN_INDEX_LOOP) != 0 {
  59697 			(*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = U32(0)
  59698 		} else if prRhsHasNull != 0 {
  59699 			*(*int32)(unsafe.Pointer(prRhsHasNull)) = libc.AssignInt32(&rMayHaveNull, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  59700 		}
  59701 
  59702 		Xsqlite3CodeRhsOfIN(tls, pParse, pX, iTab)
  59703 		if rMayHaveNull != 0 {
  59704 			sqlite3SetHasNullFlag(tls, v, iTab, rMayHaveNull)
  59705 		}
  59706 		(*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = savedNQueryLoop
  59707 	}
  59708 
  59709 	if aiMap != 0 && eType != IN_INDEX_INDEX_ASC && eType != IN_INDEX_INDEX_DESC {
  59710 		var i int32
  59711 		var n int32
  59712 		n = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pX)).FpLeft)
  59713 		for i = 0; i < n; i++ {
  59714 			*(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4)) = i
  59715 		}
  59716 	}
  59717 	*(*int32)(unsafe.Pointer(piTab)) = iTab
  59718 	return eType
  59719 }
  59720 
  59721 func exprINAffinity(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr {
  59722 	var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  59723 	var nVal int32 = Xsqlite3ExprVectorSize(tls, pLeft)
  59724 	var pSelect uintptr
  59725 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  59726 		pSelect = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  59727 	} else {
  59728 		pSelect = uintptr(0)
  59729 	}
  59730 	var zRet uintptr
  59731 
  59732 	zRet = Xsqlite3DbMallocRaw(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(nVal+1))
  59733 	if zRet != 0 {
  59734 		var i int32
  59735 		for i = 0; i < nVal; i++ {
  59736 			var pA uintptr = Xsqlite3VectorFieldSubexpr(tls, pLeft, i)
  59737 			var a uint8 = Xsqlite3ExprAffinity(tls, pA)
  59738 			if pSelect != 0 {
  59739 				*(*uint8)(unsafe.Pointer(zRet + uintptr(i))) = Xsqlite3CompareAffinity(tls, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpEList+8+uintptr(i)*20)).FpExpr, a)
  59740 			} else {
  59741 				*(*uint8)(unsafe.Pointer(zRet + uintptr(i))) = a
  59742 			}
  59743 		}
  59744 		*(*uint8)(unsafe.Pointer(zRet + uintptr(nVal))) = uint8(0)
  59745 	}
  59746 	return zRet
  59747 }
  59748 
  59749 // Load the Parse object passed as the first argument with an error
  59750 // message of the form:
  59751 //
  59752 //	"sub-select returns N columns - expected M"
  59753 func Xsqlite3SubselectError(tls *libc.TLS, pParse uintptr, nActual int32, nExpect int32) {
  59754 	bp := tls.Alloc(16)
  59755 	defer tls.Free(16)
  59756 
  59757 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  59758 		var zFmt uintptr = ts + 7801
  59759 		Xsqlite3ErrorMsg(tls, pParse, zFmt, libc.VaList(bp, nActual, nExpect))
  59760 	}
  59761 }
  59762 
  59763 // Expression pExpr is a vector that has been used in a context where
  59764 // it is not permitted. If pExpr is a sub-select vector, this routine
  59765 // loads the Parse object with a message of the form:
  59766 //
  59767 //	"sub-select returns N columns - expected 1"
  59768 //
  59769 // Or, if it is a regular scalar vector:
  59770 //
  59771 //	"row value misused"
  59772 func Xsqlite3VectorErrorMsg(tls *libc.TLS, pParse uintptr, pExpr uintptr) {
  59773 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  59774 		Xsqlite3SubselectError(tls, pParse, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpEList)).FnExpr, 1)
  59775 	} else {
  59776 		Xsqlite3ErrorMsg(tls, pParse, ts+6533, 0)
  59777 	}
  59778 }
  59779 
  59780 // Generate code that will construct an ephemeral table containing all terms
  59781 // in the RHS of an IN operator.  The IN operator can be in either of two
  59782 // forms:
  59783 //
  59784 //	x IN (4,5,11)              -- IN operator with list on right-hand side
  59785 //	x IN (SELECT a FROM b)     -- IN operator with subquery on the right
  59786 //
  59787 // The pExpr parameter is the IN operator.  The cursor number for the
  59788 // constructed ephermeral table is returned.  The first time the ephemeral
  59789 // table is computed, the cursor number is also stored in pExpr->iTable,
  59790 // however the cursor number returned might not be the same, as it might
  59791 // have been duplicated using OP_OpenDup.
  59792 //
  59793 // If the LHS expression ("x" in the examples) is a column value, or
  59794 // the SELECT statement returns a column value, then the affinity of that
  59795 // column is used to build the index keys. If both 'x' and the
  59796 // SELECT... statement are columns, then numeric affinity is used
  59797 // if either column has NUMERIC or INTEGER affinity. If neither
  59798 // 'x' nor the SELECT... statement are columns, then numeric affinity
  59799 // is used.
  59800 func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int32) {
  59801 	bp := tls.Alloc(53)
  59802 	defer tls.Free(53)
  59803 
  59804 	var addrOnce int32 = 0
  59805 	var addr int32
  59806 	var pLeft uintptr
  59807 	var pKeyInfo uintptr = uintptr(0)
  59808 	var nVal int32
  59809 	var v uintptr
  59810 
  59811 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  59812 
  59813 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_VarSelect) != U32(0)) && (*Parse)(unsafe.Pointer(pParse)).FiSelfTab == 0 {
  59814 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Subrtn) != U32(0) {
  59815 			addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  59816 			if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  59817 				Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+7845, libc.VaList(bp, (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FselId))
  59818 			}
  59819 
  59820 			Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, *(*int32)(unsafe.Pointer(pExpr + 44 + 4)),
  59821 				*(*int32)(unsafe.Pointer(pExpr + 44)))
  59822 
  59823 			Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, iTab, (*Expr)(unsafe.Pointer(pExpr)).FiTable)
  59824 			Xsqlite3VdbeJumpHere(tls, v, addrOnce)
  59825 			return
  59826 		}
  59827 
  59828 		*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_Subrtn)
  59829 
  59830 		*(*int32)(unsafe.Pointer(pExpr + 44 + 4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  59831 		*(*int32)(unsafe.Pointer(pExpr + 44)) = Xsqlite3VdbeAddOp2(tls, v, OP_BeginSubrtn, 0, *(*int32)(unsafe.Pointer(pExpr + 44 + 4))) + 1
  59832 
  59833 		addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  59834 	}
  59835 
  59836 	pLeft = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  59837 	nVal = Xsqlite3ExprVectorSize(tls, pLeft)
  59838 
  59839 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = iTab
  59840 	addr = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Expr)(unsafe.Pointer(pExpr)).FiTable, nVal)
  59841 	pKeyInfo = Xsqlite3KeyInfoAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, nVal, 1)
  59842 
  59843 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  59844 		var pSelect uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  59845 		var pEList uintptr = (*Select)(unsafe.Pointer(pSelect)).FpEList
  59846 
  59847 		Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+7868, libc.VaList(bp+8, func() uintptr {
  59848 			if addrOnce != 0 {
  59849 				return ts + 1554
  59850 			}
  59851 			return ts + 7887
  59852 		}(), (*Select)(unsafe.Pointer(pSelect)).FselId))
  59853 
  59854 		if (*ExprList)(unsafe.Pointer(pEList)).FnExpr == nVal {
  59855 			var pCopy uintptr
  59856 
  59857 			var i int32
  59858 			var rc int32
  59859 			Xsqlite3SelectDestInit(tls, bp+24, SRT_Set, iTab)
  59860 			(*SelectDest)(unsafe.Pointer(bp + 24)).FzAffSdst = exprINAffinity(tls, pParse, pExpr)
  59861 			(*Select)(unsafe.Pointer(pSelect)).FiLimit = 0
  59862 
  59863 			pCopy = Xsqlite3SelectDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0)
  59864 			if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  59865 				rc = 1
  59866 			} else {
  59867 				rc = Xsqlite3Select(tls, pParse, pCopy, bp+24)
  59868 			}
  59869 			Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pCopy)
  59870 			Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*SelectDest)(unsafe.Pointer(bp+24)).FzAffSdst)
  59871 			if rc != 0 {
  59872 				Xsqlite3KeyInfoUnref(tls, pKeyInfo)
  59873 				return
  59874 			}
  59875 
  59876 			for i = 0; i < nVal; i++ {
  59877 				var p uintptr = Xsqlite3VectorFieldSubexpr(tls, pLeft, i)
  59878 				*(*uintptr)(unsafe.Pointer(pKeyInfo + 20 + uintptr(i)*4)) = Xsqlite3BinaryCompareCollSeq(tls,
  59879 					pParse, p, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FpExpr)
  59880 			}
  59881 		}
  59882 	} else if *(*uintptr)(unsafe.Pointer(pExpr + 20)) != uintptr(0) {
  59883 		var i int32
  59884 		var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  59885 		var pItem uintptr
  59886 		var r1 int32
  59887 		var r2 int32
  59888 		*(*uint8)(unsafe.Pointer(bp + 52)) = Xsqlite3ExprAffinity(tls, pLeft)
  59889 		if int32(*(*uint8)(unsafe.Pointer(bp + 52))) <= SQLITE_AFF_NONE {
  59890 			*(*uint8)(unsafe.Pointer(bp + 52)) = uint8(SQLITE_AFF_BLOB)
  59891 		} else if int32(*(*uint8)(unsafe.Pointer(bp + 52))) == SQLITE_AFF_REAL {
  59892 			*(*uint8)(unsafe.Pointer(bp + 52)) = uint8(SQLITE_AFF_NUMERIC)
  59893 		}
  59894 		if pKeyInfo != 0 {
  59895 			*(*uintptr)(unsafe.Pointer(pKeyInfo + 20)) = Xsqlite3ExprCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  59896 		}
  59897 
  59898 		r1 = Xsqlite3GetTempReg(tls, pParse)
  59899 		r2 = Xsqlite3GetTempReg(tls, pParse)
  59900 		i = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  59901 		pItem = pList + 8
  59902 	__1:
  59903 		if !(i > 0) {
  59904 			goto __3
  59905 		}
  59906 		{
  59907 			var pE2 uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr
  59908 
  59909 			if addrOnce != 0 && !(Xsqlite3ExprIsConstant(tls, pE2) != 0) {
  59910 				Xsqlite3VdbeChangeToNoop(tls, v, addrOnce-1)
  59911 				Xsqlite3VdbeChangeToNoop(tls, v, addrOnce)
  59912 				*(*U32)(unsafe.Pointer(pExpr + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Subrtn))
  59913 				addrOnce = 0
  59914 			}
  59915 
  59916 			Xsqlite3ExprCode(tls, pParse, pE2, r1)
  59917 			Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, r1, 1, r2, bp+52, 1)
  59918 			Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iTab, r2, r1, 1)
  59919 
  59920 		}
  59921 		goto __2
  59922 	__2:
  59923 		i--
  59924 		pItem += 20
  59925 		goto __1
  59926 		goto __3
  59927 	__3:
  59928 		;
  59929 		Xsqlite3ReleaseTempReg(tls, pParse, r1)
  59930 		Xsqlite3ReleaseTempReg(tls, pParse, r2)
  59931 	}
  59932 	if pKeyInfo != 0 {
  59933 		Xsqlite3VdbeChangeP4(tls, v, addr, pKeyInfo, -8)
  59934 	}
  59935 	if addrOnce != 0 {
  59936 		Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, iTab)
  59937 		Xsqlite3VdbeJumpHere(tls, v, addrOnce)
  59938 
  59939 		Xsqlite3VdbeAddOp3(tls, v, OP_Return, *(*int32)(unsafe.Pointer(pExpr + 44 + 4)),
  59940 			*(*int32)(unsafe.Pointer(pExpr + 44)), 1)
  59941 
  59942 		Xsqlite3ClearTempRegCache(tls, pParse)
  59943 	}
  59944 }
  59945 
  59946 // Generate code for scalar subqueries used as a subquery expression
  59947 // or EXISTS operator:
  59948 //
  59949 //	(SELECT a FROM b)          -- subquery
  59950 //	EXISTS (SELECT a FROM b)   -- EXISTS subquery
  59951 //
  59952 // The pExpr parameter is the SELECT or EXISTS operator to be coded.
  59953 //
  59954 // Return the register that holds the result.  For a multi-column SELECT,
  59955 // the result is stored in a contiguous array of registers and the
  59956 // return value is the register of the left-most result column.
  59957 // Return 0 if an error occurs.
  59958 func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 {
  59959 	bp := tls.Alloc(52)
  59960 	defer tls.Free(52)
  59961 
  59962 	var addrOnce int32 = 0
  59963 	var rReg int32 = 0
  59964 	var pSel uintptr
  59965 
  59966 	var nReg int32
  59967 	var pLimit uintptr
  59968 
  59969 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  59970 
  59971 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  59972 		return 0
  59973 	}
  59974 
  59975 	pSel = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  59976 
  59977 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Subrtn) != U32(0) {
  59978 		Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+7899, libc.VaList(bp, (*Select)(unsafe.Pointer(pSel)).FselId))
  59979 
  59980 		Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, *(*int32)(unsafe.Pointer(pExpr + 44 + 4)),
  59981 			*(*int32)(unsafe.Pointer(pExpr + 44)))
  59982 		return (*Expr)(unsafe.Pointer(pExpr)).FiTable
  59983 	}
  59984 
  59985 	*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_Subrtn)
  59986 	*(*int32)(unsafe.Pointer(pExpr + 44 + 4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  59987 	*(*int32)(unsafe.Pointer(pExpr + 44)) = Xsqlite3VdbeAddOp2(tls, v, OP_BeginSubrtn, 0, *(*int32)(unsafe.Pointer(pExpr + 44 + 4))) + 1
  59988 
  59989 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_VarSelect) != U32(0)) {
  59990 		addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  59991 	}
  59992 
  59993 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+7917, libc.VaList(bp+8, func() uintptr {
  59994 		if addrOnce != 0 {
  59995 			return ts + 1554
  59996 		}
  59997 		return ts + 7887
  59998 	}(), (*Select)(unsafe.Pointer(pSel)).FselId))
  59999 
  60000 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT {
  60001 		nReg = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpEList)).FnExpr
  60002 	} else {
  60003 		nReg = 1
  60004 	}
  60005 	Xsqlite3SelectDestInit(tls, bp+24, 0, (*Parse)(unsafe.Pointer(pParse)).FnMem+1)
  60006 	*(*int32)(unsafe.Pointer(pParse + 44)) += nReg
  60007 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT {
  60008 		(*SelectDest)(unsafe.Pointer(bp + 24)).FeDest = U8(SRT_Mem)
  60009 		(*SelectDest)(unsafe.Pointer(bp + 24)).FiSdst = (*SelectDest)(unsafe.Pointer(bp + 24)).FiSDParm
  60010 		(*SelectDest)(unsafe.Pointer(bp + 24)).FnSdst = nReg
  60011 		Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*SelectDest)(unsafe.Pointer(bp+24)).FiSDParm, (*SelectDest)(unsafe.Pointer(bp+24)).FiSDParm+nReg-1)
  60012 
  60013 	} else {
  60014 		(*SelectDest)(unsafe.Pointer(bp + 24)).FeDest = U8(SRT_Exists)
  60015 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*SelectDest)(unsafe.Pointer(bp+24)).FiSDParm)
  60016 
  60017 	}
  60018 	if (*Select)(unsafe.Pointer(pSel)).FpLimit != 0 {
  60019 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  60020 		pLimit = Xsqlite3Expr(tls, db, TK_INTEGER, ts+7519)
  60021 		if pLimit != 0 {
  60022 			(*Expr)(unsafe.Pointer(pLimit)).FaffExpr = uint8(SQLITE_AFF_NUMERIC)
  60023 			pLimit = Xsqlite3PExpr(tls, pParse, TK_NE,
  60024 				Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft, 0), pLimit)
  60025 		}
  60026 		Xsqlite3ExprDeferredDelete(tls, pParse, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft)
  60027 		(*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft = pLimit
  60028 	} else {
  60029 		pLimit = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, ts+7938)
  60030 		(*Select)(unsafe.Pointer(pSel)).FpLimit = Xsqlite3PExpr(tls, pParse, TK_LIMIT, pLimit, uintptr(0))
  60031 	}
  60032 	(*Select)(unsafe.Pointer(pSel)).FiLimit = 0
  60033 	if Xsqlite3Select(tls, pParse, pSel, bp+24) != 0 {
  60034 		(*Expr)(unsafe.Pointer(pExpr)).Fop2 = (*Expr)(unsafe.Pointer(pExpr)).Fop
  60035 		(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_ERROR)
  60036 		return 0
  60037 	}
  60038 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = libc.AssignInt32(&rReg, (*SelectDest)(unsafe.Pointer(bp+24)).FiSDParm)
  60039 
  60040 	if addrOnce != 0 {
  60041 		Xsqlite3VdbeJumpHere(tls, v, addrOnce)
  60042 	}
  60043 
  60044 	Xsqlite3VdbeAddOp3(tls, v, OP_Return, *(*int32)(unsafe.Pointer(pExpr + 44 + 4)),
  60045 		*(*int32)(unsafe.Pointer(pExpr + 44)), 1)
  60046 
  60047 	Xsqlite3ClearTempRegCache(tls, pParse)
  60048 	return rReg
  60049 }
  60050 
  60051 // Expr pIn is an IN(...) expression. This function checks that the
  60052 // sub-select on the RHS of the IN() operator has the same number of
  60053 // columns as the vector on the LHS. Or, if the RHS of the IN() is not
  60054 // a sub-query, that the LHS is a vector of size 1.
  60055 func Xsqlite3ExprCheckIN(tls *libc.TLS, pParse uintptr, pIn uintptr) int32 {
  60056 	var nVector int32 = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pIn)).FpLeft)
  60057 	if (*Expr)(unsafe.Pointer(pIn)).Fflags&U32(EP_xIsSelect) != U32(0) && !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) {
  60058 		if nVector != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 20)))).FpEList)).FnExpr {
  60059 			Xsqlite3SubselectError(tls, pParse, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 20)))).FpEList)).FnExpr, nVector)
  60060 			return 1
  60061 		}
  60062 	} else if nVector != 1 {
  60063 		Xsqlite3VectorErrorMsg(tls, pParse, (*Expr)(unsafe.Pointer(pIn)).FpLeft)
  60064 		return 1
  60065 	}
  60066 	return 0
  60067 }
  60068 
  60069 func sqlite3ExprCodeIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, destIfFalse int32, destIfNull int32) {
  60070 	bp := tls.Alloc(16)
  60071 	defer tls.Free(16)
  60072 
  60073 	var eType int32
  60074 	var rLhs int32
  60075 	var rLhsOrig int32
  60076 	var v uintptr
  60077 	var aiMap uintptr
  60078 	var zAff uintptr
  60079 	var nVector int32
  60080 
  60081 	var pLeft uintptr
  60082 	var i int32
  60083 	var destStep2 int32
  60084 	var destStep6 int32
  60085 	var addrTruthOp int32
  60086 	var destNotNull int32
  60087 	var addrTop int32
  60088 
  60089 	var okConstFactor U8
  60090 	var op int32
  60091 	var op1 int32
  60092 	var pList uintptr
  60093 	var pColl uintptr
  60094 	var labelOk int32
  60095 	var r2 int32
  60096 
  60097 	var regCkNull int32
  60098 	var ii int32
  60099 	var p uintptr
  60100 	var p1 uintptr
  60101 	var pColl1 uintptr
  60102 	var r3 int32
  60103 	*(*int32)(unsafe.Pointer(bp)) = 0
  60104 	aiMap = uintptr(0)
  60105 	zAff = uintptr(0)
  60106 	destStep6 = 0
  60107 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
  60108 	okConstFactor = (*Parse)(unsafe.Pointer(pParse)).FokConstFactor
  60109 
  60110 	pLeft = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  60111 	if !(Xsqlite3ExprCheckIN(tls, pParse, pExpr) != 0) {
  60112 		goto __1
  60113 	}
  60114 	return
  60115 __1:
  60116 	;
  60117 	zAff = exprINAffinity(tls, pParse, pExpr)
  60118 	nVector = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  60119 	aiMap = Xsqlite3DbMallocZero(tls,
  60120 		(*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(nVector)*(uint32(unsafe.Sizeof(int32(0)))+uint32(unsafe.Sizeof(uint8(0))))+uint32(1)))
  60121 	if !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) {
  60122 		goto __2
  60123 	}
  60124 	goto sqlite3ExprCodeIN_oom_error
  60125 __2:
  60126 	;
  60127 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  60128 
  60129 	eType = Xsqlite3FindInIndex(tls, pParse, pExpr,
  60130 		uint32(IN_INDEX_MEMBERSHIP|IN_INDEX_NOOP_OK),
  60131 		func() uintptr {
  60132 			if destIfFalse == destIfNull {
  60133 				return uintptr(0)
  60134 			}
  60135 			return bp
  60136 		}(),
  60137 		aiMap, bp+4)
  60138 
  60139 	(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(0)
  60140 	rLhsOrig = exprCodeVector(tls, pParse, pLeft, bp+8)
  60141 	(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = okConstFactor
  60142 	i = 0
  60143 __3:
  60144 	if !(i < nVector && *(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4)) == i) {
  60145 		goto __5
  60146 	}
  60147 	goto __4
  60148 __4:
  60149 	i++
  60150 	goto __3
  60151 	goto __5
  60152 __5:
  60153 	;
  60154 	if !(i == nVector) {
  60155 		goto __6
  60156 	}
  60157 
  60158 	rLhs = rLhsOrig
  60159 	goto __7
  60160 __6:
  60161 	rLhs = Xsqlite3GetTempRange(tls, pParse, nVector)
  60162 	i = 0
  60163 __8:
  60164 	if !(i < nVector) {
  60165 		goto __10
  60166 	}
  60167 	Xsqlite3VdbeAddOp3(tls, v, OP_Copy, rLhsOrig+i, rLhs+*(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4)), 0)
  60168 	goto __9
  60169 __9:
  60170 	i++
  60171 	goto __8
  60172 	goto __10
  60173 __10:
  60174 	;
  60175 __7:
  60176 	;
  60177 	if !(eType == IN_INDEX_NOOP) {
  60178 		goto __11
  60179 	}
  60180 	labelOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  60181 	regCkNull = 0
  60182 
  60183 	pList = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  60184 	pColl = Xsqlite3ExprCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  60185 	if !(destIfNull != destIfFalse) {
  60186 		goto __12
  60187 	}
  60188 	regCkNull = Xsqlite3GetTempReg(tls, pParse)
  60189 	Xsqlite3VdbeAddOp3(tls, v, OP_BitAnd, rLhs, rLhs, regCkNull)
  60190 __12:
  60191 	;
  60192 	ii = 0
  60193 __13:
  60194 	if !(ii < (*ExprList)(unsafe.Pointer(pList)).FnExpr) {
  60195 		goto __15
  60196 	}
  60197 	r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ii)*20)).FpExpr, bp+12)
  60198 	if !(regCkNull != 0 && Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ii)*20)).FpExpr) != 0) {
  60199 		goto __16
  60200 	}
  60201 	Xsqlite3VdbeAddOp3(tls, v, OP_BitAnd, regCkNull, r2, regCkNull)
  60202 __16:
  60203 	;
  60204 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 12)))
  60205 	if !(ii < (*ExprList)(unsafe.Pointer(pList)).FnExpr-1 || destIfNull != destIfFalse) {
  60206 		goto __17
  60207 	}
  60208 	if rLhs != r2 {
  60209 		op = OP_Eq
  60210 	} else {
  60211 		op = OP_NotNull
  60212 	}
  60213 	Xsqlite3VdbeAddOp4(tls, v, op, rLhs, labelOk, r2,
  60214 		pColl, -2)
  60215 
  60216 	Xsqlite3VdbeChangeP5(tls, v, uint16(*(*uint8)(unsafe.Pointer(zAff))))
  60217 	goto __18
  60218 __17:
  60219 	if rLhs != r2 {
  60220 		op1 = OP_Ne
  60221 	} else {
  60222 		op1 = OP_IsNull
  60223 	}
  60224 
  60225 	Xsqlite3VdbeAddOp4(tls, v, op1, rLhs, destIfFalse, r2,
  60226 		pColl, -2)
  60227 
  60228 	Xsqlite3VdbeChangeP5(tls, v, uint16(int32(*(*uint8)(unsafe.Pointer(zAff)))|SQLITE_JUMPIFNULL))
  60229 __18:
  60230 	;
  60231 	goto __14
  60232 __14:
  60233 	ii++
  60234 	goto __13
  60235 	goto __15
  60236 __15:
  60237 	;
  60238 	if !(regCkNull != 0) {
  60239 		goto __19
  60240 	}
  60241 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regCkNull, destIfNull)
  60242 	Xsqlite3VdbeGoto(tls, v, destIfFalse)
  60243 __19:
  60244 	;
  60245 	Xsqlite3VdbeResolveLabel(tls, v, labelOk)
  60246 	Xsqlite3ReleaseTempReg(tls, pParse, regCkNull)
  60247 	goto sqlite3ExprCodeIN_finished
  60248 __11:
  60249 	;
  60250 	if !(destIfNull == destIfFalse) {
  60251 		goto __20
  60252 	}
  60253 	destStep2 = destIfFalse
  60254 	goto __21
  60255 __20:
  60256 	destStep2 = libc.AssignInt32(&destStep6, Xsqlite3VdbeMakeLabel(tls, pParse))
  60257 __21:
  60258 	;
  60259 	i = 0
  60260 __22:
  60261 	if !(i < nVector) {
  60262 		goto __24
  60263 	}
  60264 	p = Xsqlite3VectorFieldSubexpr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, i)
  60265 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  60266 		goto __25
  60267 	}
  60268 	goto sqlite3ExprCodeIN_oom_error
  60269 __25:
  60270 	;
  60271 	if !(Xsqlite3ExprCanBeNull(tls, p) != 0) {
  60272 		goto __26
  60273 	}
  60274 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, rLhs+i, destStep2)
  60275 
  60276 __26:
  60277 	;
  60278 	goto __23
  60279 __23:
  60280 	i++
  60281 	goto __22
  60282 	goto __24
  60283 __24:
  60284 	;
  60285 	if !(eType == IN_INDEX_ROWID) {
  60286 		goto __27
  60287 	}
  60288 
  60289 	Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, *(*int32)(unsafe.Pointer(bp + 4)), destIfFalse, rLhs)
  60290 
  60291 	addrTruthOp = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  60292 	goto __28
  60293 __27:
  60294 	Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, rLhs, nVector, 0, zAff, nVector)
  60295 	if !(destIfFalse == destIfNull) {
  60296 		goto __29
  60297 	}
  60298 
  60299 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, *(*int32)(unsafe.Pointer(bp + 4)), destIfFalse,
  60300 		rLhs, nVector)
  60301 	goto sqlite3ExprCodeIN_finished
  60302 __29:
  60303 	;
  60304 	addrTruthOp = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, *(*int32)(unsafe.Pointer(bp + 4)), 0,
  60305 		rLhs, nVector)
  60306 __28:
  60307 	;
  60308 	if !(*(*int32)(unsafe.Pointer(bp)) != 0 && nVector == 1) {
  60309 		goto __30
  60310 	}
  60311 	Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, *(*int32)(unsafe.Pointer(bp)), destIfFalse)
  60312 
  60313 __30:
  60314 	;
  60315 	if !(destIfFalse == destIfNull) {
  60316 		goto __31
  60317 	}
  60318 	Xsqlite3VdbeGoto(tls, v, destIfFalse)
  60319 __31:
  60320 	;
  60321 	if !(destStep6 != 0) {
  60322 		goto __32
  60323 	}
  60324 	Xsqlite3VdbeResolveLabel(tls, v, destStep6)
  60325 __32:
  60326 	;
  60327 	addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, *(*int32)(unsafe.Pointer(bp + 4)), destIfFalse)
  60328 
  60329 	if !(nVector > 1) {
  60330 		goto __33
  60331 	}
  60332 	destNotNull = Xsqlite3VdbeMakeLabel(tls, pParse)
  60333 	goto __34
  60334 __33:
  60335 	destNotNull = destIfFalse
  60336 __34:
  60337 	;
  60338 	i = 0
  60339 __35:
  60340 	if !(i < nVector) {
  60341 		goto __37
  60342 	}
  60343 	r3 = Xsqlite3GetTempReg(tls, pParse)
  60344 	p1 = Xsqlite3VectorFieldSubexpr(tls, pLeft, i)
  60345 	pColl1 = Xsqlite3ExprCollSeq(tls, pParse, p1)
  60346 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 4)), i, r3)
  60347 	Xsqlite3VdbeAddOp4(tls, v, OP_Ne, rLhs+i, destNotNull, r3,
  60348 		pColl1, -2)
  60349 
  60350 	Xsqlite3ReleaseTempReg(tls, pParse, r3)
  60351 	goto __36
  60352 __36:
  60353 	i++
  60354 	goto __35
  60355 	goto __37
  60356 __37:
  60357 	;
  60358 	Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, destIfNull)
  60359 	if !(nVector > 1) {
  60360 		goto __38
  60361 	}
  60362 	Xsqlite3VdbeResolveLabel(tls, v, destNotNull)
  60363 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 4)), addrTop+1)
  60364 
  60365 	Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, destIfFalse)
  60366 __38:
  60367 	;
  60368 	Xsqlite3VdbeJumpHere(tls, v, addrTruthOp)
  60369 
  60370 sqlite3ExprCodeIN_finished:
  60371 	if !(rLhs != rLhsOrig) {
  60372 		goto __39
  60373 	}
  60374 	Xsqlite3ReleaseTempReg(tls, pParse, rLhs)
  60375 __39:
  60376 	;
  60377 sqlite3ExprCodeIN_oom_error:
  60378 	Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, aiMap)
  60379 	Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zAff)
  60380 }
  60381 
  60382 func codeReal(tls *libc.TLS, v uintptr, z uintptr, negateFlag int32, iMem int32) {
  60383 	bp := tls.Alloc(8)
  60384 	defer tls.Free(8)
  60385 
  60386 	if z != uintptr(0) {
  60387 		Xsqlite3AtoF(tls, z, bp, Xsqlite3Strlen30(tls, z), uint8(SQLITE_UTF8))
  60388 
  60389 		if negateFlag != 0 {
  60390 			*(*float64)(unsafe.Pointer(bp)) = -*(*float64)(unsafe.Pointer(bp))
  60391 		}
  60392 		Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Real, 0, iMem, 0, bp, -12)
  60393 	}
  60394 }
  60395 
  60396 func codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iMem int32) {
  60397 	bp := tls.Alloc(24)
  60398 	defer tls.Free(24)
  60399 
  60400 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  60401 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_IntValue) != 0 {
  60402 		var i int32 = *(*int32)(unsafe.Pointer(pExpr + 8))
  60403 
  60404 		if negFlag != 0 {
  60405 			i = -i
  60406 		}
  60407 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, i, iMem)
  60408 	} else {
  60409 		var c int32
  60410 
  60411 		var z uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 8))
  60412 
  60413 		c = Xsqlite3DecOrHexToI64(tls, z, bp+16)
  60414 		if c == 3 && !(negFlag != 0) || c == 2 || negFlag != 0 && *(*I64)(unsafe.Pointer(bp + 16)) == int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32) {
  60415 			if Xsqlite3_strnicmp(tls, z, ts+7940, 2) == 0 {
  60416 				Xsqlite3ErrorMsg(tls, pParse, ts+7943,
  60417 					libc.VaList(bp, func() uintptr {
  60418 						if negFlag != 0 {
  60419 							return ts + 4932
  60420 						}
  60421 						return ts + 1554
  60422 					}(), pExpr))
  60423 			} else {
  60424 				codeReal(tls, v, z, negFlag, iMem)
  60425 			}
  60426 		} else {
  60427 			if negFlag != 0 {
  60428 				if c == 3 {
  60429 					*(*I64)(unsafe.Pointer(bp + 16)) = int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
  60430 				} else {
  60431 					*(*I64)(unsafe.Pointer(bp + 16)) = -*(*I64)(unsafe.Pointer(bp + 16))
  60432 				}
  60433 			}
  60434 			Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Int64, 0, iMem, 0, bp+16, -13)
  60435 		}
  60436 	}
  60437 }
  60438 
  60439 // Generate code that will load into register regOut a value that is
  60440 // appropriate for the iIdxCol-th column of index pIdx.
  60441 func Xsqlite3ExprCodeLoadIndexColumn(tls *libc.TLS, pParse uintptr, pIdx uintptr, iTabCur int32, iIdxCol int32, regOut int32) {
  60442 	var iTabCol I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iIdxCol)*2))
  60443 	if int32(iTabCol) == -2 {
  60444 		(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = iTabCur + 1
  60445 		Xsqlite3ExprCodeCopy(tls, pParse, (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8+uintptr(iIdxCol)*20)).FpExpr, regOut)
  60446 		(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  60447 	} else {
  60448 		Xsqlite3ExprCodeGetColumnOfTable(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, (*Index)(unsafe.Pointer(pIdx)).FpTable, iTabCur,
  60449 			int32(iTabCol), regOut)
  60450 	}
  60451 }
  60452 
  60453 // Generate code that will compute the value of generated column pCol
  60454 // and store the result in register regOut
  60455 func Xsqlite3ExprCodeGeneratedColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, pCol uintptr, regOut int32) {
  60456 	var iAddr int32
  60457 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  60458 	var nErr int32 = (*Parse)(unsafe.Pointer(pParse)).FnErr
  60459 
  60460 	if (*Parse)(unsafe.Pointer(pParse)).FiSelfTab > 0 {
  60461 		iAddr = Xsqlite3VdbeAddOp3(tls, v, OP_IfNullRow, (*Parse)(unsafe.Pointer(pParse)).FiSelfTab-1, 0, regOut)
  60462 	} else {
  60463 		iAddr = 0
  60464 	}
  60465 	Xsqlite3ExprCodeCopy(tls, pParse, Xsqlite3ColumnExpr(tls, pTab, pCol), regOut)
  60466 	if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= SQLITE_AFF_TEXT {
  60467 		Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, regOut, 1, 0, pCol+6, 1)
  60468 	}
  60469 	if iAddr != 0 {
  60470 		Xsqlite3VdbeJumpHere(tls, v, iAddr)
  60471 	}
  60472 	if (*Parse)(unsafe.Pointer(pParse)).FnErr > nErr {
  60473 		(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FerrByteOffset = -1
  60474 	}
  60475 }
  60476 
  60477 // Generate code to extract the value of the iCol-th column of a table.
  60478 func Xsqlite3ExprCodeGetColumnOfTable(tls *libc.TLS, v uintptr, pTab uintptr, iTabCur int32, iCol int32, regOut int32) {
  60479 	bp := tls.Alloc(8)
  60480 	defer tls.Free(8)
  60481 
  60482 	var pCol uintptr
  60483 
  60484 	if iCol < 0 || iCol == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  60485 		Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iTabCur, regOut)
  60486 
  60487 	} else {
  60488 		var op int32
  60489 		var x int32
  60490 		if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  60491 			op = OP_VColumn
  60492 			x = iCol
  60493 		} else if int32((*Column)(unsafe.Pointer(libc.AssignUintptr(&pCol, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16))).FcolFlags)&COLFLAG_VIRTUAL != 0 {
  60494 			var pParse uintptr = Xsqlite3VdbeParser(tls, v)
  60495 			if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_BUSY != 0 {
  60496 				Xsqlite3ErrorMsg(tls, pParse, ts+7970,
  60497 					libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzCnName))
  60498 			} else {
  60499 				var savedSelfTab int32 = (*Parse)(unsafe.Pointer(pParse)).FiSelfTab
  60500 				*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_BUSY)
  60501 				(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = iTabCur + 1
  60502 				Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, regOut)
  60503 				(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = savedSelfTab
  60504 				*(*U16)(unsafe.Pointer(pCol + 12)) &= libc.Uint16FromInt32(libc.CplInt32(COLFLAG_BUSY))
  60505 			}
  60506 			return
  60507 		} else if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  60508 			x = int32(Xsqlite3TableColumnToIndex(tls, Xsqlite3PrimaryKeyIndex(tls, pTab), int16(iCol)))
  60509 			op = OP_Column
  60510 		} else {
  60511 			x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol)))
  60512 
  60513 			op = OP_Column
  60514 		}
  60515 		Xsqlite3VdbeAddOp3(tls, v, op, iTabCur, x, regOut)
  60516 		Xsqlite3ColumnDefault(tls, v, pTab, iCol, regOut)
  60517 	}
  60518 }
  60519 
  60520 // Generate code that will extract the iColumn-th column from
  60521 // table pTab and store the column value in register iReg.
  60522 //
  60523 // There must be an open cursor to pTab in iTable when this routine
  60524 // is called.  If iColumn<0 then code is generated that extracts the rowid.
  60525 func Xsqlite3ExprCodeGetColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, iColumn int32, iTable int32, iReg int32, p5 U8) int32 {
  60526 	Xsqlite3ExprCodeGetColumnOfTable(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iTable, iColumn, iReg)
  60527 	if p5 != 0 {
  60528 		var pOp uintptr = Xsqlite3VdbeGetLastOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe)
  60529 		if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column {
  60530 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp5 = U16(p5)
  60531 		}
  60532 	}
  60533 	return iReg
  60534 }
  60535 
  60536 // Generate code to move content from registers iFrom...iFrom+nReg-1
  60537 // over to iTo..iTo+nReg-1.
  60538 func Xsqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, nReg int32) {
  60539 	Xsqlite3VdbeAddOp3(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Move, iFrom, iTo, nReg)
  60540 }
  60541 
  60542 func exprToRegister(tls *libc.TLS, pExpr uintptr, iReg int32) {
  60543 	var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr)
  60544 	if p == uintptr(0) {
  60545 		return
  60546 	}
  60547 	(*Expr)(unsafe.Pointer(p)).Fop2 = (*Expr)(unsafe.Pointer(p)).Fop
  60548 	(*Expr)(unsafe.Pointer(p)).Fop = U8(TK_REGISTER)
  60549 	(*Expr)(unsafe.Pointer(p)).FiTable = iReg
  60550 	*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Skip))
  60551 }
  60552 
  60553 func exprCodeVector(tls *libc.TLS, pParse uintptr, p uintptr, piFreeable uintptr) int32 {
  60554 	var iResult int32
  60555 	var nResult int32 = Xsqlite3ExprVectorSize(tls, p)
  60556 	if nResult == 1 {
  60557 		iResult = Xsqlite3ExprCodeTemp(tls, pParse, p, piFreeable)
  60558 	} else {
  60559 		*(*int32)(unsafe.Pointer(piFreeable)) = 0
  60560 		if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_SELECT {
  60561 			iResult = Xsqlite3CodeSubselect(tls, pParse, p)
  60562 		} else {
  60563 			var i int32
  60564 			iResult = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  60565 			*(*int32)(unsafe.Pointer(pParse + 44)) += nResult
  60566 
  60567 			for i = 0; i < nResult; i++ {
  60568 				Xsqlite3ExprCodeFactorable(tls, pParse, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20))+8+uintptr(i)*20)).FpExpr, i+iResult)
  60569 			}
  60570 		}
  60571 	}
  60572 	return iResult
  60573 }
  60574 
  60575 func setDoNotMergeFlagOnCopy(tls *libc.TLS, v uintptr) {
  60576 	if int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetLastOp(tls, v))).Fopcode) == OP_Copy {
  60577 		Xsqlite3VdbeChangeP5(tls, v, uint16(1))
  60578 	}
  60579 }
  60580 
  60581 func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncId int32, target int32) int32 {
  60582 	bp := tls.Alloc(76)
  60583 	defer tls.Free(76)
  60584 
  60585 	var nFarg int32
  60586 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  60587 
  60588 	nFarg = (*ExprList)(unsafe.Pointer(pFarg)).FnExpr
  60589 
  60590 	switch iFuncId {
  60591 	case INLINEFUNC_coalesce:
  60592 		{
  60593 			var endCoalesce int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
  60594 			var i int32
  60595 
  60596 			Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr, target)
  60597 			for i = 1; i < nFarg; i++ {
  60598 				Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, target, endCoalesce)
  60599 
  60600 				Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pFarg+8+uintptr(i)*20)).FpExpr, target)
  60601 			}
  60602 			setDoNotMergeFlagOnCopy(tls, v)
  60603 			Xsqlite3VdbeResolveLabel(tls, v, endCoalesce)
  60604 			break
  60605 
  60606 		}
  60607 	case INLINEFUNC_iif:
  60608 		{
  60609 			libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Expr{})))
  60610 			(*Expr)(unsafe.Pointer(bp)).Fop = U8(TK_CASE)
  60611 			*(*uintptr)(unsafe.Pointer(bp + 20)) = pFarg
  60612 			return Xsqlite3ExprCodeTarget(tls, pParse, bp, target)
  60613 
  60614 		}
  60615 	case INLINEFUNC_sqlite_offset:
  60616 		{
  60617 			var pArg uintptr = (*ExprList_item)(unsafe.Pointer(pFarg + 8)).FpExpr
  60618 			if int32((*Expr)(unsafe.Pointer(pArg)).Fop) == TK_COLUMN && (*Expr)(unsafe.Pointer(pArg)).FiTable >= 0 {
  60619 				Xsqlite3VdbeAddOp3(tls, v, OP_Offset, (*Expr)(unsafe.Pointer(pArg)).FiTable, int32((*Expr)(unsafe.Pointer(pArg)).FiColumn), target)
  60620 			} else {
  60621 				Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target)
  60622 			}
  60623 			break
  60624 
  60625 		}
  60626 	default:
  60627 		{
  60628 			target = Xsqlite3ExprCodeTarget(tls, pParse, (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr, target)
  60629 			break
  60630 
  60631 		}
  60632 
  60633 	case INLINEFUNC_expr_compare:
  60634 		{
  60635 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer,
  60636 				Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr, (*ExprList_item)(unsafe.Pointer(pFarg+8+1*20)).FpExpr, -1),
  60637 				target)
  60638 			break
  60639 
  60640 		}
  60641 
  60642 	case INLINEFUNC_expr_implies_expr:
  60643 		{
  60644 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer,
  60645 				Xsqlite3ExprImpliesExpr(tls, pParse, (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr, (*ExprList_item)(unsafe.Pointer(pFarg+8+1*20)).FpExpr, -1),
  60646 				target)
  60647 			break
  60648 
  60649 		}
  60650 
  60651 	case INLINEFUNC_implies_nonnull_row:
  60652 		{
  60653 			var pA1 uintptr
  60654 
  60655 			pA1 = (*ExprList_item)(unsafe.Pointer(pFarg + 8 + 1*20)).FpExpr
  60656 			if int32((*Expr)(unsafe.Pointer(pA1)).Fop) == TK_COLUMN {
  60657 				Xsqlite3VdbeAddOp2(tls, v, OP_Integer,
  60658 					Xsqlite3ExprImpliesNonNullRow(tls, (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr, (*Expr)(unsafe.Pointer(pA1)).FiTable),
  60659 					target)
  60660 			} else {
  60661 				Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target)
  60662 			}
  60663 			break
  60664 
  60665 		}
  60666 
  60667 	case INLINEFUNC_affinity:
  60668 		{
  60669 			*(*[6]uintptr)(unsafe.Pointer(bp + 52)) = [6]uintptr{ts + 8000, ts + 8005, ts + 8010, ts + 6191,
  60670 				ts + 6186, ts + 8018}
  60671 			var aff uint8
  60672 
  60673 			aff = Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr)
  60674 
  60675 			Xsqlite3VdbeLoadString(tls, v, target,
  60676 				func() uintptr {
  60677 					if int32(aff) <= SQLITE_AFF_NONE {
  60678 						return ts + 8026
  60679 					}
  60680 					return *(*uintptr)(unsafe.Pointer(bp + 52 + uintptr(int32(aff)-SQLITE_AFF_BLOB)*4))
  60681 				}())
  60682 			break
  60683 
  60684 		}
  60685 	}
  60686 	return target
  60687 }
  60688 
  60689 func sqlite3IndexedExprLookup(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) int32 {
  60690 	var p uintptr
  60691 	var v uintptr
  60692 	for p = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr; p != 0; p = (*IndexedExpr)(unsafe.Pointer(p)).FpIENext {
  60693 		var exprAff U8
  60694 		var iDataCur int32 = (*IndexedExpr)(unsafe.Pointer(p)).FiDataCur
  60695 		if iDataCur < 0 {
  60696 			continue
  60697 		}
  60698 		if (*Parse)(unsafe.Pointer(pParse)).FiSelfTab != 0 {
  60699 			if (*IndexedExpr)(unsafe.Pointer(p)).FiDataCur != (*Parse)(unsafe.Pointer(pParse)).FiSelfTab-1 {
  60700 				continue
  60701 			}
  60702 			iDataCur = -1
  60703 		}
  60704 		if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, (*IndexedExpr)(unsafe.Pointer(p)).FpExpr, iDataCur) != 0 {
  60705 			continue
  60706 		}
  60707 
  60708 		exprAff = Xsqlite3ExprAffinity(tls, pExpr)
  60709 		if int32(exprAff) <= SQLITE_AFF_BLOB && int32((*IndexedExpr)(unsafe.Pointer(p)).Faff) != SQLITE_AFF_BLOB ||
  60710 			int32(exprAff) == SQLITE_AFF_TEXT && int32((*IndexedExpr)(unsafe.Pointer(p)).Faff) != SQLITE_AFF_TEXT ||
  60711 			int32(exprAff) >= SQLITE_AFF_NUMERIC && int32((*IndexedExpr)(unsafe.Pointer(p)).Faff) != SQLITE_AFF_NUMERIC {
  60712 			continue
  60713 		}
  60714 
  60715 		v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  60716 
  60717 		if (*IndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow != 0 {
  60718 			var addr int32 = Xsqlite3VdbeCurrentAddr(tls, v)
  60719 			Xsqlite3VdbeAddOp3(tls, v, OP_IfNullRow, (*IndexedExpr)(unsafe.Pointer(p)).FiIdxCur, addr+3, target)
  60720 
  60721 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*IndexedExpr)(unsafe.Pointer(p)).FiIdxCur, (*IndexedExpr)(unsafe.Pointer(p)).FiIdxCol, target)
  60722 
  60723 			Xsqlite3VdbeGoto(tls, v, 0)
  60724 			p = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr
  60725 			(*Parse)(unsafe.Pointer(pParse)).FpIdxEpr = uintptr(0)
  60726 			Xsqlite3ExprCode(tls, pParse, pExpr, target)
  60727 			(*Parse)(unsafe.Pointer(pParse)).FpIdxEpr = p
  60728 			Xsqlite3VdbeJumpHere(tls, v, addr+2)
  60729 		} else {
  60730 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*IndexedExpr)(unsafe.Pointer(p)).FiIdxCur, (*IndexedExpr)(unsafe.Pointer(p)).FiIdxCol, target)
  60731 
  60732 		}
  60733 		return target
  60734 	}
  60735 	return -1
  60736 }
  60737 
  60738 // Generate code into the current Vdbe to evaluate the given
  60739 // expression.  Attempt to store the results in register "target".
  60740 // Return the register where results are stored.
  60741 //
  60742 // With this routine, there is no guarantee that results will
  60743 // be stored in target.  The result might be stored in some other
  60744 // register if it is convenient to do so.  The calling function
  60745 // must check the return code and move the results to the desired
  60746 // register.
  60747 func Xsqlite3ExprCodeTarget(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) int32 {
  60748 	bp := tls.Alloc(152)
  60749 	defer tls.Free(152)
  60750 
  60751 	var v uintptr
  60752 	var op int32
  60753 	var inReg int32
  60754 
  60755 	var r1 int32
  60756 	var r2 int32
  60757 
  60758 	var p5 int32
  60759 	var pTab uintptr
  60760 	var pAggInfo uintptr
  60761 	var pCol uintptr
  60762 
  60763 	var aff int32
  60764 
  60765 	var pCol1 uintptr
  60766 	var pTab1 uintptr
  60767 	var iSrc int32
  60768 	var iCol int32
  60769 	var iTab int32
  60770 	var iReg int32
  60771 	var n int32
  60772 	var z uintptr
  60773 	var zBlob uintptr
  60774 	var z1 uintptr
  60775 	var pLeft uintptr
  60776 	var pLeft1 uintptr
  60777 	var isTrue int32
  60778 	var bNormal int32
  60779 	var addr int32
  60780 	var pInfo uintptr
  60781 	var exprOp U8
  60782 	var pFarg uintptr
  60783 	var nFarg int32
  60784 	var pDef uintptr
  60785 	var zId uintptr
  60786 	var constMask U32
  60787 	var i int32
  60788 	var db uintptr
  60789 	var enc U8
  60790 	var pColl uintptr
  60791 	var nCol int32
  60792 	var n1 int32
  60793 	var pLeft2 uintptr
  60794 	var destIfFalse int32
  60795 	var destIfNull int32
  60796 
  60797 	var pTab2 uintptr
  60798 	var iCol1 int32
  60799 	var p1 int32
  60800 	var addrINR int32
  60801 	var okConstFactor U8
  60802 	var pAggInfo1 uintptr
  60803 	var endLabel int32
  60804 	var nextCase int32
  60805 	var nExpr int32
  60806 	var i1 int32
  60807 	var pEList uintptr
  60808 	var aListelem uintptr
  60809 
  60810 	var pX uintptr
  60811 	var pTest uintptr
  60812 	var pDel uintptr
  60813 	var db1 uintptr
  60814 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  60815 	inReg = target
  60816 	*(*int32)(unsafe.Pointer(bp + 40)) = 0
  60817 	*(*int32)(unsafe.Pointer(bp + 44)) = 0
  60818 	p5 = 0
  60819 
  60820 expr_code_doover:
  60821 	if !(pExpr == uintptr(0)) {
  60822 		goto __1
  60823 	}
  60824 	op = TK_NULL
  60825 	goto __2
  60826 __1:
  60827 	if !((*Parse)(unsafe.Pointer(pParse)).FpIdxEpr != uintptr(0) &&
  60828 		!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Leaf) != U32(0)) &&
  60829 		libc.AssignInt32(&r1, sqlite3IndexedExprLookup(tls, pParse, pExpr, target)) >= 0) {
  60830 		goto __3
  60831 	}
  60832 	return r1
  60833 	goto __4
  60834 __3:
  60835 	;
  60836 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
  60837 __4:
  60838 	;
  60839 __2:
  60840 	;
  60841 	switch op {
  60842 	case TK_AGG_COLUMN:
  60843 		goto __6
  60844 	case TK_COLUMN:
  60845 		goto __7
  60846 	case TK_INTEGER:
  60847 		goto __8
  60848 	case TK_TRUEFALSE:
  60849 		goto __9
  60850 	case TK_FLOAT:
  60851 		goto __10
  60852 	case TK_STRING:
  60853 		goto __11
  60854 	default:
  60855 		goto __12
  60856 	case TK_BLOB:
  60857 		goto __13
  60858 	case TK_VARIABLE:
  60859 		goto __14
  60860 	case TK_REGISTER:
  60861 		goto __15
  60862 	case TK_CAST:
  60863 		goto __16
  60864 	case TK_IS:
  60865 		goto __17
  60866 	case TK_ISNOT:
  60867 		goto __18
  60868 
  60869 	case TK_LT:
  60870 		goto __19
  60871 	case TK_LE:
  60872 		goto __20
  60873 	case TK_GT:
  60874 		goto __21
  60875 	case TK_GE:
  60876 		goto __22
  60877 	case TK_NE:
  60878 		goto __23
  60879 	case TK_EQ:
  60880 		goto __24
  60881 	case TK_AND:
  60882 		goto __25
  60883 	case TK_OR:
  60884 		goto __26
  60885 	case TK_PLUS:
  60886 		goto __27
  60887 	case TK_STAR:
  60888 		goto __28
  60889 	case TK_MINUS:
  60890 		goto __29
  60891 	case TK_REM:
  60892 		goto __30
  60893 	case TK_BITAND:
  60894 		goto __31
  60895 	case TK_BITOR:
  60896 		goto __32
  60897 	case TK_SLASH:
  60898 		goto __33
  60899 	case TK_LSHIFT:
  60900 		goto __34
  60901 	case TK_RSHIFT:
  60902 		goto __35
  60903 	case TK_CONCAT:
  60904 		goto __36
  60905 	case TK_UMINUS:
  60906 		goto __37
  60907 	case TK_BITNOT:
  60908 		goto __38
  60909 	case TK_NOT:
  60910 		goto __39
  60911 	case TK_TRUTH:
  60912 		goto __40
  60913 	case TK_ISNULL:
  60914 		goto __41
  60915 	case TK_NOTNULL:
  60916 		goto __42
  60917 	case TK_AGG_FUNCTION:
  60918 		goto __43
  60919 	case TK_FUNCTION:
  60920 		goto __44
  60921 	case TK_EXISTS:
  60922 		goto __45
  60923 	case TK_SELECT:
  60924 		goto __46
  60925 	case TK_SELECT_COLUMN:
  60926 		goto __47
  60927 	case TK_IN:
  60928 		goto __48
  60929 
  60930 	case TK_BETWEEN:
  60931 		goto __49
  60932 	case TK_COLLATE:
  60933 		goto __50
  60934 	case TK_SPAN:
  60935 		goto __51
  60936 	case TK_UPLUS:
  60937 		goto __52
  60938 
  60939 	case TK_TRIGGER:
  60940 		goto __53
  60941 
  60942 	case TK_VECTOR:
  60943 		goto __54
  60944 
  60945 	case TK_IF_NULL_ROW:
  60946 		goto __55
  60947 
  60948 	case TK_CASE:
  60949 		goto __56
  60950 	case TK_RAISE:
  60951 		goto __57
  60952 	}
  60953 	goto __5
  60954 __6:
  60955 	pAggInfo = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo
  60956 
  60957 	pCol = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiAgg)*16
  60958 	if !!(int32((*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode) != 0) {
  60959 		goto __58
  60960 	}
  60961 	return func() int32 {
  60962 		return (*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg)
  60963 	}()
  60964 	goto __59
  60965 __58:
  60966 	if !((*AggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx != 0) {
  60967 		goto __60
  60968 	}
  60969 	pTab = (*AggInfo_col)(unsafe.Pointer(pCol)).FpTab
  60970 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab,
  60971 		int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn), target)
  60972 	if !(pTab == uintptr(0)) {
  60973 		goto __62
  60974 	}
  60975 
  60976 	goto __63
  60977 __62:
  60978 	if !(int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn) < 0) {
  60979 		goto __64
  60980 	}
  60981 
  60982 	goto __65
  60983 __64:
  60984 	;
  60985 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*16)).Faffinity) == SQLITE_AFF_REAL) {
  60986 		goto __66
  60987 	}
  60988 	Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target)
  60989 __66:
  60990 	;
  60991 __65:
  60992 	;
  60993 __63:
  60994 	;
  60995 	return target
  60996 	goto __61
  60997 __60:
  60998 	if !(*(*uintptr)(unsafe.Pointer(pExpr + 44)) == uintptr(0)) {
  60999 		goto __67
  61000 	}
  61001 
  61002 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Expr)(unsafe.Pointer(pExpr)).FiTable, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), target)
  61003 	return target
  61004 __67:
  61005 	;
  61006 __61:
  61007 	;
  61008 __59:
  61009 	;
  61010 __7:
  61011 	iTab = (*Expr)(unsafe.Pointer(pExpr)).FiTable
  61012 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_FixedCol) != U32(0)) {
  61013 		goto __68
  61014 	}
  61015 	iReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, target)
  61016 
  61017 	aff = int32(Xsqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 44)), int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)))
  61018 	if !(aff > SQLITE_AFF_BLOB) {
  61019 		goto __69
  61020 	}
  61021 
  61022 	Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, iReg, 1, 0,
  61023 		uintptr(unsafe.Pointer(&zAff))+uintptr((aff-'B')*2), -1)
  61024 __69:
  61025 	;
  61026 	return iReg
  61027 __68:
  61028 	;
  61029 	if !(iTab < 0) {
  61030 		goto __70
  61031 	}
  61032 	if !((*Parse)(unsafe.Pointer(pParse)).FiSelfTab < 0) {
  61033 		goto __71
  61034 	}
  61035 	iCol = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  61036 
  61037 	pTab1 = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  61038 
  61039 	if !(iCol < 0) {
  61040 		goto __73
  61041 	}
  61042 	return -1 - (*Parse)(unsafe.Pointer(pParse)).FiSelfTab
  61043 __73:
  61044 	;
  61045 	pCol1 = (*Table)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*16
  61046 
  61047 	iSrc = int32(Xsqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*Parse)(unsafe.Pointer(pParse)).FiSelfTab
  61048 	if !(int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags)&COLFLAG_GENERATED != 0) {
  61049 		goto __74
  61050 	}
  61051 	if !(int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags)&COLFLAG_BUSY != 0) {
  61052 		goto __76
  61053 	}
  61054 	Xsqlite3ErrorMsg(tls, pParse, ts+7970,
  61055 		libc.VaList(bp, (*Column)(unsafe.Pointer(pCol1)).FzCnName))
  61056 	return 0
  61057 __76:
  61058 	;
  61059 	*(*U16)(unsafe.Pointer(pCol1 + 12)) |= U16(COLFLAG_BUSY)
  61060 	if !(int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags)&COLFLAG_NOTAVAIL != 0) {
  61061 		goto __77
  61062 	}
  61063 	Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pTab1, pCol1, iSrc)
  61064 __77:
  61065 	;
  61066 	*(*U16)(unsafe.Pointer(pCol1 + 12)) &= libc.Uint16FromInt32(libc.CplInt32(COLFLAG_BUSY | COLFLAG_NOTAVAIL))
  61067 	return iSrc
  61068 	goto __75
  61069 __74:
  61070 	if !(int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) == SQLITE_AFF_REAL) {
  61071 		goto __78
  61072 	}
  61073 	Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, iSrc, target)
  61074 	Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target)
  61075 	return target
  61076 	goto __79
  61077 __78:
  61078 	return iSrc
  61079 __79:
  61080 	;
  61081 __75:
  61082 	;
  61083 	goto __72
  61084 __71:
  61085 	iTab = (*Parse)(unsafe.Pointer(pParse)).FiSelfTab - 1
  61086 __72:
  61087 	;
  61088 __70:
  61089 	;
  61090 	iReg = Xsqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 44)),
  61091 		int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target,
  61092 		(*Expr)(unsafe.Pointer(pExpr)).Fop2)
  61093 	return iReg
  61094 
  61095 __8:
  61096 	codeInteger(tls, pParse, pExpr, 0, target)
  61097 	return target
  61098 
  61099 __9:
  61100 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, Xsqlite3ExprTruthValue(tls, pExpr), target)
  61101 	return target
  61102 
  61103 __10:
  61104 	;
  61105 	codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pExpr + 8)), 0, target)
  61106 	return target
  61107 
  61108 __11:
  61109 	;
  61110 	Xsqlite3VdbeLoadString(tls, v, target, *(*uintptr)(unsafe.Pointer(pExpr + 8)))
  61111 	return target
  61112 
  61113 __12:
  61114 	;
  61115 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target)
  61116 	return target
  61117 
  61118 __13:
  61119 	;
  61120 	z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + 2
  61121 	n = Xsqlite3Strlen30(tls, z) - 1
  61122 
  61123 	zBlob = Xsqlite3HexToBlob(tls, Xsqlite3VdbeDb(tls, v), z, n)
  61124 	Xsqlite3VdbeAddOp4(tls, v, OP_Blob, n/2, target, 0, zBlob, -6)
  61125 	return target
  61126 
  61127 __14:
  61128 	;
  61129 	Xsqlite3VdbeAddOp2(tls, v, OP_Variable, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), target)
  61130 	if !(int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8)) + 1))) != 0) {
  61131 		goto __80
  61132 	}
  61133 	z1 = Xsqlite3VListNumToName(tls, (*Parse)(unsafe.Pointer(pParse)).FpVList, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn))
  61134 
  61135 	*(*VList)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpVList)) = 0
  61136 	Xsqlite3VdbeAppendP4(tls, v, z1, -1)
  61137 __80:
  61138 	;
  61139 	return target
  61140 
  61141 __15:
  61142 	return (*Expr)(unsafe.Pointer(pExpr)).FiTable
  61143 
  61144 __16:
  61145 	inReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, target)
  61146 	if !(inReg != target) {
  61147 		goto __81
  61148 	}
  61149 	Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, inReg, target)
  61150 	inReg = target
  61151 __81:
  61152 	;
  61153 	Xsqlite3VdbeAddOp2(tls, v, OP_Cast, target,
  61154 		int32(Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0))))
  61155 	return inReg
  61156 
  61157 __17:
  61158 __18:
  61159 	if op == TK_IS {
  61160 		op = TK_EQ
  61161 	} else {
  61162 		op = TK_NE
  61163 	}
  61164 	p5 = SQLITE_NULLEQ
  61165 
  61166 __19:
  61167 __20:
  61168 __21:
  61169 __22:
  61170 __23:
  61171 __24:
  61172 	pLeft = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  61173 	if !(Xsqlite3ExprIsVector(tls, pLeft) != 0) {
  61174 		goto __82
  61175 	}
  61176 	codeVectorCompare(tls, pParse, pExpr, target, uint8(op), uint8(p5))
  61177 	goto __83
  61178 __82:
  61179 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, pLeft, bp+40)
  61180 	r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+44)
  61181 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, inReg)
  61182 	codeCompare(tls, pParse, pLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, r1, r2,
  61183 		Xsqlite3VdbeCurrentAddr(tls, v)+2, p5,
  61184 		libc.Bool32((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Commuted) != U32(0)))
  61185 
  61186 	if !(p5 == SQLITE_NULLEQ) {
  61187 		goto __84
  61188 	}
  61189 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, inReg)
  61190 	goto __85
  61191 __84:
  61192 	Xsqlite3VdbeAddOp3(tls, v, OP_ZeroOrNull, r1, inReg, r2)
  61193 __85:
  61194 	;
  61195 __83:
  61196 	;
  61197 	goto __5
  61198 
  61199 __25:
  61200 __26:
  61201 __27:
  61202 __28:
  61203 __29:
  61204 __30:
  61205 __31:
  61206 __32:
  61207 __33:
  61208 __34:
  61209 __35:
  61210 __36:
  61211 	;
  61212 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+40)
  61213 	r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+44)
  61214 	Xsqlite3VdbeAddOp3(tls, v, op, r2, r1, target)
  61215 
  61216 	goto __5
  61217 
  61218 __37:
  61219 	pLeft1 = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  61220 
  61221 	if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == TK_INTEGER) {
  61222 		goto __86
  61223 	}
  61224 	codeInteger(tls, pParse, pLeft1, 1, target)
  61225 	return target
  61226 	goto __87
  61227 __86:
  61228 	if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == TK_FLOAT) {
  61229 		goto __88
  61230 	}
  61231 
  61232 	codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pLeft1 + 8)), 1, target)
  61233 	return target
  61234 	goto __89
  61235 __88:
  61236 	(*Expr)(unsafe.Pointer(bp + 48)).Fop = U8(TK_INTEGER)
  61237 	(*Expr)(unsafe.Pointer(bp + 48)).Fflags = U32(EP_IntValue | EP_TokenOnly)
  61238 	*(*int32)(unsafe.Pointer(bp + 48 + 8)) = 0
  61239 
  61240 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, bp+48, bp+40)
  61241 	r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+44)
  61242 	Xsqlite3VdbeAddOp3(tls, v, OP_Subtract, r2, r1, target)
  61243 
  61244 __89:
  61245 	;
  61246 __87:
  61247 	;
  61248 	goto __5
  61249 
  61250 __38:
  61251 __39:
  61252 	;
  61253 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+40)
  61254 
  61255 	Xsqlite3VdbeAddOp2(tls, v, op, r1, inReg)
  61256 	goto __5
  61257 
  61258 __40:
  61259 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+40)
  61260 
  61261 	isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  61262 	bNormal = libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_IS)
  61263 
  61264 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IsTrue, r1, inReg, libc.BoolInt32(!(isTrue != 0)), isTrue^bNormal)
  61265 	goto __5
  61266 
  61267 __41:
  61268 __42:
  61269 	;
  61270 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, target)
  61271 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+40)
  61272 
  61273 	addr = Xsqlite3VdbeAddOp1(tls, v, op, r1)
  61274 
  61275 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, target)
  61276 	Xsqlite3VdbeJumpHere(tls, v, addr)
  61277 	goto __5
  61278 
  61279 __43:
  61280 	pInfo = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo
  61281 	if !(pInfo == uintptr(0) ||
  61282 		int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg) < 0 ||
  61283 		int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg) >= (*AggInfo)(unsafe.Pointer(pInfo)).FnFunc) {
  61284 		goto __90
  61285 	}
  61286 
  61287 	Xsqlite3ErrorMsg(tls, pParse, ts+8031, libc.VaList(bp+8, pExpr))
  61288 	goto __91
  61289 __90:
  61290 	return func() int32 {
  61291 		return (*AggInfo)(unsafe.Pointer(pInfo)).FiFirstReg + (*AggInfo)(unsafe.Pointer(pInfo)).FnColumn + int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg)
  61292 	}()
  61293 __91:
  61294 	;
  61295 	goto __5
  61296 
  61297 __44:
  61298 	constMask = U32(0)
  61299 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  61300 	enc = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  61301 	pColl = uintptr(0)
  61302 
  61303 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0)) {
  61304 		goto __92
  61305 	}
  61306 	return (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FregResult
  61307 __92:
  61308 	;
  61309 	if !((*Parse)(unsafe.Pointer(pParse)).FokConstFactor != 0 && Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0) {
  61310 		goto __93
  61311 	}
  61312 
  61313 	return Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -1)
  61314 __93:
  61315 	;
  61316 	pFarg = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  61317 	if pFarg != 0 {
  61318 		nFarg = (*ExprList)(unsafe.Pointer(pFarg)).FnExpr
  61319 	} else {
  61320 		nFarg = 0
  61321 	}
  61322 
  61323 	zId = *(*uintptr)(unsafe.Pointer(pExpr + 8))
  61324 	pDef = Xsqlite3FindFunction(tls, db, zId, nFarg, enc, uint8(0))
  61325 	if !(pDef == uintptr(0) || (*FuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0)) {
  61326 		goto __94
  61327 	}
  61328 	Xsqlite3ErrorMsg(tls, pParse, ts+8058, libc.VaList(bp+16, pExpr))
  61329 	goto __5
  61330 __94:
  61331 	;
  61332 	if !((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_INLINE) != 0) {
  61333 		goto __95
  61334 	}
  61335 
  61336 	return exprCodeInlineFunction(tls, pParse, pFarg,
  61337 		int32((*FuncDef)(unsafe.Pointer(pDef)).FpUserData), target)
  61338 	goto __96
  61339 __95:
  61340 	if !((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE) != 0) {
  61341 		goto __97
  61342 	}
  61343 	Xsqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef)
  61344 __97:
  61345 	;
  61346 __96:
  61347 	;
  61348 	i = 0
  61349 __98:
  61350 	if !(i < nFarg) {
  61351 		goto __100
  61352 	}
  61353 	if !(i < 32 && Xsqlite3ExprIsConstant(tls, (*ExprList_item)(unsafe.Pointer(pFarg+8+uintptr(i)*20)).FpExpr) != 0) {
  61354 		goto __101
  61355 	}
  61356 
  61357 	constMask = constMask | uint32(1)<<i
  61358 __101:
  61359 	;
  61360 	if !((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != U32(0) && !(pColl != 0)) {
  61361 		goto __102
  61362 	}
  61363 	pColl = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pFarg+8+uintptr(i)*20)).FpExpr)
  61364 __102:
  61365 	;
  61366 	goto __99
  61367 __99:
  61368 	i++
  61369 	goto __98
  61370 	goto __100
  61371 __100:
  61372 	;
  61373 	if !(pFarg != 0) {
  61374 		goto __103
  61375 	}
  61376 	if !(constMask != 0) {
  61377 		goto __105
  61378 	}
  61379 	r1 = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  61380 	*(*int32)(unsafe.Pointer(pParse + 44)) += nFarg
  61381 	goto __106
  61382 __105:
  61383 	r1 = Xsqlite3GetTempRange(tls, pParse, nFarg)
  61384 __106:
  61385 	;
  61386 	if !((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF) != U32(0)) {
  61387 		goto __107
  61388 	}
  61389 
  61390 	exprOp = (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pFarg + 8)).FpExpr)).Fop
  61391 	if !(int32(exprOp) == TK_COLUMN || int32(exprOp) == TK_AGG_COLUMN) {
  61392 		goto __108
  61393 	}
  61394 
  61395 	(*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pFarg + 8)).FpExpr)).Fop2 = U8((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))
  61396 __108:
  61397 	;
  61398 __107:
  61399 	;
  61400 	Xsqlite3ExprCodeExprList(tls, pParse, pFarg, r1, 0,
  61401 		uint8(SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR))
  61402 	goto __104
  61403 __103:
  61404 	r1 = 0
  61405 __104:
  61406 	;
  61407 	if !(nFarg >= 2 && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_InfixFunc) != U32(0)) {
  61408 		goto __109
  61409 	}
  61410 	pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer(pFarg+8+1*20)).FpExpr)
  61411 	goto __110
  61412 __109:
  61413 	if !(nFarg > 0) {
  61414 		goto __111
  61415 	}
  61416 	pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer(pFarg+8)).FpExpr)
  61417 __111:
  61418 	;
  61419 __110:
  61420 	;
  61421 	if !((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != 0) {
  61422 		goto __112
  61423 	}
  61424 	if !!(pColl != 0) {
  61425 		goto __113
  61426 	}
  61427 	pColl = (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl
  61428 __113:
  61429 	;
  61430 	Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, 0, 0, 0, pColl, -2)
  61431 __112:
  61432 	;
  61433 	Xsqlite3VdbeAddFunctionCall(tls, pParse, int32(constMask), r1, target, nFarg,
  61434 		pDef, int32((*Expr)(unsafe.Pointer(pExpr)).Fop2))
  61435 	if !(nFarg != 0) {
  61436 		goto __114
  61437 	}
  61438 	if !(constMask == U32(0)) {
  61439 		goto __115
  61440 	}
  61441 	Xsqlite3ReleaseTempRange(tls, pParse, r1, nFarg)
  61442 	goto __116
  61443 __115:
  61444 	;
  61445 __116:
  61446 	;
  61447 __114:
  61448 	;
  61449 	return target
  61450 
  61451 __45:
  61452 __46:
  61453 	;
  61454 	if !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) {
  61455 		goto __117
  61456 	}
  61457 	return 0
  61458 	goto __118
  61459 __117:
  61460 	if !(op == TK_SELECT &&
  61461 		(*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) &&
  61462 		libc.AssignInt32(&nCol, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpEList)).FnExpr) != 1) {
  61463 		goto __119
  61464 	}
  61465 	Xsqlite3SubselectError(tls, pParse, nCol, 1)
  61466 	goto __120
  61467 __119:
  61468 	return Xsqlite3CodeSubselect(tls, pParse, pExpr)
  61469 __120:
  61470 	;
  61471 __118:
  61472 	;
  61473 	goto __5
  61474 
  61475 __47:
  61476 	pLeft2 = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  61477 	if !((*Expr)(unsafe.Pointer(pLeft2)).FiTable == 0 || int32((*Parse)(unsafe.Pointer(pParse)).FwithinRJSubrtn) > int32((*Expr)(unsafe.Pointer(pLeft2)).Fop2)) {
  61478 		goto __121
  61479 	}
  61480 	(*Expr)(unsafe.Pointer(pLeft2)).FiTable = Xsqlite3CodeSubselect(tls, pParse, pLeft2)
  61481 	(*Expr)(unsafe.Pointer(pLeft2)).Fop2 = (*Parse)(unsafe.Pointer(pParse)).FwithinRJSubrtn
  61482 __121:
  61483 	;
  61484 	n1 = Xsqlite3ExprVectorSize(tls, pLeft2)
  61485 	if !((*Expr)(unsafe.Pointer(pExpr)).FiTable != n1) {
  61486 		goto __122
  61487 	}
  61488 	Xsqlite3ErrorMsg(tls, pParse, ts+7641,
  61489 		libc.VaList(bp+24, (*Expr)(unsafe.Pointer(pExpr)).FiTable, n1))
  61490 __122:
  61491 	;
  61492 	return (*Expr)(unsafe.Pointer(pLeft2)).FiTable + int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  61493 
  61494 __48:
  61495 	destIfFalse = Xsqlite3VdbeMakeLabel(tls, pParse)
  61496 	destIfNull = Xsqlite3VdbeMakeLabel(tls, pParse)
  61497 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target)
  61498 	sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull)
  61499 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, target)
  61500 	Xsqlite3VdbeResolveLabel(tls, v, destIfFalse)
  61501 	Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, target, 0)
  61502 	Xsqlite3VdbeResolveLabel(tls, v, destIfNull)
  61503 	return target
  61504 
  61505 __49:
  61506 	exprCodeBetween(tls, pParse, pExpr, target, uintptr(0), 0)
  61507 	return target
  61508 
  61509 __50:
  61510 	if !!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Collate) != U32(0)) {
  61511 		goto __123
  61512 	}
  61513 
  61514 	inReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, target)
  61515 	if !(inReg != target) {
  61516 		goto __125
  61517 	}
  61518 	Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, inReg, target)
  61519 	inReg = target
  61520 __125:
  61521 	;
  61522 	Xsqlite3VdbeAddOp1(tls, v, OP_ClrSubtype, inReg)
  61523 	return inReg
  61524 	goto __124
  61525 __123:
  61526 	pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  61527 	goto expr_code_doover
  61528 __124:
  61529 	;
  61530 __51:
  61531 __52:
  61532 	pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  61533 	goto expr_code_doover
  61534 
  61535 __53:
  61536 	;
  61537 	pTab2 = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  61538 	iCol1 = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  61539 	p1 = (*Expr)(unsafe.Pointer(pExpr)).FiTable*(int32((*Table)(unsafe.Pointer(pTab2)).FnCol)+1) + 1 +
  61540 		int32(Xsqlite3TableColumnToStorage(tls, pTab2, int16(iCol1)))
  61541 
  61542 	Xsqlite3VdbeAddOp2(tls, v, OP_Param, p1, target)
  61543 
  61544 	if !(iCol1 >= 0 && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab2)).FaCol+uintptr(iCol1)*16)).Faffinity) == SQLITE_AFF_REAL) {
  61545 		goto __126
  61546 	}
  61547 	Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target)
  61548 __126:
  61549 	;
  61550 	goto __5
  61551 
  61552 __54:
  61553 	Xsqlite3ErrorMsg(tls, pParse, ts+6533, 0)
  61554 	goto __5
  61555 
  61556 __55:
  61557 	okConstFactor = (*Parse)(unsafe.Pointer(pParse)).FokConstFactor
  61558 	pAggInfo1 = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo
  61559 	if !(pAggInfo1 != 0) {
  61560 		goto __127
  61561 	}
  61562 
  61563 	if !!(int32((*AggInfo)(unsafe.Pointer(pAggInfo1)).FdirectMode) != 0) {
  61564 		goto __128
  61565 	}
  61566 	inReg = func() int32 {
  61567 		return (*AggInfo)(unsafe.Pointer(pAggInfo1)).FiFirstReg + int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg)
  61568 	}()
  61569 	goto __5
  61570 __128:
  61571 	;
  61572 	if !((*AggInfo)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpAggInfo)).FuseSortingIdx != 0) {
  61573 		goto __129
  61574 	}
  61575 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*AggInfo)(unsafe.Pointer(pAggInfo1)).FsortingIdxPTab,
  61576 		int32((*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo1)).FaCol+uintptr((*Expr)(unsafe.Pointer(pExpr)).FiAgg)*16)).FiSorterColumn),
  61577 		target)
  61578 	inReg = target
  61579 	goto __5
  61580 __129:
  61581 	;
  61582 __127:
  61583 	;
  61584 	addrINR = Xsqlite3VdbeAddOp3(tls, v, OP_IfNullRow, (*Expr)(unsafe.Pointer(pExpr)).FiTable, 0, target)
  61585 
  61586 	(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(0)
  61587 	inReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, target)
  61588 	(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = okConstFactor
  61589 	if !(inReg != target) {
  61590 		goto __130
  61591 	}
  61592 	Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, inReg, target)
  61593 	inReg = target
  61594 __130:
  61595 	;
  61596 	Xsqlite3VdbeJumpHere(tls, v, addrINR)
  61597 	goto __5
  61598 
  61599 __56:
  61600 	pTest = uintptr(0)
  61601 	pDel = uintptr(0)
  61602 	db1 = (*Parse)(unsafe.Pointer(pParse)).Fdb
  61603 
  61604 	pEList = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  61605 	aListelem = pEList + 8
  61606 	nExpr = (*ExprList)(unsafe.Pointer(pEList)).FnExpr
  61607 	endLabel = Xsqlite3VdbeMakeLabel(tls, pParse)
  61608 	if !(libc.AssignUintptr(&pX, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) != uintptr(0)) {
  61609 		goto __131
  61610 	}
  61611 	pDel = Xsqlite3ExprDup(tls, db1, pX, 0)
  61612 	if !((*Sqlite3)(unsafe.Pointer(db1)).FmallocFailed != 0) {
  61613 		goto __132
  61614 	}
  61615 	Xsqlite3ExprDelete(tls, db1, pDel)
  61616 	goto __5
  61617 __132:
  61618 	;
  61619 	exprToRegister(tls, pDel, exprCodeVector(tls, pParse, pDel, bp+40))
  61620 
  61621 	libc.Xmemset(tls, bp+100, 0, uint32(unsafe.Sizeof(Expr{})))
  61622 	(*Expr)(unsafe.Pointer(bp + 100)).Fop = U8(TK_EQ)
  61623 	(*Expr)(unsafe.Pointer(bp + 100)).FpLeft = pDel
  61624 	pTest = bp + 100
  61625 
  61626 	*(*int32)(unsafe.Pointer(bp + 40)) = 0
  61627 __131:
  61628 	;
  61629 	i1 = 0
  61630 __133:
  61631 	if !(i1 < nExpr-1) {
  61632 		goto __135
  61633 	}
  61634 	if !(pX != 0) {
  61635 		goto __136
  61636 	}
  61637 
  61638 	(*Expr)(unsafe.Pointer(bp + 100)).FpRight = (*ExprList_item)(unsafe.Pointer(aListelem + uintptr(i1)*20)).FpExpr
  61639 	goto __137
  61640 __136:
  61641 	pTest = (*ExprList_item)(unsafe.Pointer(aListelem + uintptr(i1)*20)).FpExpr
  61642 __137:
  61643 	;
  61644 	nextCase = Xsqlite3VdbeMakeLabel(tls, pParse)
  61645 
  61646 	Xsqlite3ExprIfFalse(tls, pParse, pTest, nextCase, SQLITE_JUMPIFNULL)
  61647 
  61648 	Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(aListelem+uintptr(i1+1)*20)).FpExpr, target)
  61649 	Xsqlite3VdbeGoto(tls, v, endLabel)
  61650 	Xsqlite3VdbeResolveLabel(tls, v, nextCase)
  61651 	goto __134
  61652 __134:
  61653 	i1 = i1 + 2
  61654 	goto __133
  61655 	goto __135
  61656 __135:
  61657 	;
  61658 	if !(nExpr&1 != 0) {
  61659 		goto __138
  61660 	}
  61661 	Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(nExpr-1)*20)).FpExpr, target)
  61662 	goto __139
  61663 __138:
  61664 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target)
  61665 __139:
  61666 	;
  61667 	Xsqlite3ExprDelete(tls, db1, pDel)
  61668 	setDoNotMergeFlagOnCopy(tls, v)
  61669 	Xsqlite3VdbeResolveLabel(tls, v, endLabel)
  61670 	goto __5
  61671 
  61672 __57:
  61673 	;
  61674 	if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) && !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0)) {
  61675 		goto __140
  61676 	}
  61677 	Xsqlite3ErrorMsg(tls, pParse,
  61678 		ts+8082, 0)
  61679 	return 0
  61680 __140:
  61681 	;
  61682 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == OE_Abort) {
  61683 		goto __141
  61684 	}
  61685 	Xsqlite3MayAbort(tls, pParse)
  61686 __141:
  61687 	;
  61688 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == OE_Ignore) {
  61689 		goto __142
  61690 	}
  61691 	Xsqlite3VdbeAddOp4(tls,
  61692 		v, OP_Halt, SQLITE_OK, OE_Ignore, 0, *(*uintptr)(unsafe.Pointer(pExpr + 8)), 0)
  61693 
  61694 	goto __143
  61695 __142:
  61696 	Xsqlite3HaltConstraint(tls, pParse,
  61697 		func() int32 {
  61698 			if (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 {
  61699 				return SQLITE_CONSTRAINT | int32(7)<<8
  61700 			}
  61701 			return SQLITE_ERROR
  61702 		}(),
  61703 		int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr), *(*uintptr)(unsafe.Pointer(pExpr + 8)), int8(0), uint8(0))
  61704 __143:
  61705 	;
  61706 	goto __5
  61707 
  61708 __5:
  61709 	;
  61710 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 40)))
  61711 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 44)))
  61712 	return inReg
  61713 }
  61714 
  61715 var zAff = *(*[10]uint8)(unsafe.Pointer(ts + 8132))
  61716 
  61717 // Generate code that will evaluate expression pExpr just one time
  61718 // per prepared statement execution.
  61719 //
  61720 // If the expression uses functions (that might throw an exception) then
  61721 // guard them with an OP_Once opcode to ensure that the code is only executed
  61722 // once. If no functions are involved, then factor the code out and put it at
  61723 // the end of the prepared statement in the initialization section.
  61724 //
  61725 // If regDest>=0 then the result is always stored in that register and the
  61726 // result is not reusable.  If regDest<0 then this routine is free to
  61727 // store the value whereever it wants.  The register where the expression
  61728 // is stored is returned.  When regDest<0, two identical expressions might
  61729 // code to the same register, if they do not contain function calls and hence
  61730 // are factored out into the initialization section at the end of the
  61731 // prepared statement.
  61732 func Xsqlite3ExprCodeRunJustOnce(tls *libc.TLS, pParse uintptr, pExpr uintptr, regDest int32) int32 {
  61733 	var p uintptr
  61734 
  61735 	p = (*Parse)(unsafe.Pointer(pParse)).FpConstExpr
  61736 	if regDest < 0 && p != 0 {
  61737 		var pItem uintptr
  61738 		var i int32
  61739 		pItem = p + 8
  61740 		i = (*ExprList)(unsafe.Pointer(p)).FnExpr
  61741 	__1:
  61742 		if !(i > 0) {
  61743 			goto __3
  61744 		}
  61745 		{
  61746 			if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 8 + 4))&0x8>>3)) != 0 &&
  61747 				Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr, pExpr, -1) == 0 {
  61748 				return *(*int32)(unsafe.Pointer(pItem + 16))
  61749 			}
  61750 
  61751 		}
  61752 		goto __2
  61753 	__2:
  61754 		pItem += 20
  61755 		i--
  61756 		goto __1
  61757 		goto __3
  61758 	__3:
  61759 	}
  61760 	pExpr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)
  61761 	if pExpr != uintptr(0) && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_HasFunc) != U32(0) {
  61762 		var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  61763 		var addr int32
  61764 
  61765 		addr = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  61766 		(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(0)
  61767 		if !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) {
  61768 			if regDest < 0 {
  61769 				regDest = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  61770 			}
  61771 			Xsqlite3ExprCode(tls, pParse, pExpr, regDest)
  61772 		}
  61773 		(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(1)
  61774 		Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  61775 		Xsqlite3VdbeJumpHere(tls, v, addr)
  61776 	} else {
  61777 		p = Xsqlite3ExprListAppend(tls, pParse, p, pExpr)
  61778 		if p != 0 {
  61779 			var pItem uintptr = p + 8 + uintptr((*ExprList)(unsafe.Pointer(p)).FnExpr-1)*20
  61780 			libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(libc.Bool32(regDest < 0)), 3, 0x8)
  61781 			if regDest < 0 {
  61782 				regDest = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  61783 			}
  61784 			*(*int32)(unsafe.Pointer(pItem + 16)) = regDest
  61785 		}
  61786 		(*Parse)(unsafe.Pointer(pParse)).FpConstExpr = p
  61787 	}
  61788 	return regDest
  61789 }
  61790 
  61791 // Generate code to evaluate an expression and store the results
  61792 // into a register.  Return the register number where the results
  61793 // are stored.
  61794 //
  61795 // If the register is a temporary register that can be deallocated,
  61796 // then write its number into *pReg.  If the result register is not
  61797 // a temporary, then set *pReg to zero.
  61798 //
  61799 // If pExpr is a constant, then this routine might generate this
  61800 // code to fill the register in the initialization section of the
  61801 // VDBE program, in order to factor it out of the evaluation loop.
  61802 func Xsqlite3ExprCodeTemp(tls *libc.TLS, pParse uintptr, pExpr uintptr, pReg uintptr) int32 {
  61803 	var r2 int32
  61804 	pExpr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr)
  61805 	if (*Parse)(unsafe.Pointer(pParse)).FokConstFactor != 0 &&
  61806 		pExpr != uintptr(0) &&
  61807 		int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_REGISTER &&
  61808 		Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0 {
  61809 		*(*int32)(unsafe.Pointer(pReg)) = 0
  61810 		r2 = Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -1)
  61811 	} else {
  61812 		var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  61813 		r2 = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, r1)
  61814 		if r2 == r1 {
  61815 			*(*int32)(unsafe.Pointer(pReg)) = r1
  61816 		} else {
  61817 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
  61818 			*(*int32)(unsafe.Pointer(pReg)) = 0
  61819 		}
  61820 	}
  61821 	return r2
  61822 }
  61823 
  61824 // Generate code that will evaluate expression pExpr and store the
  61825 // results in register target.  The results are guaranteed to appear
  61826 // in register target.
  61827 func Xsqlite3ExprCode(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) {
  61828 	var inReg int32
  61829 
  61830 	if (*Parse)(unsafe.Pointer(pParse)).FpVdbe == uintptr(0) {
  61831 		return
  61832 	}
  61833 	inReg = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, target)
  61834 	if inReg != target {
  61835 		var op U8
  61836 		if pExpr != 0 && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Subquery) != U32(0) {
  61837 			op = U8(OP_Copy)
  61838 		} else {
  61839 			op = U8(OP_SCopy)
  61840 		}
  61841 		Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, int32(op), inReg, target)
  61842 	}
  61843 }
  61844 
  61845 // Make a transient copy of expression pExpr and then code it using
  61846 // sqlite3ExprCode().  This routine works just like sqlite3ExprCode()
  61847 // except that the input expression is guaranteed to be unchanged.
  61848 func Xsqlite3ExprCodeCopy(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) {
  61849 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  61850 	pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0)
  61851 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  61852 		Xsqlite3ExprCode(tls, pParse, pExpr, target)
  61853 	}
  61854 	Xsqlite3ExprDelete(tls, db, pExpr)
  61855 }
  61856 
  61857 // Generate code that will evaluate expression pExpr and store the
  61858 // results in register target.  The results are guaranteed to appear
  61859 // in register target.  If the expression is constant, then this routine
  61860 // might choose to code the expression at initialization time.
  61861 func Xsqlite3ExprCodeFactorable(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) {
  61862 	if (*Parse)(unsafe.Pointer(pParse)).FokConstFactor != 0 && Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0 {
  61863 		Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, target)
  61864 	} else {
  61865 		Xsqlite3ExprCodeCopy(tls, pParse, pExpr, target)
  61866 	}
  61867 }
  61868 
  61869 // Generate code that pushes the value of every element of the given
  61870 // expression list into a sequence of registers beginning at target.
  61871 //
  61872 // Return the number of elements evaluated.  The number returned will
  61873 // usually be pList->nExpr but might be reduced if SQLITE_ECEL_OMITREF
  61874 // is defined.
  61875 //
  61876 // The SQLITE_ECEL_DUP flag prevents the arguments from being
  61877 // filled using OP_SCopy.  OP_Copy must be used instead.
  61878 //
  61879 // The SQLITE_ECEL_FACTOR argument allows constant arguments to be
  61880 // factored out into initialization code.
  61881 //
  61882 // The SQLITE_ECEL_REF flag means that expressions in the list with
  61883 // ExprList.a[].u.x.iOrderByCol>0 have already been evaluated and stored
  61884 // in registers at srcReg, and so the value can be copied from there.
  61885 // If SQLITE_ECEL_OMITREF is also set, then the values with u.x.iOrderByCol>0
  61886 // are simply omitted rather than being copied from srcReg.
  61887 func Xsqlite3ExprCodeExprList(tls *libc.TLS, pParse uintptr, pList uintptr, target int32, srcReg int32, flags U8) int32 {
  61888 	var pItem uintptr
  61889 	var i int32
  61890 	var j int32
  61891 	var n int32
  61892 	var copyOp U8
  61893 	if int32(flags)&SQLITE_ECEL_DUP != 0 {
  61894 		copyOp = uint8(OP_Copy)
  61895 	} else {
  61896 		copyOp = uint8(OP_SCopy)
  61897 	}
  61898 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  61899 
  61900 	n = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  61901 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FokConstFactor) != 0) {
  61902 		flags = libc.Uint8FromInt32(int32(flags) & libc.CplInt32(SQLITE_ECEL_FACTOR))
  61903 	}
  61904 	pItem = pList + 8
  61905 	i = 0
  61906 __1:
  61907 	if !(i < n) {
  61908 		goto __3
  61909 	}
  61910 	{
  61911 		var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr
  61912 		if int32(flags)&SQLITE_ECEL_REF != 0 && libc.AssignInt32(&j, int32(*(*U16)(unsafe.Pointer(pItem + 16)))) > 0 {
  61913 			if int32(flags)&SQLITE_ECEL_OMITREF != 0 {
  61914 				i--
  61915 				n--
  61916 			} else {
  61917 				Xsqlite3VdbeAddOp2(tls, v, int32(copyOp), j+srcReg-1, target+i)
  61918 			}
  61919 		} else if int32(flags)&SQLITE_ECEL_FACTOR != 0 &&
  61920 			Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0 {
  61921 			Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, target+i)
  61922 		} else {
  61923 			var inReg int32 = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, target+i)
  61924 			if inReg != target+i {
  61925 				var pOp uintptr
  61926 				if int32(copyOp) == OP_Copy &&
  61927 					int32((*VdbeOp)(unsafe.Pointer(libc.AssignUintptr(&pOp, Xsqlite3VdbeGetLastOp(tls, v)))).Fopcode) == OP_Copy &&
  61928 					(*VdbeOp)(unsafe.Pointer(pOp)).Fp1+(*VdbeOp)(unsafe.Pointer(pOp)).Fp3+1 == inReg &&
  61929 					(*VdbeOp)(unsafe.Pointer(pOp)).Fp2+(*VdbeOp)(unsafe.Pointer(pOp)).Fp3+1 == target+i &&
  61930 					int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) == 0 {
  61931 					(*VdbeOp)(unsafe.Pointer(pOp)).Fp3++
  61932 				} else {
  61933 					Xsqlite3VdbeAddOp2(tls, v, int32(copyOp), inReg, target+i)
  61934 				}
  61935 			}
  61936 		}
  61937 
  61938 	}
  61939 	goto __2
  61940 __2:
  61941 	i++
  61942 	pItem += 20
  61943 	goto __1
  61944 	goto __3
  61945 __3:
  61946 	;
  61947 	return n
  61948 }
  61949 
  61950 func exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, xJump uintptr, jumpIfNull int32) {
  61951 	bp := tls.Alloc(160)
  61952 	defer tls.Free(160)
  61953 
  61954 	*(*int32)(unsafe.Pointer(bp + 156)) = 0
  61955 	var pDel uintptr = uintptr(0)
  61956 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  61957 
  61958 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Expr{})))
  61959 	libc.Xmemset(tls, bp+52, 0, uint32(unsafe.Sizeof(Expr{})))
  61960 	libc.Xmemset(tls, bp+104, 0, uint32(unsafe.Sizeof(Expr{})))
  61961 
  61962 	pDel = Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0)
  61963 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  61964 		(*Expr)(unsafe.Pointer(bp + 104)).Fop = U8(TK_AND)
  61965 		(*Expr)(unsafe.Pointer(bp + 104)).FpLeft = bp
  61966 		(*Expr)(unsafe.Pointer(bp + 104)).FpRight = bp + 52
  61967 		(*Expr)(unsafe.Pointer(bp)).Fop = U8(TK_GE)
  61968 		(*Expr)(unsafe.Pointer(bp)).FpLeft = pDel
  61969 		(*Expr)(unsafe.Pointer(bp)).FpRight = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)) + 8)).FpExpr
  61970 		(*Expr)(unsafe.Pointer(bp + 52)).Fop = U8(TK_LE)
  61971 		(*Expr)(unsafe.Pointer(bp + 52)).FpLeft = pDel
  61972 		(*Expr)(unsafe.Pointer(bp + 52)).FpRight = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)) + 8 + 1*20)).FpExpr
  61973 		exprToRegister(tls, pDel, exprCodeVector(tls, pParse, pDel, bp+156))
  61974 		if xJump != 0 {
  61975 			(*struct {
  61976 				f func(*libc.TLS, uintptr, uintptr, int32, int32)
  61977 			})(unsafe.Pointer(&struct{ uintptr }{xJump})).f(tls, pParse, bp+104, dest, jumpIfNull)
  61978 		} else {
  61979 			*(*U32)(unsafe.Pointer(pDel + 4)) |= U32(EP_OuterON)
  61980 			Xsqlite3ExprCodeTarget(tls, pParse, bp+104, dest)
  61981 		}
  61982 		Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 156)))
  61983 	}
  61984 	Xsqlite3ExprDelete(tls, db, pDel)
  61985 
  61986 }
  61987 
  61988 // Generate code for a boolean expression such that a jump is made
  61989 // to the label "dest" if the expression is true but execution
  61990 // continues straight thru if the expression is false.
  61991 //
  61992 // If the expression evaluates to NULL (neither true nor false), then
  61993 // take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL.
  61994 //
  61995 // This code depends on the fact that certain token values (ex: TK_EQ)
  61996 // are the same as opcode values (ex: OP_Eq) that implement the corresponding
  61997 // operation.  Special comments in vdbe.c and the mkopcodeh.awk script in
  61998 // the make process cause these values to align.  Assert()s in the code
  61999 // below verify that the numbers are aligned correctly.
  62000 func Xsqlite3ExprIfTrue(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, jumpIfNull int32) {
  62001 	bp := tls.Alloc(8)
  62002 	defer tls.Free(8)
  62003 
  62004 	var v uintptr
  62005 	var op int32
  62006 
  62007 	var r1 int32
  62008 	var r2 int32
  62009 	var d2 int32
  62010 	var pAlt uintptr
  62011 	var isNot int32
  62012 	var isTrue int32
  62013 	var destIfFalse int32
  62014 	var destIfNull int32
  62015 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  62016 	op = 0
  62017 	*(*int32)(unsafe.Pointer(bp)) = 0
  62018 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
  62019 
  62020 	if !(v == uintptr(0)) {
  62021 		goto __1
  62022 	}
  62023 	return
  62024 __1:
  62025 	;
  62026 	if !(pExpr == uintptr(0)) {
  62027 		goto __2
  62028 	}
  62029 	return
  62030 __2:
  62031 	;
  62032 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
  62033 	switch op {
  62034 	case TK_AND:
  62035 		goto __4
  62036 	case TK_OR:
  62037 		goto __5
  62038 	case TK_NOT:
  62039 		goto __6
  62040 	case TK_TRUTH:
  62041 		goto __7
  62042 	case TK_IS:
  62043 		goto __8
  62044 	case TK_ISNOT:
  62045 		goto __9
  62046 	case TK_LT:
  62047 		goto __10
  62048 	case TK_LE:
  62049 		goto __11
  62050 	case TK_GT:
  62051 		goto __12
  62052 	case TK_GE:
  62053 		goto __13
  62054 	case TK_NE:
  62055 		goto __14
  62056 	case TK_EQ:
  62057 		goto __15
  62058 	case TK_ISNULL:
  62059 		goto __16
  62060 	case TK_NOTNULL:
  62061 		goto __17
  62062 	case TK_BETWEEN:
  62063 		goto __18
  62064 	case TK_IN:
  62065 		goto __19
  62066 	default:
  62067 		goto __20
  62068 	}
  62069 	goto __3
  62070 __4:
  62071 __5:
  62072 	pAlt = Xsqlite3ExprSimplifiedAndOr(tls, pExpr)
  62073 	if !(pAlt != pExpr) {
  62074 		goto __21
  62075 	}
  62076 	Xsqlite3ExprIfTrue(tls, pParse, pAlt, dest, jumpIfNull)
  62077 	goto __22
  62078 __21:
  62079 	if !(op == TK_AND) {
  62080 		goto __23
  62081 	}
  62082 	d2 = Xsqlite3VdbeMakeLabel(tls, pParse)
  62083 
  62084 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, d2,
  62085 		jumpIfNull^SQLITE_JUMPIFNULL)
  62086 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull)
  62087 	Xsqlite3VdbeResolveLabel(tls, v, d2)
  62088 	goto __24
  62089 __23:
  62090 	;
  62091 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, jumpIfNull)
  62092 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull)
  62093 __24:
  62094 	;
  62095 __22:
  62096 	;
  62097 	goto __3
  62098 
  62099 __6:
  62100 	;
  62101 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, jumpIfNull)
  62102 	goto __3
  62103 
  62104 __7:
  62105 	;
  62106 	isNot = libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_ISNOT)
  62107 	isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  62108 
  62109 	if !(isTrue^isNot != 0) {
  62110 		goto __25
  62111 	}
  62112 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest,
  62113 		func() int32 {
  62114 			if isNot != 0 {
  62115 				return SQLITE_JUMPIFNULL
  62116 			}
  62117 			return 0
  62118 		}())
  62119 	goto __26
  62120 __25:
  62121 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest,
  62122 		func() int32 {
  62123 			if isNot != 0 {
  62124 				return SQLITE_JUMPIFNULL
  62125 			}
  62126 			return 0
  62127 		}())
  62128 __26:
  62129 	;
  62130 	goto __3
  62131 
  62132 __8:
  62133 __9:
  62134 	;
  62135 	if op == TK_IS {
  62136 		op = TK_EQ
  62137 	} else {
  62138 		op = TK_NE
  62139 	}
  62140 	jumpIfNull = SQLITE_NULLEQ
  62141 __10:
  62142 __11:
  62143 __12:
  62144 __13:
  62145 __14:
  62146 __15:
  62147 	if !(Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) != 0) {
  62148 		goto __27
  62149 	}
  62150 	goto default_expr
  62151 __27:
  62152 	;
  62153 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp)
  62154 	r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+4)
  62155 	codeCompare(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op,
  62156 		r1, r2, dest, jumpIfNull, libc.Bool32((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Commuted) != U32(0)))
  62157 
  62158 	goto __3
  62159 
  62160 __16:
  62161 __17:
  62162 	;
  62163 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp)
  62164 	Xsqlite3VdbeTypeofColumn(tls, v, r1)
  62165 	Xsqlite3VdbeAddOp2(tls, v, op, r1, dest)
  62166 
  62167 	goto __3
  62168 
  62169 __18:
  62170 	;
  62171 	exprCodeBetween(tls, pParse, pExpr, dest, *(*uintptr)(unsafe.Pointer(&struct {
  62172 		f func(*libc.TLS, uintptr, uintptr, int32, int32)
  62173 	}{Xsqlite3ExprIfTrue})), jumpIfNull)
  62174 	goto __3
  62175 
  62176 __19:
  62177 	destIfFalse = Xsqlite3VdbeMakeLabel(tls, pParse)
  62178 	if jumpIfNull != 0 {
  62179 		destIfNull = dest
  62180 	} else {
  62181 		destIfNull = destIfFalse
  62182 	}
  62183 	sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull)
  62184 	Xsqlite3VdbeGoto(tls, v, dest)
  62185 	Xsqlite3VdbeResolveLabel(tls, v, destIfFalse)
  62186 	goto __3
  62187 
  62188 __20:
  62189 default_expr:
  62190 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_IsTrue) == U32(EP_IsTrue)) {
  62191 		goto __28
  62192 	}
  62193 	Xsqlite3VdbeGoto(tls, v, dest)
  62194 	goto __29
  62195 __28:
  62196 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse)) {
  62197 		goto __30
  62198 	}
  62199 
  62200 	goto __31
  62201 __30:
  62202 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, pExpr, bp)
  62203 	Xsqlite3VdbeAddOp3(tls, v, OP_If, r1, dest, libc.Bool32(jumpIfNull != 0))
  62204 
  62205 __31:
  62206 	;
  62207 __29:
  62208 	;
  62209 	goto __3
  62210 
  62211 __3:
  62212 	;
  62213 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp)))
  62214 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 4)))
  62215 }
  62216 
  62217 // Generate code for a boolean expression such that a jump is made
  62218 // to the label "dest" if the expression is false but execution
  62219 // continues straight thru if the expression is true.
  62220 //
  62221 // If the expression evaluates to NULL (neither true nor false) then
  62222 // jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull
  62223 // is 0.
  62224 func Xsqlite3ExprIfFalse(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, jumpIfNull int32) {
  62225 	bp := tls.Alloc(8)
  62226 	defer tls.Free(8)
  62227 
  62228 	var v uintptr
  62229 	var op int32
  62230 
  62231 	var r1 int32
  62232 	var r2 int32
  62233 	var d2 int32
  62234 	var pAlt uintptr
  62235 	var isNot int32
  62236 	var isTrue int32
  62237 	var destIfNull int32
  62238 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  62239 	op = 0
  62240 	*(*int32)(unsafe.Pointer(bp)) = 0
  62241 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
  62242 
  62243 	if !(v == uintptr(0)) {
  62244 		goto __1
  62245 	}
  62246 	return
  62247 __1:
  62248 	;
  62249 	if !(pExpr == uintptr(0)) {
  62250 		goto __2
  62251 	}
  62252 	return
  62253 __2:
  62254 	;
  62255 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) + TK_ISNULL&1 ^ 1 - TK_ISNULL&1
  62256 
  62257 	switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  62258 	case TK_AND:
  62259 		goto __4
  62260 	case TK_OR:
  62261 		goto __5
  62262 	case TK_NOT:
  62263 		goto __6
  62264 	case TK_TRUTH:
  62265 		goto __7
  62266 	case TK_IS:
  62267 		goto __8
  62268 	case TK_ISNOT:
  62269 		goto __9
  62270 	case TK_LT:
  62271 		goto __10
  62272 	case TK_LE:
  62273 		goto __11
  62274 	case TK_GT:
  62275 		goto __12
  62276 	case TK_GE:
  62277 		goto __13
  62278 	case TK_NE:
  62279 		goto __14
  62280 	case TK_EQ:
  62281 		goto __15
  62282 	case TK_ISNULL:
  62283 		goto __16
  62284 	case TK_NOTNULL:
  62285 		goto __17
  62286 	case TK_BETWEEN:
  62287 		goto __18
  62288 	case TK_IN:
  62289 		goto __19
  62290 	default:
  62291 		goto __20
  62292 	}
  62293 	goto __3
  62294 __4:
  62295 __5:
  62296 	pAlt = Xsqlite3ExprSimplifiedAndOr(tls, pExpr)
  62297 	if !(pAlt != pExpr) {
  62298 		goto __21
  62299 	}
  62300 	Xsqlite3ExprIfFalse(tls, pParse, pAlt, dest, jumpIfNull)
  62301 	goto __22
  62302 __21:
  62303 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND) {
  62304 		goto __23
  62305 	}
  62306 
  62307 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, jumpIfNull)
  62308 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull)
  62309 	goto __24
  62310 __23:
  62311 	d2 = Xsqlite3VdbeMakeLabel(tls, pParse)
  62312 
  62313 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, d2,
  62314 		jumpIfNull^SQLITE_JUMPIFNULL)
  62315 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull)
  62316 	Xsqlite3VdbeResolveLabel(tls, v, d2)
  62317 __24:
  62318 	;
  62319 __22:
  62320 	;
  62321 	goto __3
  62322 
  62323 __6:
  62324 	;
  62325 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, jumpIfNull)
  62326 	goto __3
  62327 
  62328 __7:
  62329 	;
  62330 	isNot = libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_ISNOT)
  62331 	isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  62332 
  62333 	if !(isTrue^isNot != 0) {
  62334 		goto __25
  62335 	}
  62336 
  62337 	Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest,
  62338 		func() int32 {
  62339 			if isNot != 0 {
  62340 				return 0
  62341 			}
  62342 			return SQLITE_JUMPIFNULL
  62343 		}())
  62344 
  62345 	goto __26
  62346 __25:
  62347 	Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest,
  62348 		func() int32 {
  62349 			if isNot != 0 {
  62350 				return 0
  62351 			}
  62352 			return SQLITE_JUMPIFNULL
  62353 		}())
  62354 __26:
  62355 	;
  62356 	goto __3
  62357 
  62358 __8:
  62359 __9:
  62360 	;
  62361 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS {
  62362 		op = TK_NE
  62363 	} else {
  62364 		op = TK_EQ
  62365 	}
  62366 	jumpIfNull = SQLITE_NULLEQ
  62367 __10:
  62368 __11:
  62369 __12:
  62370 __13:
  62371 __14:
  62372 __15:
  62373 	if !(Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) != 0) {
  62374 		goto __27
  62375 	}
  62376 	goto default_expr
  62377 __27:
  62378 	;
  62379 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp)
  62380 	r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+4)
  62381 	codeCompare(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op,
  62382 		r1, r2, dest, jumpIfNull, libc.Bool32((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Commuted) != U32(0)))
  62383 
  62384 	goto __3
  62385 
  62386 __16:
  62387 __17:
  62388 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp)
  62389 	Xsqlite3VdbeTypeofColumn(tls, v, r1)
  62390 	Xsqlite3VdbeAddOp2(tls, v, op, r1, dest)
  62391 
  62392 	goto __3
  62393 
  62394 __18:
  62395 	;
  62396 	exprCodeBetween(tls, pParse, pExpr, dest, *(*uintptr)(unsafe.Pointer(&struct {
  62397 		f func(*libc.TLS, uintptr, uintptr, int32, int32)
  62398 	}{Xsqlite3ExprIfFalse})), jumpIfNull)
  62399 	goto __3
  62400 
  62401 __19:
  62402 	if !(jumpIfNull != 0) {
  62403 		goto __28
  62404 	}
  62405 	sqlite3ExprCodeIN(tls, pParse, pExpr, dest, dest)
  62406 	goto __29
  62407 __28:
  62408 	destIfNull = Xsqlite3VdbeMakeLabel(tls, pParse)
  62409 	sqlite3ExprCodeIN(tls, pParse, pExpr, dest, destIfNull)
  62410 	Xsqlite3VdbeResolveLabel(tls, v, destIfNull)
  62411 __29:
  62412 	;
  62413 	goto __3
  62414 
  62415 __20:
  62416 default_expr:
  62417 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse)) {
  62418 		goto __30
  62419 	}
  62420 	Xsqlite3VdbeGoto(tls, v, dest)
  62421 	goto __31
  62422 __30:
  62423 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_IsTrue) == U32(EP_IsTrue)) {
  62424 		goto __32
  62425 	}
  62426 
  62427 	goto __33
  62428 __32:
  62429 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, pExpr, bp)
  62430 	Xsqlite3VdbeAddOp3(tls, v, OP_IfNot, r1, dest, libc.Bool32(jumpIfNull != 0))
  62431 
  62432 __33:
  62433 	;
  62434 __31:
  62435 	;
  62436 	goto __3
  62437 
  62438 __3:
  62439 	;
  62440 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp)))
  62441 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 4)))
  62442 }
  62443 
  62444 // Like sqlite3ExprIfFalse() except that a copy is made of pExpr before
  62445 // code generation, and that copy is deleted after code generation. This
  62446 // ensures that the original pExpr is unchanged.
  62447 func Xsqlite3ExprIfFalseDup(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, jumpIfNull int32) {
  62448 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  62449 	var pCopy uintptr = Xsqlite3ExprDup(tls, db, pExpr, 0)
  62450 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  62451 		Xsqlite3ExprIfFalse(tls, pParse, pCopy, dest, jumpIfNull)
  62452 	}
  62453 	Xsqlite3ExprDelete(tls, db, pCopy)
  62454 }
  62455 
  62456 func exprCompareVariable(tls *libc.TLS, pParse uintptr, pVar uintptr, pExpr uintptr) int32 {
  62457 	bp := tls.Alloc(4)
  62458 	defer tls.Free(4)
  62459 
  62460 	var res int32 = 0
  62461 	var iVar int32
  62462 	var pL uintptr
  62463 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  62464 
  62465 	Xsqlite3ValueFromExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp)
  62466 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  62467 		iVar = int32((*Expr)(unsafe.Pointer(pVar)).FiColumn)
  62468 		Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iVar)
  62469 		pL = Xsqlite3VdbeGetBoundValue(tls, (*Parse)(unsafe.Pointer(pParse)).FpReprepare, iVar, uint8(SQLITE_AFF_BLOB))
  62470 		if pL != 0 {
  62471 			if Xsqlite3_value_type(tls, pL) == SQLITE_TEXT {
  62472 				Xsqlite3_value_text(tls, pL)
  62473 			}
  62474 			res = libc.Bool32(0 == Xsqlite3MemCompare(tls, pL, *(*uintptr)(unsafe.Pointer(bp)), uintptr(0)))
  62475 		}
  62476 		Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
  62477 		Xsqlite3ValueFree(tls, pL)
  62478 	}
  62479 
  62480 	return res
  62481 }
  62482 
  62483 // Do a deep comparison of two expression trees.  Return 0 if the two
  62484 // expressions are completely identical.  Return 1 if they differ only
  62485 // by a COLLATE operator at the top level.  Return 2 if there are differences
  62486 // other than the top-level COLLATE operator.
  62487 //
  62488 // If any subelement of pB has Expr.iTable==(-1) then it is allowed
  62489 // to compare equal to an equivalent element in pA with Expr.iTable==iTab.
  62490 //
  62491 // The pA side might be using TK_REGISTER.  If that is the case and pB is
  62492 // not using TK_REGISTER but is otherwise equivalent, then still return 0.
  62493 //
  62494 // Sometimes this routine will return 2 even if the two expressions
  62495 // really are equivalent.  If we cannot prove that the expressions are
  62496 // identical, we return 2 just to be safe.  So if this routine
  62497 // returns 2, then you do not really know for certain if the two
  62498 // expressions are the same.  But if you get a 0 or 1 return, then you
  62499 // can be sure the expressions are the same.  In the places where
  62500 // this routine is used, it does not hurt to get an extra 2 - that
  62501 // just might result in some slightly slower code.  But returning
  62502 // an incorrect 0 or 1 could lead to a malfunction.
  62503 //
  62504 // If pParse is not NULL then TK_VARIABLE terms in pA with bindings in
  62505 // pParse->pReprepare can be matched against literals in pB.  The
  62506 // pParse->pVdbe->expmask bitmask is updated for each variable referenced.
  62507 // If pParse is NULL (the normal case) then any TK_VARIABLE term in
  62508 // Argument pParse should normally be NULL. If it is not NULL and pA or
  62509 // pB causes a return value of 2.
  62510 func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, iTab int32) int32 {
  62511 	var combinedFlags U32
  62512 	if pA == uintptr(0) || pB == uintptr(0) {
  62513 		if pB == pA {
  62514 			return 0
  62515 		}
  62516 		return 2
  62517 	}
  62518 	if pParse != 0 && int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_VARIABLE && exprCompareVariable(tls, pParse, pA, pB) != 0 {
  62519 		return 0
  62520 	}
  62521 	combinedFlags = (*Expr)(unsafe.Pointer(pA)).Fflags | (*Expr)(unsafe.Pointer(pB)).Fflags
  62522 	if combinedFlags&U32(EP_IntValue) != 0 {
  62523 		if (*Expr)(unsafe.Pointer(pA)).Fflags&(*Expr)(unsafe.Pointer(pB)).Fflags&U32(EP_IntValue) != U32(0) && *(*int32)(unsafe.Pointer(pA + 8)) == *(*int32)(unsafe.Pointer(pB + 8)) {
  62524 			return 0
  62525 		}
  62526 		return 2
  62527 	}
  62528 	if int32((*Expr)(unsafe.Pointer(pA)).Fop) != int32((*Expr)(unsafe.Pointer(pB)).Fop) || int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_RAISE {
  62529 		if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_COLLATE && Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, pB, iTab) < 2 {
  62530 			return 1
  62531 		}
  62532 		if int32((*Expr)(unsafe.Pointer(pB)).Fop) == TK_COLLATE && Xsqlite3ExprCompare(tls, pParse, pA, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) < 2 {
  62533 			return 1
  62534 		}
  62535 		if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_AGG_COLUMN && int32((*Expr)(unsafe.Pointer(pB)).Fop) == TK_COLUMN &&
  62536 			(*Expr)(unsafe.Pointer(pB)).FiTable < 0 && (*Expr)(unsafe.Pointer(pA)).FiTable == iTab {
  62537 		} else {
  62538 			return 2
  62539 		}
  62540 	}
  62541 
  62542 	if *(*uintptr)(unsafe.Pointer(pA + 8)) != 0 {
  62543 		if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_FUNCTION || int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_AGG_FUNCTION {
  62544 			if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8)), *(*uintptr)(unsafe.Pointer(pB + 8))) != 0 {
  62545 				return 2
  62546 			}
  62547 
  62548 			if libc.Bool32((*Expr)(unsafe.Pointer(pA)).Fflags&U32(EP_WinFunc) != U32(0)) != libc.Bool32((*Expr)(unsafe.Pointer(pB)).Fflags&U32(EP_WinFunc) != U32(0)) {
  62549 				return 2
  62550 			}
  62551 			if (*Expr)(unsafe.Pointer(pA)).Fflags&U32(EP_WinFunc) != U32(0) {
  62552 				if Xsqlite3WindowCompare(tls, pParse, *(*uintptr)(unsafe.Pointer(pA + 44)), *(*uintptr)(unsafe.Pointer(pB + 44)), 1) != 0 {
  62553 					return 2
  62554 				}
  62555 			}
  62556 		} else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_NULL {
  62557 			return 0
  62558 		} else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_COLLATE {
  62559 			if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8)), *(*uintptr)(unsafe.Pointer(pB + 8))) != 0 {
  62560 				return 2
  62561 			}
  62562 		} else if *(*uintptr)(unsafe.Pointer(pB + 8)) != uintptr(0) &&
  62563 			int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_COLUMN &&
  62564 			int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_AGG_COLUMN &&
  62565 			libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8)), *(*uintptr)(unsafe.Pointer(pB + 8))) != 0 {
  62566 			return 2
  62567 		}
  62568 	}
  62569 	if (*Expr)(unsafe.Pointer(pA)).Fflags&U32(EP_Distinct|EP_Commuted) !=
  62570 		(*Expr)(unsafe.Pointer(pB)).Fflags&U32(EP_Distinct|EP_Commuted) {
  62571 		return 2
  62572 	}
  62573 	if combinedFlags&U32(EP_TokenOnly) == U32(0) {
  62574 		if combinedFlags&U32(EP_xIsSelect) != 0 {
  62575 			return 2
  62576 		}
  62577 		if combinedFlags&U32(EP_FixedCol) == U32(0) &&
  62578 			Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) != 0 {
  62579 			return 2
  62580 		}
  62581 		if Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpRight, (*Expr)(unsafe.Pointer(pB)).FpRight, iTab) != 0 {
  62582 			return 2
  62583 		}
  62584 		if Xsqlite3ExprListCompare(tls, *(*uintptr)(unsafe.Pointer(pA + 20)), *(*uintptr)(unsafe.Pointer(pB + 20)), iTab) != 0 {
  62585 			return 2
  62586 		}
  62587 		if int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_STRING &&
  62588 			int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_TRUEFALSE &&
  62589 			combinedFlags&U32(EP_Reduced) == U32(0) {
  62590 			if int32((*Expr)(unsafe.Pointer(pA)).FiColumn) != int32((*Expr)(unsafe.Pointer(pB)).FiColumn) {
  62591 				return 2
  62592 			}
  62593 			if int32((*Expr)(unsafe.Pointer(pA)).Fop2) != int32((*Expr)(unsafe.Pointer(pB)).Fop2) && int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_TRUTH {
  62594 				return 2
  62595 			}
  62596 			if int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_IN && (*Expr)(unsafe.Pointer(pA)).FiTable != (*Expr)(unsafe.Pointer(pB)).FiTable && (*Expr)(unsafe.Pointer(pA)).FiTable != iTab {
  62597 				return 2
  62598 			}
  62599 		}
  62600 	}
  62601 	return 0
  62602 }
  62603 
  62604 // Compare two ExprList objects.  Return 0 if they are identical, 1
  62605 // if they are certainly different, or 2 if it is not possible to
  62606 // determine if they are identical or not.
  62607 //
  62608 // If any subelement of pB has Expr.iTable==(-1) then it is allowed
  62609 // to compare equal to an equivalent element in pA with Expr.iTable==iTab.
  62610 //
  62611 // This routine might return non-zero for equivalent ExprLists.  The
  62612 // only consequence will be disabled optimizations.  But this routine
  62613 // must never return 0 if the two ExprList objects are different, or
  62614 // a malfunction will result.
  62615 //
  62616 // Two NULL pointers are considered to be the same.  But a NULL pointer
  62617 // always differs from a non-NULL pointer.
  62618 func Xsqlite3ExprListCompare(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) int32 {
  62619 	var i int32
  62620 	if pA == uintptr(0) && pB == uintptr(0) {
  62621 		return 0
  62622 	}
  62623 	if pA == uintptr(0) || pB == uintptr(0) {
  62624 		return 1
  62625 	}
  62626 	if (*ExprList)(unsafe.Pointer(pA)).FnExpr != (*ExprList)(unsafe.Pointer(pB)).FnExpr {
  62627 		return 1
  62628 	}
  62629 	for i = 0; i < (*ExprList)(unsafe.Pointer(pA)).FnExpr; i++ {
  62630 		var res int32
  62631 		var pExprA uintptr = (*ExprList_item)(unsafe.Pointer(pA + 8 + uintptr(i)*20)).FpExpr
  62632 		var pExprB uintptr = (*ExprList_item)(unsafe.Pointer(pB + 8 + uintptr(i)*20)).FpExpr
  62633 		if int32((*ExprList_item)(unsafe.Pointer(pA+8+uintptr(i)*20)).Ffg.FsortFlags) != int32((*ExprList_item)(unsafe.Pointer(pB+8+uintptr(i)*20)).Ffg.FsortFlags) {
  62634 			return 1
  62635 		}
  62636 		if libc.AssignInt32(&res, Xsqlite3ExprCompare(tls, uintptr(0), pExprA, pExprB, iTab)) != 0 {
  62637 			return res
  62638 		}
  62639 	}
  62640 	return 0
  62641 }
  62642 
  62643 // Like sqlite3ExprCompare() except COLLATE operators at the top-level
  62644 // are ignored.
  62645 func Xsqlite3ExprCompareSkip(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) int32 {
  62646 	return Xsqlite3ExprCompare(tls, uintptr(0),
  62647 		Xsqlite3ExprSkipCollateAndLikely(tls, pA),
  62648 		Xsqlite3ExprSkipCollateAndLikely(tls, pB),
  62649 		iTab)
  62650 }
  62651 
  62652 func exprImpliesNotNull(tls *libc.TLS, pParse uintptr, p uintptr, pNN uintptr, iTab int32, seenNot int32) int32 {
  62653 	if Xsqlite3ExprCompare(tls, pParse, p, pNN, iTab) == 0 {
  62654 		return libc.Bool32(int32((*Expr)(unsafe.Pointer(pNN)).Fop) != TK_NULL)
  62655 	}
  62656 	{
  62657 		switch int32((*Expr)(unsafe.Pointer(p)).Fop) {
  62658 		case TK_IN:
  62659 			{
  62660 				if seenNot != 0 && (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_xIsSelect) != U32(0) {
  62661 					return 0
  62662 				}
  62663 
  62664 				return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1)
  62665 
  62666 			}
  62667 		case TK_BETWEEN:
  62668 			{
  62669 				var pList uintptr
  62670 
  62671 				pList = *(*uintptr)(unsafe.Pointer(p + 20))
  62672 
  62673 				if seenNot != 0 {
  62674 					return 0
  62675 				}
  62676 				if exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8)).FpExpr, pNN, iTab, 1) != 0 ||
  62677 					exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+1*20)).FpExpr, pNN, iTab, 1) != 0 {
  62678 					return 1
  62679 				}
  62680 				return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1)
  62681 
  62682 			}
  62683 		case TK_EQ:
  62684 			fallthrough
  62685 		case TK_NE:
  62686 			fallthrough
  62687 		case TK_LT:
  62688 			fallthrough
  62689 		case TK_LE:
  62690 			fallthrough
  62691 		case TK_GT:
  62692 			fallthrough
  62693 		case TK_GE:
  62694 			fallthrough
  62695 		case TK_PLUS:
  62696 			fallthrough
  62697 		case TK_MINUS:
  62698 			fallthrough
  62699 		case TK_BITOR:
  62700 			fallthrough
  62701 		case TK_LSHIFT:
  62702 			fallthrough
  62703 		case TK_RSHIFT:
  62704 			fallthrough
  62705 		case TK_CONCAT:
  62706 			seenNot = 1
  62707 			fallthrough
  62708 		case TK_STAR:
  62709 			fallthrough
  62710 		case TK_REM:
  62711 			fallthrough
  62712 		case TK_BITAND:
  62713 			fallthrough
  62714 		case TK_SLASH:
  62715 			{
  62716 				if exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpRight, pNN, iTab, seenNot) != 0 {
  62717 					return 1
  62718 				}
  62719 
  62720 			}
  62721 			fallthrough
  62722 		case TK_SPAN:
  62723 			fallthrough
  62724 		case TK_COLLATE:
  62725 			fallthrough
  62726 		case TK_UPLUS:
  62727 			fallthrough
  62728 		case TK_UMINUS:
  62729 			{
  62730 				return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, seenNot)
  62731 
  62732 			}
  62733 		case TK_TRUTH:
  62734 			{
  62735 				if seenNot != 0 {
  62736 					return 0
  62737 				}
  62738 				if int32((*Expr)(unsafe.Pointer(p)).Fop2) != TK_IS {
  62739 					return 0
  62740 				}
  62741 				return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1)
  62742 
  62743 			}
  62744 		case TK_BITNOT:
  62745 			fallthrough
  62746 		case TK_NOT:
  62747 			{
  62748 				return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1)
  62749 
  62750 			}
  62751 		}
  62752 	}
  62753 	return 0
  62754 }
  62755 
  62756 // Return true if we can prove the pE2 will always be true if pE1 is
  62757 // true.  Return false if we cannot complete the proof or if pE2 might
  62758 // be false.  Examples:
  62759 //
  62760 //	pE1: x==5       pE2: x==5             Result: true
  62761 //	pE1: x>0        pE2: x==5             Result: false
  62762 //	pE1: x=21       pE2: x=21 OR y=43     Result: true
  62763 //	pE1: x!=123     pE2: x IS NOT NULL    Result: true
  62764 //	pE1: x!=?1      pE2: x IS NOT NULL    Result: true
  62765 //	pE1: x IS NULL  pE2: x IS NOT NULL    Result: false
  62766 //	pE1: x IS ?2    pE2: x IS NOT NULL    Reuslt: false
  62767 //
  62768 // When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
  62769 // Expr.iTable<0 then assume a table number given by iTab.
  62770 //
  62771 // If pParse is not NULL, then the values of bound variables in pE1 are
  62772 // compared against literal values in pE2 and pParse->pVdbe->expmask is
  62773 // modified to record which bound variables are referenced.  If pParse
  62774 // is NULL, then false will be returned if pE1 contains any bound variables.
  62775 //
  62776 // When in doubt, return false.  Returning true might give a performance
  62777 // improvement.  Returning false might cause a performance reduction, but
  62778 // it will always give the correct answer and is hence always safe.
  62779 func Xsqlite3ExprImpliesExpr(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uintptr, iTab int32) int32 {
  62780 	if Xsqlite3ExprCompare(tls, pParse, pE1, pE2, iTab) == 0 {
  62781 		return 1
  62782 	}
  62783 	if int32((*Expr)(unsafe.Pointer(pE2)).Fop) == TK_OR &&
  62784 		(Xsqlite3ExprImpliesExpr(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpLeft, iTab) != 0 ||
  62785 			Xsqlite3ExprImpliesExpr(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpRight, iTab) != 0) {
  62786 		return 1
  62787 	}
  62788 	if int32((*Expr)(unsafe.Pointer(pE2)).Fop) == TK_NOTNULL &&
  62789 		exprImpliesNotNull(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpLeft, iTab, 0) != 0 {
  62790 		return 1
  62791 	}
  62792 	return 0
  62793 }
  62794 
  62795 func impliesNotNullRow(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  62796 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) {
  62797 		return WRC_Prune
  62798 	}
  62799 	switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  62800 	case TK_ISNOT:
  62801 		fallthrough
  62802 	case TK_ISNULL:
  62803 		fallthrough
  62804 	case TK_NOTNULL:
  62805 		fallthrough
  62806 	case TK_IS:
  62807 		fallthrough
  62808 	case TK_OR:
  62809 		fallthrough
  62810 	case TK_VECTOR:
  62811 		fallthrough
  62812 	case TK_CASE:
  62813 		fallthrough
  62814 	case TK_IN:
  62815 		fallthrough
  62816 	case TK_FUNCTION:
  62817 		fallthrough
  62818 	case TK_TRUTH:
  62819 		return WRC_Prune
  62820 	case TK_COLUMN:
  62821 		if *(*int32)(unsafe.Pointer(pWalker + 24)) == (*Expr)(unsafe.Pointer(pExpr)).FiTable {
  62822 			(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1)
  62823 			return WRC_Abort
  62824 		}
  62825 		return WRC_Prune
  62826 
  62827 	case TK_AND:
  62828 		if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 0 {
  62829 			Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  62830 			if (*Walker)(unsafe.Pointer(pWalker)).FeCode != 0 {
  62831 				(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
  62832 				Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  62833 			}
  62834 		}
  62835 		return WRC_Prune
  62836 
  62837 	case TK_BETWEEN:
  62838 		if Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) == WRC_Abort {
  62839 			return WRC_Abort
  62840 		}
  62841 		return WRC_Prune
  62842 
  62843 	case TK_EQ:
  62844 		fallthrough
  62845 	case TK_NE:
  62846 		fallthrough
  62847 	case TK_LT:
  62848 		fallthrough
  62849 	case TK_LE:
  62850 		fallthrough
  62851 	case TK_GT:
  62852 		fallthrough
  62853 	case TK_GE:
  62854 		{
  62855 			var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  62856 			var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight
  62857 
  62858 			if int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN &&
  62859 				*(*uintptr)(unsafe.Pointer(pLeft + 44)) != uintptr(0) &&
  62860 				int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 44)))).FeTabType) == TABTYP_VTAB ||
  62861 				int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN &&
  62862 					*(*uintptr)(unsafe.Pointer(pRight + 44)) != uintptr(0) &&
  62863 					int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 44)))).FeTabType) == TABTYP_VTAB {
  62864 				return WRC_Prune
  62865 			}
  62866 
  62867 		}
  62868 		fallthrough
  62869 	default:
  62870 		return WRC_Continue
  62871 	}
  62872 	return int32(0)
  62873 }
  62874 
  62875 // Return true (non-zero) if expression p can only be true if at least
  62876 // one column of table iTab is non-null.  In other words, return true
  62877 // if expression p will always be NULL or false if every column of iTab
  62878 // is NULL.
  62879 //
  62880 // False negatives are acceptable.  In other words, it is ok to return
  62881 // zero even if expression p will never be true of every column of iTab
  62882 // is NULL.  A false negative is merely a missed optimization opportunity.
  62883 //
  62884 // False positives are not allowed, however.  A false positive may result
  62885 // in an incorrect answer.
  62886 //
  62887 // Terms of p that are marked with EP_OuterON (and hence that come from
  62888 // the ON or USING clauses of OUTER JOINS) are excluded from the analysis.
  62889 //
  62890 // This routine is used to check if a LEFT JOIN can be converted into
  62891 // an ordinary JOIN.  The p argument is the WHERE clause.  If the WHERE
  62892 // clause requires that some column of the right table of the LEFT JOIN
  62893 // be non-NULL, then the LEFT JOIN can be safely converted into an
  62894 // ordinary join.
  62895 func Xsqlite3ExprImpliesNonNullRow(tls *libc.TLS, p uintptr, iTab int32) int32 {
  62896 	bp := tls.Alloc(28)
  62897 	defer tls.Free(28)
  62898 
  62899 	p = Xsqlite3ExprSkipCollateAndLikely(tls, p)
  62900 	if p == uintptr(0) {
  62901 		return 0
  62902 	}
  62903 	if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_NOTNULL {
  62904 		p = (*Expr)(unsafe.Pointer(p)).FpLeft
  62905 	} else {
  62906 		for int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AND {
  62907 			if Xsqlite3ExprImpliesNonNullRow(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, iTab) != 0 {
  62908 				return 1
  62909 			}
  62910 			p = (*Expr)(unsafe.Pointer(p)).FpRight
  62911 		}
  62912 	}
  62913 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  62914 		f func(*libc.TLS, uintptr, uintptr) int32
  62915 	}{impliesNotNullRow}))
  62916 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = uintptr(0)
  62917 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = uintptr(0)
  62918 	(*Walker)(unsafe.Pointer(bp)).FeCode = U16(0)
  62919 	*(*int32)(unsafe.Pointer(bp + 24)) = iTab
  62920 	Xsqlite3WalkExpr(tls, bp, p)
  62921 	return int32((*Walker)(unsafe.Pointer(bp)).FeCode)
  62922 }
  62923 
  62924 func exprIdxCover(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  62925 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN &&
  62926 		(*Expr)(unsafe.Pointer(pExpr)).FiTable == (*IdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 24)))).FiCur &&
  62927 		int32(Xsqlite3TableColumnToIndex(tls, (*IdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 24)))).FpIdx, (*Expr)(unsafe.Pointer(pExpr)).FiColumn)) < 0 {
  62928 		(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1)
  62929 		return WRC_Abort
  62930 	}
  62931 	return WRC_Continue
  62932 }
  62933 
  62934 // Determine if an index pIdx on table with cursor iCur contains will
  62935 // the expression pExpr.  Return true if the index does cover the
  62936 // expression and false if the pExpr expression references table columns
  62937 // that are not found in the index pIdx.
  62938 //
  62939 // An index covering an expression means that the expression can be
  62940 // evaluated using only the index and without having to lookup the
  62941 // corresponding table entry.
  62942 func Xsqlite3ExprCoveredByIndex(tls *libc.TLS, pExpr uintptr, iCur int32, pIdx uintptr) int32 {
  62943 	bp := tls.Alloc(36)
  62944 	defer tls.Free(36)
  62945 
  62946 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  62947 	(*IdxCover)(unsafe.Pointer(bp + 28)).FiCur = iCur
  62948 	(*IdxCover)(unsafe.Pointer(bp + 28)).FpIdx = pIdx
  62949 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  62950 		f func(*libc.TLS, uintptr, uintptr) int32
  62951 	}{exprIdxCover}))
  62952 	*(*uintptr)(unsafe.Pointer(bp + 24)) = bp + 28
  62953 	Xsqlite3WalkExpr(tls, bp, pExpr)
  62954 	return libc.BoolInt32(!((*Walker)(unsafe.Pointer(bp)).FeCode != 0))
  62955 }
  62956 
  62957 func selectRefEnter(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 {
  62958 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  62959 	var pSrc uintptr = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  62960 	var i I64
  62961 	var j I64
  62962 	var piNew uintptr
  62963 	if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc == 0 {
  62964 		return WRC_Continue
  62965 	}
  62966 	j = (*RefSrcList)(unsafe.Pointer(p)).FnExclude
  62967 	*(*I64)(unsafe.Pointer(p + 8)) += I64((*SrcList)(unsafe.Pointer(pSrc)).FnSrc)
  62968 	piNew = Xsqlite3DbRealloc(tls, (*RefSrcList)(unsafe.Pointer(p)).Fdb, (*RefSrcList)(unsafe.Pointer(p)).FaiExclude, uint64((*RefSrcList)(unsafe.Pointer(p)).FnExclude*I64(unsafe.Sizeof(int32(0)))))
  62969 	if piNew == uintptr(0) {
  62970 		(*RefSrcList)(unsafe.Pointer(p)).FnExclude = int64(0)
  62971 		return WRC_Abort
  62972 	} else {
  62973 		(*RefSrcList)(unsafe.Pointer(p)).FaiExclude = piNew
  62974 	}
  62975 	i = int64(0)
  62976 __1:
  62977 	if !(i < I64((*SrcList)(unsafe.Pointer(pSrc)).FnSrc)) {
  62978 		goto __3
  62979 	}
  62980 	{
  62981 		*(*int32)(unsafe.Pointer((*RefSrcList)(unsafe.Pointer(p)).FaiExclude + uintptr(j)*4)) = (*SrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72)).FiCursor
  62982 
  62983 	}
  62984 	goto __2
  62985 __2:
  62986 	i++
  62987 	j++
  62988 	goto __1
  62989 	goto __3
  62990 __3:
  62991 	;
  62992 	return WRC_Continue
  62993 }
  62994 
  62995 func selectRefLeave(tls *libc.TLS, pWalker uintptr, pSelect uintptr) {
  62996 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  62997 	var pSrc uintptr = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  62998 	if (*RefSrcList)(unsafe.Pointer(p)).FnExclude != 0 {
  62999 		*(*I64)(unsafe.Pointer(p + 8)) -= I64((*SrcList)(unsafe.Pointer(pSrc)).FnSrc)
  63000 	}
  63001 }
  63002 
  63003 func exprRefToSrcList(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  63004 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN ||
  63005 		int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN {
  63006 		var i int32
  63007 		var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  63008 		var pSrc uintptr = (*RefSrcList)(unsafe.Pointer(p)).FpRef
  63009 		var nSrc int32
  63010 		if pSrc != 0 {
  63011 			nSrc = (*SrcList)(unsafe.Pointer(pSrc)).FnSrc
  63012 		} else {
  63013 			nSrc = 0
  63014 		}
  63015 		for i = 0; i < nSrc; i++ {
  63016 			if (*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SrcItem)(unsafe.Pointer(pSrc+8+uintptr(i)*72)).FiCursor {
  63017 				*(*U16)(unsafe.Pointer(pWalker + 20)) |= U16(1)
  63018 				return WRC_Continue
  63019 			}
  63020 		}
  63021 		for i = 0; I64(i) < (*RefSrcList)(unsafe.Pointer(p)).FnExclude && *(*int32)(unsafe.Pointer((*RefSrcList)(unsafe.Pointer(p)).FaiExclude + uintptr(i)*4)) != (*Expr)(unsafe.Pointer(pExpr)).FiTable; i++ {
  63022 		}
  63023 		if I64(i) >= (*RefSrcList)(unsafe.Pointer(p)).FnExclude {
  63024 			*(*U16)(unsafe.Pointer(pWalker + 20)) |= U16(2)
  63025 		}
  63026 	}
  63027 	return WRC_Continue
  63028 }
  63029 
  63030 // Check to see if pExpr references any tables in pSrcList.
  63031 // Possible return values:
  63032 //
  63033 //	 1         pExpr does references a table in pSrcList.
  63034 //
  63035 //	 0         pExpr references some table that is not defined in either
  63036 //	           pSrcList or in subqueries of pExpr itself.
  63037 //
  63038 //	-1         pExpr only references no tables at all, or it only
  63039 //	           references tables defined in subqueries of pExpr itself.
  63040 //
  63041 // As currently used, pExpr is always an aggregate function call.  That
  63042 // fact is exploited for efficiency.
  63043 func Xsqlite3ReferencesSrcList(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSrcList uintptr) int32 {
  63044 	bp := tls.Alloc(56)
  63045 	defer tls.Free(56)
  63046 
  63047 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  63048 	libc.Xmemset(tls, bp+32, 0, uint32(unsafe.Sizeof(RefSrcList{})))
  63049 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  63050 		f func(*libc.TLS, uintptr, uintptr) int32
  63051 	}{exprRefToSrcList}))
  63052 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  63053 		f func(*libc.TLS, uintptr, uintptr) int32
  63054 	}{selectRefEnter}))
  63055 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = *(*uintptr)(unsafe.Pointer(&struct {
  63056 		f func(*libc.TLS, uintptr, uintptr)
  63057 	}{selectRefLeave}))
  63058 	*(*uintptr)(unsafe.Pointer(bp + 24)) = bp + 32
  63059 	(*RefSrcList)(unsafe.Pointer(bp + 32)).Fdb = (*Parse)(unsafe.Pointer(pParse)).Fdb
  63060 	(*RefSrcList)(unsafe.Pointer(bp + 32)).FpRef = pSrcList
  63061 
  63062 	Xsqlite3WalkExprList(tls, bp, *(*uintptr)(unsafe.Pointer(pExpr + 20)))
  63063 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  63064 		Xsqlite3WalkExpr(tls, bp, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FpFilter)
  63065 	}
  63066 	if (*RefSrcList)(unsafe.Pointer(bp+32)).FaiExclude != 0 {
  63067 		Xsqlite3DbNNFreeNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*RefSrcList)(unsafe.Pointer(bp+32)).FaiExclude)
  63068 	}
  63069 	if int32((*Walker)(unsafe.Pointer(bp)).FeCode)&0x01 != 0 {
  63070 		return 1
  63071 	} else if (*Walker)(unsafe.Pointer(bp)).FeCode != 0 {
  63072 		return 0
  63073 	} else {
  63074 		return -1
  63075 	}
  63076 	return int32(0)
  63077 }
  63078 
  63079 func agginfoPersistExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  63080 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_TokenOnly|EP_Reduced) != U32(0)) &&
  63081 		(*Expr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0) {
  63082 		var pAggInfo uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo
  63083 		var iAgg int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg)
  63084 		var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  63085 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  63086 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AGG_FUNCTION {
  63087 			if (*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol+uintptr(iAgg)*16)).FpCExpr == pExpr {
  63088 				pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0)
  63089 				if pExpr != 0 {
  63090 					(*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(iAgg)*16)).FpCExpr = pExpr
  63091 					Xsqlite3ExprDeferredDelete(tls, pParse, pExpr)
  63092 				}
  63093 			}
  63094 		} else {
  63095 			if (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(iAgg)*16)).FpFExpr == pExpr {
  63096 				pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0)
  63097 				if pExpr != 0 {
  63098 					(*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(iAgg)*16)).FpFExpr = pExpr
  63099 					Xsqlite3ExprDeferredDelete(tls, pParse, pExpr)
  63100 				}
  63101 			}
  63102 		}
  63103 	}
  63104 	return WRC_Continue
  63105 }
  63106 
  63107 // Initialize a Walker object so that will persist AggInfo entries referenced
  63108 // by the tree that is walked.
  63109 func Xsqlite3AggInfoPersistWalkerInit(tls *libc.TLS, pWalker uintptr, pParse uintptr) {
  63110 	libc.Xmemset(tls, pWalker, 0, uint32(unsafe.Sizeof(Walker{})))
  63111 	(*Walker)(unsafe.Pointer(pWalker)).FpParse = pParse
  63112 	(*Walker)(unsafe.Pointer(pWalker)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  63113 		f func(*libc.TLS, uintptr, uintptr) int32
  63114 	}{agginfoPersistExprCb}))
  63115 	(*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  63116 		f func(*libc.TLS, uintptr, uintptr) int32
  63117 	}{Xsqlite3SelectWalkNoop}))
  63118 }
  63119 
  63120 func addAggInfoColumn(tls *libc.TLS, db uintptr, pInfo uintptr) int32 {
  63121 	bp := tls.Alloc(4)
  63122 	defer tls.Free(4)
  63123 
  63124 	(*AggInfo)(unsafe.Pointer(pInfo)).FaCol = Xsqlite3ArrayAllocate(tls,
  63125 		db,
  63126 		(*AggInfo)(unsafe.Pointer(pInfo)).FaCol,
  63127 		int32(unsafe.Sizeof(AggInfo_col{})),
  63128 		pInfo+24,
  63129 		bp)
  63130 	return *(*int32)(unsafe.Pointer(bp))
  63131 }
  63132 
  63133 func addAggInfoFunc(tls *libc.TLS, db uintptr, pInfo uintptr) int32 {
  63134 	bp := tls.Alloc(4)
  63135 	defer tls.Free(4)
  63136 
  63137 	(*AggInfo)(unsafe.Pointer(pInfo)).FaFunc = Xsqlite3ArrayAllocate(tls,
  63138 		db,
  63139 		(*AggInfo)(unsafe.Pointer(pInfo)).FaFunc,
  63140 		int32(unsafe.Sizeof(AggInfo_func{})),
  63141 		pInfo+36,
  63142 		bp)
  63143 	return *(*int32)(unsafe.Pointer(bp))
  63144 }
  63145 
  63146 func findOrCreateAggInfoColumn(tls *libc.TLS, pParse uintptr, pAggInfo uintptr, pExpr uintptr) {
  63147 	var pCol uintptr
  63148 	var k int32
  63149 	var pE uintptr
  63150 	var j int32
  63151 	var n int32
  63152 	var pGB uintptr
  63153 	var pTerm uintptr
  63154 
  63155 	pCol = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol
  63156 	k = 0
  63157 __1:
  63158 	if !(k < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) {
  63159 		goto __3
  63160 	}
  63161 	if !((*AggInfo_col)(unsafe.Pointer(pCol)).FiTable == (*Expr)(unsafe.Pointer(pExpr)).FiTable &&
  63162 		int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) &&
  63163 		int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_IF_NULL_ROW) {
  63164 		goto __4
  63165 	}
  63166 	goto fix_up_expr
  63167 __4:
  63168 	;
  63169 	goto __2
  63170 __2:
  63171 	k++
  63172 	pCol += 16
  63173 	goto __1
  63174 	goto __3
  63175 __3:
  63176 	;
  63177 	k = addAggInfoColumn(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pAggInfo)
  63178 	if !(k < 0) {
  63179 		goto __5
  63180 	}
  63181 
  63182 	return
  63183 __5:
  63184 	;
  63185 	pCol = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(k)*16
  63186 
  63187 	(*AggInfo_col)(unsafe.Pointer(pCol)).FpTab = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  63188 	(*AggInfo_col)(unsafe.Pointer(pCol)).FiTable = (*Expr)(unsafe.Pointer(pExpr)).FiTable
  63189 	(*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn = (*Expr)(unsafe.Pointer(pExpr)).FiColumn
  63190 	(*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = int16(-1)
  63191 	(*AggInfo_col)(unsafe.Pointer(pCol)).FpCExpr = pExpr
  63192 	if !((*AggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy != 0 && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_IF_NULL_ROW) {
  63193 		goto __6
  63194 	}
  63195 	pGB = (*AggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy
  63196 	pTerm = pGB + 8
  63197 	n = (*ExprList)(unsafe.Pointer(pGB)).FnExpr
  63198 	j = 0
  63199 __7:
  63200 	if !(j < n) {
  63201 		goto __9
  63202 	}
  63203 	pE = (*ExprList_item)(unsafe.Pointer(pTerm)).FpExpr
  63204 	if !(int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_COLUMN &&
  63205 		(*Expr)(unsafe.Pointer(pE)).FiTable == (*Expr)(unsafe.Pointer(pExpr)).FiTable &&
  63206 		int32((*Expr)(unsafe.Pointer(pE)).FiColumn) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) {
  63207 		goto __10
  63208 	}
  63209 	(*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = I16(j)
  63210 	goto __9
  63211 __10:
  63212 	;
  63213 	goto __8
  63214 __8:
  63215 	j++
  63216 	pTerm += 20
  63217 	goto __7
  63218 	goto __9
  63219 __9:
  63220 	;
  63221 __6:
  63222 	;
  63223 	if !(int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn) < 0) {
  63224 		goto __11
  63225 	}
  63226 	(*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = I16(libc.PostIncUint16(&(*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn, 1))
  63227 __11:
  63228 	;
  63229 fix_up_expr:
  63230 	;
  63231 	(*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo
  63232 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) {
  63233 		goto __12
  63234 	}
  63235 	(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_AGG_COLUMN)
  63236 __12:
  63237 	;
  63238 	(*Expr)(unsafe.Pointer(pExpr)).FiAgg = I16(k)
  63239 }
  63240 
  63241 func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  63242 	bp := tls.Alloc(52)
  63243 	defer tls.Free(52)
  63244 
  63245 	var i int32
  63246 	var pNC uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  63247 	var pParse uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  63248 	var pSrcList uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpSrcList
  63249 	var pAggInfo uintptr = *(*uintptr)(unsafe.Pointer(pNC + 8))
  63250 
  63251 	switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  63252 	default:
  63253 		{
  63254 			var pIEpr uintptr
  63255 
  63256 			if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_InAggFunc == 0 {
  63257 				break
  63258 			}
  63259 			if (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr == uintptr(0) {
  63260 				break
  63261 			}
  63262 			for pIEpr = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr; pIEpr != 0; pIEpr = (*IndexedExpr)(unsafe.Pointer(pIEpr)).FpIENext {
  63263 				var iDataCur int32 = (*IndexedExpr)(unsafe.Pointer(pIEpr)).FiDataCur
  63264 				if iDataCur < 0 {
  63265 					continue
  63266 				}
  63267 				if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, (*IndexedExpr)(unsafe.Pointer(pIEpr)).FpExpr, iDataCur) == 0 {
  63268 					break
  63269 				}
  63270 			}
  63271 			if pIEpr == uintptr(0) {
  63272 				break
  63273 			}
  63274 			if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc|EP_Subrtn) == U32(0)) {
  63275 				break
  63276 			}
  63277 			if (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0) {
  63278 				break
  63279 			}
  63280 
  63281 			libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Expr{})))
  63282 			(*Expr)(unsafe.Pointer(bp)).Fop = U8(TK_AGG_COLUMN)
  63283 			(*Expr)(unsafe.Pointer(bp)).FiTable = (*IndexedExpr)(unsafe.Pointer(pIEpr)).FiIdxCur
  63284 			(*Expr)(unsafe.Pointer(bp)).FiColumn = YnVar((*IndexedExpr)(unsafe.Pointer(pIEpr)).FiIdxCol)
  63285 			findOrCreateAggInfoColumn(tls, pParse, pAggInfo, bp)
  63286 			(*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*Expr)(unsafe.Pointer(bp)).FiAgg)*16)).FpCExpr = pExpr
  63287 			(*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo
  63288 			(*Expr)(unsafe.Pointer(pExpr)).FiAgg = (*Expr)(unsafe.Pointer(bp)).FiAgg
  63289 			return WRC_Prune
  63290 
  63291 		}
  63292 	case TK_IF_NULL_ROW:
  63293 		fallthrough
  63294 	case TK_AGG_COLUMN:
  63295 		fallthrough
  63296 	case TK_COLUMN:
  63297 		{
  63298 			if pSrcList != uintptr(0) {
  63299 				var pItem uintptr = pSrcList + 8
  63300 				i = 0
  63301 			__1:
  63302 				if !(i < (*SrcList)(unsafe.Pointer(pSrcList)).FnSrc) {
  63303 					goto __3
  63304 				}
  63305 				{
  63306 					if (*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SrcItem)(unsafe.Pointer(pItem)).FiCursor {
  63307 						findOrCreateAggInfoColumn(tls, pParse, pAggInfo, pExpr)
  63308 						goto __3
  63309 					}
  63310 
  63311 				}
  63312 				goto __2
  63313 			__2:
  63314 				i++
  63315 				pItem += 72
  63316 				goto __1
  63317 				goto __3
  63318 			__3:
  63319 			}
  63320 			return WRC_Prune
  63321 
  63322 		}
  63323 	case TK_AGG_FUNCTION:
  63324 		{
  63325 			if (*NameContext)(unsafe.Pointer(pNC)).FncFlags&NC_InAggFunc == 0 &&
  63326 				(*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth == int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) {
  63327 				var pItem uintptr = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc
  63328 				i = 0
  63329 			__4:
  63330 				if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) {
  63331 					goto __6
  63332 				}
  63333 				{
  63334 					if (*AggInfo_func)(unsafe.Pointer(pItem)).FpFExpr == pExpr {
  63335 						goto __6
  63336 					}
  63337 					if Xsqlite3ExprCompare(tls, uintptr(0), (*AggInfo_func)(unsafe.Pointer(pItem)).FpFExpr, pExpr, -1) == 0 {
  63338 						goto __6
  63339 					}
  63340 
  63341 				}
  63342 				goto __5
  63343 			__5:
  63344 				i++
  63345 				pItem += 16
  63346 				goto __4
  63347 				goto __6
  63348 			__6:
  63349 				;
  63350 				if i >= (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc {
  63351 					var enc U8 = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fenc
  63352 					i = addAggInfoFunc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pAggInfo)
  63353 					if i >= 0 {
  63354 						pItem = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*16
  63355 						(*AggInfo_func)(unsafe.Pointer(pItem)).FpFExpr = pExpr
  63356 
  63357 						(*AggInfo_func)(unsafe.Pointer(pItem)).FpFunc = Xsqlite3FindFunction(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb,
  63358 							*(*uintptr)(unsafe.Pointer(pExpr + 8)),
  63359 							func() int32 {
  63360 								if *(*uintptr)(unsafe.Pointer(pExpr + 20)) != 0 {
  63361 									return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FnExpr
  63362 								}
  63363 								return 0
  63364 							}(), enc, uint8(0))
  63365 						if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Distinct) != 0 {
  63366 							(*AggInfo_func)(unsafe.Pointer(pItem)).FiDistinct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  63367 						} else {
  63368 							(*AggInfo_func)(unsafe.Pointer(pItem)).FiDistinct = -1
  63369 						}
  63370 					}
  63371 				}
  63372 
  63373 				(*Expr)(unsafe.Pointer(pExpr)).FiAgg = I16(i)
  63374 				(*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo
  63375 				return WRC_Prune
  63376 			} else {
  63377 				return WRC_Continue
  63378 			}
  63379 
  63380 		}
  63381 	}
  63382 	return WRC_Continue
  63383 }
  63384 
  63385 // Analyze the pExpr expression looking for aggregate functions and
  63386 // for variables that need to be added to AggInfo object that pNC->pAggInfo
  63387 // points to.  Additional entries are made on the AggInfo object as
  63388 // necessary.
  63389 //
  63390 // This routine should only be called after the expression has been
  63391 // analyzed by sqlite3ResolveExprNames().
  63392 func Xsqlite3ExprAnalyzeAggregates(tls *libc.TLS, pNC uintptr, pExpr uintptr) {
  63393 	bp := tls.Alloc(28)
  63394 	defer tls.Free(28)
  63395 
  63396 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  63397 		f func(*libc.TLS, uintptr, uintptr) int32
  63398 	}{analyzeAggregate}))
  63399 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  63400 		f func(*libc.TLS, uintptr, uintptr) int32
  63401 	}{Xsqlite3WalkerDepthIncrease}))
  63402 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = *(*uintptr)(unsafe.Pointer(&struct {
  63403 		f func(*libc.TLS, uintptr, uintptr)
  63404 	}{Xsqlite3WalkerDepthDecrease}))
  63405 	(*Walker)(unsafe.Pointer(bp)).FwalkerDepth = 0
  63406 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pNC
  63407 	(*Walker)(unsafe.Pointer(bp)).FpParse = uintptr(0)
  63408 
  63409 	Xsqlite3WalkExpr(tls, bp, pExpr)
  63410 }
  63411 
  63412 // Call sqlite3ExprAnalyzeAggregates() for every expression in an
  63413 // expression list.  Return the number of errors.
  63414 //
  63415 // If an error is found, the analysis is cut short.
  63416 func Xsqlite3ExprAnalyzeAggList(tls *libc.TLS, pNC uintptr, pList uintptr) {
  63417 	var pItem uintptr
  63418 	var i int32
  63419 	if pList != 0 {
  63420 		pItem = pList + 8
  63421 		i = 0
  63422 	__1:
  63423 		if !(i < (*ExprList)(unsafe.Pointer(pList)).FnExpr) {
  63424 			goto __3
  63425 		}
  63426 		{
  63427 			Xsqlite3ExprAnalyzeAggregates(tls, pNC, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)
  63428 
  63429 		}
  63430 		goto __2
  63431 	__2:
  63432 		i++
  63433 		pItem += 20
  63434 		goto __1
  63435 		goto __3
  63436 	__3:
  63437 	}
  63438 }
  63439 
  63440 // Allocate a single new register for use to hold some intermediate result.
  63441 func Xsqlite3GetTempReg(tls *libc.TLS, pParse uintptr) int32 {
  63442 	if int32((*Parse)(unsafe.Pointer(pParse)).FnTempReg) == 0 {
  63443 		return libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  63444 	}
  63445 	return *(*int32)(unsafe.Pointer(pParse + 160 + uintptr(libc.PreDecUint8(&(*Parse)(unsafe.Pointer(pParse)).FnTempReg, 1))*4))
  63446 }
  63447 
  63448 // Deallocate a register, making available for reuse for some other
  63449 // purpose.
  63450 func Xsqlite3ReleaseTempReg(tls *libc.TLS, pParse uintptr, iReg int32) {
  63451 	if iReg != 0 {
  63452 		if int32((*Parse)(unsafe.Pointer(pParse)).FnTempReg) < int32(uint32(unsafe.Sizeof([8]int32{}))/uint32(unsafe.Sizeof(int32(0)))) {
  63453 			*(*int32)(unsafe.Pointer(pParse + 160 + uintptr(libc.PostIncUint8(&(*Parse)(unsafe.Pointer(pParse)).FnTempReg, 1))*4)) = iReg
  63454 		}
  63455 	}
  63456 }
  63457 
  63458 // Allocate or deallocate a block of nReg consecutive registers.
  63459 func Xsqlite3GetTempRange(tls *libc.TLS, pParse uintptr, nReg int32) int32 {
  63460 	var i int32
  63461 	var n int32
  63462 	if nReg == 1 {
  63463 		return Xsqlite3GetTempReg(tls, pParse)
  63464 	}
  63465 	i = (*Parse)(unsafe.Pointer(pParse)).FiRangeReg
  63466 	n = (*Parse)(unsafe.Pointer(pParse)).FnRangeReg
  63467 	if nReg <= n {
  63468 		*(*int32)(unsafe.Pointer(pParse + 32)) += nReg
  63469 		*(*int32)(unsafe.Pointer(pParse + 28)) -= nReg
  63470 	} else {
  63471 		i = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  63472 		*(*int32)(unsafe.Pointer(pParse + 44)) += nReg
  63473 	}
  63474 	return i
  63475 }
  63476 
  63477 func Xsqlite3ReleaseTempRange(tls *libc.TLS, pParse uintptr, iReg int32, nReg int32) {
  63478 	if nReg == 1 {
  63479 		Xsqlite3ReleaseTempReg(tls, pParse, iReg)
  63480 		return
  63481 	}
  63482 
  63483 	if nReg > (*Parse)(unsafe.Pointer(pParse)).FnRangeReg {
  63484 		(*Parse)(unsafe.Pointer(pParse)).FnRangeReg = nReg
  63485 		(*Parse)(unsafe.Pointer(pParse)).FiRangeReg = iReg
  63486 	}
  63487 }
  63488 
  63489 // Mark all temporary registers as being unavailable for reuse.
  63490 //
  63491 // Always invoke this procedure after coding a subroutine or co-routine
  63492 // that might be invoked from other parts of the code, to ensure that
  63493 // the sub/co-routine does not use registers in common with the code that
  63494 // invokes the sub/co-routine.
  63495 func Xsqlite3ClearTempRegCache(tls *libc.TLS, pParse uintptr) {
  63496 	(*Parse)(unsafe.Pointer(pParse)).FnTempReg = U8(0)
  63497 	(*Parse)(unsafe.Pointer(pParse)).FnRangeReg = 0
  63498 }
  63499 
  63500 func isAlterableTable(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 {
  63501 	bp := tls.Alloc(8)
  63502 	defer tls.Free(8)
  63503 
  63504 	if 0 == Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+6381, 7) ||
  63505 		(*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Eponymous) != U32(0) ||
  63506 		(*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Shadow) != U32(0) &&
  63507 			Xsqlite3ReadOnlyShadowTables(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb) != 0 {
  63508 		Xsqlite3ErrorMsg(tls, pParse, ts+8142, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  63509 		return 1
  63510 	}
  63511 	return 0
  63512 }
  63513 
  63514 func renameTestSchema(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32, zWhen uintptr, bNoDQS int32) {
  63515 	bp := tls.Alloc(64)
  63516 	defer tls.Free(64)
  63517 
  63518 	(*Parse)(unsafe.Pointer(pParse)).FcolNamesSet = U8(1)
  63519 	Xsqlite3NestedParse(tls, pParse,
  63520 		ts+8170,
  63521 		libc.VaList(bp, zDb,
  63522 			zDb, bTemp, zWhen, bNoDQS))
  63523 
  63524 	if bTemp == 0 {
  63525 		Xsqlite3NestedParse(tls, pParse,
  63526 			ts+8345,
  63527 			libc.VaList(bp+40, zDb, zWhen, bNoDQS))
  63528 	}
  63529 }
  63530 
  63531 func renameFixQuotes(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32) {
  63532 	bp := tls.Alloc(16)
  63533 	defer tls.Free(16)
  63534 
  63535 	Xsqlite3NestedParse(tls, pParse,
  63536 		ts+8519, libc.VaList(bp, zDb, zDb))
  63537 	if bTemp == 0 {
  63538 		Xsqlite3NestedParse(tls, pParse,
  63539 			ts+8666, 0)
  63540 	}
  63541 }
  63542 
  63543 func renameReloadSchema(tls *libc.TLS, pParse uintptr, iDb int32, p5 U16) {
  63544 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  63545 	if v != 0 {
  63546 		Xsqlite3ChangeCookie(tls, pParse, iDb)
  63547 		Xsqlite3VdbeAddParseSchemaOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iDb, uintptr(0), p5)
  63548 		if iDb != 1 {
  63549 			Xsqlite3VdbeAddParseSchemaOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 1, uintptr(0), p5)
  63550 		}
  63551 	}
  63552 }
  63553 
  63554 // Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
  63555 // command.
  63556 func Xsqlite3AlterRenameTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) {
  63557 	bp := tls.Alloc(184)
  63558 	defer tls.Free(184)
  63559 
  63560 	var iDb int32
  63561 	var zDb uintptr
  63562 	var pTab uintptr
  63563 	var zName uintptr
  63564 	var db uintptr
  63565 	var nTabName int32
  63566 	var zTabName uintptr
  63567 	var v uintptr
  63568 	var pVTab uintptr
  63569 	var i int32
  63570 	zName = uintptr(0)
  63571 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  63572 	pVTab = uintptr(0)
  63573 
  63574 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  63575 		goto __1
  63576 	}
  63577 	goto exit_rename_table
  63578 __1:
  63579 	;
  63580 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8)
  63581 	if !!(pTab != 0) {
  63582 		goto __2
  63583 	}
  63584 	goto exit_rename_table
  63585 __2:
  63586 	;
  63587 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  63588 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  63589 
  63590 	zName = Xsqlite3NameFromToken(tls, db, pName)
  63591 	if !!(zName != 0) {
  63592 		goto __3
  63593 	}
  63594 	goto exit_rename_table
  63595 __3:
  63596 	;
  63597 	if !(Xsqlite3FindTable(tls, db, zName, zDb) != 0 ||
  63598 		Xsqlite3FindIndex(tls, db, zName, zDb) != 0 ||
  63599 		Xsqlite3IsShadowTableOf(tls, db, pTab, zName) != 0) {
  63600 		goto __4
  63601 	}
  63602 	Xsqlite3ErrorMsg(tls, pParse,
  63603 		ts+8817, libc.VaList(bp, zName))
  63604 	goto exit_rename_table
  63605 __4:
  63606 	;
  63607 	if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) {
  63608 		goto __5
  63609 	}
  63610 	goto exit_rename_table
  63611 __5:
  63612 	;
  63613 	if !(SQLITE_OK != Xsqlite3CheckObjectName(tls, pParse, zName, ts+8876, zName)) {
  63614 		goto __6
  63615 	}
  63616 	goto exit_rename_table
  63617 __6:
  63618 	;
  63619 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  63620 		goto __7
  63621 	}
  63622 	Xsqlite3ErrorMsg(tls, pParse, ts+8882, libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName))
  63623 	goto exit_rename_table
  63624 __7:
  63625 	;
  63626 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) {
  63627 		goto __8
  63628 	}
  63629 	goto exit_rename_table
  63630 __8:
  63631 	;
  63632 	if !(Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0) {
  63633 		goto __9
  63634 	}
  63635 	goto exit_rename_table
  63636 __9:
  63637 	;
  63638 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  63639 		goto __10
  63640 	}
  63641 	pVTab = Xsqlite3GetVTable(tls, db, pTab)
  63642 	if !((*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule)).FxRename == uintptr(0)) {
  63643 		goto __11
  63644 	}
  63645 	pVTab = uintptr(0)
  63646 __11:
  63647 	;
  63648 __10:
  63649 	;
  63650 	v = Xsqlite3GetVdbe(tls, pParse)
  63651 	if !(v == uintptr(0)) {
  63652 		goto __12
  63653 	}
  63654 	goto exit_rename_table
  63655 __12:
  63656 	;
  63657 	Xsqlite3MayAbort(tls, pParse)
  63658 
  63659 	zTabName = (*Table)(unsafe.Pointer(pTab)).FzName
  63660 	nTabName = Xsqlite3Utf8CharLen(tls, zTabName, -1)
  63661 
  63662 	Xsqlite3NestedParse(tls, pParse,
  63663 		ts+8909, libc.VaList(bp+16, zDb, zDb, zTabName, zName, libc.Bool32(iDb == 1), zTabName))
  63664 
  63665 	Xsqlite3NestedParse(tls, pParse,
  63666 		ts+9093,
  63667 		libc.VaList(bp+64, zDb,
  63668 			zName, zName, zName,
  63669 			nTabName, zTabName))
  63670 
  63671 	if !(Xsqlite3FindTable(tls, db, ts+9398, zDb) != 0) {
  63672 		goto __13
  63673 	}
  63674 	Xsqlite3NestedParse(tls, pParse,
  63675 		ts+9414,
  63676 		libc.VaList(bp+112, zDb, zName, (*Table)(unsafe.Pointer(pTab)).FzName))
  63677 __13:
  63678 	;
  63679 	if !(iDb != 1) {
  63680 		goto __14
  63681 	}
  63682 	Xsqlite3NestedParse(tls, pParse,
  63683 		ts+9472, libc.VaList(bp+136, zDb, zTabName, zName, zTabName, zDb, zName))
  63684 __14:
  63685 	;
  63686 	if !(pVTab != 0) {
  63687 		goto __15
  63688 	}
  63689 	i = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  63690 	Xsqlite3VdbeLoadString(tls, v, i, zName)
  63691 	Xsqlite3VdbeAddOp4(tls, v, OP_VRename, i, 0, 0, pVTab, -11)
  63692 __15:
  63693 	;
  63694 	renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterRename))
  63695 	renameTestSchema(tls, pParse, zDb, libc.Bool32(iDb == 1), ts+9737, 0)
  63696 
  63697 exit_rename_table:
  63698 	Xsqlite3SrcListDelete(tls, db, pSrc)
  63699 	Xsqlite3DbFree(tls, db, zName)
  63700 }
  63701 
  63702 func sqlite3ErrorIfNotEmpty(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zErr uintptr) {
  63703 	bp := tls.Alloc(24)
  63704 	defer tls.Free(24)
  63705 
  63706 	Xsqlite3NestedParse(tls, pParse,
  63707 		ts+9750,
  63708 		libc.VaList(bp, zErr, zDb, zTab))
  63709 }
  63710 
  63711 // This function is called after an "ALTER TABLE ... ADD" statement
  63712 // has been parsed. Argument pColDef contains the text of the new
  63713 // column definition.
  63714 //
  63715 // The Table structure pParse->pNewTable was extended to include
  63716 // the new column during parsing.
  63717 func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr) {
  63718 	bp := tls.Alloc(60)
  63719 	defer tls.Free(60)
  63720 
  63721 	var pNew uintptr
  63722 	var pTab uintptr
  63723 	var iDb int32
  63724 	var zDb uintptr
  63725 	var zTab uintptr
  63726 	var zCol uintptr
  63727 	var pCol uintptr
  63728 	var pDflt uintptr
  63729 	var db uintptr
  63730 	var v uintptr
  63731 	var r1 int32
  63732 
  63733 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  63734 
  63735 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  63736 		return
  63737 	}
  63738 
  63739 	pNew = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  63740 
  63741 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pNew)).FpSchema)
  63742 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  63743 	zTab = (*Table)(unsafe.Pointer(pNew)).FzName + 16
  63744 	pCol = (*Table)(unsafe.Pointer(pNew)).FaCol + uintptr(int32((*Table)(unsafe.Pointer(pNew)).FnCol)-1)*16
  63745 	pDflt = Xsqlite3ColumnExpr(tls, pNew, pCol)
  63746 	pTab = Xsqlite3FindTable(tls, db, zTab, zDb)
  63747 
  63748 	if Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 {
  63749 		return
  63750 	}
  63751 
  63752 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_PRIMKEY != 0 {
  63753 		Xsqlite3ErrorMsg(tls, pParse, ts+9788, 0)
  63754 		return
  63755 	}
  63756 	if (*Table)(unsafe.Pointer(pNew)).FpIndex != 0 {
  63757 		Xsqlite3ErrorMsg(tls, pParse,
  63758 			ts+9820, 0)
  63759 		return
  63760 	}
  63761 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_GENERATED == 0 {
  63762 		if pDflt != 0 && int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == TK_NULL {
  63763 			pDflt = uintptr(0)
  63764 		}
  63765 
  63766 		if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && *(*uintptr)(unsafe.Pointer(pNew + 44 + 4)) != 0 && pDflt != 0 {
  63767 			sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab,
  63768 				ts+9847)
  63769 		}
  63770 		if uint32(int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf>>0)) != 0 && !(pDflt != 0) {
  63771 			sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab,
  63772 				ts+9906)
  63773 		}
  63774 
  63775 		if pDflt != 0 {
  63776 			*(*uintptr)(unsafe.Pointer(bp + 56)) = uintptr(0)
  63777 			var rc int32
  63778 			rc = Xsqlite3ValueFromExpr(tls, db, pDflt, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp+56)
  63779 
  63780 			if rc != SQLITE_OK {
  63781 				return
  63782 			}
  63783 			if !(*(*uintptr)(unsafe.Pointer(bp + 56)) != 0) {
  63784 				sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab,
  63785 					ts+9959)
  63786 			}
  63787 			Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 56)))
  63788 		}
  63789 	} else if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_STORED != 0 {
  63790 		sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, ts+10005)
  63791 	}
  63792 
  63793 	zCol = Xsqlite3DbStrNDup(tls, db, (*Token)(unsafe.Pointer(pColDef)).Fz, uint64((*Token)(unsafe.Pointer(pColDef)).Fn))
  63794 	if zCol != 0 {
  63795 		var zEnd uintptr = zCol + uintptr((*Token)(unsafe.Pointer(pColDef)).Fn-uint32(1))
  63796 		for zEnd > zCol && (int32(*(*uint8)(unsafe.Pointer(zEnd))) == ';' || int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zEnd))])&0x01 != 0) {
  63797 			*(*uint8)(unsafe.Pointer(libc.PostDecUintptr(&zEnd, 1))) = uint8(0)
  63798 		}
  63799 
  63800 		Xsqlite3NestedParse(tls, pParse,
  63801 			ts+10032,
  63802 			libc.VaList(bp, zDb, *(*int32)(unsafe.Pointer(pNew + 44)), zCol, *(*int32)(unsafe.Pointer(pNew + 44)),
  63803 				zTab))
  63804 		Xsqlite3DbFree(tls, db, zCol)
  63805 	}
  63806 
  63807 	v = Xsqlite3GetVdbe(tls, pParse)
  63808 	if v != 0 {
  63809 		r1 = Xsqlite3GetTempReg(tls, pParse)
  63810 		Xsqlite3VdbeAddOp3(tls, v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT)
  63811 		Xsqlite3VdbeUsesBtree(tls, v, iDb)
  63812 		Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, r1, -2)
  63813 		Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, r1, Xsqlite3VdbeCurrentAddr(tls, v)+2)
  63814 
  63815 		Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3)
  63816 		Xsqlite3ReleaseTempReg(tls, pParse, r1)
  63817 
  63818 		renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterAdd))
  63819 
  63820 		if (*Table)(unsafe.Pointer(pNew)).FpCheck != uintptr(0) ||
  63821 			uint32(int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf>>0)) != 0 && int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_GENERATED != 0 {
  63822 			Xsqlite3NestedParse(tls, pParse,
  63823 				ts+10178,
  63824 				libc.VaList(bp+40, zTab, zDb))
  63825 		}
  63826 	}
  63827 }
  63828 
  63829 // This function is called by the parser after the table-name in
  63830 // an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
  63831 // pSrc is the full-name of the table being altered.
  63832 //
  63833 // This routine makes a (partial) copy of the Table structure
  63834 // for the table being altered and sets Parse.pNewTable to point
  63835 // to it. Routines called by the parser as the column definition
  63836 // is parsed (i.e. sqlite3AddColumn()) add the new Column data to
  63837 // the copy. The copy of the Table structure is deleted by tokenize.c
  63838 // after parsing is finished.
  63839 //
  63840 // Routine sqlite3AlterFinishAddColumn() will be called to complete
  63841 // coding the "ALTER TABLE ... ADD" statement.
  63842 func Xsqlite3AlterBeginAddColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr) {
  63843 	bp := tls.Alloc(8)
  63844 	defer tls.Free(8)
  63845 
  63846 	var pNew uintptr
  63847 	var pTab uintptr
  63848 	var iDb int32
  63849 	var i int32
  63850 	var nAlloc int32
  63851 	var db uintptr
  63852 	var pCol uintptr
  63853 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  63854 
  63855 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  63856 		goto __1
  63857 	}
  63858 	goto exit_begin_add_column
  63859 __1:
  63860 	;
  63861 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8)
  63862 	if !!(pTab != 0) {
  63863 		goto __2
  63864 	}
  63865 	goto exit_begin_add_column
  63866 __2:
  63867 	;
  63868 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  63869 		goto __3
  63870 	}
  63871 	Xsqlite3ErrorMsg(tls, pParse, ts+10408, 0)
  63872 	goto exit_begin_add_column
  63873 __3:
  63874 	;
  63875 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  63876 		goto __4
  63877 	}
  63878 	Xsqlite3ErrorMsg(tls, pParse, ts+10442, 0)
  63879 	goto exit_begin_add_column
  63880 __4:
  63881 	;
  63882 	if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) {
  63883 		goto __5
  63884 	}
  63885 	goto exit_begin_add_column
  63886 __5:
  63887 	;
  63888 	Xsqlite3MayAbort(tls, pParse)
  63889 
  63890 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  63891 
  63892 	pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))
  63893 	if !!(pNew != 0) {
  63894 		goto __6
  63895 	}
  63896 	goto exit_begin_add_column
  63897 __6:
  63898 	;
  63899 	(*Parse)(unsafe.Pointer(pParse)).FpNewTable = pNew
  63900 	(*Table)(unsafe.Pointer(pNew)).FnTabRef = U32(1)
  63901 	(*Table)(unsafe.Pointer(pNew)).FnCol = (*Table)(unsafe.Pointer(pTab)).FnCol
  63902 
  63903 	nAlloc = (int32((*Table)(unsafe.Pointer(pNew)).FnCol)-1)/8*8 + 8
  63904 
  63905 	(*Table)(unsafe.Pointer(pNew)).FaCol = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(Column{}))*uint32(nAlloc)))
  63906 	(*Table)(unsafe.Pointer(pNew)).FzName = Xsqlite3MPrintf(tls, db, ts+10472, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  63907 	if !(!(int32((*Table)(unsafe.Pointer(pNew)).FaCol) != 0) || !(int32((*Table)(unsafe.Pointer(pNew)).FzName) != 0)) {
  63908 		goto __7
  63909 	}
  63910 
  63911 	goto exit_begin_add_column
  63912 __7:
  63913 	;
  63914 	libc.Xmemcpy(tls, (*Table)(unsafe.Pointer(pNew)).FaCol, (*Table)(unsafe.Pointer(pTab)).FaCol, uint32(unsafe.Sizeof(Column{}))*uint32((*Table)(unsafe.Pointer(pNew)).FnCol))
  63915 	i = 0
  63916 __8:
  63917 	if !(i < int32((*Table)(unsafe.Pointer(pNew)).FnCol)) {
  63918 		goto __10
  63919 	}
  63920 	pCol = (*Table)(unsafe.Pointer(pNew)).FaCol + uintptr(i)*16
  63921 	(*Column)(unsafe.Pointer(pCol)).FzCnName = Xsqlite3DbStrDup(tls, db, (*Column)(unsafe.Pointer(pCol)).FzCnName)
  63922 	(*Column)(unsafe.Pointer(pCol)).FhName = Xsqlite3StrIHash(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName)
  63923 	goto __9
  63924 __9:
  63925 	i++
  63926 	goto __8
  63927 	goto __10
  63928 __10:
  63929 	;
  63930 	*(*uintptr)(unsafe.Pointer(pNew + 44 + 8)) = Xsqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(pTab + 44 + 8)), 0)
  63931 	(*Table)(unsafe.Pointer(pNew)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  63932 	*(*int32)(unsafe.Pointer(pNew + 44)) = *(*int32)(unsafe.Pointer(pTab + 44))
  63933 	(*Table)(unsafe.Pointer(pNew)).FnTabRef = U32(1)
  63934 
  63935 exit_begin_add_column:
  63936 	Xsqlite3SrcListDelete(tls, db, pSrc)
  63937 	return
  63938 }
  63939 
  63940 func isRealTable(tls *libc.TLS, pParse uintptr, pTab uintptr, bDrop int32) int32 {
  63941 	bp := tls.Alloc(24)
  63942 	defer tls.Free(24)
  63943 
  63944 	var zType uintptr = uintptr(0)
  63945 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW {
  63946 		zType = ts + 10491
  63947 	}
  63948 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  63949 		zType = ts + 10496
  63950 	}
  63951 	if zType != 0 {
  63952 		Xsqlite3ErrorMsg(tls, pParse, ts+10510,
  63953 			libc.VaList(bp, func() uintptr {
  63954 				if bDrop != 0 {
  63955 					return ts + 10528
  63956 				}
  63957 				return ts + 10545
  63958 			}(),
  63959 				zType, (*Table)(unsafe.Pointer(pTab)).FzName))
  63960 		return 1
  63961 	}
  63962 	return 0
  63963 }
  63964 
  63965 // Handles the following parser reduction:
  63966 //
  63967 //	cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew
  63968 func Xsqlite3AlterRenameColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pOld uintptr, pNew uintptr) {
  63969 	bp := tls.Alloc(112)
  63970 	defer tls.Free(112)
  63971 
  63972 	var db uintptr
  63973 	var pTab uintptr
  63974 	var iCol int32
  63975 	var zOld uintptr
  63976 	var zNew uintptr
  63977 	var zDb uintptr
  63978 	var iSchema int32
  63979 	var bQuote int32
  63980 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  63981 	zOld = uintptr(0)
  63982 	zNew = uintptr(0)
  63983 
  63984 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8)
  63985 	if !!(pTab != 0) {
  63986 		goto __1
  63987 	}
  63988 	goto exit_rename_column
  63989 __1:
  63990 	;
  63991 	if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) {
  63992 		goto __2
  63993 	}
  63994 	goto exit_rename_column
  63995 __2:
  63996 	;
  63997 	if !(SQLITE_OK != isRealTable(tls, pParse, pTab, 0)) {
  63998 		goto __3
  63999 	}
  64000 	goto exit_rename_column
  64001 __3:
  64002 	;
  64003 	iSchema = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  64004 
  64005 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*16)).FzDbSName
  64006 
  64007 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) {
  64008 		goto __4
  64009 	}
  64010 	goto exit_rename_column
  64011 __4:
  64012 	;
  64013 	zOld = Xsqlite3NameFromToken(tls, db, pOld)
  64014 	if !!(zOld != 0) {
  64015 		goto __5
  64016 	}
  64017 	goto exit_rename_column
  64018 __5:
  64019 	;
  64020 	iCol = 0
  64021 __6:
  64022 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  64023 		goto __8
  64024 	}
  64025 	if !(0 == Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FzCnName, zOld)) {
  64026 		goto __9
  64027 	}
  64028 	goto __8
  64029 __9:
  64030 	;
  64031 	goto __7
  64032 __7:
  64033 	iCol++
  64034 	goto __6
  64035 	goto __8
  64036 __8:
  64037 	;
  64038 	if !(iCol == int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  64039 		goto __10
  64040 	}
  64041 	Xsqlite3ErrorMsg(tls, pParse, ts+10563, libc.VaList(bp, pOld))
  64042 	goto exit_rename_column
  64043 __10:
  64044 	;
  64045 	renameTestSchema(tls, pParse, zDb, libc.Bool32(iSchema == 1), ts+1554, 0)
  64046 	renameFixQuotes(tls, pParse, zDb, libc.Bool32(iSchema == 1))
  64047 
  64048 	Xsqlite3MayAbort(tls, pParse)
  64049 	zNew = Xsqlite3NameFromToken(tls, db, pNew)
  64050 	if !!(zNew != 0) {
  64051 		goto __11
  64052 	}
  64053 	goto exit_rename_column
  64054 __11:
  64055 	;
  64056 	bQuote = int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(pNew)).Fz))]) & 0x80
  64057 	Xsqlite3NestedParse(tls, pParse,
  64058 		ts+10584,
  64059 		libc.VaList(bp+8, zDb,
  64060 			zDb, (*Table)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote, libc.Bool32(iSchema == 1),
  64061 			(*Table)(unsafe.Pointer(pTab)).FzName))
  64062 
  64063 	Xsqlite3NestedParse(tls, pParse,
  64064 		ts+10766,
  64065 		libc.VaList(bp+72, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, iCol, zNew, bQuote))
  64066 
  64067 	renameReloadSchema(tls, pParse, iSchema, uint16(INITFLAG_AlterRename))
  64068 	renameTestSchema(tls, pParse, zDb, libc.Bool32(iSchema == 1), ts+9737, 1)
  64069 
  64070 exit_rename_column:
  64071 	Xsqlite3SrcListDelete(tls, db, pSrc)
  64072 	Xsqlite3DbFree(tls, db, zOld)
  64073 	Xsqlite3DbFree(tls, db, zNew)
  64074 	return
  64075 }
  64076 
  64077 // The context of an ALTER TABLE RENAME COLUMN operation that gets passed
  64078 // down into the Walker.
  64079 type RenameCtx = RenameCtx1
  64080 
  64081 // Remember that the parser tree element pPtr was created using
  64082 // the token pToken.
  64083 //
  64084 // In other words, construct a new RenameToken object and add it
  64085 // to the list of RenameToken objects currently being built up
  64086 // in pParse->pRename.
  64087 //
  64088 // The pPtr argument is returned so that this routine can be used
  64089 // with tail recursion in tokenExpr() routine, for a small performance
  64090 // improvement.
  64091 func Xsqlite3RenameTokenMap(tls *libc.TLS, pParse uintptr, pPtr uintptr, pToken uintptr) uintptr {
  64092 	var pNew uintptr
  64093 
  64094 	if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_UNMAP {
  64095 		pNew = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(RenameToken{})))
  64096 		if pNew != 0 {
  64097 			(*RenameToken)(unsafe.Pointer(pNew)).Fp = pPtr
  64098 			(*RenameToken)(unsafe.Pointer(pNew)).Ft = *(*Token)(unsafe.Pointer(pToken))
  64099 			(*RenameToken)(unsafe.Pointer(pNew)).FpNext = (*Parse)(unsafe.Pointer(pParse)).FpRename
  64100 			(*Parse)(unsafe.Pointer(pParse)).FpRename = pNew
  64101 		}
  64102 	}
  64103 
  64104 	return pPtr
  64105 }
  64106 
  64107 // It is assumed that there is already a RenameToken object associated
  64108 // with parse tree element pFrom. This function remaps the associated token
  64109 // to parse tree element pTo.
  64110 func Xsqlite3RenameTokenRemap(tls *libc.TLS, pParse uintptr, pTo uintptr, pFrom uintptr) {
  64111 	var p uintptr
  64112 
  64113 	for p = (*Parse)(unsafe.Pointer(pParse)).FpRename; p != 0; p = (*RenameToken)(unsafe.Pointer(p)).FpNext {
  64114 		if (*RenameToken)(unsafe.Pointer(p)).Fp == pFrom {
  64115 			(*RenameToken)(unsafe.Pointer(p)).Fp = pTo
  64116 			break
  64117 		}
  64118 	}
  64119 }
  64120 
  64121 func renameUnmapExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  64122 	var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  64123 	Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr)
  64124 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc|EP_Subrtn) == U32(0) {
  64125 		Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+44)
  64126 	}
  64127 	return WRC_Continue
  64128 }
  64129 
  64130 func renameWalkWith(tls *libc.TLS, pWalker uintptr, pSelect uintptr) {
  64131 	bp := tls.Alloc(32)
  64132 	defer tls.Free(32)
  64133 
  64134 	var pWith uintptr = (*Select)(unsafe.Pointer(pSelect)).FpWith
  64135 	if pWith != 0 {
  64136 		var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  64137 		var i int32
  64138 		var pCopy uintptr = uintptr(0)
  64139 
  64140 		if (*Select)(unsafe.Pointer((*Cte)(unsafe.Pointer(pWith+12)).FpSelect)).FselFlags&U32(SF_Expanded) == U32(0) {
  64141 			pCopy = Xsqlite3WithDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pWith)
  64142 			pCopy = Xsqlite3WithPush(tls, pParse, pCopy, uint8(1))
  64143 		}
  64144 		for i = 0; i < (*With)(unsafe.Pointer(pWith)).FnCte; i++ {
  64145 			var p uintptr = (*Cte)(unsafe.Pointer(pWith + 12 + uintptr(i)*24)).FpSelect
  64146 
  64147 			libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  64148 			(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  64149 			if pCopy != 0 {
  64150 				Xsqlite3SelectPrep(tls, (*NameContext)(unsafe.Pointer(bp)).FpParse, p, bp)
  64151 			}
  64152 			if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*NameContext)(unsafe.Pointer(bp)).FpParse)).Fdb)).FmallocFailed != 0 {
  64153 				return
  64154 			}
  64155 			Xsqlite3WalkSelect(tls, pWalker, p)
  64156 			Xsqlite3RenameExprlistUnmap(tls, pParse, (*Cte)(unsafe.Pointer(pWith+12+uintptr(i)*24)).FpCols)
  64157 		}
  64158 		if pCopy != 0 && (*Parse)(unsafe.Pointer(pParse)).FpWith == pCopy {
  64159 			(*Parse)(unsafe.Pointer(pParse)).FpWith = (*With)(unsafe.Pointer(pCopy)).FpOuter
  64160 		}
  64161 	}
  64162 }
  64163 
  64164 func unmapColumnIdlistNames(tls *libc.TLS, pParse uintptr, pIdList uintptr) {
  64165 	var ii int32
  64166 
  64167 	for ii = 0; ii < (*IdList)(unsafe.Pointer(pIdList)).FnId; ii++ {
  64168 		Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*IdList_item)(unsafe.Pointer(pIdList+8+uintptr(ii)*8)).FzName)
  64169 	}
  64170 }
  64171 
  64172 func renameUnmapSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  64173 	var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  64174 	var i int32
  64175 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  64176 		return WRC_Abort
  64177 	}
  64178 
  64179 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_View|SF_CopyCte) != 0 {
  64180 		return WRC_Prune
  64181 	}
  64182 	if (*Select)(unsafe.Pointer(p)).FpEList != 0 {
  64183 		var pList uintptr = (*Select)(unsafe.Pointer(p)).FpEList
  64184 		for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
  64185 			if (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FzEName != 0 && int32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*20 + 8 + 4))&0x3>>0) == ENAME_NAME {
  64186 				Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FzEName)
  64187 			}
  64188 		}
  64189 	}
  64190 	if (*Select)(unsafe.Pointer(p)).FpSrc != 0 {
  64191 		var pSrc uintptr = (*Select)(unsafe.Pointer(p)).FpSrc
  64192 		for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ {
  64193 			Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*SrcItem)(unsafe.Pointer(pSrc+8+uintptr(i)*72)).FzName)
  64194 			if int32(*(*uint16)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 36 + 4))&0x400>>10) == 0 {
  64195 				Xsqlite3WalkExpr(tls, pWalker, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 48)))
  64196 			} else {
  64197 				unmapColumnIdlistNames(tls, pParse, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 48)))
  64198 			}
  64199 		}
  64200 	}
  64201 
  64202 	renameWalkWith(tls, pWalker, p)
  64203 	return WRC_Continue
  64204 }
  64205 
  64206 // Remove all nodes that are part of expression pExpr from the rename list.
  64207 func Xsqlite3RenameExprUnmap(tls *libc.TLS, pParse uintptr, pExpr uintptr) {
  64208 	bp := tls.Alloc(28)
  64209 	defer tls.Free(28)
  64210 
  64211 	var eMode U8 = (*Parse)(unsafe.Pointer(pParse)).FeParseMode
  64212 
  64213 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  64214 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  64215 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  64216 		f func(*libc.TLS, uintptr, uintptr) int32
  64217 	}{renameUnmapExprCb}))
  64218 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  64219 		f func(*libc.TLS, uintptr, uintptr) int32
  64220 	}{renameUnmapSelectCb}))
  64221 	(*Parse)(unsafe.Pointer(pParse)).FeParseMode = U8(PARSE_MODE_UNMAP)
  64222 	Xsqlite3WalkExpr(tls, bp, pExpr)
  64223 	(*Parse)(unsafe.Pointer(pParse)).FeParseMode = eMode
  64224 }
  64225 
  64226 // Remove all nodes that are part of expression-list pEList from the
  64227 // rename list.
  64228 func Xsqlite3RenameExprlistUnmap(tls *libc.TLS, pParse uintptr, pEList uintptr) {
  64229 	bp := tls.Alloc(28)
  64230 	defer tls.Free(28)
  64231 
  64232 	if pEList != 0 {
  64233 		var i int32
  64234 
  64235 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  64236 		(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  64237 		(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  64238 			f func(*libc.TLS, uintptr, uintptr) int32
  64239 		}{renameUnmapExprCb}))
  64240 		Xsqlite3WalkExprList(tls, bp, pEList)
  64241 		for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  64242 			if int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*20 + 8 + 4))&0x3>>0) == ENAME_NAME {
  64243 				Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FzEName)
  64244 			}
  64245 		}
  64246 	}
  64247 }
  64248 
  64249 func renameTokenFree(tls *libc.TLS, db uintptr, pToken uintptr) {
  64250 	var pNext uintptr
  64251 	var p uintptr
  64252 	for p = pToken; p != 0; p = pNext {
  64253 		pNext = (*RenameToken)(unsafe.Pointer(p)).FpNext
  64254 		Xsqlite3DbFree(tls, db, p)
  64255 	}
  64256 }
  64257 
  64258 func renameTokenFind(tls *libc.TLS, pParse uintptr, pCtx uintptr, pPtr uintptr) uintptr {
  64259 	var pp uintptr
  64260 	if pPtr == uintptr(0) {
  64261 		return uintptr(0)
  64262 	}
  64263 	for pp = pParse + 276; *(*uintptr)(unsafe.Pointer(pp)) != 0; pp = *(*uintptr)(unsafe.Pointer(pp)) + 12 {
  64264 		if (*RenameToken)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).Fp == pPtr {
  64265 			var pToken uintptr = *(*uintptr)(unsafe.Pointer(pp))
  64266 			if pCtx != 0 {
  64267 				*(*uintptr)(unsafe.Pointer(pp)) = (*RenameToken)(unsafe.Pointer(pToken)).FpNext
  64268 				(*RenameToken)(unsafe.Pointer(pToken)).FpNext = (*RenameCtx1)(unsafe.Pointer(pCtx)).FpList
  64269 				(*RenameCtx1)(unsafe.Pointer(pCtx)).FpList = pToken
  64270 				(*RenameCtx1)(unsafe.Pointer(pCtx)).FnList++
  64271 			}
  64272 			return pToken
  64273 		}
  64274 	}
  64275 	return uintptr(0)
  64276 }
  64277 
  64278 func renameColumnSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  64279 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_View|SF_CopyCte) != 0 {
  64280 		return WRC_Prune
  64281 	}
  64282 	renameWalkWith(tls, pWalker, p)
  64283 	return WRC_Continue
  64284 }
  64285 
  64286 func renameColumnExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  64287 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  64288 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER &&
  64289 		int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*RenameCtx)(unsafe.Pointer(p)).FiCol &&
  64290 		(*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(pWalker)).FpParse)).FpTriggerTab == (*RenameCtx)(unsafe.Pointer(p)).FpTab {
  64291 		renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr)
  64292 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN &&
  64293 		int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*RenameCtx)(unsafe.Pointer(p)).FiCol &&
  64294 		(*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc|EP_Subrtn) == U32(0) &&
  64295 		(*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 44)) {
  64296 		renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr)
  64297 	}
  64298 	return WRC_Continue
  64299 }
  64300 
  64301 func renameColumnTokenNext(tls *libc.TLS, pCtx uintptr) uintptr {
  64302 	var pBest uintptr = (*RenameCtx)(unsafe.Pointer(pCtx)).FpList
  64303 	var pToken uintptr
  64304 	var pp uintptr
  64305 
  64306 	for pToken = (*RenameToken)(unsafe.Pointer(pBest)).FpNext; pToken != 0; pToken = (*RenameToken)(unsafe.Pointer(pToken)).FpNext {
  64307 		if (*RenameToken)(unsafe.Pointer(pToken)).Ft.Fz > (*RenameToken)(unsafe.Pointer(pBest)).Ft.Fz {
  64308 			pBest = pToken
  64309 		}
  64310 	}
  64311 	for pp = pCtx; *(*uintptr)(unsafe.Pointer(pp)) != pBest; pp = *(*uintptr)(unsafe.Pointer(pp)) + 12 {
  64312 	}
  64313 	*(*uintptr)(unsafe.Pointer(pp)) = (*RenameToken)(unsafe.Pointer(pBest)).FpNext
  64314 
  64315 	return pBest
  64316 }
  64317 
  64318 func renameColumnParseError(tls *libc.TLS, pCtx uintptr, zWhen uintptr, pType uintptr, pObject uintptr, pParse uintptr) {
  64319 	bp := tls.Alloc(40)
  64320 	defer tls.Free(40)
  64321 
  64322 	var zT uintptr = Xsqlite3_value_text(tls, pType)
  64323 	var zN uintptr = Xsqlite3_value_text(tls, pObject)
  64324 	var zErr uintptr
  64325 
  64326 	zErr = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+10897,
  64327 		libc.VaList(bp, zT, zN, func() uintptr {
  64328 			if *(*uint8)(unsafe.Pointer(zWhen)) != 0 {
  64329 				return ts + 10920
  64330 			}
  64331 			return ts + 1554
  64332 		}(), zWhen,
  64333 			(*Parse)(unsafe.Pointer(pParse)).FzErrMsg))
  64334 	Xsqlite3_result_error(tls, pCtx, zErr, -1)
  64335 	Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zErr)
  64336 }
  64337 
  64338 func renameColumnElistNames(tls *libc.TLS, pParse uintptr, pCtx uintptr, pEList uintptr, zOld uintptr) {
  64339 	if pEList != 0 {
  64340 		var i int32
  64341 		for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  64342 			var zName uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FzEName
  64343 			if int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*20 + 8 + 4))&0x3>>0) == ENAME_NAME &&
  64344 				zName != uintptr(0) &&
  64345 				0 == Xsqlite3_stricmp(tls, zName, zOld) {
  64346 				renameTokenFind(tls, pParse, pCtx, zName)
  64347 			}
  64348 		}
  64349 	}
  64350 }
  64351 
  64352 func renameColumnIdlistNames(tls *libc.TLS, pParse uintptr, pCtx uintptr, pIdList uintptr, zOld uintptr) {
  64353 	if pIdList != 0 {
  64354 		var i int32
  64355 		for i = 0; i < (*IdList)(unsafe.Pointer(pIdList)).FnId; i++ {
  64356 			var zName uintptr = (*IdList_item)(unsafe.Pointer(pIdList + 8 + uintptr(i)*8)).FzName
  64357 			if 0 == Xsqlite3_stricmp(tls, zName, zOld) {
  64358 				renameTokenFind(tls, pParse, pCtx, zName)
  64359 			}
  64360 		}
  64361 	}
  64362 }
  64363 
  64364 func renameParseSql(tls *libc.TLS, p uintptr, zDb uintptr, db uintptr, zSql uintptr, bTemp int32) int32 {
  64365 	var rc int32
  64366 
  64367 	Xsqlite3ParseObjectInit(tls, p, db)
  64368 	if zSql == uintptr(0) {
  64369 		return SQLITE_NOMEM
  64370 	}
  64371 	if Xsqlite3_strnicmp(tls, zSql, ts+10922, 7) != 0 {
  64372 		return Xsqlite3CorruptError(tls, 113516)
  64373 	}
  64374 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = func() uint8 {
  64375 		if bTemp != 0 {
  64376 			return uint8(1)
  64377 		}
  64378 		return uint8(Xsqlite3FindDbName(tls, db, zDb))
  64379 	}()
  64380 	(*Parse)(unsafe.Pointer(p)).FeParseMode = U8(PARSE_MODE_RENAME)
  64381 	(*Parse)(unsafe.Pointer(p)).Fdb = db
  64382 	(*Parse)(unsafe.Pointer(p)).FnQueryLoop = U32(1)
  64383 	rc = Xsqlite3RunParser(tls, p, zSql)
  64384 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  64385 		rc = SQLITE_NOMEM
  64386 	}
  64387 	if rc == SQLITE_OK &&
  64388 		((*Parse)(unsafe.Pointer(p)).FpNewTable == uintptr(0) && (*Parse)(unsafe.Pointer(p)).FpNewIndex == uintptr(0) && (*Parse)(unsafe.Pointer(p)).FpNewTrigger == uintptr(0)) {
  64389 		rc = Xsqlite3CorruptError(tls, 113527)
  64390 	}
  64391 
  64392 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(0)
  64393 	return rc
  64394 }
  64395 
  64396 func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, zNew uintptr, bQuote int32) int32 {
  64397 	bp := tls.Alloc(24)
  64398 	defer tls.Free(24)
  64399 
  64400 	var nNew I64 = I64(Xsqlite3Strlen30(tls, zNew))
  64401 	var nSql I64 = I64(Xsqlite3Strlen30(tls, zSql))
  64402 	var db uintptr = Xsqlite3_context_db_handle(tls, pCtx)
  64403 	var rc int32 = SQLITE_OK
  64404 	var zQuot uintptr = uintptr(0)
  64405 	var zOut uintptr
  64406 	var nQuot I64 = int64(0)
  64407 	var zBuf1 uintptr = uintptr(0)
  64408 	var zBuf2 uintptr = uintptr(0)
  64409 
  64410 	if zNew != 0 {
  64411 		zQuot = Xsqlite3MPrintf(tls, db, ts+10930, libc.VaList(bp, zNew))
  64412 		if zQuot == uintptr(0) {
  64413 			return SQLITE_NOMEM
  64414 		} else {
  64415 			nQuot = I64(Xsqlite3Strlen30(tls, zQuot) - 1)
  64416 		}
  64417 
  64418 		zOut = Xsqlite3DbMallocZero(tls, db, uint64(nSql+I64((*RenameCtx)(unsafe.Pointer(pRename)).FnList)*nQuot+int64(1)))
  64419 	} else {
  64420 		zOut = Xsqlite3DbMallocZero(tls, db, uint64((nSql*int64(2)+int64(1))*int64(3)))
  64421 		if zOut != 0 {
  64422 			zBuf1 = zOut + uintptr(nSql*int64(2)+int64(1))
  64423 			zBuf2 = zOut + uintptr(nSql*int64(4)+int64(2))
  64424 		}
  64425 	}
  64426 
  64427 	if zOut != 0 {
  64428 		var nOut int32 = int32(nSql)
  64429 		libc.Xmemcpy(tls, zOut, zSql, uint32(nSql))
  64430 		for (*RenameCtx)(unsafe.Pointer(pRename)).FpList != 0 {
  64431 			var iOff int32
  64432 			var nReplace U32
  64433 			var zReplace uintptr
  64434 			var pBest uintptr = renameColumnTokenNext(tls, pRename)
  64435 
  64436 			if zNew != 0 {
  64437 				if bQuote == 0 && Xsqlite3IsIdChar(tls, *(*uint8)(unsafe.Pointer((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fz))) != 0 {
  64438 					nReplace = U32(nNew)
  64439 					zReplace = zNew
  64440 				} else {
  64441 					nReplace = U32(nQuot)
  64442 					zReplace = zQuot
  64443 					if int32(*(*uint8)(unsafe.Pointer((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == '"' {
  64444 						nReplace++
  64445 					}
  64446 				}
  64447 			} else {
  64448 				libc.Xmemcpy(tls, zBuf1, (*RenameToken)(unsafe.Pointer(pBest)).Ft.Fz, (*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn)
  64449 				*(*uint8)(unsafe.Pointer(zBuf1 + uintptr((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn))) = uint8(0)
  64450 				Xsqlite3Dequote(tls, zBuf1)
  64451 				Xsqlite3_snprintf(tls, int32(nSql*int64(2)), zBuf2, ts+10936, libc.VaList(bp+8, zBuf1,
  64452 					func() uintptr {
  64453 						if int32(*(*uint8)(unsafe.Pointer((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fz + uintptr((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn)))) == '\'' {
  64454 							return ts + 10920
  64455 						}
  64456 						return ts + 1554
  64457 					}()))
  64458 				zReplace = zBuf2
  64459 				nReplace = U32(Xsqlite3Strlen30(tls, zReplace))
  64460 			}
  64461 
  64462 			iOff = (int32((*RenameToken)(unsafe.Pointer(pBest)).Ft.Fz) - int32(zSql)) / 1
  64463 			if (*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn != nReplace {
  64464 				libc.Xmemmove(tls, zOut+uintptr(U32(iOff)+nReplace), zOut+uintptr(uint32(iOff)+(*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn),
  64465 					uint32(nOut)-(uint32(iOff)+(*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn))
  64466 				nOut = int32(U32(nOut) + (nReplace - (*RenameToken)(unsafe.Pointer(pBest)).Ft.Fn))
  64467 				*(*uint8)(unsafe.Pointer(zOut + uintptr(nOut))) = uint8(0)
  64468 			}
  64469 			libc.Xmemcpy(tls, zOut+uintptr(iOff), zReplace, nReplace)
  64470 			Xsqlite3DbFree(tls, db, pBest)
  64471 		}
  64472 
  64473 		Xsqlite3_result_text(tls, pCtx, zOut, -1, libc.UintptrFromInt32(-1))
  64474 		Xsqlite3DbFree(tls, db, zOut)
  64475 	} else {
  64476 		rc = SQLITE_NOMEM
  64477 	}
  64478 
  64479 	Xsqlite3_free(tls, zQuot)
  64480 	return rc
  64481 }
  64482 
  64483 func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 {
  64484 	bp := tls.Alloc(32)
  64485 	defer tls.Free(32)
  64486 
  64487 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  64488 	var pNew uintptr = (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger
  64489 	var pStep uintptr
  64490 
  64491 	var rc int32 = SQLITE_OK
  64492 
  64493 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  64494 	(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  64495 
  64496 	(*Parse)(unsafe.Pointer(pParse)).FpTriggerTab = Xsqlite3FindTable(tls, db, (*Trigger)(unsafe.Pointer(pNew)).Ftable,
  64497 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(Xsqlite3SchemaToIndex(tls, db, (*Trigger)(unsafe.Pointer(pNew)).FpTabSchema))*16)).FzDbSName)
  64498 	(*Parse)(unsafe.Pointer(pParse)).FeTriggerOp = (*Trigger)(unsafe.Pointer(pNew)).Fop
  64499 
  64500 	if (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 {
  64501 		rc = Xsqlite3ViewGetColumnNames(tls, pParse, (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab)
  64502 	}
  64503 
  64504 	if rc == SQLITE_OK && (*Trigger)(unsafe.Pointer(pNew)).FpWhen != 0 {
  64505 		rc = Xsqlite3ResolveExprNames(tls, bp, (*Trigger)(unsafe.Pointer(pNew)).FpWhen)
  64506 	}
  64507 
  64508 	for pStep = (*Trigger)(unsafe.Pointer(pNew)).Fstep_list; rc == SQLITE_OK && pStep != 0; pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext {
  64509 		if (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect != 0 {
  64510 			Xsqlite3SelectPrep(tls, pParse, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, bp)
  64511 			if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  64512 				rc = (*Parse)(unsafe.Pointer(pParse)).Frc
  64513 			}
  64514 		}
  64515 		if rc == SQLITE_OK && (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0 {
  64516 			var pSrc uintptr = Xsqlite3TriggerStepSrc(tls, pParse, pStep)
  64517 			if pSrc != 0 {
  64518 				var pSel uintptr = Xsqlite3SelectNew(tls,
  64519 					pParse, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList, pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0))
  64520 				if pSel == uintptr(0) {
  64521 					(*TriggerStep)(unsafe.Pointer(pStep)).FpExprList = uintptr(0)
  64522 					pSrc = uintptr(0)
  64523 					rc = SQLITE_NOMEM
  64524 				} else {
  64525 					Xsqlite3SelectPrep(tls, pParse, pSel, uintptr(0))
  64526 					if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  64527 						rc = SQLITE_ERROR
  64528 					} else {
  64529 						rc = SQLITE_OK
  64530 					}
  64531 
  64532 					if (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList != 0 {
  64533 						(*Select)(unsafe.Pointer(pSel)).FpEList = uintptr(0)
  64534 					}
  64535 					(*Select)(unsafe.Pointer(pSel)).FpSrc = uintptr(0)
  64536 					Xsqlite3SelectDelete(tls, db, pSel)
  64537 				}
  64538 				if (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom != 0 {
  64539 					var i int32
  64540 					for i = 0; i < (*SrcList)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpFrom)).FnSrc && rc == SQLITE_OK; i++ {
  64541 						var p uintptr = (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom + 8 + uintptr(i)*72
  64542 						if (*SrcItem)(unsafe.Pointer(p)).FpSelect != 0 {
  64543 							Xsqlite3SelectPrep(tls, pParse, (*SrcItem)(unsafe.Pointer(p)).FpSelect, uintptr(0))
  64544 						}
  64545 					}
  64546 				}
  64547 
  64548 				if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  64549 					rc = SQLITE_NOMEM
  64550 				}
  64551 				(*NameContext)(unsafe.Pointer(bp)).FpSrcList = pSrc
  64552 				if rc == SQLITE_OK && (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0 {
  64553 					rc = Xsqlite3ResolveExprNames(tls, bp, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere)
  64554 				}
  64555 				if rc == SQLITE_OK {
  64556 					rc = Xsqlite3ResolveExprListNames(tls, bp, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList)
  64557 				}
  64558 
  64559 				if (*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 && rc == SQLITE_OK {
  64560 					var pUpsert uintptr = (*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert
  64561 					(*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pSrc
  64562 					*(*uintptr)(unsafe.Pointer(bp + 8)) = pUpsert
  64563 					(*NameContext)(unsafe.Pointer(bp)).FncFlags = NC_UUpsert
  64564 					rc = Xsqlite3ResolveExprListNames(tls, bp, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget)
  64565 					if rc == SQLITE_OK {
  64566 						var pUpsertSet uintptr = (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet
  64567 						rc = Xsqlite3ResolveExprListNames(tls, bp, pUpsertSet)
  64568 					}
  64569 					if rc == SQLITE_OK {
  64570 						rc = Xsqlite3ResolveExprNames(tls, bp, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere)
  64571 					}
  64572 					if rc == SQLITE_OK {
  64573 						rc = Xsqlite3ResolveExprNames(tls, bp, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere)
  64574 					}
  64575 					(*NameContext)(unsafe.Pointer(bp)).FncFlags = 0
  64576 				}
  64577 				(*NameContext)(unsafe.Pointer(bp)).FpSrcList = uintptr(0)
  64578 				Xsqlite3SrcListDelete(tls, db, pSrc)
  64579 			} else {
  64580 				rc = SQLITE_NOMEM
  64581 			}
  64582 		}
  64583 	}
  64584 	return rc
  64585 }
  64586 
  64587 func renameWalkTrigger(tls *libc.TLS, pWalker uintptr, pTrigger uintptr) {
  64588 	var pStep uintptr
  64589 
  64590 	Xsqlite3WalkExpr(tls, pWalker, (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen)
  64591 
  64592 	for pStep = (*Trigger)(unsafe.Pointer(pTrigger)).Fstep_list; pStep != 0; pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext {
  64593 		Xsqlite3WalkSelect(tls, pWalker, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect)
  64594 		Xsqlite3WalkExpr(tls, pWalker, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere)
  64595 		Xsqlite3WalkExprList(tls, pWalker, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList)
  64596 		if (*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 {
  64597 			var pUpsert uintptr = (*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert
  64598 			Xsqlite3WalkExprList(tls, pWalker, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget)
  64599 			Xsqlite3WalkExprList(tls, pWalker, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet)
  64600 			Xsqlite3WalkExpr(tls, pWalker, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere)
  64601 			Xsqlite3WalkExpr(tls, pWalker, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere)
  64602 		}
  64603 		if (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom != 0 {
  64604 			var i int32
  64605 			for i = 0; i < (*SrcList)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpFrom)).FnSrc; i++ {
  64606 				Xsqlite3WalkSelect(tls, pWalker, (*SrcItem)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpFrom+8+uintptr(i)*72)).FpSelect)
  64607 			}
  64608 		}
  64609 	}
  64610 }
  64611 
  64612 func renameParseCleanup(tls *libc.TLS, pParse uintptr) {
  64613 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  64614 	var pIdx uintptr
  64615 	if (*Parse)(unsafe.Pointer(pParse)).FpVdbe != 0 {
  64616 		Xsqlite3VdbeFinalize(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe)
  64617 	}
  64618 	Xsqlite3DeleteTable(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTable)
  64619 	for libc.AssignUintptr(&pIdx, (*Parse)(unsafe.Pointer(pParse)).FpNewIndex) != uintptr(0) {
  64620 		(*Parse)(unsafe.Pointer(pParse)).FpNewIndex = (*Index)(unsafe.Pointer(pIdx)).FpNext
  64621 		Xsqlite3FreeIndex(tls, db, pIdx)
  64622 	}
  64623 	Xsqlite3DeleteTrigger(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger)
  64624 	Xsqlite3DbFree(tls, db, (*Parse)(unsafe.Pointer(pParse)).FzErrMsg)
  64625 	renameTokenFree(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpRename)
  64626 	Xsqlite3ParseObjectReset(tls, pParse)
  64627 }
  64628 
  64629 func renameColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  64630 	bp := tls.Alloc(328)
  64631 	defer tls.Free(328)
  64632 
  64633 	var db uintptr
  64634 
  64635 	var zSql uintptr
  64636 	var zDb uintptr
  64637 	var zTable uintptr
  64638 	var iCol int32
  64639 	var zNew uintptr
  64640 	var bQuote int32
  64641 	var bTemp int32
  64642 	var zOld uintptr
  64643 	var rc int32
  64644 
  64645 	var pIdx uintptr
  64646 	var i int32
  64647 	var pTab uintptr
  64648 	var xAuth Sqlite3_xauth
  64649 	var pSelect uintptr
  64650 	var pExpr uintptr
  64651 
  64652 	var bFKOnly int32
  64653 	var pFKey uintptr
  64654 	var pUpsertSet uintptr
  64655 	var pTarget uintptr
  64656 
  64657 	var pStep uintptr
  64658 	db = Xsqlite3_context_db_handle(tls, context)
  64659 	zSql = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  64660 	zDb = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4)))
  64661 	zTable = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*4)))
  64662 	iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 5*4)))
  64663 	zNew = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 6*4)))
  64664 	bQuote = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 7*4)))
  64665 	bTemp = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 8*4)))
  64666 	xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  64667 
  64668 	_ = NotUsed
  64669 	if !(zSql == uintptr(0)) {
  64670 		goto __1
  64671 	}
  64672 	return
  64673 __1:
  64674 	;
  64675 	if !(zTable == uintptr(0)) {
  64676 		goto __2
  64677 	}
  64678 	return
  64679 __2:
  64680 	;
  64681 	if !(zNew == uintptr(0)) {
  64682 		goto __3
  64683 	}
  64684 	return
  64685 __3:
  64686 	;
  64687 	if !(iCol < 0) {
  64688 		goto __4
  64689 	}
  64690 	return
  64691 __4:
  64692 	;
  64693 	Xsqlite3BtreeEnterAll(tls, db)
  64694 	pTab = Xsqlite3FindTable(tls, db, zTable, zDb)
  64695 	if !(pTab == uintptr(0) || iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  64696 		goto __5
  64697 	}
  64698 	Xsqlite3BtreeLeaveAll(tls, db)
  64699 	return
  64700 __5:
  64701 	;
  64702 	zOld = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16)).FzCnName
  64703 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(RenameCtx{})))
  64704 	(*RenameCtx)(unsafe.Pointer(bp)).FiCol = func() int32 {
  64705 		if iCol == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  64706 			return -1
  64707 		}
  64708 		return iCol
  64709 	}()
  64710 
  64711 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  64712 	rc = renameParseSql(tls, bp+20, zDb, db, zSql, bTemp)
  64713 
  64714 	libc.Xmemset(tls, bp+300, 0, uint32(unsafe.Sizeof(Walker{})))
  64715 	(*Walker)(unsafe.Pointer(bp + 300)).FpParse = bp + 20
  64716 	(*Walker)(unsafe.Pointer(bp + 300)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  64717 		f func(*libc.TLS, uintptr, uintptr) int32
  64718 	}{renameColumnExprCb}))
  64719 	(*Walker)(unsafe.Pointer(bp + 300)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  64720 		f func(*libc.TLS, uintptr, uintptr) int32
  64721 	}{renameColumnSelectCb}))
  64722 	*(*uintptr)(unsafe.Pointer(bp + 300 + 24)) = bp
  64723 
  64724 	(*RenameCtx)(unsafe.Pointer(bp)).FpTab = pTab
  64725 	if !(rc != SQLITE_OK) {
  64726 		goto __6
  64727 	}
  64728 	goto renameColumnFunc_done
  64729 __6:
  64730 	;
  64731 	if !((*Parse)(unsafe.Pointer(bp+20)).FpNewTable != 0) {
  64732 		goto __7
  64733 	}
  64734 	if !(int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FeTabType) == TABTYP_VIEW) {
  64735 		goto __9
  64736 	}
  64737 	pSelect = *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable + 44))
  64738 	*(*U32)(unsafe.Pointer(pSelect + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_View))
  64739 	(*Parse)(unsafe.Pointer(bp + 20)).Frc = SQLITE_OK
  64740 	Xsqlite3SelectPrep(tls, bp+20, pSelect, uintptr(0))
  64741 	rc = func() int32 {
  64742 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  64743 			return SQLITE_NOMEM
  64744 		}
  64745 		return (*Parse)(unsafe.Pointer(bp + 20)).Frc
  64746 	}()
  64747 	if !(rc == SQLITE_OK) {
  64748 		goto __11
  64749 	}
  64750 	Xsqlite3WalkSelect(tls, bp+300, pSelect)
  64751 __11:
  64752 	;
  64753 	if !(rc != SQLITE_OK) {
  64754 		goto __12
  64755 	}
  64756 	goto renameColumnFunc_done
  64757 __12:
  64758 	;
  64759 	goto __10
  64760 __9:
  64761 	if !(int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FeTabType) == TABTYP_NORM) {
  64762 		goto __13
  64763 	}
  64764 
  64765 	bFKOnly = Xsqlite3_stricmp(tls, zTable, (*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FzName)
  64766 	(*RenameCtx)(unsafe.Pointer(bp)).FpTab = (*Parse)(unsafe.Pointer(bp + 20)).FpNewTable
  64767 	if !(bFKOnly == 0) {
  64768 		goto __14
  64769 	}
  64770 	if !(iCol < int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FnCol)) {
  64771 		goto __15
  64772 	}
  64773 	renameTokenFind(tls,
  64774 		bp+20, bp, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FaCol+uintptr(iCol)*16)).FzCnName)
  64775 __15:
  64776 	;
  64777 	if !((*RenameCtx)(unsafe.Pointer(bp)).FiCol < 0) {
  64778 		goto __16
  64779 	}
  64780 	renameTokenFind(tls, bp+20, bp, (*Parse)(unsafe.Pointer(bp+20)).FpNewTable+32)
  64781 __16:
  64782 	;
  64783 	Xsqlite3WalkExprList(tls, bp+300, (*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FpCheck)
  64784 	pIdx = (*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp + 20)).FpNewTable)).FpIndex
  64785 __17:
  64786 	if !(pIdx != 0) {
  64787 		goto __19
  64788 	}
  64789 	Xsqlite3WalkExprList(tls, bp+300, (*Index)(unsafe.Pointer(pIdx)).FaColExpr)
  64790 	goto __18
  64791 __18:
  64792 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  64793 	goto __17
  64794 	goto __19
  64795 __19:
  64796 	;
  64797 	pIdx = (*Parse)(unsafe.Pointer(bp + 20)).FpNewIndex
  64798 __20:
  64799 	if !(pIdx != 0) {
  64800 		goto __22
  64801 	}
  64802 	Xsqlite3WalkExprList(tls, bp+300, (*Index)(unsafe.Pointer(pIdx)).FaColExpr)
  64803 	goto __21
  64804 __21:
  64805 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  64806 	goto __20
  64807 	goto __22
  64808 __22:
  64809 	;
  64810 	i = 0
  64811 __23:
  64812 	if !(i < int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FnCol)) {
  64813 		goto __25
  64814 	}
  64815 	pExpr = Xsqlite3ColumnExpr(tls, (*Parse)(unsafe.Pointer(bp+20)).FpNewTable,
  64816 		(*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable)).FaCol+uintptr(i)*16)
  64817 	Xsqlite3WalkExpr(tls, bp+300, pExpr)
  64818 	goto __24
  64819 __24:
  64820 	i++
  64821 	goto __23
  64822 	goto __25
  64823 __25:
  64824 	;
  64825 __14:
  64826 	;
  64827 	pFKey = *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTable + 44 + 4))
  64828 __26:
  64829 	if !(pFKey != 0) {
  64830 		goto __28
  64831 	}
  64832 	i = 0
  64833 __29:
  64834 	if !(i < (*FKey)(unsafe.Pointer(pFKey)).FnCol) {
  64835 		goto __31
  64836 	}
  64837 	if !(bFKOnly == 0 && (*sColMap)(unsafe.Pointer(pFKey+36+uintptr(i)*8)).FiFrom == iCol) {
  64838 		goto __32
  64839 	}
  64840 	renameTokenFind(tls, bp+20, bp, pFKey+36+uintptr(i)*8)
  64841 __32:
  64842 	;
  64843 	if !(0 == Xsqlite3_stricmp(tls, (*FKey)(unsafe.Pointer(pFKey)).FzTo, zTable) &&
  64844 		0 == Xsqlite3_stricmp(tls, (*sColMap)(unsafe.Pointer(pFKey+36+uintptr(i)*8)).FzCol, zOld)) {
  64845 		goto __33
  64846 	}
  64847 	renameTokenFind(tls, bp+20, bp, (*sColMap)(unsafe.Pointer(pFKey+36+uintptr(i)*8)).FzCol)
  64848 __33:
  64849 	;
  64850 	goto __30
  64851 __30:
  64852 	i++
  64853 	goto __29
  64854 	goto __31
  64855 __31:
  64856 	;
  64857 	goto __27
  64858 __27:
  64859 	pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom
  64860 	goto __26
  64861 	goto __28
  64862 __28:
  64863 	;
  64864 __13:
  64865 	;
  64866 __10:
  64867 	;
  64868 	goto __8
  64869 __7:
  64870 	if !((*Parse)(unsafe.Pointer(bp+20)).FpNewIndex != 0) {
  64871 		goto __34
  64872 	}
  64873 	Xsqlite3WalkExprList(tls, bp+300, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewIndex)).FaColExpr)
  64874 	Xsqlite3WalkExpr(tls, bp+300, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewIndex)).FpPartIdxWhere)
  64875 	goto __35
  64876 __34:
  64877 	rc = renameResolveTrigger(tls, bp+20)
  64878 	if !(rc != SQLITE_OK) {
  64879 		goto __36
  64880 	}
  64881 	goto renameColumnFunc_done
  64882 __36:
  64883 	;
  64884 	pStep = (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp + 20)).FpNewTrigger)).Fstep_list
  64885 __37:
  64886 	if !(pStep != 0) {
  64887 		goto __39
  64888 	}
  64889 	if !((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) {
  64890 		goto __40
  64891 	}
  64892 	pTarget = Xsqlite3LocateTable(tls, bp+20, uint32(0), (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zDb)
  64893 	if !(pTarget == pTab) {
  64894 		goto __41
  64895 	}
  64896 	if !((*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0) {
  64897 		goto __42
  64898 	}
  64899 	pUpsertSet = (*Upsert)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert)).FpUpsertSet
  64900 	renameColumnElistNames(tls, bp+20, bp, pUpsertSet, zOld)
  64901 __42:
  64902 	;
  64903 	renameColumnIdlistNames(tls, bp+20, bp, (*TriggerStep)(unsafe.Pointer(pStep)).FpIdList, zOld)
  64904 	renameColumnElistNames(tls, bp+20, bp, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList, zOld)
  64905 __41:
  64906 	;
  64907 __40:
  64908 	;
  64909 	goto __38
  64910 __38:
  64911 	pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext
  64912 	goto __37
  64913 	goto __39
  64914 __39:
  64915 	;
  64916 	if !((*Parse)(unsafe.Pointer(bp+20)).FpTriggerTab == pTab) {
  64917 		goto __43
  64918 	}
  64919 	renameColumnIdlistNames(tls, bp+20, bp, (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+20)).FpNewTrigger)).FpColumns, zOld)
  64920 __43:
  64921 	;
  64922 	renameWalkTrigger(tls, bp+300, (*Parse)(unsafe.Pointer(bp+20)).FpNewTrigger)
  64923 __35:
  64924 	;
  64925 __8:
  64926 	;
  64927 	rc = renameEditSql(tls, context, bp, zSql, zNew, bQuote)
  64928 
  64929 renameColumnFunc_done:
  64930 	if !(rc != SQLITE_OK) {
  64931 		goto __44
  64932 	}
  64933 	if !(rc == SQLITE_ERROR && Xsqlite3WritableSchema(tls, db) != 0) {
  64934 		goto __45
  64935 	}
  64936 	Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv)))
  64937 	goto __46
  64938 __45:
  64939 	if !((*Parse)(unsafe.Pointer(bp+20)).FzErrMsg != 0) {
  64940 		goto __47
  64941 	}
  64942 	renameColumnParseError(tls, context, ts+1554, *(*uintptr)(unsafe.Pointer(argv + 1*4)), *(*uintptr)(unsafe.Pointer(argv + 2*4)), bp+20)
  64943 	goto __48
  64944 __47:
  64945 	Xsqlite3_result_error_code(tls, context, rc)
  64946 __48:
  64947 	;
  64948 __46:
  64949 	;
  64950 __44:
  64951 	;
  64952 	renameParseCleanup(tls, bp+20)
  64953 	renameTokenFree(tls, db, (*RenameCtx)(unsafe.Pointer(bp)).FpList)
  64954 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  64955 	Xsqlite3BtreeLeaveAll(tls, db)
  64956 }
  64957 
  64958 func renameTableExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  64959 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  64960 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN &&
  64961 		(*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc|EP_Subrtn) == U32(0) &&
  64962 		(*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 44)) {
  64963 		renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr+44)
  64964 	}
  64965 	return WRC_Continue
  64966 }
  64967 
  64968 func renameTableSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 {
  64969 	var i int32
  64970 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  64971 	var pSrc uintptr = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  64972 	if (*Select)(unsafe.Pointer(pSelect)).FselFlags&U32(SF_View|SF_CopyCte) != 0 {
  64973 		return WRC_Prune
  64974 	}
  64975 	if pSrc == uintptr(0) {
  64976 		return WRC_Abort
  64977 	}
  64978 	for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ {
  64979 		var pItem uintptr = pSrc + 8 + uintptr(i)*72
  64980 		if (*SrcItem)(unsafe.Pointer(pItem)).FpTab == (*RenameCtx)(unsafe.Pointer(p)).FpTab {
  64981 			renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, (*SrcItem)(unsafe.Pointer(pItem)).FzName)
  64982 		}
  64983 	}
  64984 	renameWalkWith(tls, pWalker, pSelect)
  64985 
  64986 	return WRC_Continue
  64987 }
  64988 
  64989 func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  64990 	bp := tls.Alloc(360)
  64991 	defer tls.Free(360)
  64992 
  64993 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  64994 	var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  64995 	var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4)))
  64996 	var zOld uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*4)))
  64997 	var zNew uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*4)))
  64998 	var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 6*4)))
  64999 	_ = NotUsed
  65000 
  65001 	if zInput != 0 && zOld != 0 && zNew != 0 {
  65002 		var rc int32
  65003 		var bQuote int32 = 1
  65004 
  65005 		var xAuth Sqlite3_xauth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  65006 		(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  65007 
  65008 		Xsqlite3BtreeEnterAll(tls, db)
  65009 
  65010 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(RenameCtx{})))
  65011 		(*RenameCtx)(unsafe.Pointer(bp)).FpTab = Xsqlite3FindTable(tls, db, zOld, zDb)
  65012 		libc.Xmemset(tls, bp+20, 0, uint32(unsafe.Sizeof(Walker{})))
  65013 		(*Walker)(unsafe.Pointer(bp + 20)).FpParse = bp + 48
  65014 		(*Walker)(unsafe.Pointer(bp + 20)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  65015 			f func(*libc.TLS, uintptr, uintptr) int32
  65016 		}{renameTableExprCb}))
  65017 		(*Walker)(unsafe.Pointer(bp + 20)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  65018 			f func(*libc.TLS, uintptr, uintptr) int32
  65019 		}{renameTableSelectCb}))
  65020 		*(*uintptr)(unsafe.Pointer(bp + 20 + 24)) = bp
  65021 
  65022 		rc = renameParseSql(tls, bp+48, zDb, db, zInput, bTemp)
  65023 
  65024 		if rc == SQLITE_OK {
  65025 			var isLegacy int32 = int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(SQLITE_LegacyAlter))
  65026 			if (*Parse)(unsafe.Pointer(bp+48)).FpNewTable != 0 {
  65027 				var pTab uintptr = (*Parse)(unsafe.Pointer(bp + 48)).FpNewTable
  65028 
  65029 				if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW {
  65030 					if isLegacy == 0 {
  65031 						var pSelect uintptr = *(*uintptr)(unsafe.Pointer(pTab + 44))
  65032 
  65033 						libc.Xmemset(tls, bp+328, 0, uint32(unsafe.Sizeof(NameContext{})))
  65034 						(*NameContext)(unsafe.Pointer(bp + 328)).FpParse = bp + 48
  65035 
  65036 						*(*U32)(unsafe.Pointer(pSelect + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_View))
  65037 						Xsqlite3SelectPrep(tls, bp+48, *(*uintptr)(unsafe.Pointer(pTab + 44)), bp+328)
  65038 						if (*Parse)(unsafe.Pointer(bp+48)).FnErr != 0 {
  65039 							rc = (*Parse)(unsafe.Pointer(bp + 48)).Frc
  65040 						} else {
  65041 							Xsqlite3WalkSelect(tls, bp+20, *(*uintptr)(unsafe.Pointer(pTab + 44)))
  65042 						}
  65043 					}
  65044 				} else {
  65045 					if (isLegacy == 0 || (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0) &&
  65046 						!(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  65047 						var pFKey uintptr
  65048 
  65049 						for pFKey = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom {
  65050 							if Xsqlite3_stricmp(tls, (*FKey)(unsafe.Pointer(pFKey)).FzTo, zOld) == 0 {
  65051 								renameTokenFind(tls, bp+48, bp, (*FKey)(unsafe.Pointer(pFKey)).FzTo)
  65052 							}
  65053 						}
  65054 					}
  65055 
  65056 					if Xsqlite3_stricmp(tls, zOld, (*Table)(unsafe.Pointer(pTab)).FzName) == 0 {
  65057 						(*RenameCtx)(unsafe.Pointer(bp)).FpTab = pTab
  65058 						if isLegacy == 0 {
  65059 							Xsqlite3WalkExprList(tls, bp+20, (*Table)(unsafe.Pointer(pTab)).FpCheck)
  65060 						}
  65061 						renameTokenFind(tls, bp+48, bp, (*Table)(unsafe.Pointer(pTab)).FzName)
  65062 					}
  65063 				}
  65064 			} else if (*Parse)(unsafe.Pointer(bp+48)).FpNewIndex != 0 {
  65065 				renameTokenFind(tls, bp+48, bp, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+48)).FpNewIndex)).FzName)
  65066 				if isLegacy == 0 {
  65067 					Xsqlite3WalkExpr(tls, bp+20, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+48)).FpNewIndex)).FpPartIdxWhere)
  65068 				}
  65069 			} else {
  65070 				var pTrigger uintptr = (*Parse)(unsafe.Pointer(bp + 48)).FpNewTrigger
  65071 				var pStep uintptr
  65072 				if 0 == Xsqlite3_stricmp(tls, (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+48)).FpNewTrigger)).Ftable, zOld) &&
  65073 					(*Table)(unsafe.Pointer((*RenameCtx)(unsafe.Pointer(bp)).FpTab)).FpSchema == (*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema {
  65074 					renameTokenFind(tls, bp+48, bp, (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+48)).FpNewTrigger)).Ftable)
  65075 				}
  65076 
  65077 				if isLegacy == 0 {
  65078 					rc = renameResolveTrigger(tls, bp+48)
  65079 					if rc == SQLITE_OK {
  65080 						renameWalkTrigger(tls, bp+20, pTrigger)
  65081 						for pStep = (*Trigger)(unsafe.Pointer(pTrigger)).Fstep_list; pStep != 0; pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext {
  65082 							if (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0 && 0 == Xsqlite3_stricmp(tls, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zOld) {
  65083 								renameTokenFind(tls, bp+48, bp, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget)
  65084 							}
  65085 							if (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom != 0 {
  65086 								var i int32
  65087 								for i = 0; i < (*SrcList)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpFrom)).FnSrc; i++ {
  65088 									var pItem uintptr = (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom + 8 + uintptr(i)*72
  65089 									if 0 == Xsqlite3_stricmp(tls, (*SrcItem)(unsafe.Pointer(pItem)).FzName, zOld) {
  65090 										renameTokenFind(tls, bp+48, bp, (*SrcItem)(unsafe.Pointer(pItem)).FzName)
  65091 									}
  65092 								}
  65093 							}
  65094 						}
  65095 					}
  65096 				}
  65097 			}
  65098 		}
  65099 
  65100 		if rc == SQLITE_OK {
  65101 			rc = renameEditSql(tls, context, bp, zInput, zNew, bQuote)
  65102 		}
  65103 		if rc != SQLITE_OK {
  65104 			if rc == SQLITE_ERROR && Xsqlite3WritableSchema(tls, db) != 0 {
  65105 				Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + 3*4)))
  65106 			} else if (*Parse)(unsafe.Pointer(bp+48)).FzErrMsg != 0 {
  65107 				renameColumnParseError(tls, context, ts+1554, *(*uintptr)(unsafe.Pointer(argv + 1*4)), *(*uintptr)(unsafe.Pointer(argv + 2*4)), bp+48)
  65108 			} else {
  65109 				Xsqlite3_result_error_code(tls, context, rc)
  65110 			}
  65111 		}
  65112 
  65113 		renameParseCleanup(tls, bp+48)
  65114 		renameTokenFree(tls, db, (*RenameCtx)(unsafe.Pointer(bp)).FpList)
  65115 		Xsqlite3BtreeLeaveAll(tls, db)
  65116 		(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  65117 	}
  65118 
  65119 	return
  65120 }
  65121 
  65122 func renameQuotefixExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  65123 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_STRING && (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_DblQuoted) != 0 {
  65124 		renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, *(*uintptr)(unsafe.Pointer(pWalker + 24)), pExpr)
  65125 	}
  65126 	return WRC_Continue
  65127 }
  65128 
  65129 func renameQuotefixFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  65130 	bp := tls.Alloc(328)
  65131 	defer tls.Free(328)
  65132 
  65133 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  65134 	var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  65135 	var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  65136 
  65137 	var xAuth Sqlite3_xauth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  65138 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  65139 
  65140 	Xsqlite3BtreeEnterAll(tls, db)
  65141 
  65142 	_ = NotUsed
  65143 	if zDb != 0 && zInput != 0 {
  65144 		var rc int32
  65145 
  65146 		rc = renameParseSql(tls, bp, zDb, db, zInput, 0)
  65147 
  65148 		if rc == SQLITE_OK {
  65149 			libc.Xmemset(tls, bp+280, 0, uint32(unsafe.Sizeof(RenameCtx{})))
  65150 			libc.Xmemset(tls, bp+300, 0, uint32(unsafe.Sizeof(Walker{})))
  65151 			(*Walker)(unsafe.Pointer(bp + 300)).FpParse = bp
  65152 			(*Walker)(unsafe.Pointer(bp + 300)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  65153 				f func(*libc.TLS, uintptr, uintptr) int32
  65154 			}{renameQuotefixExprCb}))
  65155 			(*Walker)(unsafe.Pointer(bp + 300)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  65156 				f func(*libc.TLS, uintptr, uintptr) int32
  65157 			}{renameColumnSelectCb}))
  65158 			*(*uintptr)(unsafe.Pointer(bp + 300 + 24)) = bp + 280
  65159 
  65160 			if (*Parse)(unsafe.Pointer(bp)).FpNewTable != 0 {
  65161 				if int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable)).FeTabType) == TABTYP_VIEW {
  65162 					var pSelect uintptr = *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable + 44))
  65163 					*(*U32)(unsafe.Pointer(pSelect + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_View))
  65164 					(*Parse)(unsafe.Pointer(bp)).Frc = SQLITE_OK
  65165 					Xsqlite3SelectPrep(tls, bp, pSelect, uintptr(0))
  65166 					rc = func() int32 {
  65167 						if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  65168 							return SQLITE_NOMEM
  65169 						}
  65170 						return (*Parse)(unsafe.Pointer(bp)).Frc
  65171 					}()
  65172 					if rc == SQLITE_OK {
  65173 						Xsqlite3WalkSelect(tls, bp+300, pSelect)
  65174 					}
  65175 				} else {
  65176 					var i int32
  65177 					Xsqlite3WalkExprList(tls, bp+300, (*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable)).FpCheck)
  65178 					for i = 0; i < int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable)).FnCol); i++ {
  65179 						Xsqlite3WalkExpr(tls, bp+300,
  65180 							Xsqlite3ColumnExpr(tls, (*Parse)(unsafe.Pointer(bp)).FpNewTable,
  65181 								(*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable)).FaCol+uintptr(i)*16))
  65182 					}
  65183 				}
  65184 			} else if (*Parse)(unsafe.Pointer(bp)).FpNewIndex != 0 {
  65185 				Xsqlite3WalkExprList(tls, bp+300, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewIndex)).FaColExpr)
  65186 				Xsqlite3WalkExpr(tls, bp+300, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewIndex)).FpPartIdxWhere)
  65187 			} else {
  65188 				rc = renameResolveTrigger(tls, bp)
  65189 				if rc == SQLITE_OK {
  65190 					renameWalkTrigger(tls, bp+300, (*Parse)(unsafe.Pointer(bp)).FpNewTrigger)
  65191 				}
  65192 			}
  65193 
  65194 			if rc == SQLITE_OK {
  65195 				rc = renameEditSql(tls, context, bp+280, zInput, uintptr(0), 0)
  65196 			}
  65197 			renameTokenFree(tls, db, (*RenameCtx)(unsafe.Pointer(bp+280)).FpList)
  65198 		}
  65199 		if rc != SQLITE_OK {
  65200 			if Xsqlite3WritableSchema(tls, db) != 0 && rc == SQLITE_ERROR {
  65201 				Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  65202 			} else {
  65203 				Xsqlite3_result_error_code(tls, context, rc)
  65204 			}
  65205 		}
  65206 		renameParseCleanup(tls, bp)
  65207 	}
  65208 
  65209 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  65210 
  65211 	Xsqlite3BtreeLeaveAll(tls, db)
  65212 }
  65213 
  65214 func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  65215 	bp := tls.Alloc(312)
  65216 	defer tls.Free(312)
  65217 
  65218 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  65219 	var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  65220 	var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  65221 	var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 4*4)))
  65222 	var isLegacy int32 = int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(SQLITE_LegacyAlter))
  65223 	var zWhen uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*4)))
  65224 	var bNoDQS int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 6*4)))
  65225 
  65226 	var xAuth Sqlite3_xauth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  65227 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  65228 
  65229 	_ = NotUsed
  65230 
  65231 	if zDb != 0 && zInput != 0 {
  65232 		var rc int32
  65233 
  65234 		var flags int32 = int32((*Sqlite3)(unsafe.Pointer(db)).Fflags)
  65235 		if bNoDQS != 0 {
  65236 			*(*U64)(unsafe.Pointer(db + 32)) &= libc.Uint64FromInt32(libc.CplInt32(SQLITE_DqsDML | SQLITE_DqsDDL))
  65237 		}
  65238 		rc = renameParseSql(tls, bp, zDb, db, zInput, bTemp)
  65239 		*(*U64)(unsafe.Pointer(db + 32)) |= U64(flags & (SQLITE_DqsDML | SQLITE_DqsDDL))
  65240 		if rc == SQLITE_OK {
  65241 			if isLegacy == 0 && (*Parse)(unsafe.Pointer(bp)).FpNewTable != 0 && int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable)).FeTabType) == TABTYP_VIEW {
  65242 				libc.Xmemset(tls, bp+280, 0, uint32(unsafe.Sizeof(NameContext{})))
  65243 				(*NameContext)(unsafe.Pointer(bp + 280)).FpParse = bp
  65244 				Xsqlite3SelectPrep(tls, bp, *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTable + 44)), bp+280)
  65245 				if (*Parse)(unsafe.Pointer(bp)).FnErr != 0 {
  65246 					rc = (*Parse)(unsafe.Pointer(bp)).Frc
  65247 				}
  65248 			} else if (*Parse)(unsafe.Pointer(bp)).FpNewTrigger != 0 {
  65249 				if isLegacy == 0 {
  65250 					rc = renameResolveTrigger(tls, bp)
  65251 				}
  65252 				if rc == SQLITE_OK {
  65253 					var i1 int32 = Xsqlite3SchemaToIndex(tls, db, (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp)).FpNewTrigger)).FpTabSchema)
  65254 					var i2 int32 = Xsqlite3FindDbName(tls, db, zDb)
  65255 					if i1 == i2 {
  65256 						Xsqlite3_result_int(tls, context, 1)
  65257 					}
  65258 				}
  65259 			}
  65260 		}
  65261 
  65262 		if rc != SQLITE_OK && zWhen != 0 && !(Xsqlite3WritableSchema(tls, db) != 0) {
  65263 			renameColumnParseError(tls, context, zWhen, *(*uintptr)(unsafe.Pointer(argv + 2*4)), *(*uintptr)(unsafe.Pointer(argv + 3*4)), bp)
  65264 		}
  65265 		renameParseCleanup(tls, bp)
  65266 	}
  65267 
  65268 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  65269 }
  65270 
  65271 func dropColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  65272 	bp := tls.Alloc(304)
  65273 	defer tls.Free(304)
  65274 
  65275 	var db uintptr
  65276 	var iSchema int32
  65277 	var zSql uintptr
  65278 	var iCol int32
  65279 	var zDb uintptr
  65280 	var rc int32
  65281 
  65282 	var pCol uintptr
  65283 	var pTab uintptr
  65284 	var zEnd uintptr
  65285 	var zNew uintptr
  65286 	var xAuth Sqlite3_xauth
  65287 	var pEnd uintptr
  65288 	db = Xsqlite3_context_db_handle(tls, context)
  65289 	iSchema = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv)))
  65290 	zSql = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  65291 	iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
  65292 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*16)).FzDbSName
  65293 	zNew = uintptr(0)
  65294 	xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  65295 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  65296 
  65297 	_ = NotUsed
  65298 	rc = renameParseSql(tls, bp+24, zDb, db, zSql, libc.Bool32(iSchema == 1))
  65299 	if !(rc != SQLITE_OK) {
  65300 		goto __1
  65301 	}
  65302 	goto drop_column_done
  65303 __1:
  65304 	;
  65305 	pTab = (*Parse)(unsafe.Pointer(bp + 24)).FpNewTable
  65306 	if !(pTab == uintptr(0) || int32((*Table)(unsafe.Pointer(pTab)).FnCol) == 1 || iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  65307 		goto __2
  65308 	}
  65309 
  65310 	rc = Xsqlite3CorruptError(tls, 114463)
  65311 	goto drop_column_done
  65312 __2:
  65313 	;
  65314 	pCol = renameTokenFind(tls, bp+24, uintptr(0), (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FzCnName)
  65315 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1) {
  65316 		goto __3
  65317 	}
  65318 	pEnd = renameTokenFind(tls, bp+24, uintptr(0), (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol+1)*16)).FzCnName)
  65319 	zEnd = (*RenameToken)(unsafe.Pointer(pEnd)).Ft.Fz
  65320 	goto __4
  65321 __3:
  65322 	;
  65323 	zEnd = zSql + uintptr(*(*int32)(unsafe.Pointer(pTab + 44)))
  65324 __5:
  65325 	if !(int32(*(*uint8)(unsafe.Pointer((*RenameToken)(unsafe.Pointer(pCol)).Ft.Fz))) != 0 && int32(*(*uint8)(unsafe.Pointer((*RenameToken)(unsafe.Pointer(pCol)).Ft.Fz))) != ',') {
  65326 		goto __6
  65327 	}
  65328 	(*RenameToken)(unsafe.Pointer(pCol)).Ft.Fz--
  65329 	goto __5
  65330 __6:
  65331 	;
  65332 __4:
  65333 	;
  65334 	zNew = Xsqlite3MPrintf(tls, db, ts+10941, libc.VaList(bp, (int32((*RenameToken)(unsafe.Pointer(pCol)).Ft.Fz)-int32(zSql))/1, zSql, zEnd))
  65335 	Xsqlite3_result_text(tls, context, zNew, -1, libc.UintptrFromInt32(-1))
  65336 	Xsqlite3_free(tls, zNew)
  65337 
  65338 drop_column_done:
  65339 	renameParseCleanup(tls, bp+24)
  65340 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  65341 	if !(rc != SQLITE_OK) {
  65342 		goto __7
  65343 	}
  65344 	Xsqlite3_result_error_code(tls, context, rc)
  65345 __7:
  65346 }
  65347 
  65348 // This function is called by the parser upon parsing an
  65349 //
  65350 //	ALTER TABLE pSrc DROP COLUMN pName
  65351 //
  65352 // statement. Argument pSrc contains the possibly qualified name of the
  65353 // table being edited, and token pName the name of the column to drop.
  65354 func Xsqlite3AlterDropColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName uintptr) {
  65355 	bp := tls.Alloc(64)
  65356 	defer tls.Free(64)
  65357 
  65358 	var db uintptr
  65359 	var pTab uintptr
  65360 	var iDb int32
  65361 	var zDb uintptr
  65362 	var zCol uintptr
  65363 	var iCol int32
  65364 	var iPos int32
  65365 	var iColPos int32
  65366 	var regOut int32
  65367 	var i int32
  65368 	var addr int32
  65369 	var reg int32
  65370 	var regRec int32
  65371 	var pPk uintptr
  65372 	var nField int32
  65373 	var iCur int32
  65374 	var v uintptr
  65375 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  65376 	zCol = uintptr(0)
  65377 
  65378 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  65379 		goto __1
  65380 	}
  65381 	goto exit_drop_column
  65382 __1:
  65383 	;
  65384 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pSrc+8)
  65385 	if !!(pTab != 0) {
  65386 		goto __2
  65387 	}
  65388 	goto exit_drop_column
  65389 __2:
  65390 	;
  65391 	if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) {
  65392 		goto __3
  65393 	}
  65394 	goto exit_drop_column
  65395 __3:
  65396 	;
  65397 	if !(SQLITE_OK != isRealTable(tls, pParse, pTab, 1)) {
  65398 		goto __4
  65399 	}
  65400 	goto exit_drop_column
  65401 __4:
  65402 	;
  65403 	zCol = Xsqlite3NameFromToken(tls, db, pName)
  65404 	if !(zCol == uintptr(0)) {
  65405 		goto __5
  65406 	}
  65407 
  65408 	goto exit_drop_column
  65409 __5:
  65410 	;
  65411 	iCol = Xsqlite3ColumnIndex(tls, pTab, zCol)
  65412 	if !(iCol < 0) {
  65413 		goto __6
  65414 	}
  65415 	Xsqlite3ErrorMsg(tls, pParse, ts+10563, libc.VaList(bp, pName))
  65416 	goto exit_drop_column
  65417 __6:
  65418 	;
  65419 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FcolFlags)&(COLFLAG_PRIMKEY|COLFLAG_UNIQUE) != 0) {
  65420 		goto __7
  65421 	}
  65422 	Xsqlite3ErrorMsg(tls, pParse, ts+10948,
  65423 		libc.VaList(bp+8, func() uintptr {
  65424 			if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FcolFlags)&COLFLAG_PRIMKEY != 0 {
  65425 				return ts + 10976
  65426 			}
  65427 			return ts + 6127
  65428 		}(),
  65429 			zCol))
  65430 	goto exit_drop_column
  65431 __7:
  65432 	;
  65433 	if !(int32((*Table)(unsafe.Pointer(pTab)).FnCol) <= 1) {
  65434 		goto __8
  65435 	}
  65436 	Xsqlite3ErrorMsg(tls, pParse, ts+10988, libc.VaList(bp+24, zCol))
  65437 	goto exit_drop_column
  65438 __8:
  65439 	;
  65440 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  65441 
  65442 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  65443 
  65444 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, zCol) != 0) {
  65445 		goto __9
  65446 	}
  65447 	goto exit_drop_column
  65448 __9:
  65449 	;
  65450 	renameTestSchema(tls, pParse, zDb, libc.Bool32(iDb == 1), ts+1554, 0)
  65451 	renameFixQuotes(tls, pParse, zDb, libc.Bool32(iDb == 1))
  65452 	Xsqlite3NestedParse(tls, pParse,
  65453 		ts+11036, libc.VaList(bp+32, zDb, iDb, iCol, (*Table)(unsafe.Pointer(pTab)).FzName))
  65454 
  65455 	renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterDrop))
  65456 	renameTestSchema(tls, pParse, zDb, libc.Bool32(iDb == 1), ts+11157, 1)
  65457 
  65458 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr == 0 && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0) {
  65459 		goto __10
  65460 	}
  65461 	pPk = uintptr(0)
  65462 	nField = 0
  65463 	v = Xsqlite3GetVdbe(tls, pParse)
  65464 	iCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  65465 	Xsqlite3OpenTable(tls, pParse, iCur, iDb, pTab, OP_OpenWrite)
  65466 	addr = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iCur)
  65467 	reg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  65468 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  65469 		goto __11
  65470 	}
  65471 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCur, reg)
  65472 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  65473 	goto __12
  65474 __11:
  65475 	pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  65476 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Index)(unsafe.Pointer(pPk)).FnColumn)
  65477 	i = 0
  65478 __13:
  65479 	if !(i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) {
  65480 		goto __15
  65481 	}
  65482 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, i, reg+i+1)
  65483 	goto __14
  65484 __14:
  65485 	i++
  65486 	goto __13
  65487 	goto __15
  65488 __15:
  65489 	;
  65490 	nField = int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  65491 __12:
  65492 	;
  65493 	regRec = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  65494 	i = 0
  65495 __16:
  65496 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  65497 		goto __18
  65498 	}
  65499 	if !(i != iCol && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0) {
  65500 		goto __19
  65501 	}
  65502 	if !(pPk != 0) {
  65503 		goto __20
  65504 	}
  65505 	iPos = int32(Xsqlite3TableColumnToIndex(tls, pPk, int16(i)))
  65506 	iColPos = int32(Xsqlite3TableColumnToIndex(tls, pPk, int16(iCol)))
  65507 	if !(iPos < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) {
  65508 		goto __22
  65509 	}
  65510 	goto __17
  65511 __22:
  65512 	;
  65513 	regOut = reg + 1 + iPos - libc.Bool32(iPos > iColPos)
  65514 	goto __21
  65515 __20:
  65516 	regOut = reg + 1 + nField
  65517 __21:
  65518 	;
  65519 	if !(i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  65520 		goto __23
  65521 	}
  65522 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regOut)
  65523 	goto __24
  65524 __23:
  65525 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, i, regOut)
  65526 __24:
  65527 	;
  65528 	nField++
  65529 __19:
  65530 	;
  65531 	goto __17
  65532 __17:
  65533 	i++
  65534 	goto __16
  65535 	goto __18
  65536 __18:
  65537 	;
  65538 	if !(nField == 0) {
  65539 		goto __25
  65540 	}
  65541 
  65542 	(*Parse)(unsafe.Pointer(pParse)).FnMem++
  65543 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, reg+1)
  65544 	nField = 1
  65545 __25:
  65546 	;
  65547 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, reg+1, nField, regRec)
  65548 	if !(pPk != 0) {
  65549 		goto __26
  65550 	}
  65551 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iCur, regRec, reg+1, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol))
  65552 	goto __27
  65553 __26:
  65554 	Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iCur, regRec, reg)
  65555 __27:
  65556 	;
  65557 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION))
  65558 
  65559 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, iCur, addr+1)
  65560 	Xsqlite3VdbeJumpHere(tls, v, addr)
  65561 __10:
  65562 	;
  65563 exit_drop_column:
  65564 	Xsqlite3DbFree(tls, db, zCol)
  65565 	Xsqlite3SrcListDelete(tls, db, pSrc)
  65566 }
  65567 
  65568 // Register built-in functions used to help implement ALTER TABLE
  65569 func Xsqlite3AlterFunctions(tls *libc.TLS) {
  65570 	Xsqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&aAlterTableFuncs)), int32(uint32(unsafe.Sizeof(aAlterTableFuncs))/uint32(unsafe.Sizeof(FuncDef{}))))
  65571 }
  65572 
  65573 var aAlterTableFuncs = [5]FuncDef{
  65574 	{FnArg: int8(9), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_INTERNAL | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FxSFunc: 0, FzName: ts + 11175},
  65575 	{FnArg: int8(7), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_INTERNAL | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FxSFunc: 0, FzName: ts + 11196},
  65576 	{FnArg: int8(7), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_INTERNAL | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FxSFunc: 0, FzName: ts + 11216},
  65577 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_INTERNAL | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FxSFunc: 0, FzName: ts + 11235},
  65578 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_INTERNAL | SQLITE_UTF8 | SQLITE_FUNC_CONSTANT), FxSFunc: 0, FzName: ts + 11254}}
  65579 
  65580 func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWhere uintptr, zWhereType uintptr) {
  65581 	bp := tls.Alloc(88)
  65582 	defer tls.Free(88)
  65583 
  65584 	var i int32
  65585 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  65586 	var pDb uintptr
  65587 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  65588 
  65589 	var nToOpen int32
  65590 	if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) {
  65591 		nToOpen = 2
  65592 	} else {
  65593 		nToOpen = 1
  65594 	}
  65595 
  65596 	if v == uintptr(0) {
  65597 		return
  65598 	}
  65599 
  65600 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  65601 
  65602 	for i = 0; i < int32(uint32(unsafe.Sizeof(aTable))/uint32(unsafe.Sizeof(struct {
  65603 		FzName uintptr
  65604 		FzCols uintptr
  65605 	}{}))); i++ {
  65606 		var zTab uintptr = aTable[i].FzName
  65607 		var pStat uintptr
  65608 		*(*U8)(unsafe.Pointer(bp + 72 + uintptr(i))) = U8(0)
  65609 		if libc.AssignUintptr(&pStat, Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer(pDb)).FzDbSName)) == uintptr(0) {
  65610 			if i < nToOpen {
  65611 				Xsqlite3NestedParse(tls, pParse,
  65612 					ts+11277, libc.VaList(bp, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab, aTable[i].FzCols))
  65613 				*(*U32)(unsafe.Pointer(bp + 76 + uintptr(i)*4)) = U32((*Parse)(unsafe.Pointer(pParse)).FregRoot)
  65614 				*(*U8)(unsafe.Pointer(bp + 72 + uintptr(i))) = U8(OPFLAG_P2ISREG)
  65615 			}
  65616 		} else {
  65617 			*(*U32)(unsafe.Pointer(bp + 76 + uintptr(i)*4)) = (*Table)(unsafe.Pointer(pStat)).Ftnum
  65618 			Xsqlite3TableLock(tls, pParse, iDb, *(*U32)(unsafe.Pointer(bp + 76 + uintptr(i)*4)), uint8(1), zTab)
  65619 			if zWhere != 0 {
  65620 				Xsqlite3NestedParse(tls, pParse,
  65621 					ts+11300,
  65622 					libc.VaList(bp+24, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab, zWhereType, zWhere))
  65623 			} else if (*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 {
  65624 				Xsqlite3NestedParse(tls, pParse, ts+11330, libc.VaList(bp+56, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab))
  65625 			} else {
  65626 				Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32(*(*U32)(unsafe.Pointer(bp + 76 + uintptr(i)*4))), iDb)
  65627 			}
  65628 		}
  65629 	}
  65630 
  65631 	for i = 0; i < nToOpen; i++ {
  65632 		Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenWrite, iStatCur+i, int32(*(*U32)(unsafe.Pointer(bp + 76 + uintptr(i)*4))), iDb, 3)
  65633 		Xsqlite3VdbeChangeP5(tls, v, uint16(*(*U8)(unsafe.Pointer(bp + 72 + uintptr(i)))))
  65634 
  65635 	}
  65636 }
  65637 
  65638 var aTable = [3]struct {
  65639 	FzName uintptr
  65640 	FzCols uintptr
  65641 }{
  65642 	{FzName: ts + 11348, FzCols: ts + 11361},
  65643 	{FzName: ts + 11374, FzCols: ts + 11387},
  65644 	{FzName: ts + 11415},
  65645 }
  65646 
  65647 // Three SQL functions - stat_init(), stat_push(), and stat_get() -
  65648 // share an instance of the following structure to hold their state
  65649 // information.
  65650 type StatAccum1 = struct {
  65651 	Fdb          uintptr
  65652 	F__ccgo_pad1 [4]byte
  65653 	FnEst        TRowcnt
  65654 	FnRow        TRowcnt
  65655 	FnLimit      int32
  65656 	FnCol        int32
  65657 	FnKeyCol     int32
  65658 	FnSkipAhead  U8
  65659 	F__ccgo_pad2 [3]byte
  65660 	Fcurrent     StatSample
  65661 	FnPSample    TRowcnt
  65662 	FmxSample    int32
  65663 	FiPrn        U32
  65664 	FaBest       uintptr
  65665 	FiMin        int32
  65666 	FnSample     int32
  65667 	FnMaxEqZero  int32
  65668 	FiGet        int32
  65669 	Fa           uintptr
  65670 }
  65671 
  65672 // Three SQL functions - stat_init(), stat_push(), and stat_get() -
  65673 // share an instance of the following structure to hold their state
  65674 // information.
  65675 type StatAccum = StatAccum1
  65676 type StatSample1 = struct {
  65677 	FanEq        uintptr
  65678 	FanDLt       uintptr
  65679 	FanLt        uintptr
  65680 	F__ccgo_pad1 [4]byte
  65681 	Fu           struct{ FiRowid I64 }
  65682 	FnRowid      U32
  65683 	FisPSample   U8
  65684 	F__ccgo_pad2 [3]byte
  65685 	FiCol        int32
  65686 	FiHash       U32
  65687 }
  65688 
  65689 type StatSample = StatSample1
  65690 
  65691 func sampleClear(tls *libc.TLS, db uintptr, p uintptr) {
  65692 	if (*StatSample)(unsafe.Pointer(p)).FnRowid != 0 {
  65693 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 16)))
  65694 		(*StatSample)(unsafe.Pointer(p)).FnRowid = U32(0)
  65695 	}
  65696 }
  65697 
  65698 func sampleSetRowid(tls *libc.TLS, db uintptr, p uintptr, n int32, pData uintptr) {
  65699 	if (*StatSample)(unsafe.Pointer(p)).FnRowid != 0 {
  65700 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 16)))
  65701 	}
  65702 	*(*uintptr)(unsafe.Pointer(p + 16)) = Xsqlite3DbMallocRawNN(tls, db, uint64(n))
  65703 	if *(*uintptr)(unsafe.Pointer(p + 16)) != 0 {
  65704 		(*StatSample)(unsafe.Pointer(p)).FnRowid = U32(n)
  65705 		libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 16)), pData, uint32(n))
  65706 	} else {
  65707 		(*StatSample)(unsafe.Pointer(p)).FnRowid = U32(0)
  65708 	}
  65709 }
  65710 
  65711 func sampleSetRowidInt64(tls *libc.TLS, db uintptr, p uintptr, iRowid I64) {
  65712 	if (*StatSample)(unsafe.Pointer(p)).FnRowid != 0 {
  65713 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 16)))
  65714 	}
  65715 	(*StatSample)(unsafe.Pointer(p)).FnRowid = U32(0)
  65716 	*(*I64)(unsafe.Pointer(p + 16)) = iRowid
  65717 }
  65718 
  65719 func sampleCopy(tls *libc.TLS, p uintptr, pTo uintptr, pFrom uintptr) {
  65720 	(*StatSample)(unsafe.Pointer(pTo)).FisPSample = (*StatSample)(unsafe.Pointer(pFrom)).FisPSample
  65721 	(*StatSample)(unsafe.Pointer(pTo)).FiCol = (*StatSample)(unsafe.Pointer(pFrom)).FiCol
  65722 	(*StatSample)(unsafe.Pointer(pTo)).FiHash = (*StatSample)(unsafe.Pointer(pFrom)).FiHash
  65723 	libc.Xmemcpy(tls, (*StatSample)(unsafe.Pointer(pTo)).FanEq, (*StatSample)(unsafe.Pointer(pFrom)).FanEq, uint32(unsafe.Sizeof(TRowcnt(0)))*uint32((*StatAccum)(unsafe.Pointer(p)).FnCol))
  65724 	libc.Xmemcpy(tls, (*StatSample)(unsafe.Pointer(pTo)).FanLt, (*StatSample)(unsafe.Pointer(pFrom)).FanLt, uint32(unsafe.Sizeof(TRowcnt(0)))*uint32((*StatAccum)(unsafe.Pointer(p)).FnCol))
  65725 	libc.Xmemcpy(tls, (*StatSample)(unsafe.Pointer(pTo)).FanDLt, (*StatSample)(unsafe.Pointer(pFrom)).FanDLt, uint32(unsafe.Sizeof(TRowcnt(0)))*uint32((*StatAccum)(unsafe.Pointer(p)).FnCol))
  65726 	if (*StatSample)(unsafe.Pointer(pFrom)).FnRowid != 0 {
  65727 		sampleSetRowid(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, pTo, int32((*StatSample)(unsafe.Pointer(pFrom)).FnRowid), *(*uintptr)(unsafe.Pointer(pFrom + 16)))
  65728 	} else {
  65729 		sampleSetRowidInt64(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, pTo, *(*I64)(unsafe.Pointer(pFrom + 16)))
  65730 	}
  65731 }
  65732 
  65733 func statAccumDestructor(tls *libc.TLS, pOld uintptr) {
  65734 	var p uintptr = pOld
  65735 	if (*StatAccum)(unsafe.Pointer(p)).FmxSample != 0 {
  65736 		var i int32
  65737 		for i = 0; i < (*StatAccum)(unsafe.Pointer(p)).FnCol; i++ {
  65738 			sampleClear(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (*StatAccum)(unsafe.Pointer(p)).FaBest+uintptr(i)*40)
  65739 		}
  65740 		for i = 0; i < (*StatAccum)(unsafe.Pointer(p)).FmxSample; i++ {
  65741 			sampleClear(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (*StatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*40)
  65742 		}
  65743 		sampleClear(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, p+40)
  65744 	}
  65745 	Xsqlite3DbFree(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, p)
  65746 }
  65747 
  65748 func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  65749 	var p uintptr
  65750 	var nCol int32
  65751 	var nKeyCol int32
  65752 	var nColUp int32
  65753 	var n int32
  65754 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  65755 
  65756 	var mxSample int32
  65757 	if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) {
  65758 		mxSample = SQLITE_STAT4_SAMPLES
  65759 	} else {
  65760 		mxSample = 0
  65761 	}
  65762 
  65763 	_ = argc
  65764 	nCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv)))
  65765 
  65766 	if uint32(unsafe.Sizeof(TRowcnt(0))) < uint32(8) {
  65767 		nColUp = (nCol + 1) & libc.CplInt32(1)
  65768 	} else {
  65769 		nColUp = nCol
  65770 	}
  65771 	nKeyCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  65772 
  65773 	n = int32(uint32(unsafe.Sizeof(StatAccum{})) +
  65774 		uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(nColUp) +
  65775 		uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(nColUp))
  65776 	if mxSample != 0 {
  65777 		n = int32(uint32(n) + (uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(nColUp) +
  65778 			uint32(unsafe.Sizeof(StatSample{}))*uint32(nCol+mxSample) +
  65779 			uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(3)*uint32(nColUp)*uint32(nCol+mxSample)))
  65780 	}
  65781 	p = Xsqlite3DbMallocZero(tls, db, uint64(n))
  65782 	if p == uintptr(0) {
  65783 		Xsqlite3_result_error_nomem(tls, context)
  65784 		return
  65785 	}
  65786 
  65787 	(*StatAccum)(unsafe.Pointer(p)).Fdb = db
  65788 	(*StatAccum)(unsafe.Pointer(p)).FnEst = TRowcnt(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
  65789 	(*StatAccum)(unsafe.Pointer(p)).FnRow = uint64(0)
  65790 	(*StatAccum)(unsafe.Pointer(p)).FnLimit = int32(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4))))
  65791 	(*StatAccum)(unsafe.Pointer(p)).FnCol = nCol
  65792 	(*StatAccum)(unsafe.Pointer(p)).FnKeyCol = nKeyCol
  65793 	(*StatAccum)(unsafe.Pointer(p)).FnSkipAhead = U8(0)
  65794 	(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt = p + 1*120
  65795 	(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq = (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(nColUp)*8
  65796 
  65797 	(*StatAccum)(unsafe.Pointer(p)).FmxSample = func() int32 {
  65798 		if (*StatAccum)(unsafe.Pointer(p)).FnLimit == 0 {
  65799 			return mxSample
  65800 		}
  65801 		return 0
  65802 	}()
  65803 	if mxSample != 0 {
  65804 		var pSpace uintptr
  65805 		var i int32
  65806 
  65807 		(*StatAccum)(unsafe.Pointer(p)).FiGet = -1
  65808 		(*StatAccum)(unsafe.Pointer(p)).FnPSample = (*StatAccum)(unsafe.Pointer(p)).FnEst/TRowcnt(mxSample/3+1) + uint64(1)
  65809 		(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt = (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(nColUp)*8
  65810 		(*StatAccum)(unsafe.Pointer(p)).FiPrn = U32(0x689e962d)*U32(nCol) ^ 0xd0944565*U32(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
  65811 
  65812 		(*StatAccum)(unsafe.Pointer(p)).Fa = (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr(nColUp)*8
  65813 		(*StatAccum)(unsafe.Pointer(p)).FaBest = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(mxSample)*40
  65814 		pSpace = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(mxSample+nCol)*40
  65815 		for i = 0; i < mxSample+nCol; i++ {
  65816 			(*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*40)).FanEq = pSpace
  65817 			pSpace += uintptr(uint32(unsafe.Sizeof(TRowcnt(0))) * uint32(nColUp))
  65818 			(*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*40)).FanLt = pSpace
  65819 			pSpace += uintptr(uint32(unsafe.Sizeof(TRowcnt(0))) * uint32(nColUp))
  65820 			(*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*40)).FanDLt = pSpace
  65821 			pSpace += uintptr(uint32(unsafe.Sizeof(TRowcnt(0))) * uint32(nColUp))
  65822 		}
  65823 
  65824 		for i = 0; i < nCol; i++ {
  65825 			(*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).FaBest + uintptr(i)*40)).FiCol = i
  65826 		}
  65827 	}
  65828 
  65829 	Xsqlite3_result_blob(tls, context, p, int32(unsafe.Sizeof(StatAccum{})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{statAccumDestructor})))
  65830 }
  65831 
  65832 var statInitFuncdef = FuncDef{
  65833 	FnArg:      int8(4),
  65834 	FfuncFlags: U32(SQLITE_UTF8),
  65835 	FxSFunc:    0,
  65836 	FzName:     ts + 11428}
  65837 
  65838 func sampleIsBetterPost(tls *libc.TLS, pAccum uintptr, pNew uintptr, pOld uintptr) int32 {
  65839 	var nCol int32 = (*StatAccum)(unsafe.Pointer(pAccum)).FnCol
  65840 	var i int32
  65841 
  65842 	for i = (*StatSample)(unsafe.Pointer(pNew)).FiCol + 1; i < nCol; i++ {
  65843 		if *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pNew)).FanEq + uintptr(i)*8)) > *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pOld)).FanEq + uintptr(i)*8)) {
  65844 			return 1
  65845 		}
  65846 		if *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pNew)).FanEq + uintptr(i)*8)) < *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pOld)).FanEq + uintptr(i)*8)) {
  65847 			return 0
  65848 		}
  65849 	}
  65850 	if (*StatSample)(unsafe.Pointer(pNew)).FiHash > (*StatSample)(unsafe.Pointer(pOld)).FiHash {
  65851 		return 1
  65852 	}
  65853 	return 0
  65854 }
  65855 
  65856 func sampleIsBetter(tls *libc.TLS, pAccum uintptr, pNew uintptr, pOld uintptr) int32 {
  65857 	var nEqNew TRowcnt = *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pNew)).FanEq + uintptr((*StatSample)(unsafe.Pointer(pNew)).FiCol)*8))
  65858 	var nEqOld TRowcnt = *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pOld)).FanEq + uintptr((*StatSample)(unsafe.Pointer(pOld)).FiCol)*8))
  65859 
  65860 	if nEqNew > nEqOld {
  65861 		return 1
  65862 	}
  65863 	if nEqNew == nEqOld {
  65864 		if (*StatSample)(unsafe.Pointer(pNew)).FiCol < (*StatSample)(unsafe.Pointer(pOld)).FiCol {
  65865 			return 1
  65866 		}
  65867 		return libc.Bool32((*StatSample)(unsafe.Pointer(pNew)).FiCol == (*StatSample)(unsafe.Pointer(pOld)).FiCol && sampleIsBetterPost(tls, pAccum, pNew, pOld) != 0)
  65868 	}
  65869 	return 0
  65870 }
  65871 
  65872 func sampleInsert(tls *libc.TLS, p uintptr, pNew uintptr, nEqZero int32) {
  65873 	var pSample uintptr
  65874 	var i int32
  65875 	var pOld uintptr
  65876 	var pUpgrade uintptr
  65877 	var pMin uintptr
  65878 	var anEq uintptr
  65879 	var anLt uintptr
  65880 	var anDLt uintptr
  65881 	var iMin int32
  65882 	pSample = uintptr(0)
  65883 
  65884 	if !(nEqZero > (*StatAccum)(unsafe.Pointer(p)).FnMaxEqZero) {
  65885 		goto __1
  65886 	}
  65887 	(*StatAccum)(unsafe.Pointer(p)).FnMaxEqZero = nEqZero
  65888 __1:
  65889 	;
  65890 	if !(int32((*StatSample)(unsafe.Pointer(pNew)).FisPSample) == 0) {
  65891 		goto __2
  65892 	}
  65893 	pUpgrade = uintptr(0)
  65894 
  65895 	i = (*StatAccum)(unsafe.Pointer(p)).FnSample - 1
  65896 __3:
  65897 	if !(i >= 0) {
  65898 		goto __5
  65899 	}
  65900 	pOld = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(i)*40
  65901 	if !(*(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pOld)).FanEq + uintptr((*StatSample)(unsafe.Pointer(pNew)).FiCol)*8)) == uint64(0)) {
  65902 		goto __6
  65903 	}
  65904 	if !((*StatSample)(unsafe.Pointer(pOld)).FisPSample != 0) {
  65905 		goto __7
  65906 	}
  65907 	return
  65908 __7:
  65909 	;
  65910 	if !(pUpgrade == uintptr(0) || sampleIsBetter(tls, p, pOld, pUpgrade) != 0) {
  65911 		goto __8
  65912 	}
  65913 	pUpgrade = pOld
  65914 __8:
  65915 	;
  65916 __6:
  65917 	;
  65918 	goto __4
  65919 __4:
  65920 	i--
  65921 	goto __3
  65922 	goto __5
  65923 __5:
  65924 	;
  65925 	if !(pUpgrade != 0) {
  65926 		goto __9
  65927 	}
  65928 	(*StatSample)(unsafe.Pointer(pUpgrade)).FiCol = (*StatSample)(unsafe.Pointer(pNew)).FiCol
  65929 	*(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pUpgrade)).FanEq + uintptr((*StatSample)(unsafe.Pointer(pUpgrade)).FiCol)*8)) = *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pNew)).FanEq + uintptr((*StatSample)(unsafe.Pointer(pUpgrade)).FiCol)*8))
  65930 	goto find_new_min
  65931 __9:
  65932 	;
  65933 __2:
  65934 	;
  65935 	if !((*StatAccum)(unsafe.Pointer(p)).FnSample >= (*StatAccum)(unsafe.Pointer(p)).FmxSample) {
  65936 		goto __10
  65937 	}
  65938 	pMin = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiMin)*40
  65939 	anEq = (*StatSample)(unsafe.Pointer(pMin)).FanEq
  65940 	anLt = (*StatSample)(unsafe.Pointer(pMin)).FanLt
  65941 	anDLt = (*StatSample)(unsafe.Pointer(pMin)).FanDLt
  65942 	sampleClear(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, pMin)
  65943 	libc.Xmemmove(tls, pMin, pMin+1*40, uint32(unsafe.Sizeof(StatSample{}))*uint32((*StatAccum)(unsafe.Pointer(p)).FnSample-(*StatAccum)(unsafe.Pointer(p)).FiMin-1))
  65944 	pSample = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FnSample-1)*40
  65945 	(*StatSample)(unsafe.Pointer(pSample)).FnRowid = U32(0)
  65946 	(*StatSample)(unsafe.Pointer(pSample)).FanEq = anEq
  65947 	(*StatSample)(unsafe.Pointer(pSample)).FanDLt = anDLt
  65948 	(*StatSample)(unsafe.Pointer(pSample)).FanLt = anLt
  65949 	(*StatAccum)(unsafe.Pointer(p)).FnSample = (*StatAccum)(unsafe.Pointer(p)).FmxSample - 1
  65950 __10:
  65951 	;
  65952 	pSample = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FnSample)*40
  65953 	sampleCopy(tls, p, pSample, pNew)
  65954 	(*StatAccum)(unsafe.Pointer(p)).FnSample++
  65955 
  65956 	libc.Xmemset(tls, (*StatSample)(unsafe.Pointer(pSample)).FanEq, 0, uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(nEqZero))
  65957 
  65958 find_new_min:
  65959 	if !((*StatAccum)(unsafe.Pointer(p)).FnSample >= (*StatAccum)(unsafe.Pointer(p)).FmxSample) {
  65960 		goto __11
  65961 	}
  65962 	iMin = -1
  65963 	i = 0
  65964 __12:
  65965 	if !(i < (*StatAccum)(unsafe.Pointer(p)).FmxSample) {
  65966 		goto __14
  65967 	}
  65968 	if !((*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*40)).FisPSample != 0) {
  65969 		goto __15
  65970 	}
  65971 	goto __13
  65972 __15:
  65973 	;
  65974 	if !(iMin < 0 || sampleIsBetter(tls, p, (*StatAccum)(unsafe.Pointer(p)).Fa+uintptr(iMin)*40, (*StatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*40) != 0) {
  65975 		goto __16
  65976 	}
  65977 	iMin = i
  65978 __16:
  65979 	;
  65980 	goto __13
  65981 __13:
  65982 	i++
  65983 	goto __12
  65984 	goto __14
  65985 __14:
  65986 	;
  65987 	(*StatAccum)(unsafe.Pointer(p)).FiMin = iMin
  65988 __11:
  65989 }
  65990 
  65991 func samplePushPrevious(tls *libc.TLS, p uintptr, iChng int32) {
  65992 	var i int32
  65993 
  65994 	for i = (*StatAccum)(unsafe.Pointer(p)).FnCol - 2; i >= iChng; i-- {
  65995 		var pBest uintptr = (*StatAccum)(unsafe.Pointer(p)).FaBest + uintptr(i)*40
  65996 		*(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer(pBest)).FanEq + uintptr(i)*8)) = *(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8))
  65997 		if (*StatAccum)(unsafe.Pointer(p)).FnSample < (*StatAccum)(unsafe.Pointer(p)).FmxSample || sampleIsBetter(tls, p, pBest, (*StatAccum)(unsafe.Pointer(p)).Fa+uintptr((*StatAccum)(unsafe.Pointer(p)).FiMin)*40) != 0 {
  65998 			sampleInsert(tls, p, pBest, i)
  65999 		}
  66000 	}
  66001 
  66002 	for i = (*StatAccum)(unsafe.Pointer(p)).FnSample - 1; i >= 0; i-- {
  66003 		var j int32
  66004 		for j = (*StatAccum)(unsafe.Pointer(p)).FnMaxEqZero; j < (*StatAccum)(unsafe.Pointer(p)).FnCol; j++ {
  66005 		}
  66006 	}
  66007 
  66008 	if iChng < (*StatAccum)(unsafe.Pointer(p)).FnMaxEqZero {
  66009 		for i = (*StatAccum)(unsafe.Pointer(p)).FnSample - 1; i >= 0; i-- {
  66010 			var j int32
  66011 			for j = iChng; j < (*StatAccum)(unsafe.Pointer(p)).FnCol; j++ {
  66012 				if *(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*40)).FanEq + uintptr(j)*8)) == uint64(0) {
  66013 					*(*TRowcnt)(unsafe.Pointer((*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa+uintptr(i)*40)).FanEq + uintptr(j)*8)) = *(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(j)*8))
  66014 				}
  66015 			}
  66016 		}
  66017 		(*StatAccum)(unsafe.Pointer(p)).FnMaxEqZero = iChng
  66018 	}
  66019 }
  66020 
  66021 func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  66022 	var i int32
  66023 
  66024 	var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv)))
  66025 	var iChng int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  66026 
  66027 	_ = argc
  66028 	_ = context
  66029 
  66030 	if (*StatAccum)(unsafe.Pointer(p)).FnRow == uint64(0) {
  66031 		for i = 0; i < (*StatAccum)(unsafe.Pointer(p)).FnCol; i++ {
  66032 			*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) = uint64(1)
  66033 		}
  66034 	} else {
  66035 		if (*StatAccum)(unsafe.Pointer(p)).FmxSample != 0 {
  66036 			samplePushPrevious(tls, p, iChng)
  66037 		}
  66038 
  66039 		for i = 0; i < iChng; i++ {
  66040 			*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8))++
  66041 		}
  66042 		for i = iChng; i < (*StatAccum)(unsafe.Pointer(p)).FnCol; i++ {
  66043 			*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(i)*8))++
  66044 			if (*StatAccum)(unsafe.Pointer(p)).FmxSample != 0 {
  66045 				*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr(i)*8)) += *(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8))
  66046 			}
  66047 			*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(i)*8)) = uint64(1)
  66048 		}
  66049 	}
  66050 
  66051 	(*StatAccum)(unsafe.Pointer(p)).FnRow++
  66052 	if (*StatAccum)(unsafe.Pointer(p)).FmxSample != 0 {
  66053 		var nLt TRowcnt
  66054 		if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))) == SQLITE_INTEGER {
  66055 			sampleSetRowidInt64(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, p+40, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
  66056 		} else {
  66057 			sampleSetRowid(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, p+40, Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))),
  66058 				Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
  66059 		}
  66060 		(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FiHash = libc.AssignPtrUint32(p+92, (*StatAccum)(unsafe.Pointer(p)).FiPrn*U32(1103515245)+U32(12345))
  66061 
  66062 		nLt = *(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr((*StatAccum)(unsafe.Pointer(p)).FnCol-1)*8))
  66063 
  66064 		if nLt/(*StatAccum)(unsafe.Pointer(p)).FnPSample != (nLt+uint64(1))/(*StatAccum)(unsafe.Pointer(p)).FnPSample {
  66065 			(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FisPSample = U8(1)
  66066 			(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FiCol = 0
  66067 			sampleInsert(tls, p, p+40, (*StatAccum)(unsafe.Pointer(p)).FnCol-1)
  66068 			(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FisPSample = U8(0)
  66069 		}
  66070 
  66071 		for i = 0; i < (*StatAccum)(unsafe.Pointer(p)).FnCol-1; i++ {
  66072 			(*StatAccum)(unsafe.Pointer(p)).Fcurrent.FiCol = i
  66073 			if i >= iChng || sampleIsBetterPost(tls, p, p+40, (*StatAccum)(unsafe.Pointer(p)).FaBest+uintptr(i)*40) != 0 {
  66074 				sampleCopy(tls, p, (*StatAccum)(unsafe.Pointer(p)).FaBest+uintptr(i)*40, p+40)
  66075 			}
  66076 		}
  66077 	} else if (*StatAccum)(unsafe.Pointer(p)).FnLimit != 0 && (*StatAccum)(unsafe.Pointer(p)).FnRow > TRowcnt((*StatAccum)(unsafe.Pointer(p)).FnLimit)*TRowcnt(int32((*StatAccum)(unsafe.Pointer(p)).FnSkipAhead)+1) {
  66078 		(*StatAccum)(unsafe.Pointer(p)).FnSkipAhead++
  66079 		Xsqlite3_result_int(tls, context, libc.Bool32(*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt)) > uint64(0)))
  66080 	}
  66081 }
  66082 
  66083 var statPushFuncdef = FuncDef{
  66084 	FnArg:      int8(2 + IsStat4),
  66085 	FfuncFlags: U32(SQLITE_UTF8),
  66086 	FxSFunc:    0,
  66087 	FzName:     ts + 11438}
  66088 
  66089 func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  66090 	bp := tls.Alloc(72)
  66091 	defer tls.Free(72)
  66092 
  66093 	var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv)))
  66094 
  66095 	var eCall int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  66096 
  66097 	if eCall == STAT_GET_STAT1 {
  66098 		var i int32
  66099 
  66100 		Xsqlite3StrAccumInit(tls, bp+24, uintptr(0), uintptr(0), 0, ((*StatAccum)(unsafe.Pointer(p)).FnKeyCol+1)*100)
  66101 		Xsqlite3_str_appendf(tls, bp+24, ts+11448,
  66102 			libc.VaList(bp, func() uint64 {
  66103 				if (*StatAccum)(unsafe.Pointer(p)).FnSkipAhead != 0 {
  66104 					return (*StatAccum)(unsafe.Pointer(p)).FnEst
  66105 				}
  66106 				return (*StatAccum)(unsafe.Pointer(p)).FnRow
  66107 			}()))
  66108 		for i = 0; i < (*StatAccum)(unsafe.Pointer(p)).FnKeyCol; i++ {
  66109 			var nDistinct U64 = *(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(i)*8)) + uint64(1)
  66110 			var iVal U64 = ((*StatAccum)(unsafe.Pointer(p)).FnRow + nDistinct - uint64(1)) / nDistinct
  66111 			if iVal == uint64(2) && (*StatAccum)(unsafe.Pointer(p)).FnRow*uint64(10) <= nDistinct*uint64(11) {
  66112 				iVal = uint64(1)
  66113 			}
  66114 			Xsqlite3_str_appendf(tls, bp+24, ts+11453, libc.VaList(bp+8, iVal))
  66115 
  66116 		}
  66117 		Xsqlite3ResultStrAccum(tls, context, bp+24)
  66118 	} else if eCall == STAT_GET_ROWID {
  66119 		if (*StatAccum)(unsafe.Pointer(p)).FiGet < 0 {
  66120 			samplePushPrevious(tls, p, 0)
  66121 			(*StatAccum)(unsafe.Pointer(p)).FiGet = 0
  66122 		}
  66123 		if (*StatAccum)(unsafe.Pointer(p)).FiGet < (*StatAccum)(unsafe.Pointer(p)).FnSample {
  66124 			var pS uintptr = (*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*40
  66125 			if (*StatSample)(unsafe.Pointer(pS)).FnRowid == U32(0) {
  66126 				Xsqlite3_result_int64(tls, context, *(*I64)(unsafe.Pointer(pS + 16)))
  66127 			} else {
  66128 				Xsqlite3_result_blob(tls, context, *(*uintptr)(unsafe.Pointer(pS + 16)), int32((*StatSample)(unsafe.Pointer(pS)).FnRowid),
  66129 					libc.UintptrFromInt32(-1))
  66130 			}
  66131 		}
  66132 	} else {
  66133 		var aCnt uintptr = uintptr(0)
  66134 
  66135 		var i int32
  66136 
  66137 		switch eCall {
  66138 		case STAT_GET_NEQ:
  66139 			aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*40)).FanEq
  66140 			break
  66141 			fallthrough
  66142 		case STAT_GET_NLT:
  66143 			aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*40)).FanLt
  66144 			break
  66145 			fallthrough
  66146 		default:
  66147 			{
  66148 				aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*40)).FanDLt
  66149 				(*StatAccum)(unsafe.Pointer(p)).FiGet++
  66150 				break
  66151 
  66152 			}
  66153 		}
  66154 		Xsqlite3StrAccumInit(tls, bp+48, uintptr(0), uintptr(0), 0, (*StatAccum)(unsafe.Pointer(p)).FnCol*100)
  66155 		for i = 0; i < (*StatAccum)(unsafe.Pointer(p)).FnCol; i++ {
  66156 			Xsqlite3_str_appendf(tls, bp+48, ts+11459, libc.VaList(bp+16, *(*TRowcnt)(unsafe.Pointer(aCnt + uintptr(i)*8))))
  66157 		}
  66158 		if (*Sqlite3_str)(unsafe.Pointer(bp+48)).FnChar != 0 {
  66159 			(*Sqlite3_str)(unsafe.Pointer(bp+48)).FnChar--
  66160 		}
  66161 		Xsqlite3ResultStrAccum(tls, context, bp+48)
  66162 	}
  66163 	_ = argc
  66164 }
  66165 
  66166 var statGetFuncdef = FuncDef{
  66167 	FnArg:      int8(1 + IsStat4),
  66168 	FfuncFlags: U32(SQLITE_UTF8),
  66169 	FxSFunc:    0,
  66170 	FzName:     ts + 11465}
  66171 
  66172 func callStatGet(tls *libc.TLS, pParse uintptr, regStat int32, iParam int32, regOut int32) {
  66173 	Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Integer, iParam, regStat+1)
  66174 
  66175 	Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, 1+IsStat4,
  66176 		uintptr(unsafe.Pointer(&statGetFuncdef)), 0)
  66177 }
  66178 
  66179 func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintptr, iStatCur int32, iMem int32, iTab int32) {
  66180 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  66181 	var pIdx uintptr
  66182 	var iIdxCur int32
  66183 	var iTabCur int32
  66184 	var v uintptr
  66185 	var i int32
  66186 	var jZeroRows int32 = -1
  66187 	var iDb int32
  66188 	var needTableCnt U8 = U8(1)
  66189 	var regNewRowid int32 = libc.PostIncInt32(&iMem, 1)
  66190 	var regStat int32 = libc.PostIncInt32(&iMem, 1)
  66191 	var regChng int32 = libc.PostIncInt32(&iMem, 1)
  66192 	var regRowid int32 = libc.PostIncInt32(&iMem, 1)
  66193 	var regTemp int32 = libc.PostIncInt32(&iMem, 1)
  66194 	var regTemp2 int32 = libc.PostIncInt32(&iMem, 1)
  66195 	var regTabname int32 = libc.PostIncInt32(&iMem, 1)
  66196 	var regIdxname int32 = libc.PostIncInt32(&iMem, 1)
  66197 	var regStat1 int32 = libc.PostIncInt32(&iMem, 1)
  66198 	var regPrev int32 = iMem
  66199 	var pStat1 uintptr = uintptr(0)
  66200 
  66201 	(*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 {
  66202 		if (*Parse)(unsafe.Pointer(pParse)).FnMem > iMem {
  66203 			return (*Parse)(unsafe.Pointer(pParse)).FnMem
  66204 		}
  66205 		return iMem
  66206 	}()
  66207 	v = Xsqlite3GetVdbe(tls, pParse)
  66208 	if v == uintptr(0) || pTab == uintptr(0) {
  66209 		return
  66210 	}
  66211 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  66212 		return
  66213 	}
  66214 	if Xsqlite3_strlike(tls, ts+11474, (*Table)(unsafe.Pointer(pTab)).FzName, uint32('\\')) == 0 {
  66215 		return
  66216 	}
  66217 
  66218 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  66219 
  66220 	if Xsqlite3AuthCheck(tls, pParse, SQLITE_ANALYZE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0),
  66221 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName) != 0 {
  66222 		return
  66223 	}
  66224 
  66225 	if (*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 {
  66226 		pStat1 = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(Table{}))+uint32(13)))
  66227 		if pStat1 == uintptr(0) {
  66228 			return
  66229 		}
  66230 		(*Table)(unsafe.Pointer(pStat1)).FzName = pStat1 + 1*64
  66231 		libc.Xmemcpy(tls, (*Table)(unsafe.Pointer(pStat1)).FzName, ts+11348, uint32(13))
  66232 		(*Table)(unsafe.Pointer(pStat1)).FnCol = int16(3)
  66233 		(*Table)(unsafe.Pointer(pStat1)).FiPKey = int16(-1)
  66234 		Xsqlite3VdbeAddOp4(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Noop, 0, 0, 0, pStat1, -6)
  66235 	}
  66236 
  66237 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab)).FzName)
  66238 	iTabCur = libc.PostIncInt32(&iTab, 1)
  66239 	iIdxCur = libc.PostIncInt32(&iTab, 1)
  66240 	(*Parse)(unsafe.Pointer(pParse)).FnTab = func() int32 {
  66241 		if (*Parse)(unsafe.Pointer(pParse)).FnTab > iTab {
  66242 			return (*Parse)(unsafe.Pointer(pParse)).FnTab
  66243 		}
  66244 		return iTab
  66245 	}()
  66246 	Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, OP_OpenRead)
  66247 	Xsqlite3VdbeLoadString(tls, v, regTabname, (*Table)(unsafe.Pointer(pTab)).FzName)
  66248 
  66249 	for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  66250 		var nCol int32
  66251 		var addrRewind int32
  66252 		var addrNextRow int32
  66253 		var zIdxName uintptr
  66254 		var nColTest int32
  66255 
  66256 		if pOnlyIdx != 0 && pOnlyIdx != pIdx {
  66257 			continue
  66258 		}
  66259 		if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) {
  66260 			needTableCnt = U8(0)
  66261 		}
  66262 		if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) && int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  66263 			nCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  66264 			zIdxName = (*Table)(unsafe.Pointer(pTab)).FzName
  66265 			nColTest = nCol - 1
  66266 		} else {
  66267 			nCol = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  66268 			zIdxName = (*Index)(unsafe.Pointer(pIdx)).FzName
  66269 			if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x8>>3)) != 0 {
  66270 				nColTest = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) - 1
  66271 			} else {
  66272 				nColTest = nCol - 1
  66273 			}
  66274 		}
  66275 
  66276 		Xsqlite3VdbeLoadString(tls, v, regIdxname, zIdxName)
  66277 
  66278 		(*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 {
  66279 			if (*Parse)(unsafe.Pointer(pParse)).FnMem > regPrev+nColTest {
  66280 				return (*Parse)(unsafe.Pointer(pParse)).FnMem
  66281 			}
  66282 			return regPrev + nColTest
  66283 		}()
  66284 
  66285 		Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iIdxCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb)
  66286 		Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx)
  66287 
  66288 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nCol, regStat+1)
  66289 
  66290 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid)
  66291 		if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) {
  66292 			Xsqlite3VdbeAddOp2(tls, v, OP_Count, iIdxCur, regTemp)
  66293 			addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iIdxCur)
  66294 
  66295 		} else {
  66296 			addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iIdxCur)
  66297 
  66298 			Xsqlite3VdbeAddOp3(tls, v, OP_Count, iIdxCur, regTemp, 1)
  66299 		}
  66300 
  66301 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2)
  66302 		Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat+1, regStat, 4,
  66303 			uintptr(unsafe.Pointer(&statInitFuncdef)), 0)
  66304 
  66305 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regChng)
  66306 		addrNextRow = Xsqlite3VdbeCurrentAddr(tls, v)
  66307 
  66308 		if nColTest > 0 {
  66309 			var endDistinctTest int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
  66310 			var aGotoChng uintptr
  66311 			aGotoChng = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(int32(0)))*uint32(nColTest)))
  66312 			if aGotoChng == uintptr(0) {
  66313 				continue
  66314 			}
  66315 
  66316 			Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  66317 			addrNextRow = Xsqlite3VdbeCurrentAddr(tls, v)
  66318 			if nColTest == 1 && int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == 1 && int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None {
  66319 				Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, regPrev, endDistinctTest)
  66320 
  66321 			}
  66322 			for i = 0; i < nColTest; i++ {
  66323 				var pColl uintptr = Xsqlite3LocateCollSeq(tls, pParse, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*4)))
  66324 				Xsqlite3VdbeAddOp2(tls, v, OP_Integer, i, regChng)
  66325 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, i, regTemp)
  66326 
  66327 				*(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4)) = Xsqlite3VdbeAddOp4(tls, v, OP_Ne, regTemp, 0, regPrev+i, pColl, -2)
  66328 				Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ))
  66329 
  66330 			}
  66331 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nColTest, regChng)
  66332 			Xsqlite3VdbeGoto(tls, v, endDistinctTest)
  66333 
  66334 			Xsqlite3VdbeJumpHere(tls, v, addrNextRow-1)
  66335 			for i = 0; i < nColTest; i++ {
  66336 				Xsqlite3VdbeJumpHere(tls, v, *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4)))
  66337 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, i, regPrev+i)
  66338 
  66339 			}
  66340 			Xsqlite3VdbeResolveLabel(tls, v, endDistinctTest)
  66341 			Xsqlite3DbFree(tls, db, aGotoChng)
  66342 		}
  66343 
  66344 		if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) {
  66345 			if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  66346 				Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iIdxCur, regRowid)
  66347 			} else {
  66348 				var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, (*Index)(unsafe.Pointer(pIdx)).FpTable)
  66349 				var j int32
  66350 				var k int32
  66351 				var regKey int32
  66352 				regKey = Xsqlite3GetTempRange(tls, pParse, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol))
  66353 				for j = 0; j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); j++ {
  66354 					k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2))))
  66355 
  66356 					Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, k, regKey+j)
  66357 
  66358 				}
  66359 				Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol), regRowid)
  66360 				Xsqlite3ReleaseTempRange(tls, pParse, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol))
  66361 			}
  66362 		}
  66363 
  66364 		{
  66365 			Xsqlite3VdbeAddFunctionCall(tls, pParse, 1, regStat, regTemp, 2+IsStat4,
  66366 				uintptr(unsafe.Pointer(&statPushFuncdef)), 0)
  66367 			if (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit != 0 {
  66368 				var j1 int32
  66369 				var j2 int32
  66370 				var j3 int32
  66371 				j1 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regTemp)
  66372 				j2 = Xsqlite3VdbeAddOp1(tls, v, OP_If, regTemp)
  66373 				j3 = Xsqlite3VdbeAddOp4Int(tls, v, OP_SeekGT, iIdxCur, 0, regPrev, 1)
  66374 
  66375 				Xsqlite3VdbeJumpHere(tls, v, j1)
  66376 				Xsqlite3VdbeAddOp2(tls, v, OP_Next, iIdxCur, addrNextRow)
  66377 				Xsqlite3VdbeJumpHere(tls, v, j2)
  66378 				Xsqlite3VdbeJumpHere(tls, v, j3)
  66379 			} else {
  66380 				Xsqlite3VdbeAddOp2(tls, v, OP_Next, iIdxCur, addrNextRow)
  66381 			}
  66382 
  66383 		}
  66384 
  66385 		callStatGet(tls, pParse, regStat, STAT_GET_STAT1, regStat1)
  66386 
  66387 		Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTabname, 3, regTemp, ts+11484, 0)
  66388 		Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur, regNewRowid)
  66389 		Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur, regTemp, regNewRowid)
  66390 		Xsqlite3VdbeChangeP4(tls, v, -1, pStat1, -5)
  66391 		Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND))
  66392 
  66393 		if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) && (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0 {
  66394 			var regEq int32 = regStat1
  66395 			var regLt int32 = regStat1 + 1
  66396 			var regDLt int32 = regStat1 + 2
  66397 			var regSample int32 = regStat1 + 3
  66398 			var regCol int32 = regStat1 + 4
  66399 			var regSampleRowid int32 = regCol + nCol
  66400 			var addrNext int32
  66401 			var addrIsNull int32
  66402 			var seekOp U8
  66403 			if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  66404 				seekOp = uint8(OP_NotExists)
  66405 			} else {
  66406 				seekOp = uint8(OP_NotFound)
  66407 			}
  66408 
  66409 			(*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 {
  66410 				if (*Parse)(unsafe.Pointer(pParse)).FnMem > regCol+nCol {
  66411 					return (*Parse)(unsafe.Pointer(pParse)).FnMem
  66412 				}
  66413 				return regCol + nCol
  66414 			}()
  66415 
  66416 			addrNext = Xsqlite3VdbeCurrentAddr(tls, v)
  66417 			callStatGet(tls, pParse, regStat, STAT_GET_ROWID, regSampleRowid)
  66418 			addrIsNull = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regSampleRowid)
  66419 
  66420 			callStatGet(tls, pParse, regStat, STAT_GET_NEQ, regEq)
  66421 			callStatGet(tls, pParse, regStat, STAT_GET_NLT, regLt)
  66422 			callStatGet(tls, pParse, regStat, STAT_GET_NDLT, regDLt)
  66423 			Xsqlite3VdbeAddOp4Int(tls, v, int32(seekOp), iTabCur, addrNext, regSampleRowid, 0)
  66424 
  66425 			for i = 0; i < nCol; i++ {
  66426 				Xsqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iTabCur, i, regCol+i)
  66427 			}
  66428 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regCol, nCol, regSample)
  66429 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regTabname, 6, regTemp)
  66430 			Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur+1, regNewRowid)
  66431 			Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur+1, regTemp, regNewRowid)
  66432 			Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 1, addrNext)
  66433 			Xsqlite3VdbeJumpHere(tls, v, addrIsNull)
  66434 		}
  66435 
  66436 		Xsqlite3VdbeJumpHere(tls, v, addrRewind)
  66437 	}
  66438 
  66439 	if pOnlyIdx == uintptr(0) && needTableCnt != 0 {
  66440 		Xsqlite3VdbeAddOp2(tls, v, OP_Count, iTabCur, regStat1)
  66441 		jZeroRows = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regStat1)
  66442 		Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regIdxname)
  66443 
  66444 		Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTabname, 3, regTemp, ts+11484, 0)
  66445 		Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur, regNewRowid)
  66446 		Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur, regTemp, regNewRowid)
  66447 		Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND))
  66448 		Xsqlite3VdbeChangeP4(tls, v, -1, pStat1, -5)
  66449 		Xsqlite3VdbeJumpHere(tls, v, jZeroRows)
  66450 	}
  66451 }
  66452 
  66453 func loadAnalysis(tls *libc.TLS, pParse uintptr, iDb int32) {
  66454 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  66455 	if v != 0 {
  66456 		Xsqlite3VdbeAddOp1(tls, v, OP_LoadAnalysis, iDb)
  66457 	}
  66458 }
  66459 
  66460 func analyzeDatabase(tls *libc.TLS, pParse uintptr, iDb int32) {
  66461 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  66462 	var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  66463 	var k uintptr
  66464 	var iStatCur int32
  66465 	var iMem int32
  66466 	var iTab int32
  66467 
  66468 	Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  66469 	iStatCur = (*Parse)(unsafe.Pointer(pParse)).FnTab
  66470 	*(*int32)(unsafe.Pointer(pParse + 40)) += 3
  66471 	openStatTable(tls, pParse, iDb, iStatCur, uintptr(0), uintptr(0))
  66472 	iMem = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  66473 	iTab = (*Parse)(unsafe.Pointer(pParse)).FnTab
  66474 
  66475 	for k = (*Hash)(unsafe.Pointer(pSchema + 8)).Ffirst; k != 0; k = (*HashElem)(unsafe.Pointer(k)).Fnext {
  66476 		var pTab uintptr = (*HashElem)(unsafe.Pointer(k)).Fdata
  66477 		analyzeOneTable(tls, pParse, pTab, uintptr(0), iStatCur, iMem, iTab)
  66478 	}
  66479 	loadAnalysis(tls, pParse, iDb)
  66480 }
  66481 
  66482 func analyzeTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintptr) {
  66483 	var iDb int32
  66484 	var iStatCur int32
  66485 
  66486 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  66487 	Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  66488 	iStatCur = (*Parse)(unsafe.Pointer(pParse)).FnTab
  66489 	*(*int32)(unsafe.Pointer(pParse + 40)) += 3
  66490 	if pOnlyIdx != 0 {
  66491 		openStatTable(tls, pParse, iDb, iStatCur, (*Index)(unsafe.Pointer(pOnlyIdx)).FzName, ts+11488)
  66492 	} else {
  66493 		openStatTable(tls, pParse, iDb, iStatCur, (*Table)(unsafe.Pointer(pTab)).FzName, ts+11492)
  66494 	}
  66495 	analyzeOneTable(tls, pParse, pTab, pOnlyIdx, iStatCur, (*Parse)(unsafe.Pointer(pParse)).FnMem+1, (*Parse)(unsafe.Pointer(pParse)).FnTab)
  66496 	loadAnalysis(tls, pParse, iDb)
  66497 }
  66498 
  66499 // Generate code for the ANALYZE command.  The parser calls this routine
  66500 // when it recognizes an ANALYZE command.
  66501 //
  66502 //	ANALYZE                            -- 1
  66503 //	ANALYZE  <database>                -- 2
  66504 //	ANALYZE  ?<database>.?<tablename>  -- 3
  66505 //
  66506 // Form 1 causes all indices in all attached databases to be analyzed.
  66507 // Form 2 analyzes all indices the single database named.
  66508 // Form 3 analyzes all indices associated with the named table.
  66509 func Xsqlite3Analyze(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr) {
  66510 	bp := tls.Alloc(4)
  66511 	defer tls.Free(4)
  66512 
  66513 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  66514 	var iDb int32
  66515 	var i int32
  66516 	var z uintptr
  66517 	var zDb uintptr
  66518 	var pTab uintptr
  66519 	var pIdx uintptr
  66520 
  66521 	var v uintptr
  66522 
  66523 	if SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) {
  66524 		return
  66525 	}
  66526 
  66527 	if pName1 == uintptr(0) {
  66528 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  66529 			if i == 1 {
  66530 				continue
  66531 			}
  66532 			analyzeDatabase(tls, pParse, i)
  66533 		}
  66534 	} else if (*Token)(unsafe.Pointer(pName2)).Fn == uint32(0) && libc.AssignInt32(&iDb, Xsqlite3FindDb(tls, db, pName1)) >= 0 {
  66535 		analyzeDatabase(tls, pParse, iDb)
  66536 	} else {
  66537 		iDb = Xsqlite3TwoPartName(tls, pParse, pName1, pName2, bp)
  66538 		if iDb >= 0 {
  66539 			if (*Token)(unsafe.Pointer(pName2)).Fn != 0 {
  66540 				zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  66541 			} else {
  66542 				zDb = uintptr(0)
  66543 			}
  66544 			z = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp)))
  66545 			if z != 0 {
  66546 				if libc.AssignUintptr(&pIdx, Xsqlite3FindIndex(tls, db, z, zDb)) != uintptr(0) {
  66547 					analyzeTable(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpTable, pIdx)
  66548 				} else if libc.AssignUintptr(&pTab, Xsqlite3LocateTable(tls, pParse, uint32(0), z, zDb)) != uintptr(0) {
  66549 					analyzeTable(tls, pParse, pTab, uintptr(0))
  66550 				}
  66551 				Xsqlite3DbFree(tls, db, z)
  66552 			}
  66553 		}
  66554 	}
  66555 	if int32((*Sqlite3)(unsafe.Pointer(db)).FnSqlExec) == 0 && libc.AssignUintptr(&v, Xsqlite3GetVdbe(tls, pParse)) != uintptr(0) {
  66556 		Xsqlite3VdbeAddOp0(tls, v, OP_Expire)
  66557 	}
  66558 }
  66559 
  66560 type analysisInfo = struct {
  66561 	Fdb        uintptr
  66562 	FzDatabase uintptr
  66563 }
  66564 
  66565 // Used to pass information from the analyzer reader through to the
  66566 // callback routine.
  66567 type AnalysisInfo = analysisInfo
  66568 
  66569 func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, aLog uintptr, pIndex uintptr) {
  66570 	var z uintptr = zIntArray
  66571 	var c int32
  66572 	var i int32
  66573 	var v TRowcnt
  66574 
  66575 	if z == uintptr(0) {
  66576 		z = ts + 1554
  66577 	}
  66578 	for i = 0; *(*uint8)(unsafe.Pointer(z)) != 0 && i < nOut; i++ {
  66579 		v = uint64(0)
  66580 		for libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z)))) >= '0' && c <= '9' {
  66581 			v = v*uint64(10) + TRowcnt(c) - uint64('0')
  66582 			z++
  66583 		}
  66584 		if aOut != 0 {
  66585 			*(*TRowcnt)(unsafe.Pointer(aOut + uintptr(i)*8)) = v
  66586 		}
  66587 		if aLog != 0 {
  66588 			*(*LogEst)(unsafe.Pointer(aLog + uintptr(i)*2)) = Xsqlite3LogEst(tls, v)
  66589 		}
  66590 		if int32(*(*uint8)(unsafe.Pointer(z))) == ' ' {
  66591 			z++
  66592 		}
  66593 	}
  66594 	if pIndex != 0 {
  66595 		libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(0), 2, 0x4)
  66596 		libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(0), 6, 0x40)
  66597 		for *(*uint8)(unsafe.Pointer(z)) != 0 {
  66598 			if Xsqlite3_strglob(tls, ts+11496, z) == 0 {
  66599 				libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 2, 0x4)
  66600 			} else if Xsqlite3_strglob(tls, ts+11507, z) == 0 {
  66601 				var sz int32 = Xsqlite3Atoi(tls, z+uintptr(3))
  66602 				if sz < 2 {
  66603 					sz = 2
  66604 				}
  66605 				(*Index)(unsafe.Pointer(pIndex)).FszIdxRow = Xsqlite3LogEst(tls, uint64(sz))
  66606 			} else if Xsqlite3_strglob(tls, ts+11517, z) == 0 {
  66607 				libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 6, 0x40)
  66608 			}
  66609 			for int32(*(*uint8)(unsafe.Pointer(z))) != 0 && int32(*(*uint8)(unsafe.Pointer(z))) != ' ' {
  66610 				z++
  66611 			}
  66612 			for int32(*(*uint8)(unsafe.Pointer(z))) == ' ' {
  66613 				z++
  66614 			}
  66615 		}
  66616 	}
  66617 }
  66618 
  66619 func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotUsed uintptr) int32 {
  66620 	bp := tls.Alloc(96)
  66621 	defer tls.Free(96)
  66622 
  66623 	var pInfo uintptr = pData
  66624 	var pIndex uintptr
  66625 	var pTable uintptr
  66626 	var z uintptr
  66627 
  66628 	_ = NotUsed
  66629 	_ = argc
  66630 
  66631 	if argv == uintptr(0) || *(*uintptr)(unsafe.Pointer(argv)) == uintptr(0) || *(*uintptr)(unsafe.Pointer(argv + 2*4)) == uintptr(0) {
  66632 		return 0
  66633 	}
  66634 	pTable = Xsqlite3FindTable(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase)
  66635 	if pTable == uintptr(0) {
  66636 		return 0
  66637 	}
  66638 	if *(*uintptr)(unsafe.Pointer(argv + 1*4)) == uintptr(0) {
  66639 		pIndex = uintptr(0)
  66640 	} else if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*uintptr)(unsafe.Pointer(argv + 1*4))) == 0 {
  66641 		pIndex = Xsqlite3PrimaryKeyIndex(tls, pTable)
  66642 	} else {
  66643 		pIndex = Xsqlite3FindIndex(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + 1*4)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase)
  66644 	}
  66645 	z = *(*uintptr)(unsafe.Pointer(argv + 2*4))
  66646 
  66647 	if pIndex != 0 {
  66648 		var aiRowEst uintptr = uintptr(0)
  66649 		var nCol int32 = int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol) + 1
  66650 
  66651 		if (*Index)(unsafe.Pointer(pIndex)).FaiRowEst == uintptr(0) {
  66652 			(*Index)(unsafe.Pointer(pIndex)).FaiRowEst = Xsqlite3MallocZero(tls, uint64(uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(nCol)))
  66653 			if (*Index)(unsafe.Pointer(pIndex)).FaiRowEst == uintptr(0) {
  66654 				Xsqlite3OomFault(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb)
  66655 			}
  66656 		}
  66657 		aiRowEst = (*Index)(unsafe.Pointer(pIndex)).FaiRowEst
  66658 		libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(0), 2, 0x4)
  66659 		decodeIntArray(tls, z, nCol, aiRowEst, (*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst, pIndex)
  66660 		libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 7, 0x80)
  66661 		if (*Index)(unsafe.Pointer(pIndex)).FpPartIdxWhere == uintptr(0) {
  66662 			(*Table)(unsafe.Pointer(pTable)).FnRowLogEst = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst))
  66663 			*(*U32)(unsafe.Pointer(pTable + 28)) |= U32(TF_HasStat1)
  66664 		}
  66665 	} else {
  66666 		(*Index)(unsafe.Pointer(bp)).FszIdxRow = (*Table)(unsafe.Pointer(pTable)).FszTabRow
  66667 		decodeIntArray(tls, z, 1, uintptr(0), pTable+38, bp)
  66668 		(*Table)(unsafe.Pointer(pTable)).FszTabRow = (*Index)(unsafe.Pointer(bp)).FszIdxRow
  66669 		*(*U32)(unsafe.Pointer(pTable + 28)) |= U32(TF_HasStat1)
  66670 	}
  66671 
  66672 	return 0
  66673 }
  66674 
  66675 // If the Index.aSample variable is not NULL, delete the aSample[] array
  66676 // and its contents.
  66677 func Xsqlite3DeleteIndexSamples(tls *libc.TLS, db uintptr, pIdx uintptr) {
  66678 	if (*Index)(unsafe.Pointer(pIdx)).FaSample != 0 {
  66679 		var j int32
  66680 		for j = 0; j < (*Index)(unsafe.Pointer(pIdx)).FnSample; j++ {
  66681 			var p uintptr = (*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(j)*20
  66682 			Xsqlite3DbFree(tls, db, (*IndexSample)(unsafe.Pointer(p)).Fp)
  66683 		}
  66684 		Xsqlite3DbFree(tls, db, (*Index)(unsafe.Pointer(pIdx)).FaSample)
  66685 	}
  66686 	if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  66687 		(*Index)(unsafe.Pointer(pIdx)).FnSample = 0
  66688 		(*Index)(unsafe.Pointer(pIdx)).FaSample = uintptr(0)
  66689 	}
  66690 }
  66691 
  66692 func initAvgEq(tls *libc.TLS, pIdx uintptr) {
  66693 	if pIdx != 0 {
  66694 		var aSample uintptr = (*Index)(unsafe.Pointer(pIdx)).FaSample
  66695 		var pFinal uintptr = aSample + uintptr((*Index)(unsafe.Pointer(pIdx)).FnSample-1)*20
  66696 		var iCol int32
  66697 		var nCol int32 = 1
  66698 		if (*Index)(unsafe.Pointer(pIdx)).FnSampleCol > 1 {
  66699 			nCol = (*Index)(unsafe.Pointer(pIdx)).FnSampleCol - 1
  66700 			*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr(nCol)*8)) = uint64(1)
  66701 		}
  66702 		for iCol = 0; iCol < nCol; iCol++ {
  66703 			var nSample int32 = (*Index)(unsafe.Pointer(pIdx)).FnSample
  66704 			var i int32
  66705 			var sumEq TRowcnt = uint64(0)
  66706 			var avgEq TRowcnt = uint64(0)
  66707 			var nRow TRowcnt
  66708 			var nSum100 I64 = int64(0)
  66709 			var nDist100 I64
  66710 
  66711 			if !(int32((*Index)(unsafe.Pointer(pIdx)).FaiRowEst) != 0) || iCol >= int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) || *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(iCol+1)*8)) == uint64(0) {
  66712 				nRow = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(pFinal)).FanLt + uintptr(iCol)*8))
  66713 				nDist100 = I64(TRowcnt(int64(100)) * *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(pFinal)).FanDLt + uintptr(iCol)*8)))
  66714 				nSample--
  66715 			} else {
  66716 				nRow = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst))
  66717 				nDist100 = I64(TRowcnt(int64(100)) * *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst)) / *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(iCol+1)*8)))
  66718 			}
  66719 			(*Index)(unsafe.Pointer(pIdx)).FnRowEst0 = nRow
  66720 
  66721 			for i = 0; i < nSample; i++ {
  66722 				if i == (*Index)(unsafe.Pointer(pIdx)).FnSample-1 ||
  66723 					*(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*20)).FanDLt + uintptr(iCol)*8)) != *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i+1)*20)).FanDLt + uintptr(iCol)*8)) {
  66724 					sumEq = sumEq + *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*20)).FanEq + uintptr(iCol)*8))
  66725 					nSum100 = nSum100 + int64(100)
  66726 				}
  66727 			}
  66728 
  66729 			if nDist100 > nSum100 && sumEq < nRow {
  66730 				avgEq = TRowcnt(int64(100)) * (nRow - sumEq) / TRowcnt(nDist100-nSum100)
  66731 			}
  66732 			if avgEq == uint64(0) {
  66733 				avgEq = uint64(1)
  66734 			}
  66735 			*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr(iCol)*8)) = avgEq
  66736 		}
  66737 	}
  66738 }
  66739 
  66740 func findIndexOrPrimaryKey(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) uintptr {
  66741 	var pIdx uintptr = Xsqlite3FindIndex(tls, db, zName, zDb)
  66742 	if pIdx == uintptr(0) {
  66743 		var pTab uintptr = Xsqlite3FindTable(tls, db, zName, zDb)
  66744 		if pTab != 0 && !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  66745 			pIdx = Xsqlite3PrimaryKeyIndex(tls, pTab)
  66746 		}
  66747 	}
  66748 	return pIdx
  66749 }
  66750 
  66751 func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb uintptr) int32 {
  66752 	bp := tls.Alloc(20)
  66753 	defer tls.Free(20)
  66754 
  66755 	var rc int32
  66756 	*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
  66757 	var zSql uintptr
  66758 	var pPrevIdx uintptr = uintptr(0)
  66759 	var pSample uintptr
  66760 
  66761 	zSql = Xsqlite3MPrintf(tls, db, zSql1, libc.VaList(bp, zDb))
  66762 	if !(zSql != 0) {
  66763 		return SQLITE_NOMEM
  66764 	}
  66765 	rc = Xsqlite3_prepare(tls, db, zSql, -1, bp+16, uintptr(0))
  66766 	Xsqlite3DbFree(tls, db, zSql)
  66767 	if rc != 0 {
  66768 		return rc
  66769 	}
  66770 
  66771 	for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) == SQLITE_ROW {
  66772 		var nIdxCol int32 = 1
  66773 
  66774 		var zIndex uintptr
  66775 		var pIdx uintptr
  66776 		var nSample int32
  66777 		var nByte int32
  66778 		var i int32
  66779 		var pSpace uintptr
  66780 
  66781 		zIndex = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 0)
  66782 		if zIndex == uintptr(0) {
  66783 			continue
  66784 		}
  66785 		nSample = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 1)
  66786 		pIdx = findIndexOrPrimaryKey(tls, db, zIndex, zDb)
  66787 
  66788 		if pIdx == uintptr(0) {
  66789 			continue
  66790 		}
  66791 
  66792 		if !((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) && int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  66793 			nIdxCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  66794 		} else {
  66795 			nIdxCol = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  66796 		}
  66797 		(*Index)(unsafe.Pointer(pIdx)).FnSampleCol = nIdxCol
  66798 		nByte = int32(uint32(unsafe.Sizeof(IndexSample{})) * uint32(nSample))
  66799 		nByte = int32(uint32(nByte) + uint32(unsafe.Sizeof(TRowcnt(0)))*uint32(nIdxCol)*uint32(3)*uint32(nSample))
  66800 		nByte = int32(uint32(nByte) + uint32(nIdxCol)*uint32(unsafe.Sizeof(TRowcnt(0))))
  66801 
  66802 		(*Index)(unsafe.Pointer(pIdx)).FaSample = Xsqlite3DbMallocZero(tls, db, uint64(nByte))
  66803 		if (*Index)(unsafe.Pointer(pIdx)).FaSample == uintptr(0) {
  66804 			Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  66805 			return SQLITE_NOMEM
  66806 		}
  66807 		pSpace = (*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(nSample)*20
  66808 		(*Index)(unsafe.Pointer(pIdx)).FaAvgEq = pSpace
  66809 		pSpace += 8 * uintptr(nIdxCol)
  66810 		*(*U32)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable + 28)) |= U32(TF_HasStat4)
  66811 		for i = 0; i < nSample; i++ {
  66812 			(*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*20)).FanEq = pSpace
  66813 			pSpace += 8 * uintptr(nIdxCol)
  66814 			(*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*20)).FanLt = pSpace
  66815 			pSpace += 8 * uintptr(nIdxCol)
  66816 			(*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(i)*20)).FanDLt = pSpace
  66817 			pSpace += 8 * uintptr(nIdxCol)
  66818 		}
  66819 
  66820 	}
  66821 	rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  66822 	if rc != 0 {
  66823 		return rc
  66824 	}
  66825 
  66826 	zSql = Xsqlite3MPrintf(tls, db, zSql2, libc.VaList(bp+8, zDb))
  66827 	if !(zSql != 0) {
  66828 		return SQLITE_NOMEM
  66829 	}
  66830 	rc = Xsqlite3_prepare(tls, db, zSql, -1, bp+16, uintptr(0))
  66831 	Xsqlite3DbFree(tls, db, zSql)
  66832 	if rc != 0 {
  66833 		return rc
  66834 	}
  66835 
  66836 	for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) == SQLITE_ROW {
  66837 		var zIndex uintptr
  66838 		var pIdx uintptr
  66839 		var nCol int32 = 1
  66840 
  66841 		zIndex = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 0)
  66842 		if zIndex == uintptr(0) {
  66843 			continue
  66844 		}
  66845 		pIdx = findIndexOrPrimaryKey(tls, db, zIndex, zDb)
  66846 		if pIdx == uintptr(0) {
  66847 			continue
  66848 		}
  66849 
  66850 		nCol = (*Index)(unsafe.Pointer(pIdx)).FnSampleCol
  66851 		if pIdx != pPrevIdx {
  66852 			initAvgEq(tls, pPrevIdx)
  66853 			pPrevIdx = pIdx
  66854 		}
  66855 		pSample = (*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr((*Index)(unsafe.Pointer(pIdx)).FnSample)*20
  66856 		decodeIntArray(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 1), nCol, (*IndexSample)(unsafe.Pointer(pSample)).FanEq, uintptr(0), uintptr(0))
  66857 		decodeIntArray(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 2), nCol, (*IndexSample)(unsafe.Pointer(pSample)).FanLt, uintptr(0), uintptr(0))
  66858 		decodeIntArray(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 3), nCol, (*IndexSample)(unsafe.Pointer(pSample)).FanDLt, uintptr(0), uintptr(0))
  66859 
  66860 		(*IndexSample)(unsafe.Pointer(pSample)).Fn = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 4)
  66861 		(*IndexSample)(unsafe.Pointer(pSample)).Fp = Xsqlite3DbMallocZero(tls, db, uint64((*IndexSample)(unsafe.Pointer(pSample)).Fn+2))
  66862 		if (*IndexSample)(unsafe.Pointer(pSample)).Fp == uintptr(0) {
  66863 			Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  66864 			return SQLITE_NOMEM
  66865 		}
  66866 		if (*IndexSample)(unsafe.Pointer(pSample)).Fn != 0 {
  66867 			libc.Xmemcpy(tls, (*IndexSample)(unsafe.Pointer(pSample)).Fp, Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 4), uint32((*IndexSample)(unsafe.Pointer(pSample)).Fn))
  66868 		}
  66869 		(*Index)(unsafe.Pointer(pIdx)).FnSample++
  66870 	}
  66871 	rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
  66872 	if rc == SQLITE_OK {
  66873 		initAvgEq(tls, pPrevIdx)
  66874 	}
  66875 	return rc
  66876 }
  66877 
  66878 func loadStat4(tls *libc.TLS, db uintptr, zDb uintptr) int32 {
  66879 	var rc int32 = SQLITE_OK
  66880 	var pStat4 uintptr
  66881 
  66882 	if libc.AssignUintptr(&pStat4, Xsqlite3FindTable(tls, db, ts+11374, zDb)) != uintptr(0) &&
  66883 		int32((*Table)(unsafe.Pointer(pStat4)).FeTabType) == TABTYP_NORM {
  66884 		rc = loadStatTbl(tls, db,
  66885 			ts+11529,
  66886 			ts+11583,
  66887 			zDb)
  66888 	}
  66889 	return rc
  66890 }
  66891 
  66892 // Load the content of the sqlite_stat1 and sqlite_stat4 tables. The
  66893 // contents of sqlite_stat1 are used to populate the Index.aiRowEst[]
  66894 // arrays. The contents of sqlite_stat4 are used to populate the
  66895 // Index.aSample[] arrays.
  66896 //
  66897 // If the sqlite_stat1 table is not present in the database, SQLITE_ERROR
  66898 // is returned. In this case, even if SQLITE_ENABLE_STAT4 was defined
  66899 // during compilation and the sqlite_stat4 table is present, no data is
  66900 // read from it.
  66901 //
  66902 // If SQLITE_ENABLE_STAT4 was defined during compilation and the
  66903 // sqlite_stat4 table is not present in the database, SQLITE_ERROR is
  66904 // returned. However, in this case, data is read from the sqlite_stat1
  66905 // table (if it is present) before returning.
  66906 //
  66907 // If an OOM error occurs, this function always sets db->mallocFailed.
  66908 // This means if the caller does not care about other errors, the return
  66909 // code may be ignored.
  66910 func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 {
  66911 	bp := tls.Alloc(16)
  66912 	defer tls.Free(16)
  66913 
  66914 	var i uintptr
  66915 	var zSql uintptr
  66916 	var rc int32 = SQLITE_OK
  66917 	var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  66918 	var pStat1 uintptr
  66919 
  66920 	for i = (*Hash)(unsafe.Pointer(pSchema + 8)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
  66921 		var pTab uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
  66922 		*(*U32)(unsafe.Pointer(pTab + 28)) &= libc.Uint32FromInt32(libc.CplInt32(TF_HasStat1))
  66923 	}
  66924 	for i = (*Hash)(unsafe.Pointer(pSchema + 24)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
  66925 		var pIdx uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
  66926 		libc.SetBitFieldPtr16Uint32(pIdx+56, uint32(0), 7, 0x80)
  66927 		Xsqlite3DeleteIndexSamples(tls, db, pIdx)
  66928 		(*Index)(unsafe.Pointer(pIdx)).FaSample = uintptr(0)
  66929 	}
  66930 
  66931 	(*AnalysisInfo)(unsafe.Pointer(bp + 8)).Fdb = db
  66932 	(*AnalysisInfo)(unsafe.Pointer(bp + 8)).FzDatabase = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  66933 	if libc.AssignUintptr(&pStat1, Xsqlite3FindTable(tls, db, ts+11348, (*AnalysisInfo)(unsafe.Pointer(bp+8)).FzDatabase)) != 0 &&
  66934 		int32((*Table)(unsafe.Pointer(pStat1)).FeTabType) == TABTYP_NORM {
  66935 		zSql = Xsqlite3MPrintf(tls, db,
  66936 			ts+11635, libc.VaList(bp, (*AnalysisInfo)(unsafe.Pointer(bp+8)).FzDatabase))
  66937 		if zSql == uintptr(0) {
  66938 			rc = SQLITE_NOMEM
  66939 		} else {
  66940 			rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct {
  66941 				f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
  66942 			}{analysisLoader})), bp+8, uintptr(0))
  66943 			Xsqlite3DbFree(tls, db, zSql)
  66944 		}
  66945 	}
  66946 
  66947 	for i = (*Hash)(unsafe.Pointer(pSchema + 24)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
  66948 		var pIdx uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
  66949 		if !(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x80>>7) != 0) {
  66950 			Xsqlite3DefaultRowEst(tls, pIdx)
  66951 		}
  66952 	}
  66953 
  66954 	if rc == SQLITE_OK {
  66955 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++
  66956 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
  66957 		rc = loadStat4(tls, db, (*AnalysisInfo)(unsafe.Pointer(bp+8)).FzDatabase)
  66958 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable--
  66959 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = func() uint16 {
  66960 			if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 {
  66961 				return uint16(0)
  66962 			}
  66963 			return (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue
  66964 		}()
  66965 	}
  66966 	for i = (*Hash)(unsafe.Pointer(pSchema + 24)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
  66967 		var pIdx uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
  66968 		Xsqlite3_free(tls, (*Index)(unsafe.Pointer(pIdx)).FaiRowEst)
  66969 		(*Index)(unsafe.Pointer(pIdx)).FaiRowEst = uintptr(0)
  66970 	}
  66971 
  66972 	if rc == SQLITE_NOMEM {
  66973 		Xsqlite3OomFault(tls, db)
  66974 	}
  66975 	return rc
  66976 }
  66977 
  66978 func resolveAttachExpr(tls *libc.TLS, pName uintptr, pExpr uintptr) int32 {
  66979 	var rc int32 = SQLITE_OK
  66980 	if pExpr != 0 {
  66981 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_ID {
  66982 			rc = Xsqlite3ResolveExprNames(tls, pName, pExpr)
  66983 		} else {
  66984 			(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_STRING)
  66985 		}
  66986 	}
  66987 	return rc
  66988 }
  66989 
  66990 // Return true if zName points to a name that may be used to refer to
  66991 // database iDb attached to handle db.
  66992 func Xsqlite3DbIsNamed(tls *libc.TLS, db uintptr, iDb int32, zName uintptr) int32 {
  66993 	return libc.Bool32(Xsqlite3StrICmp(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName, zName) == 0 ||
  66994 		iDb == 0 && Xsqlite3StrICmp(tls, ts+6441, zName) == 0)
  66995 }
  66996 
  66997 func attachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  66998 	bp := tls.Alloc(48)
  66999 	defer tls.Free(48)
  67000 
  67001 	var i int32
  67002 	var rc int32
  67003 	var db uintptr
  67004 	var zName uintptr
  67005 	var zFile uintptr
  67006 
  67007 	var aNew uintptr
  67008 	var pNew uintptr
  67009 
  67010 	var pNewSchema uintptr
  67011 
  67012 	var pPager uintptr
  67013 	var iDb int32
  67014 	rc = 0
  67015 	db = Xsqlite3_context_db_handle(tls, context)
  67016 	*(*uintptr)(unsafe.Pointer(bp + 36)) = uintptr(0)
  67017 	*(*uintptr)(unsafe.Pointer(bp + 40)) = uintptr(0)
  67018 	pNew = uintptr(0)
  67019 	*(*uintptr)(unsafe.Pointer(bp + 44)) = uintptr(0)
  67020 
  67021 	_ = NotUsed
  67022 	zFile = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  67023 	zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  67024 	if !(zFile == uintptr(0)) {
  67025 		goto __1
  67026 	}
  67027 	zFile = ts + 1554
  67028 __1:
  67029 	;
  67030 	if !(zName == uintptr(0)) {
  67031 		goto __2
  67032 	}
  67033 	zName = ts + 1554
  67034 __2:
  67035 	;
  67036 	if !(uint32(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x4>>2)) != 0) {
  67037 		goto __3
  67038 	}
  67039 
  67040 	*(*uintptr)(unsafe.Pointer(bp + 24)) = uintptr(0)
  67041 	*(*uintptr)(unsafe.Pointer(bp + 32)) = Xsqlite3_vfs_find(tls, ts+3835)
  67042 	if !(*(*uintptr)(unsafe.Pointer(bp + 32)) == uintptr(0)) {
  67043 		goto __5
  67044 	}
  67045 	return
  67046 __5:
  67047 	;
  67048 	rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), ts+11676, db, bp+24, 0, SQLITE_OPEN_MAIN_DB)
  67049 	if !(rc == SQLITE_OK) {
  67050 		goto __6
  67051 	}
  67052 	pNewSchema = Xsqlite3SchemaGet(tls, db, *(*uintptr)(unsafe.Pointer(bp + 24)))
  67053 	if !(pNewSchema != 0) {
  67054 		goto __7
  67055 	}
  67056 
  67057 	pNew = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb)*16
  67058 	if !((*Db)(unsafe.Pointer(pNew)).FpBt != 0) {
  67059 		goto __9
  67060 	}
  67061 	Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer(pNew)).FpBt)
  67062 __9:
  67063 	;
  67064 	(*Db)(unsafe.Pointer(pNew)).FpBt = *(*uintptr)(unsafe.Pointer(bp + 24))
  67065 	(*Db)(unsafe.Pointer(pNew)).FpSchema = pNewSchema
  67066 	goto __8
  67067 __7:
  67068 	Xsqlite3BtreeClose(tls, *(*uintptr)(unsafe.Pointer(bp + 24)))
  67069 	rc = SQLITE_NOMEM
  67070 __8:
  67071 	;
  67072 __6:
  67073 	;
  67074 	if !(rc != 0) {
  67075 		goto __10
  67076 	}
  67077 	goto attach_error
  67078 __10:
  67079 	;
  67080 	goto __4
  67081 __3:
  67082 	if !((*Sqlite3)(unsafe.Pointer(db)).FnDb >= *(*int32)(unsafe.Pointer(db + 120 + 7*4))+2) {
  67083 		goto __11
  67084 	}
  67085 	*(*uintptr)(unsafe.Pointer(bp + 44)) = Xsqlite3MPrintf(tls, db, ts+11679,
  67086 		libc.VaList(bp, *(*int32)(unsafe.Pointer(db + 120 + 7*4))))
  67087 	goto attach_error
  67088 __11:
  67089 	;
  67090 	i = 0
  67091 __12:
  67092 	if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  67093 		goto __14
  67094 	}
  67095 
  67096 	if !(Xsqlite3DbIsNamed(tls, db, i, zName) != 0) {
  67097 		goto __15
  67098 	}
  67099 	*(*uintptr)(unsafe.Pointer(bp + 44)) = Xsqlite3MPrintf(tls, db, ts+11716, libc.VaList(bp+8, zName))
  67100 	goto attach_error
  67101 __15:
  67102 	;
  67103 	goto __13
  67104 __13:
  67105 	i++
  67106 	goto __12
  67107 	goto __14
  67108 __14:
  67109 	;
  67110 	if !((*Sqlite3)(unsafe.Pointer(db)).FaDb == db+476) {
  67111 		goto __16
  67112 	}
  67113 	aNew = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(Db{}))*uint32(3)))
  67114 	if !(aNew == uintptr(0)) {
  67115 		goto __18
  67116 	}
  67117 	return
  67118 __18:
  67119 	;
  67120 	libc.Xmemcpy(tls, aNew, (*Sqlite3)(unsafe.Pointer(db)).FaDb, uint32(unsafe.Sizeof(Db{}))*uint32(2))
  67121 	goto __17
  67122 __16:
  67123 	aNew = Xsqlite3DbRealloc(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaDb, uint64(uint32(unsafe.Sizeof(Db{}))*uint32((*Sqlite3)(unsafe.Pointer(db)).FnDb+1)))
  67124 	if !(aNew == uintptr(0)) {
  67125 		goto __19
  67126 	}
  67127 	return
  67128 __19:
  67129 	;
  67130 __17:
  67131 	;
  67132 	(*Sqlite3)(unsafe.Pointer(db)).FaDb = aNew
  67133 	pNew = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*Sqlite3)(unsafe.Pointer(db)).FnDb)*16
  67134 	libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Db{})))
  67135 
  67136 	*(*uint32)(unsafe.Pointer(bp + 28)) = (*Sqlite3)(unsafe.Pointer(db)).FopenFlags
  67137 	rc = Xsqlite3ParseUri(tls, (*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpVfs)).FzName, zFile, bp+28, bp+32, bp+36, bp+40)
  67138 	if !(rc != SQLITE_OK) {
  67139 		goto __20
  67140 	}
  67141 	if !(rc == SQLITE_NOMEM) {
  67142 		goto __21
  67143 	}
  67144 	Xsqlite3OomFault(tls, db)
  67145 __21:
  67146 	;
  67147 	Xsqlite3_result_error(tls, context, *(*uintptr)(unsafe.Pointer(bp + 40)), -1)
  67148 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 40)))
  67149 	return
  67150 __20:
  67151 	;
  67152 	*(*uint32)(unsafe.Pointer(bp + 28)) |= uint32(SQLITE_OPEN_MAIN_DB)
  67153 	rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), *(*uintptr)(unsafe.Pointer(bp + 36)), db, pNew+4, 0, int32(*(*uint32)(unsafe.Pointer(bp + 28))))
  67154 	(*Sqlite3)(unsafe.Pointer(db)).FnDb++
  67155 	(*Db)(unsafe.Pointer(pNew)).FzDbSName = Xsqlite3DbStrDup(tls, db, zName)
  67156 __4:
  67157 	;
  67158 	(*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache = U8(0)
  67159 	if !(rc == SQLITE_CONSTRAINT) {
  67160 		goto __22
  67161 	}
  67162 	rc = SQLITE_ERROR
  67163 	*(*uintptr)(unsafe.Pointer(bp + 44)) = Xsqlite3MPrintf(tls, db, ts+11746, 0)
  67164 	goto __23
  67165 __22:
  67166 	if !(rc == SQLITE_OK) {
  67167 		goto __24
  67168 	}
  67169 	(*Db)(unsafe.Pointer(pNew)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer(pNew)).FpBt)
  67170 	if !!(int32((*Db)(unsafe.Pointer(pNew)).FpSchema) != 0) {
  67171 		goto __25
  67172 	}
  67173 	rc = SQLITE_NOMEM
  67174 	goto __26
  67175 __25:
  67176 	if !((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pNew)).FpSchema)).Ffile_format != 0 && int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pNew)).FpSchema)).Fenc) != int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) {
  67177 		goto __27
  67178 	}
  67179 	*(*uintptr)(unsafe.Pointer(bp + 44)) = Xsqlite3MPrintf(tls, db,
  67180 		ts+11775, 0)
  67181 	rc = SQLITE_ERROR
  67182 __27:
  67183 	;
  67184 __26:
  67185 	;
  67186 	Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer(pNew)).FpBt)
  67187 	pPager = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer(pNew)).FpBt)
  67188 	Xsqlite3PagerLockingMode(tls, pPager, int32((*Sqlite3)(unsafe.Pointer(db)).FdfltLockMode))
  67189 	Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer(pNew)).FpBt,
  67190 		Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt, -1))
  67191 	Xsqlite3BtreeSetPagerFlags(tls, (*Db)(unsafe.Pointer(pNew)).FpBt,
  67192 		uint32(uint64(PAGER_SYNCHRONOUS_FULL)|(*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK)))
  67193 	Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer(pNew)).FpBt)
  67194 __24:
  67195 	;
  67196 __23:
  67197 	;
  67198 	(*Db)(unsafe.Pointer(pNew)).Fsafety_level = U8(SQLITE_DEFAULT_SYNCHRONOUS + 1)
  67199 	if !(rc == SQLITE_OK && (*Db)(unsafe.Pointer(pNew)).FzDbSName == uintptr(0)) {
  67200 		goto __28
  67201 	}
  67202 	rc = SQLITE_NOMEM
  67203 __28:
  67204 	;
  67205 	Xsqlite3_free_filename(tls, *(*uintptr)(unsafe.Pointer(bp + 36)))
  67206 
  67207 	if !(rc == SQLITE_OK) {
  67208 		goto __29
  67209 	}
  67210 	Xsqlite3BtreeEnterAll(tls, db)
  67211 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(0)
  67212 	*(*U32)(unsafe.Pointer(db + 24)) &= libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))
  67213 	if !!(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x4>>2) != 0) {
  67214 		goto __30
  67215 	}
  67216 	rc = Xsqlite3Init(tls, db, bp+44)
  67217 __30:
  67218 	;
  67219 	Xsqlite3BtreeLeaveAll(tls, db)
  67220 
  67221 __29:
  67222 	;
  67223 	if !(rc != 0) {
  67224 		goto __31
  67225 	}
  67226 	if !!(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x4>>2) != 0) {
  67227 		goto __32
  67228 	}
  67229 	iDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
  67230 
  67231 	if !((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpBt != 0) {
  67232 		goto __33
  67233 	}
  67234 	Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpBt)
  67235 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt = uintptr(0)
  67236 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema = uintptr(0)
  67237 __33:
  67238 	;
  67239 	Xsqlite3ResetAllSchemasOfConnection(tls, db)
  67240 	(*Sqlite3)(unsafe.Pointer(db)).FnDb = iDb
  67241 	if !(rc == SQLITE_NOMEM || rc == SQLITE_IOERR|int32(12)<<8) {
  67242 		goto __34
  67243 	}
  67244 	Xsqlite3OomFault(tls, db)
  67245 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 44)))
  67246 	*(*uintptr)(unsafe.Pointer(bp + 44)) = Xsqlite3MPrintf(tls, db, ts+1490, 0)
  67247 	goto __35
  67248 __34:
  67249 	if !(*(*uintptr)(unsafe.Pointer(bp + 44)) == uintptr(0)) {
  67250 		goto __36
  67251 	}
  67252 	*(*uintptr)(unsafe.Pointer(bp + 44)) = Xsqlite3MPrintf(tls, db, ts+11843, libc.VaList(bp+16, zFile))
  67253 __36:
  67254 	;
  67255 __35:
  67256 	;
  67257 __32:
  67258 	;
  67259 	goto attach_error
  67260 __31:
  67261 	;
  67262 	return
  67263 
  67264 attach_error:
  67265 	if !(*(*uintptr)(unsafe.Pointer(bp + 44)) != 0) {
  67266 		goto __37
  67267 	}
  67268 	Xsqlite3_result_error(tls, context, *(*uintptr)(unsafe.Pointer(bp + 44)), -1)
  67269 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 44)))
  67270 __37:
  67271 	;
  67272 	if !(rc != 0) {
  67273 		goto __38
  67274 	}
  67275 	Xsqlite3_result_error_code(tls, context, rc)
  67276 __38:
  67277 }
  67278 
  67279 func detachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  67280 	bp := tls.Alloc(152)
  67281 	defer tls.Free(152)
  67282 
  67283 	var zName uintptr
  67284 	var db uintptr
  67285 	var i int32
  67286 	var pDb uintptr
  67287 	var pEntry uintptr
  67288 
  67289 	var pTrig uintptr
  67290 	zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  67291 	db = Xsqlite3_context_db_handle(tls, context)
  67292 	pDb = uintptr(0)
  67293 
  67294 	_ = NotUsed
  67295 
  67296 	if !(zName == uintptr(0)) {
  67297 		goto __1
  67298 	}
  67299 	zName = ts + 1554
  67300 __1:
  67301 	;
  67302 	i = 0
  67303 __2:
  67304 	if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  67305 		goto __4
  67306 	}
  67307 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16
  67308 	if !((*Db)(unsafe.Pointer(pDb)).FpBt == uintptr(0)) {
  67309 		goto __5
  67310 	}
  67311 	goto __3
  67312 __5:
  67313 	;
  67314 	if !(Xsqlite3DbIsNamed(tls, db, i, zName) != 0) {
  67315 		goto __6
  67316 	}
  67317 	goto __4
  67318 __6:
  67319 	;
  67320 	goto __3
  67321 __3:
  67322 	i++
  67323 	goto __2
  67324 	goto __4
  67325 __4:
  67326 	;
  67327 	if !(i >= (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  67328 		goto __7
  67329 	}
  67330 	Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([128]uint8{})), bp+24, ts+11871, libc.VaList(bp, zName))
  67331 	goto detach_error
  67332 __7:
  67333 	;
  67334 	if !(i < 2) {
  67335 		goto __8
  67336 	}
  67337 	Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([128]uint8{})), bp+24, ts+11892, libc.VaList(bp+8, zName))
  67338 	goto detach_error
  67339 __8:
  67340 	;
  67341 	if !(Xsqlite3BtreeTxnState(tls, (*Db)(unsafe.Pointer(pDb)).FpBt) != SQLITE_TXN_NONE ||
  67342 		Xsqlite3BtreeIsInBackup(tls, (*Db)(unsafe.Pointer(pDb)).FpBt) != 0) {
  67343 		goto __9
  67344 	}
  67345 	Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([128]uint8{})), bp+24, ts+11918, libc.VaList(bp+16, zName))
  67346 	goto detach_error
  67347 __9:
  67348 	;
  67349 	pEntry = (*Hash)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema + 40)).Ffirst
  67350 __10:
  67351 	if !(pEntry != 0) {
  67352 		goto __11
  67353 	}
  67354 	pTrig = (*HashElem)(unsafe.Pointer(pEntry)).Fdata
  67355 	if !((*Trigger)(unsafe.Pointer(pTrig)).FpTabSchema == (*Db)(unsafe.Pointer(pDb)).FpSchema) {
  67356 		goto __12
  67357 	}
  67358 	(*Trigger)(unsafe.Pointer(pTrig)).FpTabSchema = (*Trigger)(unsafe.Pointer(pTrig)).FpSchema
  67359 __12:
  67360 	;
  67361 	pEntry = (*HashElem)(unsafe.Pointer(pEntry)).Fnext
  67362 	goto __10
  67363 __11:
  67364 	;
  67365 	Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  67366 	(*Db)(unsafe.Pointer(pDb)).FpBt = uintptr(0)
  67367 	(*Db)(unsafe.Pointer(pDb)).FpSchema = uintptr(0)
  67368 	Xsqlite3CollapseDatabaseArray(tls, db)
  67369 	return
  67370 
  67371 detach_error:
  67372 	Xsqlite3_result_error(tls, context, bp+24, -1)
  67373 }
  67374 
  67375 func codeAttach(tls *libc.TLS, pParse uintptr, type1 int32, pFunc uintptr, pAuthArg uintptr, pFilename uintptr, pDbname uintptr, pKey uintptr) {
  67376 	bp := tls.Alloc(32)
  67377 	defer tls.Free(32)
  67378 
  67379 	var rc int32
  67380 
  67381 	var v uintptr
  67382 	var db uintptr
  67383 	var regArgs int32
  67384 	var zAuthArg uintptr
  67385 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  67386 
  67387 	if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) {
  67388 		goto __1
  67389 	}
  67390 	goto attach_end
  67391 __1:
  67392 	;
  67393 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  67394 		goto __2
  67395 	}
  67396 	goto attach_end
  67397 __2:
  67398 	;
  67399 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  67400 	(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  67401 
  67402 	if !(SQLITE_OK != resolveAttachExpr(tls, bp, pFilename) || SQLITE_OK != resolveAttachExpr(tls, bp, pDbname) || SQLITE_OK != resolveAttachExpr(tls, bp, pKey)) {
  67403 		goto __3
  67404 	}
  67405 	goto attach_end
  67406 __3:
  67407 	;
  67408 	if !(pAuthArg != 0) {
  67409 		goto __4
  67410 	}
  67411 	if !(int32((*Expr)(unsafe.Pointer(pAuthArg)).Fop) == TK_STRING) {
  67412 		goto __5
  67413 	}
  67414 
  67415 	zAuthArg = *(*uintptr)(unsafe.Pointer(pAuthArg + 8))
  67416 	goto __6
  67417 __5:
  67418 	zAuthArg = uintptr(0)
  67419 __6:
  67420 	;
  67421 	rc = Xsqlite3AuthCheck(tls, pParse, type1, zAuthArg, uintptr(0), uintptr(0))
  67422 	if !(rc != SQLITE_OK) {
  67423 		goto __7
  67424 	}
  67425 	goto attach_end
  67426 __7:
  67427 	;
  67428 __4:
  67429 	;
  67430 	v = Xsqlite3GetVdbe(tls, pParse)
  67431 	regArgs = Xsqlite3GetTempRange(tls, pParse, 4)
  67432 	Xsqlite3ExprCode(tls, pParse, pFilename, regArgs)
  67433 	Xsqlite3ExprCode(tls, pParse, pDbname, regArgs+1)
  67434 	Xsqlite3ExprCode(tls, pParse, pKey, regArgs+2)
  67435 
  67436 	if !(v != 0) {
  67437 		goto __8
  67438 	}
  67439 	Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regArgs+3-int32((*FuncDef)(unsafe.Pointer(pFunc)).FnArg), regArgs+3,
  67440 		int32((*FuncDef)(unsafe.Pointer(pFunc)).FnArg), pFunc, 0)
  67441 
  67442 	Xsqlite3VdbeAddOp1(tls, v, OP_Expire, libc.Bool32(type1 == SQLITE_ATTACH))
  67443 __8:
  67444 	;
  67445 attach_end:
  67446 	Xsqlite3ExprDelete(tls, db, pFilename)
  67447 	Xsqlite3ExprDelete(tls, db, pDbname)
  67448 	Xsqlite3ExprDelete(tls, db, pKey)
  67449 }
  67450 
  67451 // Called by the parser to compile a DETACH statement.
  67452 //
  67453 //	DETACH pDbname
  67454 func Xsqlite3Detach(tls *libc.TLS, pParse uintptr, pDbname uintptr) {
  67455 	codeAttach(tls, pParse, SQLITE_DETACH, uintptr(unsafe.Pointer(&detach_func)), pDbname, uintptr(0), uintptr(0), pDbname)
  67456 }
  67457 
  67458 var detach_func = FuncDef{
  67459 	FnArg:      int8(1),
  67460 	FfuncFlags: U32(SQLITE_UTF8),
  67461 	FxSFunc:    0,
  67462 	FzName:     ts + 11940}
  67463 
  67464 // Called by the parser to compile an ATTACH statement.
  67465 //
  67466 //	ATTACH p AS pDbname KEY pKey
  67467 func Xsqlite3Attach(tls *libc.TLS, pParse uintptr, p uintptr, pDbname uintptr, pKey uintptr) {
  67468 	codeAttach(tls, pParse, SQLITE_ATTACH, uintptr(unsafe.Pointer(&attach_func)), p, p, pDbname, pKey)
  67469 }
  67470 
  67471 var attach_func = FuncDef{
  67472 	FnArg:      int8(3),
  67473 	FfuncFlags: U32(SQLITE_UTF8),
  67474 	FxSFunc:    0,
  67475 	FzName:     ts + 11954}
  67476 
  67477 func fixExprCb(tls *libc.TLS, p uintptr, pExpr uintptr) int32 {
  67478 	bp := tls.Alloc(8)
  67479 	defer tls.Free(8)
  67480 
  67481 	var pFix uintptr = *(*uintptr)(unsafe.Pointer(p + 24))
  67482 	if !(int32((*DbFixer)(unsafe.Pointer(pFix)).FbTemp) != 0) {
  67483 		*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_FromDDL)
  67484 	}
  67485 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VARIABLE {
  67486 		if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*DbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb)).Finit.Fbusy != 0 {
  67487 			(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_NULL)
  67488 		} else {
  67489 			Xsqlite3ErrorMsg(tls, (*DbFixer)(unsafe.Pointer(pFix)).FpParse, ts+11968, libc.VaList(bp, (*DbFixer)(unsafe.Pointer(pFix)).FzType))
  67490 			return WRC_Abort
  67491 		}
  67492 	}
  67493 	return WRC_Continue
  67494 }
  67495 
  67496 func fixSelectCb(tls *libc.TLS, p uintptr, pSelect uintptr) int32 {
  67497 	bp := tls.Alloc(24)
  67498 	defer tls.Free(24)
  67499 
  67500 	var pFix uintptr = *(*uintptr)(unsafe.Pointer(p + 24))
  67501 	var i int32
  67502 	var pItem uintptr
  67503 	var db uintptr = (*Parse)(unsafe.Pointer((*DbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb
  67504 	var iDb int32 = Xsqlite3FindDbName(tls, db, (*DbFixer)(unsafe.Pointer(pFix)).FzDb)
  67505 	var pList uintptr = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  67506 
  67507 	if pList == uintptr(0) {
  67508 		return WRC_Continue
  67509 	}
  67510 	i = 0
  67511 	pItem = pList + 8
  67512 __1:
  67513 	if !(i < (*SrcList)(unsafe.Pointer(pList)).FnSrc) {
  67514 		goto __3
  67515 	}
  67516 	{
  67517 		if int32((*DbFixer)(unsafe.Pointer(pFix)).FbTemp) == 0 {
  67518 			if (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase != 0 {
  67519 				if iDb != Xsqlite3FindDbName(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase) {
  67520 					Xsqlite3ErrorMsg(tls, (*DbFixer)(unsafe.Pointer(pFix)).FpParse,
  67521 						ts+11992,
  67522 						libc.VaList(bp, (*DbFixer)(unsafe.Pointer(pFix)).FzType, (*DbFixer)(unsafe.Pointer(pFix)).FpName, (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase))
  67523 					return WRC_Abort
  67524 				}
  67525 				Xsqlite3DbFree(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase)
  67526 				(*SrcItem)(unsafe.Pointer(pItem)).FzDatabase = uintptr(0)
  67527 				libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 9, 0x200)
  67528 			}
  67529 			(*SrcItem)(unsafe.Pointer(pItem)).FpSchema = (*DbFixer)(unsafe.Pointer(pFix)).FpSchema
  67530 			libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 7, 0x80)
  67531 		}
  67532 		if int32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*72 + 36 + 4))&0x400>>10) == 0 &&
  67533 			Xsqlite3WalkExpr(tls, pFix+4, *(*uintptr)(unsafe.Pointer(pList + 8 + uintptr(i)*72 + 48))) != 0 {
  67534 			return WRC_Abort
  67535 		}
  67536 
  67537 	}
  67538 	goto __2
  67539 __2:
  67540 	i++
  67541 	pItem += 72
  67542 	goto __1
  67543 	goto __3
  67544 __3:
  67545 	;
  67546 	if (*Select)(unsafe.Pointer(pSelect)).FpWith != 0 {
  67547 		for i = 0; i < (*With)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpWith)).FnCte; i++ {
  67548 			if Xsqlite3WalkSelect(tls, p, (*Cte)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpWith+12+uintptr(i)*24)).FpSelect) != 0 {
  67549 				return WRC_Abort
  67550 			}
  67551 		}
  67552 	}
  67553 	return WRC_Continue
  67554 }
  67555 
  67556 // Initialize a DbFixer structure.  This routine must be called prior
  67557 // to passing the structure to one of the sqliteFixAAAA() routines below.
  67558 func Xsqlite3FixInit(tls *libc.TLS, pFix uintptr, pParse uintptr, iDb int32, zType uintptr, pName uintptr) {
  67559 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  67560 
  67561 	(*DbFixer)(unsafe.Pointer(pFix)).FpParse = pParse
  67562 	(*DbFixer)(unsafe.Pointer(pFix)).FzDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  67563 	(*DbFixer)(unsafe.Pointer(pFix)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  67564 	(*DbFixer)(unsafe.Pointer(pFix)).FzType = zType
  67565 	(*DbFixer)(unsafe.Pointer(pFix)).FpName = pName
  67566 	(*DbFixer)(unsafe.Pointer(pFix)).FbTemp = U8(libc.Bool32(iDb == 1))
  67567 	(*DbFixer)(unsafe.Pointer(pFix)).Fw.FpParse = pParse
  67568 	(*DbFixer)(unsafe.Pointer(pFix)).Fw.FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  67569 		f func(*libc.TLS, uintptr, uintptr) int32
  67570 	}{fixExprCb}))
  67571 	(*DbFixer)(unsafe.Pointer(pFix)).Fw.FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  67572 		f func(*libc.TLS, uintptr, uintptr) int32
  67573 	}{fixSelectCb}))
  67574 	(*DbFixer)(unsafe.Pointer(pFix)).Fw.FxSelectCallback2 = *(*uintptr)(unsafe.Pointer(&struct {
  67575 		f func(*libc.TLS, uintptr, uintptr)
  67576 	}{Xsqlite3WalkWinDefnDummyCallback}))
  67577 	(*DbFixer)(unsafe.Pointer(pFix)).Fw.FwalkerDepth = 0
  67578 	(*DbFixer)(unsafe.Pointer(pFix)).Fw.FeCode = U16(0)
  67579 	*(*uintptr)(unsafe.Pointer(pFix + 4 + 24)) = pFix
  67580 }
  67581 
  67582 // The following set of routines walk through the parse tree and assign
  67583 // a specific database to all table references where the database name
  67584 // was left unspecified in the original SQL statement.  The pFix structure
  67585 // must have been initialized by a prior call to sqlite3FixInit().
  67586 //
  67587 // These routines are used to make sure that an index, trigger, or
  67588 // view in one database does not refer to objects in a different database.
  67589 // (Exception: indices, triggers, and views in the TEMP database are
  67590 // allowed to refer to anything.)  If a reference is explicitly made
  67591 // to an object in a different database, an error message is added to
  67592 // pParse->zErrMsg and these routines return non-zero.  If everything
  67593 // checks out, these routines return 0.
  67594 func Xsqlite3FixSrcList(tls *libc.TLS, pFix uintptr, pList uintptr) int32 {
  67595 	bp := tls.Alloc(76)
  67596 	defer tls.Free(76)
  67597 
  67598 	var res int32 = 0
  67599 	if pList != 0 {
  67600 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Select{})))
  67601 		(*Select)(unsafe.Pointer(bp)).FpSrc = pList
  67602 		res = Xsqlite3WalkSelect(tls, pFix+4, bp)
  67603 	}
  67604 	return res
  67605 }
  67606 
  67607 func Xsqlite3FixSelect(tls *libc.TLS, pFix uintptr, pSelect uintptr) int32 {
  67608 	return Xsqlite3WalkSelect(tls, pFix+4, pSelect)
  67609 }
  67610 
  67611 func Xsqlite3FixExpr(tls *libc.TLS, pFix uintptr, pExpr uintptr) int32 {
  67612 	return Xsqlite3WalkExpr(tls, pFix+4, pExpr)
  67613 }
  67614 
  67615 func Xsqlite3FixTriggerStep(tls *libc.TLS, pFix uintptr, pStep uintptr) int32 {
  67616 	for pStep != 0 {
  67617 		if Xsqlite3WalkSelect(tls, pFix+4, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect) != 0 ||
  67618 			Xsqlite3WalkExpr(tls, pFix+4, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere) != 0 ||
  67619 			Xsqlite3WalkExprList(tls, pFix+4, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList) != 0 ||
  67620 			Xsqlite3FixSrcList(tls, pFix, (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom) != 0 {
  67621 			return 1
  67622 		}
  67623 		{
  67624 			var pUp uintptr
  67625 			for pUp = (*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert; pUp != 0; pUp = (*Upsert)(unsafe.Pointer(pUp)).FpNextUpsert {
  67626 				if Xsqlite3WalkExprList(tls, pFix+4, (*Upsert)(unsafe.Pointer(pUp)).FpUpsertTarget) != 0 ||
  67627 					Xsqlite3WalkExpr(tls, pFix+4, (*Upsert)(unsafe.Pointer(pUp)).FpUpsertTargetWhere) != 0 ||
  67628 					Xsqlite3WalkExprList(tls, pFix+4, (*Upsert)(unsafe.Pointer(pUp)).FpUpsertSet) != 0 ||
  67629 					Xsqlite3WalkExpr(tls, pFix+4, (*Upsert)(unsafe.Pointer(pUp)).FpUpsertWhere) != 0 {
  67630 					return 1
  67631 				}
  67632 			}
  67633 
  67634 		}
  67635 		pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext
  67636 	}
  67637 
  67638 	return 0
  67639 }
  67640 
  67641 // Set or clear the access authorization function.
  67642 //
  67643 // The access authorization function is be called during the compilation
  67644 // phase to verify that the user has read and/or write access permission on
  67645 // various fields of the database.  The first argument to the auth function
  67646 // is a copy of the 3rd argument to this routine.  The second argument
  67647 // to the auth function is one of these constants:
  67648 //
  67649 //	SQLITE_CREATE_INDEX
  67650 //	SQLITE_CREATE_TABLE
  67651 //	SQLITE_CREATE_TEMP_INDEX
  67652 //	SQLITE_CREATE_TEMP_TABLE
  67653 //	SQLITE_CREATE_TEMP_TRIGGER
  67654 //	SQLITE_CREATE_TEMP_VIEW
  67655 //	SQLITE_CREATE_TRIGGER
  67656 //	SQLITE_CREATE_VIEW
  67657 //	SQLITE_DELETE
  67658 //	SQLITE_DROP_INDEX
  67659 //	SQLITE_DROP_TABLE
  67660 //	SQLITE_DROP_TEMP_INDEX
  67661 //	SQLITE_DROP_TEMP_TABLE
  67662 //	SQLITE_DROP_TEMP_TRIGGER
  67663 //	SQLITE_DROP_TEMP_VIEW
  67664 //	SQLITE_DROP_TRIGGER
  67665 //	SQLITE_DROP_VIEW
  67666 //	SQLITE_INSERT
  67667 //	SQLITE_PRAGMA
  67668 //	SQLITE_READ
  67669 //	SQLITE_SELECT
  67670 //	SQLITE_TRANSACTION
  67671 //	SQLITE_UPDATE
  67672 //
  67673 // The third and fourth arguments to the auth function are the name of
  67674 // the table and the column that are being accessed.  The auth function
  67675 // should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  If
  67676 // SQLITE_OK is returned, it means that access is allowed.  SQLITE_DENY
  67677 // means that the SQL statement will never-run - the sqlite3_exec() call
  67678 // will return with an error.  SQLITE_IGNORE means that the SQL statement
  67679 // should run but attempts to read the specified column will return NULL
  67680 // and attempts to write the column will be ignored.
  67681 //
  67682 // Setting the auth function to NULL disables this hook.  The default
  67683 // setting of the auth function is NULL.
  67684 func Xsqlite3_set_authorizer(tls *libc.TLS, db uintptr, xAuth uintptr, pArg uintptr) int32 {
  67685 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  67686 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  67687 	(*Sqlite3)(unsafe.Pointer(db)).FpAuthArg = pArg
  67688 	if (*Sqlite3)(unsafe.Pointer(db)).FxAuth != 0 {
  67689 		Xsqlite3ExpirePreparedStatements(tls, db, 1)
  67690 	}
  67691 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  67692 	return SQLITE_OK
  67693 }
  67694 
  67695 func sqliteAuthBadReturnCode(tls *libc.TLS, pParse uintptr) {
  67696 	Xsqlite3ErrorMsg(tls, pParse, ts+12038, 0)
  67697 	(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR
  67698 }
  67699 
  67700 // Invoke the authorization callback for permission to read column zCol from
  67701 // table zTab in database zDb. This function assumes that an authorization
  67702 // callback has been registered (i.e. that sqlite3.xAuth is not NULL).
  67703 //
  67704 // If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed
  67705 // to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
  67706 // is treated as SQLITE_DENY. In this case an error is left in pParse.
  67707 func Xsqlite3AuthReadCol(tls *libc.TLS, pParse uintptr, zTab uintptr, zCol uintptr, iDb int32) int32 {
  67708 	bp := tls.Alloc(40)
  67709 	defer tls.Free(40)
  67710 
  67711 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  67712 	var zDb uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  67713 	var rc int32
  67714 
  67715 	if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  67716 		return SQLITE_OK
  67717 	}
  67718 	rc = (*struct {
  67719 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32
  67720 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxAuth})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, SQLITE_READ, zTab, zCol, zDb, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext)
  67721 	if rc == SQLITE_DENY {
  67722 		var z uintptr = Xsqlite3_mprintf(tls, ts+12061, libc.VaList(bp, zTab, zCol))
  67723 		if (*Sqlite3)(unsafe.Pointer(db)).FnDb > 2 || iDb != 0 {
  67724 			z = Xsqlite3_mprintf(tls, ts+12067, libc.VaList(bp+16, zDb, z))
  67725 		}
  67726 		Xsqlite3ErrorMsg(tls, pParse, ts+12073, libc.VaList(bp+32, z))
  67727 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_AUTH
  67728 	} else if rc != SQLITE_IGNORE && rc != SQLITE_OK {
  67729 		sqliteAuthBadReturnCode(tls, pParse)
  67730 	}
  67731 	return rc
  67732 }
  67733 
  67734 // The pExpr should be a TK_COLUMN expression.  The table referred to
  67735 // is in pTabList or else it is the NEW or OLD table of a trigger.
  67736 // Check to see if it is OK to read this particular column.
  67737 //
  67738 // If the auth function returns SQLITE_IGNORE, change the TK_COLUMN
  67739 // instruction into a TK_NULL.  If the auth function returns SQLITE_DENY,
  67740 // then generate an error.
  67741 func Xsqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uintptr, pTabList uintptr) {
  67742 	var pTab uintptr = uintptr(0)
  67743 	var zCol uintptr
  67744 	var iSrc int32
  67745 	var iDb int32
  67746 	var iCol int32
  67747 
  67748 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pSchema)
  67749 	if iDb < 0 {
  67750 		return
  67751 	}
  67752 
  67753 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER {
  67754 		pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab
  67755 	} else {
  67756 		for iSrc = 0; iSrc < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc; iSrc++ {
  67757 			if (*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SrcItem)(unsafe.Pointer(pTabList+8+uintptr(iSrc)*72)).FiCursor {
  67758 				pTab = (*SrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(iSrc)*72)).FpTab
  67759 				break
  67760 			}
  67761 		}
  67762 	}
  67763 	iCol = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  67764 	if pTab == uintptr(0) {
  67765 		return
  67766 	}
  67767 
  67768 	if iCol >= 0 {
  67769 		zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16)).FzCnName
  67770 	} else if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) >= 0 {
  67771 		zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*16)).FzCnName
  67772 	} else {
  67773 		zCol = ts + 7713
  67774 	}
  67775 
  67776 	if SQLITE_IGNORE == Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FzName, zCol, iDb) {
  67777 		(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_NULL)
  67778 	}
  67779 }
  67780 
  67781 // Do an authorization check using the code and arguments given.  Return
  67782 // either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY.  If SQLITE_DENY
  67783 // is returned, then the error count and error message in pParse are
  67784 // modified appropriately.
  67785 func Xsqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, zArg2 uintptr, zArg3 uintptr) int32 {
  67786 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  67787 	var rc int32
  67788 
  67789 	if (*Sqlite3)(unsafe.Pointer(db)).FxAuth == uintptr(0) || (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 || int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL {
  67790 		return SQLITE_OK
  67791 	}
  67792 
  67793 	rc = (*struct {
  67794 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32
  67795 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxAuth})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, code, zArg1, zArg2, zArg3, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext)
  67796 	if rc == SQLITE_DENY {
  67797 		Xsqlite3ErrorMsg(tls, pParse, ts+12100, 0)
  67798 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_AUTH
  67799 	} else if rc != SQLITE_OK && rc != SQLITE_IGNORE {
  67800 		rc = SQLITE_DENY
  67801 		sqliteAuthBadReturnCode(tls, pParse)
  67802 	}
  67803 	return rc
  67804 }
  67805 
  67806 // Push an authorization context.  After this routine is called, the
  67807 // zArg3 argument to authorization callbacks will be zContext until
  67808 // popped.  Or if pParse==0, this routine is a no-op.
  67809 func Xsqlite3AuthContextPush(tls *libc.TLS, pParse uintptr, pContext uintptr, zContext uintptr) {
  67810 	(*AuthContext)(unsafe.Pointer(pContext)).FpParse = pParse
  67811 	(*AuthContext)(unsafe.Pointer(pContext)).FzAuthContext = (*Parse)(unsafe.Pointer(pParse)).FzAuthContext
  67812 	(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zContext
  67813 }
  67814 
  67815 // Pop an authorization context that was previously pushed
  67816 // by sqlite3AuthContextPush
  67817 func Xsqlite3AuthContextPop(tls *libc.TLS, pContext uintptr) {
  67818 	if (*AuthContext)(unsafe.Pointer(pContext)).FpParse != 0 {
  67819 		(*Parse)(unsafe.Pointer((*AuthContext)(unsafe.Pointer(pContext)).FpParse)).FzAuthContext = (*AuthContext)(unsafe.Pointer(pContext)).FzAuthContext
  67820 		(*AuthContext)(unsafe.Pointer(pContext)).FpParse = uintptr(0)
  67821 	}
  67822 }
  67823 
  67824 func lockTable(tls *libc.TLS, pParse uintptr, iDb int32, iTab Pgno, isWriteLock U8, zName uintptr) {
  67825 	var pToplevel uintptr
  67826 	var i int32
  67827 	var nBytes int32
  67828 	var p uintptr
  67829 
  67830 	pToplevel = func() uintptr {
  67831 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  67832 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  67833 		}
  67834 		return pParse
  67835 	}()
  67836 	for i = 0; i < (*Parse)(unsafe.Pointer(pToplevel)).FnTableLock; i++ {
  67837 		p = (*Parse)(unsafe.Pointer(pToplevel)).FaTableLock + uintptr(i)*16
  67838 		if (*TableLock)(unsafe.Pointer(p)).FiDb == iDb && (*TableLock)(unsafe.Pointer(p)).FiTab == iTab {
  67839 			(*TableLock)(unsafe.Pointer(p)).FisWriteLock = U8(libc.Bool32((*TableLock)(unsafe.Pointer(p)).FisWriteLock != 0 || isWriteLock != 0))
  67840 			return
  67841 		}
  67842 	}
  67843 
  67844 	nBytes = int32(uint32(unsafe.Sizeof(TableLock{})) * uint32((*Parse)(unsafe.Pointer(pToplevel)).FnTableLock+1))
  67845 	(*Parse)(unsafe.Pointer(pToplevel)).FaTableLock = Xsqlite3DbReallocOrFree(tls, (*Parse)(unsafe.Pointer(pToplevel)).Fdb, (*Parse)(unsafe.Pointer(pToplevel)).FaTableLock, uint64(nBytes))
  67846 	if (*Parse)(unsafe.Pointer(pToplevel)).FaTableLock != 0 {
  67847 		p = (*Parse)(unsafe.Pointer(pToplevel)).FaTableLock + uintptr(libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pToplevel)).FnTableLock, 1))*16
  67848 		(*TableLock)(unsafe.Pointer(p)).FiDb = iDb
  67849 		(*TableLock)(unsafe.Pointer(p)).FiTab = iTab
  67850 		(*TableLock)(unsafe.Pointer(p)).FisWriteLock = isWriteLock
  67851 		(*TableLock)(unsafe.Pointer(p)).FzLockName = zName
  67852 	} else {
  67853 		(*Parse)(unsafe.Pointer(pToplevel)).FnTableLock = 0
  67854 		Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(pToplevel)).Fdb)
  67855 	}
  67856 }
  67857 
  67858 func Xsqlite3TableLock(tls *libc.TLS, pParse uintptr, iDb int32, iTab Pgno, isWriteLock U8, zName uintptr) {
  67859 	if iDb == 1 {
  67860 		return
  67861 	}
  67862 	if !(Xsqlite3BtreeSharable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*16)).FpBt) != 0) {
  67863 		return
  67864 	}
  67865 	lockTable(tls, pParse, iDb, iTab, isWriteLock, zName)
  67866 }
  67867 
  67868 func codeTableLocks(tls *libc.TLS, pParse uintptr) {
  67869 	var i int32
  67870 	var pVdbe uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  67871 
  67872 	for i = 0; i < (*Parse)(unsafe.Pointer(pParse)).FnTableLock; i++ {
  67873 		var p uintptr = (*Parse)(unsafe.Pointer(pParse)).FaTableLock + uintptr(i)*16
  67874 		var p1 int32 = (*TableLock)(unsafe.Pointer(p)).FiDb
  67875 		Xsqlite3VdbeAddOp4(tls, pVdbe, OP_TableLock, p1, int32((*TableLock)(unsafe.Pointer(p)).FiTab), int32((*TableLock)(unsafe.Pointer(p)).FisWriteLock),
  67876 			(*TableLock)(unsafe.Pointer(p)).FzLockName, -1)
  67877 	}
  67878 }
  67879 
  67880 // This routine is called after a single SQL statement has been
  67881 // parsed and a VDBE program to execute that statement has been
  67882 // prepared.  This routine puts the finishing touches on the
  67883 // VDBE program and resets the pParse structure for the next
  67884 // parse.
  67885 //
  67886 // Note that if an error occurred, it might be the case that
  67887 // no VDBE code was generated.
  67888 func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) {
  67889 	var db uintptr
  67890 	var v uintptr
  67891 	var iDb int32
  67892 	var i int32
  67893 
  67894 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  67895 
  67896 	if (*Parse)(unsafe.Pointer(pParse)).Fnested != 0 {
  67897 		return
  67898 	}
  67899 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  67900 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  67901 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
  67902 		}
  67903 		return
  67904 	}
  67905 
  67906 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  67907 	if v == uintptr(0) {
  67908 		if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  67909 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_DONE
  67910 			return
  67911 		}
  67912 		v = Xsqlite3GetVdbe(tls, pParse)
  67913 		if v == uintptr(0) {
  67914 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR
  67915 		}
  67916 	}
  67917 
  67918 	if v != 0 {
  67919 		if (*Parse)(unsafe.Pointer(pParse)).FbReturning != 0 {
  67920 			var pReturning uintptr = *(*uintptr)(unsafe.Pointer(pParse + 136))
  67921 			var addrRewind int32
  67922 			var reg int32
  67923 
  67924 			if (*Returning)(unsafe.Pointer(pReturning)).FnRetCol != 0 {
  67925 				Xsqlite3VdbeAddOp0(tls, v, OP_FkCheck)
  67926 				addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*Returning)(unsafe.Pointer(pReturning)).FiRetCur)
  67927 
  67928 				reg = (*Returning)(unsafe.Pointer(pReturning)).FiRetReg
  67929 				for i = 0; i < (*Returning)(unsafe.Pointer(pReturning)).FnRetCol; i++ {
  67930 					Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Returning)(unsafe.Pointer(pReturning)).FiRetCur, i, reg+i)
  67931 				}
  67932 				Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, reg, i)
  67933 				Xsqlite3VdbeAddOp2(tls, v, OP_Next, (*Returning)(unsafe.Pointer(pReturning)).FiRetCur, addrRewind+1)
  67934 
  67935 				Xsqlite3VdbeJumpHere(tls, v, addrRewind)
  67936 			}
  67937 		}
  67938 		Xsqlite3VdbeAddOp0(tls, v, OP_Halt)
  67939 
  67940 		Xsqlite3VdbeJumpHere(tls, v, 0)
  67941 
  67942 		iDb = 0
  67943 		for __ccgo := true; __ccgo; __ccgo = libc.PreIncInt32(&iDb, 1) < (*Sqlite3)(unsafe.Pointer(db)).FnDb {
  67944 			var pSchema uintptr
  67945 			if libc.Bool32((*Parse)(unsafe.Pointer(pParse)).FcookieMask&(YDbMask(1)<<iDb) != YDbMask(0)) == 0 {
  67946 				continue
  67947 			}
  67948 			Xsqlite3VdbeUsesBtree(tls, v, iDb)
  67949 			pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  67950 			Xsqlite3VdbeAddOp4Int(tls, v,
  67951 				OP_Transaction,
  67952 				iDb,
  67953 				libc.Bool32((*Parse)(unsafe.Pointer(pParse)).FwriteMask&(YDbMask(1)<<iDb) != YDbMask(0)),
  67954 				(*Schema)(unsafe.Pointer(pSchema)).Fschema_cookie,
  67955 				(*Schema)(unsafe.Pointer(pSchema)).FiGeneration)
  67956 			if int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0 {
  67957 				Xsqlite3VdbeChangeP5(tls, v, uint16(1))
  67958 			}
  67959 
  67960 		}
  67961 		for i = 0; i < (*Parse)(unsafe.Pointer(pParse)).FnVtabLock; i++ {
  67962 			var vtab uintptr = Xsqlite3GetVTable(tls, db, *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FapVtabLock + uintptr(i)*4)))
  67963 			Xsqlite3VdbeAddOp4(tls, v, OP_VBegin, 0, 0, 0, vtab, -11)
  67964 		}
  67965 		(*Parse)(unsafe.Pointer(pParse)).FnVtabLock = 0
  67966 
  67967 		codeTableLocks(tls, pParse)
  67968 
  67969 		Xsqlite3AutoincrementBegin(tls, pParse)
  67970 
  67971 		if (*Parse)(unsafe.Pointer(pParse)).FpConstExpr != 0 {
  67972 			var pEL uintptr = (*Parse)(unsafe.Pointer(pParse)).FpConstExpr
  67973 			(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(0)
  67974 			for i = 0; i < (*ExprList)(unsafe.Pointer(pEL)).FnExpr; i++ {
  67975 				var iReg int32 = *(*int32)(unsafe.Pointer(pEL + 8 + uintptr(i)*20 + 16))
  67976 				Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pEL+8+uintptr(i)*20)).FpExpr, iReg)
  67977 			}
  67978 		}
  67979 
  67980 		if (*Parse)(unsafe.Pointer(pParse)).FbReturning != 0 {
  67981 			var pRet uintptr = *(*uintptr)(unsafe.Pointer(pParse + 136))
  67982 			if (*Returning)(unsafe.Pointer(pRet)).FnRetCol != 0 {
  67983 				Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Returning)(unsafe.Pointer(pRet)).FiRetCur, (*Returning)(unsafe.Pointer(pRet)).FnRetCol)
  67984 			}
  67985 		}
  67986 
  67987 		Xsqlite3VdbeGoto(tls, v, 1)
  67988 	}
  67989 
  67990 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  67991 		Xsqlite3VdbeMakeReady(tls, v, pParse)
  67992 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_DONE
  67993 	} else {
  67994 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR
  67995 	}
  67996 }
  67997 
  67998 // Run the parser and code generator recursively in order to generate
  67999 // code for the SQL statement given onto the end of the pParse context
  68000 // currently under construction.  Notes:
  68001 //
  68002 //   - The final OP_Halt is not appended and other initialization
  68003 //     and finalization steps are omitted because those are handling by the
  68004 //     outermost parser.
  68005 //
  68006 //   - Built-in SQL functions always take precedence over application-defined
  68007 //     SQL functions.  In other words, it is not possible to override a
  68008 //     built-in function.
  68009 func Xsqlite3NestedParse(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) {
  68010 	bp := tls.Alloc(76)
  68011 	defer tls.Free(76)
  68012 
  68013 	var ap Va_list
  68014 	_ = ap
  68015 	var zSql uintptr
  68016 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  68017 	var savedDbFlags U32 = (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags
  68018 
  68019 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  68020 		return
  68021 	}
  68022 	if (*Parse)(unsafe.Pointer(pParse)).FeParseMode != 0 {
  68023 		return
  68024 	}
  68025 
  68026 	ap = va
  68027 	zSql = Xsqlite3VMPrintf(tls, db, zFormat, ap)
  68028 	_ = ap
  68029 	if zSql == uintptr(0) {
  68030 		if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  68031 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_TOOBIG
  68032 		}
  68033 		(*Parse)(unsafe.Pointer(pParse)).FnErr++
  68034 		return
  68035 	}
  68036 	(*Parse)(unsafe.Pointer(pParse)).Fnested++
  68037 	libc.Xmemcpy(tls, bp, pParse+uintptr(uint32(uintptr(0)+204)), uint32(unsafe.Sizeof(Parse{}))-uint32(uintptr(0)+204))
  68038 	libc.Xmemset(tls, pParse+uintptr(uint32(uintptr(0)+204)), 0, uint32(unsafe.Sizeof(Parse{}))-uint32(uintptr(0)+204))
  68039 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_PreferBuiltin)
  68040 	Xsqlite3RunParser(tls, pParse, zSql)
  68041 	(*Sqlite3)(unsafe.Pointer(db)).FmDbFlags = savedDbFlags
  68042 	Xsqlite3DbFree(tls, db, zSql)
  68043 	libc.Xmemcpy(tls, pParse+uintptr(uint32(uintptr(0)+204)), bp, uint32(unsafe.Sizeof(Parse{}))-uint32(uintptr(0)+204))
  68044 	(*Parse)(unsafe.Pointer(pParse)).Fnested--
  68045 }
  68046 
  68047 // Locate the in-memory structure that describes a particular database
  68048 // table given the name of that table and (optionally) the name of the
  68049 // database containing the table.  Return NULL if not found.
  68050 //
  68051 // If zDatabase is 0, all databases are searched for the table and the
  68052 // first matching table is returned.  (No checking for duplicate table
  68053 // names is done.)  The search order is TEMP first, then MAIN, then any
  68054 // auxiliary databases added using the ATTACH command.
  68055 //
  68056 // See also sqlite3LocateTable().
  68057 func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintptr) uintptr {
  68058 	var p uintptr = uintptr(0)
  68059 	var i int32
  68060 
  68061 	if zDatabase != 0 {
  68062 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  68063 			if Xsqlite3StrICmp(tls, zDatabase, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FzDbSName) == 0 {
  68064 				break
  68065 			}
  68066 		}
  68067 		if i >= (*Sqlite3)(unsafe.Pointer(db)).FnDb {
  68068 			if Xsqlite3StrICmp(tls, zDatabase, ts+6441) == 0 {
  68069 				i = 0
  68070 			} else {
  68071 				return uintptr(0)
  68072 			}
  68073 		}
  68074 		p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema+8, zName)
  68075 		if p == uintptr(0) && Xsqlite3_strnicmp(tls, zName, ts+6381, 7) == 0 {
  68076 			if i == 1 {
  68077 				if Xsqlite3StrICmp(tls, zName+uintptr(7), ts+6408+7) == 0 ||
  68078 					Xsqlite3StrICmp(tls, zName+uintptr(7), ts+6427+7) == 0 ||
  68079 					Xsqlite3StrICmp(tls, zName+uintptr(7), ts+5883+7) == 0 {
  68080 					p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema+8,
  68081 						ts+6389)
  68082 				}
  68083 			} else {
  68084 				if Xsqlite3StrICmp(tls, zName+uintptr(7), ts+6427+7) == 0 {
  68085 					p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema+8,
  68086 						ts+5883)
  68087 				}
  68088 			}
  68089 		}
  68090 	} else {
  68091 		p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema+8, zName)
  68092 		if p != 0 {
  68093 			return p
  68094 		}
  68095 
  68096 		p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema+8, zName)
  68097 		if p != 0 {
  68098 			return p
  68099 		}
  68100 
  68101 		for i = 2; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  68102 			p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema+8, zName)
  68103 			if p != 0 {
  68104 				break
  68105 			}
  68106 		}
  68107 		if p == uintptr(0) && Xsqlite3_strnicmp(tls, zName, ts+6381, 7) == 0 {
  68108 			if Xsqlite3StrICmp(tls, zName+uintptr(7), ts+6427+7) == 0 {
  68109 				p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema+8, ts+5883)
  68110 			} else if Xsqlite3StrICmp(tls, zName+uintptr(7), ts+6408+7) == 0 {
  68111 				p = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema+8,
  68112 					ts+6389)
  68113 			}
  68114 		}
  68115 	}
  68116 	return p
  68117 }
  68118 
  68119 // Locate the in-memory structure that describes a particular database
  68120 // table given the name of that table and (optionally) the name of the
  68121 // database containing the table.  Return NULL if not found.  Also leave an
  68122 // error message in pParse->zErrMsg.
  68123 //
  68124 // The difference between this routine and sqlite3FindTable() is that this
  68125 // routine leaves an error message in pParse->zErrMsg where
  68126 // sqlite3FindTable() does not.
  68127 func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr, zDbase uintptr) uintptr {
  68128 	bp := tls.Alloc(40)
  68129 	defer tls.Free(40)
  68130 
  68131 	var p uintptr
  68132 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  68133 
  68134 	if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_SchemaKnownOk) == U32(0) &&
  68135 		SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) {
  68136 		return uintptr(0)
  68137 	}
  68138 
  68139 	p = Xsqlite3FindTable(tls, db, zName, zDbase)
  68140 	if p == uintptr(0) {
  68141 		if int32((*Parse)(unsafe.Pointer(pParse)).FprepFlags)&SQLITE_PREPARE_NO_VTAB == 0 && int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0 {
  68142 			var pMod uintptr = Xsqlite3HashFind(tls, db+404, zName)
  68143 			if pMod == uintptr(0) && Xsqlite3_strnicmp(tls, zName, ts+12115, 7) == 0 {
  68144 				pMod = Xsqlite3PragmaVtabRegister(tls, db, zName)
  68145 			}
  68146 			if pMod != 0 && Xsqlite3VtabEponymousTableInit(tls, pParse, pMod) != 0 {
  68147 				return (*Module)(unsafe.Pointer(pMod)).FpEpoTab
  68148 			}
  68149 		}
  68150 		if flags&U32(LOCATE_NOERR) != 0 {
  68151 			return uintptr(0)
  68152 		}
  68153 		(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  68154 	} else if int32((*Table)(unsafe.Pointer(p)).FeTabType) == TABTYP_VTAB && int32((*Parse)(unsafe.Pointer(pParse)).FprepFlags)&SQLITE_PREPARE_NO_VTAB != 0 {
  68155 		p = uintptr(0)
  68156 	}
  68157 
  68158 	if p == uintptr(0) {
  68159 		var zMsg uintptr
  68160 		if flags&U32(LOCATE_VIEW) != 0 {
  68161 			zMsg = ts + 12123
  68162 		} else {
  68163 			zMsg = ts + 12136
  68164 		}
  68165 		if zDbase != 0 {
  68166 			Xsqlite3ErrorMsg(tls, pParse, ts+6645, libc.VaList(bp, zMsg, zDbase, zName))
  68167 		} else {
  68168 			Xsqlite3ErrorMsg(tls, pParse, ts+6655, libc.VaList(bp+24, zMsg, zName))
  68169 		}
  68170 	} else {
  68171 	}
  68172 
  68173 	return p
  68174 }
  68175 
  68176 // Locate the table identified by *p.
  68177 //
  68178 // This is a wrapper around sqlite3LocateTable(). The difference between
  68179 // sqlite3LocateTable() and this function is that this function restricts
  68180 // the search to schema (p->pSchema) if it is not NULL. p->pSchema may be
  68181 // non-NULL if it is part of a view or trigger program definition. See
  68182 // sqlite3FixSrcList() for details.
  68183 func Xsqlite3LocateTableItem(tls *libc.TLS, pParse uintptr, flags U32, p uintptr) uintptr {
  68184 	var zDb uintptr
  68185 
  68186 	if (*SrcItem)(unsafe.Pointer(p)).FpSchema != 0 {
  68187 		var iDb int32 = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*SrcItem)(unsafe.Pointer(p)).FpSchema)
  68188 		zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*16)).FzDbSName
  68189 	} else {
  68190 		zDb = (*SrcItem)(unsafe.Pointer(p)).FzDatabase
  68191 	}
  68192 	return Xsqlite3LocateTable(tls, pParse, flags, (*SrcItem)(unsafe.Pointer(p)).FzName, zDb)
  68193 }
  68194 
  68195 // Return the preferred table name for system tables.  Translate legacy
  68196 // names into the new preferred names, as appropriate.
  68197 func Xsqlite3PreferredTableName(tls *libc.TLS, zName uintptr) uintptr {
  68198 	if Xsqlite3_strnicmp(tls, zName, ts+6381, 7) == 0 {
  68199 		if Xsqlite3StrICmp(tls, zName+uintptr(7), ts+5883+7) == 0 {
  68200 			return ts + 6427
  68201 		}
  68202 		if Xsqlite3StrICmp(tls, zName+uintptr(7), ts+6389+7) == 0 {
  68203 			return ts + 6408
  68204 		}
  68205 	}
  68206 	return zName
  68207 }
  68208 
  68209 // Locate the in-memory structure that describes
  68210 // a particular index given the name of that index
  68211 // and the name of the database that contains the index.
  68212 // Return NULL if not found.
  68213 //
  68214 // If zDatabase is 0, all databases are searched for the
  68215 // table and the first matching index is returned.  (No checking
  68216 // for duplicate index names is done.)  The search order is
  68217 // TEMP first, then MAIN, then any auxiliary databases added
  68218 // using the ATTACH command.
  68219 func Xsqlite3FindIndex(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) uintptr {
  68220 	var p uintptr = uintptr(0)
  68221 	var i int32
  68222 
  68223 	for i = OMIT_TEMPDB; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  68224 		var j int32
  68225 		if i < 2 {
  68226 			j = i ^ 1
  68227 		} else {
  68228 			j = i
  68229 		}
  68230 		var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*16)).FpSchema
  68231 
  68232 		if zDb != 0 && Xsqlite3DbIsNamed(tls, db, j, zDb) == 0 {
  68233 			continue
  68234 		}
  68235 
  68236 		p = Xsqlite3HashFind(tls, pSchema+24, zName)
  68237 		if p != 0 {
  68238 			break
  68239 		}
  68240 	}
  68241 	return p
  68242 }
  68243 
  68244 // Reclaim the memory used by an index
  68245 func Xsqlite3FreeIndex(tls *libc.TLS, db uintptr, p uintptr) {
  68246 	Xsqlite3DeleteIndexSamples(tls, db, p)
  68247 	Xsqlite3ExprDelete(tls, db, (*Index)(unsafe.Pointer(p)).FpPartIdxWhere)
  68248 	Xsqlite3ExprListDelete(tls, db, (*Index)(unsafe.Pointer(p)).FaColExpr)
  68249 	Xsqlite3DbFree(tls, db, (*Index)(unsafe.Pointer(p)).FzColAff)
  68250 	if uint32(int32(*(*uint16)(unsafe.Pointer(p + 56))&0x10>>4)) != 0 {
  68251 		Xsqlite3DbFree(tls, db, (*Index)(unsafe.Pointer(p)).FazColl)
  68252 	}
  68253 	Xsqlite3_free(tls, (*Index)(unsafe.Pointer(p)).FaiRowEst)
  68254 	Xsqlite3DbFree(tls, db, p)
  68255 }
  68256 
  68257 // For the index called zIdxName which is found in the database iDb,
  68258 // unlike that index from its Table then remove the index from
  68259 // the index hash table and free all memory structures associated
  68260 // with the index.
  68261 func Xsqlite3UnlinkAndDeleteIndex(tls *libc.TLS, db uintptr, iDb int32, zIdxName uintptr) {
  68262 	var pIndex uintptr
  68263 	var pHash uintptr
  68264 
  68265 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 24
  68266 	pIndex = Xsqlite3HashInsert(tls, pHash, zIdxName, uintptr(0))
  68267 	if pIndex != 0 {
  68268 		if (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FpIndex == pIndex {
  68269 			(*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FpIndex = (*Index)(unsafe.Pointer(pIndex)).FpNext
  68270 		} else {
  68271 			var p uintptr
  68272 
  68273 			p = (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FpIndex
  68274 			for p != 0 && (*Index)(unsafe.Pointer(p)).FpNext != pIndex {
  68275 				p = (*Index)(unsafe.Pointer(p)).FpNext
  68276 			}
  68277 			if p != 0 && (*Index)(unsafe.Pointer(p)).FpNext == pIndex {
  68278 				(*Index)(unsafe.Pointer(p)).FpNext = (*Index)(unsafe.Pointer(pIndex)).FpNext
  68279 			}
  68280 		}
  68281 		Xsqlite3FreeIndex(tls, db, pIndex)
  68282 	}
  68283 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  68284 }
  68285 
  68286 // Look through the list of open database files in db->aDb[] and if
  68287 // any have been closed, remove them from the list.  Reallocate the
  68288 // db->aDb[] structure to a smaller size, if possible.
  68289 //
  68290 // Entry 0 (the "main" database) and entry 1 (the "temp" database)
  68291 // are never candidates for being collapsed.
  68292 func Xsqlite3CollapseDatabaseArray(tls *libc.TLS, db uintptr) {
  68293 	var i int32
  68294 	var j int32
  68295 	for i = libc.AssignInt32(&j, 2); i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  68296 		var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16
  68297 		if (*Db1)(unsafe.Pointer(pDb)).FpBt == uintptr(0) {
  68298 			Xsqlite3DbFree(tls, db, (*Db1)(unsafe.Pointer(pDb)).FzDbSName)
  68299 			(*Db1)(unsafe.Pointer(pDb)).FzDbSName = uintptr(0)
  68300 			continue
  68301 		}
  68302 		if j < i {
  68303 			*(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*16)) = *(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16))
  68304 		}
  68305 		j++
  68306 	}
  68307 	(*Sqlite3)(unsafe.Pointer(db)).FnDb = j
  68308 	if (*Sqlite3)(unsafe.Pointer(db)).FnDb <= 2 && (*Sqlite3)(unsafe.Pointer(db)).FaDb != db+476 {
  68309 		libc.Xmemcpy(tls, db+476, (*Sqlite3)(unsafe.Pointer(db)).FaDb, uint32(2)*uint32(unsafe.Sizeof(Db{})))
  68310 		Xsqlite3DbFree(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaDb)
  68311 		(*Sqlite3)(unsafe.Pointer(db)).FaDb = db + 476
  68312 	}
  68313 }
  68314 
  68315 // Reset the schema for the database at index iDb.  Also reset the
  68316 // TEMP schema.  The reset is deferred if db->nSchemaLock is not zero.
  68317 // Deferred resets may be run by calling with iDb<0.
  68318 func Xsqlite3ResetOneSchema(tls *libc.TLS, db uintptr, iDb int32) {
  68319 	var i int32
  68320 
  68321 	if iDb >= 0 {
  68322 		*(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 78)) |= U16(DB_ResetWanted)
  68323 		*(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema + 78)) |= U16(DB_ResetWanted)
  68324 		*(*U32)(unsafe.Pointer(db + 24)) &= libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))
  68325 	}
  68326 
  68327 	if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) {
  68328 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  68329 			if int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema)).FschemaFlags)&DB_ResetWanted == DB_ResetWanted {
  68330 				Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema)
  68331 			}
  68332 		}
  68333 	}
  68334 }
  68335 
  68336 // Erase all schema information from all attached databases (including
  68337 // "main" and "temp") for a single database connection.
  68338 func Xsqlite3ResetAllSchemasOfConnection(tls *libc.TLS, db uintptr) {
  68339 	var i int32
  68340 	Xsqlite3BtreeEnterAll(tls, db)
  68341 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  68342 		var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16
  68343 		if (*Db)(unsafe.Pointer(pDb)).FpSchema != 0 {
  68344 			if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) {
  68345 				Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer(pDb)).FpSchema)
  68346 			} else {
  68347 				*(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema + 78)) |= U16(DB_ResetWanted)
  68348 			}
  68349 		}
  68350 	}
  68351 	*(*U32)(unsafe.Pointer(db + 24)) &= libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaChange | DBFLAG_SchemaKnownOk))
  68352 	Xsqlite3VtabUnlockList(tls, db)
  68353 	Xsqlite3BtreeLeaveAll(tls, db)
  68354 	if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) {
  68355 		Xsqlite3CollapseDatabaseArray(tls, db)
  68356 	}
  68357 }
  68358 
  68359 // This routine is called when a commit occurs.
  68360 func Xsqlite3CommitInternalChanges(tls *libc.TLS, db uintptr) {
  68361 	*(*U32)(unsafe.Pointer(db + 24)) &= libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaChange))
  68362 }
  68363 
  68364 // Set the expression associated with a column.  This is usually
  68365 // the DEFAULT value, but might also be the expression that computes
  68366 // the value for a generated column.
  68367 func Xsqlite3ColumnSetExpr(tls *libc.TLS, pParse uintptr, pTab uintptr, pCol uintptr, pExpr uintptr) {
  68368 	var pList uintptr
  68369 
  68370 	pList = *(*uintptr)(unsafe.Pointer(pTab + 44 + 8))
  68371 	if int32((*Column)(unsafe.Pointer(pCol)).FiDflt) == 0 ||
  68372 		pList == uintptr(0) ||
  68373 		(*ExprList)(unsafe.Pointer(pList)).FnExpr < int32((*Column)(unsafe.Pointer(pCol)).FiDflt) {
  68374 		(*Column)(unsafe.Pointer(pCol)).FiDflt = func() uint16 {
  68375 			if pList == uintptr(0) {
  68376 				return uint16(1)
  68377 			}
  68378 			return uint16((*ExprList)(unsafe.Pointer(pList)).FnExpr + 1)
  68379 		}()
  68380 		*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) = Xsqlite3ExprListAppend(tls, pParse, pList, pExpr)
  68381 	} else {
  68382 		Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(int32((*Column)(unsafe.Pointer(pCol)).FiDflt)-1)*20)).FpExpr)
  68383 		(*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(int32((*Column)(unsafe.Pointer(pCol)).FiDflt)-1)*20)).FpExpr = pExpr
  68384 	}
  68385 }
  68386 
  68387 // Return the expression associated with a column.  The expression might be
  68388 // the DEFAULT clause or the AS clause of a generated column.
  68389 // Return NULL if the column has no associated expression.
  68390 func Xsqlite3ColumnExpr(tls *libc.TLS, pTab uintptr, pCol uintptr) uintptr {
  68391 	if int32((*Column)(unsafe.Pointer(pCol)).FiDflt) == 0 {
  68392 		return uintptr(0)
  68393 	}
  68394 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  68395 		return uintptr(0)
  68396 	}
  68397 	if *(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) == uintptr(0) {
  68398 		return uintptr(0)
  68399 	}
  68400 	if (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)))).FnExpr < int32((*Column)(unsafe.Pointer(pCol)).FiDflt) {
  68401 		return uintptr(0)
  68402 	}
  68403 	return (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) + 8 + uintptr(int32((*Column)(unsafe.Pointer(pCol)).FiDflt)-1)*20)).FpExpr
  68404 }
  68405 
  68406 // Set the collating sequence name for a column.
  68407 func Xsqlite3ColumnSetColl(tls *libc.TLS, db uintptr, pCol uintptr, zColl uintptr) {
  68408 	var nColl I64
  68409 	var n I64
  68410 	var zNew uintptr
  68411 
  68412 	n = I64(Xsqlite3Strlen30(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName) + 1)
  68413 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_HASTYPE != 0 {
  68414 		n = n + I64(Xsqlite3Strlen30(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName+uintptr(n))+1)
  68415 	}
  68416 	nColl = I64(Xsqlite3Strlen30(tls, zColl) + 1)
  68417 	zNew = Xsqlite3DbRealloc(tls, db, (*Column)(unsafe.Pointer(pCol)).FzCnName, uint64(nColl+n))
  68418 	if zNew != 0 {
  68419 		(*Column)(unsafe.Pointer(pCol)).FzCnName = zNew
  68420 		libc.Xmemcpy(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName+uintptr(n), zColl, uint32(nColl))
  68421 		*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_HASCOLL)
  68422 	}
  68423 }
  68424 
  68425 // Return the collating squence name for a column
  68426 func Xsqlite3ColumnColl(tls *libc.TLS, pCol uintptr) uintptr {
  68427 	var z uintptr
  68428 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_HASCOLL == 0 {
  68429 		return uintptr(0)
  68430 	}
  68431 	z = (*Column)(unsafe.Pointer(pCol)).FzCnName
  68432 	for *(*uint8)(unsafe.Pointer(z)) != 0 {
  68433 		z++
  68434 	}
  68435 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_HASTYPE != 0 {
  68436 		for __ccgo := true; __ccgo; __ccgo = *(*uint8)(unsafe.Pointer(z)) != 0 {
  68437 			z++
  68438 		}
  68439 	}
  68440 	return z + uintptr(1)
  68441 }
  68442 
  68443 // Delete memory allocated for the column names of a table or view (the
  68444 // Table.aCol[] array).
  68445 func Xsqlite3DeleteColumnNames(tls *libc.TLS, db uintptr, pTable uintptr) {
  68446 	var i int32
  68447 	var pCol uintptr
  68448 
  68449 	if libc.AssignUintptr(&pCol, (*Table)(unsafe.Pointer(pTable)).FaCol) != uintptr(0) {
  68450 		i = 0
  68451 	__1:
  68452 		if !(i < int32((*Table)(unsafe.Pointer(pTable)).FnCol)) {
  68453 			goto __3
  68454 		}
  68455 		{
  68456 			Xsqlite3DbFree(tls, db, (*Column)(unsafe.Pointer(pCol)).FzCnName)
  68457 
  68458 		}
  68459 		goto __2
  68460 	__2:
  68461 		i++
  68462 		pCol += 16
  68463 		goto __1
  68464 		goto __3
  68465 	__3:
  68466 		;
  68467 		Xsqlite3DbNNFreeNN(tls, db, (*Table)(unsafe.Pointer(pTable)).FaCol)
  68468 		if int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_NORM {
  68469 			Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pTable + 44 + 8)))
  68470 		}
  68471 		if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  68472 			(*Table)(unsafe.Pointer(pTable)).FaCol = uintptr(0)
  68473 			(*Table)(unsafe.Pointer(pTable)).FnCol = int16(0)
  68474 			if int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_NORM {
  68475 				*(*uintptr)(unsafe.Pointer(pTable + 44 + 8)) = uintptr(0)
  68476 			}
  68477 		}
  68478 	}
  68479 }
  68480 
  68481 func deleteTable(tls *libc.TLS, db uintptr, pTable uintptr) {
  68482 	var pIndex uintptr
  68483 	var pNext uintptr
  68484 
  68485 	for pIndex = (*Table)(unsafe.Pointer(pTable)).FpIndex; pIndex != 0; pIndex = pNext {
  68486 		pNext = (*Index)(unsafe.Pointer(pIndex)).FpNext
  68487 
  68488 		if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) && !(int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_VTAB) {
  68489 			var zName uintptr = (*Index)(unsafe.Pointer(pIndex)).FzName
  68490 			Xsqlite3HashInsert(tls,
  68491 				(*Index)(unsafe.Pointer(pIndex)).FpSchema+24, zName, uintptr(0))
  68492 
  68493 		}
  68494 		Xsqlite3FreeIndex(tls, db, pIndex)
  68495 	}
  68496 
  68497 	if int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_NORM {
  68498 		Xsqlite3FkDelete(tls, db, pTable)
  68499 	} else if int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_VTAB {
  68500 		Xsqlite3VtabClear(tls, db, pTable)
  68501 	} else {
  68502 		Xsqlite3SelectDelete(tls, db, *(*uintptr)(unsafe.Pointer(pTable + 44)))
  68503 	}
  68504 
  68505 	Xsqlite3DeleteColumnNames(tls, db, pTable)
  68506 	Xsqlite3DbFree(tls, db, (*Table)(unsafe.Pointer(pTable)).FzName)
  68507 	Xsqlite3DbFree(tls, db, (*Table)(unsafe.Pointer(pTable)).FzColAff)
  68508 	Xsqlite3ExprListDelete(tls, db, (*Table)(unsafe.Pointer(pTable)).FpCheck)
  68509 	Xsqlite3DbFree(tls, db, pTable)
  68510 
  68511 }
  68512 
  68513 func Xsqlite3DeleteTable(tls *libc.TLS, db uintptr, pTable uintptr) {
  68514 	if !(pTable != 0) {
  68515 		return
  68516 	}
  68517 	if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) && libc.PreDecUint32(&(*Table)(unsafe.Pointer(pTable)).FnTabRef, 1) > U32(0) {
  68518 		return
  68519 	}
  68520 	deleteTable(tls, db, pTable)
  68521 }
  68522 
  68523 // Unlink the given table from the hash tables and the delete the
  68524 // table structure with all its indices and foreign keys.
  68525 func Xsqlite3UnlinkAndDeleteTable(tls *libc.TLS, db uintptr, iDb int32, zTabName uintptr) {
  68526 	var p uintptr
  68527 	var pDb uintptr
  68528 
  68529 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  68530 	p = Xsqlite3HashInsert(tls, (*Db)(unsafe.Pointer(pDb)).FpSchema+8, zTabName, uintptr(0))
  68531 	Xsqlite3DeleteTable(tls, db, p)
  68532 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  68533 }
  68534 
  68535 // Given a token, return a string that consists of the text of that
  68536 // token.  Space to hold the returned string
  68537 // is obtained from sqliteMalloc() and must be freed by the calling
  68538 // function.
  68539 //
  68540 // Any quotation marks (ex:  "name", 'name', [name], or `name`) that
  68541 // surround the body of the token are removed.
  68542 //
  68543 // Tokens are often just pointers into the original SQL text and so
  68544 // are not \000 terminated and are not persistent.  The returned string
  68545 // is \000 terminated and is persistent.
  68546 func Xsqlite3NameFromToken(tls *libc.TLS, db uintptr, pName uintptr) uintptr {
  68547 	var zName uintptr
  68548 	if pName != 0 {
  68549 		zName = Xsqlite3DbStrNDup(tls, db, (*Token)(unsafe.Pointer(pName)).Fz, uint64((*Token)(unsafe.Pointer(pName)).Fn))
  68550 		Xsqlite3Dequote(tls, zName)
  68551 	} else {
  68552 		zName = uintptr(0)
  68553 	}
  68554 	return zName
  68555 }
  68556 
  68557 // Open the sqlite_schema table stored in database number iDb for
  68558 // writing. The table is opened using cursor 0.
  68559 func Xsqlite3OpenSchemaTable(tls *libc.TLS, p uintptr, iDb int32) {
  68560 	var v uintptr = Xsqlite3GetVdbe(tls, p)
  68561 	Xsqlite3TableLock(tls, p, iDb, uint32(SCHEMA_ROOT), uint8(1), ts+5883)
  68562 	Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenWrite, 0, SCHEMA_ROOT, iDb, 5)
  68563 	if (*Parse)(unsafe.Pointer(p)).FnTab == 0 {
  68564 		(*Parse)(unsafe.Pointer(p)).FnTab = 1
  68565 	}
  68566 }
  68567 
  68568 // Parameter zName points to a nul-terminated buffer containing the name
  68569 // of a database ("main", "temp" or the name of an attached db). This
  68570 // function returns the index of the named database in db->aDb[], or
  68571 // -1 if the named db cannot be found.
  68572 func Xsqlite3FindDbName(tls *libc.TLS, db uintptr, zName uintptr) int32 {
  68573 	var i int32 = -1
  68574 	if zName != 0 {
  68575 		var pDb uintptr
  68576 		i = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
  68577 		pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16
  68578 	__1:
  68579 		if !(i >= 0) {
  68580 			goto __3
  68581 		}
  68582 		{
  68583 			if 0 == Xsqlite3_stricmp(tls, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zName) {
  68584 				goto __3
  68585 			}
  68586 
  68587 			if i == 0 && 0 == Xsqlite3_stricmp(tls, ts+6441, zName) {
  68588 				goto __3
  68589 			}
  68590 
  68591 		}
  68592 		goto __2
  68593 	__2:
  68594 		i--
  68595 		pDb -= 16
  68596 		goto __1
  68597 		goto __3
  68598 	__3:
  68599 	}
  68600 	return i
  68601 }
  68602 
  68603 // The token *pName contains the name of a database (either "main" or
  68604 // "temp" or the name of an attached db). This routine returns the
  68605 // index of the named database in db->aDb[], or -1 if the named db
  68606 // does not exist.
  68607 func Xsqlite3FindDb(tls *libc.TLS, db uintptr, pName uintptr) int32 {
  68608 	var i int32
  68609 	var zName uintptr
  68610 	zName = Xsqlite3NameFromToken(tls, db, pName)
  68611 	i = Xsqlite3FindDbName(tls, db, zName)
  68612 	Xsqlite3DbFree(tls, db, zName)
  68613 	return i
  68614 }
  68615 
  68616 // The table or view or trigger name is passed to this routine via tokens
  68617 // pName1 and pName2. If the table name was fully qualified, for example:
  68618 //
  68619 // CREATE TABLE xxx.yyy (...);
  68620 //
  68621 // Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if
  68622 // the table name is not fully qualified, i.e.:
  68623 //
  68624 // CREATE TABLE yyy(...);
  68625 //
  68626 // Then pName1 is set to "yyy" and pName2 is "".
  68627 //
  68628 // This routine sets the *ppUnqual pointer to point at the token (pName1 or
  68629 // pName2) that stores the unqualified table name.  The index of the
  68630 // database "xxx" is returned.
  68631 func Xsqlite3TwoPartName(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pUnqual uintptr) int32 {
  68632 	bp := tls.Alloc(8)
  68633 	defer tls.Free(8)
  68634 
  68635 	var iDb int32
  68636 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  68637 
  68638 	if (*Token)(unsafe.Pointer(pName2)).Fn > uint32(0) {
  68639 		if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  68640 			Xsqlite3ErrorMsg(tls, pParse, ts+12150, 0)
  68641 			return -1
  68642 		}
  68643 		*(*uintptr)(unsafe.Pointer(pUnqual)) = pName2
  68644 		iDb = Xsqlite3FindDb(tls, db, pName1)
  68645 		if iDb < 0 {
  68646 			Xsqlite3ErrorMsg(tls, pParse, ts+12167, libc.VaList(bp, pName1))
  68647 			return -1
  68648 		}
  68649 	} else {
  68650 		iDb = int32((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb)
  68651 		*(*uintptr)(unsafe.Pointer(pUnqual)) = pName1
  68652 	}
  68653 	return iDb
  68654 }
  68655 
  68656 // True if PRAGMA writable_schema is ON
  68657 func Xsqlite3WritableSchema(tls *libc.TLS, db uintptr) int32 {
  68658 	return libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_WriteSchema|SQLITE_Defensive) == uint64(SQLITE_WriteSchema))
  68659 }
  68660 
  68661 // This routine is used to check if the UTF-8 string zName is a legal
  68662 // unqualified name for a new schema object (table, index, view or
  68663 // trigger). All names are legal except those that begin with the string
  68664 // "sqlite_" (in upper, lower or mixed case). This portion of the namespace
  68665 // is reserved for internal use.
  68666 //
  68667 // When parsing the sqlite_schema table, this routine also checks to
  68668 // make sure the "type", "name", and "tbl_name" columns are consistent
  68669 // with the SQL.
  68670 func Xsqlite3CheckObjectName(tls *libc.TLS, pParse uintptr, zName uintptr, zType uintptr, zTblName uintptr) int32 {
  68671 	bp := tls.Alloc(8)
  68672 	defer tls.Free(8)
  68673 
  68674 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  68675 	if Xsqlite3WritableSchema(tls, db) != 0 ||
  68676 		uint32(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x2>>1)) != 0 ||
  68677 		!(int32(Xsqlite3Config.FbExtraSchemaChecks) != 0) {
  68678 		return SQLITE_OK
  68679 	}
  68680 	if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  68681 		if Xsqlite3_stricmp(tls, zType, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit))) != 0 ||
  68682 			Xsqlite3_stricmp(tls, zName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + 1*4))) != 0 ||
  68683 			Xsqlite3_stricmp(tls, zTblName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + 2*4))) != 0 {
  68684 			Xsqlite3ErrorMsg(tls, pParse, ts+1554, 0)
  68685 			return SQLITE_ERROR
  68686 		}
  68687 	} else {
  68688 		if int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 && 0 == Xsqlite3_strnicmp(tls, zName, ts+6381, 7) ||
  68689 			Xsqlite3ReadOnlyShadowTables(tls, db) != 0 && Xsqlite3ShadowTableName(tls, db, zName) != 0 {
  68690 			Xsqlite3ErrorMsg(tls, pParse, ts+12187,
  68691 				libc.VaList(bp, zName))
  68692 			return SQLITE_ERROR
  68693 		}
  68694 
  68695 	}
  68696 	return SQLITE_OK
  68697 }
  68698 
  68699 // Return the PRIMARY KEY index of a table
  68700 func Xsqlite3PrimaryKeyIndex(tls *libc.TLS, pTab uintptr) uintptr {
  68701 	var p uintptr
  68702 	for p = (*Table)(unsafe.Pointer(pTab)).FpIndex; p != 0 && !(int32(*(*uint16)(unsafe.Pointer(p + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY); p = (*Index)(unsafe.Pointer(p)).FpNext {
  68703 	}
  68704 	return p
  68705 }
  68706 
  68707 // Convert an table column number into a index column number.  That is,
  68708 // for the column iCol in the table (as defined by the CREATE TABLE statement)
  68709 // find the (first) offset of that column in index pIdx.  Or return -1
  68710 // if column iCol is not used in index pIdx.
  68711 func Xsqlite3TableColumnToIndex(tls *libc.TLS, pIdx uintptr, iCol I16) I16 {
  68712 	var i int32
  68713 	for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); i++ {
  68714 		if int32(iCol) == int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) {
  68715 			return I16(i)
  68716 		}
  68717 	}
  68718 	return int16(-1)
  68719 }
  68720 
  68721 // Convert a storage column number into a table column number.
  68722 //
  68723 // The storage column number (0,1,2,....) is the index of the value
  68724 // as it appears in the record on disk.  The true column number
  68725 // is the index (0,1,2,...) of the column in the CREATE TABLE statement.
  68726 //
  68727 // The storage column number is less than the table column number if
  68728 // and only there are VIRTUAL columns to the left.
  68729 //
  68730 // If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
  68731 func Xsqlite3StorageColumnToTable(tls *libc.TLS, pTab uintptr, iCol I16) I16 {
  68732 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasVirtual) != 0 {
  68733 		var i int32
  68734 		for i = 0; i <= int32(iCol); i++ {
  68735 			if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0 {
  68736 				iCol++
  68737 			}
  68738 		}
  68739 	}
  68740 	return iCol
  68741 }
  68742 
  68743 // Convert a table column number into a storage column number.
  68744 //
  68745 // The storage column number (0,1,2,....) is the index of the value
  68746 // as it appears in the record on disk.  Or, if the input column is
  68747 // the N-th virtual column (zero-based) then the storage number is
  68748 // the number of non-virtual columns in the table plus N.
  68749 //
  68750 // The true column number is the index (0,1,2,...) of the column in
  68751 // the CREATE TABLE statement.
  68752 //
  68753 // If the input column is a VIRTUAL column, then it should not appear
  68754 // in storage.  But the value sometimes is cached in registers that
  68755 // follow the range of registers used to construct storage.  This
  68756 // avoids computing the same VIRTUAL column multiple times, and provides
  68757 // values for use by OP_Param opcodes in triggers.  Hence, if the
  68758 // input column is a VIRTUAL table, put it after all the other columns.
  68759 //
  68760 // In the following, N means "normal column", S means STORED, and
  68761 // V means VIRTUAL.  Suppose the CREATE TABLE has columns like this:
  68762 //
  68763 //	CREATE TABLE ex(N,S,V,N,S,V,N,S,V);
  68764 //	             -- 0 1 2 3 4 5 6 7 8
  68765 //
  68766 // Then the mapping from this function is as follows:
  68767 //
  68768 //	INPUTS:     0 1 2 3 4 5 6 7 8
  68769 //	OUTPUTS:    0 1 6 2 3 7 4 5 8
  68770 //
  68771 // So, in other words, this routine shifts all the virtual columns to
  68772 // the end.
  68773 //
  68774 // If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and
  68775 // this routine is a no-op macro.  If the pTab does not have any virtual
  68776 // columns, then this routine is no-op that always return iCol.  If iCol
  68777 // is negative (indicating the ROWID column) then this routine return iCol.
  68778 func Xsqlite3TableColumnToStorage(tls *libc.TLS, pTab uintptr, iCol I16) I16 {
  68779 	var i int32
  68780 	var n I16
  68781 
  68782 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasVirtual) == U32(0) || int32(iCol) < 0 {
  68783 		return iCol
  68784 	}
  68785 	i = 0
  68786 	n = int16(0)
  68787 	for ; i < int32(iCol); i++ {
  68788 		if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0 {
  68789 			n++
  68790 		}
  68791 	}
  68792 	if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0 {
  68793 		return I16(int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) + i - int32(n))
  68794 	} else {
  68795 		return n
  68796 	}
  68797 	return I16(0)
  68798 }
  68799 
  68800 func sqlite3ForceNotReadOnly(tls *libc.TLS, pParse uintptr) {
  68801 	var iReg int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  68802 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  68803 	if v != 0 {
  68804 		Xsqlite3VdbeAddOp3(tls, v, OP_JournalMode, 0, iReg, -1)
  68805 		Xsqlite3VdbeUsesBtree(tls, v, 0)
  68806 	}
  68807 }
  68808 
  68809 // Begin constructing a new table representation in memory.  This is
  68810 // the first of several action routines that get called in response
  68811 // to a CREATE TABLE statement.  In particular, this routine is called
  68812 // after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp
  68813 // flag is true if the table should be stored in the auxiliary database
  68814 // file instead of in the main database file.  This is normally the case
  68815 // when the "TEMP" or "TEMPORARY" keyword occurs in between
  68816 // CREATE and TABLE.
  68817 //
  68818 // The new table record is initialized and put in pParse->pNewTable.
  68819 // As more of the CREATE TABLE statement is parsed, additional action
  68820 // routines will be called to add more information to this record.
  68821 // At the end of the CREATE TABLE statement, the sqlite3EndTable() routine
  68822 // is called to complete the construction of the new table record.
  68823 func Xsqlite3StartTable(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, isTemp int32, isView int32, isVirtual int32, noErr int32) {
  68824 	bp := tls.Alloc(28)
  68825 	defer tls.Free(28)
  68826 
  68827 	var pTable uintptr
  68828 	var zName uintptr
  68829 	var db uintptr
  68830 	var v uintptr
  68831 	var iDb int32
  68832 
  68833 	var zDb uintptr
  68834 	var zDb1 uintptr
  68835 	var addr1 int32
  68836 	var fileFormat int32
  68837 	var reg1 int32
  68838 	var reg2 int32
  68839 	var reg3 int32
  68840 	zName = uintptr(0)
  68841 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  68842 
  68843 	if !((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 && (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum == Pgno(1)) {
  68844 		goto __1
  68845 	}
  68846 
  68847 	iDb = int32((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb)
  68848 	zName = Xsqlite3DbStrDup(tls, db, func() uintptr {
  68849 		if !(0 != 0) && iDb == 1 {
  68850 			return ts + 6389
  68851 		}
  68852 		return ts + 5883
  68853 	}())
  68854 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pName1
  68855 	goto __2
  68856 __1:
  68857 	iDb = Xsqlite3TwoPartName(tls, pParse, pName1, pName2, bp+24)
  68858 	if !(iDb < 0) {
  68859 		goto __3
  68860 	}
  68861 	return
  68862 __3:
  68863 	;
  68864 	if !(!(0 != 0) && isTemp != 0 && (*Token)(unsafe.Pointer(pName2)).Fn > uint32(0) && iDb != 1) {
  68865 		goto __4
  68866 	}
  68867 
  68868 	Xsqlite3ErrorMsg(tls, pParse, ts+12229, 0)
  68869 	return
  68870 __4:
  68871 	;
  68872 	if !(!(0 != 0) && isTemp != 0) {
  68873 		goto __5
  68874 	}
  68875 	iDb = 1
  68876 __5:
  68877 	;
  68878 	zName = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp + 24)))
  68879 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  68880 		goto __6
  68881 	}
  68882 	Xsqlite3RenameTokenMap(tls, pParse, zName, *(*uintptr)(unsafe.Pointer(bp + 24)))
  68883 __6:
  68884 	;
  68885 __2:
  68886 	;
  68887 	(*Parse)(unsafe.Pointer(pParse)).FsNameToken = *(*Token)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24))))
  68888 	if !(zName == uintptr(0)) {
  68889 		goto __7
  68890 	}
  68891 	return
  68892 __7:
  68893 	;
  68894 	if !(Xsqlite3CheckObjectName(tls, pParse, zName, func() uintptr {
  68895 		if isView != 0 {
  68896 			return ts + 10491
  68897 		}
  68898 		return ts + 8876
  68899 	}(), zName) != 0) {
  68900 		goto __8
  68901 	}
  68902 	goto begin_table_error
  68903 __8:
  68904 	;
  68905 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb) == 1) {
  68906 		goto __9
  68907 	}
  68908 	isTemp = 1
  68909 __9:
  68910 	;
  68911 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  68912 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr {
  68913 		if !(0 != 0) && isTemp == 1 {
  68914 			return ts + 6389
  68915 		}
  68916 		return ts + 5883
  68917 	}(), uintptr(0), zDb) != 0) {
  68918 		goto __10
  68919 	}
  68920 	goto begin_table_error
  68921 __10:
  68922 	;
  68923 	if !(!(isVirtual != 0) && Xsqlite3AuthCheck(tls, pParse, int32(aCode[isTemp+2*isView]),
  68924 		zName, uintptr(0), zDb) != 0) {
  68925 		goto __11
  68926 	}
  68927 	goto begin_table_error
  68928 __11:
  68929 	;
  68930 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) {
  68931 		goto __12
  68932 	}
  68933 	zDb1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  68934 	if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) {
  68935 		goto __13
  68936 	}
  68937 	goto begin_table_error
  68938 __13:
  68939 	;
  68940 	pTable = Xsqlite3FindTable(tls, db, zName, zDb1)
  68941 	if !(pTable != 0) {
  68942 		goto __14
  68943 	}
  68944 	if !!(noErr != 0) {
  68945 		goto __15
  68946 	}
  68947 	Xsqlite3ErrorMsg(tls, pParse, ts+12270,
  68948 		libc.VaList(bp, func() uintptr {
  68949 			if int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_VIEW {
  68950 				return ts + 10491
  68951 			}
  68952 			return ts + 8876
  68953 		}(), *(*uintptr)(unsafe.Pointer(bp + 24))))
  68954 	goto __16
  68955 __15:
  68956 	;
  68957 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  68958 	sqlite3ForceNotReadOnly(tls, pParse)
  68959 __16:
  68960 	;
  68961 	goto begin_table_error
  68962 __14:
  68963 	;
  68964 	if !(Xsqlite3FindIndex(tls, db, zName, zDb1) != uintptr(0)) {
  68965 		goto __17
  68966 	}
  68967 	Xsqlite3ErrorMsg(tls, pParse, ts+12291, libc.VaList(bp+16, zName))
  68968 	goto begin_table_error
  68969 __17:
  68970 	;
  68971 __12:
  68972 	;
  68973 	pTable = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))
  68974 	if !(pTable == uintptr(0)) {
  68975 		goto __18
  68976 	}
  68977 
  68978 	(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
  68979 	(*Parse)(unsafe.Pointer(pParse)).FnErr++
  68980 	goto begin_table_error
  68981 __18:
  68982 	;
  68983 	(*Table)(unsafe.Pointer(pTable)).FzName = zName
  68984 	(*Table)(unsafe.Pointer(pTable)).FiPKey = int16(-1)
  68985 	(*Table)(unsafe.Pointer(pTable)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  68986 	(*Table)(unsafe.Pointer(pTable)).FnTabRef = U32(1)
  68987 	(*Table)(unsafe.Pointer(pTable)).FnRowLogEst = int16(200)
  68988 
  68989 	(*Parse)(unsafe.Pointer(pParse)).FpNewTable = pTable
  68990 
  68991 	if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) && libc.AssignUintptr(&v, Xsqlite3GetVdbe(tls, pParse)) != uintptr(0)) {
  68992 		goto __19
  68993 	}
  68994 	Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb)
  68995 
  68996 	if !(isVirtual != 0) {
  68997 		goto __20
  68998 	}
  68999 	Xsqlite3VdbeAddOp0(tls, v, OP_VBegin)
  69000 __20:
  69001 	;
  69002 	reg1 = libc.AssignPtrInt32(pParse+92, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  69003 	reg2 = libc.AssignPtrInt32(pParse+96, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  69004 	reg3 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  69005 	Xsqlite3VdbeAddOp3(tls, v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT)
  69006 	Xsqlite3VdbeUsesBtree(tls, v, iDb)
  69007 	addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_If, reg3)
  69008 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LegacyFileFmt) != uint64(0) {
  69009 		fileFormat = 1
  69010 	} else {
  69011 		fileFormat = SQLITE_MAX_FILE_FORMAT
  69012 	}
  69013 	Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat)
  69014 	Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc))
  69015 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  69016 
  69017 	if !(isView != 0 || isVirtual != 0) {
  69018 		goto __21
  69019 	}
  69020 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, reg2)
  69021 	goto __22
  69022 __21:
  69023 	;
  69024 	*(*int32)(unsafe.Pointer(pParse + 136)) = Xsqlite3VdbeAddOp3(tls, v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY)
  69025 __22:
  69026 	;
  69027 	Xsqlite3OpenSchemaTable(tls, pParse, iDb)
  69028 	Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, 0, reg1)
  69029 	Xsqlite3VdbeAddOp4(tls, v, OP_Blob, 6, reg3, 0, uintptr(unsafe.Pointer(&nullRow)), -1)
  69030 	Xsqlite3VdbeAddOp3(tls, v, OP_Insert, 0, reg3, reg1)
  69031 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND))
  69032 	Xsqlite3VdbeAddOp0(tls, v, OP_Close)
  69033 __19:
  69034 	;
  69035 	return
  69036 
  69037 begin_table_error:
  69038 	(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  69039 	Xsqlite3DbFree(tls, db, zName)
  69040 	return
  69041 }
  69042 
  69043 var aCode = [4]U8{
  69044 	U8(SQLITE_CREATE_TABLE),
  69045 	U8(SQLITE_CREATE_TEMP_TABLE),
  69046 	U8(SQLITE_CREATE_VIEW),
  69047 	U8(SQLITE_CREATE_TEMP_VIEW),
  69048 }
  69049 var nullRow = [6]uint8{uint8(6), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0)}
  69050 
  69051 func sqlite3DeleteReturning(tls *libc.TLS, db uintptr, pRet uintptr) {
  69052 	var pHash uintptr
  69053 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema + 40
  69054 	Xsqlite3HashInsert(tls, pHash, ts+12326, uintptr(0))
  69055 	Xsqlite3ExprListDelete(tls, db, (*Returning)(unsafe.Pointer(pRet)).FpReturnEL)
  69056 	Xsqlite3DbFree(tls, db, pRet)
  69057 }
  69058 
  69059 // Add the RETURNING clause to the parse currently underway.
  69060 //
  69061 // This routine creates a special TEMP trigger that will fire for each row
  69062 // of the DML statement.  That TEMP trigger contains a single SELECT
  69063 // statement with a result set that is the argument of the RETURNING clause.
  69064 // The trigger has the Trigger.bReturning flag and an opcode of
  69065 // TK_RETURNING instead of TK_SELECT, so that the trigger code generator
  69066 // knows to handle it specially.  The TEMP trigger is automatically
  69067 // removed at the end of the parse.
  69068 //
  69069 // When this routine is called, we do not yet know if the RETURNING clause
  69070 // is attached to a DELETE, INSERT, or UPDATE, so construct it as a
  69071 // RETURNING trigger instead.  It will then be converted into the appropriate
  69072 // type on the first call to sqlite3TriggersExist().
  69073 func Xsqlite3AddReturning(tls *libc.TLS, pParse uintptr, pList uintptr) {
  69074 	var pRet uintptr
  69075 	var pHash uintptr
  69076 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69077 	if (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 {
  69078 		Xsqlite3ErrorMsg(tls, pParse, ts+12343, 0)
  69079 	} else {
  69080 	}
  69081 	(*Parse)(unsafe.Pointer(pParse)).FbReturning = U8(1)
  69082 	pRet = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Returning{})))
  69083 	if pRet == uintptr(0) {
  69084 		Xsqlite3ExprListDelete(tls, db, pList)
  69085 		return
  69086 	}
  69087 	*(*uintptr)(unsafe.Pointer(pParse + 136)) = pRet
  69088 	(*Returning)(unsafe.Pointer(pRet)).FpParse = pParse
  69089 	(*Returning)(unsafe.Pointer(pRet)).FpReturnEL = pList
  69090 	Xsqlite3ParserAddCleanup(tls, pParse,
  69091 		*(*uintptr)(unsafe.Pointer(&struct {
  69092 			f func(*libc.TLS, uintptr, uintptr)
  69093 		}{sqlite3DeleteReturning})), pRet)
  69094 
  69095 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  69096 		return
  69097 	}
  69098 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.FzName = ts + 12326
  69099 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.Fop = U8(TK_RETURNING)
  69100 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.Ftr_tm = U8(TRIGGER_AFTER)
  69101 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.FbReturning = U8(1)
  69102 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FpSchema
  69103 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.FpTabSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FpSchema
  69104 	(*Returning)(unsafe.Pointer(pRet)).FretTrig.Fstep_list = pRet + 44
  69105 	(*Returning)(unsafe.Pointer(pRet)).FretTStep.Fop = U8(TK_RETURNING)
  69106 	(*Returning)(unsafe.Pointer(pRet)).FretTStep.FpTrig = pRet + 8
  69107 	(*Returning)(unsafe.Pointer(pRet)).FretTStep.FpExprList = pList
  69108 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema + 40
  69109 
  69110 	if Xsqlite3HashInsert(tls, pHash, ts+12326, pRet+8) ==
  69111 		pRet+8 {
  69112 		Xsqlite3OomFault(tls, db)
  69113 	}
  69114 }
  69115 
  69116 // Add a new column to the table currently being constructed.
  69117 //
  69118 // The parser calls this routine once for each column declaration
  69119 // in a CREATE TABLE statement.  sqlite3StartTable() gets called
  69120 // first to get things going.  Then this routine is called for each
  69121 // column.
  69122 func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, sName Token, sType Token) {
  69123 	bp := tls.Alloc(32)
  69124 	defer tls.Free(32)
  69125 	*(*Token)(unsafe.Pointer(bp + 16)) = sName
  69126 	*(*Token)(unsafe.Pointer(bp + 24)) = sType
  69127 
  69128 	var p uintptr
  69129 	var i int32
  69130 	var z uintptr
  69131 	var zType uintptr
  69132 	var pCol uintptr
  69133 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69134 	var hName U8
  69135 	var aNew uintptr
  69136 	var eType U8 = U8(COLTYPE_CUSTOM)
  69137 	var szEst U8 = U8(1)
  69138 	var affinity uint8 = uint8(SQLITE_AFF_BLOB)
  69139 
  69140 	if libc.AssignUintptr(&p, (*Parse)(unsafe.Pointer(pParse)).FpNewTable) == uintptr(0) {
  69141 		return
  69142 	}
  69143 	if int32((*Table)(unsafe.Pointer(p)).FnCol)+1 > *(*int32)(unsafe.Pointer(db + 120 + 2*4)) {
  69144 		Xsqlite3ErrorMsg(tls, pParse, ts+12377, libc.VaList(bp, (*Table)(unsafe.Pointer(p)).FzName))
  69145 		return
  69146 	}
  69147 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  69148 		Xsqlite3DequoteToken(tls, bp+16)
  69149 	}
  69150 
  69151 	if (*Token)(unsafe.Pointer(bp+24)).Fn >= uint32(16) &&
  69152 		Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(bp+24)).Fz+uintptr((*Token)(unsafe.Pointer(bp+24)).Fn-uint32(6)), ts+12400, 6) == 0 {
  69153 		*(*uint32)(unsafe.Pointer(bp + 24 + 4)) -= uint32(6)
  69154 		for (*Token)(unsafe.Pointer(bp+24)).Fn > uint32(0) && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp+24)).Fz + uintptr((*Token)(unsafe.Pointer(bp+24)).Fn-uint32(1))))])&0x01 != 0 {
  69155 			(*Token)(unsafe.Pointer(bp+24)).Fn--
  69156 		}
  69157 		if (*Token)(unsafe.Pointer(bp+24)).Fn >= uint32(9) &&
  69158 			Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(bp+24)).Fz+uintptr((*Token)(unsafe.Pointer(bp+24)).Fn-uint32(9)), ts+12407, 9) == 0 {
  69159 			*(*uint32)(unsafe.Pointer(bp + 24 + 4)) -= uint32(9)
  69160 			for (*Token)(unsafe.Pointer(bp+24)).Fn > uint32(0) && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp+24)).Fz + uintptr((*Token)(unsafe.Pointer(bp+24)).Fn-uint32(1))))])&0x01 != 0 {
  69161 				(*Token)(unsafe.Pointer(bp+24)).Fn--
  69162 			}
  69163 		}
  69164 	}
  69165 
  69166 	if (*Token)(unsafe.Pointer(bp+24)).Fn >= uint32(3) {
  69167 		Xsqlite3DequoteToken(tls, bp+24)
  69168 		for i = 0; i < SQLITE_N_STDTYPE; i++ {
  69169 			if (*Token)(unsafe.Pointer(bp+24)).Fn == uint32(Xsqlite3StdTypeLen[i]) &&
  69170 				Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(bp+24)).Fz, Xsqlite3StdType[i], int32((*Token)(unsafe.Pointer(bp+24)).Fn)) == 0 {
  69171 				(*Token)(unsafe.Pointer(bp + 24)).Fn = uint32(0)
  69172 				eType = U8(i + 1)
  69173 				affinity = Xsqlite3StdTypeAffinity[i]
  69174 				if int32(affinity) <= SQLITE_AFF_TEXT {
  69175 					szEst = U8(5)
  69176 				}
  69177 				break
  69178 			}
  69179 		}
  69180 	}
  69181 
  69182 	z = Xsqlite3DbMallocRaw(tls, db, uint64(I64((*Token)(unsafe.Pointer(bp+16)).Fn)+int64(1)+I64((*Token)(unsafe.Pointer(bp+24)).Fn)+I64(libc.Bool32((*Token)(unsafe.Pointer(bp+24)).Fn > uint32(0)))))
  69183 	if z == uintptr(0) {
  69184 		return
  69185 	}
  69186 	if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  69187 		Xsqlite3RenameTokenMap(tls, pParse, z, bp+16)
  69188 	}
  69189 	libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(bp+16)).Fz, (*Token)(unsafe.Pointer(bp+16)).Fn)
  69190 	*(*uint8)(unsafe.Pointer(z + uintptr((*Token)(unsafe.Pointer(bp+16)).Fn))) = uint8(0)
  69191 	Xsqlite3Dequote(tls, z)
  69192 	hName = Xsqlite3StrIHash(tls, z)
  69193 	for i = 0; i < int32((*Table)(unsafe.Pointer(p)).FnCol); i++ {
  69194 		if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol+uintptr(i)*16)).FhName) == int32(hName) && Xsqlite3StrICmp(tls, z, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol+uintptr(i)*16)).FzCnName) == 0 {
  69195 			Xsqlite3ErrorMsg(tls, pParse, ts+12417, libc.VaList(bp+8, z))
  69196 			Xsqlite3DbFree(tls, db, z)
  69197 			return
  69198 		}
  69199 	}
  69200 	aNew = Xsqlite3DbRealloc(tls, db, (*Table)(unsafe.Pointer(p)).FaCol, uint64((I64((*Table)(unsafe.Pointer(p)).FnCol)+int64(1))*I64(unsafe.Sizeof(Column{}))))
  69201 	if aNew == uintptr(0) {
  69202 		Xsqlite3DbFree(tls, db, z)
  69203 		return
  69204 	}
  69205 	(*Table)(unsafe.Pointer(p)).FaCol = aNew
  69206 	pCol = (*Table)(unsafe.Pointer(p)).FaCol + uintptr((*Table)(unsafe.Pointer(p)).FnCol)*16
  69207 	libc.Xmemset(tls, pCol, 0, uint32(unsafe.Sizeof(Column{})))
  69208 	(*Column)(unsafe.Pointer(pCol)).FzCnName = z
  69209 	(*Column)(unsafe.Pointer(pCol)).FhName = hName
  69210 
  69211 	if (*Token)(unsafe.Pointer(bp+24)).Fn == uint32(0) {
  69212 		(*Column)(unsafe.Pointer(pCol)).Faffinity = affinity
  69213 		libc.SetBitFieldPtr8Uint32(pCol+4, uint32(eType), 4, 0xf0)
  69214 		(*Column)(unsafe.Pointer(pCol)).FszEst = szEst
  69215 	} else {
  69216 		zType = z + uintptr(Xsqlite3Strlen30(tls, z)) + uintptr(1)
  69217 		libc.Xmemcpy(tls, zType, (*Token)(unsafe.Pointer(bp+24)).Fz, (*Token)(unsafe.Pointer(bp+24)).Fn)
  69218 		*(*uint8)(unsafe.Pointer(zType + uintptr((*Token)(unsafe.Pointer(bp+24)).Fn))) = uint8(0)
  69219 		Xsqlite3Dequote(tls, zType)
  69220 		(*Column)(unsafe.Pointer(pCol)).Faffinity = Xsqlite3AffinityType(tls, zType, pCol)
  69221 		*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_HASTYPE)
  69222 	}
  69223 	(*Table)(unsafe.Pointer(p)).FnCol++
  69224 	(*Table)(unsafe.Pointer(p)).FnNVCol++
  69225 	(*Parse)(unsafe.Pointer(pParse)).FconstraintName.Fn = uint32(0)
  69226 }
  69227 
  69228 // This routine is called by the parser while in the middle of
  69229 // parsing a CREATE TABLE statement.  A "NOT NULL" constraint has
  69230 // been seen on a column.  This routine sets the notNull flag on
  69231 // the column currently under construction.
  69232 func Xsqlite3AddNotNull(tls *libc.TLS, pParse uintptr, onError int32) {
  69233 	var p uintptr
  69234 	var pCol uintptr
  69235 	p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  69236 	if p == uintptr(0) || int32((*Table)(unsafe.Pointer(p)).FnCol) < 1 {
  69237 		return
  69238 	}
  69239 	pCol = (*Table)(unsafe.Pointer(p)).FaCol + uintptr(int32((*Table)(unsafe.Pointer(p)).FnCol)-1)*16
  69240 	libc.SetBitFieldPtr8Uint32(pCol+4, uint32(U8(onError)), 0, 0xf)
  69241 	*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_HasNotNull)
  69242 
  69243 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_UNIQUE != 0 {
  69244 		var pIdx uintptr
  69245 		for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  69246 			if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn))) == int32((*Table)(unsafe.Pointer(p)).FnCol)-1 {
  69247 				libc.SetBitFieldPtr16Uint32(pIdx+56, uint32(1), 3, 0x8)
  69248 			}
  69249 		}
  69250 	}
  69251 }
  69252 
  69253 // Scan the column type name zType (length nType) and return the
  69254 // associated affinity type.
  69255 //
  69256 // This routine does a case-independent search of zType for the
  69257 // substrings in the following table. If one of the substrings is
  69258 // found, the corresponding affinity is returned. If zType contains
  69259 // more than one of the substrings, entries toward the top of
  69260 // the table take priority. For example, if zType is 'BLOBINT',
  69261 // SQLITE_AFF_INTEGER is returned.
  69262 //
  69263 // Substring     | Affinity
  69264 // --------------------------------
  69265 // 'INT'         | SQLITE_AFF_INTEGER
  69266 // 'CHAR'        | SQLITE_AFF_TEXT
  69267 // 'CLOB'        | SQLITE_AFF_TEXT
  69268 // 'TEXT'        | SQLITE_AFF_TEXT
  69269 // 'BLOB'        | SQLITE_AFF_BLOB
  69270 // 'REAL'        | SQLITE_AFF_REAL
  69271 // 'FLOA'        | SQLITE_AFF_REAL
  69272 // 'DOUB'        | SQLITE_AFF_REAL
  69273 //
  69274 // If none of the substrings in the above table are found,
  69275 // SQLITE_AFF_NUMERIC is returned.
  69276 func Xsqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) uint8 {
  69277 	bp := tls.Alloc(4)
  69278 	defer tls.Free(4)
  69279 
  69280 	var h U32 = U32(0)
  69281 	var aff uint8 = uint8(SQLITE_AFF_NUMERIC)
  69282 	var zChar uintptr = uintptr(0)
  69283 
  69284 	for *(*uint8)(unsafe.Pointer(zIn)) != 0 {
  69285 		h = h<<8 + U32(Xsqlite3UpperToLower[int32(*(*uint8)(unsafe.Pointer(zIn)))&0xff])
  69286 		zIn++
  69287 		if h == U32(int32('c')<<24+int32('h')<<16+int32('a')<<8+'r') {
  69288 			aff = uint8(SQLITE_AFF_TEXT)
  69289 			zChar = zIn
  69290 		} else if h == U32(int32('c')<<24+int32('l')<<16+int32('o')<<8+'b') {
  69291 			aff = uint8(SQLITE_AFF_TEXT)
  69292 		} else if h == U32(int32('t')<<24+int32('e')<<16+int32('x')<<8+'t') {
  69293 			aff = uint8(SQLITE_AFF_TEXT)
  69294 		} else if h == U32(int32('b')<<24+int32('l')<<16+int32('o')<<8+'b') &&
  69295 			(int32(aff) == SQLITE_AFF_NUMERIC || int32(aff) == SQLITE_AFF_REAL) {
  69296 			aff = uint8(SQLITE_AFF_BLOB)
  69297 			if int32(*(*uint8)(unsafe.Pointer(zIn))) == '(' {
  69298 				zChar = zIn
  69299 			}
  69300 		} else if h == U32(int32('r')<<24+int32('e')<<16+int32('a')<<8+'l') &&
  69301 			int32(aff) == SQLITE_AFF_NUMERIC {
  69302 			aff = uint8(SQLITE_AFF_REAL)
  69303 		} else if h == U32(int32('f')<<24+int32('l')<<16+int32('o')<<8+'a') &&
  69304 			int32(aff) == SQLITE_AFF_NUMERIC {
  69305 			aff = uint8(SQLITE_AFF_REAL)
  69306 		} else if h == U32(int32('d')<<24+int32('o')<<16+int32('u')<<8+'b') &&
  69307 			int32(aff) == SQLITE_AFF_NUMERIC {
  69308 			aff = uint8(SQLITE_AFF_REAL)
  69309 		} else if h&U32(0x00FFFFFF) == U32(int32('i')<<16+int32('n')<<8+'t') {
  69310 			aff = uint8(SQLITE_AFF_INTEGER)
  69311 			break
  69312 		}
  69313 	}
  69314 
  69315 	if pCol != 0 {
  69316 		*(*int32)(unsafe.Pointer(bp)) = 0
  69317 		if int32(aff) < SQLITE_AFF_NUMERIC {
  69318 			if zChar != 0 {
  69319 				for *(*uint8)(unsafe.Pointer(zChar)) != 0 {
  69320 					if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zChar))])&0x04 != 0 {
  69321 						Xsqlite3GetInt32(tls, zChar, bp)
  69322 						break
  69323 					}
  69324 					zChar++
  69325 				}
  69326 			} else {
  69327 				*(*int32)(unsafe.Pointer(bp)) = 16
  69328 			}
  69329 		}
  69330 		*(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(bp))/4 + 1
  69331 		if *(*int32)(unsafe.Pointer(bp)) > 255 {
  69332 			*(*int32)(unsafe.Pointer(bp)) = 255
  69333 		}
  69334 		(*Column)(unsafe.Pointer(pCol)).FszEst = U8(*(*int32)(unsafe.Pointer(bp)))
  69335 	}
  69336 	return aff
  69337 }
  69338 
  69339 // The expression is the default value for the most recently added column
  69340 // of the table currently under construction.
  69341 //
  69342 // Default value expressions must be constant.  Raise an exception if this
  69343 // is not the case.
  69344 //
  69345 // This routine is called by the parser while in the middle of
  69346 // parsing a CREATE TABLE statement.
  69347 func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStart uintptr, zEnd uintptr) {
  69348 	bp := tls.Alloc(60)
  69349 	defer tls.Free(60)
  69350 
  69351 	var p uintptr
  69352 	var pCol uintptr
  69353 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69354 	p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  69355 	if p != uintptr(0) {
  69356 		var isInit int32 = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 && int32((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb) != 1)
  69357 		pCol = (*Table)(unsafe.Pointer(p)).FaCol + uintptr(int32((*Table)(unsafe.Pointer(p)).FnCol)-1)*16
  69358 		if !(Xsqlite3ExprIsConstantOrFunction(tls, pExpr, uint8(isInit)) != 0) {
  69359 			Xsqlite3ErrorMsg(tls, pParse, ts+12443,
  69360 				libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzCnName))
  69361 		} else if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_GENERATED != 0 {
  69362 			Xsqlite3ErrorMsg(tls, pParse, ts+12488, 0)
  69363 		} else {
  69364 			var pDfltExpr uintptr
  69365 			libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(Expr{})))
  69366 			(*Expr)(unsafe.Pointer(bp + 8)).Fop = U8(TK_SPAN)
  69367 			*(*uintptr)(unsafe.Pointer(bp + 8 + 8)) = Xsqlite3DbSpanDup(tls, db, zStart, zEnd)
  69368 			(*Expr)(unsafe.Pointer(bp + 8)).FpLeft = pExpr
  69369 			(*Expr)(unsafe.Pointer(bp + 8)).Fflags = U32(EP_Skip)
  69370 			pDfltExpr = Xsqlite3ExprDup(tls, db, bp+8, EXPRDUP_REDUCE)
  69371 			Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 + 8)))
  69372 			Xsqlite3ColumnSetExpr(tls, pParse, p, pCol, pDfltExpr)
  69373 		}
  69374 	}
  69375 	if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  69376 		Xsqlite3RenameExprUnmap(tls, pParse, pExpr)
  69377 	}
  69378 	Xsqlite3ExprDelete(tls, db, pExpr)
  69379 }
  69380 
  69381 func sqlite3StringToId(tls *libc.TLS, p uintptr) {
  69382 	if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_STRING {
  69383 		(*Expr)(unsafe.Pointer(p)).Fop = U8(TK_ID)
  69384 	} else if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLLATE && int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop) == TK_STRING {
  69385 		(*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop = U8(TK_ID)
  69386 	}
  69387 }
  69388 
  69389 func makeColumnPartOfPrimaryKey(tls *libc.TLS, pParse uintptr, pCol uintptr) {
  69390 	*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_PRIMKEY)
  69391 	if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_GENERATED != 0 {
  69392 		Xsqlite3ErrorMsg(tls, pParse,
  69393 			ts+12529, 0)
  69394 	}
  69395 }
  69396 
  69397 // Designate the PRIMARY KEY for the table.  pList is a list of names
  69398 // of columns that form the primary key.  If pList is NULL, then the
  69399 // most recently added column of the table is the primary key.
  69400 //
  69401 // A table can have at most one primary key.  If the table already has
  69402 // a primary key (and this is the second primary key) then create an
  69403 // error.
  69404 //
  69405 // If the PRIMARY KEY is on a single column whose datatype is INTEGER,
  69406 // then we will try to use that column as the rowid.  Set the Table.iPKey
  69407 // field of the table under construction to be the index of the
  69408 // INTEGER PRIMARY KEY column.  Table.iPKey is set to -1 if there is
  69409 // no INTEGER PRIMARY KEY.
  69410 //
  69411 // If the key is not an INTEGER PRIMARY KEY, then create a unique
  69412 // index for the key.  No index is created for INTEGER PRIMARY KEYs.
  69413 func Xsqlite3AddPrimaryKey(tls *libc.TLS, pParse uintptr, pList uintptr, onError int32, autoInc int32, sortOrder int32) {
  69414 	bp := tls.Alloc(8)
  69415 	defer tls.Free(8)
  69416 
  69417 	var pTab uintptr
  69418 	var pCol uintptr
  69419 	var iCol int32
  69420 	var i int32
  69421 	var nTerm int32
  69422 	var zCName uintptr
  69423 	var pCExpr uintptr
  69424 	var pCExpr1 uintptr
  69425 	pTab = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  69426 	pCol = uintptr(0)
  69427 	iCol = -1
  69428 	if !(pTab == uintptr(0)) {
  69429 		goto __1
  69430 	}
  69431 	goto primary_key_exit
  69432 __1:
  69433 	;
  69434 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasPrimaryKey) != 0) {
  69435 		goto __2
  69436 	}
  69437 	Xsqlite3ErrorMsg(tls, pParse,
  69438 		ts+12581, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  69439 	goto primary_key_exit
  69440 __2:
  69441 	;
  69442 	*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_HasPrimaryKey)
  69443 	if !(pList == uintptr(0)) {
  69444 		goto __3
  69445 	}
  69446 	iCol = int32((*Table)(unsafe.Pointer(pTab)).FnCol) - 1
  69447 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16
  69448 	makeColumnPartOfPrimaryKey(tls, pParse, pCol)
  69449 	nTerm = 1
  69450 	goto __4
  69451 __3:
  69452 	nTerm = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  69453 	i = 0
  69454 __5:
  69455 	if !(i < nTerm) {
  69456 		goto __7
  69457 	}
  69458 	pCExpr = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr)
  69459 
  69460 	sqlite3StringToId(tls, pCExpr)
  69461 	if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) == TK_ID) {
  69462 		goto __8
  69463 	}
  69464 
  69465 	zCName = *(*uintptr)(unsafe.Pointer(pCExpr + 8))
  69466 	iCol = 0
  69467 __9:
  69468 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  69469 		goto __11
  69470 	}
  69471 	if !(Xsqlite3StrICmp(tls, zCName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FzCnName) == 0) {
  69472 		goto __12
  69473 	}
  69474 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16
  69475 	makeColumnPartOfPrimaryKey(tls, pParse, pCol)
  69476 	goto __11
  69477 __12:
  69478 	;
  69479 	goto __10
  69480 __10:
  69481 	iCol++
  69482 	goto __9
  69483 	goto __11
  69484 __11:
  69485 	;
  69486 __8:
  69487 	;
  69488 	goto __6
  69489 __6:
  69490 	i++
  69491 	goto __5
  69492 	goto __7
  69493 __7:
  69494 	;
  69495 __4:
  69496 	;
  69497 	if !(nTerm == 1 &&
  69498 		pCol != 0 &&
  69499 		int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf0>>4) == COLTYPE_INTEGER &&
  69500 		sortOrder != SQLITE_SO_DESC) {
  69501 		goto __13
  69502 	}
  69503 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && pList != 0) {
  69504 		goto __15
  69505 	}
  69506 	pCExpr1 = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer(pList+8)).FpExpr)
  69507 	Xsqlite3RenameTokenRemap(tls, pParse, pTab+32, pCExpr1)
  69508 __15:
  69509 	;
  69510 	(*Table)(unsafe.Pointer(pTab)).FiPKey = I16(iCol)
  69511 	(*Table)(unsafe.Pointer(pTab)).FkeyConf = U8(onError)
  69512 
  69513 	*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(autoInc * TF_Autoincrement)
  69514 	if !(pList != 0) {
  69515 		goto __16
  69516 	}
  69517 	(*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*ExprList_item)(unsafe.Pointer(pList + 8)).Ffg.FsortFlags
  69518 __16:
  69519 	;
  69520 	Xsqlite3HasExplicitNulls(tls, pParse, pList)
  69521 	goto __14
  69522 __13:
  69523 	if !(autoInc != 0) {
  69524 		goto __17
  69525 	}
  69526 	Xsqlite3ErrorMsg(tls, pParse,
  69527 		ts+12622, 0)
  69528 	goto __18
  69529 __17:
  69530 	Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, onError, uintptr(0),
  69531 		uintptr(0), sortOrder, 0, uint8(SQLITE_IDXTYPE_PRIMARYKEY))
  69532 	pList = uintptr(0)
  69533 __18:
  69534 	;
  69535 __14:
  69536 	;
  69537 primary_key_exit:
  69538 	Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList)
  69539 	return
  69540 }
  69541 
  69542 // Add a new CHECK constraint to the table currently under construction.
  69543 func Xsqlite3AddCheckConstraint(tls *libc.TLS, pParse uintptr, pCheckExpr uintptr, zStart uintptr, zEnd uintptr) {
  69544 	bp := tls.Alloc(8)
  69545 	defer tls.Free(8)
  69546 
  69547 	var pTab uintptr = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  69548 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69549 	if pTab != 0 && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) &&
  69550 		!(Xsqlite3BtreeIsReadonly(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb)*16)).FpBt) != 0) {
  69551 		(*Table)(unsafe.Pointer(pTab)).FpCheck = Xsqlite3ExprListAppend(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FpCheck, pCheckExpr)
  69552 		if (*Parse)(unsafe.Pointer(pParse)).FconstraintName.Fn != 0 {
  69553 			Xsqlite3ExprListSetName(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FpCheck, pParse+76, 1)
  69554 		} else {
  69555 			for zStart++; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zStart))])&0x01 != 0; zStart++ {
  69556 			}
  69557 			for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zEnd + libc.UintptrFromInt32(-1)))])&0x01 != 0 {
  69558 				zEnd--
  69559 			}
  69560 			(*Token)(unsafe.Pointer(bp)).Fz = zStart
  69561 			(*Token)(unsafe.Pointer(bp)).Fn = uint32((int32(zEnd) - int32((*Token)(unsafe.Pointer(bp)).Fz)) / 1)
  69562 			Xsqlite3ExprListSetName(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FpCheck, bp, 1)
  69563 		}
  69564 	} else {
  69565 		Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pCheckExpr)
  69566 	}
  69567 }
  69568 
  69569 // Set the collation function of the most recently parsed table column
  69570 // to the CollSeq given.
  69571 func Xsqlite3AddCollateType(tls *libc.TLS, pParse uintptr, pToken uintptr) {
  69572 	var p uintptr
  69573 	var i int32
  69574 	var zColl uintptr
  69575 	var db uintptr
  69576 
  69577 	if libc.AssignUintptr(&p, (*Parse)(unsafe.Pointer(pParse)).FpNewTable) == uintptr(0) || int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  69578 		return
  69579 	}
  69580 	i = int32((*Table)(unsafe.Pointer(p)).FnCol) - 1
  69581 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69582 	zColl = Xsqlite3NameFromToken(tls, db, pToken)
  69583 	if !(zColl != 0) {
  69584 		return
  69585 	}
  69586 
  69587 	if Xsqlite3LocateCollSeq(tls, pParse, zColl) != 0 {
  69588 		var pIdx uintptr
  69589 		Xsqlite3ColumnSetColl(tls, db, (*Table)(unsafe.Pointer(p)).FaCol+uintptr(i)*16, zColl)
  69590 
  69591 		for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  69592 			if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn))) == i {
  69593 				*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl)) = Xsqlite3ColumnColl(tls, (*Table)(unsafe.Pointer(p)).FaCol+uintptr(i)*16)
  69594 			}
  69595 		}
  69596 	}
  69597 	Xsqlite3DbFree(tls, db, zColl)
  69598 }
  69599 
  69600 // Change the most recently parsed column to be a GENERATED ALWAYS AS
  69601 // column.
  69602 func Xsqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType uintptr) {
  69603 	bp := tls.Alloc(8)
  69604 	defer tls.Free(8)
  69605 
  69606 	var eType U8
  69607 	var pTab uintptr
  69608 	var pCol uintptr
  69609 	eType = U8(COLFLAG_VIRTUAL)
  69610 	pTab = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  69611 	if !(pTab == uintptr(0)) {
  69612 		goto __1
  69613 	}
  69614 
  69615 	goto generated_done
  69616 __1:
  69617 	;
  69618 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1)*16
  69619 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) {
  69620 		goto __2
  69621 	}
  69622 	Xsqlite3ErrorMsg(tls, pParse, ts+12678, 0)
  69623 	goto generated_done
  69624 __2:
  69625 	;
  69626 	if !(int32((*Column)(unsafe.Pointer(pCol)).FiDflt) > 0) {
  69627 		goto __3
  69628 	}
  69629 	goto generated_error
  69630 __3:
  69631 	;
  69632 	if !(pType != 0) {
  69633 		goto __4
  69634 	}
  69635 	if !((*Token)(unsafe.Pointer(pType)).Fn == uint32(7) && Xsqlite3_strnicmp(tls, ts+12721, (*Token)(unsafe.Pointer(pType)).Fz, 7) == 0) {
  69636 		goto __5
  69637 	}
  69638 
  69639 	goto __6
  69640 __5:
  69641 	if !((*Token)(unsafe.Pointer(pType)).Fn == uint32(6) && Xsqlite3_strnicmp(tls, ts+12729, (*Token)(unsafe.Pointer(pType)).Fz, 6) == 0) {
  69642 		goto __7
  69643 	}
  69644 	eType = U8(COLFLAG_STORED)
  69645 	goto __8
  69646 __7:
  69647 	goto generated_error
  69648 __8:
  69649 	;
  69650 __6:
  69651 	;
  69652 __4:
  69653 	;
  69654 	if !(int32(eType) == COLFLAG_VIRTUAL) {
  69655 		goto __9
  69656 	}
  69657 	(*Table)(unsafe.Pointer(pTab)).FnNVCol--
  69658 __9:
  69659 	;
  69660 	*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(int32(eType))
  69661 
  69662 	*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(eType)
  69663 	if !(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_PRIMKEY != 0) {
  69664 		goto __10
  69665 	}
  69666 	makeColumnPartOfPrimaryKey(tls, pParse, pCol)
  69667 __10:
  69668 	;
  69669 	if !(pExpr != 0 && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ID) {
  69670 		goto __11
  69671 	}
  69672 
  69673 	pExpr = Xsqlite3PExpr(tls, pParse, TK_UPLUS, pExpr, uintptr(0))
  69674 __11:
  69675 	;
  69676 	if !(pExpr != 0 && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_RAISE) {
  69677 		goto __12
  69678 	}
  69679 	(*Expr)(unsafe.Pointer(pExpr)).FaffExpr = (*Column)(unsafe.Pointer(pCol)).Faffinity
  69680 __12:
  69681 	;
  69682 	Xsqlite3ColumnSetExpr(tls, pParse, pTab, pCol, pExpr)
  69683 	pExpr = uintptr(0)
  69684 	goto generated_done
  69685 
  69686 generated_error:
  69687 	Xsqlite3ErrorMsg(tls, pParse, ts+12736,
  69688 		libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzCnName))
  69689 generated_done:
  69690 	Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
  69691 }
  69692 
  69693 // Generate code that will increment the schema cookie.
  69694 //
  69695 // The schema cookie is used to determine when the schema for the
  69696 // database changes.  After each schema change, the cookie value
  69697 // changes.  When a process first reads the schema it records the
  69698 // cookie.  Thereafter, whenever it goes to access the database,
  69699 // it checks the cookie to make sure the schema has not changed
  69700 // since it was last read.
  69701 //
  69702 // This plan is not completely bullet-proof.  It is possible for
  69703 // the schema to change multiple times and for the cookie to be
  69704 // set back to prior value.  But schema changes are infrequent
  69705 // and the probability of hitting the same cookie value is only
  69706 // 1 chance in 2^32.  So we're safe enough.
  69707 //
  69708 // IMPLEMENTATION-OF: R-34230-56049 SQLite automatically increments
  69709 // the schema-version whenever the schema changes.
  69710 func Xsqlite3ChangeCookie(tls *libc.TLS, pParse uintptr, iDb int32) {
  69711 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69712 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  69713 
  69714 	Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION,
  69715 		int32(uint32(1)+uint32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema)).Fschema_cookie)))
  69716 }
  69717 
  69718 func identLength(tls *libc.TLS, z uintptr) int32 {
  69719 	var n int32
  69720 	n = 0
  69721 __1:
  69722 	if !(*(*uint8)(unsafe.Pointer(z)) != 0) {
  69723 		goto __3
  69724 	}
  69725 	{
  69726 		if int32(*(*uint8)(unsafe.Pointer(z))) == '"' {
  69727 			n++
  69728 		}
  69729 
  69730 	}
  69731 	goto __2
  69732 __2:
  69733 	n++
  69734 	z++
  69735 	goto __1
  69736 	goto __3
  69737 __3:
  69738 	;
  69739 	return n + 2
  69740 }
  69741 
  69742 func identPut(tls *libc.TLS, z uintptr, pIdx uintptr, zSignedIdent uintptr) {
  69743 	var zIdent uintptr = zSignedIdent
  69744 	var i int32
  69745 	var j int32
  69746 	var needQuote int32
  69747 	i = *(*int32)(unsafe.Pointer(pIdx))
  69748 
  69749 	for j = 0; *(*uint8)(unsafe.Pointer(zIdent + uintptr(j))) != 0; j++ {
  69750 		if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))])&0x06 != 0) && int32(*(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))) != '_' {
  69751 			break
  69752 		}
  69753 	}
  69754 	needQuote = libc.Bool32(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zIdent))])&0x04 != 0 ||
  69755 		Xsqlite3KeywordCode(tls, zIdent, j) != TK_ID ||
  69756 		int32(*(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))) != 0 ||
  69757 		j == 0)
  69758 
  69759 	if needQuote != 0 {
  69760 		*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = uint8('"')
  69761 	}
  69762 	for j = 0; *(*uint8)(unsafe.Pointer(zIdent + uintptr(j))) != 0; j++ {
  69763 		*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = *(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))
  69764 		if int32(*(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))) == '"' {
  69765 			*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = uint8('"')
  69766 		}
  69767 	}
  69768 	if needQuote != 0 {
  69769 		*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = uint8('"')
  69770 	}
  69771 	*(*uint8)(unsafe.Pointer(z + uintptr(i))) = uint8(0)
  69772 	*(*int32)(unsafe.Pointer(pIdx)) = i
  69773 }
  69774 
  69775 func createTableStmt(tls *libc.TLS, db uintptr, p uintptr) uintptr {
  69776 	bp := tls.Alloc(12)
  69777 	defer tls.Free(12)
  69778 
  69779 	var i int32
  69780 
  69781 	var n int32
  69782 	var zStmt uintptr
  69783 	var zSep uintptr
  69784 	var zSep2 uintptr
  69785 	var zEnd uintptr
  69786 	var pCol uintptr
  69787 	n = 0
  69788 	pCol = (*Table)(unsafe.Pointer(p)).FaCol
  69789 	i = 0
  69790 __1:
  69791 	if !(i < int32((*Table)(unsafe.Pointer(p)).FnCol)) {
  69792 		goto __3
  69793 	}
  69794 	{
  69795 		n = n + (identLength(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName) + 5)
  69796 
  69797 	}
  69798 	goto __2
  69799 __2:
  69800 	i++
  69801 	pCol += 16
  69802 	goto __1
  69803 	goto __3
  69804 __3:
  69805 	;
  69806 	n = n + identLength(tls, (*Table)(unsafe.Pointer(p)).FzName)
  69807 	if n < 50 {
  69808 		zSep = ts + 1554
  69809 		zSep2 = ts + 12767
  69810 		zEnd = ts + 4957
  69811 	} else {
  69812 		zSep = ts + 12769
  69813 		zSep2 = ts + 12773
  69814 		zEnd = ts + 12778
  69815 	}
  69816 	n = n + (35 + 6*int32((*Table)(unsafe.Pointer(p)).FnCol))
  69817 	zStmt = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(n))
  69818 	if zStmt == uintptr(0) {
  69819 		Xsqlite3OomFault(tls, db)
  69820 		return uintptr(0)
  69821 	}
  69822 	Xsqlite3_snprintf(tls, n, zStmt, ts+12781, 0)
  69823 	*(*int32)(unsafe.Pointer(bp + 8)) = Xsqlite3Strlen30(tls, zStmt)
  69824 	identPut(tls, zStmt, bp+8, (*Table)(unsafe.Pointer(p)).FzName)
  69825 	*(*uint8)(unsafe.Pointer(zStmt + uintptr(libc.PostIncInt32(&*(*int32)(unsafe.Pointer(bp + 8)), 1)))) = uint8('(')
  69826 	pCol = (*Table)(unsafe.Pointer(p)).FaCol
  69827 	i = 0
  69828 __4:
  69829 	if !(i < int32((*Table)(unsafe.Pointer(p)).FnCol)) {
  69830 		goto __6
  69831 	}
  69832 	{
  69833 		var len int32
  69834 		var zType uintptr
  69835 
  69836 		Xsqlite3_snprintf(tls, n-*(*int32)(unsafe.Pointer(bp + 8)), zStmt+uintptr(*(*int32)(unsafe.Pointer(bp + 8))), zSep, 0)
  69837 		*(*int32)(unsafe.Pointer(bp + 8)) += Xsqlite3Strlen30(tls, zStmt+uintptr(*(*int32)(unsafe.Pointer(bp + 8))))
  69838 		zSep = zSep2
  69839 		identPut(tls, zStmt, bp+8, (*Column)(unsafe.Pointer(pCol)).FzCnName)
  69840 
  69841 		zType = azType1[int32((*Column)(unsafe.Pointer(pCol)).Faffinity)-SQLITE_AFF_BLOB]
  69842 		len = Xsqlite3Strlen30(tls, zType)
  69843 
  69844 		libc.Xmemcpy(tls, zStmt+uintptr(*(*int32)(unsafe.Pointer(bp + 8))), zType, uint32(len))
  69845 		*(*int32)(unsafe.Pointer(bp + 8)) += len
  69846 
  69847 	}
  69848 	goto __5
  69849 __5:
  69850 	i++
  69851 	pCol += 16
  69852 	goto __4
  69853 	goto __6
  69854 __6:
  69855 	;
  69856 	Xsqlite3_snprintf(tls, n-*(*int32)(unsafe.Pointer(bp + 8)), zStmt+uintptr(*(*int32)(unsafe.Pointer(bp + 8))), ts+3663, libc.VaList(bp, zEnd))
  69857 	return zStmt
  69858 }
  69859 
  69860 var azType1 = [6]uintptr{
  69861 	ts + 1554,
  69862 	ts + 12795,
  69863 	ts + 12801,
  69864 	ts + 12806,
  69865 	ts + 12811,
  69866 	ts + 12801,
  69867 }
  69868 
  69869 func resizeIndexObject(tls *libc.TLS, db uintptr, pIdx uintptr, N int32) int32 {
  69870 	var zExtra uintptr
  69871 	var nByte int32
  69872 	if int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) >= N {
  69873 		return SQLITE_OK
  69874 	}
  69875 
  69876 	nByte = int32((uint32(unsafe.Sizeof(uintptr(0))) + uint32(unsafe.Sizeof(LogEst(0))) + uint32(unsafe.Sizeof(I16(0))) + uint32(1)) * uint32(N))
  69877 	zExtra = Xsqlite3DbMallocZero(tls, db, uint64(nByte))
  69878 	if zExtra == uintptr(0) {
  69879 		return SQLITE_NOMEM
  69880 	}
  69881 	libc.Xmemcpy(tls, zExtra, (*Index)(unsafe.Pointer(pIdx)).FazColl, uint32(unsafe.Sizeof(uintptr(0)))*uint32((*Index)(unsafe.Pointer(pIdx)).FnColumn))
  69882 	(*Index)(unsafe.Pointer(pIdx)).FazColl = zExtra
  69883 	zExtra += uintptr(uint32(unsafe.Sizeof(uintptr(0))) * uint32(N))
  69884 	libc.Xmemcpy(tls, zExtra, (*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst, uint32(unsafe.Sizeof(LogEst(0)))*uint32(int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)+1))
  69885 	(*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst = zExtra
  69886 	zExtra += uintptr(uint32(unsafe.Sizeof(LogEst(0))) * uint32(N))
  69887 	libc.Xmemcpy(tls, zExtra, (*Index)(unsafe.Pointer(pIdx)).FaiColumn, uint32(unsafe.Sizeof(I16(0)))*uint32((*Index)(unsafe.Pointer(pIdx)).FnColumn))
  69888 	(*Index)(unsafe.Pointer(pIdx)).FaiColumn = zExtra
  69889 	zExtra += uintptr(uint32(unsafe.Sizeof(I16(0))) * uint32(N))
  69890 	libc.Xmemcpy(tls, zExtra, (*Index)(unsafe.Pointer(pIdx)).FaSortOrder, uint32((*Index)(unsafe.Pointer(pIdx)).FnColumn))
  69891 	(*Index)(unsafe.Pointer(pIdx)).FaSortOrder = zExtra
  69892 	(*Index)(unsafe.Pointer(pIdx)).FnColumn = U16(N)
  69893 	libc.SetBitFieldPtr16Uint32(pIdx+56, uint32(1), 4, 0x10)
  69894 	return SQLITE_OK
  69895 }
  69896 
  69897 func estimateTableWidth(tls *libc.TLS, pTab uintptr) {
  69898 	var wTable uint32 = uint32(0)
  69899 	var pTabCol uintptr
  69900 	var i int32
  69901 	i = int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  69902 	pTabCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  69903 __1:
  69904 	if !(i > 0) {
  69905 		goto __3
  69906 	}
  69907 	{
  69908 		wTable = wTable + uint32((*Column)(unsafe.Pointer(pTabCol)).FszEst)
  69909 
  69910 	}
  69911 	goto __2
  69912 __2:
  69913 	i--
  69914 	pTabCol += 16
  69915 	goto __1
  69916 	goto __3
  69917 __3:
  69918 	;
  69919 	if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) < 0 {
  69920 		wTable++
  69921 	}
  69922 	(*Table)(unsafe.Pointer(pTab)).FszTabRow = Xsqlite3LogEst(tls, uint64(wTable*uint32(4)))
  69923 }
  69924 
  69925 func estimateIndexWidth(tls *libc.TLS, pIdx uintptr) {
  69926 	var wIndex uint32 = uint32(0)
  69927 	var i int32
  69928 	var aCol uintptr = (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FaCol
  69929 	for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); i++ {
  69930 		var x I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))
  69931 
  69932 		wIndex = wIndex + func() uint32 {
  69933 			if int32(x) < 0 {
  69934 				return uint32(1)
  69935 			}
  69936 			return uint32((*Column)(unsafe.Pointer(aCol + uintptr(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)))*16)).FszEst)
  69937 		}()
  69938 	}
  69939 	(*Index)(unsafe.Pointer(pIdx)).FszIdxRow = Xsqlite3LogEst(tls, uint64(wIndex*uint32(4)))
  69940 }
  69941 
  69942 func hasColumn(tls *libc.TLS, aiCol uintptr, nCol int32, x int32) int32 {
  69943 	for libc.PostDecInt32(&nCol, 1) > 0 {
  69944 		if x == int32(*(*I16)(unsafe.Pointer(libc.PostIncUintptr(&aiCol, 2)))) {
  69945 			return 1
  69946 		}
  69947 	}
  69948 	return 0
  69949 }
  69950 
  69951 func isDupColumn(tls *libc.TLS, pIdx uintptr, nKey int32, pPk uintptr, iCol int32) int32 {
  69952 	var i int32
  69953 	var j int32
  69954 
  69955 	j = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(iCol)*2)))
  69956 
  69957 	for i = 0; i < nKey; i++ {
  69958 		if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) == j &&
  69959 			Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*4)), *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(iCol)*4))) == 0 {
  69960 			return 1
  69961 		}
  69962 	}
  69963 	return 0
  69964 }
  69965 
  69966 func recomputeColumnsNotIndexed(tls *libc.TLS, pIdx uintptr) {
  69967 	var m Bitmask = uint64(0)
  69968 	var j int32
  69969 	var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable
  69970 	for j = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) - 1; j >= 0; j-- {
  69971 		var x int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)))
  69972 		if x >= 0 && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(x)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0 {
  69973 			if x < int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1 {
  69974 				m = m | uint64(1)<<x
  69975 			}
  69976 		}
  69977 	}
  69978 	(*Index)(unsafe.Pointer(pIdx)).FcolNotIdxed = ^m
  69979 
  69980 }
  69981 
  69982 func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) {
  69983 	bp := tls.Alloc(8)
  69984 	defer tls.Free(8)
  69985 
  69986 	var pIdx uintptr
  69987 	var pPk uintptr
  69988 	var nPk int32
  69989 	var nExtra int32
  69990 	var i int32
  69991 	var j int32
  69992 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  69993 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  69994 
  69995 	if !(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x2>>1) != 0) {
  69996 		for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  69997 			if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_PRIMKEY != 0 &&
  69998 				int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + 4))&0xf>>0) == OE_None {
  69999 				libc.SetBitFieldPtr8Uint32((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16+4, uint32(OE_Abort), 0, 0xf)
  70000 			}
  70001 		}
  70002 		*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_HasNotNull)
  70003 	}
  70004 
  70005 	if *(*int32)(unsafe.Pointer(pParse + 136)) != 0 {
  70006 		Xsqlite3VdbeChangeP3(tls, v, *(*int32)(unsafe.Pointer(pParse + 136)), BTREE_BLOBKEY)
  70007 	}
  70008 
  70009 	if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) >= 0 {
  70010 		var pList uintptr
  70011 
  70012 		Xsqlite3TokenInit(tls, bp, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*16)).FzCnName)
  70013 		pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0),
  70014 			Xsqlite3ExprAlloc(tls, db, TK_ID, bp, 0))
  70015 		if pList == uintptr(0) {
  70016 			*(*U32)(unsafe.Pointer(pTab + 28)) &= libc.Uint32FromInt32(libc.CplInt32(TF_WithoutRowid))
  70017 			return
  70018 		}
  70019 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  70020 			Xsqlite3RenameTokenRemap(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8)).FpExpr, pTab+32)
  70021 		}
  70022 		(*ExprList_item)(unsafe.Pointer(pList + 8)).Ffg.FsortFlags = (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder
  70023 
  70024 		(*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1)
  70025 		Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, int32((*Table)(unsafe.Pointer(pTab)).FkeyConf), uintptr(0), uintptr(0), 0, 0,
  70026 			uint8(SQLITE_IDXTYPE_PRIMARYKEY))
  70027 		if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  70028 			*(*U32)(unsafe.Pointer(pTab + 28)) &= libc.Uint32FromInt32(libc.CplInt32(TF_WithoutRowid))
  70029 			return
  70030 		}
  70031 
  70032 		pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  70033 
  70034 	} else {
  70035 		pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  70036 
  70037 		for i = libc.AssignInt32(&j, 1); i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ {
  70038 			if isDupColumn(tls, pPk, j, pPk, i) != 0 {
  70039 				(*Index)(unsafe.Pointer(pPk)).FnColumn--
  70040 			} else {
  70041 				*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*4)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*4))
  70042 				*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j))) = *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(i)))
  70043 				*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(libc.PostIncInt32(&j, 1))*2)) = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))
  70044 			}
  70045 		}
  70046 		(*Index)(unsafe.Pointer(pPk)).FnKeyCol = U16(j)
  70047 	}
  70048 
  70049 	libc.SetBitFieldPtr16Uint32(pPk+56, uint32(1), 5, 0x20)
  70050 	if !(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x2>>1) != 0) {
  70051 		libc.SetBitFieldPtr16Uint32(pPk+56, uint32(1), 3, 0x8)
  70052 	}
  70053 	nPk = int32(libc.AssignPtrUint16(pPk+52, (*Index)(unsafe.Pointer(pPk)).FnKeyCol))
  70054 
  70055 	if v != 0 && (*Index)(unsafe.Pointer(pPk)).Ftnum > Pgno(0) {
  70056 		Xsqlite3VdbeChangeOpcode(tls, v, int32((*Index)(unsafe.Pointer(pPk)).Ftnum), uint8(OP_Goto))
  70057 	}
  70058 
  70059 	(*Index)(unsafe.Pointer(pPk)).Ftnum = (*Table)(unsafe.Pointer(pTab)).Ftnum
  70060 
  70061 	for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  70062 		var n int32
  70063 		if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  70064 			continue
  70065 		}
  70066 		for i = libc.AssignInt32(&n, 0); i < nPk; i++ {
  70067 			if !(isDupColumn(tls, pIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), pPk, i) != 0) {
  70068 				n++
  70069 			}
  70070 		}
  70071 		if n == 0 {
  70072 			(*Index)(unsafe.Pointer(pIdx)).FnColumn = (*Index)(unsafe.Pointer(pIdx)).FnKeyCol
  70073 			continue
  70074 		}
  70075 		if resizeIndexObject(tls, db, pIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)+n) != 0 {
  70076 			return
  70077 		}
  70078 		i = 0
  70079 		j = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  70080 		for ; i < nPk; i++ {
  70081 			if !(isDupColumn(tls, pIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), pPk, i) != 0) {
  70082 				*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)) = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))
  70083 				*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*4)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*4))
  70084 				if *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(i))) != 0 {
  70085 					libc.SetBitFieldPtr16Uint32(pIdx+56, uint32(1), 9, 0x200)
  70086 				}
  70087 				j++
  70088 			}
  70089 		}
  70090 
  70091 	}
  70092 
  70093 	nExtra = 0
  70094 	for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  70095 		if !(hasColumn(tls, (*Index)(unsafe.Pointer(pPk)).FaiColumn, nPk, i) != 0) &&
  70096 			int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0 {
  70097 			nExtra++
  70098 		}
  70099 	}
  70100 	if resizeIndexObject(tls, db, pPk, nPk+nExtra) != 0 {
  70101 		return
  70102 	}
  70103 	i = 0
  70104 	j = nPk
  70105 	for ; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  70106 		if !(hasColumn(tls, (*Index)(unsafe.Pointer(pPk)).FaiColumn, j, i) != 0) &&
  70107 			int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0 {
  70108 			*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)) = I16(i)
  70109 			*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*4)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
  70110 			j++
  70111 		}
  70112 	}
  70113 
  70114 	recomputeColumnsNotIndexed(tls, pPk)
  70115 }
  70116 
  70117 // Return true if pTab is a virtual table and zName is a shadow table name
  70118 // for that virtual table.
  70119 func Xsqlite3IsShadowTableOf(tls *libc.TLS, db uintptr, pTab uintptr, zName uintptr) int32 {
  70120 	var nName int32
  70121 	var pMod uintptr
  70122 
  70123 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  70124 		return 0
  70125 	}
  70126 	nName = Xsqlite3Strlen30(tls, (*Table)(unsafe.Pointer(pTab)).FzName)
  70127 	if Xsqlite3_strnicmp(tls, zName, (*Table)(unsafe.Pointer(pTab)).FzName, nName) != 0 {
  70128 		return 0
  70129 	}
  70130 	if int32(*(*uint8)(unsafe.Pointer(zName + uintptr(nName)))) != '_' {
  70131 		return 0
  70132 	}
  70133 	pMod = Xsqlite3HashFind(tls, db+404, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 4)))))
  70134 	if pMod == uintptr(0) {
  70135 		return 0
  70136 	}
  70137 	if (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FiVersion < 3 {
  70138 		return 0
  70139 	}
  70140 	if (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxShadowName == uintptr(0) {
  70141 		return 0
  70142 	}
  70143 	return (*struct {
  70144 		f func(*libc.TLS, uintptr) int32
  70145 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxShadowName})).f(tls, zName+uintptr(nName)+uintptr(1))
  70146 }
  70147 
  70148 // Table pTab is a virtual table.  If it the virtual table implementation
  70149 // exists and has an xShadowName method, then loop over all other ordinary
  70150 // tables within the same schema looking for shadow tables of pTab, and mark
  70151 // any shadow tables seen using the TF_Shadow flag.
  70152 func Xsqlite3MarkAllShadowTablesOf(tls *libc.TLS, db uintptr, pTab uintptr) {
  70153 	var nName int32
  70154 	var pMod uintptr
  70155 	var k uintptr
  70156 
  70157 	pMod = Xsqlite3HashFind(tls, db+404, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 4)))))
  70158 	if pMod == uintptr(0) {
  70159 		return
  70160 	}
  70161 	if (*Module)(unsafe.Pointer(pMod)).FpModule == uintptr(0) {
  70162 		return
  70163 	}
  70164 	if (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FiVersion < 3 {
  70165 		return
  70166 	}
  70167 	if (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxShadowName == uintptr(0) {
  70168 		return
  70169 	}
  70170 
  70171 	nName = Xsqlite3Strlen30(tls, (*Table)(unsafe.Pointer(pTab)).FzName)
  70172 	for k = (*Hash)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema + 8)).Ffirst; k != 0; k = (*HashElem)(unsafe.Pointer(k)).Fnext {
  70173 		var pOther uintptr = (*HashElem)(unsafe.Pointer(k)).Fdata
  70174 
  70175 		if !(int32((*Table)(unsafe.Pointer(pOther)).FeTabType) == TABTYP_NORM) {
  70176 			continue
  70177 		}
  70178 		if (*Table)(unsafe.Pointer(pOther)).FtabFlags&U32(TF_Shadow) != 0 {
  70179 			continue
  70180 		}
  70181 		if Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pOther)).FzName, (*Table)(unsafe.Pointer(pTab)).FzName, nName) == 0 &&
  70182 			int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer(pOther)).FzName + uintptr(nName)))) == '_' &&
  70183 			(*struct {
  70184 				f func(*libc.TLS, uintptr) int32
  70185 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxShadowName})).f(tls, (*Table)(unsafe.Pointer(pOther)).FzName+uintptr(nName)+uintptr(1)) != 0 {
  70186 			*(*U32)(unsafe.Pointer(pOther + 28)) |= U32(TF_Shadow)
  70187 		}
  70188 	}
  70189 }
  70190 
  70191 // Return true if zName is a shadow table name in the current database
  70192 // connection.
  70193 //
  70194 // zName is temporarily modified while this routine is running, but is
  70195 // restored to its original value prior to this routine returning.
  70196 func Xsqlite3ShadowTableName(tls *libc.TLS, db uintptr, zName uintptr) int32 {
  70197 	var zTail uintptr
  70198 	var pTab uintptr
  70199 	zTail = libc.Xstrrchr(tls, zName, '_')
  70200 	if zTail == uintptr(0) {
  70201 		return 0
  70202 	}
  70203 	*(*uint8)(unsafe.Pointer(zTail)) = uint8(0)
  70204 	pTab = Xsqlite3FindTable(tls, db, zName, uintptr(0))
  70205 	*(*uint8)(unsafe.Pointer(zTail)) = uint8('_')
  70206 	if pTab == uintptr(0) {
  70207 		return 0
  70208 	}
  70209 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  70210 		return 0
  70211 	}
  70212 	return Xsqlite3IsShadowTableOf(tls, db, pTab, zName)
  70213 }
  70214 
  70215 // This routine is called to report the final ")" that terminates
  70216 // a CREATE TABLE statement.
  70217 //
  70218 // The table structure that other action routines have been building
  70219 // is added to the internal hash tables, assuming no errors have
  70220 // occurred.
  70221 //
  70222 // An entry for the table is made in the schema table on disk, unless
  70223 // this is a temporary table or db->init.busy==1.  When db->init.busy==1
  70224 // it means we are reading the sqlite_schema table because we just
  70225 // connected to the database or because the sqlite_schema table has
  70226 // recently changed, so the entry for this table already exists in
  70227 // the sqlite_schema table.  We do not want to create it again.
  70228 //
  70229 // If the pSelect argument is not NULL, it means that this routine
  70230 // was called to create a table generated from a
  70231 // "CREATE TABLE ... AS SELECT ..." statement.  The column names of
  70232 // the new table will match the result set of the SELECT.
  70233 func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr, tabOpts U32, pSelect uintptr) {
  70234 	bp := tls.Alloc(172)
  70235 	defer tls.Free(172)
  70236 
  70237 	var p uintptr
  70238 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  70239 	var iDb int32
  70240 	var pIdx uintptr
  70241 
  70242 	if pEnd == uintptr(0) && pSelect == uintptr(0) {
  70243 		return
  70244 	}
  70245 	p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  70246 	if p == uintptr(0) {
  70247 		return
  70248 	}
  70249 
  70250 	if pSelect == uintptr(0) && Xsqlite3ShadowTableName(tls, db, (*Table)(unsafe.Pointer(p)).FzName) != 0 {
  70251 		*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_Shadow)
  70252 	}
  70253 
  70254 	if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  70255 		if pSelect != 0 || !(int32((*Table)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM) && (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum != 0 {
  70256 			Xsqlite3ErrorMsg(tls, pParse, ts+1554, 0)
  70257 			return
  70258 		}
  70259 		(*Table)(unsafe.Pointer(p)).Ftnum = (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum
  70260 		if (*Table)(unsafe.Pointer(p)).Ftnum == Pgno(1) {
  70261 			*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_Readonly)
  70262 		}
  70263 	}
  70264 
  70265 	if tabOpts&U32(TF_Strict) != 0 {
  70266 		var ii int32
  70267 		*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_Strict)
  70268 		for ii = 0; ii < int32((*Table)(unsafe.Pointer(p)).FnCol); ii++ {
  70269 			var pCol uintptr = (*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*16
  70270 			if int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf0>>4) == COLTYPE_CUSTOM {
  70271 				if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_HASTYPE != 0 {
  70272 					Xsqlite3ErrorMsg(tls, pParse,
  70273 						ts+12817,
  70274 						libc.VaList(bp, (*Table)(unsafe.Pointer(p)).FzName, (*Column)(unsafe.Pointer(pCol)).FzCnName, Xsqlite3ColumnType(tls, pCol, ts+1554)))
  70275 				} else {
  70276 					Xsqlite3ErrorMsg(tls, pParse, ts+12850,
  70277 						libc.VaList(bp+24, (*Table)(unsafe.Pointer(p)).FzName, (*Column)(unsafe.Pointer(pCol)).FzCnName))
  70278 				}
  70279 				return
  70280 			} else if int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf0>>4) == COLTYPE_ANY {
  70281 				(*Column)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB)
  70282 			}
  70283 			if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_PRIMKEY != 0 &&
  70284 				int32((*Table)(unsafe.Pointer(p)).FiPKey) != ii &&
  70285 				int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf>>0) == OE_None {
  70286 				libc.SetBitFieldPtr8Uint32(pCol+4, uint32(OE_Abort), 0, 0xf)
  70287 				*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_HasNotNull)
  70288 			}
  70289 		}
  70290 	}
  70291 
  70292 	if tabOpts&U32(TF_WithoutRowid) != 0 {
  70293 		if (*Table)(unsafe.Pointer(p)).FtabFlags&U32(TF_Autoincrement) != 0 {
  70294 			Xsqlite3ErrorMsg(tls, pParse,
  70295 				ts+12877, 0)
  70296 			return
  70297 		}
  70298 		if (*Table)(unsafe.Pointer(p)).FtabFlags&U32(TF_HasPrimaryKey) == U32(0) {
  70299 			Xsqlite3ErrorMsg(tls, pParse, ts+12927, libc.VaList(bp+40, (*Table)(unsafe.Pointer(p)).FzName))
  70300 			return
  70301 		}
  70302 		*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_WithoutRowid | TF_NoVisibleRowid)
  70303 		convertToWithoutRowidTable(tls, pParse, p)
  70304 	}
  70305 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(p)).FpSchema)
  70306 
  70307 	if (*Table)(unsafe.Pointer(p)).FpCheck != 0 {
  70308 		Xsqlite3ResolveSelfReference(tls, pParse, p, NC_IsCheck, uintptr(0), (*Table)(unsafe.Pointer(p)).FpCheck)
  70309 		if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  70310 			Xsqlite3ExprListDelete(tls, db, (*Table)(unsafe.Pointer(p)).FpCheck)
  70311 			(*Table)(unsafe.Pointer(p)).FpCheck = uintptr(0)
  70312 		} else {
  70313 		}
  70314 	}
  70315 	if (*Table)(unsafe.Pointer(p)).FtabFlags&U32(TF_HasGenerated) != 0 {
  70316 		var ii int32
  70317 		var nNG int32 = 0
  70318 
  70319 		for ii = 0; ii < int32((*Table)(unsafe.Pointer(p)).FnCol); ii++ {
  70320 			var colFlags U32 = U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*16)).FcolFlags)
  70321 			if colFlags&U32(COLFLAG_GENERATED) != U32(0) {
  70322 				var pX uintptr = Xsqlite3ColumnExpr(tls, p, (*Table)(unsafe.Pointer(p)).FaCol+uintptr(ii)*16)
  70323 
  70324 				if Xsqlite3ResolveSelfReference(tls, pParse, p, NC_GenCol, pX, uintptr(0)) != 0 {
  70325 					Xsqlite3ColumnSetExpr(tls, pParse, p, (*Table)(unsafe.Pointer(p)).FaCol+uintptr(ii)*16,
  70326 						Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0))
  70327 				}
  70328 			} else {
  70329 				nNG++
  70330 			}
  70331 		}
  70332 		if nNG == 0 {
  70333 			Xsqlite3ErrorMsg(tls, pParse, ts+12959, 0)
  70334 			return
  70335 		}
  70336 	}
  70337 
  70338 	estimateTableWidth(tls, p)
  70339 	for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  70340 		estimateIndexWidth(tls, pIdx)
  70341 	}
  70342 
  70343 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) {
  70344 		var n int32
  70345 		var v uintptr
  70346 		var zType uintptr
  70347 		var zType2 uintptr
  70348 		var zStmt uintptr
  70349 
  70350 		v = Xsqlite3GetVdbe(tls, pParse)
  70351 		if v == uintptr(0) {
  70352 			return
  70353 		}
  70354 
  70355 		Xsqlite3VdbeAddOp1(tls, v, OP_Close, 0)
  70356 
  70357 		if int32((*Table)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM {
  70358 			zType = ts + 8876
  70359 			zType2 = ts + 13003
  70360 		} else {
  70361 			zType = ts + 10491
  70362 			zType2 = ts + 13009
  70363 		}
  70364 
  70365 		if pSelect != 0 {
  70366 			var regYield int32
  70367 			var addrTop int32
  70368 			var regRec int32
  70369 			var regRowid int32
  70370 			var addrInsLoop int32
  70371 			var pSelTab uintptr
  70372 
  70373 			if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL {
  70374 				(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR
  70375 				(*Parse)(unsafe.Pointer(pParse)).FnErr++
  70376 				return
  70377 			}
  70378 			regYield = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  70379 			regRec = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  70380 			regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  70381 
  70382 			Xsqlite3MayAbort(tls, pParse)
  70383 			Xsqlite3VdbeAddOp3(tls, v, OP_OpenWrite, 1, (*Parse)(unsafe.Pointer(pParse)).FregRoot, iDb)
  70384 			Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_P2ISREG))
  70385 			(*Parse)(unsafe.Pointer(pParse)).FnTab = 2
  70386 			addrTop = Xsqlite3VdbeCurrentAddr(tls, v) + 1
  70387 			Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, addrTop)
  70388 			if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  70389 				return
  70390 			}
  70391 			pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSelect, uint8(SQLITE_AFF_BLOB))
  70392 			if pSelTab == uintptr(0) {
  70393 				return
  70394 			}
  70395 
  70396 			(*Table)(unsafe.Pointer(p)).FnCol = libc.AssignPtrInt16(p+36, (*Table)(unsafe.Pointer(pSelTab)).FnCol)
  70397 			(*Table)(unsafe.Pointer(p)).FaCol = (*Table)(unsafe.Pointer(pSelTab)).FaCol
  70398 			(*Table)(unsafe.Pointer(pSelTab)).FnCol = int16(0)
  70399 			(*Table)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0)
  70400 			Xsqlite3DeleteTable(tls, db, pSelTab)
  70401 			Xsqlite3SelectDestInit(tls, bp+144, SRT_Coroutine, regYield)
  70402 			Xsqlite3Select(tls, pParse, pSelect, bp+144)
  70403 			if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  70404 				return
  70405 			}
  70406 			Xsqlite3VdbeEndCoroutine(tls, v, regYield)
  70407 			Xsqlite3VdbeJumpHere(tls, v, addrTop-1)
  70408 			addrInsLoop = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+144)).FiSDParm)
  70409 
  70410 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(bp+144)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+144)).FnSdst, regRec)
  70411 			Xsqlite3TableAffinity(tls, v, p, 0)
  70412 			Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, 1, regRowid)
  70413 			Xsqlite3VdbeAddOp3(tls, v, OP_Insert, 1, regRec, regRowid)
  70414 			Xsqlite3VdbeGoto(tls, v, addrInsLoop)
  70415 			Xsqlite3VdbeJumpHere(tls, v, addrInsLoop)
  70416 			Xsqlite3VdbeAddOp1(tls, v, OP_Close, 1)
  70417 		}
  70418 
  70419 		if pSelect != 0 {
  70420 			zStmt = createTableStmt(tls, db, p)
  70421 		} else {
  70422 			var pEnd2 uintptr
  70423 			if tabOpts != 0 {
  70424 				pEnd2 = pParse + 204
  70425 			} else {
  70426 				pEnd2 = pEnd
  70427 			}
  70428 			n = (int32((*Token)(unsafe.Pointer(pEnd2)).Fz) - int32((*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) / 1
  70429 			if int32(*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(pEnd2)).Fz))) != ';' {
  70430 				n = int32(uint32(n) + (*Token)(unsafe.Pointer(pEnd2)).Fn)
  70431 			}
  70432 			zStmt = Xsqlite3MPrintf(tls, db,
  70433 				ts+13014, libc.VaList(bp+48, zType2, n, (*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz))
  70434 		}
  70435 
  70436 		Xsqlite3NestedParse(tls, pParse,
  70437 			ts+13029,
  70438 			libc.VaList(bp+72, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName,
  70439 				zType,
  70440 				(*Table)(unsafe.Pointer(p)).FzName,
  70441 				(*Table)(unsafe.Pointer(p)).FzName,
  70442 				(*Parse)(unsafe.Pointer(pParse)).FregRoot,
  70443 				zStmt,
  70444 				(*Parse)(unsafe.Pointer(pParse)).FregRowid))
  70445 		Xsqlite3DbFree(tls, db, zStmt)
  70446 		Xsqlite3ChangeCookie(tls, pParse, iDb)
  70447 
  70448 		if (*Table)(unsafe.Pointer(p)).FtabFlags&U32(TF_Autoincrement) != U32(0) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) {
  70449 			var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  70450 
  70451 			if (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) {
  70452 				Xsqlite3NestedParse(tls, pParse,
  70453 					ts+13127,
  70454 					libc.VaList(bp+128, (*Db)(unsafe.Pointer(pDb)).FzDbSName))
  70455 			}
  70456 		}
  70457 
  70458 		Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb,
  70459 			Xsqlite3MPrintf(tls, db, ts+13169, libc.VaList(bp+136, (*Table)(unsafe.Pointer(p)).FzName)), uint16(0))
  70460 	}
  70461 
  70462 	if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 {
  70463 		var pOld uintptr
  70464 		var pSchema uintptr = (*Table)(unsafe.Pointer(p)).FpSchema
  70465 
  70466 		pOld = Xsqlite3HashInsert(tls, pSchema+8, (*Table)(unsafe.Pointer(p)).FzName, p)
  70467 		if pOld != 0 {
  70468 			Xsqlite3OomFault(tls, db)
  70469 			return
  70470 		}
  70471 		(*Parse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0)
  70472 		*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  70473 
  70474 		if libc.Xstrcmp(tls, (*Table)(unsafe.Pointer(p)).FzName, ts+9398) == 0 {
  70475 			(*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FpSchema)).FpSeqTab = p
  70476 		}
  70477 	}
  70478 
  70479 	if !(pSelect != 0) && int32((*Table)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM {
  70480 		if (*Token)(unsafe.Pointer(pCons)).Fz == uintptr(0) {
  70481 			pCons = pEnd
  70482 		}
  70483 		*(*int32)(unsafe.Pointer(p + 44)) = 13 + (int32((*Token)(unsafe.Pointer(pCons)).Fz)-int32((*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz))/1
  70484 	}
  70485 }
  70486 
  70487 // The parser calls this routine in order to create a new VIEW
  70488 func Xsqlite3CreateView(tls *libc.TLS, pParse uintptr, pBegin uintptr, pName1 uintptr, pName2 uintptr, pCNames uintptr, pSelect uintptr, isTemp int32, noErr int32) {
  70489 	bp := tls.Alloc(64)
  70490 	defer tls.Free(64)
  70491 
  70492 	var p uintptr
  70493 	var n int32
  70494 	var z uintptr
  70495 
  70496 	var iDb int32
  70497 	var db uintptr
  70498 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  70499 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  70500 
  70501 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FnVar) > 0) {
  70502 		goto __1
  70503 	}
  70504 	Xsqlite3ErrorMsg(tls, pParse, ts+13203, 0)
  70505 	goto create_view_fail
  70506 __1:
  70507 	;
  70508 	Xsqlite3StartTable(tls, pParse, pName1, pName2, isTemp, 1, 0, noErr)
  70509 	p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  70510 	if !(p == uintptr(0) || (*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  70511 		goto __2
  70512 	}
  70513 	goto create_view_fail
  70514 __2:
  70515 	;
  70516 	*(*U32)(unsafe.Pointer(p + 28)) |= U32(TF_NoVisibleRowid)
  70517 
  70518 	Xsqlite3TwoPartName(tls, pParse, pName1, pName2, bp)
  70519 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(p)).FpSchema)
  70520 	Xsqlite3FixInit(tls, bp+4, pParse, iDb, ts+10491, *(*uintptr)(unsafe.Pointer(bp)))
  70521 	if !(Xsqlite3FixSelect(tls, bp+4, pSelect) != 0) {
  70522 		goto __3
  70523 	}
  70524 	goto create_view_fail
  70525 __3:
  70526 	;
  70527 	*(*U32)(unsafe.Pointer(pSelect + 4)) |= U32(SF_View)
  70528 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  70529 		goto __4
  70530 	}
  70531 	*(*uintptr)(unsafe.Pointer(p + 44)) = pSelect
  70532 	pSelect = uintptr(0)
  70533 	goto __5
  70534 __4:
  70535 	*(*uintptr)(unsafe.Pointer(p + 44)) = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE)
  70536 __5:
  70537 	;
  70538 	(*Table)(unsafe.Pointer(p)).FpCheck = Xsqlite3ExprListDup(tls, db, pCNames, EXPRDUP_REDUCE)
  70539 	(*Table)(unsafe.Pointer(p)).FeTabType = U8(TABTYP_VIEW)
  70540 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  70541 		goto __6
  70542 	}
  70543 	goto create_view_fail
  70544 __6:
  70545 	;
  70546 	*(*Token)(unsafe.Pointer(bp + 56)) = (*Parse)(unsafe.Pointer(pParse)).FsLastToken
  70547 
  70548 	if !(int32(*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp + 56)).Fz))) != ';') {
  70549 		goto __7
  70550 	}
  70551 	*(*uintptr)(unsafe.Pointer(bp + 56)) += uintptr((*Token)(unsafe.Pointer(bp + 56)).Fn)
  70552 __7:
  70553 	;
  70554 	(*Token)(unsafe.Pointer(bp + 56)).Fn = uint32(0)
  70555 	n = (int32((*Token)(unsafe.Pointer(bp+56)).Fz) - int32((*Token)(unsafe.Pointer(pBegin)).Fz)) / 1
  70556 
  70557 	z = (*Token)(unsafe.Pointer(pBegin)).Fz
  70558 __8:
  70559 	if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(n-1)))])&0x01 != 0) {
  70560 		goto __9
  70561 	}
  70562 	n--
  70563 	goto __8
  70564 __9:
  70565 	;
  70566 	(*Token)(unsafe.Pointer(bp + 56)).Fz = z + uintptr(n-1)
  70567 	(*Token)(unsafe.Pointer(bp + 56)).Fn = uint32(1)
  70568 
  70569 	Xsqlite3EndTable(tls, pParse, uintptr(0), bp+56, uint32(0), uintptr(0))
  70570 
  70571 create_view_fail:
  70572 	Xsqlite3SelectDelete(tls, db, pSelect)
  70573 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  70574 		goto __10
  70575 	}
  70576 	Xsqlite3RenameExprlistUnmap(tls, pParse, pCNames)
  70577 __10:
  70578 	;
  70579 	Xsqlite3ExprListDelete(tls, db, pCNames)
  70580 	return
  70581 }
  70582 
  70583 func viewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) int32 {
  70584 	bp := tls.Alloc(8)
  70585 	defer tls.Free(8)
  70586 
  70587 	var pSelTab uintptr
  70588 	var pSel uintptr
  70589 	var nErr int32 = 0
  70590 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  70591 	var rc int32
  70592 	var xAuth Sqlite3_xauth
  70593 
  70594 	if int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_VTAB {
  70595 		(*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock++
  70596 		rc = Xsqlite3VtabCallConnect(tls, pParse, pTable)
  70597 		(*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock--
  70598 		return rc
  70599 	}
  70600 
  70601 	if int32((*Table)(unsafe.Pointer(pTable)).FnCol) < 0 {
  70602 		Xsqlite3ErrorMsg(tls, pParse, ts+13239, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName))
  70603 		return 1
  70604 	}
  70605 
  70606 	pSel = Xsqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(pTable + 44)), 0)
  70607 	if pSel != 0 {
  70608 		var eParseMode U8 = (*Parse)(unsafe.Pointer(pParse)).FeParseMode
  70609 		var nTab int32 = (*Parse)(unsafe.Pointer(pParse)).FnTab
  70610 		var nSelect int32 = (*Parse)(unsafe.Pointer(pParse)).FnSelect
  70611 		(*Parse)(unsafe.Pointer(pParse)).FeParseMode = U8(PARSE_MODE_NORMAL)
  70612 		Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer(pSel)).FpSrc)
  70613 		(*Table)(unsafe.Pointer(pTable)).FnCol = int16(-1)
  70614 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++
  70615 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
  70616 		xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  70617 		(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  70618 		pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSel, uint8(SQLITE_AFF_NONE))
  70619 		(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  70620 		(*Parse)(unsafe.Pointer(pParse)).FnTab = nTab
  70621 		(*Parse)(unsafe.Pointer(pParse)).FnSelect = nSelect
  70622 		if pSelTab == uintptr(0) {
  70623 			(*Table)(unsafe.Pointer(pTable)).FnCol = int16(0)
  70624 			nErr++
  70625 		} else if (*Table)(unsafe.Pointer(pTable)).FpCheck != 0 {
  70626 			Xsqlite3ColumnsFromExprList(tls, pParse, (*Table)(unsafe.Pointer(pTable)).FpCheck,
  70627 				pTable+34, pTable+4)
  70628 			if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 &&
  70629 				int32((*Table)(unsafe.Pointer(pTable)).FnCol) == (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpEList)).FnExpr {
  70630 				Xsqlite3SubqueryColumnTypes(tls, pParse, pTable, pSel, uint8(SQLITE_AFF_NONE))
  70631 			}
  70632 		} else {
  70633 			(*Table)(unsafe.Pointer(pTable)).FnCol = (*Table)(unsafe.Pointer(pSelTab)).FnCol
  70634 			(*Table)(unsafe.Pointer(pTable)).FaCol = (*Table)(unsafe.Pointer(pSelTab)).FaCol
  70635 			*(*U32)(unsafe.Pointer(pTable + 28)) |= (*Table)(unsafe.Pointer(pSelTab)).FtabFlags & U32(COLFLAG_NOINSERT)
  70636 			(*Table)(unsafe.Pointer(pSelTab)).FnCol = int16(0)
  70637 			(*Table)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0)
  70638 
  70639 		}
  70640 		(*Table)(unsafe.Pointer(pTable)).FnNVCol = (*Table)(unsafe.Pointer(pTable)).FnCol
  70641 		Xsqlite3DeleteTable(tls, db, pSelTab)
  70642 		Xsqlite3SelectDelete(tls, db, pSel)
  70643 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable--
  70644 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = func() uint16 {
  70645 			if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 {
  70646 				return uint16(0)
  70647 			}
  70648 			return (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue
  70649 		}()
  70650 		(*Parse)(unsafe.Pointer(pParse)).FeParseMode = eParseMode
  70651 	} else {
  70652 		nErr++
  70653 	}
  70654 	*(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FpSchema + 78)) |= U16(DB_UnresetViews)
  70655 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  70656 		Xsqlite3DeleteColumnNames(tls, db, pTable)
  70657 	}
  70658 	return nErr
  70659 }
  70660 
  70661 func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) int32 {
  70662 	if !(int32((*Table)(unsafe.Pointer(pTable)).FeTabType) == TABTYP_VTAB) && int32((*Table)(unsafe.Pointer(pTable)).FnCol) > 0 {
  70663 		return 0
  70664 	}
  70665 	return viewGetColumnNames(tls, pParse, pTable)
  70666 }
  70667 
  70668 func sqliteViewResetAll(tls *libc.TLS, db uintptr, idx int32) {
  70669 	var i uintptr
  70670 
  70671 	if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(idx)*16)).FpSchema)).FschemaFlags)&DB_UnresetViews == DB_UnresetViews) {
  70672 		return
  70673 	}
  70674 	for i = (*Hash)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(idx)*16)).FpSchema + 8)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
  70675 		var pTab uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
  70676 		if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW {
  70677 			Xsqlite3DeleteColumnNames(tls, db, pTab)
  70678 		}
  70679 	}
  70680 	*(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(idx)*16)).FpSchema + 78)) &= libc.Uint16FromInt32(libc.CplInt32(DB_UnresetViews))
  70681 }
  70682 
  70683 // This function is called by the VDBE to adjust the internal schema
  70684 // used by SQLite when the btree layer moves a table root page. The
  70685 // root-page of a table or index in database iDb has changed from iFrom
  70686 // to iTo.
  70687 //
  70688 // Ticket #1728:  The symbol table might still contain information
  70689 // on tables and/or indices that are the process of being deleted.
  70690 // If you are unlucky, one of those deleted indices or tables might
  70691 // have the same rootpage number as the real table or index that is
  70692 // being moved.  So we cannot stop searching after the first match
  70693 // because the first match might be for one of the deleted indices
  70694 // or tables and not the table/index that is actually being moved.
  70695 // We must continue looping until all tables and indices with
  70696 // rootpage==iFrom have been converted to have a rootpage of iTo
  70697 // in order to be certain that we got the right one.
  70698 func Xsqlite3RootPageMoved(tls *libc.TLS, db uintptr, iDb int32, iFrom Pgno, iTo Pgno) {
  70699 	var pElem uintptr
  70700 	var pHash uintptr
  70701 	var pDb uintptr
  70702 
  70703 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  70704 	pHash = (*Db)(unsafe.Pointer(pDb)).FpSchema + 8
  70705 	for pElem = (*Hash)(unsafe.Pointer(pHash)).Ffirst; pElem != 0; pElem = (*HashElem)(unsafe.Pointer(pElem)).Fnext {
  70706 		var pTab uintptr = (*HashElem)(unsafe.Pointer(pElem)).Fdata
  70707 		if (*Table)(unsafe.Pointer(pTab)).Ftnum == iFrom {
  70708 			(*Table)(unsafe.Pointer(pTab)).Ftnum = iTo
  70709 		}
  70710 	}
  70711 	pHash = (*Db)(unsafe.Pointer(pDb)).FpSchema + 24
  70712 	for pElem = (*Hash)(unsafe.Pointer(pHash)).Ffirst; pElem != 0; pElem = (*HashElem)(unsafe.Pointer(pElem)).Fnext {
  70713 		var pIdx uintptr = (*HashElem)(unsafe.Pointer(pElem)).Fdata
  70714 		if (*Index)(unsafe.Pointer(pIdx)).Ftnum == iFrom {
  70715 			(*Index)(unsafe.Pointer(pIdx)).Ftnum = iTo
  70716 		}
  70717 	}
  70718 }
  70719 
  70720 func destroyRootPage(tls *libc.TLS, pParse uintptr, iTable int32, iDb int32) {
  70721 	bp := tls.Alloc(32)
  70722 	defer tls.Free(32)
  70723 
  70724 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  70725 	var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  70726 	if iTable < 2 {
  70727 		Xsqlite3ErrorMsg(tls, pParse, ts+13269, 0)
  70728 	}
  70729 	Xsqlite3VdbeAddOp3(tls, v, OP_Destroy, iTable, r1, iDb)
  70730 	Xsqlite3MayAbort(tls, pParse)
  70731 
  70732 	Xsqlite3NestedParse(tls, pParse,
  70733 		ts+13284,
  70734 		libc.VaList(bp, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*16)).FzDbSName, iTable, r1, r1))
  70735 	Xsqlite3ReleaseTempReg(tls, pParse, r1)
  70736 }
  70737 
  70738 func destroyTable(tls *libc.TLS, pParse uintptr, pTab uintptr) {
  70739 	var iTab Pgno = (*Table)(unsafe.Pointer(pTab)).Ftnum
  70740 	var iDestroyed Pgno = Pgno(0)
  70741 
  70742 	for 1 != 0 {
  70743 		var pIdx uintptr
  70744 		var iLargest Pgno = Pgno(0)
  70745 
  70746 		if iDestroyed == Pgno(0) || iTab < iDestroyed {
  70747 			iLargest = iTab
  70748 		}
  70749 		for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  70750 			var iIdx Pgno = (*Index)(unsafe.Pointer(pIdx)).Ftnum
  70751 
  70752 			if (iDestroyed == Pgno(0) || iIdx < iDestroyed) && iIdx > iLargest {
  70753 				iLargest = iIdx
  70754 			}
  70755 		}
  70756 		if iLargest == Pgno(0) {
  70757 			return
  70758 		} else {
  70759 			var iDb int32 = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  70760 
  70761 			destroyRootPage(tls, pParse, int32(iLargest), iDb)
  70762 			iDestroyed = iLargest
  70763 		}
  70764 	}
  70765 }
  70766 
  70767 func sqlite3ClearStatTables(tls *libc.TLS, pParse uintptr, iDb int32, zType uintptr, zName uintptr) {
  70768 	bp := tls.Alloc(64)
  70769 	defer tls.Free(64)
  70770 
  70771 	var i int32
  70772 	var zDbName uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*16)).FzDbSName
  70773 	for i = 1; i <= 4; i++ {
  70774 		Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([24]uint8{})), bp+40, ts+13351, libc.VaList(bp, i))
  70775 		if Xsqlite3FindTable(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, bp+40, zDbName) != 0 {
  70776 			Xsqlite3NestedParse(tls, pParse,
  70777 				ts+11300,
  70778 				libc.VaList(bp+8, zDbName, bp+40, zType, zName))
  70779 		}
  70780 	}
  70781 }
  70782 
  70783 // Generate code to drop a table.
  70784 func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int32, isView int32) {
  70785 	bp := tls.Alloc(32)
  70786 	defer tls.Free(32)
  70787 
  70788 	var v uintptr
  70789 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  70790 	var pTrigger uintptr
  70791 	var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  70792 
  70793 	v = Xsqlite3GetVdbe(tls, pParse)
  70794 
  70795 	Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb)
  70796 
  70797 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  70798 		Xsqlite3VdbeAddOp0(tls, v, OP_VBegin)
  70799 	}
  70800 
  70801 	pTrigger = Xsqlite3TriggerList(tls, pParse, pTab)
  70802 	for pTrigger != 0 {
  70803 		Xsqlite3DropTriggerPtr(tls, pParse, pTrigger)
  70804 		pTrigger = (*Trigger)(unsafe.Pointer(pTrigger)).FpNext
  70805 	}
  70806 
  70807 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Autoincrement) != 0 {
  70808 		Xsqlite3NestedParse(tls, pParse,
  70809 			ts+13365,
  70810 			libc.VaList(bp, (*Db)(unsafe.Pointer(pDb)).FzDbSName, (*Table)(unsafe.Pointer(pTab)).FzName))
  70811 	}
  70812 
  70813 	Xsqlite3NestedParse(tls, pParse,
  70814 		ts+13410,
  70815 		libc.VaList(bp+16, (*Db)(unsafe.Pointer(pDb)).FzDbSName, (*Table)(unsafe.Pointer(pTab)).FzName))
  70816 	if !(isView != 0) && !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  70817 		destroyTable(tls, pParse, pTab)
  70818 	}
  70819 
  70820 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  70821 		Xsqlite3VdbeAddOp4(tls, v, OP_VDestroy, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0)
  70822 		Xsqlite3MayAbort(tls, pParse)
  70823 	}
  70824 	Xsqlite3VdbeAddOp4(tls, v, OP_DropTable, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0)
  70825 	Xsqlite3ChangeCookie(tls, pParse, iDb)
  70826 	sqliteViewResetAll(tls, db, iDb)
  70827 }
  70828 
  70829 // Return TRUE if shadow tables should be read-only in the current
  70830 // context.
  70831 func Xsqlite3ReadOnlyShadowTables(tls *libc.TLS, db uintptr) int32 {
  70832 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) &&
  70833 		(*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx == uintptr(0) &&
  70834 		(*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0 &&
  70835 		!((*Sqlite3)(unsafe.Pointer(db)).FnVTrans > 0 && (*Sqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0)) {
  70836 		return 1
  70837 	}
  70838 	return 0
  70839 }
  70840 
  70841 func tableMayNotBeDropped(tls *libc.TLS, db uintptr, pTab uintptr) int32 {
  70842 	if Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+6381, 7) == 0 {
  70843 		if Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName+uintptr(7), ts+3286, 4) == 0 {
  70844 			return 0
  70845 		}
  70846 		if Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName+uintptr(7), ts+7122, 10) == 0 {
  70847 			return 0
  70848 		}
  70849 		return 1
  70850 	}
  70851 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Shadow) != U32(0) && Xsqlite3ReadOnlyShadowTables(tls, db) != 0 {
  70852 		return 1
  70853 	}
  70854 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Eponymous) != 0 {
  70855 		return 1
  70856 	}
  70857 	return 0
  70858 }
  70859 
  70860 // This routine is called to do the work of a DROP TABLE statement.
  70861 // pName is the name of the table to be dropped.
  70862 func Xsqlite3DropTable(tls *libc.TLS, pParse uintptr, pName uintptr, isView int32, noErr int32) {
  70863 	bp := tls.Alloc(24)
  70864 	defer tls.Free(24)
  70865 
  70866 	var pTab uintptr
  70867 	var v uintptr
  70868 	var db uintptr
  70869 	var iDb int32
  70870 	var code int32
  70871 	var zTab uintptr
  70872 	var zDb uintptr
  70873 	var zArg2 uintptr
  70874 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  70875 
  70876 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  70877 		goto __1
  70878 	}
  70879 	goto exit_drop_table
  70880 __1:
  70881 	;
  70882 	if !(Xsqlite3ReadSchema(tls, pParse) != 0) {
  70883 		goto __2
  70884 	}
  70885 	goto exit_drop_table
  70886 __2:
  70887 	;
  70888 	if !(noErr != 0) {
  70889 		goto __3
  70890 	}
  70891 	(*Sqlite3)(unsafe.Pointer(db)).FsuppressErr++
  70892 __3:
  70893 	;
  70894 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(isView), pName+8)
  70895 	if !(noErr != 0) {
  70896 		goto __4
  70897 	}
  70898 	(*Sqlite3)(unsafe.Pointer(db)).FsuppressErr--
  70899 __4:
  70900 	;
  70901 	if !(pTab == uintptr(0)) {
  70902 		goto __5
  70903 	}
  70904 	if !(noErr != 0) {
  70905 		goto __6
  70906 	}
  70907 	Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcItem)(unsafe.Pointer(pName+8)).FzDatabase)
  70908 	sqlite3ForceNotReadOnly(tls, pParse)
  70909 __6:
  70910 	;
  70911 	goto exit_drop_table
  70912 __5:
  70913 	;
  70914 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  70915 
  70916 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB && Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0) {
  70917 		goto __7
  70918 	}
  70919 	goto exit_drop_table
  70920 __7:
  70921 	;
  70922 	zTab = func() uintptr {
  70923 		if !(0 != 0) && iDb == 1 {
  70924 			return ts + 6389
  70925 		}
  70926 		return ts + 5883
  70927 	}()
  70928 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  70929 	zArg2 = uintptr(0)
  70930 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) {
  70931 		goto __8
  70932 	}
  70933 	goto exit_drop_table
  70934 __8:
  70935 	;
  70936 	if !(isView != 0) {
  70937 		goto __9
  70938 	}
  70939 	if !(!(0 != 0) && iDb == 1) {
  70940 		goto __11
  70941 	}
  70942 	code = SQLITE_DROP_TEMP_VIEW
  70943 	goto __12
  70944 __11:
  70945 	code = SQLITE_DROP_VIEW
  70946 __12:
  70947 	;
  70948 	goto __10
  70949 __9:
  70950 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  70951 		goto __13
  70952 	}
  70953 	code = SQLITE_DROP_VTABLE
  70954 	zArg2 = (*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, db, pTab))).FpMod)).FzName
  70955 	goto __14
  70956 __13:
  70957 	if !(!(0 != 0) && iDb == 1) {
  70958 		goto __15
  70959 	}
  70960 	code = SQLITE_DROP_TEMP_TABLE
  70961 	goto __16
  70962 __15:
  70963 	code = SQLITE_DROP_TABLE
  70964 __16:
  70965 	;
  70966 __14:
  70967 	;
  70968 __10:
  70969 	;
  70970 	if !(Xsqlite3AuthCheck(tls, pParse, code, (*Table)(unsafe.Pointer(pTab)).FzName, zArg2, zDb) != 0) {
  70971 		goto __17
  70972 	}
  70973 	goto exit_drop_table
  70974 __17:
  70975 	;
  70976 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0) {
  70977 		goto __18
  70978 	}
  70979 	goto exit_drop_table
  70980 __18:
  70981 	;
  70982 	if !(tableMayNotBeDropped(tls, db, pTab) != 0) {
  70983 		goto __19
  70984 	}
  70985 	Xsqlite3ErrorMsg(tls, pParse, ts+13477, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  70986 	goto exit_drop_table
  70987 __19:
  70988 	;
  70989 	if !(isView != 0 && !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW)) {
  70990 		goto __20
  70991 	}
  70992 	Xsqlite3ErrorMsg(tls, pParse, ts+13505, libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName))
  70993 	goto exit_drop_table
  70994 __20:
  70995 	;
  70996 	if !(!(isView != 0) && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  70997 		goto __21
  70998 	}
  70999 	Xsqlite3ErrorMsg(tls, pParse, ts+13539, libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName))
  71000 	goto exit_drop_table
  71001 __21:
  71002 	;
  71003 	v = Xsqlite3GetVdbe(tls, pParse)
  71004 	if !(v != 0) {
  71005 		goto __22
  71006 	}
  71007 	Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb)
  71008 	if !!(isView != 0) {
  71009 		goto __23
  71010 	}
  71011 	sqlite3ClearStatTables(tls, pParse, iDb, ts+11492, (*Table)(unsafe.Pointer(pTab)).FzName)
  71012 	Xsqlite3FkDropTable(tls, pParse, pName, pTab)
  71013 __23:
  71014 	;
  71015 	Xsqlite3CodeDropTable(tls, pParse, pTab, iDb, isView)
  71016 __22:
  71017 	;
  71018 exit_drop_table:
  71019 	Xsqlite3SrcListDelete(tls, db, pName)
  71020 }
  71021 
  71022 // This routine is called to create a new foreign key on the table
  71023 // currently under construction.  pFromCol determines which columns
  71024 // in the current table point to the foreign key.  If pFromCol==0 then
  71025 // connect the key to the last column inserted.  pTo is the name of
  71026 // the table referred to (a.k.a the "parent" table).  pToCol is a list
  71027 // of tables in the parent pTo table.  flags contains all
  71028 // information about the conflict resolution algorithms specified
  71029 // in the ON DELETE, ON UPDATE and ON INSERT clauses.
  71030 //
  71031 // An FKey structure is created and added to the table currently
  71032 // under construction in the pParse->pNewTable field.
  71033 //
  71034 // The foreign key is set for IMMEDIATE processing.  A subsequent call
  71035 // to sqlite3DeferForeignKey() might change this to DEFERRED.
  71036 func Xsqlite3CreateForeignKey(tls *libc.TLS, pParse uintptr, pFromCol uintptr, pTo uintptr, pToCol uintptr, flags int32) {
  71037 	bp := tls.Alloc(24)
  71038 	defer tls.Free(24)
  71039 
  71040 	var db uintptr
  71041 	var pFKey uintptr
  71042 	var pNextTo uintptr
  71043 	var p uintptr
  71044 	var nByte I64
  71045 	var i int32
  71046 	var nCol int32
  71047 	var z uintptr
  71048 	var iCol int32
  71049 	var j int32
  71050 	var n int32
  71051 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  71052 	pFKey = uintptr(0)
  71053 	p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  71054 
  71055 	if !(p == uintptr(0) || int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) {
  71056 		goto __1
  71057 	}
  71058 	goto fk_end
  71059 __1:
  71060 	;
  71061 	if !(pFromCol == uintptr(0)) {
  71062 		goto __2
  71063 	}
  71064 	iCol = int32((*Table)(unsafe.Pointer(p)).FnCol) - 1
  71065 	if !(iCol < 0) {
  71066 		goto __4
  71067 	}
  71068 	goto fk_end
  71069 __4:
  71070 	;
  71071 	if !(pToCol != 0 && (*ExprList)(unsafe.Pointer(pToCol)).FnExpr != 1) {
  71072 		goto __5
  71073 	}
  71074 	Xsqlite3ErrorMsg(tls, pParse,
  71075 		ts+13571,
  71076 		libc.VaList(bp, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol+uintptr(iCol)*16)).FzCnName, pTo))
  71077 	goto fk_end
  71078 __5:
  71079 	;
  71080 	nCol = 1
  71081 	goto __3
  71082 __2:
  71083 	if !(pToCol != 0 && (*ExprList)(unsafe.Pointer(pToCol)).FnExpr != (*ExprList)(unsafe.Pointer(pFromCol)).FnExpr) {
  71084 		goto __6
  71085 	}
  71086 	Xsqlite3ErrorMsg(tls, pParse,
  71087 		ts+13634, 0)
  71088 	goto fk_end
  71089 	goto __7
  71090 __6:
  71091 	nCol = (*ExprList)(unsafe.Pointer(pFromCol)).FnExpr
  71092 __7:
  71093 	;
  71094 __3:
  71095 	;
  71096 	nByte = I64(uint32(unsafe.Sizeof(FKey{})) + uint32(nCol-1)*uint32(unsafe.Sizeof(sColMap{})) + (*Token)(unsafe.Pointer(pTo)).Fn + uint32(1))
  71097 	if !(pToCol != 0) {
  71098 		goto __8
  71099 	}
  71100 	i = 0
  71101 __9:
  71102 	if !(i < (*ExprList)(unsafe.Pointer(pToCol)).FnExpr) {
  71103 		goto __11
  71104 	}
  71105 	nByte = nByte + I64(Xsqlite3Strlen30(tls, (*ExprList_item)(unsafe.Pointer(pToCol+8+uintptr(i)*20)).FzEName)+1)
  71106 	goto __10
  71107 __10:
  71108 	i++
  71109 	goto __9
  71110 	goto __11
  71111 __11:
  71112 	;
  71113 __8:
  71114 	;
  71115 	pFKey = Xsqlite3DbMallocZero(tls, db, uint64(nByte))
  71116 	if !(pFKey == uintptr(0)) {
  71117 		goto __12
  71118 	}
  71119 	goto fk_end
  71120 __12:
  71121 	;
  71122 	(*FKey)(unsafe.Pointer(pFKey)).FpFrom = p
  71123 
  71124 	(*FKey)(unsafe.Pointer(pFKey)).FpNextFrom = *(*uintptr)(unsafe.Pointer(p + 44 + 4))
  71125 	z = pFKey + 36 + uintptr(nCol)*8
  71126 	(*FKey)(unsafe.Pointer(pFKey)).FzTo = z
  71127 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  71128 		goto __13
  71129 	}
  71130 	Xsqlite3RenameTokenMap(tls, pParse, z, pTo)
  71131 __13:
  71132 	;
  71133 	libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(pTo)).Fz, (*Token)(unsafe.Pointer(pTo)).Fn)
  71134 	*(*uint8)(unsafe.Pointer(z + uintptr((*Token)(unsafe.Pointer(pTo)).Fn))) = uint8(0)
  71135 	Xsqlite3Dequote(tls, z)
  71136 	z += uintptr((*Token)(unsafe.Pointer(pTo)).Fn + uint32(1))
  71137 	(*FKey)(unsafe.Pointer(pFKey)).FnCol = nCol
  71138 	if !(pFromCol == uintptr(0)) {
  71139 		goto __14
  71140 	}
  71141 	(*sColMap)(unsafe.Pointer(pFKey + 36)).FiFrom = int32((*Table)(unsafe.Pointer(p)).FnCol) - 1
  71142 	goto __15
  71143 __14:
  71144 	i = 0
  71145 __16:
  71146 	if !(i < nCol) {
  71147 		goto __18
  71148 	}
  71149 	j = 0
  71150 __19:
  71151 	if !(j < int32((*Table)(unsafe.Pointer(p)).FnCol)) {
  71152 		goto __21
  71153 	}
  71154 	if !(Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol+uintptr(j)*16)).FzCnName, (*ExprList_item)(unsafe.Pointer(pFromCol+8+uintptr(i)*20)).FzEName) == 0) {
  71155 		goto __22
  71156 	}
  71157 	(*sColMap)(unsafe.Pointer(pFKey + 36 + uintptr(i)*8)).FiFrom = j
  71158 	goto __21
  71159 __22:
  71160 	;
  71161 	goto __20
  71162 __20:
  71163 	j++
  71164 	goto __19
  71165 	goto __21
  71166 __21:
  71167 	;
  71168 	if !(j >= int32((*Table)(unsafe.Pointer(p)).FnCol)) {
  71169 		goto __23
  71170 	}
  71171 	Xsqlite3ErrorMsg(tls, pParse,
  71172 		ts+13728,
  71173 		libc.VaList(bp+16, (*ExprList_item)(unsafe.Pointer(pFromCol+8+uintptr(i)*20)).FzEName))
  71174 	goto fk_end
  71175 __23:
  71176 	;
  71177 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  71178 		goto __24
  71179 	}
  71180 	Xsqlite3RenameTokenRemap(tls, pParse, pFKey+36+uintptr(i)*8, (*ExprList_item)(unsafe.Pointer(pFromCol+8+uintptr(i)*20)).FzEName)
  71181 __24:
  71182 	;
  71183 	goto __17
  71184 __17:
  71185 	i++
  71186 	goto __16
  71187 	goto __18
  71188 __18:
  71189 	;
  71190 __15:
  71191 	;
  71192 	if !(pToCol != 0) {
  71193 		goto __25
  71194 	}
  71195 	i = 0
  71196 __26:
  71197 	if !(i < nCol) {
  71198 		goto __28
  71199 	}
  71200 	n = Xsqlite3Strlen30(tls, (*ExprList_item)(unsafe.Pointer(pToCol+8+uintptr(i)*20)).FzEName)
  71201 	(*sColMap)(unsafe.Pointer(pFKey + 36 + uintptr(i)*8)).FzCol = z
  71202 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  71203 		goto __29
  71204 	}
  71205 	Xsqlite3RenameTokenRemap(tls, pParse, z, (*ExprList_item)(unsafe.Pointer(pToCol+8+uintptr(i)*20)).FzEName)
  71206 __29:
  71207 	;
  71208 	libc.Xmemcpy(tls, z, (*ExprList_item)(unsafe.Pointer(pToCol+8+uintptr(i)*20)).FzEName, uint32(n))
  71209 	*(*uint8)(unsafe.Pointer(z + uintptr(n))) = uint8(0)
  71210 	z += uintptr(n + 1)
  71211 	goto __27
  71212 __27:
  71213 	i++
  71214 	goto __26
  71215 	goto __28
  71216 __28:
  71217 	;
  71218 __25:
  71219 	;
  71220 	(*FKey)(unsafe.Pointer(pFKey)).FisDeferred = U8(0)
  71221 	*(*U8)(unsafe.Pointer(pFKey + 25)) = U8(flags & 0xff)
  71222 	*(*U8)(unsafe.Pointer(pFKey + 25 + 1)) = U8(flags >> 8 & 0xff)
  71223 
  71224 	pNextTo = Xsqlite3HashInsert(tls, (*Table)(unsafe.Pointer(p)).FpSchema+56,
  71225 		(*FKey)(unsafe.Pointer(pFKey)).FzTo, pFKey)
  71226 	if !(pNextTo == pFKey) {
  71227 		goto __30
  71228 	}
  71229 	Xsqlite3OomFault(tls, db)
  71230 	goto fk_end
  71231 __30:
  71232 	;
  71233 	if !(pNextTo != 0) {
  71234 		goto __31
  71235 	}
  71236 
  71237 	(*FKey)(unsafe.Pointer(pFKey)).FpNextTo = pNextTo
  71238 	(*FKey)(unsafe.Pointer(pNextTo)).FpPrevTo = pFKey
  71239 __31:
  71240 	;
  71241 	*(*uintptr)(unsafe.Pointer(p + 44 + 4)) = pFKey
  71242 	pFKey = uintptr(0)
  71243 
  71244 fk_end:
  71245 	Xsqlite3DbFree(tls, db, pFKey)
  71246 	Xsqlite3ExprListDelete(tls, db, pFromCol)
  71247 	Xsqlite3ExprListDelete(tls, db, pToCol)
  71248 }
  71249 
  71250 // This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED
  71251 // clause is seen as part of a foreign key definition.  The isDeferred
  71252 // parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.
  71253 // The behavior of the most recently created foreign key is adjusted
  71254 // accordingly.
  71255 func Xsqlite3DeferForeignKey(tls *libc.TLS, pParse uintptr, isDeferred int32) {
  71256 	var pTab uintptr
  71257 	var pFKey uintptr
  71258 	if libc.AssignUintptr(&pTab, (*Parse)(unsafe.Pointer(pParse)).FpNewTable) == uintptr(0) {
  71259 		return
  71260 	}
  71261 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  71262 		return
  71263 	}
  71264 	if libc.AssignUintptr(&pFKey, *(*uintptr)(unsafe.Pointer(pTab + 44 + 4))) == uintptr(0) {
  71265 		return
  71266 	}
  71267 
  71268 	(*FKey)(unsafe.Pointer(pFKey)).FisDeferred = U8(isDeferred)
  71269 }
  71270 
  71271 func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPage int32) {
  71272 	bp := tls.Alloc(4)
  71273 	defer tls.Free(4)
  71274 
  71275 	var pTab uintptr = (*Index)(unsafe.Pointer(pIndex)).FpTable
  71276 	var iTab int32 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  71277 	var iIdx int32 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  71278 	var iSorter int32
  71279 	var addr1 int32
  71280 	var addr2 int32
  71281 	var tnum Pgno
  71282 
  71283 	var v uintptr
  71284 	var pKey uintptr
  71285 	var regRecord int32
  71286 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  71287 	var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIndex)).FpSchema)
  71288 
  71289 	if Xsqlite3AuthCheck(tls, pParse, SQLITE_REINDEX, (*Index)(unsafe.Pointer(pIndex)).FzName, uintptr(0),
  71290 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName) != 0 {
  71291 		return
  71292 	}
  71293 
  71294 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pTab)).FzName)
  71295 
  71296 	v = Xsqlite3GetVdbe(tls, pParse)
  71297 	if v == uintptr(0) {
  71298 		return
  71299 	}
  71300 	if memRootPage >= 0 {
  71301 		tnum = Pgno(memRootPage)
  71302 	} else {
  71303 		tnum = (*Index)(unsafe.Pointer(pIndex)).Ftnum
  71304 	}
  71305 	pKey = Xsqlite3KeyInfoOfIndex(tls, pParse, pIndex)
  71306 
  71307 	iSorter = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  71308 	Xsqlite3VdbeAddOp4(tls, v, OP_SorterOpen, iSorter, 0, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol), Xsqlite3KeyInfoRef(tls, pKey), -8)
  71309 
  71310 	Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, OP_OpenRead)
  71311 	addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iTab, 0)
  71312 	regRecord = Xsqlite3GetTempReg(tls, pParse)
  71313 	Xsqlite3MultiWrite(tls, pParse)
  71314 
  71315 	Xsqlite3GenerateIndexKey(tls, pParse, pIndex, iTab, regRecord, 0, bp, uintptr(0), 0)
  71316 	Xsqlite3VdbeAddOp2(tls, v, OP_SorterInsert, iSorter, regRecord)
  71317 	Xsqlite3ResolvePartIdxLabel(tls, pParse, *(*int32)(unsafe.Pointer(bp)))
  71318 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, iTab, addr1+1)
  71319 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  71320 	if memRootPage < 0 {
  71321 		Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32(tnum), iDb)
  71322 	}
  71323 	Xsqlite3VdbeAddOp4(tls, v, OP_OpenWrite, iIdx, int32(tnum), iDb,
  71324 		pKey, -8)
  71325 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_BULKCSR|func() int32 {
  71326 		if memRootPage >= 0 {
  71327 			return OPFLAG_P2ISREG
  71328 		}
  71329 		return 0
  71330 	}()))
  71331 
  71332 	addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, iSorter, 0)
  71333 	if int32((*Index)(unsafe.Pointer(pIndex)).FonError) != OE_None {
  71334 		var j2 int32 = Xsqlite3VdbeGoto(tls, v, 1)
  71335 		addr2 = Xsqlite3VdbeCurrentAddr(tls, v)
  71336 
  71337 		Xsqlite3VdbeAddOp4Int(tls, v, OP_SorterCompare, iSorter, j2, regRecord,
  71338 			int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol))
  71339 		Xsqlite3UniqueConstraint(tls, pParse, OE_Abort, pIndex)
  71340 		Xsqlite3VdbeJumpHere(tls, v, j2)
  71341 	} else {
  71342 		Xsqlite3MayAbort(tls, pParse)
  71343 		addr2 = Xsqlite3VdbeCurrentAddr(tls, v)
  71344 	}
  71345 	Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, iSorter, regRecord, iIdx)
  71346 	if !(int32(*(*uint16)(unsafe.Pointer(pIndex + 56))&0x200>>9) != 0) {
  71347 		Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iIdx)
  71348 	}
  71349 	Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iIdx, regRecord)
  71350 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT))
  71351 	Xsqlite3ReleaseTempReg(tls, pParse, regRecord)
  71352 	Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, iSorter, addr2)
  71353 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  71354 
  71355 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, iTab)
  71356 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, iIdx)
  71357 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, iSorter)
  71358 }
  71359 
  71360 // Allocate heap space to hold an Index object with nCol columns.
  71361 //
  71362 // Increase the allocation size to provide an extra nExtra bytes
  71363 // of 8-byte aligned space after the Index object and return a
  71364 // pointer to this extra space in *ppExtra.
  71365 func Xsqlite3AllocateIndexObject(tls *libc.TLS, db uintptr, nCol I16, nExtra int32, ppExtra uintptr) uintptr {
  71366 	var p uintptr
  71367 	var nByte int32
  71368 
  71369 	nByte = int32((uint32(unsafe.Sizeof(Index{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)) + (uint32(unsafe.Sizeof(uintptr(0)))*uint32(nCol)+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)) + (uint32(unsafe.Sizeof(LogEst(0)))*uint32(int32(nCol)+1)+uint32(unsafe.Sizeof(I16(0)))*uint32(nCol)+uint32(unsafe.Sizeof(U8(0)))*uint32(nCol)+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)))
  71370 	p = Xsqlite3DbMallocZero(tls, db, uint64(nByte+nExtra))
  71371 	if p != 0 {
  71372 		var pExtra uintptr = p + uintptr((uint32(unsafe.Sizeof(Index{}))+uint32(7))&libc.Uint32FromInt32(libc.CplInt32(7)))
  71373 		(*Index)(unsafe.Pointer(p)).FazColl = pExtra
  71374 		pExtra += uintptr((uint32(unsafe.Sizeof(uintptr(0)))*uint32(nCol) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
  71375 		(*Index)(unsafe.Pointer(p)).FaiRowLogEst = pExtra
  71376 		pExtra += uintptr(uint32(unsafe.Sizeof(LogEst(0))) * uint32(int32(nCol)+1))
  71377 		(*Index)(unsafe.Pointer(p)).FaiColumn = pExtra
  71378 		pExtra += uintptr(uint32(unsafe.Sizeof(I16(0))) * uint32(nCol))
  71379 		(*Index)(unsafe.Pointer(p)).FaSortOrder = pExtra
  71380 		(*Index)(unsafe.Pointer(p)).FnColumn = U16(nCol)
  71381 		(*Index)(unsafe.Pointer(p)).FnKeyCol = U16(int32(nCol) - 1)
  71382 		*(*uintptr)(unsafe.Pointer(ppExtra)) = p + uintptr(nByte)
  71383 	}
  71384 	return p
  71385 }
  71386 
  71387 // If expression list pList contains an expression that was parsed with
  71388 // an explicit "NULLS FIRST" or "NULLS LAST" clause, leave an error in
  71389 // pParse and return non-zero. Otherwise, return zero.
  71390 func Xsqlite3HasExplicitNulls(tls *libc.TLS, pParse uintptr, pList uintptr) int32 {
  71391 	bp := tls.Alloc(8)
  71392 	defer tls.Free(8)
  71393 
  71394 	if pList != 0 {
  71395 		var i int32
  71396 		for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
  71397 			if uint32(int32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*20 + 8 + 4))&0x20>>5)) != 0 {
  71398 				var sf U8 = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*20)).Ffg.FsortFlags
  71399 				Xsqlite3ErrorMsg(tls, pParse, ts+13774,
  71400 					libc.VaList(bp, func() uintptr {
  71401 						if int32(sf) == 0 || int32(sf) == 3 {
  71402 							return ts + 13802
  71403 						}
  71404 						return ts + 13808
  71405 					}()))
  71406 				return 1
  71407 			}
  71408 		}
  71409 	}
  71410 	return 0
  71411 }
  71412 
  71413 // Create a new index for an SQL table.  pName1.pName2 is the name of the index
  71414 // and pTblList is the name of the table that is to be indexed.  Both will
  71415 // be NULL for a primary key or an index that is created to satisfy a
  71416 // UNIQUE constraint.  If pTable and pIndex are NULL, use pParse->pNewTable
  71417 // as the table to be indexed.  pParse->pNewTable is a table that is
  71418 // currently being constructed by a CREATE TABLE statement.
  71419 //
  71420 // pList is a list of columns to be indexed.  pList will be NULL if this
  71421 // is a primary key or unique-constraint on the most recent column added
  71422 // to the table currently under construction.
  71423 func Xsqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pTblName uintptr, pList uintptr, onError int32, pStart uintptr, pPIWhere uintptr, sortOrder int32, ifNotExist int32, idxType U8) {
  71424 	bp := tls.Alloc(196)
  71425 	defer tls.Free(196)
  71426 
  71427 	var pTab uintptr
  71428 	var pIndex uintptr
  71429 	var zName uintptr
  71430 	var nName int32
  71431 	var i int32
  71432 	var j int32
  71433 
  71434 	var sortOrderMask int32
  71435 	var db uintptr
  71436 	var pDb uintptr
  71437 	var iDb int32
  71438 
  71439 	var pListItem uintptr
  71440 	var nExtra int32
  71441 	var nExtraCol int32
  71442 
  71443 	var pPk uintptr
  71444 	var n int32
  71445 	var pLoop uintptr
  71446 	var zDb uintptr
  71447 
  71448 	var pCol uintptr
  71449 	var pExpr uintptr
  71450 	var nColl int32
  71451 	var pCExpr uintptr
  71452 	var requestedSortOrder int32
  71453 	var zColl uintptr
  71454 	var x int32
  71455 	var z1 uintptr
  71456 	var z2 uintptr
  71457 	var k int32
  71458 
  71459 	var pIdx uintptr
  71460 	var p uintptr
  71461 	var n1 int32
  71462 	var v uintptr
  71463 	var zStmt uintptr
  71464 	var iMem int32
  71465 	var pNext uintptr
  71466 
  71467 	var ppFrom uintptr
  71468 	var pThis uintptr
  71469 	pTab = uintptr(0)
  71470 	pIndex = uintptr(0)
  71471 	zName = uintptr(0)
  71472 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  71473 	*(*uintptr)(unsafe.Pointer(bp + 128)) = uintptr(0)
  71474 	nExtra = 0
  71475 	*(*uintptr)(unsafe.Pointer(bp + 192)) = uintptr(0)
  71476 	pPk = uintptr(0)
  71477 
  71478 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  71479 		goto __1
  71480 	}
  71481 	goto exit_create_index
  71482 __1:
  71483 	;
  71484 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB && int32(idxType) != SQLITE_IDXTYPE_PRIMARYKEY) {
  71485 		goto __2
  71486 	}
  71487 	goto exit_create_index
  71488 __2:
  71489 	;
  71490 	if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) {
  71491 		goto __3
  71492 	}
  71493 	goto exit_create_index
  71494 __3:
  71495 	;
  71496 	if !(Xsqlite3HasExplicitNulls(tls, pParse, pList) != 0) {
  71497 		goto __4
  71498 	}
  71499 	goto exit_create_index
  71500 __4:
  71501 	;
  71502 	if !(pTblName != uintptr(0)) {
  71503 		goto __5
  71504 	}
  71505 
  71506 	iDb = Xsqlite3TwoPartName(tls, pParse, pName1, pName2, bp+128)
  71507 	if !(iDb < 0) {
  71508 		goto __7
  71509 	}
  71510 	goto exit_create_index
  71511 __7:
  71512 	;
  71513 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) {
  71514 		goto __8
  71515 	}
  71516 	pTab = Xsqlite3SrcListLookup(tls, pParse, pTblName)
  71517 	if !((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema) {
  71518 		goto __9
  71519 	}
  71520 	iDb = 1
  71521 __9:
  71522 	;
  71523 __8:
  71524 	;
  71525 	Xsqlite3FixInit(tls, bp+132, pParse, iDb, ts+13813, *(*uintptr)(unsafe.Pointer(bp + 128)))
  71526 	if !(Xsqlite3FixSrcList(tls, bp+132, pTblName) != 0) {
  71527 		goto __10
  71528 	}
  71529 
  71530 __10:
  71531 	;
  71532 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pTblName+8)
  71533 
  71534 	if !(pTab == uintptr(0)) {
  71535 		goto __11
  71536 	}
  71537 	goto exit_create_index
  71538 __11:
  71539 	;
  71540 	if !(iDb == 1 && (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema != (*Table)(unsafe.Pointer(pTab)).FpSchema) {
  71541 		goto __12
  71542 	}
  71543 	Xsqlite3ErrorMsg(tls, pParse,
  71544 		ts+13819,
  71545 		libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  71546 	goto exit_create_index
  71547 __12:
  71548 	;
  71549 	if !!((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  71550 		goto __13
  71551 	}
  71552 	pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  71553 __13:
  71554 	;
  71555 	goto __6
  71556 __5:
  71557 	;
  71558 	pTab = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  71559 	if !!(pTab != 0) {
  71560 		goto __14
  71561 	}
  71562 	goto exit_create_index
  71563 __14:
  71564 	;
  71565 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  71566 __6:
  71567 	;
  71568 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  71569 
  71570 	if !(Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+6381, 7) == 0 &&
  71571 		int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0 &&
  71572 		pTblName != uintptr(0)) {
  71573 		goto __15
  71574 	}
  71575 	Xsqlite3ErrorMsg(tls, pParse, ts+13869, libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName))
  71576 	goto exit_create_index
  71577 __15:
  71578 	;
  71579 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  71580 		goto __16
  71581 	}
  71582 	Xsqlite3ErrorMsg(tls, pParse, ts+13897, 0)
  71583 	goto exit_create_index
  71584 __16:
  71585 	;
  71586 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  71587 		goto __17
  71588 	}
  71589 	Xsqlite3ErrorMsg(tls, pParse, ts+13922, 0)
  71590 	goto exit_create_index
  71591 __17:
  71592 	;
  71593 	if !(*(*uintptr)(unsafe.Pointer(bp + 128)) != 0) {
  71594 		goto __18
  71595 	}
  71596 	zName = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp + 128)))
  71597 	if !(zName == uintptr(0)) {
  71598 		goto __20
  71599 	}
  71600 	goto exit_create_index
  71601 __20:
  71602 	;
  71603 	if !(SQLITE_OK != Xsqlite3CheckObjectName(tls, pParse, zName, ts+13813, (*Table)(unsafe.Pointer(pTab)).FzName)) {
  71604 		goto __21
  71605 	}
  71606 	goto exit_create_index
  71607 __21:
  71608 	;
  71609 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  71610 		goto __22
  71611 	}
  71612 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) {
  71613 		goto __23
  71614 	}
  71615 	if !(Xsqlite3FindTable(tls, db, zName, (*Db)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0)) {
  71616 		goto __24
  71617 	}
  71618 	Xsqlite3ErrorMsg(tls, pParse, ts+13956, libc.VaList(bp+16, zName))
  71619 	goto exit_create_index
  71620 __24:
  71621 	;
  71622 __23:
  71623 	;
  71624 	if !(Xsqlite3FindIndex(tls, db, zName, (*Db)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0)) {
  71625 		goto __25
  71626 	}
  71627 	if !!(ifNotExist != 0) {
  71628 		goto __26
  71629 	}
  71630 	Xsqlite3ErrorMsg(tls, pParse, ts+13990, libc.VaList(bp+24, zName))
  71631 	goto __27
  71632 __26:
  71633 	;
  71634 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  71635 	sqlite3ForceNotReadOnly(tls, pParse)
  71636 __27:
  71637 	;
  71638 	goto exit_create_index
  71639 __25:
  71640 	;
  71641 __22:
  71642 	;
  71643 	goto __19
  71644 __18:
  71645 	pLoop = (*Table)(unsafe.Pointer(pTab)).FpIndex
  71646 	n = 1
  71647 __28:
  71648 	if !(pLoop != 0) {
  71649 		goto __30
  71650 	}
  71651 	goto __29
  71652 __29:
  71653 	pLoop = (*Index)(unsafe.Pointer(pLoop)).FpNext
  71654 	n++
  71655 	goto __28
  71656 	goto __30
  71657 __30:
  71658 	;
  71659 	zName = Xsqlite3MPrintf(tls, db, ts+14014, libc.VaList(bp+32, (*Table)(unsafe.Pointer(pTab)).FzName, n))
  71660 	if !(zName == uintptr(0)) {
  71661 		goto __31
  71662 	}
  71663 	goto exit_create_index
  71664 __31:
  71665 	;
  71666 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) {
  71667 		goto __32
  71668 	}
  71669 	*(*uint8)(unsafe.Pointer(zName + 7))++
  71670 __32:
  71671 	;
  71672 __19:
  71673 	;
  71674 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  71675 		goto __33
  71676 	}
  71677 	zDb = (*Db)(unsafe.Pointer(pDb)).FzDbSName
  71678 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr {
  71679 		if !(0 != 0) && iDb == 1 {
  71680 			return ts + 6389
  71681 		}
  71682 		return ts + 5883
  71683 	}(), uintptr(0), zDb) != 0) {
  71684 		goto __34
  71685 	}
  71686 	goto exit_create_index
  71687 __34:
  71688 	;
  71689 	i = SQLITE_CREATE_INDEX
  71690 	if !(!(0 != 0) && iDb == 1) {
  71691 		goto __35
  71692 	}
  71693 	i = SQLITE_CREATE_TEMP_INDEX
  71694 __35:
  71695 	;
  71696 	if !(Xsqlite3AuthCheck(tls, pParse, i, zName, (*Table)(unsafe.Pointer(pTab)).FzName, zDb) != 0) {
  71697 		goto __36
  71698 	}
  71699 	goto exit_create_index
  71700 __36:
  71701 	;
  71702 __33:
  71703 	;
  71704 	if !(pList == uintptr(0)) {
  71705 		goto __37
  71706 	}
  71707 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1)*16
  71708 	*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_UNIQUE)
  71709 	Xsqlite3TokenInit(tls, bp+184, (*Column)(unsafe.Pointer(pCol)).FzCnName)
  71710 	pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0),
  71711 		Xsqlite3ExprAlloc(tls, db, TK_ID, bp+184, 0))
  71712 	if !(pList == uintptr(0)) {
  71713 		goto __39
  71714 	}
  71715 	goto exit_create_index
  71716 __39:
  71717 	;
  71718 	Xsqlite3ExprListSetSortOrder(tls, pList, sortOrder, -1)
  71719 	goto __38
  71720 __37:
  71721 	Xsqlite3ExprListCheckLength(tls, pParse, pList, ts+13813)
  71722 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  71723 		goto __40
  71724 	}
  71725 	goto exit_create_index
  71726 __40:
  71727 	;
  71728 __38:
  71729 	;
  71730 	i = 0
  71731 __41:
  71732 	if !(i < (*ExprList)(unsafe.Pointer(pList)).FnExpr) {
  71733 		goto __43
  71734 	}
  71735 	pExpr = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*20)).FpExpr
  71736 
  71737 	if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE) {
  71738 		goto __44
  71739 	}
  71740 
  71741 	nExtra = nExtra + (1 + Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8))))
  71742 __44:
  71743 	;
  71744 	goto __42
  71745 __42:
  71746 	i++
  71747 	goto __41
  71748 	goto __43
  71749 __43:
  71750 	;
  71751 	nName = Xsqlite3Strlen30(tls, zName)
  71752 	if pPk != 0 {
  71753 		nExtraCol = int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  71754 	} else {
  71755 		nExtraCol = 1
  71756 	}
  71757 
  71758 	pIndex = Xsqlite3AllocateIndexObject(tls, db, int16((*ExprList)(unsafe.Pointer(pList)).FnExpr+nExtraCol),
  71759 		nName+nExtra+1, bp+192)
  71760 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  71761 		goto __45
  71762 	}
  71763 	goto exit_create_index
  71764 __45:
  71765 	;
  71766 	(*Index)(unsafe.Pointer(pIndex)).FzName = *(*uintptr)(unsafe.Pointer(bp + 192))
  71767 	*(*uintptr)(unsafe.Pointer(bp + 192)) += uintptr(nName + 1)
  71768 	libc.Xmemcpy(tls, (*Index)(unsafe.Pointer(pIndex)).FzName, zName, uint32(nName+1))
  71769 	(*Index)(unsafe.Pointer(pIndex)).FpTable = pTab
  71770 	(*Index)(unsafe.Pointer(pIndex)).FonError = U8(onError)
  71771 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(libc.Bool32(onError != OE_None)), 3, 0x8)
  71772 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(idxType), 0, 0x3)
  71773 	(*Index)(unsafe.Pointer(pIndex)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  71774 	(*Index)(unsafe.Pointer(pIndex)).FnKeyCol = U16((*ExprList)(unsafe.Pointer(pList)).FnExpr)
  71775 	if !(pPIWhere != 0) {
  71776 		goto __46
  71777 	}
  71778 	Xsqlite3ResolveSelfReference(tls, pParse, pTab, NC_PartIdx, pPIWhere, uintptr(0))
  71779 	(*Index)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere
  71780 	pPIWhere = uintptr(0)
  71781 __46:
  71782 	;
  71783 	if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) >= 4) {
  71784 		goto __47
  71785 	}
  71786 	sortOrderMask = -1
  71787 	goto __48
  71788 __47:
  71789 	sortOrderMask = 0
  71790 __48:
  71791 	;
  71792 	pListItem = pList + 8
  71793 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  71794 		goto __49
  71795 	}
  71796 	(*Index)(unsafe.Pointer(pIndex)).FaColExpr = pList
  71797 	pList = uintptr(0)
  71798 __49:
  71799 	;
  71800 	i = 0
  71801 __50:
  71802 	if !(i < int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol)) {
  71803 		goto __52
  71804 	}
  71805 
  71806 	sqlite3StringToId(tls, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)
  71807 	Xsqlite3ResolveSelfReference(tls, pParse, pTab, NC_IdxExpr, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0))
  71808 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  71809 		goto __53
  71810 	}
  71811 	goto exit_create_index
  71812 __53:
  71813 	;
  71814 	pCExpr = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)
  71815 	if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) != TK_COLUMN) {
  71816 		goto __54
  71817 	}
  71818 	if !(pTab == (*Parse)(unsafe.Pointer(pParse)).FpNewTable) {
  71819 		goto __56
  71820 	}
  71821 	Xsqlite3ErrorMsg(tls, pParse,
  71822 		ts+14037, 0)
  71823 	goto exit_create_index
  71824 __56:
  71825 	;
  71826 	if !((*Index)(unsafe.Pointer(pIndex)).FaColExpr == uintptr(0)) {
  71827 		goto __57
  71828 	}
  71829 	(*Index)(unsafe.Pointer(pIndex)).FaColExpr = pList
  71830 	pList = uintptr(0)
  71831 __57:
  71832 	;
  71833 	j = -2
  71834 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-2)
  71835 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(0), 3, 0x8)
  71836 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 11, 0x800)
  71837 	goto __55
  71838 __54:
  71839 	j = int32((*Expr)(unsafe.Pointer(pCExpr)).FiColumn)
  71840 
  71841 	if !(j < 0) {
  71842 		goto __58
  71843 	}
  71844 	j = int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
  71845 	goto __59
  71846 __58:
  71847 	if !(int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16 + 4))&0xf>>0) == 0) {
  71848 		goto __60
  71849 	}
  71850 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(0), 3, 0x8)
  71851 __60:
  71852 	;
  71853 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0) {
  71854 		goto __61
  71855 	}
  71856 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 10, 0x400)
  71857 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 11, 0x800)
  71858 __61:
  71859 	;
  71860 __59:
  71861 	;
  71862 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = I16(j)
  71863 __55:
  71864 	;
  71865 	zColl = uintptr(0)
  71866 	if !(int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == TK_COLLATE) {
  71867 		goto __62
  71868 	}
  71869 
  71870 	zColl = *(*uintptr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8))
  71871 	nColl = Xsqlite3Strlen30(tls, zColl) + 1
  71872 
  71873 	libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp + 192)), zColl, uint32(nColl))
  71874 	zColl = *(*uintptr)(unsafe.Pointer(bp + 192))
  71875 	*(*uintptr)(unsafe.Pointer(bp + 192)) += uintptr(nColl)
  71876 	nExtra = nExtra - nColl
  71877 	goto __63
  71878 __62:
  71879 	if !(j >= 0) {
  71880 		goto __64
  71881 	}
  71882 	zColl = Xsqlite3ColumnColl(tls, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)
  71883 __64:
  71884 	;
  71885 __63:
  71886 	;
  71887 	if !!(zColl != 0) {
  71888 		goto __65
  71889 	}
  71890 	zColl = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
  71891 __65:
  71892 	;
  71893 	if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) && !(Xsqlite3LocateCollSeq(tls, pParse, zColl) != 0)) {
  71894 		goto __66
  71895 	}
  71896 	goto exit_create_index
  71897 __66:
  71898 	;
  71899 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*4)) = zColl
  71900 	requestedSortOrder = int32((*ExprList_item)(unsafe.Pointer(pListItem)).Ffg.FsortFlags) & sortOrderMask
  71901 	*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = U8(requestedSortOrder)
  71902 	goto __51
  71903 __51:
  71904 	i++
  71905 	pListItem += 20
  71906 	goto __50
  71907 	goto __52
  71908 __52:
  71909 	;
  71910 	if !(pPk != 0) {
  71911 		goto __67
  71912 	}
  71913 	j = 0
  71914 __69:
  71915 	if !(j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) {
  71916 		goto __71
  71917 	}
  71918 	x = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))
  71919 
  71920 	if !(isDupColumn(tls, pIndex, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol), pPk, j) != 0) {
  71921 		goto __72
  71922 	}
  71923 	(*Index)(unsafe.Pointer(pIndex)).FnColumn--
  71924 	goto __73
  71925 __72:
  71926 	;
  71927 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = I16(x)
  71928 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*4))
  71929 	*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j)))
  71930 	i++
  71931 __73:
  71932 	;
  71933 	goto __70
  71934 __70:
  71935 	j++
  71936 	goto __69
  71937 	goto __71
  71938 __71:
  71939 	;
  71940 	goto __68
  71941 __67:
  71942 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-1)
  71943 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*4)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
  71944 __68:
  71945 	;
  71946 	Xsqlite3DefaultRowEst(tls, pIndex)
  71947 	if !((*Parse)(unsafe.Pointer(pParse)).FpNewTable == uintptr(0)) {
  71948 		goto __74
  71949 	}
  71950 	estimateIndexWidth(tls, pIndex)
  71951 __74:
  71952 	;
  71953 	recomputeColumnsNotIndexed(tls, pIndex)
  71954 	if !(pTblName != uintptr(0) && int32((*Index)(unsafe.Pointer(pIndex)).FnColumn) >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  71955 		goto __75
  71956 	}
  71957 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(1), 5, 0x20)
  71958 	j = 0
  71959 __76:
  71960 	if !(j < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  71961 		goto __78
  71962 	}
  71963 	if !(j == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  71964 		goto __79
  71965 	}
  71966 	goto __77
  71967 __79:
  71968 	;
  71969 	if !(int32(Xsqlite3TableColumnToIndex(tls, pIndex, int16(j))) >= 0) {
  71970 		goto __80
  71971 	}
  71972 	goto __77
  71973 __80:
  71974 	;
  71975 	libc.SetBitFieldPtr16Uint32(pIndex+56, uint32(0), 5, 0x20)
  71976 	goto __78
  71977 	goto __77
  71978 __77:
  71979 	j++
  71980 	goto __76
  71981 	goto __78
  71982 __78:
  71983 	;
  71984 __75:
  71985 	;
  71986 	if !(pTab == (*Parse)(unsafe.Pointer(pParse)).FpNewTable) {
  71987 		goto __81
  71988 	}
  71989 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  71990 __82:
  71991 	if !(pIdx != 0) {
  71992 		goto __84
  71993 	}
  71994 
  71995 	if !(int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) != int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol)) {
  71996 		goto __85
  71997 	}
  71998 	goto __83
  71999 __85:
  72000 	;
  72001 	k = 0
  72002 __86:
  72003 	if !(k < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) {
  72004 		goto __88
  72005 	}
  72006 
  72007 	if !(int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(k)*2))) != int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(k)*2)))) {
  72008 		goto __89
  72009 	}
  72010 	goto __88
  72011 __89:
  72012 	;
  72013 	z1 = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(k)*4))
  72014 	z2 = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FazColl + uintptr(k)*4))
  72015 	if !(Xsqlite3StrICmp(tls, z1, z2) != 0) {
  72016 		goto __90
  72017 	}
  72018 	goto __88
  72019 __90:
  72020 	;
  72021 	goto __87
  72022 __87:
  72023 	k++
  72024 	goto __86
  72025 	goto __88
  72026 __88:
  72027 	;
  72028 	if !(k == int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) {
  72029 		goto __91
  72030 	}
  72031 	if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) != int32((*Index)(unsafe.Pointer(pIndex)).FonError)) {
  72032 		goto __92
  72033 	}
  72034 
  72035 	if !!(int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Default || int32((*Index)(unsafe.Pointer(pIndex)).FonError) == OE_Default) {
  72036 		goto __93
  72037 	}
  72038 	Xsqlite3ErrorMsg(tls, pParse,
  72039 		ts+14098, libc.VaList(bp+48, 0))
  72040 __93:
  72041 	;
  72042 	if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Default) {
  72043 		goto __94
  72044 	}
  72045 	(*Index)(unsafe.Pointer(pIdx)).FonError = (*Index)(unsafe.Pointer(pIndex)).FonError
  72046 __94:
  72047 	;
  72048 __92:
  72049 	;
  72050 	if !(int32(idxType) == SQLITE_IDXTYPE_PRIMARYKEY) {
  72051 		goto __95
  72052 	}
  72053 	libc.SetBitFieldPtr16Uint32(pIdx+56, uint32(idxType), 0, 0x3)
  72054 __95:
  72055 	;
  72056 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  72057 		goto __96
  72058 	}
  72059 	(*Index)(unsafe.Pointer(pIndex)).FpNext = (*Parse)(unsafe.Pointer(pParse)).FpNewIndex
  72060 	(*Parse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex
  72061 	pIndex = uintptr(0)
  72062 __96:
  72063 	;
  72064 	goto exit_create_index
  72065 __91:
  72066 	;
  72067 	goto __83
  72068 __83:
  72069 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  72070 	goto __82
  72071 	goto __84
  72072 __84:
  72073 	;
  72074 __81:
  72075 	;
  72076 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  72077 		goto __97
  72078 	}
  72079 
  72080 	if !((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) {
  72081 		goto __98
  72082 	}
  72083 
  72084 	if !(pTblName != uintptr(0)) {
  72085 		goto __100
  72086 	}
  72087 	(*Index)(unsafe.Pointer(pIndex)).Ftnum = (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum
  72088 	if !(Xsqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0) {
  72089 		goto __101
  72090 	}
  72091 	Xsqlite3ErrorMsg(tls, pParse, ts+14140, 0)
  72092 	(*Parse)(unsafe.Pointer(pParse)).Frc = Xsqlite3CorruptError(tls, 121859)
  72093 	goto exit_create_index
  72094 __101:
  72095 	;
  72096 __100:
  72097 	;
  72098 	p = Xsqlite3HashInsert(tls, (*Index)(unsafe.Pointer(pIndex)).FpSchema+24,
  72099 		(*Index)(unsafe.Pointer(pIndex)).FzName, pIndex)
  72100 	if !(p != 0) {
  72101 		goto __102
  72102 	}
  72103 
  72104 	Xsqlite3OomFault(tls, db)
  72105 	goto exit_create_index
  72106 __102:
  72107 	;
  72108 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  72109 	goto __99
  72110 __98:
  72111 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) || pTblName != uintptr(0)) {
  72112 		goto __103
  72113 	}
  72114 	iMem = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  72115 
  72116 	v = Xsqlite3GetVdbe(tls, pParse)
  72117 	if !(v == uintptr(0)) {
  72118 		goto __104
  72119 	}
  72120 	goto exit_create_index
  72121 __104:
  72122 	;
  72123 	Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb)
  72124 
  72125 	(*Index)(unsafe.Pointer(pIndex)).Ftnum = Pgno(Xsqlite3VdbeAddOp0(tls, v, OP_Noop))
  72126 	Xsqlite3VdbeAddOp3(tls, v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY)
  72127 
  72128 	if !(pStart != 0) {
  72129 		goto __105
  72130 	}
  72131 	n1 = int32(uint32((int32((*Parse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int32((*Token)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 128)))).Fz))/1) + (*Parse)(unsafe.Pointer(pParse)).FsLastToken.Fn)
  72132 	if !(int32(*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 128)))).Fz + uintptr(n1-1)))) == ';') {
  72133 		goto __107
  72134 	}
  72135 	n1--
  72136 __107:
  72137 	;
  72138 	zStmt = Xsqlite3MPrintf(tls, db, ts+14157,
  72139 		libc.VaList(bp+56, func() uintptr {
  72140 			if onError == OE_None {
  72141 				return ts + 1554
  72142 			}
  72143 			return ts + 14177
  72144 		}(), n1, (*Token)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 128)))).Fz))
  72145 	goto __106
  72146 __105:
  72147 	zStmt = uintptr(0)
  72148 __106:
  72149 	;
  72150 	Xsqlite3NestedParse(tls, pParse,
  72151 		ts+14185,
  72152 		libc.VaList(bp+80, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName,
  72153 			(*Index)(unsafe.Pointer(pIndex)).FzName,
  72154 			(*Table)(unsafe.Pointer(pTab)).FzName,
  72155 			iMem,
  72156 			zStmt))
  72157 	Xsqlite3DbFree(tls, db, zStmt)
  72158 
  72159 	if !(pTblName != 0) {
  72160 		goto __108
  72161 	}
  72162 	sqlite3RefillIndex(tls, pParse, pIndex, iMem)
  72163 	Xsqlite3ChangeCookie(tls, pParse, iDb)
  72164 	Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb,
  72165 		Xsqlite3MPrintf(tls, db, ts+14244, libc.VaList(bp+120, (*Index)(unsafe.Pointer(pIndex)).FzName)), uint16(0))
  72166 	Xsqlite3VdbeAddOp2(tls, v, OP_Expire, 0, 1)
  72167 __108:
  72168 	;
  72169 	Xsqlite3VdbeJumpHere(tls, v, int32((*Index)(unsafe.Pointer(pIndex)).Ftnum))
  72170 __103:
  72171 	;
  72172 __99:
  72173 	;
  72174 __97:
  72175 	;
  72176 	if !((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 || pTblName == uintptr(0)) {
  72177 		goto __109
  72178 	}
  72179 	(*Index)(unsafe.Pointer(pIndex)).FpNext = (*Table)(unsafe.Pointer(pTab)).FpIndex
  72180 	(*Table)(unsafe.Pointer(pTab)).FpIndex = pIndex
  72181 	pIndex = uintptr(0)
  72182 	goto __110
  72183 __109:
  72184 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  72185 		goto __111
  72186 	}
  72187 
  72188 	(*Parse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex
  72189 	pIndex = uintptr(0)
  72190 __111:
  72191 	;
  72192 __110:
  72193 	;
  72194 exit_create_index:
  72195 	if !(pIndex != 0) {
  72196 		goto __112
  72197 	}
  72198 	Xsqlite3FreeIndex(tls, db, pIndex)
  72199 __112:
  72200 	;
  72201 	if !(pTab != 0) {
  72202 		goto __113
  72203 	}
  72204 	ppFrom = pTab + 8
  72205 __114:
  72206 	if !(libc.AssignUintptr(&pThis, *(*uintptr)(unsafe.Pointer(ppFrom))) != uintptr(0)) {
  72207 		goto __116
  72208 	}
  72209 	if !(int32((*Index)(unsafe.Pointer(pThis)).FonError) != OE_Replace) {
  72210 		goto __117
  72211 	}
  72212 	goto __115
  72213 __117:
  72214 	;
  72215 __118:
  72216 	if !(libc.AssignUintptr(&pNext, (*Index)(unsafe.Pointer(pThis)).FpNext) != uintptr(0) && int32((*Index)(unsafe.Pointer(pNext)).FonError) != OE_Replace) {
  72217 		goto __119
  72218 	}
  72219 	*(*uintptr)(unsafe.Pointer(ppFrom)) = pNext
  72220 	(*Index)(unsafe.Pointer(pThis)).FpNext = (*Index)(unsafe.Pointer(pNext)).FpNext
  72221 	(*Index)(unsafe.Pointer(pNext)).FpNext = pThis
  72222 	ppFrom = pNext + 20
  72223 	goto __118
  72224 __119:
  72225 	;
  72226 	goto __116
  72227 	goto __115
  72228 __115:
  72229 	ppFrom = pThis + 20
  72230 	goto __114
  72231 	goto __116
  72232 __116:
  72233 	;
  72234 __113:
  72235 	;
  72236 	Xsqlite3ExprDelete(tls, db, pPIWhere)
  72237 	Xsqlite3ExprListDelete(tls, db, pList)
  72238 	Xsqlite3SrcListDelete(tls, db, pTblName)
  72239 	Xsqlite3DbFree(tls, db, zName)
  72240 }
  72241 
  72242 // Fill the Index.aiRowEst[] array with default information - information
  72243 // to be used when we have not run the ANALYZE command.
  72244 //
  72245 // aiRowEst[0] is supposed to contain the number of elements in the index.
  72246 // Since we do not know, guess 1 million.  aiRowEst[1] is an estimate of the
  72247 // number of rows in the table that match any particular value of the
  72248 // first column of the index.  aiRowEst[2] is an estimate of the number
  72249 // of rows that match any particular combination of the first 2 columns
  72250 // of the index.  And so forth.  It must always be the case that
  72251 //
  72252 //	aiRowEst[N]<=aiRowEst[N-1]
  72253 //	aiRowEst[N]>=1
  72254 //
  72255 // Apart from that, we have little to go on besides intuition as to
  72256 // how aiRowEst[] should be initialized.  The numbers generated here
  72257 // are based on typical values found in actual indices.
  72258 func Xsqlite3DefaultRowEst(tls *libc.TLS, pIdx uintptr) {
  72259 	var a uintptr = (*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst
  72260 	var x LogEst
  72261 	var nCopy int32 = func() int32 {
  72262 		if int32(uint32(unsafe.Sizeof(aVal))/uint32(unsafe.Sizeof(LogEst(0)))) < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) {
  72263 			return int32(uint32(unsafe.Sizeof(aVal)) / uint32(unsafe.Sizeof(LogEst(0))))
  72264 		}
  72265 		return int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  72266 	}()
  72267 	var i int32
  72268 
  72269 	x = (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FnRowLogEst
  72270 
  72271 	if int32(x) < 99 {
  72272 		(*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FnRowLogEst = libc.AssignInt16(&x, int16(99))
  72273 	}
  72274 	if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) {
  72275 		x = int16(int32(x) - 10)
  72276 	}
  72277 	*(*LogEst)(unsafe.Pointer(a)) = x
  72278 
  72279 	libc.Xmemcpy(tls, a+1*2, uintptr(unsafe.Pointer(&aVal)), uint32(nCopy)*uint32(unsafe.Sizeof(LogEst(0))))
  72280 	for i = nCopy + 1; i <= int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ {
  72281 		*(*LogEst)(unsafe.Pointer(a + uintptr(i)*2)) = int16(23)
  72282 	}
  72283 
  72284 	if int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None {
  72285 		*(*LogEst)(unsafe.Pointer(a + uintptr((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)*2)) = int16(0)
  72286 	}
  72287 }
  72288 
  72289 var aVal = [5]LogEst{int16(33), int16(32), int16(30), int16(28), int16(26)}
  72290 
  72291 // This routine will drop an existing named index.  This routine
  72292 // implements the DROP INDEX statement.
  72293 func Xsqlite3DropIndex(tls *libc.TLS, pParse uintptr, pName uintptr, ifExists int32) {
  72294 	bp := tls.Alloc(32)
  72295 	defer tls.Free(32)
  72296 
  72297 	var pIndex uintptr
  72298 	var v uintptr
  72299 	var db uintptr
  72300 	var iDb int32
  72301 	var code int32
  72302 	var pTab uintptr
  72303 	var zDb uintptr
  72304 	var zTab uintptr
  72305 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72306 
  72307 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  72308 		goto __1
  72309 	}
  72310 	goto exit_drop_index
  72311 __1:
  72312 	;
  72313 	if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) {
  72314 		goto __2
  72315 	}
  72316 	goto exit_drop_index
  72317 __2:
  72318 	;
  72319 	pIndex = Xsqlite3FindIndex(tls, db, (*SrcItem)(unsafe.Pointer(pName+8)).FzName, (*SrcItem)(unsafe.Pointer(pName+8)).FzDatabase)
  72320 	if !(pIndex == uintptr(0)) {
  72321 		goto __3
  72322 	}
  72323 	if !!(ifExists != 0) {
  72324 		goto __4
  72325 	}
  72326 	Xsqlite3ErrorMsg(tls, pParse, ts+14271, libc.VaList(bp, pName+8))
  72327 	goto __5
  72328 __4:
  72329 	Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcItem)(unsafe.Pointer(pName+8)).FzDatabase)
  72330 	sqlite3ForceNotReadOnly(tls, pParse)
  72331 __5:
  72332 	;
  72333 	(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  72334 	goto exit_drop_index
  72335 __3:
  72336 	;
  72337 	if !(int32(*(*uint16)(unsafe.Pointer(pIndex + 56))&0x3>>0) != SQLITE_IDXTYPE_APPDEF) {
  72338 		goto __6
  72339 	}
  72340 	Xsqlite3ErrorMsg(tls, pParse,
  72341 		ts+14289, libc.VaList(bp+8, 0))
  72342 	goto exit_drop_index
  72343 __6:
  72344 	;
  72345 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIndex)).FpSchema)
  72346 
  72347 	code = SQLITE_DROP_INDEX
  72348 	pTab = (*Index)(unsafe.Pointer(pIndex)).FpTable
  72349 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  72350 	zTab = func() uintptr {
  72351 		if !(0 != 0) && iDb == 1 {
  72352 			return ts + 6389
  72353 		}
  72354 		return ts + 5883
  72355 	}()
  72356 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) {
  72357 		goto __7
  72358 	}
  72359 	goto exit_drop_index
  72360 __7:
  72361 	;
  72362 	if !(!(0 != 0) && iDb == 1) {
  72363 		goto __8
  72364 	}
  72365 	code = SQLITE_DROP_TEMP_INDEX
  72366 __8:
  72367 	;
  72368 	if !(Xsqlite3AuthCheck(tls, pParse, code, (*Index)(unsafe.Pointer(pIndex)).FzName, (*Table)(unsafe.Pointer(pTab)).FzName, zDb) != 0) {
  72369 		goto __9
  72370 	}
  72371 	goto exit_drop_index
  72372 __9:
  72373 	;
  72374 	v = Xsqlite3GetVdbe(tls, pParse)
  72375 	if !(v != 0) {
  72376 		goto __10
  72377 	}
  72378 	Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb)
  72379 	Xsqlite3NestedParse(tls, pParse,
  72380 		ts+14362,
  72381 		libc.VaList(bp+16, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName, (*Index)(unsafe.Pointer(pIndex)).FzName))
  72382 	sqlite3ClearStatTables(tls, pParse, iDb, ts+11488, (*Index)(unsafe.Pointer(pIndex)).FzName)
  72383 	Xsqlite3ChangeCookie(tls, pParse, iDb)
  72384 	destroyRootPage(tls, pParse, int32((*Index)(unsafe.Pointer(pIndex)).Ftnum), iDb)
  72385 	Xsqlite3VdbeAddOp4(tls, v, OP_DropIndex, iDb, 0, 0, (*Index)(unsafe.Pointer(pIndex)).FzName, 0)
  72386 __10:
  72387 	;
  72388 exit_drop_index:
  72389 	Xsqlite3SrcListDelete(tls, db, pName)
  72390 }
  72391 
  72392 // pArray is a pointer to an array of objects. Each object in the
  72393 // array is szEntry bytes in size. This routine uses sqlite3DbRealloc()
  72394 // to extend the array so that there is space for a new object at the end.
  72395 //
  72396 // When this function is called, *pnEntry contains the current size of
  72397 // the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes
  72398 // in total).
  72399 //
  72400 // If the realloc() is successful (i.e. if no OOM condition occurs), the
  72401 // space allocated for the new object is zeroed, *pnEntry updated to
  72402 // reflect the new size of the array and a pointer to the new allocation
  72403 // returned. *pIdx is set to the index of the new array entry in this case.
  72404 //
  72405 // Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains
  72406 // unchanged and a copy of pArray returned.
  72407 func Xsqlite3ArrayAllocate(tls *libc.TLS, db uintptr, pArray uintptr, szEntry int32, pnEntry uintptr, pIdx uintptr) uintptr {
  72408 	var z uintptr
  72409 	var n Sqlite3_int64 = Sqlite3_int64(libc.AssignPtrInt32(pIdx, *(*int32)(unsafe.Pointer(pnEntry))))
  72410 	if n&(n-int64(1)) == int64(0) {
  72411 		var sz Sqlite3_int64
  72412 		if n == int64(0) {
  72413 			sz = int64(1)
  72414 		} else {
  72415 			sz = int64(2) * n
  72416 		}
  72417 		var pNew uintptr = Xsqlite3DbRealloc(tls, db, pArray, uint64(sz*Sqlite3_int64(szEntry)))
  72418 		if pNew == uintptr(0) {
  72419 			*(*int32)(unsafe.Pointer(pIdx)) = -1
  72420 			return pArray
  72421 		}
  72422 		pArray = pNew
  72423 	}
  72424 	z = pArray
  72425 	libc.Xmemset(tls, z+uintptr(n*Sqlite3_int64(szEntry)), 0, uint32(szEntry))
  72426 	*(*int32)(unsafe.Pointer(pnEntry))++
  72427 	return pArray
  72428 }
  72429 
  72430 // Append a new element to the given IdList.  Create a new IdList if
  72431 // need be.
  72432 //
  72433 // A new IdList is returned, or NULL if malloc() fails.
  72434 func Xsqlite3IdListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pToken uintptr) uintptr {
  72435 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72436 	var i int32
  72437 	if pList == uintptr(0) {
  72438 		pList = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(IdList{})))
  72439 		if pList == uintptr(0) {
  72440 			return uintptr(0)
  72441 		}
  72442 	} else {
  72443 		var pNew uintptr
  72444 		pNew = Xsqlite3DbRealloc(tls, db, pList,
  72445 			uint64(uint32(unsafe.Sizeof(IdList{}))+uint32((*IdList)(unsafe.Pointer(pList)).FnId)*uint32(unsafe.Sizeof([1]IdList_item{}))))
  72446 		if pNew == uintptr(0) {
  72447 			Xsqlite3IdListDelete(tls, db, pList)
  72448 			return uintptr(0)
  72449 		}
  72450 		pList = pNew
  72451 	}
  72452 	i = libc.PostIncInt32(&(*IdList)(unsafe.Pointer(pList)).FnId, 1)
  72453 	(*IdList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*8)).FzName = Xsqlite3NameFromToken(tls, db, pToken)
  72454 	if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && (*IdList_item)(unsafe.Pointer(pList+8+uintptr(i)*8)).FzName != 0 {
  72455 		Xsqlite3RenameTokenMap(tls, pParse, (*IdList_item)(unsafe.Pointer(pList+8+uintptr(i)*8)).FzName, pToken)
  72456 	}
  72457 	return pList
  72458 }
  72459 
  72460 // Delete an IdList.
  72461 func Xsqlite3IdListDelete(tls *libc.TLS, db uintptr, pList uintptr) {
  72462 	var i int32
  72463 
  72464 	if pList == uintptr(0) {
  72465 		return
  72466 	}
  72467 
  72468 	for i = 0; i < (*IdList)(unsafe.Pointer(pList)).FnId; i++ {
  72469 		Xsqlite3DbFree(tls, db, (*IdList_item)(unsafe.Pointer(pList+8+uintptr(i)*8)).FzName)
  72470 	}
  72471 	Xsqlite3DbNNFreeNN(tls, db, pList)
  72472 }
  72473 
  72474 // Return the index in pList of the identifier named zId.  Return -1
  72475 // if not found.
  72476 func Xsqlite3IdListIndex(tls *libc.TLS, pList uintptr, zName uintptr) int32 {
  72477 	var i int32
  72478 
  72479 	for i = 0; i < (*IdList)(unsafe.Pointer(pList)).FnId; i++ {
  72480 		if Xsqlite3StrICmp(tls, (*IdList_item)(unsafe.Pointer(pList+8+uintptr(i)*8)).FzName, zName) == 0 {
  72481 			return i
  72482 		}
  72483 	}
  72484 	return -1
  72485 }
  72486 
  72487 // Expand the space allocated for the given SrcList object by
  72488 // creating nExtra new slots beginning at iStart.  iStart is zero based.
  72489 // New slots are zeroed.
  72490 //
  72491 // For example, suppose a SrcList initially contains two entries: A,B.
  72492 // To append 3 new entries onto the end, do this:
  72493 //
  72494 //	sqlite3SrcListEnlarge(db, pSrclist, 3, 2);
  72495 //
  72496 // After the call above it would contain:  A, B, nil, nil, nil.
  72497 // If the iStart argument had been 1 instead of 2, then the result
  72498 // would have been:  A, nil, nil, nil, B.  To prepend the new slots,
  72499 // the iStart value would be 0.  The result then would
  72500 // be: nil, nil, nil, A, B.
  72501 //
  72502 // If a memory allocation fails or the SrcList becomes too large, leave
  72503 // the original SrcList unchanged, return NULL, and leave an error message
  72504 // in pParse.
  72505 func Xsqlite3SrcListEnlarge(tls *libc.TLS, pParse uintptr, pSrc uintptr, nExtra int32, iStart int32) uintptr {
  72506 	bp := tls.Alloc(8)
  72507 	defer tls.Free(8)
  72508 
  72509 	var i int32
  72510 
  72511 	if U32((*SrcList)(unsafe.Pointer(pSrc)).FnSrc)+U32(nExtra) > (*SrcList)(unsafe.Pointer(pSrc)).FnAlloc {
  72512 		var pNew uintptr
  72513 		var nAlloc Sqlite3_int64 = int64(2)*Sqlite3_int64((*SrcList)(unsafe.Pointer(pSrc)).FnSrc) + Sqlite3_int64(nExtra)
  72514 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72515 
  72516 		if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc+nExtra >= SQLITE_MAX_SRCLIST {
  72517 			Xsqlite3ErrorMsg(tls, pParse, ts+14422,
  72518 				libc.VaList(bp, SQLITE_MAX_SRCLIST))
  72519 			return uintptr(0)
  72520 		}
  72521 		if nAlloc > int64(SQLITE_MAX_SRCLIST) {
  72522 			nAlloc = int64(SQLITE_MAX_SRCLIST)
  72523 		}
  72524 		pNew = Xsqlite3DbRealloc(tls, db, pSrc,
  72525 			uint64(Sqlite3_int64(unsafe.Sizeof(SrcList{}))+(nAlloc-int64(1))*Sqlite3_int64(unsafe.Sizeof(SrcItem{}))))
  72526 		if pNew == uintptr(0) {
  72527 			return uintptr(0)
  72528 		}
  72529 		pSrc = pNew
  72530 		(*SrcList)(unsafe.Pointer(pSrc)).FnAlloc = U32(nAlloc)
  72531 	}
  72532 
  72533 	for i = (*SrcList)(unsafe.Pointer(pSrc)).FnSrc - 1; i >= iStart; i-- {
  72534 		*(*SrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+nExtra)*72)) = *(*SrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72))
  72535 	}
  72536 	*(*int32)(unsafe.Pointer(pSrc)) += nExtra
  72537 
  72538 	libc.Xmemset(tls, pSrc+8+uintptr(iStart)*72, 0, uint32(unsafe.Sizeof(SrcItem{}))*uint32(nExtra))
  72539 	for i = iStart; i < iStart+nExtra; i++ {
  72540 		(*SrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72)).FiCursor = -1
  72541 	}
  72542 
  72543 	return pSrc
  72544 }
  72545 
  72546 // Append a new table name to the given SrcList.  Create a new SrcList if
  72547 // need be.  A new entry is created in the SrcList even if pTable is NULL.
  72548 //
  72549 // A SrcList is returned, or NULL if there is an OOM error or if the
  72550 // SrcList grows to large.  The returned
  72551 // SrcList might be the same as the SrcList that was input or it might be
  72552 // a new one.  If an OOM error does occurs, then the prior value of pList
  72553 // that is input to this routine is automatically freed.
  72554 //
  72555 // If pDatabase is not null, it means that the table has an optional
  72556 // database name prefix.  Like this:  "database.table".  The pDatabase
  72557 // points to the table name and the pTable points to the database name.
  72558 // The SrcList.a[].zName field is filled with the table name which might
  72559 // come from pTable (if pDatabase is NULL) or from pDatabase.
  72560 // SrcList.a[].zDatabase is filled with the database name from pTable,
  72561 // or with NULL if no database is specified.
  72562 //
  72563 // In other words, if call like this:
  72564 //
  72565 //	sqlite3SrcListAppend(D,A,B,0);
  72566 //
  72567 // Then B is a table name and the database name is unspecified.  If called
  72568 // like this:
  72569 //
  72570 //	sqlite3SrcListAppend(D,A,B,C);
  72571 //
  72572 // Then C is the table name and B is the database name.  If C is defined
  72573 // then so is B.  In other words, we never have a case where:
  72574 //
  72575 //	sqlite3SrcListAppend(D,A,0,C);
  72576 //
  72577 // Both pTable and pDatabase are assumed to be quoted.  They are dequoted
  72578 // before being added to the SrcList.
  72579 func Xsqlite3SrcListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pTable uintptr, pDatabase uintptr) uintptr {
  72580 	var pItem uintptr
  72581 	var db uintptr
  72582 
  72583 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72584 	if pList == uintptr(0) {
  72585 		pList = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(SrcList{})))
  72586 		if pList == uintptr(0) {
  72587 			return uintptr(0)
  72588 		}
  72589 		(*SrcList)(unsafe.Pointer(pList)).FnAlloc = U32(1)
  72590 		(*SrcList)(unsafe.Pointer(pList)).FnSrc = 1
  72591 		libc.Xmemset(tls, pList+8, 0, uint32(unsafe.Sizeof(SrcItem{})))
  72592 		(*SrcItem)(unsafe.Pointer(pList + 8)).FiCursor = -1
  72593 	} else {
  72594 		var pNew uintptr = Xsqlite3SrcListEnlarge(tls, pParse, pList, 1, (*SrcList)(unsafe.Pointer(pList)).FnSrc)
  72595 		if pNew == uintptr(0) {
  72596 			Xsqlite3SrcListDelete(tls, db, pList)
  72597 			return uintptr(0)
  72598 		} else {
  72599 			pList = pNew
  72600 		}
  72601 	}
  72602 	pItem = pList + 8 + uintptr((*SrcList)(unsafe.Pointer(pList)).FnSrc-1)*72
  72603 	if pDatabase != 0 && (*Token)(unsafe.Pointer(pDatabase)).Fz == uintptr(0) {
  72604 		pDatabase = uintptr(0)
  72605 	}
  72606 	if pDatabase != 0 {
  72607 		(*SrcItem)(unsafe.Pointer(pItem)).FzName = Xsqlite3NameFromToken(tls, db, pDatabase)
  72608 		(*SrcItem)(unsafe.Pointer(pItem)).FzDatabase = Xsqlite3NameFromToken(tls, db, pTable)
  72609 	} else {
  72610 		(*SrcItem)(unsafe.Pointer(pItem)).FzName = Xsqlite3NameFromToken(tls, db, pTable)
  72611 		(*SrcItem)(unsafe.Pointer(pItem)).FzDatabase = uintptr(0)
  72612 	}
  72613 	return pList
  72614 }
  72615 
  72616 // Assign VdbeCursor index numbers to all tables in a SrcList
  72617 func Xsqlite3SrcListAssignCursors(tls *libc.TLS, pParse uintptr, pList uintptr) {
  72618 	var i int32
  72619 	var pItem uintptr
  72620 
  72621 	if pList != 0 {
  72622 		i = 0
  72623 		pItem = pList + 8
  72624 	__1:
  72625 		if !(i < (*SrcList)(unsafe.Pointer(pList)).FnSrc) {
  72626 			goto __3
  72627 		}
  72628 		{
  72629 			if (*SrcItem)(unsafe.Pointer(pItem)).FiCursor >= 0 {
  72630 				goto __2
  72631 			}
  72632 			(*SrcItem)(unsafe.Pointer(pItem)).FiCursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  72633 			if (*SrcItem)(unsafe.Pointer(pItem)).FpSelect != 0 {
  72634 				Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpSelect)).FpSrc)
  72635 			}
  72636 
  72637 		}
  72638 		goto __2
  72639 	__2:
  72640 		i++
  72641 		pItem += 72
  72642 		goto __1
  72643 		goto __3
  72644 	__3:
  72645 	}
  72646 }
  72647 
  72648 // Delete an entire SrcList including all its substructure.
  72649 func Xsqlite3SrcListDelete(tls *libc.TLS, db uintptr, pList uintptr) {
  72650 	var i int32
  72651 	var pItem uintptr
  72652 
  72653 	if pList == uintptr(0) {
  72654 		return
  72655 	}
  72656 	pItem = pList + 8
  72657 	i = 0
  72658 __1:
  72659 	if !(i < (*SrcList)(unsafe.Pointer(pList)).FnSrc) {
  72660 		goto __3
  72661 	}
  72662 	{
  72663 		if (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase != 0 {
  72664 			Xsqlite3DbNNFreeNN(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase)
  72665 		}
  72666 		if (*SrcItem)(unsafe.Pointer(pItem)).FzName != 0 {
  72667 			Xsqlite3DbNNFreeNN(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FzName)
  72668 		}
  72669 		if (*SrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 {
  72670 			Xsqlite3DbNNFreeNN(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FzAlias)
  72671 		}
  72672 		if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x2>>1)) != 0 {
  72673 			Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 64)))
  72674 		}
  72675 		if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x4>>2)) != 0 {
  72676 			Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 64)))
  72677 		}
  72678 		Xsqlite3DeleteTable(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FpTab)
  72679 		if (*SrcItem)(unsafe.Pointer(pItem)).FpSelect != 0 {
  72680 			Xsqlite3SelectDelete(tls, db, (*SrcItem)(unsafe.Pointer(pItem)).FpSelect)
  72681 		}
  72682 		if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x400>>10)) != 0 {
  72683 			Xsqlite3IdListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 48)))
  72684 		} else if *(*uintptr)(unsafe.Pointer(pItem + 48)) != 0 {
  72685 			Xsqlite3ExprDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 48)))
  72686 		}
  72687 
  72688 	}
  72689 	goto __2
  72690 __2:
  72691 	i++
  72692 	pItem += 72
  72693 	goto __1
  72694 	goto __3
  72695 __3:
  72696 	;
  72697 	Xsqlite3DbNNFreeNN(tls, db, pList)
  72698 }
  72699 
  72700 // This routine is called by the parser to add a new term to the
  72701 // end of a growing FROM clause.  The "p" parameter is the part of
  72702 // the FROM clause that has already been constructed.  "p" is NULL
  72703 // if this is the first term of the FROM clause.  pTable and pDatabase
  72704 // are the name of the table and database named in the FROM clause term.
  72705 // pDatabase is NULL if the database name qualifier is missing - the
  72706 // usual case.  If the term has an alias, then pAlias points to the
  72707 // alias token.  If the term is a subquery, then pSubquery is the
  72708 // SELECT statement that the subquery encodes.  The pTable and
  72709 // pDatabase parameters are NULL for subqueries.  The pOn and pUsing
  72710 // parameters are the content of the ON and USING clauses.
  72711 //
  72712 // Return a new SrcList which encodes is the FROM with the new
  72713 // term added.
  72714 func Xsqlite3SrcListAppendFromTerm(tls *libc.TLS, pParse uintptr, p uintptr, pTable uintptr, pDatabase uintptr, pAlias uintptr, pSubquery uintptr, pOnUsing uintptr) uintptr {
  72715 	bp := tls.Alloc(8)
  72716 	defer tls.Free(8)
  72717 
  72718 	var pItem uintptr
  72719 	var db uintptr
  72720 	var pToken uintptr
  72721 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72722 	if !(!(p != 0) && pOnUsing != uintptr(0) && ((*OnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn != 0 || (*OnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing != 0)) {
  72723 		goto __1
  72724 	}
  72725 	Xsqlite3ErrorMsg(tls, pParse, ts+14458,
  72726 		libc.VaList(bp, func() uintptr {
  72727 			if (*OnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn != 0 {
  72728 				return ts + 14494
  72729 			}
  72730 			return ts + 14497
  72731 		}()))
  72732 	goto append_from_error
  72733 __1:
  72734 	;
  72735 	p = Xsqlite3SrcListAppend(tls, pParse, p, pTable, pDatabase)
  72736 	if !(p == uintptr(0)) {
  72737 		goto __2
  72738 	}
  72739 	goto append_from_error
  72740 __2:
  72741 	;
  72742 	pItem = p + 8 + uintptr((*SrcList)(unsafe.Pointer(p)).FnSrc-1)*72
  72743 
  72744 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && (*SrcItem)(unsafe.Pointer(pItem)).FzName != 0) {
  72745 		goto __3
  72746 	}
  72747 	if pDatabase != 0 && (*Token)(unsafe.Pointer(pDatabase)).Fz != 0 {
  72748 		pToken = pDatabase
  72749 	} else {
  72750 		pToken = pTable
  72751 	}
  72752 	Xsqlite3RenameTokenMap(tls, pParse, (*SrcItem)(unsafe.Pointer(pItem)).FzName, pToken)
  72753 __3:
  72754 	;
  72755 	if !((*Token)(unsafe.Pointer(pAlias)).Fn != 0) {
  72756 		goto __4
  72757 	}
  72758 	(*SrcItem)(unsafe.Pointer(pItem)).FzAlias = Xsqlite3NameFromToken(tls, db, pAlias)
  72759 __4:
  72760 	;
  72761 	if !(pSubquery != 0) {
  72762 		goto __5
  72763 	}
  72764 	(*SrcItem)(unsafe.Pointer(pItem)).FpSelect = pSubquery
  72765 	if !((*Select)(unsafe.Pointer(pSubquery)).FselFlags&U32(SF_NestedFrom) != 0) {
  72766 		goto __6
  72767 	}
  72768 	libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 13, 0x2000)
  72769 __6:
  72770 	;
  72771 __5:
  72772 	;
  72773 	if !(pOnUsing == uintptr(0)) {
  72774 		goto __7
  72775 	}
  72776 	*(*uintptr)(unsafe.Pointer(pItem + 48)) = uintptr(0)
  72777 	goto __8
  72778 __7:
  72779 	if !((*OnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing != 0) {
  72780 		goto __9
  72781 	}
  72782 	libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 10, 0x400)
  72783 	*(*uintptr)(unsafe.Pointer(pItem + 48)) = (*OnOrUsing)(unsafe.Pointer(pOnUsing)).FpUsing
  72784 	goto __10
  72785 __9:
  72786 	*(*uintptr)(unsafe.Pointer(pItem + 48)) = (*OnOrUsing)(unsafe.Pointer(pOnUsing)).FpOn
  72787 __10:
  72788 	;
  72789 __8:
  72790 	;
  72791 	return p
  72792 
  72793 append_from_error:
  72794 	;
  72795 	Xsqlite3ClearOnOrUsing(tls, db, pOnUsing)
  72796 	Xsqlite3SelectDelete(tls, db, pSubquery)
  72797 	return uintptr(0)
  72798 }
  72799 
  72800 // Add an INDEXED BY or NOT INDEXED clause to the most recently added
  72801 // element of the source-list passed as the second argument.
  72802 func Xsqlite3SrcListIndexedBy(tls *libc.TLS, pParse uintptr, p uintptr, pIndexedBy uintptr) {
  72803 	if p != 0 && (*Token)(unsafe.Pointer(pIndexedBy)).Fn > uint32(0) {
  72804 		var pItem uintptr
  72805 
  72806 		pItem = p + 8 + uintptr((*SrcList)(unsafe.Pointer(p)).FnSrc-1)*72
  72807 
  72808 		if (*Token)(unsafe.Pointer(pIndexedBy)).Fn == uint32(1) && !(int32((*Token)(unsafe.Pointer(pIndexedBy)).Fz) != 0) {
  72809 			libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 0, 0x1)
  72810 		} else {
  72811 			*(*uintptr)(unsafe.Pointer(pItem + 64)) = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIndexedBy)
  72812 			libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 1, 0x2)
  72813 
  72814 		}
  72815 	}
  72816 }
  72817 
  72818 // Append the contents of SrcList p2 to SrcList p1 and return the resulting
  72819 // SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
  72820 // are deleted by this function.
  72821 func Xsqlite3SrcListAppendList(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr) uintptr {
  72822 	if p2 != 0 {
  72823 		var pNew uintptr = Xsqlite3SrcListEnlarge(tls, pParse, p1, (*SrcList)(unsafe.Pointer(p2)).FnSrc, 1)
  72824 		if pNew == uintptr(0) {
  72825 			Xsqlite3SrcListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p2)
  72826 		} else {
  72827 			p1 = pNew
  72828 			libc.Xmemcpy(tls, p1+8+1*72, p2+8, uint32((*SrcList)(unsafe.Pointer(p2)).FnSrc)*uint32(unsafe.Sizeof(SrcItem{})))
  72829 			Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p2)
  72830 			*(*U8)(unsafe.Pointer(p1 + 8 + 36)) |= U8(JT_LTORJ & int32((*SrcItem)(unsafe.Pointer(p1+8+1*72)).Ffg.Fjointype))
  72831 		}
  72832 	}
  72833 	return p1
  72834 }
  72835 
  72836 // Add the list of function arguments to the SrcList entry for a
  72837 // table-valued-function.
  72838 func Xsqlite3SrcListFuncArgs(tls *libc.TLS, pParse uintptr, p uintptr, pList uintptr) {
  72839 	if p != 0 {
  72840 		var pItem uintptr = p + 8 + uintptr((*SrcList)(unsafe.Pointer(p)).FnSrc-1)*72
  72841 
  72842 		*(*uintptr)(unsafe.Pointer(pItem + 64)) = pList
  72843 		libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 2, 0x4)
  72844 	} else {
  72845 		Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList)
  72846 	}
  72847 }
  72848 
  72849 // When building up a FROM clause in the parser, the join operator
  72850 // is initially attached to the left operand.  But the code generator
  72851 // expects the join operator to be on the right operand.  This routine
  72852 // Shifts all join operators from left to right for an entire FROM
  72853 // clause.
  72854 //
  72855 // Example: Suppose the join is like this:
  72856 //
  72857 //	A natural cross join B
  72858 //
  72859 // The operator is "natural cross join".  The A and B operands are stored
  72860 // in p->a[0] and p->a[1], respectively.  The parser initially stores the
  72861 // operator with A.  This routine shifts that operator over to B.
  72862 //
  72863 // Additional changes:
  72864 //
  72865 //   - All tables to the left of the right-most RIGHT JOIN are tagged with
  72866 //     JT_LTORJ (mnemonic: Left Table Of Right Join) so that the
  72867 //     code generator can easily tell that the table is part of
  72868 //     the left operand of at least one RIGHT JOIN.
  72869 func Xsqlite3SrcListShiftJoinType(tls *libc.TLS, pParse uintptr, p uintptr) {
  72870 	_ = pParse
  72871 	if p != 0 && (*SrcList)(unsafe.Pointer(p)).FnSrc > 1 {
  72872 		var i int32 = (*SrcList)(unsafe.Pointer(p)).FnSrc - 1
  72873 		var allFlags U8 = U8(0)
  72874 		for __ccgo := true; __ccgo; __ccgo = libc.PreDecInt32(&i, 1) > 0 {
  72875 			allFlags = U8(int32(allFlags) | int32(libc.AssignPtrUint8(p+8+uintptr(i)*72+36, (*SrcItem)(unsafe.Pointer(p+8+uintptr(i-1)*72)).Ffg.Fjointype)))
  72876 		}
  72877 		(*SrcItem)(unsafe.Pointer(p + 8)).Ffg.Fjointype = U8(0)
  72878 
  72879 		if int32(allFlags)&JT_RIGHT != 0 {
  72880 			for i = (*SrcList)(unsafe.Pointer(p)).FnSrc - 1; i > 0 && int32((*SrcItem)(unsafe.Pointer(p+8+uintptr(i)*72)).Ffg.Fjointype)&JT_RIGHT == 0; i-- {
  72881 			}
  72882 			i--
  72883 
  72884 			for __ccgo1 := true; __ccgo1; __ccgo1 = libc.PreDecInt32(&i, 1) >= 0 {
  72885 				*(*U8)(unsafe.Pointer(p + 8 + uintptr(i)*72 + 36)) |= U8(JT_LTORJ)
  72886 			}
  72887 		}
  72888 	}
  72889 }
  72890 
  72891 // Generate VDBE code for a BEGIN statement.
  72892 func Xsqlite3BeginTransaction(tls *libc.TLS, pParse uintptr, type1 int32) {
  72893 	var db uintptr
  72894 	var v uintptr
  72895 	var i int32
  72896 
  72897 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72898 
  72899 	if Xsqlite3AuthCheck(tls, pParse, SQLITE_TRANSACTION, ts+14503, uintptr(0), uintptr(0)) != 0 {
  72900 		return
  72901 	}
  72902 	v = Xsqlite3GetVdbe(tls, pParse)
  72903 	if !(v != 0) {
  72904 		return
  72905 	}
  72906 	if type1 != TK_DEFERRED {
  72907 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  72908 			var eTxnType int32
  72909 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  72910 			if pBt != 0 && Xsqlite3BtreeIsReadonly(tls, pBt) != 0 {
  72911 				eTxnType = 0
  72912 			} else if type1 == TK_EXCLUSIVE {
  72913 				eTxnType = 2
  72914 			} else {
  72915 				eTxnType = 1
  72916 			}
  72917 			Xsqlite3VdbeAddOp2(tls, v, OP_Transaction, i, eTxnType)
  72918 			Xsqlite3VdbeUsesBtree(tls, v, i)
  72919 		}
  72920 	}
  72921 	Xsqlite3VdbeAddOp0(tls, v, OP_AutoCommit)
  72922 }
  72923 
  72924 // Generate VDBE code for a COMMIT or ROLLBACK statement.
  72925 // Code for ROLLBACK is generated if eType==TK_ROLLBACK.  Otherwise
  72926 // code is generated for a COMMIT.
  72927 func Xsqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) {
  72928 	var v uintptr
  72929 	var isRollback int32
  72930 
  72931 	isRollback = libc.Bool32(eType == TK_ROLLBACK)
  72932 	if Xsqlite3AuthCheck(tls, pParse, SQLITE_TRANSACTION,
  72933 		func() uintptr {
  72934 			if isRollback != 0 {
  72935 				return ts + 14509
  72936 			}
  72937 			return ts + 14518
  72938 		}(), uintptr(0), uintptr(0)) != 0 {
  72939 		return
  72940 	}
  72941 	v = Xsqlite3GetVdbe(tls, pParse)
  72942 	if v != 0 {
  72943 		Xsqlite3VdbeAddOp2(tls, v, OP_AutoCommit, 1, isRollback)
  72944 	}
  72945 }
  72946 
  72947 // This function is called by the parser when it parses a command to create,
  72948 // release or rollback an SQL savepoint.
  72949 func Xsqlite3Savepoint(tls *libc.TLS, pParse uintptr, op int32, pName uintptr) {
  72950 	var zName uintptr = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pName)
  72951 	if zName != 0 {
  72952 		var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  72953 
  72954 		if !(v != 0) || Xsqlite3AuthCheck(tls, pParse, SQLITE_SAVEPOINT, az[op], zName, uintptr(0)) != 0 {
  72955 			Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zName)
  72956 			return
  72957 		}
  72958 		Xsqlite3VdbeAddOp4(tls, v, OP_Savepoint, op, 0, 0, zName, -6)
  72959 	}
  72960 }
  72961 
  72962 var az = [3]uintptr{ts + 14503, ts + 14525, ts + 14509}
  72963 
  72964 // Make sure the TEMP database is open and available for use.  Return
  72965 // the number of errors.  Leave any error messages in the pParse structure.
  72966 func Xsqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) int32 {
  72967 	bp := tls.Alloc(4)
  72968 	defer tls.Free(4)
  72969 
  72970 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  72971 	if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpBt == uintptr(0) && !(int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) != 0) {
  72972 		var rc int32
  72973 
  72974 		rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, bp, 0, flags)
  72975 		if rc != SQLITE_OK {
  72976 			Xsqlite3ErrorMsg(tls, pParse,
  72977 				ts+14533, 0)
  72978 			(*Parse)(unsafe.Pointer(pParse)).Frc = rc
  72979 			return 1
  72980 		}
  72981 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FpBt = *(*uintptr)(unsafe.Pointer(bp))
  72982 
  72983 		if SQLITE_NOMEM == Xsqlite3BtreeSetPageSize(tls, *(*uintptr)(unsafe.Pointer(bp)), (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) {
  72984 			Xsqlite3OomFault(tls, db)
  72985 			return 1
  72986 		}
  72987 	}
  72988 	return 0
  72989 }
  72990 
  72991 var flags int32 = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_DB
  72992 
  72993 func sqlite3CodeVerifySchemaAtToplevel(tls *libc.TLS, pToplevel uintptr, iDb int32) {
  72994 	if libc.Bool32((*Parse)(unsafe.Pointer(pToplevel)).FcookieMask&(YDbMask(1)<<iDb) != YDbMask(0)) == 0 {
  72995 		*(*YDbMask)(unsafe.Pointer(pToplevel + 88)) |= YDbMask(1) << iDb
  72996 		if !(0 != 0) && iDb == 1 {
  72997 			Xsqlite3OpenTempDatabase(tls, pToplevel)
  72998 		}
  72999 	}
  73000 }
  73001 
  73002 func Xsqlite3CodeVerifySchema(tls *libc.TLS, pParse uintptr, iDb int32) {
  73003 	sqlite3CodeVerifySchemaAtToplevel(tls, func() uintptr {
  73004 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  73005 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  73006 		}
  73007 		return pParse
  73008 	}(), iDb)
  73009 }
  73010 
  73011 // If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each
  73012 // attached database. Otherwise, invoke it for the database named zDb only.
  73013 func Xsqlite3CodeVerifyNamedSchema(tls *libc.TLS, pParse uintptr, zDb uintptr) {
  73014 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73015 	var i int32
  73016 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
  73017 		var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16
  73018 		if (*Db)(unsafe.Pointer(pDb)).FpBt != 0 && (!(zDb != 0) || 0 == Xsqlite3StrICmp(tls, zDb, (*Db)(unsafe.Pointer(pDb)).FzDbSName)) {
  73019 			Xsqlite3CodeVerifySchema(tls, pParse, i)
  73020 		}
  73021 	}
  73022 }
  73023 
  73024 // Generate VDBE code that prepares for doing an operation that
  73025 // might change the database.
  73026 //
  73027 // This routine starts a new transaction if we are not already within
  73028 // a transaction.  If we are already within a transaction, then a checkpoint
  73029 // is set if the setStatement parameter is true.  A checkpoint should
  73030 // be set for operations that might fail (due to a constraint) part of
  73031 // the way through and which will need to undo some writes without having to
  73032 // rollback the whole transaction.  For operations where all constraints
  73033 // can be checked before any changes are made to the database, it is never
  73034 // necessary to undo a write and the checkpoint should not be set.
  73035 func Xsqlite3BeginWriteOperation(tls *libc.TLS, pParse uintptr, setStatement int32, iDb int32) {
  73036 	var pToplevel uintptr = func() uintptr {
  73037 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  73038 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  73039 		}
  73040 		return pParse
  73041 	}()
  73042 	sqlite3CodeVerifySchemaAtToplevel(tls, pToplevel, iDb)
  73043 	*(*YDbMask)(unsafe.Pointer(pToplevel + 84)) |= YDbMask(1) << iDb
  73044 	*(*U8)(unsafe.Pointer(pToplevel + 20)) |= U8(setStatement)
  73045 }
  73046 
  73047 // Indicate that the statement currently under construction might write
  73048 // more than one entry (example: deleting one row then inserting another,
  73049 // inserting multiple rows in a table, or inserting a row and index entries.)
  73050 // If an abort occurs after some of these writes have completed, then it will
  73051 // be necessary to undo the completed writes.
  73052 func Xsqlite3MultiWrite(tls *libc.TLS, pParse uintptr) {
  73053 	var pToplevel uintptr = func() uintptr {
  73054 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  73055 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  73056 		}
  73057 		return pParse
  73058 	}()
  73059 	(*Parse)(unsafe.Pointer(pToplevel)).FisMultiWrite = U8(1)
  73060 }
  73061 
  73062 // The code generator calls this routine if is discovers that it is
  73063 // possible to abort a statement prior to completion.  In order to
  73064 // perform this abort without corrupting the database, we need to make
  73065 // sure that the statement is protected by a statement transaction.
  73066 //
  73067 // Technically, we only need to set the mayAbort flag if the
  73068 // isMultiWrite flag was previously set.  There is a time dependency
  73069 // such that the abort must occur after the multiwrite.  This makes
  73070 // some statements involving the REPLACE conflict resolution algorithm
  73071 // go a little faster.  But taking advantage of this time dependency
  73072 // makes it more difficult to prove that the code is correct (in
  73073 // particular, it prevents us from writing an effective
  73074 // implementation of sqlite3AssertMayAbort()) and so we have chosen
  73075 // to take the safe route and skip the optimization.
  73076 func Xsqlite3MayAbort(tls *libc.TLS, pParse uintptr) {
  73077 	var pToplevel uintptr = func() uintptr {
  73078 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  73079 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  73080 		}
  73081 		return pParse
  73082 	}()
  73083 	(*Parse)(unsafe.Pointer(pToplevel)).FmayAbort = U8(1)
  73084 }
  73085 
  73086 // Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT
  73087 // error. The onError parameter determines which (if any) of the statement
  73088 // and/or current transaction is rolled back.
  73089 func Xsqlite3HaltConstraint(tls *libc.TLS, pParse uintptr, errCode int32, onError int32, p4 uintptr, p4type I8, p5Errmsg U8) {
  73090 	var v uintptr
  73091 
  73092 	v = Xsqlite3GetVdbe(tls, pParse)
  73093 
  73094 	if onError == OE_Abort {
  73095 		Xsqlite3MayAbort(tls, pParse)
  73096 	}
  73097 	Xsqlite3VdbeAddOp4(tls, v, OP_Halt, errCode, onError, 0, p4, int32(p4type))
  73098 	Xsqlite3VdbeChangeP5(tls, v, uint16(p5Errmsg))
  73099 }
  73100 
  73101 // Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation.
  73102 func Xsqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx uintptr) {
  73103 	bp := tls.Alloc(32)
  73104 	defer tls.Free(32)
  73105 
  73106 	var zErr uintptr
  73107 	var j int32
  73108 
  73109 	var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable
  73110 
  73111 	Xsqlite3StrAccumInit(tls, bp+8, (*Parse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), 0,
  73112 		*(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb + 120)))
  73113 	if (*Index)(unsafe.Pointer(pIdx)).FaColExpr != 0 {
  73114 		Xsqlite3_str_appendf(tls, bp+8, ts+14603, libc.VaList(bp, (*Index)(unsafe.Pointer(pIdx)).FzName))
  73115 	} else {
  73116 		for j = 0; j < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); j++ {
  73117 			var zCol uintptr
  73118 
  73119 			zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)))*16)).FzCnName
  73120 			if j != 0 {
  73121 				Xsqlite3_str_append(tls, bp+8, ts+14614, 2)
  73122 			}
  73123 			Xsqlite3_str_appendall(tls, bp+8, (*Table)(unsafe.Pointer(pTab)).FzName)
  73124 			Xsqlite3_str_append(tls, bp+8, ts+1567, 1)
  73125 			Xsqlite3_str_appendall(tls, bp+8, zCol)
  73126 		}
  73127 	}
  73128 	zErr = Xsqlite3StrAccumFinish(tls, bp+8)
  73129 	Xsqlite3HaltConstraint(tls, pParse,
  73130 		func() int32 {
  73131 			if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  73132 				return SQLITE_CONSTRAINT | int32(6)<<8
  73133 			}
  73134 			return SQLITE_CONSTRAINT | int32(8)<<8
  73135 		}(),
  73136 		onError, zErr, int8(-6), uint8(P5_ConstraintUnique))
  73137 }
  73138 
  73139 // Code an OP_Halt due to non-unique rowid.
  73140 func Xsqlite3RowidConstraint(tls *libc.TLS, pParse uintptr, onError int32, pTab uintptr) {
  73141 	bp := tls.Alloc(24)
  73142 	defer tls.Free(24)
  73143 
  73144 	var zMsg uintptr
  73145 	var rc int32
  73146 	if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) >= 0 {
  73147 		zMsg = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+12061, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName,
  73148 			(*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*16)).FzCnName))
  73149 		rc = SQLITE_CONSTRAINT | int32(6)<<8
  73150 	} else {
  73151 		zMsg = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+14617, libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName))
  73152 		rc = SQLITE_CONSTRAINT | int32(10)<<8
  73153 	}
  73154 	Xsqlite3HaltConstraint(tls, pParse, rc, onError, zMsg, int8(-6),
  73155 		uint8(P5_ConstraintUnique))
  73156 }
  73157 
  73158 func collationMatch(tls *libc.TLS, zColl uintptr, pIndex uintptr) int32 {
  73159 	var i int32
  73160 
  73161 	for i = 0; i < int32((*Index)(unsafe.Pointer(pIndex)).FnColumn); i++ {
  73162 		var z uintptr = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*4))
  73163 
  73164 		if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2))) >= 0 && 0 == Xsqlite3StrICmp(tls, z, zColl) {
  73165 			return 1
  73166 		}
  73167 	}
  73168 	return 0
  73169 }
  73170 
  73171 func reindexTable(tls *libc.TLS, pParse uintptr, pTab uintptr, zColl uintptr) {
  73172 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  73173 		var pIndex uintptr
  73174 
  73175 		for pIndex = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIndex != 0; pIndex = (*Index)(unsafe.Pointer(pIndex)).FpNext {
  73176 			if zColl == uintptr(0) || collationMatch(tls, zColl, pIndex) != 0 {
  73177 				var iDb int32 = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  73178 				Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  73179 				sqlite3RefillIndex(tls, pParse, pIndex, -1)
  73180 			}
  73181 		}
  73182 	}
  73183 }
  73184 
  73185 func reindexDatabases(tls *libc.TLS, pParse uintptr, zColl uintptr) {
  73186 	var pDb uintptr
  73187 	var iDb int32
  73188 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73189 	var k uintptr
  73190 	var pTab uintptr
  73191 
  73192 	iDb = 0
  73193 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb
  73194 __1:
  73195 	if !(iDb < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  73196 		goto __3
  73197 	}
  73198 	{
  73199 		for k = (*Hash)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema + 8)).Ffirst; k != 0; k = (*HashElem)(unsafe.Pointer(k)).Fnext {
  73200 			pTab = (*HashElem)(unsafe.Pointer(k)).Fdata
  73201 			reindexTable(tls, pParse, pTab, zColl)
  73202 		}
  73203 
  73204 	}
  73205 	goto __2
  73206 __2:
  73207 	iDb++
  73208 	pDb += 16
  73209 	goto __1
  73210 	goto __3
  73211 __3:
  73212 }
  73213 
  73214 // Generate code for the REINDEX command.
  73215 //
  73216 //	REINDEX                            -- 1
  73217 //	REINDEX  <collation>               -- 2
  73218 //	REINDEX  ?<database>.?<tablename>  -- 3
  73219 //	REINDEX  ?<database>.?<indexname>  -- 4
  73220 //
  73221 // Form 1 causes all indices in all attached databases to be rebuilt.
  73222 // Form 2 rebuilds all indices in all databases that use the named
  73223 // collating function.  Forms 3 and 4 rebuild the named index or all
  73224 // indices associated with the named table.
  73225 func Xsqlite3Reindex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr) {
  73226 	bp := tls.Alloc(4)
  73227 	defer tls.Free(4)
  73228 
  73229 	var pColl uintptr
  73230 	var z uintptr
  73231 	var zDb uintptr
  73232 	var pTab uintptr
  73233 	var pIndex uintptr
  73234 	var iDb int32
  73235 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73236 
  73237 	if SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) {
  73238 		return
  73239 	}
  73240 
  73241 	if pName1 == uintptr(0) {
  73242 		reindexDatabases(tls, pParse, uintptr(0))
  73243 		return
  73244 	} else if pName2 == uintptr(0) || (*Token)(unsafe.Pointer(pName2)).Fz == uintptr(0) {
  73245 		var zColl uintptr
  73246 
  73247 		zColl = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pName1)
  73248 		if !(zColl != 0) {
  73249 			return
  73250 		}
  73251 		pColl = Xsqlite3FindCollSeq(tls, db, (*Sqlite3)(unsafe.Pointer(db)).Fenc, zColl, 0)
  73252 		if pColl != 0 {
  73253 			reindexDatabases(tls, pParse, zColl)
  73254 			Xsqlite3DbFree(tls, db, zColl)
  73255 			return
  73256 		}
  73257 		Xsqlite3DbFree(tls, db, zColl)
  73258 	}
  73259 	iDb = Xsqlite3TwoPartName(tls, pParse, pName1, pName2, bp)
  73260 	if iDb < 0 {
  73261 		return
  73262 	}
  73263 	z = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp)))
  73264 	if z == uintptr(0) {
  73265 		return
  73266 	}
  73267 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  73268 	pTab = Xsqlite3FindTable(tls, db, z, zDb)
  73269 	if pTab != 0 {
  73270 		reindexTable(tls, pParse, pTab, uintptr(0))
  73271 		Xsqlite3DbFree(tls, db, z)
  73272 		return
  73273 	}
  73274 	pIndex = Xsqlite3FindIndex(tls, db, z, zDb)
  73275 	Xsqlite3DbFree(tls, db, z)
  73276 	if pIndex != 0 {
  73277 		Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  73278 		sqlite3RefillIndex(tls, pParse, pIndex, -1)
  73279 		return
  73280 	}
  73281 	Xsqlite3ErrorMsg(tls, pParse, ts+14626, 0)
  73282 }
  73283 
  73284 // Return a KeyInfo structure that is appropriate for the given Index.
  73285 //
  73286 // The caller should invoke sqlite3KeyInfoUnref() on the returned object
  73287 // when it has finished using it.
  73288 func Xsqlite3KeyInfoOfIndex(tls *libc.TLS, pParse uintptr, pIdx uintptr) uintptr {
  73289 	var i int32
  73290 	var nCol int32 = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  73291 	var nKey int32 = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  73292 	var pKey uintptr
  73293 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  73294 		return uintptr(0)
  73295 	}
  73296 	if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x8>>3)) != 0 {
  73297 		pKey = Xsqlite3KeyInfoAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, nKey, nCol-nKey)
  73298 	} else {
  73299 		pKey = Xsqlite3KeyInfoAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, nCol, 0)
  73300 	}
  73301 	if pKey != 0 {
  73302 		for i = 0; i < nCol; i++ {
  73303 			var zColl uintptr = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*4))
  73304 			*(*uintptr)(unsafe.Pointer(pKey + 20 + uintptr(i)*4)) = func() uintptr {
  73305 				if zColl == uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)) {
  73306 					return uintptr(0)
  73307 				}
  73308 				return Xsqlite3LocateCollSeq(tls, pParse, zColl)
  73309 			}()
  73310 			*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKey)).FaSortFlags + uintptr(i))) = *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i)))
  73311 
  73312 		}
  73313 		if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  73314 			if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x100>>8) == 0 {
  73315 				libc.SetBitFieldPtr16Uint32(pIdx+56, uint32(1), 8, 0x100)
  73316 				(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR | int32(2)<<8
  73317 			}
  73318 			Xsqlite3KeyInfoUnref(tls, pKey)
  73319 			pKey = uintptr(0)
  73320 		}
  73321 	}
  73322 	return pKey
  73323 }
  73324 
  73325 // Create a new CTE object
  73326 func Xsqlite3CteNew(tls *libc.TLS, pParse uintptr, pName uintptr, pArglist uintptr, pQuery uintptr, eM10d U8) uintptr {
  73327 	var pNew uintptr
  73328 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73329 
  73330 	pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Cte{})))
  73331 
  73332 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  73333 		Xsqlite3ExprListDelete(tls, db, pArglist)
  73334 		Xsqlite3SelectDelete(tls, db, pQuery)
  73335 	} else {
  73336 		(*Cte)(unsafe.Pointer(pNew)).FpSelect = pQuery
  73337 		(*Cte)(unsafe.Pointer(pNew)).FpCols = pArglist
  73338 		(*Cte)(unsafe.Pointer(pNew)).FzName = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pName)
  73339 		(*Cte)(unsafe.Pointer(pNew)).FeM10d = eM10d
  73340 	}
  73341 	return pNew
  73342 }
  73343 
  73344 func cteClear(tls *libc.TLS, db uintptr, pCte uintptr) {
  73345 	Xsqlite3ExprListDelete(tls, db, (*Cte)(unsafe.Pointer(pCte)).FpCols)
  73346 	Xsqlite3SelectDelete(tls, db, (*Cte)(unsafe.Pointer(pCte)).FpSelect)
  73347 	Xsqlite3DbFree(tls, db, (*Cte)(unsafe.Pointer(pCte)).FzName)
  73348 }
  73349 
  73350 // Free the contents of the CTE object passed as the second argument.
  73351 func Xsqlite3CteDelete(tls *libc.TLS, db uintptr, pCte uintptr) {
  73352 	cteClear(tls, db, pCte)
  73353 	Xsqlite3DbFree(tls, db, pCte)
  73354 }
  73355 
  73356 // This routine is invoked once per CTE by the parser while parsing a
  73357 // WITH clause.  The CTE described by teh third argument is added to
  73358 // the WITH clause of the second argument.  If the second argument is
  73359 // NULL, then a new WITH argument is created.
  73360 func Xsqlite3WithAdd(tls *libc.TLS, pParse uintptr, pWith uintptr, pCte uintptr) uintptr {
  73361 	bp := tls.Alloc(8)
  73362 	defer tls.Free(8)
  73363 
  73364 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73365 	var pNew uintptr
  73366 	var zName uintptr
  73367 
  73368 	if pCte == uintptr(0) {
  73369 		return pWith
  73370 	}
  73371 
  73372 	zName = (*Cte)(unsafe.Pointer(pCte)).FzName
  73373 	if zName != 0 && pWith != 0 {
  73374 		var i int32
  73375 		for i = 0; i < (*With)(unsafe.Pointer(pWith)).FnCte; i++ {
  73376 			if Xsqlite3StrICmp(tls, zName, (*Cte)(unsafe.Pointer(pWith+12+uintptr(i)*24)).FzName) == 0 {
  73377 				Xsqlite3ErrorMsg(tls, pParse, ts+14672, libc.VaList(bp, zName))
  73378 			}
  73379 		}
  73380 	}
  73381 
  73382 	if pWith != 0 {
  73383 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(With{})) + uint32(unsafe.Sizeof(Cte{}))*uint32((*With)(unsafe.Pointer(pWith)).FnCte))
  73384 		pNew = Xsqlite3DbRealloc(tls, db, pWith, uint64(nByte))
  73385 	} else {
  73386 		pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(With{})))
  73387 	}
  73388 
  73389 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  73390 		Xsqlite3CteDelete(tls, db, pCte)
  73391 		pNew = pWith
  73392 	} else {
  73393 		*(*Cte)(unsafe.Pointer(pNew + 12 + uintptr(libc.PostIncInt32(&(*With)(unsafe.Pointer(pNew)).FnCte, 1))*24)) = *(*Cte)(unsafe.Pointer(pCte))
  73394 		Xsqlite3DbFree(tls, db, pCte)
  73395 	}
  73396 
  73397 	return pNew
  73398 }
  73399 
  73400 // Free the contents of the With object passed as the second argument.
  73401 func Xsqlite3WithDelete(tls *libc.TLS, db uintptr, pWith uintptr) {
  73402 	if pWith != 0 {
  73403 		var i int32
  73404 		for i = 0; i < (*With)(unsafe.Pointer(pWith)).FnCte; i++ {
  73405 			cteClear(tls, db, pWith+12+uintptr(i)*24)
  73406 		}
  73407 		Xsqlite3DbFree(tls, db, pWith)
  73408 	}
  73409 }
  73410 
  73411 func callCollNeeded(tls *libc.TLS, db uintptr, enc int32, zName uintptr) {
  73412 	if (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded != 0 {
  73413 		var zExternal uintptr = Xsqlite3DbStrDup(tls, db, zName)
  73414 		if !(zExternal != 0) {
  73415 			return
  73416 		}
  73417 		(*struct {
  73418 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr)
  73419 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg, db, enc, zExternal)
  73420 		Xsqlite3DbFree(tls, db, zExternal)
  73421 	}
  73422 	if (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 != 0 {
  73423 		var zExternal uintptr
  73424 		var pTmp uintptr = Xsqlite3ValueNew(tls, db)
  73425 		Xsqlite3ValueSetStr(tls, pTmp, -1, zName, uint8(SQLITE_UTF8), uintptr(0))
  73426 		zExternal = Xsqlite3ValueText(tls, pTmp, uint8(SQLITE_UTF16LE))
  73427 		if zExternal != 0 {
  73428 			(*struct {
  73429 				f func(*libc.TLS, uintptr, uintptr, int32, uintptr)
  73430 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg, db, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc), zExternal)
  73431 		}
  73432 		Xsqlite3ValueFree(tls, pTmp)
  73433 	}
  73434 }
  73435 
  73436 func synthCollSeq(tls *libc.TLS, db uintptr, pColl uintptr) int32 {
  73437 	var pColl2 uintptr
  73438 	var z uintptr = (*CollSeq)(unsafe.Pointer(pColl)).FzName
  73439 	var i int32
  73440 	for i = 0; i < 3; i++ {
  73441 		pColl2 = Xsqlite3FindCollSeq(tls, db, aEnc[i], z, 0)
  73442 		if (*CollSeq)(unsafe.Pointer(pColl2)).FxCmp != uintptr(0) {
  73443 			libc.Xmemcpy(tls, pColl, pColl2, uint32(unsafe.Sizeof(CollSeq{})))
  73444 			(*CollSeq)(unsafe.Pointer(pColl)).FxDel = uintptr(0)
  73445 			return SQLITE_OK
  73446 		}
  73447 	}
  73448 	return SQLITE_ERROR
  73449 }
  73450 
  73451 var aEnc = [3]U8{U8(SQLITE_UTF16BE), U8(SQLITE_UTF16LE), U8(SQLITE_UTF8)}
  73452 
  73453 // This routine is called on a collation sequence before it is used to
  73454 // check that it is defined. An undefined collation sequence exists when
  73455 // a database is loaded that contains references to collation sequences
  73456 // that have not been defined by sqlite3_create_collation() etc.
  73457 //
  73458 // If required, this routine calls the 'collation needed' callback to
  73459 // request a definition of the collating sequence. If this doesn't work,
  73460 // an equivalent collating sequence that uses a text encoding different
  73461 // from the main database is substituted, if one is available.
  73462 func Xsqlite3CheckCollSeq(tls *libc.TLS, pParse uintptr, pColl uintptr) int32 {
  73463 	if pColl != 0 && (*CollSeq)(unsafe.Pointer(pColl)).FxCmp == uintptr(0) {
  73464 		var zName uintptr = (*CollSeq)(unsafe.Pointer(pColl)).FzName
  73465 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73466 		var p uintptr = Xsqlite3GetCollSeq(tls, pParse, (*Sqlite3)(unsafe.Pointer(db)).Fenc, pColl, zName)
  73467 		if !(p != 0) {
  73468 			return SQLITE_ERROR
  73469 		}
  73470 
  73471 	}
  73472 	return SQLITE_OK
  73473 }
  73474 
  73475 func findCollSeqEntry(tls *libc.TLS, db uintptr, zName uintptr, create int32) uintptr {
  73476 	var pColl uintptr
  73477 	pColl = Xsqlite3HashFind(tls, db+448, zName)
  73478 
  73479 	if uintptr(0) == pColl && create != 0 {
  73480 		var nName int32 = Xsqlite3Strlen30(tls, zName) + 1
  73481 		pColl = Xsqlite3DbMallocZero(tls, db, uint64(uint32(3)*uint32(unsafe.Sizeof(CollSeq{}))+uint32(nName)))
  73482 		if pColl != 0 {
  73483 			var pDel uintptr = uintptr(0)
  73484 			(*CollSeq)(unsafe.Pointer(pColl)).FzName = pColl + 3*20
  73485 			(*CollSeq)(unsafe.Pointer(pColl)).Fenc = U8(SQLITE_UTF8)
  73486 			(*CollSeq)(unsafe.Pointer(pColl + 1*20)).FzName = pColl + 3*20
  73487 			(*CollSeq)(unsafe.Pointer(pColl + 1*20)).Fenc = U8(SQLITE_UTF16LE)
  73488 			(*CollSeq)(unsafe.Pointer(pColl + 2*20)).FzName = pColl + 3*20
  73489 			(*CollSeq)(unsafe.Pointer(pColl + 2*20)).Fenc = U8(SQLITE_UTF16BE)
  73490 			libc.Xmemcpy(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, zName, uint32(nName))
  73491 			pDel = Xsqlite3HashInsert(tls, db+448, (*CollSeq)(unsafe.Pointer(pColl)).FzName, pColl)
  73492 
  73493 			if pDel != uintptr(0) {
  73494 				Xsqlite3OomFault(tls, db)
  73495 				Xsqlite3DbFree(tls, db, pDel)
  73496 				pColl = uintptr(0)
  73497 			}
  73498 		}
  73499 	}
  73500 	return pColl
  73501 }
  73502 
  73503 // Parameter zName points to a UTF-8 encoded string nName bytes long.
  73504 // Return the CollSeq* pointer for the collation sequence named zName
  73505 // for the encoding 'enc' from the database 'db'.
  73506 //
  73507 // If the entry specified is not found and 'create' is true, then create a
  73508 // new entry.  Otherwise return NULL.
  73509 //
  73510 // A separate function sqlite3LocateCollSeq() is a wrapper around
  73511 // this routine.  sqlite3LocateCollSeq() invokes the collation factory
  73512 // if necessary and generates an error message if the collating sequence
  73513 // cannot be found.
  73514 //
  73515 // See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()
  73516 func Xsqlite3FindCollSeq(tls *libc.TLS, db uintptr, enc U8, zName uintptr, create int32) uintptr {
  73517 	var pColl uintptr
  73518 
  73519 	if zName != 0 {
  73520 		pColl = findCollSeqEntry(tls, db, zName, create)
  73521 		if pColl != 0 {
  73522 			pColl += 20 * uintptr(int32(enc)-1)
  73523 		}
  73524 	} else {
  73525 		pColl = (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl
  73526 	}
  73527 	return pColl
  73528 }
  73529 
  73530 // Change the text encoding for a database connection. This means that
  73531 // the pDfltColl must change as well.
  73532 func Xsqlite3SetTextEncoding(tls *libc.TLS, db uintptr, enc U8) {
  73533 	(*Sqlite3)(unsafe.Pointer(db)).Fenc = enc
  73534 
  73535 	(*Sqlite3)(unsafe.Pointer(db)).FpDfltColl = Xsqlite3FindCollSeq(tls, db, enc, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), 0)
  73536 }
  73537 
  73538 // This function is responsible for invoking the collation factory callback
  73539 // or substituting a collation sequence of a different encoding when the
  73540 // requested collation sequence is not available in the desired encoding.
  73541 //
  73542 // If it is not NULL, then pColl must point to the database native encoding
  73543 // collation sequence with name zName, length nName.
  73544 //
  73545 // The return value is either the collation sequence to be used in database
  73546 // db for collation type name zName, length nName, or NULL, if no collation
  73547 // sequence can be found.  If no collation is found, leave an error message.
  73548 //
  73549 // See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
  73550 func Xsqlite3GetCollSeq(tls *libc.TLS, pParse uintptr, enc U8, pColl uintptr, zName uintptr) uintptr {
  73551 	bp := tls.Alloc(8)
  73552 	defer tls.Free(8)
  73553 
  73554 	var p uintptr
  73555 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73556 
  73557 	p = pColl
  73558 	if !(p != 0) {
  73559 		p = Xsqlite3FindCollSeq(tls, db, enc, zName, 0)
  73560 	}
  73561 	if !(p != 0) || !(int32((*CollSeq)(unsafe.Pointer(p)).FxCmp) != 0) {
  73562 		callCollNeeded(tls, db, int32(enc), zName)
  73563 		p = Xsqlite3FindCollSeq(tls, db, enc, zName, 0)
  73564 	}
  73565 	if p != 0 && !(int32((*CollSeq)(unsafe.Pointer(p)).FxCmp) != 0) && synthCollSeq(tls, db, p) != 0 {
  73566 		p = uintptr(0)
  73567 	}
  73568 
  73569 	if p == uintptr(0) {
  73570 		Xsqlite3ErrorMsg(tls, pParse, ts+14702, libc.VaList(bp, zName))
  73571 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR | int32(1)<<8
  73572 	}
  73573 	return p
  73574 }
  73575 
  73576 // This function returns the collation sequence for database native text
  73577 // encoding identified by the string zName.
  73578 //
  73579 // If the requested collation sequence is not available, or not available
  73580 // in the database native encoding, the collation factory is invoked to
  73581 // request it. If the collation factory does not supply such a sequence,
  73582 // and the sequence is available in another text encoding, then that is
  73583 // returned instead.
  73584 //
  73585 // If no versions of the requested collations sequence are available, or
  73586 // another error occurs, NULL is returned and an error message written into
  73587 // pParse.
  73588 //
  73589 // This routine is a wrapper around sqlite3FindCollSeq().  This routine
  73590 // invokes the collation factory if the named collation cannot be found
  73591 // and generates an error message.
  73592 //
  73593 // See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()
  73594 func Xsqlite3LocateCollSeq(tls *libc.TLS, pParse uintptr, zName uintptr) uintptr {
  73595 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73596 	var enc U8 = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  73597 	var initbusy U8 = (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy
  73598 	var pColl uintptr
  73599 
  73600 	pColl = Xsqlite3FindCollSeq(tls, db, enc, zName, int32(initbusy))
  73601 	if !(initbusy != 0) && (!(pColl != 0) || !(int32((*CollSeq)(unsafe.Pointer(pColl)).FxCmp) != 0)) {
  73602 		pColl = Xsqlite3GetCollSeq(tls, pParse, enc, pColl, zName)
  73603 	}
  73604 
  73605 	return pColl
  73606 }
  73607 
  73608 func matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc U8) int32 {
  73609 	var match int32
  73610 
  73611 	if int32((*FuncDef)(unsafe.Pointer(p)).FnArg) != nArg {
  73612 		if nArg == -2 {
  73613 			if (*FuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) {
  73614 				return 0
  73615 			}
  73616 			return FUNC_PERFECT_MATCH
  73617 		}
  73618 		if int32((*FuncDef)(unsafe.Pointer(p)).FnArg) >= 0 {
  73619 			return 0
  73620 		}
  73621 	}
  73622 
  73623 	if int32((*FuncDef)(unsafe.Pointer(p)).FnArg) == nArg {
  73624 		match = 4
  73625 	} else {
  73626 		match = 1
  73627 	}
  73628 
  73629 	if U32(enc) == (*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(SQLITE_FUNC_ENCMASK) {
  73630 		match = match + 2
  73631 	} else if U32(enc)&(*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(2) != U32(0) {
  73632 		match = match + 1
  73633 	}
  73634 
  73635 	return match
  73636 }
  73637 
  73638 // Search a FuncDefHash for a function with the given name.  Return
  73639 // a pointer to the matching FuncDef if found, or 0 if there is no match.
  73640 func Xsqlite3FunctionSearch(tls *libc.TLS, h int32, zFunc uintptr) uintptr {
  73641 	var p uintptr
  73642 	for p = *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)) + uintptr(h)*4)); p != 0; p = *(*uintptr)(unsafe.Pointer(p + 36)) {
  73643 		if Xsqlite3StrICmp(tls, (*FuncDef)(unsafe.Pointer(p)).FzName, zFunc) == 0 {
  73644 			return p
  73645 		}
  73646 	}
  73647 	return uintptr(0)
  73648 }
  73649 
  73650 // Insert a new FuncDef into a FuncDefHash hash table.
  73651 func Xsqlite3InsertBuiltinFuncs(tls *libc.TLS, aDef uintptr, nDef int32) {
  73652 	var i int32
  73653 	for i = 0; i < nDef; i++ {
  73654 		var pOther uintptr
  73655 		var zName uintptr = (*FuncDef)(unsafe.Pointer(aDef + uintptr(i)*40)).FzName
  73656 		var nName int32 = Xsqlite3Strlen30(tls, zName)
  73657 		var h int32 = (int32(*(*uint8)(unsafe.Pointer(zName))) + nName) % SQLITE_FUNC_HASH_SZ
  73658 
  73659 		pOther = Xsqlite3FunctionSearch(tls, h, zName)
  73660 		if pOther != 0 {
  73661 			(*FuncDef)(unsafe.Pointer(aDef + uintptr(i)*40)).FpNext = (*FuncDef)(unsafe.Pointer(pOther)).FpNext
  73662 			(*FuncDef)(unsafe.Pointer(pOther)).FpNext = aDef + uintptr(i)*40
  73663 		} else {
  73664 			(*FuncDef)(unsafe.Pointer(aDef + uintptr(i)*40)).FpNext = uintptr(0)
  73665 			*(*uintptr)(unsafe.Pointer(aDef + uintptr(i)*40 + 36)) = *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)) + uintptr(h)*4))
  73666 			*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)) + uintptr(h)*4)) = aDef + uintptr(i)*40
  73667 		}
  73668 	}
  73669 }
  73670 
  73671 // Locate a user function given a name, a number of arguments and a flag
  73672 // indicating whether the function prefers UTF-16 over UTF-8.  Return a
  73673 // pointer to the FuncDef structure that defines that function, or return
  73674 // NULL if the function does not exist.
  73675 //
  73676 // If the createFlag argument is true, then a new (blank) FuncDef
  73677 // structure is created and liked into the "db" structure if a
  73678 // no matching function previously existed.
  73679 //
  73680 // If nArg is -2, then the first valid function found is returned.  A
  73681 // function is valid if xSFunc is non-zero.  The nArg==(-2)
  73682 // case is used to see if zName is a valid function name for some number
  73683 // of arguments.  If nArg is -2, then createFlag must be 0.
  73684 //
  73685 // If createFlag is false, then a function with the required name and
  73686 // number of arguments may be returned even if the eTextRep flag does not
  73687 // match that requested.
  73688 func Xsqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, enc U8, createFlag U8) uintptr {
  73689 	var p uintptr
  73690 	var pBest uintptr = uintptr(0)
  73691 	var bestScore int32 = 0
  73692 	var h int32
  73693 	var nName int32
  73694 
  73695 	nName = Xsqlite3Strlen30(tls, zName)
  73696 
  73697 	p = Xsqlite3HashFind(tls, db+432, zName)
  73698 	for p != 0 {
  73699 		var score int32 = matchQuality(tls, p, nArg, enc)
  73700 		if score > bestScore {
  73701 			pBest = p
  73702 			bestScore = score
  73703 		}
  73704 		p = (*FuncDef)(unsafe.Pointer(p)).FpNext
  73705 	}
  73706 
  73707 	if !(createFlag != 0) && (pBest == uintptr(0) || (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_PreferBuiltin) != U32(0)) {
  73708 		bestScore = 0
  73709 		h = (int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(zName))]) + nName) % SQLITE_FUNC_HASH_SZ
  73710 		p = Xsqlite3FunctionSearch(tls, h, zName)
  73711 		for p != 0 {
  73712 			var score int32 = matchQuality(tls, p, nArg, enc)
  73713 			if score > bestScore {
  73714 				pBest = p
  73715 				bestScore = score
  73716 			}
  73717 			p = (*FuncDef)(unsafe.Pointer(p)).FpNext
  73718 		}
  73719 	}
  73720 
  73721 	if createFlag != 0 && bestScore < FUNC_PERFECT_MATCH && libc.AssignUintptr(&pBest, Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(FuncDef{}))+uint32(nName)+uint32(1)))) != uintptr(0) {
  73722 		var pOther uintptr
  73723 		var z uintptr
  73724 		(*FuncDef)(unsafe.Pointer(pBest)).FzName = pBest + 1*40
  73725 		(*FuncDef)(unsafe.Pointer(pBest)).FnArg = I8(U16(nArg))
  73726 		(*FuncDef)(unsafe.Pointer(pBest)).FfuncFlags = U32(enc)
  73727 		libc.Xmemcpy(tls, pBest+1*40, zName, uint32(nName+1))
  73728 		for z = (*FuncDef)(unsafe.Pointer(pBest)).FzName; *(*U8)(unsafe.Pointer(z)) != 0; z++ {
  73729 			*(*U8)(unsafe.Pointer(z)) = Xsqlite3UpperToLower[*(*U8)(unsafe.Pointer(z))]
  73730 		}
  73731 		pOther = Xsqlite3HashInsert(tls, db+432, (*FuncDef)(unsafe.Pointer(pBest)).FzName, pBest)
  73732 		if pOther == pBest {
  73733 			Xsqlite3DbFree(tls, db, pBest)
  73734 			Xsqlite3OomFault(tls, db)
  73735 			return uintptr(0)
  73736 		} else {
  73737 			(*FuncDef)(unsafe.Pointer(pBest)).FpNext = pOther
  73738 		}
  73739 	}
  73740 
  73741 	if pBest != 0 && ((*FuncDef)(unsafe.Pointer(pBest)).FxSFunc != 0 || createFlag != 0) {
  73742 		return pBest
  73743 	}
  73744 	return uintptr(0)
  73745 }
  73746 
  73747 // Free all resources held by the schema structure. The void* argument points
  73748 // at a Schema struct. This function does not call sqlite3DbFree(db, ) on the
  73749 // pointer itself, it just cleans up subsidiary resources (i.e. the contents
  73750 // of the schema hash tables).
  73751 //
  73752 // The Schema.cache_size variable is not cleared.
  73753 func Xsqlite3SchemaClear(tls *libc.TLS, p uintptr) {
  73754 	bp := tls.Alloc(600)
  73755 	defer tls.Free(600)
  73756 
  73757 	var pElem uintptr
  73758 	var pSchema uintptr = p
  73759 
  73760 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Sqlite3{})))
  73761 	*(*Hash)(unsafe.Pointer(bp + 584)) = (*Schema)(unsafe.Pointer(pSchema)).FtblHash
  73762 	*(*Hash)(unsafe.Pointer(bp + 568)) = (*Schema)(unsafe.Pointer(pSchema)).FtrigHash
  73763 	Xsqlite3HashInit(tls, pSchema+40)
  73764 	Xsqlite3HashClear(tls, pSchema+24)
  73765 	for pElem = (*Hash)(unsafe.Pointer(bp + 568)).Ffirst; pElem != 0; pElem = (*HashElem)(unsafe.Pointer(pElem)).Fnext {
  73766 		Xsqlite3DeleteTrigger(tls, bp, (*HashElem)(unsafe.Pointer(pElem)).Fdata)
  73767 	}
  73768 	Xsqlite3HashClear(tls, bp+568)
  73769 	Xsqlite3HashInit(tls, pSchema+8)
  73770 	for pElem = (*Hash)(unsafe.Pointer(bp + 584)).Ffirst; pElem != 0; pElem = (*HashElem)(unsafe.Pointer(pElem)).Fnext {
  73771 		var pTab uintptr = (*HashElem)(unsafe.Pointer(pElem)).Fdata
  73772 		Xsqlite3DeleteTable(tls, bp, pTab)
  73773 	}
  73774 	Xsqlite3HashClear(tls, bp+584)
  73775 	Xsqlite3HashClear(tls, pSchema+56)
  73776 	(*Schema)(unsafe.Pointer(pSchema)).FpSeqTab = uintptr(0)
  73777 	if int32((*Schema)(unsafe.Pointer(pSchema)).FschemaFlags)&DB_SchemaLoaded != 0 {
  73778 		(*Schema)(unsafe.Pointer(pSchema)).FiGeneration++
  73779 	}
  73780 	*(*U16)(unsafe.Pointer(pSchema + 78)) &= libc.Uint16FromInt32(libc.CplInt32(DB_SchemaLoaded | DB_ResetWanted))
  73781 }
  73782 
  73783 // Find and return the schema associated with a BTree.  Create
  73784 // a new one if necessary.
  73785 func Xsqlite3SchemaGet(tls *libc.TLS, db uintptr, pBt uintptr) uintptr {
  73786 	var p uintptr
  73787 	if pBt != 0 {
  73788 		p = Xsqlite3BtreeSchema(tls, pBt, int32(unsafe.Sizeof(Schema{})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3SchemaClear})))
  73789 	} else {
  73790 		p = Xsqlite3DbMallocZero(tls, uintptr(0), uint64(unsafe.Sizeof(Schema{})))
  73791 	}
  73792 	if !(p != 0) {
  73793 		Xsqlite3OomFault(tls, db)
  73794 	} else if 0 == int32((*Schema)(unsafe.Pointer(p)).Ffile_format) {
  73795 		Xsqlite3HashInit(tls, p+8)
  73796 		Xsqlite3HashInit(tls, p+24)
  73797 		Xsqlite3HashInit(tls, p+40)
  73798 		Xsqlite3HashInit(tls, p+56)
  73799 		(*Schema)(unsafe.Pointer(p)).Fenc = U8(SQLITE_UTF8)
  73800 	}
  73801 	return p
  73802 }
  73803 
  73804 // While a SrcList can in general represent multiple tables and subqueries
  73805 // (as in the FROM clause of a SELECT statement) in this case it contains
  73806 // the name of a single table, as one might find in an INSERT, DELETE,
  73807 // or UPDATE statement.  Look up that table in the symbol table and
  73808 // return a pointer.  Set an error message and return NULL if the table
  73809 // name is not found or if any other error occurs.
  73810 //
  73811 // The following fields are initialized appropriate in pSrc:
  73812 //
  73813 //	pSrc->a[0].pTab       Pointer to the Table object
  73814 //	pSrc->a[0].pIndex     Pointer to the INDEXED BY index, if there is one
  73815 func Xsqlite3SrcListLookup(tls *libc.TLS, pParse uintptr, pSrc uintptr) uintptr {
  73816 	var pItem uintptr = pSrc + 8
  73817 	var pTab uintptr
  73818 
  73819 	pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pItem)
  73820 	Xsqlite3DeleteTable(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*SrcItem)(unsafe.Pointer(pItem)).FpTab)
  73821 	(*SrcItem)(unsafe.Pointer(pItem)).FpTab = pTab
  73822 	if pTab != 0 {
  73823 		(*Table)(unsafe.Pointer(pTab)).FnTabRef++
  73824 		if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x2>>1)) != 0 && Xsqlite3IndexedByLookup(tls, pParse, pItem) != 0 {
  73825 			pTab = uintptr(0)
  73826 		}
  73827 	}
  73828 	return pTab
  73829 }
  73830 
  73831 // Generate byte-code that will report the number of rows modified
  73832 // by a DELETE, INSERT, or UPDATE statement.
  73833 func Xsqlite3CodeChangeCount(tls *libc.TLS, v uintptr, regCounter int32, zColName uintptr) {
  73834 	Xsqlite3VdbeAddOp0(tls, v, OP_FkCheck)
  73835 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regCounter, 1)
  73836 	Xsqlite3VdbeSetNumCols(tls, v, 1)
  73837 	Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, zColName, uintptr(0))
  73838 }
  73839 
  73840 func vtabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 {
  73841 	bp := tls.Alloc(8)
  73842 	defer tls.Free(8)
  73843 
  73844 	if (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpMod)).FpModule)).FxUpdate == uintptr(0) {
  73845 		return 1
  73846 	}
  73847 
  73848 	if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != uintptr(0) &&
  73849 		int32((*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)))).FeVtabRisk) > libc.Bool32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_TrustedSchema) != uint64(0)) {
  73850 		Xsqlite3ErrorMsg(tls, pParse, ts+14733,
  73851 			libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  73852 	}
  73853 	return 0
  73854 }
  73855 
  73856 func tabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 {
  73857 	var db uintptr
  73858 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  73859 		return vtabIsReadOnly(tls, pParse, pTab)
  73860 	}
  73861 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Readonly|TF_Shadow) == U32(0) {
  73862 		return 0
  73863 	}
  73864 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73865 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Readonly) != U32(0) {
  73866 		return libc.Bool32(Xsqlite3WritableSchema(tls, db) == 0 && int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0)
  73867 	}
  73868 
  73869 	return Xsqlite3ReadOnlyShadowTables(tls, db)
  73870 }
  73871 
  73872 // Check to make sure the given table is writable.
  73873 //
  73874 // If pTab is not writable  ->  generate an error message and return 1.
  73875 // If pTab is writable but other errors have occurred -> return 1.
  73876 // If pTab is writable and no prior errors -> return 0;
  73877 func Xsqlite3IsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr, viewOk int32) int32 {
  73878 	bp := tls.Alloc(16)
  73879 	defer tls.Free(16)
  73880 
  73881 	if tabIsReadOnly(tls, pParse, pTab) != 0 {
  73882 		Xsqlite3ErrorMsg(tls, pParse, ts+14766, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  73883 		return 1
  73884 	}
  73885 	if !(viewOk != 0) && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW {
  73886 		Xsqlite3ErrorMsg(tls, pParse, ts+14795, libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName))
  73887 		return 1
  73888 	}
  73889 	return 0
  73890 }
  73891 
  73892 // Evaluate a view and store its result in an ephemeral table.  The
  73893 // pWhere argument is an optional WHERE clause that restricts the
  73894 // set of rows in the view that are to be added to the ephemeral table.
  73895 func Xsqlite3MaterializeView(tls *libc.TLS, pParse uintptr, pView uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr, iCur int32) {
  73896 	bp := tls.Alloc(28)
  73897 	defer tls.Free(28)
  73898 
  73899 	var pSel uintptr
  73900 	var pFrom uintptr
  73901 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73902 	var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pView)).FpSchema)
  73903 	pWhere = Xsqlite3ExprDup(tls, db, pWhere, 0)
  73904 	pFrom = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0))
  73905 	if pFrom != 0 {
  73906 		(*SrcItem)(unsafe.Pointer(pFrom + 8)).FzName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pView)).FzName)
  73907 		(*SrcItem)(unsafe.Pointer(pFrom + 8)).FzDatabase = Xsqlite3DbStrDup(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName)
  73908 
  73909 	}
  73910 	pSel = Xsqlite3SelectNew(tls, pParse, uintptr(0), pFrom, pWhere, uintptr(0), uintptr(0), pOrderBy,
  73911 		uint32(SF_IncludeHidden), pLimit)
  73912 	Xsqlite3SelectDestInit(tls, bp, SRT_EphemTab, iCur)
  73913 	Xsqlite3Select(tls, pParse, pSel, bp)
  73914 	Xsqlite3SelectDelete(tls, db, pSel)
  73915 }
  73916 
  73917 // Generate code for a DELETE FROM statement.
  73918 //
  73919 //	DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;
  73920 //	            \________/       \________________/
  73921 //	             pTabList              pWhere
  73922 func Xsqlite3DeleteFrom(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr) {
  73923 	bp := tls.Alloc(56)
  73924 	defer tls.Free(56)
  73925 
  73926 	var v uintptr
  73927 	var pTab uintptr
  73928 	var i int32
  73929 	var pWInfo uintptr
  73930 	var pIdx uintptr
  73931 	var iTabCur int32
  73932 
  73933 	var nIdx int32
  73934 	var db uintptr
  73935 
  73936 	var iDb int32
  73937 	var memCnt int32
  73938 	var rcauth int32
  73939 	var eOnePass int32
  73940 
  73941 	var aToOpen uintptr
  73942 	var pPk uintptr
  73943 	var iPk int32
  73944 	var nPk I16
  73945 	var iKey int32
  73946 	var nKey I16
  73947 	var iEphCur int32
  73948 	var iRowSet int32
  73949 	var addrBypass int32
  73950 	var addrLoop int32
  73951 	var addrEphOpen int32
  73952 	var bComplex int32
  73953 
  73954 	var isView int32
  73955 	var pTrigger uintptr
  73956 	var iAddrOnce int32
  73957 	var pVTab uintptr
  73958 	var count int32
  73959 	var wcf U16
  73960 	*(*int32)(unsafe.Pointer(bp + 48)) = 0
  73961 	*(*int32)(unsafe.Pointer(bp + 52)) = 0
  73962 	memCnt = 0
  73963 	aToOpen = uintptr(0)
  73964 	iPk = 0
  73965 	nPk = int16(1)
  73966 	iEphCur = 0
  73967 	iRowSet = 0
  73968 	addrBypass = 0
  73969 	addrLoop = 0
  73970 	addrEphOpen = 0
  73971 
  73972 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(AuthContext{})))
  73973 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  73974 
  73975 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  73976 		goto __1
  73977 	}
  73978 	goto delete_from_cleanup
  73979 __1:
  73980 	;
  73981 	pTab = Xsqlite3SrcListLookup(tls, pParse, pTabList)
  73982 	if !(pTab == uintptr(0)) {
  73983 		goto __2
  73984 	}
  73985 	goto delete_from_cleanup
  73986 __2:
  73987 	;
  73988 	pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_DELETE, uintptr(0), uintptr(0))
  73989 	isView = libc.Bool32(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW)
  73990 	bComplex = libc.Bool32(pTrigger != 0 || Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0)
  73991 
  73992 	if !(Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0) {
  73993 		goto __3
  73994 	}
  73995 	goto delete_from_cleanup
  73996 __3:
  73997 	;
  73998 	if !(Xsqlite3IsReadOnly(tls, pParse, pTab, func() int32 {
  73999 		if pTrigger != 0 {
  74000 			return 1
  74001 		}
  74002 		return 0
  74003 	}()) != 0) {
  74004 		goto __4
  74005 	}
  74006 	goto delete_from_cleanup
  74007 __4:
  74008 	;
  74009 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  74010 
  74011 	rcauth = Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0),
  74012 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName)
  74013 
  74014 	if !(rcauth == SQLITE_DENY) {
  74015 		goto __5
  74016 	}
  74017 	goto delete_from_cleanup
  74018 __5:
  74019 	;
  74020 	iTabCur = libc.AssignPtrInt32(pTabList+8+44, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1))
  74021 	nIdx = 0
  74022 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  74023 __6:
  74024 	if !(pIdx != 0) {
  74025 		goto __8
  74026 	}
  74027 	(*Parse)(unsafe.Pointer(pParse)).FnTab++
  74028 	goto __7
  74029 __7:
  74030 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  74031 	nIdx++
  74032 	goto __6
  74033 	goto __8
  74034 __8:
  74035 	;
  74036 	if !(isView != 0) {
  74037 		goto __9
  74038 	}
  74039 	Xsqlite3AuthContextPush(tls, pParse, bp, (*Table)(unsafe.Pointer(pTab)).FzName)
  74040 __9:
  74041 	;
  74042 	v = Xsqlite3GetVdbe(tls, pParse)
  74043 	if !(v == uintptr(0)) {
  74044 		goto __10
  74045 	}
  74046 	goto delete_from_cleanup
  74047 __10:
  74048 	;
  74049 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) {
  74050 		goto __11
  74051 	}
  74052 	Xsqlite3VdbeCountChanges(tls, v)
  74053 __11:
  74054 	;
  74055 	Xsqlite3BeginWriteOperation(tls, pParse, bComplex, iDb)
  74056 
  74057 	if !(isView != 0) {
  74058 		goto __12
  74059 	}
  74060 	Xsqlite3MaterializeView(tls, pParse, pTab,
  74061 		pWhere, pOrderBy, pLimit, iTabCur)
  74062 	*(*int32)(unsafe.Pointer(bp + 48)) = libc.AssignPtrInt32(bp+52, iTabCur)
  74063 	pOrderBy = uintptr(0)
  74064 	pLimit = uintptr(0)
  74065 __12:
  74066 	;
  74067 	libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(NameContext{})))
  74068 	(*NameContext)(unsafe.Pointer(bp + 8)).FpParse = pParse
  74069 	(*NameContext)(unsafe.Pointer(bp + 8)).FpSrcList = pTabList
  74070 	if !(Xsqlite3ResolveExprNames(tls, bp+8, pWhere) != 0) {
  74071 		goto __13
  74072 	}
  74073 	goto delete_from_cleanup
  74074 __13:
  74075 	;
  74076 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&(uint64(0x00001)<<32) != uint64(0) &&
  74077 		!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) &&
  74078 		!(int32((*Parse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) &&
  74079 		!(int32((*Parse)(unsafe.Pointer(pParse)).FbReturning) != 0)) {
  74080 		goto __14
  74081 	}
  74082 	memCnt = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  74083 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, memCnt)
  74084 __14:
  74085 	;
  74086 	if !(rcauth == SQLITE_OK &&
  74087 		pWhere == uintptr(0) &&
  74088 		!(bComplex != 0) &&
  74089 		!(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) &&
  74090 		(*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback == uintptr(0)) {
  74091 		goto __15
  74092 	}
  74093 
  74094 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pTab)).FzName)
  74095 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  74096 		goto __17
  74097 	}
  74098 	Xsqlite3VdbeAddOp4(tls, v, OP_Clear, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, func() int32 {
  74099 		if memCnt != 0 {
  74100 			return memCnt
  74101 		}
  74102 		return -1
  74103 	}(),
  74104 		(*Table)(unsafe.Pointer(pTab)).FzName, -1)
  74105 __17:
  74106 	;
  74107 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  74108 __18:
  74109 	if !(pIdx != 0) {
  74110 		goto __20
  74111 	}
  74112 
  74113 	if !(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY && !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0))) {
  74114 		goto __21
  74115 	}
  74116 	Xsqlite3VdbeAddOp3(tls, v, OP_Clear, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb, func() int32 {
  74117 		if memCnt != 0 {
  74118 			return memCnt
  74119 		}
  74120 		return -1
  74121 	}())
  74122 	goto __22
  74123 __21:
  74124 	Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb)
  74125 __22:
  74126 	;
  74127 	goto __19
  74128 __19:
  74129 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  74130 	goto __18
  74131 	goto __20
  74132 __20:
  74133 	;
  74134 	goto __16
  74135 __15:
  74136 	wcf = U16(WHERE_ONEPASS_DESIRED | WHERE_DUPLICATES_OK)
  74137 	if !((*NameContext)(unsafe.Pointer(bp+8)).FncFlags&NC_Subquery != 0) {
  74138 		goto __23
  74139 	}
  74140 	bComplex = 1
  74141 __23:
  74142 	;
  74143 	wcf = U16(int32(wcf) | func() int32 {
  74144 		if bComplex != 0 {
  74145 			return 0
  74146 		}
  74147 		return WHERE_ONEPASS_MULTIROW
  74148 	}())
  74149 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  74150 		goto __24
  74151 	}
  74152 
  74153 	pPk = uintptr(0)
  74154 	nPk = int16(1)
  74155 	iRowSet = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  74156 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, iRowSet)
  74157 	goto __25
  74158 __24:
  74159 	pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  74160 
  74161 	nPk = I16((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  74162 	iPk = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  74163 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32(nPk)
  74164 	iEphCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  74165 	addrEphOpen = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iEphCur, int32(nPk))
  74166 	Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk)
  74167 __25:
  74168 	;
  74169 	pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uintptr(0), wcf, iTabCur+1)
  74170 	if !(pWInfo == uintptr(0)) {
  74171 		goto __26
  74172 	}
  74173 	goto delete_from_cleanup
  74174 __26:
  74175 	;
  74176 	eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp+40)
  74177 
  74178 	if !(eOnePass != ONEPASS_SINGLE) {
  74179 		goto __27
  74180 	}
  74181 	Xsqlite3MultiWrite(tls, pParse)
  74182 __27:
  74183 	;
  74184 	if !(Xsqlite3WhereUsesDeferredSeek(tls, pWInfo) != 0) {
  74185 		goto __28
  74186 	}
  74187 	Xsqlite3VdbeAddOp1(tls, v, OP_FinishSeek, iTabCur)
  74188 __28:
  74189 	;
  74190 	if !(memCnt != 0) {
  74191 		goto __29
  74192 	}
  74193 	Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, memCnt, 1)
  74194 __29:
  74195 	;
  74196 	if !(pPk != 0) {
  74197 		goto __30
  74198 	}
  74199 	i = 0
  74200 __32:
  74201 	if !(i < int32(nPk)) {
  74202 		goto __34
  74203 	}
  74204 
  74205 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iTabCur,
  74206 		int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))), iPk+i)
  74207 	goto __33
  74208 __33:
  74209 	i++
  74210 	goto __32
  74211 	goto __34
  74212 __34:
  74213 	;
  74214 	iKey = iPk
  74215 	goto __31
  74216 __30:
  74217 	iKey = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  74218 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iTabCur, -1, iKey)
  74219 __31:
  74220 	;
  74221 	if !(eOnePass != ONEPASS_OFF) {
  74222 		goto __35
  74223 	}
  74224 
  74225 	nKey = nPk
  74226 	aToOpen = Xsqlite3DbMallocRawNN(tls, db, uint64(nIdx+2))
  74227 	if !(aToOpen == uintptr(0)) {
  74228 		goto __37
  74229 	}
  74230 	Xsqlite3WhereEnd(tls, pWInfo)
  74231 	goto delete_from_cleanup
  74232 __37:
  74233 	;
  74234 	libc.Xmemset(tls, aToOpen, 1, uint32(nIdx+1))
  74235 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(nIdx+1))) = U8(0)
  74236 	if !(*(*int32)(unsafe.Pointer(bp + 40)) >= 0) {
  74237 		goto __38
  74238 	}
  74239 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(*(*int32)(unsafe.Pointer(bp + 40))-iTabCur))) = U8(0)
  74240 __38:
  74241 	;
  74242 	if !(*(*int32)(unsafe.Pointer(bp + 40 + 1*4)) >= 0) {
  74243 		goto __39
  74244 	}
  74245 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(*(*int32)(unsafe.Pointer(bp + 40 + 1*4))-iTabCur))) = U8(0)
  74246 __39:
  74247 	;
  74248 	if !(addrEphOpen != 0) {
  74249 		goto __40
  74250 	}
  74251 	Xsqlite3VdbeChangeToNoop(tls, v, addrEphOpen)
  74252 __40:
  74253 	;
  74254 	addrBypass = Xsqlite3VdbeMakeLabel(tls, pParse)
  74255 	goto __36
  74256 __35:
  74257 	if !(pPk != 0) {
  74258 		goto __41
  74259 	}
  74260 
  74261 	iKey = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  74262 	nKey = int16(0)
  74263 	Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, iPk, int32(nPk), iKey,
  74264 		Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pPk), int32(nPk))
  74265 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iEphCur, iKey, iPk, int32(nPk))
  74266 	goto __42
  74267 __41:
  74268 	nKey = int16(1)
  74269 	Xsqlite3VdbeAddOp2(tls, v, OP_RowSetAdd, iRowSet, iKey)
  74270 __42:
  74271 	;
  74272 	Xsqlite3WhereEnd(tls, pWInfo)
  74273 __36:
  74274 	;
  74275 	if !!(isView != 0) {
  74276 		goto __43
  74277 	}
  74278 	iAddrOnce = 0
  74279 	if !(eOnePass == ONEPASS_MULTI) {
  74280 		goto __44
  74281 	}
  74282 	iAddrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  74283 __44:
  74284 	;
  74285 	Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(OPFLAG_FORDELETE),
  74286 		iTabCur, aToOpen, bp+48, bp+52)
  74287 
  74288 	if !(eOnePass == ONEPASS_MULTI) {
  74289 		goto __45
  74290 	}
  74291 	Xsqlite3VdbeJumpHereOrPopInst(tls, v, iAddrOnce)
  74292 __45:
  74293 	;
  74294 __43:
  74295 	;
  74296 	if !(eOnePass != ONEPASS_OFF) {
  74297 		goto __46
  74298 	}
  74299 
  74300 	if !(!(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) && *(*U8)(unsafe.Pointer(aToOpen + uintptr(*(*int32)(unsafe.Pointer(bp + 48))-iTabCur))) != 0) {
  74301 		goto __48
  74302 	}
  74303 
  74304 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, *(*int32)(unsafe.Pointer(bp + 48)), addrBypass, iKey, int32(nKey))
  74305 
  74306 __48:
  74307 	;
  74308 	goto __47
  74309 __46:
  74310 	if !(pPk != 0) {
  74311 		goto __49
  74312 	}
  74313 	addrLoop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iEphCur)
  74314 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  74315 		goto __51
  74316 	}
  74317 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEphCur, 0, iKey)
  74318 	goto __52
  74319 __51:
  74320 	Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iEphCur, iKey)
  74321 __52:
  74322 	;
  74323 	goto __50
  74324 __49:
  74325 	addrLoop = Xsqlite3VdbeAddOp3(tls, v, OP_RowSetRead, iRowSet, 0, iKey)
  74326 
  74327 __50:
  74328 	;
  74329 __47:
  74330 	;
  74331 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  74332 		goto __53
  74333 	}
  74334 	pVTab = Xsqlite3GetVTable(tls, db, pTab)
  74335 	Xsqlite3VtabMakeWritable(tls, pParse, pTab)
  74336 
  74337 	Xsqlite3MayAbort(tls, pParse)
  74338 	if !(eOnePass == ONEPASS_SINGLE) {
  74339 		goto __55
  74340 	}
  74341 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, iTabCur)
  74342 	if !((*Parse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0)) {
  74343 		goto __56
  74344 	}
  74345 	(*Parse)(unsafe.Pointer(pParse)).FisMultiWrite = U8(0)
  74346 __56:
  74347 	;
  74348 __55:
  74349 	;
  74350 	Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 0, 1, iKey, pVTab, -11)
  74351 	Xsqlite3VdbeChangeP5(tls, v, uint16(OE_Abort))
  74352 	goto __54
  74353 __53:
  74354 	count = libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0)
  74355 	Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, *(*int32)(unsafe.Pointer(bp + 48)), *(*int32)(unsafe.Pointer(bp + 52)),
  74356 		iKey, nKey, uint8(count), uint8(OE_Default), uint8(eOnePass), *(*int32)(unsafe.Pointer(bp + 40 + 1*4)))
  74357 __54:
  74358 	;
  74359 	if !(eOnePass != ONEPASS_OFF) {
  74360 		goto __57
  74361 	}
  74362 	Xsqlite3VdbeResolveLabel(tls, v, addrBypass)
  74363 	Xsqlite3WhereEnd(tls, pWInfo)
  74364 	goto __58
  74365 __57:
  74366 	if !(pPk != 0) {
  74367 		goto __59
  74368 	}
  74369 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, iEphCur, addrLoop+1)
  74370 	Xsqlite3VdbeJumpHere(tls, v, addrLoop)
  74371 	goto __60
  74372 __59:
  74373 	Xsqlite3VdbeGoto(tls, v, addrLoop)
  74374 	Xsqlite3VdbeJumpHere(tls, v, addrLoop)
  74375 __60:
  74376 	;
  74377 __58:
  74378 	;
  74379 __16:
  74380 	;
  74381 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0)) {
  74382 		goto __61
  74383 	}
  74384 	Xsqlite3AutoincrementEnd(tls, pParse)
  74385 __61:
  74386 	;
  74387 	if !(memCnt != 0) {
  74388 		goto __62
  74389 	}
  74390 	Xsqlite3CodeChangeCount(tls, v, memCnt, ts+14833)
  74391 __62:
  74392 	;
  74393 delete_from_cleanup:
  74394 	Xsqlite3AuthContextPop(tls, bp)
  74395 	Xsqlite3SrcListDelete(tls, db, pTabList)
  74396 	Xsqlite3ExprDelete(tls, db, pWhere)
  74397 	if !(aToOpen != 0) {
  74398 		goto __63
  74399 	}
  74400 	Xsqlite3DbNNFreeNN(tls, db, aToOpen)
  74401 __63:
  74402 	;
  74403 	return
  74404 }
  74405 
  74406 // This routine generates VDBE code that causes a single row of a
  74407 // single table to be deleted.  Both the original table entry and
  74408 // all indices are removed.
  74409 //
  74410 // Preconditions:
  74411 //
  74412 //  1. iDataCur is an open cursor on the btree that is the canonical data
  74413 //     store for the table.  (This will be either the table itself,
  74414 //     in the case of a rowid table, or the PRIMARY KEY index in the case
  74415 //     of a WITHOUT ROWID table.)
  74416 //
  74417 //  2. Read/write cursors for all indices of pTab must be open as
  74418 //     cursor number iIdxCur+i for the i-th index.
  74419 //
  74420 //  3. The primary key for the row to be deleted must be stored in a
  74421 //     sequence of nPk memory cells starting at iPk.  If nPk==0 that means
  74422 //     that a search record formed from OP_MakeRecord is contained in the
  74423 //     single memory location iPk.
  74424 //
  74425 // eMode:
  74426 //
  74427 //	Parameter eMode may be passed either ONEPASS_OFF (0), ONEPASS_SINGLE, or
  74428 //	ONEPASS_MULTI.  If eMode is not ONEPASS_OFF, then the cursor
  74429 //	iDataCur already points to the row to delete. If eMode is ONEPASS_OFF
  74430 //	then this function must seek iDataCur to the entry identified by iPk
  74431 //	and nPk before reading from it.
  74432 //
  74433 //	If eMode is ONEPASS_MULTI, then this call is being made as part
  74434 //	of a ONEPASS delete that affects multiple rows. In this case, if
  74435 //	iIdxNoSeek is a valid cursor number (>=0) and is not the same as
  74436 //	iDataCur, then its position should be preserved following the delete
  74437 //	operation. Or, if iIdxNoSeek is not a valid cursor number, the
  74438 //	position of iDataCur should be preserved instead.
  74439 //
  74440 // iIdxNoSeek:
  74441 //
  74442 //	If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur,
  74443 //	then it identifies an index cursor (from within array of cursors
  74444 //	starting at iIdxCur) that already points to the index entry to be deleted.
  74445 //	Except, this optimization is disabled if there are BEFORE triggers since
  74446 //	the trigger body might have moved the cursor.
  74447 func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTrigger uintptr, iDataCur int32, iIdxCur int32, iPk int32, nPk I16, count U8, onconf U8, eMode U8, iIdxNoSeek int32) {
  74448 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  74449 	var iOld int32 = 0
  74450 	var iLabel int32
  74451 	var opSeek U8
  74452 
  74453 	iLabel = Xsqlite3VdbeMakeLabel(tls, pParse)
  74454 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  74455 		opSeek = uint8(OP_NotExists)
  74456 	} else {
  74457 		opSeek = uint8(OP_NotFound)
  74458 	}
  74459 	if int32(eMode) == ONEPASS_OFF {
  74460 		Xsqlite3VdbeAddOp4Int(tls, v, int32(opSeek), iDataCur, iLabel, iPk, int32(nPk))
  74461 
  74462 	}
  74463 
  74464 	if Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0 || pTrigger != 0 {
  74465 		var mask U32
  74466 		var iCol int32
  74467 		var addrStart int32
  74468 
  74469 		mask = Xsqlite3TriggerColmask(tls,
  74470 			pParse, pTrigger, uintptr(0), 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, int32(onconf))
  74471 		mask = mask | Xsqlite3FkOldmask(tls, pParse, pTab)
  74472 		iOld = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  74473 		*(*int32)(unsafe.Pointer(pParse + 44)) += 1 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  74474 
  74475 		Xsqlite3VdbeAddOp2(tls, v, OP_Copy, iPk, iOld)
  74476 		for iCol = 0; iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol); iCol++ {
  74477 			if mask == 0xffffffff || iCol <= 31 && mask&(uint32(1)<<iCol) != U32(0) {
  74478 				var kk int32 = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol)))
  74479 				Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, iCol, iOld+kk+1)
  74480 			}
  74481 		}
  74482 
  74483 		addrStart = Xsqlite3VdbeCurrentAddr(tls, v)
  74484 		Xsqlite3CodeRowTrigger(tls, pParse, pTrigger,
  74485 			TK_DELETE, uintptr(0), TRIGGER_BEFORE, pTab, iOld, int32(onconf), iLabel)
  74486 
  74487 		if addrStart < Xsqlite3VdbeCurrentAddr(tls, v) {
  74488 			Xsqlite3VdbeAddOp4Int(tls, v, int32(opSeek), iDataCur, iLabel, iPk, int32(nPk))
  74489 
  74490 			iIdxNoSeek = -1
  74491 		}
  74492 
  74493 		Xsqlite3FkCheck(tls, pParse, pTab, iOld, 0, uintptr(0), 0)
  74494 	}
  74495 
  74496 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  74497 		var p5 U8 = U8(0)
  74498 		Xsqlite3GenerateRowIndexDelete(tls, pParse, pTab, iDataCur, iIdxCur, uintptr(0), iIdxNoSeek)
  74499 		Xsqlite3VdbeAddOp2(tls, v, OP_Delete, iDataCur, func() int32 {
  74500 			if count != 0 {
  74501 				return OPFLAG_NCHANGE
  74502 			}
  74503 			return 0
  74504 		}())
  74505 		if int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 || 0 == Xsqlite3_stricmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+11348) {
  74506 			Xsqlite3VdbeAppendP4(tls, v, pTab, -5)
  74507 		}
  74508 		if int32(eMode) != ONEPASS_OFF {
  74509 			Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_AUXDELETE))
  74510 		}
  74511 		if iIdxNoSeek >= 0 && iIdxNoSeek != iDataCur {
  74512 			Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iIdxNoSeek)
  74513 		}
  74514 		if int32(eMode) == ONEPASS_MULTI {
  74515 			p5 = U8(int32(p5) | OPFLAG_SAVEPOSITION)
  74516 		}
  74517 		Xsqlite3VdbeChangeP5(tls, v, uint16(p5))
  74518 	}
  74519 
  74520 	Xsqlite3FkActions(tls, pParse, pTab, uintptr(0), iOld, uintptr(0), 0)
  74521 
  74522 	Xsqlite3CodeRowTrigger(tls, pParse, pTrigger,
  74523 		TK_DELETE, uintptr(0), TRIGGER_AFTER, pTab, iOld, int32(onconf), iLabel)
  74524 
  74525 	Xsqlite3VdbeResolveLabel(tls, v, iLabel)
  74526 
  74527 }
  74528 
  74529 // This routine generates VDBE code that causes the deletion of all
  74530 // index entries associated with a single row of a single table, pTab
  74531 //
  74532 // Preconditions:
  74533 //
  74534 //  1. A read/write cursor "iDataCur" must be open on the canonical storage
  74535 //     btree for the table pTab.  (This will be either the table itself
  74536 //     for rowid tables or to the primary key index for WITHOUT ROWID
  74537 //     tables.)
  74538 //
  74539 //  2. Read/write cursors for all indices of pTab must be open as
  74540 //     cursor number iIdxCur+i for the i-th index.  (The pTab->pIndex
  74541 //     index is the 0-th index.)
  74542 //
  74543 //  3. The "iDataCur" cursor must be already be positioned on the row
  74544 //     that is to be deleted.
  74545 func Xsqlite3GenerateRowIndexDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, iDataCur int32, iIdxCur int32, aRegIdx uintptr, iIdxNoSeek int32) {
  74546 	bp := tls.Alloc(4)
  74547 	defer tls.Free(4)
  74548 
  74549 	var i int32
  74550 	var r1 int32 = -1
  74551 
  74552 	var pIdx uintptr
  74553 	var pPrior uintptr = uintptr(0)
  74554 	var v uintptr
  74555 	var pPk uintptr
  74556 
  74557 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  74558 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  74559 		pPk = uintptr(0)
  74560 	} else {
  74561 		pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  74562 	}
  74563 	i = 0
  74564 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  74565 __1:
  74566 	if !(pIdx != 0) {
  74567 		goto __3
  74568 	}
  74569 	{
  74570 		if aRegIdx != uintptr(0) && *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)) == 0 {
  74571 			goto __2
  74572 		}
  74573 		if pIdx == pPk {
  74574 			goto __2
  74575 		}
  74576 		if iIdxCur+i == iIdxNoSeek {
  74577 			goto __2
  74578 		}
  74579 
  74580 		r1 = Xsqlite3GenerateIndexKey(tls, pParse, pIdx, iDataCur, 0, 1,
  74581 			bp, pPrior, r1)
  74582 		Xsqlite3VdbeAddOp3(tls, v, OP_IdxDelete, iIdxCur+i, r1,
  74583 			func() int32 {
  74584 				if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x8>>3)) != 0 {
  74585 					return int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  74586 				}
  74587 				return int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  74588 			}())
  74589 		Xsqlite3VdbeChangeP5(tls, v, uint16(1))
  74590 		Xsqlite3ResolvePartIdxLabel(tls, pParse, *(*int32)(unsafe.Pointer(bp)))
  74591 		pPrior = pIdx
  74592 
  74593 	}
  74594 	goto __2
  74595 __2:
  74596 	i++
  74597 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  74598 	goto __1
  74599 	goto __3
  74600 __3:
  74601 }
  74602 
  74603 // Generate code that will assemble an index key and stores it in register
  74604 // regOut.  The key with be for index pIdx which is an index on pTab.
  74605 // iCur is the index of a cursor open on the pTab table and pointing to
  74606 // the entry that needs indexing.  If pTab is a WITHOUT ROWID table, then
  74607 // iCur must be the cursor of the PRIMARY KEY index.
  74608 //
  74609 // Return a register number which is the first in a block of
  74610 // registers that holds the elements of the index key.  The
  74611 // block of registers has already been deallocated by the time
  74612 // this routine returns.
  74613 //
  74614 // If *piPartIdxLabel is not NULL, fill it in with a label and jump
  74615 // to that label if pIdx is a partial index that should be skipped.
  74616 // The label should be resolved using sqlite3ResolvePartIdxLabel().
  74617 // A partial index should be skipped if its WHERE clause evaluates
  74618 // to false or null.  If pIdx is not a partial index, *piPartIdxLabel
  74619 // will be set to zero which is an empty label that is ignored by
  74620 // sqlite3ResolvePartIdxLabel().
  74621 //
  74622 // The pPrior and regPrior parameters are used to implement a cache to
  74623 // avoid unnecessary register loads.  If pPrior is not NULL, then it is
  74624 // a pointer to a different index for which an index key has just been
  74625 // computed into register regPrior.  If the current pIdx index is generating
  74626 // its key into the same sequence of registers and if pPrior and pIdx share
  74627 // a column in common, then the register corresponding to that column already
  74628 // holds the correct value and the loading of that register is skipped.
  74629 // This optimization is helpful when doing a DELETE or an INTEGRITY_CHECK
  74630 // on a table with multiple indices, and especially with the ROWID or
  74631 // PRIMARY KEY columns of the index.
  74632 func Xsqlite3GenerateIndexKey(tls *libc.TLS, pParse uintptr, pIdx uintptr, iDataCur int32, regOut int32, prefixOnly int32, piPartIdxLabel uintptr, pPrior uintptr, regPrior int32) int32 {
  74633 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  74634 	var j int32
  74635 	var regBase int32
  74636 	var nCol int32
  74637 
  74638 	if piPartIdxLabel != 0 {
  74639 		if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 {
  74640 			*(*int32)(unsafe.Pointer(piPartIdxLabel)) = Xsqlite3VdbeMakeLabel(tls, pParse)
  74641 			(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = iDataCur + 1
  74642 			Xsqlite3ExprIfFalseDup(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, *(*int32)(unsafe.Pointer(piPartIdxLabel)),
  74643 				SQLITE_JUMPIFNULL)
  74644 			(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  74645 			pPrior = uintptr(0)
  74646 
  74647 		} else {
  74648 			*(*int32)(unsafe.Pointer(piPartIdxLabel)) = 0
  74649 		}
  74650 	}
  74651 	if prefixOnly != 0 && uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x8>>3)) != 0 {
  74652 		nCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  74653 	} else {
  74654 		nCol = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  74655 	}
  74656 	regBase = Xsqlite3GetTempRange(tls, pParse, nCol)
  74657 	if pPrior != 0 && (regBase != regPrior || (*Index)(unsafe.Pointer(pPrior)).FpPartIdxWhere != 0) {
  74658 		pPrior = uintptr(0)
  74659 	}
  74660 	for j = 0; j < nCol; j++ {
  74661 		if pPrior != 0 &&
  74662 			int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPrior)).FaiColumn + uintptr(j)*2))) == int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) &&
  74663 			int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPrior)).FaiColumn + uintptr(j)*2))) != -2 {
  74664 			continue
  74665 		}
  74666 		Xsqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iDataCur, j, regBase+j)
  74667 		if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) >= 0 {
  74668 			Xsqlite3VdbeDeletePriorOpcode(tls, v, uint8(OP_RealAffinity))
  74669 		}
  74670 	}
  74671 	if regOut != 0 {
  74672 		Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase, nCol, regOut)
  74673 	}
  74674 	Xsqlite3ReleaseTempRange(tls, pParse, regBase, nCol)
  74675 	return regBase
  74676 }
  74677 
  74678 // If a prior call to sqlite3GenerateIndexKey() generated a jump-over label
  74679 // because it was a partial index, then this routine should be called to
  74680 // resolve that label.
  74681 func Xsqlite3ResolvePartIdxLabel(tls *libc.TLS, pParse uintptr, iLabel int32) {
  74682 	if iLabel != 0 {
  74683 		Xsqlite3VdbeResolveLabel(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iLabel)
  74684 	}
  74685 }
  74686 
  74687 func sqlite3GetFuncCollSeq(tls *libc.TLS, context uintptr) uintptr {
  74688 	var pOp uintptr
  74689 
  74690 	pOp = (*Vdbe)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(context)).FpVdbe)).FaOp + uintptr((*Sqlite3_context)(unsafe.Pointer(context)).FiOp-1)*20
  74691 
  74692 	return *(*uintptr)(unsafe.Pointer(pOp + 16))
  74693 }
  74694 
  74695 func sqlite3SkipAccumulatorLoad(tls *libc.TLS, context uintptr) {
  74696 	(*Sqlite3_context)(unsafe.Pointer(context)).FisError = -1
  74697 	(*Sqlite3_context)(unsafe.Pointer(context)).FskipFlag = U8(1)
  74698 }
  74699 
  74700 func minmaxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74701 	var i int32
  74702 	var mask int32
  74703 	var iBest int32
  74704 	var pColl uintptr
  74705 
  74706 	if Xsqlite3_user_data(tls, context) == uintptr(0) {
  74707 		mask = 0
  74708 	} else {
  74709 		mask = -1
  74710 	}
  74711 	pColl = sqlite3GetFuncCollSeq(tls, context)
  74712 
  74713 	iBest = 0
  74714 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL {
  74715 		return
  74716 	}
  74717 	for i = 1; i < argc; i++ {
  74718 		if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4))) == SQLITE_NULL {
  74719 			return
  74720 		}
  74721 		if Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(iBest)*4)), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)), pColl)^mask >= 0 {
  74722 			iBest = i
  74723 		}
  74724 	}
  74725 	Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(iBest)*4)))
  74726 }
  74727 
  74728 func typeofFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  74729 	var i int32 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) - 1
  74730 	_ = NotUsed
  74731 
  74732 	Xsqlite3_result_text(tls, context, azType2[i], -1, uintptr(0))
  74733 }
  74734 
  74735 var azType2 = [5]uintptr{ts + 6191, ts + 6186, ts + 8005, ts + 8000, ts + 6181}
  74736 
  74737 func subtypeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74738 	_ = argc
  74739 	Xsqlite3_result_int(tls, context, int32(Xsqlite3_value_subtype(tls, *(*uintptr)(unsafe.Pointer(argv)))))
  74740 }
  74741 
  74742 func lengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74743 	_ = argc
  74744 	switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) {
  74745 	case SQLITE_BLOB:
  74746 		fallthrough
  74747 	case SQLITE_INTEGER:
  74748 		fallthrough
  74749 	case SQLITE_FLOAT:
  74750 		{
  74751 			Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))))
  74752 			break
  74753 
  74754 		}
  74755 	case SQLITE_TEXT:
  74756 		{
  74757 			var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74758 			var z0 uintptr
  74759 			var c uint8
  74760 			if z == uintptr(0) {
  74761 				return
  74762 			}
  74763 			z0 = z
  74764 			for int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(z)))) != 0 {
  74765 				z++
  74766 				if int32(c) >= 0xc0 {
  74767 					for int32(*(*uint8)(unsafe.Pointer(z)))&0xc0 == 0x80 {
  74768 						z++
  74769 						z0++
  74770 					}
  74771 				}
  74772 			}
  74773 			Xsqlite3_result_int(tls, context, (int32(z)-int32(z0))/1)
  74774 			break
  74775 
  74776 		}
  74777 	default:
  74778 		{
  74779 			Xsqlite3_result_null(tls, context)
  74780 			break
  74781 
  74782 		}
  74783 	}
  74784 }
  74785 
  74786 func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74787 	_ = argc
  74788 	switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) {
  74789 	case SQLITE_INTEGER:
  74790 		{
  74791 			var iVal I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74792 			if iVal < int64(0) {
  74793 				if iVal == int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32) {
  74794 					Xsqlite3_result_error(tls, context, ts+14846, -1)
  74795 					return
  74796 				}
  74797 				iVal = -iVal
  74798 			}
  74799 			Xsqlite3_result_int64(tls, context, iVal)
  74800 			break
  74801 
  74802 		}
  74803 	case SQLITE_NULL:
  74804 		{
  74805 			Xsqlite3_result_null(tls, context)
  74806 			break
  74807 
  74808 		}
  74809 	default:
  74810 		{
  74811 			var rVal float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74812 			if rVal < float64(0) {
  74813 				rVal = -rVal
  74814 			}
  74815 			Xsqlite3_result_double(tls, context, rVal)
  74816 			break
  74817 
  74818 		}
  74819 	}
  74820 }
  74821 
  74822 func instrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74823 	var zHaystack uintptr
  74824 	var zNeedle uintptr
  74825 	var nHaystack int32
  74826 	var nNeedle int32
  74827 	var typeHaystack int32
  74828 	var typeNeedle int32
  74829 	var N int32
  74830 	var isText int32
  74831 	var firstChar uint8
  74832 	var pC1 uintptr
  74833 	var pC2 uintptr
  74834 	N = 1
  74835 	pC1 = uintptr(0)
  74836 	pC2 = uintptr(0)
  74837 
  74838 	_ = argc
  74839 	typeHaystack = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74840 	typeNeedle = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  74841 	if !(typeHaystack == SQLITE_NULL || typeNeedle == SQLITE_NULL) {
  74842 		goto __1
  74843 	}
  74844 	return
  74845 __1:
  74846 	;
  74847 	nHaystack = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74848 	nNeedle = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  74849 	if !(nNeedle > 0) {
  74850 		goto __2
  74851 	}
  74852 	if !(typeHaystack == SQLITE_BLOB && typeNeedle == SQLITE_BLOB) {
  74853 		goto __3
  74854 	}
  74855 	zHaystack = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74856 	zNeedle = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  74857 	isText = 0
  74858 	goto __4
  74859 __3:
  74860 	if !(typeHaystack != SQLITE_BLOB && typeNeedle != SQLITE_BLOB) {
  74861 		goto __5
  74862 	}
  74863 	zHaystack = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74864 	zNeedle = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  74865 	isText = 1
  74866 	goto __6
  74867 __5:
  74868 	pC1 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74869 	zHaystack = Xsqlite3_value_text(tls, pC1)
  74870 	if !(zHaystack == uintptr(0)) {
  74871 		goto __7
  74872 	}
  74873 	goto endInstrOOM
  74874 __7:
  74875 	;
  74876 	nHaystack = Xsqlite3_value_bytes(tls, pC1)
  74877 	pC2 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  74878 	zNeedle = Xsqlite3_value_text(tls, pC2)
  74879 	if !(zNeedle == uintptr(0)) {
  74880 		goto __8
  74881 	}
  74882 	goto endInstrOOM
  74883 __8:
  74884 	;
  74885 	nNeedle = Xsqlite3_value_bytes(tls, pC2)
  74886 	isText = 1
  74887 __6:
  74888 	;
  74889 __4:
  74890 	;
  74891 	if !(zNeedle == uintptr(0) || nHaystack != 0 && zHaystack == uintptr(0)) {
  74892 		goto __9
  74893 	}
  74894 	goto endInstrOOM
  74895 __9:
  74896 	;
  74897 	firstChar = *(*uint8)(unsafe.Pointer(zNeedle))
  74898 __10:
  74899 	if !(nNeedle <= nHaystack &&
  74900 		(int32(*(*uint8)(unsafe.Pointer(zHaystack))) != int32(firstChar) || libc.Xmemcmp(tls, zHaystack, zNeedle, uint32(nNeedle)) != 0)) {
  74901 		goto __11
  74902 	}
  74903 	N++
  74904 __12:
  74905 	nHaystack--
  74906 	zHaystack++
  74907 	goto __13
  74908 __13:
  74909 	if isText != 0 && int32(*(*uint8)(unsafe.Pointer(zHaystack)))&0xc0 == 0x80 {
  74910 		goto __12
  74911 	}
  74912 	goto __14
  74913 __14:
  74914 	;
  74915 	goto __10
  74916 __11:
  74917 	;
  74918 	if !(nNeedle > nHaystack) {
  74919 		goto __15
  74920 	}
  74921 	N = 0
  74922 __15:
  74923 	;
  74924 __2:
  74925 	;
  74926 	Xsqlite3_result_int(tls, context, N)
  74927 endInstr:
  74928 	Xsqlite3_value_free(tls, pC1)
  74929 	Xsqlite3_value_free(tls, pC2)
  74930 	return
  74931 endInstrOOM:
  74932 	Xsqlite3_result_error_nomem(tls, context)
  74933 	goto endInstr
  74934 }
  74935 
  74936 func printfFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74937 	bp := tls.Alloc(44)
  74938 	defer tls.Free(44)
  74939 
  74940 	var zFormat uintptr
  74941 	var n int32
  74942 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  74943 
  74944 	if argc >= 1 && libc.AssignUintptr(&zFormat, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != uintptr(0) {
  74945 		(*PrintfArguments)(unsafe.Pointer(bp + 32)).FnArg = argc - 1
  74946 		(*PrintfArguments)(unsafe.Pointer(bp + 32)).FnUsed = 0
  74947 		(*PrintfArguments)(unsafe.Pointer(bp + 32)).FapArg = argv + uintptr(1)*4
  74948 		Xsqlite3StrAccumInit(tls, bp+8, db, uintptr(0), 0, *(*int32)(unsafe.Pointer(db + 120)))
  74949 		(*StrAccum)(unsafe.Pointer(bp + 8)).FprintfFlags = U8(SQLITE_PRINTF_SQLFUNC)
  74950 		Xsqlite3_str_appendf(tls, bp+8, zFormat, libc.VaList(bp, bp+32))
  74951 		n = int32((*StrAccum)(unsafe.Pointer(bp + 8)).FnChar)
  74952 		Xsqlite3_result_text(tls, context, Xsqlite3StrAccumFinish(tls, bp+8), n,
  74953 			*(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  74954 	}
  74955 }
  74956 
  74957 func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  74958 	var z uintptr
  74959 	var z2 uintptr
  74960 	var len int32
  74961 	var p0type int32
  74962 	var p1 I64
  74963 	var p2 I64
  74964 	var negP2 int32 = 0
  74965 
  74966 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))) == SQLITE_NULL ||
  74967 		argc == 3 && Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))) == SQLITE_NULL {
  74968 		return
  74969 	}
  74970 	p0type = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74971 	p1 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))))
  74972 	if p0type == SQLITE_BLOB {
  74973 		len = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74974 		z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74975 		if z == uintptr(0) {
  74976 			return
  74977 		}
  74978 
  74979 	} else {
  74980 		z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  74981 		if z == uintptr(0) {
  74982 			return
  74983 		}
  74984 		len = 0
  74985 		if p1 < int64(0) {
  74986 			for z2 = z; *(*uint8)(unsafe.Pointer(z2)) != 0; len++ {
  74987 				{
  74988 					if int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z2, 1)))) >= 0xc0 {
  74989 						for int32(*(*uint8)(unsafe.Pointer(z2)))&0xc0 == 0x80 {
  74990 							z2++
  74991 						}
  74992 					}
  74993 				}
  74994 
  74995 			}
  74996 		}
  74997 	}
  74998 	if argc == 3 {
  74999 		p2 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
  75000 		if p2 < int64(0) {
  75001 			p2 = -p2
  75002 			negP2 = 1
  75003 		}
  75004 	} else {
  75005 		p2 = I64(*(*int32)(unsafe.Pointer(Xsqlite3_context_db_handle(tls, context) + 120)))
  75006 	}
  75007 	if p1 < int64(0) {
  75008 		p1 = p1 + I64(len)
  75009 		if p1 < int64(0) {
  75010 			p2 = p2 + p1
  75011 			if p2 < int64(0) {
  75012 				p2 = int64(0)
  75013 			}
  75014 			p1 = int64(0)
  75015 		}
  75016 	} else if p1 > int64(0) {
  75017 		p1--
  75018 	} else if p2 > int64(0) {
  75019 		p2--
  75020 	}
  75021 	if negP2 != 0 {
  75022 		p1 = p1 - p2
  75023 		if p1 < int64(0) {
  75024 			p2 = p2 + p1
  75025 			p1 = int64(0)
  75026 		}
  75027 	}
  75028 
  75029 	if p0type != SQLITE_BLOB {
  75030 		for *(*uint8)(unsafe.Pointer(z)) != 0 && p1 != 0 {
  75031 			{
  75032 				if int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) >= 0xc0 {
  75033 					for int32(*(*uint8)(unsafe.Pointer(z)))&0xc0 == 0x80 {
  75034 						z++
  75035 					}
  75036 				}
  75037 			}
  75038 
  75039 			p1--
  75040 		}
  75041 		for z2 = z; *(*uint8)(unsafe.Pointer(z2)) != 0 && p2 != 0; p2-- {
  75042 			{
  75043 				if int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z2, 1)))) >= 0xc0 {
  75044 					for int32(*(*uint8)(unsafe.Pointer(z2)))&0xc0 == 0x80 {
  75045 						z2++
  75046 					}
  75047 				}
  75048 			}
  75049 
  75050 		}
  75051 		Xsqlite3_result_text64(tls, context, z, uint64((int32(z2)-int32(z))/1), libc.UintptrFromInt32(-1),
  75052 			uint8(SQLITE_UTF8))
  75053 	} else {
  75054 		if p1+p2 > I64(len) {
  75055 			p2 = I64(len) - p1
  75056 			if p2 < int64(0) {
  75057 				p2 = int64(0)
  75058 			}
  75059 		}
  75060 		Xsqlite3_result_blob64(tls, context, z+uintptr(p1), U64(p2), libc.UintptrFromInt32(-1))
  75061 	}
  75062 }
  75063 
  75064 func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75065 	bp := tls.Alloc(24)
  75066 	defer tls.Free(24)
  75067 
  75068 	var n int32 = 0
  75069 
  75070 	var zBuf uintptr
  75071 
  75072 	if argc == 2 {
  75073 		if SQLITE_NULL == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))) {
  75074 			return
  75075 		}
  75076 		n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  75077 		if n > 30 {
  75078 			n = 30
  75079 		}
  75080 		if n < 0 {
  75081 			n = 0
  75082 		}
  75083 	}
  75084 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL {
  75085 		return
  75086 	}
  75087 	*(*float64)(unsafe.Pointer(bp + 16)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75088 
  75089 	if *(*float64)(unsafe.Pointer(bp + 16)) < -4503599627370496.0 || *(*float64)(unsafe.Pointer(bp + 16)) > +4503599627370496.0 {
  75090 	} else if n == 0 {
  75091 		*(*float64)(unsafe.Pointer(bp + 16)) = float64(libc.Int64FromFloat64(*(*float64)(unsafe.Pointer(bp + 16)) + func() float64 {
  75092 			if *(*float64)(unsafe.Pointer(bp + 16)) < float64(0) {
  75093 				return -0.5
  75094 			}
  75095 			return +0.5
  75096 		}()))
  75097 	} else {
  75098 		zBuf = Xsqlite3_mprintf(tls, ts+14863, libc.VaList(bp, n, *(*float64)(unsafe.Pointer(bp + 16))))
  75099 		if zBuf == uintptr(0) {
  75100 			Xsqlite3_result_error_nomem(tls, context)
  75101 			return
  75102 		}
  75103 		Xsqlite3AtoF(tls, zBuf, bp+16, Xsqlite3Strlen30(tls, zBuf), uint8(SQLITE_UTF8))
  75104 		Xsqlite3_free(tls, zBuf)
  75105 	}
  75106 	Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 16)))
  75107 }
  75108 
  75109 func contextMalloc(tls *libc.TLS, context uintptr, nByte I64) uintptr {
  75110 	var z uintptr
  75111 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75112 
  75113 	if nByte > I64(*(*int32)(unsafe.Pointer(db + 120))) {
  75114 		Xsqlite3_result_error_toobig(tls, context)
  75115 		z = uintptr(0)
  75116 	} else {
  75117 		z = Xsqlite3Malloc(tls, uint64(nByte))
  75118 		if !(z != 0) {
  75119 			Xsqlite3_result_error_nomem(tls, context)
  75120 		}
  75121 	}
  75122 	return z
  75123 }
  75124 
  75125 func upperFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75126 	var z1 uintptr
  75127 	var z2 uintptr
  75128 	var i int32
  75129 	var n int32
  75130 	_ = argc
  75131 	z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75132 	n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75133 
  75134 	if z2 != 0 {
  75135 		z1 = contextMalloc(tls, context, I64(n)+int64(1))
  75136 		if z1 != 0 {
  75137 			for i = 0; i < n; i++ {
  75138 				*(*uint8)(unsafe.Pointer(z1 + uintptr(i))) = uint8(int32(*(*uint8)(unsafe.Pointer(z2 + uintptr(i)))) & ^(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z2 + uintptr(i)))]) & 0x20))
  75139 			}
  75140 			Xsqlite3_result_text(tls, context, z1, n, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  75141 		}
  75142 	}
  75143 }
  75144 
  75145 func lowerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75146 	var z1 uintptr
  75147 	var z2 uintptr
  75148 	var i int32
  75149 	var n int32
  75150 	_ = argc
  75151 	z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75152 	n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75153 
  75154 	if z2 != 0 {
  75155 		z1 = contextMalloc(tls, context, I64(n)+int64(1))
  75156 		if z1 != 0 {
  75157 			for i = 0; i < n; i++ {
  75158 				*(*uint8)(unsafe.Pointer(z1 + uintptr(i))) = Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(z2 + uintptr(i)))]
  75159 			}
  75160 			Xsqlite3_result_text(tls, context, z1, n, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  75161 		}
  75162 	}
  75163 }
  75164 
  75165 func randomFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
  75166 	bp := tls.Alloc(8)
  75167 	defer tls.Free(8)
  75168 
  75169 	_ = NotUsed
  75170 	_ = NotUsed2
  75171 	Xsqlite3_randomness(tls, int32(unsafe.Sizeof(Sqlite_int64(0))), bp)
  75172 	if *(*Sqlite_int64)(unsafe.Pointer(bp)) < int64(0) {
  75173 		*(*Sqlite_int64)(unsafe.Pointer(bp)) = -(*(*Sqlite_int64)(unsafe.Pointer(bp)) & (int64(0xffffffff) | int64(0x7fffffff)<<32))
  75174 	}
  75175 	Xsqlite3_result_int64(tls, context, *(*Sqlite_int64)(unsafe.Pointer(bp)))
  75176 }
  75177 
  75178 func randomBlob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75179 	var n Sqlite3_int64
  75180 	var p uintptr
  75181 
  75182 	_ = argc
  75183 	n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75184 	if n < int64(1) {
  75185 		n = int64(1)
  75186 	}
  75187 	p = contextMalloc(tls, context, n)
  75188 	if p != 0 {
  75189 		Xsqlite3_randomness(tls, int32(n), p)
  75190 		Xsqlite3_result_blob(tls, context, p, int32(n), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  75191 	}
  75192 }
  75193 
  75194 func last_insert_rowid(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
  75195 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75196 	_ = NotUsed
  75197 	_ = NotUsed2
  75198 
  75199 	Xsqlite3_result_int64(tls, context, Xsqlite3_last_insert_rowid(tls, db))
  75200 }
  75201 
  75202 func changes(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
  75203 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75204 	_ = NotUsed
  75205 	_ = NotUsed2
  75206 	Xsqlite3_result_int64(tls, context, Xsqlite3_changes64(tls, db))
  75207 }
  75208 
  75209 func total_changes(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
  75210 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75211 	_ = NotUsed
  75212 	_ = NotUsed2
  75213 
  75214 	Xsqlite3_result_int64(tls, context, Xsqlite3_total_changes64(tls, db))
  75215 }
  75216 
  75217 type compareInfo = struct {
  75218 	FmatchAll U8
  75219 	FmatchOne U8
  75220 	FmatchSet U8
  75221 	FnoCase   U8
  75222 }
  75223 
  75224 var globInfo = compareInfo{FmatchAll: U8('*'), FmatchOne: U8('?'), FmatchSet: U8('[')}
  75225 
  75226 var likeInfoNorm = compareInfo{FmatchAll: U8('%'), FmatchOne: U8('_'), FnoCase: U8(1)}
  75227 
  75228 var likeInfoAlt = compareInfo{FmatchAll: U8('%'), FmatchOne: U8('_')}
  75229 
  75230 func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uintptr, matchOther U32) int32 {
  75231 	bp := tls.Alloc(11)
  75232 	defer tls.Free(11)
  75233 	*(*uintptr)(unsafe.Pointer(bp)) = zPattern
  75234 	*(*uintptr)(unsafe.Pointer(bp + 4)) = zString
  75235 
  75236 	var c U32
  75237 	var c2 U32
  75238 	var matchOne U32 = U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchOne)
  75239 	var matchAll U32 = U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchAll)
  75240 	var noCase U8 = (*compareInfo)(unsafe.Pointer(pInfo)).FnoCase
  75241 	var zEscaped uintptr = uintptr(0)
  75242 
  75243 	for libc.AssignUint32(&c, func() uint32 {
  75244 		if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) < 0x80 {
  75245 			return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp)), 1))))
  75246 		}
  75247 		return Xsqlite3Utf8Read(tls, bp)
  75248 	}()) != U32(0) {
  75249 		if c == matchAll {
  75250 			for libc.AssignUint32(&c, func() uint32 {
  75251 				if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) < 0x80 {
  75252 					return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp)), 1))))
  75253 				}
  75254 				return Xsqlite3Utf8Read(tls, bp)
  75255 			}()) == matchAll ||
  75256 				c == matchOne && matchOne != U32(0) {
  75257 				if c == matchOne && Xsqlite3Utf8Read(tls, bp+4) == U32(0) {
  75258 					return SQLITE_NOWILDCARDMATCH
  75259 				}
  75260 			}
  75261 			if c == U32(0) {
  75262 				return SQLITE_MATCH
  75263 			} else if c == matchOther {
  75264 				if int32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 {
  75265 					c = Xsqlite3Utf8Read(tls, bp)
  75266 					if c == U32(0) {
  75267 						return SQLITE_NOWILDCARDMATCH
  75268 					}
  75269 				} else {
  75270 					for *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))) != 0 {
  75271 						var bMatch int32 = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp))+libc.UintptrFromInt32(-1), *(*uintptr)(unsafe.Pointer(bp + 4)), pInfo, matchOther)
  75272 						if bMatch != SQLITE_NOMATCH {
  75273 							return bMatch
  75274 						}
  75275 						{
  75276 							if int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 4)), 1)))) >= 0xc0 {
  75277 								for int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))))&0xc0 == 0x80 {
  75278 									*(*uintptr)(unsafe.Pointer(bp + 4))++
  75279 								}
  75280 							}
  75281 						}
  75282 
  75283 					}
  75284 					return SQLITE_NOWILDCARDMATCH
  75285 				}
  75286 			}
  75287 
  75288 			if c < U32(0x80) {
  75289 				var bMatch int32
  75290 				if noCase != 0 {
  75291 					*(*uint8)(unsafe.Pointer(bp + 8)) = uint8(c & U32(^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20)))
  75292 					*(*uint8)(unsafe.Pointer(bp + 8 + 1)) = Xsqlite3UpperToLower[uint8(c)]
  75293 					*(*uint8)(unsafe.Pointer(bp + 8 + 2)) = uint8(0)
  75294 				} else {
  75295 					*(*uint8)(unsafe.Pointer(bp + 8)) = uint8(c)
  75296 					*(*uint8)(unsafe.Pointer(bp + 8 + 1)) = uint8(0)
  75297 				}
  75298 				for 1 != 0 {
  75299 					*(*uintptr)(unsafe.Pointer(bp + 4)) += uintptr(libc.Xstrcspn(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), bp+8))
  75300 					if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4))))) == 0 {
  75301 						break
  75302 					}
  75303 					*(*uintptr)(unsafe.Pointer(bp + 4))++
  75304 					bMatch = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 4)), pInfo, matchOther)
  75305 					if bMatch != SQLITE_NOMATCH {
  75306 						return bMatch
  75307 					}
  75308 				}
  75309 			} else {
  75310 				var bMatch int32
  75311 				for libc.AssignUint32(&c2, func() uint32 {
  75312 					if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4))))) < 0x80 {
  75313 						return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 4)), 1))))
  75314 					}
  75315 					return Xsqlite3Utf8Read(tls, bp+4)
  75316 				}()) != U32(0) {
  75317 					if c2 != c {
  75318 						continue
  75319 					}
  75320 					bMatch = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 4)), pInfo, matchOther)
  75321 					if bMatch != SQLITE_NOMATCH {
  75322 						return bMatch
  75323 					}
  75324 				}
  75325 			}
  75326 			return SQLITE_NOWILDCARDMATCH
  75327 		}
  75328 		if c == matchOther {
  75329 			if int32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 {
  75330 				c = Xsqlite3Utf8Read(tls, bp)
  75331 				if c == U32(0) {
  75332 					return SQLITE_NOMATCH
  75333 				}
  75334 				zEscaped = *(*uintptr)(unsafe.Pointer(bp))
  75335 			} else {
  75336 				var prior_c U32 = U32(0)
  75337 				var seen int32 = 0
  75338 				var invert int32 = 0
  75339 				c = Xsqlite3Utf8Read(tls, bp+4)
  75340 				if c == U32(0) {
  75341 					return SQLITE_NOMATCH
  75342 				}
  75343 				c2 = Xsqlite3Utf8Read(tls, bp)
  75344 				if c2 == U32('^') {
  75345 					invert = 1
  75346 					c2 = Xsqlite3Utf8Read(tls, bp)
  75347 				}
  75348 				if c2 == U32(']') {
  75349 					if c == U32(']') {
  75350 						seen = 1
  75351 					}
  75352 					c2 = Xsqlite3Utf8Read(tls, bp)
  75353 				}
  75354 				for c2 != 0 && c2 != U32(']') {
  75355 					if c2 == U32('-') && int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != ']' && int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0 && prior_c > U32(0) {
  75356 						c2 = Xsqlite3Utf8Read(tls, bp)
  75357 						if c >= prior_c && c <= c2 {
  75358 							seen = 1
  75359 						}
  75360 						prior_c = U32(0)
  75361 					} else {
  75362 						if c == c2 {
  75363 							seen = 1
  75364 						}
  75365 						prior_c = c2
  75366 					}
  75367 					c2 = Xsqlite3Utf8Read(tls, bp)
  75368 				}
  75369 				if c2 == U32(0) || seen^invert == 0 {
  75370 					return SQLITE_NOMATCH
  75371 				}
  75372 				continue
  75373 			}
  75374 		}
  75375 		c2 = func() uint32 {
  75376 			if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4))))) < 0x80 {
  75377 				return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 4)), 1))))
  75378 			}
  75379 			return Xsqlite3Utf8Read(tls, bp+4)
  75380 		}()
  75381 		if c == c2 {
  75382 			continue
  75383 		}
  75384 		if noCase != 0 && int32(Xsqlite3UpperToLower[uint8(c)]) == int32(Xsqlite3UpperToLower[uint8(c2)]) && c < U32(0x80) && c2 < U32(0x80) {
  75385 			continue
  75386 		}
  75387 		if c == matchOne && *(*uintptr)(unsafe.Pointer(bp)) != zEscaped && c2 != U32(0) {
  75388 			continue
  75389 		}
  75390 		return SQLITE_NOMATCH
  75391 	}
  75392 	if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4))))) == 0 {
  75393 		return SQLITE_MATCH
  75394 	}
  75395 	return SQLITE_NOMATCH
  75396 }
  75397 
  75398 // The sqlite3_strglob() interface.  Return 0 on a match (like strcmp()) and
  75399 // non-zero if there is no match.
  75400 func Xsqlite3_strglob(tls *libc.TLS, zGlobPattern uintptr, zString uintptr) int32 {
  75401 	if zString == uintptr(0) {
  75402 		return libc.Bool32(zGlobPattern != uintptr(0))
  75403 	} else if zGlobPattern == uintptr(0) {
  75404 		return 1
  75405 	} else {
  75406 		return patternCompare(tls, zGlobPattern, zString, uintptr(unsafe.Pointer(&globInfo)), uint32('['))
  75407 	}
  75408 	return int32(0)
  75409 }
  75410 
  75411 // The sqlite3_strlike() interface.  Return 0 on a match and non-zero for
  75412 // a miss - like strcmp().
  75413 func Xsqlite3_strlike(tls *libc.TLS, zPattern uintptr, zStr uintptr, esc uint32) int32 {
  75414 	if zStr == uintptr(0) {
  75415 		return libc.Bool32(zPattern != uintptr(0))
  75416 	} else if zPattern == uintptr(0) {
  75417 		return 1
  75418 	} else {
  75419 		return patternCompare(tls, zPattern, zStr, uintptr(unsafe.Pointer(&likeInfoNorm)), esc)
  75420 	}
  75421 	return int32(0)
  75422 }
  75423 
  75424 func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75425 	bp := tls.Alloc(8)
  75426 	defer tls.Free(8)
  75427 
  75428 	var zA uintptr
  75429 	var zB uintptr
  75430 	var escape U32
  75431 	var nPat int32
  75432 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75433 	var pInfo uintptr = Xsqlite3_user_data(tls, context)
  75434 
  75435 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB ||
  75436 		Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))) == SQLITE_BLOB {
  75437 		Xsqlite3_result_int(tls, context, 0)
  75438 		return
  75439 	}
  75440 
  75441 	nPat = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75442 
  75443 	if nPat > *(*int32)(unsafe.Pointer(db + 120 + 8*4)) {
  75444 		Xsqlite3_result_error(tls, context, ts+14868, -1)
  75445 		return
  75446 	}
  75447 	if argc == 3 {
  75448 		*(*uintptr)(unsafe.Pointer(bp)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
  75449 		if *(*uintptr)(unsafe.Pointer(bp)) == uintptr(0) {
  75450 			return
  75451 		}
  75452 		if Xsqlite3Utf8CharLen(tls, *(*uintptr)(unsafe.Pointer(bp)), -1) != 1 {
  75453 			Xsqlite3_result_error(tls, context,
  75454 				ts+14901, -1)
  75455 			return
  75456 		}
  75457 		escape = Xsqlite3Utf8Read(tls, bp)
  75458 		if escape == U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchAll) || escape == U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchOne) {
  75459 			libc.Xmemcpy(tls, bp+4, pInfo, uint32(unsafe.Sizeof(compareInfo{})))
  75460 			pInfo = bp + 4
  75461 			if escape == U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchAll) {
  75462 				(*compareInfo)(unsafe.Pointer(pInfo)).FmatchAll = U8(0)
  75463 			}
  75464 			if escape == U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchOne) {
  75465 				(*compareInfo)(unsafe.Pointer(pInfo)).FmatchOne = U8(0)
  75466 			}
  75467 		}
  75468 	} else {
  75469 		escape = U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet)
  75470 	}
  75471 	zB = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75472 	zA = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  75473 	if zA != 0 && zB != 0 {
  75474 		Xsqlite3_result_int(tls, context,
  75475 			libc.Bool32(patternCompare(tls, zB, zA, pInfo, escape) == SQLITE_MATCH))
  75476 	}
  75477 }
  75478 
  75479 func nullifFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  75480 	var pColl uintptr = sqlite3GetFuncCollSeq(tls, context)
  75481 	_ = NotUsed
  75482 	if Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*uintptr)(unsafe.Pointer(argv + 1*4)), pColl) != 0 {
  75483 		Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv)))
  75484 	}
  75485 }
  75486 
  75487 func versionFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
  75488 	_ = NotUsed
  75489 	_ = NotUsed2
  75490 
  75491 	Xsqlite3_result_text(tls, context, Xsqlite3_libversion(tls), -1, uintptr(0))
  75492 }
  75493 
  75494 func sourceidFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
  75495 	_ = NotUsed
  75496 	_ = NotUsed2
  75497 
  75498 	Xsqlite3_result_text(tls, context, Xsqlite3_sourceid(tls), -1, uintptr(0))
  75499 }
  75500 
  75501 func errlogFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75502 	bp := tls.Alloc(8)
  75503 	defer tls.Free(8)
  75504 
  75505 	_ = argc
  75506 	_ = context
  75507 	Xsqlite3_log(tls, Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))), ts+3663, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))))
  75508 }
  75509 
  75510 func compileoptionusedFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75511 	var zOptName uintptr
  75512 
  75513 	_ = argc
  75514 
  75515 	if libc.AssignUintptr(&zOptName, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != uintptr(0) {
  75516 		Xsqlite3_result_int(tls, context, Xsqlite3_compileoption_used(tls, zOptName))
  75517 	}
  75518 }
  75519 
  75520 func compileoptiongetFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75521 	var n int32
  75522 
  75523 	_ = argc
  75524 
  75525 	n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75526 	Xsqlite3_result_text(tls, context, Xsqlite3_compileoption_get(tls, n), -1, uintptr(0))
  75527 }
  75528 
  75529 var hexdigits = [16]uint8{
  75530 	uint8('0'), uint8('1'), uint8('2'), uint8('3'), uint8('4'), uint8('5'), uint8('6'), uint8('7'),
  75531 	uint8('8'), uint8('9'), uint8('A'), uint8('B'), uint8('C'), uint8('D'), uint8('E'), uint8('F'),
  75532 }
  75533 
  75534 // Append to pStr text that is the SQL literal representation of the
  75535 // value contained in pValue.
  75536 func Xsqlite3QuoteValue(tls *libc.TLS, pStr uintptr, pValue uintptr) {
  75537 	bp := tls.Alloc(40)
  75538 	defer tls.Free(40)
  75539 
  75540 	switch Xsqlite3_value_type(tls, pValue) {
  75541 	case SQLITE_FLOAT:
  75542 		{
  75543 			var r1 float64
  75544 
  75545 			var zVal uintptr
  75546 			r1 = Xsqlite3_value_double(tls, pValue)
  75547 			Xsqlite3_str_appendf(tls, pStr, ts+4925, libc.VaList(bp, r1))
  75548 			zVal = Xsqlite3_str_value(tls, pStr)
  75549 			if zVal != 0 {
  75550 				Xsqlite3AtoF(tls, zVal, bp+32, int32((*StrAccum)(unsafe.Pointer(pStr)).FnChar), uint8(SQLITE_UTF8))
  75551 				if r1 != *(*float64)(unsafe.Pointer(bp + 32)) {
  75552 					Xsqlite3_str_reset(tls, pStr)
  75553 					Xsqlite3_str_appendf(tls, pStr, ts+14946, libc.VaList(bp+8, r1))
  75554 				}
  75555 			}
  75556 			break
  75557 
  75558 		}
  75559 	case SQLITE_INTEGER:
  75560 		{
  75561 			Xsqlite3_str_appendf(tls, pStr, ts+1334, libc.VaList(bp+16, Xsqlite3_value_int64(tls, pValue)))
  75562 			break
  75563 
  75564 		}
  75565 	case SQLITE_BLOB:
  75566 		{
  75567 			var zBlob uintptr = Xsqlite3_value_blob(tls, pValue)
  75568 			var nBlob I64 = I64(Xsqlite3_value_bytes(tls, pValue))
  75569 
  75570 			Xsqlite3StrAccumEnlarge(tls, pStr, nBlob*int64(2)+int64(4))
  75571 			if int32((*StrAccum)(unsafe.Pointer(pStr)).FaccError) == 0 {
  75572 				var zText uintptr = (*StrAccum)(unsafe.Pointer(pStr)).FzText
  75573 				var i int32
  75574 				for i = 0; I64(i) < nBlob; i++ {
  75575 					*(*uint8)(unsafe.Pointer(zText + uintptr(i*2+2))) = hexdigits[int32(*(*uint8)(unsafe.Pointer(zBlob + uintptr(i))))>>4&0x0F]
  75576 					*(*uint8)(unsafe.Pointer(zText + uintptr(i*2+3))) = hexdigits[int32(*(*uint8)(unsafe.Pointer(zBlob + uintptr(i))))&0x0F]
  75577 				}
  75578 				*(*uint8)(unsafe.Pointer(zText + uintptr(nBlob*int64(2)+int64(2)))) = uint8('\'')
  75579 				*(*uint8)(unsafe.Pointer(zText + uintptr(nBlob*int64(2)+int64(3)))) = uint8(0)
  75580 				*(*uint8)(unsafe.Pointer(zText)) = uint8('X')
  75581 				*(*uint8)(unsafe.Pointer(zText + 1)) = uint8('\'')
  75582 				(*StrAccum)(unsafe.Pointer(pStr)).FnChar = U32(nBlob*int64(2) + int64(3))
  75583 			}
  75584 			break
  75585 
  75586 		}
  75587 	case SQLITE_TEXT:
  75588 		{
  75589 			var zArg uintptr = Xsqlite3_value_text(tls, pValue)
  75590 			Xsqlite3_str_appendf(tls, pStr, ts+14953, libc.VaList(bp+24, zArg))
  75591 			break
  75592 
  75593 		}
  75594 	default:
  75595 		{
  75596 			Xsqlite3_str_append(tls, pStr, ts+1555, 4)
  75597 			break
  75598 
  75599 		}
  75600 	}
  75601 }
  75602 
  75603 func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75604 	bp := tls.Alloc(24)
  75605 	defer tls.Free(24)
  75606 
  75607 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75608 
  75609 	_ = argc
  75610 	Xsqlite3StrAccumInit(tls, bp, db, uintptr(0), 0, *(*int32)(unsafe.Pointer(db + 120)))
  75611 	Xsqlite3QuoteValue(tls, bp, *(*uintptr)(unsafe.Pointer(argv)))
  75612 	Xsqlite3_result_text(tls, context, Xsqlite3StrAccumFinish(tls, bp), int32((*Sqlite3_str)(unsafe.Pointer(bp)).FnChar),
  75613 		*(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  75614 	if int32((*Sqlite3_str)(unsafe.Pointer(bp)).FaccError) != SQLITE_OK {
  75615 		Xsqlite3_result_null(tls, context)
  75616 		Xsqlite3_result_error_code(tls, context, int32((*Sqlite3_str)(unsafe.Pointer(bp)).FaccError))
  75617 	}
  75618 }
  75619 
  75620 func unicodeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75621 	bp := tls.Alloc(4)
  75622 	defer tls.Free(4)
  75623 
  75624 	*(*uintptr)(unsafe.Pointer(bp)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75625 	_ = argc
  75626 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 && *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))) != 0 {
  75627 		Xsqlite3_result_int(tls, context, int32(Xsqlite3Utf8Read(tls, bp)))
  75628 	}
  75629 }
  75630 
  75631 func charFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75632 	var z uintptr
  75633 	var zOut uintptr
  75634 	var i int32
  75635 	zOut = libc.AssignUintptr(&z, Xsqlite3_malloc64(tls, uint64(argc*4+1)))
  75636 	if z == uintptr(0) {
  75637 		Xsqlite3_result_error_nomem(tls, context)
  75638 		return
  75639 	}
  75640 	for i = 0; i < argc; i++ {
  75641 		var x Sqlite3_int64
  75642 		var c uint32
  75643 		x = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
  75644 		if x < int64(0) || x > int64(0x10ffff) {
  75645 			x = int64(0xfffd)
  75646 		}
  75647 		c = uint32(x & int64(0x1fffff))
  75648 		if c < uint32(0x00080) {
  75649 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = U8(c & uint32(0xFF))
  75650 		} else if c < uint32(0x00800) {
  75651 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xC0 + int32(U8(c>>6&uint32(0x1F))))
  75652 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  75653 		} else if c < uint32(0x10000) {
  75654 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xE0 + int32(U8(c>>12&uint32(0x0F))))
  75655 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(c>>6&uint32(0x3F))))
  75656 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  75657 		} else {
  75658 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xF0 + int32(U8(c>>18&uint32(0x07))))
  75659 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(c>>12&uint32(0x3F))))
  75660 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(c>>6&uint32(0x3F))))
  75661 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(c&uint32(0x3F))))
  75662 		}
  75663 	}
  75664 	Xsqlite3_result_text64(tls, context, z, uint64((int32(zOut)-int32(z))/1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})), uint8(SQLITE_UTF8))
  75665 }
  75666 
  75667 func hexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75668 	var i int32
  75669 	var n int32
  75670 	var pBlob uintptr
  75671 	var zHex uintptr
  75672 	var z uintptr
  75673 
  75674 	_ = argc
  75675 	pBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75676 	n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75677 
  75678 	z = libc.AssignUintptr(&zHex, contextMalloc(tls, context, I64(n)*int64(2)+int64(1)))
  75679 	if zHex != 0 {
  75680 		i = 0
  75681 	__1:
  75682 		if !(i < n) {
  75683 			goto __3
  75684 		}
  75685 		{
  75686 			var c uint8 = *(*uint8)(unsafe.Pointer(pBlob))
  75687 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = hexdigits[int32(c)>>4&0xf]
  75688 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))) = hexdigits[int32(c)&0xf]
  75689 
  75690 		}
  75691 		goto __2
  75692 	__2:
  75693 		i++
  75694 		pBlob++
  75695 		goto __1
  75696 		goto __3
  75697 	__3:
  75698 		;
  75699 		*(*uint8)(unsafe.Pointer(z)) = uint8(0)
  75700 		Xsqlite3_result_text(tls, context, zHex, n*2, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  75701 	}
  75702 }
  75703 
  75704 func strContainsChar(tls *libc.TLS, zStr uintptr, nStr int32, ch U32) int32 {
  75705 	bp := tls.Alloc(4)
  75706 	defer tls.Free(4)
  75707 
  75708 	var zEnd uintptr = zStr + uintptr(nStr)
  75709 	*(*uintptr)(unsafe.Pointer(bp)) = zStr
  75710 	for *(*uintptr)(unsafe.Pointer(bp)) < zEnd {
  75711 		var tst U32 = func() uint32 {
  75712 			if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) < 0x80 {
  75713 				return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp)), 1))))
  75714 			}
  75715 			return Xsqlite3Utf8Read(tls, bp)
  75716 		}()
  75717 		if tst == ch {
  75718 			return 1
  75719 		}
  75720 	}
  75721 	return 0
  75722 }
  75723 
  75724 func unhexFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) {
  75725 	bp := tls.Alloc(4)
  75726 	defer tls.Free(4)
  75727 
  75728 	var zPass uintptr
  75729 	var nPass int32
  75730 
  75731 	var nHex int32
  75732 	var pBlob uintptr
  75733 	var p uintptr
  75734 	var ch U32
  75735 	var c U8
  75736 	var d U8
  75737 	zPass = ts + 1554
  75738 	nPass = 0
  75739 	*(*uintptr)(unsafe.Pointer(bp)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75740 	nHex = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75741 	pBlob = uintptr(0)
  75742 	p = uintptr(0)
  75743 
  75744 	if !(argc == 2) {
  75745 		goto __1
  75746 	}
  75747 	zPass = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  75748 	nPass = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  75749 __1:
  75750 	;
  75751 	if !(!(*(*uintptr)(unsafe.Pointer(bp)) != 0) || !(zPass != 0)) {
  75752 		goto __2
  75753 	}
  75754 	return
  75755 __2:
  75756 	;
  75757 	p = libc.AssignUintptr(&pBlob, contextMalloc(tls, pCtx, int64(nHex/2+1)))
  75758 	if !(pBlob != 0) {
  75759 		goto __3
  75760 	}
  75761 
  75762 __4:
  75763 	if !(int32(libc.AssignUint8(&c, *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))))) != 0x00) {
  75764 		goto __5
  75765 	}
  75766 __6:
  75767 	if !!(int32(Xsqlite3CtypeMap[c])&0x08 != 0) {
  75768 		goto __7
  75769 	}
  75770 	ch = func() uint32 {
  75771 		if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) < 0x80 {
  75772 			return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp)), 1))))
  75773 		}
  75774 		return Xsqlite3Utf8Read(tls, bp)
  75775 	}()
  75776 
  75777 	if !!(strContainsChar(tls, zPass, nPass, ch) != 0) {
  75778 		goto __8
  75779 	}
  75780 	goto unhex_null
  75781 __8:
  75782 	;
  75783 	c = *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))
  75784 	if !(int32(c) == 0x00) {
  75785 		goto __9
  75786 	}
  75787 	goto unhex_done
  75788 __9:
  75789 	;
  75790 	goto __6
  75791 __7:
  75792 	;
  75793 	*(*uintptr)(unsafe.Pointer(bp))++
  75794 
  75795 	d = *(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp)), 1)))
  75796 	if !!(int32(Xsqlite3CtypeMap[d])&0x08 != 0) {
  75797 		goto __10
  75798 	}
  75799 	goto unhex_null
  75800 __10:
  75801 	;
  75802 	*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))) = U8(int32(Xsqlite3HexToInt(tls, int32(c)))<<4 | int32(Xsqlite3HexToInt(tls, int32(d))))
  75803 	goto __4
  75804 __5:
  75805 	;
  75806 __3:
  75807 	;
  75808 unhex_done:
  75809 	Xsqlite3_result_blob(tls, pCtx, pBlob, (int32(p)-int32(pBlob))/1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  75810 	return
  75811 
  75812 unhex_null:
  75813 	Xsqlite3_free(tls, pBlob)
  75814 	return
  75815 }
  75816 
  75817 func zeroblobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75818 	var n I64
  75819 	var rc int32
  75820 
  75821 	_ = argc
  75822 	n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75823 	if n < int64(0) {
  75824 		n = int64(0)
  75825 	}
  75826 	rc = Xsqlite3_result_zeroblob64(tls, context, uint64(n))
  75827 	if rc != 0 {
  75828 		Xsqlite3_result_error_code(tls, context, rc)
  75829 	}
  75830 }
  75831 
  75832 func replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75833 	var zStr uintptr
  75834 	var zPattern uintptr
  75835 	var zRep uintptr
  75836 	var zOut uintptr
  75837 	var nStr int32
  75838 	var nPattern int32
  75839 	var nRep int32
  75840 	var nOut I64
  75841 	var loopLimit int32
  75842 	var i int32
  75843 	var j int32
  75844 	var cntExpand uint32
  75845 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  75846 
  75847 	_ = argc
  75848 	zStr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75849 	if zStr == uintptr(0) {
  75850 		return
  75851 	}
  75852 	nStr = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75853 
  75854 	zPattern = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  75855 	if zPattern == uintptr(0) {
  75856 		return
  75857 	}
  75858 	if int32(*(*uint8)(unsafe.Pointer(zPattern))) == 0 {
  75859 		Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv)))
  75860 		return
  75861 	}
  75862 	nPattern = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  75863 
  75864 	zRep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
  75865 	if zRep == uintptr(0) {
  75866 		return
  75867 	}
  75868 	nRep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
  75869 
  75870 	nOut = I64(nStr + 1)
  75871 
  75872 	zOut = contextMalloc(tls, context, nOut)
  75873 	if zOut == uintptr(0) {
  75874 		return
  75875 	}
  75876 	loopLimit = nStr - nPattern
  75877 	cntExpand = uint32(0)
  75878 	for i = libc.AssignInt32(&j, 0); i <= loopLimit; i++ {
  75879 		if int32(*(*uint8)(unsafe.Pointer(zStr + uintptr(i)))) != int32(*(*uint8)(unsafe.Pointer(zPattern))) || libc.Xmemcmp(tls, zStr+uintptr(i), zPattern, uint32(nPattern)) != 0 {
  75880 			*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&j, 1)))) = *(*uint8)(unsafe.Pointer(zStr + uintptr(i)))
  75881 		} else {
  75882 			if nRep > nPattern {
  75883 				nOut = nOut + I64(nRep-nPattern)
  75884 
  75885 				if nOut-int64(1) > I64(*(*int32)(unsafe.Pointer(db + 120))) {
  75886 					Xsqlite3_result_error_toobig(tls, context)
  75887 					Xsqlite3_free(tls, zOut)
  75888 					return
  75889 				}
  75890 				cntExpand++
  75891 				if cntExpand&(cntExpand-uint32(1)) == uint32(0) {
  75892 					var zOld uintptr
  75893 					zOld = zOut
  75894 					zOut = Xsqlite3Realloc(tls, zOut, uint64(I64(int32(nOut))+(nOut-I64(nStr)-int64(1))))
  75895 					if zOut == uintptr(0) {
  75896 						Xsqlite3_result_error_nomem(tls, context)
  75897 						Xsqlite3_free(tls, zOld)
  75898 						return
  75899 					}
  75900 				}
  75901 			}
  75902 			libc.Xmemcpy(tls, zOut+uintptr(j), zRep, uint32(nRep))
  75903 			j = j + nRep
  75904 			i = i + (nPattern - 1)
  75905 		}
  75906 	}
  75907 
  75908 	libc.Xmemcpy(tls, zOut+uintptr(j), zStr+uintptr(i), uint32(nStr-i))
  75909 	j = j + (nStr - i)
  75910 
  75911 	*(*uint8)(unsafe.Pointer(zOut + uintptr(j))) = uint8(0)
  75912 	Xsqlite3_result_text(tls, context, zOut, j, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
  75913 }
  75914 
  75915 func trimFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  75916 	var zIn uintptr
  75917 	var zCharSet uintptr
  75918 	var nIn uint32
  75919 	var flags int32
  75920 	var i int32
  75921 	var aLen uintptr = uintptr(0)
  75922 	var azChar uintptr = uintptr(0)
  75923 	var nChar int32
  75924 
  75925 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL {
  75926 		return
  75927 	}
  75928 	zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  75929 	if zIn == uintptr(0) {
  75930 		return
  75931 	}
  75932 	nIn = uint32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))))
  75933 
  75934 	if argc == 1 {
  75935 		nChar = 1
  75936 		aLen = uintptr(unsafe.Pointer(&lenOne))
  75937 		azChar = uintptr(unsafe.Pointer(&azOne))
  75938 		zCharSet = uintptr(0)
  75939 	} else if libc.AssignUintptr(&zCharSet, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))) == uintptr(0) {
  75940 		return
  75941 	} else {
  75942 		var z uintptr
  75943 		z = zCharSet
  75944 		nChar = 0
  75945 		for ; *(*uint8)(unsafe.Pointer(z)) != 0; nChar++ {
  75946 			{
  75947 				if int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) >= 0xc0 {
  75948 					for int32(*(*uint8)(unsafe.Pointer(z)))&0xc0 == 0x80 {
  75949 						z++
  75950 					}
  75951 				}
  75952 			}
  75953 
  75954 		}
  75955 		if nChar > 0 {
  75956 			azChar = contextMalloc(tls, context,
  75957 				I64(nChar)*int64(uint32(unsafe.Sizeof(uintptr(0)))+uint32(unsafe.Sizeof(uint32(0)))))
  75958 			if azChar == uintptr(0) {
  75959 				return
  75960 			}
  75961 			aLen = azChar + uintptr(nChar)*4
  75962 			z = zCharSet
  75963 			nChar = 0
  75964 			for ; *(*uint8)(unsafe.Pointer(z)) != 0; nChar++ {
  75965 				*(*uintptr)(unsafe.Pointer(azChar + uintptr(nChar)*4)) = z
  75966 				{
  75967 					if int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) >= 0xc0 {
  75968 						for int32(*(*uint8)(unsafe.Pointer(z)))&0xc0 == 0x80 {
  75969 							z++
  75970 						}
  75971 					}
  75972 				}
  75973 
  75974 				*(*uint32)(unsafe.Pointer(aLen + uintptr(nChar)*4)) = uint32((int32(z) - int32(*(*uintptr)(unsafe.Pointer(azChar + uintptr(nChar)*4)))) / 1)
  75975 			}
  75976 		}
  75977 	}
  75978 	if nChar > 0 {
  75979 		flags = int32(Xsqlite3_user_data(tls, context))
  75980 		if flags&1 != 0 {
  75981 			for nIn > uint32(0) {
  75982 				var len uint32 = uint32(0)
  75983 				for i = 0; i < nChar; i++ {
  75984 					len = *(*uint32)(unsafe.Pointer(aLen + uintptr(i)*4))
  75985 					if len <= nIn && libc.Xmemcmp(tls, zIn, *(*uintptr)(unsafe.Pointer(azChar + uintptr(i)*4)), len) == 0 {
  75986 						break
  75987 					}
  75988 				}
  75989 				if i >= nChar {
  75990 					break
  75991 				}
  75992 				zIn += uintptr(len)
  75993 				nIn = nIn - len
  75994 			}
  75995 		}
  75996 		if flags&2 != 0 {
  75997 			for nIn > uint32(0) {
  75998 				var len uint32 = uint32(0)
  75999 				for i = 0; i < nChar; i++ {
  76000 					len = *(*uint32)(unsafe.Pointer(aLen + uintptr(i)*4))
  76001 					if len <= nIn && libc.Xmemcmp(tls, zIn+uintptr(nIn-len), *(*uintptr)(unsafe.Pointer(azChar + uintptr(i)*4)), len) == 0 {
  76002 						break
  76003 					}
  76004 				}
  76005 				if i >= nChar {
  76006 					break
  76007 				}
  76008 				nIn = nIn - len
  76009 			}
  76010 		}
  76011 		if zCharSet != 0 {
  76012 			Xsqlite3_free(tls, azChar)
  76013 		}
  76014 	}
  76015 	Xsqlite3_result_text(tls, context, zIn, int32(nIn), libc.UintptrFromInt32(-1))
  76016 }
  76017 
  76018 var lenOne = [1]uint32{uint32(1)}
  76019 var azOne = [1]uintptr{ts + 10920}
  76020 
  76021 func soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76022 	bp := tls.Alloc(8)
  76023 	defer tls.Free(8)
  76024 
  76025 	var zIn uintptr
  76026 	var i int32
  76027 	var j int32
  76028 
  76029 	zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76030 	if zIn == uintptr(0) {
  76031 		zIn = ts + 1554
  76032 	}
  76033 	for i = 0; *(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0 && !(int32(Xsqlite3CtypeMap[*(*U8)(unsafe.Pointer(zIn + uintptr(i)))])&0x02 != 0); i++ {
  76034 	}
  76035 	if *(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0 {
  76036 		var prevcode U8 = iCode[int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i))))&0x7f]
  76037 		*(*uint8)(unsafe.Pointer(bp)) = uint8(int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i)))) & ^(int32(Xsqlite3CtypeMap[*(*U8)(unsafe.Pointer(zIn + uintptr(i)))]) & 0x20))
  76038 		for j = 1; j < 4 && *(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0; i++ {
  76039 			var code int32 = int32(iCode[int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i))))&0x7f])
  76040 			if code > 0 {
  76041 				if code != int32(prevcode) {
  76042 					prevcode = U8(code)
  76043 					*(*uint8)(unsafe.Pointer(bp + uintptr(libc.PostIncInt32(&j, 1)))) = uint8(code + '0')
  76044 				}
  76045 			} else {
  76046 				prevcode = U8(0)
  76047 			}
  76048 		}
  76049 		for j < 4 {
  76050 			*(*uint8)(unsafe.Pointer(bp + uintptr(libc.PostIncInt32(&j, 1)))) = uint8('0')
  76051 		}
  76052 		*(*uint8)(unsafe.Pointer(bp + uintptr(j))) = uint8(0)
  76053 		Xsqlite3_result_text(tls, context, bp, 4, libc.UintptrFromInt32(-1))
  76054 	} else {
  76055 		Xsqlite3_result_text(tls, context, ts+14956, 4, uintptr(0))
  76056 	}
  76057 }
  76058 
  76059 var iCode = [128]uint8{
  76060 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
  76061 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
  76062 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
  76063 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
  76064 	uint8(0), uint8(0), uint8(1), uint8(2), uint8(3), uint8(0), uint8(1), uint8(2), uint8(0), uint8(0), uint8(2), uint8(2), uint8(4), uint8(5), uint8(5), uint8(0),
  76065 	uint8(1), uint8(2), uint8(6), uint8(2), uint8(3), uint8(0), uint8(1), uint8(0), uint8(2), uint8(0), uint8(2), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
  76066 	uint8(0), uint8(0), uint8(1), uint8(2), uint8(3), uint8(0), uint8(1), uint8(2), uint8(0), uint8(0), uint8(2), uint8(2), uint8(4), uint8(5), uint8(5), uint8(0),
  76067 	uint8(1), uint8(2), uint8(6), uint8(2), uint8(3), uint8(0), uint8(1), uint8(0), uint8(2), uint8(0), uint8(2), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
  76068 }
  76069 
  76070 func loadExt(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76071 	bp := tls.Alloc(4)
  76072 	defer tls.Free(4)
  76073 
  76074 	var zFile uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76075 	var zProc uintptr
  76076 	var db uintptr = Xsqlite3_context_db_handle(tls, context)
  76077 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  76078 
  76079 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtFunc) == uint64(0) {
  76080 		Xsqlite3_result_error(tls, context, ts+12100, -1)
  76081 		return
  76082 	}
  76083 
  76084 	if argc == 2 {
  76085 		zProc = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76086 	} else {
  76087 		zProc = uintptr(0)
  76088 	}
  76089 	if zFile != 0 && Xsqlite3_load_extension(tls, db, zFile, zProc, bp) != 0 {
  76090 		Xsqlite3_result_error(tls, context, *(*uintptr)(unsafe.Pointer(bp)), -1)
  76091 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp)))
  76092 	}
  76093 }
  76094 
  76095 // An instance of the following structure holds the context of a
  76096 // sum() or avg() aggregate computation.
  76097 type SumCtx1 = struct {
  76098 	FrSum        float64
  76099 	FiSum        I64
  76100 	Fcnt         I64
  76101 	Foverflow    U8
  76102 	Fapprox      U8
  76103 	F__ccgo_pad1 [6]byte
  76104 }
  76105 
  76106 // An instance of the following structure holds the context of a
  76107 // sum() or avg() aggregate computation.
  76108 type SumCtx = SumCtx1
  76109 
  76110 func sumStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76111 	var p uintptr
  76112 	var type1 int32
  76113 
  76114 	_ = argc
  76115 	p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(SumCtx{})))
  76116 	type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76117 	if p != 0 && type1 != SQLITE_NULL {
  76118 		(*SumCtx)(unsafe.Pointer(p)).Fcnt++
  76119 		if type1 == SQLITE_INTEGER {
  76120 			var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76121 			*(*float64)(unsafe.Pointer(p)) += float64(v)
  76122 			if int32((*SumCtx)(unsafe.Pointer(p)).Fapprox)|int32((*SumCtx)(unsafe.Pointer(p)).Foverflow) == 0 && Xsqlite3AddInt64(tls, p+8, v) != 0 {
  76123 				(*SumCtx)(unsafe.Pointer(p)).Fapprox = libc.AssignPtrUint8(p+24, U8(1))
  76124 			}
  76125 		} else {
  76126 			*(*float64)(unsafe.Pointer(p)) += Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76127 			(*SumCtx)(unsafe.Pointer(p)).Fapprox = U8(1)
  76128 		}
  76129 	}
  76130 }
  76131 
  76132 func sumInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76133 	var p uintptr
  76134 	var type1 int32
  76135 
  76136 	_ = argc
  76137 	p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(SumCtx{})))
  76138 	type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76139 
  76140 	if p != 0 && type1 != SQLITE_NULL {
  76141 		(*SumCtx)(unsafe.Pointer(p)).Fcnt--
  76142 
  76143 		if type1 == SQLITE_INTEGER && int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) == 0 {
  76144 			var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76145 			*(*float64)(unsafe.Pointer(p)) -= float64(v)
  76146 			*(*I64)(unsafe.Pointer(p + 8)) -= v
  76147 		} else {
  76148 			*(*float64)(unsafe.Pointer(p)) -= Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76149 		}
  76150 	}
  76151 }
  76152 
  76153 func sumFinalize(tls *libc.TLS, context uintptr) {
  76154 	var p uintptr
  76155 	p = Xsqlite3_aggregate_context(tls, context, 0)
  76156 	if p != 0 && (*SumCtx)(unsafe.Pointer(p)).Fcnt > int64(0) {
  76157 		if (*SumCtx)(unsafe.Pointer(p)).Foverflow != 0 {
  76158 			Xsqlite3_result_error(tls, context, ts+14846, -1)
  76159 		} else if (*SumCtx)(unsafe.Pointer(p)).Fapprox != 0 {
  76160 			Xsqlite3_result_double(tls, context, (*SumCtx)(unsafe.Pointer(p)).FrSum)
  76161 		} else {
  76162 			Xsqlite3_result_int64(tls, context, (*SumCtx)(unsafe.Pointer(p)).FiSum)
  76163 		}
  76164 	}
  76165 }
  76166 
  76167 func avgFinalize(tls *libc.TLS, context uintptr) {
  76168 	var p uintptr
  76169 	p = Xsqlite3_aggregate_context(tls, context, 0)
  76170 	if p != 0 && (*SumCtx)(unsafe.Pointer(p)).Fcnt > int64(0) {
  76171 		Xsqlite3_result_double(tls, context, (*SumCtx)(unsafe.Pointer(p)).FrSum/float64((*SumCtx)(unsafe.Pointer(p)).Fcnt))
  76172 	}
  76173 }
  76174 
  76175 func totalFinalize(tls *libc.TLS, context uintptr) {
  76176 	var p uintptr
  76177 	p = Xsqlite3_aggregate_context(tls, context, 0)
  76178 
  76179 	Xsqlite3_result_double(tls, context, func() float64 {
  76180 		if p != 0 {
  76181 			return (*SumCtx)(unsafe.Pointer(p)).FrSum
  76182 		}
  76183 		return float64(0)
  76184 	}())
  76185 }
  76186 
  76187 // The following structure keeps track of state information for the
  76188 // count() aggregate function.
  76189 type CountCtx1 = struct{ Fn I64 }
  76190 
  76191 // The following structure keeps track of state information for the
  76192 // count() aggregate function.
  76193 type CountCtx = CountCtx1
  76194 
  76195 func countStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76196 	var p uintptr
  76197 	p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(CountCtx{})))
  76198 	if (argc == 0 || SQLITE_NULL != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv)))) && p != 0 {
  76199 		(*CountCtx)(unsafe.Pointer(p)).Fn++
  76200 	}
  76201 
  76202 }
  76203 
  76204 func countFinalize(tls *libc.TLS, context uintptr) {
  76205 	var p uintptr
  76206 	p = Xsqlite3_aggregate_context(tls, context, 0)
  76207 	Xsqlite3_result_int64(tls, context, func() int64 {
  76208 		if p != 0 {
  76209 			return (*CountCtx)(unsafe.Pointer(p)).Fn
  76210 		}
  76211 		return int64(0)
  76212 	}())
  76213 }
  76214 
  76215 func countInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
  76216 	var p uintptr
  76217 	p = Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(CountCtx{})))
  76218 
  76219 	if (argc == 0 || SQLITE_NULL != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv)))) && p != 0 {
  76220 		(*CountCtx)(unsafe.Pointer(p)).Fn--
  76221 	}
  76222 }
  76223 
  76224 func minmaxStep(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
  76225 	var pArg uintptr = *(*uintptr)(unsafe.Pointer(argv))
  76226 	var pBest uintptr
  76227 	_ = NotUsed
  76228 
  76229 	pBest = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(Mem{})))
  76230 	if !(pBest != 0) {
  76231 		return
  76232 	}
  76233 
  76234 	if Xsqlite3_value_type(tls, pArg) == SQLITE_NULL {
  76235 		if (*Mem)(unsafe.Pointer(pBest)).Fflags != 0 {
  76236 			sqlite3SkipAccumulatorLoad(tls, context)
  76237 		}
  76238 	} else if (*Mem)(unsafe.Pointer(pBest)).Fflags != 0 {
  76239 		var max int32
  76240 		var cmp int32
  76241 		var pColl uintptr = sqlite3GetFuncCollSeq(tls, context)
  76242 
  76243 		max = libc.Bool32(Xsqlite3_user_data(tls, context) != uintptr(0))
  76244 		cmp = Xsqlite3MemCompare(tls, pBest, pArg, pColl)
  76245 		if max != 0 && cmp < 0 || !(max != 0) && cmp > 0 {
  76246 			Xsqlite3VdbeMemCopy(tls, pBest, pArg)
  76247 		} else {
  76248 			sqlite3SkipAccumulatorLoad(tls, context)
  76249 		}
  76250 	} else {
  76251 		(*Mem)(unsafe.Pointer(pBest)).Fdb = Xsqlite3_context_db_handle(tls, context)
  76252 		Xsqlite3VdbeMemCopy(tls, pBest, pArg)
  76253 	}
  76254 }
  76255 
  76256 func minMaxValueFinalize(tls *libc.TLS, context uintptr, bValue int32) {
  76257 	var pRes uintptr
  76258 	pRes = Xsqlite3_aggregate_context(tls, context, 0)
  76259 	if pRes != 0 {
  76260 		if (*Sqlite3_value)(unsafe.Pointer(pRes)).Fflags != 0 {
  76261 			Xsqlite3_result_value(tls, context, pRes)
  76262 		}
  76263 		if bValue == 0 {
  76264 			Xsqlite3VdbeMemRelease(tls, pRes)
  76265 		}
  76266 	}
  76267 }
  76268 
  76269 func minMaxValue(tls *libc.TLS, context uintptr) {
  76270 	minMaxValueFinalize(tls, context, 1)
  76271 }
  76272 
  76273 func minMaxFinalize(tls *libc.TLS, context uintptr) {
  76274 	minMaxValueFinalize(tls, context, 0)
  76275 }
  76276 
  76277 // group_concat(EXPR, ?SEPARATOR?)
  76278 //
  76279 // The SEPARATOR goes before the EXPR string.  This is tragic.  The
  76280 // groupConcatInverse() implementation would have been easier if the
  76281 // SEPARATOR were appended after EXPR.  And the order is undocumented,
  76282 // so we could change it, in theory.  But the old behavior has been
  76283 // around for so long that we dare not, for fear of breaking something.
  76284 type GroupConcatCtx = struct {
  76285 	Fstr             StrAccum
  76286 	FnAccum          int32
  76287 	FnFirstSepLength int32
  76288 	FpnSepLengths    uintptr
  76289 }
  76290 
  76291 func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76292 	var zVal uintptr
  76293 	var pGCC uintptr
  76294 	var zSep uintptr
  76295 	var nVal int32
  76296 	var nSep int32
  76297 
  76298 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL {
  76299 		return
  76300 	}
  76301 	pGCC = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(GroupConcatCtx{})))
  76302 	if pGCC != 0 {
  76303 		var db uintptr = Xsqlite3_context_db_handle(tls, context)
  76304 		var firstTerm int32 = libc.Bool32((*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc == U32(0))
  76305 		(*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc = U32(*(*int32)(unsafe.Pointer(db + 120)))
  76306 		if argc == 1 {
  76307 			if !(firstTerm != 0) {
  76308 				Xsqlite3_str_appendchar(tls, pGCC, 1, uint8(','))
  76309 			} else {
  76310 				(*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength = 1
  76311 			}
  76312 		} else if !(firstTerm != 0) {
  76313 			zSep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76314 			nSep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76315 			if zSep != 0 {
  76316 				Xsqlite3_str_append(tls, pGCC, zSep, nSep)
  76317 			} else {
  76318 				nSep = 0
  76319 			}
  76320 			if nSep != (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength || (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths != uintptr(0) {
  76321 				var pnsl uintptr = (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths
  76322 				if pnsl == uintptr(0) {
  76323 					pnsl = Xsqlite3_malloc64(tls, uint64(uint32((*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum+1)*uint32(unsafe.Sizeof(int32(0)))))
  76324 					if pnsl != uintptr(0) {
  76325 						var i int32 = 0
  76326 						var nA int32 = (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum - 1
  76327 						for i < nA {
  76328 							*(*int32)(unsafe.Pointer(pnsl + uintptr(libc.PostIncInt32(&i, 1))*4)) = (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength
  76329 						}
  76330 					}
  76331 				} else {
  76332 					pnsl = Xsqlite3_realloc64(tls, pnsl, uint64(uint32((*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum)*uint32(unsafe.Sizeof(int32(0)))))
  76333 				}
  76334 				if pnsl != uintptr(0) {
  76335 					if (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 {
  76336 						*(*int32)(unsafe.Pointer(pnsl + uintptr((*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum-1)*4)) = nSep
  76337 					}
  76338 					(*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths = pnsl
  76339 				} else {
  76340 					Xsqlite3StrAccumSetError(tls, pGCC, uint8(SQLITE_NOMEM))
  76341 				}
  76342 			}
  76343 		} else {
  76344 			(*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76345 		}
  76346 		*(*int32)(unsafe.Pointer(pGCC + 24)) += 1
  76347 		zVal = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76348 		nVal = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76349 		if zVal != 0 {
  76350 			Xsqlite3_str_append(tls, pGCC, zVal, nVal)
  76351 		}
  76352 	}
  76353 }
  76354 
  76355 func groupConcatInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76356 	var pGCC uintptr
  76357 
  76358 	_ = argc
  76359 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL {
  76360 		return
  76361 	}
  76362 	pGCC = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(GroupConcatCtx{})))
  76363 
  76364 	if pGCC != 0 {
  76365 		var nVS int32
  76366 
  76367 		Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76368 		nVS = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76369 		*(*int32)(unsafe.Pointer(pGCC + 24)) -= 1
  76370 		if (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths != uintptr(0) {
  76371 			if (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 {
  76372 				nVS = nVS + *(*int32)(unsafe.Pointer((*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths))
  76373 				libc.Xmemmove(tls, (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths, (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths+uintptr(1)*4,
  76374 					uint32((*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum-1)*uint32(unsafe.Sizeof(int32(0))))
  76375 			}
  76376 		} else {
  76377 			nVS = nVS + (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FnFirstSepLength
  76378 		}
  76379 		if nVS >= int32((*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar) {
  76380 			(*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar = U32(0)
  76381 		} else {
  76382 			*(*U32)(unsafe.Pointer(pGCC + 16)) -= U32(nVS)
  76383 			libc.Xmemmove(tls, (*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FzText, (*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FzText+uintptr(nVS), (*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar)
  76384 		}
  76385 		if (*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FnChar == U32(0) {
  76386 			(*GroupConcatCtx)(unsafe.Pointer(pGCC)).Fstr.FmxAlloc = U32(0)
  76387 			Xsqlite3_free(tls, (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths)
  76388 			(*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths = uintptr(0)
  76389 		}
  76390 	}
  76391 }
  76392 
  76393 func groupConcatFinalize(tls *libc.TLS, context uintptr) {
  76394 	var pGCC uintptr = Xsqlite3_aggregate_context(tls, context, 0)
  76395 	if pGCC != 0 {
  76396 		Xsqlite3ResultStrAccum(tls, context, pGCC)
  76397 		Xsqlite3_free(tls, (*GroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths)
  76398 	}
  76399 }
  76400 
  76401 func groupConcatValue(tls *libc.TLS, context uintptr) {
  76402 	var pGCC uintptr = Xsqlite3_aggregate_context(tls, context, 0)
  76403 	if pGCC != 0 {
  76404 		var pAccum uintptr = pGCC
  76405 		if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_TOOBIG {
  76406 			Xsqlite3_result_error_toobig(tls, context)
  76407 		} else if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_NOMEM {
  76408 			Xsqlite3_result_error_nomem(tls, context)
  76409 		} else {
  76410 			var zText uintptr = Xsqlite3_str_value(tls, pAccum)
  76411 			Xsqlite3_result_text(tls, context, zText, int32((*StrAccum)(unsafe.Pointer(pAccum)).FnChar), libc.UintptrFromInt32(-1))
  76412 		}
  76413 	}
  76414 }
  76415 
  76416 // This routine does per-connection function registration.  Most
  76417 // of the built-in functions above are part of the global function set.
  76418 // This routine only deals with those that are not global.
  76419 func Xsqlite3RegisterPerConnectionBuiltinFunctions(tls *libc.TLS, db uintptr) {
  76420 	var rc int32 = Xsqlite3_overload_function(tls, db, ts+14961, 2)
  76421 
  76422 	if rc == SQLITE_NOMEM {
  76423 		Xsqlite3OomFault(tls, db)
  76424 	}
  76425 }
  76426 
  76427 // Re-register the built-in LIKE functions.  The caseSensitive
  76428 // parameter determines whether or not the LIKE operator is case
  76429 // sensitive.
  76430 func Xsqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int32) {
  76431 	var pInfo uintptr
  76432 	var flags int32
  76433 	if caseSensitive != 0 {
  76434 		pInfo = uintptr(unsafe.Pointer(&likeInfoAlt))
  76435 		flags = SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE
  76436 	} else {
  76437 		pInfo = uintptr(unsafe.Pointer(&likeInfoNorm))
  76438 		flags = SQLITE_FUNC_LIKE
  76439 	}
  76440 	Xsqlite3CreateFunc(tls, db, ts+14967, 2, SQLITE_UTF8, pInfo, *(*uintptr)(unsafe.Pointer(&struct {
  76441 		f func(*libc.TLS, uintptr, int32, uintptr)
  76442 	}{likeFunc})), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
  76443 	Xsqlite3CreateFunc(tls, db, ts+14967, 3, SQLITE_UTF8, pInfo, *(*uintptr)(unsafe.Pointer(&struct {
  76444 		f func(*libc.TLS, uintptr, int32, uintptr)
  76445 	}{likeFunc})), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
  76446 	*(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+14967, 2, uint8(SQLITE_UTF8), uint8(0)) + 4)) |= U32(flags)
  76447 	*(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+14967, 3, uint8(SQLITE_UTF8), uint8(0)) + 4)) |= U32(flags)
  76448 }
  76449 
  76450 // pExpr points to an expression which implements a function.  If
  76451 // it is appropriate to apply the LIKE optimization to that function
  76452 // then set aWc[0] through aWc[2] to the wildcard characters and the
  76453 // escape character and then return TRUE.  If the function is not a
  76454 // LIKE-style function then return FALSE.
  76455 //
  76456 // The expression "a LIKE b ESCAPE c" is only considered a valid LIKE
  76457 // operator if c is a string literal that is exactly one byte in length.
  76458 // That one byte is stored in aWc[3].  aWc[3] is set to zero if there is
  76459 // no ESCAPE clause.
  76460 //
  76461 // *pIsNocase is set to true if uppercase and lowercase are equivalent for
  76462 // the function (default for LIKE).  If the function makes the distinction
  76463 // between uppercase and lowercase (as does GLOB) then *pIsNocase is set to
  76464 // false.
  76465 func Xsqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase uintptr, aWc uintptr) int32 {
  76466 	var pDef uintptr
  76467 	var nExpr int32
  76468 
  76469 	if !(int32(*(*uintptr)(unsafe.Pointer(pExpr + 20))) != 0) {
  76470 		return 0
  76471 	}
  76472 	nExpr = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FnExpr
  76473 
  76474 	pDef = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8)), nExpr, uint8(SQLITE_UTF8), uint8(0))
  76475 	if pDef == uintptr(0) || (*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_LIKE) == U32(0) {
  76476 		return 0
  76477 	}
  76478 
  76479 	libc.Xmemcpy(tls, aWc, (*FuncDef)(unsafe.Pointer(pDef)).FpUserData, uint32(3))
  76480 
  76481 	if nExpr < 3 {
  76482 		*(*uint8)(unsafe.Pointer(aWc + 3)) = uint8(0)
  76483 	} else {
  76484 		var pEscape uintptr = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)) + 8 + 2*20)).FpExpr
  76485 		var zEscape uintptr
  76486 		if int32((*Expr)(unsafe.Pointer(pEscape)).Fop) != TK_STRING {
  76487 			return 0
  76488 		}
  76489 
  76490 		zEscape = *(*uintptr)(unsafe.Pointer(pEscape + 8))
  76491 		if int32(*(*uint8)(unsafe.Pointer(zEscape))) == 0 || int32(*(*uint8)(unsafe.Pointer(zEscape + 1))) != 0 {
  76492 			return 0
  76493 		}
  76494 		if int32(*(*uint8)(unsafe.Pointer(zEscape))) == int32(*(*uint8)(unsafe.Pointer(aWc))) {
  76495 			return 0
  76496 		}
  76497 		if int32(*(*uint8)(unsafe.Pointer(zEscape))) == int32(*(*uint8)(unsafe.Pointer(aWc + 1))) {
  76498 			return 0
  76499 		}
  76500 		*(*uint8)(unsafe.Pointer(aWc + 3)) = *(*uint8)(unsafe.Pointer(zEscape))
  76501 	}
  76502 
  76503 	*(*int32)(unsafe.Pointer(pIsNocase)) = libc.Bool32((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags&U32(SQLITE_FUNC_CASE) == U32(0))
  76504 	return 1
  76505 }
  76506 
  76507 func ceilingFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76508 	switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) {
  76509 	case SQLITE_INTEGER:
  76510 		{
  76511 			Xsqlite3_result_int64(tls, context, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))))
  76512 			break
  76513 
  76514 		}
  76515 	case SQLITE_FLOAT:
  76516 		{
  76517 			var x uintptr = Xsqlite3_user_data(tls, context)
  76518 			Xsqlite3_result_double(tls, context, (*struct {
  76519 				f func(*libc.TLS, float64) float64
  76520 			})(unsafe.Pointer(&struct{ uintptr }{x})).f(tls, Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))))
  76521 			break
  76522 
  76523 		}
  76524 	default:
  76525 		{
  76526 			break
  76527 
  76528 		}
  76529 	}
  76530 }
  76531 
  76532 func xCeil(tls *libc.TLS, x float64) float64 {
  76533 	return libc.Xceil(tls, x)
  76534 }
  76535 
  76536 func xFloor(tls *libc.TLS, x float64) float64 {
  76537 	return libc.Xfloor(tls, x)
  76538 }
  76539 
  76540 func logFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76541 	var x float64
  76542 	var b float64
  76543 	var ans float64
  76544 
  76545 	switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) {
  76546 	case SQLITE_INTEGER:
  76547 		fallthrough
  76548 	case SQLITE_FLOAT:
  76549 		x = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76550 		if x <= 0.0 {
  76551 			return
  76552 		}
  76553 		break
  76554 	default:
  76555 		return
  76556 	}
  76557 	if argc == 2 {
  76558 		switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) {
  76559 		case SQLITE_INTEGER:
  76560 			fallthrough
  76561 		case SQLITE_FLOAT:
  76562 			b = libc.Xlog(tls, x)
  76563 			if b <= 0.0 {
  76564 				return
  76565 			}
  76566 			x = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76567 			if x <= 0.0 {
  76568 				return
  76569 			}
  76570 			break
  76571 			fallthrough
  76572 		default:
  76573 			return
  76574 		}
  76575 		ans = libc.Xlog(tls, x) / b
  76576 	} else {
  76577 		switch int32(Xsqlite3_user_data(tls, context)) {
  76578 		case 1:
  76579 			ans = libc.Xlog10(tls, x)
  76580 			break
  76581 			fallthrough
  76582 		case 2:
  76583 			ans = libc.Xlog2(tls, x)
  76584 			break
  76585 			fallthrough
  76586 		default:
  76587 			ans = libc.Xlog(tls, x)
  76588 			break
  76589 		}
  76590 	}
  76591 	Xsqlite3_result_double(tls, context, ans)
  76592 }
  76593 
  76594 func degToRad(tls *libc.TLS, x float64) float64 {
  76595 	return x * (float64(3.14159265358979323846) / 180.0)
  76596 }
  76597 
  76598 func radToDeg(tls *libc.TLS, x float64) float64 {
  76599 	return x * (float64(180.0) / 3.14159265358979323846)
  76600 }
  76601 
  76602 func math1Func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76603 	var type0 int32
  76604 	var v0 float64
  76605 	var ans float64
  76606 	var x uintptr
  76607 
  76608 	type0 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76609 	if type0 != SQLITE_INTEGER && type0 != SQLITE_FLOAT {
  76610 		return
  76611 	}
  76612 	v0 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76613 	x = Xsqlite3_user_data(tls, context)
  76614 	ans = (*struct {
  76615 		f func(*libc.TLS, float64) float64
  76616 	})(unsafe.Pointer(&struct{ uintptr }{x})).f(tls, v0)
  76617 	Xsqlite3_result_double(tls, context, ans)
  76618 }
  76619 
  76620 func math2Func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76621 	var type0 int32
  76622 	var type1 int32
  76623 	var v0 float64
  76624 	var v1 float64
  76625 	var ans float64
  76626 	var x uintptr
  76627 
  76628 	type0 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76629 	if type0 != SQLITE_INTEGER && type0 != SQLITE_FLOAT {
  76630 		return
  76631 	}
  76632 	type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76633 	if type1 != SQLITE_INTEGER && type1 != SQLITE_FLOAT {
  76634 		return
  76635 	}
  76636 	v0 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76637 	v1 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
  76638 	x = Xsqlite3_user_data(tls, context)
  76639 	ans = (*struct {
  76640 		f func(*libc.TLS, float64, float64) float64
  76641 	})(unsafe.Pointer(&struct{ uintptr }{x})).f(tls, v0, v1)
  76642 	Xsqlite3_result_double(tls, context, ans)
  76643 }
  76644 
  76645 func piFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76646 	_ = argv
  76647 	Xsqlite3_result_double(tls, context, 3.14159265358979323846)
  76648 }
  76649 
  76650 func signFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
  76651 	var type0 int32
  76652 	var x float64
  76653 	_ = argc
  76654 
  76655 	type0 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76656 	if type0 != SQLITE_INTEGER && type0 != SQLITE_FLOAT {
  76657 		return
  76658 	}
  76659 	x = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
  76660 	Xsqlite3_result_int(tls, context, func() int32 {
  76661 		if x < 0.0 {
  76662 			return -1
  76663 		}
  76664 		return func() int32 {
  76665 			if x > 0.0 {
  76666 				return +1
  76667 			}
  76668 			return 0
  76669 		}()
  76670 	}())
  76671 }
  76672 
  76673 // All of the FuncDef structures in the aBuiltinFunc[] array above
  76674 // to the global function hash table.  This occurs at start-time (as
  76675 // a consequence of calling sqlite3_initialize()).
  76676 //
  76677 // After this routine runs
  76678 func Xsqlite3RegisterBuiltinFunctions(tls *libc.TLS) {
  76679 	Xsqlite3AlterFunctions(tls)
  76680 	Xsqlite3WindowFunctions(tls)
  76681 	Xsqlite3RegisterDateTimeFunctions(tls)
  76682 	Xsqlite3RegisterJsonFunctions(tls)
  76683 	Xsqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&aBuiltinFunc)), int32(uint32(unsafe.Sizeof(aBuiltinFunc))/uint32(unsafe.Sizeof(FuncDef{}))))
  76684 
  76685 }
  76686 
  76687 var aBuiltinFunc = [103]FuncDef{
  76688 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INTERNAL | SQLITE_FUNC_TEST | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FpUserData: uintptr(INLINEFUNC_implies_nonnull_row), FxSFunc: 0, FzName: ts + 14972},
  76689 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INTERNAL | SQLITE_FUNC_TEST | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FpUserData: uintptr(INLINEFUNC_expr_compare), FxSFunc: 0, FzName: ts + 14992},
  76690 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INTERNAL | SQLITE_FUNC_TEST | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FpUserData: uintptr(INLINEFUNC_expr_implies_expr), FxSFunc: 0, FzName: ts + 15005},
  76691 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INTERNAL | SQLITE_FUNC_TEST | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FpUserData: uintptr(INLINEFUNC_affinity), FxSFunc: 0, FzName: ts + 15023},
  76692 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15032},
  76693 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_DIRECTONLY | SQLITE_FUNC_UNSAFE), FxSFunc: 0, FzName: ts + 15040},
  76694 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_DIRECTONLY | SQLITE_FUNC_UNSAFE), FxSFunc: 0, FzName: ts + 15040},
  76695 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 15055},
  76696 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 15081},
  76697 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | SQLITE_FUNC_UNLIKELY), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 15106},
  76698 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | SQLITE_FUNC_UNLIKELY), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 15115},
  76699 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | SQLITE_FUNC_UNLIKELY), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 15126},
  76700 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FpUserData: uintptr(INLINEFUNC_sqlite_offset), FxSFunc: 0, FzName: ts + 15133},
  76701 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(1), FxSFunc: 0, FzName: ts + 15147},
  76702 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(1), FxSFunc: 0, FzName: ts + 15147},
  76703 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(2), FxSFunc: 0, FzName: ts + 15153},
  76704 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(2), FxSFunc: 0, FzName: ts + 15153},
  76705 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(3), FxSFunc: 0, FzName: ts + 15159},
  76706 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(3), FxSFunc: 0, FzName: ts + 15159},
  76707 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15164},
  76708 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL), FzName: ts + 15164},
  76709 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_MINMAX | SQLITE_FUNC_ANYORDER), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FzName: ts + 15164},
  76710 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(1), FxSFunc: 0, FzName: ts + 15168},
  76711 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(1), FzName: ts + 15168},
  76712 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_MINMAX | SQLITE_FUNC_ANYORDER), FpUserData: uintptr(1), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FzName: ts + 15168},
  76713 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_TYPEOF), FxSFunc: 0, FzName: ts + 15172},
  76714 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_TYPEOF), FxSFunc: 0, FzName: ts + 15179},
  76715 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_LENGTH), FxSFunc: 0, FzName: ts + 15187},
  76716 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15194},
  76717 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15200},
  76718 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15207},
  76719 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15214},
  76720 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15222},
  76721 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15227},
  76722 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15231},
  76723 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15231},
  76724 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15237},
  76725 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15243},
  76726 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15249},
  76727 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15253},
  76728 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15253},
  76729 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FxSFunc: 0, FzName: ts + 15259},
  76730 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15266},
  76731 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15273},
  76732 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 1*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15284},
  76733 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 15291},
  76734 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_SLOCHNG | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 15306},
  76735 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15323},
  76736 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15334},
  76737 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15340},
  76738 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15358},
  76739 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15366},
  76740 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15380},
  76741 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15388},
  76742 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15397},
  76743 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15397},
  76744 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15404},
  76745 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15404},
  76746 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15414},
  76747 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15418},
  76748 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15424},
  76749 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_COUNT | SQLITE_FUNC_ANYORDER), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15428},
  76750 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_FUNC_ANYORDER), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15428},
  76751 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15434},
  76752 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 15434},
  76753 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE), FpUserData: 0, FxSFunc: 0, FzName: ts + 15447},
  76754 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | SQLITE_FUNC_LIKE), FpUserData: 0, FxSFunc: 0, FzName: ts + 14967},
  76755 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | SQLITE_FUNC_LIKE), FpUserData: 0, FxSFunc: 0, FzName: ts + 14967},
  76756 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FzName: ts + 6586},
  76757 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FzName: ts + 6586},
  76758 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15452},
  76759 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15457},
  76760 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15465},
  76761 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15471},
  76762 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15477},
  76763 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(1), FxSFunc: 0, FzName: ts + 15480},
  76764 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(1), FxSFunc: 0, FzName: ts + 15484},
  76765 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FpUserData: uintptr(2), FxSFunc: 0, FzName: ts + 15490},
  76766 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15480},
  76767 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15495},
  76768 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15499},
  76769 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15503},
  76770 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15509},
  76771 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15513},
  76772 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15518},
  76773 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15523},
  76774 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15528},
  76775 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15534},
  76776 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15538},
  76777 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15542},
  76778 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15546},
  76779 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15551},
  76780 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15556},
  76781 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15561},
  76782 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15567},
  76783 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15573},
  76784 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15579},
  76785 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15584},
  76786 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: 0, FxSFunc: 0, FzName: ts + 15592},
  76787 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15600},
  76788 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_FUNC_CONSTANT | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL), FxSFunc: 0, FzName: ts + 15603},
  76789 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FxSFunc: 0, FzName: ts + 6586},
  76790 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_INLINE | SQLITE_FUNC_CONSTANT | 0), FpUserData: uintptr(INLINEFUNC_iif), FxSFunc: 0, FzName: ts + 15608}}
  76791 
  76792 // A foreign key constraint requires that the key columns in the parent
  76793 // table are collectively subject to a UNIQUE or PRIMARY KEY constraint.
  76794 // Given that pParent is the parent table for foreign key constraint pFKey,
  76795 // search the schema for a unique index on the parent key columns.
  76796 //
  76797 // If successful, zero is returned. If the parent key is an INTEGER PRIMARY
  76798 // KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx
  76799 // is set to point to the unique index.
  76800 //
  76801 // If the parent key consists of a single column (the foreign key constraint
  76802 // is not a composite foreign key), output variable *paiCol is set to NULL.
  76803 // Otherwise, it is set to point to an allocated array of size N, where
  76804 // N is the number of columns in the parent key. The first element of the
  76805 // array is the index of the child table column that is mapped by the FK
  76806 // constraint to the parent table column stored in the left-most column
  76807 // of index *ppIdx. The second element of the array is the index of the
  76808 // child table column that corresponds to the second left-most column of
  76809 // *ppIdx, and so on.
  76810 //
  76811 // If the required index cannot be found, either because:
  76812 //
  76813 //  1. The named parent key columns do not exist, or
  76814 //
  76815 //  2. The named parent key columns do exist, but are not subject to a
  76816 //     UNIQUE or PRIMARY KEY constraint, or
  76817 //
  76818 //  3. No parent key columns were provided explicitly as part of the
  76819 //     foreign key definition, and the parent table does not have a
  76820 //     PRIMARY KEY, or
  76821 //
  76822 //  4. No parent key columns were provided explicitly as part of the
  76823 //     foreign key definition, and the PRIMARY KEY of the parent table
  76824 //     consists of a different number of columns to the child key in
  76825 //     the child table.
  76826 //
  76827 // then non-zero is returned, and a "foreign key mismatch" error loaded
  76828 // into pParse. If an OOM error occurs, non-zero is returned and the
  76829 // pParse->db->mallocFailed flag is set.
  76830 func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey uintptr, ppIdx uintptr, paiCol uintptr) int32 {
  76831 	bp := tls.Alloc(16)
  76832 	defer tls.Free(16)
  76833 
  76834 	var pIdx uintptr = uintptr(0)
  76835 	var aiCol uintptr = uintptr(0)
  76836 	var nCol int32 = (*FKey)(unsafe.Pointer(pFKey)).FnCol
  76837 	var zKey uintptr = (*sColMap)(unsafe.Pointer(pFKey + 36)).FzCol
  76838 
  76839 	if nCol == 1 {
  76840 		if int32((*Table)(unsafe.Pointer(pParent)).FiPKey) >= 0 {
  76841 			if !(zKey != 0) {
  76842 				return 0
  76843 			}
  76844 			if !(Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pParent)).FaCol+uintptr((*Table)(unsafe.Pointer(pParent)).FiPKey)*16)).FzCnName, zKey) != 0) {
  76845 				return 0
  76846 			}
  76847 		}
  76848 	} else if paiCol != 0 {
  76849 		aiCol = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(nCol)*uint32(unsafe.Sizeof(int32(0)))))
  76850 		if !(aiCol != 0) {
  76851 			return 1
  76852 		}
  76853 		*(*uintptr)(unsafe.Pointer(paiCol)) = aiCol
  76854 	}
  76855 
  76856 	for pIdx = (*Table)(unsafe.Pointer(pParent)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  76857 		if int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol && int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None && (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) {
  76858 			if zKey == uintptr(0) {
  76859 				if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  76860 					if aiCol != 0 {
  76861 						var i int32
  76862 						for i = 0; i < nCol; i++ {
  76863 							*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) = (*sColMap)(unsafe.Pointer(pFKey + 36 + uintptr(i)*8)).FiFrom
  76864 						}
  76865 					}
  76866 					break
  76867 				}
  76868 			} else {
  76869 				var i int32
  76870 				var j int32
  76871 				for i = 0; i < nCol; i++ {
  76872 					var iCol I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))
  76873 					var zDfltColl uintptr
  76874 					var zIdxCol uintptr
  76875 
  76876 					if int32(iCol) < 0 {
  76877 						break
  76878 					}
  76879 
  76880 					zDfltColl = Xsqlite3ColumnColl(tls, (*Table)(unsafe.Pointer(pParent)).FaCol+uintptr(iCol)*16)
  76881 					if !(zDfltColl != 0) {
  76882 						zDfltColl = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
  76883 					}
  76884 					if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*4)), zDfltColl) != 0 {
  76885 						break
  76886 					}
  76887 
  76888 					zIdxCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pParent)).FaCol + uintptr(iCol)*16)).FzCnName
  76889 					for j = 0; j < nCol; j++ {
  76890 						if Xsqlite3StrICmp(tls, (*sColMap)(unsafe.Pointer(pFKey+36+uintptr(j)*8)).FzCol, zIdxCol) == 0 {
  76891 							if aiCol != 0 {
  76892 								*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) = (*sColMap)(unsafe.Pointer(pFKey + 36 + uintptr(j)*8)).FiFrom
  76893 							}
  76894 							break
  76895 						}
  76896 					}
  76897 					if j == nCol {
  76898 						break
  76899 					}
  76900 				}
  76901 				if i == nCol {
  76902 					break
  76903 				}
  76904 			}
  76905 		}
  76906 	}
  76907 
  76908 	if !(pIdx != 0) {
  76909 		if !(int32((*Parse)(unsafe.Pointer(pParse)).FdisableTriggers) != 0) {
  76910 			Xsqlite3ErrorMsg(tls, pParse,
  76911 				ts+15612,
  76912 				libc.VaList(bp, (*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName, (*FKey)(unsafe.Pointer(pFKey)).FzTo))
  76913 		}
  76914 		Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, aiCol)
  76915 		return 1
  76916 	}
  76917 
  76918 	*(*uintptr)(unsafe.Pointer(ppIdx)) = pIdx
  76919 	return 0
  76920 }
  76921 
  76922 func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx uintptr, pFKey uintptr, aiCol uintptr, regData int32, nIncr int32, isIgnore int32) {
  76923 	var i int32
  76924 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  76925 	var iCur int32 = (*Parse)(unsafe.Pointer(pParse)).FnTab - 1
  76926 	var iOk int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
  76927 
  76928 	if nIncr < 0 {
  76929 		Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), iOk)
  76930 
  76931 	}
  76932 	for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ {
  76933 		var iReg int32 = int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))))) + regData + 1
  76934 		Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, iOk)
  76935 	}
  76936 
  76937 	if isIgnore == 0 {
  76938 		if pIdx == uintptr(0) {
  76939 			var iMustBeInt int32
  76940 			var regTemp int32 = Xsqlite3GetTempReg(tls, pParse)
  76941 
  76942 			Xsqlite3VdbeAddOp2(tls, v, OP_SCopy,
  76943 				int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol)))))+1+regData, regTemp)
  76944 			iMustBeInt = Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, regTemp, 0)
  76945 
  76946 			if pTab == (*FKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr == 1 {
  76947 				Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regData, iOk, regTemp)
  76948 				Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL))
  76949 			}
  76950 
  76951 			Xsqlite3OpenTable(tls, pParse, iCur, iDb, pTab, OP_OpenRead)
  76952 			Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iCur, 0, regTemp)
  76953 			Xsqlite3VdbeGoto(tls, v, iOk)
  76954 			Xsqlite3VdbeJumpHere(tls, v, Xsqlite3VdbeCurrentAddr(tls, v)-2)
  76955 			Xsqlite3VdbeJumpHere(tls, v, iMustBeInt)
  76956 			Xsqlite3ReleaseTempReg(tls, pParse, regTemp)
  76957 		} else {
  76958 			var nCol int32 = (*FKey)(unsafe.Pointer(pFKey)).FnCol
  76959 			var regTemp int32 = Xsqlite3GetTempRange(tls, pParse, nCol)
  76960 
  76961 			Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb)
  76962 			Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx)
  76963 			for i = 0; i < nCol; i++ {
  76964 				Xsqlite3VdbeAddOp2(tls, v, OP_Copy,
  76965 					int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)))))+1+regData,
  76966 					regTemp+i)
  76967 			}
  76968 
  76969 			if pTab == (*FKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr == 1 {
  76970 				var iJump int32 = Xsqlite3VdbeCurrentAddr(tls, v) + nCol + 1
  76971 				for i = 0; i < nCol; i++ {
  76972 					var iChild int32 = int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))))) +
  76973 						1 + regData
  76974 					var iParent int32 = 1 + regData
  76975 					iParent = iParent + int32(Xsqlite3TableColumnToStorage(tls, (*Index)(unsafe.Pointer(pIdx)).FpTable,
  76976 						*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))))
  76977 
  76978 					if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  76979 						iParent = regData
  76980 					}
  76981 					Xsqlite3VdbeAddOp3(tls, v, OP_Ne, iChild, iJump, iParent)
  76982 					Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_JUMPIFNULL))
  76983 				}
  76984 				Xsqlite3VdbeGoto(tls, v, iOk)
  76985 			}
  76986 
  76987 			Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, regTemp, nCol, 0,
  76988 				Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx), nCol)
  76989 			Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iCur, iOk, regTemp, nCol)
  76990 
  76991 			Xsqlite3ReleaseTempRange(tls, pParse, regTemp, nCol)
  76992 		}
  76993 	}
  76994 
  76995 	if !(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_DeferFKs) != 0) &&
  76996 		!(int32((*Parse)(unsafe.Pointer(pParse)).FpToplevel) != 0) &&
  76997 		!(int32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite) != 0) {
  76998 		Xsqlite3HaltConstraint(tls, pParse, SQLITE_CONSTRAINT|int32(3)<<8,
  76999 			OE_Abort, uintptr(0), int8(-1), uint8(P5_ConstraintFK))
  77000 	} else {
  77001 		if nIncr > 0 && int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) == 0 {
  77002 			Xsqlite3MayAbort(tls, pParse)
  77003 		}
  77004 		Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr)
  77005 	}
  77006 
  77007 	Xsqlite3VdbeResolveLabel(tls, v, iOk)
  77008 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCur)
  77009 }
  77010 
  77011 func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int32, iCol I16) uintptr {
  77012 	var pExpr uintptr
  77013 	var pCol uintptr
  77014 	var zColl uintptr
  77015 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  77016 
  77017 	pExpr = Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0))
  77018 	if pExpr != 0 {
  77019 		if int32(iCol) >= 0 && int32(iCol) != int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  77020 			pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16
  77021 			(*Expr)(unsafe.Pointer(pExpr)).FiTable = regBase + int32(Xsqlite3TableColumnToStorage(tls, pTab, iCol)) + 1
  77022 			(*Expr)(unsafe.Pointer(pExpr)).FaffExpr = (*Column)(unsafe.Pointer(pCol)).Faffinity
  77023 			zColl = Xsqlite3ColumnColl(tls, pCol)
  77024 			if zColl == uintptr(0) {
  77025 				zColl = (*CollSeq)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpDfltColl)).FzName
  77026 			}
  77027 			pExpr = Xsqlite3ExprAddCollateString(tls, pParse, pExpr, zColl)
  77028 		} else {
  77029 			(*Expr)(unsafe.Pointer(pExpr)).FiTable = regBase
  77030 			(*Expr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER)
  77031 		}
  77032 	}
  77033 	return pExpr
  77034 }
  77035 
  77036 func exprTableColumn(tls *libc.TLS, db uintptr, pTab uintptr, iCursor int32, iCol I16) uintptr {
  77037 	var pExpr uintptr = Xsqlite3Expr(tls, db, TK_COLUMN, uintptr(0))
  77038 	if pExpr != 0 {
  77039 		*(*uintptr)(unsafe.Pointer(pExpr + 44)) = pTab
  77040 		(*Expr)(unsafe.Pointer(pExpr)).FiTable = iCursor
  77041 		(*Expr)(unsafe.Pointer(pExpr)).FiColumn = iCol
  77042 	}
  77043 	return pExpr
  77044 }
  77045 
  77046 func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, pIdx uintptr, pFKey uintptr, aiCol uintptr, regData int32, nIncr int32) {
  77047 	bp := tls.Alloc(32)
  77048 	defer tls.Free(32)
  77049 
  77050 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  77051 	var i int32
  77052 	var pWhere uintptr = uintptr(0)
  77053 
  77054 	var pWInfo uintptr
  77055 	var iFkIfZero int32 = 0
  77056 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  77057 
  77058 	if nIncr < 0 {
  77059 		iFkIfZero = Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), 0)
  77060 
  77061 	}
  77062 
  77063 	for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ {
  77064 		var pLeft uintptr
  77065 		var pRight uintptr
  77066 		var pEq uintptr
  77067 		var iCol I16
  77068 		var zCol uintptr
  77069 
  77070 		if pIdx != 0 {
  77071 			iCol = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))
  77072 		} else {
  77073 			iCol = int16(-1)
  77074 		}
  77075 		pLeft = exprTableRegister(tls, pParse, pTab, regData, iCol)
  77076 		if aiCol != 0 {
  77077 			iCol = int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)))
  77078 		} else {
  77079 			iCol = int16((*sColMap)(unsafe.Pointer(pFKey + 36)).FiFrom)
  77080 		}
  77081 
  77082 		zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iCol)*16)).FzCnName
  77083 		pRight = Xsqlite3Expr(tls, db, TK_ID, zCol)
  77084 		pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, pLeft, pRight)
  77085 		pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pEq)
  77086 	}
  77087 
  77088 	if pTab == (*FKey)(unsafe.Pointer(pFKey)).FpFrom && nIncr > 0 {
  77089 		var pNe uintptr
  77090 		var pLeft uintptr
  77091 		var pRight uintptr
  77092 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  77093 			pLeft = exprTableRegister(tls, pParse, pTab, regData, int16(-1))
  77094 			pRight = exprTableColumn(tls, db, pTab, (*SrcItem)(unsafe.Pointer(pSrc+8)).FiCursor, int16(-1))
  77095 			pNe = Xsqlite3PExpr(tls, pParse, TK_NE, pLeft, pRight)
  77096 		} else {
  77097 			var pEq uintptr
  77098 			var pAll uintptr = uintptr(0)
  77099 
  77100 			for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ {
  77101 				var iCol I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))
  77102 
  77103 				pLeft = exprTableRegister(tls, pParse, pTab, regData, iCol)
  77104 				pRight = Xsqlite3Expr(tls, db, TK_ID, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16)).FzCnName)
  77105 				pEq = Xsqlite3PExpr(tls, pParse, TK_IS, pLeft, pRight)
  77106 				pAll = Xsqlite3ExprAnd(tls, pParse, pAll, pEq)
  77107 			}
  77108 			pNe = Xsqlite3PExpr(tls, pParse, TK_NOT, pAll, uintptr(0))
  77109 		}
  77110 		pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pNe)
  77111 	}
  77112 
  77113 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  77114 	(*NameContext)(unsafe.Pointer(bp)).FpSrcList = pSrc
  77115 	(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  77116 	Xsqlite3ResolveExprNames(tls, bp, pWhere)
  77117 
  77118 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  77119 		pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint16(0), 0)
  77120 		Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr)
  77121 		if pWInfo != 0 {
  77122 			Xsqlite3WhereEnd(tls, pWInfo)
  77123 		}
  77124 	}
  77125 
  77126 	Xsqlite3ExprDelete(tls, db, pWhere)
  77127 	if iFkIfZero != 0 {
  77128 		Xsqlite3VdbeJumpHereOrPopInst(tls, v, iFkIfZero)
  77129 	}
  77130 }
  77131 
  77132 // This function returns a linked list of FKey objects (connected by
  77133 // FKey.pNextTo) holding all children of table pTab.  For example,
  77134 // given the following schema:
  77135 //
  77136 //	CREATE TABLE t1(a PRIMARY KEY);
  77137 //	CREATE TABLE t2(b REFERENCES t1(a);
  77138 //
  77139 // Calling this function with table "t1" as an argument returns a pointer
  77140 // to the FKey structure representing the foreign key constraint on table
  77141 // "t2". Calling this function with "t2" as the argument would return a
  77142 // NULL pointer (as there are no FK constraints for which t2 is the parent
  77143 // table).
  77144 func Xsqlite3FkReferences(tls *libc.TLS, pTab uintptr) uintptr {
  77145 	return Xsqlite3HashFind(tls, (*Table)(unsafe.Pointer(pTab)).FpSchema+56, (*Table)(unsafe.Pointer(pTab)).FzName)
  77146 }
  77147 
  77148 func fkTriggerDelete(tls *libc.TLS, dbMem uintptr, p uintptr) {
  77149 	if p != 0 {
  77150 		var pStep uintptr = (*Trigger)(unsafe.Pointer(p)).Fstep_list
  77151 		Xsqlite3ExprDelete(tls, dbMem, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere)
  77152 		Xsqlite3ExprListDelete(tls, dbMem, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList)
  77153 		Xsqlite3SelectDelete(tls, dbMem, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect)
  77154 		Xsqlite3ExprDelete(tls, dbMem, (*Trigger)(unsafe.Pointer(p)).FpWhen)
  77155 		Xsqlite3DbFree(tls, dbMem, p)
  77156 	}
  77157 }
  77158 
  77159 // Clear the apTrigger[] cache of CASCADE triggers for all foreign keys
  77160 // in a particular database.  This needs to happen when the schema
  77161 // changes.
  77162 func Xsqlite3FkClearTriggerCache(tls *libc.TLS, db uintptr, iDb int32) {
  77163 	var k uintptr
  77164 	var pHash uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 8
  77165 	for k = (*Hash)(unsafe.Pointer(pHash)).Ffirst; k != 0; k = (*HashElem)(unsafe.Pointer(k)).Fnext {
  77166 		var pTab uintptr = (*HashElem)(unsafe.Pointer(k)).Fdata
  77167 		var pFKey uintptr
  77168 		if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  77169 			continue
  77170 		}
  77171 		for pFKey = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom {
  77172 			fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer(pFKey + 28)))
  77173 			*(*uintptr)(unsafe.Pointer(pFKey + 28)) = uintptr(0)
  77174 			fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer(pFKey + 28 + 1*4)))
  77175 			*(*uintptr)(unsafe.Pointer(pFKey + 28 + 1*4)) = uintptr(0)
  77176 		}
  77177 	}
  77178 }
  77179 
  77180 // This function is called to generate code that runs when table pTab is
  77181 // being dropped from the database. The SrcList passed as the second argument
  77182 // to this function contains a single entry guaranteed to resolve to
  77183 // table pTab.
  77184 //
  77185 // Normally, no code is required. However, if either
  77186 //
  77187 //	(a) The table is the parent table of a FK constraint, or
  77188 //	(b) The table is the child table of a deferred FK constraint and it is
  77189 //	    determined at runtime that there are outstanding deferred FK
  77190 //	    constraint violations in the database,
  77191 //
  77192 // then the equivalent of "DELETE FROM <tbl>" is executed before dropping
  77193 // the table from the database. Triggers are disabled while running this
  77194 // DELETE, but foreign key actions are not.
  77195 func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uintptr) {
  77196 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  77197 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM {
  77198 		var iSkip int32 = 0
  77199 		var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  77200 
  77201 		if Xsqlite3FkReferences(tls, pTab) == uintptr(0) {
  77202 			var p uintptr
  77203 			for p = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom {
  77204 				if (*FKey)(unsafe.Pointer(p)).FisDeferred != 0 || (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 {
  77205 					break
  77206 				}
  77207 			}
  77208 			if !(p != 0) {
  77209 				return
  77210 			}
  77211 			iSkip = Xsqlite3VdbeMakeLabel(tls, pParse)
  77212 			Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, 1, iSkip)
  77213 		}
  77214 
  77215 		(*Parse)(unsafe.Pointer(pParse)).FdisableTriggers = U8(1)
  77216 		Xsqlite3DeleteFrom(tls, pParse, Xsqlite3SrcListDup(tls, db, pName, 0), uintptr(0), uintptr(0), uintptr(0))
  77217 		(*Parse)(unsafe.Pointer(pParse)).FdisableTriggers = U8(0)
  77218 
  77219 		if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) == uint64(0) {
  77220 			Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, 0, Xsqlite3VdbeCurrentAddr(tls, v)+2)
  77221 
  77222 			Xsqlite3HaltConstraint(tls, pParse, SQLITE_CONSTRAINT|int32(3)<<8,
  77223 				OE_Abort, uintptr(0), int8(-1), uint8(P5_ConstraintFK))
  77224 		}
  77225 
  77226 		if iSkip != 0 {
  77227 			Xsqlite3VdbeResolveLabel(tls, v, iSkip)
  77228 		}
  77229 	}
  77230 }
  77231 
  77232 func fkChildIsModified(tls *libc.TLS, pTab uintptr, p uintptr, aChange uintptr, bChngRowid int32) int32 {
  77233 	var i int32
  77234 	for i = 0; i < (*FKey)(unsafe.Pointer(p)).FnCol; i++ {
  77235 		var iChildKey int32 = (*sColMap)(unsafe.Pointer(p + 36 + uintptr(i)*8)).FiFrom
  77236 		if *(*int32)(unsafe.Pointer(aChange + uintptr(iChildKey)*4)) >= 0 {
  77237 			return 1
  77238 		}
  77239 		if iChildKey == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) && bChngRowid != 0 {
  77240 			return 1
  77241 		}
  77242 	}
  77243 	return 0
  77244 }
  77245 
  77246 func fkParentIsModified(tls *libc.TLS, pTab uintptr, p uintptr, aChange uintptr, bChngRowid int32) int32 {
  77247 	var i int32
  77248 	for i = 0; i < (*FKey)(unsafe.Pointer(p)).FnCol; i++ {
  77249 		var zKey uintptr = (*sColMap)(unsafe.Pointer(p + 36 + uintptr(i)*8)).FzCol
  77250 		var iKey int32
  77251 		for iKey = 0; iKey < int32((*Table)(unsafe.Pointer(pTab)).FnCol); iKey++ {
  77252 			if *(*int32)(unsafe.Pointer(aChange + uintptr(iKey)*4)) >= 0 || iKey == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) && bChngRowid != 0 {
  77253 				var pCol uintptr = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iKey)*16
  77254 				if zKey != 0 {
  77255 					if 0 == Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName, zKey) {
  77256 						return 1
  77257 					}
  77258 				} else if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_PRIMKEY != 0 {
  77259 					return 1
  77260 				}
  77261 			}
  77262 		}
  77263 	}
  77264 	return 0
  77265 }
  77266 
  77267 func isSetNullAction(tls *libc.TLS, pParse uintptr, pFKey uintptr) int32 {
  77268 	var pTop uintptr = func() uintptr {
  77269 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  77270 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  77271 		}
  77272 		return pParse
  77273 	}()
  77274 	if (*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg != 0 {
  77275 		var p uintptr = (*TriggerPrg)(unsafe.Pointer((*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg)).FpTrigger
  77276 		if p == *(*uintptr)(unsafe.Pointer(pFKey + 28)) && int32(*(*U8)(unsafe.Pointer(pFKey + 25))) == OE_SetNull ||
  77277 			p == *(*uintptr)(unsafe.Pointer(pFKey + 28 + 1*4)) && int32(*(*U8)(unsafe.Pointer(pFKey + 25 + 1))) == OE_SetNull {
  77278 			return 1
  77279 		}
  77280 	}
  77281 	return 0
  77282 }
  77283 
  77284 // This function is called when inserting, deleting or updating a row of
  77285 // table pTab to generate VDBE code to perform foreign key constraint
  77286 // processing for the operation.
  77287 //
  77288 // For a DELETE operation, parameter regOld is passed the index of the
  77289 // first register in an array of (pTab->nCol+1) registers containing the
  77290 // rowid of the row being deleted, followed by each of the column values
  77291 // of the row being deleted, from left to right. Parameter regNew is passed
  77292 // zero in this case.
  77293 //
  77294 // For an INSERT operation, regOld is passed zero and regNew is passed the
  77295 // first register of an array of (pTab->nCol+1) registers containing the new
  77296 // row data.
  77297 //
  77298 // For an UPDATE operation, this function is called twice. Once before
  77299 // the original record is deleted from the table using the calling convention
  77300 // described for DELETE. Then again after the original record is deleted
  77301 // but before the new record is inserted using the INSERT convention.
  77302 func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, regNew int32, aChange uintptr, bChngRowid int32) {
  77303 	bp := tls.Alloc(20)
  77304 	defer tls.Free(20)
  77305 
  77306 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  77307 	var pFKey uintptr
  77308 	var iDb int32
  77309 	var zDb uintptr
  77310 	var isIgnoreErrors int32 = int32((*Parse)(unsafe.Pointer(pParse)).FdisableTriggers)
  77311 
  77312 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) == uint64(0) {
  77313 		return
  77314 	}
  77315 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  77316 		return
  77317 	}
  77318 
  77319 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  77320 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  77321 
  77322 	for pFKey = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom {
  77323 		var pTo uintptr
  77324 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  77325 		*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  77326 		var aiCol uintptr
  77327 
  77328 		var i int32
  77329 		var bIgnore int32 = 0
  77330 
  77331 		if aChange != 0 &&
  77332 			Xsqlite3_stricmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, (*FKey)(unsafe.Pointer(pFKey)).FzTo) != 0 &&
  77333 			fkChildIsModified(tls, pTab, pFKey, aChange, bChngRowid) == 0 {
  77334 			continue
  77335 		}
  77336 
  77337 		if (*Parse)(unsafe.Pointer(pParse)).FdisableTriggers != 0 {
  77338 			pTo = Xsqlite3FindTable(tls, db, (*FKey)(unsafe.Pointer(pFKey)).FzTo, zDb)
  77339 		} else {
  77340 			pTo = Xsqlite3LocateTable(tls, pParse, uint32(0), (*FKey)(unsafe.Pointer(pFKey)).FzTo, zDb)
  77341 		}
  77342 		if !(pTo != 0) || Xsqlite3FkLocateIndex(tls, pParse, pTo, pFKey, bp, bp+4) != 0 {
  77343 			if !(isIgnoreErrors != 0) || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  77344 				return
  77345 			}
  77346 			if pTo == uintptr(0) {
  77347 				var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  77348 				var iJump int32 = Xsqlite3VdbeCurrentAddr(tls, v) + (*FKey)(unsafe.Pointer(pFKey)).FnCol + 1
  77349 				for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ {
  77350 					var iFromCol int32
  77351 					var iReg int32
  77352 					iFromCol = (*sColMap)(unsafe.Pointer(pFKey + 36 + uintptr(i)*8)).FiFrom
  77353 					iReg = int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(iFromCol))) + regOld + 1
  77354 					Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, iJump)
  77355 				}
  77356 				Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), -1)
  77357 			}
  77358 			continue
  77359 		}
  77360 
  77361 		if *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
  77362 			aiCol = *(*uintptr)(unsafe.Pointer(bp + 4))
  77363 		} else {
  77364 			*(*int32)(unsafe.Pointer(bp + 8)) = (*sColMap)(unsafe.Pointer(pFKey + 36)).FiFrom
  77365 			aiCol = bp + 8
  77366 		}
  77367 		for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ {
  77368 			if *(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  77369 				*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) = -1
  77370 			}
  77371 
  77372 			if (*Sqlite3)(unsafe.Pointer(db)).FxAuth != 0 {
  77373 				var rcauth int32
  77374 				var zCol uintptr = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTo)).FaCol + uintptr(func() int32 {
  77375 					if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  77376 						return int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaiColumn + uintptr(i)*2)))
  77377 					}
  77378 					return int32((*Table)(unsafe.Pointer(pTo)).FiPKey)
  77379 				}())*16)).FzCnName
  77380 				rcauth = Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTo)).FzName, zCol, iDb)
  77381 				bIgnore = libc.Bool32(rcauth == SQLITE_IGNORE)
  77382 			}
  77383 		}
  77384 
  77385 		Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTo)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTo)).FzName)
  77386 		(*Parse)(unsafe.Pointer(pParse)).FnTab++
  77387 
  77388 		if regOld != 0 {
  77389 			fkLookupParent(tls, pParse, iDb, pTo, *(*uintptr)(unsafe.Pointer(bp)), pFKey, aiCol, regOld, -1, bIgnore)
  77390 		}
  77391 		if regNew != 0 && !(isSetNullAction(tls, pParse, pFKey) != 0) {
  77392 			fkLookupParent(tls, pParse, iDb, pTo, *(*uintptr)(unsafe.Pointer(bp)), pFKey, aiCol, regNew, +1, bIgnore)
  77393 		}
  77394 
  77395 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 4)))
  77396 	}
  77397 
  77398 	for pFKey = Xsqlite3FkReferences(tls, pTab); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextTo {
  77399 		*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
  77400 		var pSrc uintptr
  77401 		*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
  77402 
  77403 		if aChange != 0 && fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) == 0 {
  77404 			continue
  77405 		}
  77406 
  77407 		if !(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0) &&
  77408 			!(int32((*Parse)(unsafe.Pointer(pParse)).FpToplevel) != 0) && !(int32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite) != 0) {
  77409 			continue
  77410 		}
  77411 
  77412 		if Xsqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp+12, bp+16) != 0 {
  77413 			if !(isIgnoreErrors != 0) || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  77414 				return
  77415 			}
  77416 			continue
  77417 		}
  77418 
  77419 		pSrc = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0))
  77420 		if pSrc != 0 {
  77421 			var pItem uintptr = pSrc + 8
  77422 			(*SrcItem)(unsafe.Pointer(pItem)).FpTab = (*FKey)(unsafe.Pointer(pFKey)).FpFrom
  77423 			(*SrcItem)(unsafe.Pointer(pItem)).FzName = (*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName
  77424 			(*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpTab)).FnTabRef++
  77425 			(*SrcItem)(unsafe.Pointer(pItem)).FiCursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  77426 
  77427 			if regNew != 0 {
  77428 				fkScanChildren(tls, pParse, pSrc, pTab, *(*uintptr)(unsafe.Pointer(bp + 12)), pFKey, *(*uintptr)(unsafe.Pointer(bp + 16)), regNew, -1)
  77429 			}
  77430 			if regOld != 0 {
  77431 				var eAction int32 = int32(*(*U8)(unsafe.Pointer(pFKey + 25 + uintptr(libc.Bool32(aChange != uintptr(0))))))
  77432 				fkScanChildren(tls, pParse, pSrc, pTab, *(*uintptr)(unsafe.Pointer(bp + 12)), pFKey, *(*uintptr)(unsafe.Pointer(bp + 16)), regOld, 1)
  77433 
  77434 				if !(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && eAction != OE_Cascade && eAction != OE_SetNull {
  77435 					Xsqlite3MayAbort(tls, pParse)
  77436 				}
  77437 			}
  77438 			(*SrcItem)(unsafe.Pointer(pItem)).FzName = uintptr(0)
  77439 			Xsqlite3SrcListDelete(tls, db, pSrc)
  77440 		}
  77441 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 16)))
  77442 	}
  77443 }
  77444 
  77445 // This function is called before generating code to update or delete a
  77446 // row contained in table pTab.
  77447 func Xsqlite3FkOldmask(tls *libc.TLS, pParse uintptr, pTab uintptr) U32 {
  77448 	bp := tls.Alloc(4)
  77449 	defer tls.Free(4)
  77450 
  77451 	var mask U32 = U32(0)
  77452 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM {
  77453 		var p uintptr
  77454 		var i int32
  77455 		for p = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom {
  77456 			for i = 0; i < (*FKey)(unsafe.Pointer(p)).FnCol; i++ {
  77457 				mask = mask | func() uint32 {
  77458 					if (*sColMap)(unsafe.Pointer(p+36+uintptr(i)*8)).FiFrom > 31 {
  77459 						return 0xffffffff
  77460 					}
  77461 					return U32(1) << (*sColMap)(unsafe.Pointer(p+36+uintptr(i)*8)).FiFrom
  77462 				}()
  77463 			}
  77464 		}
  77465 		for p = Xsqlite3FkReferences(tls, pTab); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextTo {
  77466 			*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  77467 			Xsqlite3FkLocateIndex(tls, pParse, pTab, p, bp, uintptr(0))
  77468 			if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  77469 				for i = 0; i < int32((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnKeyCol); i++ {
  77470 					mask = mask | func() uint32 {
  77471 						if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaiColumn + uintptr(i)*2))) > 31 {
  77472 							return 0xffffffff
  77473 						}
  77474 						return U32(1) << int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaiColumn + uintptr(i)*2)))
  77475 					}()
  77476 				}
  77477 			}
  77478 		}
  77479 	}
  77480 	return mask
  77481 }
  77482 
  77483 // This function is called before generating code to update or delete a
  77484 // row contained in table pTab. If the operation is a DELETE, then
  77485 // parameter aChange is passed a NULL value. For an UPDATE, aChange points
  77486 // to an array of size N, where N is the number of columns in table pTab.
  77487 // If the i'th column is not modified by the UPDATE, then the corresponding
  77488 // entry in the aChange[] array is set to -1. If the column is modified,
  77489 // the value is 0 or greater. Parameter chngRowid is set to true if the
  77490 // UPDATE statement modifies the rowid fields of the table.
  77491 //
  77492 // If any foreign key processing will be required, this function returns
  77493 // non-zero. If there is no foreign key related processing, this function
  77494 // returns zero.
  77495 //
  77496 // For an UPDATE, this function returns 2 if:
  77497 //
  77498 //   - There are any FKs for which pTab is the child and the parent table
  77499 //     and any FK processing at all is required (even of a different FK), or
  77500 //
  77501 //   - the UPDATE modifies one or more parent keys for which the action is
  77502 //     not "NO ACTION" (i.e. is CASCADE, SET DEFAULT or SET NULL).
  77503 //
  77504 // Or, assuming some other foreign key processing is required, 1.
  77505 func Xsqlite3FkRequired(tls *libc.TLS, pParse uintptr, pTab uintptr, aChange uintptr, chngRowid int32) int32 {
  77506 	var eRet int32 = 1
  77507 	var bHaveFK int32 = 0
  77508 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM {
  77509 		if !(aChange != 0) {
  77510 			bHaveFK = libc.Bool32(Xsqlite3FkReferences(tls, pTab) != 0 || *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)) != 0)
  77511 		} else {
  77512 			var p uintptr
  77513 
  77514 			for p = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom {
  77515 				if fkChildIsModified(tls, pTab, p, aChange, chngRowid) != 0 {
  77516 					if 0 == Xsqlite3_stricmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, (*FKey)(unsafe.Pointer(p)).FzTo) {
  77517 						eRet = 2
  77518 					}
  77519 					bHaveFK = 1
  77520 				}
  77521 			}
  77522 
  77523 			for p = Xsqlite3FkReferences(tls, pTab); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextTo {
  77524 				if fkParentIsModified(tls, pTab, p, aChange, chngRowid) != 0 {
  77525 					if int32(*(*U8)(unsafe.Pointer(p + 25 + 1))) != OE_None {
  77526 						return 2
  77527 					}
  77528 					bHaveFK = 1
  77529 				}
  77530 			}
  77531 		}
  77532 	}
  77533 	if bHaveFK != 0 {
  77534 		return eRet
  77535 	}
  77536 	return 0
  77537 }
  77538 
  77539 func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pChanges uintptr) uintptr {
  77540 	bp := tls.Alloc(56)
  77541 	defer tls.Free(56)
  77542 
  77543 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  77544 	var action int32
  77545 	var pTrigger uintptr
  77546 	var iAction int32 = libc.Bool32(pChanges != uintptr(0))
  77547 
  77548 	action = int32(*(*U8)(unsafe.Pointer(pFKey + 25 + uintptr(iAction))))
  77549 	if action == OE_Restrict && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 {
  77550 		return uintptr(0)
  77551 	}
  77552 	pTrigger = *(*uintptr)(unsafe.Pointer(pFKey + 28 + uintptr(iAction)*4))
  77553 
  77554 	if action != OE_None && !(pTrigger != 0) {
  77555 		var zFrom uintptr
  77556 		var nFrom int32
  77557 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  77558 		*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  77559 		var pStep uintptr = uintptr(0)
  77560 		var pWhere uintptr = uintptr(0)
  77561 		var pList uintptr = uintptr(0)
  77562 		var pSelect uintptr = uintptr(0)
  77563 		var i int32
  77564 		var pWhen uintptr = uintptr(0)
  77565 
  77566 		if Xsqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp, bp+4) != 0 {
  77567 			return uintptr(0)
  77568 		}
  77569 
  77570 		for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ {
  77571 			*(*Token)(unsafe.Pointer(bp + 24)) = Token{Fz: ts + 6452, Fn: uint32(3)}
  77572 			*(*Token)(unsafe.Pointer(bp + 32)) = Token{Fz: ts + 6448, Fn: uint32(3)}
  77573 
  77574 			var iFromCol int32
  77575 			var pEq uintptr
  77576 
  77577 			if *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
  77578 				iFromCol = *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)) + uintptr(i)*4))
  77579 			} else {
  77580 				iFromCol = (*sColMap)(unsafe.Pointer(pFKey + 36)).FiFrom
  77581 			}
  77582 
  77583 			Xsqlite3TokenInit(tls, bp+8,
  77584 				(*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(func() int32 {
  77585 					if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  77586 						return int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaiColumn + uintptr(i)*2)))
  77587 					}
  77588 					return int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
  77589 				}())*16)).FzCnName)
  77590 			Xsqlite3TokenInit(tls, bp+16, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol+uintptr(iFromCol)*16)).FzCnName)
  77591 
  77592 			pEq = Xsqlite3PExpr(tls, pParse, TK_EQ,
  77593 				Xsqlite3PExpr(tls, pParse, TK_DOT,
  77594 					Xsqlite3ExprAlloc(tls, db, TK_ID, bp+24, 0),
  77595 					Xsqlite3ExprAlloc(tls, db, TK_ID, bp+8, 0)),
  77596 				Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16, 0))
  77597 			pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pEq)
  77598 
  77599 			if pChanges != 0 {
  77600 				pEq = Xsqlite3PExpr(tls, pParse, TK_IS,
  77601 					Xsqlite3PExpr(tls, pParse, TK_DOT,
  77602 						Xsqlite3ExprAlloc(tls, db, TK_ID, bp+24, 0),
  77603 						Xsqlite3ExprAlloc(tls, db, TK_ID, bp+8, 0)),
  77604 					Xsqlite3PExpr(tls, pParse, TK_DOT,
  77605 						Xsqlite3ExprAlloc(tls, db, TK_ID, bp+32, 0),
  77606 						Xsqlite3ExprAlloc(tls, db, TK_ID, bp+8, 0)))
  77607 				pWhen = Xsqlite3ExprAnd(tls, pParse, pWhen, pEq)
  77608 			}
  77609 
  77610 			if action != OE_Restrict && (action != OE_Cascade || pChanges != 0) {
  77611 				var pNew uintptr
  77612 				if action == OE_Cascade {
  77613 					pNew = Xsqlite3PExpr(tls, pParse, TK_DOT,
  77614 						Xsqlite3ExprAlloc(tls, db, TK_ID, bp+32, 0),
  77615 						Xsqlite3ExprAlloc(tls, db, TK_ID, bp+8, 0))
  77616 				} else if action == OE_SetDflt {
  77617 					var pCol uintptr = (*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16
  77618 					var pDflt uintptr
  77619 					if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_GENERATED != 0 {
  77620 						pDflt = uintptr(0)
  77621 					} else {
  77622 						pDflt = Xsqlite3ColumnExpr(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, pCol)
  77623 					}
  77624 					if pDflt != 0 {
  77625 						pNew = Xsqlite3ExprDup(tls, db, pDflt, 0)
  77626 					} else {
  77627 						pNew = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0)
  77628 					}
  77629 				} else {
  77630 					pNew = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0)
  77631 				}
  77632 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, pNew)
  77633 				Xsqlite3ExprListSetName(tls, pParse, pList, bp+16, 0)
  77634 			}
  77635 		}
  77636 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 4)))
  77637 
  77638 		zFrom = (*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName
  77639 		nFrom = Xsqlite3Strlen30(tls, zFrom)
  77640 
  77641 		if action == OE_Restrict {
  77642 			var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  77643 
  77644 			var pRaise uintptr
  77645 
  77646 			(*Token)(unsafe.Pointer(bp + 48)).Fz = zFrom
  77647 			(*Token)(unsafe.Pointer(bp + 48)).Fn = uint32(nFrom)
  77648 			(*Token)(unsafe.Pointer(bp + 40)).Fz = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  77649 			(*Token)(unsafe.Pointer(bp + 40)).Fn = uint32(Xsqlite3Strlen30(tls, (*Token)(unsafe.Pointer(bp+40)).Fz))
  77650 
  77651 			pRaise = Xsqlite3Expr(tls, db, TK_RAISE, ts+5136)
  77652 			if pRaise != 0 {
  77653 				(*Expr)(unsafe.Pointer(pRaise)).FaffExpr = uint8(OE_Abort)
  77654 			}
  77655 			pSelect = Xsqlite3SelectNew(tls, pParse,
  77656 				Xsqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise),
  77657 				Xsqlite3SrcListAppend(tls, pParse, uintptr(0), bp+40, bp+48),
  77658 				pWhere,
  77659 				uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0))
  77660 			pWhere = uintptr(0)
  77661 		}
  77662 
  77663 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++
  77664 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
  77665 
  77666 		pTrigger = Xsqlite3DbMallocZero(tls, db,
  77667 			uint64(uint32(unsafe.Sizeof(Trigger{}))+uint32(unsafe.Sizeof(TriggerStep{}))+uint32(nFrom)+uint32(1)))
  77668 		if pTrigger != 0 {
  77669 			pStep = libc.AssignPtrUintptr(pTrigger+28, pTrigger+1*36)
  77670 			(*TriggerStep)(unsafe.Pointer(pStep)).FzTarget = pStep + 1*48
  77671 			libc.Xmemcpy(tls, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zFrom, uint32(nFrom))
  77672 
  77673 			(*TriggerStep)(unsafe.Pointer(pStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE)
  77674 			(*TriggerStep)(unsafe.Pointer(pStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pList, EXPRDUP_REDUCE)
  77675 			(*TriggerStep)(unsafe.Pointer(pStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE)
  77676 			if pWhen != 0 {
  77677 				pWhen = Xsqlite3PExpr(tls, pParse, TK_NOT, pWhen, uintptr(0))
  77678 				(*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, EXPRDUP_REDUCE)
  77679 			}
  77680 		}
  77681 
  77682 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable--
  77683 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = func() uint16 {
  77684 			if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 {
  77685 				return uint16(0)
  77686 			}
  77687 			return (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue
  77688 		}()
  77689 
  77690 		Xsqlite3ExprDelete(tls, db, pWhere)
  77691 		Xsqlite3ExprDelete(tls, db, pWhen)
  77692 		Xsqlite3ExprListDelete(tls, db, pList)
  77693 		Xsqlite3SelectDelete(tls, db, pSelect)
  77694 		if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 1 {
  77695 			fkTriggerDelete(tls, db, pTrigger)
  77696 			return uintptr(0)
  77697 		}
  77698 
  77699 		{
  77700 			switch action {
  77701 			case OE_Restrict:
  77702 				(*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(TK_SELECT)
  77703 				break
  77704 				fallthrough
  77705 			case OE_Cascade:
  77706 				if !(pChanges != 0) {
  77707 					(*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(TK_DELETE)
  77708 					break
  77709 				}
  77710 				fallthrough
  77711 			default:
  77712 				(*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(TK_UPDATE)
  77713 			}
  77714 		}
  77715 		(*TriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger
  77716 		(*Trigger)(unsafe.Pointer(pTrigger)).FpSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema
  77717 		(*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema
  77718 		*(*uintptr)(unsafe.Pointer(pFKey + 28 + uintptr(iAction)*4)) = pTrigger
  77719 		(*Trigger)(unsafe.Pointer(pTrigger)).Fop = func() uint8 {
  77720 			if pChanges != 0 {
  77721 				return uint8(TK_UPDATE)
  77722 			}
  77723 			return uint8(TK_DELETE)
  77724 		}()
  77725 	}
  77726 
  77727 	return pTrigger
  77728 }
  77729 
  77730 // This function is called when deleting or updating a row to implement
  77731 // any required CASCADE, SET NULL or SET DEFAULT actions.
  77732 func Xsqlite3FkActions(tls *libc.TLS, pParse uintptr, pTab uintptr, pChanges uintptr, regOld int32, aChange uintptr, bChngRowid int32) {
  77733 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_ForeignKeys) != 0 {
  77734 		var pFKey uintptr
  77735 		for pFKey = Xsqlite3FkReferences(tls, pTab); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextTo {
  77736 			if aChange == uintptr(0) || fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) != 0 {
  77737 				var pAct uintptr = fkActionTrigger(tls, pParse, pTab, pFKey, pChanges)
  77738 				if pAct != 0 {
  77739 					Xsqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, OE_Abort, 0)
  77740 				}
  77741 			}
  77742 		}
  77743 	}
  77744 }
  77745 
  77746 // Free all memory associated with foreign key definitions attached to
  77747 // table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
  77748 // hash table.
  77749 func Xsqlite3FkDelete(tls *libc.TLS, db uintptr, pTab uintptr) {
  77750 	var pFKey uintptr
  77751 	var pNext uintptr
  77752 
  77753 	for pFKey = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4)); pFKey != 0; pFKey = pNext {
  77754 		if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  77755 			if (*FKey)(unsafe.Pointer(pFKey)).FpPrevTo != 0 {
  77756 				(*FKey)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpPrevTo)).FpNextTo = (*FKey)(unsafe.Pointer(pFKey)).FpNextTo
  77757 			} else {
  77758 				var p uintptr = (*FKey)(unsafe.Pointer(pFKey)).FpNextTo
  77759 				var z uintptr = func() uintptr {
  77760 					if p != 0 {
  77761 						return (*FKey)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpNextTo)).FzTo
  77762 					}
  77763 					return (*FKey)(unsafe.Pointer(pFKey)).FzTo
  77764 				}()
  77765 				Xsqlite3HashInsert(tls, (*Table)(unsafe.Pointer(pTab)).FpSchema+56, z, p)
  77766 			}
  77767 			if (*FKey)(unsafe.Pointer(pFKey)).FpNextTo != 0 {
  77768 				(*FKey)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpNextTo)).FpPrevTo = (*FKey)(unsafe.Pointer(pFKey)).FpPrevTo
  77769 			}
  77770 		}
  77771 
  77772 		fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer(pFKey + 28)))
  77773 		fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer(pFKey + 28 + 1*4)))
  77774 
  77775 		pNext = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom
  77776 		Xsqlite3DbFree(tls, db, pFKey)
  77777 	}
  77778 }
  77779 
  77780 // Generate code that will
  77781 //
  77782 //	(1) acquire a lock for table pTab then
  77783 //	(2) open pTab as cursor iCur.
  77784 //
  77785 // If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index
  77786 // for that table that is actually opened.
  77787 func Xsqlite3OpenTable(tls *libc.TLS, pParse uintptr, iCur int32, iDb int32, pTab uintptr, opcode int32) {
  77788 	var v uintptr
  77789 
  77790 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  77791 
  77792 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum,
  77793 		func() uint8 {
  77794 			if opcode == OP_OpenWrite {
  77795 				return uint8(1)
  77796 			}
  77797 			return uint8(0)
  77798 		}(), (*Table)(unsafe.Pointer(pTab)).FzName)
  77799 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  77800 		Xsqlite3VdbeAddOp4Int(tls, v, opcode, iCur, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, int32((*Table)(unsafe.Pointer(pTab)).FnNVCol))
  77801 
  77802 	} else {
  77803 		var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab)
  77804 
  77805 		Xsqlite3VdbeAddOp3(tls, v, opcode, iCur, int32((*Index)(unsafe.Pointer(pPk)).Ftnum), iDb)
  77806 		Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk)
  77807 
  77808 	}
  77809 }
  77810 
  77811 // Return a pointer to the column affinity string associated with index
  77812 // pIdx. A column affinity string has one character for each column in
  77813 // the table, according to the affinity of the column:
  77814 //
  77815 //	Character      Column affinity
  77816 //	------------------------------
  77817 //	'A'            BLOB
  77818 //	'B'            TEXT
  77819 //	'C'            NUMERIC
  77820 //	'D'            INTEGER
  77821 //	'F'            REAL
  77822 //
  77823 // An extra 'D' is appended to the end of the string to cover the
  77824 // rowid that appears as the last column in every index.
  77825 //
  77826 // Memory for the buffer containing the column index affinity string
  77827 // is managed along with the rest of the Index structure. It will be
  77828 // released when sqlite3DeleteIndex() is called.
  77829 func Xsqlite3IndexAffinityStr(tls *libc.TLS, db uintptr, pIdx uintptr) uintptr {
  77830 	if !(int32((*Index)(unsafe.Pointer(pIdx)).FzColAff) != 0) {
  77831 		var n int32
  77832 		var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable
  77833 		(*Index)(unsafe.Pointer(pIdx)).FzColAff = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)+1))
  77834 		if !(int32((*Index)(unsafe.Pointer(pIdx)).FzColAff) != 0) {
  77835 			Xsqlite3OomFault(tls, db)
  77836 			return uintptr(0)
  77837 		}
  77838 		for n = 0; n < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); n++ {
  77839 			var x I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2))
  77840 			var aff uint8
  77841 			if int32(x) >= 0 {
  77842 				aff = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(x)*16)).Faffinity
  77843 			} else if int32(x) == -1 {
  77844 				aff = uint8(SQLITE_AFF_INTEGER)
  77845 			} else {
  77846 				aff = Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8+uintptr(n)*20)).FpExpr)
  77847 			}
  77848 			if int32(aff) < SQLITE_AFF_BLOB {
  77849 				aff = uint8(SQLITE_AFF_BLOB)
  77850 			}
  77851 			if int32(aff) > SQLITE_AFF_NUMERIC {
  77852 				aff = uint8(SQLITE_AFF_NUMERIC)
  77853 			}
  77854 			*(*uint8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = aff
  77855 		}
  77856 		*(*uint8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = uint8(0)
  77857 	}
  77858 
  77859 	return (*Index)(unsafe.Pointer(pIdx)).FzColAff
  77860 }
  77861 
  77862 // Compute an affinity string for a table.   Space is obtained
  77863 // from sqlite3DbMalloc().  The caller is responsible for freeing
  77864 // the space when done.
  77865 func Xsqlite3TableAffinityStr(tls *libc.TLS, db uintptr, pTab uintptr) uintptr {
  77866 	var zColAff uintptr
  77867 	zColAff = Xsqlite3DbMallocRaw(tls, db, uint64(int32((*Table)(unsafe.Pointer(pTab)).FnCol)+1))
  77868 	if zColAff != 0 {
  77869 		var i int32
  77870 		var j int32
  77871 		for i = libc.AssignInt32(&j, 0); i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  77872 			if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0 {
  77873 				*(*uint8)(unsafe.Pointer(zColAff + uintptr(libc.PostIncInt32(&j, 1)))) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16)).Faffinity
  77874 			}
  77875 		}
  77876 		for __ccgo := true; __ccgo; __ccgo = j >= 0 && int32(*(*uint8)(unsafe.Pointer(zColAff + uintptr(j)))) <= SQLITE_AFF_BLOB {
  77877 			*(*uint8)(unsafe.Pointer(zColAff + uintptr(libc.PostDecInt32(&j, 1)))) = uint8(0)
  77878 		}
  77879 	}
  77880 	return zColAff
  77881 }
  77882 
  77883 // Make changes to the evolving bytecode to do affinity transformations
  77884 // of values that are about to be gathered into a row for table pTab.
  77885 //
  77886 // For ordinary (legacy, non-strict) tables:
  77887 // -----------------------------------------
  77888 //
  77889 // Compute the affinity string for table pTab, if it has not already been
  77890 // computed.  As an optimization, omit trailing SQLITE_AFF_BLOB affinities.
  77891 //
  77892 // If the affinity string is empty (because it was all SQLITE_AFF_BLOB entries
  77893 // which were then optimized out) then this routine becomes a no-op.
  77894 //
  77895 // Otherwise if iReg>0 then code an OP_Affinity opcode that will set the
  77896 // affinities for register iReg and following.  Or if iReg==0,
  77897 // then just set the P4 operand of the previous opcode (which should  be
  77898 // an OP_MakeRecord) to the affinity string.
  77899 //
  77900 // A column affinity string has one character per column:
  77901 //
  77902 //	Character      Column affinity
  77903 //	---------      ---------------
  77904 //	'A'            BLOB
  77905 //	'B'            TEXT
  77906 //	'C'            NUMERIC
  77907 //	'D'            INTEGER
  77908 //	'E'            REAL
  77909 //
  77910 // For STRICT tables:
  77911 // ------------------
  77912 //
  77913 // Generate an appropropriate OP_TypeCheck opcode that will verify the
  77914 // datatypes against the column definitions in pTab.  If iReg==0, that
  77915 // means an OP_MakeRecord opcode has already been generated and should be
  77916 // the last opcode generated.  The new OP_TypeCheck needs to be inserted
  77917 // before the OP_MakeRecord.  The new OP_TypeCheck should use the same
  77918 // register set as the OP_MakeRecord.  If iReg>0 then register iReg is
  77919 // the first of a series of registers that will form the new record.
  77920 // Apply the type checking to that array of registers.
  77921 func Xsqlite3TableAffinity(tls *libc.TLS, v uintptr, pTab uintptr, iReg int32) {
  77922 	var i int32
  77923 	var zColAff uintptr
  77924 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Strict) != 0 {
  77925 		if iReg == 0 {
  77926 			var pPrev uintptr
  77927 			Xsqlite3VdbeAppendP4(tls, v, pTab, -5)
  77928 			pPrev = Xsqlite3VdbeGetLastOp(tls, v)
  77929 
  77930 			(*VdbeOp)(unsafe.Pointer(pPrev)).Fopcode = U8(OP_TypeCheck)
  77931 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*VdbeOp)(unsafe.Pointer(pPrev)).Fp1, (*VdbeOp)(unsafe.Pointer(pPrev)).Fp2, (*VdbeOp)(unsafe.Pointer(pPrev)).Fp3)
  77932 		} else {
  77933 			Xsqlite3VdbeAddOp2(tls, v, OP_TypeCheck, iReg, int32((*Table)(unsafe.Pointer(pTab)).FnNVCol))
  77934 			Xsqlite3VdbeAppendP4(tls, v, pTab, -5)
  77935 		}
  77936 		return
  77937 	}
  77938 	zColAff = (*Table)(unsafe.Pointer(pTab)).FzColAff
  77939 	if zColAff == uintptr(0) {
  77940 		zColAff = Xsqlite3TableAffinityStr(tls, uintptr(0), pTab)
  77941 		if !(zColAff != 0) {
  77942 			Xsqlite3OomFault(tls, Xsqlite3VdbeDb(tls, v))
  77943 			return
  77944 		}
  77945 		(*Table)(unsafe.Pointer(pTab)).FzColAff = zColAff
  77946 	}
  77947 
  77948 	i = int32(libc.Xstrlen(tls, zColAff) & Size_t(0x3fffffff))
  77949 	if i != 0 {
  77950 		if iReg != 0 {
  77951 			Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, iReg, i, 0, zColAff, i)
  77952 		} else {
  77953 			Xsqlite3VdbeChangeP4(tls, v, -1, zColAff, i)
  77954 		}
  77955 	}
  77956 }
  77957 
  77958 func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 {
  77959 	var v uintptr = Xsqlite3GetVdbe(tls, p)
  77960 	var i int32
  77961 	var iEnd int32 = Xsqlite3VdbeCurrentAddr(tls, v)
  77962 	var pVTab uintptr
  77963 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  77964 		pVTab = Xsqlite3GetVTable(tls, (*Parse)(unsafe.Pointer(p)).Fdb, pTab)
  77965 	} else {
  77966 		pVTab = uintptr(0)
  77967 	}
  77968 
  77969 	for i = 1; i < iEnd; i++ {
  77970 		var pOp uintptr = Xsqlite3VdbeGetOp(tls, v, i)
  77971 
  77972 		if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenRead && (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDb {
  77973 			var pIndex uintptr
  77974 			var tnum Pgno = Pgno((*VdbeOp)(unsafe.Pointer(pOp)).Fp2)
  77975 			if tnum == (*Table)(unsafe.Pointer(pTab)).Ftnum {
  77976 				return 1
  77977 			}
  77978 			for pIndex = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIndex != 0; pIndex = (*Index)(unsafe.Pointer(pIndex)).FpNext {
  77979 				if tnum == (*Index)(unsafe.Pointer(pIndex)).Ftnum {
  77980 					return 1
  77981 				}
  77982 			}
  77983 		}
  77984 		if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_VOpen && *(*uintptr)(unsafe.Pointer(pOp + 16)) == pVTab {
  77985 			return 1
  77986 		}
  77987 	}
  77988 	return 0
  77989 }
  77990 
  77991 func exprColumnFlagUnion(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  77992 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN && int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 {
  77993 		*(*U16)(unsafe.Pointer(pWalker + 20)) |= U16(int32((*Column)(unsafe.Pointer((*Table1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 24)))).FaCol + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*16)).FcolFlags))
  77994 	}
  77995 	return WRC_Continue
  77996 }
  77997 
  77998 // All regular columns for table pTab have been puts into registers
  77999 // starting with iRegStore.  The registers that correspond to STORED
  78000 // or VIRTUAL columns have not yet been initialized.  This routine goes
  78001 // back and computes the values for those columns based on the previously
  78002 // computed normal columns.
  78003 func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore int32, pTab uintptr) {
  78004 	bp := tls.Alloc(36)
  78005 	defer tls.Free(36)
  78006 
  78007 	var i int32
  78008 
  78009 	var pRedo uintptr
  78010 	var eProgress int32
  78011 	var pOp uintptr
  78012 
  78013 	Xsqlite3TableAffinity(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iRegStore)
  78014 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasStored) != U32(0) {
  78015 		pOp = Xsqlite3VdbeGetLastOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe)
  78016 		if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Affinity {
  78017 			var ii int32
  78018 			var jj int32
  78019 			var zP4 uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16))
  78020 
  78021 			for ii = libc.AssignInt32(&jj, 0); *(*uint8)(unsafe.Pointer(zP4 + uintptr(jj))) != 0; ii++ {
  78022 				if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0 {
  78023 					continue
  78024 				}
  78025 				if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*16)).FcolFlags)&COLFLAG_STORED != 0 {
  78026 					*(*uint8)(unsafe.Pointer(zP4 + uintptr(jj))) = uint8(SQLITE_AFF_NONE)
  78027 				}
  78028 				jj++
  78029 			}
  78030 		} else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_TypeCheck {
  78031 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = 1
  78032 		}
  78033 	}
  78034 
  78035 	for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  78036 		if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_GENERATED != 0 {
  78037 			*(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16 + 12)) |= U16(COLFLAG_NOTAVAIL)
  78038 		}
  78039 	}
  78040 
  78041 	*(*uintptr)(unsafe.Pointer(bp + 8 + 24)) = pTab
  78042 	(*Walker)(unsafe.Pointer(bp + 8)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  78043 		f func(*libc.TLS, uintptr, uintptr) int32
  78044 	}{exprColumnFlagUnion}))
  78045 	(*Walker)(unsafe.Pointer(bp + 8)).FxSelectCallback = uintptr(0)
  78046 	(*Walker)(unsafe.Pointer(bp + 8)).FxSelectCallback2 = uintptr(0)
  78047 
  78048 	(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -iRegStore
  78049 	for __ccgo := true; __ccgo; __ccgo = pRedo != 0 && eProgress != 0 {
  78050 		eProgress = 0
  78051 		pRedo = uintptr(0)
  78052 		for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  78053 			var pCol uintptr = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16
  78054 			if int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_NOTAVAIL != 0 {
  78055 				var x int32
  78056 				*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_BUSY)
  78057 				(*Walker)(unsafe.Pointer(bp + 8)).FeCode = U16(0)
  78058 				Xsqlite3WalkExpr(tls, bp+8, Xsqlite3ColumnExpr(tls, pTab, pCol))
  78059 				*(*U16)(unsafe.Pointer(pCol + 12)) &= libc.Uint16FromInt32(libc.CplInt32(COLFLAG_BUSY))
  78060 				if int32((*Walker)(unsafe.Pointer(bp+8)).FeCode)&COLFLAG_NOTAVAIL != 0 {
  78061 					pRedo = pCol
  78062 					continue
  78063 				}
  78064 				eProgress = 1
  78065 
  78066 				x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + iRegStore
  78067 				Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pTab, pCol, x)
  78068 				*(*U16)(unsafe.Pointer(pCol + 12)) &= libc.Uint16FromInt32(libc.CplInt32(COLFLAG_NOTAVAIL))
  78069 			}
  78070 		}
  78071 	}
  78072 	if pRedo != 0 {
  78073 		Xsqlite3ErrorMsg(tls, pParse, ts+7970, libc.VaList(bp, (*Column)(unsafe.Pointer(pRedo)).FzCnName))
  78074 	}
  78075 	(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  78076 }
  78077 
  78078 func autoIncBegin(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr) int32 {
  78079 	var memId int32 = 0
  78080 
  78081 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Autoincrement) != U32(0) &&
  78082 		(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&U32(DBFLAG_Vacuum) == U32(0) {
  78083 		var pToplevel uintptr = func() uintptr {
  78084 			if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  78085 				return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  78086 			}
  78087 			return pParse
  78088 		}()
  78089 		var pInfo uintptr
  78090 		var pSeqTab uintptr = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(iDb)*16)).FpSchema)).FpSeqTab
  78091 
  78092 		if pSeqTab == uintptr(0) ||
  78093 			!((*Table)(unsafe.Pointer(pSeqTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) ||
  78094 			int32((*Table)(unsafe.Pointer(pSeqTab)).FeTabType) == TABTYP_VTAB ||
  78095 			int32((*Table)(unsafe.Pointer(pSeqTab)).FnCol) != 2 {
  78096 			(*Parse)(unsafe.Pointer(pParse)).FnErr++
  78097 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_CORRUPT | int32(2)<<8
  78098 			return 0
  78099 		}
  78100 
  78101 		pInfo = (*Parse)(unsafe.Pointer(pToplevel)).FpAinc
  78102 		for pInfo != 0 && (*AutoincInfo)(unsafe.Pointer(pInfo)).FpTab != pTab {
  78103 			pInfo = (*AutoincInfo)(unsafe.Pointer(pInfo)).FpNext
  78104 		}
  78105 		if pInfo == uintptr(0) {
  78106 			pInfo = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(AutoincInfo{})))
  78107 			Xsqlite3ParserAddCleanup(tls, pToplevel, *(*uintptr)(unsafe.Pointer(&struct {
  78108 				f func(*libc.TLS, uintptr, uintptr)
  78109 			}{Xsqlite3DbFree})), pInfo)
  78110 
  78111 			if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  78112 				return 0
  78113 			}
  78114 			(*AutoincInfo)(unsafe.Pointer(pInfo)).FpNext = (*Parse)(unsafe.Pointer(pToplevel)).FpAinc
  78115 			(*Parse)(unsafe.Pointer(pToplevel)).FpAinc = pInfo
  78116 			(*AutoincInfo)(unsafe.Pointer(pInfo)).FpTab = pTab
  78117 			(*AutoincInfo)(unsafe.Pointer(pInfo)).FiDb = iDb
  78118 			(*Parse)(unsafe.Pointer(pToplevel)).FnMem++
  78119 			(*AutoincInfo)(unsafe.Pointer(pInfo)).FregCtr = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pToplevel)).FnMem, 1)
  78120 			*(*int32)(unsafe.Pointer(pToplevel + 44)) += 2
  78121 		}
  78122 		memId = (*AutoincInfo)(unsafe.Pointer(pInfo)).FregCtr
  78123 	}
  78124 	return memId
  78125 }
  78126 
  78127 // This routine generates code that will initialize all of the
  78128 // register used by the autoincrement tracker.
  78129 func Xsqlite3AutoincrementBegin(tls *libc.TLS, pParse uintptr) {
  78130 	var p uintptr
  78131 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  78132 	var pDb uintptr
  78133 	var memId int32
  78134 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  78135 
  78136 	for p = (*Parse)(unsafe.Pointer(pParse)).FpAinc; p != 0; p = (*AutoincInfo)(unsafe.Pointer(p)).FpNext {
  78137 		var aOp uintptr
  78138 		pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*AutoincInfo)(unsafe.Pointer(p)).FiDb)*16
  78139 		memId = (*AutoincInfo)(unsafe.Pointer(p)).FregCtr
  78140 
  78141 		Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, OP_OpenRead)
  78142 		Xsqlite3VdbeLoadString(tls, v, memId-1, (*Table)(unsafe.Pointer((*AutoincInfo)(unsafe.Pointer(p)).FpTab)).FzName)
  78143 		aOp = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(autoInc))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&autoInc)), iLn1)
  78144 		if aOp == uintptr(0) {
  78145 			break
  78146 		}
  78147 		(*VdbeOp)(unsafe.Pointer(aOp)).Fp2 = memId
  78148 		(*VdbeOp)(unsafe.Pointer(aOp)).Fp3 = memId + 2
  78149 		(*VdbeOp)(unsafe.Pointer(aOp + 2*20)).Fp3 = memId
  78150 		(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp1 = memId - 1
  78151 		(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp3 = memId
  78152 		(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp5 = U16(SQLITE_JUMPIFNULL)
  78153 		(*VdbeOp)(unsafe.Pointer(aOp + 4*20)).Fp2 = memId + 1
  78154 		(*VdbeOp)(unsafe.Pointer(aOp + 5*20)).Fp3 = memId
  78155 		(*VdbeOp)(unsafe.Pointer(aOp + 6*20)).Fp1 = memId
  78156 		(*VdbeOp)(unsafe.Pointer(aOp + 7*20)).Fp2 = memId + 2
  78157 		(*VdbeOp)(unsafe.Pointer(aOp + 7*20)).Fp1 = memId
  78158 		(*VdbeOp)(unsafe.Pointer(aOp + 10*20)).Fp2 = memId
  78159 		if (*Parse)(unsafe.Pointer(pParse)).FnTab == 0 {
  78160 			(*Parse)(unsafe.Pointer(pParse)).FnTab = 1
  78161 		}
  78162 	}
  78163 }
  78164 
  78165 var iLn1 int32 = 0
  78166 var autoInc = [12]VdbeOpList{
  78167 	{Fopcode: U8(OP_Null)},
  78168 	{Fopcode: U8(OP_Rewind), Fp2: int8(10)},
  78169 	{Fopcode: U8(OP_Column)},
  78170 	{Fopcode: U8(OP_Ne), Fp2: int8(9)},
  78171 	{Fopcode: U8(OP_Rowid)},
  78172 	{Fopcode: U8(OP_Column), Fp2: int8(1)},
  78173 	{Fopcode: U8(OP_AddImm)},
  78174 	{Fopcode: U8(OP_Copy)},
  78175 	{Fopcode: U8(OP_Goto), Fp2: int8(11)},
  78176 	{Fopcode: U8(OP_Next), Fp2: int8(2)},
  78177 	{Fopcode: U8(OP_Integer)},
  78178 	{Fopcode: U8(OP_Close)},
  78179 }
  78180 
  78181 func autoIncStep(tls *libc.TLS, pParse uintptr, memId int32, regRowid int32) {
  78182 	if memId > 0 {
  78183 		Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_MemMax, memId, regRowid)
  78184 	}
  78185 }
  78186 
  78187 func autoIncrementEnd(tls *libc.TLS, pParse uintptr) {
  78188 	var p uintptr
  78189 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  78190 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  78191 
  78192 	for p = (*Parse)(unsafe.Pointer(pParse)).FpAinc; p != 0; p = (*AutoincInfo)(unsafe.Pointer(p)).FpNext {
  78193 		var aOp uintptr
  78194 		var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*AutoincInfo)(unsafe.Pointer(p)).FiDb)*16
  78195 		var iRec int32
  78196 		var memId int32 = (*AutoincInfo)(unsafe.Pointer(p)).FregCtr
  78197 
  78198 		iRec = Xsqlite3GetTempReg(tls, pParse)
  78199 
  78200 		Xsqlite3VdbeAddOp3(tls, v, OP_Le, memId+2, Xsqlite3VdbeCurrentAddr(tls, v)+7, memId)
  78201 
  78202 		Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, OP_OpenWrite)
  78203 		aOp = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(autoIncEnd))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&autoIncEnd)), iLn2)
  78204 		if aOp == uintptr(0) {
  78205 			break
  78206 		}
  78207 		(*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = memId + 1
  78208 		(*VdbeOp)(unsafe.Pointer(aOp + 1*20)).Fp2 = memId + 1
  78209 		(*VdbeOp)(unsafe.Pointer(aOp + 2*20)).Fp1 = memId - 1
  78210 		(*VdbeOp)(unsafe.Pointer(aOp + 2*20)).Fp3 = iRec
  78211 		(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp2 = iRec
  78212 		(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp3 = memId + 1
  78213 		(*VdbeOp)(unsafe.Pointer(aOp + 3*20)).Fp5 = U16(OPFLAG_APPEND)
  78214 		Xsqlite3ReleaseTempReg(tls, pParse, iRec)
  78215 	}
  78216 }
  78217 
  78218 var iLn2 int32 = 0
  78219 var autoIncEnd = [5]VdbeOpList{
  78220 	{Fopcode: U8(OP_NotNull), Fp2: int8(2)},
  78221 	{Fopcode: U8(OP_NewRowid)},
  78222 	{Fopcode: U8(OP_MakeRecord), Fp2: int8(2)},
  78223 	{Fopcode: U8(OP_Insert)},
  78224 	{Fopcode: U8(OP_Close)},
  78225 }
  78226 
  78227 func Xsqlite3AutoincrementEnd(tls *libc.TLS, pParse uintptr) {
  78228 	if (*Parse)(unsafe.Pointer(pParse)).FpAinc != 0 {
  78229 		autoIncrementEnd(tls, pParse)
  78230 	}
  78231 }
  78232 
  78233 // This routine is called to handle SQL of the following forms:
  78234 //
  78235 //	insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...
  78236 //	insert into TABLE (IDLIST) select
  78237 //	insert into TABLE (IDLIST) default values
  78238 //
  78239 // The IDLIST following the table name is always optional.  If omitted,
  78240 // then a list of all (non-hidden) columns for the table is substituted.
  78241 // The IDLIST appears in the pColumn parameter.  pColumn is NULL if IDLIST
  78242 // is omitted.
  78243 //
  78244 // For the pSelect parameter holds the values to be inserted for the
  78245 // first two forms shown above.  A VALUES clause is really just short-hand
  78246 // for a SELECT statement that omits the FROM clause and everything else
  78247 // that follows.  If the pSelect parameter is NULL, that means that the
  78248 // DEFAULT VALUES form of the INSERT statement is intended.
  78249 //
  78250 // The code generated follows one of four templates.  For a simple
  78251 // insert with data coming from a single-row VALUES clause, the code executes
  78252 // once straight down through.  Pseudo-code follows (we call this
  78253 // the "1st template"):
  78254 //
  78255 //	open write cursor to <table> and its indices
  78256 //	put VALUES clause expressions into registers
  78257 //	write the resulting record into <table>
  78258 //	cleanup
  78259 //
  78260 // The three remaining templates assume the statement is of the form
  78261 //
  78262 //	INSERT INTO <table> SELECT ...
  78263 //
  78264 // If the SELECT clause is of the restricted form "SELECT * FROM <table2>" -
  78265 // in other words if the SELECT pulls all columns from a single table
  78266 // and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and
  78267 // if <table2> and <table1> are distinct tables but have identical
  78268 // schemas, including all the same indices, then a special optimization
  78269 // is invoked that copies raw records from <table2> over to <table1>.
  78270 // See the xferOptimization() function for the implementation of this
  78271 // template.  This is the 2nd template.
  78272 //
  78273 //	open a write cursor to <table>
  78274 //	open read cursor on <table2>
  78275 //	transfer all records in <table2> over to <table>
  78276 //	close cursors
  78277 //	foreach index on <table>
  78278 //	  open a write cursor on the <table> index
  78279 //	  open a read cursor on the corresponding <table2> index
  78280 //	  transfer all records from the read to the write cursors
  78281 //	  close cursors
  78282 //	end foreach
  78283 //
  78284 // The 3rd template is for when the second template does not apply
  78285 // and the SELECT clause does not read from <table> at any time.
  78286 // The generated code follows this template:
  78287 //
  78288 //	   X <- A
  78289 //	   goto B
  78290 //	A: setup for the SELECT
  78291 //	   loop over the rows in the SELECT
  78292 //	     load values into registers R..R+n
  78293 //	     yield X
  78294 //	   end loop
  78295 //	   cleanup after the SELECT
  78296 //	   end-coroutine X
  78297 //	B: open write cursor to <table> and its indices
  78298 //	C: yield X, at EOF goto D
  78299 //	   insert the select result into <table> from R..R+n
  78300 //	   goto C
  78301 //	D: cleanup
  78302 //
  78303 // The 4th template is used if the insert statement takes its
  78304 // values from a SELECT but the data is being inserted into a table
  78305 // that is also read as part of the SELECT.  In the third form,
  78306 // we have to use an intermediate table to store the results of
  78307 // the select.  The template is like this:
  78308 //
  78309 //	   X <- A
  78310 //	   goto B
  78311 //	A: setup for the SELECT
  78312 //	   loop over the tables in the SELECT
  78313 //	     load value into register R..R+n
  78314 //	     yield X
  78315 //	   end loop
  78316 //	   cleanup after the SELECT
  78317 //	   end co-routine R
  78318 //	B: open temp table
  78319 //	L: yield X, at EOF goto M
  78320 //	   insert row from R..R+n into temp table
  78321 //	   goto L
  78322 //	M: open write cursor to <table> and its indices
  78323 //	   rewind temp table
  78324 //	C: loop over rows of intermediate table
  78325 //	     transfer values form intermediate table into <table>
  78326 //	   end loop
  78327 //	D: cleanup
  78328 func Xsqlite3Insert(tls *libc.TLS, pParse uintptr, pTabList uintptr, pSelect uintptr, pColumn uintptr, onError int32, pUpsert uintptr) {
  78329 	bp := tls.Alloc(148)
  78330 	defer tls.Free(148)
  78331 
  78332 	var db uintptr
  78333 	var pTab uintptr
  78334 	var i int32
  78335 	var j int32
  78336 	var v uintptr
  78337 	var pIdx uintptr
  78338 	var nColumn int32
  78339 	var nHidden int32
  78340 
  78341 	var ipkColumn int32
  78342 	var endOfLoop int32
  78343 	var srcTab int32
  78344 	var addrInsTop int32
  78345 	var addrCont int32
  78346 
  78347 	var iDb int32
  78348 	var useTempTable U8
  78349 	var appendFlag U8
  78350 	var withoutRowid U8
  78351 	var bIdListInOrder U8
  78352 	var pList uintptr
  78353 	var iRegStore int32
  78354 
  78355 	var regFromSelect int32
  78356 	var regAutoinc int32
  78357 	var regRowCount int32
  78358 	var regIns int32
  78359 	var regRowid int32
  78360 	var regData int32
  78361 	var aRegIdx uintptr
  78362 
  78363 	var isView int32
  78364 	var pTrigger uintptr
  78365 
  78366 	var regRec int32
  78367 	var regTempRowid int32
  78368 	var addrL int32
  78369 
  78370 	var regYield int32
  78371 	var addrTop int32
  78372 	var rc int32
  78373 
  78374 	var nIdx int32
  78375 	var pNx uintptr
  78376 	var pX uintptr
  78377 	var y int32
  78378 	var k int32
  78379 	var colFlags U32
  78380 	var addr1 int32
  78381 	var regCols int32
  78382 	var pIpk uintptr
  78383 	var addr11 int32
  78384 	var pVTab uintptr
  78385 
  78386 	var bUseSeek int32
  78387 	nHidden = 0
  78388 	*(*int32)(unsafe.Pointer(bp + 136)) = 0
  78389 	*(*int32)(unsafe.Pointer(bp + 140)) = 0
  78390 	ipkColumn = -1
  78391 	srcTab = 0
  78392 	addrInsTop = 0
  78393 	addrCont = 0
  78394 	useTempTable = U8(0)
  78395 	appendFlag = U8(0)
  78396 	pList = uintptr(0)
  78397 	regFromSelect = 0
  78398 	regAutoinc = 0
  78399 	regRowCount = 0
  78400 	aRegIdx = uintptr(0)
  78401 
  78402 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  78403 
  78404 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  78405 		goto __1
  78406 	}
  78407 	goto insert_cleanup
  78408 __1:
  78409 	;
  78410 	(*SelectDest)(unsafe.Pointer(bp + 76)).FiSDParm = 0
  78411 
  78412 	if !(pSelect != 0 && (*Select)(unsafe.Pointer(pSelect)).FselFlags&U32(SF_Values) != U32(0) && (*Select)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0)) {
  78413 		goto __2
  78414 	}
  78415 	pList = (*Select)(unsafe.Pointer(pSelect)).FpEList
  78416 	(*Select)(unsafe.Pointer(pSelect)).FpEList = uintptr(0)
  78417 	Xsqlite3SelectDelete(tls, db, pSelect)
  78418 	pSelect = uintptr(0)
  78419 __2:
  78420 	;
  78421 	pTab = Xsqlite3SrcListLookup(tls, pParse, pTabList)
  78422 	if !(pTab == uintptr(0)) {
  78423 		goto __3
  78424 	}
  78425 	goto insert_cleanup
  78426 __3:
  78427 	;
  78428 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  78429 
  78430 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0),
  78431 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName) != 0) {
  78432 		goto __4
  78433 	}
  78434 	goto insert_cleanup
  78435 __4:
  78436 	;
  78437 	withoutRowid = libc.BoolUint8(!((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)))
  78438 
  78439 	pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_INSERT, uintptr(0), bp+72)
  78440 	isView = libc.Bool32(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW)
  78441 
  78442 	if !(Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0) {
  78443 		goto __5
  78444 	}
  78445 	goto insert_cleanup
  78446 __5:
  78447 	;
  78448 	if !(Xsqlite3IsReadOnly(tls, pParse, pTab, *(*int32)(unsafe.Pointer(bp + 72))) != 0) {
  78449 		goto __6
  78450 	}
  78451 	goto insert_cleanup
  78452 __6:
  78453 	;
  78454 	v = Xsqlite3GetVdbe(tls, pParse)
  78455 	if !(v == uintptr(0)) {
  78456 		goto __7
  78457 	}
  78458 	goto insert_cleanup
  78459 __7:
  78460 	;
  78461 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) {
  78462 		goto __8
  78463 	}
  78464 	Xsqlite3VdbeCountChanges(tls, v)
  78465 __8:
  78466 	;
  78467 	Xsqlite3BeginWriteOperation(tls, pParse, libc.Bool32(pSelect != 0 || pTrigger != 0), iDb)
  78468 
  78469 	if !(pColumn == uintptr(0) &&
  78470 		pSelect != uintptr(0) &&
  78471 		pTrigger == uintptr(0) &&
  78472 		xferOptimization(tls, pParse, pTab, pSelect, onError, iDb) != 0) {
  78473 		goto __9
  78474 	}
  78475 
  78476 	goto insert_end
  78477 __9:
  78478 	;
  78479 	regAutoinc = autoIncBegin(tls, pParse, iDb, pTab)
  78480 
  78481 	regRowid = libc.AssignInt32(&regIns, (*Parse)(unsafe.Pointer(pParse)).FnMem+1)
  78482 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1
  78483 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  78484 		goto __10
  78485 	}
  78486 	regRowid++
  78487 	(*Parse)(unsafe.Pointer(pParse)).FnMem++
  78488 __10:
  78489 	;
  78490 	regData = regRowid + 1
  78491 
  78492 	bIdListInOrder = U8(libc.Bool32((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_OOOHidden|TF_HasStored) == U32(0)))
  78493 	if !(pColumn != 0) {
  78494 		goto __11
  78495 	}
  78496 
  78497 	(*IdList)(unsafe.Pointer(pColumn)).FeU4 = U8(EU4_IDX)
  78498 	i = 0
  78499 __12:
  78500 	if !(i < (*IdList)(unsafe.Pointer(pColumn)).FnId) {
  78501 		goto __14
  78502 	}
  78503 	*(*int32)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8 + 4)) = -1
  78504 	goto __13
  78505 __13:
  78506 	i++
  78507 	goto __12
  78508 	goto __14
  78509 __14:
  78510 	;
  78511 	i = 0
  78512 __15:
  78513 	if !(i < (*IdList)(unsafe.Pointer(pColumn)).FnId) {
  78514 		goto __17
  78515 	}
  78516 	j = 0
  78517 __18:
  78518 	if !(j < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  78519 		goto __20
  78520 	}
  78521 	if !(Xsqlite3StrICmp(tls, (*IdList_item)(unsafe.Pointer(pColumn+8+uintptr(i)*8)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FzCnName) == 0) {
  78522 		goto __21
  78523 	}
  78524 	*(*int32)(unsafe.Pointer(pColumn + 8 + uintptr(i)*8 + 4)) = j
  78525 	if !(i != j) {
  78526 		goto __22
  78527 	}
  78528 	bIdListInOrder = U8(0)
  78529 __22:
  78530 	;
  78531 	if !(j == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  78532 		goto __23
  78533 	}
  78534 	ipkColumn = i
  78535 __23:
  78536 	;
  78537 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&(COLFLAG_STORED|COLFLAG_VIRTUAL) != 0) {
  78538 		goto __24
  78539 	}
  78540 	Xsqlite3ErrorMsg(tls, pParse,
  78541 		ts+15657,
  78542 		libc.VaList(bp, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FzCnName))
  78543 	goto insert_cleanup
  78544 __24:
  78545 	;
  78546 	goto __20
  78547 __21:
  78548 	;
  78549 	goto __19
  78550 __19:
  78551 	j++
  78552 	goto __18
  78553 	goto __20
  78554 __20:
  78555 	;
  78556 	if !(j >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  78557 		goto __25
  78558 	}
  78559 	if !(Xsqlite3IsRowid(tls, (*IdList_item)(unsafe.Pointer(pColumn+8+uintptr(i)*8)).FzName) != 0 && !(withoutRowid != 0)) {
  78560 		goto __26
  78561 	}
  78562 	ipkColumn = i
  78563 	bIdListInOrder = U8(0)
  78564 	goto __27
  78565 __26:
  78566 	Xsqlite3ErrorMsg(tls, pParse, ts+15698,
  78567 		libc.VaList(bp+8, pTabList+8, (*IdList_item)(unsafe.Pointer(pColumn+8+uintptr(i)*8)).FzName))
  78568 	(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  78569 	goto insert_cleanup
  78570 __27:
  78571 	;
  78572 __25:
  78573 	;
  78574 	goto __16
  78575 __16:
  78576 	i++
  78577 	goto __15
  78578 	goto __17
  78579 __17:
  78580 	;
  78581 __11:
  78582 	;
  78583 	if !(pSelect != 0) {
  78584 		goto __28
  78585 	}
  78586 
  78587 	regYield = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  78588 	addrTop = Xsqlite3VdbeCurrentAddr(tls, v) + 1
  78589 	Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, addrTop)
  78590 	Xsqlite3SelectDestInit(tls, bp+76, SRT_Coroutine, regYield)
  78591 	(*SelectDest)(unsafe.Pointer(bp + 76)).FiSdst = func() int32 {
  78592 		if bIdListInOrder != 0 {
  78593 			return regData
  78594 		}
  78595 		return 0
  78596 	}()
  78597 	(*SelectDest)(unsafe.Pointer(bp + 76)).FnSdst = int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  78598 	rc = Xsqlite3Select(tls, pParse, pSelect, bp+76)
  78599 	regFromSelect = (*SelectDest)(unsafe.Pointer(bp + 76)).FiSdst
  78600 
  78601 	if !(rc != 0 || (*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  78602 		goto __30
  78603 	}
  78604 	goto insert_cleanup
  78605 __30:
  78606 	;
  78607 	Xsqlite3VdbeEndCoroutine(tls, v, regYield)
  78608 	Xsqlite3VdbeJumpHere(tls, v, addrTop-1)
  78609 
  78610 	nColumn = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpEList)).FnExpr
  78611 
  78612 	if !(pTrigger != 0 || readsTable(tls, pParse, iDb, pTab) != 0) {
  78613 		goto __31
  78614 	}
  78615 	useTempTable = U8(1)
  78616 __31:
  78617 	;
  78618 	if !(useTempTable != 0) {
  78619 		goto __32
  78620 	}
  78621 
  78622 	srcTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  78623 	regRec = Xsqlite3GetTempReg(tls, pParse)
  78624 	regTempRowid = Xsqlite3GetTempReg(tls, pParse)
  78625 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, srcTab, nColumn)
  78626 	addrL = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+76)).FiSDParm)
  78627 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regFromSelect, nColumn, regRec)
  78628 	Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, srcTab, regTempRowid)
  78629 	Xsqlite3VdbeAddOp3(tls, v, OP_Insert, srcTab, regRec, regTempRowid)
  78630 	Xsqlite3VdbeGoto(tls, v, addrL)
  78631 	Xsqlite3VdbeJumpHere(tls, v, addrL)
  78632 	Xsqlite3ReleaseTempReg(tls, pParse, regRec)
  78633 	Xsqlite3ReleaseTempReg(tls, pParse, regTempRowid)
  78634 __32:
  78635 	;
  78636 	goto __29
  78637 __28:
  78638 	libc.Xmemset(tls, bp+104, 0, uint32(unsafe.Sizeof(NameContext{})))
  78639 	(*NameContext)(unsafe.Pointer(bp + 104)).FpParse = pParse
  78640 	srcTab = -1
  78641 
  78642 	if !(pList != 0) {
  78643 		goto __33
  78644 	}
  78645 	nColumn = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  78646 	if !(Xsqlite3ResolveExprListNames(tls, bp+104, pList) != 0) {
  78647 		goto __35
  78648 	}
  78649 	goto insert_cleanup
  78650 __35:
  78651 	;
  78652 	goto __34
  78653 __33:
  78654 	nColumn = 0
  78655 __34:
  78656 	;
  78657 __29:
  78658 	;
  78659 	if !(pColumn == uintptr(0) && nColumn > 0) {
  78660 		goto __36
  78661 	}
  78662 	ipkColumn = int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
  78663 	if !(ipkColumn >= 0 && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != U32(0)) {
  78664 		goto __37
  78665 	}
  78666 
  78667 	i = ipkColumn - 1
  78668 __38:
  78669 	if !(i >= 0) {
  78670 		goto __40
  78671 	}
  78672 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_GENERATED != 0) {
  78673 		goto __41
  78674 	}
  78675 
  78676 	ipkColumn--
  78677 __41:
  78678 	;
  78679 	goto __39
  78680 __39:
  78681 	i--
  78682 	goto __38
  78683 	goto __40
  78684 __40:
  78685 	;
  78686 __37:
  78687 	;
  78688 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated|TF_HasHidden) != U32(0)) {
  78689 		goto __42
  78690 	}
  78691 	i = 0
  78692 __43:
  78693 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  78694 		goto __45
  78695 	}
  78696 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_NOINSERT != 0) {
  78697 		goto __46
  78698 	}
  78699 	nHidden++
  78700 __46:
  78701 	;
  78702 	goto __44
  78703 __44:
  78704 	i++
  78705 	goto __43
  78706 	goto __45
  78707 __45:
  78708 	;
  78709 __42:
  78710 	;
  78711 	if !(nColumn != int32((*Table)(unsafe.Pointer(pTab)).FnCol)-nHidden) {
  78712 		goto __47
  78713 	}
  78714 	Xsqlite3ErrorMsg(tls, pParse,
  78715 		ts+15730,
  78716 		libc.VaList(bp+24, pTabList+8, int32((*Table)(unsafe.Pointer(pTab)).FnCol)-nHidden, nColumn))
  78717 	goto insert_cleanup
  78718 __47:
  78719 	;
  78720 __36:
  78721 	;
  78722 	if !(pColumn != uintptr(0) && nColumn != (*IdList)(unsafe.Pointer(pColumn)).FnId) {
  78723 		goto __48
  78724 	}
  78725 	Xsqlite3ErrorMsg(tls, pParse, ts+15782, libc.VaList(bp+48, nColumn, (*IdList)(unsafe.Pointer(pColumn)).FnId))
  78726 	goto insert_cleanup
  78727 __48:
  78728 	;
  78729 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&(uint64(0x00001)<<32) != uint64(0) &&
  78730 		!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) &&
  78731 		!(int32((*Parse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) &&
  78732 		!(int32((*Parse)(unsafe.Pointer(pParse)).FbReturning) != 0)) {
  78733 		goto __49
  78734 	}
  78735 	regRowCount = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  78736 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regRowCount)
  78737 __49:
  78738 	;
  78739 	if !!(isView != 0) {
  78740 		goto __50
  78741 	}
  78742 	nIdx = Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(0), -1, uintptr(0),
  78743 		bp+136, bp+140)
  78744 	aRegIdx = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(int32(0)))*uint32(nIdx+2)))
  78745 	if !(aRegIdx == uintptr(0)) {
  78746 		goto __51
  78747 	}
  78748 	goto insert_cleanup
  78749 __51:
  78750 	;
  78751 	i = 0
  78752 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  78753 __52:
  78754 	if !(i < nIdx) {
  78755 		goto __54
  78756 	}
  78757 
  78758 	*(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  78759 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  78760 	goto __53
  78761 __53:
  78762 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  78763 	i++
  78764 	goto __52
  78765 	goto __54
  78766 __54:
  78767 	;
  78768 	*(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  78769 __50:
  78770 	;
  78771 	if !(pUpsert != 0) {
  78772 		goto __55
  78773 	}
  78774 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  78775 		goto __56
  78776 	}
  78777 	Xsqlite3ErrorMsg(tls, pParse, ts+15807,
  78778 		libc.VaList(bp+64, (*Table)(unsafe.Pointer(pTab)).FzName))
  78779 	goto insert_cleanup
  78780 __56:
  78781 	;
  78782 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
  78783 		goto __57
  78784 	}
  78785 	Xsqlite3ErrorMsg(tls, pParse, ts+15853, 0)
  78786 	goto insert_cleanup
  78787 __57:
  78788 	;
  78789 	if !(Xsqlite3HasExplicitNulls(tls, pParse, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) != 0) {
  78790 		goto __58
  78791 	}
  78792 	goto insert_cleanup
  78793 __58:
  78794 	;
  78795 	(*SrcItem)(unsafe.Pointer(pTabList + 8)).FiCursor = *(*int32)(unsafe.Pointer(bp + 136))
  78796 	pNx = pUpsert
  78797 __59:
  78798 	(*Upsert)(unsafe.Pointer(pNx)).FpUpsertSrc = pTabList
  78799 	(*Upsert)(unsafe.Pointer(pNx)).FregData = regData
  78800 	(*Upsert)(unsafe.Pointer(pNx)).FiDataCur = *(*int32)(unsafe.Pointer(bp + 136))
  78801 	(*Upsert)(unsafe.Pointer(pNx)).FiIdxCur = *(*int32)(unsafe.Pointer(bp + 140))
  78802 	if !((*Upsert)(unsafe.Pointer(pNx)).FpUpsertTarget != 0) {
  78803 		goto __62
  78804 	}
  78805 	if !(Xsqlite3UpsertAnalyzeTarget(tls, pParse, pTabList, pNx) != 0) {
  78806 		goto __63
  78807 	}
  78808 	goto insert_cleanup
  78809 __63:
  78810 	;
  78811 __62:
  78812 	;
  78813 	pNx = (*Upsert)(unsafe.Pointer(pNx)).FpNextUpsert
  78814 	goto __60
  78815 __60:
  78816 	if pNx != uintptr(0) {
  78817 		goto __59
  78818 	}
  78819 	goto __61
  78820 __61:
  78821 	;
  78822 __55:
  78823 	;
  78824 	if !(useTempTable != 0) {
  78825 		goto __64
  78826 	}
  78827 
  78828 	addrInsTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, srcTab)
  78829 	addrCont = Xsqlite3VdbeCurrentAddr(tls, v)
  78830 	goto __65
  78831 __64:
  78832 	if !(pSelect != 0) {
  78833 		goto __66
  78834 	}
  78835 
  78836 	addrInsTop = libc.AssignInt32(&addrCont, Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+76)).FiSDParm))
  78837 
  78838 	if !(ipkColumn >= 0) {
  78839 		goto __67
  78840 	}
  78841 
  78842 	Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regFromSelect+ipkColumn, regRowid)
  78843 __67:
  78844 	;
  78845 __66:
  78846 	;
  78847 __65:
  78848 	;
  78849 	nHidden = 0
  78850 	iRegStore = regData
  78851 	i = 0
  78852 __68:
  78853 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  78854 		goto __70
  78855 	}
  78856 
  78857 	if !(i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  78858 		goto __71
  78859 	}
  78860 
  78861 	Xsqlite3VdbeAddOp1(tls, v, OP_SoftNull, iRegStore)
  78862 	goto __69
  78863 __71:
  78864 	;
  78865 	if !(libc.AssignUint32(&colFlags, U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags))&U32(COLFLAG_NOINSERT) != U32(0)) {
  78866 		goto __72
  78867 	}
  78868 	nHidden++
  78869 	if !(colFlags&U32(COLFLAG_VIRTUAL) != U32(0)) {
  78870 		goto __73
  78871 	}
  78872 
  78873 	iRegStore--
  78874 	goto __69
  78875 	goto __74
  78876 __73:
  78877 	if !(colFlags&U32(COLFLAG_STORED) != U32(0)) {
  78878 		goto __75
  78879 	}
  78880 
  78881 	if !(*(*int32)(unsafe.Pointer(bp + 72))&TRIGGER_BEFORE != 0) {
  78882 		goto __77
  78883 	}
  78884 	Xsqlite3VdbeAddOp1(tls, v, OP_SoftNull, iRegStore)
  78885 __77:
  78886 	;
  78887 	goto __69
  78888 	goto __76
  78889 __75:
  78890 	if !(pColumn == uintptr(0)) {
  78891 		goto __78
  78892 	}
  78893 
  78894 	Xsqlite3ExprCodeFactorable(tls, pParse,
  78895 		Xsqlite3ColumnExpr(tls, pTab, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16),
  78896 		iRegStore)
  78897 	goto __69
  78898 __78:
  78899 	;
  78900 __76:
  78901 	;
  78902 __74:
  78903 	;
  78904 __72:
  78905 	;
  78906 	if !(pColumn != 0) {
  78907 		goto __79
  78908 	}
  78909 
  78910 	j = 0
  78911 __81:
  78912 	if !(j < (*IdList)(unsafe.Pointer(pColumn)).FnId && *(*int32)(unsafe.Pointer(pColumn + 8 + uintptr(j)*8 + 4)) != i) {
  78913 		goto __83
  78914 	}
  78915 	goto __82
  78916 __82:
  78917 	j++
  78918 	goto __81
  78919 	goto __83
  78920 __83:
  78921 	;
  78922 	if !(j >= (*IdList)(unsafe.Pointer(pColumn)).FnId) {
  78923 		goto __84
  78924 	}
  78925 
  78926 	Xsqlite3ExprCodeFactorable(tls, pParse,
  78927 		Xsqlite3ColumnExpr(tls, pTab, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16),
  78928 		iRegStore)
  78929 	goto __69
  78930 __84:
  78931 	;
  78932 	k = j
  78933 	goto __80
  78934 __79:
  78935 	if !(nColumn == 0) {
  78936 		goto __85
  78937 	}
  78938 
  78939 	Xsqlite3ExprCodeFactorable(tls, pParse,
  78940 		Xsqlite3ColumnExpr(tls, pTab, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16),
  78941 		iRegStore)
  78942 	goto __69
  78943 	goto __86
  78944 __85:
  78945 	k = i - nHidden
  78946 __86:
  78947 	;
  78948 __80:
  78949 	;
  78950 	if !(useTempTable != 0) {
  78951 		goto __87
  78952 	}
  78953 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, k, iRegStore)
  78954 	goto __88
  78955 __87:
  78956 	if !(pSelect != 0) {
  78957 		goto __89
  78958 	}
  78959 	if !(regFromSelect != regData) {
  78960 		goto __91
  78961 	}
  78962 	Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, regFromSelect+k, iRegStore)
  78963 __91:
  78964 	;
  78965 	goto __90
  78966 __89:
  78967 	pX = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(k)*20)).FpExpr
  78968 	y = Xsqlite3ExprCodeTarget(tls, pParse, pX, iRegStore)
  78969 	if !(y != iRegStore) {
  78970 		goto __92
  78971 	}
  78972 	Xsqlite3VdbeAddOp2(tls, v,
  78973 		func() int32 {
  78974 			if (*Expr)(unsafe.Pointer(pX)).Fflags&U32(EP_Subquery) != U32(0) {
  78975 				return OP_Copy
  78976 			}
  78977 			return OP_SCopy
  78978 		}(), y, iRegStore)
  78979 __92:
  78980 	;
  78981 __90:
  78982 	;
  78983 __88:
  78984 	;
  78985 	goto __69
  78986 __69:
  78987 	i++
  78988 	iRegStore++
  78989 	goto __68
  78990 	goto __70
  78991 __70:
  78992 	;
  78993 	endOfLoop = Xsqlite3VdbeMakeLabel(tls, pParse)
  78994 	if !(*(*int32)(unsafe.Pointer(bp + 72))&TRIGGER_BEFORE != 0) {
  78995 		goto __93
  78996 	}
  78997 	regCols = Xsqlite3GetTempRange(tls, pParse, int32((*Table)(unsafe.Pointer(pTab)).FnCol)+1)
  78998 
  78999 	if !(ipkColumn < 0) {
  79000 		goto __94
  79001 	}
  79002 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, -1, regCols)
  79003 	goto __95
  79004 __94:
  79005 	;
  79006 	if !(useTempTable != 0) {
  79007 		goto __96
  79008 	}
  79009 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, ipkColumn, regCols)
  79010 	goto __97
  79011 __96:
  79012 	;
  79013 	Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ipkColumn)*20)).FpExpr, regCols)
  79014 __97:
  79015 	;
  79016 	addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, regCols)
  79017 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, -1, regCols)
  79018 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  79019 	Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regCols)
  79020 __95:
  79021 	;
  79022 	Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regRowid+1, regCols+1, int32((*Table)(unsafe.Pointer(pTab)).FnNVCol)-1)
  79023 
  79024 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != 0) {
  79025 		goto __98
  79026 	}
  79027 
  79028 	Xsqlite3ComputeGeneratedColumns(tls, pParse, regCols+1, pTab)
  79029 __98:
  79030 	;
  79031 	if !!(isView != 0) {
  79032 		goto __99
  79033 	}
  79034 	Xsqlite3TableAffinity(tls, v, pTab, regCols+1)
  79035 __99:
  79036 	;
  79037 	Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_INSERT, uintptr(0), TRIGGER_BEFORE,
  79038 		pTab, regCols-int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1, onError, endOfLoop)
  79039 
  79040 	Xsqlite3ReleaseTempRange(tls, pParse, regCols, int32((*Table)(unsafe.Pointer(pTab)).FnCol)+1)
  79041 __93:
  79042 	;
  79043 	if !!(isView != 0) {
  79044 		goto __100
  79045 	}
  79046 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  79047 		goto __101
  79048 	}
  79049 
  79050 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regIns)
  79051 __101:
  79052 	;
  79053 	if !(ipkColumn >= 0) {
  79054 		goto __102
  79055 	}
  79056 
  79057 	if !(useTempTable != 0) {
  79058 		goto __104
  79059 	}
  79060 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, ipkColumn, regRowid)
  79061 	goto __105
  79062 __104:
  79063 	if !(pSelect != 0) {
  79064 		goto __106
  79065 	}
  79066 
  79067 	goto __107
  79068 __106:
  79069 	pIpk = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(ipkColumn)*20)).FpExpr
  79070 	if !(int32((*Expr)(unsafe.Pointer(pIpk)).Fop) == TK_NULL && !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB)) {
  79071 		goto __108
  79072 	}
  79073 	Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 136)), regRowid, regAutoinc)
  79074 	appendFlag = U8(1)
  79075 	goto __109
  79076 __108:
  79077 	Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ipkColumn)*20)).FpExpr, regRowid)
  79078 __109:
  79079 	;
  79080 __107:
  79081 	;
  79082 __105:
  79083 	;
  79084 	if !!(appendFlag != 0) {
  79085 		goto __110
  79086 	}
  79087 	if !!(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  79088 		goto __111
  79089 	}
  79090 	addr11 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, regRowid)
  79091 	Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 136)), regRowid, regAutoinc)
  79092 	Xsqlite3VdbeJumpHere(tls, v, addr11)
  79093 	goto __112
  79094 __111:
  79095 	addr11 = Xsqlite3VdbeCurrentAddr(tls, v)
  79096 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regRowid, addr11+2)
  79097 __112:
  79098 	;
  79099 	Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regRowid)
  79100 __110:
  79101 	;
  79102 	goto __103
  79103 __102:
  79104 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB || withoutRowid != 0) {
  79105 		goto __113
  79106 	}
  79107 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regRowid)
  79108 	goto __114
  79109 __113:
  79110 	Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 136)), regRowid, regAutoinc)
  79111 	appendFlag = U8(1)
  79112 __114:
  79113 	;
  79114 __103:
  79115 	;
  79116 	autoIncStep(tls, pParse, regAutoinc, regRowid)
  79117 
  79118 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != 0) {
  79119 		goto __115
  79120 	}
  79121 	Xsqlite3ComputeGeneratedColumns(tls, pParse, regRowid+1, pTab)
  79122 __115:
  79123 	;
  79124 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  79125 		goto __116
  79126 	}
  79127 	pVTab = Xsqlite3GetVTable(tls, db, pTab)
  79128 	Xsqlite3VtabMakeWritable(tls, pParse, pTab)
  79129 	Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 1, int32((*Table)(unsafe.Pointer(pTab)).FnCol)+2, regIns, pVTab, -11)
  79130 	Xsqlite3VdbeChangeP5(tls, v, func() uint16 {
  79131 		if onError == OE_Default {
  79132 			return uint16(OE_Abort)
  79133 		}
  79134 		return uint16(onError)
  79135 	}())
  79136 	Xsqlite3MayAbort(tls, pParse)
  79137 	goto __117
  79138 __116:
  79139 	*(*int32)(unsafe.Pointer(bp + 144)) = 0
  79140 	Xsqlite3GenerateConstraintChecks(tls, pParse, pTab, aRegIdx, *(*int32)(unsafe.Pointer(bp + 136)), *(*int32)(unsafe.Pointer(bp + 140)),
  79141 		regIns, 0, uint8(libc.Bool32(ipkColumn >= 0)), uint8(onError), endOfLoop, bp+144, uintptr(0), pUpsert)
  79142 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0) {
  79143 		goto __118
  79144 	}
  79145 	Xsqlite3FkCheck(tls, pParse, pTab, 0, regIns, uintptr(0), 0)
  79146 __118:
  79147 	;
  79148 	bUseSeek = libc.Bool32(*(*int32)(unsafe.Pointer(bp + 144)) == 0 || !(Xsqlite3VdbeHasSubProgram(tls, v) != 0))
  79149 	Xsqlite3CompleteInsertion(tls, pParse, pTab, *(*int32)(unsafe.Pointer(bp + 136)), *(*int32)(unsafe.Pointer(bp + 140)),
  79150 		regIns, aRegIdx, 0, int32(appendFlag), bUseSeek)
  79151 __117:
  79152 	;
  79153 __100:
  79154 	;
  79155 	if !(regRowCount != 0) {
  79156 		goto __119
  79157 	}
  79158 	Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regRowCount, 1)
  79159 __119:
  79160 	;
  79161 	if !(pTrigger != 0) {
  79162 		goto __120
  79163 	}
  79164 
  79165 	Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_INSERT, uintptr(0), TRIGGER_AFTER,
  79166 		pTab, regData-2-int32((*Table)(unsafe.Pointer(pTab)).FnCol), onError, endOfLoop)
  79167 __120:
  79168 	;
  79169 	Xsqlite3VdbeResolveLabel(tls, v, endOfLoop)
  79170 	if !(useTempTable != 0) {
  79171 		goto __121
  79172 	}
  79173 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, srcTab, addrCont)
  79174 	Xsqlite3VdbeJumpHere(tls, v, addrInsTop)
  79175 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, srcTab)
  79176 	goto __122
  79177 __121:
  79178 	if !(pSelect != 0) {
  79179 		goto __123
  79180 	}
  79181 	Xsqlite3VdbeGoto(tls, v, addrCont)
  79182 	Xsqlite3VdbeJumpHere(tls, v, addrInsTop)
  79183 __123:
  79184 	;
  79185 __122:
  79186 	;
  79187 insert_end:
  79188 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0)) {
  79189 		goto __124
  79190 	}
  79191 	Xsqlite3AutoincrementEnd(tls, pParse)
  79192 __124:
  79193 	;
  79194 	if !(regRowCount != 0) {
  79195 		goto __125
  79196 	}
  79197 	Xsqlite3CodeChangeCount(tls, v, regRowCount, ts+15874)
  79198 __125:
  79199 	;
  79200 insert_cleanup:
  79201 	Xsqlite3SrcListDelete(tls, db, pTabList)
  79202 	Xsqlite3ExprListDelete(tls, db, pList)
  79203 	Xsqlite3UpsertDelete(tls, db, pUpsert)
  79204 	Xsqlite3SelectDelete(tls, db, pSelect)
  79205 	Xsqlite3IdListDelete(tls, db, pColumn)
  79206 	if !(aRegIdx != 0) {
  79207 		goto __126
  79208 	}
  79209 	Xsqlite3DbNNFreeNN(tls, db, aRegIdx)
  79210 __126:
  79211 }
  79212 
  79213 func checkConstraintExprNode(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  79214 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN {
  79215 		if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 {
  79216 			if *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 24)) + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*4)) >= 0 {
  79217 				*(*U16)(unsafe.Pointer(pWalker + 20)) |= U16(CKCNSTRNT_COLUMN)
  79218 			}
  79219 		} else {
  79220 			*(*U16)(unsafe.Pointer(pWalker + 20)) |= U16(CKCNSTRNT_ROWID)
  79221 		}
  79222 	}
  79223 	return WRC_Continue
  79224 }
  79225 
  79226 // pExpr is a CHECK constraint on a row that is being UPDATE-ed.  The
  79227 // only columns that are modified by the UPDATE are those for which
  79228 // aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.
  79229 //
  79230 // Return true if CHECK constraint pExpr uses any of the
  79231 // changing columns (or the rowid if it is changing).  In other words,
  79232 // return true if this CHECK constraint must be validated for
  79233 // the new row in the UPDATE statement.
  79234 //
  79235 // 2018-09-15: pExpr might also be an expression for an index-on-expressions.
  79236 // The operation of this routine is the same - return true if an only if
  79237 // the expression uses one or more of columns identified by the second and
  79238 // third arguments.
  79239 func Xsqlite3ExprReferencesUpdatedColumn(tls *libc.TLS, pExpr uintptr, aiChng uintptr, chngRowid int32) int32 {
  79240 	bp := tls.Alloc(28)
  79241 	defer tls.Free(28)
  79242 
  79243 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  79244 	(*Walker)(unsafe.Pointer(bp)).FeCode = U16(0)
  79245 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  79246 		f func(*libc.TLS, uintptr, uintptr) int32
  79247 	}{checkConstraintExprNode}))
  79248 	*(*uintptr)(unsafe.Pointer(bp + 24)) = aiChng
  79249 	Xsqlite3WalkExpr(tls, bp, pExpr)
  79250 	if !(chngRowid != 0) {
  79251 		*(*U16)(unsafe.Pointer(bp + 20)) &= libc.Uint16FromInt32(libc.CplInt32(CKCNSTRNT_ROWID))
  79252 	}
  79253 
  79254 	return libc.Bool32(int32((*Walker)(unsafe.Pointer(bp)).FeCode) != 0)
  79255 }
  79256 
  79257 // The sqlite3GenerateConstraintChecks() routine usually wants to visit
  79258 // the indexes of a table in the order provided in the Table->pIndex list.
  79259 // However, sometimes (rarely - when there is an upsert) it wants to visit
  79260 // the indexes in a different order.  The following data structures accomplish
  79261 // this.
  79262 //
  79263 // The IndexIterator object is used to walk through all of the indexes
  79264 // of a table in either Index.pNext order, or in some other order established
  79265 // by an array of IndexListTerm objects.
  79266 type IndexListTerm1 = struct {
  79267 	Fp  uintptr
  79268 	Fix int32
  79269 }
  79270 
  79271 // The sqlite3GenerateConstraintChecks() routine usually wants to visit
  79272 // the indexes of a table in the order provided in the Table->pIndex list.
  79273 // However, sometimes (rarely - when there is an upsert) it wants to visit
  79274 // the indexes in a different order.  The following data structures accomplish
  79275 // this.
  79276 //
  79277 // The IndexIterator object is used to walk through all of the indexes
  79278 // of a table in either Index.pNext order, or in some other order established
  79279 // by an array of IndexListTerm objects.
  79280 type IndexListTerm = IndexListTerm1
  79281 type IndexIterator1 = struct {
  79282 	FeType int32
  79283 	Fi     int32
  79284 	Fu     struct {
  79285 		Flx          struct{ FpIdx uintptr }
  79286 		F__ccgo_pad1 [4]byte
  79287 	}
  79288 }
  79289 
  79290 type IndexIterator = IndexIterator1
  79291 
  79292 func indexIteratorFirst(tls *libc.TLS, pIter uintptr, pIx uintptr) uintptr {
  79293 	if (*IndexIterator)(unsafe.Pointer(pIter)).FeType != 0 {
  79294 		*(*int32)(unsafe.Pointer(pIx)) = (*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIter + 8 + 4)))).Fix
  79295 		return (*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIter + 8 + 4)))).Fp
  79296 	} else {
  79297 		*(*int32)(unsafe.Pointer(pIx)) = 0
  79298 		return *(*uintptr)(unsafe.Pointer(pIter + 8))
  79299 	}
  79300 	return uintptr(0)
  79301 }
  79302 
  79303 func indexIteratorNext(tls *libc.TLS, pIter uintptr, pIx uintptr) uintptr {
  79304 	if (*IndexIterator)(unsafe.Pointer(pIter)).FeType != 0 {
  79305 		var i int32 = libc.PreIncInt32(&(*IndexIterator)(unsafe.Pointer(pIter)).Fi, 1)
  79306 		if i >= *(*int32)(unsafe.Pointer(pIter + 8)) {
  79307 			*(*int32)(unsafe.Pointer(pIx)) = i
  79308 			return uintptr(0)
  79309 		}
  79310 		*(*int32)(unsafe.Pointer(pIx)) = (*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIter + 8 + 4)) + uintptr(i)*8)).Fix
  79311 		return (*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIter + 8 + 4)) + uintptr(i)*8)).Fp
  79312 	} else {
  79313 		*(*int32)(unsafe.Pointer(pIx))++
  79314 		*(*uintptr)(unsafe.Pointer(pIter + 8)) = (*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIter + 8)))).FpNext
  79315 		return *(*uintptr)(unsafe.Pointer(pIter + 8))
  79316 	}
  79317 	return uintptr(0)
  79318 }
  79319 
  79320 // Generate code to do constraint checks prior to an INSERT or an UPDATE
  79321 // on table pTab.
  79322 //
  79323 // The regNewData parameter is the first register in a range that contains
  79324 // the data to be inserted or the data after the update.  There will be
  79325 // pTab->nCol+1 registers in this range.  The first register (the one
  79326 // that regNewData points to) will contain the new rowid, or NULL in the
  79327 // case of a WITHOUT ROWID table.  The second register in the range will
  79328 // contain the content of the first table column.  The third register will
  79329 // contain the content of the second table column.  And so forth.
  79330 //
  79331 // The regOldData parameter is similar to regNewData except that it contains
  79332 // the data prior to an UPDATE rather than afterwards.  regOldData is zero
  79333 // for an INSERT.  This routine can distinguish between UPDATE and INSERT by
  79334 // checking regOldData for zero.
  79335 //
  79336 // For an UPDATE, the pkChng boolean is true if the true primary key (the
  79337 // rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)
  79338 // might be modified by the UPDATE.  If pkChng is false, then the key of
  79339 // the iDataCur content table is guaranteed to be unchanged by the UPDATE.
  79340 //
  79341 // For an INSERT, the pkChng boolean indicates whether or not the rowid
  79342 // was explicitly specified as part of the INSERT statement.  If pkChng
  79343 // is zero, it means that the either rowid is computed automatically or
  79344 // that the table is a WITHOUT ROWID table and has no rowid.  On an INSERT,
  79345 // pkChng will only be true if the INSERT statement provides an integer
  79346 // value for either the rowid column or its INTEGER PRIMARY KEY alias.
  79347 //
  79348 // The code generated by this routine will store new index entries into
  79349 // registers identified by aRegIdx[].  No index entry is created for
  79350 // indices where aRegIdx[i]==0.  The order of indices in aRegIdx[] is
  79351 // the same as the order of indices on the linked list of indices
  79352 // at pTab->pIndex.
  79353 //
  79354 // (2019-05-07) The generated code also creates a new record for the
  79355 // main table, if pTab is a rowid table, and stores that record in the
  79356 // register identified by aRegIdx[nIdx] - in other words in the first
  79357 // entry of aRegIdx[] past the last index.  It is important that the
  79358 // record be generated during constraint checks to avoid affinity changes
  79359 // to the register content that occur after constraint checks but before
  79360 // the new record is inserted.
  79361 //
  79362 // The caller must have already opened writeable cursors on the main
  79363 // table and all applicable indices (that is to say, all indices for which
  79364 // aRegIdx[] is not zero).  iDataCur is the cursor for the main table when
  79365 // inserting or updating a rowid table, or the cursor for the PRIMARY KEY
  79366 // index when operating on a WITHOUT ROWID table.  iIdxCur is the cursor
  79367 // for the first index in the pTab->pIndex list.  Cursors for other indices
  79368 // are at iIdxCur+N for the N-th element of the pTab->pIndex list.
  79369 //
  79370 // This routine also generates code to check constraints.  NOT NULL,
  79371 // CHECK, and UNIQUE constraints are all checked.  If a constraint fails,
  79372 // then the appropriate action is performed.  There are five possible
  79373 // actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE.
  79374 //
  79375 //	Constraint type  Action       What Happens
  79376 //	---------------  ----------   ----------------------------------------
  79377 //	any              ROLLBACK     The current transaction is rolled back and
  79378 //	                              sqlite3_step() returns immediately with a
  79379 //	                              return code of SQLITE_CONSTRAINT.
  79380 //
  79381 //	any              ABORT        Back out changes from the current command
  79382 //	                              only (do not do a complete rollback) then
  79383 //	                              cause sqlite3_step() to return immediately
  79384 //	                              with SQLITE_CONSTRAINT.
  79385 //
  79386 //	any              FAIL         Sqlite3_step() returns immediately with a
  79387 //	                              return code of SQLITE_CONSTRAINT.  The
  79388 //	                              transaction is not rolled back and any
  79389 //	                              changes to prior rows are retained.
  79390 //
  79391 //	any              IGNORE       The attempt in insert or update the current
  79392 //	                              row is skipped, without throwing an error.
  79393 //	                              Processing continues with the next row.
  79394 //	                              (There is an immediate jump to ignoreDest.)
  79395 //
  79396 //	NOT NULL         REPLACE      The NULL value is replace by the default
  79397 //	                              value for that column.  If the default value
  79398 //	                              is NULL, the action is the same as ABORT.
  79399 //
  79400 //	UNIQUE           REPLACE      The other row that conflicts with the row
  79401 //	                              being inserted is removed.
  79402 //
  79403 //	CHECK            REPLACE      Illegal.  The results in an exception.
  79404 //
  79405 // Which action to take is determined by the overrideError parameter.
  79406 // Or if overrideError==OE_Default, then the pParse->onError parameter
  79407 // is used.  Or if pParse->onError==OE_Default then the onError value
  79408 // for the constraint is used.
  79409 func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintptr, aRegIdx uintptr, iDataCur int32, iIdxCur int32, regNewData int32, regOldData int32, pkChng U8, overrideError U8, ignoreDest int32, pbMayReplace uintptr, aiChng uintptr, pUpsert uintptr) {
  79410 	bp := tls.Alloc(56)
  79411 	defer tls.Free(56)
  79412 
  79413 	var v uintptr
  79414 	var pIdx uintptr
  79415 	var pPk uintptr = uintptr(0)
  79416 	var db uintptr
  79417 	var i int32
  79418 
  79419 	var nCol int32
  79420 	var onError int32
  79421 	var seenReplace int32 = 0
  79422 	var nPkField int32
  79423 	var pUpsertClause uintptr = uintptr(0)
  79424 	var isUpdate U8
  79425 	var bAffinityDone U8 = U8(0)
  79426 	var upsertIpkReturn int32 = 0
  79427 	var upsertIpkDelay int32 = 0
  79428 	var ipkTop int32 = 0
  79429 	var ipkBottom int32 = 0
  79430 
  79431 	var regTrigCnt int32
  79432 	var addrRecheck int32 = 0
  79433 	var lblRecheckOk int32 = 0
  79434 	var pTrigger uintptr
  79435 	var nReplaceTrig int32 = 0
  79436 
  79437 	isUpdate = U8(libc.Bool32(regOldData != 0))
  79438 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  79439 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  79440 
  79441 	nCol = int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  79442 
  79443 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  79444 		pPk = uintptr(0)
  79445 		nPkField = 1
  79446 	} else {
  79447 		pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  79448 		nPkField = int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  79449 	}
  79450 
  79451 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasNotNull) != 0 {
  79452 		var b2ndPass int32 = 0
  79453 		var nSeenReplace int32 = 0
  79454 		var nGenerated int32 = 0
  79455 		for 1 != 0 {
  79456 			for i = 0; i < nCol; i++ {
  79457 				var iReg int32
  79458 				var pCol uintptr = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16
  79459 				var isGenerated int32
  79460 				onError = int32(*(*uint8)(unsafe.Pointer(pCol + 4)) & 0xf >> 0)
  79461 				if onError == OE_None {
  79462 					continue
  79463 				}
  79464 				if i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  79465 					continue
  79466 				}
  79467 				isGenerated = int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED
  79468 				if isGenerated != 0 && !(b2ndPass != 0) {
  79469 					nGenerated++
  79470 					continue
  79471 				}
  79472 				if aiChng != 0 && *(*int32)(unsafe.Pointer(aiChng + uintptr(i)*4)) < 0 && !(isGenerated != 0) {
  79473 					continue
  79474 				}
  79475 				if int32(overrideError) != OE_Default {
  79476 					onError = int32(overrideError)
  79477 				} else if onError == OE_Default {
  79478 					onError = OE_Abort
  79479 				}
  79480 				if onError == OE_Replace {
  79481 					if b2ndPass != 0 ||
  79482 						int32((*Column)(unsafe.Pointer(pCol)).FiDflt) == 0 {
  79483 						onError = OE_Abort
  79484 					} else {
  79485 					}
  79486 				} else if b2ndPass != 0 && !(isGenerated != 0) {
  79487 					continue
  79488 				}
  79489 
  79490 				iReg = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + regNewData + 1
  79491 				{
  79492 					switch onError {
  79493 					case OE_Replace:
  79494 						{
  79495 							var addr1 int32 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, iReg)
  79496 
  79497 							nSeenReplace++
  79498 							Xsqlite3ExprCodeCopy(tls, pParse,
  79499 								Xsqlite3ColumnExpr(tls, pTab, pCol), iReg)
  79500 							Xsqlite3VdbeJumpHere(tls, v, addr1)
  79501 							break
  79502 
  79503 						}
  79504 						fallthrough
  79505 					case OE_Abort:
  79506 						Xsqlite3MayAbort(tls, pParse)
  79507 						fallthrough
  79508 					case OE_Rollback:
  79509 						fallthrough
  79510 					case OE_Fail:
  79511 						{
  79512 							var zMsg uintptr = Xsqlite3MPrintf(tls, db, ts+12061, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName,
  79513 								(*Column)(unsafe.Pointer(pCol)).FzCnName))
  79514 
  79515 							Xsqlite3VdbeAddOp3(tls, v, OP_HaltIfNull, SQLITE_CONSTRAINT|int32(5)<<8,
  79516 								onError, iReg)
  79517 							Xsqlite3VdbeAppendP4(tls, v, zMsg, -6)
  79518 							Xsqlite3VdbeChangeP5(tls, v, uint16(P5_ConstraintNotNull))
  79519 
  79520 							break
  79521 
  79522 						}
  79523 						fallthrough
  79524 					default:
  79525 						{
  79526 							Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, ignoreDest)
  79527 
  79528 							break
  79529 
  79530 						}
  79531 					}
  79532 				}
  79533 			}
  79534 			if nGenerated == 0 && nSeenReplace == 0 {
  79535 				break
  79536 			}
  79537 			if b2ndPass != 0 {
  79538 				break
  79539 			}
  79540 			b2ndPass = 1
  79541 			if nSeenReplace > 0 && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != U32(0) {
  79542 				Xsqlite3ComputeGeneratedColumns(tls, pParse, regNewData+1, pTab)
  79543 			}
  79544 		}
  79545 	}
  79546 
  79547 	if (*Table)(unsafe.Pointer(pTab)).FpCheck != 0 && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) {
  79548 		var pCheck uintptr = (*Table)(unsafe.Pointer(pTab)).FpCheck
  79549 		(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1)
  79550 		if int32(overrideError) != OE_Default {
  79551 			onError = int32(overrideError)
  79552 		} else {
  79553 			onError = OE_Abort
  79554 		}
  79555 		for i = 0; i < (*ExprList)(unsafe.Pointer(pCheck)).FnExpr; i++ {
  79556 			var allOk int32
  79557 			var pCopy uintptr
  79558 			var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(i)*20)).FpExpr
  79559 			if aiChng != 0 &&
  79560 				!(Xsqlite3ExprReferencesUpdatedColumn(tls, pExpr, aiChng, int32(pkChng)) != 0) {
  79561 				continue
  79562 			}
  79563 			if int32(bAffinityDone) == 0 {
  79564 				Xsqlite3TableAffinity(tls, v, pTab, regNewData+1)
  79565 				bAffinityDone = U8(1)
  79566 			}
  79567 			allOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  79568 
  79569 			pCopy = Xsqlite3ExprDup(tls, db, pExpr, 0)
  79570 			if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  79571 				Xsqlite3ExprIfTrue(tls, pParse, pCopy, allOk, SQLITE_JUMPIFNULL)
  79572 			}
  79573 			Xsqlite3ExprDelete(tls, db, pCopy)
  79574 			if onError == OE_Ignore {
  79575 				Xsqlite3VdbeGoto(tls, v, ignoreDest)
  79576 			} else {
  79577 				var zName uintptr = (*ExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(i)*20)).FzEName
  79578 
  79579 				if onError == OE_Replace {
  79580 					onError = OE_Abort
  79581 				}
  79582 				Xsqlite3HaltConstraint(tls, pParse, SQLITE_CONSTRAINT|int32(1)<<8,
  79583 					onError, zName, int8(P4_TRANSIENT),
  79584 					uint8(P5_ConstraintCheck))
  79585 			}
  79586 			Xsqlite3VdbeResolveLabel(tls, v, allOk)
  79587 		}
  79588 		(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  79589 	}
  79590 
  79591 	(*IndexIterator)(unsafe.Pointer(bp + 16)).FeType = 0
  79592 	(*IndexIterator)(unsafe.Pointer(bp + 16)).Fi = 0
  79593 	*(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) = uintptr(0)
  79594 	*(*uintptr)(unsafe.Pointer(bp + 16 + 8)) = (*Table)(unsafe.Pointer(pTab)).FpIndex
  79595 	if pUpsert != 0 {
  79596 		if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget == uintptr(0) {
  79597 			if int32((*Upsert)(unsafe.Pointer(pUpsert)).FisDoUpdate) == 0 {
  79598 				overrideError = U8(OE_Ignore)
  79599 				pUpsert = uintptr(0)
  79600 			} else {
  79601 				overrideError = U8(OE_Update)
  79602 			}
  79603 		} else if (*Table)(unsafe.Pointer(pTab)).FpIndex != uintptr(0) {
  79604 			var nIdx int32
  79605 			var jj int32
  79606 			var nByte U64
  79607 			var pTerm uintptr
  79608 			var bUsed uintptr
  79609 			nIdx = 0
  79610 			pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  79611 		__1:
  79612 			if !(pIdx != 0) {
  79613 				goto __3
  79614 			}
  79615 			{
  79616 			}
  79617 			goto __2
  79618 		__2:
  79619 			pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  79620 			nIdx++
  79621 			goto __1
  79622 			goto __3
  79623 		__3:
  79624 			;
  79625 			(*IndexIterator)(unsafe.Pointer(bp + 16)).FeType = 1
  79626 			*(*int32)(unsafe.Pointer(bp + 16 + 8)) = nIdx
  79627 			nByte = U64((uint32(unsafe.Sizeof(IndexListTerm{}))+uint32(1))*uint32(nIdx) + uint32(nIdx))
  79628 			*(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) = Xsqlite3DbMallocZero(tls, db, nByte)
  79629 			if *(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) == uintptr(0) {
  79630 				return
  79631 			}
  79632 			bUsed = *(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) + uintptr(nIdx)*8
  79633 			(*Upsert)(unsafe.Pointer(pUpsert)).FpToFree = *(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4))
  79634 			i = 0
  79635 			pTerm = pUpsert
  79636 			for ; pTerm != 0; pTerm = (*Upsert)(unsafe.Pointer(pTerm)).FpNextUpsert {
  79637 				if (*Upsert)(unsafe.Pointer(pTerm)).FpUpsertTarget == uintptr(0) {
  79638 					break
  79639 				}
  79640 				if (*Upsert)(unsafe.Pointer(pTerm)).FpUpsertIdx == uintptr(0) {
  79641 					continue
  79642 				}
  79643 				jj = 0
  79644 				pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  79645 				for pIdx != uintptr(0) && pIdx != (*Upsert)(unsafe.Pointer(pTerm)).FpUpsertIdx {
  79646 					pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  79647 					jj++
  79648 				}
  79649 				if *(*U8)(unsafe.Pointer(bUsed + uintptr(jj))) != 0 {
  79650 					continue
  79651 				}
  79652 				*(*U8)(unsafe.Pointer(bUsed + uintptr(jj))) = U8(1)
  79653 				(*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) + uintptr(i)*8)).Fp = pIdx
  79654 				(*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) + uintptr(i)*8)).Fix = jj
  79655 				i++
  79656 			}
  79657 			jj = 0
  79658 			pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  79659 		__4:
  79660 			if !(pIdx != 0) {
  79661 				goto __6
  79662 			}
  79663 			{
  79664 				if *(*U8)(unsafe.Pointer(bUsed + uintptr(jj))) != 0 {
  79665 					goto __5
  79666 				}
  79667 				(*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) + uintptr(i)*8)).Fp = pIdx
  79668 				(*IndexListTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 + 8 + 4)) + uintptr(i)*8)).Fix = jj
  79669 				i++
  79670 
  79671 			}
  79672 			goto __5
  79673 		__5:
  79674 			pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  79675 			jj++
  79676 			goto __4
  79677 			goto __6
  79678 		__6:
  79679 		}
  79680 	}
  79681 
  79682 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_RecTriggers|SQLITE_ForeignKeys) == uint64(0) {
  79683 		pTrigger = uintptr(0)
  79684 		regTrigCnt = 0
  79685 	} else {
  79686 		if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_RecTriggers) != 0 {
  79687 			pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_DELETE, uintptr(0), uintptr(0))
  79688 			regTrigCnt = libc.Bool32(pTrigger != uintptr(0) || Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0)
  79689 		} else {
  79690 			pTrigger = uintptr(0)
  79691 			regTrigCnt = Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0)
  79692 		}
  79693 		if regTrigCnt != 0 {
  79694 			regTrigCnt = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  79695 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regTrigCnt)
  79696 
  79697 			lblRecheckOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  79698 			addrRecheck = lblRecheckOk
  79699 		}
  79700 	}
  79701 
  79702 	if pkChng != 0 && pPk == uintptr(0) {
  79703 		var addrRowidOk int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
  79704 
  79705 		onError = int32((*Table)(unsafe.Pointer(pTab)).FkeyConf)
  79706 		if int32(overrideError) != OE_Default {
  79707 			onError = int32(overrideError)
  79708 		} else if onError == OE_Default {
  79709 			onError = OE_Abort
  79710 		}
  79711 
  79712 		if pUpsert != 0 {
  79713 			pUpsertClause = Xsqlite3UpsertOfIndex(tls, pUpsert, uintptr(0))
  79714 			if pUpsertClause != uintptr(0) {
  79715 				if int32((*Upsert)(unsafe.Pointer(pUpsertClause)).FisDoUpdate) == 0 {
  79716 					onError = OE_Ignore
  79717 				} else {
  79718 					onError = OE_Update
  79719 				}
  79720 			}
  79721 			if pUpsertClause != pUpsert {
  79722 				upsertIpkDelay = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  79723 			}
  79724 		}
  79725 
  79726 		if onError == OE_Replace &&
  79727 			onError != int32(overrideError) &&
  79728 			(*Table)(unsafe.Pointer(pTab)).FpIndex != 0 &&
  79729 			!(upsertIpkDelay != 0) {
  79730 			ipkTop = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) + 1
  79731 
  79732 		}
  79733 
  79734 		if isUpdate != 0 {
  79735 			Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regNewData, addrRowidOk, regOldData)
  79736 			Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL))
  79737 
  79738 		}
  79739 
  79740 		Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, addrRowidOk, regNewData)
  79741 
  79742 		switch onError {
  79743 		default:
  79744 			{
  79745 				onError = OE_Abort
  79746 
  79747 			}
  79748 			fallthrough
  79749 		case OE_Rollback:
  79750 			fallthrough
  79751 		case OE_Abort:
  79752 			fallthrough
  79753 		case OE_Fail:
  79754 			{
  79755 				Xsqlite3RowidConstraint(tls, pParse, onError, pTab)
  79756 				break
  79757 
  79758 			}
  79759 			fallthrough
  79760 		case OE_Replace:
  79761 			{
  79762 				if regTrigCnt != 0 {
  79763 					Xsqlite3MultiWrite(tls, pParse)
  79764 					Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur,
  79765 						regNewData, int16(1), uint8(0), uint8(OE_Replace), uint8(1), -1)
  79766 					Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regTrigCnt, 1)
  79767 					nReplaceTrig++
  79768 				} else {
  79769 					Xsqlite3VdbeAddOp2(tls, v, OP_Delete, iDataCur, OPFLAG_ISNOOP)
  79770 					Xsqlite3VdbeAppendP4(tls, v, pTab, -5)
  79771 					if (*Table)(unsafe.Pointer(pTab)).FpIndex != 0 {
  79772 						Xsqlite3MultiWrite(tls, pParse)
  79773 						Xsqlite3GenerateRowIndexDelete(tls, pParse, pTab, iDataCur, iIdxCur, uintptr(0), -1)
  79774 					}
  79775 				}
  79776 				seenReplace = 1
  79777 				break
  79778 
  79779 			}
  79780 			fallthrough
  79781 		case OE_Update:
  79782 			{
  79783 				Xsqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, uintptr(0), iDataCur)
  79784 
  79785 			}
  79786 			fallthrough
  79787 		case OE_Ignore:
  79788 			{
  79789 				Xsqlite3VdbeGoto(tls, v, ignoreDest)
  79790 				break
  79791 
  79792 			}
  79793 		}
  79794 		Xsqlite3VdbeResolveLabel(tls, v, addrRowidOk)
  79795 		if pUpsert != 0 && pUpsertClause != pUpsert {
  79796 			upsertIpkReturn = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  79797 		} else if ipkTop != 0 {
  79798 			ipkBottom = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  79799 			Xsqlite3VdbeJumpHere(tls, v, ipkTop-1)
  79800 		}
  79801 	}
  79802 
  79803 	for pIdx = indexIteratorFirst(tls, bp+16, bp+32); pIdx != 0; pIdx = indexIteratorNext(tls, bp+16, bp+32) {
  79804 		var regIdx int32
  79805 		var regR int32
  79806 		var iThisCur int32
  79807 		var addrUniqueOk int32
  79808 		var addrConflictCk int32
  79809 
  79810 		if *(*int32)(unsafe.Pointer(aRegIdx + uintptr(*(*int32)(unsafe.Pointer(bp + 32)))*4)) == 0 {
  79811 			continue
  79812 		}
  79813 		if pUpsert != 0 {
  79814 			pUpsertClause = Xsqlite3UpsertOfIndex(tls, pUpsert, pIdx)
  79815 			if upsertIpkDelay != 0 && pUpsertClause == pUpsert {
  79816 				Xsqlite3VdbeJumpHere(tls, v, upsertIpkDelay)
  79817 			}
  79818 		}
  79819 		addrUniqueOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  79820 		if int32(bAffinityDone) == 0 {
  79821 			Xsqlite3TableAffinity(tls, v, pTab, regNewData+1)
  79822 			bAffinityDone = U8(1)
  79823 		}
  79824 
  79825 		iThisCur = iIdxCur + *(*int32)(unsafe.Pointer(bp + 32))
  79826 
  79827 		if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 {
  79828 			Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(*(*int32)(unsafe.Pointer(bp + 32)))*4)))
  79829 			(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1)
  79830 			Xsqlite3ExprIfFalseDup(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, addrUniqueOk,
  79831 				SQLITE_JUMPIFNULL)
  79832 			(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  79833 		}
  79834 
  79835 		regIdx = *(*int32)(unsafe.Pointer(aRegIdx + uintptr(*(*int32)(unsafe.Pointer(bp + 32)))*4)) + 1
  79836 		for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); i++ {
  79837 			var iField int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)))
  79838 			var x int32
  79839 			if iField == -2 {
  79840 				(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1)
  79841 				Xsqlite3ExprCodeCopy(tls, pParse, (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8+uintptr(i)*20)).FpExpr, regIdx+i)
  79842 				(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  79843 
  79844 			} else if iField == -1 || iField == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) {
  79845 				x = regNewData
  79846 				Xsqlite3VdbeAddOp2(tls, v, OP_IntCopy, x, regIdx+i)
  79847 
  79848 			} else {
  79849 				x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iField))) + regNewData + 1
  79850 				Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, x, regIdx+i)
  79851 
  79852 			}
  79853 		}
  79854 		Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnColumn), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(*(*int32)(unsafe.Pointer(bp + 32)))*4)))
  79855 
  79856 		if isUpdate != 0 && pPk == pIdx && int32(pkChng) == 0 {
  79857 			Xsqlite3VdbeResolveLabel(tls, v, addrUniqueOk)
  79858 			continue
  79859 		}
  79860 
  79861 		onError = int32((*Index)(unsafe.Pointer(pIdx)).FonError)
  79862 		if onError == OE_None {
  79863 			Xsqlite3VdbeResolveLabel(tls, v, addrUniqueOk)
  79864 			continue
  79865 		}
  79866 		if int32(overrideError) != OE_Default {
  79867 			onError = int32(overrideError)
  79868 		} else if onError == OE_Default {
  79869 			onError = OE_Abort
  79870 		}
  79871 
  79872 		if pUpsertClause != 0 {
  79873 			if int32((*Upsert)(unsafe.Pointer(pUpsertClause)).FisDoUpdate) == 0 {
  79874 				onError = OE_Ignore
  79875 			} else {
  79876 				onError = OE_Update
  79877 			}
  79878 		}
  79879 
  79880 		addrConflictCk = Xsqlite3VdbeAddOp4Int(tls, v, OP_NoConflict, iThisCur, addrUniqueOk,
  79881 			regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol))
  79882 
  79883 		if pIdx == pPk {
  79884 			regR = regIdx
  79885 		} else {
  79886 			regR = Xsqlite3GetTempRange(tls, pParse, nPkField)
  79887 		}
  79888 		if isUpdate != 0 || onError == OE_Replace {
  79889 			if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  79890 				Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iThisCur, regR)
  79891 
  79892 				if isUpdate != 0 {
  79893 					Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regR, addrUniqueOk, regOldData)
  79894 					Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL))
  79895 
  79896 				}
  79897 			} else {
  79898 				var x int32
  79899 
  79900 				if pIdx != pPk {
  79901 					for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ {
  79902 						x = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))))
  79903 						Xsqlite3VdbeAddOp3(tls, v, OP_Column, iThisCur, x, regR+i)
  79904 
  79905 					}
  79906 				}
  79907 				if isUpdate != 0 {
  79908 					var addrJump int32 = Xsqlite3VdbeCurrentAddr(tls, v) + int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  79909 					var op int32 = OP_Ne
  79910 					var regCmp int32 = func() int32 {
  79911 						if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  79912 							return regIdx
  79913 						}
  79914 						return regR
  79915 					}()
  79916 
  79917 					for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ {
  79918 						var p4 uintptr = Xsqlite3LocateCollSeq(tls, pParse, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(i)*4)))
  79919 						x = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))
  79920 
  79921 						if i == int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)-1 {
  79922 							addrJump = addrUniqueOk
  79923 							op = OP_Eq
  79924 						}
  79925 						x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(x)))
  79926 						Xsqlite3VdbeAddOp4(tls, v, op,
  79927 							regOldData+1+x, addrJump, regCmp+i, p4, -2)
  79928 						Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL))
  79929 
  79930 					}
  79931 				}
  79932 			}
  79933 		}
  79934 
  79935 		switch onError {
  79936 		case OE_Rollback:
  79937 			fallthrough
  79938 		case OE_Abort:
  79939 			fallthrough
  79940 		case OE_Fail:
  79941 			{
  79942 				Xsqlite3UniqueConstraint(tls, pParse, onError, pIdx)
  79943 				break
  79944 
  79945 			}
  79946 		case OE_Update:
  79947 			{
  79948 				Xsqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, pIdx, iIdxCur+*(*int32)(unsafe.Pointer(bp + 32)))
  79949 
  79950 			}
  79951 			fallthrough
  79952 		case OE_Ignore:
  79953 			{
  79954 				Xsqlite3VdbeGoto(tls, v, ignoreDest)
  79955 				break
  79956 
  79957 			}
  79958 		default:
  79959 			{
  79960 				var nConflictCk int32
  79961 
  79962 				nConflictCk = Xsqlite3VdbeCurrentAddr(tls, v) - addrConflictCk
  79963 
  79964 				if regTrigCnt != 0 {
  79965 					Xsqlite3MultiWrite(tls, pParse)
  79966 					nReplaceTrig++
  79967 				}
  79968 				if pTrigger != 0 && isUpdate != 0 {
  79969 					Xsqlite3VdbeAddOp1(tls, v, OP_CursorLock, iDataCur)
  79970 				}
  79971 				Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur,
  79972 					regR, int16(nPkField), uint8(0), uint8(OE_Replace),
  79973 					func() uint8 {
  79974 						if pIdx == pPk {
  79975 							return uint8(ONEPASS_SINGLE)
  79976 						}
  79977 						return uint8(ONEPASS_OFF)
  79978 					}(), iThisCur)
  79979 				if pTrigger != 0 && isUpdate != 0 {
  79980 					Xsqlite3VdbeAddOp1(tls, v, OP_CursorUnlock, iDataCur)
  79981 				}
  79982 				if regTrigCnt != 0 {
  79983 					var addrBypass int32
  79984 
  79985 					Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regTrigCnt, 1)
  79986 					addrBypass = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  79987 
  79988 					Xsqlite3VdbeResolveLabel(tls, v, lblRecheckOk)
  79989 					lblRecheckOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  79990 					if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 {
  79991 						Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regIdx-1, lblRecheckOk)
  79992 
  79993 					}
  79994 
  79995 					for nConflictCk > 0 {
  79996 						*(*VdbeOp)(unsafe.Pointer(bp + 36)) = *(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, addrConflictCk)))
  79997 						if int32((*VdbeOp)(unsafe.Pointer(bp+36)).Fopcode) != OP_IdxRowid {
  79998 							var p2 int32
  79999 							var zP4 uintptr
  80000 							if int32(Xsqlite3OpcodeProperty[(*VdbeOp)(unsafe.Pointer(bp+36)).Fopcode])&OPFLG_JUMP != 0 {
  80001 								p2 = lblRecheckOk
  80002 							} else {
  80003 								p2 = (*VdbeOp)(unsafe.Pointer(bp + 36)).Fp2
  80004 							}
  80005 							if int32((*VdbeOp)(unsafe.Pointer(bp+36)).Fp4type) == -3 {
  80006 								zP4 = uintptr(*(*int32)(unsafe.Pointer(bp + 36 + 16)))
  80007 							} else {
  80008 								zP4 = *(*uintptr)(unsafe.Pointer(bp + 36 + 16))
  80009 							}
  80010 							Xsqlite3VdbeAddOp4(tls, v, int32((*VdbeOp)(unsafe.Pointer(bp+36)).Fopcode), (*VdbeOp)(unsafe.Pointer(bp+36)).Fp1, p2, (*VdbeOp)(unsafe.Pointer(bp+36)).Fp3, zP4, int32((*VdbeOp)(unsafe.Pointer(bp+36)).Fp4type))
  80011 							Xsqlite3VdbeChangeP5(tls, v, (*VdbeOp)(unsafe.Pointer(bp+36)).Fp5)
  80012 
  80013 						}
  80014 						nConflictCk--
  80015 						addrConflictCk++
  80016 					}
  80017 
  80018 					Xsqlite3UniqueConstraint(tls, pParse, OE_Abort, pIdx)
  80019 
  80020 					Xsqlite3VdbeJumpHere(tls, v, addrBypass)
  80021 				}
  80022 				seenReplace = 1
  80023 				break
  80024 
  80025 			}
  80026 		}
  80027 		Xsqlite3VdbeResolveLabel(tls, v, addrUniqueOk)
  80028 		if regR != regIdx {
  80029 			Xsqlite3ReleaseTempRange(tls, pParse, regR, nPkField)
  80030 		}
  80031 		if pUpsertClause != 0 &&
  80032 			upsertIpkReturn != 0 &&
  80033 			Xsqlite3UpsertNextIsIPK(tls, pUpsertClause) != 0 {
  80034 			Xsqlite3VdbeGoto(tls, v, upsertIpkDelay+1)
  80035 			Xsqlite3VdbeJumpHere(tls, v, upsertIpkReturn)
  80036 			upsertIpkReturn = 0
  80037 		}
  80038 	}
  80039 
  80040 	if ipkTop != 0 {
  80041 		Xsqlite3VdbeGoto(tls, v, ipkTop)
  80042 
  80043 		Xsqlite3VdbeJumpHere(tls, v, ipkBottom)
  80044 	}
  80045 
  80046 	if nReplaceTrig != 0 {
  80047 		Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, regTrigCnt, lblRecheckOk)
  80048 
  80049 		if !(pPk != 0) {
  80050 			if isUpdate != 0 {
  80051 				Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regNewData, addrRecheck, regOldData)
  80052 				Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL))
  80053 
  80054 			}
  80055 			Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, addrRecheck, regNewData)
  80056 
  80057 			Xsqlite3RowidConstraint(tls, pParse, OE_Abort, pTab)
  80058 		} else {
  80059 			Xsqlite3VdbeGoto(tls, v, addrRecheck)
  80060 		}
  80061 		Xsqlite3VdbeResolveLabel(tls, v, lblRecheckOk)
  80062 	}
  80063 
  80064 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  80065 		var regRec int32 = *(*int32)(unsafe.Pointer(aRegIdx + uintptr(*(*int32)(unsafe.Pointer(bp + 32)))*4))
  80066 		Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regNewData+1, int32((*Table)(unsafe.Pointer(pTab)).FnNVCol), regRec)
  80067 
  80068 		if !(bAffinityDone != 0) {
  80069 			Xsqlite3TableAffinity(tls, v, pTab, 0)
  80070 		}
  80071 	}
  80072 
  80073 	*(*int32)(unsafe.Pointer(pbMayReplace)) = seenReplace
  80074 
  80075 }
  80076 
  80077 func codeWithoutRowidPreupdate(tls *libc.TLS, pParse uintptr, pTab uintptr, iCur int32, regData int32) {
  80078 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  80079 	var r int32 = Xsqlite3GetTempReg(tls, pParse)
  80080 
  80081 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, r)
  80082 	Xsqlite3VdbeAddOp4(tls, v, OP_Insert, iCur, regData, r, pTab, -5)
  80083 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_ISNOOP))
  80084 	Xsqlite3ReleaseTempReg(tls, pParse, r)
  80085 }
  80086 
  80087 // This routine generates code to finish the INSERT or UPDATE operation
  80088 // that was started by a prior call to sqlite3GenerateConstraintChecks.
  80089 // A consecutive range of registers starting at regNewData contains the
  80090 // rowid and the content to be inserted.
  80091 //
  80092 // The arguments to this routine should be the same as the first six
  80093 // arguments to sqlite3GenerateConstraintChecks.
  80094 func Xsqlite3CompleteInsertion(tls *libc.TLS, pParse uintptr, pTab uintptr, iDataCur int32, iIdxCur int32, regNewData int32, aRegIdx uintptr, update_flags int32, appendBias int32, useSeekResult int32) {
  80095 	var v uintptr
  80096 	var pIdx uintptr
  80097 	var pik_flags U8
  80098 	var i int32
  80099 
  80100 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  80101 
  80102 	i = 0
  80103 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  80104 __1:
  80105 	if !(pIdx != 0) {
  80106 		goto __3
  80107 	}
  80108 	{
  80109 		if *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)) == 0 {
  80110 			goto __2
  80111 		}
  80112 		if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 {
  80113 			Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), Xsqlite3VdbeCurrentAddr(tls, v)+2)
  80114 
  80115 		}
  80116 		pik_flags = func() uint8 {
  80117 			if useSeekResult != 0 {
  80118 				return uint8(OPFLAG_USESEEKRESULT)
  80119 			}
  80120 			return uint8(0)
  80121 		}()
  80122 		if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY && !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  80123 			pik_flags = U8(int32(pik_flags) | OPFLAG_NCHANGE)
  80124 			pik_flags = U8(int32(pik_flags) | update_flags&OPFLAG_SAVEPOSITION)
  80125 			if update_flags == 0 {
  80126 				codeWithoutRowidPreupdate(tls, pParse, pTab, iIdxCur+i, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)))
  80127 			}
  80128 		}
  80129 		Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iIdxCur+i, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)),
  80130 			*(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4))+1,
  80131 			func() int32 {
  80132 				if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x8>>3)) != 0 {
  80133 					return int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  80134 				}
  80135 				return int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  80136 			}())
  80137 		Xsqlite3VdbeChangeP5(tls, v, uint16(pik_flags))
  80138 
  80139 	}
  80140 	goto __2
  80141 __2:
  80142 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  80143 	i++
  80144 	goto __1
  80145 	goto __3
  80146 __3:
  80147 	;
  80148 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  80149 		return
  80150 	}
  80151 	if (*Parse)(unsafe.Pointer(pParse)).Fnested != 0 {
  80152 		pik_flags = U8(0)
  80153 	} else {
  80154 		pik_flags = U8(OPFLAG_NCHANGE)
  80155 		pik_flags = U8(int32(pik_flags) | func() int32 {
  80156 			if update_flags != 0 {
  80157 				return update_flags
  80158 			}
  80159 			return OPFLAG_LASTROWID
  80160 		}())
  80161 	}
  80162 	if appendBias != 0 {
  80163 		pik_flags = U8(int32(pik_flags) | OPFLAG_APPEND)
  80164 	}
  80165 	if useSeekResult != 0 {
  80166 		pik_flags = U8(int32(pik_flags) | OPFLAG_USESEEKRESULT)
  80167 	}
  80168 	Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iDataCur, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), regNewData)
  80169 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) {
  80170 		Xsqlite3VdbeAppendP4(tls, v, pTab, -5)
  80171 	}
  80172 	Xsqlite3VdbeChangeP5(tls, v, uint16(pik_flags))
  80173 }
  80174 
  80175 // Allocate cursors for the pTab table and all its indices and generate
  80176 // code to open and initialized those cursors.
  80177 //
  80178 // The cursor for the object that contains the complete data (normally
  80179 // the table itself, but the PRIMARY KEY index in the case of a WITHOUT
  80180 // ROWID table) is returned in *piDataCur.  The first index cursor is
  80181 // returned in *piIdxCur.  The number of indices is returned.
  80182 //
  80183 // Use iBase as the first cursor (either the *piDataCur for rowid tables
  80184 // or the first index for WITHOUT ROWID tables) if it is non-negative.
  80185 // If iBase is negative, then allocate the next available cursor.
  80186 //
  80187 // For a rowid table, *piDataCur will be exactly one less than *piIdxCur.
  80188 // For a WITHOUT ROWID table, *piDataCur will be somewhere in the range
  80189 // of *piIdxCurs, depending on where the PRIMARY KEY index appears on the
  80190 // pTab->pIndex list.
  80191 //
  80192 // If pTab is a virtual table, then this routine is a no-op and the
  80193 // *piDataCur and *piIdxCur values are left uninitialized.
  80194 func Xsqlite3OpenTableAndIndices(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, p5 U8, iBase int32, aToOpen uintptr, piDataCur uintptr, piIdxCur uintptr) int32 {
  80195 	var i int32
  80196 	var iDb int32
  80197 	var iDataCur int32
  80198 	var pIdx uintptr
  80199 	var v uintptr
  80200 
  80201 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  80202 		*(*int32)(unsafe.Pointer(piDataCur)) = libc.AssignPtrInt32(piIdxCur, -999)
  80203 		return 0
  80204 	}
  80205 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  80206 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  80207 
  80208 	if iBase < 0 {
  80209 		iBase = (*Parse)(unsafe.Pointer(pParse)).FnTab
  80210 	}
  80211 	iDataCur = libc.PostIncInt32(&iBase, 1)
  80212 	if piDataCur != 0 {
  80213 		*(*int32)(unsafe.Pointer(piDataCur)) = iDataCur
  80214 	}
  80215 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) && (aToOpen == uintptr(0) || *(*U8)(unsafe.Pointer(aToOpen)) != 0) {
  80216 		Xsqlite3OpenTable(tls, pParse, iDataCur, iDb, pTab, op)
  80217 	} else {
  80218 		Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(libc.Bool32(op == OP_OpenWrite)), (*Table)(unsafe.Pointer(pTab)).FzName)
  80219 	}
  80220 	if piIdxCur != 0 {
  80221 		*(*int32)(unsafe.Pointer(piIdxCur)) = iBase
  80222 	}
  80223 	i = 0
  80224 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  80225 __1:
  80226 	if !(pIdx != 0) {
  80227 		goto __3
  80228 	}
  80229 	{
  80230 		var iIdxCur int32 = libc.PostIncInt32(&iBase, 1)
  80231 
  80232 		if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY && !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  80233 			if piDataCur != 0 {
  80234 				*(*int32)(unsafe.Pointer(piDataCur)) = iIdxCur
  80235 			}
  80236 			p5 = U8(0)
  80237 		}
  80238 		if aToOpen == uintptr(0) || *(*U8)(unsafe.Pointer(aToOpen + uintptr(i+1))) != 0 {
  80239 			Xsqlite3VdbeAddOp3(tls, v, op, iIdxCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb)
  80240 			Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx)
  80241 			Xsqlite3VdbeChangeP5(tls, v, uint16(p5))
  80242 
  80243 		}
  80244 
  80245 	}
  80246 	goto __2
  80247 __2:
  80248 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  80249 	i++
  80250 	goto __1
  80251 	goto __3
  80252 __3:
  80253 	;
  80254 	if iBase > (*Parse)(unsafe.Pointer(pParse)).FnTab {
  80255 		(*Parse)(unsafe.Pointer(pParse)).FnTab = iBase
  80256 	}
  80257 	return i
  80258 }
  80259 
  80260 func xferCompatibleIndex(tls *libc.TLS, pDest uintptr, pSrc uintptr) int32 {
  80261 	var i int32
  80262 
  80263 	if int32((*Index)(unsafe.Pointer(pDest)).FnKeyCol) != int32((*Index)(unsafe.Pointer(pSrc)).FnKeyCol) || int32((*Index)(unsafe.Pointer(pDest)).FnColumn) != int32((*Index)(unsafe.Pointer(pSrc)).FnColumn) {
  80264 		return 0
  80265 	}
  80266 	if int32((*Index)(unsafe.Pointer(pDest)).FonError) != int32((*Index)(unsafe.Pointer(pSrc)).FonError) {
  80267 		return 0
  80268 	}
  80269 	for i = 0; i < int32((*Index)(unsafe.Pointer(pSrc)).FnKeyCol); i++ {
  80270 		if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pSrc)).FaiColumn + uintptr(i)*2))) != int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pDest)).FaiColumn + uintptr(i)*2))) {
  80271 			return 0
  80272 		}
  80273 		if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pSrc)).FaiColumn + uintptr(i)*2))) == -2 {
  80274 			if Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pSrc)).FaColExpr+8+uintptr(i)*20)).FpExpr,
  80275 				(*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pDest)).FaColExpr+8+uintptr(i)*20)).FpExpr, -1) != 0 {
  80276 				return 0
  80277 			}
  80278 		}
  80279 		if int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pSrc)).FaSortOrder + uintptr(i)))) != int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pDest)).FaSortOrder + uintptr(i)))) {
  80280 			return 0
  80281 		}
  80282 		if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pSrc)).FazColl + uintptr(i)*4)), *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pDest)).FazColl + uintptr(i)*4))) != 0 {
  80283 			return 0
  80284 		}
  80285 	}
  80286 	if Xsqlite3ExprCompare(tls, uintptr(0), (*Index)(unsafe.Pointer(pSrc)).FpPartIdxWhere, (*Index)(unsafe.Pointer(pDest)).FpPartIdxWhere, -1) != 0 {
  80287 		return 0
  80288 	}
  80289 
  80290 	return 1
  80291 }
  80292 
  80293 func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uintptr, onError int32, iDbDest int32) int32 {
  80294 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  80295 	var pEList uintptr
  80296 	var pSrc uintptr
  80297 	var pSrcIdx uintptr
  80298 	var pDestIdx uintptr
  80299 	var pItem uintptr
  80300 	var i int32
  80301 	var iDbSrc int32
  80302 	var iSrc int32
  80303 	var iDest int32
  80304 	var addr1 int32
  80305 	var addr2 int32
  80306 	var emptyDestTest int32 = 0
  80307 	var emptySrcTest int32 = 0
  80308 	var v uintptr
  80309 	var regAutoinc int32
  80310 	var destHasUniqueIdx int32 = 0
  80311 	var regData int32
  80312 	var regRowid int32
  80313 
  80314 	if (*Parse)(unsafe.Pointer(pParse)).FpWith != 0 || (*Select)(unsafe.Pointer(pSelect)).FpWith != 0 {
  80315 		return 0
  80316 	}
  80317 	if int32((*Table)(unsafe.Pointer(pDest)).FeTabType) == TABTYP_VTAB {
  80318 		return 0
  80319 	}
  80320 	if onError == OE_Default {
  80321 		if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) >= 0 {
  80322 			onError = int32((*Table)(unsafe.Pointer(pDest)).FkeyConf)
  80323 		}
  80324 		if onError == OE_Default {
  80325 			onError = OE_Abort
  80326 		}
  80327 	}
  80328 
  80329 	if (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc != 1 {
  80330 		return 0
  80331 	}
  80332 	if (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpSrc+8)).FpSelect != 0 {
  80333 		return 0
  80334 	}
  80335 	if (*Select)(unsafe.Pointer(pSelect)).FpWhere != 0 {
  80336 		return 0
  80337 	}
  80338 	if (*Select)(unsafe.Pointer(pSelect)).FpOrderBy != 0 {
  80339 		return 0
  80340 	}
  80341 
  80342 	if (*Select)(unsafe.Pointer(pSelect)).FpGroupBy != 0 {
  80343 		return 0
  80344 	}
  80345 	if (*Select)(unsafe.Pointer(pSelect)).FpLimit != 0 {
  80346 		return 0
  80347 	}
  80348 	if (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 {
  80349 		return 0
  80350 	}
  80351 	if (*Select)(unsafe.Pointer(pSelect)).FselFlags&U32(SF_Distinct) != 0 {
  80352 		return 0
  80353 	}
  80354 	pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList
  80355 
  80356 	if (*ExprList)(unsafe.Pointer(pEList)).FnExpr != 1 {
  80357 		return 0
  80358 	}
  80359 
  80360 	if int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pEList+8)).FpExpr)).Fop) != TK_ASTERISK {
  80361 		return 0
  80362 	}
  80363 
  80364 	pItem = (*Select)(unsafe.Pointer(pSelect)).FpSrc + 8
  80365 	pSrc = Xsqlite3LocateTableItem(tls, pParse, uint32(0), pItem)
  80366 	if pSrc == uintptr(0) {
  80367 		return 0
  80368 	}
  80369 	if (*Table)(unsafe.Pointer(pSrc)).Ftnum == (*Table)(unsafe.Pointer(pDest)).Ftnum && (*Table)(unsafe.Pointer(pSrc)).FpSchema == (*Table)(unsafe.Pointer(pDest)).FpSchema {
  80370 		return 0
  80371 	}
  80372 	if libc.Bool32((*Table)(unsafe.Pointer(pDest)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) != libc.Bool32((*Table)(unsafe.Pointer(pSrc)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  80373 		return 0
  80374 	}
  80375 	if !(int32((*Table)(unsafe.Pointer(pSrc)).FeTabType) == TABTYP_NORM) {
  80376 		return 0
  80377 	}
  80378 	if int32((*Table)(unsafe.Pointer(pDest)).FnCol) != int32((*Table)(unsafe.Pointer(pSrc)).FnCol) {
  80379 		return 0
  80380 	}
  80381 	if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) != int32((*Table)(unsafe.Pointer(pSrc)).FiPKey) {
  80382 		return 0
  80383 	}
  80384 	if (*Table)(unsafe.Pointer(pDest)).FtabFlags&U32(TF_Strict) != U32(0) && (*Table)(unsafe.Pointer(pSrc)).FtabFlags&U32(TF_Strict) == U32(0) {
  80385 		return 0
  80386 	}
  80387 	for i = 0; i < int32((*Table)(unsafe.Pointer(pDest)).FnCol); i++ {
  80388 		var pDestCol uintptr = (*Table)(unsafe.Pointer(pDest)).FaCol + uintptr(i)*16
  80389 		var pSrcCol uintptr = (*Table)(unsafe.Pointer(pSrc)).FaCol + uintptr(i)*16
  80390 
  80391 		if int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags)&COLFLAG_GENERATED != int32((*Column)(unsafe.Pointer(pSrcCol)).FcolFlags)&COLFLAG_GENERATED {
  80392 			return 0
  80393 		}
  80394 
  80395 		if int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags)&COLFLAG_GENERATED != 0 {
  80396 			if Xsqlite3ExprCompare(tls, uintptr(0),
  80397 				Xsqlite3ColumnExpr(tls, pSrc, pSrcCol),
  80398 				Xsqlite3ColumnExpr(tls, pDest, pDestCol), -1) != 0 {
  80399 				return 0
  80400 			}
  80401 		}
  80402 		if int32((*Column)(unsafe.Pointer(pDestCol)).Faffinity) != int32((*Column)(unsafe.Pointer(pSrcCol)).Faffinity) {
  80403 			return 0
  80404 		}
  80405 		if Xsqlite3_stricmp(tls, Xsqlite3ColumnColl(tls, pDestCol),
  80406 			Xsqlite3ColumnColl(tls, pSrcCol)) != 0 {
  80407 			return 0
  80408 		}
  80409 		if uint32(int32(*(*uint8)(unsafe.Pointer(pDestCol + 4))&0xf>>0)) != 0 && !(int32(*(*uint8)(unsafe.Pointer(pSrcCol + 4))&0xf>>0) != 0) {
  80410 			return 0
  80411 		}
  80412 
  80413 		if int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags)&COLFLAG_GENERATED == 0 && i > 0 {
  80414 			var pDestExpr uintptr = Xsqlite3ColumnExpr(tls, pDest, pDestCol)
  80415 			var pSrcExpr uintptr = Xsqlite3ColumnExpr(tls, pSrc, pSrcCol)
  80416 
  80417 			if libc.Bool32(pDestExpr == uintptr(0)) != libc.Bool32(pSrcExpr == uintptr(0)) ||
  80418 				pDestExpr != uintptr(0) && libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(pDestExpr + 8)),
  80419 					*(*uintptr)(unsafe.Pointer(pSrcExpr + 8))) != 0 {
  80420 				return 0
  80421 			}
  80422 		}
  80423 	}
  80424 	for pDestIdx = (*Table)(unsafe.Pointer(pDest)).FpIndex; pDestIdx != 0; pDestIdx = (*Index)(unsafe.Pointer(pDestIdx)).FpNext {
  80425 		if int32((*Index)(unsafe.Pointer(pDestIdx)).FonError) != OE_None {
  80426 			destHasUniqueIdx = 1
  80427 		}
  80428 		for pSrcIdx = (*Table)(unsafe.Pointer(pSrc)).FpIndex; pSrcIdx != 0; pSrcIdx = (*Index)(unsafe.Pointer(pSrcIdx)).FpNext {
  80429 			if xferCompatibleIndex(tls, pDestIdx, pSrcIdx) != 0 {
  80430 				break
  80431 			}
  80432 		}
  80433 		if pSrcIdx == uintptr(0) {
  80434 			return 0
  80435 		}
  80436 		if (*Index)(unsafe.Pointer(pSrcIdx)).Ftnum == (*Index)(unsafe.Pointer(pDestIdx)).Ftnum && (*Table)(unsafe.Pointer(pSrc)).FpSchema == (*Table)(unsafe.Pointer(pDest)).FpSchema &&
  80437 			Xsqlite3FaultSim(tls, 411) == SQLITE_OK {
  80438 			return 0
  80439 		}
  80440 	}
  80441 	if (*Table)(unsafe.Pointer(pDest)).FpCheck != 0 && Xsqlite3ExprListCompare(tls, (*Table)(unsafe.Pointer(pSrc)).FpCheck, (*Table)(unsafe.Pointer(pDest)).FpCheck, -1) != 0 {
  80442 		return 0
  80443 	}
  80444 
  80445 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != uint64(0) && *(*uintptr)(unsafe.Pointer(pDest + 44 + 4)) != uintptr(0) {
  80446 		return 0
  80447 	}
  80448 	if (*Sqlite3)(unsafe.Pointer(db)).Fflags&(uint64(0x00001)<<32) != uint64(0) {
  80449 		return 0
  80450 	}
  80451 
  80452 	iDbSrc = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pSrc)).FpSchema)
  80453 	v = Xsqlite3GetVdbe(tls, pParse)
  80454 	Xsqlite3CodeVerifySchema(tls, pParse, iDbSrc)
  80455 	iSrc = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  80456 	iDest = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  80457 	regAutoinc = autoIncBegin(tls, pParse, iDbDest, pDest)
  80458 	regData = Xsqlite3GetTempReg(tls, pParse)
  80459 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regData)
  80460 	regRowid = Xsqlite3GetTempReg(tls, pParse)
  80461 	Xsqlite3OpenTable(tls, pParse, iDest, iDbDest, pDest, OP_OpenWrite)
  80462 
  80463 	if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) == U32(0) && (int32((*Table)(unsafe.Pointer(pDest)).FiPKey) < 0 && (*Table)(unsafe.Pointer(pDest)).FpIndex != uintptr(0) ||
  80464 		destHasUniqueIdx != 0 ||
  80465 		onError != OE_Abort && onError != OE_Rollback) {
  80466 		addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iDest, 0)
  80467 		emptyDestTest = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  80468 		Xsqlite3VdbeJumpHere(tls, v, addr1)
  80469 	}
  80470 	if (*Table)(unsafe.Pointer(pSrc)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  80471 		var insFlags U8
  80472 		Xsqlite3OpenTable(tls, pParse, iSrc, iDbSrc, pSrc, OP_OpenRead)
  80473 		emptySrcTest = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iSrc, 0)
  80474 		if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) >= 0 {
  80475 			addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iSrc, regRowid)
  80476 			if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) == U32(0) {
  80477 				addr2 = Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDest, 0, regRowid)
  80478 
  80479 				Xsqlite3RowidConstraint(tls, pParse, onError, pDest)
  80480 				Xsqlite3VdbeJumpHere(tls, v, addr2)
  80481 			}
  80482 			autoIncStep(tls, pParse, regAutoinc, regRowid)
  80483 		} else if (*Table)(unsafe.Pointer(pDest)).FpIndex == uintptr(0) && !((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_VacuumInto) != 0) {
  80484 			addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iDest, regRowid)
  80485 		} else {
  80486 			addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iSrc, regRowid)
  80487 
  80488 		}
  80489 
  80490 		if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) != 0 {
  80491 			Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iDest)
  80492 			insFlags = U8(OPFLAG_APPEND | OPFLAG_USESEEKRESULT | OPFLAG_PREFORMAT)
  80493 		} else {
  80494 			insFlags = U8(OPFLAG_NCHANGE | OPFLAG_LASTROWID | OPFLAG_APPEND | OPFLAG_PREFORMAT)
  80495 		}
  80496 		if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) == U32(0) {
  80497 			Xsqlite3VdbeAddOp3(tls, v, OP_RowData, iSrc, regData, 1)
  80498 			insFlags = libc.Uint8FromInt32(int32(insFlags) & libc.CplInt32(OPFLAG_PREFORMAT))
  80499 		} else {
  80500 			Xsqlite3VdbeAddOp3(tls, v, OP_RowCell, iDest, iSrc, regRowid)
  80501 		}
  80502 		Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iDest, regData, regRowid)
  80503 		if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) == U32(0) {
  80504 			Xsqlite3VdbeChangeP4(tls, v, -1, pDest, -5)
  80505 		}
  80506 		Xsqlite3VdbeChangeP5(tls, v, uint16(insFlags))
  80507 
  80508 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, iSrc, addr1)
  80509 		Xsqlite3VdbeAddOp2(tls, v, OP_Close, iSrc, 0)
  80510 		Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0)
  80511 	} else {
  80512 		Xsqlite3TableLock(tls, pParse, iDbDest, (*Table)(unsafe.Pointer(pDest)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pDest)).FzName)
  80513 		Xsqlite3TableLock(tls, pParse, iDbSrc, (*Table)(unsafe.Pointer(pSrc)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pSrc)).FzName)
  80514 	}
  80515 	for pDestIdx = (*Table)(unsafe.Pointer(pDest)).FpIndex; pDestIdx != 0; pDestIdx = (*Index)(unsafe.Pointer(pDestIdx)).FpNext {
  80516 		var idxInsFlags U8 = U8(0)
  80517 		for pSrcIdx = (*Table)(unsafe.Pointer(pSrc)).FpIndex; pSrcIdx != 0; pSrcIdx = (*Index)(unsafe.Pointer(pSrcIdx)).FpNext {
  80518 			if xferCompatibleIndex(tls, pDestIdx, pSrcIdx) != 0 {
  80519 				break
  80520 			}
  80521 		}
  80522 
  80523 		Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iSrc, int32((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc)
  80524 		Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pSrcIdx)
  80525 
  80526 		Xsqlite3VdbeAddOp3(tls, v, OP_OpenWrite, iDest, int32((*Index)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest)
  80527 		Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pDestIdx)
  80528 		Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_BULKCSR))
  80529 
  80530 		addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iSrc, 0)
  80531 		if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) != 0 {
  80532 			for i = 0; i < int32((*Index)(unsafe.Pointer(pSrcIdx)).FnColumn); i++ {
  80533 				var zColl uintptr = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pSrcIdx)).FazColl + uintptr(i)*4))
  80534 				if Xsqlite3_stricmp(tls, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), zColl) != 0 {
  80535 					break
  80536 				}
  80537 			}
  80538 			if i == int32((*Index)(unsafe.Pointer(pSrcIdx)).FnColumn) {
  80539 				idxInsFlags = U8(OPFLAG_USESEEKRESULT | OPFLAG_PREFORMAT)
  80540 				Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iDest)
  80541 				Xsqlite3VdbeAddOp2(tls, v, OP_RowCell, iDest, iSrc)
  80542 			}
  80543 		} else if !((*Table)(unsafe.Pointer(pSrc)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) && int32(*(*uint16)(unsafe.Pointer(pDestIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  80544 			idxInsFlags = U8(int32(idxInsFlags) | OPFLAG_NCHANGE)
  80545 		}
  80546 		if int32(idxInsFlags) != OPFLAG_USESEEKRESULT|OPFLAG_PREFORMAT {
  80547 			Xsqlite3VdbeAddOp3(tls, v, OP_RowData, iSrc, regData, 1)
  80548 			if (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_Vacuum) == U32(0) &&
  80549 				!((*Table)(unsafe.Pointer(pDest)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) &&
  80550 				int32(*(*uint16)(unsafe.Pointer(pDestIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  80551 				codeWithoutRowidPreupdate(tls, pParse, pDest, iDest, regData)
  80552 			}
  80553 		}
  80554 		Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iDest, regData)
  80555 		Xsqlite3VdbeChangeP5(tls, v, uint16(int32(idxInsFlags)|OPFLAG_APPEND))
  80556 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, iSrc, addr1+1)
  80557 		Xsqlite3VdbeJumpHere(tls, v, addr1)
  80558 		Xsqlite3VdbeAddOp2(tls, v, OP_Close, iSrc, 0)
  80559 		Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0)
  80560 	}
  80561 	if emptySrcTest != 0 {
  80562 		Xsqlite3VdbeJumpHere(tls, v, emptySrcTest)
  80563 	}
  80564 	Xsqlite3ReleaseTempReg(tls, pParse, regRowid)
  80565 	Xsqlite3ReleaseTempReg(tls, pParse, regData)
  80566 	if emptyDestTest != 0 {
  80567 		Xsqlite3AutoincrementEnd(tls, pParse)
  80568 		Xsqlite3VdbeAddOp2(tls, v, OP_Halt, SQLITE_OK, 0)
  80569 		Xsqlite3VdbeJumpHere(tls, v, emptyDestTest)
  80570 		Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0)
  80571 		return 0
  80572 	} else {
  80573 		return 1
  80574 	}
  80575 	return int32(0)
  80576 }
  80577 
  80578 // Execute SQL code.  Return one of the SQLITE_ success/failure
  80579 // codes.  Also write an error message into memory obtained from
  80580 // malloc() and make *pzErrMsg point to that message.
  80581 //
  80582 // If the SQL is a query, then for each row in the query result
  80583 // the xCallback() function is called.  pArg becomes the first
  80584 // argument to xCallback().  If xCallback=NULL then no callback
  80585 // is invoked, even for queries.
  80586 func Xsqlite3_exec(tls *libc.TLS, db uintptr, zSql uintptr, xCallback Sqlite3_callback, pArg uintptr, pzErrMsg uintptr) int32 {
  80587 	bp := tls.Alloc(8)
  80588 	defer tls.Free(8)
  80589 
  80590 	var rc int32
  80591 
  80592 	var azCols uintptr
  80593 	var callbackIsInit int32
  80594 	var i int32
  80595 	var nCol int32
  80596 	var azVals uintptr
  80597 	rc = SQLITE_OK
  80598 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  80599 	azCols = uintptr(0)
  80600 
  80601 	if !!(Xsqlite3SafetyCheckOk(tls, db) != 0) {
  80602 		goto __1
  80603 	}
  80604 	return Xsqlite3MisuseError(tls, 131931)
  80605 __1:
  80606 	;
  80607 	if !(zSql == uintptr(0)) {
  80608 		goto __2
  80609 	}
  80610 	zSql = ts + 1554
  80611 __2:
  80612 	;
  80613 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  80614 	Xsqlite3Error(tls, db, SQLITE_OK)
  80615 __3:
  80616 	if !(rc == SQLITE_OK && *(*uint8)(unsafe.Pointer(zSql)) != 0) {
  80617 		goto __4
  80618 	}
  80619 	nCol = 0
  80620 	azVals = uintptr(0)
  80621 
  80622 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  80623 	rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp, bp+4)
  80624 
  80625 	if !(rc != SQLITE_OK) {
  80626 		goto __5
  80627 	}
  80628 	goto __3
  80629 __5:
  80630 	;
  80631 	if !!(*(*uintptr)(unsafe.Pointer(bp)) != 0) {
  80632 		goto __6
  80633 	}
  80634 
  80635 	zSql = *(*uintptr)(unsafe.Pointer(bp + 4))
  80636 	goto __3
  80637 __6:
  80638 	;
  80639 	callbackIsInit = 0
  80640 
  80641 __7:
  80642 	if !(1 != 0) {
  80643 		goto __8
  80644 	}
  80645 	rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
  80646 
  80647 	if !(xCallback != 0 && (SQLITE_ROW == rc || SQLITE_DONE == rc && !(callbackIsInit != 0) &&
  80648 		(*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NullCallback) != 0)) {
  80649 		goto __9
  80650 	}
  80651 	if !!(callbackIsInit != 0) {
  80652 		goto __10
  80653 	}
  80654 	nCol = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp)))
  80655 	azCols = Xsqlite3DbMallocRaw(tls, db, uint64(uint32(2*nCol+1)*uint32(unsafe.Sizeof(uintptr(0)))))
  80656 	if !(azCols == uintptr(0)) {
  80657 		goto __11
  80658 	}
  80659 	goto exec_out
  80660 __11:
  80661 	;
  80662 	i = 0
  80663 __12:
  80664 	if !(i < nCol) {
  80665 		goto __14
  80666 	}
  80667 	*(*uintptr)(unsafe.Pointer(azCols + uintptr(i)*4)) = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp)), i)
  80668 
  80669 	goto __13
  80670 __13:
  80671 	i++
  80672 	goto __12
  80673 	goto __14
  80674 __14:
  80675 	;
  80676 	callbackIsInit = 1
  80677 __10:
  80678 	;
  80679 	if !(rc == SQLITE_ROW) {
  80680 		goto __15
  80681 	}
  80682 	azVals = azCols + uintptr(nCol)*4
  80683 	i = 0
  80684 __16:
  80685 	if !(i < nCol) {
  80686 		goto __18
  80687 	}
  80688 	*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*4)) = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp)), i)
  80689 	if !(!(int32(*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*4))) != 0) && Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp)), i) != SQLITE_NULL) {
  80690 		goto __19
  80691 	}
  80692 	Xsqlite3OomFault(tls, db)
  80693 	goto exec_out
  80694 __19:
  80695 	;
  80696 	goto __17
  80697 __17:
  80698 	i++
  80699 	goto __16
  80700 	goto __18
  80701 __18:
  80702 	;
  80703 	*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*4)) = uintptr(0)
  80704 __15:
  80705 	;
  80706 	if !((*struct {
  80707 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
  80708 	})(unsafe.Pointer(&struct{ uintptr }{xCallback})).f(tls, pArg, nCol, azVals, azCols) != 0) {
  80709 		goto __20
  80710 	}
  80711 
  80712 	rc = SQLITE_ABORT
  80713 	Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  80714 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  80715 	Xsqlite3Error(tls, db, SQLITE_ABORT)
  80716 	goto exec_out
  80717 __20:
  80718 	;
  80719 __9:
  80720 	;
  80721 	if !(rc != SQLITE_ROW) {
  80722 		goto __21
  80723 	}
  80724 	rc = Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  80725 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  80726 	zSql = *(*uintptr)(unsafe.Pointer(bp + 4))
  80727 __22:
  80728 	if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zSql))])&0x01 != 0) {
  80729 		goto __23
  80730 	}
  80731 	zSql++
  80732 	goto __22
  80733 __23:
  80734 	;
  80735 	goto __8
  80736 __21:
  80737 	;
  80738 	goto __7
  80739 __8:
  80740 	;
  80741 	Xsqlite3DbFree(tls, db, azCols)
  80742 	azCols = uintptr(0)
  80743 	goto __3
  80744 __4:
  80745 	;
  80746 exec_out:
  80747 	if !(*(*uintptr)(unsafe.Pointer(bp)) != 0) {
  80748 		goto __24
  80749 	}
  80750 	Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  80751 __24:
  80752 	;
  80753 	Xsqlite3DbFree(tls, db, azCols)
  80754 
  80755 	rc = Xsqlite3ApiExit(tls, db, rc)
  80756 	if !(rc != SQLITE_OK && pzErrMsg != 0) {
  80757 		goto __25
  80758 	}
  80759 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3DbStrDup(tls, uintptr(0), Xsqlite3_errmsg(tls, db))
  80760 	if !(*(*uintptr)(unsafe.Pointer(pzErrMsg)) == uintptr(0)) {
  80761 		goto __27
  80762 	}
  80763 	rc = SQLITE_NOMEM
  80764 	Xsqlite3Error(tls, db, SQLITE_NOMEM)
  80765 __27:
  80766 	;
  80767 	goto __26
  80768 __25:
  80769 	if !(pzErrMsg != 0) {
  80770 		goto __28
  80771 	}
  80772 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = uintptr(0)
  80773 __28:
  80774 	;
  80775 __26:
  80776 	;
  80777 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  80778 	return rc
  80779 }
  80780 
  80781 // This is the function signature used for all extension entry points.  It
  80782 // is also defined in the file "loadext.c".
  80783 type Sqlite3_loadext_entry = uintptr
  80784 
  80785 var sqlite3Apis = Sqlite3_api_routines{
  80786 	Faggregate_context:      0,
  80787 	Faggregate_count:        0,
  80788 	Fbind_blob:              0,
  80789 	Fbind_double:            0,
  80790 	Fbind_int:               0,
  80791 	Fbind_int64:             0,
  80792 	Fbind_null:              0,
  80793 	Fbind_parameter_count:   0,
  80794 	Fbind_parameter_index:   0,
  80795 	Fbind_parameter_name:    0,
  80796 	Fbind_text:              0,
  80797 	Fbind_text16:            0,
  80798 	Fbind_value:             0,
  80799 	Fbusy_handler:           0,
  80800 	Fbusy_timeout:           0,
  80801 	Fchanges:                0,
  80802 	Fclose:                  0,
  80803 	Fcollation_needed:       0,
  80804 	Fcollation_needed16:     0,
  80805 	Fcolumn_blob:            0,
  80806 	Fcolumn_bytes:           0,
  80807 	Fcolumn_bytes16:         0,
  80808 	Fcolumn_count:           0,
  80809 	Fcolumn_database_name:   0,
  80810 	Fcolumn_database_name16: 0,
  80811 	Fcolumn_decltype:        0,
  80812 	Fcolumn_decltype16:      0,
  80813 	Fcolumn_double:          0,
  80814 	Fcolumn_int:             0,
  80815 	Fcolumn_int64:           0,
  80816 	Fcolumn_name:            0,
  80817 	Fcolumn_name16:          0,
  80818 	Fcolumn_origin_name:     0,
  80819 	Fcolumn_origin_name16:   0,
  80820 	Fcolumn_table_name:      0,
  80821 	Fcolumn_table_name16:    0,
  80822 	Fcolumn_text:            0,
  80823 	Fcolumn_text16:          0,
  80824 	Fcolumn_type:            0,
  80825 	Fcolumn_value:           0,
  80826 	Fcommit_hook:            0,
  80827 	Fcomplete:               0,
  80828 	Fcomplete16:             0,
  80829 	Fcreate_collation:       0,
  80830 	Fcreate_collation16:     0,
  80831 	Fcreate_function:        0,
  80832 	Fcreate_function16:      0,
  80833 	Fcreate_module:          0,
  80834 	Fdata_count:             0,
  80835 	Fdb_handle:              0,
  80836 	Fdeclare_vtab:           0,
  80837 	Fenable_shared_cache:    0,
  80838 	Ferrcode:                0,
  80839 	Ferrmsg:                 0,
  80840 	Ferrmsg16:               0,
  80841 	Fexec:                   0,
  80842 	Fexpired:                0,
  80843 	Ffinalize:               0,
  80844 	Ffree:                   0,
  80845 	Ffree_table:             0,
  80846 	Fget_autocommit:         0,
  80847 	Fget_auxdata:            0,
  80848 	Fget_table:              0,
  80849 	Finterruptx:             0,
  80850 	Flast_insert_rowid:      0,
  80851 	Flibversion:             0,
  80852 	Flibversion_number:      0,
  80853 	Fmalloc:                 0,
  80854 	Fmprintf:                0,
  80855 	Fopen:                   0,
  80856 	Fopen16:                 0,
  80857 	Fprepare:                0,
  80858 	Fprepare16:              0,
  80859 	Fprofile:                0,
  80860 	Fprogress_handler:       0,
  80861 	Frealloc:                0,
  80862 	Freset:                  0,
  80863 	Fresult_blob:            0,
  80864 	Fresult_double:          0,
  80865 	Fresult_error:           0,
  80866 	Fresult_error16:         0,
  80867 	Fresult_int:             0,
  80868 	Fresult_int64:           0,
  80869 	Fresult_null:            0,
  80870 	Fresult_text:            0,
  80871 	Fresult_text16:          0,
  80872 	Fresult_text16be:        0,
  80873 	Fresult_text16le:        0,
  80874 	Fresult_value:           0,
  80875 	Frollback_hook:          0,
  80876 	Fset_authorizer:         0,
  80877 	Fset_auxdata:            0,
  80878 	Fxsnprintf:              0,
  80879 	Fstep:                   0,
  80880 	Ftable_column_metadata:  0,
  80881 	Fthread_cleanup:         0,
  80882 	Ftotal_changes:          0,
  80883 	Ftrace:                  0,
  80884 	Ftransfer_bindings:      0,
  80885 	Fupdate_hook:            0,
  80886 	Fuser_data:              0,
  80887 	Fvalue_blob:             0,
  80888 	Fvalue_bytes:            0,
  80889 	Fvalue_bytes16:          0,
  80890 	Fvalue_double:           0,
  80891 	Fvalue_int:              0,
  80892 	Fvalue_int64:            0,
  80893 	Fvalue_numeric_type:     0,
  80894 	Fvalue_text:             0,
  80895 	Fvalue_text16:           0,
  80896 	Fvalue_text16be:         0,
  80897 	Fvalue_text16le:         0,
  80898 	Fvalue_type:             0,
  80899 	Fvmprintf:               0,
  80900 	Foverload_function:      0,
  80901 	Fprepare_v2:             0,
  80902 	Fprepare16_v2:           0,
  80903 	Fclear_bindings:         0,
  80904 	Fcreate_module_v2:       0,
  80905 	Fbind_zeroblob:          0,
  80906 	Fblob_bytes:             0,
  80907 	Fblob_close:             0,
  80908 	Fblob_open:              0,
  80909 	Fblob_read:              0,
  80910 	Fblob_write:             0,
  80911 	Fcreate_collation_v2:    0,
  80912 	Ffile_control:           0,
  80913 	Fmemory_highwater:       0,
  80914 	Fmemory_used:            0,
  80915 	Fmutex_alloc:            0,
  80916 	Fmutex_enter:            0,
  80917 	Fmutex_free:             0,
  80918 	Fmutex_leave:            0,
  80919 	Fmutex_try:              0,
  80920 	Fopen_v2:                0,
  80921 	Frelease_memory:         0,
  80922 	Fresult_error_nomem:     0,
  80923 	Fresult_error_toobig:    0,
  80924 	Fsleep:                  0,
  80925 	Fsoft_heap_limit:        0,
  80926 	Fvfs_find:               0,
  80927 	Fvfs_register:           0,
  80928 	Fvfs_unregister:         0,
  80929 	Fxthreadsafe:            0,
  80930 	Fresult_zeroblob:        0,
  80931 	Fresult_error_code:      0,
  80932 	Ftest_control:           0,
  80933 	Frandomness:             0,
  80934 	Fcontext_db_handle:      0,
  80935 	Fextended_result_codes:  0,
  80936 	Flimit:                  0,
  80937 	Fnext_stmt:              0,
  80938 	Fsql:                    0,
  80939 	Fstatus:                 0,
  80940 	Fbackup_finish:          0,
  80941 	Fbackup_init:            0,
  80942 	Fbackup_pagecount:       0,
  80943 	Fbackup_remaining:       0,
  80944 	Fbackup_step:            0,
  80945 	Fcompileoption_get:      0,
  80946 	Fcompileoption_used:     0,
  80947 	Fcreate_function_v2:     0,
  80948 	Fdb_config:              0,
  80949 	Fdb_mutex:               0,
  80950 	Fdb_status:              0,
  80951 	Fextended_errcode:       0,
  80952 	Flog:                    0,
  80953 	Fsoft_heap_limit64:      0,
  80954 	Fsourceid:               0,
  80955 	Fstmt_status:            0,
  80956 	Fstrnicmp:               0,
  80957 	Funlock_notify:          0,
  80958 	Fwal_autocheckpoint:     0,
  80959 	Fwal_checkpoint:         0,
  80960 	Fwal_hook:               0,
  80961 	Fblob_reopen:            0,
  80962 	Fvtab_config:            0,
  80963 	Fvtab_on_conflict:       0,
  80964 	Fclose_v2:               0,
  80965 	Fdb_filename:            0,
  80966 	Fdb_readonly:            0,
  80967 	Fdb_release_memory:      0,
  80968 	Ferrstr:                 0,
  80969 	Fstmt_busy:              0,
  80970 	Fstmt_readonly:          0,
  80971 	Fstricmp:                0,
  80972 	Furi_boolean:            0,
  80973 	Furi_int64:              0,
  80974 	Furi_parameter:          0,
  80975 	Fxvsnprintf:             0,
  80976 	Fwal_checkpoint_v2:      0,
  80977 	Fauto_extension:         0,
  80978 	Fbind_blob64:            0,
  80979 	Fbind_text64:            0,
  80980 	Fcancel_auto_extension:  0,
  80981 	Fload_extension:         0,
  80982 	Fmalloc64:               0,
  80983 	Fmsize:                  0,
  80984 	Frealloc64:              0,
  80985 	Freset_auto_extension:   0,
  80986 	Fresult_blob64:          0,
  80987 	Fresult_text64:          0,
  80988 	Fstrglob:                0,
  80989 	Fvalue_dup:              0,
  80990 	Fvalue_free:             0,
  80991 	Fresult_zeroblob64:      0,
  80992 	Fbind_zeroblob64:        0,
  80993 	Fvalue_subtype:          0,
  80994 	Fresult_subtype:         0,
  80995 	Fstatus64:               0,
  80996 	Fstrlike:                0,
  80997 	Fdb_cacheflush:          0,
  80998 	Fsystem_errno:           0,
  80999 	Ftrace_v2:               0,
  81000 	Fexpanded_sql:           0,
  81001 	Fset_last_insert_rowid:  0,
  81002 	Fprepare_v3:             0,
  81003 	Fprepare16_v3:           0,
  81004 	Fbind_pointer:           0,
  81005 	Fresult_pointer:         0,
  81006 	Fvalue_pointer:          0,
  81007 	Fvtab_nochange:          0,
  81008 	Fvalue_nochange:         0,
  81009 	Fvtab_collation:         0,
  81010 	Fkeyword_count:          0,
  81011 	Fkeyword_name:           0,
  81012 	Fkeyword_check:          0,
  81013 	Fstr_new:                0,
  81014 	Fstr_finish:             0,
  81015 	Fstr_appendf:            0,
  81016 	Fstr_vappendf:           0,
  81017 	Fstr_append:             0,
  81018 	Fstr_appendall:          0,
  81019 	Fstr_appendchar:         0,
  81020 	Fstr_reset:              0,
  81021 	Fstr_errcode:            0,
  81022 	Fstr_length:             0,
  81023 	Fstr_value:              0,
  81024 	Fcreate_window_function: 0,
  81025 	Fstmt_isexplain:         0,
  81026 	Fvalue_frombind:         0,
  81027 	Fdrop_modules:           0,
  81028 	Fhard_heap_limit64:      0,
  81029 	Furi_key:                0,
  81030 	Ffilename_database:      0,
  81031 	Ffilename_journal:       0,
  81032 	Ffilename_wal:           0,
  81033 	Fcreate_filename:        0,
  81034 	Ffree_filename:          0,
  81035 	Fdatabase_file_object:   0,
  81036 	Ftxn_state:              0,
  81037 	Fchanges64:              0,
  81038 	Ftotal_changes64:        0,
  81039 	Fautovacuum_pages:       0,
  81040 	Ferror_offset:           0,
  81041 	Fvtab_rhs_value:         0,
  81042 	Fvtab_distinct:          0,
  81043 	Fvtab_in:                0,
  81044 	Fvtab_in_first:          0,
  81045 	Fvtab_in_next:           0,
  81046 	Fdeserialize:            0,
  81047 	Fserialize:              0,
  81048 	Fdb_name:                0,
  81049 	Fvalue_encoding:         0,
  81050 	Fis_interrupted:         0,
  81051 }
  81052 
  81053 func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) int32 {
  81054 	bp := tls.Alloc(60)
  81055 	defer tls.Free(60)
  81056 
  81057 	var pVfs uintptr
  81058 	var handle uintptr
  81059 	var xInit Sqlite3_loadext_entry
  81060 
  81061 	var zEntry uintptr
  81062 	var zAltEntry uintptr
  81063 	var aHandle uintptr
  81064 	var nMsg U64
  81065 	var ii int32
  81066 	var rc int32
  81067 	var zAltFile uintptr
  81068 	var iFile int32
  81069 	var iEntry int32
  81070 	var c int32
  81071 	var ncFile int32
  81072 	pVfs = (*Sqlite3)(unsafe.Pointer(db)).FpVfs
  81073 	*(*uintptr)(unsafe.Pointer(bp + 56)) = uintptr(0)
  81074 	zAltEntry = uintptr(0)
  81075 	nMsg = U64(libc.Xstrlen(tls, zFile))
  81076 
  81077 	if !(pzErrMsg != 0) {
  81078 		goto __1
  81079 	}
  81080 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = uintptr(0)
  81081 __1:
  81082 	;
  81083 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_LoadExtension) == uint64(0)) {
  81084 		goto __2
  81085 	}
  81086 	if !(pzErrMsg != 0) {
  81087 		goto __3
  81088 	}
  81089 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+12100, 0)
  81090 __3:
  81091 	;
  81092 	return SQLITE_ERROR
  81093 __2:
  81094 	;
  81095 	if zProc != 0 {
  81096 		zEntry = zProc
  81097 	} else {
  81098 		zEntry = ts + 15888
  81099 	}
  81100 
  81101 	if !(nMsg > uint64(FILENAME_MAX)) {
  81102 		goto __4
  81103 	}
  81104 	goto extension_not_found
  81105 __4:
  81106 	;
  81107 	handle = Xsqlite3OsDlOpen(tls, pVfs, zFile)
  81108 	ii = 0
  81109 __5:
  81110 	if !(ii < int32(uint32(unsafe.Sizeof(azEndings))/uint32(unsafe.Sizeof(uintptr(0)))) && handle == uintptr(0)) {
  81111 		goto __7
  81112 	}
  81113 	zAltFile = Xsqlite3_mprintf(tls, ts+12061, libc.VaList(bp, zFile, azEndings[ii]))
  81114 	if !(zAltFile == uintptr(0)) {
  81115 		goto __8
  81116 	}
  81117 	return SQLITE_NOMEM
  81118 __8:
  81119 	;
  81120 	handle = Xsqlite3OsDlOpen(tls, pVfs, zAltFile)
  81121 	Xsqlite3_free(tls, zAltFile)
  81122 	goto __6
  81123 __6:
  81124 	ii++
  81125 	goto __5
  81126 	goto __7
  81127 __7:
  81128 	;
  81129 	if !(handle == uintptr(0)) {
  81130 		goto __9
  81131 	}
  81132 	goto extension_not_found
  81133 __9:
  81134 	;
  81135 	xInit = Xsqlite3OsDlSym(tls, pVfs, handle, zEntry)
  81136 
  81137 	if !(xInit == uintptr(0) && zProc == uintptr(0)) {
  81138 		goto __10
  81139 	}
  81140 	ncFile = Xsqlite3Strlen30(tls, zFile)
  81141 	zAltEntry = Xsqlite3_malloc64(tls, uint64(ncFile+30))
  81142 	if !(zAltEntry == uintptr(0)) {
  81143 		goto __11
  81144 	}
  81145 	Xsqlite3OsDlClose(tls, pVfs, handle)
  81146 	return SQLITE_NOMEM
  81147 __11:
  81148 	;
  81149 	libc.Xmemcpy(tls, zAltEntry, ts+15911, uint32(8))
  81150 	iFile = ncFile - 1
  81151 __12:
  81152 	if !(iFile >= 0 && !(int32(*(*uint8)(unsafe.Pointer(zFile + uintptr(iFile)))) == '/')) {
  81153 		goto __14
  81154 	}
  81155 	goto __13
  81156 __13:
  81157 	iFile--
  81158 	goto __12
  81159 	goto __14
  81160 __14:
  81161 	;
  81162 	iFile++
  81163 	if !(Xsqlite3_strnicmp(tls, zFile+uintptr(iFile), ts+15920, 3) == 0) {
  81164 		goto __15
  81165 	}
  81166 	iFile = iFile + 3
  81167 __15:
  81168 	;
  81169 	iEntry = 8
  81170 __16:
  81171 	if !(libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(zFile + uintptr(iFile))))) != 0 && c != '.') {
  81172 		goto __18
  81173 	}
  81174 	if !(int32(Xsqlite3CtypeMap[uint8(c)])&0x02 != 0) {
  81175 		goto __19
  81176 	}
  81177 	*(*uint8)(unsafe.Pointer(zAltEntry + uintptr(libc.PostIncInt32(&iEntry, 1)))) = Xsqlite3UpperToLower[uint32(c)]
  81178 __19:
  81179 	;
  81180 	goto __17
  81181 __17:
  81182 	iFile++
  81183 	goto __16
  81184 	goto __18
  81185 __18:
  81186 	;
  81187 	libc.Xmemcpy(tls, zAltEntry+uintptr(iEntry), ts+15924, uint32(6))
  81188 	zEntry = zAltEntry
  81189 	xInit = Xsqlite3OsDlSym(tls, pVfs, handle, zEntry)
  81190 __10:
  81191 	;
  81192 	if !(xInit == uintptr(0)) {
  81193 		goto __20
  81194 	}
  81195 	if !(pzErrMsg != 0) {
  81196 		goto __21
  81197 	}
  81198 	nMsg = nMsg + U64(libc.Xstrlen(tls, zEntry)+Size_t(300))
  81199 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = libc.AssignPtrUintptr(bp+56, Xsqlite3_malloc64(tls, nMsg))
  81200 	if !(*(*uintptr)(unsafe.Pointer(bp + 56)) != 0) {
  81201 		goto __22
  81202 	}
  81203 
  81204 	Xsqlite3_snprintf(tls, int32(nMsg), *(*uintptr)(unsafe.Pointer(bp + 56)),
  81205 		ts+15930, libc.VaList(bp+16, zEntry, zFile))
  81206 	Xsqlite3OsDlError(tls, pVfs, int32(nMsg-uint64(1)), *(*uintptr)(unsafe.Pointer(bp + 56)))
  81207 __22:
  81208 	;
  81209 __21:
  81210 	;
  81211 	Xsqlite3OsDlClose(tls, pVfs, handle)
  81212 	Xsqlite3_free(tls, zAltEntry)
  81213 	return SQLITE_ERROR
  81214 __20:
  81215 	;
  81216 	Xsqlite3_free(tls, zAltEntry)
  81217 	rc = (*struct {
  81218 		f func(*libc.TLS, uintptr, uintptr, uintptr) int32
  81219 	})(unsafe.Pointer(&struct{ uintptr }{xInit})).f(tls, db, bp+56, uintptr(unsafe.Pointer(&sqlite3Apis)))
  81220 	if !(rc != 0) {
  81221 		goto __23
  81222 	}
  81223 	if !(rc == SQLITE_OK|int32(1)<<8) {
  81224 		goto __24
  81225 	}
  81226 	return SQLITE_OK
  81227 __24:
  81228 	;
  81229 	if !(pzErrMsg != 0) {
  81230 		goto __25
  81231 	}
  81232 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+15973, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 56))))
  81233 __25:
  81234 	;
  81235 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 56)))
  81236 	Xsqlite3OsDlClose(tls, pVfs, handle)
  81237 	return SQLITE_ERROR
  81238 __23:
  81239 	;
  81240 	aHandle = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(handle))*uint32((*Sqlite3)(unsafe.Pointer(db)).FnExtension+1)))
  81241 	if !(aHandle == uintptr(0)) {
  81242 		goto __26
  81243 	}
  81244 	return SQLITE_NOMEM
  81245 __26:
  81246 	;
  81247 	if !((*Sqlite3)(unsafe.Pointer(db)).FnExtension > 0) {
  81248 		goto __27
  81249 	}
  81250 	libc.Xmemcpy(tls, aHandle, (*Sqlite3)(unsafe.Pointer(db)).FaExtension, uint32(unsafe.Sizeof(handle))*uint32((*Sqlite3)(unsafe.Pointer(db)).FnExtension))
  81251 __27:
  81252 	;
  81253 	Xsqlite3DbFree(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaExtension)
  81254 	(*Sqlite3)(unsafe.Pointer(db)).FaExtension = aHandle
  81255 
  81256 	*(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(libc.PostIncInt32(&(*Sqlite3)(unsafe.Pointer(db)).FnExtension, 1))*4)) = handle
  81257 	return SQLITE_OK
  81258 
  81259 extension_not_found:
  81260 	if !(pzErrMsg != 0) {
  81261 		goto __28
  81262 	}
  81263 	nMsg = nMsg + uint64(300)
  81264 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = libc.AssignPtrUintptr(bp+56, Xsqlite3_malloc64(tls, nMsg))
  81265 	if !(*(*uintptr)(unsafe.Pointer(bp + 56)) != 0) {
  81266 		goto __29
  81267 	}
  81268 
  81269 	Xsqlite3_snprintf(tls, int32(nMsg), *(*uintptr)(unsafe.Pointer(bp + 56)),
  81270 		ts+16005, libc.VaList(bp+40, FILENAME_MAX, zFile))
  81271 	Xsqlite3OsDlError(tls, pVfs, int32(nMsg-uint64(1)), *(*uintptr)(unsafe.Pointer(bp + 56)))
  81272 __29:
  81273 	;
  81274 __28:
  81275 	;
  81276 	return SQLITE_ERROR
  81277 }
  81278 
  81279 var azEndings = [1]uintptr{
  81280 	ts + 16042,
  81281 }
  81282 
  81283 func Xsqlite3_load_extension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) int32 {
  81284 	var rc int32
  81285 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  81286 	rc = sqlite3LoadExtension(tls, db, zFile, zProc, pzErrMsg)
  81287 	rc = Xsqlite3ApiExit(tls, db, rc)
  81288 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  81289 	return rc
  81290 }
  81291 
  81292 // Call this routine when the database connection is closing in order
  81293 // to clean up loaded extensions
  81294 func Xsqlite3CloseExtensions(tls *libc.TLS, db uintptr) {
  81295 	var i int32
  81296 
  81297 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnExtension; i++ {
  81298 		Xsqlite3OsDlClose(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(i)*4)))
  81299 	}
  81300 	Xsqlite3DbFree(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaExtension)
  81301 }
  81302 
  81303 // Enable or disable extension loading.  Extension loading is disabled by
  81304 // default so as not to open security holes in older applications.
  81305 func Xsqlite3_enable_load_extension(tls *libc.TLS, db uintptr, onoff int32) int32 {
  81306 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  81307 	if onoff != 0 {
  81308 		*(*U64)(unsafe.Pointer(db + 32)) |= uint64(SQLITE_LoadExtension | SQLITE_LoadExtFunc)
  81309 	} else {
  81310 		*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_LoadExtension | SQLITE_LoadExtFunc))
  81311 	}
  81312 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  81313 	return SQLITE_OK
  81314 }
  81315 
  81316 type sqlite3AutoExtList = struct {
  81317 	FnExt U32
  81318 	FaExt uintptr
  81319 }
  81320 
  81321 // The following object holds the list of automatically loaded
  81322 // extensions.
  81323 //
  81324 // This list is shared across threads.  The SQLITE_MUTEX_STATIC_MAIN
  81325 // mutex must be held while accessing this list.
  81326 type Sqlite3AutoExtList = sqlite3AutoExtList
  81327 
  81328 var sqlite3Autoext = sqlite3AutoExtList{}
  81329 
  81330 // Register a statically linked extension that is automatically
  81331 // loaded by every new database connection.
  81332 func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 {
  81333 	var rc int32 = SQLITE_OK
  81334 	rc = Xsqlite3_initialize(tls)
  81335 	if rc != 0 {
  81336 		return rc
  81337 	} else {
  81338 		var i U32
  81339 		var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  81340 
  81341 		Xsqlite3_mutex_enter(tls, mutex)
  81342 		for i = U32(0); i < sqlite3Autoext.FnExt; i++ {
  81343 			if *(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(i)*4)) == xInit {
  81344 				break
  81345 			}
  81346 		}
  81347 		if i == sqlite3Autoext.FnExt {
  81348 			var nByte U64 = U64((sqlite3Autoext.FnExt + U32(1)) * U32(unsafe.Sizeof(uintptr(0))))
  81349 			var aNew uintptr
  81350 			aNew = Xsqlite3_realloc64(tls, sqlite3Autoext.FaExt, nByte)
  81351 			if aNew == uintptr(0) {
  81352 				rc = SQLITE_NOMEM
  81353 			} else {
  81354 				sqlite3Autoext.FaExt = aNew
  81355 				*(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(sqlite3Autoext.FnExt)*4)) = xInit
  81356 				sqlite3Autoext.FnExt++
  81357 			}
  81358 		}
  81359 		Xsqlite3_mutex_leave(tls, mutex)
  81360 
  81361 		return rc
  81362 	}
  81363 	return int32(0)
  81364 }
  81365 
  81366 // Cancel a prior call to sqlite3_auto_extension.  Remove xInit from the
  81367 // set of routines that is invoked for each new database connection, if it
  81368 // is currently on the list.  If xInit is not on the list, then this
  81369 // routine is a no-op.
  81370 //
  81371 // Return 1 if xInit was found on the list and removed.  Return 0 if xInit
  81372 // was not on the list.
  81373 func Xsqlite3_cancel_auto_extension(tls *libc.TLS, xInit uintptr) int32 {
  81374 	var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  81375 	var i int32
  81376 	var n int32 = 0
  81377 
  81378 	Xsqlite3_mutex_enter(tls, mutex)
  81379 	for i = int32(sqlite3Autoext.FnExt) - 1; i >= 0; i-- {
  81380 		if *(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(i)*4)) == xInit {
  81381 			sqlite3Autoext.FnExt--
  81382 			*(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(sqlite3Autoext.FnExt)*4))
  81383 			n++
  81384 			break
  81385 		}
  81386 	}
  81387 	Xsqlite3_mutex_leave(tls, mutex)
  81388 	return n
  81389 }
  81390 
  81391 // Reset the automatic extension loading mechanism.
  81392 func Xsqlite3_reset_auto_extension(tls *libc.TLS) {
  81393 	if Xsqlite3_initialize(tls) == SQLITE_OK {
  81394 		var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  81395 
  81396 		Xsqlite3_mutex_enter(tls, mutex)
  81397 		Xsqlite3_free(tls, sqlite3Autoext.FaExt)
  81398 		sqlite3Autoext.FaExt = uintptr(0)
  81399 		sqlite3Autoext.FnExt = U32(0)
  81400 		Xsqlite3_mutex_leave(tls, mutex)
  81401 	}
  81402 }
  81403 
  81404 // Load all automatic extensions.
  81405 //
  81406 // If anything goes wrong, set an error in the database connection.
  81407 func Xsqlite3AutoLoadExtensions(tls *libc.TLS, db uintptr) {
  81408 	bp := tls.Alloc(12)
  81409 	defer tls.Free(12)
  81410 
  81411 	var i U32
  81412 	var go1 int32 = 1
  81413 	var rc int32
  81414 	var xInit Sqlite3_loadext_entry
  81415 
  81416 	if sqlite3Autoext.FnExt == U32(0) {
  81417 		return
  81418 	}
  81419 	for i = U32(0); go1 != 0; i++ {
  81420 		var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
  81421 		var pThunk uintptr = uintptr(unsafe.Pointer(&sqlite3Apis))
  81422 		Xsqlite3_mutex_enter(tls, mutex)
  81423 		if i >= sqlite3Autoext.FnExt {
  81424 			xInit = uintptr(0)
  81425 			go1 = 0
  81426 		} else {
  81427 			xInit = *(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(i)*4))
  81428 		}
  81429 		Xsqlite3_mutex_leave(tls, mutex)
  81430 		*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  81431 		if xInit != 0 && libc.AssignInt32(&rc, (*struct {
  81432 			f func(*libc.TLS, uintptr, uintptr, uintptr) int32
  81433 		})(unsafe.Pointer(&struct{ uintptr }{xInit})).f(tls, db, bp+8, pThunk)) != 0 {
  81434 			Xsqlite3ErrorWithMsg(tls, db, rc,
  81435 				ts+16045, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 8))))
  81436 			go1 = 0
  81437 		}
  81438 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
  81439 	}
  81440 }
  81441 
  81442 var pragCName = [57]uintptr{
  81443 	ts + 5057,
  81444 	ts + 16084,
  81445 	ts + 8876,
  81446 	ts + 16088,
  81447 	ts + 16093,
  81448 	ts + 16096,
  81449 	ts + 16106,
  81450 	ts + 16116,
  81451 	ts + 16122,
  81452 	ts + 16126,
  81453 	ts + 16131,
  81454 	ts + 16136,
  81455 	ts + 16144,
  81456 	ts + 16155,
  81457 	ts + 16158,
  81458 	ts + 16165,
  81459 	ts + 16126,
  81460 	ts + 16131,
  81461 	ts + 16172,
  81462 	ts + 16177,
  81463 	ts + 16180,
  81464 	ts + 16187,
  81465 	ts + 16122,
  81466 	ts + 16126,
  81467 	ts + 16193,
  81468 	ts + 16198,
  81469 	ts + 16203,
  81470 	ts + 16126,
  81471 	ts + 16207,
  81472 	ts + 16131,
  81473 	ts + 16215,
  81474 	ts + 16219,
  81475 	ts + 16224,
  81476 	ts + 11492,
  81477 	ts + 11488,
  81478 	ts + 16230,
  81479 	ts + 16235,
  81480 	ts + 16240,
  81481 	ts + 16084,
  81482 	ts + 16126,
  81483 	ts + 16245,
  81484 	ts + 16252,
  81485 	ts + 16259,
  81486 	ts + 8876,
  81487 	ts + 16267,
  81488 	ts + 5060,
  81489 	ts + 16273,
  81490 	ts + 16084,
  81491 	ts + 16126,
  81492 	ts + 16278,
  81493 	ts + 16283,
  81494 	ts + 15480,
  81495 	ts + 16288,
  81496 	ts + 16301,
  81497 	ts + 16310,
  81498 	ts + 16317,
  81499 	ts + 16328,
  81500 }
  81501 
  81502 // Definitions of all built-in pragmas
  81503 type PragmaName1 = struct {
  81504 	FzName      uintptr
  81505 	FePragTyp   U8
  81506 	FmPragFlg   U8
  81507 	FiPragCName U8
  81508 	FnPragCName U8
  81509 	FiArg       U64
  81510 }
  81511 
  81512 // Definitions of all built-in pragmas
  81513 type PragmaName = PragmaName1
  81514 
  81515 var aPragmaName = [66]PragmaName{
  81516 	{FzName: ts + 16336,
  81517 		FePragTyp: U8(PragTyp_ANALYSIS_LIMIT),
  81518 		FmPragFlg: U8(PragFlg_Result0)},
  81519 	{FzName: ts + 16351,
  81520 		FePragTyp: U8(PragTyp_HEADER_VALUE),
  81521 		FmPragFlg: U8(PragFlg_NoColumns1 | PragFlg_Result0),
  81522 		FiArg:     uint64(BTREE_APPLICATION_ID)},
  81523 	{FzName: ts + 16366,
  81524 		FePragTyp: U8(PragTyp_AUTO_VACUUM),
  81525 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1)},
  81526 	{FzName: ts + 16378,
  81527 		FePragTyp: U8(PragTyp_FLAG),
  81528 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81529 		FiArg:     uint64(SQLITE_AutoIndex)},
  81530 	{FzName: ts + 16394,
  81531 		FePragTyp:   U8(PragTyp_BUSY_TIMEOUT),
  81532 		FmPragFlg:   U8(PragFlg_Result0),
  81533 		FiPragCName: U8(56), FnPragCName: U8(1)},
  81534 	{FzName: ts + 16317,
  81535 		FePragTyp: U8(PragTyp_CACHE_SIZE),
  81536 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1)},
  81537 	{FzName: ts + 16407,
  81538 		FePragTyp: U8(PragTyp_CACHE_SPILL),
  81539 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1)},
  81540 	{FzName: ts + 16419,
  81541 		FePragTyp: U8(PragTyp_CASE_SENSITIVE_LIKE),
  81542 		FmPragFlg: U8(PragFlg_NoColumns)},
  81543 	{FzName: ts + 16439,
  81544 		FePragTyp: U8(PragTyp_FLAG),
  81545 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81546 		FiArg:     uint64(SQLITE_CellSizeCk)},
  81547 	{FzName: ts + 16455,
  81548 		FePragTyp: U8(PragTyp_FLAG),
  81549 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81550 		FiArg:     uint64(SQLITE_CkptFullFSync)},
  81551 	{FzName: ts + 16476,
  81552 		FePragTyp:   U8(PragTyp_COLLATION_LIST),
  81553 		FmPragFlg:   U8(PragFlg_Result0),
  81554 		FiPragCName: U8(38), FnPragCName: U8(2)},
  81555 	{FzName: ts + 16491,
  81556 		FePragTyp: U8(PragTyp_COMPILE_OPTIONS),
  81557 		FmPragFlg: U8(PragFlg_Result0)},
  81558 	{FzName: ts + 16507,
  81559 		FePragTyp: U8(PragTyp_FLAG),
  81560 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81561 		FiArg:     uint64(0x00001) << 32},
  81562 	{FzName: ts + 16521,
  81563 		FePragTyp: U8(PragTyp_HEADER_VALUE),
  81564 		FmPragFlg: U8(PragFlg_ReadOnly | PragFlg_Result0),
  81565 		FiArg:     uint64(BTREE_DATA_VERSION)},
  81566 	{FzName: ts + 16534,
  81567 		FePragTyp:   U8(PragTyp_DATABASE_LIST),
  81568 		FmPragFlg:   U8(PragFlg_Result0),
  81569 		FiPragCName: U8(47), FnPragCName: U8(3)},
  81570 	{FzName: ts + 16548,
  81571 		FePragTyp:   U8(PragTyp_DEFAULT_CACHE_SIZE),
  81572 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1),
  81573 		FiPragCName: U8(55), FnPragCName: U8(1)},
  81574 	{FzName: ts + 16567,
  81575 		FePragTyp: U8(PragTyp_FLAG),
  81576 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81577 		FiArg:     uint64(SQLITE_DeferFKs)},
  81578 	{FzName: ts + 16586,
  81579 		FePragTyp: U8(PragTyp_FLAG),
  81580 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81581 		FiArg:     uint64(SQLITE_NullCallback)},
  81582 	{FzName: ts + 16609,
  81583 		FePragTyp: U8(PragTyp_ENCODING),
  81584 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1)},
  81585 	{FzName: ts + 16618,
  81586 		FePragTyp:   U8(PragTyp_FOREIGN_KEY_CHECK),
  81587 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_Result1 | PragFlg_SchemaOpt),
  81588 		FiPragCName: U8(43), FnPragCName: U8(4)},
  81589 	{FzName: ts + 16636,
  81590 		FePragTyp: U8(PragTyp_FOREIGN_KEY_LIST),
  81591 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt), FnPragCName: U8(8)},
  81592 	{FzName: ts + 16653,
  81593 		FePragTyp: U8(PragTyp_FLAG),
  81594 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81595 		FiArg:     uint64(SQLITE_ForeignKeys)},
  81596 	{FzName: ts + 16666,
  81597 		FePragTyp: U8(PragTyp_HEADER_VALUE),
  81598 		FmPragFlg: U8(PragFlg_ReadOnly | PragFlg_Result0)},
  81599 	{FzName: ts + 16681,
  81600 		FePragTyp: U8(PragTyp_FLAG),
  81601 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81602 		FiArg:     uint64(SQLITE_FullColNames)},
  81603 	{FzName: ts + 16699,
  81604 		FePragTyp: U8(PragTyp_FLAG),
  81605 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81606 		FiArg:     uint64(SQLITE_FullFSync)},
  81607 	{FzName: ts + 16709,
  81608 		FePragTyp:   U8(PragTyp_FUNCTION_LIST),
  81609 		FmPragFlg:   U8(PragFlg_Result0),
  81610 		FiPragCName: U8(27), FnPragCName: U8(6)},
  81611 	{FzName: ts + 16723,
  81612 		FePragTyp: U8(PragTyp_HARD_HEAP_LIMIT),
  81613 		FmPragFlg: U8(PragFlg_Result0)},
  81614 	{FzName: ts + 16739,
  81615 		FePragTyp: U8(PragTyp_FLAG),
  81616 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81617 		FiArg:     uint64(SQLITE_IgnoreChecks)},
  81618 	{FzName: ts + 16764,
  81619 		FePragTyp: U8(PragTyp_INCREMENTAL_VACUUM),
  81620 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_NoColumns)},
  81621 	{FzName: ts + 16783,
  81622 		FePragTyp:   U8(PragTyp_INDEX_INFO),
  81623 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt),
  81624 		FiPragCName: U8(21), FnPragCName: U8(3)},
  81625 	{FzName: ts + 16794,
  81626 		FePragTyp:   U8(PragTyp_INDEX_LIST),
  81627 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt),
  81628 		FiPragCName: U8(38), FnPragCName: U8(5)},
  81629 	{FzName: ts + 16805,
  81630 		FePragTyp:   U8(PragTyp_INDEX_INFO),
  81631 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt),
  81632 		FiPragCName: U8(21), FnPragCName: U8(6),
  81633 		FiArg: uint64(1)},
  81634 	{FzName: ts + 16817,
  81635 		FePragTyp: U8(PragTyp_INTEGRITY_CHECK),
  81636 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_Result1 | PragFlg_SchemaOpt)},
  81637 	{FzName: ts + 16833,
  81638 		FePragTyp: U8(PragTyp_JOURNAL_MODE),
  81639 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq)},
  81640 	{FzName: ts + 16846,
  81641 		FePragTyp: U8(PragTyp_JOURNAL_SIZE_LIMIT),
  81642 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_SchemaReq)},
  81643 	{FzName: ts + 16865,
  81644 		FePragTyp: U8(PragTyp_FLAG),
  81645 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81646 		FiArg:     uint64(SQLITE_LegacyAlter)},
  81647 	{FzName: ts + 16884,
  81648 		FePragTyp: U8(PragTyp_LOCKING_MODE),
  81649 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_SchemaReq)},
  81650 	{FzName: ts + 16897,
  81651 		FePragTyp: U8(PragTyp_PAGE_COUNT),
  81652 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq)},
  81653 	{FzName: ts + 16912,
  81654 		FePragTyp: U8(PragTyp_MMAP_SIZE)},
  81655 	{FzName: ts + 16922,
  81656 		FePragTyp:   U8(PragTyp_MODULE_LIST),
  81657 		FmPragFlg:   U8(PragFlg_Result0),
  81658 		FiPragCName: U8(9), FnPragCName: U8(1)},
  81659 	{FzName: ts + 16934,
  81660 		FePragTyp: U8(PragTyp_OPTIMIZE),
  81661 		FmPragFlg: U8(PragFlg_Result1 | PragFlg_NeedSchema)},
  81662 	{FzName: ts + 16943,
  81663 		FePragTyp: U8(PragTyp_PAGE_COUNT),
  81664 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq)},
  81665 	{FzName: ts + 16954,
  81666 		FePragTyp: U8(PragTyp_PAGE_SIZE),
  81667 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1)},
  81668 	{FzName: ts + 16964,
  81669 		FePragTyp:   U8(PragTyp_PRAGMA_LIST),
  81670 		FmPragFlg:   U8(PragFlg_Result0),
  81671 		FiPragCName: U8(9), FnPragCName: U8(1)},
  81672 	{FzName: ts + 16976,
  81673 		FePragTyp: U8(PragTyp_FLAG),
  81674 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81675 		FiArg:     uint64(SQLITE_QueryOnly)},
  81676 	{FzName: ts + 16987,
  81677 		FePragTyp: U8(PragTyp_INTEGRITY_CHECK),
  81678 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_Result1 | PragFlg_SchemaOpt)},
  81679 	{FzName: ts + 16999,
  81680 		FePragTyp: U8(PragTyp_FLAG),
  81681 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81682 		FiArg:     uint64(SQLITE_ReadUncommit)},
  81683 	{FzName: ts + 17016,
  81684 		FePragTyp: U8(PragTyp_FLAG),
  81685 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81686 		FiArg:     uint64(SQLITE_RecTriggers)},
  81687 	{FzName: ts + 17035,
  81688 		FePragTyp: U8(PragTyp_FLAG),
  81689 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81690 		FiArg:     uint64(SQLITE_ReverseOrder)},
  81691 	{FzName: ts + 17061,
  81692 		FePragTyp: U8(PragTyp_HEADER_VALUE),
  81693 		FmPragFlg: U8(PragFlg_NoColumns1 | PragFlg_Result0),
  81694 		FiArg:     uint64(BTREE_SCHEMA_VERSION)},
  81695 	{FzName: ts + 17076,
  81696 		FePragTyp: U8(PragTyp_SECURE_DELETE),
  81697 		FmPragFlg: U8(PragFlg_Result0)},
  81698 	{FzName: ts + 17090,
  81699 		FePragTyp: U8(PragTyp_FLAG),
  81700 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81701 		FiArg:     uint64(SQLITE_ShortColNames)},
  81702 	{FzName: ts + 17109,
  81703 		FePragTyp: U8(PragTyp_SHRINK_MEMORY),
  81704 		FmPragFlg: U8(PragFlg_NoColumns)},
  81705 	{FzName: ts + 17123,
  81706 		FePragTyp: U8(PragTyp_SOFT_HEAP_LIMIT),
  81707 		FmPragFlg: U8(PragFlg_Result0)},
  81708 	{FzName: ts + 17139,
  81709 		FePragTyp: U8(PragTyp_SYNCHRONOUS),
  81710 		FmPragFlg: U8(PragFlg_NeedSchema | PragFlg_Result0 | PragFlg_SchemaReq | PragFlg_NoColumns1)},
  81711 	{FzName: ts + 17151,
  81712 		FePragTyp:   U8(PragTyp_TABLE_INFO),
  81713 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt),
  81714 		FiPragCName: U8(8), FnPragCName: U8(6)},
  81715 	{FzName: ts + 17162,
  81716 		FePragTyp:   U8(PragTyp_TABLE_LIST),
  81717 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result1),
  81718 		FiPragCName: U8(15), FnPragCName: U8(6)},
  81719 	{FzName: ts + 17173,
  81720 		FePragTyp:   U8(PragTyp_TABLE_INFO),
  81721 		FmPragFlg:   U8(PragFlg_NeedSchema | PragFlg_Result1 | PragFlg_SchemaOpt),
  81722 		FiPragCName: U8(8), FnPragCName: U8(7),
  81723 		FiArg: uint64(1)},
  81724 	{FzName: ts + 17185,
  81725 		FePragTyp: U8(PragTyp_TEMP_STORE),
  81726 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1)},
  81727 	{FzName: ts + 17196,
  81728 		FePragTyp: U8(PragTyp_TEMP_STORE_DIRECTORY),
  81729 		FmPragFlg: U8(PragFlg_NoColumns1)},
  81730 	{FzName: ts + 17217,
  81731 		FePragTyp: U8(PragTyp_THREADS),
  81732 		FmPragFlg: U8(PragFlg_Result0)},
  81733 	{FzName: ts + 17225,
  81734 		FePragTyp: U8(PragTyp_FLAG),
  81735 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81736 		FiArg:     uint64(SQLITE_TrustedSchema)},
  81737 	{FzName: ts + 17240,
  81738 		FePragTyp: U8(PragTyp_HEADER_VALUE),
  81739 		FmPragFlg: U8(PragFlg_NoColumns1 | PragFlg_Result0),
  81740 		FiArg:     uint64(BTREE_USER_VERSION)},
  81741 	{FzName: ts + 17253,
  81742 		FePragTyp: U8(PragTyp_WAL_AUTOCHECKPOINT)},
  81743 	{FzName: ts + 17272,
  81744 		FePragTyp:   U8(PragTyp_WAL_CHECKPOINT),
  81745 		FmPragFlg:   U8(PragFlg_NeedSchema),
  81746 		FiPragCName: U8(50), FnPragCName: U8(3)},
  81747 	{FzName: ts + 17287,
  81748 		FePragTyp: U8(PragTyp_FLAG),
  81749 		FmPragFlg: U8(PragFlg_Result0 | PragFlg_NoColumns1),
  81750 		FiArg:     uint64(SQLITE_WriteSchema | SQLITE_NoSchemaError)},
  81751 }
  81752 
  81753 func getSafetyLevel(tls *libc.TLS, z uintptr, omitFull int32, dflt U8) U8 {
  81754 	var i int32
  81755 	var n int32
  81756 	if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z))])&0x04 != 0 {
  81757 		return U8(Xsqlite3Atoi(tls, z))
  81758 	}
  81759 	n = Xsqlite3Strlen30(tls, z)
  81760 	for i = 0; i < int32(uint32(unsafe.Sizeof(iLength))/uint32(unsafe.Sizeof(U8(0)))); i++ {
  81761 		if int32(iLength[i]) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&zText))+uintptr(iOffset[i]), z, n) == 0 &&
  81762 			(!(omitFull != 0) || int32(iValue[i]) <= 1) {
  81763 			return iValue[i]
  81764 		}
  81765 	}
  81766 	return dflt
  81767 }
  81768 
  81769 var zText = *(*[25]uint8)(unsafe.Pointer(ts + 17303))
  81770 var iOffset = [8]U8{U8(0), U8(1), U8(2), U8(4), U8(9), U8(12), U8(15), U8(20)}
  81771 var iLength = [8]U8{U8(2), U8(2), U8(3), U8(5), U8(3), U8(4), U8(5), U8(4)}
  81772 var iValue = [8]U8{U8(1), U8(0), U8(0), U8(0), U8(1), U8(1), U8(3), U8(2)}
  81773 
  81774 // Interpret the given string as a boolean value.
  81775 func Xsqlite3GetBoolean(tls *libc.TLS, z uintptr, dflt U8) U8 {
  81776 	return U8(libc.Bool32(int32(getSafetyLevel(tls, z, 1, dflt)) != 0))
  81777 }
  81778 
  81779 func getLockingMode(tls *libc.TLS, z uintptr) int32 {
  81780 	if z != 0 {
  81781 		if 0 == Xsqlite3StrICmp(tls, z, ts+17328) {
  81782 			return PAGER_LOCKINGMODE_EXCLUSIVE
  81783 		}
  81784 		if 0 == Xsqlite3StrICmp(tls, z, ts+17338) {
  81785 			return PAGER_LOCKINGMODE_NORMAL
  81786 		}
  81787 	}
  81788 	return -1
  81789 }
  81790 
  81791 func getAutoVacuum(tls *libc.TLS, z uintptr) int32 {
  81792 	var i int32
  81793 	if 0 == Xsqlite3StrICmp(tls, z, ts+8026) {
  81794 		return BTREE_AUTOVACUUM_NONE
  81795 	}
  81796 	if 0 == Xsqlite3StrICmp(tls, z, ts+17345) {
  81797 		return BTREE_AUTOVACUUM_FULL
  81798 	}
  81799 	if 0 == Xsqlite3StrICmp(tls, z, ts+17350) {
  81800 		return BTREE_AUTOVACUUM_INCR
  81801 	}
  81802 	i = Xsqlite3Atoi(tls, z)
  81803 	return int32(func() uint8 {
  81804 		if i >= 0 && i <= 2 {
  81805 			return uint8(i)
  81806 		}
  81807 		return uint8(0)
  81808 	}())
  81809 }
  81810 
  81811 func getTempStore(tls *libc.TLS, z uintptr) int32 {
  81812 	if int32(*(*uint8)(unsafe.Pointer(z))) >= '0' && int32(*(*uint8)(unsafe.Pointer(z))) <= '2' {
  81813 		return int32(*(*uint8)(unsafe.Pointer(z))) - '0'
  81814 	} else if Xsqlite3StrICmp(tls, z, ts+16278) == 0 {
  81815 		return 1
  81816 	} else if Xsqlite3StrICmp(tls, z, ts+17362) == 0 {
  81817 		return 2
  81818 	} else {
  81819 		return 0
  81820 	}
  81821 	return int32(0)
  81822 }
  81823 
  81824 func invalidateTempStorage(tls *libc.TLS, pParse uintptr) int32 {
  81825 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  81826 	if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpBt != uintptr(0) {
  81827 		if !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) ||
  81828 			Xsqlite3BtreeTxnState(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpBt) != SQLITE_TXN_NONE {
  81829 			Xsqlite3ErrorMsg(tls, pParse,
  81830 				ts+17369, 0)
  81831 			return SQLITE_ERROR
  81832 		}
  81833 		Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpBt)
  81834 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FpBt = uintptr(0)
  81835 		Xsqlite3ResetAllSchemasOfConnection(tls, db)
  81836 	}
  81837 	return SQLITE_OK
  81838 }
  81839 
  81840 func changeTempStorage(tls *libc.TLS, pParse uintptr, zStorageType uintptr) int32 {
  81841 	var ts int32 = getTempStore(tls, zStorageType)
  81842 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  81843 	if int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == ts {
  81844 		return SQLITE_OK
  81845 	}
  81846 	if invalidateTempStorage(tls, pParse) != SQLITE_OK {
  81847 		return SQLITE_ERROR
  81848 	}
  81849 	(*Sqlite3)(unsafe.Pointer(db)).Ftemp_store = U8(ts)
  81850 	return SQLITE_OK
  81851 }
  81852 
  81853 func setPragmaResultColumnNames(tls *libc.TLS, v uintptr, pPragma uintptr) {
  81854 	var n U8 = (*PragmaName)(unsafe.Pointer(pPragma)).FnPragCName
  81855 	Xsqlite3VdbeSetNumCols(tls, v, func() int32 {
  81856 		if int32(n) == 0 {
  81857 			return 1
  81858 		}
  81859 		return int32(n)
  81860 	}())
  81861 	if int32(n) == 0 {
  81862 		Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (*PragmaName)(unsafe.Pointer(pPragma)).FzName, uintptr(0))
  81863 	} else {
  81864 		var i int32
  81865 		var j int32
  81866 		i = 0
  81867 		j = int32((*PragmaName)(unsafe.Pointer(pPragma)).FiPragCName)
  81868 	__1:
  81869 		if !(i < int32(n)) {
  81870 			goto __3
  81871 		}
  81872 		{
  81873 			Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, pragCName[j], uintptr(0))
  81874 
  81875 		}
  81876 		goto __2
  81877 	__2:
  81878 		i++
  81879 		j++
  81880 		goto __1
  81881 		goto __3
  81882 	__3:
  81883 	}
  81884 }
  81885 
  81886 func returnSingleInt(tls *libc.TLS, v uintptr, value I64) {
  81887 	bp := tls.Alloc(8)
  81888 	defer tls.Free(8)
  81889 	*(*I64)(unsafe.Pointer(bp)) = value
  81890 
  81891 	Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Int64, 0, 1, 0, bp, -13)
  81892 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1)
  81893 }
  81894 
  81895 func returnSingleText(tls *libc.TLS, v uintptr, zValue uintptr) {
  81896 	if zValue != 0 {
  81897 		Xsqlite3VdbeLoadString(tls, v, 1, zValue)
  81898 		Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1)
  81899 	}
  81900 }
  81901 
  81902 func setAllPagerFlags(tls *libc.TLS, db uintptr) {
  81903 	if (*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0 {
  81904 		var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb
  81905 		var n int32 = (*Sqlite3)(unsafe.Pointer(db)).FnDb
  81906 
  81907 		for libc.PostDecInt32(&n, 1) > 0 {
  81908 			if (*Db)(unsafe.Pointer(pDb)).FpBt != 0 {
  81909 				Xsqlite3BtreeSetPagerFlags(tls, (*Db)(unsafe.Pointer(pDb)).FpBt,
  81910 					uint32(U64((*Db)(unsafe.Pointer(pDb)).Fsafety_level)|(*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK)))
  81911 			}
  81912 			pDb += 16
  81913 		}
  81914 	}
  81915 }
  81916 
  81917 func actionName(tls *libc.TLS, action U8) uintptr {
  81918 	var zName uintptr
  81919 	switch int32(action) {
  81920 	case OE_SetNull:
  81921 		zName = ts + 17431
  81922 		break
  81923 	case OE_SetDflt:
  81924 		zName = ts + 17440
  81925 		break
  81926 	case OE_Cascade:
  81927 		zName = ts + 17452
  81928 		break
  81929 	case OE_Restrict:
  81930 		zName = ts + 17460
  81931 		break
  81932 	default:
  81933 		zName = ts + 17469
  81934 		break
  81935 	}
  81936 	return zName
  81937 }
  81938 
  81939 // Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants
  81940 // defined in pager.h. This function returns the associated lowercase
  81941 // journal-mode name.
  81942 func Xsqlite3JournalModename(tls *libc.TLS, eMode int32) uintptr {
  81943 	if eMode == int32(uint32(unsafe.Sizeof(azModeName))/uint32(unsafe.Sizeof(uintptr(0)))) {
  81944 		return uintptr(0)
  81945 	}
  81946 	return azModeName[eMode]
  81947 }
  81948 
  81949 var azModeName = [6]uintptr{
  81950 	ts + 17479, ts + 17486, ts + 17494, ts + 17498, ts + 17362, ts + 17507,
  81951 }
  81952 
  81953 func pragmaLocate(tls *libc.TLS, zName uintptr) uintptr {
  81954 	var upr int32
  81955 	var lwr int32
  81956 	var mid int32 = 0
  81957 	var rc int32
  81958 	lwr = 0
  81959 	upr = int32(uint32(unsafe.Sizeof(aPragmaName))/uint32(unsafe.Sizeof(PragmaName{}))) - 1
  81960 	for lwr <= upr {
  81961 		mid = (lwr + upr) / 2
  81962 		rc = Xsqlite3_stricmp(tls, zName, aPragmaName[mid].FzName)
  81963 		if rc == 0 {
  81964 			break
  81965 		}
  81966 		if rc < 0 {
  81967 			upr = mid - 1
  81968 		} else {
  81969 			lwr = mid + 1
  81970 		}
  81971 	}
  81972 	if lwr > upr {
  81973 		return uintptr(0)
  81974 	}
  81975 	return uintptr(unsafe.Pointer(&aPragmaName)) + uintptr(mid)*16
  81976 }
  81977 
  81978 func pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, showInternFuncs int32) {
  81979 	bp := tls.Alloc(48)
  81980 	defer tls.Free(48)
  81981 
  81982 	var mask U32 = U32(SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY | SQLITE_SUBTYPE | SQLITE_INNOCUOUS | SQLITE_FUNC_INTERNAL)
  81983 	if showInternFuncs != 0 {
  81984 		mask = 0xffffffff
  81985 	}
  81986 	for ; p != 0; p = (*FuncDef)(unsafe.Pointer(p)).FpNext {
  81987 		var zType uintptr
  81988 
  81989 		if (*FuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) {
  81990 			continue
  81991 		}
  81992 		if (*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(SQLITE_FUNC_INTERNAL) != U32(0) &&
  81993 			showInternFuncs == 0 {
  81994 			continue
  81995 		}
  81996 		if (*FuncDef)(unsafe.Pointer(p)).FxValue != uintptr(0) {
  81997 			zType = ts + 17511
  81998 		} else if (*FuncDef)(unsafe.Pointer(p)).FxFinalize != uintptr(0) {
  81999 			zType = ts + 17513
  82000 		} else {
  82001 			zType = ts + 7517
  82002 		}
  82003 		Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17515,
  82004 			libc.VaList(bp, (*FuncDef)(unsafe.Pointer(p)).FzName, isBuiltin,
  82005 				zType, azEnc[(*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(SQLITE_FUNC_ENCMASK)],
  82006 				int32((*FuncDef)(unsafe.Pointer(p)).FnArg),
  82007 				(*FuncDef)(unsafe.Pointer(p)).FfuncFlags&mask^U32(SQLITE_INNOCUOUS)))
  82008 	}
  82009 }
  82010 
  82011 var azEnc = [4]uintptr{uintptr(0), ts + 17522, ts + 17527, ts + 17535}
  82012 
  82013 func integrityCheckResultRow(tls *libc.TLS, v uintptr) int32 {
  82014 	var addr int32
  82015 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 3, 1)
  82016 	addr = Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, 1, Xsqlite3VdbeCurrentAddr(tls, v)+2, 1)
  82017 
  82018 	Xsqlite3VdbeAddOp0(tls, v, OP_Halt)
  82019 	return addr
  82020 }
  82021 
  82022 // Process a pragma statement.
  82023 //
  82024 // Pragmas are of this form:
  82025 //
  82026 //	PRAGMA [schema.]id [= value]
  82027 //
  82028 // The identifier might also be a string.  The value is a string, and
  82029 // identifier, or a number.  If minusFlag is true, then the value is
  82030 // a number that was preceded by a minus sign.
  82031 //
  82032 // If the left side is "database.id" then pId1 is the database name
  82033 // and pId2 is the id.  If the left side is just "id" then pId1 is the
  82034 // id and pId2 is any empty string.
  82035 func Xsqlite3Pragma(tls *libc.TLS, pParse uintptr, pId1 uintptr, pId2 uintptr, pValue uintptr, minusFlag int32) {
  82036 	bp := tls.Alloc(616)
  82037 	defer tls.Free(616)
  82038 
  82039 	var zLeft uintptr
  82040 	var zRight uintptr
  82041 	var zDb uintptr
  82042 
  82043 	var iDb int32
  82044 	var rc int32
  82045 	var db uintptr
  82046 	var pDb uintptr
  82047 	var v uintptr
  82048 	var pPragma uintptr
  82049 	var size int32
  82050 	var aOp uintptr
  82051 	var size1 int32
  82052 	var pBt uintptr
  82053 	var ii int32
  82054 	var pBt1 uintptr
  82055 	var b int32
  82056 	var iReg int32
  82057 
  82058 	var ii1 int32
  82059 	var pPager uintptr
  82060 	var zRet uintptr
  82061 	var eMode int32
  82062 	var zMode uintptr
  82063 	var n int32
  82064 	var eMode1 int32
  82065 	var ii2 int32
  82066 	var pPager1 uintptr
  82067 
  82068 	var aOp1 uintptr
  82069 	var iAddr int32
  82070 	var eAuto int32
  82071 	var pBt2 uintptr
  82072 
  82073 	var addr int32
  82074 	var size2 int32
  82075 
  82076 	var ii3 int32
  82077 
  82078 	var iLevel int32
  82079 	var mask U64
  82080 	var isHidden int32
  82081 	var pColExpr uintptr
  82082 	var i int32
  82083 	var k int32
  82084 	var nHidden int32
  82085 	var pCol uintptr
  82086 	var pPk uintptr
  82087 	var pTab uintptr
  82088 
  82089 	var zSql uintptr
  82090 	var pTab1 uintptr
  82091 	var pTab2 uintptr
  82092 	var zType uintptr
  82093 	var k1 uintptr
  82094 	var pHash uintptr
  82095 	var initNCol int32
  82096 	var ii4 int32
  82097 	var cnum I16
  82098 	var iIdxDb int32
  82099 	var i1 int32
  82100 	var mx int32
  82101 	var pIdx uintptr
  82102 	var pTab3 uintptr
  82103 
  82104 	var iTabDb int32
  82105 	var pIdx1 uintptr
  82106 	var pTab4 uintptr
  82107 	var i2 int32
  82108 	var i3 int32
  82109 	var pColl uintptr
  82110 	var i4 int32
  82111 	var p uintptr
  82112 	var i5 int32
  82113 	var j uintptr
  82114 	var p1 uintptr
  82115 	var showInternFunc int32
  82116 	var pMod uintptr
  82117 	var j1 uintptr
  82118 	var i6 int32
  82119 	var j2 int32
  82120 	var iTabDb1 int32
  82121 	var i7 int32
  82122 	var pFK uintptr
  82123 	var pTab5 uintptr
  82124 	var iCol int32
  82125 	var jmp int32
  82126 	var pFK1 uintptr
  82127 	var pTab6 uintptr
  82128 	var pParent uintptr
  82129 
  82130 	var i8 int32
  82131 	var j3 int32
  82132 	var k2 uintptr
  82133 	var x1 int32
  82134 	var regResult int32
  82135 	var regRow int32
  82136 	var addrTop int32
  82137 	var addrOk int32
  82138 
  82139 	var pTab7 uintptr
  82140 	var pIdx3 uintptr
  82141 	var nIdx int32
  82142 	var pTab8 uintptr
  82143 	var pIdx4 uintptr
  82144 
  82145 	var a1 int32
  82146 	var zErr uintptr
  82147 
  82148 	var jmp2 int32
  82149 	var zErr1 uintptr
  82150 	var pCol1 uintptr
  82151 	var labelError int32
  82152 	var labelOk int32
  82153 	var p11 int32
  82154 	var p3 int32
  82155 	var p4 int32
  82156 	var doTypeCheck int32
  82157 	var addrCkFault int32
  82158 	var addrCkOk int32
  82159 	var zErr2 uintptr
  82160 	var k3 int32
  82161 	var pCheck uintptr
  82162 	var jmp7 int32
  82163 	var jmp6 int32
  82164 	var iCol1 int32
  82165 	var uniqOk int32
  82166 	var jmp61 int32
  82167 	var jmp21 int32
  82168 
  82169 	var jmp4 int32
  82170 	var jmp5 int32
  82171 	var label6 int32
  82172 	var kk int32
  82173 	var ckUniq int32
  82174 	var pTab9 uintptr
  82175 	var pIdx5 uintptr
  82176 	var pPk1 uintptr
  82177 	var pPrior uintptr
  82178 	var loopTop int32
  82179 
  82180 	var r1 int32
  82181 	var bStrict int32
  82182 	var r2 int32
  82183 	var mxCol int32
  82184 	var x2 uintptr
  82185 	var pTbls uintptr
  82186 	var aRoot uintptr
  82187 	var cnt int32
  82188 	var mxIdx int32
  82189 	var aOp2 uintptr
  82190 	var i9 int32
  82191 	var j4 int32
  82192 	var addr1 int32
  82193 
  82194 	var pObjTab uintptr
  82195 
  82196 	var isQuick int32
  82197 	var enc U8
  82198 	var pEnc uintptr
  82199 	var aOp3 uintptr
  82200 	var aOp4 uintptr
  82201 	var iCookie int32
  82202 	var i10 int32
  82203 	var zOpt uintptr
  82204 	var iBt int32
  82205 	var eMode2 int32
  82206 	var r11 int32
  82207 	var iDbLast int32
  82208 	var iTabCur int32
  82209 	var k4 uintptr
  82210 	var pSchema uintptr
  82211 	var pTab10 uintptr
  82212 	var pIdx6 uintptr
  82213 	var szThreshold LogEst
  82214 	var zSubSql uintptr
  82215 	var opMask U32
  82216 
  82217 	var iPrior Sqlite3_int64
  82218 
  82219 	zLeft = uintptr(0)
  82220 	zRight = uintptr(0)
  82221 	zDb = uintptr(0)
  82222 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  82223 	v = Xsqlite3GetVdbe(tls, pParse)
  82224 
  82225 	if !(v == uintptr(0)) {
  82226 		goto __1
  82227 	}
  82228 	return
  82229 __1:
  82230 	;
  82231 	Xsqlite3VdbeRunOnlyOnce(tls, v)
  82232 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 2
  82233 
  82234 	iDb = Xsqlite3TwoPartName(tls, pParse, pId1, pId2, bp+480)
  82235 	if !(iDb < 0) {
  82236 		goto __2
  82237 	}
  82238 	return
  82239 __2:
  82240 	;
  82241 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  82242 
  82243 	if !(iDb == 1 && Xsqlite3OpenTempDatabase(tls, pParse) != 0) {
  82244 		goto __3
  82245 	}
  82246 	return
  82247 __3:
  82248 	;
  82249 	zLeft = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp + 480)))
  82250 	if !!(zLeft != 0) {
  82251 		goto __4
  82252 	}
  82253 	return
  82254 __4:
  82255 	;
  82256 	if !(minusFlag != 0) {
  82257 		goto __5
  82258 	}
  82259 	zRight = Xsqlite3MPrintf(tls, db, ts+17543, libc.VaList(bp, pValue))
  82260 	goto __6
  82261 __5:
  82262 	zRight = Xsqlite3NameFromToken(tls, db, pValue)
  82263 __6:
  82264 	;
  82265 	if (*Token)(unsafe.Pointer(pId2)).Fn > uint32(0) {
  82266 		zDb = (*Db)(unsafe.Pointer(pDb)).FzDbSName
  82267 	} else {
  82268 		zDb = uintptr(0)
  82269 	}
  82270 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) != 0) {
  82271 		goto __7
  82272 	}
  82273 	goto pragma_out
  82274 __7:
  82275 	;
  82276 	*(*uintptr)(unsafe.Pointer(bp + 484)) = uintptr(0)
  82277 	*(*uintptr)(unsafe.Pointer(bp + 484 + 1*4)) = zLeft
  82278 	*(*uintptr)(unsafe.Pointer(bp + 484 + 2*4)) = zRight
  82279 	*(*uintptr)(unsafe.Pointer(bp + 484 + 3*4)) = uintptr(0)
  82280 	(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
  82281 	rc = Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_PRAGMA, bp+484)
  82282 	if !(rc == SQLITE_OK) {
  82283 		goto __8
  82284 	}
  82285 	Xsqlite3VdbeSetNumCols(tls, v, 1)
  82286 	Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, *(*uintptr)(unsafe.Pointer(bp + 484)), libc.UintptrFromInt32(-1))
  82287 	returnSingleText(tls, v, *(*uintptr)(unsafe.Pointer(bp + 484)))
  82288 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 484)))
  82289 	goto pragma_out
  82290 __8:
  82291 	;
  82292 	if !(rc != SQLITE_NOTFOUND) {
  82293 		goto __9
  82294 	}
  82295 	if !(*(*uintptr)(unsafe.Pointer(bp + 484)) != 0) {
  82296 		goto __10
  82297 	}
  82298 	Xsqlite3ErrorMsg(tls, pParse, ts+3663, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 484))))
  82299 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 484)))
  82300 __10:
  82301 	;
  82302 	(*Parse)(unsafe.Pointer(pParse)).FnErr++
  82303 	(*Parse)(unsafe.Pointer(pParse)).Frc = rc
  82304 	goto pragma_out
  82305 __9:
  82306 	;
  82307 	pPragma = pragmaLocate(tls, zLeft)
  82308 	if !(pPragma == uintptr(0)) {
  82309 		goto __11
  82310 	}
  82311 
  82312 	goto pragma_out
  82313 __11:
  82314 	;
  82315 	if !(int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&PragFlg_NeedSchema != 0) {
  82316 		goto __12
  82317 	}
  82318 	if !(Xsqlite3ReadSchema(tls, pParse) != 0) {
  82319 		goto __13
  82320 	}
  82321 	goto pragma_out
  82322 __13:
  82323 	;
  82324 __12:
  82325 	;
  82326 	if !(int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&PragFlg_NoColumns == 0 &&
  82327 		(int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&PragFlg_NoColumns1 == 0 || zRight == uintptr(0))) {
  82328 		goto __14
  82329 	}
  82330 	setPragmaResultColumnNames(tls, v, pPragma)
  82331 __14:
  82332 	;
  82333 	switch int32((*PragmaName)(unsafe.Pointer(pPragma)).FePragTyp) {
  82334 	case PragTyp_DEFAULT_CACHE_SIZE:
  82335 		goto __16
  82336 
  82337 	case PragTyp_PAGE_SIZE:
  82338 		goto __17
  82339 
  82340 	case PragTyp_SECURE_DELETE:
  82341 		goto __18
  82342 
  82343 	case PragTyp_PAGE_COUNT:
  82344 		goto __19
  82345 
  82346 	case PragTyp_LOCKING_MODE:
  82347 		goto __20
  82348 
  82349 	case PragTyp_JOURNAL_MODE:
  82350 		goto __21
  82351 
  82352 	case PragTyp_JOURNAL_SIZE_LIMIT:
  82353 		goto __22
  82354 
  82355 	case PragTyp_AUTO_VACUUM:
  82356 		goto __23
  82357 
  82358 	case PragTyp_INCREMENTAL_VACUUM:
  82359 		goto __24
  82360 
  82361 	case PragTyp_CACHE_SIZE:
  82362 		goto __25
  82363 
  82364 	case PragTyp_CACHE_SPILL:
  82365 		goto __26
  82366 
  82367 	case PragTyp_MMAP_SIZE:
  82368 		goto __27
  82369 
  82370 	case PragTyp_TEMP_STORE:
  82371 		goto __28
  82372 
  82373 	case PragTyp_TEMP_STORE_DIRECTORY:
  82374 		goto __29
  82375 
  82376 	case PragTyp_SYNCHRONOUS:
  82377 		goto __30
  82378 
  82379 	case PragTyp_FLAG:
  82380 		goto __31
  82381 
  82382 	case PragTyp_TABLE_INFO:
  82383 		goto __32
  82384 
  82385 	case PragTyp_TABLE_LIST:
  82386 		goto __33
  82387 
  82388 	case PragTyp_INDEX_INFO:
  82389 		goto __34
  82390 
  82391 	case PragTyp_INDEX_LIST:
  82392 		goto __35
  82393 
  82394 	case PragTyp_DATABASE_LIST:
  82395 		goto __36
  82396 
  82397 	case PragTyp_COLLATION_LIST:
  82398 		goto __37
  82399 
  82400 	case PragTyp_FUNCTION_LIST:
  82401 		goto __38
  82402 
  82403 	case PragTyp_MODULE_LIST:
  82404 		goto __39
  82405 
  82406 	case PragTyp_PRAGMA_LIST:
  82407 		goto __40
  82408 
  82409 	case PragTyp_FOREIGN_KEY_LIST:
  82410 		goto __41
  82411 
  82412 	case PragTyp_FOREIGN_KEY_CHECK:
  82413 		goto __42
  82414 
  82415 	case PragTyp_CASE_SENSITIVE_LIKE:
  82416 		goto __43
  82417 
  82418 	case PragTyp_INTEGRITY_CHECK:
  82419 		goto __44
  82420 
  82421 	case PragTyp_ENCODING:
  82422 		goto __45
  82423 
  82424 	case PragTyp_HEADER_VALUE:
  82425 		goto __46
  82426 
  82427 	case PragTyp_COMPILE_OPTIONS:
  82428 		goto __47
  82429 
  82430 	case PragTyp_WAL_CHECKPOINT:
  82431 		goto __48
  82432 
  82433 	case PragTyp_WAL_AUTOCHECKPOINT:
  82434 		goto __49
  82435 
  82436 	case PragTyp_SHRINK_MEMORY:
  82437 		goto __50
  82438 
  82439 	case PragTyp_OPTIMIZE:
  82440 		goto __51
  82441 
  82442 	default:
  82443 		goto __52
  82444 
  82445 	case PragTyp_SOFT_HEAP_LIMIT:
  82446 		goto __53
  82447 
  82448 	case PragTyp_HARD_HEAP_LIMIT:
  82449 		goto __54
  82450 
  82451 	case PragTyp_THREADS:
  82452 		goto __55
  82453 
  82454 	case PragTyp_ANALYSIS_LIMIT:
  82455 		goto __56
  82456 	}
  82457 	goto __15
  82458 
  82459 __16:
  82460 	Xsqlite3VdbeUsesBtree(tls, v, iDb)
  82461 	if !!(zRight != 0) {
  82462 		goto __57
  82463 	}
  82464 	*(*int32)(unsafe.Pointer(pParse + 44)) += 2
  82465 
  82466 	aOp = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(getCacheSize))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&getCacheSize)), iLn3)
  82467 	if !(0 != 0) {
  82468 		goto __59
  82469 	}
  82470 	goto __15
  82471 __59:
  82472 	;
  82473 	(*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = iDb
  82474 	(*VdbeOp)(unsafe.Pointer(aOp + 1*20)).Fp1 = iDb
  82475 	(*VdbeOp)(unsafe.Pointer(aOp + 6*20)).Fp1 = -2000
  82476 	goto __58
  82477 __57:
  82478 	size = Xsqlite3AbsInt32(tls, Xsqlite3Atoi(tls, zRight))
  82479 	Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  82480 	Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, size)
  82481 
  82482 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size
  82483 	Xsqlite3BtreeSetCacheSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)
  82484 __58:
  82485 	;
  82486 	goto __15
  82487 
  82488 __17:
  82489 	pBt = (*Db)(unsafe.Pointer(pDb)).FpBt
  82490 
  82491 	if !!(zRight != 0) {
  82492 		goto __60
  82493 	}
  82494 	if pBt != 0 {
  82495 		size1 = Xsqlite3BtreeGetPageSize(tls, pBt)
  82496 	} else {
  82497 		size1 = 0
  82498 	}
  82499 	returnSingleInt(tls, v, int64(size1))
  82500 	goto __61
  82501 __60:
  82502 	(*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = Xsqlite3Atoi(tls, zRight)
  82503 	if !(SQLITE_NOMEM == Xsqlite3BtreeSetPageSize(tls, pBt, (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0)) {
  82504 		goto __62
  82505 	}
  82506 	Xsqlite3OomFault(tls, db)
  82507 __62:
  82508 	;
  82509 __61:
  82510 	;
  82511 	goto __15
  82512 
  82513 __18:
  82514 	pBt1 = (*Db)(unsafe.Pointer(pDb)).FpBt
  82515 	b = -1
  82516 
  82517 	if !(zRight != 0) {
  82518 		goto __63
  82519 	}
  82520 	if !(Xsqlite3_stricmp(tls, zRight, ts+17547) == 0) {
  82521 		goto __64
  82522 	}
  82523 	b = 2
  82524 	goto __65
  82525 __64:
  82526 	b = int32(Xsqlite3GetBoolean(tls, zRight, uint8(0)))
  82527 __65:
  82528 	;
  82529 __63:
  82530 	;
  82531 	if !((*Token)(unsafe.Pointer(pId2)).Fn == uint32(0) && b >= 0) {
  82532 		goto __66
  82533 	}
  82534 	ii = 0
  82535 __67:
  82536 	if !(ii < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  82537 		goto __69
  82538 	}
  82539 	Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*16)).FpBt, b)
  82540 	goto __68
  82541 __68:
  82542 	ii++
  82543 	goto __67
  82544 	goto __69
  82545 __69:
  82546 	;
  82547 __66:
  82548 	;
  82549 	b = Xsqlite3BtreeSecureDelete(tls, pBt1, b)
  82550 	returnSingleInt(tls, v, int64(b))
  82551 	goto __15
  82552 
  82553 __19:
  82554 	*(*I64)(unsafe.Pointer(bp + 504)) = int64(0)
  82555 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  82556 	iReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  82557 	if !(int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(zLeft))]) == 'p') {
  82558 		goto __70
  82559 	}
  82560 	Xsqlite3VdbeAddOp2(tls, v, OP_Pagecount, iDb, iReg)
  82561 	goto __71
  82562 __70:
  82563 	if !(zRight != 0 && Xsqlite3DecOrHexToI64(tls, zRight, bp+504) == 0) {
  82564 		goto __72
  82565 	}
  82566 	if !(*(*I64)(unsafe.Pointer(bp + 504)) < int64(0)) {
  82567 		goto __74
  82568 	}
  82569 	*(*I64)(unsafe.Pointer(bp + 504)) = int64(0)
  82570 	goto __75
  82571 __74:
  82572 	if !(*(*I64)(unsafe.Pointer(bp + 504)) > int64(0xfffffffe)) {
  82573 		goto __76
  82574 	}
  82575 	*(*I64)(unsafe.Pointer(bp + 504)) = int64(0xfffffffe)
  82576 __76:
  82577 	;
  82578 __75:
  82579 	;
  82580 	goto __73
  82581 __72:
  82582 	*(*I64)(unsafe.Pointer(bp + 504)) = int64(0)
  82583 __73:
  82584 	;
  82585 	Xsqlite3VdbeAddOp3(tls, v, OP_MaxPgcnt, iDb, iReg, int32(*(*I64)(unsafe.Pointer(bp + 504))))
  82586 __71:
  82587 	;
  82588 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, iReg, 1)
  82589 	goto __15
  82590 
  82591 __20:
  82592 	zRet = ts + 17338
  82593 	eMode = getLockingMode(tls, zRight)
  82594 
  82595 	if !((*Token)(unsafe.Pointer(pId2)).Fn == uint32(0) && eMode == -1) {
  82596 		goto __77
  82597 	}
  82598 
  82599 	eMode = int32((*Sqlite3)(unsafe.Pointer(db)).FdfltLockMode)
  82600 	goto __78
  82601 __77:
  82602 	if !((*Token)(unsafe.Pointer(pId2)).Fn == uint32(0)) {
  82603 		goto __79
  82604 	}
  82605 
  82606 	ii1 = 2
  82607 __80:
  82608 	if !(ii1 < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  82609 		goto __82
  82610 	}
  82611 	pPager = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii1)*16)).FpBt)
  82612 	Xsqlite3PagerLockingMode(tls, pPager, eMode)
  82613 	goto __81
  82614 __81:
  82615 	ii1++
  82616 	goto __80
  82617 	goto __82
  82618 __82:
  82619 	;
  82620 	(*Sqlite3)(unsafe.Pointer(db)).FdfltLockMode = U8(eMode)
  82621 __79:
  82622 	;
  82623 	pPager = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  82624 	eMode = Xsqlite3PagerLockingMode(tls, pPager, eMode)
  82625 __78:
  82626 	;
  82627 	if !(eMode == PAGER_LOCKINGMODE_EXCLUSIVE) {
  82628 		goto __83
  82629 	}
  82630 	zRet = ts + 17328
  82631 __83:
  82632 	;
  82633 	returnSingleText(tls, v, zRet)
  82634 	goto __15
  82635 
  82636 __21:
  82637 	if !(zRight == uintptr(0)) {
  82638 		goto __84
  82639 	}
  82640 
  82641 	eMode1 = -1
  82642 	goto __85
  82643 __84:
  82644 	n = Xsqlite3Strlen30(tls, zRight)
  82645 	eMode1 = 0
  82646 __86:
  82647 	if !(libc.AssignUintptr(&zMode, Xsqlite3JournalModename(tls, eMode1)) != uintptr(0)) {
  82648 		goto __88
  82649 	}
  82650 	if !(Xsqlite3_strnicmp(tls, zRight, zMode, n) == 0) {
  82651 		goto __89
  82652 	}
  82653 	goto __88
  82654 __89:
  82655 	;
  82656 	goto __87
  82657 __87:
  82658 	eMode1++
  82659 	goto __86
  82660 	goto __88
  82661 __88:
  82662 	;
  82663 	if !!(zMode != 0) {
  82664 		goto __90
  82665 	}
  82666 
  82667 	eMode1 = -1
  82668 __90:
  82669 	;
  82670 	if !(eMode1 == PAGER_JOURNALMODE_OFF && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0)) {
  82671 		goto __91
  82672 	}
  82673 
  82674 	eMode1 = -1
  82675 __91:
  82676 	;
  82677 __85:
  82678 	;
  82679 	if !(eMode1 == -1 && (*Token)(unsafe.Pointer(pId2)).Fn == uint32(0)) {
  82680 		goto __92
  82681 	}
  82682 
  82683 	iDb = 0
  82684 	(*Token)(unsafe.Pointer(pId2)).Fn = uint32(1)
  82685 __92:
  82686 	;
  82687 	ii2 = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
  82688 __93:
  82689 	if !(ii2 >= 0) {
  82690 		goto __95
  82691 	}
  82692 	if !((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii2)*16)).FpBt != 0 && (ii2 == iDb || (*Token)(unsafe.Pointer(pId2)).Fn == uint32(0))) {
  82693 		goto __96
  82694 	}
  82695 	Xsqlite3VdbeUsesBtree(tls, v, ii2)
  82696 	Xsqlite3VdbeAddOp3(tls, v, OP_JournalMode, ii2, 1, eMode1)
  82697 __96:
  82698 	;
  82699 	goto __94
  82700 __94:
  82701 	ii2--
  82702 	goto __93
  82703 	goto __95
  82704 __95:
  82705 	;
  82706 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1)
  82707 	goto __15
  82708 
  82709 __22:
  82710 	pPager1 = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  82711 	*(*I64)(unsafe.Pointer(bp + 512)) = int64(-2)
  82712 	if !(zRight != 0) {
  82713 		goto __97
  82714 	}
  82715 	Xsqlite3DecOrHexToI64(tls, zRight, bp+512)
  82716 	if !(*(*I64)(unsafe.Pointer(bp + 512)) < int64(-1)) {
  82717 		goto __98
  82718 	}
  82719 	*(*I64)(unsafe.Pointer(bp + 512)) = int64(-1)
  82720 __98:
  82721 	;
  82722 __97:
  82723 	;
  82724 	*(*I64)(unsafe.Pointer(bp + 512)) = Xsqlite3PagerJournalSizeLimit(tls, pPager1, *(*I64)(unsafe.Pointer(bp + 512)))
  82725 	returnSingleInt(tls, v, *(*I64)(unsafe.Pointer(bp + 512)))
  82726 	goto __15
  82727 
  82728 __23:
  82729 	pBt2 = (*Db)(unsafe.Pointer(pDb)).FpBt
  82730 
  82731 	if !!(zRight != 0) {
  82732 		goto __99
  82733 	}
  82734 	returnSingleInt(tls, v, int64(Xsqlite3BtreeGetAutoVacuum(tls, pBt2)))
  82735 	goto __100
  82736 __99:
  82737 	eAuto = getAutoVacuum(tls, zRight)
  82738 
  82739 	(*Sqlite3)(unsafe.Pointer(db)).FnextAutovac = int8(U8(eAuto))
  82740 
  82741 	rc = Xsqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto)
  82742 	if !(rc == SQLITE_OK && (eAuto == 1 || eAuto == 2)) {
  82743 		goto __101
  82744 	}
  82745 	iAddr = Xsqlite3VdbeCurrentAddr(tls, v)
  82746 
  82747 	aOp1 = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(setMeta6))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&setMeta6)), iLn4)
  82748 	if !(0 != 0) {
  82749 		goto __102
  82750 	}
  82751 	goto __15
  82752 __102:
  82753 	;
  82754 	(*VdbeOp)(unsafe.Pointer(aOp1)).Fp1 = iDb
  82755 	(*VdbeOp)(unsafe.Pointer(aOp1 + 1*20)).Fp1 = iDb
  82756 	(*VdbeOp)(unsafe.Pointer(aOp1 + 2*20)).Fp2 = iAddr + 4
  82757 	(*VdbeOp)(unsafe.Pointer(aOp1 + 4*20)).Fp1 = iDb
  82758 	(*VdbeOp)(unsafe.Pointer(aOp1 + 4*20)).Fp3 = eAuto - 1
  82759 	Xsqlite3VdbeUsesBtree(tls, v, iDb)
  82760 __101:
  82761 	;
  82762 __100:
  82763 	;
  82764 	goto __15
  82765 
  82766 __24:
  82767 	*(*int32)(unsafe.Pointer(bp + 520)) = 0
  82768 	if !(zRight == uintptr(0) || !(Xsqlite3GetInt32(tls, zRight, bp+520) != 0) || *(*int32)(unsafe.Pointer(bp + 520)) <= 0) {
  82769 		goto __103
  82770 	}
  82771 	*(*int32)(unsafe.Pointer(bp + 520)) = 0x7fffffff
  82772 __103:
  82773 	;
  82774 	Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  82775 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp + 520)), 1)
  82776 	addr = Xsqlite3VdbeAddOp1(tls, v, OP_IncrVacuum, iDb)
  82777 	Xsqlite3VdbeAddOp1(tls, v, OP_ResultRow, 1)
  82778 	Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 1, -1)
  82779 	Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, 1, addr)
  82780 	Xsqlite3VdbeJumpHere(tls, v, addr)
  82781 	goto __15
  82782 
  82783 __25:
  82784 	;
  82785 	if !!(zRight != 0) {
  82786 		goto __104
  82787 	}
  82788 	returnSingleInt(tls, v, int64((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size))
  82789 	goto __105
  82790 __104:
  82791 	size2 = Xsqlite3Atoi(tls, zRight)
  82792 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size2
  82793 	Xsqlite3BtreeSetCacheSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)
  82794 __105:
  82795 	;
  82796 	goto __15
  82797 
  82798 __26:
  82799 	;
  82800 	if !!(zRight != 0) {
  82801 		goto __106
  82802 	}
  82803 	returnSingleInt(tls, v,
  82804 		func() int64 {
  82805 			if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_CacheSpill) == uint64(0) {
  82806 				return int64(0)
  82807 			}
  82808 			return int64(Xsqlite3BtreeSetSpillSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, 0))
  82809 		}())
  82810 	goto __107
  82811 __106:
  82812 	*(*int32)(unsafe.Pointer(bp + 524)) = 1
  82813 	if !(Xsqlite3GetInt32(tls, zRight, bp+524) != 0) {
  82814 		goto __108
  82815 	}
  82816 	Xsqlite3BtreeSetSpillSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, *(*int32)(unsafe.Pointer(bp + 524)))
  82817 __108:
  82818 	;
  82819 	if !(Xsqlite3GetBoolean(tls, zRight, uint8(libc.Bool32(*(*int32)(unsafe.Pointer(bp + 524)) != 0))) != 0) {
  82820 		goto __109
  82821 	}
  82822 	*(*U64)(unsafe.Pointer(db + 32)) |= uint64(SQLITE_CacheSpill)
  82823 	goto __110
  82824 __109:
  82825 	*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_CacheSpill))
  82826 __110:
  82827 	;
  82828 	setAllPagerFlags(tls, db)
  82829 __107:
  82830 	;
  82831 	goto __15
  82832 
  82833 __27:
  82834 	;
  82835 	if !(zRight != 0) {
  82836 		goto __111
  82837 	}
  82838 	Xsqlite3DecOrHexToI64(tls, zRight, bp+528)
  82839 	if !(*(*Sqlite3_int64)(unsafe.Pointer(bp + 528)) < int64(0)) {
  82840 		goto __112
  82841 	}
  82842 	*(*Sqlite3_int64)(unsafe.Pointer(bp + 528)) = Xsqlite3Config.FszMmap
  82843 __112:
  82844 	;
  82845 	if !((*Token)(unsafe.Pointer(pId2)).Fn == uint32(0)) {
  82846 		goto __113
  82847 	}
  82848 	(*Sqlite3)(unsafe.Pointer(db)).FszMmap = *(*Sqlite3_int64)(unsafe.Pointer(bp + 528))
  82849 __113:
  82850 	;
  82851 	ii3 = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
  82852 __114:
  82853 	if !(ii3 >= 0) {
  82854 		goto __116
  82855 	}
  82856 	if !((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii3)*16)).FpBt != 0 && (ii3 == iDb || (*Token)(unsafe.Pointer(pId2)).Fn == uint32(0))) {
  82857 		goto __117
  82858 	}
  82859 	Xsqlite3BtreeSetMmapLimit(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii3)*16)).FpBt, *(*Sqlite3_int64)(unsafe.Pointer(bp + 528)))
  82860 __117:
  82861 	;
  82862 	goto __115
  82863 __115:
  82864 	ii3--
  82865 	goto __114
  82866 	goto __116
  82867 __116:
  82868 	;
  82869 __111:
  82870 	;
  82871 	*(*Sqlite3_int64)(unsafe.Pointer(bp + 528)) = int64(-1)
  82872 	rc = Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_MMAP_SIZE, bp+528)
  82873 	if !(rc == SQLITE_OK) {
  82874 		goto __118
  82875 	}
  82876 	returnSingleInt(tls, v, *(*Sqlite3_int64)(unsafe.Pointer(bp + 528)))
  82877 	goto __119
  82878 __118:
  82879 	if !(rc != SQLITE_NOTFOUND) {
  82880 		goto __120
  82881 	}
  82882 	(*Parse)(unsafe.Pointer(pParse)).FnErr++
  82883 	(*Parse)(unsafe.Pointer(pParse)).Frc = rc
  82884 __120:
  82885 	;
  82886 __119:
  82887 	;
  82888 	goto __15
  82889 
  82890 __28:
  82891 	if !!(zRight != 0) {
  82892 		goto __121
  82893 	}
  82894 	returnSingleInt(tls, v, int64((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store))
  82895 	goto __122
  82896 __121:
  82897 	changeTempStorage(tls, pParse, zRight)
  82898 __122:
  82899 	;
  82900 	goto __15
  82901 
  82902 __29:
  82903 	Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1))
  82904 	if !!(zRight != 0) {
  82905 		goto __123
  82906 	}
  82907 	returnSingleText(tls, v, Xsqlite3_temp_directory)
  82908 	goto __124
  82909 __123:
  82910 	if !(*(*uint8)(unsafe.Pointer(zRight)) != 0) {
  82911 		goto __125
  82912 	}
  82913 	rc = Xsqlite3OsAccess(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, zRight, SQLITE_ACCESS_READWRITE, bp+536)
  82914 	if !(rc != SQLITE_OK || *(*int32)(unsafe.Pointer(bp + 536)) == 0) {
  82915 		goto __126
  82916 	}
  82917 	Xsqlite3ErrorMsg(tls, pParse, ts+17552, 0)
  82918 	Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1))
  82919 	goto pragma_out
  82920 __126:
  82921 	;
  82922 __125:
  82923 	;
  82924 	if !(SQLITE_TEMP_STORE == 0 ||
  82925 		SQLITE_TEMP_STORE == 1 && int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) <= 1 ||
  82926 		SQLITE_TEMP_STORE == 2 && int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == 1) {
  82927 		goto __127
  82928 	}
  82929 	invalidateTempStorage(tls, pParse)
  82930 __127:
  82931 	;
  82932 	Xsqlite3_free(tls, Xsqlite3_temp_directory)
  82933 	if !(*(*uint8)(unsafe.Pointer(zRight)) != 0) {
  82934 		goto __128
  82935 	}
  82936 	Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+16, zRight))
  82937 	goto __129
  82938 __128:
  82939 	Xsqlite3_temp_directory = uintptr(0)
  82940 __129:
  82941 	;
  82942 __124:
  82943 	;
  82944 	Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1))
  82945 	goto __15
  82946 
  82947 __30:
  82948 	if !!(zRight != 0) {
  82949 		goto __130
  82950 	}
  82951 	returnSingleInt(tls, v, int64(int32((*Db)(unsafe.Pointer(pDb)).Fsafety_level)-1))
  82952 	goto __131
  82953 __130:
  82954 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) {
  82955 		goto __132
  82956 	}
  82957 	Xsqlite3ErrorMsg(tls, pParse,
  82958 		ts+17577, 0)
  82959 	goto __133
  82960 __132:
  82961 	if !(iDb != 1) {
  82962 		goto __134
  82963 	}
  82964 	iLevel = (int32(getSafetyLevel(tls, zRight, 0, uint8(1))) + 1) & PAGER_SYNCHRONOUS_MASK
  82965 	if !(iLevel == 0) {
  82966 		goto __135
  82967 	}
  82968 	iLevel = 1
  82969 __135:
  82970 	;
  82971 	(*Db)(unsafe.Pointer(pDb)).Fsafety_level = U8(iLevel)
  82972 	(*Db)(unsafe.Pointer(pDb)).FbSyncSet = U8(1)
  82973 	setAllPagerFlags(tls, db)
  82974 __134:
  82975 	;
  82976 __133:
  82977 	;
  82978 __131:
  82979 	;
  82980 	goto __15
  82981 
  82982 __31:
  82983 	if !(zRight == uintptr(0)) {
  82984 		goto __136
  82985 	}
  82986 	setPragmaResultColumnNames(tls, v, pPragma)
  82987 	returnSingleInt(tls, v, int64(libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&(*PragmaName)(unsafe.Pointer(pPragma)).FiArg != uint64(0))))
  82988 	goto __137
  82989 __136:
  82990 	mask = (*PragmaName)(unsafe.Pointer(pPragma)).FiArg
  82991 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0) {
  82992 		goto __138
  82993 	}
  82994 
  82995 	mask = mask & libc.Uint64FromInt32(libc.CplInt32(SQLITE_ForeignKeys))
  82996 __138:
  82997 	;
  82998 	if !(Xsqlite3GetBoolean(tls, zRight, uint8(0)) != 0) {
  82999 		goto __139
  83000 	}
  83001 	*(*U64)(unsafe.Pointer(db + 32)) |= mask
  83002 	goto __140
  83003 __139:
  83004 	*(*U64)(unsafe.Pointer(db + 32)) &= ^mask
  83005 	if !(mask == uint64(SQLITE_DeferFKs)) {
  83006 		goto __141
  83007 	}
  83008 	(*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0)
  83009 __141:
  83010 	;
  83011 	if !(mask&uint64(SQLITE_WriteSchema) != uint64(0) &&
  83012 		Xsqlite3_stricmp(tls, zRight, ts+17630) == 0) {
  83013 		goto __142
  83014 	}
  83015 
  83016 	Xsqlite3ResetAllSchemasOfConnection(tls, db)
  83017 __142:
  83018 	;
  83019 __140:
  83020 	;
  83021 	Xsqlite3VdbeAddOp0(tls, v, OP_Expire)
  83022 	setAllPagerFlags(tls, db)
  83023 __137:
  83024 	;
  83025 	goto __15
  83026 
  83027 __32:
  83028 	if !(zRight != 0) {
  83029 		goto __143
  83030 	}
  83031 	Xsqlite3CodeVerifyNamedSchema(tls, pParse, zDb)
  83032 	pTab = Xsqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb)
  83033 	if !(pTab != 0) {
  83034 		goto __144
  83035 	}
  83036 	nHidden = 0
  83037 	pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  83038 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 7
  83039 	Xsqlite3ViewGetColumnNames(tls, pParse, pTab)
  83040 	i = 0
  83041 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  83042 __145:
  83043 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  83044 		goto __147
  83045 	}
  83046 	isHidden = 0
  83047 	if !(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_NOINSERT != 0) {
  83048 		goto __148
  83049 	}
  83050 	if !((*PragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0)) {
  83051 		goto __149
  83052 	}
  83053 	nHidden++
  83054 	goto __146
  83055 __149:
  83056 	;
  83057 	if !(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_VIRTUAL != 0) {
  83058 		goto __150
  83059 	}
  83060 	isHidden = 2
  83061 	goto __151
  83062 __150:
  83063 	if !(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_STORED != 0) {
  83064 		goto __152
  83065 	}
  83066 	isHidden = 3
  83067 	goto __153
  83068 __152:
  83069 	;
  83070 	isHidden = 1
  83071 __153:
  83072 	;
  83073 __151:
  83074 	;
  83075 __148:
  83076 	;
  83077 	if !(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_PRIMKEY == 0) {
  83078 		goto __154
  83079 	}
  83080 	k = 0
  83081 	goto __155
  83082 __154:
  83083 	if !(pPk == uintptr(0)) {
  83084 		goto __156
  83085 	}
  83086 	k = 1
  83087 	goto __157
  83088 __156:
  83089 	k = 1
  83090 __158:
  83091 	if !(k <= int32((*Table)(unsafe.Pointer(pTab)).FnCol) && int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(k-1)*2))) != i) {
  83092 		goto __160
  83093 	}
  83094 	goto __159
  83095 __159:
  83096 	k++
  83097 	goto __158
  83098 	goto __160
  83099 __160:
  83100 	;
  83101 __157:
  83102 	;
  83103 __155:
  83104 	;
  83105 	pColExpr = Xsqlite3ColumnExpr(tls, pTab, pCol)
  83106 
  83107 	Xsqlite3VdbeMultiLoad(tls, v, 1, func() uintptr {
  83108 		if (*PragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 {
  83109 			return ts + 17636
  83110 		}
  83111 		return ts + 17644
  83112 	}(),
  83113 		libc.VaList(bp+24, i-nHidden,
  83114 			(*Column)(unsafe.Pointer(pCol)).FzCnName,
  83115 			Xsqlite3ColumnType(tls, pCol, ts+1554),
  83116 			func() int32 {
  83117 				if uint32(int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf>>0)) != 0 {
  83118 					return 1
  83119 				}
  83120 				return 0
  83121 			}(),
  83122 			func() uintptr {
  83123 				if isHidden >= 2 || pColExpr == uintptr(0) {
  83124 					return uintptr(0)
  83125 				}
  83126 				return *(*uintptr)(unsafe.Pointer(pColExpr + 8))
  83127 			}(),
  83128 			k,
  83129 			isHidden))
  83130 	goto __146
  83131 __146:
  83132 	i++
  83133 	pCol += 16
  83134 	goto __145
  83135 	goto __147
  83136 __147:
  83137 	;
  83138 __144:
  83139 	;
  83140 __143:
  83141 	;
  83142 	goto __15
  83143 
  83144 __33:
  83145 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 6
  83146 	Xsqlite3CodeVerifyNamedSchema(tls, pParse, zDb)
  83147 	ii4 = 0
  83148 __161:
  83149 	if !(ii4 < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  83150 		goto __163
  83151 	}
  83152 	if !(zDb != 0 && Xsqlite3_stricmp(tls, zDb, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii4)*16)).FzDbSName) != 0) {
  83153 		goto __164
  83154 	}
  83155 	goto __162
  83156 __164:
  83157 	;
  83158 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii4)*16)).FpSchema + 8
  83159 	initNCol = int32((*Hash)(unsafe.Pointer(pHash)).Fcount)
  83160 __165:
  83161 	if !(libc.PostDecInt32(&initNCol, 1) != 0) {
  83162 		goto __166
  83163 	}
  83164 	k1 = (*Hash)(unsafe.Pointer(pHash)).Ffirst
  83165 __167:
  83166 	if !(1 != 0) {
  83167 		goto __169
  83168 	}
  83169 	if !(k1 == uintptr(0)) {
  83170 		goto __170
  83171 	}
  83172 	initNCol = 0
  83173 	goto __169
  83174 __170:
  83175 	;
  83176 	pTab1 = (*HashElem)(unsafe.Pointer(k1)).Fdata
  83177 	if !(int32((*Table)(unsafe.Pointer(pTab1)).FnCol) == 0) {
  83178 		goto __171
  83179 	}
  83180 	zSql = Xsqlite3MPrintf(tls, db, ts+17651, libc.VaList(bp+80, (*Table)(unsafe.Pointer(pTab1)).FzName))
  83181 	if !(zSql != 0) {
  83182 		goto __172
  83183 	}
  83184 	*(*uintptr)(unsafe.Pointer(bp + 540)) = uintptr(0)
  83185 	Xsqlite3_prepare(tls, db, zSql, -1, bp+540, uintptr(0))
  83186 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 540)))
  83187 	Xsqlite3DbFree(tls, db, zSql)
  83188 __172:
  83189 	;
  83190 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  83191 		goto __173
  83192 	}
  83193 	Xsqlite3ErrorMsg(tls, (*Sqlite3)(unsafe.Pointer(db)).FpParse, ts+1490, 0)
  83194 	(*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).Frc = SQLITE_NOMEM
  83195 __173:
  83196 	;
  83197 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii4)*16)).FpSchema + 8
  83198 	goto __169
  83199 __171:
  83200 	;
  83201 	goto __168
  83202 __168:
  83203 	k1 = (*HashElem)(unsafe.Pointer(k1)).Fnext
  83204 	goto __167
  83205 	goto __169
  83206 __169:
  83207 	;
  83208 	goto __165
  83209 __166:
  83210 	;
  83211 	k1 = (*Hash)(unsafe.Pointer(pHash)).Ffirst
  83212 __174:
  83213 	if !(k1 != 0) {
  83214 		goto __176
  83215 	}
  83216 	pTab2 = (*HashElem)(unsafe.Pointer(k1)).Fdata
  83217 	if !(zRight != 0 && Xsqlite3_stricmp(tls, zRight, (*Table)(unsafe.Pointer(pTab2)).FzName) != 0) {
  83218 		goto __177
  83219 	}
  83220 	goto __175
  83221 __177:
  83222 	;
  83223 	if !(int32((*Table)(unsafe.Pointer(pTab2)).FeTabType) == TABTYP_VIEW) {
  83224 		goto __178
  83225 	}
  83226 	zType = ts + 10491
  83227 	goto __179
  83228 __178:
  83229 	if !(int32((*Table)(unsafe.Pointer(pTab2)).FeTabType) == TABTYP_VTAB) {
  83230 		goto __180
  83231 	}
  83232 	zType = ts + 12721
  83233 	goto __181
  83234 __180:
  83235 	if !((*Table)(unsafe.Pointer(pTab2)).FtabFlags&U32(TF_Shadow) != 0) {
  83236 		goto __182
  83237 	}
  83238 	zType = ts + 17667
  83239 	goto __183
  83240 __182:
  83241 	zType = ts + 8876
  83242 __183:
  83243 	;
  83244 __181:
  83245 	;
  83246 __179:
  83247 	;
  83248 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17674,
  83249 		libc.VaList(bp+88, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii4)*16)).FzDbSName,
  83250 			Xsqlite3PreferredTableName(tls, (*Table)(unsafe.Pointer(pTab2)).FzName),
  83251 			zType,
  83252 			int32((*Table)(unsafe.Pointer(pTab2)).FnCol),
  83253 			libc.Bool32((*Table)(unsafe.Pointer(pTab2)).FtabFlags&U32(TF_WithoutRowid) != U32(0)),
  83254 			libc.Bool32((*Table)(unsafe.Pointer(pTab2)).FtabFlags&U32(TF_Strict) != U32(0))))
  83255 	goto __175
  83256 __175:
  83257 	k1 = (*HashElem)(unsafe.Pointer(k1)).Fnext
  83258 	goto __174
  83259 	goto __176
  83260 __176:
  83261 	;
  83262 	goto __162
  83263 __162:
  83264 	ii4++
  83265 	goto __161
  83266 	goto __163
  83267 __163:
  83268 	;
  83269 	goto __15
  83270 
  83271 __34:
  83272 	if !(zRight != 0) {
  83273 		goto __184
  83274 	}
  83275 	pIdx = Xsqlite3FindIndex(tls, db, zRight, zDb)
  83276 	if !(pIdx == uintptr(0)) {
  83277 		goto __185
  83278 	}
  83279 
  83280 	pTab3 = Xsqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb)
  83281 	if !(pTab3 != 0 && !((*Table)(unsafe.Pointer(pTab3)).FtabFlags&U32(TF_WithoutRowid) == U32(0))) {
  83282 		goto __186
  83283 	}
  83284 	pIdx = Xsqlite3PrimaryKeyIndex(tls, pTab3)
  83285 __186:
  83286 	;
  83287 __185:
  83288 	;
  83289 	if !(pIdx != 0) {
  83290 		goto __187
  83291 	}
  83292 	iIdxDb = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIdx)).FpSchema)
  83293 	if !((*PragmaName)(unsafe.Pointer(pPragma)).FiArg != 0) {
  83294 		goto __188
  83295 	}
  83296 
  83297 	mx = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  83298 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 6
  83299 	goto __189
  83300 __188:
  83301 	mx = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  83302 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 3
  83303 __189:
  83304 	;
  83305 	pTab3 = (*Index)(unsafe.Pointer(pIdx)).FpTable
  83306 	Xsqlite3CodeVerifySchema(tls, pParse, iIdxDb)
  83307 
  83308 	i1 = 0
  83309 __190:
  83310 	if !(i1 < mx) {
  83311 		goto __192
  83312 	}
  83313 	cnum = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2))
  83314 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17681, libc.VaList(bp+136, i1, int32(cnum),
  83315 		func() uintptr {
  83316 			if int32(cnum) < 0 {
  83317 				return uintptr(0)
  83318 			}
  83319 			return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab3)).FaCol + uintptr(cnum)*16)).FzCnName
  83320 		}()))
  83321 	if !((*PragmaName)(unsafe.Pointer(pPragma)).FiArg != 0) {
  83322 		goto __193
  83323 	}
  83324 	Xsqlite3VdbeMultiLoad(tls, v, 4, ts+17686,
  83325 		libc.VaList(bp+160, int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i1)))),
  83326 			*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*4)),
  83327 			libc.Bool32(i1 < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol))))
  83328 __193:
  83329 	;
  83330 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, (*Parse)(unsafe.Pointer(pParse)).FnMem)
  83331 	goto __191
  83332 __191:
  83333 	i1++
  83334 	goto __190
  83335 	goto __192
  83336 __192:
  83337 	;
  83338 __187:
  83339 	;
  83340 __184:
  83341 	;
  83342 	goto __15
  83343 
  83344 __35:
  83345 	if !(zRight != 0) {
  83346 		goto __194
  83347 	}
  83348 	pTab4 = Xsqlite3FindTable(tls, db, zRight, zDb)
  83349 	if !(pTab4 != 0) {
  83350 		goto __195
  83351 	}
  83352 	iTabDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab4)).FpSchema)
  83353 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 5
  83354 	Xsqlite3CodeVerifySchema(tls, pParse, iTabDb)
  83355 	pIdx1 = (*Table)(unsafe.Pointer(pTab4)).FpIndex
  83356 	i2 = 0
  83357 __196:
  83358 	if !(pIdx1 != 0) {
  83359 		goto __198
  83360 	}
  83361 	*(*[3]uintptr)(unsafe.Pointer(bp + 544)) = [3]uintptr{ts + 17691, ts + 17693, ts + 16155}
  83362 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17695,
  83363 		libc.VaList(bp+184, i2,
  83364 			(*Index)(unsafe.Pointer(pIdx1)).FzName,
  83365 			libc.Bool32(int32((*Index)(unsafe.Pointer(pIdx1)).FonError) != OE_None),
  83366 			*(*uintptr)(unsafe.Pointer(bp + 544 + uintptr(uint32(int32(*(*uint16)(unsafe.Pointer(pIdx1 + 56))&0x3>>0)))*4)),
  83367 			libc.Bool32((*Index)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0))))
  83368 	goto __197
  83369 __197:
  83370 	pIdx1 = (*Index)(unsafe.Pointer(pIdx1)).FpNext
  83371 	i2++
  83372 	goto __196
  83373 	goto __198
  83374 __198:
  83375 	;
  83376 __195:
  83377 	;
  83378 __194:
  83379 	;
  83380 	goto __15
  83381 
  83382 __36:
  83383 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 3
  83384 	i3 = 0
  83385 __199:
  83386 	if !(i3 < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  83387 		goto __201
  83388 	}
  83389 	if !((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i3)*16)).FpBt == uintptr(0)) {
  83390 		goto __202
  83391 	}
  83392 	goto __200
  83393 __202:
  83394 	;
  83395 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17701,
  83396 		libc.VaList(bp+224, i3,
  83397 			(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i3)*16)).FzDbSName,
  83398 			Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i3)*16)).FpBt)))
  83399 	goto __200
  83400 __200:
  83401 	i3++
  83402 	goto __199
  83403 	goto __201
  83404 __201:
  83405 	;
  83406 	goto __15
  83407 
  83408 __37:
  83409 	i4 = 0
  83410 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 2
  83411 	p = (*Hash)(unsafe.Pointer(db + 448)).Ffirst
  83412 __203:
  83413 	if !(p != 0) {
  83414 		goto __205
  83415 	}
  83416 	pColl = (*HashElem)(unsafe.Pointer(p)).Fdata
  83417 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17705, libc.VaList(bp+248, libc.PostIncInt32(&i4, 1), (*CollSeq)(unsafe.Pointer(pColl)).FzName))
  83418 	goto __204
  83419 __204:
  83420 	p = (*HashElem)(unsafe.Pointer(p)).Fnext
  83421 	goto __203
  83422 	goto __205
  83423 __205:
  83424 	;
  83425 	goto __15
  83426 
  83427 __38:
  83428 	showInternFunc = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_InternalFunc) != U32(0))
  83429 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 6
  83430 	i5 = 0
  83431 __206:
  83432 	if !(i5 < SQLITE_FUNC_HASH_SZ) {
  83433 		goto __208
  83434 	}
  83435 	p1 = *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)) + uintptr(i5)*4))
  83436 __209:
  83437 	if !(p1 != 0) {
  83438 		goto __211
  83439 	}
  83440 
  83441 	pragmaFunclistLine(tls, v, p1, 1, showInternFunc)
  83442 	goto __210
  83443 __210:
  83444 	p1 = *(*uintptr)(unsafe.Pointer(p1 + 36))
  83445 	goto __209
  83446 	goto __211
  83447 __211:
  83448 	;
  83449 	goto __207
  83450 __207:
  83451 	i5++
  83452 	goto __206
  83453 	goto __208
  83454 __208:
  83455 	;
  83456 	j = (*Hash)(unsafe.Pointer(db + 432)).Ffirst
  83457 __212:
  83458 	if !(j != 0) {
  83459 		goto __214
  83460 	}
  83461 	p1 = (*HashElem)(unsafe.Pointer(j)).Fdata
  83462 
  83463 	pragmaFunclistLine(tls, v, p1, 0, showInternFunc)
  83464 	goto __213
  83465 __213:
  83466 	j = (*HashElem)(unsafe.Pointer(j)).Fnext
  83467 	goto __212
  83468 	goto __214
  83469 __214:
  83470 	;
  83471 	goto __15
  83472 
  83473 __39:
  83474 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 1
  83475 	j1 = (*Hash)(unsafe.Pointer(db + 404)).Ffirst
  83476 __215:
  83477 	if !(j1 != 0) {
  83478 		goto __217
  83479 	}
  83480 	pMod = (*HashElem)(unsafe.Pointer(j1)).Fdata
  83481 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+7517, libc.VaList(bp+264, (*Module)(unsafe.Pointer(pMod)).FzName))
  83482 	goto __216
  83483 __216:
  83484 	j1 = (*HashElem)(unsafe.Pointer(j1)).Fnext
  83485 	goto __215
  83486 	goto __217
  83487 __217:
  83488 	;
  83489 	goto __15
  83490 
  83491 __40:
  83492 	i6 = 0
  83493 __218:
  83494 	if !(i6 < int32(uint32(unsafe.Sizeof(aPragmaName))/uint32(unsafe.Sizeof(PragmaName{})))) {
  83495 		goto __220
  83496 	}
  83497 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+7517, libc.VaList(bp+272, aPragmaName[i6].FzName))
  83498 	goto __219
  83499 __219:
  83500 	i6++
  83501 	goto __218
  83502 	goto __220
  83503 __220:
  83504 	;
  83505 	goto __15
  83506 
  83507 __41:
  83508 	if !(zRight != 0) {
  83509 		goto __221
  83510 	}
  83511 	pTab5 = Xsqlite3FindTable(tls, db, zRight, zDb)
  83512 	if !(pTab5 != 0 && int32((*Table)(unsafe.Pointer(pTab5)).FeTabType) == TABTYP_NORM) {
  83513 		goto __222
  83514 	}
  83515 	pFK = *(*uintptr)(unsafe.Pointer(pTab5 + 44 + 4))
  83516 	if !(pFK != 0) {
  83517 		goto __223
  83518 	}
  83519 	iTabDb1 = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab5)).FpSchema)
  83520 	i7 = 0
  83521 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 8
  83522 	Xsqlite3CodeVerifySchema(tls, pParse, iTabDb1)
  83523 __224:
  83524 	if !(pFK != 0) {
  83525 		goto __225
  83526 	}
  83527 	j2 = 0
  83528 __226:
  83529 	if !(j2 < (*FKey)(unsafe.Pointer(pFK)).FnCol) {
  83530 		goto __228
  83531 	}
  83532 	Xsqlite3VdbeMultiLoad(tls, v, 1, ts+17708,
  83533 		libc.VaList(bp+280, i7,
  83534 			j2,
  83535 			(*FKey)(unsafe.Pointer(pFK)).FzTo,
  83536 			(*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab5)).FaCol+uintptr((*sColMap)(unsafe.Pointer(pFK+36+uintptr(j2)*8)).FiFrom)*16)).FzCnName,
  83537 			(*sColMap)(unsafe.Pointer(pFK+36+uintptr(j2)*8)).FzCol,
  83538 			actionName(tls, *(*U8)(unsafe.Pointer(pFK + 25 + 1))),
  83539 			actionName(tls, *(*U8)(unsafe.Pointer(pFK + 25))),
  83540 			ts+17717))
  83541 	goto __227
  83542 __227:
  83543 	j2++
  83544 	goto __226
  83545 	goto __228
  83546 __228:
  83547 	;
  83548 	i7++
  83549 	pFK = (*FKey)(unsafe.Pointer(pFK)).FpNextFrom
  83550 	goto __224
  83551 __225:
  83552 	;
  83553 __223:
  83554 	;
  83555 __222:
  83556 	;
  83557 __221:
  83558 	;
  83559 	goto __15
  83560 
  83561 __42:
  83562 	regResult = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  83563 	*(*int32)(unsafe.Pointer(pParse + 44)) += 4
  83564 	regRow = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  83565 	k2 = (*Hash)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 8)).Ffirst
  83566 __229:
  83567 	if !(k2 != 0) {
  83568 		goto __230
  83569 	}
  83570 	if !(zRight != 0) {
  83571 		goto __231
  83572 	}
  83573 	pTab6 = Xsqlite3LocateTable(tls, pParse, uint32(0), zRight, zDb)
  83574 	k2 = uintptr(0)
  83575 	goto __232
  83576 __231:
  83577 	pTab6 = (*HashElem)(unsafe.Pointer(k2)).Fdata
  83578 	k2 = (*HashElem)(unsafe.Pointer(k2)).Fnext
  83579 __232:
  83580 	;
  83581 	if !(pTab6 == uintptr(0) || !(int32((*Table)(unsafe.Pointer(pTab6)).FeTabType) == TABTYP_NORM) || *(*uintptr)(unsafe.Pointer(pTab6 + 44 + 4)) == uintptr(0)) {
  83582 		goto __233
  83583 	}
  83584 	goto __229
  83585 __233:
  83586 	;
  83587 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab6)).FpSchema)
  83588 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  83589 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  83590 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab6)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab6)).FzName)
  83591 	if !(int32((*Table)(unsafe.Pointer(pTab6)).FnCol)+regRow > (*Parse)(unsafe.Pointer(pParse)).FnMem) {
  83592 		goto __234
  83593 	}
  83594 	(*Parse)(unsafe.Pointer(pParse)).FnMem = int32((*Table)(unsafe.Pointer(pTab6)).FnCol) + regRow
  83595 __234:
  83596 	;
  83597 	Xsqlite3OpenTable(tls, pParse, 0, iDb, pTab6, OP_OpenRead)
  83598 	Xsqlite3VdbeLoadString(tls, v, regResult, (*Table)(unsafe.Pointer(pTab6)).FzName)
  83599 
  83600 	i8 = 1
  83601 	pFK1 = *(*uintptr)(unsafe.Pointer(pTab6 + 44 + 4))
  83602 __235:
  83603 	if !(pFK1 != 0) {
  83604 		goto __237
  83605 	}
  83606 	pParent = Xsqlite3FindTable(tls, db, (*FKey)(unsafe.Pointer(pFK1)).FzTo, zDb)
  83607 	if !(pParent == uintptr(0)) {
  83608 		goto __238
  83609 	}
  83610 	goto __236
  83611 __238:
  83612 	;
  83613 	*(*uintptr)(unsafe.Pointer(bp + 556)) = uintptr(0)
  83614 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pParent)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pParent)).FzName)
  83615 	x1 = Xsqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+556, uintptr(0))
  83616 	if !(x1 == 0) {
  83617 		goto __239
  83618 	}
  83619 	if !(*(*uintptr)(unsafe.Pointer(bp + 556)) == uintptr(0)) {
  83620 		goto __241
  83621 	}
  83622 	Xsqlite3OpenTable(tls, pParse, i8, iDb, pParent, OP_OpenRead)
  83623 	goto __242
  83624 __241:
  83625 	Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, i8, int32((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 556)))).Ftnum), iDb)
  83626 	Xsqlite3VdbeSetP4KeyInfo(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 556)))
  83627 __242:
  83628 	;
  83629 	goto __240
  83630 __239:
  83631 	k2 = uintptr(0)
  83632 	goto __237
  83633 __240:
  83634 	;
  83635 	goto __236
  83636 __236:
  83637 	i8++
  83638 	pFK1 = (*FKey)(unsafe.Pointer(pFK1)).FpNextFrom
  83639 	goto __235
  83640 	goto __237
  83641 __237:
  83642 	;
  83643 	if !(pFK1 != 0) {
  83644 		goto __243
  83645 	}
  83646 	goto __230
  83647 __243:
  83648 	;
  83649 	if !((*Parse)(unsafe.Pointer(pParse)).FnTab < i8) {
  83650 		goto __244
  83651 	}
  83652 	(*Parse)(unsafe.Pointer(pParse)).FnTab = i8
  83653 __244:
  83654 	;
  83655 	addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, 0)
  83656 
  83657 	i8 = 1
  83658 	pFK1 = *(*uintptr)(unsafe.Pointer(pTab6 + 44 + 4))
  83659 __245:
  83660 	if !(pFK1 != 0) {
  83661 		goto __247
  83662 	}
  83663 	pParent = Xsqlite3FindTable(tls, db, (*FKey)(unsafe.Pointer(pFK1)).FzTo, zDb)
  83664 	*(*uintptr)(unsafe.Pointer(bp + 556)) = uintptr(0)
  83665 	*(*uintptr)(unsafe.Pointer(bp + 560)) = uintptr(0)
  83666 	if !(pParent != 0) {
  83667 		goto __248
  83668 	}
  83669 	x1 = Xsqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+556, bp+560)
  83670 
  83671 __248:
  83672 	;
  83673 	addrOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  83674 
  83675 	if !(regRow+(*FKey)(unsafe.Pointer(pFK1)).FnCol > (*Parse)(unsafe.Pointer(pParse)).FnMem) {
  83676 		goto __249
  83677 	}
  83678 	(*Parse)(unsafe.Pointer(pParse)).FnMem = regRow + (*FKey)(unsafe.Pointer(pFK1)).FnCol
  83679 __249:
  83680 	;
  83681 	j3 = 0
  83682 __250:
  83683 	if !(j3 < (*FKey)(unsafe.Pointer(pFK1)).FnCol) {
  83684 		goto __252
  83685 	}
  83686 	if *(*uintptr)(unsafe.Pointer(bp + 560)) != 0 {
  83687 		iCol = *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 560)) + uintptr(j3)*4))
  83688 	} else {
  83689 		iCol = (*sColMap)(unsafe.Pointer(pFK1 + 36 + uintptr(j3)*8)).FiFrom
  83690 	}
  83691 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab6, 0, iCol, regRow+j3)
  83692 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regRow+j3, addrOk)
  83693 	goto __251
  83694 __251:
  83695 	j3++
  83696 	goto __250
  83697 	goto __252
  83698 __252:
  83699 	;
  83700 	if !(*(*uintptr)(unsafe.Pointer(bp + 556)) != 0) {
  83701 		goto __253
  83702 	}
  83703 	Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, regRow, (*FKey)(unsafe.Pointer(pFK1)).FnCol, 0,
  83704 		Xsqlite3IndexAffinityStr(tls, db, *(*uintptr)(unsafe.Pointer(bp + 556))), (*FKey)(unsafe.Pointer(pFK1)).FnCol)
  83705 	Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, i8, addrOk, regRow, (*FKey)(unsafe.Pointer(pFK1)).FnCol)
  83706 
  83707 	goto __254
  83708 __253:
  83709 	if !(pParent != 0) {
  83710 		goto __255
  83711 	}
  83712 	jmp = Xsqlite3VdbeCurrentAddr(tls, v) + 2
  83713 	Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, i8, jmp, regRow)
  83714 	Xsqlite3VdbeGoto(tls, v, addrOk)
  83715 
  83716 __255:
  83717 	;
  83718 __254:
  83719 	;
  83720 	if !((*Table)(unsafe.Pointer(pTab6)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  83721 		goto __256
  83722 	}
  83723 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, 0, regResult+1)
  83724 	goto __257
  83725 __256:
  83726 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regResult+1)
  83727 __257:
  83728 	;
  83729 	Xsqlite3VdbeMultiLoad(tls, v, regResult+2, ts+17722, libc.VaList(bp+344, (*FKey)(unsafe.Pointer(pFK1)).FzTo, i8-1))
  83730 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regResult, 4)
  83731 	Xsqlite3VdbeResolveLabel(tls, v, addrOk)
  83732 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 560)))
  83733 	goto __246
  83734 __246:
  83735 	i8++
  83736 	pFK1 = (*FKey)(unsafe.Pointer(pFK1)).FpNextFrom
  83737 	goto __245
  83738 	goto __247
  83739 __247:
  83740 	;
  83741 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, 0, addrTop+1)
  83742 	Xsqlite3VdbeJumpHere(tls, v, addrTop)
  83743 	goto __229
  83744 __230:
  83745 	;
  83746 	goto __15
  83747 
  83748 __43:
  83749 	if !(zRight != 0) {
  83750 		goto __258
  83751 	}
  83752 	Xsqlite3RegisterLikeFunctions(tls, db, int32(Xsqlite3GetBoolean(tls, zRight, uint8(0))))
  83753 __258:
  83754 	;
  83755 	goto __15
  83756 
  83757 __44:
  83758 	pObjTab = uintptr(0)
  83759 
  83760 	isQuick = libc.Bool32(int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(zLeft))]) == 'q')
  83761 
  83762 	if !((*Token)(unsafe.Pointer(pId2)).Fz == uintptr(0)) {
  83763 		goto __259
  83764 	}
  83765 	iDb = -1
  83766 __259:
  83767 	;
  83768 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 6
  83769 
  83770 	*(*int32)(unsafe.Pointer(bp + 564)) = SQLITE_INTEGRITY_CHECK_ERROR_MAX
  83771 	if !(zRight != 0) {
  83772 		goto __260
  83773 	}
  83774 	if !(Xsqlite3GetInt32(tls, zRight, bp+564) != 0) {
  83775 		goto __261
  83776 	}
  83777 	if !(*(*int32)(unsafe.Pointer(bp + 564)) <= 0) {
  83778 		goto __263
  83779 	}
  83780 	*(*int32)(unsafe.Pointer(bp + 564)) = SQLITE_INTEGRITY_CHECK_ERROR_MAX
  83781 __263:
  83782 	;
  83783 	goto __262
  83784 __261:
  83785 	pObjTab = Xsqlite3LocateTable(tls, pParse, uint32(0), zRight,
  83786 		func() uintptr {
  83787 			if iDb >= 0 {
  83788 				return (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  83789 			}
  83790 			return uintptr(0)
  83791 		}())
  83792 __262:
  83793 	;
  83794 __260:
  83795 	;
  83796 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp + 564))-1, 1)
  83797 
  83798 	i9 = 0
  83799 __264:
  83800 	if !(i9 < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  83801 		goto __266
  83802 	}
  83803 	cnt = 0
  83804 	mxIdx = 0
  83805 
  83806 	if !(0 != 0 && i9 == 1) {
  83807 		goto __267
  83808 	}
  83809 	goto __265
  83810 __267:
  83811 	;
  83812 	if !(iDb >= 0 && i9 != iDb) {
  83813 		goto __268
  83814 	}
  83815 	goto __265
  83816 __268:
  83817 	;
  83818 	Xsqlite3CodeVerifySchema(tls, pParse, i9)
  83819 
  83820 	pTbls = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i9)*16)).FpSchema + 8
  83821 	cnt = 0
  83822 	x2 = (*Hash)(unsafe.Pointer(pTbls)).Ffirst
  83823 __269:
  83824 	if !(x2 != 0) {
  83825 		goto __271
  83826 	}
  83827 	pTab7 = (*HashElem)(unsafe.Pointer(x2)).Fdata
  83828 	if !(pObjTab != 0 && pObjTab != pTab7) {
  83829 		goto __272
  83830 	}
  83831 	goto __270
  83832 __272:
  83833 	;
  83834 	if !((*Table)(unsafe.Pointer(pTab7)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  83835 		goto __273
  83836 	}
  83837 	cnt++
  83838 __273:
  83839 	;
  83840 	nIdx = 0
  83841 	pIdx3 = (*Table)(unsafe.Pointer(pTab7)).FpIndex
  83842 __274:
  83843 	if !(pIdx3 != 0) {
  83844 		goto __276
  83845 	}
  83846 	cnt++
  83847 	goto __275
  83848 __275:
  83849 	pIdx3 = (*Index)(unsafe.Pointer(pIdx3)).FpNext
  83850 	nIdx++
  83851 	goto __274
  83852 	goto __276
  83853 __276:
  83854 	;
  83855 	if !(nIdx > mxIdx) {
  83856 		goto __277
  83857 	}
  83858 	mxIdx = nIdx
  83859 __277:
  83860 	;
  83861 	goto __270
  83862 __270:
  83863 	x2 = (*HashElem)(unsafe.Pointer(x2)).Fnext
  83864 	goto __269
  83865 	goto __271
  83866 __271:
  83867 	;
  83868 	if !(cnt == 0) {
  83869 		goto __278
  83870 	}
  83871 	goto __265
  83872 __278:
  83873 	;
  83874 	if !(pObjTab != 0) {
  83875 		goto __279
  83876 	}
  83877 	cnt++
  83878 __279:
  83879 	;
  83880 	aRoot = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(int32(0)))*uint32(cnt+1)))
  83881 	if !(aRoot == uintptr(0)) {
  83882 		goto __280
  83883 	}
  83884 	goto __266
  83885 __280:
  83886 	;
  83887 	cnt = 0
  83888 	if !(pObjTab != 0) {
  83889 		goto __281
  83890 	}
  83891 	*(*int32)(unsafe.Pointer(aRoot + uintptr(libc.PreIncInt32(&cnt, 1))*4)) = 0
  83892 __281:
  83893 	;
  83894 	x2 = (*Hash)(unsafe.Pointer(pTbls)).Ffirst
  83895 __282:
  83896 	if !(x2 != 0) {
  83897 		goto __284
  83898 	}
  83899 	pTab8 = (*HashElem)(unsafe.Pointer(x2)).Fdata
  83900 	if !(pObjTab != 0 && pObjTab != pTab8) {
  83901 		goto __285
  83902 	}
  83903 	goto __283
  83904 __285:
  83905 	;
  83906 	if !((*Table)(unsafe.Pointer(pTab8)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  83907 		goto __286
  83908 	}
  83909 	*(*int32)(unsafe.Pointer(aRoot + uintptr(libc.PreIncInt32(&cnt, 1))*4)) = int32((*Table)(unsafe.Pointer(pTab8)).Ftnum)
  83910 __286:
  83911 	;
  83912 	pIdx4 = (*Table)(unsafe.Pointer(pTab8)).FpIndex
  83913 __287:
  83914 	if !(pIdx4 != 0) {
  83915 		goto __289
  83916 	}
  83917 	*(*int32)(unsafe.Pointer(aRoot + uintptr(libc.PreIncInt32(&cnt, 1))*4)) = int32((*Index)(unsafe.Pointer(pIdx4)).Ftnum)
  83918 	goto __288
  83919 __288:
  83920 	pIdx4 = (*Index)(unsafe.Pointer(pIdx4)).FpNext
  83921 	goto __287
  83922 	goto __289
  83923 __289:
  83924 	;
  83925 	goto __283
  83926 __283:
  83927 	x2 = (*HashElem)(unsafe.Pointer(x2)).Fnext
  83928 	goto __282
  83929 	goto __284
  83930 __284:
  83931 	;
  83932 	*(*int32)(unsafe.Pointer(aRoot)) = cnt
  83933 
  83934 	(*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 {
  83935 		if (*Parse)(unsafe.Pointer(pParse)).FnMem > 8+mxIdx {
  83936 			return (*Parse)(unsafe.Pointer(pParse)).FnMem
  83937 		}
  83938 		return 8 + mxIdx
  83939 	}()
  83940 	Xsqlite3ClearTempRegCache(tls, pParse)
  83941 
  83942 	Xsqlite3VdbeAddOp4(tls, v, OP_IntegrityCk, 2, cnt, 1, aRoot, -14)
  83943 	Xsqlite3VdbeChangeP5(tls, v, uint16(U8(i9)))
  83944 	addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, 2)
  83945 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0,
  83946 		Xsqlite3MPrintf(tls, db, ts+17726, libc.VaList(bp+360, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i9)*16)).FzDbSName)),
  83947 		-6)
  83948 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 2, 3, 3)
  83949 	integrityCheckResultRow(tls, v)
  83950 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  83951 
  83952 	x2 = (*Hash)(unsafe.Pointer(pTbls)).Ffirst
  83953 __290:
  83954 	if !(x2 != 0) {
  83955 		goto __292
  83956 	}
  83957 	pTab9 = (*HashElem)(unsafe.Pointer(x2)).Fdata
  83958 	pPrior = uintptr(0)
  83959 	r1 = -1
  83960 
  83961 	if !!(int32((*Table)(unsafe.Pointer(pTab9)).FeTabType) == TABTYP_NORM) {
  83962 		goto __293
  83963 	}
  83964 	goto __291
  83965 __293:
  83966 	;
  83967 	if !(pObjTab != 0 && pObjTab != pTab9) {
  83968 		goto __294
  83969 	}
  83970 	goto __291
  83971 __294:
  83972 	;
  83973 	if !(isQuick != 0 || (*Table)(unsafe.Pointer(pTab9)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  83974 		goto __295
  83975 	}
  83976 	pPk1 = uintptr(0)
  83977 	r2 = 0
  83978 	goto __296
  83979 __295:
  83980 	pPk1 = Xsqlite3PrimaryKeyIndex(tls, pTab9)
  83981 	r2 = Xsqlite3GetTempRange(tls, pParse, int32((*Index)(unsafe.Pointer(pPk1)).FnKeyCol))
  83982 	Xsqlite3VdbeAddOp3(tls, v, OP_Null, 1, r2, r2+int32((*Index)(unsafe.Pointer(pPk1)).FnKeyCol)-1)
  83983 __296:
  83984 	;
  83985 	Xsqlite3OpenTableAndIndices(tls, pParse, pTab9, OP_OpenRead, uint8(0),
  83986 		1, uintptr(0), bp+568, bp+572)
  83987 
  83988 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 7)
  83989 	j4 = 0
  83990 	pIdx5 = (*Table)(unsafe.Pointer(pTab9)).FpIndex
  83991 __297:
  83992 	if !(pIdx5 != 0) {
  83993 		goto __299
  83994 	}
  83995 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 8+j4)
  83996 	goto __298
  83997 __298:
  83998 	pIdx5 = (*Index)(unsafe.Pointer(pIdx5)).FpNext
  83999 	j4++
  84000 	goto __297
  84001 	goto __299
  84002 __299:
  84003 	;
  84004 	Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, *(*int32)(unsafe.Pointer(bp + 568)), 0)
  84005 	loopTop = Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 7, 1)
  84006 
  84007 	if !((*Table)(unsafe.Pointer(pTab9)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  84008 		goto __300
  84009 	}
  84010 	mxCol = -1
  84011 	j4 = 0
  84012 __302:
  84013 	if !(j4 < int32((*Table)(unsafe.Pointer(pTab9)).FnCol)) {
  84014 		goto __304
  84015 	}
  84016 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab9)).FaCol+uintptr(j4)*16)).FcolFlags)&COLFLAG_VIRTUAL == 0) {
  84017 		goto __305
  84018 	}
  84019 	mxCol++
  84020 __305:
  84021 	;
  84022 	goto __303
  84023 __303:
  84024 	j4++
  84025 	goto __302
  84026 	goto __304
  84027 __304:
  84028 	;
  84029 	if !(mxCol == int32((*Table)(unsafe.Pointer(pTab9)).FiPKey)) {
  84030 		goto __306
  84031 	}
  84032 	mxCol--
  84033 __306:
  84034 	;
  84035 	goto __301
  84036 __300:
  84037 	mxCol = int32((*Index)(unsafe.Pointer(Xsqlite3PrimaryKeyIndex(tls, pTab9))).FnColumn) - 1
  84038 __301:
  84039 	;
  84040 	if !(mxCol >= 0) {
  84041 		goto __307
  84042 	}
  84043 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 568)), mxCol, 3)
  84044 	Xsqlite3VdbeTypeofColumn(tls, v, 3)
  84045 __307:
  84046 	;
  84047 	if !!(isQuick != 0) {
  84048 		goto __308
  84049 	}
  84050 	if !(pPk1 != 0) {
  84051 		goto __309
  84052 	}
  84053 	a1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxGT, *(*int32)(unsafe.Pointer(bp + 568)), 0, r2, int32((*Index)(unsafe.Pointer(pPk1)).FnKeyCol))
  84054 
  84055 	Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, r2)
  84056 	zErr = Xsqlite3MPrintf(tls, db,
  84057 		ts+17750,
  84058 		libc.VaList(bp+368, (*Table)(unsafe.Pointer(pTab9)).FzName))
  84059 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr, -6)
  84060 	integrityCheckResultRow(tls, v)
  84061 	Xsqlite3VdbeJumpHere(tls, v, a1)
  84062 	Xsqlite3VdbeJumpHere(tls, v, a1+1)
  84063 	j4 = 0
  84064 __310:
  84065 	if !(j4 < int32((*Index)(unsafe.Pointer(pPk1)).FnKeyCol)) {
  84066 		goto __312
  84067 	}
  84068 	Xsqlite3ExprCodeLoadIndexColumn(tls, pParse, pPk1, *(*int32)(unsafe.Pointer(bp + 568)), j4, r2+j4)
  84069 	goto __311
  84070 __311:
  84071 	j4++
  84072 	goto __310
  84073 	goto __312
  84074 __312:
  84075 	;
  84076 __309:
  84077 	;
  84078 __308:
  84079 	;
  84080 	bStrict = libc.Bool32((*Table)(unsafe.Pointer(pTab9)).FtabFlags&U32(TF_Strict) != U32(0))
  84081 	j4 = 0
  84082 __313:
  84083 	if !(j4 < int32((*Table)(unsafe.Pointer(pTab9)).FnCol)) {
  84084 		goto __315
  84085 	}
  84086 	pCol1 = (*Table)(unsafe.Pointer(pTab9)).FaCol + uintptr(j4)*16
  84087 
  84088 	if !(j4 == int32((*Table)(unsafe.Pointer(pTab9)).FiPKey)) {
  84089 		goto __316
  84090 	}
  84091 	goto __314
  84092 __316:
  84093 	;
  84094 	if !(bStrict != 0) {
  84095 		goto __317
  84096 	}
  84097 	doTypeCheck = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(pCol1 + 4))&0xf0>>4) > COLTYPE_ANY)
  84098 	goto __318
  84099 __317:
  84100 	doTypeCheck = libc.Bool32(int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) > SQLITE_AFF_BLOB)
  84101 __318:
  84102 	;
  84103 	if !(int32(*(*uint8)(unsafe.Pointer(pCol1 + 4))&0xf>>0) == 0 && !(doTypeCheck != 0)) {
  84104 		goto __319
  84105 	}
  84106 	goto __314
  84107 __319:
  84108 	;
  84109 	p4 = SQLITE_NULL
  84110 	if !(int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags)&COLFLAG_VIRTUAL != 0) {
  84111 		goto __320
  84112 	}
  84113 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab9, *(*int32)(unsafe.Pointer(bp + 568)), j4, 3)
  84114 	p11 = -1
  84115 	p3 = 3
  84116 	goto __321
  84117 __320:
  84118 	if !((*Column)(unsafe.Pointer(pCol1)).FiDflt != 0) {
  84119 		goto __322
  84120 	}
  84121 	*(*uintptr)(unsafe.Pointer(bp + 576)) = uintptr(0)
  84122 	Xsqlite3ValueFromExpr(tls, db, Xsqlite3ColumnExpr(tls, pTab9, pCol1), (*Sqlite3)(unsafe.Pointer(db)).Fenc,
  84123 		(*Column)(unsafe.Pointer(pCol1)).Faffinity, bp+576)
  84124 	if !(*(*uintptr)(unsafe.Pointer(bp + 576)) != 0) {
  84125 		goto __323
  84126 	}
  84127 	p4 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp + 576)))
  84128 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 576)))
  84129 __323:
  84130 	;
  84131 __322:
  84132 	;
  84133 	p11 = *(*int32)(unsafe.Pointer(bp + 568))
  84134 	if !!((*Table)(unsafe.Pointer(pTab9)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  84135 		goto __324
  84136 	}
  84137 
  84138 	p3 = int32(Xsqlite3TableColumnToIndex(tls, Xsqlite3PrimaryKeyIndex(tls, pTab9), int16(j4)))
  84139 	goto __325
  84140 __324:
  84141 	p3 = int32(Xsqlite3TableColumnToStorage(tls, pTab9, int16(j4)))
  84142 
  84143 __325:
  84144 	;
  84145 __321:
  84146 	;
  84147 	labelError = Xsqlite3VdbeMakeLabel(tls, pParse)
  84148 	labelOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  84149 	if !(uint32(int32(*(*uint8)(unsafe.Pointer(pCol1 + 4))&0xf>>0)) != 0) {
  84150 		goto __326
  84151 	}
  84152 
  84153 	jmp2 = Xsqlite3VdbeAddOp4Int(tls, v, OP_IsType, p11, labelOk, p3, p4)
  84154 	Xsqlite3VdbeChangeP5(tls, v, uint16(0x0f))
  84155 
  84156 	zErr1 = Xsqlite3MPrintf(tls, db, ts+17786, libc.VaList(bp+376, (*Table)(unsafe.Pointer(pTab9)).FzName,
  84157 		(*Column)(unsafe.Pointer(pCol1)).FzCnName))
  84158 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr1, -6)
  84159 	if !(doTypeCheck != 0) {
  84160 		goto __327
  84161 	}
  84162 	Xsqlite3VdbeGoto(tls, v, labelError)
  84163 	Xsqlite3VdbeJumpHere(tls, v, jmp2)
  84164 	goto __328
  84165 __327:
  84166 	;
  84167 __328:
  84168 	;
  84169 __326:
  84170 	;
  84171 	if !(bStrict != 0 && doTypeCheck != 0) {
  84172 		goto __329
  84173 	}
  84174 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IsType, p11, labelOk, p3, p4)
  84175 
  84176 	Xsqlite3VdbeChangeP5(tls, v, uint16(aStdTypeMask[(int32(*(*uint8)(unsafe.Pointer(pCol1 + 4))&0xf0>>4)-1)&0xf<<28>>28]))
  84177 
  84178 	zErr1 = Xsqlite3MPrintf(tls, db, ts+17806,
  84179 		libc.VaList(bp+392, Xsqlite3StdType[(int32(*(*uint8)(unsafe.Pointer(pCol1 + 4))&0xf0>>4)-1)&0xf<<28>>28],
  84180 			(*Table)(unsafe.Pointer(pTab9)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab9)).FaCol+uintptr(j4)*16)).FzCnName))
  84181 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr1, -6)
  84182 	goto __330
  84183 __329:
  84184 	if !(!(bStrict != 0) && int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) == SQLITE_AFF_TEXT) {
  84185 		goto __331
  84186 	}
  84187 
  84188 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IsType, p11, labelOk, p3, p4)
  84189 	Xsqlite3VdbeChangeP5(tls, v, uint16(0x1c))
  84190 
  84191 	zErr1 = Xsqlite3MPrintf(tls, db, ts+17828,
  84192 		libc.VaList(bp+416, (*Table)(unsafe.Pointer(pTab9)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab9)).FaCol+uintptr(j4)*16)).FzCnName))
  84193 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr1, -6)
  84194 	goto __332
  84195 __331:
  84196 	if !(!(bStrict != 0) && int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) >= SQLITE_AFF_NUMERIC) {
  84197 		goto __333
  84198 	}
  84199 
  84200 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IsType, p11, labelOk, p3, p4)
  84201 	Xsqlite3VdbeChangeP5(tls, v, uint16(0x1b))
  84202 
  84203 	if !(p11 >= 0) {
  84204 		goto __334
  84205 	}
  84206 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab9, *(*int32)(unsafe.Pointer(bp + 568)), j4, 3)
  84207 __334:
  84208 	;
  84209 	Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, 3, 1, 0, ts+17851, -1)
  84210 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IsType, -1, labelOk, 3, p4)
  84211 	Xsqlite3VdbeChangeP5(tls, v, uint16(0x1c))
  84212 
  84213 	zErr1 = Xsqlite3MPrintf(tls, db, ts+17853,
  84214 		libc.VaList(bp+432, (*Table)(unsafe.Pointer(pTab9)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab9)).FaCol+uintptr(j4)*16)).FzCnName))
  84215 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr1, -6)
  84216 __333:
  84217 	;
  84218 __332:
  84219 	;
  84220 __330:
  84221 	;
  84222 	Xsqlite3VdbeResolveLabel(tls, v, labelError)
  84223 	integrityCheckResultRow(tls, v)
  84224 	Xsqlite3VdbeResolveLabel(tls, v, labelOk)
  84225 	goto __314
  84226 __314:
  84227 	j4++
  84228 	goto __313
  84229 	goto __315
  84230 __315:
  84231 	;
  84232 	if !((*Table)(unsafe.Pointer(pTab9)).FpCheck != 0 && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0)) {
  84233 		goto __335
  84234 	}
  84235 	pCheck = Xsqlite3ExprListDup(tls, db, (*Table)(unsafe.Pointer(pTab9)).FpCheck, 0)
  84236 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) {
  84237 		goto __336
  84238 	}
  84239 	addrCkFault = Xsqlite3VdbeMakeLabel(tls, pParse)
  84240 	addrCkOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  84241 	(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = *(*int32)(unsafe.Pointer(bp + 568)) + 1
  84242 	k3 = (*ExprList)(unsafe.Pointer(pCheck)).FnExpr - 1
  84243 __337:
  84244 	if !(k3 > 0) {
  84245 		goto __339
  84246 	}
  84247 	Xsqlite3ExprIfFalse(tls, pParse, (*ExprList_item)(unsafe.Pointer(pCheck+8+uintptr(k3)*20)).FpExpr, addrCkFault, 0)
  84248 	goto __338
  84249 __338:
  84250 	k3--
  84251 	goto __337
  84252 	goto __339
  84253 __339:
  84254 	;
  84255 	Xsqlite3ExprIfTrue(tls, pParse, (*ExprList_item)(unsafe.Pointer(pCheck+8)).FpExpr, addrCkOk,
  84256 		SQLITE_JUMPIFNULL)
  84257 	Xsqlite3VdbeResolveLabel(tls, v, addrCkFault)
  84258 	(*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0
  84259 	zErr2 = Xsqlite3MPrintf(tls, db, ts+17873,
  84260 		libc.VaList(bp+448, (*Table)(unsafe.Pointer(pTab9)).FzName))
  84261 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr2, -6)
  84262 	integrityCheckResultRow(tls, v)
  84263 	Xsqlite3VdbeResolveLabel(tls, v, addrCkOk)
  84264 __336:
  84265 	;
  84266 	Xsqlite3ExprListDelete(tls, db, pCheck)
  84267 __335:
  84268 	;
  84269 	if !!(isQuick != 0) {
  84270 		goto __340
  84271 	}
  84272 
  84273 	j4 = 0
  84274 	pIdx5 = (*Table)(unsafe.Pointer(pTab9)).FpIndex
  84275 __341:
  84276 	if !(pIdx5 != 0) {
  84277 		goto __343
  84278 	}
  84279 	ckUniq = Xsqlite3VdbeMakeLabel(tls, pParse)
  84280 	if !(pPk1 == pIdx5) {
  84281 		goto __344
  84282 	}
  84283 	goto __342
  84284 __344:
  84285 	;
  84286 	r1 = Xsqlite3GenerateIndexKey(tls, pParse, pIdx5, *(*int32)(unsafe.Pointer(bp + 568)), 0, 0, bp+580,
  84287 		pPrior, r1)
  84288 	pPrior = pIdx5
  84289 	Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 8+j4, 1)
  84290 
  84291 	jmp21 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, *(*int32)(unsafe.Pointer(bp + 572))+j4, ckUniq, r1,
  84292 		int32((*Index)(unsafe.Pointer(pIdx5)).FnColumn))
  84293 	Xsqlite3VdbeLoadString(tls, v, 3, ts+17903)
  84294 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 7, 3, 3)
  84295 	Xsqlite3VdbeLoadString(tls, v, 4, ts+17908)
  84296 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 3, 3)
  84297 	jmp5 = Xsqlite3VdbeLoadString(tls, v, 4, (*Index)(unsafe.Pointer(pIdx5)).FzName)
  84298 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 3, 3)
  84299 	jmp4 = integrityCheckResultRow(tls, v)
  84300 	Xsqlite3VdbeJumpHere(tls, v, jmp21)
  84301 
  84302 	if !((*Table)(unsafe.Pointer(pTab9)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  84303 		goto __345
  84304 	}
  84305 	Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, *(*int32)(unsafe.Pointer(bp + 572))+j4, 3)
  84306 	jmp7 = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, 3, 0, r1+int32((*Index)(unsafe.Pointer(pIdx5)).FnColumn)-1)
  84307 
  84308 	Xsqlite3VdbeLoadString(tls, v, 3,
  84309 		ts+17929)
  84310 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 7, 3, 3)
  84311 	Xsqlite3VdbeLoadString(tls, v, 4, ts+17965)
  84312 	Xsqlite3VdbeGoto(tls, v, jmp5-1)
  84313 	Xsqlite3VdbeJumpHere(tls, v, jmp7)
  84314 __345:
  84315 	;
  84316 	label6 = 0
  84317 	kk = 0
  84318 __346:
  84319 	if !(kk < int32((*Index)(unsafe.Pointer(pIdx5)).FnKeyCol)) {
  84320 		goto __348
  84321 	}
  84322 	if !(*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx5)).FazColl + uintptr(kk)*4)) == uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))) {
  84323 		goto __349
  84324 	}
  84325 	goto __347
  84326 __349:
  84327 	;
  84328 	if !(label6 == 0) {
  84329 		goto __350
  84330 	}
  84331 	label6 = Xsqlite3VdbeMakeLabel(tls, pParse)
  84332 __350:
  84333 	;
  84334 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 572))+j4, kk, 3)
  84335 	Xsqlite3VdbeAddOp3(tls, v, OP_Ne, 3, label6, r1+kk)
  84336 	goto __347
  84337 __347:
  84338 	kk++
  84339 	goto __346
  84340 	goto __348
  84341 __348:
  84342 	;
  84343 	if !(label6 != 0) {
  84344 		goto __351
  84345 	}
  84346 	jmp6 = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  84347 	Xsqlite3VdbeResolveLabel(tls, v, label6)
  84348 	Xsqlite3VdbeLoadString(tls, v, 3, ts+17903)
  84349 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 7, 3, 3)
  84350 	Xsqlite3VdbeLoadString(tls, v, 4, ts+17976)
  84351 	Xsqlite3VdbeGoto(tls, v, jmp5-1)
  84352 	Xsqlite3VdbeJumpHere(tls, v, jmp6)
  84353 __351:
  84354 	;
  84355 	if !(int32((*Index)(unsafe.Pointer(pIdx5)).FonError) != OE_None) {
  84356 		goto __352
  84357 	}
  84358 	uniqOk = Xsqlite3VdbeMakeLabel(tls, pParse)
  84359 	kk = 0
  84360 __353:
  84361 	if !(kk < int32((*Index)(unsafe.Pointer(pIdx5)).FnKeyCol)) {
  84362 		goto __355
  84363 	}
  84364 	iCol1 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx5)).FaiColumn + uintptr(kk)*2)))
  84365 
  84366 	if !(iCol1 >= 0 && uint32(int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab9)).FaCol + uintptr(iCol1)*16 + 4))&0xf>>0)) != 0) {
  84367 		goto __356
  84368 	}
  84369 	goto __354
  84370 __356:
  84371 	;
  84372 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, r1+kk, uniqOk)
  84373 
  84374 	goto __354
  84375 __354:
  84376 	kk++
  84377 	goto __353
  84378 	goto __355
  84379 __355:
  84380 	;
  84381 	jmp61 = Xsqlite3VdbeAddOp1(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 572))+j4)
  84382 	Xsqlite3VdbeGoto(tls, v, uniqOk)
  84383 	Xsqlite3VdbeJumpHere(tls, v, jmp61)
  84384 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxGT, *(*int32)(unsafe.Pointer(bp + 572))+j4, uniqOk, r1,
  84385 		int32((*Index)(unsafe.Pointer(pIdx5)).FnKeyCol))
  84386 	Xsqlite3VdbeLoadString(tls, v, 3, ts+18003)
  84387 	Xsqlite3VdbeGoto(tls, v, jmp5)
  84388 	Xsqlite3VdbeResolveLabel(tls, v, uniqOk)
  84389 __352:
  84390 	;
  84391 	Xsqlite3VdbeJumpHere(tls, v, jmp4)
  84392 	Xsqlite3ResolvePartIdxLabel(tls, pParse, *(*int32)(unsafe.Pointer(bp + 580)))
  84393 	goto __342
  84394 __342:
  84395 	pIdx5 = (*Index)(unsafe.Pointer(pIdx5)).FpNext
  84396 	j4++
  84397 	goto __341
  84398 	goto __343
  84399 __343:
  84400 	;
  84401 __340:
  84402 	;
  84403 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 568)), loopTop)
  84404 	Xsqlite3VdbeJumpHere(tls, v, loopTop-1)
  84405 	if !!(isQuick != 0) {
  84406 		goto __357
  84407 	}
  84408 	Xsqlite3VdbeLoadString(tls, v, 2, ts+18030)
  84409 	j4 = 0
  84410 	pIdx5 = (*Table)(unsafe.Pointer(pTab9)).FpIndex
  84411 __358:
  84412 	if !(pIdx5 != 0) {
  84413 		goto __360
  84414 	}
  84415 	if !(pPk1 == pIdx5) {
  84416 		goto __361
  84417 	}
  84418 	goto __359
  84419 __361:
  84420 	;
  84421 	Xsqlite3VdbeAddOp2(tls, v, OP_Count, *(*int32)(unsafe.Pointer(bp + 572))+j4, 3)
  84422 	addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, 8+j4, 0, 3)
  84423 	Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NOTNULL))
  84424 	Xsqlite3VdbeLoadString(tls, v, 4, (*Index)(unsafe.Pointer(pIdx5)).FzName)
  84425 	Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 2, 3)
  84426 	integrityCheckResultRow(tls, v)
  84427 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  84428 	goto __359
  84429 __359:
  84430 	pIdx5 = (*Index)(unsafe.Pointer(pIdx5)).FpNext
  84431 	j4++
  84432 	goto __358
  84433 	goto __360
  84434 __360:
  84435 	;
  84436 	if !(pPk1 != 0) {
  84437 		goto __362
  84438 	}
  84439 	Xsqlite3ReleaseTempRange(tls, pParse, r2, int32((*Index)(unsafe.Pointer(pPk1)).FnKeyCol))
  84440 __362:
  84441 	;
  84442 __357:
  84443 	;
  84444 	goto __291
  84445 __291:
  84446 	x2 = (*HashElem)(unsafe.Pointer(x2)).Fnext
  84447 	goto __290
  84448 	goto __292
  84449 __292:
  84450 	;
  84451 	goto __265
  84452 __265:
  84453 	i9++
  84454 	goto __264
  84455 	goto __266
  84456 __266:
  84457 	;
  84458 	aOp2 = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(endCode))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&endCode)), iLn5)
  84459 	if !(aOp2 != 0) {
  84460 		goto __363
  84461 	}
  84462 	(*VdbeOp)(unsafe.Pointer(aOp2)).Fp2 = 1 - *(*int32)(unsafe.Pointer(bp + 564))
  84463 	(*VdbeOp)(unsafe.Pointer(aOp2 + 2*20)).Fp4type = int8(-1)
  84464 	*(*uintptr)(unsafe.Pointer(aOp2 + 2*20 + 16)) = ts + 18059
  84465 	(*VdbeOp)(unsafe.Pointer(aOp2 + 5*20)).Fp4type = int8(-1)
  84466 	*(*uintptr)(unsafe.Pointer(aOp2 + 5*20 + 16)) = Xsqlite3ErrStr(tls, SQLITE_CORRUPT)
  84467 __363:
  84468 	;
  84469 	Xsqlite3VdbeChangeP3(tls, v, 0, Xsqlite3VdbeCurrentAddr(tls, v)-2)
  84470 
  84471 	goto __15
  84472 
  84473 __45:
  84474 	if !!(zRight != 0) {
  84475 		goto __364
  84476 	}
  84477 	if !(Xsqlite3ReadSchema(tls, pParse) != 0) {
  84478 		goto __366
  84479 	}
  84480 	goto pragma_out
  84481 __366:
  84482 	;
  84483 	returnSingleText(tls, v, encnames1[(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fenc].FzName)
  84484 	goto __365
  84485 __364:
  84486 	if !((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_EncodingFixed) == U32(0)) {
  84487 		goto __367
  84488 	}
  84489 	pEnc = uintptr(unsafe.Pointer(&encnames1))
  84490 __368:
  84491 	if !((*EncName)(unsafe.Pointer(pEnc)).FzName != 0) {
  84492 		goto __370
  84493 	}
  84494 	if !(0 == Xsqlite3StrICmp(tls, zRight, (*EncName)(unsafe.Pointer(pEnc)).FzName)) {
  84495 		goto __371
  84496 	}
  84497 	if (*EncName)(unsafe.Pointer(pEnc)).Fenc != 0 {
  84498 		enc = (*EncName)(unsafe.Pointer(pEnc)).Fenc
  84499 	} else {
  84500 		enc = uint8(SQLITE_UTF16LE)
  84501 	}
  84502 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fenc = enc
  84503 	Xsqlite3SetTextEncoding(tls, db, enc)
  84504 	goto __370
  84505 __371:
  84506 	;
  84507 	goto __369
  84508 __369:
  84509 	pEnc += 8
  84510 	goto __368
  84511 	goto __370
  84512 __370:
  84513 	;
  84514 	if !!(int32((*EncName)(unsafe.Pointer(pEnc)).FzName) != 0) {
  84515 		goto __372
  84516 	}
  84517 	Xsqlite3ErrorMsg(tls, pParse, ts+18062, libc.VaList(bp+456, zRight))
  84518 __372:
  84519 	;
  84520 __367:
  84521 	;
  84522 __365:
  84523 	;
  84524 	goto __15
  84525 
  84526 __46:
  84527 	iCookie = int32((*PragmaName)(unsafe.Pointer(pPragma)).FiArg)
  84528 	Xsqlite3VdbeUsesBtree(tls, v, iDb)
  84529 	if !(zRight != 0 && int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&PragFlg_ReadOnly == 0) {
  84530 		goto __373
  84531 	}
  84532 
  84533 	aOp3 = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(setCookie))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&setCookie)), 0)
  84534 	if !(0 != 0) {
  84535 		goto __375
  84536 	}
  84537 	goto __15
  84538 __375:
  84539 	;
  84540 	(*VdbeOp)(unsafe.Pointer(aOp3)).Fp1 = iDb
  84541 	(*VdbeOp)(unsafe.Pointer(aOp3 + 1*20)).Fp1 = iDb
  84542 	(*VdbeOp)(unsafe.Pointer(aOp3 + 1*20)).Fp2 = iCookie
  84543 	(*VdbeOp)(unsafe.Pointer(aOp3 + 1*20)).Fp3 = Xsqlite3Atoi(tls, zRight)
  84544 	(*VdbeOp)(unsafe.Pointer(aOp3 + 1*20)).Fp5 = U16(1)
  84545 	if !(iCookie == BTREE_SCHEMA_VERSION && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0)) {
  84546 		goto __376
  84547 	}
  84548 
  84549 	(*VdbeOp)(unsafe.Pointer(aOp3 + 1*20)).Fopcode = U8(OP_Noop)
  84550 __376:
  84551 	;
  84552 	goto __374
  84553 __373:
  84554 	;
  84555 	aOp4 = Xsqlite3VdbeAddOpList(tls, v, int32(uint32(unsafe.Sizeof(readCookie))/uint32(unsafe.Sizeof(VdbeOpList{}))), uintptr(unsafe.Pointer(&readCookie)), 0)
  84556 	if !(0 != 0) {
  84557 		goto __377
  84558 	}
  84559 	goto __15
  84560 __377:
  84561 	;
  84562 	(*VdbeOp)(unsafe.Pointer(aOp4)).Fp1 = iDb
  84563 	(*VdbeOp)(unsafe.Pointer(aOp4 + 1*20)).Fp1 = iDb
  84564 	(*VdbeOp)(unsafe.Pointer(aOp4 + 1*20)).Fp3 = iCookie
  84565 	Xsqlite3VdbeReusable(tls, v)
  84566 __374:
  84567 	;
  84568 	goto __15
  84569 
  84570 __47:
  84571 	i10 = 0
  84572 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 1
  84573 __378:
  84574 	if !(libc.AssignUintptr(&zOpt, Xsqlite3_compileoption_get(tls, libc.PostIncInt32(&i10, 1))) != uintptr(0)) {
  84575 		goto __379
  84576 	}
  84577 	Xsqlite3VdbeLoadString(tls, v, 1, zOpt)
  84578 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1)
  84579 	goto __378
  84580 __379:
  84581 	;
  84582 	Xsqlite3VdbeReusable(tls, v)
  84583 
  84584 	goto __15
  84585 
  84586 __48:
  84587 	iBt = func() int32 {
  84588 		if (*Token)(unsafe.Pointer(pId2)).Fz != 0 {
  84589 			return iDb
  84590 		}
  84591 		return SQLITE_MAX_ATTACHED + 2
  84592 	}()
  84593 	eMode2 = SQLITE_CHECKPOINT_PASSIVE
  84594 	if !(zRight != 0) {
  84595 		goto __380
  84596 	}
  84597 	if !(Xsqlite3StrICmp(tls, zRight, ts+17345) == 0) {
  84598 		goto __381
  84599 	}
  84600 	eMode2 = SQLITE_CHECKPOINT_FULL
  84601 	goto __382
  84602 __381:
  84603 	if !(Xsqlite3StrICmp(tls, zRight, ts+18087) == 0) {
  84604 		goto __383
  84605 	}
  84606 	eMode2 = SQLITE_CHECKPOINT_RESTART
  84607 	goto __384
  84608 __383:
  84609 	if !(Xsqlite3StrICmp(tls, zRight, ts+17498) == 0) {
  84610 		goto __385
  84611 	}
  84612 	eMode2 = SQLITE_CHECKPOINT_TRUNCATE
  84613 __385:
  84614 	;
  84615 __384:
  84616 	;
  84617 __382:
  84618 	;
  84619 __380:
  84620 	;
  84621 	(*Parse)(unsafe.Pointer(pParse)).FnMem = 3
  84622 	Xsqlite3VdbeAddOp3(tls, v, OP_Checkpoint, iBt, eMode2, 1)
  84623 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 3)
  84624 
  84625 	goto __15
  84626 
  84627 __49:
  84628 	if !(zRight != 0) {
  84629 		goto __386
  84630 	}
  84631 	Xsqlite3_wal_autocheckpoint(tls, db, Xsqlite3Atoi(tls, zRight))
  84632 __386:
  84633 	;
  84634 	returnSingleInt(tls, v,
  84635 		func() int64 {
  84636 			if (*Sqlite3)(unsafe.Pointer(db)).FxWalCallback == *(*uintptr)(unsafe.Pointer(&struct {
  84637 				f func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32
  84638 			}{Xsqlite3WalDefaultHook})) {
  84639 				return int64(int32((*Sqlite3)(unsafe.Pointer(db)).FpWalArg))
  84640 			}
  84641 			return int64(0)
  84642 		}())
  84643 
  84644 	goto __15
  84645 
  84646 __50:
  84647 	Xsqlite3_db_release_memory(tls, db)
  84648 	goto __15
  84649 
  84650 __51:
  84651 	if !(zRight != 0) {
  84652 		goto __387
  84653 	}
  84654 	opMask = U32(Xsqlite3Atoi(tls, zRight))
  84655 	if !(opMask&U32(0x02) == U32(0)) {
  84656 		goto __389
  84657 	}
  84658 	goto __15
  84659 __389:
  84660 	;
  84661 	goto __388
  84662 __387:
  84663 	opMask = U32(0xfffe)
  84664 __388:
  84665 	;
  84666 	iTabCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  84667 	iDbLast = func() int32 {
  84668 		if zDb != 0 {
  84669 			return iDb
  84670 		}
  84671 		return (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
  84672 	}()
  84673 __390:
  84674 	if !(iDb <= iDbLast) {
  84675 		goto __392
  84676 	}
  84677 	if !(iDb == 1) {
  84678 		goto __393
  84679 	}
  84680 	goto __391
  84681 __393:
  84682 	;
  84683 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  84684 	pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  84685 	k4 = (*Hash)(unsafe.Pointer(pSchema + 8)).Ffirst
  84686 __394:
  84687 	if !(k4 != 0) {
  84688 		goto __396
  84689 	}
  84690 	pTab10 = (*HashElem)(unsafe.Pointer(k4)).Fdata
  84691 
  84692 	if !((*Table)(unsafe.Pointer(pTab10)).FtabFlags&U32(TF_StatsUsed) == U32(0)) {
  84693 		goto __397
  84694 	}
  84695 	goto __395
  84696 __397:
  84697 	;
  84698 	szThreshold = LogEst(int32((*Table)(unsafe.Pointer(pTab10)).FnRowLogEst) + 46)
  84699 	pIdx6 = (*Table)(unsafe.Pointer(pTab10)).FpIndex
  84700 __398:
  84701 	if !(pIdx6 != 0) {
  84702 		goto __400
  84703 	}
  84704 	if !!(int32(*(*uint16)(unsafe.Pointer(pIdx6 + 56))&0x80>>7) != 0) {
  84705 		goto __401
  84706 	}
  84707 	szThreshold = int16(0)
  84708 	goto __400
  84709 __401:
  84710 	;
  84711 	goto __399
  84712 __399:
  84713 	pIdx6 = (*Index)(unsafe.Pointer(pIdx6)).FpNext
  84714 	goto __398
  84715 	goto __400
  84716 __400:
  84717 	;
  84718 	if !(szThreshold != 0) {
  84719 		goto __402
  84720 	}
  84721 	Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab10, OP_OpenRead)
  84722 	Xsqlite3VdbeAddOp3(tls, v, OP_IfSmaller, iTabCur,
  84723 		int32(U32(Xsqlite3VdbeCurrentAddr(tls, v)+2)+opMask&U32(1)), int32(szThreshold))
  84724 
  84725 __402:
  84726 	;
  84727 	zSubSql = Xsqlite3MPrintf(tls, db, ts+18095,
  84728 		libc.VaList(bp+464, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName, (*Table)(unsafe.Pointer(pTab10)).FzName))
  84729 	if !(opMask&U32(0x01) != 0) {
  84730 		goto __403
  84731 	}
  84732 	r11 = Xsqlite3GetTempReg(tls, pParse)
  84733 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, r11, 0, zSubSql, -6)
  84734 	Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, r11, 1)
  84735 	goto __404
  84736 __403:
  84737 	Xsqlite3VdbeAddOp4(tls, v, OP_SqlExec, 0, 0, 0, zSubSql, -6)
  84738 __404:
  84739 	;
  84740 	goto __395
  84741 __395:
  84742 	k4 = (*HashElem)(unsafe.Pointer(k4)).Fnext
  84743 	goto __394
  84744 	goto __396
  84745 __396:
  84746 	;
  84747 	goto __391
  84748 __391:
  84749 	iDb++
  84750 	goto __390
  84751 	goto __392
  84752 __392:
  84753 	;
  84754 	Xsqlite3VdbeAddOp0(tls, v, OP_Expire)
  84755 	goto __15
  84756 
  84757 __52:
  84758 	;
  84759 	if !(zRight != 0) {
  84760 		goto __405
  84761 	}
  84762 	Xsqlite3_busy_timeout(tls, db, Xsqlite3Atoi(tls, zRight))
  84763 __405:
  84764 	;
  84765 	returnSingleInt(tls, v, int64((*Sqlite3)(unsafe.Pointer(db)).FbusyTimeout))
  84766 	goto __15
  84767 
  84768 __53:
  84769 	if !(zRight != 0 && Xsqlite3DecOrHexToI64(tls, zRight, bp+584) == SQLITE_OK) {
  84770 		goto __406
  84771 	}
  84772 	Xsqlite3_soft_heap_limit64(tls, *(*Sqlite3_int64)(unsafe.Pointer(bp + 584)))
  84773 __406:
  84774 	;
  84775 	returnSingleInt(tls, v, Xsqlite3_soft_heap_limit64(tls, int64(-1)))
  84776 	goto __15
  84777 
  84778 __54:
  84779 	if !(zRight != 0 && Xsqlite3DecOrHexToI64(tls, zRight, bp+592) == SQLITE_OK) {
  84780 		goto __407
  84781 	}
  84782 	iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-1))
  84783 	if !(*(*Sqlite3_int64)(unsafe.Pointer(bp + 592)) > int64(0) && (iPrior == int64(0) || iPrior > *(*Sqlite3_int64)(unsafe.Pointer(bp + 592)))) {
  84784 		goto __408
  84785 	}
  84786 	Xsqlite3_hard_heap_limit64(tls, *(*Sqlite3_int64)(unsafe.Pointer(bp + 592)))
  84787 __408:
  84788 	;
  84789 __407:
  84790 	;
  84791 	returnSingleInt(tls, v, Xsqlite3_hard_heap_limit64(tls, int64(-1)))
  84792 	goto __15
  84793 
  84794 __55:
  84795 	if !(zRight != 0 &&
  84796 		Xsqlite3DecOrHexToI64(tls, zRight, bp+600) == SQLITE_OK &&
  84797 		*(*Sqlite3_int64)(unsafe.Pointer(bp + 600)) >= int64(0)) {
  84798 		goto __409
  84799 	}
  84800 	Xsqlite3_limit(tls, db, SQLITE_LIMIT_WORKER_THREADS, int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 600))&int64(0x7fffffff)))
  84801 __409:
  84802 	;
  84803 	returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, SQLITE_LIMIT_WORKER_THREADS, -1)))
  84804 	goto __15
  84805 
  84806 __56:
  84807 	if !(zRight != 0 &&
  84808 		Xsqlite3DecOrHexToI64(tls, zRight, bp+608) == SQLITE_OK &&
  84809 		*(*Sqlite3_int64)(unsafe.Pointer(bp + 608)) >= int64(0)) {
  84810 		goto __410
  84811 	}
  84812 	(*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 608)) & int64(0x7fffffff))
  84813 __410:
  84814 	;
  84815 	returnSingleInt(tls, v, int64((*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit))
  84816 	goto __15
  84817 
  84818 __15:
  84819 	;
  84820 	if !(int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&PragFlg_NoColumns1 != 0 && zRight != 0) {
  84821 		goto __411
  84822 	}
  84823 
  84824 __411:
  84825 	;
  84826 pragma_out:
  84827 	Xsqlite3DbFree(tls, db, zLeft)
  84828 	Xsqlite3DbFree(tls, db, zRight)
  84829 }
  84830 
  84831 type EncName = struct {
  84832 	FzName       uintptr
  84833 	Fenc         U8
  84834 	F__ccgo_pad1 [3]byte
  84835 }
  84836 
  84837 var iLn3 int32 = 0
  84838 var getCacheSize = [9]VdbeOpList{
  84839 	{Fopcode: U8(OP_Transaction)},
  84840 	{Fopcode: U8(OP_ReadCookie), Fp2: int8(1), Fp3: int8(BTREE_DEFAULT_CACHE_SIZE)},
  84841 	{Fopcode: U8(OP_IfPos), Fp1: int8(1), Fp2: int8(8)},
  84842 	{Fopcode: U8(OP_Integer), Fp2: int8(2)},
  84843 	{Fopcode: U8(OP_Subtract), Fp1: int8(1), Fp2: int8(2), Fp3: int8(1)},
  84844 	{Fopcode: U8(OP_IfPos), Fp1: int8(1), Fp2: int8(8)},
  84845 	{Fopcode: U8(OP_Integer), Fp2: int8(1)},
  84846 	{Fopcode: U8(OP_Noop)},
  84847 	{Fopcode: U8(OP_ResultRow), Fp1: int8(1), Fp2: int8(1)},
  84848 }
  84849 var iLn4 int32 = 0
  84850 var setMeta6 = [5]VdbeOpList{
  84851 	{Fopcode: U8(OP_Transaction), Fp2: int8(1)},
  84852 	{Fopcode: U8(OP_ReadCookie), Fp2: int8(1), Fp3: int8(BTREE_LARGEST_ROOT_PAGE)},
  84853 	{Fopcode: U8(OP_If), Fp1: int8(1)},
  84854 	{Fopcode: U8(OP_Halt), Fp2: int8(OE_Abort)},
  84855 	{Fopcode: U8(OP_SetCookie), Fp2: int8(BTREE_INCR_VACUUM)},
  84856 }
  84857 var aStdTypeMask = [6]uint8{
  84858 	uint8(0x1f),
  84859 	uint8(0x18),
  84860 	uint8(0x11),
  84861 	uint8(0x11),
  84862 	uint8(0x13),
  84863 	uint8(0x14),
  84864 }
  84865 var iLn5 int32 = 0
  84866 var endCode = [7]VdbeOpList{
  84867 	{Fopcode: U8(OP_AddImm), Fp1: int8(1)},
  84868 	{Fopcode: U8(OP_IfNotZero), Fp1: int8(1), Fp2: int8(4)},
  84869 	{Fopcode: U8(OP_String8), Fp2: int8(3)},
  84870 	{Fopcode: U8(OP_ResultRow), Fp1: int8(3), Fp2: int8(1)},
  84871 	{Fopcode: U8(OP_Halt)},
  84872 	{Fopcode: U8(OP_String8), Fp2: int8(3)},
  84873 	{Fopcode: U8(OP_Goto), Fp2: int8(3)},
  84874 }
  84875 var encnames1 = [9]EncName{
  84876 	{FzName: ts + 18113, Fenc: U8(SQLITE_UTF8)},
  84877 	{FzName: ts + 18118, Fenc: U8(SQLITE_UTF8)},
  84878 	{FzName: ts + 18124, Fenc: U8(SQLITE_UTF16LE)},
  84879 	{FzName: ts + 18133, Fenc: U8(SQLITE_UTF16BE)},
  84880 	{FzName: ts + 18142, Fenc: U8(SQLITE_UTF16LE)},
  84881 	{FzName: ts + 18150, Fenc: U8(SQLITE_UTF16BE)},
  84882 	{FzName: ts + 18158},
  84883 	{FzName: ts + 18165},
  84884 	{},
  84885 }
  84886 var setCookie = [2]VdbeOpList{
  84887 	{Fopcode: U8(OP_Transaction), Fp2: int8(1)},
  84888 	{Fopcode: U8(OP_SetCookie)},
  84889 }
  84890 var readCookie = [3]VdbeOpList{
  84891 	{Fopcode: U8(OP_Transaction)},
  84892 	{Fopcode: U8(OP_ReadCookie), Fp2: int8(1)},
  84893 	{Fopcode: U8(OP_ResultRow), Fp1: int8(1), Fp2: int8(1)},
  84894 }
  84895 
  84896 // ****************************************************************************
  84897 //
  84898 // Implementation of an eponymous virtual table that runs a pragma.
  84899 type PragmaVtab1 = struct {
  84900 	Fbase        Sqlite3_vtab
  84901 	Fdb          uintptr
  84902 	FpName       uintptr
  84903 	FnHidden     U8
  84904 	FiHidden     U8
  84905 	F__ccgo_pad1 [2]byte
  84906 }
  84907 
  84908 // ****************************************************************************
  84909 //
  84910 // Implementation of an eponymous virtual table that runs a pragma.
  84911 type PragmaVtab = PragmaVtab1
  84912 type PragmaVtabCursor1 = struct {
  84913 	Fbase    Sqlite3_vtab_cursor
  84914 	FpPragma uintptr
  84915 	FiRowid  Sqlite_int64
  84916 	FazArg   [2]uintptr
  84917 }
  84918 
  84919 type PragmaVtabCursor = PragmaVtabCursor1
  84920 
  84921 func pragmaVtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
  84922 	bp := tls.Alloc(256)
  84923 	defer tls.Free(256)
  84924 
  84925 	var pPragma uintptr = pAux
  84926 	var pTab uintptr = uintptr(0)
  84927 	var rc int32
  84928 	var i int32
  84929 	var j int32
  84930 	var cSep uint8 = uint8('(')
  84931 
  84932 	_ = argc
  84933 	_ = argv
  84934 	Xsqlite3StrAccumInit(tls, bp+32, uintptr(0), bp+56, int32(unsafe.Sizeof([200]uint8{})), 0)
  84935 	Xsqlite3_str_appendall(tls, bp+32, ts+18171)
  84936 	i = 0
  84937 	j = int32((*PragmaName)(unsafe.Pointer(pPragma)).FiPragCName)
  84938 __1:
  84939 	if !(i < int32((*PragmaName)(unsafe.Pointer(pPragma)).FnPragCName)) {
  84940 		goto __3
  84941 	}
  84942 	{
  84943 		Xsqlite3_str_appendf(tls, bp+32, ts+18186, libc.VaList(bp, int32(cSep), pragCName[j]))
  84944 		cSep = uint8(',')
  84945 
  84946 	}
  84947 	goto __2
  84948 __2:
  84949 	i++
  84950 	j++
  84951 	goto __1
  84952 	goto __3
  84953 __3:
  84954 	;
  84955 	if i == 0 {
  84956 		Xsqlite3_str_appendf(tls, bp+32, ts+18193, libc.VaList(bp+16, (*PragmaName)(unsafe.Pointer(pPragma)).FzName))
  84957 		i++
  84958 	}
  84959 	j = 0
  84960 	if int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&PragFlg_Result1 != 0 {
  84961 		Xsqlite3_str_appendall(tls, bp+32, ts+18199)
  84962 		j++
  84963 	}
  84964 	if int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&(PragFlg_SchemaOpt|PragFlg_SchemaReq) != 0 {
  84965 		Xsqlite3_str_appendall(tls, bp+32, ts+18211)
  84966 		j++
  84967 	}
  84968 	Xsqlite3_str_append(tls, bp+32, ts+4957, 1)
  84969 	Xsqlite3StrAccumFinish(tls, bp+32)
  84970 
  84971 	rc = Xsqlite3_declare_vtab(tls, db, bp+56)
  84972 	if rc == SQLITE_OK {
  84973 		pTab = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PragmaVtab{})))
  84974 		if pTab == uintptr(0) {
  84975 			rc = SQLITE_NOMEM
  84976 		} else {
  84977 			libc.Xmemset(tls, pTab, 0, uint32(unsafe.Sizeof(PragmaVtab{})))
  84978 			(*PragmaVtab)(unsafe.Pointer(pTab)).FpName = pPragma
  84979 			(*PragmaVtab)(unsafe.Pointer(pTab)).Fdb = db
  84980 			(*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden = U8(i)
  84981 			(*PragmaVtab)(unsafe.Pointer(pTab)).FnHidden = U8(j)
  84982 		}
  84983 	} else {
  84984 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+24, Xsqlite3_errmsg(tls, db)))
  84985 	}
  84986 
  84987 	*(*uintptr)(unsafe.Pointer(ppVtab)) = pTab
  84988 	return rc
  84989 }
  84990 
  84991 func pragmaVtabDisconnect(tls *libc.TLS, pVtab uintptr) int32 {
  84992 	var pTab uintptr = pVtab
  84993 	Xsqlite3_free(tls, pTab)
  84994 	return SQLITE_OK
  84995 }
  84996 
  84997 func pragmaVtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 {
  84998 	bp := tls.Alloc(8)
  84999 	defer tls.Free(8)
  85000 
  85001 	var pTab uintptr = tab
  85002 	var pConstraint uintptr
  85003 	var i int32
  85004 	var j int32
  85005 
  85006 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1)
  85007 	if int32((*PragmaVtab)(unsafe.Pointer(pTab)).FnHidden) == 0 {
  85008 		return SQLITE_OK
  85009 	}
  85010 	pConstraint = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint
  85011 	*(*int32)(unsafe.Pointer(bp)) = 0
  85012 	*(*int32)(unsafe.Pointer(bp + 1*4)) = 0
  85013 	i = 0
  85014 __1:
  85015 	if !(i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) {
  85016 		goto __3
  85017 	}
  85018 	{
  85019 		if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 {
  85020 			goto __2
  85021 		}
  85022 		if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ {
  85023 			goto __2
  85024 		}
  85025 		if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden) {
  85026 			goto __2
  85027 		}
  85028 		j = (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden)
  85029 
  85030 		*(*int32)(unsafe.Pointer(bp + uintptr(j)*4)) = i + 1
  85031 
  85032 	}
  85033 	goto __2
  85034 __2:
  85035 	i++
  85036 	pConstraint += 12
  85037 	goto __1
  85038 	goto __3
  85039 __3:
  85040 	;
  85041 	if *(*int32)(unsafe.Pointer(bp)) == 0 {
  85042 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(2147483647)
  85043 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647)
  85044 		return SQLITE_OK
  85045 	}
  85046 	j = *(*int32)(unsafe.Pointer(bp)) - 1
  85047 	(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = 1
  85048 	(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = uint8(1)
  85049 	if *(*int32)(unsafe.Pointer(bp + 1*4)) == 0 {
  85050 		return SQLITE_OK
  85051 	}
  85052 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(20)
  85053 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(20)
  85054 	j = *(*int32)(unsafe.Pointer(bp + 1*4)) - 1
  85055 	(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = 2
  85056 	(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = uint8(1)
  85057 	return SQLITE_OK
  85058 }
  85059 
  85060 func pragmaVtabOpen(tls *libc.TLS, pVtab uintptr, ppCursor uintptr) int32 {
  85061 	var pCsr uintptr
  85062 	pCsr = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PragmaVtabCursor{})))
  85063 	if pCsr == uintptr(0) {
  85064 		return SQLITE_NOMEM
  85065 	}
  85066 	libc.Xmemset(tls, pCsr, 0, uint32(unsafe.Sizeof(PragmaVtabCursor{})))
  85067 	(*PragmaVtabCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVtab
  85068 	*(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr
  85069 	return SQLITE_OK
  85070 }
  85071 
  85072 func pragmaVtabCursorClear(tls *libc.TLS, pCsr uintptr) {
  85073 	var i int32
  85074 	Xsqlite3_finalize(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma)
  85075 	(*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma = uintptr(0)
  85076 	for i = 0; i < int32(uint32(unsafe.Sizeof([2]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))); i++ {
  85077 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pCsr + 16 + uintptr(i)*4)))
  85078 		*(*uintptr)(unsafe.Pointer(pCsr + 16 + uintptr(i)*4)) = uintptr(0)
  85079 	}
  85080 }
  85081 
  85082 func pragmaVtabClose(tls *libc.TLS, cur uintptr) int32 {
  85083 	var pCsr uintptr = cur
  85084 	pragmaVtabCursorClear(tls, pCsr)
  85085 	Xsqlite3_free(tls, pCsr)
  85086 	return SQLITE_OK
  85087 }
  85088 
  85089 func pragmaVtabNext(tls *libc.TLS, pVtabCursor uintptr) int32 {
  85090 	var pCsr uintptr = pVtabCursor
  85091 	var rc int32 = SQLITE_OK
  85092 
  85093 	(*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid++
  85094 
  85095 	if SQLITE_ROW != Xsqlite3_step(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) {
  85096 		rc = Xsqlite3_finalize(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma)
  85097 		(*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma = uintptr(0)
  85098 		pragmaVtabCursorClear(tls, pCsr)
  85099 	}
  85100 	return rc
  85101 }
  85102 
  85103 func pragmaVtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 {
  85104 	bp := tls.Alloc(56)
  85105 	defer tls.Free(56)
  85106 
  85107 	var pCsr uintptr = pVtabCursor
  85108 	var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab
  85109 	var rc int32
  85110 	var i int32
  85111 	var j int32
  85112 
  85113 	var zSql uintptr
  85114 
  85115 	_ = idxNum
  85116 	_ = idxStr
  85117 	pragmaVtabCursorClear(tls, pCsr)
  85118 	if int32((*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg)&PragFlg_Result1 != 0 {
  85119 		j = 0
  85120 	} else {
  85121 		j = 1
  85122 	}
  85123 	i = 0
  85124 __1:
  85125 	if !(i < argc) {
  85126 		goto __3
  85127 	}
  85128 	{
  85129 		var zText uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
  85130 
  85131 		if zText != 0 {
  85132 			*(*uintptr)(unsafe.Pointer(pCsr + 16 + uintptr(j)*4)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, zText))
  85133 			if *(*uintptr)(unsafe.Pointer(pCsr + 16 + uintptr(j)*4)) == uintptr(0) {
  85134 				return SQLITE_NOMEM
  85135 			}
  85136 		}
  85137 
  85138 	}
  85139 	goto __2
  85140 __2:
  85141 	i++
  85142 	j++
  85143 	goto __1
  85144 	goto __3
  85145 __3:
  85146 	;
  85147 	Xsqlite3StrAccumInit(tls, bp+32, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).Fdb + 120 + 1*4)))
  85148 	Xsqlite3_str_appendall(tls, bp+32, ts+18226)
  85149 	if *(*uintptr)(unsafe.Pointer(pCsr + 16 + 1*4)) != 0 {
  85150 		Xsqlite3_str_appendf(tls, bp+32, ts+18234, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(pCsr + 16 + 1*4))))
  85151 	}
  85152 	Xsqlite3_str_appendall(tls, bp+32, (*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FzName)
  85153 	if *(*uintptr)(unsafe.Pointer(pCsr + 16)) != 0 {
  85154 		Xsqlite3_str_appendf(tls, bp+32, ts+18238, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(pCsr + 16))))
  85155 	}
  85156 	zSql = Xsqlite3StrAccumFinish(tls, bp+32)
  85157 	if zSql == uintptr(0) {
  85158 		return SQLITE_NOMEM
  85159 	}
  85160 	rc = Xsqlite3_prepare_v2(tls, (*PragmaVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, pCsr+4, uintptr(0))
  85161 	Xsqlite3_free(tls, zSql)
  85162 	if rc != SQLITE_OK {
  85163 		(*PragmaVtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+24, Xsqlite3_errmsg(tls, (*PragmaVtab)(unsafe.Pointer(pTab)).Fdb)))
  85164 		return rc
  85165 	}
  85166 	return pragmaVtabNext(tls, pVtabCursor)
  85167 }
  85168 
  85169 func pragmaVtabEof(tls *libc.TLS, pVtabCursor uintptr) int32 {
  85170 	var pCsr uintptr = pVtabCursor
  85171 	return libc.Bool32((*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma == uintptr(0))
  85172 }
  85173 
  85174 func pragmaVtabColumn(tls *libc.TLS, pVtabCursor uintptr, ctx uintptr, i int32) int32 {
  85175 	var pCsr uintptr = pVtabCursor
  85176 	var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab
  85177 	if i < int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden) {
  85178 		Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma, i))
  85179 	} else {
  85180 		Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer(pCsr + 16 + uintptr(i-int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden))*4)), -1, libc.UintptrFromInt32(-1))
  85181 	}
  85182 	return SQLITE_OK
  85183 }
  85184 
  85185 func pragmaVtabRowid(tls *libc.TLS, pVtabCursor uintptr, p uintptr) int32 {
  85186 	var pCsr uintptr = pVtabCursor
  85187 	*(*Sqlite_int64)(unsafe.Pointer(p)) = (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid
  85188 	return SQLITE_OK
  85189 }
  85190 
  85191 var pragmaVtabModule = Sqlite3_module{
  85192 	FxConnect:    0,
  85193 	FxBestIndex:  0,
  85194 	FxDisconnect: 0,
  85195 	FxOpen:       0,
  85196 	FxClose:      0,
  85197 	FxFilter:     0,
  85198 	FxNext:       0,
  85199 	FxEof:        0,
  85200 	FxColumn:     0,
  85201 	FxRowid:      0,
  85202 }
  85203 
  85204 // Check to see if zTabName is really the name of a pragma.  If it is,
  85205 // then register an eponymous virtual table for that pragma and return
  85206 // a pointer to the Module object for the new virtual table.
  85207 func Xsqlite3PragmaVtabRegister(tls *libc.TLS, db uintptr, zName uintptr) uintptr {
  85208 	var pName uintptr
  85209 
  85210 	pName = pragmaLocate(tls, zName+uintptr(7))
  85211 	if pName == uintptr(0) {
  85212 		return uintptr(0)
  85213 	}
  85214 	if int32((*PragmaName)(unsafe.Pointer(pName)).FmPragFlg)&(PragFlg_Result0|PragFlg_Result1) == 0 {
  85215 		return uintptr(0)
  85216 	}
  85217 
  85218 	return Xsqlite3VtabCreateModule(tls, db, zName, uintptr(unsafe.Pointer(&pragmaVtabModule)), pName, uintptr(0))
  85219 }
  85220 
  85221 func corruptSchema(tls *libc.TLS, pData uintptr, azObj uintptr, zExtra uintptr) {
  85222 	bp := tls.Alloc(56)
  85223 	defer tls.Free(56)
  85224 
  85225 	var db uintptr = (*InitData)(unsafe.Pointer(pData)).Fdb
  85226 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  85227 		(*InitData)(unsafe.Pointer(pData)).Frc = SQLITE_NOMEM
  85228 	} else if *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) != uintptr(0) {
  85229 	} else if (*InitData)(unsafe.Pointer(pData)).FmInitFlags&U32(INITFLAG_AlterMask) != 0 {
  85230 		*(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) = Xsqlite3MPrintf(tls, db,
  85231 			ts+18242, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azObj)), *(*uintptr)(unsafe.Pointer(azObj + 1*4)),
  85232 				azAlterType[(*InitData)(unsafe.Pointer(pData)).FmInitFlags&U32(INITFLAG_AlterMask)-U32(1)],
  85233 				zExtra))
  85234 		(*InitData)(unsafe.Pointer(pData)).Frc = SQLITE_ERROR
  85235 	} else if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_WriteSchema) != 0 {
  85236 		(*InitData)(unsafe.Pointer(pData)).Frc = Xsqlite3CorruptError(tls, 137249)
  85237 	} else {
  85238 		var z uintptr
  85239 		var zObj uintptr
  85240 		if *(*uintptr)(unsafe.Pointer(azObj + 1*4)) != 0 {
  85241 			zObj = *(*uintptr)(unsafe.Pointer(azObj + 1*4))
  85242 		} else {
  85243 			zObj = ts + 5008
  85244 		}
  85245 		z = Xsqlite3MPrintf(tls, db, ts+18270, libc.VaList(bp+32, zObj))
  85246 		if zExtra != 0 && *(*uint8)(unsafe.Pointer(zExtra)) != 0 {
  85247 			z = Xsqlite3MPrintf(tls, db, ts+18301, libc.VaList(bp+40, z, zExtra))
  85248 		}
  85249 		*(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) = z
  85250 		(*InitData)(unsafe.Pointer(pData)).Frc = Xsqlite3CorruptError(tls, 137256)
  85251 	}
  85252 }
  85253 
  85254 var azAlterType = [3]uintptr{
  85255 	ts + 18309,
  85256 	ts + 18316,
  85257 	ts + 18328,
  85258 }
  85259 
  85260 // Check to see if any sibling index (another index on the same table)
  85261 // of pIndex has the same root page number, and if it does, return true.
  85262 // This would indicate a corrupt schema.
  85263 func Xsqlite3IndexHasDuplicateRootPage(tls *libc.TLS, pIndex uintptr) int32 {
  85264 	var p uintptr
  85265 	for p = (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FpIndex; p != 0; p = (*Index)(unsafe.Pointer(p)).FpNext {
  85266 		if (*Index)(unsafe.Pointer(p)).Ftnum == (*Index)(unsafe.Pointer(pIndex)).Ftnum && p != pIndex {
  85267 			return 1
  85268 		}
  85269 	}
  85270 	return 0
  85271 }
  85272 
  85273 // This is the callback routine for the code that initializes the
  85274 // database.  See sqlite3Init() below for additional information.
  85275 // This routine is also called from the OP_ParseSchema opcode of the VDBE.
  85276 //
  85277 // Each callback contains the following information:
  85278 //
  85279 //	argv[0] = type of object: "table", "index", "trigger", or "view".
  85280 //	argv[1] = name of thing being created
  85281 //	argv[2] = associated table if an index or trigger
  85282 //	argv[3] = root page number for table or index. 0 for trigger or view.
  85283 //	argv[4] = SQL text for the CREATE statement.
  85284 func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr, NotUsed uintptr) int32 {
  85285 	bp := tls.Alloc(4)
  85286 	defer tls.Free(4)
  85287 
  85288 	var pData uintptr = pInit
  85289 	var db uintptr = (*InitData)(unsafe.Pointer(pData)).Fdb
  85290 	var iDb int32 = (*InitData)(unsafe.Pointer(pData)).FiDb
  85291 
  85292 	_ = NotUsed
  85293 	_ = argc
  85294 
  85295 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_EncodingFixed)
  85296 	if argv == uintptr(0) {
  85297 		return 0
  85298 	}
  85299 	(*InitData)(unsafe.Pointer(pData)).FnInitRow++
  85300 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  85301 		corruptSchema(tls, pData, argv, uintptr(0))
  85302 		return 1
  85303 	}
  85304 
  85305 	if *(*uintptr)(unsafe.Pointer(argv + 3*4)) == uintptr(0) {
  85306 		corruptSchema(tls, pData, argv, uintptr(0))
  85307 	} else if *(*uintptr)(unsafe.Pointer(argv + 4*4)) != 0 &&
  85308 		'c' == int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 4*4))))]) &&
  85309 		'r' == int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 4*4)) + 1))]) {
  85310 		var rc int32
  85311 		var saved_iDb U8 = (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb
  85312 
  85313 		(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(iDb)
  85314 		if Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4)), db+172) == 0 ||
  85315 			(*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum > (*InitData)(unsafe.Pointer(pData)).FmxPage && (*InitData)(unsafe.Pointer(pData)).FmxPage > Pgno(0) {
  85316 			if Xsqlite3Config.FbExtraSchemaChecks != 0 {
  85317 				corruptSchema(tls, pData, argv, ts+14140)
  85318 			}
  85319 		}
  85320 		libc.SetBitFieldPtr8Uint32(db+172+8, uint32(0), 0, 0x1)
  85321 		(*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit = argv
  85322 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  85323 		sqlite3Prepare(tls, db, *(*uintptr)(unsafe.Pointer(argv + 4*4)), -1, uint32(0), uintptr(0), bp, uintptr(0))
  85324 		rc = (*Sqlite3)(unsafe.Pointer(db)).FerrCode
  85325 
  85326 		(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = saved_iDb
  85327 
  85328 		if SQLITE_OK != rc {
  85329 			if uint32(int32(*(*uint8)(unsafe.Pointer(db + 172 + 8))&0x1>>0)) != 0 {
  85330 			} else {
  85331 				if rc > (*InitData)(unsafe.Pointer(pData)).Frc {
  85332 					(*InitData)(unsafe.Pointer(pData)).Frc = rc
  85333 				}
  85334 				if rc == SQLITE_NOMEM {
  85335 					Xsqlite3OomFault(tls, db)
  85336 				} else if rc != SQLITE_INTERRUPT && rc&0xFF != SQLITE_LOCKED {
  85337 					corruptSchema(tls, pData, argv, Xsqlite3_errmsg(tls, db))
  85338 				}
  85339 			}
  85340 		}
  85341 		(*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit = uintptr(unsafe.Pointer(&Xsqlite3StdType))
  85342 		Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  85343 	} else if *(*uintptr)(unsafe.Pointer(argv + 1*4)) == uintptr(0) || *(*uintptr)(unsafe.Pointer(argv + 4*4)) != uintptr(0) && int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 4*4))))) != 0 {
  85344 		corruptSchema(tls, pData, argv, uintptr(0))
  85345 	} else {
  85346 		var pIndex uintptr
  85347 		pIndex = Xsqlite3FindIndex(tls, db, *(*uintptr)(unsafe.Pointer(argv + 1*4)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName)
  85348 		if pIndex == uintptr(0) {
  85349 			corruptSchema(tls, pData, argv, ts+18339)
  85350 		} else if Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4)), pIndex+44) == 0 ||
  85351 			(*Index)(unsafe.Pointer(pIndex)).Ftnum < Pgno(2) ||
  85352 			(*Index)(unsafe.Pointer(pIndex)).Ftnum > (*InitData)(unsafe.Pointer(pData)).FmxPage ||
  85353 			Xsqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 {
  85354 			if Xsqlite3Config.FbExtraSchemaChecks != 0 {
  85355 				corruptSchema(tls, pData, argv, ts+14140)
  85356 			}
  85357 		}
  85358 	}
  85359 	return 0
  85360 }
  85361 
  85362 // Attempt to read the database schema and initialize internal
  85363 // data structures for a single database file.  The index of the
  85364 // database file is given by iDb.  iDb==0 is used for the main
  85365 // database.  iDb==1 should never be used.  iDb>=2 is used for
  85366 // auxiliary databases.  Return one of the SQLITE_ error codes to
  85367 // indicate success or failure.
  85368 func Xsqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFlags U32) int32 {
  85369 	bp := tls.Alloc(88)
  85370 	defer tls.Free(88)
  85371 
  85372 	var rc int32
  85373 	var i int32
  85374 	var size int32
  85375 	var pDb uintptr
  85376 
  85377 	var zSchemaTabName uintptr
  85378 	var openedTransaction int32
  85379 	var mask int32
  85380 	var encoding U8
  85381 	var xAuth Sqlite3_xauth
  85382 	var zSql uintptr
  85383 	openedTransaction = 0
  85384 	mask = int32((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_EncodingFixed) | libc.Uint32FromInt32(libc.CplInt32(DBFLAG_EncodingFixed)))
  85385 
  85386 	(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(1)
  85387 
  85388 	*(*uintptr)(unsafe.Pointer(bp + 16)) = ts + 8876
  85389 	*(*uintptr)(unsafe.Pointer(bp + 16 + 1*4)) = libc.AssignUintptr(&zSchemaTabName, func() uintptr {
  85390 		if !(0 != 0) && iDb == 1 {
  85391 			return ts + 6389
  85392 		}
  85393 		return ts + 5883
  85394 	}())
  85395 	*(*uintptr)(unsafe.Pointer(bp + 16 + 2*4)) = *(*uintptr)(unsafe.Pointer(bp + 16 + 1*4))
  85396 	*(*uintptr)(unsafe.Pointer(bp + 16 + 3*4)) = ts + 7938
  85397 	*(*uintptr)(unsafe.Pointer(bp + 16 + 4*4)) = ts + 18352
  85398 	*(*uintptr)(unsafe.Pointer(bp + 16 + 5*4)) = uintptr(0)
  85399 	(*InitData)(unsafe.Pointer(bp + 40)).Fdb = db
  85400 	(*InitData)(unsafe.Pointer(bp + 40)).FiDb = iDb
  85401 	(*InitData)(unsafe.Pointer(bp + 40)).Frc = SQLITE_OK
  85402 	(*InitData)(unsafe.Pointer(bp + 40)).FpzErrMsg = pzErrMsg
  85403 	(*InitData)(unsafe.Pointer(bp + 40)).FmInitFlags = mFlags
  85404 	(*InitData)(unsafe.Pointer(bp + 40)).FnInitRow = U32(0)
  85405 	(*InitData)(unsafe.Pointer(bp + 40)).FmxPage = Pgno(0)
  85406 	Xsqlite3InitCallback(tls, bp+40, 5, bp+16, uintptr(0))
  85407 	*(*U32)(unsafe.Pointer(db + 24)) &= U32(mask)
  85408 	if !((*InitData)(unsafe.Pointer(bp+40)).Frc != 0) {
  85409 		goto __1
  85410 	}
  85411 	rc = (*InitData)(unsafe.Pointer(bp + 40)).Frc
  85412 	goto error_out
  85413 __1:
  85414 	;
  85415 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  85416 	if !((*Db)(unsafe.Pointer(pDb)).FpBt == uintptr(0)) {
  85417 		goto __2
  85418 	}
  85419 
  85420 	*(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema + 78)) |= U16(DB_SchemaLoaded)
  85421 	rc = SQLITE_OK
  85422 	goto error_out
  85423 __2:
  85424 	;
  85425 	Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  85426 	if !(Xsqlite3BtreeTxnState(tls, (*Db)(unsafe.Pointer(pDb)).FpBt) == SQLITE_TXN_NONE) {
  85427 		goto __3
  85428 	}
  85429 	rc = Xsqlite3BtreeBeginTrans(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, 0, uintptr(0))
  85430 	if !(rc != SQLITE_OK) {
  85431 		goto __4
  85432 	}
  85433 	Xsqlite3SetString(tls, pzErrMsg, db, Xsqlite3ErrStr(tls, rc))
  85434 	goto initone_error_out
  85435 __4:
  85436 	;
  85437 	openedTransaction = 1
  85438 __3:
  85439 	;
  85440 	i = 0
  85441 __5:
  85442 	if !(i < int32(uint32(unsafe.Sizeof([5]int32{}))/uint32(unsafe.Sizeof(int32(0))))) {
  85443 		goto __7
  85444 	}
  85445 	Xsqlite3BtreeGetMeta(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, i+1, bp+68+uintptr(i)*4)
  85446 	goto __6
  85447 __6:
  85448 	i++
  85449 	goto __5
  85450 	goto __7
  85451 __7:
  85452 	;
  85453 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ResetDatabase) != uint64(0)) {
  85454 		goto __8
  85455 	}
  85456 	libc.Xmemset(tls, bp+68, 0, uint32(unsafe.Sizeof([5]int32{})))
  85457 __8:
  85458 	;
  85459 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = *(*int32)(unsafe.Pointer(bp + 68))
  85460 
  85461 	if !(*(*int32)(unsafe.Pointer(bp + 68 + 4*4)) != 0) {
  85462 		goto __9
  85463 	}
  85464 	if !(iDb == 0 && (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_EncodingFixed) == U32(0)) {
  85465 		goto __10
  85466 	}
  85467 
  85468 	encoding = U8(int32(U8(*(*int32)(unsafe.Pointer(bp + 68 + 4*4)))) & 3)
  85469 	if !(int32(encoding) == 0) {
  85470 		goto __12
  85471 	}
  85472 	encoding = U8(SQLITE_UTF8)
  85473 __12:
  85474 	;
  85475 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive > 0 && int32(encoding) != int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) {
  85476 		goto __13
  85477 	}
  85478 	rc = SQLITE_LOCKED
  85479 	goto initone_error_out
  85480 	goto __14
  85481 __13:
  85482 	Xsqlite3SetTextEncoding(tls, db, encoding)
  85483 __14:
  85484 	;
  85485 	goto __11
  85486 __10:
  85487 	if !(*(*int32)(unsafe.Pointer(bp + 68 + 4*4))&3 != int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) {
  85488 		goto __15
  85489 	}
  85490 	Xsqlite3SetString(tls, pzErrMsg, db,
  85491 		ts+11775)
  85492 	rc = SQLITE_ERROR
  85493 	goto initone_error_out
  85494 __15:
  85495 	;
  85496 __11:
  85497 	;
  85498 __9:
  85499 	;
  85500 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  85501 
  85502 	if !((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size == 0) {
  85503 		goto __16
  85504 	}
  85505 	size = Xsqlite3AbsInt32(tls, *(*int32)(unsafe.Pointer(bp + 68 + 2*4)))
  85506 	if !(size == 0) {
  85507 		goto __17
  85508 	}
  85509 	size = -2000
  85510 __17:
  85511 	;
  85512 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size
  85513 	Xsqlite3BtreeSetCacheSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)
  85514 __16:
  85515 	;
  85516 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(*(*int32)(unsafe.Pointer(bp + 68 + 1*4)))
  85517 	if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) == 0) {
  85518 		goto __18
  85519 	}
  85520 	(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(1)
  85521 __18:
  85522 	;
  85523 	if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > SQLITE_MAX_FILE_FORMAT) {
  85524 		goto __19
  85525 	}
  85526 	Xsqlite3SetString(tls, pzErrMsg, db, ts+18424)
  85527 	rc = SQLITE_ERROR
  85528 	goto initone_error_out
  85529 __19:
  85530 	;
  85531 	if !(iDb == 0 && *(*int32)(unsafe.Pointer(bp + 68 + 1*4)) >= 4) {
  85532 		goto __20
  85533 	}
  85534 	*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_LegacyFileFmt))
  85535 __20:
  85536 	;
  85537 	(*InitData)(unsafe.Pointer(bp + 40)).FmxPage = Xsqlite3BtreeLastPage(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  85538 
  85539 	zSql = Xsqlite3MPrintf(tls, db,
  85540 		ts+18448,
  85541 		libc.VaList(bp, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName, zSchemaTabName))
  85542 
  85543 	xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth
  85544 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0)
  85545 	rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct {
  85546 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
  85547 	}{Xsqlite3InitCallback})), bp+40, uintptr(0))
  85548 	(*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth
  85549 
  85550 	if !(rc == SQLITE_OK) {
  85551 		goto __21
  85552 	}
  85553 	rc = (*InitData)(unsafe.Pointer(bp + 40)).Frc
  85554 __21:
  85555 	;
  85556 	Xsqlite3DbFree(tls, db, zSql)
  85557 	if !(rc == SQLITE_OK) {
  85558 		goto __22
  85559 	}
  85560 	Xsqlite3AnalysisLoad(tls, db, iDb)
  85561 __22:
  85562 	;
  85563 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  85564 		goto __23
  85565 	}
  85566 	rc = SQLITE_NOMEM
  85567 	Xsqlite3ResetAllSchemasOfConnection(tls, db)
  85568 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16
  85569 	goto __24
  85570 __23:
  85571 	if !(rc == SQLITE_OK || (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_NoSchemaError) != 0 && rc != SQLITE_NOMEM) {
  85572 		goto __25
  85573 	}
  85574 
  85575 	*(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 78)) |= U16(DB_SchemaLoaded)
  85576 	rc = SQLITE_OK
  85577 __25:
  85578 	;
  85579 __24:
  85580 	;
  85581 initone_error_out:
  85582 	if !(openedTransaction != 0) {
  85583 		goto __26
  85584 	}
  85585 	Xsqlite3BtreeCommit(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  85586 __26:
  85587 	;
  85588 	Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  85589 
  85590 error_out:
  85591 	if !(rc != 0) {
  85592 		goto __27
  85593 	}
  85594 	if !(rc == SQLITE_NOMEM || rc == SQLITE_IOERR|int32(12)<<8) {
  85595 		goto __28
  85596 	}
  85597 	Xsqlite3OomFault(tls, db)
  85598 __28:
  85599 	;
  85600 	Xsqlite3ResetOneSchema(tls, db, iDb)
  85601 __27:
  85602 	;
  85603 	(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(0)
  85604 	return rc
  85605 }
  85606 
  85607 // Initialize all database files - the main database file, the file
  85608 // used to store temporary tables, and any additional database files
  85609 // created using ATTACH statements.  Return a success code.  If an
  85610 // error occurs, write an error message into *pzErrMsg.
  85611 //
  85612 // After a database is initialized, the DB_SchemaLoaded bit is set
  85613 // bit is set in the flags field of the Db structure.
  85614 func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 {
  85615 	var i int32
  85616 	var rc int32
  85617 	var commit_internal int32 = libc.BoolInt32(!((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_SchemaChange) != 0))
  85618 
  85619 	(*Sqlite3)(unsafe.Pointer(db)).Fenc = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fenc
  85620 
  85621 	if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).FschemaFlags)&DB_SchemaLoaded == DB_SchemaLoaded) {
  85622 		rc = Xsqlite3InitOne(tls, db, 0, pzErrMsg, uint32(0))
  85623 		if rc != 0 {
  85624 			return rc
  85625 		}
  85626 	}
  85627 
  85628 	for i = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1; i > 0; i-- {
  85629 		if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema)).FschemaFlags)&DB_SchemaLoaded == DB_SchemaLoaded) {
  85630 			rc = Xsqlite3InitOne(tls, db, i, pzErrMsg, uint32(0))
  85631 			if rc != 0 {
  85632 				return rc
  85633 			}
  85634 		}
  85635 	}
  85636 	if commit_internal != 0 {
  85637 		Xsqlite3CommitInternalChanges(tls, db)
  85638 	}
  85639 	return SQLITE_OK
  85640 }
  85641 
  85642 // This routine is a no-op if the database schema is already initialized.
  85643 // Otherwise, the schema is loaded. An error code is returned.
  85644 func Xsqlite3ReadSchema(tls *libc.TLS, pParse uintptr) int32 {
  85645 	var rc int32 = SQLITE_OK
  85646 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  85647 
  85648 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) {
  85649 		rc = Xsqlite3Init(tls, db, pParse+4)
  85650 		if rc != SQLITE_OK {
  85651 			(*Parse)(unsafe.Pointer(pParse)).Frc = rc
  85652 			(*Parse)(unsafe.Pointer(pParse)).FnErr++
  85653 		} else if (*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0 {
  85654 			*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaKnownOk)
  85655 		}
  85656 	}
  85657 	return rc
  85658 }
  85659 
  85660 func schemaIsValid(tls *libc.TLS, pParse uintptr) {
  85661 	bp := tls.Alloc(4)
  85662 	defer tls.Free(4)
  85663 
  85664 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  85665 	var iDb int32
  85666 	var rc int32
  85667 
  85668 	for iDb = 0; iDb < (*Sqlite3)(unsafe.Pointer(db)).FnDb; iDb++ {
  85669 		var openedTransaction int32 = 0
  85670 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
  85671 		if pBt == uintptr(0) {
  85672 			continue
  85673 		}
  85674 
  85675 		if Xsqlite3BtreeTxnState(tls, pBt) == SQLITE_TXN_NONE {
  85676 			rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0))
  85677 			if rc == SQLITE_NOMEM || rc == SQLITE_IOERR|int32(12)<<8 {
  85678 				Xsqlite3OomFault(tls, db)
  85679 				(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
  85680 			}
  85681 			if rc != SQLITE_OK {
  85682 				return
  85683 			}
  85684 			openedTransaction = 1
  85685 		}
  85686 
  85687 		Xsqlite3BtreeGetMeta(tls, pBt, BTREE_SCHEMA_VERSION, bp)
  85688 
  85689 		if *(*int32)(unsafe.Pointer(bp)) != (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema)).Fschema_cookie {
  85690 			if int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema)).FschemaFlags)&DB_SchemaLoaded == DB_SchemaLoaded {
  85691 				(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_SCHEMA
  85692 			}
  85693 			Xsqlite3ResetOneSchema(tls, db, iDb)
  85694 		}
  85695 
  85696 		if openedTransaction != 0 {
  85697 			Xsqlite3BtreeCommit(tls, pBt)
  85698 		}
  85699 	}
  85700 }
  85701 
  85702 // Convert a schema pointer into the iDb index that indicates
  85703 // which database file in db->aDb[] the schema refers to.
  85704 //
  85705 // If the same database is attached more than once, the first
  85706 // attached database is returned.
  85707 func Xsqlite3SchemaToIndex(tls *libc.TLS, db uintptr, pSchema uintptr) int32 {
  85708 	var i int32 = -32768
  85709 
  85710 	if pSchema != 0 {
  85711 		for i = 0; 1 != 0; i++ {
  85712 			if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpSchema == pSchema {
  85713 				break
  85714 			}
  85715 		}
  85716 
  85717 	}
  85718 	return i
  85719 }
  85720 
  85721 // Free all memory allocations in the pParse object
  85722 func Xsqlite3ParseObjectReset(tls *libc.TLS, pParse uintptr) {
  85723 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  85724 
  85725 	if (*Parse)(unsafe.Pointer(pParse)).FaTableLock != 0 {
  85726 		Xsqlite3DbNNFreeNN(tls, db, (*Parse)(unsafe.Pointer(pParse)).FaTableLock)
  85727 	}
  85728 	for (*Parse)(unsafe.Pointer(pParse)).FpCleanup != 0 {
  85729 		var pCleanup uintptr = (*Parse)(unsafe.Pointer(pParse)).FpCleanup
  85730 		(*Parse)(unsafe.Pointer(pParse)).FpCleanup = (*ParseCleanup)(unsafe.Pointer(pCleanup)).FpNext
  85731 		(*struct {
  85732 			f func(*libc.TLS, uintptr, uintptr)
  85733 		})(unsafe.Pointer(&struct{ uintptr }{(*ParseCleanup)(unsafe.Pointer(pCleanup)).FxCleanup})).f(tls, db, (*ParseCleanup)(unsafe.Pointer(pCleanup)).FpPtr)
  85734 		Xsqlite3DbNNFreeNN(tls, db, pCleanup)
  85735 	}
  85736 	if (*Parse)(unsafe.Pointer(pParse)).FaLabel != 0 {
  85737 		Xsqlite3DbNNFreeNN(tls, db, (*Parse)(unsafe.Pointer(pParse)).FaLabel)
  85738 	}
  85739 	if (*Parse)(unsafe.Pointer(pParse)).FpConstExpr != 0 {
  85740 		Xsqlite3ExprListDelete(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpConstExpr)
  85741 	}
  85742 
  85743 	*(*U32)(unsafe.Pointer(db + 320)) -= U32((*Parse)(unsafe.Pointer(pParse)).FdisableLookaside)
  85744 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = func() uint16 {
  85745 		if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 {
  85746 			return uint16(0)
  85747 		}
  85748 		return (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue
  85749 	}()
  85750 
  85751 	(*Sqlite3)(unsafe.Pointer(db)).FpParse = (*Parse)(unsafe.Pointer(pParse)).FpOuterParse
  85752 	(*Parse)(unsafe.Pointer(pParse)).Fdb = uintptr(0)
  85753 	(*Parse)(unsafe.Pointer(pParse)).FdisableLookaside = U8(0)
  85754 }
  85755 
  85756 // Add a new cleanup operation to a Parser.  The cleanup should happen when
  85757 // the parser object is destroyed.  But, beware: the cleanup might happen
  85758 // immediately.
  85759 //
  85760 // Use this mechanism for uncommon cleanups.  There is a higher setup
  85761 // cost for this mechansim (an extra malloc), so it should not be used
  85762 // for common cleanups that happen on most calls.  But for less
  85763 // common cleanups, we save a single NULL-pointer comparison in
  85764 // sqlite3ParseObjectReset(), which reduces the total CPU cycle count.
  85765 //
  85766 // If a memory allocation error occurs, then the cleanup happens immediately.
  85767 // When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the
  85768 // pParse->earlyCleanup flag is set in that case.  Calling code show verify
  85769 // that test cases exist for which this happens, to guard against possible
  85770 // use-after-free errors following an OOM.  The preferred way to do this is
  85771 // to immediately follow the call to this routine with:
  85772 //
  85773 //	testcase( pParse->earlyCleanup );
  85774 //
  85775 // This routine returns a copy of its pPtr input (the third parameter)
  85776 // except if an early cleanup occurs, in which case it returns NULL.  So
  85777 // another way to check for early cleanup is to check the return value.
  85778 // Or, stop using the pPtr parameter with this call and use only its
  85779 // return value thereafter.  Something like this:
  85780 //
  85781 //	pObj = sqlite3ParserAddCleanup(pParse, destructor, pObj);
  85782 func Xsqlite3ParserAddCleanup(tls *libc.TLS, pParse uintptr, xCleanup uintptr, pPtr uintptr) uintptr {
  85783 	var pCleanup uintptr = Xsqlite3DbMallocRaw(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(ParseCleanup{})))
  85784 	if pCleanup != 0 {
  85785 		(*ParseCleanup)(unsafe.Pointer(pCleanup)).FpNext = (*Parse)(unsafe.Pointer(pParse)).FpCleanup
  85786 		(*Parse)(unsafe.Pointer(pParse)).FpCleanup = pCleanup
  85787 		(*ParseCleanup)(unsafe.Pointer(pCleanup)).FpPtr = pPtr
  85788 		(*ParseCleanup)(unsafe.Pointer(pCleanup)).FxCleanup = xCleanup
  85789 	} else {
  85790 		(*struct {
  85791 			f func(*libc.TLS, uintptr, uintptr)
  85792 		})(unsafe.Pointer(&struct{ uintptr }{xCleanup})).f(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pPtr)
  85793 		pPtr = uintptr(0)
  85794 	}
  85795 	return pPtr
  85796 }
  85797 
  85798 // Turn bulk memory into a valid Parse object and link that Parse object
  85799 // into database connection db.
  85800 //
  85801 // Call sqlite3ParseObjectReset() to undo this operation.
  85802 //
  85803 // Caution:  Do not confuse this routine with sqlite3ParseObjectInit() which
  85804 // is generated by Lemon.
  85805 func Xsqlite3ParseObjectInit(tls *libc.TLS, pParse uintptr, db uintptr) {
  85806 	libc.Xmemset(tls, pParse+uintptr(uint32(uintptr(0)+4)), 0, uint32(uintptr(0)+160)-uint32(uintptr(0)+4))
  85807 	libc.Xmemset(tls, pParse+uintptr(uint32(uintptr(0)+204)), 0, uint32(unsafe.Sizeof(Parse{}))-uint32(uintptr(0)+204))
  85808 
  85809 	(*Parse)(unsafe.Pointer(pParse)).FpOuterParse = (*Sqlite3)(unsafe.Pointer(db)).FpParse
  85810 	(*Sqlite3)(unsafe.Pointer(db)).FpParse = pParse
  85811 	(*Parse)(unsafe.Pointer(pParse)).Fdb = db
  85812 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  85813 		Xsqlite3ErrorMsg(tls, pParse, ts+1490, 0)
  85814 	}
  85815 }
  85816 
  85817 func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags U32, pReprepare uintptr, ppStmt uintptr, pzTail uintptr) int32 {
  85818 	bp := tls.Alloc(296)
  85819 	defer tls.Free(296)
  85820 
  85821 	var rc int32
  85822 	var i int32
  85823 
  85824 	var zDb uintptr
  85825 	var pBt uintptr
  85826 	var zSqlCopy uintptr
  85827 	var mxLen int32
  85828 	var pT uintptr
  85829 	rc = SQLITE_OK
  85830 
  85831 	libc.Xmemset(tls, bp+16+uintptr(uint32(uintptr(0)+4)), 0, uint32(uintptr(0)+160)-uint32(uintptr(0)+4))
  85832 	libc.Xmemset(tls, bp+16+uintptr(uint32(uintptr(0)+204)), 0, uint32(unsafe.Sizeof(Parse{}))-uint32(uintptr(0)+204))
  85833 	(*Parse)(unsafe.Pointer(bp + 16)).FpOuterParse = (*Sqlite3)(unsafe.Pointer(db)).FpParse
  85834 	(*Sqlite3)(unsafe.Pointer(db)).FpParse = bp + 16
  85835 	(*Parse)(unsafe.Pointer(bp + 16)).Fdb = db
  85836 	(*Parse)(unsafe.Pointer(bp + 16)).FpReprepare = pReprepare
  85837 
  85838 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  85839 		goto __1
  85840 	}
  85841 	Xsqlite3ErrorMsg(tls, bp+16, ts+1490, 0)
  85842 __1:
  85843 	;
  85844 	if !(prepFlags&U32(SQLITE_PREPARE_PERSISTENT) != 0) {
  85845 		goto __2
  85846 	}
  85847 	(*Parse)(unsafe.Pointer(bp+16)).FdisableLookaside++
  85848 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++
  85849 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
  85850 __2:
  85851 	;
  85852 	(*Parse)(unsafe.Pointer(bp + 16)).FprepFlags = U8(prepFlags & U32(0xff))
  85853 
  85854 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache) != 0) {
  85855 		goto __3
  85856 	}
  85857 	i = 0
  85858 __4:
  85859 	if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  85860 		goto __6
  85861 	}
  85862 	pBt = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
  85863 	if !(pBt != 0) {
  85864 		goto __7
  85865 	}
  85866 
  85867 	rc = Xsqlite3BtreeSchemaLocked(tls, pBt)
  85868 	if !(rc != 0) {
  85869 		goto __8
  85870 	}
  85871 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FzDbSName
  85872 	Xsqlite3ErrorWithMsg(tls, db, rc, ts+18482, libc.VaList(bp, zDb))
  85873 
  85874 	goto end_prepare
  85875 __8:
  85876 	;
  85877 __7:
  85878 	;
  85879 	goto __5
  85880 __5:
  85881 	i++
  85882 	goto __4
  85883 	goto __6
  85884 __6:
  85885 	;
  85886 __3:
  85887 	;
  85888 	if !((*Sqlite3)(unsafe.Pointer(db)).FpDisconnect != 0) {
  85889 		goto __9
  85890 	}
  85891 	Xsqlite3VtabUnlockList(tls, db)
  85892 __9:
  85893 	;
  85894 	if !(nBytes >= 0 && (nBytes == 0 || int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(nBytes-1)))) != 0)) {
  85895 		goto __10
  85896 	}
  85897 	mxLen = *(*int32)(unsafe.Pointer(db + 120 + 1*4))
  85898 
  85899 	if !(nBytes > mxLen) {
  85900 		goto __12
  85901 	}
  85902 	Xsqlite3ErrorWithMsg(tls, db, SQLITE_TOOBIG, ts+18512, 0)
  85903 	rc = Xsqlite3ApiExit(tls, db, SQLITE_TOOBIG)
  85904 	goto end_prepare
  85905 __12:
  85906 	;
  85907 	zSqlCopy = Xsqlite3DbStrNDup(tls, db, zSql, uint64(nBytes))
  85908 	if !(zSqlCopy != 0) {
  85909 		goto __13
  85910 	}
  85911 	Xsqlite3RunParser(tls, bp+16, zSqlCopy)
  85912 	(*Parse)(unsafe.Pointer(bp + 16)).FzTail = zSql + uintptr((int32((*Parse)(unsafe.Pointer(bp+16)).FzTail)-int32(zSqlCopy))/1)
  85913 	Xsqlite3DbFree(tls, db, zSqlCopy)
  85914 	goto __14
  85915 __13:
  85916 	(*Parse)(unsafe.Pointer(bp + 16)).FzTail = zSql + uintptr(nBytes)
  85917 __14:
  85918 	;
  85919 	goto __11
  85920 __10:
  85921 	Xsqlite3RunParser(tls, bp+16, zSql)
  85922 __11:
  85923 	;
  85924 	if !(pzTail != 0) {
  85925 		goto __15
  85926 	}
  85927 	*(*uintptr)(unsafe.Pointer(pzTail)) = (*Parse)(unsafe.Pointer(bp + 16)).FzTail
  85928 __15:
  85929 	;
  85930 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0) {
  85931 		goto __16
  85932 	}
  85933 	Xsqlite3VdbeSetSql(tls, (*Parse)(unsafe.Pointer(bp+16)).FpVdbe, zSql, (int32((*Parse)(unsafe.Pointer(bp+16)).FzTail)-int32(zSql))/1, uint8(prepFlags))
  85934 __16:
  85935 	;
  85936 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  85937 		goto __17
  85938 	}
  85939 	(*Parse)(unsafe.Pointer(bp + 16)).Frc = SQLITE_NOMEM
  85940 	(*Parse)(unsafe.Pointer(bp + 16)).FcheckSchema = U8(0)
  85941 __17:
  85942 	;
  85943 	if !((*Parse)(unsafe.Pointer(bp+16)).Frc != SQLITE_OK && (*Parse)(unsafe.Pointer(bp+16)).Frc != SQLITE_DONE) {
  85944 		goto __18
  85945 	}
  85946 	if !((*Parse)(unsafe.Pointer(bp+16)).FcheckSchema != 0 && int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0) {
  85947 		goto __20
  85948 	}
  85949 	schemaIsValid(tls, bp+16)
  85950 __20:
  85951 	;
  85952 	if !((*Parse)(unsafe.Pointer(bp+16)).FpVdbe != 0) {
  85953 		goto __21
  85954 	}
  85955 	Xsqlite3VdbeFinalize(tls, (*Parse)(unsafe.Pointer(bp+16)).FpVdbe)
  85956 __21:
  85957 	;
  85958 	rc = (*Parse)(unsafe.Pointer(bp + 16)).Frc
  85959 	if !((*Parse)(unsafe.Pointer(bp+16)).FzErrMsg != 0) {
  85960 		goto __22
  85961 	}
  85962 	Xsqlite3ErrorWithMsg(tls, db, rc, ts+3663, libc.VaList(bp+8, (*Parse)(unsafe.Pointer(bp+16)).FzErrMsg))
  85963 	Xsqlite3DbFree(tls, db, (*Parse)(unsafe.Pointer(bp+16)).FzErrMsg)
  85964 	goto __23
  85965 __22:
  85966 	Xsqlite3Error(tls, db, rc)
  85967 __23:
  85968 	;
  85969 	goto __19
  85970 __18:
  85971 	;
  85972 	*(*uintptr)(unsafe.Pointer(ppStmt)) = (*Parse)(unsafe.Pointer(bp + 16)).FpVdbe
  85973 	rc = SQLITE_OK
  85974 	Xsqlite3ErrorClear(tls, db)
  85975 __19:
  85976 	;
  85977 __24:
  85978 	if !((*Parse)(unsafe.Pointer(bp+16)).FpTriggerPrg != 0) {
  85979 		goto __25
  85980 	}
  85981 	pT = (*Parse)(unsafe.Pointer(bp + 16)).FpTriggerPrg
  85982 	(*Parse)(unsafe.Pointer(bp + 16)).FpTriggerPrg = (*TriggerPrg)(unsafe.Pointer(pT)).FpNext
  85983 	Xsqlite3DbFree(tls, db, pT)
  85984 	goto __24
  85985 __25:
  85986 	;
  85987 end_prepare:
  85988 	Xsqlite3ParseObjectReset(tls, bp+16)
  85989 	return rc
  85990 }
  85991 
  85992 func sqlite3LockAndPrepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags U32, pOld uintptr, ppStmt uintptr, pzTail uintptr) int32 {
  85993 	var rc int32
  85994 	var cnt int32 = 0
  85995 
  85996 	*(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0)
  85997 	if !(Xsqlite3SafetyCheckOk(tls, db) != 0) || zSql == uintptr(0) {
  85998 		return Xsqlite3MisuseError(tls, 138048)
  85999 	}
  86000 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  86001 	Xsqlite3BtreeEnterAll(tls, db)
  86002 	for __ccgo := true; __ccgo; __ccgo = rc == SQLITE_ERROR|int32(2)<<8 && libc.PostIncInt32(&cnt, 1) < SQLITE_MAX_PREPARE_RETRY ||
  86003 		rc == SQLITE_SCHEMA && func() int32 { Xsqlite3ResetOneSchema(tls, db, -1); return libc.PostIncInt32(&cnt, 1) }() == 0 {
  86004 		rc = sqlite3Prepare(tls, db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail)
  86005 
  86006 		if rc == SQLITE_OK || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  86007 			break
  86008 		}
  86009 	}
  86010 	Xsqlite3BtreeLeaveAll(tls, db)
  86011 	rc = Xsqlite3ApiExit(tls, db, rc)
  86012 
  86013 	(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
  86014 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  86015 	return rc
  86016 }
  86017 
  86018 // Rerun the compilation of a statement after a schema change.
  86019 //
  86020 // If the statement is successfully recompiled, return SQLITE_OK. Otherwise,
  86021 // if the statement cannot be recompiled because another connection has
  86022 // locked the sqlite3_schema table, return SQLITE_LOCKED. If any other error
  86023 // occurs, return SQLITE_SCHEMA.
  86024 func Xsqlite3Reprepare(tls *libc.TLS, p uintptr) int32 {
  86025 	bp := tls.Alloc(4)
  86026 	defer tls.Free(4)
  86027 
  86028 	var rc int32
  86029 
  86030 	var zSql uintptr
  86031 	var db uintptr
  86032 	var prepFlags U8
  86033 
  86034 	zSql = Xsqlite3_sql(tls, p)
  86035 
  86036 	db = Xsqlite3VdbeDb(tls, p)
  86037 
  86038 	prepFlags = Xsqlite3VdbePrepareFlags(tls, p)
  86039 	rc = sqlite3LockAndPrepare(tls, db, zSql, -1, uint32(prepFlags), p, bp, uintptr(0))
  86040 	if rc != 0 {
  86041 		if rc == SQLITE_NOMEM {
  86042 			Xsqlite3OomFault(tls, db)
  86043 		}
  86044 
  86045 		return rc
  86046 	} else {
  86047 	}
  86048 	Xsqlite3VdbeSwap(tls, *(*uintptr)(unsafe.Pointer(bp)), p)
  86049 	Xsqlite3TransferBindings(tls, *(*uintptr)(unsafe.Pointer(bp)), p)
  86050 	Xsqlite3VdbeResetStepResult(tls, *(*uintptr)(unsafe.Pointer(bp)))
  86051 	Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  86052 	return SQLITE_OK
  86053 }
  86054 
  86055 // Two versions of the official API.  Legacy and new use.  In the legacy
  86056 // version, the original SQL text is not saved in the prepared statement
  86057 // and so if a schema change occurs, SQLITE_SCHEMA is returned by
  86058 // sqlite3_step().  In the new version, the original SQL text is retained
  86059 // and the statement is automatically recompiled if an schema change
  86060 // occurs.
  86061 func Xsqlite3_prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) int32 {
  86062 	var rc int32
  86063 	rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(0), uintptr(0), ppStmt, pzTail)
  86064 
  86065 	return rc
  86066 }
  86067 
  86068 func Xsqlite3_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) int32 {
  86069 	var rc int32
  86070 
  86071 	rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL), uintptr(0),
  86072 		ppStmt, pzTail)
  86073 
  86074 	return rc
  86075 }
  86076 
  86077 func Xsqlite3_prepare_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) int32 {
  86078 	var rc int32
  86079 
  86080 	rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes,
  86081 		uint32(SQLITE_PREPARE_SAVESQL)|prepFlags&uint32(SQLITE_PREPARE_MASK),
  86082 		uintptr(0), ppStmt, pzTail)
  86083 
  86084 	return rc
  86085 }
  86086 
  86087 func sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags U32, ppStmt uintptr, pzTail uintptr) int32 {
  86088 	bp := tls.Alloc(4)
  86089 	defer tls.Free(4)
  86090 
  86091 	var zSql8 uintptr
  86092 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  86093 	var rc int32 = SQLITE_OK
  86094 
  86095 	*(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0)
  86096 	if !(Xsqlite3SafetyCheckOk(tls, db) != 0) || zSql == uintptr(0) {
  86097 		return Xsqlite3MisuseError(tls, 138196)
  86098 	}
  86099 	if nBytes >= 0 {
  86100 		var sz int32
  86101 		var z uintptr = zSql
  86102 		for sz = 0; sz < nBytes && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(sz)))) != 0 || int32(*(*uint8)(unsafe.Pointer(z + uintptr(sz+1)))) != 0); sz = sz + 2 {
  86103 		}
  86104 		nBytes = sz
  86105 	}
  86106 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  86107 	zSql8 = Xsqlite3Utf16to8(tls, db, zSql, nBytes, uint8(SQLITE_UTF16LE))
  86108 	if zSql8 != 0 {
  86109 		rc = sqlite3LockAndPrepare(tls, db, zSql8, -1, prepFlags, uintptr(0), ppStmt, bp)
  86110 	}
  86111 
  86112 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 && pzTail != 0 {
  86113 		var chars_parsed int32 = Xsqlite3Utf8CharLen(tls, zSql8, (int32(*(*uintptr)(unsafe.Pointer(bp)))-int32(zSql8))/1)
  86114 		*(*uintptr)(unsafe.Pointer(pzTail)) = zSql + uintptr(Xsqlite3Utf16ByteLen(tls, zSql, chars_parsed))
  86115 	}
  86116 	Xsqlite3DbFree(tls, db, zSql8)
  86117 	rc = Xsqlite3ApiExit(tls, db, rc)
  86118 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  86119 	return rc
  86120 }
  86121 
  86122 // Two versions of the official API.  Legacy and new use.  In the legacy
  86123 // version, the original SQL text is not saved in the prepared statement
  86124 // and so if a schema change occurs, SQLITE_SCHEMA is returned by
  86125 // sqlite3_step().  In the new version, the original SQL text is retained
  86126 // and the statement is automatically recompiled if an schema change
  86127 // occurs.
  86128 func Xsqlite3_prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) int32 {
  86129 	var rc int32
  86130 	rc = sqlite3Prepare16(tls, db, zSql, nBytes, uint32(0), ppStmt, pzTail)
  86131 
  86132 	return rc
  86133 }
  86134 
  86135 func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) int32 {
  86136 	var rc int32
  86137 	rc = sqlite3Prepare16(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL), ppStmt, pzTail)
  86138 
  86139 	return rc
  86140 }
  86141 
  86142 func Xsqlite3_prepare16_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) int32 {
  86143 	var rc int32
  86144 	rc = sqlite3Prepare16(tls, db, zSql, nBytes,
  86145 		uint32(SQLITE_PREPARE_SAVESQL)|prepFlags&uint32(SQLITE_PREPARE_MASK),
  86146 		ppStmt, pzTail)
  86147 
  86148 	return rc
  86149 }
  86150 
  86151 // An instance of the following object is used to record information about
  86152 // how to process the DISTINCT keyword, to simplify passing that information
  86153 // into the selectInnerLoop() routine.
  86154 type DistinctCtx1 = struct {
  86155 	FisTnct      U8
  86156 	FeTnctType   U8
  86157 	F__ccgo_pad1 [2]byte
  86158 	FtabTnct     int32
  86159 	FaddrTnct    int32
  86160 }
  86161 
  86162 // An instance of the following object is used to record information about
  86163 // how to process the DISTINCT keyword, to simplify passing that information
  86164 // into the selectInnerLoop() routine.
  86165 type DistinctCtx = DistinctCtx1
  86166 
  86167 // An instance of the following object is used to record information about
  86168 // the ORDER BY (or GROUP BY) clause of query is being coded.
  86169 //
  86170 // The aDefer[] array is used by the sorter-references optimization. For
  86171 // example, assuming there is no index that can be used for the ORDER BY,
  86172 // for the query:
  86173 //
  86174 //	SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
  86175 //
  86176 // it may be more efficient to add just the "a" values to the sorter, and
  86177 // retrieve the associated "bigblob" values directly from table t1 as the
  86178 // 10 smallest "a" values are extracted from the sorter.
  86179 //
  86180 // When the sorter-reference optimization is used, there is one entry in the
  86181 // aDefer[] array for each database table that may be read as values are
  86182 // extracted from the sorter.
  86183 type SortCtx1 = struct {
  86184 	FpOrderBy         uintptr
  86185 	FnOBSat           int32
  86186 	FiECursor         int32
  86187 	FregReturn        int32
  86188 	FlabelBkOut       int32
  86189 	FaddrSortIndex    int32
  86190 	FlabelDone        int32
  86191 	FlabelOBLopt      int32
  86192 	FsortFlags        U8
  86193 	F__ccgo_pad1      [3]byte
  86194 	FpDeferredRowLoad uintptr
  86195 }
  86196 
  86197 // An instance of the following object is used to record information about
  86198 // the ORDER BY (or GROUP BY) clause of query is being coded.
  86199 //
  86200 // The aDefer[] array is used by the sorter-references optimization. For
  86201 // example, assuming there is no index that can be used for the ORDER BY,
  86202 // for the query:
  86203 //
  86204 //	SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
  86205 //
  86206 // it may be more efficient to add just the "a" values to the sorter, and
  86207 // retrieve the associated "bigblob" values directly from table t1 as the
  86208 // 10 smallest "a" values are extracted from the sorter.
  86209 //
  86210 // When the sorter-reference optimization is used, there is one entry in the
  86211 // aDefer[] array for each database table that may be read as values are
  86212 // extracted from the sorter.
  86213 type SortCtx = SortCtx1
  86214 type RowLoadInfo1 = struct {
  86215 	FregResult   int32
  86216 	FecelFlags   U8
  86217 	F__ccgo_pad1 [3]byte
  86218 }
  86219 
  86220 func clearSelect(tls *libc.TLS, db uintptr, p uintptr, bFree int32) {
  86221 	for p != 0 {
  86222 		var pPrior uintptr = (*Select)(unsafe.Pointer(p)).FpPrior
  86223 		Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpEList)
  86224 		Xsqlite3SrcListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpSrc)
  86225 		Xsqlite3ExprDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpWhere)
  86226 		Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpGroupBy)
  86227 		Xsqlite3ExprDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpHaving)
  86228 		Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpOrderBy)
  86229 		Xsqlite3ExprDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit)
  86230 		if (*Select)(unsafe.Pointer(p)).FpWith != 0 {
  86231 			Xsqlite3WithDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpWith)
  86232 		}
  86233 		if (*Select)(unsafe.Pointer(p)).FpWinDefn != 0 {
  86234 			Xsqlite3WindowListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpWinDefn)
  86235 		}
  86236 		for (*Select)(unsafe.Pointer(p)).FpWin != 0 {
  86237 			Xsqlite3WindowUnlinkFromSelect(tls, (*Select)(unsafe.Pointer(p)).FpWin)
  86238 		}
  86239 		if bFree != 0 {
  86240 			Xsqlite3DbNNFreeNN(tls, db, p)
  86241 		}
  86242 		p = pPrior
  86243 		bFree = 1
  86244 	}
  86245 }
  86246 
  86247 // Initialize a SelectDest structure.
  86248 func Xsqlite3SelectDestInit(tls *libc.TLS, pDest uintptr, eDest int32, iParm int32) {
  86249 	(*SelectDest)(unsafe.Pointer(pDest)).FeDest = U8(eDest)
  86250 	(*SelectDest)(unsafe.Pointer(pDest)).FiSDParm = iParm
  86251 	(*SelectDest)(unsafe.Pointer(pDest)).FiSDParm2 = 0
  86252 	(*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst = uintptr(0)
  86253 	(*SelectDest)(unsafe.Pointer(pDest)).FiSdst = 0
  86254 	(*SelectDest)(unsafe.Pointer(pDest)).FnSdst = 0
  86255 }
  86256 
  86257 // Allocate a new Select structure and return a pointer to that
  86258 // structure.
  86259 func Xsqlite3SelectNew(tls *libc.TLS, pParse uintptr, pEList uintptr, pSrc uintptr, pWhere uintptr, pGroupBy uintptr, pHaving uintptr, pOrderBy uintptr, selFlags U32, pLimit uintptr) uintptr {
  86260 	bp := tls.Alloc(76)
  86261 	defer tls.Free(76)
  86262 
  86263 	var pNew uintptr
  86264 	var pAllocated uintptr
  86265 
  86266 	pAllocated = libc.AssignUintptr(&pNew, Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Select{}))))
  86267 	if pNew == uintptr(0) {
  86268 		pNew = bp
  86269 	}
  86270 	if pEList == uintptr(0) {
  86271 		pEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0),
  86272 			Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ASTERISK, uintptr(0)))
  86273 	}
  86274 	(*Select)(unsafe.Pointer(pNew)).FpEList = pEList
  86275 	(*Select)(unsafe.Pointer(pNew)).Fop = U8(TK_SELECT)
  86276 	(*Select)(unsafe.Pointer(pNew)).FselFlags = selFlags
  86277 	(*Select)(unsafe.Pointer(pNew)).FiLimit = 0
  86278 	(*Select)(unsafe.Pointer(pNew)).FiOffset = 0
  86279 	(*Select)(unsafe.Pointer(pNew)).FselId = U32(libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnSelect, 1))
  86280 	*(*int32)(unsafe.Pointer(pNew + 20)) = -1
  86281 	*(*int32)(unsafe.Pointer(pNew + 20 + 1*4)) = -1
  86282 	(*Select)(unsafe.Pointer(pNew)).FnSelectRow = int16(0)
  86283 	if pSrc == uintptr(0) {
  86284 		pSrc = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(SrcList{})))
  86285 	}
  86286 	(*Select)(unsafe.Pointer(pNew)).FpSrc = pSrc
  86287 	(*Select)(unsafe.Pointer(pNew)).FpWhere = pWhere
  86288 	(*Select)(unsafe.Pointer(pNew)).FpGroupBy = pGroupBy
  86289 	(*Select)(unsafe.Pointer(pNew)).FpHaving = pHaving
  86290 	(*Select)(unsafe.Pointer(pNew)).FpOrderBy = pOrderBy
  86291 	(*Select)(unsafe.Pointer(pNew)).FpPrior = uintptr(0)
  86292 	(*Select)(unsafe.Pointer(pNew)).FpNext = uintptr(0)
  86293 	(*Select)(unsafe.Pointer(pNew)).FpLimit = pLimit
  86294 	(*Select)(unsafe.Pointer(pNew)).FpWith = uintptr(0)
  86295 	(*Select)(unsafe.Pointer(pNew)).FpWin = uintptr(0)
  86296 	(*Select)(unsafe.Pointer(pNew)).FpWinDefn = uintptr(0)
  86297 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  86298 		clearSelect(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pNew, libc.Bool32(pNew != bp))
  86299 		pAllocated = uintptr(0)
  86300 	} else {
  86301 	}
  86302 	return pAllocated
  86303 }
  86304 
  86305 // Delete the given Select structure and all of its substructures.
  86306 func Xsqlite3SelectDelete(tls *libc.TLS, db uintptr, p uintptr) {
  86307 	if p != 0 {
  86308 		clearSelect(tls, db, p, 1)
  86309 	}
  86310 }
  86311 
  86312 func findRightmost(tls *libc.TLS, p uintptr) uintptr {
  86313 	for (*Select)(unsafe.Pointer(p)).FpNext != 0 {
  86314 		p = (*Select)(unsafe.Pointer(p)).FpNext
  86315 	}
  86316 	return p
  86317 }
  86318 
  86319 // Given 1 to 3 identifiers preceding the JOIN keyword, determine the
  86320 // type of join.  Return an integer constant that expresses that type
  86321 // in terms of the following bit values:
  86322 //
  86323 //	JT_INNER
  86324 //	JT_CROSS
  86325 //	JT_OUTER
  86326 //	JT_NATURAL
  86327 //	JT_LEFT
  86328 //	JT_RIGHT
  86329 //
  86330 // A full outer join is the combination of JT_LEFT and JT_RIGHT.
  86331 //
  86332 // If an illegal or unsupported join type is seen, then still return
  86333 // a join type, but put an error in the pParse structure.
  86334 //
  86335 // These are the valid join types:
  86336 //
  86337 //	 pA       pB       pC               Return Value
  86338 //	-------  -----    -----             ------------
  86339 //	CROSS      -        -                 JT_CROSS
  86340 //	INNER      -        -                 JT_INNER
  86341 //	LEFT       -        -                 JT_LEFT|JT_OUTER
  86342 //	LEFT     OUTER      -                 JT_LEFT|JT_OUTER
  86343 //	RIGHT      -        -                 JT_RIGHT|JT_OUTER
  86344 //	RIGHT    OUTER      -                 JT_RIGHT|JT_OUTER
  86345 //	FULL       -        -                 JT_LEFT|JT_RIGHT|JT_OUTER
  86346 //	FULL     OUTER      -                 JT_LEFT|JT_RIGHT|JT_OUTER
  86347 //	NATURAL  INNER      -                 JT_NATURAL|JT_INNER
  86348 //	NATURAL  LEFT       -                 JT_NATURAL|JT_LEFT|JT_OUTER
  86349 //	NATURAL  LEFT     OUTER               JT_NATURAL|JT_LEFT|JT_OUTER
  86350 //	NATURAL  RIGHT      -                 JT_NATURAL|JT_RIGHT|JT_OUTER
  86351 //	NATURAL  RIGHT    OUTER               JT_NATURAL|JT_RIGHT|JT_OUTER
  86352 //	NATURAL  FULL       -                 JT_NATURAL|JT_LEFT|JT_RIGHT
  86353 //	NATURAL  FULL     OUTER               JT_NATRUAL|JT_LEFT|JT_RIGHT
  86354 //
  86355 // To preserve historical compatibly, SQLite also accepts a variety
  86356 // of other non-standard and in many cases non-sensical join types.
  86357 // This routine makes as much sense at it can from the nonsense join
  86358 // type and returns a result.  Examples of accepted nonsense join types
  86359 // include but are not limited to:
  86360 //
  86361 //	INNER CROSS JOIN        ->   same as JOIN
  86362 //	NATURAL CROSS JOIN      ->   same as NATURAL JOIN
  86363 //	OUTER LEFT JOIN         ->   same as LEFT JOIN
  86364 //	LEFT NATURAL JOIN       ->   same as NATURAL LEFT JOIN
  86365 //	LEFT RIGHT JOIN         ->   same as FULL JOIN
  86366 //	RIGHT OUTER FULL JOIN   ->   same as FULL JOIN
  86367 //	CROSS CROSS CROSS JOIN  ->   same as JOIN
  86368 //
  86369 // The only restrictions on the join type name are:
  86370 //
  86371 //   - "INNER" cannot appear together with "OUTER", "LEFT", "RIGHT",
  86372 //     or "FULL".
  86373 //
  86374 //   - "CROSS" cannot appear together with "OUTER", "LEFT", "RIGHT,
  86375 //     or "FULL".
  86376 //
  86377 //   - If "OUTER" is present then there must also be one of
  86378 //     "LEFT", "RIGHT", or "FULL"
  86379 func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC uintptr) int32 {
  86380 	bp := tls.Alloc(52)
  86381 	defer tls.Free(52)
  86382 
  86383 	var jointype int32 = 0
  86384 
  86385 	var p uintptr
  86386 	var i int32
  86387 	var j int32
  86388 	*(*uintptr)(unsafe.Pointer(bp + 40)) = pA
  86389 	*(*uintptr)(unsafe.Pointer(bp + 40 + 1*4)) = pB
  86390 	*(*uintptr)(unsafe.Pointer(bp + 40 + 2*4)) = pC
  86391 	for i = 0; i < 3 && *(*uintptr)(unsafe.Pointer(bp + 40 + uintptr(i)*4)) != 0; i++ {
  86392 		p = *(*uintptr)(unsafe.Pointer(bp + 40 + uintptr(i)*4))
  86393 		for j = 0; j < int32(uint32(unsafe.Sizeof(aKeyword))/uint32(unsafe.Sizeof(struct {
  86394 			Fi     U8
  86395 			FnChar U8
  86396 			Fcode  U8
  86397 		}{}))); j++ {
  86398 			if (*Token)(unsafe.Pointer(p)).Fn == uint32(aKeyword[j].FnChar) &&
  86399 				Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(p)).Fz, uintptr(unsafe.Pointer(&zKeyText))+uintptr(aKeyword[j].Fi), int32((*Token)(unsafe.Pointer(p)).Fn)) == 0 {
  86400 				jointype = jointype | int32(aKeyword[j].Fcode)
  86401 				break
  86402 			}
  86403 		}
  86404 
  86405 		if j >= int32(uint32(unsafe.Sizeof(aKeyword))/uint32(unsafe.Sizeof(struct {
  86406 			Fi     U8
  86407 			FnChar U8
  86408 			Fcode  U8
  86409 		}{}))) {
  86410 			jointype = jointype | JT_ERROR
  86411 			break
  86412 		}
  86413 	}
  86414 	if jointype&(JT_INNER|JT_OUTER) == JT_INNER|JT_OUTER || jointype&JT_ERROR != 0 || jointype&(JT_OUTER|JT_LEFT|JT_RIGHT) == JT_OUTER {
  86415 		var zSp1 uintptr = ts + 10920
  86416 		var zSp2 uintptr = ts + 10920
  86417 		if pB == uintptr(0) {
  86418 			zSp1++
  86419 		}
  86420 		if pC == uintptr(0) {
  86421 			zSp2++
  86422 		}
  86423 		Xsqlite3ErrorMsg(tls, pParse,
  86424 			ts+18531, libc.VaList(bp, pA, zSp1, pB, zSp2, pC))
  86425 		jointype = JT_INNER
  86426 	}
  86427 	return jointype
  86428 }
  86429 
  86430 var zKeyText = *(*[34]uint8)(unsafe.Pointer(ts + 18561))
  86431 var aKeyword = [7]struct {
  86432 	Fi     U8
  86433 	FnChar U8
  86434 	Fcode  U8
  86435 }{
  86436 	{FnChar: U8(7), Fcode: U8(JT_NATURAL)},
  86437 	{Fi: U8(6), FnChar: U8(4), Fcode: U8(JT_LEFT | JT_OUTER)},
  86438 	{Fi: U8(10), FnChar: U8(5), Fcode: U8(JT_OUTER)},
  86439 	{Fi: U8(14), FnChar: U8(5), Fcode: U8(JT_RIGHT | JT_OUTER)},
  86440 	{Fi: U8(19), FnChar: U8(4), Fcode: U8(JT_LEFT | JT_RIGHT | JT_OUTER)},
  86441 	{Fi: U8(23), FnChar: U8(5), Fcode: U8(JT_INNER)},
  86442 	{Fi: U8(28), FnChar: U8(5), Fcode: U8(JT_INNER | JT_CROSS)},
  86443 }
  86444 
  86445 // Return the index of a column in a table.  Return -1 if the column
  86446 // is not contained in the table.
  86447 func Xsqlite3ColumnIndex(tls *libc.TLS, pTab uintptr, zCol uintptr) int32 {
  86448 	var i int32
  86449 	var h U8 = Xsqlite3StrIHash(tls, zCol)
  86450 	var pCol uintptr
  86451 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  86452 	i = 0
  86453 __1:
  86454 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  86455 		goto __3
  86456 	}
  86457 	{
  86458 		if int32((*Column)(unsafe.Pointer(pCol)).FhName) == int32(h) && Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName, zCol) == 0 {
  86459 			return i
  86460 		}
  86461 
  86462 	}
  86463 	goto __2
  86464 __2:
  86465 	pCol += 16
  86466 	i++
  86467 	goto __1
  86468 	goto __3
  86469 __3:
  86470 	;
  86471 	return -1
  86472 }
  86473 
  86474 // Mark a subquery result column as having been used.
  86475 func Xsqlite3SrcItemColumnUsed(tls *libc.TLS, pItem uintptr, iCol int32) {
  86476 	if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x2000>>13)) != 0 {
  86477 		var pResults uintptr
  86478 
  86479 		pResults = (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpSelect)).FpEList
  86480 
  86481 		libc.SetBitFieldPtr16Uint32(pResults+8+uintptr(iCol)*20+8+4, uint32(1), 6, 0x40)
  86482 	}
  86483 }
  86484 
  86485 func tableAndColumnIndex(tls *libc.TLS, pSrc uintptr, iStart int32, iEnd int32, zCol uintptr, piTab uintptr, piCol uintptr, bIgnoreHidden int32) int32 {
  86486 	var i int32
  86487 	var iCol int32
  86488 
  86489 	for i = iStart; i <= iEnd; i++ {
  86490 		iCol = Xsqlite3ColumnIndex(tls, (*SrcItem)(unsafe.Pointer(pSrc+8+uintptr(i)*72)).FpTab, zCol)
  86491 		if iCol >= 0 &&
  86492 			(bIgnoreHidden == 0 || libc.Bool32(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc+8+uintptr(i)*72)).FpTab)).FaCol+uintptr(iCol)*16)).FcolFlags)&COLFLAG_HIDDEN != 0) == 0) {
  86493 			if piTab != 0 {
  86494 				Xsqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(i)*72, iCol)
  86495 				*(*int32)(unsafe.Pointer(piTab)) = i
  86496 				*(*int32)(unsafe.Pointer(piCol)) = iCol
  86497 			}
  86498 			return 1
  86499 		}
  86500 	}
  86501 	return 0
  86502 }
  86503 
  86504 // Set the EP_OuterON property on all terms of the given expression.
  86505 // And set the Expr.w.iJoin to iTable for every term in the
  86506 // expression.
  86507 //
  86508 // The EP_OuterON property is used on terms of an expression to tell
  86509 // the OUTER JOIN processing logic that this term is part of the
  86510 // join restriction specified in the ON or USING clause and not a part
  86511 // of the more general WHERE clause.  These terms are moved over to the
  86512 // WHERE clause during join processing but we need to remember that they
  86513 // originated in the ON or USING clause.
  86514 //
  86515 // The Expr.w.iJoin tells the WHERE clause processing that the
  86516 // expression depends on table w.iJoin even if that table is not
  86517 // explicitly mentioned in the expression.  That information is needed
  86518 // for cases like this:
  86519 //
  86520 //	SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5
  86521 //
  86522 // The where clause needs to defer the handling of the t1.x=5
  86523 // term until after the t2 loop of the join.  In that way, a
  86524 // NULL t2 row will be inserted whenever t1.x!=5.  If we do not
  86525 // defer the handling of t1.x=5, it will be processed immediately
  86526 // after the t1 loop and rows with t1.x!=5 will never appear in
  86527 // the output, which is incorrect.
  86528 func Xsqlite3SetJoinExpr(tls *libc.TLS, p uintptr, iTable int32, joinFlag U32) {
  86529 	for p != 0 {
  86530 		*(*U32)(unsafe.Pointer(p + 4)) |= joinFlag
  86531 
  86532 		*(*int32)(unsafe.Pointer(p + 36)) = iTable
  86533 		if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION {
  86534 			if *(*uintptr)(unsafe.Pointer(p + 20)) != 0 {
  86535 				var i int32
  86536 				for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20)))).FnExpr; i++ {
  86537 					Xsqlite3SetJoinExpr(tls, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20))+8+uintptr(i)*20)).FpExpr, iTable, joinFlag)
  86538 				}
  86539 			}
  86540 		}
  86541 		Xsqlite3SetJoinExpr(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, iTable, joinFlag)
  86542 		p = (*Expr)(unsafe.Pointer(p)).FpRight
  86543 	}
  86544 }
  86545 
  86546 func unsetJoinExpr(tls *libc.TLS, p uintptr, iTable int32, nullable int32) {
  86547 	for p != 0 {
  86548 		if iTable < 0 || (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_OuterON) != U32(0) && *(*int32)(unsafe.Pointer(p + 36)) == iTable {
  86549 			*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_OuterON | EP_InnerON))
  86550 			if iTable >= 0 {
  86551 				*(*U32)(unsafe.Pointer(p + 4)) |= U32(EP_InnerON)
  86552 			}
  86553 		}
  86554 		if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN && (*Expr)(unsafe.Pointer(p)).FiTable == iTable && !(nullable != 0) {
  86555 			*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_CanBeNull))
  86556 		}
  86557 		if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION {
  86558 			if *(*uintptr)(unsafe.Pointer(p + 20)) != 0 {
  86559 				var i int32
  86560 				for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20)))).FnExpr; i++ {
  86561 					unsetJoinExpr(tls, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 20))+8+uintptr(i)*20)).FpExpr, iTable, nullable)
  86562 				}
  86563 			}
  86564 		}
  86565 		unsetJoinExpr(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, iTable, nullable)
  86566 		p = (*Expr)(unsafe.Pointer(p)).FpRight
  86567 	}
  86568 }
  86569 
  86570 func sqlite3ProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) int32 {
  86571 	bp := tls.Alloc(32)
  86572 	defer tls.Free(32)
  86573 
  86574 	var pSrc uintptr
  86575 	var i int32
  86576 	var j int32
  86577 	var pLeft uintptr
  86578 	var pRight uintptr
  86579 
  86580 	pSrc = (*Select)(unsafe.Pointer(p)).FpSrc
  86581 	pLeft = pSrc + 8
  86582 	pRight = pLeft + 1*72
  86583 	i = 0
  86584 __1:
  86585 	if !(i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc-1) {
  86586 		goto __3
  86587 	}
  86588 	{
  86589 		var pRightTab uintptr = (*SrcItem)(unsafe.Pointer(pRight)).FpTab
  86590 		var joinType U32
  86591 
  86592 		if (*SrcItem)(unsafe.Pointer(pLeft)).FpTab == uintptr(0) || pRightTab == uintptr(0) {
  86593 			goto __2
  86594 		}
  86595 		if int32((*SrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&JT_OUTER != 0 {
  86596 			joinType = uint32(EP_OuterON)
  86597 		} else {
  86598 			joinType = uint32(EP_InnerON)
  86599 		}
  86600 
  86601 		if int32((*SrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&JT_NATURAL != 0 {
  86602 			var pUsing uintptr = uintptr(0)
  86603 			if uint32(int32(*(*uint16)(unsafe.Pointer(pRight + 36 + 4))&0x400>>10)) != 0 || *(*uintptr)(unsafe.Pointer(pRight + 48)) != 0 {
  86604 				Xsqlite3ErrorMsg(tls, pParse,
  86605 					ts+18595, libc.VaList(bp, 0))
  86606 				return 1
  86607 			}
  86608 			for j = 0; j < int32((*Table)(unsafe.Pointer(pRightTab)).FnCol); j++ {
  86609 				var zName uintptr
  86610 
  86611 				if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pRightTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_HIDDEN != 0 {
  86612 					continue
  86613 				}
  86614 				zName = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*16)).FzCnName
  86615 				if tableAndColumnIndex(tls, pSrc, 0, i, zName, uintptr(0), uintptr(0), 1) != 0 {
  86616 					pUsing = Xsqlite3IdListAppend(tls, pParse, pUsing, uintptr(0))
  86617 					if pUsing != 0 {
  86618 						(*IdList_item)(unsafe.Pointer(pUsing + 8 + uintptr((*IdList)(unsafe.Pointer(pUsing)).FnId-1)*8)).FzName = Xsqlite3DbStrDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zName)
  86619 					}
  86620 				}
  86621 			}
  86622 			if pUsing != 0 {
  86623 				libc.SetBitFieldPtr16Uint32(pRight+36+4, uint32(1), 10, 0x400)
  86624 				libc.SetBitFieldPtr16Uint32(pRight+36+4, uint32(1), 12, 0x1000)
  86625 				*(*uintptr)(unsafe.Pointer(pRight + 48)) = pUsing
  86626 			}
  86627 			if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  86628 				return 1
  86629 			}
  86630 		}
  86631 
  86632 		if uint32(int32(*(*uint16)(unsafe.Pointer(pRight + 36 + 4))&0x400>>10)) != 0 {
  86633 			var pList uintptr = *(*uintptr)(unsafe.Pointer(pRight + 48))
  86634 			var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  86635 
  86636 			for j = 0; j < (*IdList)(unsafe.Pointer(pList)).FnId; j++ {
  86637 				var zName uintptr
  86638 
  86639 				var iRightCol int32
  86640 				var pE1 uintptr
  86641 				var pE2 uintptr
  86642 				var pEq uintptr
  86643 
  86644 				zName = (*IdList_item)(unsafe.Pointer(pList + 8 + uintptr(j)*8)).FzName
  86645 				iRightCol = Xsqlite3ColumnIndex(tls, pRightTab, zName)
  86646 				if iRightCol < 0 ||
  86647 					tableAndColumnIndex(tls, pSrc, 0, i, zName, bp+24, bp+28,
  86648 						int32(*(*uint16)(unsafe.Pointer(pRight + 36 + 4))&0x1000>>12)) == 0 {
  86649 					Xsqlite3ErrorMsg(tls, pParse,
  86650 						ts+18645, libc.VaList(bp+8, zName))
  86651 					return 1
  86652 				}
  86653 				pE1 = Xsqlite3CreateColumnExpr(tls, db, pSrc, *(*int32)(unsafe.Pointer(bp + 24)), *(*int32)(unsafe.Pointer(bp + 28)))
  86654 				Xsqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*72, *(*int32)(unsafe.Pointer(bp + 28)))
  86655 				if int32((*SrcItem)(unsafe.Pointer(pSrc+8)).Ffg.Fjointype)&JT_LTORJ != 0 {
  86656 					var pFuncArgs uintptr = uintptr(0)
  86657 					for tableAndColumnIndex(tls, pSrc, *(*int32)(unsafe.Pointer(bp + 24))+1, i, zName, bp+24, bp+28,
  86658 						int32(*(*uint16)(unsafe.Pointer(pRight + 36 + 4))&0x1000>>12)) != 0 {
  86659 						if int32(*(*uint16)(unsafe.Pointer(pSrc + 8 + uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*72 + 36 + 4))&0x400>>10) == 0 ||
  86660 							Xsqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*72 + 48)), zName) < 0 {
  86661 							Xsqlite3ErrorMsg(tls, pParse, ts+18709,
  86662 								libc.VaList(bp+16, zName))
  86663 							break
  86664 						}
  86665 						pFuncArgs = Xsqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1)
  86666 						pE1 = Xsqlite3CreateColumnExpr(tls, db, pSrc, *(*int32)(unsafe.Pointer(bp + 24)), *(*int32)(unsafe.Pointer(bp + 28)))
  86667 						Xsqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*72, *(*int32)(unsafe.Pointer(bp + 28)))
  86668 					}
  86669 					if pFuncArgs != 0 {
  86670 						pFuncArgs = Xsqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1)
  86671 						pE1 = Xsqlite3ExprFunction(tls, pParse, pFuncArgs, uintptr(unsafe.Pointer(&tkCoalesce)), 0)
  86672 					}
  86673 				}
  86674 				pE2 = Xsqlite3CreateColumnExpr(tls, db, pSrc, i+1, iRightCol)
  86675 				Xsqlite3SrcItemColumnUsed(tls, pRight, iRightCol)
  86676 				pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, pE1, pE2)
  86677 
  86678 				if pEq != 0 {
  86679 					*(*U32)(unsafe.Pointer(pEq + 4)) |= joinType
  86680 
  86681 					*(*int32)(unsafe.Pointer(pEq + 36)) = (*Expr)(unsafe.Pointer(pE2)).FiTable
  86682 				}
  86683 				(*Select)(unsafe.Pointer(p)).FpWhere = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(p)).FpWhere, pEq)
  86684 			}
  86685 		} else if *(*uintptr)(unsafe.Pointer(pRight + 48)) != 0 {
  86686 			Xsqlite3SetJoinExpr(tls, *(*uintptr)(unsafe.Pointer(pRight + 48)), (*SrcItem)(unsafe.Pointer(pRight)).FiCursor, joinType)
  86687 			(*Select)(unsafe.Pointer(p)).FpWhere = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(p)).FpWhere, *(*uintptr)(unsafe.Pointer(pRight + 48)))
  86688 			*(*uintptr)(unsafe.Pointer(pRight + 48)) = uintptr(0)
  86689 			libc.SetBitFieldPtr16Uint32(pRight+36+4, uint32(1), 11, 0x800)
  86690 		}
  86691 
  86692 	}
  86693 	goto __2
  86694 __2:
  86695 	i++
  86696 	pRight += 72
  86697 	pLeft += 72
  86698 	goto __1
  86699 	goto __3
  86700 __3:
  86701 	;
  86702 	return 0
  86703 }
  86704 
  86705 var tkCoalesce = Token{Fz: ts + 6586, Fn: uint32(8)}
  86706 
  86707 // An instance of this object holds information (beyond pParse and pSelect)
  86708 // needed to load the next result row that is to be added to the sorter.
  86709 type RowLoadInfo = RowLoadInfo1
  86710 
  86711 func innerLoopLoadRow(tls *libc.TLS, pParse uintptr, pSelect uintptr, pInfo uintptr) {
  86712 	Xsqlite3ExprCodeExprList(tls, pParse, (*Select)(unsafe.Pointer(pSelect)).FpEList, (*RowLoadInfo)(unsafe.Pointer(pInfo)).FregResult,
  86713 		0, (*RowLoadInfo)(unsafe.Pointer(pInfo)).FecelFlags)
  86714 }
  86715 
  86716 func makeSorterRecord(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regBase int32, nBase int32) int32 {
  86717 	var nOBSat int32 = (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat
  86718 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  86719 	var regOut int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  86720 	if (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad != 0 {
  86721 		innerLoopLoadRow(tls, pParse, pSelect, (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad)
  86722 	}
  86723 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regOut)
  86724 	return regOut
  86725 }
  86726 
  86727 func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regData int32, regOrigData int32, nData int32, nPrefixReg int32) {
  86728 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  86729 	var bSeq int32 = libc.Bool32(int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags)&SORTFLAG_UseSorter == 0)
  86730 	var nExpr int32 = (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr
  86731 	var nBase int32 = nExpr + bSeq + nData
  86732 	var regBase int32
  86733 	var regRecord int32 = 0
  86734 	var nOBSat int32 = (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat
  86735 	var op int32
  86736 	var iLimit int32
  86737 	var iSkip int32 = 0
  86738 
  86739 	if nPrefixReg != 0 {
  86740 		regBase = regData - nPrefixReg
  86741 	} else {
  86742 		regBase = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  86743 		*(*int32)(unsafe.Pointer(pParse + 44)) += nBase
  86744 	}
  86745 
  86746 	if (*Select)(unsafe.Pointer(pSelect)).FiOffset != 0 {
  86747 		iLimit = (*Select)(unsafe.Pointer(pSelect)).FiOffset + 1
  86748 	} else {
  86749 		iLimit = (*Select)(unsafe.Pointer(pSelect)).FiLimit
  86750 	}
  86751 	(*SortCtx)(unsafe.Pointer(pSort)).FlabelDone = Xsqlite3VdbeMakeLabel(tls, pParse)
  86752 	Xsqlite3ExprCodeExprList(tls, pParse, (*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy, regBase, regOrigData,
  86753 		uint8(SQLITE_ECEL_DUP|func() int32 {
  86754 			if regOrigData != 0 {
  86755 				return SQLITE_ECEL_REF
  86756 			}
  86757 			return 0
  86758 		}()))
  86759 	if bSeq != 0 {
  86760 		Xsqlite3VdbeAddOp2(tls, v, OP_Sequence, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, regBase+nExpr)
  86761 	}
  86762 	if nPrefixReg == 0 && nData > 0 {
  86763 		Xsqlite3ExprCodeMove(tls, pParse, regData, regBase+nExpr+bSeq, nData)
  86764 	}
  86765 	if nOBSat > 0 {
  86766 		var regPrevKey int32
  86767 		var addrFirst int32
  86768 		var addrJmp int32
  86769 		var pOp uintptr
  86770 		var nKey int32
  86771 		var pKI uintptr
  86772 
  86773 		regRecord = makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase)
  86774 		regPrevKey = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  86775 		*(*int32)(unsafe.Pointer(pParse + 44)) += (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat
  86776 		nKey = nExpr - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat + bSeq
  86777 		if bSeq != 0 {
  86778 			addrFirst = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regBase+nExpr)
  86779 		} else {
  86780 			addrFirst = Xsqlite3VdbeAddOp1(tls, v, OP_SequenceTest, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor)
  86781 		}
  86782 
  86783 		Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regPrevKey, regBase, (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat)
  86784 		pOp = Xsqlite3VdbeGetOp(tls, v, (*SortCtx)(unsafe.Pointer(pSort)).FaddrSortIndex)
  86785 		if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  86786 			return
  86787 		}
  86788 		(*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = nKey + nData
  86789 		pKI = *(*uintptr)(unsafe.Pointer(pOp + 16))
  86790 		libc.Xmemset(tls, (*KeyInfo)(unsafe.Pointer(pKI)).FaSortFlags, 0, uint32((*KeyInfo)(unsafe.Pointer(pKI)).FnKeyField))
  86791 		Xsqlite3VdbeChangeP4(tls, v, -1, pKI, -8)
  86792 
  86793 		*(*uintptr)(unsafe.Pointer(pOp + 16)) = Xsqlite3KeyInfoFromExprList(tls, pParse, (*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy, nOBSat,
  86794 			int32((*KeyInfo)(unsafe.Pointer(pKI)).FnAllField)-int32((*KeyInfo)(unsafe.Pointer(pKI)).FnKeyField)-1)
  86795 		pOp = uintptr(0)
  86796 		addrJmp = Xsqlite3VdbeCurrentAddr(tls, v)
  86797 		Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addrJmp+1, 0, addrJmp+1)
  86798 		(*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut = Xsqlite3VdbeMakeLabel(tls, pParse)
  86799 		(*SortCtx)(unsafe.Pointer(pSort)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  86800 		Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut)
  86801 		Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor)
  86802 		if iLimit != 0 {
  86803 			Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, iLimit, (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone)
  86804 
  86805 		}
  86806 		Xsqlite3VdbeJumpHere(tls, v, addrFirst)
  86807 		Xsqlite3ExprCodeMove(tls, pParse, regBase, regPrevKey, (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat)
  86808 		Xsqlite3VdbeJumpHere(tls, v, addrJmp)
  86809 	}
  86810 	if iLimit != 0 {
  86811 		var iCsr int32 = (*SortCtx)(unsafe.Pointer(pSort)).FiECursor
  86812 		Xsqlite3VdbeAddOp2(tls, v, OP_IfNotZero, iLimit, Xsqlite3VdbeCurrentAddr(tls, v)+4)
  86813 
  86814 		Xsqlite3VdbeAddOp2(tls, v, OP_Last, iCsr, 0)
  86815 		iSkip = Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxLE,
  86816 			iCsr, 0, regBase+nOBSat, nExpr-nOBSat)
  86817 
  86818 		Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iCsr)
  86819 	}
  86820 	if regRecord == 0 {
  86821 		regRecord = makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase)
  86822 	}
  86823 	if int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags)&SORTFLAG_UseSorter != 0 {
  86824 		op = OP_SorterInsert
  86825 	} else {
  86826 		op = OP_IdxInsert
  86827 	}
  86828 	Xsqlite3VdbeAddOp4Int(tls, v, op, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, regRecord,
  86829 		regBase+nOBSat, nBase-nOBSat)
  86830 	if iSkip != 0 {
  86831 		Xsqlite3VdbeChangeP2(tls, v, iSkip,
  86832 			func() int32 {
  86833 				if (*SortCtx)(unsafe.Pointer(pSort)).FlabelOBLopt != 0 {
  86834 					return (*SortCtx)(unsafe.Pointer(pSort)).FlabelOBLopt
  86835 				}
  86836 				return Xsqlite3VdbeCurrentAddr(tls, v)
  86837 			}())
  86838 	}
  86839 }
  86840 
  86841 func codeOffset(tls *libc.TLS, v uintptr, iOffset int32, iContinue int32) {
  86842 	if iOffset > 0 {
  86843 		Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, iOffset, iContinue, 1)
  86844 
  86845 	}
  86846 }
  86847 
  86848 func codeDistinct(tls *libc.TLS, pParse uintptr, eTnctType int32, iTab int32, addrRepeat int32, pEList uintptr, regElem int32) int32 {
  86849 	var iRet int32 = 0
  86850 	var nResultCol int32 = (*ExprList)(unsafe.Pointer(pEList)).FnExpr
  86851 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  86852 
  86853 	switch eTnctType {
  86854 	case WHERE_DISTINCT_ORDERED:
  86855 		{
  86856 			var i int32
  86857 			var iJump int32
  86858 			var regPrev int32
  86859 
  86860 			iRet = libc.AssignInt32(&regPrev, (*Parse)(unsafe.Pointer(pParse)).FnMem+1)
  86861 			*(*int32)(unsafe.Pointer(pParse + 44)) += nResultCol
  86862 
  86863 			iJump = Xsqlite3VdbeCurrentAddr(tls, v) + nResultCol
  86864 			for i = 0; i < nResultCol; i++ {
  86865 				var pColl uintptr = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FpExpr)
  86866 				if i < nResultCol-1 {
  86867 					Xsqlite3VdbeAddOp3(tls, v, OP_Ne, regElem+i, iJump, regPrev+i)
  86868 
  86869 				} else {
  86870 					Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regElem+i, addrRepeat, regPrev+i)
  86871 
  86872 				}
  86873 				Xsqlite3VdbeChangeP4(tls, v, -1, pColl, -2)
  86874 				Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ))
  86875 			}
  86876 
  86877 			Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regElem, regPrev, nResultCol-1)
  86878 			break
  86879 
  86880 		}
  86881 
  86882 	case WHERE_DISTINCT_UNIQUE:
  86883 		{
  86884 			break
  86885 
  86886 		}
  86887 
  86888 	default:
  86889 		{
  86890 			var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  86891 			Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iTab, addrRepeat, regElem, nResultCol)
  86892 
  86893 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regElem, nResultCol, r1)
  86894 			Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iTab, r1, regElem, nResultCol)
  86895 			Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT))
  86896 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
  86897 			iRet = iTab
  86898 			break
  86899 
  86900 		}
  86901 	}
  86902 
  86903 	return iRet
  86904 }
  86905 
  86906 func fixDistinctOpenEph(tls *libc.TLS, pParse uintptr, eTnctType int32, iVal int32, iOpenEphAddr int32) {
  86907 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 &&
  86908 		(eTnctType == WHERE_DISTINCT_UNIQUE || eTnctType == WHERE_DISTINCT_ORDERED) {
  86909 		var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  86910 		Xsqlite3VdbeChangeToNoop(tls, v, iOpenEphAddr)
  86911 		if int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, iOpenEphAddr+1))).Fopcode) == OP_Explain {
  86912 			Xsqlite3VdbeChangeToNoop(tls, v, iOpenEphAddr+1)
  86913 		}
  86914 		if eTnctType == WHERE_DISTINCT_ORDERED {
  86915 			var pOp uintptr = Xsqlite3VdbeGetOp(tls, v, iOpenEphAddr)
  86916 			(*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(OP_Null)
  86917 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = 1
  86918 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = iVal
  86919 		}
  86920 	}
  86921 }
  86922 
  86923 func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSort uintptr, pDistinct uintptr, pDest uintptr, iContinue int32, iBreak int32) {
  86924 	bp := tls.Alloc(8)
  86925 	defer tls.Free(8)
  86926 
  86927 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  86928 	var i int32
  86929 	var hasDistinct int32
  86930 	var eDest int32 = int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)
  86931 	var iParm int32 = (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm
  86932 	var nResultCol int32
  86933 	var nPrefixReg int32 = 0
  86934 
  86935 	var regResult int32
  86936 	var regOrig int32
  86937 
  86938 	if pDistinct != 0 {
  86939 		hasDistinct = int32((*DistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType)
  86940 	} else {
  86941 		hasDistinct = WHERE_DISTINCT_NOOP
  86942 	}
  86943 	if pSort != 0 && (*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy == uintptr(0) {
  86944 		pSort = uintptr(0)
  86945 	}
  86946 	if pSort == uintptr(0) && !(hasDistinct != 0) {
  86947 		codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, iContinue)
  86948 	}
  86949 
  86950 	nResultCol = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr
  86951 
  86952 	if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 {
  86953 		if pSort != 0 {
  86954 			nPrefixReg = (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr
  86955 			if !(int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags)&SORTFLAG_UseSorter != 0) {
  86956 				nPrefixReg++
  86957 			}
  86958 			*(*int32)(unsafe.Pointer(pParse + 44)) += nPrefixReg
  86959 		}
  86960 		(*SelectDest)(unsafe.Pointer(pDest)).FiSdst = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  86961 		*(*int32)(unsafe.Pointer(pParse + 44)) += nResultCol
  86962 	} else if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst+nResultCol > (*Parse)(unsafe.Pointer(pParse)).FnMem {
  86963 		*(*int32)(unsafe.Pointer(pParse + 44)) += nResultCol
  86964 	}
  86965 	(*SelectDest)(unsafe.Pointer(pDest)).FnSdst = nResultCol
  86966 	regOrig = libc.AssignInt32(&regResult, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst)
  86967 	if srcTab >= 0 {
  86968 		for i = 0; i < nResultCol; i++ {
  86969 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, i, regResult+i)
  86970 
  86971 		}
  86972 	} else if eDest != SRT_Exists {
  86973 		var ecelFlags U8
  86974 		var pEList uintptr
  86975 		if eDest == SRT_Mem || eDest == SRT_Output || eDest == SRT_Coroutine {
  86976 			ecelFlags = U8(SQLITE_ECEL_DUP)
  86977 		} else {
  86978 			ecelFlags = U8(0)
  86979 		}
  86980 		if pSort != 0 && hasDistinct == 0 && eDest != SRT_EphemTab && eDest != SRT_Table {
  86981 			ecelFlags = U8(int32(ecelFlags) | (SQLITE_ECEL_OMITREF | SQLITE_ECEL_REF))
  86982 
  86983 			for i = (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat; i < (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr; i++ {
  86984 				var j int32
  86985 				if libc.AssignInt32(&j, int32(*(*U16)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy + 8 + uintptr(i)*20 + 16)))) > 0 {
  86986 					*(*U16)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList + 8 + uintptr(j-1)*20 + 16)) = U16(i + 1 - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat)
  86987 				}
  86988 			}
  86989 
  86990 			pEList = (*Select)(unsafe.Pointer(p)).FpEList
  86991 			for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  86992 				if int32(*(*U16)(unsafe.Pointer(pEList + 8 + uintptr(i)*20 + 16))) > 0 {
  86993 					nResultCol--
  86994 					regOrig = 0
  86995 				}
  86996 			}
  86997 
  86998 		}
  86999 		(*RowLoadInfo)(unsafe.Pointer(bp)).FregResult = regResult
  87000 		(*RowLoadInfo)(unsafe.Pointer(bp)).FecelFlags = ecelFlags
  87001 		if (*Select)(unsafe.Pointer(p)).FiLimit != 0 &&
  87002 			int32(ecelFlags)&SQLITE_ECEL_OMITREF != 0 &&
  87003 			nPrefixReg > 0 {
  87004 			(*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad = bp
  87005 			regOrig = 0
  87006 		} else {
  87007 			innerLoopLoadRow(tls, pParse, p, bp)
  87008 		}
  87009 	}
  87010 
  87011 	if hasDistinct != 0 {
  87012 		var eType int32 = int32((*DistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType)
  87013 		var iTab int32 = (*DistinctCtx)(unsafe.Pointer(pDistinct)).FtabTnct
  87014 
  87015 		iTab = codeDistinct(tls, pParse, eType, iTab, iContinue, (*Select)(unsafe.Pointer(p)).FpEList, regResult)
  87016 		fixDistinctOpenEph(tls, pParse, eType, iTab, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct)
  87017 		if pSort == uintptr(0) {
  87018 			codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, iContinue)
  87019 		}
  87020 	}
  87021 
  87022 	switch eDest {
  87023 	case SRT_Union:
  87024 		{
  87025 			var r1 int32
  87026 			r1 = Xsqlite3GetTempReg(tls, pParse)
  87027 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r1)
  87028 			Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, nResultCol)
  87029 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
  87030 			break
  87031 
  87032 		}
  87033 
  87034 	case SRT_Except:
  87035 		{
  87036 			Xsqlite3VdbeAddOp3(tls, v, OP_IdxDelete, iParm, regResult, nResultCol)
  87037 			break
  87038 
  87039 		}
  87040 
  87041 	case SRT_Fifo:
  87042 		fallthrough
  87043 	case SRT_DistFifo:
  87044 		fallthrough
  87045 	case SRT_Table:
  87046 		fallthrough
  87047 	case SRT_EphemTab:
  87048 		{
  87049 			var r1 int32 = Xsqlite3GetTempRange(tls, pParse, nPrefixReg+1)
  87050 
  87051 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r1+nPrefixReg)
  87052 			if eDest == SRT_DistFifo {
  87053 				var addr int32 = Xsqlite3VdbeCurrentAddr(tls, v) + 4
  87054 				Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iParm+1, addr, r1, 0)
  87055 
  87056 				Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm+1, r1, regResult, nResultCol)
  87057 
  87058 			}
  87059 			if pSort != 0 {
  87060 				pushOntoSorter(tls, pParse, pSort, p, r1+nPrefixReg, regOrig, 1, nPrefixReg)
  87061 			} else {
  87062 				var r2 int32 = Xsqlite3GetTempReg(tls, pParse)
  87063 				Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iParm, r2)
  87064 				Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, r2)
  87065 				Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND))
  87066 				Xsqlite3ReleaseTempReg(tls, pParse, r2)
  87067 			}
  87068 			Xsqlite3ReleaseTempRange(tls, pParse, r1, nPrefixReg+1)
  87069 			break
  87070 
  87071 		}
  87072 
  87073 	case SRT_Upfrom:
  87074 		{
  87075 			if pSort != 0 {
  87076 				pushOntoSorter(tls,
  87077 					pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg)
  87078 			} else {
  87079 				var i2 int32 = (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm2
  87080 				var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  87081 
  87082 				Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regResult, iBreak)
  87083 
  87084 				Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord,
  87085 					regResult+libc.Bool32(i2 < 0), nResultCol-libc.Bool32(i2 < 0), r1)
  87086 				if i2 < 0 {
  87087 					Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, regResult)
  87088 				} else {
  87089 					Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, i2)
  87090 				}
  87091 			}
  87092 			break
  87093 
  87094 		}
  87095 
  87096 	case SRT_Set:
  87097 		{
  87098 			if pSort != 0 {
  87099 				pushOntoSorter(tls,
  87100 					pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg)
  87101 			} else {
  87102 				var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  87103 
  87104 				Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regResult, nResultCol,
  87105 					r1, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nResultCol)
  87106 				Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, nResultCol)
  87107 				Xsqlite3ReleaseTempReg(tls, pParse, r1)
  87108 			}
  87109 			break
  87110 
  87111 		}
  87112 
  87113 	case SRT_Exists:
  87114 		{
  87115 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iParm)
  87116 
  87117 			break
  87118 
  87119 		}
  87120 
  87121 	case SRT_Mem:
  87122 		{
  87123 			if pSort != 0 {
  87124 				pushOntoSorter(tls,
  87125 					pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg)
  87126 			} else {
  87127 			}
  87128 			break
  87129 
  87130 		}
  87131 
  87132 	case SRT_Coroutine:
  87133 		fallthrough
  87134 	case SRT_Output:
  87135 		{
  87136 			if pSort != 0 {
  87137 				pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol,
  87138 					nPrefixReg)
  87139 			} else if eDest == SRT_Coroutine {
  87140 				Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm)
  87141 			} else {
  87142 				Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regResult, nResultCol)
  87143 			}
  87144 			break
  87145 
  87146 		}
  87147 
  87148 	case SRT_DistQueue:
  87149 		fallthrough
  87150 	case SRT_Queue:
  87151 		{
  87152 			var nKey int32
  87153 			var r1 int32
  87154 			var r2 int32
  87155 			var r3 int32
  87156 			var addrTest int32 = 0
  87157 			var pSO uintptr
  87158 			pSO = (*SelectDest)(unsafe.Pointer(pDest)).FpOrderBy
  87159 
  87160 			nKey = (*ExprList)(unsafe.Pointer(pSO)).FnExpr
  87161 			r1 = Xsqlite3GetTempReg(tls, pParse)
  87162 			r2 = Xsqlite3GetTempRange(tls, pParse, nKey+2)
  87163 			r3 = r2 + nKey + 1
  87164 			if eDest == SRT_DistQueue {
  87165 				addrTest = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iParm+1, 0,
  87166 					regResult, nResultCol)
  87167 
  87168 			}
  87169 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r3)
  87170 			if eDest == SRT_DistQueue {
  87171 				Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iParm+1, r3)
  87172 				Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT))
  87173 			}
  87174 			for i = 0; i < nKey; i++ {
  87175 				Xsqlite3VdbeAddOp2(tls, v, OP_SCopy,
  87176 					regResult+int32(*(*U16)(unsafe.Pointer(pSO + 8 + uintptr(i)*20 + 16)))-1,
  87177 					r2+i)
  87178 			}
  87179 			Xsqlite3VdbeAddOp2(tls, v, OP_Sequence, iParm, r2+nKey)
  87180 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r2, nKey+2, r1)
  87181 			Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, r2, nKey+2)
  87182 			if addrTest != 0 {
  87183 				Xsqlite3VdbeJumpHere(tls, v, addrTest)
  87184 			}
  87185 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
  87186 			Xsqlite3ReleaseTempRange(tls, pParse, r2, nKey+2)
  87187 			break
  87188 
  87189 		}
  87190 
  87191 	default:
  87192 		{
  87193 			break
  87194 
  87195 		}
  87196 	}
  87197 
  87198 	if pSort == uintptr(0) && (*Select)(unsafe.Pointer(p)).FiLimit != 0 {
  87199 		Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak)
  87200 	}
  87201 }
  87202 
  87203 // Allocate a KeyInfo object sufficient for an index of N key columns and
  87204 // X extra columns.
  87205 func Xsqlite3KeyInfoAlloc(tls *libc.TLS, db uintptr, N int32, X int32) uintptr {
  87206 	var nExtra int32 = int32(uint32(N+X)*(uint32(unsafe.Sizeof(uintptr(0)))+uint32(1)) - uint32(unsafe.Sizeof(uintptr(0))))
  87207 	var p uintptr = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(KeyInfo{}))+uint32(nExtra)))
  87208 	if p != 0 {
  87209 		(*KeyInfo)(unsafe.Pointer(p)).FaSortFlags = p + 20 + uintptr(N+X)*4
  87210 		(*KeyInfo)(unsafe.Pointer(p)).FnKeyField = U16(N)
  87211 		(*KeyInfo)(unsafe.Pointer(p)).FnAllField = U16(N + X)
  87212 		(*KeyInfo)(unsafe.Pointer(p)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc
  87213 		(*KeyInfo)(unsafe.Pointer(p)).Fdb = db
  87214 		(*KeyInfo)(unsafe.Pointer(p)).FnRef = U32(1)
  87215 		libc.Xmemset(tls, p+1*24, 0, uint32(nExtra))
  87216 	} else {
  87217 		return Xsqlite3OomFault(tls, db)
  87218 	}
  87219 	return p
  87220 }
  87221 
  87222 // Deallocate a KeyInfo object
  87223 func Xsqlite3KeyInfoUnref(tls *libc.TLS, p uintptr) {
  87224 	if p != 0 {
  87225 		(*KeyInfo)(unsafe.Pointer(p)).FnRef--
  87226 		if (*KeyInfo)(unsafe.Pointer(p)).FnRef == U32(0) {
  87227 			Xsqlite3DbNNFreeNN(tls, (*KeyInfo)(unsafe.Pointer(p)).Fdb, p)
  87228 		}
  87229 	}
  87230 }
  87231 
  87232 // Make a new pointer to a KeyInfo object
  87233 func Xsqlite3KeyInfoRef(tls *libc.TLS, p uintptr) uintptr {
  87234 	if p != 0 {
  87235 		(*KeyInfo)(unsafe.Pointer(p)).FnRef++
  87236 	}
  87237 	return p
  87238 }
  87239 
  87240 // Given an expression list, generate a KeyInfo structure that records
  87241 // the collating sequence for each expression in that expression list.
  87242 //
  87243 // If the ExprList is an ORDER BY or GROUP BY clause then the resulting
  87244 // KeyInfo structure is appropriate for initializing a virtual index to
  87245 // implement that clause.  If the ExprList is the result set of a SELECT
  87246 // then the KeyInfo structure is appropriate for initializing a virtual
  87247 // index to implement a DISTINCT test.
  87248 //
  87249 // Space to hold the KeyInfo structure is obtained from malloc.  The calling
  87250 // function is responsible for seeing that this structure is eventually
  87251 // freed.
  87252 func Xsqlite3KeyInfoFromExprList(tls *libc.TLS, pParse uintptr, pList uintptr, iStart int32, nExtra int32) uintptr {
  87253 	var nExpr int32
  87254 	var pInfo uintptr
  87255 	var pItem uintptr
  87256 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  87257 	var i int32
  87258 
  87259 	nExpr = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  87260 	pInfo = Xsqlite3KeyInfoAlloc(tls, db, nExpr-iStart, nExtra+1)
  87261 	if pInfo != 0 {
  87262 		i = iStart
  87263 		pItem = pList + 8 + uintptr(iStart)*20
  87264 	__1:
  87265 		if !(i < nExpr) {
  87266 			goto __3
  87267 		}
  87268 		{
  87269 			*(*uintptr)(unsafe.Pointer(pInfo + 20 + uintptr(i-iStart)*4)) = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)
  87270 			*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pInfo)).FaSortFlags + uintptr(i-iStart))) = (*ExprList_item)(unsafe.Pointer(pItem)).Ffg.FsortFlags
  87271 
  87272 		}
  87273 		goto __2
  87274 	__2:
  87275 		i++
  87276 		pItem += 20
  87277 		goto __1
  87278 		goto __3
  87279 	__3:
  87280 	}
  87281 	return pInfo
  87282 }
  87283 
  87284 // Name of the connection operator, used for error messages.
  87285 func Xsqlite3SelectOpName(tls *libc.TLS, id int32) uintptr {
  87286 	var z uintptr
  87287 	switch id {
  87288 	case TK_ALL:
  87289 		z = ts + 18746
  87290 		break
  87291 	case TK_INTERSECT:
  87292 		z = ts + 18756
  87293 		break
  87294 	case TK_EXCEPT:
  87295 		z = ts + 18766
  87296 		break
  87297 	default:
  87298 		z = ts + 18773
  87299 		break
  87300 	}
  87301 	return z
  87302 }
  87303 
  87304 func explainTempTable(tls *libc.TLS, pParse uintptr, zUsage uintptr) {
  87305 	bp := tls.Alloc(8)
  87306 	defer tls.Free(8)
  87307 
  87308 	Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+18779, libc.VaList(bp, zUsage))
  87309 }
  87310 
  87311 func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, nColumn int32, pDest uintptr) {
  87312 	bp := tls.Alloc(8)
  87313 	defer tls.Free(8)
  87314 
  87315 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  87316 	var addrBreak int32 = (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone
  87317 	var addrContinue int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
  87318 	var addr int32
  87319 	var addrOnce int32 = 0
  87320 	var iTab int32
  87321 	var pOrderBy uintptr = (*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy
  87322 	var eDest int32 = int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)
  87323 	var iParm int32 = (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm
  87324 	var regRow int32
  87325 	var regRowid int32
  87326 	var iCol int32
  87327 	var nKey int32
  87328 	var iSortTab int32
  87329 	var i int32
  87330 	var bSeq int32
  87331 	var nRefKey int32 = 0
  87332 	var aOutEx uintptr = (*Select)(unsafe.Pointer(p)).FpEList + 8
  87333 
  87334 	Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+18802, libc.VaList(bp, func() uintptr {
  87335 		if (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat > 0 {
  87336 			return ts + 18833
  87337 		}
  87338 		return ts + 1554
  87339 	}()))
  87340 
  87341 	if (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 {
  87342 		Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut)
  87343 		Xsqlite3VdbeGoto(tls, v, addrBreak)
  87344 		Xsqlite3VdbeResolveLabel(tls, v, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut)
  87345 	}
  87346 
  87347 	iTab = (*SortCtx)(unsafe.Pointer(pSort)).FiECursor
  87348 	if eDest == SRT_Output || eDest == SRT_Coroutine || eDest == SRT_Mem {
  87349 		if eDest == SRT_Mem && (*Select)(unsafe.Pointer(p)).FiOffset != 0 {
  87350 			Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst)
  87351 		}
  87352 		regRowid = 0
  87353 		regRow = (*SelectDest)(unsafe.Pointer(pDest)).FiSdst
  87354 	} else {
  87355 		regRowid = Xsqlite3GetTempReg(tls, pParse)
  87356 		if eDest == SRT_EphemTab || eDest == SRT_Table {
  87357 			regRow = Xsqlite3GetTempReg(tls, pParse)
  87358 			nColumn = 0
  87359 		} else {
  87360 			regRow = Xsqlite3GetTempRange(tls, pParse, nColumn)
  87361 		}
  87362 	}
  87363 	nKey = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat
  87364 	if int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags)&SORTFLAG_UseSorter != 0 {
  87365 		var regSortOut int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  87366 		iSortTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  87367 		if (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 {
  87368 			addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  87369 		}
  87370 		Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, iSortTab, regSortOut,
  87371 			nKey+1+nColumn+nRefKey)
  87372 		if addrOnce != 0 {
  87373 			Xsqlite3VdbeJumpHere(tls, v, addrOnce)
  87374 		}
  87375 		addr = 1 + Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, iTab, addrBreak)
  87376 
  87377 		Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, iTab, regSortOut, iSortTab)
  87378 		bSeq = 0
  87379 	} else {
  87380 		addr = 1 + Xsqlite3VdbeAddOp2(tls, v, OP_Sort, iTab, addrBreak)
  87381 		codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, addrContinue)
  87382 		iSortTab = iTab
  87383 		bSeq = 1
  87384 		if (*Select)(unsafe.Pointer(p)).FiOffset > 0 {
  87385 			Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Select)(unsafe.Pointer(p)).FiLimit, -1)
  87386 		}
  87387 	}
  87388 	i = 0
  87389 	iCol = nKey + bSeq - 1
  87390 	for ; i < nColumn; i++ {
  87391 		if int32(*(*U16)(unsafe.Pointer(aOutEx + uintptr(i)*20 + 16))) == 0 {
  87392 			iCol++
  87393 		}
  87394 	}
  87395 	for i = nColumn - 1; i >= 0; i-- {
  87396 		{
  87397 			var iRead int32
  87398 			if *(*U16)(unsafe.Pointer(aOutEx + uintptr(i)*20 + 16)) != 0 {
  87399 				iRead = int32(*(*U16)(unsafe.Pointer(aOutEx + uintptr(i)*20 + 16))) - 1
  87400 			} else {
  87401 				iRead = libc.PostDecInt32(&iCol, 1)
  87402 			}
  87403 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, iSortTab, iRead, regRow+i)
  87404 
  87405 		}
  87406 	}
  87407 
  87408 	switch eDest {
  87409 	case SRT_Table:
  87410 		fallthrough
  87411 	case SRT_EphemTab:
  87412 		{
  87413 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, iSortTab, nKey+bSeq, regRow)
  87414 			Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iParm, regRowid)
  87415 			Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, regRow, regRowid)
  87416 			Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND))
  87417 			break
  87418 
  87419 		}
  87420 	case SRT_Set:
  87421 		{
  87422 			Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regRow, nColumn, regRowid,
  87423 				(*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nColumn)
  87424 			Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, regRowid, regRow, nColumn)
  87425 			break
  87426 
  87427 		}
  87428 	case SRT_Mem:
  87429 		{
  87430 			break
  87431 
  87432 		}
  87433 	case SRT_Upfrom:
  87434 		{
  87435 			var i2 int32 = (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm2
  87436 			var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  87437 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regRow+libc.Bool32(i2 < 0), nColumn-libc.Bool32(i2 < 0), r1)
  87438 			if i2 < 0 {
  87439 				Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, regRow)
  87440 			} else {
  87441 				Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regRow, i2)
  87442 			}
  87443 			break
  87444 
  87445 		}
  87446 	default:
  87447 		{
  87448 			if eDest == SRT_Output {
  87449 				Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn)
  87450 			} else {
  87451 				Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm)
  87452 			}
  87453 			break
  87454 
  87455 		}
  87456 	}
  87457 	if regRowid != 0 {
  87458 		if eDest == SRT_Set {
  87459 			Xsqlite3ReleaseTempRange(tls, pParse, regRow, nColumn)
  87460 		} else {
  87461 			Xsqlite3ReleaseTempReg(tls, pParse, regRow)
  87462 		}
  87463 		Xsqlite3ReleaseTempReg(tls, pParse, regRowid)
  87464 	}
  87465 
  87466 	Xsqlite3VdbeResolveLabel(tls, v, addrContinue)
  87467 	if int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags)&SORTFLAG_UseSorter != 0 {
  87468 		Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, iTab, addr)
  87469 	} else {
  87470 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, iTab, addr)
  87471 	}
  87472 
  87473 	if (*SortCtx)(unsafe.Pointer(pSort)).FregReturn != 0 {
  87474 		Xsqlite3VdbeAddOp1(tls, v, OP_Return, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn)
  87475 	}
  87476 	Xsqlite3VdbeResolveLabel(tls, v, addrBreak)
  87477 }
  87478 
  87479 func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, pzOrigTab uintptr, pzOrigCol uintptr) uintptr {
  87480 	bp := tls.Alloc(76)
  87481 	defer tls.Free(76)
  87482 
  87483 	var zType uintptr = uintptr(0)
  87484 	var j int32
  87485 	*(*uintptr)(unsafe.Pointer(bp + 32)) = uintptr(0)
  87486 	*(*uintptr)(unsafe.Pointer(bp + 36)) = uintptr(0)
  87487 	*(*uintptr)(unsafe.Pointer(bp + 40)) = uintptr(0)
  87488 
  87489 	switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
  87490 	case TK_COLUMN:
  87491 		{
  87492 			var pTab uintptr = uintptr(0)
  87493 			var pS uintptr = uintptr(0)
  87494 			var iCol int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  87495 			for pNC != 0 && !(pTab != 0) {
  87496 				var pTabList uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpSrcList
  87497 				for j = 0; j < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc && (*SrcItem)(unsafe.Pointer(pTabList+8+uintptr(j)*72)).FiCursor != (*Expr)(unsafe.Pointer(pExpr)).FiTable; j++ {
  87498 				}
  87499 				if j < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc {
  87500 					pTab = (*SrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*72)).FpTab
  87501 					pS = (*SrcItem)(unsafe.Pointer(pTabList + 8 + uintptr(j)*72)).FpSelect
  87502 				} else {
  87503 					pNC = (*NameContext)(unsafe.Pointer(pNC)).FpNext
  87504 				}
  87505 			}
  87506 
  87507 			if pTab == uintptr(0) {
  87508 				break
  87509 			}
  87510 
  87511 			if pS != 0 {
  87512 				if iCol < (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pS)).FpEList)).FnExpr &&
  87513 					iCol >= 0 {
  87514 					var p uintptr = (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(pS)).FpEList + 8 + uintptr(iCol)*20)).FpExpr
  87515 					(*NameContext)(unsafe.Pointer(bp)).FpSrcList = (*Select)(unsafe.Pointer(pS)).FpSrc
  87516 					(*NameContext)(unsafe.Pointer(bp)).FpNext = pNC
  87517 					(*NameContext)(unsafe.Pointer(bp)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  87518 					zType = columnTypeImpl(tls, bp, p, bp+32, bp+36, bp+40)
  87519 				}
  87520 			} else {
  87521 				if iCol < 0 {
  87522 					iCol = int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
  87523 				}
  87524 
  87525 				if iCol < 0 {
  87526 					zType = ts + 1119
  87527 					*(*uintptr)(unsafe.Pointer(bp + 40)) = ts + 16267
  87528 				} else {
  87529 					*(*uintptr)(unsafe.Pointer(bp + 40)) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16)).FzCnName
  87530 					zType = Xsqlite3ColumnType(tls, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, uintptr(0))
  87531 				}
  87532 				*(*uintptr)(unsafe.Pointer(bp + 36)) = (*Table)(unsafe.Pointer(pTab)).FzName
  87533 				if (*NameContext)(unsafe.Pointer(pNC)).FpParse != 0 && (*Table)(unsafe.Pointer(pTab)).FpSchema != 0 {
  87534 					var iDb int32 = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer((*NameContext)(unsafe.Pointer(pNC)).FpParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  87535 					*(*uintptr)(unsafe.Pointer(bp + 32)) = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*NameContext)(unsafe.Pointer(pNC)).FpParse)).Fdb)).FaDb + uintptr(iDb)*16)).FzDbSName
  87536 				}
  87537 			}
  87538 			break
  87539 
  87540 		}
  87541 	case TK_SELECT:
  87542 		{
  87543 			var pS uintptr
  87544 			var p uintptr
  87545 
  87546 			pS = *(*uintptr)(unsafe.Pointer(pExpr + 20))
  87547 			p = (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(pS)).FpEList + 8)).FpExpr
  87548 			(*NameContext)(unsafe.Pointer(bp + 44)).FpSrcList = (*Select)(unsafe.Pointer(pS)).FpSrc
  87549 			(*NameContext)(unsafe.Pointer(bp + 44)).FpNext = pNC
  87550 			(*NameContext)(unsafe.Pointer(bp + 44)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse
  87551 			zType = columnTypeImpl(tls, bp+44, p, bp+32, bp+36, bp+40)
  87552 			break
  87553 
  87554 		}
  87555 	}
  87556 
  87557 	if pzOrigDb != 0 {
  87558 		*(*uintptr)(unsafe.Pointer(pzOrigDb)) = *(*uintptr)(unsafe.Pointer(bp + 32))
  87559 		*(*uintptr)(unsafe.Pointer(pzOrigTab)) = *(*uintptr)(unsafe.Pointer(bp + 36))
  87560 		*(*uintptr)(unsafe.Pointer(pzOrigCol)) = *(*uintptr)(unsafe.Pointer(bp + 40))
  87561 	}
  87562 	return zType
  87563 }
  87564 
  87565 func generateColumnTypes(tls *libc.TLS, pParse uintptr, pTabList uintptr, pEList uintptr) {
  87566 	bp := tls.Alloc(44)
  87567 	defer tls.Free(44)
  87568 
  87569 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  87570 	var i int32
  87571 
  87572 	(*NameContext)(unsafe.Pointer(bp)).FpSrcList = pTabList
  87573 	(*NameContext)(unsafe.Pointer(bp)).FpParse = pParse
  87574 	(*NameContext)(unsafe.Pointer(bp)).FpNext = uintptr(0)
  87575 	for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  87576 		var p uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FpExpr
  87577 		var zType uintptr
  87578 		*(*uintptr)(unsafe.Pointer(bp + 32)) = uintptr(0)
  87579 		*(*uintptr)(unsafe.Pointer(bp + 36)) = uintptr(0)
  87580 		*(*uintptr)(unsafe.Pointer(bp + 40)) = uintptr(0)
  87581 		zType = columnTypeImpl(tls, bp, p, bp+32, bp+36, bp+40)
  87582 
  87583 		Xsqlite3VdbeSetColName(tls, v, i, COLNAME_DATABASE, *(*uintptr)(unsafe.Pointer(bp + 32)), libc.UintptrFromInt32(-1))
  87584 		Xsqlite3VdbeSetColName(tls, v, i, COLNAME_TABLE, *(*uintptr)(unsafe.Pointer(bp + 36)), libc.UintptrFromInt32(-1))
  87585 		Xsqlite3VdbeSetColName(tls, v, i, COLNAME_COLUMN, *(*uintptr)(unsafe.Pointer(bp + 40)), libc.UintptrFromInt32(-1))
  87586 		Xsqlite3VdbeSetColName(tls, v, i, COLNAME_DECLTYPE, zType, libc.UintptrFromInt32(-1))
  87587 	}
  87588 }
  87589 
  87590 // Compute the column names for a SELECT statement.
  87591 //
  87592 // The only guarantee that SQLite makes about column names is that if the
  87593 // column has an AS clause assigning it a name, that will be the name used.
  87594 // That is the only documented guarantee.  However, countless applications
  87595 // developed over the years have made baseless assumptions about column names
  87596 // and will break if those assumptions changes.  Hence, use extreme caution
  87597 // when modifying this routine to avoid breaking legacy.
  87598 //
  87599 // See Also: sqlite3ColumnsFromExprList()
  87600 //
  87601 // The PRAGMA short_column_names and PRAGMA full_column_names settings are
  87602 // deprecated.  The default setting is short=ON, full=OFF.  99.9% of all
  87603 // applications should operate this way.  Nevertheless, we need to support the
  87604 // other modes for legacy:
  87605 //
  87606 //	short=OFF, full=OFF:      Column name is the text of the expression has it
  87607 //	                          originally appears in the SELECT statement.  In
  87608 //	                          other words, the zSpan of the result expression.
  87609 //
  87610 //	short=ON, full=OFF:       (This is the default setting).  If the result
  87611 //	                          refers directly to a table column, then the
  87612 //	                          result column name is just the table column
  87613 //	                          name: COLUMN.  Otherwise use zSpan.
  87614 //
  87615 //	full=ON, short=ANY:       If the result refers directly to a table column,
  87616 //	                          then the result column name with the table name
  87617 //	                          prefix, ex: TABLE.COLUMN.  Otherwise use zSpan.
  87618 func Xsqlite3GenerateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) {
  87619 	bp := tls.Alloc(24)
  87620 	defer tls.Free(24)
  87621 
  87622 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  87623 	var i int32
  87624 	var pTab uintptr
  87625 	var pTabList uintptr
  87626 	var pEList uintptr
  87627 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  87628 	var fullName int32
  87629 	var srcName int32
  87630 
  87631 	if (*Parse)(unsafe.Pointer(pParse)).Fexplain != 0 {
  87632 		return
  87633 	}
  87634 
  87635 	if (*Parse)(unsafe.Pointer(pParse)).FcolNamesSet != 0 {
  87636 		return
  87637 	}
  87638 
  87639 	for (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 {
  87640 		pSelect = (*Select)(unsafe.Pointer(pSelect)).FpPrior
  87641 	}
  87642 
  87643 	pTabList = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  87644 	pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList
  87645 
  87646 	(*Parse)(unsafe.Pointer(pParse)).FcolNamesSet = U8(1)
  87647 	fullName = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_FullColNames) != uint64(0))
  87648 	srcName = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ShortColNames) != uint64(0) || fullName != 0)
  87649 	Xsqlite3VdbeSetNumCols(tls, v, (*ExprList)(unsafe.Pointer(pEList)).FnExpr)
  87650 	for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ {
  87651 		var p uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FpExpr
  87652 
  87653 		if (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(i)*20)).FzEName != 0 && int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(i)*20 + 8 + 4))&0x3>>0) == ENAME_NAME {
  87654 			var zName uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FzEName
  87655 			Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, libc.UintptrFromInt32(-1))
  87656 		} else if srcName != 0 && int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN {
  87657 			var zCol uintptr
  87658 			var iCol int32 = int32((*Expr)(unsafe.Pointer(p)).FiColumn)
  87659 			pTab = *(*uintptr)(unsafe.Pointer(p + 44))
  87660 
  87661 			if iCol < 0 {
  87662 				iCol = int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
  87663 			}
  87664 
  87665 			if iCol < 0 {
  87666 				zCol = ts + 16267
  87667 			} else {
  87668 				zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16)).FzCnName
  87669 			}
  87670 			if fullName != 0 {
  87671 				var zName uintptr = uintptr(0)
  87672 				zName = Xsqlite3MPrintf(tls, db, ts+12061, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, zCol))
  87673 				Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  87674 			} else {
  87675 				Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zCol, libc.UintptrFromInt32(-1))
  87676 			}
  87677 		} else {
  87678 			var z uintptr = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*20)).FzEName
  87679 			if z == uintptr(0) {
  87680 				z = Xsqlite3MPrintf(tls, db, ts+18848, libc.VaList(bp+16, i+1))
  87681 			} else {
  87682 				z = Xsqlite3DbStrDup(tls, db, z)
  87683 			}
  87684 			Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, z, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomClear})))
  87685 		}
  87686 	}
  87687 	generateColumnTypes(tls, pParse, pTabList, pEList)
  87688 }
  87689 
  87690 // Given an expression list (which is really the list of expressions
  87691 // that form the result set of a SELECT statement) compute appropriate
  87692 // column names for a table that would hold the expression list.
  87693 //
  87694 // All column names will be unique.
  87695 //
  87696 // Only the column names are computed.  Column.zType, Column.zColl,
  87697 // and other fields of Column are zeroed.
  87698 //
  87699 // Return SQLITE_OK on success.  If a memory allocation error occurs,
  87700 // store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM.
  87701 //
  87702 // The only guarantee that SQLite makes about column names is that if the
  87703 // column has an AS clause assigning it a name, that will be the name used.
  87704 // That is the only documented guarantee.  However, countless applications
  87705 // developed over the years have made baseless assumptions about column names
  87706 // and will break if those assumptions changes.  Hence, use extreme caution
  87707 // when modifying this routine to avoid breaking legacy.
  87708 //
  87709 // See Also: sqlite3GenerateColumnNames()
  87710 func Xsqlite3ColumnsFromExprList(tls *libc.TLS, pParse uintptr, pEList uintptr, pnCol uintptr, paCol uintptr) int32 {
  87711 	bp := tls.Alloc(52)
  87712 	defer tls.Free(52)
  87713 
  87714 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  87715 	var i int32
  87716 	var j int32
  87717 
  87718 	var aCol uintptr
  87719 	var pCol uintptr
  87720 	var nCol int32
  87721 	var zName uintptr
  87722 	var nName int32
  87723 
  87724 	var pTab uintptr
  87725 
  87726 	Xsqlite3HashInit(tls, bp+32)
  87727 	if pEList != 0 {
  87728 		nCol = (*ExprList)(unsafe.Pointer(pEList)).FnExpr
  87729 		aCol = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(Column{}))*uint32(nCol)))
  87730 
  87731 		if nCol > 32767 {
  87732 			nCol = 32767
  87733 		}
  87734 	} else {
  87735 		nCol = 0
  87736 		aCol = uintptr(0)
  87737 	}
  87738 
  87739 	*(*I16)(unsafe.Pointer(pnCol)) = I16(nCol)
  87740 	*(*uintptr)(unsafe.Pointer(paCol)) = aCol
  87741 
  87742 	i = 0
  87743 	pCol = aCol
  87744 __1:
  87745 	if !(i < nCol && !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0)) {
  87746 		goto __3
  87747 	}
  87748 	{
  87749 		var pX uintptr = pEList + 8 + uintptr(i)*20
  87750 		var pCollide uintptr
  87751 
  87752 		if libc.AssignUintptr(&zName, (*ExprList_item)(unsafe.Pointer(pX)).FzEName) != uintptr(0) && int32(*(*uint16)(unsafe.Pointer(pX + 8 + 4))&0x3>>0) == ENAME_NAME {
  87753 		} else {
  87754 			var pColExpr uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pX)).FpExpr)
  87755 			for pColExpr != uintptr(0) && int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_DOT {
  87756 				pColExpr = (*Expr)(unsafe.Pointer(pColExpr)).FpRight
  87757 
  87758 			}
  87759 			if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_COLUMN &&
  87760 				(*Expr)(unsafe.Pointer(pColExpr)).Fflags&U32(EP_WinFunc|EP_Subrtn) == U32(0) &&
  87761 				*(*uintptr)(unsafe.Pointer(pColExpr + 44)) != uintptr(0) {
  87762 				var iCol int32 = int32((*Expr)(unsafe.Pointer(pColExpr)).FiColumn)
  87763 				pTab = *(*uintptr)(unsafe.Pointer(pColExpr + 44))
  87764 				if iCol < 0 {
  87765 					iCol = int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
  87766 				}
  87767 				if iCol >= 0 {
  87768 					zName = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16)).FzCnName
  87769 				} else {
  87770 					zName = ts + 16267
  87771 				}
  87772 			} else if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_ID {
  87773 				zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8))
  87774 			} else {
  87775 			}
  87776 		}
  87777 		if zName != 0 && !(Xsqlite3IsTrueOrFalse(tls, zName) != 0) {
  87778 			zName = Xsqlite3DbStrDup(tls, db, zName)
  87779 		} else {
  87780 			zName = Xsqlite3MPrintf(tls, db, ts+18848, libc.VaList(bp, i+1))
  87781 		}
  87782 
  87783 		*(*U32)(unsafe.Pointer(bp + 48)) = U32(0)
  87784 		for zName != 0 && libc.AssignUintptr(&pCollide, Xsqlite3HashFind(tls, bp+32, zName)) != uintptr(0) {
  87785 			if uint32(int32(*(*uint16)(unsafe.Pointer(pCollide + 8 + 4))&0x80>>7)) != 0 {
  87786 				*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_NOEXPAND)
  87787 			}
  87788 			nName = Xsqlite3Strlen30(tls, zName)
  87789 			if nName > 0 {
  87790 				for j = nName - 1; j > 0 && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zName + uintptr(j)))])&0x04 != 0; j-- {
  87791 				}
  87792 				if int32(*(*uint8)(unsafe.Pointer(zName + uintptr(j)))) == ':' {
  87793 					nName = j
  87794 				}
  87795 			}
  87796 			zName = Xsqlite3MPrintf(tls, db, ts+18857, libc.VaList(bp+8, nName, zName, libc.PreIncUint32(&*(*U32)(unsafe.Pointer(bp + 48)), 1)))
  87797 			Xsqlite3ProgressCheck(tls, pParse)
  87798 			if *(*U32)(unsafe.Pointer(bp + 48)) > U32(3) {
  87799 				Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U32(0))), bp+48)
  87800 			}
  87801 		}
  87802 		(*Column)(unsafe.Pointer(pCol)).FzCnName = zName
  87803 		(*Column)(unsafe.Pointer(pCol)).FhName = Xsqlite3StrIHash(tls, zName)
  87804 		if uint32(int32(*(*uint16)(unsafe.Pointer(pX + 8 + 4))&0x100>>8)) != 0 {
  87805 			*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_NOEXPAND)
  87806 		}
  87807 
  87808 		if zName != 0 && Xsqlite3HashInsert(tls, bp+32, zName, pX) == pX {
  87809 			Xsqlite3OomFault(tls, db)
  87810 		}
  87811 
  87812 	}
  87813 	goto __2
  87814 __2:
  87815 	i++
  87816 	pCol += 16
  87817 	goto __1
  87818 	goto __3
  87819 __3:
  87820 	;
  87821 	Xsqlite3HashClear(tls, bp+32)
  87822 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  87823 		for j = 0; j < i; j++ {
  87824 			Xsqlite3DbFree(tls, db, (*Column)(unsafe.Pointer(aCol+uintptr(j)*16)).FzCnName)
  87825 		}
  87826 		Xsqlite3DbFree(tls, db, aCol)
  87827 		*(*uintptr)(unsafe.Pointer(paCol)) = uintptr(0)
  87828 		*(*I16)(unsafe.Pointer(pnCol)) = int16(0)
  87829 		return (*Parse)(unsafe.Pointer(pParse)).Frc
  87830 	}
  87831 	return SQLITE_OK
  87832 }
  87833 
  87834 // pTab is a transient Table object that represents a subquery of some
  87835 // kind (maybe a parenthesized subquery in the FROM clause of a larger
  87836 // query, or a VIEW, or a CTE).  This routine computes type information
  87837 // for that Table object based on the Select object that implements the
  87838 // subquery.  For the purposes of this routine, "type infomation" means:
  87839 //
  87840 //   - The datatype name, as it might appear in a CREATE TABLE statement
  87841 //   - Which collating sequence to use for the column
  87842 //   - The affinity of the column
  87843 func Xsqlite3SubqueryColumnTypes(tls *libc.TLS, pParse uintptr, pTab uintptr, pSelect uintptr, aff uint8) {
  87844 	bp := tls.Alloc(32)
  87845 	defer tls.Free(32)
  87846 
  87847 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  87848 	var pCol uintptr
  87849 	var pColl uintptr
  87850 	var i int32
  87851 	var j int32
  87852 	var p uintptr
  87853 	var a uintptr
  87854 
  87855 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  87856 		return
  87857 	}
  87858 	for (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 {
  87859 		pSelect = (*Select)(unsafe.Pointer(pSelect)).FpPrior
  87860 	}
  87861 	a = (*Select)(unsafe.Pointer(pSelect)).FpEList + 8
  87862 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(NameContext{})))
  87863 	(*NameContext)(unsafe.Pointer(bp)).FpSrcList = (*Select)(unsafe.Pointer(pSelect)).FpSrc
  87864 	i = 0
  87865 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol
  87866 __1:
  87867 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  87868 		goto __3
  87869 	}
  87870 	{
  87871 		var zType uintptr
  87872 		var n I64
  87873 		*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_NOINSERT)
  87874 		p = (*ExprList_item)(unsafe.Pointer(a + uintptr(i)*20)).FpExpr
  87875 
  87876 		(*Column)(unsafe.Pointer(pCol)).Faffinity = Xsqlite3ExprAffinity(tls, p)
  87877 		if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) <= SQLITE_AFF_NONE {
  87878 			(*Column)(unsafe.Pointer(pCol)).Faffinity = aff
  87879 		}
  87880 		if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= SQLITE_AFF_TEXT && (*Select)(unsafe.Pointer(pSelect)).FpNext != 0 {
  87881 			var m int32 = 0
  87882 			var pS2 uintptr
  87883 			m = 0
  87884 			pS2 = (*Select)(unsafe.Pointer(pSelect)).FpNext
  87885 			for ; pS2 != 0; pS2 = (*Select)(unsafe.Pointer(pS2)).FpNext {
  87886 				m = m | Xsqlite3ExprDataType(tls, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(pS2)).FpEList+8+uintptr(i)*20)).FpExpr)
  87887 			}
  87888 			if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) == SQLITE_AFF_TEXT && m&0x01 != 0 {
  87889 				(*Column)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB)
  87890 			} else if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= SQLITE_AFF_NUMERIC && m&0x02 != 0 {
  87891 				(*Column)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB)
  87892 			}
  87893 			if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= SQLITE_AFF_NUMERIC && int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_CAST {
  87894 				(*Column)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_FLEXNUM)
  87895 			}
  87896 		}
  87897 		zType = columnTypeImpl(tls, bp, p, uintptr(0), uintptr(0), uintptr(0))
  87898 		if zType == uintptr(0) || int32((*Column)(unsafe.Pointer(pCol)).Faffinity) != int32(Xsqlite3AffinityType(tls, zType, uintptr(0))) {
  87899 			if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) == SQLITE_AFF_NUMERIC ||
  87900 				int32((*Column)(unsafe.Pointer(pCol)).Faffinity) == SQLITE_AFF_FLEXNUM {
  87901 				zType = ts + 18865
  87902 			} else {
  87903 				zType = uintptr(0)
  87904 				for j = 1; j < SQLITE_N_STDTYPE; j++ {
  87905 					if int32(Xsqlite3StdTypeAffinity[j]) == int32((*Column)(unsafe.Pointer(pCol)).Faffinity) {
  87906 						zType = Xsqlite3StdType[j]
  87907 						break
  87908 					}
  87909 				}
  87910 			}
  87911 		}
  87912 		if zType != 0 {
  87913 			var m I64 = I64(Xsqlite3Strlen30(tls, zType))
  87914 			n = I64(Xsqlite3Strlen30(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName))
  87915 			(*Column)(unsafe.Pointer(pCol)).FzCnName = Xsqlite3DbReallocOrFree(tls, db, (*Column)(unsafe.Pointer(pCol)).FzCnName, uint64(n+m+int64(2)))
  87916 			if (*Column)(unsafe.Pointer(pCol)).FzCnName != 0 {
  87917 				libc.Xmemcpy(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName+uintptr(n+int64(1)), zType, uint32(m+int64(1)))
  87918 				*(*U16)(unsafe.Pointer(pCol + 12)) |= U16(COLFLAG_HASTYPE)
  87919 			} else {
  87920 				*(*U16)(unsafe.Pointer(pCol + 12)) &= libc.Uint16FromInt32(libc.CplInt32(COLFLAG_HASTYPE | COLFLAG_HASCOLL))
  87921 			}
  87922 		}
  87923 		pColl = Xsqlite3ExprCollSeq(tls, pParse, p)
  87924 		if pColl != 0 {
  87925 			Xsqlite3ColumnSetColl(tls, db, pCol, (*CollSeq)(unsafe.Pointer(pColl)).FzName)
  87926 		}
  87927 
  87928 	}
  87929 	goto __2
  87930 __2:
  87931 	i++
  87932 	pCol += 16
  87933 	goto __1
  87934 	goto __3
  87935 __3:
  87936 	;
  87937 	(*Table)(unsafe.Pointer(pTab)).FszTabRow = int16(1)
  87938 }
  87939 
  87940 // Given a SELECT statement, generate a Table structure that describes
  87941 // the result set of that SELECT.
  87942 func Xsqlite3ResultSetOfSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, aff uint8) uintptr {
  87943 	var pTab uintptr
  87944 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  87945 	var savedFlags U64
  87946 
  87947 	savedFlags = (*Sqlite3)(unsafe.Pointer(db)).Fflags
  87948 	*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_FullColNames))
  87949 	*(*U64)(unsafe.Pointer(db + 32)) |= uint64(SQLITE_ShortColNames)
  87950 	Xsqlite3SelectPrep(tls, pParse, pSelect, uintptr(0))
  87951 	(*Sqlite3)(unsafe.Pointer(db)).Fflags = savedFlags
  87952 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  87953 		return uintptr(0)
  87954 	}
  87955 	for (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 {
  87956 		pSelect = (*Select)(unsafe.Pointer(pSelect)).FpPrior
  87957 	}
  87958 	pTab = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))
  87959 	if pTab == uintptr(0) {
  87960 		return uintptr(0)
  87961 	}
  87962 	(*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1)
  87963 	(*Table)(unsafe.Pointer(pTab)).FzName = uintptr(0)
  87964 	(*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200)
  87965 	Xsqlite3ColumnsFromExprList(tls, pParse, (*Select)(unsafe.Pointer(pSelect)).FpEList, pTab+34, pTab+4)
  87966 	Xsqlite3SubqueryColumnTypes(tls, pParse, pTab, pSelect, aff)
  87967 	(*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1)
  87968 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  87969 		Xsqlite3DeleteTable(tls, db, pTab)
  87970 		return uintptr(0)
  87971 	}
  87972 	return pTab
  87973 }
  87974 
  87975 // Get a VDBE for the given parser context.  Create a new one if necessary.
  87976 // If an error occurs, return NULL and leave a message in pParse.
  87977 func Xsqlite3GetVdbe(tls *libc.TLS, pParse uintptr) uintptr {
  87978 	if (*Parse)(unsafe.Pointer(pParse)).FpVdbe != 0 {
  87979 		return (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  87980 	}
  87981 	if (*Parse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) &&
  87982 		(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_FactorOutConst) == U32(0) {
  87983 		(*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(1)
  87984 	}
  87985 	return Xsqlite3VdbeCreate(tls, pParse)
  87986 }
  87987 
  87988 func computeLimitRegisters(tls *libc.TLS, pParse uintptr, p uintptr, iBreak int32) {
  87989 	bp := tls.Alloc(4)
  87990 	defer tls.Free(4)
  87991 
  87992 	var v uintptr = uintptr(0)
  87993 	var iLimit int32 = 0
  87994 	var iOffset int32
  87995 
  87996 	var pLimit uintptr = (*Select)(unsafe.Pointer(p)).FpLimit
  87997 
  87998 	if (*Select)(unsafe.Pointer(p)).FiLimit != 0 {
  87999 		return
  88000 	}
  88001 
  88002 	if pLimit != 0 {
  88003 		(*Select)(unsafe.Pointer(p)).FiLimit = libc.AssignInt32(&iLimit, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  88004 		v = Xsqlite3GetVdbe(tls, pParse)
  88005 
  88006 		if Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(pLimit)).FpLeft, bp) != 0 {
  88007 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp)), iLimit)
  88008 
  88009 			if *(*int32)(unsafe.Pointer(bp)) == 0 {
  88010 				Xsqlite3VdbeGoto(tls, v, iBreak)
  88011 			} else if *(*int32)(unsafe.Pointer(bp)) >= 0 && int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32(Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp))))) {
  88012 				(*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp))))
  88013 				*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_FixedLimit)
  88014 			}
  88015 		} else {
  88016 			Xsqlite3ExprCode(tls, pParse, (*Expr)(unsafe.Pointer(pLimit)).FpLeft, iLimit)
  88017 			Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, iLimit)
  88018 
  88019 			Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, iLimit, iBreak)
  88020 		}
  88021 		if (*Expr)(unsafe.Pointer(pLimit)).FpRight != 0 {
  88022 			(*Select)(unsafe.Pointer(p)).FiOffset = libc.AssignInt32(&iOffset, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  88023 			(*Parse)(unsafe.Pointer(pParse)).FnMem++
  88024 			Xsqlite3ExprCode(tls, pParse, (*Expr)(unsafe.Pointer(pLimit)).FpRight, iOffset)
  88025 			Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, iOffset)
  88026 
  88027 			Xsqlite3VdbeAddOp3(tls, v, OP_OffsetLimit, iLimit, iOffset+1, iOffset)
  88028 
  88029 		}
  88030 	}
  88031 }
  88032 
  88033 func multiSelectCollSeq(tls *libc.TLS, pParse uintptr, p uintptr, iCol int32) uintptr {
  88034 	var pRet uintptr
  88035 	if (*Select)(unsafe.Pointer(p)).FpPrior != 0 {
  88036 		pRet = multiSelectCollSeq(tls, pParse, (*Select)(unsafe.Pointer(p)).FpPrior, iCol)
  88037 	} else {
  88038 		pRet = uintptr(0)
  88039 	}
  88040 
  88041 	if pRet == uintptr(0) && iCol < (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr {
  88042 		pRet = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList+8+uintptr(iCol)*20)).FpExpr)
  88043 	}
  88044 	return pRet
  88045 }
  88046 
  88047 func multiSelectOrderByKeyInfo(tls *libc.TLS, pParse uintptr, p uintptr, nExtra int32) uintptr {
  88048 	var pOrderBy uintptr = (*Select)(unsafe.Pointer(p)).FpOrderBy
  88049 	var nOrderBy int32
  88050 	if pOrderBy != uintptr(0) {
  88051 		nOrderBy = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr
  88052 	} else {
  88053 		nOrderBy = 0
  88054 	}
  88055 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  88056 	var pRet uintptr = Xsqlite3KeyInfoAlloc(tls, db, nOrderBy+nExtra, 1)
  88057 	if pRet != 0 {
  88058 		var i int32
  88059 		for i = 0; i < nOrderBy; i++ {
  88060 			var pItem uintptr = pOrderBy + 8 + uintptr(i)*20
  88061 			var pTerm uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr
  88062 			var pColl uintptr
  88063 
  88064 			if (*Expr)(unsafe.Pointer(pTerm)).Fflags&U32(EP_Collate) != 0 {
  88065 				pColl = Xsqlite3ExprCollSeq(tls, pParse, pTerm)
  88066 			} else {
  88067 				pColl = multiSelectCollSeq(tls, pParse, p, int32(*(*U16)(unsafe.Pointer(pItem + 16)))-1)
  88068 				if pColl == uintptr(0) {
  88069 					pColl = (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl
  88070 				}
  88071 				(*ExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20)).FpExpr = Xsqlite3ExprAddCollateString(tls, pParse, pTerm, (*CollSeq)(unsafe.Pointer(pColl)).FzName)
  88072 			}
  88073 
  88074 			*(*uintptr)(unsafe.Pointer(pRet + 20 + uintptr(i)*4)) = pColl
  88075 			*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pRet)).FaSortFlags + uintptr(i))) = (*ExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20)).Ffg.FsortFlags
  88076 		}
  88077 	}
  88078 
  88079 	return pRet
  88080 }
  88081 
  88082 func generateWithRecursiveQuery(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) {
  88083 	bp := tls.Alloc(28)
  88084 	defer tls.Free(28)
  88085 
  88086 	var pSrc uintptr
  88087 	var nCol int32
  88088 	var v uintptr
  88089 	var pSetup uintptr
  88090 	var pFirstRec uintptr
  88091 	var addrTop int32
  88092 	var addrCont int32
  88093 	var addrBreak int32
  88094 	var iCurrent int32
  88095 	var regCurrent int32
  88096 	var iQueue int32
  88097 	var iDistinct int32
  88098 	var eDest int32
  88099 
  88100 	var i int32
  88101 	var rc int32
  88102 	var pOrderBy uintptr
  88103 	var pLimit uintptr
  88104 	var regLimit int32
  88105 	var regOffset int32
  88106 	var pKeyInfo uintptr
  88107 	pSrc = (*Select)(unsafe.Pointer(p)).FpSrc
  88108 	nCol = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr
  88109 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  88110 	iCurrent = 0
  88111 	iDistinct = 0
  88112 	eDest = SRT_Fifo
  88113 
  88114 	if !((*Select)(unsafe.Pointer(p)).FpWin != 0) {
  88115 		goto __1
  88116 	}
  88117 	Xsqlite3ErrorMsg(tls, pParse, ts+18869, 0)
  88118 	return
  88119 __1:
  88120 	;
  88121 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_RECURSIVE, uintptr(0), uintptr(0), uintptr(0)) != 0) {
  88122 		goto __2
  88123 	}
  88124 	return
  88125 __2:
  88126 	;
  88127 	addrBreak = Xsqlite3VdbeMakeLabel(tls, pParse)
  88128 	(*Select)(unsafe.Pointer(p)).FnSelectRow = int16(320)
  88129 	computeLimitRegisters(tls, pParse, p, addrBreak)
  88130 	pLimit = (*Select)(unsafe.Pointer(p)).FpLimit
  88131 	regLimit = (*Select)(unsafe.Pointer(p)).FiLimit
  88132 	regOffset = (*Select)(unsafe.Pointer(p)).FiOffset
  88133 	(*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0)
  88134 	(*Select)(unsafe.Pointer(p)).FiLimit = libc.AssignPtrInt32(p+12, 0)
  88135 	pOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy
  88136 
  88137 	i = 0
  88138 __3:
  88139 	if !(i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc) {
  88140 		goto __5
  88141 	}
  88142 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 36 + 4))&0x40>>6)) != 0) {
  88143 		goto __6
  88144 	}
  88145 	iCurrent = (*SrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72)).FiCursor
  88146 	goto __5
  88147 __6:
  88148 	;
  88149 	goto __4
  88150 __4:
  88151 	i++
  88152 	goto __3
  88153 	goto __5
  88154 __5:
  88155 	;
  88156 	iQueue = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  88157 	if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_UNION) {
  88158 		goto __7
  88159 	}
  88160 	if pOrderBy != 0 {
  88161 		eDest = SRT_DistQueue
  88162 	} else {
  88163 		eDest = SRT_DistFifo
  88164 	}
  88165 	iDistinct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  88166 	goto __8
  88167 __7:
  88168 	if pOrderBy != 0 {
  88169 		eDest = SRT_Queue
  88170 	} else {
  88171 		eDest = SRT_Fifo
  88172 	}
  88173 __8:
  88174 	;
  88175 	Xsqlite3SelectDestInit(tls, bp, eDest, iQueue)
  88176 
  88177 	regCurrent = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  88178 	Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, iCurrent, regCurrent, nCol)
  88179 	if !(pOrderBy != 0) {
  88180 		goto __9
  88181 	}
  88182 	pKeyInfo = multiSelectOrderByKeyInfo(tls, pParse, p, 1)
  88183 	Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, iQueue, (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr+2, 0,
  88184 		pKeyInfo, -8)
  88185 	(*SelectDest)(unsafe.Pointer(bp)).FpOrderBy = pOrderBy
  88186 	goto __10
  88187 __9:
  88188 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iQueue, nCol)
  88189 __10:
  88190 	;
  88191 	if !(iDistinct != 0) {
  88192 		goto __11
  88193 	}
  88194 	*(*int32)(unsafe.Pointer(p + 20)) = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iDistinct, 0)
  88195 	*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_UsesEphemeral)
  88196 __11:
  88197 	;
  88198 	(*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0)
  88199 
  88200 	pFirstRec = p
  88201 __12:
  88202 	if !(pFirstRec != uintptr(0)) {
  88203 		goto __14
  88204 	}
  88205 	if !((*Select)(unsafe.Pointer(pFirstRec)).FselFlags&U32(SF_Aggregate) != 0) {
  88206 		goto __15
  88207 	}
  88208 	Xsqlite3ErrorMsg(tls, pParse, ts+18918, 0)
  88209 	goto end_of_recursive_query
  88210 __15:
  88211 	;
  88212 	(*Select)(unsafe.Pointer(pFirstRec)).Fop = U8(TK_ALL)
  88213 	if !((*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(pFirstRec)).FpPrior)).FselFlags&U32(SF_Recursive) == U32(0)) {
  88214 		goto __16
  88215 	}
  88216 	goto __14
  88217 __16:
  88218 	;
  88219 	goto __13
  88220 __13:
  88221 	pFirstRec = (*Select)(unsafe.Pointer(pFirstRec)).FpPrior
  88222 	goto __12
  88223 	goto __14
  88224 __14:
  88225 	;
  88226 	pSetup = (*Select)(unsafe.Pointer(pFirstRec)).FpPrior
  88227 	(*Select)(unsafe.Pointer(pSetup)).FpNext = uintptr(0)
  88228 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+18960, 0)
  88229 	rc = Xsqlite3Select(tls, pParse, pSetup, bp)
  88230 	(*Select)(unsafe.Pointer(pSetup)).FpNext = p
  88231 	if !(rc != 0) {
  88232 		goto __17
  88233 	}
  88234 	goto end_of_recursive_query
  88235 __17:
  88236 	;
  88237 	addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iQueue, addrBreak)
  88238 
  88239 	Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, iCurrent)
  88240 	if !(pOrderBy != 0) {
  88241 		goto __18
  88242 	}
  88243 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iQueue, (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr+1, regCurrent)
  88244 	goto __19
  88245 __18:
  88246 	Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iQueue, regCurrent)
  88247 __19:
  88248 	;
  88249 	Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iQueue)
  88250 
  88251 	addrCont = Xsqlite3VdbeMakeLabel(tls, pParse)
  88252 	codeOffset(tls, v, regOffset, addrCont)
  88253 	selectInnerLoop(tls, pParse, p, iCurrent,
  88254 		uintptr(0), uintptr(0), pDest, addrCont, addrBreak)
  88255 	if !(regLimit != 0) {
  88256 		goto __20
  88257 	}
  88258 	Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, regLimit, addrBreak)
  88259 
  88260 __20:
  88261 	;
  88262 	Xsqlite3VdbeResolveLabel(tls, v, addrCont)
  88263 
  88264 	(*Select)(unsafe.Pointer(pFirstRec)).FpPrior = uintptr(0)
  88265 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+18966, 0)
  88266 	Xsqlite3Select(tls, pParse, p, bp)
  88267 
  88268 	(*Select)(unsafe.Pointer(pFirstRec)).FpPrior = pSetup
  88269 
  88270 	Xsqlite3VdbeGoto(tls, v, addrTop)
  88271 	Xsqlite3VdbeResolveLabel(tls, v, addrBreak)
  88272 
  88273 end_of_recursive_query:
  88274 	Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Select)(unsafe.Pointer(p)).FpOrderBy)
  88275 	(*Select)(unsafe.Pointer(p)).FpOrderBy = pOrderBy
  88276 	(*Select)(unsafe.Pointer(p)).FpLimit = pLimit
  88277 	return
  88278 }
  88279 
  88280 func multiSelectValues(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int32 {
  88281 	bp := tls.Alloc(16)
  88282 	defer tls.Free(16)
  88283 
  88284 	var nRow int32 = 1
  88285 	var rc int32 = 0
  88286 	var bShowAll int32 = libc.Bool32((*Select)(unsafe.Pointer(p)).FpLimit == uintptr(0))
  88287 
  88288 	for __ccgo := true; __ccgo; __ccgo = 1 != 0 {
  88289 		if (*Select)(unsafe.Pointer(p)).FpWin != 0 {
  88290 			return -1
  88291 		}
  88292 		if (*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0) {
  88293 			break
  88294 		}
  88295 
  88296 		p = (*Select)(unsafe.Pointer(p)).FpPrior
  88297 		nRow = nRow + bShowAll
  88298 	}
  88299 	Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+18981, libc.VaList(bp, nRow, func() uintptr {
  88300 		if nRow == 1 {
  88301 			return ts + 1554
  88302 		}
  88303 		return ts + 19004
  88304 	}()))
  88305 	for p != 0 {
  88306 		selectInnerLoop(tls, pParse, p, -1, uintptr(0), uintptr(0), pDest, 1, 1)
  88307 		if !(bShowAll != 0) {
  88308 			break
  88309 		}
  88310 		(*Select)(unsafe.Pointer(p)).FnSelectRow = LogEst(nRow)
  88311 		p = (*Select)(unsafe.Pointer(p)).FpNext
  88312 	}
  88313 	return rc
  88314 }
  88315 
  88316 func hasAnchor(tls *libc.TLS, p uintptr) int32 {
  88317 	for p != 0 && (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Recursive) != U32(0) {
  88318 		p = (*Select)(unsafe.Pointer(p)).FpPrior
  88319 	}
  88320 	return libc.Bool32(p != uintptr(0))
  88321 }
  88322 
  88323 func multiSelect(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int32 {
  88324 	bp := tls.Alloc(104)
  88325 	defer tls.Free(104)
  88326 
  88327 	var rc int32
  88328 	var pPrior uintptr
  88329 	var v uintptr
  88330 
  88331 	var pDelete uintptr
  88332 	var db uintptr
  88333 	var addr int32
  88334 
  88335 	var iCont int32
  88336 	var iBreak int32
  88337 	var iStart int32
  88338 	var unionTab int32
  88339 	var op U8
  88340 	var priorOp int32
  88341 	var pLimit uintptr
  88342 	var addr1 int32
  88343 
  88344 	var tab1 int32
  88345 	var tab2 int32
  88346 	var iCont1 int32
  88347 	var iBreak1 int32
  88348 	var iStart1 int32
  88349 	var pLimit1 uintptr
  88350 	var addr2 int32
  88351 
  88352 	var r1 int32
  88353 	var addr3 int32
  88354 	var i int32
  88355 	var pKeyInfo uintptr
  88356 	var pLoop uintptr
  88357 	var apColl uintptr
  88358 	var nCol int32
  88359 	rc = SQLITE_OK
  88360 	pDelete = uintptr(0)
  88361 
  88362 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  88363 	pPrior = (*Select)(unsafe.Pointer(p)).FpPrior
  88364 	*(*SelectDest)(unsafe.Pointer(bp + 16)) = *(*SelectDest)(unsafe.Pointer(pDest))
  88365 
  88366 	v = Xsqlite3GetVdbe(tls, pParse)
  88367 
  88368 	if !(int32((*SelectDest)(unsafe.Pointer(bp+16)).FeDest) == SRT_EphemTab) {
  88369 		goto __1
  88370 	}
  88371 
  88372 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*SelectDest)(unsafe.Pointer(bp+16)).FiSDParm, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr)
  88373 	(*SelectDest)(unsafe.Pointer(bp + 16)).FeDest = U8(SRT_Table)
  88374 __1:
  88375 	;
  88376 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_MultiValue) != 0) {
  88377 		goto __2
  88378 	}
  88379 	rc = multiSelectValues(tls, pParse, p, bp+16)
  88380 	if !(rc >= 0) {
  88381 		goto __3
  88382 	}
  88383 	goto multi_select_end
  88384 __3:
  88385 	;
  88386 	rc = SQLITE_OK
  88387 __2:
  88388 	;
  88389 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Recursive) != U32(0) && hasAnchor(tls, p) != 0) {
  88390 		goto __4
  88391 	}
  88392 	generateWithRecursiveQuery(tls, pParse, p, bp+16)
  88393 	goto __5
  88394 __4:
  88395 	if !((*Select)(unsafe.Pointer(p)).FpOrderBy != 0) {
  88396 		goto __6
  88397 	}
  88398 	return multiSelectOrderBy(tls, pParse, p, pDest)
  88399 	goto __7
  88400 __6:
  88401 	if !((*Select)(unsafe.Pointer(pPrior)).FpPrior == uintptr(0)) {
  88402 		goto __8
  88403 	}
  88404 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19006, 0)
  88405 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19021, 0)
  88406 __8:
  88407 	;
  88408 	switch int32((*Select)(unsafe.Pointer(p)).Fop) {
  88409 	case TK_ALL:
  88410 		goto __10
  88411 	case TK_EXCEPT:
  88412 		goto __11
  88413 	case TK_UNION:
  88414 		goto __12
  88415 	default:
  88416 		goto __13
  88417 	}
  88418 	goto __9
  88419 __10:
  88420 	addr = 0
  88421 	*(*int32)(unsafe.Pointer(bp + 44)) = 0
  88422 
  88423 	(*Select)(unsafe.Pointer(pPrior)).FiLimit = (*Select)(unsafe.Pointer(p)).FiLimit
  88424 	(*Select)(unsafe.Pointer(pPrior)).FiOffset = (*Select)(unsafe.Pointer(p)).FiOffset
  88425 	(*Select)(unsafe.Pointer(pPrior)).FpLimit = (*Select)(unsafe.Pointer(p)).FpLimit
  88426 
  88427 	rc = Xsqlite3Select(tls, pParse, pPrior, bp+16)
  88428 	(*Select)(unsafe.Pointer(pPrior)).FpLimit = uintptr(0)
  88429 	if !(rc != 0) {
  88430 		goto __14
  88431 	}
  88432 	goto multi_select_end
  88433 __14:
  88434 	;
  88435 	(*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0)
  88436 	(*Select)(unsafe.Pointer(p)).FiLimit = (*Select)(unsafe.Pointer(pPrior)).FiLimit
  88437 	(*Select)(unsafe.Pointer(p)).FiOffset = (*Select)(unsafe.Pointer(pPrior)).FiOffset
  88438 	if !((*Select)(unsafe.Pointer(p)).FiLimit != 0) {
  88439 		goto __15
  88440 	}
  88441 	addr = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, (*Select)(unsafe.Pointer(p)).FiLimit)
  88442 
  88443 	if !((*Select)(unsafe.Pointer(p)).FiOffset != 0) {
  88444 		goto __16
  88445 	}
  88446 	Xsqlite3VdbeAddOp3(tls, v, OP_OffsetLimit,
  88447 		(*Select)(unsafe.Pointer(p)).FiLimit, (*Select)(unsafe.Pointer(p)).FiOffset+1, (*Select)(unsafe.Pointer(p)).FiOffset)
  88448 __16:
  88449 	;
  88450 __15:
  88451 	;
  88452 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+18746, 0)
  88453 
  88454 	rc = Xsqlite3Select(tls, pParse, p, bp+16)
  88455 
  88456 	pDelete = (*Select)(unsafe.Pointer(p)).FpPrior
  88457 	(*Select)(unsafe.Pointer(p)).FpPrior = pPrior
  88458 	(*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow)
  88459 	if !((*Select)(unsafe.Pointer(p)).FpLimit != 0 &&
  88460 		Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpLimit)).FpLeft, bp+44) != 0 &&
  88461 		*(*int32)(unsafe.Pointer(bp + 44)) > 0 && int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32(Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp + 44)))))) {
  88462 		goto __17
  88463 	}
  88464 	(*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp + 44))))
  88465 __17:
  88466 	;
  88467 	if !(addr != 0) {
  88468 		goto __18
  88469 	}
  88470 	Xsqlite3VdbeJumpHere(tls, v, addr)
  88471 __18:
  88472 	;
  88473 	goto __9
  88474 
  88475 __11:
  88476 __12:
  88477 	op = U8(0)
  88478 
  88479 	priorOp = SRT_Union
  88480 	if !(int32((*SelectDest)(unsafe.Pointer(bp+16)).FeDest) == priorOp) {
  88481 		goto __19
  88482 	}
  88483 
  88484 	unionTab = (*SelectDest)(unsafe.Pointer(bp + 16)).FiSDParm
  88485 	goto __20
  88486 __19:
  88487 	unionTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  88488 
  88489 	addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, unionTab, 0)
  88490 
  88491 	*(*int32)(unsafe.Pointer(p + 20)) = addr1
  88492 	*(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4)) |= U32(SF_UsesEphemeral)
  88493 
  88494 __20:
  88495 	;
  88496 	Xsqlite3SelectDestInit(tls, bp+48, priorOp, unionTab)
  88497 
  88498 	rc = Xsqlite3Select(tls, pParse, pPrior, bp+48)
  88499 	if !(rc != 0) {
  88500 		goto __21
  88501 	}
  88502 	goto multi_select_end
  88503 __21:
  88504 	;
  88505 	if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_EXCEPT) {
  88506 		goto __22
  88507 	}
  88508 	op = U8(SRT_Except)
  88509 	goto __23
  88510 __22:
  88511 	;
  88512 	op = U8(SRT_Union)
  88513 __23:
  88514 	;
  88515 	(*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0)
  88516 	pLimit = (*Select)(unsafe.Pointer(p)).FpLimit
  88517 	(*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0)
  88518 	(*SelectDest)(unsafe.Pointer(bp + 48)).FeDest = op
  88519 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19040, libc.VaList(bp, Xsqlite3SelectOpName(tls, int32((*Select)(unsafe.Pointer(p)).Fop))))
  88520 
  88521 	rc = Xsqlite3Select(tls, pParse, p, bp+48)
  88522 
  88523 	pDelete = (*Select)(unsafe.Pointer(p)).FpPrior
  88524 	(*Select)(unsafe.Pointer(p)).FpPrior = pPrior
  88525 	(*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0)
  88526 	if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_UNION) {
  88527 		goto __24
  88528 	}
  88529 	(*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow)
  88530 __24:
  88531 	;
  88532 	Xsqlite3ExprDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit)
  88533 	(*Select)(unsafe.Pointer(p)).FpLimit = pLimit
  88534 	(*Select)(unsafe.Pointer(p)).FiLimit = 0
  88535 	(*Select)(unsafe.Pointer(p)).FiOffset = 0
  88536 
  88537 	if !(int32((*SelectDest)(unsafe.Pointer(bp+16)).FeDest) != priorOp && int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) {
  88538 		goto __25
  88539 	}
  88540 	iBreak = Xsqlite3VdbeMakeLabel(tls, pParse)
  88541 	iCont = Xsqlite3VdbeMakeLabel(tls, pParse)
  88542 	computeLimitRegisters(tls, pParse, p, iBreak)
  88543 	Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, unionTab, iBreak)
  88544 	iStart = Xsqlite3VdbeCurrentAddr(tls, v)
  88545 	selectInnerLoop(tls, pParse, p, unionTab,
  88546 		uintptr(0), uintptr(0), bp+16, iCont, iBreak)
  88547 	Xsqlite3VdbeResolveLabel(tls, v, iCont)
  88548 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, unionTab, iStart)
  88549 	Xsqlite3VdbeResolveLabel(tls, v, iBreak)
  88550 	Xsqlite3VdbeAddOp2(tls, v, OP_Close, unionTab, 0)
  88551 __25:
  88552 	;
  88553 	goto __9
  88554 
  88555 __13:
  88556 	;
  88557 	tab1 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  88558 	tab2 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  88559 
  88560 	addr2 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, tab1, 0)
  88561 
  88562 	*(*int32)(unsafe.Pointer(p + 20)) = addr2
  88563 	*(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4)) |= U32(SF_UsesEphemeral)
  88564 
  88565 	Xsqlite3SelectDestInit(tls, bp+76, SRT_Union, tab1)
  88566 
  88567 	rc = Xsqlite3Select(tls, pParse, pPrior, bp+76)
  88568 	if !(rc != 0) {
  88569 		goto __26
  88570 	}
  88571 	goto multi_select_end
  88572 __26:
  88573 	;
  88574 	addr2 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, tab2, 0)
  88575 
  88576 	*(*int32)(unsafe.Pointer(p + 20 + 1*4)) = addr2
  88577 	(*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0)
  88578 	pLimit1 = (*Select)(unsafe.Pointer(p)).FpLimit
  88579 	(*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0)
  88580 	(*SelectDest)(unsafe.Pointer(bp + 76)).FiSDParm = tab2
  88581 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19040, libc.VaList(bp+8, Xsqlite3SelectOpName(tls, int32((*Select)(unsafe.Pointer(p)).Fop))))
  88582 
  88583 	rc = Xsqlite3Select(tls, pParse, p, bp+76)
  88584 
  88585 	pDelete = (*Select)(unsafe.Pointer(p)).FpPrior
  88586 	(*Select)(unsafe.Pointer(p)).FpPrior = pPrior
  88587 	if !(int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32((*Select)(unsafe.Pointer(pPrior)).FnSelectRow)) {
  88588 		goto __27
  88589 	}
  88590 	(*Select)(unsafe.Pointer(p)).FnSelectRow = (*Select)(unsafe.Pointer(pPrior)).FnSelectRow
  88591 __27:
  88592 	;
  88593 	Xsqlite3ExprDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit)
  88594 	(*Select)(unsafe.Pointer(p)).FpLimit = pLimit1
  88595 
  88596 	if !(rc != 0) {
  88597 		goto __28
  88598 	}
  88599 	goto __9
  88600 __28:
  88601 	;
  88602 	iBreak1 = Xsqlite3VdbeMakeLabel(tls, pParse)
  88603 	iCont1 = Xsqlite3VdbeMakeLabel(tls, pParse)
  88604 	computeLimitRegisters(tls, pParse, p, iBreak1)
  88605 	Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, tab1, iBreak1)
  88606 	r1 = Xsqlite3GetTempReg(tls, pParse)
  88607 	iStart1 = Xsqlite3VdbeAddOp2(tls, v, OP_RowData, tab1, r1)
  88608 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, tab2, iCont1, r1, 0)
  88609 
  88610 	Xsqlite3ReleaseTempReg(tls, pParse, r1)
  88611 	selectInnerLoop(tls, pParse, p, tab1,
  88612 		uintptr(0), uintptr(0), bp+16, iCont1, iBreak1)
  88613 	Xsqlite3VdbeResolveLabel(tls, v, iCont1)
  88614 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, tab1, iStart1)
  88615 	Xsqlite3VdbeResolveLabel(tls, v, iBreak1)
  88616 	Xsqlite3VdbeAddOp2(tls, v, OP_Close, tab2, 0)
  88617 	Xsqlite3VdbeAddOp2(tls, v, OP_Close, tab1, 0)
  88618 	goto __9
  88619 
  88620 __9:
  88621 	;
  88622 	if !((*Select)(unsafe.Pointer(p)).FpNext == uintptr(0)) {
  88623 		goto __29
  88624 	}
  88625 	Xsqlite3VdbeExplainPop(tls, pParse)
  88626 __29:
  88627 	;
  88628 __7:
  88629 	;
  88630 __5:
  88631 	;
  88632 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  88633 		goto __30
  88634 	}
  88635 	goto multi_select_end
  88636 __30:
  88637 	;
  88638 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_UsesEphemeral) != 0) {
  88639 		goto __31
  88640 	}
  88641 
  88642 	nCol = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr
  88643 	pKeyInfo = Xsqlite3KeyInfoAlloc(tls, db, nCol, 1)
  88644 	if !!(pKeyInfo != 0) {
  88645 		goto __32
  88646 	}
  88647 	rc = SQLITE_NOMEM
  88648 	goto multi_select_end
  88649 __32:
  88650 	;
  88651 	i = 0
  88652 	apColl = pKeyInfo + 20
  88653 __33:
  88654 	if !(i < nCol) {
  88655 		goto __35
  88656 	}
  88657 	*(*uintptr)(unsafe.Pointer(apColl)) = multiSelectCollSeq(tls, pParse, p, i)
  88658 	if !(uintptr(0) == *(*uintptr)(unsafe.Pointer(apColl))) {
  88659 		goto __36
  88660 	}
  88661 	*(*uintptr)(unsafe.Pointer(apColl)) = (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl
  88662 __36:
  88663 	;
  88664 	goto __34
  88665 __34:
  88666 	i++
  88667 	apColl += 4
  88668 	goto __33
  88669 	goto __35
  88670 __35:
  88671 	;
  88672 	pLoop = p
  88673 __37:
  88674 	if !(pLoop != 0) {
  88675 		goto __39
  88676 	}
  88677 	i = 0
  88678 __40:
  88679 	if !(i < 2) {
  88680 		goto __42
  88681 	}
  88682 	addr3 = *(*int32)(unsafe.Pointer(pLoop + 20 + uintptr(i)*4))
  88683 	if !(addr3 < 0) {
  88684 		goto __43
  88685 	}
  88686 
  88687 	goto __42
  88688 __43:
  88689 	;
  88690 	Xsqlite3VdbeChangeP2(tls, v, addr3, nCol)
  88691 	Xsqlite3VdbeChangeP4(tls, v, addr3, Xsqlite3KeyInfoRef(tls, pKeyInfo),
  88692 		-8)
  88693 	*(*int32)(unsafe.Pointer(pLoop + 20 + uintptr(i)*4)) = -1
  88694 	goto __41
  88695 __41:
  88696 	i++
  88697 	goto __40
  88698 	goto __42
  88699 __42:
  88700 	;
  88701 	goto __38
  88702 __38:
  88703 	pLoop = (*Select)(unsafe.Pointer(pLoop)).FpPrior
  88704 	goto __37
  88705 	goto __39
  88706 __39:
  88707 	;
  88708 	Xsqlite3KeyInfoUnref(tls, pKeyInfo)
  88709 __31:
  88710 	;
  88711 multi_select_end:
  88712 	(*SelectDest)(unsafe.Pointer(pDest)).FiSdst = (*SelectDest)(unsafe.Pointer(bp + 16)).FiSdst
  88713 	(*SelectDest)(unsafe.Pointer(pDest)).FnSdst = (*SelectDest)(unsafe.Pointer(bp + 16)).FnSdst
  88714 	if !(pDelete != 0) {
  88715 		goto __44
  88716 	}
  88717 	Xsqlite3ParserAddCleanup(tls, pParse,
  88718 		*(*uintptr)(unsafe.Pointer(&struct {
  88719 			f func(*libc.TLS, uintptr, uintptr)
  88720 		}{Xsqlite3SelectDelete})),
  88721 		pDelete)
  88722 __44:
  88723 	;
  88724 	return rc
  88725 }
  88726 
  88727 // Error message for when two or more terms of a compound select have different
  88728 // size result sets.
  88729 func Xsqlite3SelectWrongNumTermsError(tls *libc.TLS, pParse uintptr, p uintptr) {
  88730 	bp := tls.Alloc(8)
  88731 	defer tls.Free(8)
  88732 
  88733 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Values) != 0 {
  88734 		Xsqlite3ErrorMsg(tls, pParse, ts+19061, 0)
  88735 	} else {
  88736 		Xsqlite3ErrorMsg(tls, pParse,
  88737 			ts+19107,
  88738 			libc.VaList(bp, Xsqlite3SelectOpName(tls, int32((*Select)(unsafe.Pointer(p)).Fop))))
  88739 	}
  88740 }
  88741 
  88742 func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uintptr, pDest uintptr, regReturn int32, regPrev int32, pKeyInfo uintptr, iBreak int32) int32 {
  88743 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  88744 	var iContinue int32
  88745 	var addr int32
  88746 
  88747 	addr = Xsqlite3VdbeCurrentAddr(tls, v)
  88748 	iContinue = Xsqlite3VdbeMakeLabel(tls, pParse)
  88749 
  88750 	if regPrev != 0 {
  88751 		var addr1 int32
  88752 		var addr2 int32
  88753 		addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regPrev)
  88754 		addr2 = Xsqlite3VdbeAddOp4(tls, v, OP_Compare, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, regPrev+1, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst,
  88755 			Xsqlite3KeyInfoRef(tls, pKeyInfo), -8)
  88756 		Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addr2+2, iContinue, addr2+2)
  88757 		Xsqlite3VdbeJumpHere(tls, v, addr1)
  88758 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, regPrev+1, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst-1)
  88759 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regPrev)
  88760 	}
  88761 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  88762 		return 0
  88763 	}
  88764 
  88765 	codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, iContinue)
  88766 
  88767 	switch int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) {
  88768 	case SRT_EphemTab:
  88769 		{
  88770 			var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
  88771 			var r2 int32 = Xsqlite3GetTempReg(tls, pParse)
  88772 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1)
  88773 			Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r2)
  88774 			Xsqlite3VdbeAddOp3(tls, v, OP_Insert, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, r2)
  88775 			Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_APPEND))
  88776 			Xsqlite3ReleaseTempReg(tls, pParse, r2)
  88777 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
  88778 			break
  88779 
  88780 		}
  88781 
  88782 	case SRT_Set:
  88783 		{
  88784 			var r1 int32
  88785 
  88786 			r1 = Xsqlite3GetTempReg(tls, pParse)
  88787 			Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst,
  88788 				r1, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst)
  88789 			Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1,
  88790 				(*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst)
  88791 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
  88792 			break
  88793 
  88794 		}
  88795 
  88796 	case SRT_Mem:
  88797 		{
  88798 			Xsqlite3ExprCodeMove(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst)
  88799 
  88800 			break
  88801 
  88802 		}
  88803 
  88804 	case SRT_Coroutine:
  88805 		{
  88806 			if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 {
  88807 				(*SelectDest)(unsafe.Pointer(pDest)).FiSdst = Xsqlite3GetTempRange(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst)
  88808 				(*SelectDest)(unsafe.Pointer(pDest)).FnSdst = (*SelectDest)(unsafe.Pointer(pIn)).FnSdst
  88809 			}
  88810 			Xsqlite3ExprCodeMove(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst)
  88811 			Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm)
  88812 			break
  88813 
  88814 		}
  88815 
  88816 	default:
  88817 		{
  88818 			Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst)
  88819 			break
  88820 
  88821 		}
  88822 	}
  88823 
  88824 	if (*Select)(unsafe.Pointer(p)).FiLimit != 0 {
  88825 		Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak)
  88826 	}
  88827 
  88828 	Xsqlite3VdbeResolveLabel(tls, v, iContinue)
  88829 	Xsqlite3VdbeAddOp1(tls, v, OP_Return, regReturn)
  88830 
  88831 	return addr
  88832 }
  88833 
  88834 func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int32 {
  88835 	bp := tls.Alloc(64)
  88836 	defer tls.Free(64)
  88837 
  88838 	var i int32
  88839 	var j int32
  88840 	var pPrior uintptr
  88841 	var pSplit uintptr
  88842 	var nSelect int32
  88843 	var v uintptr
  88844 
  88845 	var regAddrA int32
  88846 	var regAddrB int32
  88847 	var addrSelectA int32
  88848 	var addrSelectB int32
  88849 	var regOutA int32
  88850 	var regOutB int32
  88851 	var addrOutA int32
  88852 	var addrOutB int32 = 0
  88853 	var addrEofA int32
  88854 	var addrEofA_noB int32
  88855 	var addrEofB int32
  88856 	var addrAltB int32
  88857 	var addrAeqB int32
  88858 	var addrAgtB int32
  88859 	var regLimitA int32
  88860 	var regLimitB int32
  88861 	var regPrev int32
  88862 	var savedLimit int32
  88863 	var savedOffset int32
  88864 	var labelCmpr int32
  88865 	var labelEnd int32
  88866 	var addr1 int32
  88867 	var op int32
  88868 	var pKeyDup uintptr = uintptr(0)
  88869 	var pKeyMerge uintptr
  88870 	var db uintptr
  88871 	var pOrderBy uintptr
  88872 	var nOrderBy int32
  88873 	var aPermute uintptr
  88874 
  88875 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  88876 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  88877 
  88878 	labelEnd = Xsqlite3VdbeMakeLabel(tls, pParse)
  88879 	labelCmpr = Xsqlite3VdbeMakeLabel(tls, pParse)
  88880 
  88881 	op = int32((*Select)(unsafe.Pointer(p)).Fop)
  88882 
  88883 	pOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy
  88884 
  88885 	nOrderBy = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr
  88886 
  88887 	if op != TK_ALL {
  88888 		for i = 1; int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 && i <= (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr; i++ {
  88889 			var pItem uintptr
  88890 			j = 0
  88891 			pItem = pOrderBy + 8
  88892 		__1:
  88893 			if !(j < nOrderBy) {
  88894 				goto __3
  88895 			}
  88896 			{
  88897 				if int32(*(*U16)(unsafe.Pointer(pItem + 16))) == i {
  88898 					goto __3
  88899 				}
  88900 
  88901 			}
  88902 			goto __2
  88903 		__2:
  88904 			j++
  88905 			pItem += 20
  88906 			goto __1
  88907 			goto __3
  88908 		__3:
  88909 			;
  88910 			if j == nOrderBy {
  88911 				var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0))
  88912 				if pNew == uintptr(0) {
  88913 					return SQLITE_NOMEM
  88914 				}
  88915 				*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_IntValue)
  88916 				*(*int32)(unsafe.Pointer(pNew + 8)) = i
  88917 				(*Select)(unsafe.Pointer(p)).FpOrderBy = libc.AssignUintptr(&pOrderBy, Xsqlite3ExprListAppend(tls, pParse, pOrderBy, pNew))
  88918 				if pOrderBy != 0 {
  88919 					*(*U16)(unsafe.Pointer(pOrderBy + 8 + uintptr(libc.PostIncInt32(&nOrderBy, 1))*20 + 16)) = U16(i)
  88920 				}
  88921 			}
  88922 		}
  88923 	}
  88924 
  88925 	aPermute = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(U32(0)))*uint32(nOrderBy+1)))
  88926 	if aPermute != 0 {
  88927 		var pItem uintptr
  88928 		*(*U32)(unsafe.Pointer(aPermute)) = U32(nOrderBy)
  88929 		i = 1
  88930 		pItem = pOrderBy + 8
  88931 	__4:
  88932 		if !(i <= nOrderBy) {
  88933 			goto __6
  88934 		}
  88935 		{
  88936 			*(*U32)(unsafe.Pointer(aPermute + uintptr(i)*4)) = U32(int32(*(*U16)(unsafe.Pointer(pItem + 16))) - 1)
  88937 
  88938 		}
  88939 		goto __5
  88940 	__5:
  88941 		i++
  88942 		pItem += 20
  88943 		goto __4
  88944 		goto __6
  88945 	__6:
  88946 		;
  88947 		pKeyMerge = multiSelectOrderByKeyInfo(tls, pParse, p, 1)
  88948 	} else {
  88949 		pKeyMerge = uintptr(0)
  88950 	}
  88951 
  88952 	if op == TK_ALL {
  88953 		regPrev = 0
  88954 	} else {
  88955 		var nExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr
  88956 
  88957 		regPrev = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  88958 		*(*int32)(unsafe.Pointer(pParse + 44)) += nExpr + 1
  88959 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regPrev)
  88960 		pKeyDup = Xsqlite3KeyInfoAlloc(tls, db, nExpr, 1)
  88961 		if pKeyDup != 0 {
  88962 			for i = 0; i < nExpr; i++ {
  88963 				*(*uintptr)(unsafe.Pointer(pKeyDup + 20 + uintptr(i)*4)) = multiSelectCollSeq(tls, pParse, p, i)
  88964 				*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyDup)).FaSortFlags + uintptr(i))) = U8(0)
  88965 			}
  88966 		}
  88967 	}
  88968 
  88969 	nSelect = 1
  88970 	if (op == TK_ALL || op == TK_UNION) &&
  88971 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_BalancedMerge) == U32(0) {
  88972 		for pSplit = p; (*Select)(unsafe.Pointer(pSplit)).FpPrior != uintptr(0) && int32((*Select)(unsafe.Pointer(pSplit)).Fop) == op; pSplit = (*Select)(unsafe.Pointer(pSplit)).FpPrior {
  88973 			nSelect++
  88974 
  88975 		}
  88976 	}
  88977 	if nSelect <= 3 {
  88978 		pSplit = p
  88979 	} else {
  88980 		pSplit = p
  88981 		for i = 2; i < nSelect; i = i + 2 {
  88982 			pSplit = (*Select)(unsafe.Pointer(pSplit)).FpPrior
  88983 		}
  88984 	}
  88985 	pPrior = (*Select)(unsafe.Pointer(pSplit)).FpPrior
  88986 
  88987 	(*Select)(unsafe.Pointer(pSplit)).FpPrior = uintptr(0)
  88988 	(*Select)(unsafe.Pointer(pPrior)).FpNext = uintptr(0)
  88989 
  88990 	(*Select)(unsafe.Pointer(pPrior)).FpOrderBy = Xsqlite3ExprListDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pOrderBy, 0)
  88991 	Xsqlite3ResolveOrderGroupBy(tls, pParse, p, (*Select)(unsafe.Pointer(p)).FpOrderBy, ts+7223)
  88992 	Xsqlite3ResolveOrderGroupBy(tls, pParse, pPrior, (*Select)(unsafe.Pointer(pPrior)).FpOrderBy, ts+7223)
  88993 
  88994 	computeLimitRegisters(tls, pParse, p, labelEnd)
  88995 	if (*Select)(unsafe.Pointer(p)).FiLimit != 0 && op == TK_ALL {
  88996 		regLimitA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  88997 		regLimitB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  88998 		Xsqlite3VdbeAddOp2(tls, v, OP_Copy, func() int32 {
  88999 			if (*Select)(unsafe.Pointer(p)).FiOffset != 0 {
  89000 				return (*Select)(unsafe.Pointer(p)).FiOffset + 1
  89001 			}
  89002 			return (*Select)(unsafe.Pointer(p)).FiLimit
  89003 		}(),
  89004 			regLimitA)
  89005 		Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regLimitA, regLimitB)
  89006 	} else {
  89007 		regLimitA = libc.AssignInt32(&regLimitB, 0)
  89008 	}
  89009 	Xsqlite3ExprDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit)
  89010 	(*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0)
  89011 
  89012 	regAddrA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  89013 	regAddrB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  89014 	regOutA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  89015 	regOutB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  89016 	Xsqlite3SelectDestInit(tls, bp+8, SRT_Coroutine, regAddrA)
  89017 	Xsqlite3SelectDestInit(tls, bp+36, SRT_Coroutine, regAddrB)
  89018 
  89019 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19189, libc.VaList(bp, Xsqlite3SelectOpName(tls, int32((*Select)(unsafe.Pointer(p)).Fop))))
  89020 
  89021 	addrSelectA = Xsqlite3VdbeCurrentAddr(tls, v) + 1
  89022 	addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regAddrA, 0, addrSelectA)
  89023 
  89024 	(*Select)(unsafe.Pointer(pPrior)).FiLimit = regLimitA
  89025 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19200, 0)
  89026 	Xsqlite3Select(tls, pParse, pPrior, bp+8)
  89027 	Xsqlite3VdbeEndCoroutine(tls, v, regAddrA)
  89028 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  89029 
  89030 	addrSelectB = Xsqlite3VdbeCurrentAddr(tls, v) + 1
  89031 	addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regAddrB, 0, addrSelectB)
  89032 
  89033 	savedLimit = (*Select)(unsafe.Pointer(p)).FiLimit
  89034 	savedOffset = (*Select)(unsafe.Pointer(p)).FiOffset
  89035 	(*Select)(unsafe.Pointer(p)).FiLimit = regLimitB
  89036 	(*Select)(unsafe.Pointer(p)).FiOffset = 0
  89037 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19205, 0)
  89038 	Xsqlite3Select(tls, pParse, p, bp+36)
  89039 	(*Select)(unsafe.Pointer(p)).FiLimit = savedLimit
  89040 	(*Select)(unsafe.Pointer(p)).FiOffset = savedOffset
  89041 	Xsqlite3VdbeEndCoroutine(tls, v, regAddrB)
  89042 
  89043 	addrOutA = generateOutputSubroutine(tls, pParse,
  89044 		p, bp+8, pDest, regOutA,
  89045 		regPrev, pKeyDup, labelEnd)
  89046 
  89047 	if op == TK_ALL || op == TK_UNION {
  89048 		addrOutB = generateOutputSubroutine(tls, pParse,
  89049 			p, bp+36, pDest, regOutB,
  89050 			regPrev, pKeyDup, labelEnd)
  89051 	}
  89052 	Xsqlite3KeyInfoUnref(tls, pKeyDup)
  89053 
  89054 	if op == TK_EXCEPT || op == TK_INTERSECT {
  89055 		addrEofA_noB = libc.AssignInt32(&addrEofA, labelEnd)
  89056 	} else {
  89057 		addrEofA = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutB, addrOutB)
  89058 		addrEofA_noB = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, labelEnd)
  89059 
  89060 		Xsqlite3VdbeGoto(tls, v, addrEofA)
  89061 		(*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow)
  89062 	}
  89063 
  89064 	if op == TK_INTERSECT {
  89065 		addrEofB = addrEofA
  89066 		if int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32((*Select)(unsafe.Pointer(pPrior)).FnSelectRow) {
  89067 			(*Select)(unsafe.Pointer(p)).FnSelectRow = (*Select)(unsafe.Pointer(pPrior)).FnSelectRow
  89068 		}
  89069 	} else {
  89070 		addrEofB = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutA, addrOutA)
  89071 		Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, labelEnd)
  89072 		Xsqlite3VdbeGoto(tls, v, addrEofB)
  89073 	}
  89074 
  89075 	addrAltB = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutA, addrOutA)
  89076 	Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, addrEofA)
  89077 	Xsqlite3VdbeGoto(tls, v, labelCmpr)
  89078 
  89079 	if op == TK_ALL {
  89080 		addrAeqB = addrAltB
  89081 	} else if op == TK_INTERSECT {
  89082 		addrAeqB = addrAltB
  89083 		addrAltB++
  89084 	} else {
  89085 		addrAeqB = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, addrEofA)
  89086 		Xsqlite3VdbeGoto(tls, v, labelCmpr)
  89087 	}
  89088 
  89089 	addrAgtB = Xsqlite3VdbeCurrentAddr(tls, v)
  89090 	if op == TK_ALL || op == TK_UNION {
  89091 		Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutB, addrOutB)
  89092 	}
  89093 	Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, addrEofB)
  89094 	Xsqlite3VdbeGoto(tls, v, labelCmpr)
  89095 
  89096 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  89097 	Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, addrEofA_noB)
  89098 	Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, addrEofB)
  89099 
  89100 	Xsqlite3VdbeResolveLabel(tls, v, labelCmpr)
  89101 	Xsqlite3VdbeAddOp4(tls, v, OP_Permutation, 0, 0, 0, aPermute, -14)
  89102 	Xsqlite3VdbeAddOp4(tls, v, OP_Compare, (*SelectDest)(unsafe.Pointer(bp+8)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+36)).FiSdst, nOrderBy,
  89103 		pKeyMerge, -8)
  89104 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_PERMUTE))
  89105 	Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addrAltB, addrAeqB, addrAgtB)
  89106 
  89107 	Xsqlite3VdbeResolveLabel(tls, v, labelEnd)
  89108 
  89109 	if (*Select)(unsafe.Pointer(pSplit)).FpPrior != 0 {
  89110 		Xsqlite3ParserAddCleanup(tls, pParse,
  89111 			*(*uintptr)(unsafe.Pointer(&struct {
  89112 				f func(*libc.TLS, uintptr, uintptr)
  89113 			}{Xsqlite3SelectDelete})), (*Select)(unsafe.Pointer(pSplit)).FpPrior)
  89114 	}
  89115 	(*Select)(unsafe.Pointer(pSplit)).FpPrior = pPrior
  89116 	(*Select)(unsafe.Pointer(pPrior)).FpNext = pSplit
  89117 	Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(pPrior)).FpOrderBy)
  89118 	(*Select)(unsafe.Pointer(pPrior)).FpOrderBy = uintptr(0)
  89119 
  89120 	Xsqlite3VdbeExplainPop(tls, pParse)
  89121 	return libc.Bool32((*Parse)(unsafe.Pointer(pParse)).FnErr != 0)
  89122 }
  89123 
  89124 // An instance of the SubstContext object describes an substitution edit
  89125 // to be performed on a parse tree.
  89126 //
  89127 // All references to columns in table iTable are to be replaced by corresponding
  89128 // expressions in pEList.
  89129 //
  89130 // ## About "isOuterJoin":
  89131 //
  89132 // The isOuterJoin column indicates that the replacement will occur into a
  89133 // position in the parent that NULL-able due to an OUTER JOIN.  Either the
  89134 // target slot in the parent is the right operand of a LEFT JOIN, or one of
  89135 // the left operands of a RIGHT JOIN.  In either case, we need to potentially
  89136 // bypass the substituted expression with OP_IfNullRow.
  89137 //
  89138 // Suppose the original expression is an integer constant. Even though the table
  89139 // has the nullRow flag set, because the expression is an integer constant,
  89140 // it will not be NULLed out.  So instead, we insert an OP_IfNullRow opcode
  89141 // that checks to see if the nullRow flag is set on the table.  If the nullRow
  89142 // flag is set, then the value in the register is set to NULL and the original
  89143 // expression is bypassed.  If the nullRow flag is not set, then the original
  89144 // expression runs to populate the register.
  89145 //
  89146 // Example where this is needed:
  89147 //
  89148 //	CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
  89149 //	CREATE TABLE t2(x INT UNIQUE);
  89150 //
  89151 //	SELECT a,b,m,x FROM t1 LEFT JOIN (SELECT 59 AS m,x FROM t2) ON b=x;
  89152 //
  89153 // When the subquery on the right side of the LEFT JOIN is flattened, we
  89154 // have to add OP_IfNullRow in front of the OP_Integer that implements the
  89155 // "m" value of the subquery so that a NULL will be loaded instead of 59
  89156 // when processing a non-matched row of the left.
  89157 type SubstContext1 = struct {
  89158 	FpParse      uintptr
  89159 	FiTable      int32
  89160 	FiNewTable   int32
  89161 	FisOuterJoin int32
  89162 	FpEList      uintptr
  89163 	FpCList      uintptr
  89164 }
  89165 
  89166 // An instance of the SubstContext object describes an substitution edit
  89167 // to be performed on a parse tree.
  89168 //
  89169 // All references to columns in table iTable are to be replaced by corresponding
  89170 // expressions in pEList.
  89171 //
  89172 // ## About "isOuterJoin":
  89173 //
  89174 // The isOuterJoin column indicates that the replacement will occur into a
  89175 // position in the parent that NULL-able due to an OUTER JOIN.  Either the
  89176 // target slot in the parent is the right operand of a LEFT JOIN, or one of
  89177 // the left operands of a RIGHT JOIN.  In either case, we need to potentially
  89178 // bypass the substituted expression with OP_IfNullRow.
  89179 //
  89180 // Suppose the original expression is an integer constant. Even though the table
  89181 // has the nullRow flag set, because the expression is an integer constant,
  89182 // it will not be NULLed out.  So instead, we insert an OP_IfNullRow opcode
  89183 // that checks to see if the nullRow flag is set on the table.  If the nullRow
  89184 // flag is set, then the value in the register is set to NULL and the original
  89185 // expression is bypassed.  If the nullRow flag is not set, then the original
  89186 // expression runs to populate the register.
  89187 //
  89188 // Example where this is needed:
  89189 //
  89190 //	CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
  89191 //	CREATE TABLE t2(x INT UNIQUE);
  89192 //
  89193 //	SELECT a,b,m,x FROM t1 LEFT JOIN (SELECT 59 AS m,x FROM t2) ON b=x;
  89194 //
  89195 // When the subquery on the right side of the LEFT JOIN is flattened, we
  89196 // have to add OP_IfNullRow in front of the OP_Integer that implements the
  89197 // "m" value of the subquery so that a NULL will be loaded instead of 59
  89198 // when processing a non-matched row of the left.
  89199 type SubstContext = SubstContext1
  89200 
  89201 func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr {
  89202 	bp := tls.Alloc(52)
  89203 	defer tls.Free(52)
  89204 
  89205 	if pExpr == uintptr(0) {
  89206 		return uintptr(0)
  89207 	}
  89208 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0) &&
  89209 		*(*int32)(unsafe.Pointer(pExpr + 36)) == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable {
  89210 		*(*int32)(unsafe.Pointer(pExpr + 36)) = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable
  89211 	}
  89212 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN &&
  89213 		(*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable &&
  89214 		!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_FixedCol) != U32(0)) {
  89215 		{
  89216 			var pNew uintptr
  89217 			var iColumn int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
  89218 			var pCopy uintptr = (*ExprList_item)(unsafe.Pointer((*SubstContext)(unsafe.Pointer(pSubst)).FpEList + 8 + uintptr(iColumn)*20)).FpExpr
  89219 
  89220 			if Xsqlite3ExprIsVector(tls, pCopy) != 0 {
  89221 				Xsqlite3VectorErrorMsg(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pCopy)
  89222 			} else {
  89223 				var db uintptr = (*Parse)(unsafe.Pointer((*SubstContext)(unsafe.Pointer(pSubst)).FpParse)).Fdb
  89224 				if (*SubstContext)(unsafe.Pointer(pSubst)).FisOuterJoin != 0 &&
  89225 					(int32((*Expr)(unsafe.Pointer(pCopy)).Fop) != TK_COLUMN || (*Expr)(unsafe.Pointer(pCopy)).FiTable != (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable) {
  89226 					libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Expr{})))
  89227 					(*Expr)(unsafe.Pointer(bp)).Fop = U8(TK_IF_NULL_ROW)
  89228 					(*Expr)(unsafe.Pointer(bp)).FpLeft = pCopy
  89229 					(*Expr)(unsafe.Pointer(bp)).FiTable = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable
  89230 					(*Expr)(unsafe.Pointer(bp)).FiColumn = int16(-99)
  89231 					(*Expr)(unsafe.Pointer(bp)).Fflags = U32(EP_IfNullRow)
  89232 					pCopy = bp
  89233 				}
  89234 
  89235 				pNew = Xsqlite3ExprDup(tls, db, pCopy, 0)
  89236 				if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  89237 					Xsqlite3ExprDelete(tls, db, pNew)
  89238 					return pExpr
  89239 				}
  89240 				if (*SubstContext)(unsafe.Pointer(pSubst)).FisOuterJoin != 0 {
  89241 					*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(EP_CanBeNull)
  89242 				}
  89243 				if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0) {
  89244 					Xsqlite3SetJoinExpr(tls, pNew, *(*int32)(unsafe.Pointer(pExpr + 36)),
  89245 						(*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_InnerON))
  89246 				}
  89247 				Xsqlite3ExprDelete(tls, db, pExpr)
  89248 				pExpr = pNew
  89249 				if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRUEFALSE {
  89250 					*(*int32)(unsafe.Pointer(pExpr + 8)) = Xsqlite3ExprTruthValue(tls, pExpr)
  89251 					(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_INTEGER)
  89252 					*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_IntValue)
  89253 				}
  89254 
  89255 				{
  89256 					var pNat uintptr = Xsqlite3ExprCollSeq(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pExpr)
  89257 					var pColl uintptr = Xsqlite3ExprCollSeq(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse,
  89258 						(*ExprList_item)(unsafe.Pointer((*SubstContext)(unsafe.Pointer(pSubst)).FpCList+8+uintptr(iColumn)*20)).FpExpr)
  89259 					if pNat != pColl || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLLATE {
  89260 						pExpr = Xsqlite3ExprAddCollateString(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pExpr,
  89261 							func() uintptr {
  89262 								if pColl != 0 {
  89263 									return (*CollSeq)(unsafe.Pointer(pColl)).FzName
  89264 								}
  89265 								return ts + 1099
  89266 							}())
  89267 					}
  89268 
  89269 				}
  89270 				*(*U32)(unsafe.Pointer(pExpr + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Collate))
  89271 			}
  89272 
  89273 		}
  89274 	} else {
  89275 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IF_NULL_ROW && (*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable {
  89276 			(*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable
  89277 		}
  89278 		(*Expr)(unsafe.Pointer(pExpr)).FpLeft = substExpr(tls, pSubst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  89279 		(*Expr)(unsafe.Pointer(pExpr)).FpRight = substExpr(tls, pSubst, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  89280 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
  89281 			substSelect(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 20)), 1)
  89282 		} else {
  89283 			substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 20)))
  89284 		}
  89285 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  89286 			var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  89287 			(*Window)(unsafe.Pointer(pWin)).FpFilter = substExpr(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpFilter)
  89288 			substExprList(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpPartition)
  89289 			substExprList(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpOrderBy)
  89290 		}
  89291 	}
  89292 	return pExpr
  89293 }
  89294 
  89295 func substExprList(tls *libc.TLS, pSubst uintptr, pList uintptr) {
  89296 	var i int32
  89297 	if pList == uintptr(0) {
  89298 		return
  89299 	}
  89300 	for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
  89301 		(*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*20)).FpExpr = substExpr(tls, pSubst, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr)
  89302 	}
  89303 }
  89304 
  89305 func substSelect(tls *libc.TLS, pSubst uintptr, p uintptr, doPrior int32) {
  89306 	var pSrc uintptr
  89307 	var pItem uintptr
  89308 	var i int32
  89309 	if !(p != 0) {
  89310 		return
  89311 	}
  89312 	for __ccgo := true; __ccgo; __ccgo = doPrior != 0 && libc.AssignUintptr(&p, (*Select)(unsafe.Pointer(p)).FpPrior) != uintptr(0) {
  89313 		substExprList(tls, pSubst, (*Select)(unsafe.Pointer(p)).FpEList)
  89314 		substExprList(tls, pSubst, (*Select)(unsafe.Pointer(p)).FpGroupBy)
  89315 		substExprList(tls, pSubst, (*Select)(unsafe.Pointer(p)).FpOrderBy)
  89316 		(*Select)(unsafe.Pointer(p)).FpHaving = substExpr(tls, pSubst, (*Select)(unsafe.Pointer(p)).FpHaving)
  89317 		(*Select)(unsafe.Pointer(p)).FpWhere = substExpr(tls, pSubst, (*Select)(unsafe.Pointer(p)).FpWhere)
  89318 		pSrc = (*Select)(unsafe.Pointer(p)).FpSrc
  89319 
  89320 		i = (*SrcList)(unsafe.Pointer(pSrc)).FnSrc
  89321 		pItem = pSrc + 8
  89322 	__1:
  89323 		if !(i > 0) {
  89324 			goto __3
  89325 		}
  89326 		{
  89327 			substSelect(tls, pSubst, (*SrcItem)(unsafe.Pointer(pItem)).FpSelect, 1)
  89328 			if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x4>>2)) != 0 {
  89329 				substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pItem + 64)))
  89330 			}
  89331 
  89332 		}
  89333 		goto __2
  89334 	__2:
  89335 		i--
  89336 		pItem += 72
  89337 		goto __1
  89338 		goto __3
  89339 	__3:
  89340 	}
  89341 }
  89342 
  89343 func recomputeColumnsUsedExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  89344 	var pItem uintptr
  89345 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN {
  89346 		return WRC_Continue
  89347 	}
  89348 	pItem = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  89349 	if (*SrcItem)(unsafe.Pointer(pItem)).FiCursor != (*Expr)(unsafe.Pointer(pExpr)).FiTable {
  89350 		return WRC_Continue
  89351 	}
  89352 	if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 {
  89353 		return WRC_Continue
  89354 	}
  89355 	*(*Bitmask)(unsafe.Pointer(pItem + 56)) |= Xsqlite3ExprColUsed(tls, pExpr)
  89356 	return WRC_Continue
  89357 }
  89358 
  89359 func recomputeColumnsUsed(tls *libc.TLS, pSelect uintptr, pSrcItem uintptr) {
  89360 	bp := tls.Alloc(28)
  89361 	defer tls.Free(28)
  89362 
  89363 	if (*SrcItem)(unsafe.Pointer(pSrcItem)).FpTab == uintptr(0) {
  89364 		return
  89365 	}
  89366 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  89367 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  89368 		f func(*libc.TLS, uintptr, uintptr) int32
  89369 	}{recomputeColumnsUsedExpr}))
  89370 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  89371 		f func(*libc.TLS, uintptr, uintptr) int32
  89372 	}{Xsqlite3SelectWalkNoop}))
  89373 	*(*uintptr)(unsafe.Pointer(bp + 24)) = pSrcItem
  89374 	(*SrcItem)(unsafe.Pointer(pSrcItem)).FcolUsed = uint64(0)
  89375 	Xsqlite3WalkSelect(tls, bp, pSelect)
  89376 }
  89377 
  89378 func srclistRenumberCursors(tls *libc.TLS, pParse uintptr, aCsrMap uintptr, pSrc uintptr, iExcept int32) {
  89379 	var i int32
  89380 	var pItem uintptr
  89381 	i = 0
  89382 	pItem = pSrc + 8
  89383 __1:
  89384 	if !(i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc) {
  89385 		goto __3
  89386 	}
  89387 	{
  89388 		if i != iExcept {
  89389 			var p uintptr
  89390 
  89391 			if !(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x40>>6) != 0) || *(*int32)(unsafe.Pointer(aCsrMap + uintptr((*SrcItem)(unsafe.Pointer(pItem)).FiCursor+1)*4)) == 0 {
  89392 				*(*int32)(unsafe.Pointer(aCsrMap + uintptr((*SrcItem)(unsafe.Pointer(pItem)).FiCursor+1)*4)) = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  89393 			}
  89394 			(*SrcItem)(unsafe.Pointer(pItem)).FiCursor = *(*int32)(unsafe.Pointer(aCsrMap + uintptr((*SrcItem)(unsafe.Pointer(pItem)).FiCursor+1)*4))
  89395 			for p = (*SrcItem)(unsafe.Pointer(pItem)).FpSelect; p != 0; p = (*Select)(unsafe.Pointer(p)).FpPrior {
  89396 				srclistRenumberCursors(tls, pParse, aCsrMap, (*Select)(unsafe.Pointer(p)).FpSrc, -1)
  89397 			}
  89398 		}
  89399 
  89400 	}
  89401 	goto __2
  89402 __2:
  89403 	i++
  89404 	pItem += 72
  89405 	goto __1
  89406 	goto __3
  89407 __3:
  89408 }
  89409 
  89410 func renumberCursorDoMapping(tls *libc.TLS, pWalker uintptr, piCursor uintptr) {
  89411 	var aCsrMap uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  89412 	var iCsr int32 = *(*int32)(unsafe.Pointer(piCursor))
  89413 	if iCsr < *(*int32)(unsafe.Pointer(aCsrMap)) && *(*int32)(unsafe.Pointer(aCsrMap + uintptr(iCsr+1)*4)) > 0 {
  89414 		*(*int32)(unsafe.Pointer(piCursor)) = *(*int32)(unsafe.Pointer(aCsrMap + uintptr(iCsr+1)*4))
  89415 	}
  89416 }
  89417 
  89418 func renumberCursorsCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  89419 	var op int32 = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
  89420 	if op == TK_COLUMN || op == TK_IF_NULL_ROW {
  89421 		renumberCursorDoMapping(tls, pWalker, pExpr+28)
  89422 	}
  89423 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) {
  89424 		renumberCursorDoMapping(tls, pWalker, pExpr+36)
  89425 	}
  89426 	return WRC_Continue
  89427 }
  89428 
  89429 func renumberCursors(tls *libc.TLS, pParse uintptr, p uintptr, iExcept int32, aCsrMap uintptr) {
  89430 	bp := tls.Alloc(28)
  89431 	defer tls.Free(28)
  89432 
  89433 	srclistRenumberCursors(tls, pParse, aCsrMap, (*Select)(unsafe.Pointer(p)).FpSrc, iExcept)
  89434 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  89435 	*(*uintptr)(unsafe.Pointer(bp + 24)) = aCsrMap
  89436 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  89437 		f func(*libc.TLS, uintptr, uintptr) int32
  89438 	}{renumberCursorsCb}))
  89439 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  89440 		f func(*libc.TLS, uintptr, uintptr) int32
  89441 	}{Xsqlite3SelectWalkNoop}))
  89442 	Xsqlite3WalkSelect(tls, bp, p)
  89443 }
  89444 
  89445 func findLeftmostExprlist(tls *libc.TLS, pSel uintptr) uintptr {
  89446 	for (*Select)(unsafe.Pointer(pSel)).FpPrior != 0 {
  89447 		pSel = (*Select)(unsafe.Pointer(pSel)).FpPrior
  89448 	}
  89449 	return (*Select)(unsafe.Pointer(pSel)).FpEList
  89450 }
  89451 
  89452 func compoundHasDifferentAffinities(tls *libc.TLS, p uintptr) int32 {
  89453 	var ii int32
  89454 	var pList uintptr
  89455 
  89456 	pList = (*Select)(unsafe.Pointer(p)).FpEList
  89457 	for ii = 0; ii < (*ExprList)(unsafe.Pointer(pList)).FnExpr; ii++ {
  89458 		var aff uint8
  89459 		var pSub1 uintptr
  89460 
  89461 		aff = Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ii)*20)).FpExpr)
  89462 		for pSub1 = (*Select)(unsafe.Pointer(p)).FpPrior; pSub1 != 0; pSub1 = (*Select)(unsafe.Pointer(pSub1)).FpPrior {
  89463 			if int32(Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub1)).FpEList+8+uintptr(ii)*20)).FpExpr)) != int32(aff) {
  89464 				return 1
  89465 			}
  89466 		}
  89467 	}
  89468 	return 0
  89469 }
  89470 
  89471 func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAgg int32) int32 {
  89472 	bp := tls.Alloc(52)
  89473 	defer tls.Free(52)
  89474 
  89475 	var zSavedAuthContext uintptr = (*Parse)(unsafe.Pointer(pParse)).FzAuthContext
  89476 	var pParent uintptr
  89477 	var pSub uintptr
  89478 	var pSub1 uintptr
  89479 	var pSrc uintptr
  89480 	var pSubSrc uintptr
  89481 	var iParent int32
  89482 	var iNewParent int32 = -1
  89483 	var isOuterJoin int32 = 0
  89484 	var i int32
  89485 	var pWhere uintptr
  89486 	var pSubitem uintptr
  89487 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  89488 
  89489 	var aCsrMap uintptr = uintptr(0)
  89490 
  89491 	if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_QueryFlattener) != U32(0) {
  89492 		return 0
  89493 	}
  89494 	pSrc = (*Select)(unsafe.Pointer(p)).FpSrc
  89495 
  89496 	pSubitem = pSrc + 8 + uintptr(iFrom)*72
  89497 	iParent = (*SrcItem)(unsafe.Pointer(pSubitem)).FiCursor
  89498 	pSub = (*SrcItem)(unsafe.Pointer(pSubitem)).FpSelect
  89499 
  89500 	if (*Select)(unsafe.Pointer(p)).FpWin != 0 || (*Select)(unsafe.Pointer(pSub)).FpWin != 0 {
  89501 		return 0
  89502 	}
  89503 
  89504 	pSubSrc = (*Select)(unsafe.Pointer(pSub)).FpSrc
  89505 
  89506 	if (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 && (*Select)(unsafe.Pointer(p)).FpLimit != 0 {
  89507 		return 0
  89508 	}
  89509 	if (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 && (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub)).FpLimit)).FpRight != 0 {
  89510 		return 0
  89511 	}
  89512 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Compound) != U32(0) && (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 {
  89513 		return 0
  89514 	}
  89515 	if (*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc == 0 {
  89516 		return 0
  89517 	}
  89518 	if (*Select)(unsafe.Pointer(pSub)).FselFlags&U32(SF_Distinct) != 0 {
  89519 		return 0
  89520 	}
  89521 	if (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 && ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1 || isAgg != 0) {
  89522 		return 0
  89523 	}
  89524 	if (*Select)(unsafe.Pointer(p)).FpOrderBy != 0 && (*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0 {
  89525 		return 0
  89526 	}
  89527 	if isAgg != 0 && (*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0 {
  89528 		return 0
  89529 	}
  89530 	if (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 && (*Select)(unsafe.Pointer(p)).FpWhere != 0 {
  89531 		return 0
  89532 	}
  89533 	if (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 && (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct) != U32(0) {
  89534 		return 0
  89535 	}
  89536 	if (*Select)(unsafe.Pointer(pSub)).FselFlags&U32(SF_Recursive) != 0 {
  89537 		return 0
  89538 	}
  89539 
  89540 	if int32((*SrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype)&(JT_OUTER|JT_LTORJ) != 0 {
  89541 		if (*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc > 1 ||
  89542 			int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSubSrc+8)).FpTab)).FeTabType) == TABTYP_VTAB ||
  89543 			(*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct) != U32(0) ||
  89544 			int32((*SrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype)&JT_RIGHT != 0 {
  89545 			return 0
  89546 		}
  89547 		isOuterJoin = 1
  89548 	}
  89549 
  89550 	if iFrom > 0 && int32((*SrcItem)(unsafe.Pointer(pSubSrc+8)).Ffg.Fjointype)&JT_LTORJ != 0 {
  89551 		return 0
  89552 	}
  89553 	if uint32(int32(*(*uint16)(unsafe.Pointer(pSubitem + 36 + 4))&0x100>>8)) != 0 && int32((*CteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSubitem + 68)))).FeM10d) == M10d_Yes {
  89554 		return 0
  89555 	}
  89556 
  89557 	if (*Select)(unsafe.Pointer(pSub)).FpPrior != 0 {
  89558 		var ii int32
  89559 		if (*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0 {
  89560 			return 0
  89561 		}
  89562 		if isAgg != 0 || (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct) != U32(0) || isOuterJoin > 0 {
  89563 			return 0
  89564 		}
  89565 		for pSub1 = pSub; pSub1 != 0; pSub1 = (*Select)(unsafe.Pointer(pSub1)).FpPrior {
  89566 			if (*Select)(unsafe.Pointer(pSub1)).FselFlags&U32(SF_Distinct|SF_Aggregate) != U32(0) ||
  89567 				(*Select)(unsafe.Pointer(pSub1)).FpPrior != 0 && int32((*Select)(unsafe.Pointer(pSub1)).Fop) != TK_ALL ||
  89568 				(*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub1)).FpSrc)).FnSrc < 1 ||
  89569 				(*Select)(unsafe.Pointer(pSub1)).FpWin != 0 {
  89570 				return 0
  89571 			}
  89572 			if iFrom > 0 && int32((*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub1)).FpSrc+8)).Ffg.Fjointype)&JT_LTORJ != 0 {
  89573 				return 0
  89574 			}
  89575 
  89576 		}
  89577 
  89578 		if (*Select)(unsafe.Pointer(p)).FpOrderBy != 0 {
  89579 			for ii = 0; ii < (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy)).FnExpr; ii++ {
  89580 				if int32(*(*U16)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy + 8 + uintptr(ii)*20 + 16))) == 0 {
  89581 					return 0
  89582 				}
  89583 			}
  89584 		}
  89585 
  89586 		if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Recursive) != 0 {
  89587 			return 0
  89588 		}
  89589 
  89590 		if compoundHasDifferentAffinities(tls, pSub) != 0 {
  89591 			return 0
  89592 		}
  89593 
  89594 		if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1 {
  89595 			if (*Parse)(unsafe.Pointer(pParse)).FnSelect > 500 {
  89596 				return 0
  89597 			}
  89598 			if (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_FlttnUnionAll) != U32(0) {
  89599 				return 0
  89600 			}
  89601 			aCsrMap = Xsqlite3DbMallocZero(tls, db, uint64((I64((*Parse)(unsafe.Pointer(pParse)).FnTab)+int64(1))*I64(unsafe.Sizeof(int32(0)))))
  89602 			if aCsrMap != 0 {
  89603 				*(*int32)(unsafe.Pointer(aCsrMap)) = (*Parse)(unsafe.Pointer(pParse)).FnTab
  89604 			}
  89605 		}
  89606 	}
  89607 
  89608 	(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = (*SrcItem)(unsafe.Pointer(pSubitem)).FzName
  89609 	Xsqlite3AuthCheck(tls, pParse, SQLITE_SELECT, uintptr(0), uintptr(0), uintptr(0))
  89610 
  89611 	(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext
  89612 
  89613 	pSub1 = (*SrcItem)(unsafe.Pointer(pSubitem)).FpSelect
  89614 	Xsqlite3DbFree(tls, db, (*SrcItem)(unsafe.Pointer(pSubitem)).FzDatabase)
  89615 	Xsqlite3DbFree(tls, db, (*SrcItem)(unsafe.Pointer(pSubitem)).FzName)
  89616 	Xsqlite3DbFree(tls, db, (*SrcItem)(unsafe.Pointer(pSubitem)).FzAlias)
  89617 	(*SrcItem)(unsafe.Pointer(pSubitem)).FzDatabase = uintptr(0)
  89618 	(*SrcItem)(unsafe.Pointer(pSubitem)).FzName = uintptr(0)
  89619 	(*SrcItem)(unsafe.Pointer(pSubitem)).FzAlias = uintptr(0)
  89620 	(*SrcItem)(unsafe.Pointer(pSubitem)).FpSelect = uintptr(0)
  89621 
  89622 	for pSub = (*Select)(unsafe.Pointer(pSub)).FpPrior; pSub != 0; pSub = (*Select)(unsafe.Pointer(pSub)).FpPrior {
  89623 		var pNew uintptr
  89624 		var pOrderBy uintptr = (*Select)(unsafe.Pointer(p)).FpOrderBy
  89625 		var pLimit uintptr = (*Select)(unsafe.Pointer(p)).FpLimit
  89626 		var pPrior uintptr = (*Select)(unsafe.Pointer(p)).FpPrior
  89627 		var pItemTab uintptr = (*SrcItem)(unsafe.Pointer(pSubitem)).FpTab
  89628 		(*SrcItem)(unsafe.Pointer(pSubitem)).FpTab = uintptr(0)
  89629 		(*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0)
  89630 		(*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0)
  89631 		(*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0)
  89632 		pNew = Xsqlite3SelectDup(tls, db, p, 0)
  89633 		(*Select)(unsafe.Pointer(p)).FpLimit = pLimit
  89634 		(*Select)(unsafe.Pointer(p)).FpOrderBy = pOrderBy
  89635 		(*Select)(unsafe.Pointer(p)).Fop = U8(TK_ALL)
  89636 		(*SrcItem)(unsafe.Pointer(pSubitem)).FpTab = pItemTab
  89637 		if pNew == uintptr(0) {
  89638 			(*Select)(unsafe.Pointer(p)).FpPrior = pPrior
  89639 		} else {
  89640 			(*Select)(unsafe.Pointer(pNew)).FselId = U32(libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnSelect, 1))
  89641 			if aCsrMap != 0 && int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  89642 				renumberCursors(tls, pParse, pNew, iFrom, aCsrMap)
  89643 			}
  89644 			(*Select)(unsafe.Pointer(pNew)).FpPrior = pPrior
  89645 			if pPrior != 0 {
  89646 				(*Select)(unsafe.Pointer(pPrior)).FpNext = pNew
  89647 			}
  89648 			(*Select)(unsafe.Pointer(pNew)).FpNext = p
  89649 			(*Select)(unsafe.Pointer(p)).FpPrior = pNew
  89650 
  89651 		}
  89652 
  89653 	}
  89654 	Xsqlite3DbFree(tls, db, aCsrMap)
  89655 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  89656 		(*SrcItem)(unsafe.Pointer(pSubitem)).FpSelect = pSub1
  89657 		return 1
  89658 	}
  89659 
  89660 	if (*SrcItem)(unsafe.Pointer(pSubitem)).FpTab != uintptr(0) {
  89661 		var pTabToDel uintptr = (*SrcItem)(unsafe.Pointer(pSubitem)).FpTab
  89662 		if (*Table)(unsafe.Pointer(pTabToDel)).FnTabRef == U32(1) {
  89663 			var pToplevel uintptr = func() uintptr {
  89664 				if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  89665 					return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  89666 				}
  89667 				return pParse
  89668 			}()
  89669 			Xsqlite3ParserAddCleanup(tls, pToplevel,
  89670 				*(*uintptr)(unsafe.Pointer(&struct {
  89671 					f func(*libc.TLS, uintptr, uintptr)
  89672 				}{Xsqlite3DeleteTable})),
  89673 				pTabToDel)
  89674 
  89675 		} else {
  89676 			(*Table)(unsafe.Pointer(pTabToDel)).FnTabRef--
  89677 		}
  89678 		(*SrcItem)(unsafe.Pointer(pSubitem)).FpTab = uintptr(0)
  89679 	}
  89680 
  89681 	pSub = pSub1
  89682 	pParent = p
  89683 __1:
  89684 	if !(pParent != 0) {
  89685 		goto __3
  89686 	}
  89687 	{
  89688 		var nSubSrc int32
  89689 		var jointype U8 = U8(0)
  89690 		var ltorj U8 = U8(int32((*SrcItem)(unsafe.Pointer(pSrc+8+uintptr(iFrom)*72)).Ffg.Fjointype) & JT_LTORJ)
  89691 
  89692 		pSubSrc = (*Select)(unsafe.Pointer(pSub)).FpSrc
  89693 		nSubSrc = (*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc
  89694 		pSrc = (*Select)(unsafe.Pointer(pParent)).FpSrc
  89695 
  89696 		if pParent == p {
  89697 			jointype = (*SrcItem)(unsafe.Pointer(pSubitem)).Ffg.Fjointype
  89698 		}
  89699 
  89700 		if nSubSrc > 1 {
  89701 			pSrc = Xsqlite3SrcListEnlarge(tls, pParse, pSrc, nSubSrc-1, iFrom+1)
  89702 			if pSrc == uintptr(0) {
  89703 				goto __3
  89704 			}
  89705 			(*Select)(unsafe.Pointer(pParent)).FpSrc = pSrc
  89706 		}
  89707 
  89708 		for i = 0; i < nSubSrc; i++ {
  89709 			var pItem uintptr = pSrc + 8 + uintptr(i+iFrom)*72
  89710 			if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x400>>10)) != 0 {
  89711 				Xsqlite3IdListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pItem + 48)))
  89712 			}
  89713 
  89714 			*(*SrcItem)(unsafe.Pointer(pItem)) = *(*SrcItem)(unsafe.Pointer(pSubSrc + 8 + uintptr(i)*72))
  89715 			*(*U8)(unsafe.Pointer(pItem + 36)) |= U8(int32(ltorj))
  89716 			iNewParent = (*SrcItem)(unsafe.Pointer(pSubSrc + 8 + uintptr(i)*72)).FiCursor
  89717 			libc.Xmemset(tls, pSubSrc+8+uintptr(i)*72, 0, uint32(unsafe.Sizeof(SrcItem{})))
  89718 		}
  89719 		*(*U8)(unsafe.Pointer(pSrc + 8 + uintptr(iFrom)*72 + 36)) &= U8(JT_LTORJ)
  89720 		*(*U8)(unsafe.Pointer(pSrc + 8 + uintptr(iFrom)*72 + 36)) |= U8(int32(jointype) | int32(ltorj))
  89721 
  89722 		if (*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0 && (*Select)(unsafe.Pointer(pParent)).FselFlags&U32(SF_NoopOrderBy) == U32(0) {
  89723 			var pOrderBy uintptr = (*Select)(unsafe.Pointer(pSub)).FpOrderBy
  89724 			for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ {
  89725 				*(*U16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20 + 16)) = U16(0)
  89726 			}
  89727 
  89728 			(*Select)(unsafe.Pointer(pParent)).FpOrderBy = pOrderBy
  89729 			(*Select)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0)
  89730 		}
  89731 		pWhere = (*Select)(unsafe.Pointer(pSub)).FpWhere
  89732 		(*Select)(unsafe.Pointer(pSub)).FpWhere = uintptr(0)
  89733 		if isOuterJoin > 0 {
  89734 			Xsqlite3SetJoinExpr(tls, pWhere, iNewParent, uint32(EP_OuterON))
  89735 		}
  89736 		if pWhere != 0 {
  89737 			if (*Select)(unsafe.Pointer(pParent)).FpWhere != 0 {
  89738 				(*Select)(unsafe.Pointer(pParent)).FpWhere = Xsqlite3PExpr(tls, pParse, TK_AND, pWhere, (*Select)(unsafe.Pointer(pParent)).FpWhere)
  89739 			} else {
  89740 				(*Select)(unsafe.Pointer(pParent)).FpWhere = pWhere
  89741 			}
  89742 		}
  89743 		if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  89744 			(*SubstContext)(unsafe.Pointer(bp)).FpParse = pParse
  89745 			(*SubstContext)(unsafe.Pointer(bp)).FiTable = iParent
  89746 			(*SubstContext)(unsafe.Pointer(bp)).FiNewTable = iNewParent
  89747 			(*SubstContext)(unsafe.Pointer(bp)).FisOuterJoin = isOuterJoin
  89748 			(*SubstContext)(unsafe.Pointer(bp)).FpEList = (*Select)(unsafe.Pointer(pSub)).FpEList
  89749 			(*SubstContext)(unsafe.Pointer(bp)).FpCList = findLeftmostExprlist(tls, pSub)
  89750 			substSelect(tls, bp, pParent, 0)
  89751 		}
  89752 
  89753 		*(*U32)(unsafe.Pointer(pParent + 4)) |= (*Select)(unsafe.Pointer(pSub)).FselFlags & U32(SF_Compound)
  89754 
  89755 		if (*Select)(unsafe.Pointer(pSub)).FpLimit != 0 {
  89756 			(*Select)(unsafe.Pointer(pParent)).FpLimit = (*Select)(unsafe.Pointer(pSub)).FpLimit
  89757 			(*Select)(unsafe.Pointer(pSub)).FpLimit = uintptr(0)
  89758 		}
  89759 
  89760 		for i = 0; i < nSubSrc; i++ {
  89761 			recomputeColumnsUsed(tls, pParent, pSrc+8+uintptr(i+iFrom)*72)
  89762 		}
  89763 
  89764 	}
  89765 	goto __2
  89766 __2:
  89767 	pParent = (*Select)(unsafe.Pointer(pParent)).FpPrior
  89768 	pSub = (*Select)(unsafe.Pointer(pSub)).FpPrior
  89769 	goto __1
  89770 	goto __3
  89771 __3:
  89772 	;
  89773 	Xsqlite3AggInfoPersistWalkerInit(tls, bp+24, pParse)
  89774 	Xsqlite3WalkSelect(tls, bp+24, pSub1)
  89775 	Xsqlite3SelectDelete(tls, db, pSub1)
  89776 
  89777 	return 1
  89778 }
  89779 
  89780 // A structure to keep track of all of the column values that are fixed to
  89781 // a known value due to WHERE clause constraints of the form COLUMN=VALUE.
  89782 type WhereConst = WhereConst1
  89783 
  89784 func constInsert(tls *libc.TLS, pConst uintptr, pColumn uintptr, pValue uintptr, pExpr uintptr) {
  89785 	var i int32
  89786 
  89787 	if (*Expr)(unsafe.Pointer(pColumn)).Fflags&U32(EP_FixedCol) != U32(0) {
  89788 		return
  89789 	}
  89790 	if int32(Xsqlite3ExprAffinity(tls, pValue)) != 0 {
  89791 		return
  89792 	}
  89793 	if !(Xsqlite3IsBinary(tls, Xsqlite3ExprCompareCollSeq(tls, (*WhereConst)(unsafe.Pointer(pConst)).FpParse, pExpr)) != 0) {
  89794 		return
  89795 	}
  89796 
  89797 	for i = 0; i < (*WhereConst)(unsafe.Pointer(pConst)).FnConst; i++ {
  89798 		var pE2 uintptr = *(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*2)*4))
  89799 
  89800 		if (*Expr)(unsafe.Pointer(pE2)).FiTable == (*Expr)(unsafe.Pointer(pColumn)).FiTable &&
  89801 			int32((*Expr)(unsafe.Pointer(pE2)).FiColumn) == int32((*Expr)(unsafe.Pointer(pColumn)).FiColumn) {
  89802 			return
  89803 		}
  89804 	}
  89805 	if int32(Xsqlite3ExprAffinity(tls, pColumn)) == SQLITE_AFF_BLOB {
  89806 		(*WhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob = 1
  89807 	}
  89808 
  89809 	(*WhereConst)(unsafe.Pointer(pConst)).FnConst++
  89810 	(*WhereConst)(unsafe.Pointer(pConst)).FapExpr = Xsqlite3DbReallocOrFree(tls, (*Parse)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, (*WhereConst)(unsafe.Pointer(pConst)).FapExpr,
  89811 		uint64(uint32((*WhereConst)(unsafe.Pointer(pConst)).FnConst*2)*uint32(unsafe.Sizeof(uintptr(0)))))
  89812 	if (*WhereConst)(unsafe.Pointer(pConst)).FapExpr == uintptr(0) {
  89813 		(*WhereConst)(unsafe.Pointer(pConst)).FnConst = 0
  89814 	} else {
  89815 		*(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr((*WhereConst)(unsafe.Pointer(pConst)).FnConst*2-2)*4)) = pColumn
  89816 		*(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr((*WhereConst)(unsafe.Pointer(pConst)).FnConst*2-1)*4)) = pValue
  89817 	}
  89818 }
  89819 
  89820 func findConstInWhere(tls *libc.TLS, pConst uintptr, pExpr uintptr) {
  89821 	var pRight uintptr
  89822 	var pLeft uintptr
  89823 	if pExpr == uintptr(0) {
  89824 		return
  89825 	}
  89826 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&(*WhereConst)(unsafe.Pointer(pConst)).FmExcludeOn != U32(0) {
  89827 		return
  89828 	}
  89829 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND {
  89830 		findConstInWhere(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
  89831 		findConstInWhere(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
  89832 		return
  89833 	}
  89834 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_EQ {
  89835 		return
  89836 	}
  89837 	pRight = (*Expr)(unsafe.Pointer(pExpr)).FpRight
  89838 	pLeft = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
  89839 
  89840 	if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN && Xsqlite3ExprIsConstant(tls, pLeft) != 0 {
  89841 		constInsert(tls, pConst, pRight, pLeft, pExpr)
  89842 	}
  89843 	if int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN && Xsqlite3ExprIsConstant(tls, pRight) != 0 {
  89844 		constInsert(tls, pConst, pLeft, pRight, pExpr)
  89845 	}
  89846 }
  89847 
  89848 func propagateConstantExprRewriteOne(tls *libc.TLS, pConst uintptr, pExpr uintptr, bIgnoreAffBlob int32) int32 {
  89849 	var i int32
  89850 	if *(*U8)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpOomFault)) != 0 {
  89851 		return WRC_Prune
  89852 	}
  89853 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN {
  89854 		return WRC_Continue
  89855 	}
  89856 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&(U32(EP_FixedCol)|(*WhereConst)(unsafe.Pointer(pConst)).FmExcludeOn) != U32(0) {
  89857 		return WRC_Continue
  89858 	}
  89859 	for i = 0; i < (*WhereConst)(unsafe.Pointer(pConst)).FnConst; i++ {
  89860 		var pColumn uintptr = *(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*2)*4))
  89861 		if pColumn == pExpr {
  89862 			continue
  89863 		}
  89864 		if (*Expr)(unsafe.Pointer(pColumn)).FiTable != (*Expr)(unsafe.Pointer(pExpr)).FiTable {
  89865 			continue
  89866 		}
  89867 		if int32((*Expr)(unsafe.Pointer(pColumn)).FiColumn) != int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) {
  89868 			continue
  89869 		}
  89870 		if bIgnoreAffBlob != 0 && int32(Xsqlite3ExprAffinity(tls, pColumn)) == SQLITE_AFF_BLOB {
  89871 			break
  89872 		}
  89873 
  89874 		(*WhereConst)(unsafe.Pointer(pConst)).FnChng++
  89875 		*(*U32)(unsafe.Pointer(pExpr + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Leaf))
  89876 		*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_FixedCol)
  89877 
  89878 		(*Expr)(unsafe.Pointer(pExpr)).FpLeft = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, *(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(i*2+1)*4)), 0)
  89879 		if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb)).FmallocFailed != 0 {
  89880 			return WRC_Prune
  89881 		}
  89882 		break
  89883 	}
  89884 	return WRC_Prune
  89885 }
  89886 
  89887 func propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  89888 	var pConst uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  89889 
  89890 	if (*WhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob != 0 {
  89891 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) >= TK_EQ && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) <= TK_GE ||
  89892 			int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS {
  89893 			propagateConstantExprRewriteOne(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0)
  89894 			if *(*U8)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpOomFault)) != 0 {
  89895 				return WRC_Prune
  89896 			}
  89897 			if int32(Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)) != SQLITE_AFF_TEXT {
  89898 				propagateConstantExprRewriteOne(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpRight, 0)
  89899 			}
  89900 		}
  89901 	}
  89902 	return propagateConstantExprRewriteOne(tls, pConst, pExpr, (*WhereConst)(unsafe.Pointer(pConst)).FbHasAffBlob)
  89903 }
  89904 
  89905 func propagateConstants(tls *libc.TLS, pParse uintptr, p uintptr) int32 {
  89906 	bp := tls.Alloc(56)
  89907 	defer tls.Free(56)
  89908 
  89909 	var nChng int32 = 0
  89910 	(*WhereConst)(unsafe.Pointer(bp)).FpParse = pParse
  89911 	(*WhereConst)(unsafe.Pointer(bp)).FpOomFault = (*Parse)(unsafe.Pointer(pParse)).Fdb + 87
  89912 	for __ccgo := true; __ccgo; __ccgo = (*WhereConst)(unsafe.Pointer(bp)).FnChng != 0 {
  89913 		(*WhereConst)(unsafe.Pointer(bp)).FnConst = 0
  89914 		(*WhereConst)(unsafe.Pointer(bp)).FnChng = 0
  89915 		(*WhereConst)(unsafe.Pointer(bp)).FapExpr = uintptr(0)
  89916 		(*WhereConst)(unsafe.Pointer(bp)).FbHasAffBlob = 0
  89917 		if (*Select)(unsafe.Pointer(p)).FpSrc != uintptr(0) &&
  89918 			(*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc > 0 &&
  89919 			int32((*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc+8)).Ffg.Fjointype)&JT_LTORJ != 0 {
  89920 			(*WhereConst)(unsafe.Pointer(bp)).FmExcludeOn = U32(EP_InnerON | EP_OuterON)
  89921 		} else {
  89922 			(*WhereConst)(unsafe.Pointer(bp)).FmExcludeOn = U32(EP_OuterON)
  89923 		}
  89924 		findConstInWhere(tls, bp, (*Select)(unsafe.Pointer(p)).FpWhere)
  89925 		if (*WhereConst)(unsafe.Pointer(bp)).FnConst != 0 {
  89926 			libc.Xmemset(tls, bp+28, 0, uint32(unsafe.Sizeof(Walker{})))
  89927 			(*Walker)(unsafe.Pointer(bp + 28)).FpParse = pParse
  89928 			(*Walker)(unsafe.Pointer(bp + 28)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  89929 				f func(*libc.TLS, uintptr, uintptr) int32
  89930 			}{propagateConstantExprRewrite}))
  89931 			(*Walker)(unsafe.Pointer(bp + 28)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  89932 				f func(*libc.TLS, uintptr, uintptr) int32
  89933 			}{Xsqlite3SelectWalkNoop}))
  89934 			(*Walker)(unsafe.Pointer(bp + 28)).FxSelectCallback2 = uintptr(0)
  89935 			(*Walker)(unsafe.Pointer(bp + 28)).FwalkerDepth = 0
  89936 			*(*uintptr)(unsafe.Pointer(bp + 28 + 24)) = bp
  89937 			Xsqlite3WalkExpr(tls, bp+28, (*Select)(unsafe.Pointer(p)).FpWhere)
  89938 			Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(bp)).FpParse)).Fdb, (*WhereConst)(unsafe.Pointer(bp)).FapExpr)
  89939 			nChng = nChng + (*WhereConst)(unsafe.Pointer(bp)).FnChng
  89940 		}
  89941 	}
  89942 	return nChng
  89943 }
  89944 
  89945 func pushDownWindowCheck(tls *libc.TLS, pParse uintptr, pSubq uintptr, pExpr uintptr) int32 {
  89946 	return Xsqlite3ExprIsConstantOrGroupBy(tls, pParse, pExpr, (*Window)(unsafe.Pointer((*Select)(unsafe.Pointer(pSubq)).FpWin)).FpPartition)
  89947 }
  89948 
  89949 func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uintptr, pSrc uintptr) int32 {
  89950 	bp := tls.Alloc(24)
  89951 	defer tls.Free(24)
  89952 
  89953 	var pNew uintptr
  89954 	var nChng int32 = 0
  89955 	if pWhere == uintptr(0) {
  89956 		return 0
  89957 	}
  89958 	if (*Select)(unsafe.Pointer(pSubq)).FselFlags&U32(SF_Recursive|SF_MultiPart) != 0 {
  89959 		return 0
  89960 	}
  89961 	if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(JT_LTORJ|JT_RIGHT) != 0 {
  89962 		return 0
  89963 	}
  89964 
  89965 	if (*Select)(unsafe.Pointer(pSubq)).FpPrior != 0 {
  89966 		var pSel uintptr
  89967 		var notUnionAll int32 = 0
  89968 		for pSel = pSubq; pSel != 0; pSel = (*Select)(unsafe.Pointer(pSel)).FpPrior {
  89969 			var op U8 = (*Select)(unsafe.Pointer(pSel)).Fop
  89970 
  89971 			if int32(op) != TK_ALL && int32(op) != TK_SELECT {
  89972 				notUnionAll = 1
  89973 			}
  89974 			if (*Select)(unsafe.Pointer(pSel)).FpWin != 0 {
  89975 				return 0
  89976 			}
  89977 		}
  89978 		if compoundHasDifferentAffinities(tls, pSubq) != 0 {
  89979 			return 0
  89980 		}
  89981 		if notUnionAll != 0 {
  89982 			for pSel = pSubq; pSel != 0; pSel = (*Select)(unsafe.Pointer(pSel)).FpPrior {
  89983 				var ii int32
  89984 				var pList uintptr = (*Select)(unsafe.Pointer(pSel)).FpEList
  89985 
  89986 				for ii = 0; ii < (*ExprList)(unsafe.Pointer(pList)).FnExpr; ii++ {
  89987 					var pColl uintptr = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(ii)*20)).FpExpr)
  89988 					if !(Xsqlite3IsBinary(tls, pColl) != 0) {
  89989 						return 0
  89990 					}
  89991 				}
  89992 			}
  89993 		}
  89994 	} else {
  89995 		if (*Select)(unsafe.Pointer(pSubq)).FpWin != 0 && (*Window)(unsafe.Pointer((*Select)(unsafe.Pointer(pSubq)).FpWin)).FpPartition == uintptr(0) {
  89996 			return 0
  89997 		}
  89998 	}
  89999 
  90000 	if (*Select)(unsafe.Pointer(pSubq)).FpLimit != uintptr(0) {
  90001 		return 0
  90002 	}
  90003 	for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == TK_AND {
  90004 		nChng = nChng + pushDownWhereTerms(tls, pParse, pSubq, (*Expr)(unsafe.Pointer(pWhere)).FpRight, pSrc)
  90005 		pWhere = (*Expr)(unsafe.Pointer(pWhere)).FpLeft
  90006 	}
  90007 
  90008 	if Xsqlite3ExprIsTableConstraint(tls, pWhere, pSrc) != 0 {
  90009 		nChng++
  90010 		*(*U32)(unsafe.Pointer(pSubq + 4)) |= U32(SF_PushDown)
  90011 		for pSubq != 0 {
  90012 			pNew = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pWhere, 0)
  90013 			unsetJoinExpr(tls, pNew, -1, 1)
  90014 			(*SubstContext)(unsafe.Pointer(bp)).FpParse = pParse
  90015 			(*SubstContext)(unsafe.Pointer(bp)).FiTable = (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor
  90016 			(*SubstContext)(unsafe.Pointer(bp)).FiNewTable = (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor
  90017 			(*SubstContext)(unsafe.Pointer(bp)).FisOuterJoin = 0
  90018 			(*SubstContext)(unsafe.Pointer(bp)).FpEList = (*Select)(unsafe.Pointer(pSubq)).FpEList
  90019 			(*SubstContext)(unsafe.Pointer(bp)).FpCList = findLeftmostExprlist(tls, pSubq)
  90020 			pNew = substExpr(tls, bp, pNew)
  90021 			if (*Select)(unsafe.Pointer(pSubq)).FpWin != 0 && 0 == pushDownWindowCheck(tls, pParse, pSubq, pNew) {
  90022 				Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pNew)
  90023 				nChng--
  90024 				break
  90025 			}
  90026 			if (*Select)(unsafe.Pointer(pSubq)).FselFlags&U32(SF_Aggregate) != 0 {
  90027 				(*Select)(unsafe.Pointer(pSubq)).FpHaving = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(pSubq)).FpHaving, pNew)
  90028 			} else {
  90029 				(*Select)(unsafe.Pointer(pSubq)).FpWhere = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(pSubq)).FpWhere, pNew)
  90030 			}
  90031 			pSubq = (*Select)(unsafe.Pointer(pSubq)).FpPrior
  90032 		}
  90033 	}
  90034 	return nChng
  90035 }
  90036 
  90037 func minMaxQuery(tls *libc.TLS, db uintptr, pFunc uintptr, ppMinMax uintptr) U8 {
  90038 	var eRet int32 = WHERE_ORDERBY_NORMAL
  90039 	var pEList uintptr
  90040 	var zFunc uintptr
  90041 	var pOrderBy uintptr
  90042 	var sortFlags U8 = U8(0)
  90043 
  90044 	pEList = *(*uintptr)(unsafe.Pointer(pFunc + 20))
  90045 	if pEList == uintptr(0) ||
  90046 		(*ExprList)(unsafe.Pointer(pEList)).FnExpr != 1 ||
  90047 		(*Expr)(unsafe.Pointer(pFunc)).Fflags&U32(EP_WinFunc) != U32(0) ||
  90048 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_MinMaxOpt) != U32(0) {
  90049 		return U8(eRet)
  90050 	}
  90051 
  90052 	zFunc = *(*uintptr)(unsafe.Pointer(pFunc + 8))
  90053 	if Xsqlite3StrICmp(tls, zFunc, ts+15164) == 0 {
  90054 		eRet = WHERE_ORDERBY_MIN
  90055 		if Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer(pEList+8)).FpExpr) != 0 {
  90056 			sortFlags = U8(KEYINFO_ORDER_BIGNULL)
  90057 		}
  90058 	} else if Xsqlite3StrICmp(tls, zFunc, ts+15168) == 0 {
  90059 		eRet = WHERE_ORDERBY_MAX
  90060 		sortFlags = U8(KEYINFO_ORDER_DESC)
  90061 	} else {
  90062 		return U8(eRet)
  90063 	}
  90064 	*(*uintptr)(unsafe.Pointer(ppMinMax)) = libc.AssignUintptr(&pOrderBy, Xsqlite3ExprListDup(tls, db, pEList, 0))
  90065 
  90066 	if pOrderBy != 0 {
  90067 		(*ExprList_item)(unsafe.Pointer(pOrderBy + 8)).Ffg.FsortFlags = sortFlags
  90068 	}
  90069 	return U8(eRet)
  90070 }
  90071 
  90072 func isSimpleCount(tls *libc.TLS, p uintptr, pAggInfo uintptr) uintptr {
  90073 	var pTab uintptr
  90074 	var pExpr uintptr
  90075 
  90076 	if (*Select)(unsafe.Pointer(p)).FpWhere != 0 ||
  90077 		(*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr != 1 ||
  90078 		(*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc != 1 ||
  90079 		(*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc+8)).FpSelect != 0 ||
  90080 		(*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc != 1 ||
  90081 		(*Select)(unsafe.Pointer(p)).FpHaving != 0 {
  90082 		return uintptr(0)
  90083 	}
  90084 	pTab = (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpTab
  90085 
  90086 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  90087 		return uintptr(0)
  90088 	}
  90089 	pExpr = (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList + 8)).FpExpr
  90090 
  90091 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AGG_FUNCTION {
  90092 		return uintptr(0)
  90093 	}
  90094 	if (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo != pAggInfo {
  90095 		return uintptr(0)
  90096 	}
  90097 	if (*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFunc)).FfuncFlags&U32(SQLITE_FUNC_COUNT) == U32(0) {
  90098 		return uintptr(0)
  90099 	}
  90100 
  90101 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Distinct|EP_WinFunc) != U32(0) {
  90102 		return uintptr(0)
  90103 	}
  90104 
  90105 	return pTab
  90106 }
  90107 
  90108 // If the source-list item passed as an argument was augmented with an
  90109 // INDEXED BY clause, then try to locate the specified index. If there
  90110 // was such a clause and the named index cannot be found, return
  90111 // SQLITE_ERROR and leave an error in pParse. Otherwise, populate
  90112 // pFrom->pIndex and return SQLITE_OK.
  90113 func Xsqlite3IndexedByLookup(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 {
  90114 	bp := tls.Alloc(16)
  90115 	defer tls.Free(16)
  90116 
  90117 	var pTab uintptr = (*SrcItem)(unsafe.Pointer(pFrom)).FpTab
  90118 	var zIndexedBy uintptr = *(*uintptr)(unsafe.Pointer(pFrom + 64))
  90119 	var pIdx uintptr
  90120 
  90121 	for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0 && Xsqlite3StrICmp(tls, (*Index)(unsafe.Pointer(pIdx)).FzName, zIndexedBy) != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  90122 	}
  90123 	if !(pIdx != 0) {
  90124 		Xsqlite3ErrorMsg(tls, pParse, ts+19211, libc.VaList(bp, zIndexedBy, 0))
  90125 		(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  90126 		return SQLITE_ERROR
  90127 	}
  90128 
  90129 	*(*uintptr)(unsafe.Pointer(pFrom + 68)) = pIdx
  90130 	return SQLITE_OK
  90131 }
  90132 
  90133 func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  90134 	bp := tls.Alloc(8)
  90135 	defer tls.Free(8)
  90136 
  90137 	var i int32
  90138 	var pNew uintptr
  90139 	var pX uintptr
  90140 	var db uintptr
  90141 	var a uintptr
  90142 	var pNewSrc uintptr
  90143 	var pParse uintptr
  90144 
  90145 	if (*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0) {
  90146 		return WRC_Continue
  90147 	}
  90148 	if (*Select)(unsafe.Pointer(p)).FpOrderBy == uintptr(0) {
  90149 		return WRC_Continue
  90150 	}
  90151 	for pX = p; pX != 0 && (int32((*Select)(unsafe.Pointer(pX)).Fop) == TK_ALL || int32((*Select)(unsafe.Pointer(pX)).Fop) == TK_SELECT); pX = (*Select)(unsafe.Pointer(pX)).FpPrior {
  90152 	}
  90153 	if pX == uintptr(0) {
  90154 		return WRC_Continue
  90155 	}
  90156 	a = (*Select)(unsafe.Pointer(p)).FpOrderBy + 8
  90157 
  90158 	if *(*U16)(unsafe.Pointer(a + 16)) != 0 {
  90159 		return WRC_Continue
  90160 	}
  90161 	for i = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy)).FnExpr - 1; i >= 0; i-- {
  90162 		if (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(a+uintptr(i)*20)).FpExpr)).Fflags&U32(EP_Collate) != 0 {
  90163 			break
  90164 		}
  90165 	}
  90166 	if i < 0 {
  90167 		return WRC_Continue
  90168 	}
  90169 
  90170 	pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  90171 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  90172 	pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Select{})))
  90173 	if pNew == uintptr(0) {
  90174 		return WRC_Abort
  90175 	}
  90176 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Token{})))
  90177 	pNewSrc = Xsqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp, pNew, uintptr(0))
  90178 	if pNewSrc == uintptr(0) {
  90179 		return WRC_Abort
  90180 	}
  90181 	*(*Select)(unsafe.Pointer(pNew)) = *(*Select)(unsafe.Pointer(p))
  90182 	(*Select)(unsafe.Pointer(p)).FpSrc = pNewSrc
  90183 	(*Select)(unsafe.Pointer(p)).FpEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3Expr(tls, db, TK_ASTERISK, uintptr(0)))
  90184 	(*Select)(unsafe.Pointer(p)).Fop = U8(TK_SELECT)
  90185 	(*Select)(unsafe.Pointer(p)).FpWhere = uintptr(0)
  90186 	(*Select)(unsafe.Pointer(pNew)).FpGroupBy = uintptr(0)
  90187 	(*Select)(unsafe.Pointer(pNew)).FpHaving = uintptr(0)
  90188 	(*Select)(unsafe.Pointer(pNew)).FpOrderBy = uintptr(0)
  90189 	(*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0)
  90190 	(*Select)(unsafe.Pointer(p)).FpNext = uintptr(0)
  90191 	(*Select)(unsafe.Pointer(p)).FpWith = uintptr(0)
  90192 	(*Select)(unsafe.Pointer(p)).FpWinDefn = uintptr(0)
  90193 	*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_Compound))
  90194 
  90195 	*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_Converted)
  90196 
  90197 	(*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(pNew)).FpPrior)).FpNext = pNew
  90198 	(*Select)(unsafe.Pointer(pNew)).FpLimit = uintptr(0)
  90199 	return WRC_Continue
  90200 }
  90201 
  90202 func cannotBeFunction(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 {
  90203 	bp := tls.Alloc(8)
  90204 	defer tls.Free(8)
  90205 
  90206 	if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x4>>2)) != 0 {
  90207 		Xsqlite3ErrorMsg(tls, pParse, ts+19229, libc.VaList(bp, (*SrcItem)(unsafe.Pointer(pFrom)).FzName))
  90208 		return 1
  90209 	}
  90210 	return 0
  90211 }
  90212 
  90213 func searchWith(tls *libc.TLS, pWith uintptr, pItem uintptr, ppContext uintptr) uintptr {
  90214 	var zName uintptr = (*SrcItem)(unsafe.Pointer(pItem)).FzName
  90215 	var p uintptr
  90216 
  90217 	for p = pWith; p != 0; p = (*With)(unsafe.Pointer(p)).FpOuter {
  90218 		var i int32
  90219 		for i = 0; i < (*With)(unsafe.Pointer(p)).FnCte; i++ {
  90220 			if Xsqlite3StrICmp(tls, zName, (*Cte)(unsafe.Pointer(p+12+uintptr(i)*24)).FzName) == 0 {
  90221 				*(*uintptr)(unsafe.Pointer(ppContext)) = p
  90222 				return p + 12 + uintptr(i)*24
  90223 			}
  90224 		}
  90225 		if (*With)(unsafe.Pointer(p)).FbView != 0 {
  90226 			break
  90227 		}
  90228 	}
  90229 	return uintptr(0)
  90230 }
  90231 
  90232 // The code generator maintains a stack of active WITH clauses
  90233 // with the inner-most WITH clause being at the top of the stack.
  90234 //
  90235 // This routine pushes the WITH clause passed as the second argument
  90236 // onto the top of the stack. If argument bFree is true, then this
  90237 // WITH clause will never be popped from the stack but should instead
  90238 // be freed along with the Parse object. In other cases, when
  90239 // bFree==0, the With object will be freed along with the SELECT
  90240 // statement with which it is associated.
  90241 //
  90242 // This routine returns a copy of pWith.  Or, if bFree is true and
  90243 // the pWith object is destroyed immediately due to an OOM condition,
  90244 // then this routine return NULL.
  90245 //
  90246 // If bFree is true, do not continue to use the pWith pointer after
  90247 // calling this routine,  Instead, use only the return value.
  90248 func Xsqlite3WithPush(tls *libc.TLS, pParse uintptr, pWith uintptr, bFree U8) uintptr {
  90249 	if pWith != 0 {
  90250 		if bFree != 0 {
  90251 			pWith = Xsqlite3ParserAddCleanup(tls, pParse,
  90252 				*(*uintptr)(unsafe.Pointer(&struct {
  90253 					f func(*libc.TLS, uintptr, uintptr)
  90254 				}{Xsqlite3WithDelete})),
  90255 				pWith)
  90256 			if pWith == uintptr(0) {
  90257 				return uintptr(0)
  90258 			}
  90259 		}
  90260 		if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  90261 			(*With)(unsafe.Pointer(pWith)).FpOuter = (*Parse)(unsafe.Pointer(pParse)).FpWith
  90262 			(*Parse)(unsafe.Pointer(pParse)).FpWith = pWith
  90263 		}
  90264 	}
  90265 	return pWith
  90266 }
  90267 
  90268 func resolveFromTermToCte(tls *libc.TLS, pParse uintptr, pWalker uintptr, pFrom uintptr) int32 {
  90269 	bp := tls.Alloc(52)
  90270 	defer tls.Free(52)
  90271 
  90272 	var pCte uintptr
  90273 
  90274 	if (*Parse)(unsafe.Pointer(pParse)).FpWith == uintptr(0) {
  90275 		return 0
  90276 	}
  90277 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  90278 		return 0
  90279 	}
  90280 	if (*SrcItem)(unsafe.Pointer(pFrom)).FzDatabase != uintptr(0) {
  90281 		return 0
  90282 	}
  90283 	if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x200>>9)) != 0 {
  90284 		return 0
  90285 	}
  90286 	pCte = searchWith(tls, (*Parse)(unsafe.Pointer(pParse)).FpWith, pFrom, bp+48)
  90287 	if pCte != 0 {
  90288 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  90289 		var pTab uintptr
  90290 		var pEList uintptr
  90291 		var pSel uintptr
  90292 		var pLeft uintptr
  90293 		var pRecTerm uintptr
  90294 		var bMayRecursive int32
  90295 		var pSavedWith uintptr
  90296 		var iRecTab int32 = -1
  90297 		var pCteUse uintptr
  90298 
  90299 		if (*Cte)(unsafe.Pointer(pCte)).FzCteErr != 0 {
  90300 			Xsqlite3ErrorMsg(tls, pParse, (*Cte)(unsafe.Pointer(pCte)).FzCteErr, libc.VaList(bp, (*Cte)(unsafe.Pointer(pCte)).FzName))
  90301 			return 2
  90302 		}
  90303 		if cannotBeFunction(tls, pParse, pFrom) != 0 {
  90304 			return 2
  90305 		}
  90306 
  90307 		pTab = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))
  90308 		if pTab == uintptr(0) {
  90309 			return 2
  90310 		}
  90311 		pCteUse = (*Cte)(unsafe.Pointer(pCte)).FpUse
  90312 		if pCteUse == uintptr(0) {
  90313 			(*Cte)(unsafe.Pointer(pCte)).FpUse = libc.AssignUintptr(&pCteUse, Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(CteUse{}))))
  90314 			if pCteUse == uintptr(0) ||
  90315 				Xsqlite3ParserAddCleanup(tls, pParse, *(*uintptr)(unsafe.Pointer(&struct {
  90316 					f func(*libc.TLS, uintptr, uintptr)
  90317 				}{Xsqlite3DbFree})), pCteUse) == uintptr(0) {
  90318 				Xsqlite3DbFree(tls, db, pTab)
  90319 				return 2
  90320 			}
  90321 			(*CteUse)(unsafe.Pointer(pCteUse)).FeM10d = (*Cte)(unsafe.Pointer(pCte)).FeM10d
  90322 		}
  90323 		(*SrcItem)(unsafe.Pointer(pFrom)).FpTab = pTab
  90324 		(*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1)
  90325 		(*Table)(unsafe.Pointer(pTab)).FzName = Xsqlite3DbStrDup(tls, db, (*Cte)(unsafe.Pointer(pCte)).FzName)
  90326 		(*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1)
  90327 		(*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200)
  90328 		*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_Ephemeral | TF_NoVisibleRowid)
  90329 		(*SrcItem)(unsafe.Pointer(pFrom)).FpSelect = Xsqlite3SelectDup(tls, db, (*Cte)(unsafe.Pointer(pCte)).FpSelect, 0)
  90330 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  90331 			return 2
  90332 		}
  90333 		*(*U32)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pFrom)).FpSelect + 4)) |= U32(SF_CopyCte)
  90334 
  90335 		if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x2>>1)) != 0 {
  90336 			Xsqlite3ErrorMsg(tls, pParse, ts+19252, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(pFrom + 64))))
  90337 			return 2
  90338 		}
  90339 		libc.SetBitFieldPtr16Uint32(pFrom+36+4, uint32(1), 8, 0x100)
  90340 		*(*uintptr)(unsafe.Pointer(pFrom + 68)) = pCteUse
  90341 		(*CteUse)(unsafe.Pointer(pCteUse)).FnUse++
  90342 
  90343 		pRecTerm = libc.AssignUintptr(&pSel, (*SrcItem)(unsafe.Pointer(pFrom)).FpSelect)
  90344 		bMayRecursive = libc.Bool32(int32((*Select)(unsafe.Pointer(pSel)).Fop) == TK_ALL || int32((*Select)(unsafe.Pointer(pSel)).Fop) == TK_UNION)
  90345 		for bMayRecursive != 0 && int32((*Select)(unsafe.Pointer(pRecTerm)).Fop) == int32((*Select)(unsafe.Pointer(pSel)).Fop) {
  90346 			var i int32
  90347 			var pSrc uintptr = (*Select)(unsafe.Pointer(pRecTerm)).FpSrc
  90348 
  90349 			for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ {
  90350 				var pItem uintptr = pSrc + 8 + uintptr(i)*72
  90351 				if (*SrcItem)(unsafe.Pointer(pItem)).FzDatabase == uintptr(0) &&
  90352 					(*SrcItem)(unsafe.Pointer(pItem)).FzName != uintptr(0) &&
  90353 					0 == Xsqlite3StrICmp(tls, (*SrcItem)(unsafe.Pointer(pItem)).FzName, (*Cte)(unsafe.Pointer(pCte)).FzName) {
  90354 					(*SrcItem)(unsafe.Pointer(pItem)).FpTab = pTab
  90355 					(*Table)(unsafe.Pointer(pTab)).FnTabRef++
  90356 					libc.SetBitFieldPtr16Uint32(pItem+36+4, uint32(1), 6, 0x40)
  90357 					if (*Select)(unsafe.Pointer(pRecTerm)).FselFlags&U32(SF_Recursive) != 0 {
  90358 						Xsqlite3ErrorMsg(tls, pParse,
  90359 							ts+19272, libc.VaList(bp+16, (*Cte)(unsafe.Pointer(pCte)).FzName))
  90360 						return 2
  90361 					}
  90362 					*(*U32)(unsafe.Pointer(pRecTerm + 4)) |= U32(SF_Recursive)
  90363 					if iRecTab < 0 {
  90364 						iRecTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  90365 					}
  90366 					(*SrcItem)(unsafe.Pointer(pItem)).FiCursor = iRecTab
  90367 				}
  90368 			}
  90369 			if (*Select)(unsafe.Pointer(pRecTerm)).FselFlags&U32(SF_Recursive) == U32(0) {
  90370 				break
  90371 			}
  90372 			pRecTerm = (*Select)(unsafe.Pointer(pRecTerm)).FpPrior
  90373 		}
  90374 
  90375 		(*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 19315
  90376 		pSavedWith = (*Parse)(unsafe.Pointer(pParse)).FpWith
  90377 		(*Parse)(unsafe.Pointer(pParse)).FpWith = *(*uintptr)(unsafe.Pointer(bp + 48))
  90378 		if (*Select)(unsafe.Pointer(pSel)).FselFlags&U32(SF_Recursive) != 0 {
  90379 			var rc int32
  90380 
  90381 			(*Select)(unsafe.Pointer(pRecTerm)).FpWith = (*Select)(unsafe.Pointer(pSel)).FpWith
  90382 			rc = Xsqlite3WalkSelect(tls, pWalker, pRecTerm)
  90383 			(*Select)(unsafe.Pointer(pRecTerm)).FpWith = uintptr(0)
  90384 			if rc != 0 {
  90385 				(*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith
  90386 				return 2
  90387 			}
  90388 		} else {
  90389 			if Xsqlite3WalkSelect(tls, pWalker, pSel) != 0 {
  90390 				(*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith
  90391 				return 2
  90392 			}
  90393 		}
  90394 		(*Parse)(unsafe.Pointer(pParse)).FpWith = *(*uintptr)(unsafe.Pointer(bp + 48))
  90395 
  90396 		for pLeft = pSel; (*Select)(unsafe.Pointer(pLeft)).FpPrior != 0; pLeft = (*Select)(unsafe.Pointer(pLeft)).FpPrior {
  90397 		}
  90398 		pEList = (*Select)(unsafe.Pointer(pLeft)).FpEList
  90399 		if (*Cte)(unsafe.Pointer(pCte)).FpCols != 0 {
  90400 			if pEList != 0 && (*ExprList)(unsafe.Pointer(pEList)).FnExpr != (*ExprList)(unsafe.Pointer((*Cte)(unsafe.Pointer(pCte)).FpCols)).FnExpr {
  90401 				Xsqlite3ErrorMsg(tls, pParse, ts+19338,
  90402 					libc.VaList(bp+24, (*Cte)(unsafe.Pointer(pCte)).FzName, (*ExprList)(unsafe.Pointer(pEList)).FnExpr, (*ExprList)(unsafe.Pointer((*Cte)(unsafe.Pointer(pCte)).FpCols)).FnExpr))
  90403 				(*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith
  90404 				return 2
  90405 			}
  90406 			pEList = (*Cte)(unsafe.Pointer(pCte)).FpCols
  90407 		}
  90408 
  90409 		Xsqlite3ColumnsFromExprList(tls, pParse, pEList, pTab+34, pTab+4)
  90410 		if bMayRecursive != 0 {
  90411 			if (*Select)(unsafe.Pointer(pSel)).FselFlags&U32(SF_Recursive) != 0 {
  90412 				(*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 19376
  90413 			} else {
  90414 				(*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 19410
  90415 			}
  90416 			Xsqlite3WalkSelect(tls, pWalker, pSel)
  90417 		}
  90418 		(*Cte)(unsafe.Pointer(pCte)).FzCteErr = uintptr(0)
  90419 		(*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith
  90420 		return 1
  90421 	}
  90422 	return 0
  90423 }
  90424 
  90425 // If the SELECT passed as the second argument has an associated WITH
  90426 // clause, pop it from the stack stored as part of the Parse object.
  90427 //
  90428 // This function is used as the xSelectCallback2() callback by
  90429 // sqlite3SelectExpand() when walking a SELECT tree to resolve table
  90430 // names and other FROM clause elements.
  90431 func Xsqlite3SelectPopWith(tls *libc.TLS, pWalker uintptr, p uintptr) {
  90432 	var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  90433 	if (*Parse)(unsafe.Pointer(pParse)).FpWith != 0 && (*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0) {
  90434 		var pWith uintptr = (*Select)(unsafe.Pointer(findRightmost(tls, p))).FpWith
  90435 		if pWith != uintptr(0) {
  90436 			(*Parse)(unsafe.Pointer(pParse)).FpWith = (*With)(unsafe.Pointer(pWith)).FpOuter
  90437 		}
  90438 	}
  90439 }
  90440 
  90441 // The SrcItem structure passed as the second argument represents a
  90442 // sub-query in the FROM clause of a SELECT statement. This function
  90443 // allocates and populates the SrcItem.pTab object. If successful,
  90444 // SQLITE_OK is returned. Otherwise, if an OOM error is encountered,
  90445 // SQLITE_NOMEM.
  90446 func Xsqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 {
  90447 	bp := tls.Alloc(8)
  90448 	defer tls.Free(8)
  90449 
  90450 	var pSel uintptr = (*SrcItem)(unsafe.Pointer(pFrom)).FpSelect
  90451 	var pTab uintptr
  90452 
  90453 	(*SrcItem)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Table{}))))
  90454 	if pTab == uintptr(0) {
  90455 		return SQLITE_NOMEM
  90456 	}
  90457 	(*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1)
  90458 	if (*SrcItem)(unsafe.Pointer(pFrom)).FzAlias != 0 {
  90459 		(*Table)(unsafe.Pointer(pTab)).FzName = Xsqlite3DbStrDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*SrcItem)(unsafe.Pointer(pFrom)).FzAlias)
  90460 	} else {
  90461 		(*Table)(unsafe.Pointer(pTab)).FzName = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+19448, libc.VaList(bp, pFrom))
  90462 	}
  90463 	for (*Select)(unsafe.Pointer(pSel)).FpPrior != 0 {
  90464 		pSel = (*Select)(unsafe.Pointer(pSel)).FpPrior
  90465 	}
  90466 	Xsqlite3ColumnsFromExprList(tls, pParse, (*Select)(unsafe.Pointer(pSel)).FpEList, pTab+34, pTab+4)
  90467 	(*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1)
  90468 	(*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200)
  90469 
  90470 	*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_Ephemeral | TF_NoVisibleRowid)
  90471 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  90472 		return SQLITE_ERROR
  90473 	}
  90474 	return SQLITE_OK
  90475 }
  90476 
  90477 func inAnyUsingClause(tls *libc.TLS, zName uintptr, pBase uintptr, N int32) int32 {
  90478 	for N > 0 {
  90479 		N--
  90480 		pBase += 72
  90481 		if int32(*(*uint16)(unsafe.Pointer(pBase + 36 + 4))&0x400>>10) == 0 {
  90482 			continue
  90483 		}
  90484 		if *(*uintptr)(unsafe.Pointer(pBase + 48)) == uintptr(0) {
  90485 			continue
  90486 		}
  90487 		if Xsqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pBase + 48)), zName) >= 0 {
  90488 			return 1
  90489 		}
  90490 	}
  90491 	return 0
  90492 }
  90493 
  90494 func selectExpander(tls *libc.TLS, pWalker uintptr, p uintptr) int32 {
  90495 	bp := tls.Alloc(80)
  90496 	defer tls.Free(80)
  90497 
  90498 	var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  90499 	var i int32
  90500 	var j int32
  90501 	var k int32
  90502 	var rc int32
  90503 	var pTabList uintptr
  90504 	var pEList uintptr
  90505 	var pFrom uintptr
  90506 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  90507 	var pE uintptr
  90508 	var pRight uintptr
  90509 	var pExpr uintptr
  90510 	var selFlags U16 = U16((*Select)(unsafe.Pointer(p)).FselFlags)
  90511 	var elistFlags U32 = U32(0)
  90512 
  90513 	*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_Expanded)
  90514 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  90515 		return WRC_Abort
  90516 	}
  90517 
  90518 	if int32(selFlags)&SF_Expanded != 0 {
  90519 		return WRC_Prune
  90520 	}
  90521 	if (*Walker)(unsafe.Pointer(pWalker)).FeCode != 0 {
  90522 		(*Select)(unsafe.Pointer(p)).FselId = U32(libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnSelect, 1))
  90523 	}
  90524 	pTabList = (*Select)(unsafe.Pointer(p)).FpSrc
  90525 	pEList = (*Select)(unsafe.Pointer(p)).FpEList
  90526 	if (*Parse)(unsafe.Pointer(pParse)).FpWith != 0 && (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_View) != 0 {
  90527 		if (*Select)(unsafe.Pointer(p)).FpWith == uintptr(0) {
  90528 			(*Select)(unsafe.Pointer(p)).FpWith = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(With{})))
  90529 			if (*Select)(unsafe.Pointer(p)).FpWith == uintptr(0) {
  90530 				return WRC_Abort
  90531 			}
  90532 		}
  90533 		(*With)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpWith)).FbView = 1
  90534 	}
  90535 	Xsqlite3WithPush(tls, pParse, (*Select)(unsafe.Pointer(p)).FpWith, uint8(0))
  90536 
  90537 	Xsqlite3SrcListAssignCursors(tls, pParse, pTabList)
  90538 
  90539 	i = 0
  90540 	pFrom = pTabList + 8
  90541 __1:
  90542 	if !(i < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc) {
  90543 		goto __3
  90544 	}
  90545 	{
  90546 		var pTab uintptr
  90547 
  90548 		if (*SrcItem)(unsafe.Pointer(pFrom)).FpTab != 0 {
  90549 			goto __2
  90550 		}
  90551 
  90552 		if (*SrcItem)(unsafe.Pointer(pFrom)).FzName == uintptr(0) {
  90553 			var pSel uintptr = (*SrcItem)(unsafe.Pointer(pFrom)).FpSelect
  90554 
  90555 			if Xsqlite3WalkSelect(tls, pWalker, pSel) != 0 {
  90556 				return WRC_Abort
  90557 			}
  90558 			if Xsqlite3ExpandSubquery(tls, pParse, pFrom) != 0 {
  90559 				return WRC_Abort
  90560 			}
  90561 		} else if libc.AssignInt32(&rc, resolveFromTermToCte(tls, pParse, pWalker, pFrom)) != 0 {
  90562 			if rc > 1 {
  90563 				return WRC_Abort
  90564 			}
  90565 			pTab = (*SrcItem)(unsafe.Pointer(pFrom)).FpTab
  90566 
  90567 		} else {
  90568 			(*SrcItem)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3LocateTableItem(tls, pParse, uint32(0), pFrom))
  90569 			if pTab == uintptr(0) {
  90570 				return WRC_Abort
  90571 			}
  90572 			if (*Table)(unsafe.Pointer(pTab)).FnTabRef >= U32(0xffff) {
  90573 				Xsqlite3ErrorMsg(tls, pParse, ts+19452,
  90574 					libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  90575 				(*SrcItem)(unsafe.Pointer(pFrom)).FpTab = uintptr(0)
  90576 				return WRC_Abort
  90577 			}
  90578 			(*Table)(unsafe.Pointer(pTab)).FnTabRef++
  90579 			if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) && cannotBeFunction(tls, pParse, pFrom) != 0 {
  90580 				return WRC_Abort
  90581 			}
  90582 			if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_NORM) {
  90583 				var nCol I16
  90584 				var eCodeOrig U8 = U8((*Walker)(unsafe.Pointer(pWalker)).FeCode)
  90585 				if Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 {
  90586 					return WRC_Abort
  90587 				}
  90588 
  90589 				if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW {
  90590 					if (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableView) == uint64(0) &&
  90591 						(*Table)(unsafe.Pointer(pTab)).FpSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema {
  90592 						Xsqlite3ErrorMsg(tls, pParse, ts+19491,
  90593 							libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName))
  90594 					}
  90595 					(*SrcItem)(unsafe.Pointer(pFrom)).FpSelect = Xsqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(pTab + 44)), 0)
  90596 				} else if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB &&
  90597 					uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x80>>7)) != 0 &&
  90598 					*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) != uintptr(0) &&
  90599 					int32((*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)))).FeVtabRisk) > libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_TrustedSchema) != uint64(0)) {
  90600 					Xsqlite3ErrorMsg(tls, pParse, ts+14733,
  90601 						libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName))
  90602 				}
  90603 
  90604 				nCol = (*Table)(unsafe.Pointer(pTab)).FnCol
  90605 				(*Table)(unsafe.Pointer(pTab)).FnCol = int16(-1)
  90606 				(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1)
  90607 				Xsqlite3WalkSelect(tls, pWalker, (*SrcItem)(unsafe.Pointer(pFrom)).FpSelect)
  90608 				(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(eCodeOrig)
  90609 				(*Table)(unsafe.Pointer(pTab)).FnCol = nCol
  90610 			}
  90611 		}
  90612 
  90613 		if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x2>>1)) != 0 && Xsqlite3IndexedByLookup(tls, pParse, pFrom) != 0 {
  90614 			return WRC_Abort
  90615 		}
  90616 
  90617 	}
  90618 	goto __2
  90619 __2:
  90620 	i++
  90621 	pFrom += 72
  90622 	goto __1
  90623 	goto __3
  90624 __3:
  90625 	;
  90626 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 || sqlite3ProcessJoin(tls, pParse, p) != 0 {
  90627 		return WRC_Abort
  90628 	}
  90629 
  90630 	for k = 0; k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; k++ {
  90631 		pE = (*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(k)*20)).FpExpr
  90632 		if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_ASTERISK {
  90633 			break
  90634 		}
  90635 
  90636 		if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_DOT && int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpRight)).Fop) == TK_ASTERISK {
  90637 			break
  90638 		}
  90639 		elistFlags = elistFlags | (*Expr)(unsafe.Pointer(pE)).Fflags
  90640 	}
  90641 	if k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr {
  90642 		var a uintptr = pEList + 8
  90643 		var pNew uintptr = uintptr(0)
  90644 		var flags int32 = int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags)
  90645 		var longNames int32 = libc.Bool32(flags&SQLITE_FullColNames != 0 &&
  90646 			flags&SQLITE_ShortColNames == 0)
  90647 
  90648 		for k = 0; k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; k++ {
  90649 			pE = (*ExprList_item)(unsafe.Pointer(a + uintptr(k)*20)).FpExpr
  90650 			elistFlags = elistFlags | (*Expr)(unsafe.Pointer(pE)).Fflags
  90651 			pRight = (*Expr)(unsafe.Pointer(pE)).FpRight
  90652 
  90653 			if int32((*Expr)(unsafe.Pointer(pE)).Fop) != TK_ASTERISK &&
  90654 				(int32((*Expr)(unsafe.Pointer(pE)).Fop) != TK_DOT || int32((*Expr)(unsafe.Pointer(pRight)).Fop) != TK_ASTERISK) {
  90655 				pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, (*ExprList_item)(unsafe.Pointer(a+uintptr(k)*20)).FpExpr)
  90656 				if pNew != 0 {
  90657 					(*ExprList_item)(unsafe.Pointer(pNew + 8 + uintptr((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1)*20)).FzEName = (*ExprList_item)(unsafe.Pointer(a + uintptr(k)*20)).FzEName
  90658 					libc.SetBitFieldPtr16Uint32(pNew+8+uintptr((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1)*20+8+4, uint32(int32(*(*uint16)(unsafe.Pointer(a + uintptr(k)*20 + 8 + 4))&0x3>>0)), 0, 0x3)
  90659 					(*ExprList_item)(unsafe.Pointer(a + uintptr(k)*20)).FzEName = uintptr(0)
  90660 				}
  90661 				(*ExprList_item)(unsafe.Pointer(a + uintptr(k)*20)).FpExpr = uintptr(0)
  90662 			} else {
  90663 				var tableSeen int32 = 0
  90664 				var zTName uintptr = uintptr(0)
  90665 				if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_DOT {
  90666 					zTName = *(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpLeft + 8))
  90667 				}
  90668 				i = 0
  90669 				pFrom = pTabList + 8
  90670 			__4:
  90671 				if !(i < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc) {
  90672 					goto __6
  90673 				}
  90674 				{
  90675 					var pTab uintptr = (*SrcItem)(unsafe.Pointer(pFrom)).FpTab
  90676 					var pNestedFrom uintptr
  90677 					var zTabName uintptr
  90678 					var zSchemaName uintptr = uintptr(0)
  90679 					var iDb int32
  90680 					var pUsing uintptr
  90681 
  90682 					if libc.AssignUintptr(&zTabName, (*SrcItem)(unsafe.Pointer(pFrom)).FzAlias) == uintptr(0) {
  90683 						zTabName = (*Table)(unsafe.Pointer(pTab)).FzName
  90684 					}
  90685 					if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
  90686 						goto __6
  90687 					}
  90688 
  90689 					if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x2000>>13)) != 0 {
  90690 						pNestedFrom = (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pFrom)).FpSelect)).FpEList
  90691 
  90692 					} else {
  90693 						if zTName != 0 && Xsqlite3StrICmp(tls, zTName, zTabName) != 0 {
  90694 							goto __5
  90695 						}
  90696 						pNestedFrom = uintptr(0)
  90697 						iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  90698 						if iDb >= 0 {
  90699 							zSchemaName = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  90700 						} else {
  90701 							zSchemaName = ts + 6446
  90702 						}
  90703 					}
  90704 					if i+1 < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc &&
  90705 						uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 1*72 + 36 + 4))&0x400>>10)) != 0 &&
  90706 						int32(selFlags)&SF_NestedFrom != 0 {
  90707 						var ii int32
  90708 						pUsing = *(*uintptr)(unsafe.Pointer(pFrom + 1*72 + 48))
  90709 						for ii = 0; ii < (*IdList)(unsafe.Pointer(pUsing)).FnId; ii++ {
  90710 							var zUName uintptr = (*IdList_item)(unsafe.Pointer(pUsing + 8 + uintptr(ii)*8)).FzName
  90711 							pRight = Xsqlite3Expr(tls, db, TK_ID, zUName)
  90712 							pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, pRight)
  90713 							if pNew != 0 {
  90714 								var pX uintptr = pNew + 8 + uintptr((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1)*20
  90715 
  90716 								(*ExprList_item)(unsafe.Pointer(pX)).FzEName = Xsqlite3MPrintf(tls, db, ts+19522, libc.VaList(bp+24, zUName))
  90717 								libc.SetBitFieldPtr16Uint32(pX+8+4, uint32(ENAME_TAB), 0, 0x3)
  90718 								libc.SetBitFieldPtr16Uint32(pX+8+4, uint32(1), 7, 0x80)
  90719 							}
  90720 						}
  90721 					} else {
  90722 						pUsing = uintptr(0)
  90723 					}
  90724 					for j = 0; j < int32((*Table)(unsafe.Pointer(pTab)).FnCol); j++ {
  90725 						var zName uintptr = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16)).FzCnName
  90726 						var pX uintptr
  90727 
  90728 						if zTName != 0 &&
  90729 							pNestedFrom != 0 &&
  90730 							Xsqlite3MatchEName(tls, pNestedFrom+8+uintptr(j)*20, uintptr(0), zTName, uintptr(0)) == 0 {
  90731 							continue
  90732 						}
  90733 
  90734 						if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_IncludeHidden) == U32(0) &&
  90735 							int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_HIDDEN != 0 {
  90736 							continue
  90737 						}
  90738 						if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_NOEXPAND != 0 &&
  90739 							zTName == uintptr(0) &&
  90740 							int32(selFlags)&SF_NestedFrom == 0 {
  90741 							continue
  90742 						}
  90743 						tableSeen = 1
  90744 
  90745 						if i > 0 && zTName == uintptr(0) && int32(selFlags)&SF_NestedFrom == 0 {
  90746 							if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x400>>10)) != 0 &&
  90747 								Xsqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pFrom + 48)), zName) >= 0 {
  90748 								continue
  90749 							}
  90750 						}
  90751 						pRight = Xsqlite3Expr(tls, db, TK_ID, zName)
  90752 						if (*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1 &&
  90753 							(int32((*SrcItem)(unsafe.Pointer(pFrom)).Ffg.Fjointype)&JT_LTORJ == 0 ||
  90754 								int32(selFlags)&SF_NestedFrom != 0 ||
  90755 								!(inAnyUsingClause(tls, zName, pFrom, (*SrcList)(unsafe.Pointer(pTabList)).FnSrc-i-1) != 0)) ||
  90756 							int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  90757 							var pLeft uintptr
  90758 							pLeft = Xsqlite3Expr(tls, db, TK_ID, zTabName)
  90759 							pExpr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pRight)
  90760 							if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && (*Expr)(unsafe.Pointer(pE)).FpLeft != 0 {
  90761 								Xsqlite3RenameTokenRemap(tls, pParse, pLeft, (*Expr)(unsafe.Pointer(pE)).FpLeft)
  90762 							}
  90763 							if zSchemaName != 0 {
  90764 								pLeft = Xsqlite3Expr(tls, db, TK_ID, zSchemaName)
  90765 								pExpr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pExpr)
  90766 							}
  90767 						} else {
  90768 							pExpr = pRight
  90769 						}
  90770 						pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, pExpr)
  90771 						if pNew == uintptr(0) {
  90772 							break
  90773 						}
  90774 						pX = pNew + 8 + uintptr((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1)*20
  90775 
  90776 						if int32(selFlags)&SF_NestedFrom != 0 && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  90777 							if pNestedFrom != 0 {
  90778 								(*ExprList_item)(unsafe.Pointer(pX)).FzEName = Xsqlite3DbStrDup(tls, db, (*ExprList_item)(unsafe.Pointer(pNestedFrom+8+uintptr(j)*20)).FzEName)
  90779 
  90780 							} else {
  90781 								(*ExprList_item)(unsafe.Pointer(pX)).FzEName = Xsqlite3MPrintf(tls, db, ts+19527,
  90782 									libc.VaList(bp+32, zSchemaName, zTabName, zName))
  90783 
  90784 							}
  90785 							libc.SetBitFieldPtr16Uint32(pX+8+4, uint32(ENAME_TAB), 0, 0x3)
  90786 							if uint32(int32(*(*uint16)(unsafe.Pointer(pFrom + 36 + 4))&0x400>>10)) != 0 &&
  90787 								Xsqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pFrom + 48)), zName) >= 0 ||
  90788 								pUsing != 0 && Xsqlite3IdListIndex(tls, pUsing, zName) >= 0 ||
  90789 								int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_NOEXPAND != 0 {
  90790 								libc.SetBitFieldPtr16Uint32(pX+8+4, uint32(1), 8, 0x100)
  90791 							}
  90792 						} else if longNames != 0 {
  90793 							(*ExprList_item)(unsafe.Pointer(pX)).FzEName = Xsqlite3MPrintf(tls, db, ts+12061, libc.VaList(bp+56, zTabName, zName))
  90794 							libc.SetBitFieldPtr16Uint32(pX+8+4, uint32(ENAME_NAME), 0, 0x3)
  90795 						} else {
  90796 							(*ExprList_item)(unsafe.Pointer(pX)).FzEName = Xsqlite3DbStrDup(tls, db, zName)
  90797 							libc.SetBitFieldPtr16Uint32(pX+8+4, uint32(ENAME_NAME), 0, 0x3)
  90798 						}
  90799 					}
  90800 
  90801 				}
  90802 				goto __5
  90803 			__5:
  90804 				i++
  90805 				pFrom += 72
  90806 				goto __4
  90807 				goto __6
  90808 			__6:
  90809 				;
  90810 				if !(tableSeen != 0) {
  90811 					if zTName != 0 {
  90812 						Xsqlite3ErrorMsg(tls, pParse, ts+19536, libc.VaList(bp+72, zTName))
  90813 					} else {
  90814 						Xsqlite3ErrorMsg(tls, pParse, ts+19554, 0)
  90815 					}
  90816 				}
  90817 			}
  90818 		}
  90819 		Xsqlite3ExprListDelete(tls, db, pEList)
  90820 		(*Select)(unsafe.Pointer(p)).FpEList = pNew
  90821 	}
  90822 	if (*Select)(unsafe.Pointer(p)).FpEList != 0 {
  90823 		if (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr > *(*int32)(unsafe.Pointer(db + 120 + 2*4)) {
  90824 			Xsqlite3ErrorMsg(tls, pParse, ts+19574, 0)
  90825 			return WRC_Abort
  90826 		}
  90827 		if elistFlags&U32(EP_HasFunc|EP_Subquery) != U32(0) {
  90828 			*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_ComplexResult)
  90829 		}
  90830 	}
  90831 	return WRC_Continue
  90832 }
  90833 
  90834 func sqlite3SelectExpand(tls *libc.TLS, pParse uintptr, pSelect uintptr) {
  90835 	bp := tls.Alloc(28)
  90836 	defer tls.Free(28)
  90837 
  90838 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  90839 		f func(*libc.TLS, uintptr, uintptr) int32
  90840 	}{Xsqlite3ExprWalkNoop}))
  90841 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  90842 	if (*Parse)(unsafe.Pointer(pParse)).FhasCompound != 0 {
  90843 		(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  90844 			f func(*libc.TLS, uintptr, uintptr) int32
  90845 		}{convertCompoundSelectToSubquery}))
  90846 		(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = uintptr(0)
  90847 		Xsqlite3WalkSelect(tls, bp, pSelect)
  90848 	}
  90849 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  90850 		f func(*libc.TLS, uintptr, uintptr) int32
  90851 	}{selectExpander}))
  90852 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = *(*uintptr)(unsafe.Pointer(&struct {
  90853 		f func(*libc.TLS, uintptr, uintptr)
  90854 	}{Xsqlite3SelectPopWith}))
  90855 	(*Walker)(unsafe.Pointer(bp)).FeCode = U16(0)
  90856 	Xsqlite3WalkSelect(tls, bp, pSelect)
  90857 }
  90858 
  90859 func selectAddSubqueryTypeInfo(tls *libc.TLS, pWalker uintptr, p uintptr) {
  90860 	var pParse uintptr
  90861 	var i int32
  90862 	var pTabList uintptr
  90863 	var pFrom uintptr
  90864 
  90865 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_HasTypeInfo) != 0 {
  90866 		return
  90867 	}
  90868 	*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_HasTypeInfo)
  90869 	pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse
  90870 	pTabList = (*Select)(unsafe.Pointer(p)).FpSrc
  90871 	i = 0
  90872 	pFrom = pTabList + 8
  90873 __1:
  90874 	if !(i < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc) {
  90875 		goto __3
  90876 	}
  90877 	{
  90878 		var pTab uintptr = (*SrcItem)(unsafe.Pointer(pFrom)).FpTab
  90879 
  90880 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Ephemeral) != U32(0) {
  90881 			var pSel uintptr = (*SrcItem)(unsafe.Pointer(pFrom)).FpSelect
  90882 			if pSel != 0 {
  90883 				Xsqlite3SubqueryColumnTypes(tls, pParse, pTab, pSel, uint8(SQLITE_AFF_NONE))
  90884 			}
  90885 		}
  90886 
  90887 	}
  90888 	goto __2
  90889 __2:
  90890 	i++
  90891 	pFrom += 72
  90892 	goto __1
  90893 	goto __3
  90894 __3:
  90895 }
  90896 
  90897 func sqlite3SelectAddTypeInfo(tls *libc.TLS, pParse uintptr, pSelect uintptr) {
  90898 	bp := tls.Alloc(28)
  90899 	defer tls.Free(28)
  90900 
  90901 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
  90902 		f func(*libc.TLS, uintptr, uintptr) int32
  90903 	}{Xsqlite3SelectWalkNoop}))
  90904 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = *(*uintptr)(unsafe.Pointer(&struct {
  90905 		f func(*libc.TLS, uintptr, uintptr)
  90906 	}{selectAddSubqueryTypeInfo}))
  90907 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  90908 		f func(*libc.TLS, uintptr, uintptr) int32
  90909 	}{Xsqlite3ExprWalkNoop}))
  90910 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  90911 	Xsqlite3WalkSelect(tls, bp, pSelect)
  90912 }
  90913 
  90914 // This routine sets up a SELECT statement for processing.  The
  90915 // following is accomplished:
  90916 //
  90917 //   - VDBE Cursor numbers are assigned to all FROM-clause terms.
  90918 //   - Ephemeral Table objects are created for all FROM-clause subqueries.
  90919 //   - ON and USING clauses are shifted into WHERE statements
  90920 //   - Wildcards "*" and "TABLE.*" in result sets are expanded.
  90921 //   - Identifiers in expression are matched to tables.
  90922 //
  90923 // This routine acts recursively on all subqueries within the SELECT.
  90924 func Xsqlite3SelectPrep(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintptr) {
  90925 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
  90926 		return
  90927 	}
  90928 	if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_HasTypeInfo) != 0 {
  90929 		return
  90930 	}
  90931 	sqlite3SelectExpand(tls, pParse, p)
  90932 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  90933 		return
  90934 	}
  90935 	Xsqlite3ResolveSelectNames(tls, pParse, p, pOuterNC)
  90936 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  90937 		return
  90938 	}
  90939 	sqlite3SelectAddTypeInfo(tls, pParse, p)
  90940 }
  90941 
  90942 func analyzeAggFuncArgs(tls *libc.TLS, pAggInfo uintptr, pNC uintptr) {
  90943 	var i int32
  90944 
  90945 	*(*int32)(unsafe.Pointer(pNC + 24)) |= NC_InAggFunc
  90946 	for i = 0; i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc; i++ {
  90947 		var pExpr uintptr = (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*16)).FpFExpr
  90948 
  90949 		Xsqlite3ExprAnalyzeAggList(tls, pNC, *(*uintptr)(unsafe.Pointer(pExpr + 20)))
  90950 
  90951 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  90952 			Xsqlite3ExprAnalyzeAggregates(tls, pNC, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 44)))).FpFilter)
  90953 		}
  90954 	}
  90955 	*(*int32)(unsafe.Pointer(pNC + 24)) &= libc.CplInt32(NC_InAggFunc)
  90956 }
  90957 
  90958 func optimizeAggregateUseOfIndexedExpr(tls *libc.TLS, pParse uintptr, pSelect uintptr, pAggInfo uintptr, pNC uintptr) {
  90959 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn = (*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator
  90960 	if int32((*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn) > 0 {
  90961 		if (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn == 0 {
  90962 			(*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn = U16((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpGroupBy)).FnExpr)
  90963 		} else {
  90964 			(*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn = U16(int32((*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol+uintptr((*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn-1)*16)).FiSorterColumn) + 1)
  90965 		}
  90966 	}
  90967 	analyzeAggFuncArgs(tls, pAggInfo, pNC)
  90968 	_ = pSelect
  90969 	_ = pParse
  90970 }
  90971 
  90972 func aggregateIdxEprRefToColCallback(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  90973 	var pAggInfo uintptr
  90974 	var pCol uintptr
  90975 	_ = pWalker
  90976 	if (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) {
  90977 		return WRC_Continue
  90978 	}
  90979 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN {
  90980 		return WRC_Continue
  90981 	}
  90982 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION {
  90983 		return WRC_Continue
  90984 	}
  90985 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IF_NULL_ROW {
  90986 		return WRC_Continue
  90987 	}
  90988 	pAggInfo = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo
  90989 
  90990 	pCol = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiAgg)*16
  90991 	(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_AGG_COLUMN)
  90992 	(*Expr)(unsafe.Pointer(pExpr)).FiTable = (*AggInfo_col)(unsafe.Pointer(pCol)).FiTable
  90993 	(*Expr)(unsafe.Pointer(pExpr)).FiColumn = (*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn
  90994 	return WRC_Prune
  90995 }
  90996 
  90997 func aggregateConvertIndexedExprRefToColumn(tls *libc.TLS, pAggInfo uintptr) {
  90998 	bp := tls.Alloc(28)
  90999 	defer tls.Free(28)
  91000 
  91001 	var i int32
  91002 
  91003 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  91004 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  91005 		f func(*libc.TLS, uintptr, uintptr) int32
  91006 	}{aggregateIdxEprRefToColCallback}))
  91007 	for i = 0; i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc; i++ {
  91008 		Xsqlite3WalkExpr(tls, bp, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*16)).FpFExpr)
  91009 	}
  91010 }
  91011 
  91012 func assignAggregateRegisters(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) {
  91013 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  91014 	*(*int32)(unsafe.Pointer(pParse + 44)) += (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc
  91015 }
  91016 
  91017 func resetAccumulator(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) {
  91018 	bp := tls.Alloc(8)
  91019 	defer tls.Free(8)
  91020 
  91021 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  91022 	var i int32
  91023 	var pFunc uintptr
  91024 	var nReg int32 = (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc + (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn
  91025 
  91026 	if nReg == 0 {
  91027 		return
  91028 	}
  91029 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  91030 		return
  91031 	}
  91032 	Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg,
  91033 		(*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg+nReg-1)
  91034 	pFunc = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc
  91035 	i = 0
  91036 __1:
  91037 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) {
  91038 		goto __3
  91039 	}
  91040 	{
  91041 		if (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct >= 0 {
  91042 			var pE uintptr = (*AggInfo_func)(unsafe.Pointer(pFunc)).FpFExpr
  91043 
  91044 			if *(*uintptr)(unsafe.Pointer(pE + 20)) == uintptr(0) || (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pE + 20)))).FnExpr != 1 {
  91045 				Xsqlite3ErrorMsg(tls, pParse,
  91046 					ts+19605, 0)
  91047 				(*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct = -1
  91048 			} else {
  91049 				var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, *(*uintptr)(unsafe.Pointer(pE + 20)), 0, 0)
  91050 				(*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistAddr = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral,
  91051 					(*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, pKeyInfo, -8)
  91052 				Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+19656, libc.VaList(bp, (*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pFunc)).FpFunc)).FzName))
  91053 			}
  91054 		}
  91055 
  91056 	}
  91057 	goto __2
  91058 __2:
  91059 	i++
  91060 	pFunc += 16
  91061 	goto __1
  91062 	goto __3
  91063 __3:
  91064 }
  91065 
  91066 func finalizeAggFunctions(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) {
  91067 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  91068 	var i int32
  91069 	var pF uintptr
  91070 	i = 0
  91071 	pF = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc
  91072 __1:
  91073 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) {
  91074 		goto __3
  91075 	}
  91076 	{
  91077 		var pList uintptr
  91078 
  91079 		pList = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 20))
  91080 		Xsqlite3VdbeAddOp2(tls, v, OP_AggFinal, func() int32 {
  91081 			return (*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + i
  91082 		}(),
  91083 			func() int32 {
  91084 				if pList != 0 {
  91085 					return (*ExprList)(unsafe.Pointer(pList)).FnExpr
  91086 				}
  91087 				return 0
  91088 			}())
  91089 		Xsqlite3VdbeAppendP4(tls, v, (*AggInfo_func)(unsafe.Pointer(pF)).FpFunc, -7)
  91090 
  91091 	}
  91092 	goto __2
  91093 __2:
  91094 	i++
  91095 	pF += 16
  91096 	goto __1
  91097 	goto __3
  91098 __3:
  91099 }
  91100 
  91101 func updateAccumulator(tls *libc.TLS, pParse uintptr, regAcc int32, pAggInfo uintptr, eDistinctType int32) {
  91102 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  91103 	var i int32
  91104 	var regHit int32 = 0
  91105 	var addrHitTest int32 = 0
  91106 	var pF uintptr
  91107 	var pC uintptr
  91108 
  91109 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  91110 		return
  91111 	}
  91112 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(1)
  91113 	i = 0
  91114 	pF = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc
  91115 __1:
  91116 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) {
  91117 		goto __3
  91118 	}
  91119 	{
  91120 		var nArg int32
  91121 		var addrNext int32 = 0
  91122 		var regAgg int32
  91123 		var pList uintptr
  91124 
  91125 		pList = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 20))
  91126 		if (*Expr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr)).Fflags&U32(EP_WinFunc) != U32(0) {
  91127 			var pFilter uintptr = (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 44)))).FpFilter
  91128 			if (*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 &&
  91129 				(*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != 0 &&
  91130 				regAcc != 0 {
  91131 				if regHit == 0 {
  91132 					regHit = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  91133 				}
  91134 
  91135 				Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regAcc, regHit)
  91136 			}
  91137 			addrNext = Xsqlite3VdbeMakeLabel(tls, pParse)
  91138 			Xsqlite3ExprIfFalse(tls, pParse, pFilter, addrNext, SQLITE_JUMPIFNULL)
  91139 		}
  91140 		if pList != 0 {
  91141 			nArg = (*ExprList)(unsafe.Pointer(pList)).FnExpr
  91142 			regAgg = Xsqlite3GetTempRange(tls, pParse, nArg)
  91143 			Xsqlite3ExprCodeExprList(tls, pParse, pList, regAgg, 0, uint8(SQLITE_ECEL_DUP))
  91144 		} else {
  91145 			nArg = 0
  91146 			regAgg = 0
  91147 		}
  91148 		if (*AggInfo_func)(unsafe.Pointer(pF)).FiDistinct >= 0 && pList != 0 {
  91149 			if addrNext == 0 {
  91150 				addrNext = Xsqlite3VdbeMakeLabel(tls, pParse)
  91151 			}
  91152 			(*AggInfo_func)(unsafe.Pointer(pF)).FiDistinct = codeDistinct(tls, pParse, eDistinctType,
  91153 				(*AggInfo_func)(unsafe.Pointer(pF)).FiDistinct, addrNext, pList, regAgg)
  91154 		}
  91155 		if (*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != 0 {
  91156 			var pColl uintptr = uintptr(0)
  91157 			var pItem uintptr
  91158 			var j int32
  91159 
  91160 			j = 0
  91161 			pItem = pList + 8
  91162 		__4:
  91163 			if !(!(pColl != 0) && j < nArg) {
  91164 				goto __6
  91165 			}
  91166 			{
  91167 				pColl = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)
  91168 
  91169 			}
  91170 			goto __5
  91171 		__5:
  91172 			j++
  91173 			pItem += 20
  91174 			goto __4
  91175 			goto __6
  91176 		__6:
  91177 			;
  91178 			if !(pColl != 0) {
  91179 				pColl = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl
  91180 			}
  91181 			if regHit == 0 && (*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 {
  91182 				regHit = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  91183 			}
  91184 			Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, regHit, 0, 0, pColl, -2)
  91185 		}
  91186 		Xsqlite3VdbeAddOp3(tls, v, OP_AggStep, 0, regAgg, func() int32 {
  91187 			return (*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + i
  91188 		}())
  91189 		Xsqlite3VdbeAppendP4(tls, v, (*AggInfo_func)(unsafe.Pointer(pF)).FpFunc, -7)
  91190 		Xsqlite3VdbeChangeP5(tls, v, uint16(U8(nArg)))
  91191 		Xsqlite3ReleaseTempRange(tls, pParse, regAgg, nArg)
  91192 		if addrNext != 0 {
  91193 			Xsqlite3VdbeResolveLabel(tls, v, addrNext)
  91194 		}
  91195 
  91196 	}
  91197 	goto __2
  91198 __2:
  91199 	i++
  91200 	pF += 16
  91201 	goto __1
  91202 	goto __3
  91203 __3:
  91204 	;
  91205 	if regHit == 0 && (*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0 {
  91206 		regHit = regAcc
  91207 	}
  91208 	if regHit != 0 {
  91209 		addrHitTest = Xsqlite3VdbeAddOp1(tls, v, OP_If, regHit)
  91210 	}
  91211 	i = 0
  91212 	pC = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol
  91213 __7:
  91214 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator) {
  91215 		goto __9
  91216 	}
  91217 	{
  91218 		Xsqlite3ExprCode(tls, pParse, (*AggInfo_col)(unsafe.Pointer(pC)).FpCExpr, func() int32 { ; return (*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + i }())
  91219 
  91220 	}
  91221 	goto __8
  91222 __8:
  91223 	i++
  91224 	pC += 16
  91225 	goto __7
  91226 	goto __9
  91227 __9:
  91228 	;
  91229 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(0)
  91230 	if addrHitTest != 0 {
  91231 		Xsqlite3VdbeJumpHereOrPopInst(tls, v, addrHitTest)
  91232 	}
  91233 }
  91234 
  91235 func explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintptr) {
  91236 	bp := tls.Alloc(24)
  91237 	defer tls.Free(24)
  91238 
  91239 	if int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) == 2 {
  91240 		var bCover int32 = libc.Bool32(pIdx != uintptr(0) && ((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) || !(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY)))
  91241 		Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+19689,
  91242 			libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName,
  91243 				func() uintptr {
  91244 					if bCover != 0 {
  91245 						return ts + 19701
  91246 					}
  91247 					return ts + 1554
  91248 				}(),
  91249 				func() uintptr {
  91250 					if bCover != 0 {
  91251 						return (*Index)(unsafe.Pointer(pIdx)).FzName
  91252 					}
  91253 					return ts + 1554
  91254 				}()))
  91255 	}
  91256 }
  91257 
  91258 func havingToWhereExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
  91259 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AND {
  91260 		var pS uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
  91261 
  91262 		if Xsqlite3ExprIsConstantOrGroupBy(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, pExpr, (*Select)(unsafe.Pointer(pS)).FpGroupBy) != 0 &&
  91263 			libc.Bool32((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_IsFalse) == U32(EP_IsFalse)) == 0 &&
  91264 			(*Expr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) {
  91265 			var db uintptr = (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(pWalker)).FpParse)).Fdb
  91266 			var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, ts+7938)
  91267 			if pNew != 0 {
  91268 				var pWhere uintptr = (*Select)(unsafe.Pointer(pS)).FpWhere
  91269 				{
  91270 					var t = *(*Expr)(unsafe.Pointer(pNew))
  91271 					*(*Expr)(unsafe.Pointer(pNew)) = *(*Expr)(unsafe.Pointer(pExpr))
  91272 					*(*Expr)(unsafe.Pointer(pExpr)) = t
  91273 				}
  91274 
  91275 				pNew = Xsqlite3ExprAnd(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, pWhere, pNew)
  91276 				(*Select)(unsafe.Pointer(pS)).FpWhere = pNew
  91277 				(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1)
  91278 			}
  91279 		}
  91280 		return WRC_Prune
  91281 	}
  91282 	return WRC_Continue
  91283 }
  91284 
  91285 func havingToWhere(tls *libc.TLS, pParse uintptr, p uintptr) {
  91286 	bp := tls.Alloc(28)
  91287 	defer tls.Free(28)
  91288 
  91289 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
  91290 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
  91291 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
  91292 		f func(*libc.TLS, uintptr, uintptr) int32
  91293 	}{havingToWhereExprCb}))
  91294 	*(*uintptr)(unsafe.Pointer(bp + 24)) = p
  91295 	Xsqlite3WalkExpr(tls, bp, (*Select)(unsafe.Pointer(p)).FpHaving)
  91296 }
  91297 
  91298 func isSelfJoinView(tls *libc.TLS, pTabList uintptr, pThis uintptr, iFirst int32, iEnd int32) uintptr {
  91299 	var pItem uintptr
  91300 
  91301 	if (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pThis)).FpSelect)).FselFlags&U32(SF_PushDown) != 0 {
  91302 		return uintptr(0)
  91303 	}
  91304 	for iFirst < iEnd {
  91305 		var pS1 uintptr
  91306 		pItem = pTabList + 8 + uintptr(libc.PostIncInt32(&iFirst, 1))*72
  91307 		if (*SrcItem)(unsafe.Pointer(pItem)).FpSelect == uintptr(0) {
  91308 			continue
  91309 		}
  91310 		if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x20>>5)) != 0 {
  91311 			continue
  91312 		}
  91313 		if (*SrcItem)(unsafe.Pointer(pItem)).FzName == uintptr(0) {
  91314 			continue
  91315 		}
  91316 
  91317 		if (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpTab)).FpSchema != (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pThis)).FpTab)).FpSchema {
  91318 			continue
  91319 		}
  91320 		if Xsqlite3_stricmp(tls, (*SrcItem)(unsafe.Pointer(pItem)).FzName, (*SrcItem)(unsafe.Pointer(pThis)).FzName) != 0 {
  91321 			continue
  91322 		}
  91323 		pS1 = (*SrcItem)(unsafe.Pointer(pItem)).FpSelect
  91324 		if (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpTab)).FpSchema == uintptr(0) && (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pThis)).FpSelect)).FselId != (*Select)(unsafe.Pointer(pS1)).FselId {
  91325 			continue
  91326 		}
  91327 		if (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpSelect)).FselFlags&U32(SF_PushDown) != 0 {
  91328 			continue
  91329 		}
  91330 		return pItem
  91331 	}
  91332 	return uintptr(0)
  91333 }
  91334 
  91335 func agginfoFree(tls *libc.TLS, db uintptr, p uintptr) {
  91336 	Xsqlite3DbFree(tls, db, (*AggInfo)(unsafe.Pointer(p)).FaCol)
  91337 	Xsqlite3DbFree(tls, db, (*AggInfo)(unsafe.Pointer(p)).FaFunc)
  91338 	Xsqlite3DbFreeNN(tls, db, p)
  91339 }
  91340 
  91341 func sameSrcAlias(tls *libc.TLS, p0 uintptr, pSrc uintptr) int32 {
  91342 	var i int32
  91343 	for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ {
  91344 		var p1 uintptr = pSrc + 8 + uintptr(i)*72
  91345 		if p1 == p0 {
  91346 			continue
  91347 		}
  91348 		if (*SrcItem)(unsafe.Pointer(p0)).FpTab == (*SrcItem)(unsafe.Pointer(p1)).FpTab && 0 == Xsqlite3_stricmp(tls, (*SrcItem)(unsafe.Pointer(p0)).FzAlias, (*SrcItem)(unsafe.Pointer(p1)).FzAlias) {
  91349 			return 1
  91350 		}
  91351 		if (*SrcItem)(unsafe.Pointer(p1)).FpSelect != 0 &&
  91352 			(*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(p1)).FpSelect)).FselFlags&U32(SF_NestedFrom) != U32(0) &&
  91353 			sameSrcAlias(tls, p0, (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(p1)).FpSelect)).FpSrc) != 0 {
  91354 			return 1
  91355 		}
  91356 	}
  91357 	return 0
  91358 }
  91359 
  91360 func fromClauseTermCanBeCoroutine(tls *libc.TLS, pParse uintptr, pTabList uintptr, i int32, selFlags int32) int32 {
  91361 	var pItem uintptr = pTabList + 8 + uintptr(i)*72
  91362 	if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x100>>8)) != 0 {
  91363 		var pCteUse uintptr = *(*uintptr)(unsafe.Pointer(pItem + 68))
  91364 		if int32((*CteUse)(unsafe.Pointer(pCteUse)).FeM10d) == M10d_Yes {
  91365 			return 0
  91366 		}
  91367 		if (*CteUse)(unsafe.Pointer(pCteUse)).FnUse >= 2 && int32((*CteUse)(unsafe.Pointer(pCteUse)).FeM10d) != M10d_No {
  91368 			return 0
  91369 		}
  91370 	}
  91371 	if int32((*SrcItem)(unsafe.Pointer(pTabList+8)).Ffg.Fjointype)&JT_LTORJ != 0 {
  91372 		return 0
  91373 	}
  91374 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_Coroutines) != U32(0) {
  91375 		return 0
  91376 	}
  91377 	if isSelfJoinView(tls, pTabList, pItem, i+1, (*SrcList)(unsafe.Pointer(pTabList)).FnSrc) != uintptr(0) {
  91378 		return 0
  91379 	}
  91380 	if i == 0 {
  91381 		if (*SrcList)(unsafe.Pointer(pTabList)).FnSrc == 1 {
  91382 			return 1
  91383 		}
  91384 		if int32((*SrcItem)(unsafe.Pointer(pTabList+8+1*72)).Ffg.Fjointype)&JT_CROSS != 0 {
  91385 			return 1
  91386 		}
  91387 		if selFlags&SF_UpdateFrom != 0 {
  91388 			return 0
  91389 		}
  91390 		return 1
  91391 	}
  91392 	if selFlags&SF_UpdateFrom != 0 {
  91393 		return 0
  91394 	}
  91395 	for 1 != 0 {
  91396 		if int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(JT_OUTER|JT_CROSS) != 0 {
  91397 			return 0
  91398 		}
  91399 		if i == 0 {
  91400 			break
  91401 		}
  91402 		i--
  91403 		pItem -= 72
  91404 		if (*SrcItem)(unsafe.Pointer(pItem)).FpSelect != uintptr(0) {
  91405 			return 0
  91406 		}
  91407 	}
  91408 	return 1
  91409 }
  91410 
  91411 // Generate code for the SELECT statement given in the p argument.
  91412 //
  91413 // The results are returned according to the SelectDest structure.
  91414 // See comments in sqliteInt.h for further information.
  91415 //
  91416 // This routine returns the number of errors.  If any errors are
  91417 // encountered, then an appropriate error message is left in
  91418 // pParse->zErrMsg.
  91419 //
  91420 // This routine does NOT free the Select structure passed in.  The
  91421 // calling function needs to do that.
  91422 func Xsqlite3Select(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int32 {
  91423 	bp := tls.Alloc(164)
  91424 	defer tls.Free(164)
  91425 
  91426 	var i int32
  91427 	var j int32
  91428 	var pWInfo uintptr
  91429 	var v uintptr
  91430 	var isAgg int32
  91431 	var pEList uintptr
  91432 	var pTabList uintptr
  91433 	var pWhere uintptr
  91434 	var pGroupBy uintptr
  91435 	var pHaving uintptr
  91436 	var pAggInfo uintptr
  91437 	var rc int32
  91438 
  91439 	var iEnd int32
  91440 	var db uintptr
  91441 
  91442 	var minMaxFlag U8
  91443 	var p0 uintptr
  91444 	var pItem uintptr
  91445 	var pSub uintptr
  91446 	var pTab uintptr
  91447 
  91448 	var addrTop int32
  91449 
  91450 	var pCteUse uintptr
  91451 	var pCteUse1 uintptr
  91452 
  91453 	var topAddr int32
  91454 	var onceAddr int32
  91455 	var pItem1 uintptr
  91456 	var pPrior uintptr
  91457 
  91458 	var pSub1 uintptr
  91459 	var zSavedAuthContext uintptr
  91460 	var pKeyInfo uintptr
  91461 
  91462 	var ii int32
  91463 	var addrGosub int32
  91464 	var iCont int32
  91465 	var iBreak int32
  91466 	var regGosub int32
  91467 
  91468 	var wctrlFlags U16
  91469 	var pWin uintptr
  91470 	var sortFlags U8
  91471 	var ii1 int32
  91472 	var k int32
  91473 	var pItem2 uintptr
  91474 	var pExpr uintptr
  91475 	var pCol uintptr
  91476 
  91477 	var regBase int32
  91478 	var regRecord int32
  91479 	var nCol int32
  91480 	var nGroupBy int32
  91481 	var pF uintptr
  91482 	var pKeyInfo1 uintptr
  91483 	var addr1 int32
  91484 	var addrOutputRow int32
  91485 	var regOutputRow int32
  91486 	var addrSetAbort int32
  91487 	var addrTopOfLoop int32
  91488 	var addrSortingIdx int32
  91489 	var addrReset int32
  91490 	var regReset int32
  91491 	var pDistinct uintptr
  91492 	var distFlag U16
  91493 	var eDist int32
  91494 
  91495 	var iDb int32
  91496 	var iCsr int32
  91497 	var pIdx uintptr
  91498 	var pKeyInfo2 uintptr
  91499 	var pBest uintptr
  91500 	var iRoot Pgno
  91501 	var pF1 uintptr
  91502 	var regAcc int32
  91503 	var pDistinct1 uintptr
  91504 	var distFlag1 U16
  91505 	var eDist1 int32
  91506 	var pTab1 uintptr
  91507 
  91508 	var iAMem int32
  91509 	var iBMem int32
  91510 	var iUseFlag int32
  91511 
  91512 	var iAbortFlag int32
  91513 	var groupBySort int32
  91514 	var addrEnd int32
  91515 	var sortPTab int32
  91516 	var sortOut int32
  91517 	var orderByGrp int32
  91518 	pEList = uintptr(0)
  91519 	pAggInfo = uintptr(0)
  91520 	rc = 1
  91521 	*(*uintptr)(unsafe.Pointer(bp + 160)) = uintptr(0)
  91522 
  91523 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  91524 
  91525 	v = Xsqlite3GetVdbe(tls, pParse)
  91526 	if !(p == uintptr(0) || (*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  91527 		goto __1
  91528 	}
  91529 	return 1
  91530 __1:
  91531 	;
  91532 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_SELECT, uintptr(0), uintptr(0), uintptr(0)) != 0) {
  91533 		goto __2
  91534 	}
  91535 	return 1
  91536 __2:
  91537 	;
  91538 	if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) <= SRT_DistQueue) {
  91539 		goto __3
  91540 	}
  91541 
  91542 	if !((*Select)(unsafe.Pointer(p)).FpOrderBy != 0) {
  91543 		goto __4
  91544 	}
  91545 	Xsqlite3ParserAddCleanup(tls, pParse,
  91546 		*(*uintptr)(unsafe.Pointer(&struct {
  91547 			f func(*libc.TLS, uintptr, uintptr)
  91548 		}{Xsqlite3ExprListDelete})),
  91549 		(*Select)(unsafe.Pointer(p)).FpOrderBy)
  91550 
  91551 	(*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0)
  91552 __4:
  91553 	;
  91554 	*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_Distinct))
  91555 	*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_NoopOrderBy)
  91556 __3:
  91557 	;
  91558 	Xsqlite3SelectPrep(tls, pParse, p, uintptr(0))
  91559 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  91560 		goto __5
  91561 	}
  91562 	goto select_end
  91563 __5:
  91564 	;
  91565 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_UFSrcCheck) != 0) {
  91566 		goto __6
  91567 	}
  91568 	p0 = (*Select)(unsafe.Pointer(p)).FpSrc + 8
  91569 	if !(sameSrcAlias(tls, p0, (*Select)(unsafe.Pointer(p)).FpSrc) != 0) {
  91570 		goto __7
  91571 	}
  91572 	Xsqlite3ErrorMsg(tls, pParse,
  91573 		ts+19724,
  91574 		libc.VaList(bp, func() uintptr {
  91575 			if (*SrcItem)(unsafe.Pointer(p0)).FzAlias != 0 {
  91576 				return (*SrcItem)(unsafe.Pointer(p0)).FzAlias
  91577 			}
  91578 			return (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(p0)).FpTab)).FzName
  91579 		}()))
  91580 	goto select_end
  91581 __7:
  91582 	;
  91583 	*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_UFSrcCheck))
  91584 __6:
  91585 	;
  91586 	if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == SRT_Output) {
  91587 		goto __8
  91588 	}
  91589 	Xsqlite3GenerateColumnNames(tls, pParse, p)
  91590 __8:
  91591 	;
  91592 	if !(Xsqlite3WindowRewrite(tls, pParse, p) != 0) {
  91593 		goto __9
  91594 	}
  91595 
  91596 	goto select_end
  91597 __9:
  91598 	;
  91599 	pTabList = (*Select)(unsafe.Pointer(p)).FpSrc
  91600 	isAgg = libc.Bool32((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Aggregate) != U32(0))
  91601 	libc.Xmemset(tls, bp+48, 0, uint32(unsafe.Sizeof(SortCtx{})))
  91602 	(*SortCtx)(unsafe.Pointer(bp + 48)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy
  91603 
  91604 	i = 0
  91605 __10:
  91606 	if !(!(int32((*Select)(unsafe.Pointer(p)).FpPrior) != 0) && i < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc) {
  91607 		goto __12
  91608 	}
  91609 	pItem = pTabList + 8 + uintptr(i)*72
  91610 	pSub = (*SrcItem)(unsafe.Pointer(pItem)).FpSelect
  91611 	pTab = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
  91612 
  91613 	if !(int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(JT_LEFT|JT_RIGHT) == JT_LEFT &&
  91614 		Xsqlite3ExprImpliesNonNullRow(tls, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcItem)(unsafe.Pointer(pItem)).FiCursor) != 0 &&
  91615 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_SimplifyJoin) == U32(0)) {
  91616 		goto __13
  91617 	}
  91618 
  91619 	*(*U8)(unsafe.Pointer(pItem + 36)) &= libc.Uint8FromInt32(libc.CplInt32(JT_LEFT | JT_OUTER))
  91620 
  91621 	unsetJoinExpr(tls, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcItem)(unsafe.Pointer(pItem)).FiCursor,
  91622 		int32((*SrcItem)(unsafe.Pointer(pTabList+8)).Ffg.Fjointype)&JT_LTORJ)
  91623 __13:
  91624 	;
  91625 	if !(pSub == uintptr(0)) {
  91626 		goto __14
  91627 	}
  91628 	goto __11
  91629 __14:
  91630 	;
  91631 	if !(int32((*Table)(unsafe.Pointer(pTab)).FnCol) != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub)).FpEList)).FnExpr) {
  91632 		goto __15
  91633 	}
  91634 	Xsqlite3ErrorMsg(tls, pParse, ts+19778,
  91635 		libc.VaList(bp+8, int32((*Table)(unsafe.Pointer(pTab)).FnCol), (*Table)(unsafe.Pointer(pTab)).FzName, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub)).FpEList)).FnExpr))
  91636 	goto select_end
  91637 __15:
  91638 	;
  91639 	if !((*Select)(unsafe.Pointer(pSub)).FselFlags&U32(SF_Aggregate) != U32(0)) {
  91640 		goto __16
  91641 	}
  91642 	goto __11
  91643 __16:
  91644 	;
  91645 	if !((*Select)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0) &&
  91646 		((*Select)(unsafe.Pointer(p)).FpOrderBy != uintptr(0) || (*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1) &&
  91647 		(*Select)(unsafe.Pointer(pSub)).FpLimit == uintptr(0) &&
  91648 		(*Select)(unsafe.Pointer(pSub)).FselFlags&U32(SF_OrderByReqd) == U32(0) &&
  91649 		(*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_OrderByReqd) == U32(0) &&
  91650 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_OmitOrderBy) == U32(0)) {
  91651 		goto __17
  91652 	}
  91653 
  91654 	Xsqlite3ParserAddCleanup(tls, pParse,
  91655 		*(*uintptr)(unsafe.Pointer(&struct {
  91656 			f func(*libc.TLS, uintptr, uintptr)
  91657 		}{Xsqlite3ExprListDelete})),
  91658 		(*Select)(unsafe.Pointer(pSub)).FpOrderBy)
  91659 	(*Select)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0)
  91660 __17:
  91661 	;
  91662 	if !((*Select)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0) &&
  91663 		i == 0 &&
  91664 		(*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_ComplexResult) != U32(0) &&
  91665 		((*SrcList)(unsafe.Pointer(pTabList)).FnSrc == 1 ||
  91666 			int32((*SrcItem)(unsafe.Pointer(pTabList+8+1*72)).Ffg.Fjointype)&(JT_OUTER|JT_CROSS) != 0)) {
  91667 		goto __18
  91668 	}
  91669 	goto __11
  91670 __18:
  91671 	;
  91672 	if !(flattenSubquery(tls, pParse, p, i, isAgg) != 0) {
  91673 		goto __19
  91674 	}
  91675 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  91676 		goto __20
  91677 	}
  91678 	goto select_end
  91679 __20:
  91680 	;
  91681 	i = -1
  91682 __19:
  91683 	;
  91684 	pTabList = (*Select)(unsafe.Pointer(p)).FpSrc
  91685 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  91686 		goto __21
  91687 	}
  91688 	goto select_end
  91689 __21:
  91690 	;
  91691 	if !!(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) <= SRT_Fifo) {
  91692 		goto __22
  91693 	}
  91694 	(*SortCtx)(unsafe.Pointer(bp + 48)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy
  91695 __22:
  91696 	;
  91697 	goto __11
  91698 __11:
  91699 	i++
  91700 	goto __10
  91701 	goto __12
  91702 __12:
  91703 	;
  91704 	if !((*Select)(unsafe.Pointer(p)).FpPrior != 0) {
  91705 		goto __23
  91706 	}
  91707 	rc = multiSelect(tls, pParse, p, pDest)
  91708 	if !((*Select)(unsafe.Pointer(p)).FpNext == uintptr(0)) {
  91709 		goto __24
  91710 	}
  91711 	Xsqlite3VdbeExplainPop(tls, pParse)
  91712 __24:
  91713 	;
  91714 	return rc
  91715 __23:
  91716 	;
  91717 	if !((*Select)(unsafe.Pointer(p)).FpWhere != uintptr(0) &&
  91718 		int32((*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpWhere)).Fop) == TK_AND &&
  91719 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_PropagateConst) == U32(0) &&
  91720 		propagateConstants(tls, pParse, p) != 0) {
  91721 		goto __25
  91722 	}
  91723 	goto __26
  91724 __25:
  91725 	;
  91726 __26:
  91727 	;
  91728 	i = 0
  91729 __27:
  91730 	if !(i < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc) {
  91731 		goto __29
  91732 	}
  91733 	pItem1 = pTabList + 8 + uintptr(i)*72
  91734 
  91735 	if !((*SrcItem)(unsafe.Pointer(pItem1)).FcolUsed == uint64(0) && (*SrcItem)(unsafe.Pointer(pItem1)).FzName != uintptr(0)) {
  91736 		goto __30
  91737 	}
  91738 	Xsqlite3AuthCheck(tls, pParse, SQLITE_READ, (*SrcItem)(unsafe.Pointer(pItem1)).FzName, ts+1554, (*SrcItem)(unsafe.Pointer(pItem1)).FzDatabase)
  91739 __30:
  91740 	;
  91741 	pSub1 = (*SrcItem)(unsafe.Pointer(pItem1)).FpSelect
  91742 	if !(pSub1 == uintptr(0)) {
  91743 		goto __31
  91744 	}
  91745 	goto __28
  91746 __31:
  91747 	;
  91748 	*(*int32)(unsafe.Pointer(pParse + 224)) += Xsqlite3SelectExprHeight(tls, p)
  91749 
  91750 	if !((*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_PushDown) == U32(0) &&
  91751 		(int32(*(*uint16)(unsafe.Pointer(pItem1 + 36 + 4))&0x100>>8) == 0 ||
  91752 			int32((*CteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 68)))).FeM10d) != M10d_Yes && (*CteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 68)))).FnUse < 2) &&
  91753 		pushDownWhereTerms(tls, pParse, pSub1, (*Select)(unsafe.Pointer(p)).FpWhere, pItem1) != 0) {
  91754 		goto __32
  91755 	}
  91756 
  91757 	goto __33
  91758 __32:
  91759 	;
  91760 __33:
  91761 	;
  91762 	zSavedAuthContext = (*Parse)(unsafe.Pointer(pParse)).FzAuthContext
  91763 	(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = (*SrcItem)(unsafe.Pointer(pItem1)).FzName
  91764 
  91765 	if !(fromClauseTermCanBeCoroutine(tls, pParse, pTabList, i, int32((*Select)(unsafe.Pointer(p)).FselFlags)) != 0) {
  91766 		goto __34
  91767 	}
  91768 
  91769 	addrTop = Xsqlite3VdbeCurrentAddr(tls, v) + 1
  91770 
  91771 	(*SrcItem)(unsafe.Pointer(pItem1)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  91772 	Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, (*SrcItem)(unsafe.Pointer(pItem1)).FregReturn, 0, addrTop)
  91773 
  91774 	(*SrcItem)(unsafe.Pointer(pItem1)).FaddrFillSub = addrTop
  91775 	Xsqlite3SelectDestInit(tls, bp+88, SRT_Coroutine, (*SrcItem)(unsafe.Pointer(pItem1)).FregReturn)
  91776 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19818, libc.VaList(bp+32, pItem1))
  91777 	Xsqlite3Select(tls, pParse, pSub1, bp+88)
  91778 	(*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem1)).FpTab)).FnRowLogEst = (*Select)(unsafe.Pointer(pSub1)).FnSelectRow
  91779 	libc.SetBitFieldPtr16Uint32(pItem1+36+4, uint32(1), 5, 0x20)
  91780 	(*SrcItem)(unsafe.Pointer(pItem1)).FregResult = (*SelectDest)(unsafe.Pointer(bp + 88)).FiSdst
  91781 	Xsqlite3VdbeEndCoroutine(tls, v, (*SrcItem)(unsafe.Pointer(pItem1)).FregReturn)
  91782 	Xsqlite3VdbeJumpHere(tls, v, addrTop-1)
  91783 	Xsqlite3ClearTempRegCache(tls, pParse)
  91784 	goto __35
  91785 __34:
  91786 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pItem1 + 36 + 4))&0x100>>8)) != 0 && (*CteUse)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem1 + 68)))).FaddrM9e > 0) {
  91787 		goto __36
  91788 	}
  91789 
  91790 	pCteUse = *(*uintptr)(unsafe.Pointer(pItem1 + 68))
  91791 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*CteUse)(unsafe.Pointer(pCteUse)).FregRtn, (*CteUse)(unsafe.Pointer(pCteUse)).FaddrM9e)
  91792 	if !((*SrcItem)(unsafe.Pointer(pItem1)).FiCursor != (*CteUse)(unsafe.Pointer(pCteUse)).FiCur) {
  91793 		goto __38
  91794 	}
  91795 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*SrcItem)(unsafe.Pointer(pItem1)).FiCursor, (*CteUse)(unsafe.Pointer(pCteUse)).FiCur)
  91796 
  91797 __38:
  91798 	;
  91799 	(*Select)(unsafe.Pointer(pSub1)).FnSelectRow = (*CteUse)(unsafe.Pointer(pCteUse)).FnRowEst
  91800 	goto __37
  91801 __36:
  91802 	if !(libc.AssignUintptr(&pPrior, isSelfJoinView(tls, pTabList, pItem1, 0, i)) != uintptr(0)) {
  91803 		goto __39
  91804 	}
  91805 
  91806 	if !((*SrcItem)(unsafe.Pointer(pPrior)).FaddrFillSub != 0) {
  91807 		goto __41
  91808 	}
  91809 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SrcItem)(unsafe.Pointer(pPrior)).FregReturn, (*SrcItem)(unsafe.Pointer(pPrior)).FaddrFillSub)
  91810 __41:
  91811 	;
  91812 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*SrcItem)(unsafe.Pointer(pItem1)).FiCursor, (*SrcItem)(unsafe.Pointer(pPrior)).FiCursor)
  91813 	(*Select)(unsafe.Pointer(pSub1)).FnSelectRow = (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pPrior)).FpSelect)).FnSelectRow
  91814 	goto __40
  91815 __39:
  91816 	onceAddr = 0
  91817 
  91818 	(*SrcItem)(unsafe.Pointer(pItem1)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  91819 	topAddr = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  91820 	(*SrcItem)(unsafe.Pointer(pItem1)).FaddrFillSub = topAddr + 1
  91821 	libc.SetBitFieldPtr16Uint32(pItem1+36+4, uint32(1), 4, 0x10)
  91822 	if !(int32(*(*uint16)(unsafe.Pointer(pItem1 + 36 + 4))&0x8>>3) == 0) {
  91823 		goto __42
  91824 	}
  91825 
  91826 	onceAddr = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  91827 
  91828 	goto __43
  91829 __42:
  91830 	;
  91831 __43:
  91832 	;
  91833 	Xsqlite3SelectDestInit(tls, bp+88, SRT_EphemTab, (*SrcItem)(unsafe.Pointer(pItem1)).FiCursor)
  91834 
  91835 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19833, libc.VaList(bp+40, pItem1))
  91836 	Xsqlite3Select(tls, pParse, pSub1, bp+88)
  91837 	(*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem1)).FpTab)).FnRowLogEst = (*Select)(unsafe.Pointer(pSub1)).FnSelectRow
  91838 	if !(onceAddr != 0) {
  91839 		goto __44
  91840 	}
  91841 	Xsqlite3VdbeJumpHere(tls, v, onceAddr)
  91842 __44:
  91843 	;
  91844 	Xsqlite3VdbeAddOp2(tls, v, OP_Return, (*SrcItem)(unsafe.Pointer(pItem1)).FregReturn, topAddr+1)
  91845 
  91846 	Xsqlite3VdbeJumpHere(tls, v, topAddr)
  91847 	Xsqlite3ClearTempRegCache(tls, pParse)
  91848 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pItem1 + 36 + 4))&0x100>>8)) != 0 && int32(*(*uint16)(unsafe.Pointer(pItem1 + 36 + 4))&0x8>>3) == 0) {
  91849 		goto __45
  91850 	}
  91851 	pCteUse1 = *(*uintptr)(unsafe.Pointer(pItem1 + 68))
  91852 	(*CteUse)(unsafe.Pointer(pCteUse1)).FaddrM9e = (*SrcItem)(unsafe.Pointer(pItem1)).FaddrFillSub
  91853 	(*CteUse)(unsafe.Pointer(pCteUse1)).FregRtn = (*SrcItem)(unsafe.Pointer(pItem1)).FregReturn
  91854 	(*CteUse)(unsafe.Pointer(pCteUse1)).FiCur = (*SrcItem)(unsafe.Pointer(pItem1)).FiCursor
  91855 	(*CteUse)(unsafe.Pointer(pCteUse1)).FnRowEst = (*Select)(unsafe.Pointer(pSub1)).FnSelectRow
  91856 __45:
  91857 	;
  91858 __40:
  91859 	;
  91860 __37:
  91861 	;
  91862 __35:
  91863 	;
  91864 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  91865 		goto __46
  91866 	}
  91867 	goto select_end
  91868 __46:
  91869 	;
  91870 	*(*int32)(unsafe.Pointer(pParse + 224)) -= Xsqlite3SelectExprHeight(tls, p)
  91871 	(*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext
  91872 	goto __28
  91873 __28:
  91874 	i++
  91875 	goto __27
  91876 	goto __29
  91877 __29:
  91878 	;
  91879 	pEList = (*Select)(unsafe.Pointer(p)).FpEList
  91880 	pWhere = (*Select)(unsafe.Pointer(p)).FpWhere
  91881 	pGroupBy = (*Select)(unsafe.Pointer(p)).FpGroupBy
  91882 	pHaving = (*Select)(unsafe.Pointer(p)).FpHaving
  91883 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FisTnct = U8(libc.Bool32((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct) != U32(0)))
  91884 
  91885 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct|SF_Aggregate) == U32(SF_Distinct) &&
  91886 		Xsqlite3ExprListCompare(tls, (*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy, pEList, -1) == 0 &&
  91887 		(*Select)(unsafe.Pointer(p)).FpWin == uintptr(0)) {
  91888 		goto __47
  91889 	}
  91890 	*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_Distinct))
  91891 	pGroupBy = libc.AssignPtrUintptr(p+40, Xsqlite3ExprListDup(tls, db, pEList, 0))
  91892 	*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_Aggregate)
  91893 
  91894 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FisTnct = U8(2)
  91895 
  91896 __47:
  91897 	;
  91898 	if !((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy != 0) {
  91899 		goto __48
  91900 	}
  91901 	pKeyInfo = Xsqlite3KeyInfoFromExprList(tls,
  91902 		pParse, (*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy, 0, (*ExprList)(unsafe.Pointer(pEList)).FnExpr)
  91903 	(*SortCtx)(unsafe.Pointer(bp + 48)).FiECursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  91904 	(*SortCtx)(unsafe.Pointer(bp + 48)).FaddrSortIndex = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral,
  91905 		(*SortCtx)(unsafe.Pointer(bp+48)).FiECursor, (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy)).FnExpr+1+(*ExprList)(unsafe.Pointer(pEList)).FnExpr, 0,
  91906 		pKeyInfo, -8)
  91907 	goto __49
  91908 __48:
  91909 	(*SortCtx)(unsafe.Pointer(bp + 48)).FaddrSortIndex = -1
  91910 __49:
  91911 	;
  91912 	if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == SRT_EphemTab) {
  91913 		goto __50
  91914 	}
  91915 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*ExprList)(unsafe.Pointer(pEList)).FnExpr)
  91916 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_NestedFrom) != 0) {
  91917 		goto __51
  91918 	}
  91919 	ii = (*ExprList)(unsafe.Pointer(pEList)).FnExpr - 1
  91920 __52:
  91921 	if !(ii > 0 && int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(ii)*20 + 8 + 4))&0x40>>6) == 0) {
  91922 		goto __54
  91923 	}
  91924 	Xsqlite3ExprDelete(tls, db, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(ii)*20)).FpExpr)
  91925 	Xsqlite3DbFree(tls, db, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(ii)*20)).FzEName)
  91926 	(*ExprList)(unsafe.Pointer(pEList)).FnExpr--
  91927 	goto __53
  91928 __53:
  91929 	ii--
  91930 	goto __52
  91931 	goto __54
  91932 __54:
  91933 	;
  91934 	ii = 0
  91935 __55:
  91936 	if !(ii < (*ExprList)(unsafe.Pointer(pEList)).FnExpr) {
  91937 		goto __57
  91938 	}
  91939 	if !(int32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(ii)*20 + 8 + 4))&0x40>>6) == 0) {
  91940 		goto __58
  91941 	}
  91942 	(*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(ii)*20)).FpExpr)).Fop = U8(TK_NULL)
  91943 __58:
  91944 	;
  91945 	goto __56
  91946 __56:
  91947 	ii++
  91948 	goto __55
  91949 	goto __57
  91950 __57:
  91951 	;
  91952 __51:
  91953 	;
  91954 __50:
  91955 	;
  91956 	iEnd = Xsqlite3VdbeMakeLabel(tls, pParse)
  91957 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_FixedLimit) == U32(0)) {
  91958 		goto __59
  91959 	}
  91960 	(*Select)(unsafe.Pointer(p)).FnSelectRow = int16(320)
  91961 __59:
  91962 	;
  91963 	if !((*Select)(unsafe.Pointer(p)).FpLimit != 0) {
  91964 		goto __60
  91965 	}
  91966 	computeLimitRegisters(tls, pParse, p, iEnd)
  91967 __60:
  91968 	;
  91969 	if !((*Select)(unsafe.Pointer(p)).FiLimit == 0 && (*SortCtx)(unsafe.Pointer(bp+48)).FaddrSortIndex >= 0) {
  91970 		goto __61
  91971 	}
  91972 	Xsqlite3VdbeChangeOpcode(tls, v, (*SortCtx)(unsafe.Pointer(bp+48)).FaddrSortIndex, uint8(OP_SorterOpen))
  91973 	*(*U8)(unsafe.Pointer(bp + 48 + 32)) |= U8(SORTFLAG_UseSorter)
  91974 __61:
  91975 	;
  91976 	if !((*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct) != 0) {
  91977 		goto __62
  91978 	}
  91979 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FtabTnct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  91980 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FaddrTnct = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral,
  91981 		(*DistinctCtx)(unsafe.Pointer(bp+116)).FtabTnct, 0, 0,
  91982 		Xsqlite3KeyInfoFromExprList(tls, pParse, (*Select)(unsafe.Pointer(p)).FpEList, 0, 0),
  91983 		-8)
  91984 	Xsqlite3VdbeChangeP5(tls, v, uint16(BTREE_UNORDERED))
  91985 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FeTnctType = U8(WHERE_DISTINCT_UNORDERED)
  91986 	goto __63
  91987 __62:
  91988 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FeTnctType = U8(WHERE_DISTINCT_NOOP)
  91989 __63:
  91990 	;
  91991 	if !(!(isAgg != 0) && pGroupBy == uintptr(0)) {
  91992 		goto __64
  91993 	}
  91994 
  91995 	wctrlFlags = U16(func() uint32 {
  91996 		if (*DistinctCtx)(unsafe.Pointer(bp+116)).FisTnct != 0 {
  91997 			return uint32(WHERE_WANT_DISTINCT)
  91998 		}
  91999 		return uint32(0)
  92000 	}() |
  92001 		(*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_FixedLimit))
  92002 	pWin = (*Select)(unsafe.Pointer(p)).FpWin
  92003 	if !(pWin != 0) {
  92004 		goto __66
  92005 	}
  92006 	Xsqlite3WindowCodeInit(tls, pParse, p)
  92007 __66:
  92008 	;
  92009 	pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, (*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy,
  92010 		(*Select)(unsafe.Pointer(p)).FpEList, p, wctrlFlags, int32((*Select)(unsafe.Pointer(p)).FnSelectRow))
  92011 	if !(pWInfo == uintptr(0)) {
  92012 		goto __67
  92013 	}
  92014 	goto select_end
  92015 __67:
  92016 	;
  92017 	if !(int32(Xsqlite3WhereOutputRowCount(tls, pWInfo)) < int32((*Select)(unsafe.Pointer(p)).FnSelectRow)) {
  92018 		goto __68
  92019 	}
  92020 	(*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3WhereOutputRowCount(tls, pWInfo)
  92021 __68:
  92022 	;
  92023 	if !((*DistinctCtx)(unsafe.Pointer(bp+116)).FisTnct != 0 && Xsqlite3WhereIsDistinct(tls, pWInfo) != 0) {
  92024 		goto __69
  92025 	}
  92026 	(*DistinctCtx)(unsafe.Pointer(bp + 116)).FeTnctType = U8(Xsqlite3WhereIsDistinct(tls, pWInfo))
  92027 __69:
  92028 	;
  92029 	if !((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy != 0) {
  92030 		goto __70
  92031 	}
  92032 	(*SortCtx)(unsafe.Pointer(bp + 48)).FnOBSat = Xsqlite3WhereIsOrdered(tls, pWInfo)
  92033 	(*SortCtx)(unsafe.Pointer(bp + 48)).FlabelOBLopt = Xsqlite3WhereOrderByLimitOptLabel(tls, pWInfo)
  92034 	if !((*SortCtx)(unsafe.Pointer(bp+48)).FnOBSat == (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy)).FnExpr) {
  92035 		goto __71
  92036 	}
  92037 	(*SortCtx)(unsafe.Pointer(bp + 48)).FpOrderBy = uintptr(0)
  92038 __71:
  92039 	;
  92040 __70:
  92041 	;
  92042 	if !((*SortCtx)(unsafe.Pointer(bp+48)).FaddrSortIndex >= 0 && (*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy == uintptr(0)) {
  92043 		goto __72
  92044 	}
  92045 	Xsqlite3VdbeChangeToNoop(tls, v, (*SortCtx)(unsafe.Pointer(bp+48)).FaddrSortIndex)
  92046 __72:
  92047 	;
  92048 	if !(pWin != 0) {
  92049 		goto __73
  92050 	}
  92051 	addrGosub = Xsqlite3VdbeMakeLabel(tls, pParse)
  92052 	iCont = Xsqlite3VdbeMakeLabel(tls, pParse)
  92053 	iBreak = Xsqlite3VdbeMakeLabel(tls, pParse)
  92054 	regGosub = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  92055 
  92056 	Xsqlite3WindowCodeStep(tls, pParse, p, pWInfo, regGosub, addrGosub)
  92057 
  92058 	Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, iBreak)
  92059 	Xsqlite3VdbeResolveLabel(tls, v, addrGosub)
  92060 
  92061 	(*SortCtx)(unsafe.Pointer(bp + 48)).FlabelOBLopt = 0
  92062 	selectInnerLoop(tls, pParse, p, -1, bp+48, bp+116, pDest, iCont, iBreak)
  92063 	Xsqlite3VdbeResolveLabel(tls, v, iCont)
  92064 	Xsqlite3VdbeAddOp1(tls, v, OP_Return, regGosub)
  92065 
  92066 	Xsqlite3VdbeResolveLabel(tls, v, iBreak)
  92067 	goto __74
  92068 __73:
  92069 	selectInnerLoop(tls, pParse, p, -1, bp+48, bp+116, pDest,
  92070 		Xsqlite3WhereContinueLabel(tls, pWInfo),
  92071 		Xsqlite3WhereBreakLabel(tls, pWInfo))
  92072 
  92073 	Xsqlite3WhereEnd(tls, pWInfo)
  92074 __74:
  92075 	;
  92076 	goto __65
  92077 __64:
  92078 	sortPTab = 0
  92079 	sortOut = 0
  92080 	orderByGrp = 0
  92081 
  92082 	if !(pGroupBy != 0) {
  92083 		goto __75
  92084 	}
  92085 
  92086 	k = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr
  92087 	pItem2 = (*Select)(unsafe.Pointer(p)).FpEList + 8
  92088 __77:
  92089 	if !(k > 0) {
  92090 		goto __79
  92091 	}
  92092 	*(*U16)(unsafe.Pointer(pItem2 + 16 + 2)) = U16(0)
  92093 	goto __78
  92094 __78:
  92095 	k--
  92096 	pItem2 += 20
  92097 	goto __77
  92098 	goto __79
  92099 __79:
  92100 	;
  92101 	k = (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr
  92102 	pItem2 = pGroupBy + 8
  92103 __80:
  92104 	if !(k > 0) {
  92105 		goto __82
  92106 	}
  92107 	*(*U16)(unsafe.Pointer(pItem2 + 16 + 2)) = U16(0)
  92108 	goto __81
  92109 __81:
  92110 	k--
  92111 	pItem2 += 20
  92112 	goto __80
  92113 	goto __82
  92114 __82:
  92115 	;
  92116 	if !(int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > 66) {
  92117 		goto __83
  92118 	}
  92119 	(*Select)(unsafe.Pointer(p)).FnSelectRow = int16(66)
  92120 __83:
  92121 	;
  92122 	if !((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy != 0 && (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr == (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy)).FnExpr) {
  92123 		goto __84
  92124 	}
  92125 
  92126 	ii1 = 0
  92127 __85:
  92128 	if !(ii1 < (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) {
  92129 		goto __87
  92130 	}
  92131 	sortFlags = U8(int32((*ExprList_item)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy+8+uintptr(ii1)*20)).Ffg.FsortFlags) & KEYINFO_ORDER_DESC)
  92132 	(*ExprList_item)(unsafe.Pointer(pGroupBy + 8 + uintptr(ii1)*20)).Ffg.FsortFlags = sortFlags
  92133 	goto __86
  92134 __86:
  92135 	ii1++
  92136 	goto __85
  92137 	goto __87
  92138 __87:
  92139 	;
  92140 	if !(Xsqlite3ExprListCompare(tls, pGroupBy, (*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy, -1) == 0) {
  92141 		goto __88
  92142 	}
  92143 	orderByGrp = 1
  92144 __88:
  92145 	;
  92146 __84:
  92147 	;
  92148 	goto __76
  92149 __75:
  92150 	;
  92151 	(*Select)(unsafe.Pointer(p)).FnSelectRow = int16(0)
  92152 __76:
  92153 	;
  92154 	addrEnd = Xsqlite3VdbeMakeLabel(tls, pParse)
  92155 
  92156 	pAggInfo = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(AggInfo{})))
  92157 	if !(pAggInfo != 0) {
  92158 		goto __89
  92159 	}
  92160 	Xsqlite3ParserAddCleanup(tls, pParse,
  92161 		*(*uintptr)(unsafe.Pointer(&struct {
  92162 			f func(*libc.TLS, uintptr, uintptr)
  92163 		}{agginfoFree})), pAggInfo)
  92164 
  92165 __89:
  92166 	;
  92167 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  92168 		goto __90
  92169 	}
  92170 	goto select_end
  92171 __90:
  92172 	;
  92173 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FselId = (*Select)(unsafe.Pointer(p)).FselId
  92174 	libc.Xmemset(tls, bp+128, 0, uint32(unsafe.Sizeof(NameContext{})))
  92175 	(*NameContext)(unsafe.Pointer(bp + 128)).FpParse = pParse
  92176 	(*NameContext)(unsafe.Pointer(bp + 128)).FpSrcList = pTabList
  92177 	*(*uintptr)(unsafe.Pointer(bp + 128 + 8)) = pAggInfo
  92178 
  92179 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn = func() uint16 {
  92180 		if pGroupBy != 0 {
  92181 			return uint16((*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr)
  92182 		}
  92183 		return uint16(0)
  92184 	}()
  92185 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FpGroupBy = pGroupBy
  92186 	Xsqlite3ExprAnalyzeAggList(tls, bp+128, pEList)
  92187 	Xsqlite3ExprAnalyzeAggList(tls, bp+128, (*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy)
  92188 	if !(pHaving != 0) {
  92189 		goto __91
  92190 	}
  92191 	if !(pGroupBy != 0) {
  92192 		goto __92
  92193 	}
  92194 
  92195 	havingToWhere(tls, pParse, p)
  92196 	pWhere = (*Select)(unsafe.Pointer(p)).FpWhere
  92197 __92:
  92198 	;
  92199 	Xsqlite3ExprAnalyzeAggregates(tls, bp+128, pHaving)
  92200 __91:
  92201 	;
  92202 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator = (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn
  92203 	if !((*Select)(unsafe.Pointer(p)).FpGroupBy == uintptr(0) && (*Select)(unsafe.Pointer(p)).FpHaving == uintptr(0) && (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 1) {
  92204 		goto __93
  92205 	}
  92206 	minMaxFlag = minMaxQuery(tls, db, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr, bp+160)
  92207 	goto __94
  92208 __93:
  92209 	minMaxFlag = U8(WHERE_ORDERBY_NORMAL)
  92210 __94:
  92211 	;
  92212 	analyzeAggFuncArgs(tls, pAggInfo, bp+128)
  92213 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  92214 		goto __95
  92215 	}
  92216 	goto select_end
  92217 __95:
  92218 	;
  92219 	if !(pGroupBy != 0) {
  92220 		goto __96
  92221 	}
  92222 	pDistinct = uintptr(0)
  92223 	distFlag = U16(0)
  92224 	eDist = WHERE_DISTINCT_NOOP
  92225 
  92226 	if !((*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 1 &&
  92227 		(*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FiDistinct >= 0 &&
  92228 		(*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr != uintptr(0) &&
  92229 		(*Expr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr)).Fflags&U32(EP_xIsSelect) == U32(0) &&
  92230 		*(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr + 20)) != uintptr(0)) {
  92231 		goto __98
  92232 	}
  92233 	pExpr = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr + 20)) + 8)).FpExpr
  92234 	pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0)
  92235 	pDistinct = Xsqlite3ExprListDup(tls, db, pGroupBy, 0)
  92236 	pDistinct = Xsqlite3ExprListAppend(tls, pParse, pDistinct, pExpr)
  92237 	if pDistinct != 0 {
  92238 		distFlag = uint16(WHERE_WANT_DISTINCT | WHERE_AGG_DISTINCT)
  92239 	} else {
  92240 		distFlag = uint16(0)
  92241 	}
  92242 __98:
  92243 	;
  92244 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  92245 	pKeyInfo1 = Xsqlite3KeyInfoFromExprList(tls, pParse, pGroupBy,
  92246 		0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn)
  92247 	addrSortingIdx = Xsqlite3VdbeAddOp4(tls, v, OP_SorterOpen,
  92248 		(*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, int32((*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn),
  92249 		0, pKeyInfo1, -8)
  92250 
  92251 	iUseFlag = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  92252 	iAbortFlag = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  92253 	regOutputRow = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  92254 	addrOutputRow = Xsqlite3VdbeMakeLabel(tls, pParse)
  92255 	regReset = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  92256 	addrReset = Xsqlite3VdbeMakeLabel(tls, pParse)
  92257 	iAMem = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  92258 	*(*int32)(unsafe.Pointer(pParse + 44)) += (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr
  92259 	iBMem = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  92260 	*(*int32)(unsafe.Pointer(pParse + 44)) += (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr
  92261 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, iAbortFlag)
  92262 
  92263 	Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, iAMem, iAMem+(*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr-1)
  92264 
  92265 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReset, addrReset)
  92266 
  92267 	pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, pGroupBy, pDistinct,
  92268 		p, uint16(func() int32 {
  92269 			if int32((*DistinctCtx)(unsafe.Pointer(bp+116)).FisTnct) == 2 {
  92270 				return WHERE_DISTINCTBY
  92271 			}
  92272 			return WHERE_GROUPBY
  92273 		}()|
  92274 			func() int32 {
  92275 				if orderByGrp != 0 {
  92276 					return WHERE_SORTBYGROUP
  92277 				}
  92278 				return 0
  92279 			}()|int32(distFlag)), 0)
  92280 	if !(pWInfo == uintptr(0)) {
  92281 		goto __99
  92282 	}
  92283 	Xsqlite3ExprListDelete(tls, db, pDistinct)
  92284 	goto select_end
  92285 __99:
  92286 	;
  92287 	if !((*Parse)(unsafe.Pointer(pParse)).FpIdxEpr != 0) {
  92288 		goto __100
  92289 	}
  92290 	optimizeAggregateUseOfIndexedExpr(tls, pParse, p, pAggInfo, bp+128)
  92291 __100:
  92292 	;
  92293 	assignAggregateRegisters(tls, pParse, pAggInfo)
  92294 	eDist = Xsqlite3WhereIsDistinct(tls, pWInfo)
  92295 
  92296 	if !(Xsqlite3WhereIsOrdered(tls, pWInfo) == (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) {
  92297 		goto __101
  92298 	}
  92299 
  92300 	groupBySort = 0
  92301 	goto __102
  92302 __101:
  92303 	explainTempTable(tls, pParse,
  92304 		func() uintptr {
  92305 			if (*DistinctCtx)(unsafe.Pointer(bp+116)).FisTnct != 0 && (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct) == U32(0) {
  92306 				return ts + 19849
  92307 			}
  92308 			return ts + 19858
  92309 		}())
  92310 
  92311 	groupBySort = 1
  92312 	nGroupBy = (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr
  92313 	nCol = nGroupBy
  92314 	j = nGroupBy
  92315 	i = 0
  92316 __103:
  92317 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) {
  92318 		goto __105
  92319 	}
  92320 	if !(int32((*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol+uintptr(i)*16)).FiSorterColumn) >= j) {
  92321 		goto __106
  92322 	}
  92323 	nCol++
  92324 	j++
  92325 __106:
  92326 	;
  92327 	goto __104
  92328 __104:
  92329 	i++
  92330 	goto __103
  92331 	goto __105
  92332 __105:
  92333 	;
  92334 	regBase = Xsqlite3GetTempRange(tls, pParse, nCol)
  92335 	Xsqlite3ExprCodeExprList(tls, pParse, pGroupBy, regBase, 0, uint8(0))
  92336 	j = nGroupBy
  92337 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(1)
  92338 	i = 0
  92339 __107:
  92340 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) {
  92341 		goto __109
  92342 	}
  92343 	pCol = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr(i)*16
  92344 	if !(int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn) >= j) {
  92345 		goto __110
  92346 	}
  92347 	Xsqlite3ExprCode(tls, pParse, (*AggInfo_col)(unsafe.Pointer(pCol)).FpCExpr, j+regBase)
  92348 	j++
  92349 __110:
  92350 	;
  92351 	goto __108
  92352 __108:
  92353 	i++
  92354 	goto __107
  92355 	goto __109
  92356 __109:
  92357 	;
  92358 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(0)
  92359 	regRecord = Xsqlite3GetTempReg(tls, pParse)
  92360 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase, nCol, regRecord)
  92361 	Xsqlite3VdbeAddOp2(tls, v, OP_SorterInsert, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord)
  92362 	Xsqlite3ReleaseTempReg(tls, pParse, regRecord)
  92363 	Xsqlite3ReleaseTempRange(tls, pParse, regBase, nCol)
  92364 
  92365 	Xsqlite3WhereEnd(tls, pWInfo)
  92366 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab = libc.AssignInt32(&sortPTab, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1))
  92367 	sortOut = Xsqlite3GetTempReg(tls, pParse)
  92368 	Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, sortPTab, sortOut, nCol)
  92369 	Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd)
  92370 
  92371 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx = U8(1)
  92372 __102:
  92373 	;
  92374 	if !((*Parse)(unsafe.Pointer(pParse)).FpIdxEpr != 0) {
  92375 		goto __111
  92376 	}
  92377 	aggregateConvertIndexedExprRefToColumn(tls, pAggInfo)
  92378 __111:
  92379 	;
  92380 	if !(orderByGrp != 0 && (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_GroupByOrder) == U32(0) &&
  92381 		(groupBySort != 0 || Xsqlite3WhereIsSorted(tls, pWInfo) != 0)) {
  92382 		goto __112
  92383 	}
  92384 	(*SortCtx)(unsafe.Pointer(bp + 48)).FpOrderBy = uintptr(0)
  92385 	Xsqlite3VdbeChangeToNoop(tls, v, (*SortCtx)(unsafe.Pointer(bp+48)).FaddrSortIndex)
  92386 __112:
  92387 	;
  92388 	addrTopOfLoop = Xsqlite3VdbeCurrentAddr(tls, v)
  92389 	if !(groupBySort != 0) {
  92390 		goto __113
  92391 	}
  92392 	Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx,
  92393 		sortOut, sortPTab)
  92394 __113:
  92395 	;
  92396 	j = 0
  92397 __114:
  92398 	if !(j < (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) {
  92399 		goto __116
  92400 	}
  92401 	if !(groupBySort != 0) {
  92402 		goto __117
  92403 	}
  92404 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, sortPTab, j, iBMem+j)
  92405 	goto __118
  92406 __117:
  92407 	(*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(1)
  92408 	Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pGroupBy+8+uintptr(j)*20)).FpExpr, iBMem+j)
  92409 __118:
  92410 	;
  92411 	goto __115
  92412 __115:
  92413 	j++
  92414 	goto __114
  92415 	goto __116
  92416 __116:
  92417 	;
  92418 	Xsqlite3VdbeAddOp4(tls, v, OP_Compare, iAMem, iBMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr,
  92419 		Xsqlite3KeyInfoRef(tls, pKeyInfo1), -8)
  92420 	addr1 = Xsqlite3VdbeCurrentAddr(tls, v)
  92421 	Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addr1+1, 0, addr1+1)
  92422 
  92423 	Xsqlite3ExprCodeMove(tls, pParse, iBMem, iAMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr)
  92424 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutputRow, addrOutputRow)
  92425 
  92426 	Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, iAbortFlag, addrEnd)
  92427 
  92428 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReset, addrReset)
  92429 
  92430 	Xsqlite3VdbeJumpHere(tls, v, addr1)
  92431 	updateAccumulator(tls, pParse, iUseFlag, pAggInfo, eDist)
  92432 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iUseFlag)
  92433 
  92434 	if !(groupBySort != 0) {
  92435 		goto __119
  92436 	}
  92437 	Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop)
  92438 
  92439 	goto __120
  92440 __119:
  92441 	;
  92442 	Xsqlite3WhereEnd(tls, pWInfo)
  92443 	Xsqlite3VdbeChangeToNoop(tls, v, addrSortingIdx)
  92444 __120:
  92445 	;
  92446 	Xsqlite3ExprListDelete(tls, db, pDistinct)
  92447 
  92448 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutputRow, addrOutputRow)
  92449 
  92450 	Xsqlite3VdbeGoto(tls, v, addrEnd)
  92451 
  92452 	addrSetAbort = Xsqlite3VdbeCurrentAddr(tls, v)
  92453 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iAbortFlag)
  92454 
  92455 	Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow)
  92456 	Xsqlite3VdbeResolveLabel(tls, v, addrOutputRow)
  92457 	addrOutputRow = Xsqlite3VdbeCurrentAddr(tls, v)
  92458 	Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, iUseFlag, addrOutputRow+2)
  92459 
  92460 	Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow)
  92461 	finalizeAggFunctions(tls, pParse, pAggInfo)
  92462 	Xsqlite3ExprIfFalse(tls, pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL)
  92463 	selectInnerLoop(tls, pParse, p, -1, bp+48,
  92464 		bp+116, pDest,
  92465 		addrOutputRow+1, addrSetAbort)
  92466 	Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow)
  92467 
  92468 	Xsqlite3VdbeResolveLabel(tls, v, addrReset)
  92469 	resetAccumulator(tls, pParse, pAggInfo)
  92470 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, iUseFlag)
  92471 
  92472 	Xsqlite3VdbeAddOp1(tls, v, OP_Return, regReset)
  92473 
  92474 	if !(int32(distFlag) != 0 && eDist != WHERE_DISTINCT_NOOP) {
  92475 		goto __121
  92476 	}
  92477 	pF = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc
  92478 	fixDistinctOpenEph(tls, pParse, eDist, (*AggInfo_func)(unsafe.Pointer(pF)).FiDistinct, (*AggInfo_func)(unsafe.Pointer(pF)).FiDistAddr)
  92479 __121:
  92480 	;
  92481 	goto __97
  92482 __96:
  92483 	if !(libc.AssignUintptr(&pTab1, isSimpleCount(tls, p, pAggInfo)) != uintptr(0)) {
  92484 		goto __122
  92485 	}
  92486 
  92487 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab1)).FpSchema)
  92488 	iCsr = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  92489 	pKeyInfo2 = uintptr(0)
  92490 	pBest = uintptr(0)
  92491 	iRoot = (*Table)(unsafe.Pointer(pTab1)).Ftnum
  92492 
  92493 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  92494 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab1)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab1)).FzName)
  92495 
  92496 	if !!((*Table)(unsafe.Pointer(pTab1)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  92497 		goto __124
  92498 	}
  92499 	pBest = Xsqlite3PrimaryKeyIndex(tls, pTab1)
  92500 __124:
  92501 	;
  92502 	if !!(int32(*(*uint16)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8 + 36 + 4))&0x1>>0) != 0) {
  92503 		goto __125
  92504 	}
  92505 	pIdx = (*Table)(unsafe.Pointer(pTab1)).FpIndex
  92506 __126:
  92507 	if !(pIdx != 0) {
  92508 		goto __128
  92509 	}
  92510 	if !(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x4>>2) == 0 &&
  92511 		int32((*Index)(unsafe.Pointer(pIdx)).FszIdxRow) < int32((*Table)(unsafe.Pointer(pTab1)).FszTabRow) &&
  92512 		(*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) &&
  92513 		(!(pBest != 0) || int32((*Index)(unsafe.Pointer(pIdx)).FszIdxRow) < int32((*Index)(unsafe.Pointer(pBest)).FszIdxRow))) {
  92514 		goto __129
  92515 	}
  92516 	pBest = pIdx
  92517 __129:
  92518 	;
  92519 	goto __127
  92520 __127:
  92521 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  92522 	goto __126
  92523 	goto __128
  92524 __128:
  92525 	;
  92526 __125:
  92527 	;
  92528 	if !(pBest != 0) {
  92529 		goto __130
  92530 	}
  92531 	iRoot = (*Index)(unsafe.Pointer(pBest)).Ftnum
  92532 	pKeyInfo2 = Xsqlite3KeyInfoOfIndex(tls, pParse, pBest)
  92533 __130:
  92534 	;
  92535 	Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenRead, iCsr, int32(iRoot), iDb, 1)
  92536 	if !(pKeyInfo2 != 0) {
  92537 		goto __131
  92538 	}
  92539 	Xsqlite3VdbeChangeP4(tls, v, -1, pKeyInfo2, -8)
  92540 __131:
  92541 	;
  92542 	assignAggregateRegisters(tls, pParse, pAggInfo)
  92543 	Xsqlite3VdbeAddOp2(tls, v, OP_Count, iCsr, func() int32 {
  92544 		return (*AggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn + 0
  92545 	}())
  92546 	Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCsr)
  92547 	explainSimpleCount(tls, pParse, pTab1, pBest)
  92548 	goto __123
  92549 __122:
  92550 	regAcc = 0
  92551 	pDistinct1 = uintptr(0)
  92552 	distFlag1 = U16(0)
  92553 
  92554 	if !((*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0) {
  92555 		goto __132
  92556 	}
  92557 	i = 0
  92558 __134:
  92559 	if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) {
  92560 		goto __136
  92561 	}
  92562 	if !((*Expr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*16)).FpFExpr)).Fflags&U32(EP_WinFunc) != U32(0)) {
  92563 		goto __137
  92564 	}
  92565 	goto __135
  92566 __137:
  92567 	;
  92568 	if !((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*16)).FpFunc)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != 0) {
  92569 		goto __138
  92570 	}
  92571 	goto __136
  92572 __138:
  92573 	;
  92574 	goto __135
  92575 __135:
  92576 	i++
  92577 	goto __134
  92578 	goto __136
  92579 __136:
  92580 	;
  92581 	if !(i == (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) {
  92582 		goto __139
  92583 	}
  92584 	regAcc = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  92585 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regAcc)
  92586 __139:
  92587 	;
  92588 	goto __133
  92589 __132:
  92590 	if !((*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 1 && (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FiDistinct >= 0) {
  92591 		goto __140
  92592 	}
  92593 
  92594 	pDistinct1 = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr + 20))
  92595 	if pDistinct1 != 0 {
  92596 		distFlag1 = uint16(WHERE_WANT_DISTINCT | WHERE_AGG_DISTINCT)
  92597 	} else {
  92598 		distFlag1 = uint16(0)
  92599 	}
  92600 __140:
  92601 	;
  92602 __133:
  92603 	;
  92604 	assignAggregateRegisters(tls, pParse, pAggInfo)
  92605 
  92606 	resetAccumulator(tls, pParse, pAggInfo)
  92607 
  92608 	pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, *(*uintptr)(unsafe.Pointer(bp + 160)),
  92609 		pDistinct1, p, uint16(int32(minMaxFlag)|int32(distFlag1)), 0)
  92610 	if !(pWInfo == uintptr(0)) {
  92611 		goto __141
  92612 	}
  92613 	goto select_end
  92614 __141:
  92615 	;
  92616 	eDist1 = Xsqlite3WhereIsDistinct(tls, pWInfo)
  92617 	updateAccumulator(tls, pParse, regAcc, pAggInfo, eDist1)
  92618 	if !(eDist1 != WHERE_DISTINCT_NOOP) {
  92619 		goto __142
  92620 	}
  92621 	pF1 = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc
  92622 	if !(pF1 != 0) {
  92623 		goto __143
  92624 	}
  92625 	fixDistinctOpenEph(tls, pParse, eDist1, (*AggInfo_func)(unsafe.Pointer(pF1)).FiDistinct, (*AggInfo_func)(unsafe.Pointer(pF1)).FiDistAddr)
  92626 __143:
  92627 	;
  92628 __142:
  92629 	;
  92630 	if !(regAcc != 0) {
  92631 		goto __144
  92632 	}
  92633 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regAcc)
  92634 __144:
  92635 	;
  92636 	if !(minMaxFlag != 0) {
  92637 		goto __145
  92638 	}
  92639 	Xsqlite3WhereMinMaxOptEarlyOut(tls, v, pWInfo)
  92640 __145:
  92641 	;
  92642 	Xsqlite3WhereEnd(tls, pWInfo)
  92643 	finalizeAggFunctions(tls, pParse, pAggInfo)
  92644 __123:
  92645 	;
  92646 	(*SortCtx)(unsafe.Pointer(bp + 48)).FpOrderBy = uintptr(0)
  92647 	Xsqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL)
  92648 	selectInnerLoop(tls, pParse, p, -1, uintptr(0), uintptr(0),
  92649 		pDest, addrEnd, addrEnd)
  92650 __97:
  92651 	;
  92652 	Xsqlite3VdbeResolveLabel(tls, v, addrEnd)
  92653 
  92654 __65:
  92655 	;
  92656 	if !(int32((*DistinctCtx)(unsafe.Pointer(bp+116)).FeTnctType) == WHERE_DISTINCT_UNORDERED) {
  92657 		goto __146
  92658 	}
  92659 	explainTempTable(tls, pParse, ts+19849)
  92660 __146:
  92661 	;
  92662 	if !((*SortCtx)(unsafe.Pointer(bp+48)).FpOrderBy != 0) {
  92663 		goto __147
  92664 	}
  92665 
  92666 	generateSortTail(tls, pParse, p, bp+48, (*ExprList)(unsafe.Pointer(pEList)).FnExpr, pDest)
  92667 __147:
  92668 	;
  92669 	Xsqlite3VdbeResolveLabel(tls, v, iEnd)
  92670 
  92671 	rc = libc.Bool32((*Parse)(unsafe.Pointer(pParse)).FnErr > 0)
  92672 
  92673 select_end:
  92674 	;
  92675 	Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(bp + 160)))
  92676 
  92677 	Xsqlite3VdbeExplainPop(tls, pParse)
  92678 	return rc
  92679 }
  92680 
  92681 // This structure is used to pass data from sqlite3_get_table() through
  92682 // to the callback function is uses to build the result.
  92683 type TabResult1 = struct {
  92684 	FazResult uintptr
  92685 	FzErrMsg  uintptr
  92686 	FnAlloc   U32
  92687 	FnRow     U32
  92688 	FnColumn  U32
  92689 	FnData    U32
  92690 	Frc       int32
  92691 }
  92692 
  92693 // This structure is used to pass data from sqlite3_get_table() through
  92694 // to the callback function is uses to build the result.
  92695 type TabResult = TabResult1
  92696 
  92697 func sqlite3_get_table_cb(tls *libc.TLS, pArg uintptr, nCol int32, argv uintptr, colv uintptr) int32 {
  92698 	bp := tls.Alloc(8)
  92699 	defer tls.Free(8)
  92700 
  92701 	var p uintptr
  92702 	var need int32
  92703 	var i int32
  92704 	var z uintptr
  92705 	var azNew uintptr
  92706 	var n int32
  92707 	p = pArg
  92708 
  92709 	if !((*TabResult)(unsafe.Pointer(p)).FnRow == U32(0) && argv != uintptr(0)) {
  92710 		goto __1
  92711 	}
  92712 	need = nCol * 2
  92713 	goto __2
  92714 __1:
  92715 	need = nCol
  92716 __2:
  92717 	;
  92718 	if !((*TabResult)(unsafe.Pointer(p)).FnData+U32(need) > (*TabResult)(unsafe.Pointer(p)).FnAlloc) {
  92719 		goto __3
  92720 	}
  92721 	(*TabResult)(unsafe.Pointer(p)).FnAlloc = (*TabResult)(unsafe.Pointer(p)).FnAlloc*U32(2) + U32(need)
  92722 	azNew = Xsqlite3Realloc(tls, (*TabResult)(unsafe.Pointer(p)).FazResult, uint64(uint32(unsafe.Sizeof(uintptr(0)))*(*TabResult)(unsafe.Pointer(p)).FnAlloc))
  92723 	if !(azNew == uintptr(0)) {
  92724 		goto __4
  92725 	}
  92726 	goto malloc_failed
  92727 __4:
  92728 	;
  92729 	(*TabResult)(unsafe.Pointer(p)).FazResult = azNew
  92730 __3:
  92731 	;
  92732 	if !((*TabResult)(unsafe.Pointer(p)).FnRow == U32(0)) {
  92733 		goto __5
  92734 	}
  92735 	(*TabResult)(unsafe.Pointer(p)).FnColumn = U32(nCol)
  92736 	i = 0
  92737 __7:
  92738 	if !(i < nCol) {
  92739 		goto __9
  92740 	}
  92741 	z = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(colv + uintptr(i)*4))))
  92742 	if !(z == uintptr(0)) {
  92743 		goto __10
  92744 	}
  92745 	goto malloc_failed
  92746 __10:
  92747 	;
  92748 	*(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(p)).FazResult + uintptr(libc.PostIncUint32(&(*TabResult)(unsafe.Pointer(p)).FnData, 1))*4)) = z
  92749 	goto __8
  92750 __8:
  92751 	i++
  92752 	goto __7
  92753 	goto __9
  92754 __9:
  92755 	;
  92756 	goto __6
  92757 __5:
  92758 	if !(int32((*TabResult)(unsafe.Pointer(p)).FnColumn) != nCol) {
  92759 		goto __11
  92760 	}
  92761 	Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(p)).FzErrMsg)
  92762 	(*TabResult)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3_mprintf(tls,
  92763 		ts+19867, 0)
  92764 	(*TabResult)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
  92765 	return 1
  92766 __11:
  92767 	;
  92768 __6:
  92769 	;
  92770 	if !(argv != uintptr(0)) {
  92771 		goto __12
  92772 	}
  92773 	i = 0
  92774 __13:
  92775 	if !(i < nCol) {
  92776 		goto __15
  92777 	}
  92778 	if !(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)) == uintptr(0)) {
  92779 		goto __16
  92780 	}
  92781 	z = uintptr(0)
  92782 	goto __17
  92783 __16:
  92784 	n = Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4))) + 1
  92785 	z = Xsqlite3_malloc64(tls, uint64(n))
  92786 	if !(z == uintptr(0)) {
  92787 		goto __18
  92788 	}
  92789 	goto malloc_failed
  92790 __18:
  92791 	;
  92792 	libc.Xmemcpy(tls, z, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)), uint32(n))
  92793 __17:
  92794 	;
  92795 	*(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(p)).FazResult + uintptr(libc.PostIncUint32(&(*TabResult)(unsafe.Pointer(p)).FnData, 1))*4)) = z
  92796 	goto __14
  92797 __14:
  92798 	i++
  92799 	goto __13
  92800 	goto __15
  92801 __15:
  92802 	;
  92803 	(*TabResult)(unsafe.Pointer(p)).FnRow++
  92804 __12:
  92805 	;
  92806 	return 0
  92807 
  92808 malloc_failed:
  92809 	(*TabResult)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
  92810 	return 1
  92811 }
  92812 
  92813 // Query the database.  But instead of invoking a callback for each row,
  92814 // malloc() for space to hold the result and return the entire results
  92815 // at the conclusion of the call.
  92816 //
  92817 // The result that is written to ***pazResult is held in memory obtained
  92818 // from malloc().  But the caller cannot free this memory directly.
  92819 // Instead, the entire table should be passed to sqlite3_free_table() when
  92820 // the calling procedure is finished using it.
  92821 func Xsqlite3_get_table(tls *libc.TLS, db uintptr, zSql uintptr, pazResult uintptr, pnRow uintptr, pnColumn uintptr, pzErrMsg uintptr) int32 {
  92822 	bp := tls.Alloc(36)
  92823 	defer tls.Free(36)
  92824 
  92825 	var rc int32
  92826 
  92827 	*(*uintptr)(unsafe.Pointer(pazResult)) = uintptr(0)
  92828 	if pnColumn != 0 {
  92829 		*(*int32)(unsafe.Pointer(pnColumn)) = 0
  92830 	}
  92831 	if pnRow != 0 {
  92832 		*(*int32)(unsafe.Pointer(pnRow)) = 0
  92833 	}
  92834 	if pzErrMsg != 0 {
  92835 		*(*uintptr)(unsafe.Pointer(pzErrMsg)) = uintptr(0)
  92836 	}
  92837 	(*TabResult)(unsafe.Pointer(bp + 8)).FzErrMsg = uintptr(0)
  92838 	(*TabResult)(unsafe.Pointer(bp + 8)).FnRow = U32(0)
  92839 	(*TabResult)(unsafe.Pointer(bp + 8)).FnColumn = U32(0)
  92840 	(*TabResult)(unsafe.Pointer(bp + 8)).FnData = U32(1)
  92841 	(*TabResult)(unsafe.Pointer(bp + 8)).FnAlloc = U32(20)
  92842 	(*TabResult)(unsafe.Pointer(bp + 8)).Frc = SQLITE_OK
  92843 	(*TabResult)(unsafe.Pointer(bp + 8)).FazResult = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(uintptr(0)))*(*TabResult)(unsafe.Pointer(bp+8)).FnAlloc))
  92844 	if (*TabResult)(unsafe.Pointer(bp+8)).FazResult == uintptr(0) {
  92845 		(*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_NOMEM
  92846 		return SQLITE_NOMEM
  92847 	}
  92848 	*(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp + 8)).FazResult)) = uintptr(0)
  92849 	rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct {
  92850 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
  92851 	}{sqlite3_get_table_cb})), bp+8, pzErrMsg)
  92852 
  92853 	*(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp + 8)).FazResult)) = uintptr(int32((*TabResult)(unsafe.Pointer(bp + 8)).FnData))
  92854 	if rc&0xff == SQLITE_ABORT {
  92855 		Xsqlite3_free_table(tls, (*TabResult)(unsafe.Pointer(bp+8)).FazResult+1*4)
  92856 		if (*TabResult)(unsafe.Pointer(bp+8)).FzErrMsg != 0 {
  92857 			if pzErrMsg != 0 {
  92858 				Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pzErrMsg)))
  92859 				*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, (*TabResult)(unsafe.Pointer(bp+8)).FzErrMsg))
  92860 			}
  92861 			Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(bp+8)).FzErrMsg)
  92862 		}
  92863 		(*Sqlite3)(unsafe.Pointer(db)).FerrCode = (*TabResult)(unsafe.Pointer(bp + 8)).Frc
  92864 		return (*TabResult)(unsafe.Pointer(bp + 8)).Frc
  92865 	}
  92866 	Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(bp+8)).FzErrMsg)
  92867 	if rc != SQLITE_OK {
  92868 		Xsqlite3_free_table(tls, (*TabResult)(unsafe.Pointer(bp+8)).FazResult+1*4)
  92869 		return rc
  92870 	}
  92871 	if (*TabResult)(unsafe.Pointer(bp+8)).FnAlloc > (*TabResult)(unsafe.Pointer(bp+8)).FnData {
  92872 		var azNew uintptr
  92873 		azNew = Xsqlite3Realloc(tls, (*TabResult)(unsafe.Pointer(bp+8)).FazResult, uint64(uint32(unsafe.Sizeof(uintptr(0)))*(*TabResult)(unsafe.Pointer(bp+8)).FnData))
  92874 		if azNew == uintptr(0) {
  92875 			Xsqlite3_free_table(tls, (*TabResult)(unsafe.Pointer(bp+8)).FazResult+1*4)
  92876 			(*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_NOMEM
  92877 			return SQLITE_NOMEM
  92878 		}
  92879 		(*TabResult)(unsafe.Pointer(bp + 8)).FazResult = azNew
  92880 	}
  92881 	*(*uintptr)(unsafe.Pointer(pazResult)) = (*TabResult)(unsafe.Pointer(bp+8)).FazResult + 1*4
  92882 	if pnColumn != 0 {
  92883 		*(*int32)(unsafe.Pointer(pnColumn)) = int32((*TabResult)(unsafe.Pointer(bp + 8)).FnColumn)
  92884 	}
  92885 	if pnRow != 0 {
  92886 		*(*int32)(unsafe.Pointer(pnRow)) = int32((*TabResult)(unsafe.Pointer(bp + 8)).FnRow)
  92887 	}
  92888 	return rc
  92889 }
  92890 
  92891 // This routine frees the space the sqlite3_get_table() malloced.
  92892 func Xsqlite3_free_table(tls *libc.TLS, azResult uintptr) {
  92893 	if azResult != 0 {
  92894 		var i int32
  92895 		var n int32
  92896 		azResult -= 4
  92897 
  92898 		n = int32(*(*uintptr)(unsafe.Pointer(azResult)))
  92899 		for i = 1; i < n; i++ {
  92900 			if *(*uintptr)(unsafe.Pointer(azResult + uintptr(i)*4)) != 0 {
  92901 				Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(azResult + uintptr(i)*4)))
  92902 			}
  92903 		}
  92904 		Xsqlite3_free(tls, azResult)
  92905 	}
  92906 }
  92907 
  92908 // Delete a linked list of TriggerStep structures.
  92909 func Xsqlite3DeleteTriggerStep(tls *libc.TLS, db uintptr, pTriggerStep uintptr) {
  92910 	for pTriggerStep != 0 {
  92911 		var pTmp uintptr = pTriggerStep
  92912 		pTriggerStep = (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpNext
  92913 
  92914 		Xsqlite3ExprDelete(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FpWhere)
  92915 		Xsqlite3ExprListDelete(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FpExprList)
  92916 		Xsqlite3SelectDelete(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FpSelect)
  92917 		Xsqlite3IdListDelete(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FpIdList)
  92918 		Xsqlite3UpsertDelete(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FpUpsert)
  92919 		Xsqlite3SrcListDelete(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FpFrom)
  92920 		Xsqlite3DbFree(tls, db, (*TriggerStep)(unsafe.Pointer(pTmp)).FzSpan)
  92921 
  92922 		Xsqlite3DbFree(tls, db, pTmp)
  92923 	}
  92924 }
  92925 
  92926 // Given table pTab, return a list of all the triggers attached to
  92927 // the table. The list is connected by Trigger.pNext pointers.
  92928 //
  92929 // All of the triggers on pTab that are in the same database as pTab
  92930 // are already attached to pTab->pTrigger.  But there might be additional
  92931 // triggers on pTab in the TEMP schema.  This routine prepends all
  92932 // TEMP triggers on pTab to the beginning of the pTab->pTrigger list
  92933 // and returns the combined list.
  92934 //
  92935 // To state it another way:  This routine returns a list of all triggers
  92936 // that fire off of pTab.  The list will include any TEMP triggers on
  92937 // pTab as well as the triggers lised in pTab->pTrigger.
  92938 func Xsqlite3TriggerList(tls *libc.TLS, pParse uintptr, pTab uintptr) uintptr {
  92939 	var pTmpSchema uintptr
  92940 	var pList uintptr
  92941 	var p uintptr
  92942 
  92943 	pTmpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + 1*16)).FpSchema
  92944 	p = (*Hash)(unsafe.Pointer(pTmpSchema + 40)).Ffirst
  92945 	pList = (*Table)(unsafe.Pointer(pTab)).FpTrigger
  92946 	for p != 0 {
  92947 		var pTrig uintptr = (*HashElem)(unsafe.Pointer(p)).Fdata
  92948 		if (*Trigger)(unsafe.Pointer(pTrig)).FpTabSchema == (*Table)(unsafe.Pointer(pTab)).FpSchema &&
  92949 			(*Trigger)(unsafe.Pointer(pTrig)).Ftable != 0 &&
  92950 			0 == Xsqlite3StrICmp(tls, (*Trigger)(unsafe.Pointer(pTrig)).Ftable, (*Table)(unsafe.Pointer(pTab)).FzName) &&
  92951 			((*Trigger)(unsafe.Pointer(pTrig)).FpTabSchema != pTmpSchema || (*Trigger)(unsafe.Pointer(pTrig)).FbReturning != 0) {
  92952 			(*Trigger)(unsafe.Pointer(pTrig)).FpNext = pList
  92953 			pList = pTrig
  92954 		} else if int32((*Trigger)(unsafe.Pointer(pTrig)).Fop) == TK_RETURNING {
  92955 			(*Trigger)(unsafe.Pointer(pTrig)).Ftable = (*Table)(unsafe.Pointer(pTab)).FzName
  92956 			(*Trigger)(unsafe.Pointer(pTrig)).FpTabSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema
  92957 			(*Trigger)(unsafe.Pointer(pTrig)).FpNext = pList
  92958 			pList = pTrig
  92959 		}
  92960 		p = (*HashElem)(unsafe.Pointer(p)).Fnext
  92961 	}
  92962 	return pList
  92963 }
  92964 
  92965 // This is called by the parser when it sees a CREATE TRIGGER statement
  92966 // up to the point of the BEGIN before the trigger actions.  A Trigger
  92967 // structure is generated based on the information available and stored
  92968 // in pParse->pNewTrigger.  After the trigger actions have been parsed, the
  92969 // sqlite3FinishTrigger() function is called to complete the trigger
  92970 // construction process.
  92971 func Xsqlite3BeginTrigger(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, tr_tm int32, op int32, pColumns uintptr, pTableName uintptr, pWhen uintptr, isTemp int32, noErr int32) {
  92972 	bp := tls.Alloc(88)
  92973 	defer tls.Free(88)
  92974 
  92975 	var pTrigger uintptr
  92976 	var pTab uintptr
  92977 	var zName uintptr
  92978 	var db uintptr
  92979 	var iDb int32
  92980 
  92981 	var iTabDb int32
  92982 	var code int32
  92983 	var zDb uintptr
  92984 	var zDbTrig uintptr
  92985 	pTrigger = uintptr(0)
  92986 	zName = uintptr(0)
  92987 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  92988 
  92989 	if !(isTemp != 0) {
  92990 		goto __1
  92991 	}
  92992 
  92993 	if !((*Token)(unsafe.Pointer(pName2)).Fn > uint32(0)) {
  92994 		goto __3
  92995 	}
  92996 	Xsqlite3ErrorMsg(tls, pParse, ts+19932, 0)
  92997 	goto trigger_cleanup
  92998 __3:
  92999 	;
  93000 	iDb = 1
  93001 	*(*uintptr)(unsafe.Pointer(bp + 32)) = pName1
  93002 	goto __2
  93003 __1:
  93004 	iDb = Xsqlite3TwoPartName(tls, pParse, pName1, pName2, bp+32)
  93005 	if !(iDb < 0) {
  93006 		goto __4
  93007 	}
  93008 	goto trigger_cleanup
  93009 __4:
  93010 	;
  93011 __2:
  93012 	;
  93013 	if !(!(pTableName != 0) || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  93014 		goto __5
  93015 	}
  93016 	goto trigger_cleanup
  93017 __5:
  93018 	;
  93019 	if !((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 && iDb != 1) {
  93020 		goto __6
  93021 	}
  93022 	Xsqlite3DbFree(tls, db, (*SrcItem)(unsafe.Pointer(pTableName+8)).FzDatabase)
  93023 	(*SrcItem)(unsafe.Pointer(pTableName + 8)).FzDatabase = uintptr(0)
  93024 __6:
  93025 	;
  93026 	pTab = Xsqlite3SrcListLookup(tls, pParse, pTableName)
  93027 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0 && (*Token)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 &&
  93028 		(*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema) {
  93029 		goto __7
  93030 	}
  93031 	iDb = 1
  93032 __7:
  93033 	;
  93034 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  93035 		goto __8
  93036 	}
  93037 	goto trigger_cleanup
  93038 __8:
  93039 	;
  93040 	Xsqlite3FixInit(tls, bp+36, pParse, iDb, ts+19978, *(*uintptr)(unsafe.Pointer(bp + 32)))
  93041 	if !(Xsqlite3FixSrcList(tls, bp+36, pTableName) != 0) {
  93042 		goto __9
  93043 	}
  93044 	goto trigger_cleanup
  93045 __9:
  93046 	;
  93047 	pTab = Xsqlite3SrcListLookup(tls, pParse, pTableName)
  93048 	if !!(pTab != 0) {
  93049 		goto __10
  93050 	}
  93051 
  93052 	goto trigger_orphan_error
  93053 __10:
  93054 	;
  93055 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  93056 		goto __11
  93057 	}
  93058 	Xsqlite3ErrorMsg(tls, pParse, ts+19986, 0)
  93059 	goto trigger_orphan_error
  93060 __11:
  93061 	;
  93062 	zName = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp + 32)))
  93063 	if !(zName == uintptr(0)) {
  93064 		goto __12
  93065 	}
  93066 
  93067 	goto trigger_cleanup
  93068 __12:
  93069 	;
  93070 	if !(Xsqlite3CheckObjectName(tls, pParse, zName, ts+19978, (*Table)(unsafe.Pointer(pTab)).FzName) != 0) {
  93071 		goto __13
  93072 	}
  93073 	goto trigger_cleanup
  93074 __13:
  93075 	;
  93076 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  93077 		goto __14
  93078 	}
  93079 	if !(Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema+40, zName) != 0) {
  93080 		goto __15
  93081 	}
  93082 	if !!(noErr != 0) {
  93083 		goto __16
  93084 	}
  93085 	Xsqlite3ErrorMsg(tls, pParse, ts+20027, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 32))))
  93086 	goto __17
  93087 __16:
  93088 	;
  93089 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
  93090 
  93091 __17:
  93092 	;
  93093 	goto trigger_cleanup
  93094 __15:
  93095 	;
  93096 __14:
  93097 	;
  93098 	if !(Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+6381, 7) == 0) {
  93099 		goto __18
  93100 	}
  93101 	Xsqlite3ErrorMsg(tls, pParse, ts+20053, 0)
  93102 	goto trigger_cleanup
  93103 __18:
  93104 	;
  93105 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW && tr_tm != TK_INSTEAD) {
  93106 		goto __19
  93107 	}
  93108 	Xsqlite3ErrorMsg(tls, pParse, ts+20091,
  93109 		libc.VaList(bp+8, func() uintptr {
  93110 			if tr_tm == TK_BEFORE {
  93111 				return ts + 20128
  93112 			}
  93113 			return ts + 20135
  93114 		}(), pTableName+8))
  93115 	goto trigger_orphan_error
  93116 __19:
  93117 	;
  93118 	if !(!(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) && tr_tm == TK_INSTEAD) {
  93119 		goto __20
  93120 	}
  93121 	Xsqlite3ErrorMsg(tls, pParse,
  93122 		ts+20141, libc.VaList(bp+24, pTableName+8))
  93123 	goto trigger_orphan_error
  93124 __20:
  93125 	;
  93126 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  93127 		goto __21
  93128 	}
  93129 	iTabDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  93130 	code = SQLITE_CREATE_TRIGGER
  93131 	zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iTabDb)*16)).FzDbSName
  93132 	if isTemp != 0 {
  93133 		zDbTrig = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FzDbSName
  93134 	} else {
  93135 		zDbTrig = zDb
  93136 	}
  93137 	if !(iTabDb == 1 || isTemp != 0) {
  93138 		goto __22
  93139 	}
  93140 	code = SQLITE_CREATE_TEMP_TRIGGER
  93141 __22:
  93142 	;
  93143 	if !(Xsqlite3AuthCheck(tls, pParse, code, zName, (*Table)(unsafe.Pointer(pTab)).FzName, zDbTrig) != 0) {
  93144 		goto __23
  93145 	}
  93146 	goto trigger_cleanup
  93147 __23:
  93148 	;
  93149 	if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr {
  93150 		if !(0 != 0) && iTabDb == 1 {
  93151 			return ts + 6389
  93152 		}
  93153 		return ts + 5883
  93154 	}(), uintptr(0), zDb) != 0) {
  93155 		goto __24
  93156 	}
  93157 	goto trigger_cleanup
  93158 __24:
  93159 	;
  93160 __21:
  93161 	;
  93162 	if !(tr_tm == TK_INSTEAD) {
  93163 		goto __25
  93164 	}
  93165 	tr_tm = TK_BEFORE
  93166 __25:
  93167 	;
  93168 	pTrigger = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Trigger{})))
  93169 	if !(pTrigger == uintptr(0)) {
  93170 		goto __26
  93171 	}
  93172 	goto trigger_cleanup
  93173 __26:
  93174 	;
  93175 	(*Trigger)(unsafe.Pointer(pTrigger)).FzName = zName
  93176 	zName = uintptr(0)
  93177 	(*Trigger)(unsafe.Pointer(pTrigger)).Ftable = Xsqlite3DbStrDup(tls, db, (*SrcItem)(unsafe.Pointer(pTableName+8)).FzName)
  93178 	(*Trigger)(unsafe.Pointer(pTrigger)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpSchema
  93179 	(*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema
  93180 	(*Trigger)(unsafe.Pointer(pTrigger)).Fop = U8(op)
  93181 	(*Trigger)(unsafe.Pointer(pTrigger)).Ftr_tm = func() uint8 {
  93182 		if tr_tm == TK_BEFORE {
  93183 			return uint8(TRIGGER_BEFORE)
  93184 		}
  93185 		return uint8(TRIGGER_AFTER)
  93186 	}()
  93187 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  93188 		goto __27
  93189 	}
  93190 	Xsqlite3RenameTokenRemap(tls, pParse, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable, (*SrcItem)(unsafe.Pointer(pTableName+8)).FzName)
  93191 	(*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = pWhen
  93192 	pWhen = uintptr(0)
  93193 	goto __28
  93194 __27:
  93195 	(*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, EXPRDUP_REDUCE)
  93196 __28:
  93197 	;
  93198 	(*Trigger)(unsafe.Pointer(pTrigger)).FpColumns = pColumns
  93199 	pColumns = uintptr(0)
  93200 
  93201 	(*Parse)(unsafe.Pointer(pParse)).FpNewTrigger = pTrigger
  93202 
  93203 trigger_cleanup:
  93204 	Xsqlite3DbFree(tls, db, zName)
  93205 	Xsqlite3SrcListDelete(tls, db, pTableName)
  93206 	Xsqlite3IdListDelete(tls, db, pColumns)
  93207 	Xsqlite3ExprDelete(tls, db, pWhen)
  93208 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).FpNewTrigger) != 0) {
  93209 		goto __29
  93210 	}
  93211 	Xsqlite3DeleteTrigger(tls, db, pTrigger)
  93212 	goto __30
  93213 __29:
  93214 	;
  93215 __30:
  93216 	;
  93217 	return
  93218 
  93219 trigger_orphan_error:
  93220 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb) == 1) {
  93221 		goto __31
  93222 	}
  93223 
  93224 	libc.SetBitFieldPtr8Uint32(db+172+8, uint32(1), 0, 0x1)
  93225 __31:
  93226 	;
  93227 	goto trigger_cleanup
  93228 }
  93229 
  93230 // This routine is called after all of the trigger actions have been parsed
  93231 // in order to complete the process of building the trigger.
  93232 func Xsqlite3FinishTrigger(tls *libc.TLS, pParse uintptr, pStepList uintptr, pAll uintptr) {
  93233 	bp := tls.Alloc(116)
  93234 	defer tls.Free(116)
  93235 
  93236 	var pTrig uintptr
  93237 	var zName uintptr
  93238 	var db uintptr
  93239 
  93240 	var iDb int32
  93241 
  93242 	var pStep uintptr
  93243 	var v uintptr
  93244 	var z uintptr
  93245 	var pTab uintptr
  93246 	var pLink uintptr
  93247 	var pHash uintptr
  93248 	pTrig = (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger
  93249 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93250 
  93251 	(*Parse)(unsafe.Pointer(pParse)).FpNewTrigger = uintptr(0)
  93252 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0 || !(pTrig != 0)) {
  93253 		goto __1
  93254 	}
  93255 	goto triggerfinish_cleanup
  93256 __1:
  93257 	;
  93258 	zName = (*Trigger)(unsafe.Pointer(pTrig)).FzName
  93259 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Trigger)(unsafe.Pointer(pTrig)).FpSchema)
  93260 	(*Trigger)(unsafe.Pointer(pTrig)).Fstep_list = pStepList
  93261 __2:
  93262 	if !(pStepList != 0) {
  93263 		goto __3
  93264 	}
  93265 	(*TriggerStep)(unsafe.Pointer(pStepList)).FpTrig = pTrig
  93266 	pStepList = (*TriggerStep)(unsafe.Pointer(pStepList)).FpNext
  93267 	goto __2
  93268 __3:
  93269 	;
  93270 	Xsqlite3TokenInit(tls, bp+56, (*Trigger)(unsafe.Pointer(pTrig)).FzName)
  93271 	Xsqlite3FixInit(tls, bp+64, pParse, iDb, ts+19978, bp+56)
  93272 	if !(Xsqlite3FixTriggerStep(tls, bp+64, (*Trigger)(unsafe.Pointer(pTrig)).Fstep_list) != 0 ||
  93273 		Xsqlite3FixExpr(tls, bp+64, (*Trigger)(unsafe.Pointer(pTrig)).FpWhen) != 0) {
  93274 		goto __4
  93275 	}
  93276 	goto triggerfinish_cleanup
  93277 __4:
  93278 	;
  93279 	if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  93280 		goto __5
  93281 	}
  93282 
  93283 	(*Parse)(unsafe.Pointer(pParse)).FpNewTrigger = pTrig
  93284 	pTrig = uintptr(0)
  93285 	goto __6
  93286 __5:
  93287 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) {
  93288 		goto __7
  93289 	}
  93290 
  93291 	if !(Xsqlite3ReadOnlyShadowTables(tls, db) != 0) {
  93292 		goto __8
  93293 	}
  93294 	pStep = (*Trigger)(unsafe.Pointer(pTrig)).Fstep_list
  93295 __9:
  93296 	if !(pStep != 0) {
  93297 		goto __11
  93298 	}
  93299 	if !((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != uintptr(0) &&
  93300 		Xsqlite3ShadowTableName(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget) != 0) {
  93301 		goto __12
  93302 	}
  93303 	Xsqlite3ErrorMsg(tls, pParse,
  93304 		ts+20187,
  93305 		libc.VaList(bp, (*Trigger)(unsafe.Pointer(pTrig)).FzName, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget))
  93306 	goto triggerfinish_cleanup
  93307 __12:
  93308 	;
  93309 	goto __10
  93310 __10:
  93311 	pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext
  93312 	goto __9
  93313 	goto __11
  93314 __11:
  93315 	;
  93316 __8:
  93317 	;
  93318 	v = Xsqlite3GetVdbe(tls, pParse)
  93319 	if !(v == uintptr(0)) {
  93320 		goto __13
  93321 	}
  93322 	goto triggerfinish_cleanup
  93323 __13:
  93324 	;
  93325 	Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb)
  93326 	z = Xsqlite3DbStrNDup(tls, db, (*Token)(unsafe.Pointer(pAll)).Fz, uint64((*Token)(unsafe.Pointer(pAll)).Fn))
  93327 
  93328 	Xsqlite3NestedParse(tls, pParse,
  93329 		ts+20235,
  93330 		libc.VaList(bp+16, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName, zName,
  93331 			(*Trigger)(unsafe.Pointer(pTrig)).Ftable, z))
  93332 	Xsqlite3DbFree(tls, db, z)
  93333 	Xsqlite3ChangeCookie(tls, pParse, iDb)
  93334 	Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb,
  93335 		Xsqlite3MPrintf(tls, db, ts+20310, libc.VaList(bp+48, zName)), uint16(0))
  93336 __7:
  93337 	;
  93338 __6:
  93339 	;
  93340 	if !((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) {
  93341 		goto __14
  93342 	}
  93343 	pLink = pTrig
  93344 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 40
  93345 
  93346 	pTrig = Xsqlite3HashInsert(tls, pHash, zName, pTrig)
  93347 	if !(pTrig != 0) {
  93348 		goto __15
  93349 	}
  93350 	Xsqlite3OomFault(tls, db)
  93351 	goto __16
  93352 __15:
  93353 	if !((*Trigger)(unsafe.Pointer(pLink)).FpSchema == (*Trigger)(unsafe.Pointer(pLink)).FpTabSchema) {
  93354 		goto __17
  93355 	}
  93356 	pTab = Xsqlite3HashFind(tls, (*Trigger)(unsafe.Pointer(pLink)).FpTabSchema+8, (*Trigger)(unsafe.Pointer(pLink)).Ftable)
  93357 
  93358 	(*Trigger)(unsafe.Pointer(pLink)).FpNext = (*Table)(unsafe.Pointer(pTab)).FpTrigger
  93359 	(*Table)(unsafe.Pointer(pTab)).FpTrigger = pLink
  93360 __17:
  93361 	;
  93362 __16:
  93363 	;
  93364 __14:
  93365 	;
  93366 triggerfinish_cleanup:
  93367 	Xsqlite3DeleteTrigger(tls, db, pTrig)
  93368 
  93369 	Xsqlite3DeleteTriggerStep(tls, db, pStepList)
  93370 }
  93371 
  93372 func triggerSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) uintptr {
  93373 	var z uintptr = Xsqlite3DbSpanDup(tls, db, zStart, zEnd)
  93374 	var i int32
  93375 	if z != 0 {
  93376 		for i = 0; *(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0; i++ {
  93377 			if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x01 != 0 {
  93378 				*(*uint8)(unsafe.Pointer(z + uintptr(i))) = uint8(' ')
  93379 			}
  93380 		}
  93381 	}
  93382 	return z
  93383 }
  93384 
  93385 // Turn a SELECT statement (that the pSelect parameter points to) into
  93386 // a trigger step.  Return a pointer to a TriggerStep structure.
  93387 //
  93388 // The parser calls this routine when it finds a SELECT statement in
  93389 // body of a TRIGGER.
  93390 func Xsqlite3TriggerSelectStep(tls *libc.TLS, db uintptr, pSelect uintptr, zStart uintptr, zEnd uintptr) uintptr {
  93391 	var pTriggerStep uintptr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(TriggerStep{})))
  93392 	if pTriggerStep == uintptr(0) {
  93393 		Xsqlite3SelectDelete(tls, db, pSelect)
  93394 		return uintptr(0)
  93395 	}
  93396 	(*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = U8(TK_SELECT)
  93397 	(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect
  93398 	(*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = U8(OE_Default)
  93399 	(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = triggerSpanDup(tls, db, zStart, zEnd)
  93400 	return pTriggerStep
  93401 }
  93402 
  93403 func triggerStepAllocate(tls *libc.TLS, pParse uintptr, op U8, pName uintptr, zStart uintptr, zEnd uintptr) uintptr {
  93404 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93405 	var pTriggerStep uintptr
  93406 
  93407 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
  93408 		return uintptr(0)
  93409 	}
  93410 	pTriggerStep = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(TriggerStep{}))+(*Token)(unsafe.Pointer(pName)).Fn+uint32(1)))
  93411 	if pTriggerStep != 0 {
  93412 		var z uintptr = pTriggerStep + 1*48
  93413 		libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(pName)).Fz, (*Token)(unsafe.Pointer(pName)).Fn)
  93414 		Xsqlite3Dequote(tls, z)
  93415 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzTarget = z
  93416 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = op
  93417 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = triggerSpanDup(tls, db, zStart, zEnd)
  93418 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  93419 			Xsqlite3RenameTokenMap(tls, pParse, (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzTarget, pName)
  93420 		}
  93421 	}
  93422 	return pTriggerStep
  93423 }
  93424 
  93425 // Build a trigger step out of an INSERT statement.  Return a pointer
  93426 // to the new trigger step.
  93427 //
  93428 // The parser calls this routine when it sees an INSERT inside the
  93429 // body of a trigger.
  93430 func Xsqlite3TriggerInsertStep(tls *libc.TLS, pParse uintptr, pTableName uintptr, pColumn uintptr, pSelect uintptr, orconf U8, pUpsert uintptr, zStart uintptr, zEnd uintptr) uintptr {
  93431 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93432 	var pTriggerStep uintptr
  93433 
  93434 	pTriggerStep = triggerStepAllocate(tls, pParse, uint8(TK_INSERT), pTableName, zStart, zEnd)
  93435 	if pTriggerStep != 0 {
  93436 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  93437 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect
  93438 			pSelect = uintptr(0)
  93439 		} else {
  93440 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE)
  93441 		}
  93442 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpIdList = pColumn
  93443 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpUpsert = pUpsert
  93444 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = orconf
  93445 		if pUpsert != 0 {
  93446 			Xsqlite3HasExplicitNulls(tls, pParse, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget)
  93447 		}
  93448 	} else {
  93449 		Xsqlite3IdListDelete(tls, db, pColumn)
  93450 
  93451 		Xsqlite3UpsertDelete(tls, db, pUpsert)
  93452 	}
  93453 	Xsqlite3SelectDelete(tls, db, pSelect)
  93454 
  93455 	return pTriggerStep
  93456 }
  93457 
  93458 // Construct a trigger step that implements an UPDATE statement and return
  93459 // a pointer to that trigger step.  The parser calls this routine when it
  93460 // sees an UPDATE statement inside the body of a CREATE TRIGGER.
  93461 func Xsqlite3TriggerUpdateStep(tls *libc.TLS, pParse uintptr, pTableName uintptr, pFrom uintptr, pEList uintptr, pWhere uintptr, orconf U8, zStart uintptr, zEnd uintptr) uintptr {
  93462 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93463 	var pTriggerStep uintptr
  93464 
  93465 	pTriggerStep = triggerStepAllocate(tls, pParse, uint8(TK_UPDATE), pTableName, zStart, zEnd)
  93466 	if pTriggerStep != 0 {
  93467 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  93468 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = pEList
  93469 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere
  93470 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = pFrom
  93471 			pEList = uintptr(0)
  93472 			pWhere = uintptr(0)
  93473 			pFrom = uintptr(0)
  93474 		} else {
  93475 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pEList, EXPRDUP_REDUCE)
  93476 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE)
  93477 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = Xsqlite3SrcListDup(tls, db, pFrom, EXPRDUP_REDUCE)
  93478 		}
  93479 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = orconf
  93480 	}
  93481 	Xsqlite3ExprListDelete(tls, db, pEList)
  93482 	Xsqlite3ExprDelete(tls, db, pWhere)
  93483 	Xsqlite3SrcListDelete(tls, db, pFrom)
  93484 	return pTriggerStep
  93485 }
  93486 
  93487 // Construct a trigger step that implements a DELETE statement and return
  93488 // a pointer to that trigger step.  The parser calls this routine when it
  93489 // sees a DELETE statement inside the body of a CREATE TRIGGER.
  93490 func Xsqlite3TriggerDeleteStep(tls *libc.TLS, pParse uintptr, pTableName uintptr, pWhere uintptr, zStart uintptr, zEnd uintptr) uintptr {
  93491 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93492 	var pTriggerStep uintptr
  93493 
  93494 	pTriggerStep = triggerStepAllocate(tls, pParse, uint8(TK_DELETE), pTableName, zStart, zEnd)
  93495 	if pTriggerStep != 0 {
  93496 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
  93497 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere
  93498 			pWhere = uintptr(0)
  93499 		} else {
  93500 			(*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE)
  93501 		}
  93502 		(*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = U8(OE_Default)
  93503 	}
  93504 	Xsqlite3ExprDelete(tls, db, pWhere)
  93505 	return pTriggerStep
  93506 }
  93507 
  93508 // Recursively delete a Trigger structure
  93509 func Xsqlite3DeleteTrigger(tls *libc.TLS, db uintptr, pTrigger uintptr) {
  93510 	if pTrigger == uintptr(0) || (*Trigger)(unsafe.Pointer(pTrigger)).FbReturning != 0 {
  93511 		return
  93512 	}
  93513 	Xsqlite3DeleteTriggerStep(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).Fstep_list)
  93514 	Xsqlite3DbFree(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).FzName)
  93515 	Xsqlite3DbFree(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable)
  93516 	Xsqlite3ExprDelete(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen)
  93517 	Xsqlite3IdListDelete(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).FpColumns)
  93518 	Xsqlite3DbFree(tls, db, pTrigger)
  93519 }
  93520 
  93521 // This function is called to drop a trigger from the database schema.
  93522 //
  93523 // This may be called directly from the parser and therefore identifies
  93524 // the trigger by name.  The sqlite3DropTriggerPtr() routine does the
  93525 // same job as this routine except it takes a pointer to the trigger
  93526 // instead of the trigger name.
  93527 func Xsqlite3DropTrigger(tls *libc.TLS, pParse uintptr, pName uintptr, noErr int32) {
  93528 	bp := tls.Alloc(8)
  93529 	defer tls.Free(8)
  93530 
  93531 	var pTrigger uintptr
  93532 	var i int32
  93533 	var zDb uintptr
  93534 	var zName uintptr
  93535 	var db uintptr
  93536 	var j int32
  93537 	pTrigger = uintptr(0)
  93538 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93539 
  93540 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  93541 		goto __1
  93542 	}
  93543 	goto drop_trigger_cleanup
  93544 __1:
  93545 	;
  93546 	if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) {
  93547 		goto __2
  93548 	}
  93549 	goto drop_trigger_cleanup
  93550 __2:
  93551 	;
  93552 	zDb = (*SrcItem)(unsafe.Pointer(pName + 8)).FzDatabase
  93553 	zName = (*SrcItem)(unsafe.Pointer(pName + 8)).FzName
  93554 
  93555 	i = OMIT_TEMPDB
  93556 __3:
  93557 	if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) {
  93558 		goto __5
  93559 	}
  93560 	if i < 2 {
  93561 		j = i ^ 1
  93562 	} else {
  93563 		j = i
  93564 	}
  93565 	if !(zDb != 0 && Xsqlite3DbIsNamed(tls, db, j, zDb) == 0) {
  93566 		goto __6
  93567 	}
  93568 	goto __4
  93569 __6:
  93570 	;
  93571 	pTrigger = Xsqlite3HashFind(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(j)*16)).FpSchema+40, zName)
  93572 	if !(pTrigger != 0) {
  93573 		goto __7
  93574 	}
  93575 	goto __5
  93576 __7:
  93577 	;
  93578 	goto __4
  93579 __4:
  93580 	i++
  93581 	goto __3
  93582 	goto __5
  93583 __5:
  93584 	;
  93585 	if !!(pTrigger != 0) {
  93586 		goto __8
  93587 	}
  93588 	if !!(noErr != 0) {
  93589 		goto __9
  93590 	}
  93591 	Xsqlite3ErrorMsg(tls, pParse, ts+20339, libc.VaList(bp, pName+8))
  93592 	goto __10
  93593 __9:
  93594 	Xsqlite3CodeVerifyNamedSchema(tls, pParse, zDb)
  93595 __10:
  93596 	;
  93597 	(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  93598 	goto drop_trigger_cleanup
  93599 __8:
  93600 	;
  93601 	Xsqlite3DropTriggerPtr(tls, pParse, pTrigger)
  93602 
  93603 drop_trigger_cleanup:
  93604 	Xsqlite3SrcListDelete(tls, db, pName)
  93605 }
  93606 
  93607 func tableOfTrigger(tls *libc.TLS, pTrigger uintptr) uintptr {
  93608 	return Xsqlite3HashFind(tls, (*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema+8, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable)
  93609 }
  93610 
  93611 // Drop a trigger given a pointer to that trigger.
  93612 func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) {
  93613 	bp := tls.Alloc(16)
  93614 	defer tls.Free(16)
  93615 
  93616 	var pTable uintptr
  93617 	var v uintptr
  93618 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93619 	var iDb int32
  93620 
  93621 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Trigger)(unsafe.Pointer(pTrigger)).FpSchema)
  93622 
  93623 	pTable = tableOfTrigger(tls, pTrigger)
  93624 
  93625 	if pTable != 0 {
  93626 		var code int32 = SQLITE_DROP_TRIGGER
  93627 		var zDb uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  93628 		var zTab uintptr = func() uintptr {
  93629 			if !(0 != 0) && iDb == 1 {
  93630 				return ts + 6389
  93631 			}
  93632 			return ts + 5883
  93633 		}()
  93634 		if iDb == 1 {
  93635 			code = SQLITE_DROP_TEMP_TRIGGER
  93636 		}
  93637 		if Xsqlite3AuthCheck(tls, pParse, code, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, (*Table)(unsafe.Pointer(pTable)).FzName, zDb) != 0 || Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0 {
  93638 			return
  93639 		}
  93640 	}
  93641 
  93642 	if libc.AssignUintptr(&v, Xsqlite3GetVdbe(tls, pParse)) != uintptr(0) {
  93643 		Xsqlite3NestedParse(tls, pParse,
  93644 			ts+20359,
  93645 			libc.VaList(bp, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName, (*Trigger)(unsafe.Pointer(pTrigger)).FzName))
  93646 		Xsqlite3ChangeCookie(tls, pParse, iDb)
  93647 		Xsqlite3VdbeAddOp4(tls, v, OP_DropTrigger, iDb, 0, 0, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, 0)
  93648 	}
  93649 }
  93650 
  93651 // Remove a trigger from the hash tables of the sqlite* pointer.
  93652 func Xsqlite3UnlinkAndDeleteTrigger(tls *libc.TLS, db uintptr, iDb int32, zName uintptr) {
  93653 	var pTrigger uintptr
  93654 	var pHash uintptr
  93655 
  93656 	pHash = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema + 40
  93657 	pTrigger = Xsqlite3HashInsert(tls, pHash, zName, uintptr(0))
  93658 	if pTrigger != 0 {
  93659 		if (*Trigger)(unsafe.Pointer(pTrigger)).FpSchema == (*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema {
  93660 			var pTab uintptr = tableOfTrigger(tls, pTrigger)
  93661 			if pTab != 0 {
  93662 				var pp uintptr
  93663 				for pp = pTab + 56; *(*uintptr)(unsafe.Pointer(pp)) != 0; pp = *(*uintptr)(unsafe.Pointer(pp)) + 32 {
  93664 					if *(*uintptr)(unsafe.Pointer(pp)) == pTrigger {
  93665 						*(*uintptr)(unsafe.Pointer(pp)) = (*Trigger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext
  93666 						break
  93667 					}
  93668 				}
  93669 			}
  93670 		}
  93671 		Xsqlite3DeleteTrigger(tls, db, pTrigger)
  93672 		*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_SchemaChange)
  93673 	}
  93674 }
  93675 
  93676 func checkColumnOverlap(tls *libc.TLS, pIdList uintptr, pEList uintptr) int32 {
  93677 	var e int32
  93678 	if pIdList == uintptr(0) || pEList == uintptr(0) {
  93679 		return 1
  93680 	}
  93681 	for e = 0; e < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; e++ {
  93682 		if Xsqlite3IdListIndex(tls, pIdList, (*ExprList_item)(unsafe.Pointer(pEList+8+uintptr(e)*20)).FzEName) >= 0 {
  93683 			return 1
  93684 		}
  93685 	}
  93686 	return 0
  93687 }
  93688 
  93689 func tempTriggersExist(tls *libc.TLS, db uintptr) int32 {
  93690 	if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema == uintptr(0) {
  93691 		return 0
  93692 	}
  93693 	if (*Hash)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema+40)).Ffirst == uintptr(0) {
  93694 		return 0
  93695 	}
  93696 	return 1
  93697 }
  93698 
  93699 func triggersReallyExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, pChanges uintptr, pMask uintptr) uintptr {
  93700 	bp := tls.Alloc(8)
  93701 	defer tls.Free(8)
  93702 
  93703 	var mask int32
  93704 	var pList uintptr
  93705 	var p uintptr
  93706 	mask = 0
  93707 	pList = uintptr(0)
  93708 
  93709 	pList = Xsqlite3TriggerList(tls, pParse, pTab)
  93710 
  93711 	if !(pList != uintptr(0)) {
  93712 		goto __1
  93713 	}
  93714 	p = pList
  93715 	if !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableTrigger) == uint64(0) &&
  93716 		(*Table)(unsafe.Pointer(pTab)).FpTrigger != uintptr(0)) {
  93717 		goto __2
  93718 	}
  93719 
  93720 	if !(pList == (*Table)(unsafe.Pointer(pTab)).FpTrigger) {
  93721 		goto __3
  93722 	}
  93723 	pList = uintptr(0)
  93724 	goto exit_triggers_exist
  93725 __3:
  93726 	;
  93727 __4:
  93728 	if !((*Trigger)(unsafe.Pointer(p)).FpNext != 0 && (*Trigger)(unsafe.Pointer(p)).FpNext != (*Table)(unsafe.Pointer(pTab)).FpTrigger) {
  93729 		goto __5
  93730 	}
  93731 	p = (*Trigger)(unsafe.Pointer(p)).FpNext
  93732 	goto __4
  93733 __5:
  93734 	;
  93735 	(*Trigger)(unsafe.Pointer(p)).FpNext = uintptr(0)
  93736 	p = pList
  93737 __2:
  93738 	;
  93739 __6:
  93740 	if !(int32((*Trigger)(unsafe.Pointer(p)).Fop) == op && checkColumnOverlap(tls, (*Trigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0) {
  93741 		goto __9
  93742 	}
  93743 	mask = mask | int32((*Trigger)(unsafe.Pointer(p)).Ftr_tm)
  93744 	goto __10
  93745 __9:
  93746 	if !(int32((*Trigger)(unsafe.Pointer(p)).Fop) == TK_RETURNING) {
  93747 		goto __11
  93748 	}
  93749 
  93750 	(*Trigger)(unsafe.Pointer(p)).Fop = U8(op)
  93751 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  93752 		goto __13
  93753 	}
  93754 	if !(op != TK_INSERT) {
  93755 		goto __15
  93756 	}
  93757 	Xsqlite3ErrorMsg(tls, pParse,
  93758 		ts+20421,
  93759 		libc.VaList(bp, func() uintptr {
  93760 			if op == TK_DELETE {
  93761 				return ts + 20469
  93762 			}
  93763 			return ts + 20476
  93764 		}()))
  93765 __15:
  93766 	;
  93767 	(*Trigger)(unsafe.Pointer(p)).Ftr_tm = U8(TRIGGER_BEFORE)
  93768 	goto __14
  93769 __13:
  93770 	(*Trigger)(unsafe.Pointer(p)).Ftr_tm = U8(TRIGGER_AFTER)
  93771 __14:
  93772 	;
  93773 	mask = mask | int32((*Trigger)(unsafe.Pointer(p)).Ftr_tm)
  93774 	goto __12
  93775 __11:
  93776 	if !((*Trigger)(unsafe.Pointer(p)).FbReturning != 0 && int32((*Trigger)(unsafe.Pointer(p)).Fop) == TK_INSERT && op == TK_UPDATE &&
  93777 		(*Parse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0)) {
  93778 		goto __16
  93779 	}
  93780 
  93781 	mask = mask | int32((*Trigger)(unsafe.Pointer(p)).Ftr_tm)
  93782 __16:
  93783 	;
  93784 __12:
  93785 	;
  93786 __10:
  93787 	;
  93788 	p = (*Trigger)(unsafe.Pointer(p)).FpNext
  93789 	goto __7
  93790 __7:
  93791 	if p != 0 {
  93792 		goto __6
  93793 	}
  93794 	goto __8
  93795 __8:
  93796 	;
  93797 __1:
  93798 	;
  93799 exit_triggers_exist:
  93800 	if !(pMask != 0) {
  93801 		goto __17
  93802 	}
  93803 	*(*int32)(unsafe.Pointer(pMask)) = mask
  93804 __17:
  93805 	;
  93806 	return func() uintptr {
  93807 		if mask != 0 {
  93808 			return pList
  93809 		}
  93810 		return uintptr(0)
  93811 	}()
  93812 }
  93813 
  93814 func Xsqlite3TriggersExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, pChanges uintptr, pMask uintptr) uintptr {
  93815 	if (*Table)(unsafe.Pointer(pTab)).FpTrigger == uintptr(0) && !(tempTriggersExist(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb) != 0) ||
  93816 		(*Parse)(unsafe.Pointer(pParse)).FdisableTriggers != 0 {
  93817 		if pMask != 0 {
  93818 			*(*int32)(unsafe.Pointer(pMask)) = 0
  93819 		}
  93820 		return uintptr(0)
  93821 	}
  93822 	return triggersReallyExist(tls, pParse, pTab, op, pChanges, pMask)
  93823 }
  93824 
  93825 // Convert the pStep->zTarget string into a SrcList and return a pointer
  93826 // to that SrcList.
  93827 //
  93828 // This routine adds a specific database name, if needed, to the target when
  93829 // forming the SrcList.  This prevents a trigger in one database from
  93830 // referring to a target in another database.  An exception is when the
  93831 // trigger is in TEMP in which case it can refer to any other database it
  93832 // wants.
  93833 func Xsqlite3TriggerStepSrc(tls *libc.TLS, pParse uintptr, pStep uintptr) uintptr {
  93834 	bp := tls.Alloc(8)
  93835 	defer tls.Free(8)
  93836 
  93837 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93838 	var pSrc uintptr
  93839 	var zName uintptr = Xsqlite3DbStrDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget)
  93840 	pSrc = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0))
  93841 
  93842 	if pSrc != 0 {
  93843 		var pSchema uintptr = (*Trigger)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpTrig)).FpSchema
  93844 		(*SrcItem)(unsafe.Pointer(pSrc + 8)).FzName = zName
  93845 		if pSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema {
  93846 			(*SrcItem)(unsafe.Pointer(pSrc + 8)).FpSchema = pSchema
  93847 		}
  93848 		if (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom != 0 {
  93849 			var pDup uintptr = Xsqlite3SrcListDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom, 0)
  93850 			if pDup != 0 && (*SrcList)(unsafe.Pointer(pDup)).FnSrc > 1 && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
  93851 				var pSubquery uintptr
  93852 
  93853 				pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), pDup, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0))
  93854 				(*Token)(unsafe.Pointer(bp)).Fn = uint32(0)
  93855 				(*Token)(unsafe.Pointer(bp)).Fz = uintptr(0)
  93856 				pDup = Xsqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp, pSubquery, uintptr(0))
  93857 			}
  93858 			pSrc = Xsqlite3SrcListAppendList(tls, pParse, pSrc, pDup)
  93859 		}
  93860 	} else {
  93861 		Xsqlite3DbFree(tls, db, zName)
  93862 	}
  93863 	return pSrc
  93864 }
  93865 
  93866 func isAsteriskTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr) int32 {
  93867 	if int32((*Expr)(unsafe.Pointer(pTerm)).Fop) == TK_ASTERISK {
  93868 		return 1
  93869 	}
  93870 	if int32((*Expr)(unsafe.Pointer(pTerm)).Fop) != TK_DOT {
  93871 		return 0
  93872 	}
  93873 
  93874 	if int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pTerm)).FpRight)).Fop) != TK_ASTERISK {
  93875 		return 0
  93876 	}
  93877 	Xsqlite3ErrorMsg(tls, pParse, ts+20483, 0)
  93878 	return 1
  93879 }
  93880 
  93881 func sqlite3ExpandReturning(tls *libc.TLS, pParse uintptr, pList uintptr, pTab uintptr) uintptr {
  93882 	var pNew uintptr = uintptr(0)
  93883 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93884 	var i int32
  93885 
  93886 	for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
  93887 		var pOldExpr uintptr = (*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*20)).FpExpr
  93888 		if pOldExpr == uintptr(0) {
  93889 			continue
  93890 		}
  93891 		if isAsteriskTerm(tls, pParse, pOldExpr) != 0 {
  93892 			var jj int32
  93893 			for jj = 0; jj < int32((*Table)(unsafe.Pointer(pTab)).FnCol); jj++ {
  93894 				var pNewExpr uintptr
  93895 				if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(jj)*16)).FcolFlags)&COLFLAG_HIDDEN != 0 {
  93896 					continue
  93897 				}
  93898 				pNewExpr = Xsqlite3Expr(tls, db, TK_ID, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(jj)*16)).FzCnName)
  93899 				pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, pNewExpr)
  93900 				if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  93901 					var pItem uintptr = pNew + 8 + uintptr((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1)*20
  93902 					(*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbStrDup(tls, db, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(jj)*16)).FzCnName)
  93903 					libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(ENAME_NAME), 0, 0x3)
  93904 				}
  93905 			}
  93906 		} else {
  93907 			var pNewExpr uintptr = Xsqlite3ExprDup(tls, db, pOldExpr, 0)
  93908 			pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, pNewExpr)
  93909 			if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) && (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FzEName != uintptr(0) {
  93910 				var pItem uintptr = pNew + 8 + uintptr((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1)*20
  93911 				(*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbStrDup(tls, db, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FzEName)
  93912 				libc.SetBitFieldPtr16Uint32(pItem+8+4, uint32(int32(*(*uint16)(unsafe.Pointer(pList + 8 + uintptr(i)*20 + 8 + 4))&0x3>>0)), 0, 0x3)
  93913 			}
  93914 		}
  93915 	}
  93916 	return pNew
  93917 }
  93918 
  93919 func codeReturningTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, regIn int32) {
  93920 	bp := tls.Alloc(192)
  93921 	defer tls.Free(192)
  93922 
  93923 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  93924 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93925 	var pNew uintptr
  93926 	var pReturning uintptr
  93927 
  93928 	pReturning = *(*uintptr)(unsafe.Pointer(pParse + 136))
  93929 
  93930 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Select{})))
  93931 	libc.Xmemset(tls, bp+80, 0, uint32(unsafe.Sizeof(SrcList{})))
  93932 	(*Select)(unsafe.Pointer(bp)).FpEList = Xsqlite3ExprListDup(tls, db, (*Returning)(unsafe.Pointer(pReturning)).FpReturnEL, 0)
  93933 	(*Select)(unsafe.Pointer(bp)).FpSrc = bp + 80
  93934 	(*SrcList)(unsafe.Pointer(bp + 80)).FnSrc = 1
  93935 	(*SrcItem)(unsafe.Pointer(bp + 80 + 8)).FpTab = pTab
  93936 	(*SrcItem)(unsafe.Pointer(bp + 80 + 8)).FiCursor = -1
  93937 	Xsqlite3SelectPrep(tls, pParse, bp, uintptr(0))
  93938 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  93939 		Xsqlite3GenerateColumnNames(tls, pParse, bp)
  93940 	}
  93941 	Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(bp)).FpEList)
  93942 	pNew = sqlite3ExpandReturning(tls, pParse, (*Returning)(unsafe.Pointer(pReturning)).FpReturnEL, pTab)
  93943 	if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  93944 		libc.Xmemset(tls, bp+160, 0, uint32(unsafe.Sizeof(NameContext{})))
  93945 		if (*Returning)(unsafe.Pointer(pReturning)).FnRetCol == 0 {
  93946 			(*Returning)(unsafe.Pointer(pReturning)).FnRetCol = (*ExprList)(unsafe.Pointer(pNew)).FnExpr
  93947 			(*Returning)(unsafe.Pointer(pReturning)).FiRetCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  93948 		}
  93949 		(*NameContext)(unsafe.Pointer(bp + 160)).FpParse = pParse
  93950 		*(*int32)(unsafe.Pointer(bp + 160 + 8)) = regIn
  93951 		(*NameContext)(unsafe.Pointer(bp + 160)).FncFlags = NC_UBaseReg
  93952 		(*Parse)(unsafe.Pointer(pParse)).FeTriggerOp = (*Trigger)(unsafe.Pointer(pTrigger)).Fop
  93953 		(*Parse)(unsafe.Pointer(pParse)).FpTriggerTab = pTab
  93954 		if Xsqlite3ResolveExprListNames(tls, bp+160, pNew) == SQLITE_OK &&
  93955 			!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  93956 			var i int32
  93957 			var nCol int32 = (*ExprList)(unsafe.Pointer(pNew)).FnExpr
  93958 			var reg int32 = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  93959 			*(*int32)(unsafe.Pointer(pParse + 44)) += nCol + 2
  93960 			(*Returning)(unsafe.Pointer(pReturning)).FiRetReg = reg
  93961 			for i = 0; i < nCol; i++ {
  93962 				var pCol uintptr = (*ExprList_item)(unsafe.Pointer(pNew + 8 + uintptr(i)*20)).FpExpr
  93963 
  93964 				Xsqlite3ExprCodeFactorable(tls, pParse, pCol, reg+i)
  93965 				if int32(Xsqlite3ExprAffinity(tls, pCol)) == SQLITE_AFF_REAL {
  93966 					Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, reg+i)
  93967 				}
  93968 			}
  93969 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, reg, i, reg+i)
  93970 			Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, (*Returning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i+1)
  93971 			Xsqlite3VdbeAddOp3(tls, v, OP_Insert, (*Returning)(unsafe.Pointer(pReturning)).FiRetCur, reg+i, reg+i+1)
  93972 		}
  93973 	}
  93974 	Xsqlite3ExprListDelete(tls, db, pNew)
  93975 	(*Parse)(unsafe.Pointer(pParse)).FeTriggerOp = U8(0)
  93976 	(*Parse)(unsafe.Pointer(pParse)).FpTriggerTab = uintptr(0)
  93977 }
  93978 
  93979 func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf int32) int32 {
  93980 	bp := tls.Alloc(36)
  93981 	defer tls.Free(36)
  93982 
  93983 	var pStep uintptr
  93984 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  93985 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  93986 
  93987 	for pStep = pStepList; pStep != 0; pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext {
  93988 		(*Parse)(unsafe.Pointer(pParse)).FeOrconf = func() uint8 {
  93989 			if orconf == OE_Default {
  93990 				return (*TriggerStep)(unsafe.Pointer(pStep)).Forconf
  93991 			}
  93992 			return U8(orconf)
  93993 		}()
  93994 
  93995 		if (*TriggerStep)(unsafe.Pointer(pStep)).FzSpan != 0 {
  93996 			Xsqlite3VdbeAddOp4(tls, v, OP_Trace, 0x7fffffff, 1, 0,
  93997 				Xsqlite3MPrintf(tls, db, ts+6080, libc.VaList(bp, (*TriggerStep)(unsafe.Pointer(pStep)).FzSpan)),
  93998 				-6)
  93999 		}
  94000 
  94001 		switch int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) {
  94002 		case TK_UPDATE:
  94003 			{
  94004 				Xsqlite3Update(tls, pParse,
  94005 					Xsqlite3TriggerStepSrc(tls, pParse, pStep),
  94006 					Xsqlite3ExprListDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList, 0),
  94007 					Xsqlite3ExprDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere, 0),
  94008 					int32((*Parse)(unsafe.Pointer(pParse)).FeOrconf), uintptr(0), uintptr(0), uintptr(0))
  94009 				Xsqlite3VdbeAddOp0(tls, v, OP_ResetCount)
  94010 				break
  94011 
  94012 			}
  94013 		case TK_INSERT:
  94014 			{
  94015 				Xsqlite3Insert(tls, pParse,
  94016 					Xsqlite3TriggerStepSrc(tls, pParse, pStep),
  94017 					Xsqlite3SelectDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, 0),
  94018 					Xsqlite3IdListDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpIdList),
  94019 					int32((*Parse)(unsafe.Pointer(pParse)).FeOrconf),
  94020 					Xsqlite3UpsertDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpUpsert))
  94021 				Xsqlite3VdbeAddOp0(tls, v, OP_ResetCount)
  94022 				break
  94023 
  94024 			}
  94025 		case TK_DELETE:
  94026 			{
  94027 				Xsqlite3DeleteFrom(tls, pParse,
  94028 					Xsqlite3TriggerStepSrc(tls, pParse, pStep),
  94029 					Xsqlite3ExprDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere, 0), uintptr(0), uintptr(0))
  94030 				Xsqlite3VdbeAddOp0(tls, v, OP_ResetCount)
  94031 				break
  94032 
  94033 			}
  94034 		default:
  94035 			{
  94036 				var pSelect uintptr = Xsqlite3SelectDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, 0)
  94037 				Xsqlite3SelectDestInit(tls, bp+8, SRT_Discard, 0)
  94038 				Xsqlite3Select(tls, pParse, pSelect, bp+8)
  94039 				Xsqlite3SelectDelete(tls, db, pSelect)
  94040 				break
  94041 
  94042 			}
  94043 		}
  94044 	}
  94045 
  94046 	return 0
  94047 }
  94048 
  94049 func transferParseError(tls *libc.TLS, pTo uintptr, pFrom uintptr) {
  94050 	if (*Parse)(unsafe.Pointer(pTo)).FnErr == 0 {
  94051 		(*Parse)(unsafe.Pointer(pTo)).FzErrMsg = (*Parse)(unsafe.Pointer(pFrom)).FzErrMsg
  94052 		(*Parse)(unsafe.Pointer(pTo)).FnErr = (*Parse)(unsafe.Pointer(pFrom)).FnErr
  94053 		(*Parse)(unsafe.Pointer(pTo)).Frc = (*Parse)(unsafe.Pointer(pFrom)).Frc
  94054 	} else {
  94055 		Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pFrom)).Fdb, (*Parse)(unsafe.Pointer(pFrom)).FzErrMsg)
  94056 	}
  94057 }
  94058 
  94059 func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, orconf int32) uintptr {
  94060 	bp := tls.Alloc(320)
  94061 	defer tls.Free(320)
  94062 
  94063 	var pTop uintptr = func() uintptr {
  94064 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  94065 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  94066 		}
  94067 		return pParse
  94068 	}()
  94069 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  94070 	var pPrg uintptr
  94071 	var pWhen uintptr = uintptr(0)
  94072 	var v uintptr
  94073 
  94074 	var pProgram uintptr = uintptr(0)
  94075 	var iEndTrigger int32 = 0
  94076 
  94077 	pPrg = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(TriggerPrg{})))
  94078 	if !(pPrg != 0) {
  94079 		return uintptr(0)
  94080 	}
  94081 	(*TriggerPrg)(unsafe.Pointer(pPrg)).FpNext = (*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg
  94082 	(*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg = pPrg
  94083 	(*TriggerPrg)(unsafe.Pointer(pPrg)).FpProgram = libc.AssignUintptr(&pProgram, Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(SubProgram{}))))
  94084 	if !(pProgram != 0) {
  94085 		return uintptr(0)
  94086 	}
  94087 	Xsqlite3VdbeLinkSubProgram(tls, (*Parse)(unsafe.Pointer(pTop)).FpVdbe, pProgram)
  94088 	(*TriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger = pTrigger
  94089 	(*TriggerPrg)(unsafe.Pointer(pPrg)).Forconf = orconf
  94090 	*(*U32)(unsafe.Pointer(pPrg + 16)) = 0xffffffff
  94091 	*(*U32)(unsafe.Pointer(pPrg + 16 + 1*4)) = 0xffffffff
  94092 
  94093 	Xsqlite3ParseObjectInit(tls, bp+8, db)
  94094 	libc.Xmemset(tls, bp+288, 0, uint32(unsafe.Sizeof(NameContext{})))
  94095 	(*NameContext)(unsafe.Pointer(bp + 288)).FpParse = bp + 8
  94096 	(*Parse)(unsafe.Pointer(bp + 8)).FpTriggerTab = pTab
  94097 	(*Parse)(unsafe.Pointer(bp + 8)).FpToplevel = pTop
  94098 	(*Parse)(unsafe.Pointer(bp + 8)).FzAuthContext = (*Trigger)(unsafe.Pointer(pTrigger)).FzName
  94099 	(*Parse)(unsafe.Pointer(bp + 8)).FeTriggerOp = (*Trigger)(unsafe.Pointer(pTrigger)).Fop
  94100 	(*Parse)(unsafe.Pointer(bp + 8)).FnQueryLoop = (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop
  94101 	(*Parse)(unsafe.Pointer(bp + 8)).FprepFlags = (*Parse)(unsafe.Pointer(pParse)).FprepFlags
  94102 
  94103 	v = Xsqlite3GetVdbe(tls, bp+8)
  94104 	if v != 0 {
  94105 		if (*Trigger)(unsafe.Pointer(pTrigger)).FzName != 0 {
  94106 			Xsqlite3VdbeChangeP4(tls, v, -1,
  94107 				Xsqlite3MPrintf(tls, db, ts+20525, libc.VaList(bp, (*Trigger)(unsafe.Pointer(pTrigger)).FzName)), -6)
  94108 		}
  94109 
  94110 		if (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen != 0 {
  94111 			pWhen = Xsqlite3ExprDup(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen, 0)
  94112 			if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 &&
  94113 				SQLITE_OK == Xsqlite3ResolveExprNames(tls, bp+288, pWhen) {
  94114 				iEndTrigger = Xsqlite3VdbeMakeLabel(tls, bp+8)
  94115 				Xsqlite3ExprIfFalse(tls, bp+8, pWhen, iEndTrigger, SQLITE_JUMPIFNULL)
  94116 			}
  94117 			Xsqlite3ExprDelete(tls, db, pWhen)
  94118 		}
  94119 
  94120 		codeTriggerProgram(tls, bp+8, (*Trigger)(unsafe.Pointer(pTrigger)).Fstep_list, orconf)
  94121 
  94122 		if iEndTrigger != 0 {
  94123 			Xsqlite3VdbeResolveLabel(tls, v, iEndTrigger)
  94124 		}
  94125 		Xsqlite3VdbeAddOp0(tls, v, OP_Halt)
  94126 
  94127 		transferParseError(tls, pParse, bp+8)
  94128 
  94129 		if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  94130 			(*SubProgram)(unsafe.Pointer(pProgram)).FaOp = Xsqlite3VdbeTakeOpArray(tls, v, pProgram+4, pTop+100)
  94131 		}
  94132 		(*SubProgram)(unsafe.Pointer(pProgram)).FnMem = (*Parse)(unsafe.Pointer(bp + 8)).FnMem
  94133 		(*SubProgram)(unsafe.Pointer(pProgram)).FnCsr = (*Parse)(unsafe.Pointer(bp + 8)).FnTab
  94134 		(*SubProgram)(unsafe.Pointer(pProgram)).Ftoken = pTrigger
  94135 		*(*U32)(unsafe.Pointer(pPrg + 16)) = (*Parse)(unsafe.Pointer(bp + 8)).Foldmask
  94136 		*(*U32)(unsafe.Pointer(pPrg + 16 + 1*4)) = (*Parse)(unsafe.Pointer(bp + 8)).Fnewmask
  94137 		Xsqlite3VdbeDelete(tls, v)
  94138 	} else {
  94139 		transferParseError(tls, pParse, bp+8)
  94140 	}
  94141 
  94142 	Xsqlite3ParseObjectReset(tls, bp+8)
  94143 	return pPrg
  94144 }
  94145 
  94146 func getRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, orconf int32) uintptr {
  94147 	var pRoot uintptr = func() uintptr {
  94148 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  94149 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  94150 		}
  94151 		return pParse
  94152 	}()
  94153 	var pPrg uintptr
  94154 
  94155 	for pPrg = (*Parse)(unsafe.Pointer(pRoot)).FpTriggerPrg; pPrg != 0 && ((*TriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger != pTrigger || (*TriggerPrg)(unsafe.Pointer(pPrg)).Forconf != orconf); pPrg = (*TriggerPrg)(unsafe.Pointer(pPrg)).FpNext {
  94156 	}
  94157 
  94158 	if !(pPrg != 0) {
  94159 		pPrg = codeRowTrigger(tls, pParse, pTrigger, pTab, orconf)
  94160 		(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FerrByteOffset = -1
  94161 	}
  94162 
  94163 	return pPrg
  94164 }
  94165 
  94166 // Generate code for the trigger program associated with trigger p on
  94167 // table pTab. The reg, orconf and ignoreJump parameters passed to this
  94168 // function are the same as those described in the header function for
  94169 // sqlite3CodeRowTrigger()
  94170 func Xsqlite3CodeRowTriggerDirect(tls *libc.TLS, pParse uintptr, p uintptr, pTab uintptr, reg int32, orconf int32, ignoreJump int32) {
  94171 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
  94172 	var pPrg uintptr
  94173 	pPrg = getRowTrigger(tls, pParse, p, pTab, orconf)
  94174 
  94175 	if pPrg != 0 {
  94176 		var bRecursive int32 = libc.Bool32((*Trigger)(unsafe.Pointer(p)).FzName != 0 && uint64(0) == (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_RecTriggers))
  94177 
  94178 		Xsqlite3VdbeAddOp4(tls, v, OP_Program, reg, ignoreJump, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1),
  94179 			(*TriggerPrg)(unsafe.Pointer(pPrg)).FpProgram, -4)
  94180 
  94181 		Xsqlite3VdbeChangeP5(tls, v, uint16(U8(bRecursive)))
  94182 	}
  94183 }
  94184 
  94185 // This is called to code the required FOR EACH ROW triggers for an operation
  94186 // on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)
  94187 // is given by the op parameter. The tr_tm parameter determines whether the
  94188 // BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
  94189 // parameter pChanges is passed the list of columns being modified.
  94190 //
  94191 // If there are no triggers that fire at the specified time for the specified
  94192 // operation on pTab, this function is a no-op.
  94193 //
  94194 // The reg argument is the address of the first in an array of registers
  94195 // that contain the values substituted for the new.* and old.* references
  94196 // in the trigger program. If N is the number of columns in table pTab
  94197 // (a copy of pTab->nCol), then registers are populated as follows:
  94198 //
  94199 //	Register       Contains
  94200 //	------------------------------------------------------
  94201 //	reg+0          OLD.rowid
  94202 //	reg+1          OLD.* value of left-most column of pTab
  94203 //	...            ...
  94204 //	reg+N          OLD.* value of right-most column of pTab
  94205 //	reg+N+1        NEW.rowid
  94206 //	reg+N+2        NEW.* value of left-most column of pTab
  94207 //	...            ...
  94208 //	reg+N+N+1      NEW.* value of right-most column of pTab
  94209 //
  94210 // For ON DELETE triggers, the registers containing the NEW.* values will
  94211 // never be accessed by the trigger program, so they are not allocated or
  94212 // populated by the caller (there is no data to populate them with anyway).
  94213 // Similarly, for ON INSERT triggers the values stored in the OLD.* registers
  94214 // are never accessed, and so are not allocated by the caller. So, for an
  94215 // ON INSERT trigger, the value passed to this function as parameter reg
  94216 // is not a readable register, although registers (reg+N) through
  94217 // (reg+N+N+1) are.
  94218 //
  94219 // Parameter orconf is the default conflict resolution algorithm for the
  94220 // trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump
  94221 // is the instruction that control should jump to if a trigger program
  94222 // raises an IGNORE exception.
  94223 func Xsqlite3CodeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, op int32, pChanges uintptr, tr_tm int32, pTab uintptr, reg int32, orconf int32, ignoreJump int32) {
  94224 	var p uintptr
  94225 
  94226 	for p = pTrigger; p != 0; p = (*Trigger)(unsafe.Pointer(p)).FpNext {
  94227 		if (int32((*Trigger)(unsafe.Pointer(p)).Fop) == op || (*Trigger)(unsafe.Pointer(p)).FbReturning != 0 && int32((*Trigger)(unsafe.Pointer(p)).Fop) == TK_INSERT && op == TK_UPDATE) &&
  94228 			int32((*Trigger)(unsafe.Pointer(p)).Ftr_tm) == tr_tm &&
  94229 			checkColumnOverlap(tls, (*Trigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 {
  94230 			if !(int32((*Trigger)(unsafe.Pointer(p)).FbReturning) != 0) {
  94231 				Xsqlite3CodeRowTriggerDirect(tls, pParse, p, pTab, reg, orconf, ignoreJump)
  94232 			} else if (*Parse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) {
  94233 				codeReturningTrigger(tls, pParse, p, pTab, reg)
  94234 			}
  94235 		}
  94236 	}
  94237 }
  94238 
  94239 // Triggers may access values stored in the old.* or new.* pseudo-table.
  94240 // This function returns a 32-bit bitmask indicating which columns of the
  94241 // old.* or new.* tables actually are used by triggers. This information
  94242 // may be used by the caller, for example, to avoid having to load the entire
  94243 // old.* record into memory when executing an UPDATE or DELETE command.
  94244 //
  94245 // Bit 0 of the returned mask is set if the left-most column of the
  94246 // table may be accessed using an [old|new].<col> reference. Bit 1 is set if
  94247 // the second leftmost column value is required, and so on. If there
  94248 // are more than 32 columns in the table, and at least one of the columns
  94249 // with an index greater than 32 may be accessed, 0xffffffff is returned.
  94250 //
  94251 // It is not possible to determine if the old.rowid or new.rowid column is
  94252 // accessed by triggers. The caller must always assume that it is.
  94253 //
  94254 // Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
  94255 // applies to the old.* table. If 1, the new.* table.
  94256 //
  94257 // Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE
  94258 // and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only
  94259 // included in the returned mask if the TRIGGER_BEFORE bit is set in the
  94260 // tr_tm parameter. Similarly, values accessed by AFTER triggers are only
  94261 // included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.
  94262 func Xsqlite3TriggerColmask(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pChanges uintptr, isNew int32, tr_tm int32, pTab uintptr, orconf int32) U32 {
  94263 	var op int32
  94264 	if pChanges != 0 {
  94265 		op = TK_UPDATE
  94266 	} else {
  94267 		op = TK_DELETE
  94268 	}
  94269 	var mask U32 = U32(0)
  94270 	var p uintptr
  94271 
  94272 	for p = pTrigger; p != 0; p = (*Trigger)(unsafe.Pointer(p)).FpNext {
  94273 		if int32((*Trigger)(unsafe.Pointer(p)).Fop) == op &&
  94274 			tr_tm&int32((*Trigger)(unsafe.Pointer(p)).Ftr_tm) != 0 &&
  94275 			checkColumnOverlap(tls, (*Trigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 {
  94276 			if (*Trigger)(unsafe.Pointer(p)).FbReturning != 0 {
  94277 				mask = 0xffffffff
  94278 			} else {
  94279 				var pPrg uintptr
  94280 				pPrg = getRowTrigger(tls, pParse, p, pTab, orconf)
  94281 				if pPrg != 0 {
  94282 					mask = mask | *(*U32)(unsafe.Pointer(pPrg + 16 + uintptr(isNew)*4))
  94283 				}
  94284 			}
  94285 		}
  94286 	}
  94287 
  94288 	return mask
  94289 }
  94290 
  94291 // The most recently coded instruction was an OP_Column to retrieve the
  94292 // i-th column of table pTab. This routine sets the P4 parameter of the
  94293 // OP_Column to the default value, if any.
  94294 //
  94295 // The default value of a column is specified by a DEFAULT clause in the
  94296 // column definition. This was either supplied by the user when the table
  94297 // was created, or added later to the table definition by an ALTER TABLE
  94298 // command. If the latter, then the row-records in the table btree on disk
  94299 // may not contain a value for the column and the default value, taken
  94300 // from the P4 parameter of the OP_Column instruction, is returned instead.
  94301 // If the former, then all row-records are guaranteed to include a value
  94302 // for the column and the P4 value is not required.
  94303 //
  94304 // Column definitions created by an ALTER TABLE command may only have
  94305 // literal default values specified: a number, null or a string. (If a more
  94306 // complicated default expression value was provided, it is evaluated
  94307 // when the ALTER TABLE is executed and one of the literal values written
  94308 // into the sqlite_schema table.)
  94309 //
  94310 // Therefore, the P4 parameter is only required if the default value for
  94311 // the column is a literal number, string or null. The sqlite3ValueFromExpr()
  94312 // function is capable of transforming these types of expressions into
  94313 // sqlite3_value objects.
  94314 //
  94315 // If column as REAL affinity and the table is an ordinary b-tree table
  94316 // (not a virtual table) then the value might have been stored as an
  94317 // integer.  In that case, add an OP_RealAffinity opcode to make sure
  94318 // it has been converted into REAL.
  94319 func Xsqlite3ColumnDefault(tls *libc.TLS, v uintptr, pTab uintptr, i int32, iReg int32) {
  94320 	bp := tls.Alloc(4)
  94321 	defer tls.Free(4)
  94322 
  94323 	var pCol uintptr
  94324 
  94325 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16
  94326 	if (*Column)(unsafe.Pointer(pCol)).FiDflt != 0 {
  94327 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  94328 		var enc U8 = (*Sqlite3)(unsafe.Pointer(Xsqlite3VdbeDb(tls, v))).Fenc
  94329 
  94330 		Xsqlite3ValueFromExpr(tls, Xsqlite3VdbeDb(tls, v),
  94331 			Xsqlite3ColumnExpr(tls, pTab, pCol), enc,
  94332 			(*Column)(unsafe.Pointer(pCol)).Faffinity, bp)
  94333 		if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
  94334 			Xsqlite3VdbeAppendP4(tls, v, *(*uintptr)(unsafe.Pointer(bp)), -10)
  94335 		}
  94336 	}
  94337 	if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) == SQLITE_AFF_REAL && !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  94338 		Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, iReg)
  94339 	}
  94340 }
  94341 
  94342 func indexColumnIsBeingUpdated(tls *libc.TLS, pIdx uintptr, iCol int32, aXRef uintptr, chngRowid int32) int32 {
  94343 	var iIdxCol I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2))
  94344 
  94345 	if int32(iIdxCol) >= 0 {
  94346 		return libc.Bool32(*(*int32)(unsafe.Pointer(aXRef + uintptr(iIdxCol)*4)) >= 0)
  94347 	}
  94348 
  94349 	return Xsqlite3ExprReferencesUpdatedColumn(tls, (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8+uintptr(iCol)*20)).FpExpr,
  94350 		aXRef, chngRowid)
  94351 }
  94352 
  94353 func indexWhereClauseMightChange(tls *libc.TLS, pIdx uintptr, aXRef uintptr, chngRowid int32) int32 {
  94354 	if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) {
  94355 		return 0
  94356 	}
  94357 	return Xsqlite3ExprReferencesUpdatedColumn(tls, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere,
  94358 		aXRef, chngRowid)
  94359 }
  94360 
  94361 func exprRowColumn(tls *libc.TLS, pParse uintptr, iCol int32) uintptr {
  94362 	var pRet uintptr = Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0))
  94363 	if pRet != 0 {
  94364 		(*Expr)(unsafe.Pointer(pRet)).FiColumn = YnVar(iCol + 1)
  94365 	}
  94366 	return pRet
  94367 }
  94368 
  94369 func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pChanges uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pLimit uintptr) {
  94370 	bp := tls.Alloc(28)
  94371 	defer tls.Free(28)
  94372 
  94373 	var i int32
  94374 
  94375 	var pSelect uintptr = uintptr(0)
  94376 	var pList uintptr = uintptr(0)
  94377 	var pGrp uintptr = uintptr(0)
  94378 	var pLimit2 uintptr = uintptr(0)
  94379 	var pOrderBy2 uintptr = uintptr(0)
  94380 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  94381 	var pTab uintptr = (*SrcItem)(unsafe.Pointer(pTabList + 8)).FpTab
  94382 	var pSrc uintptr
  94383 	var pWhere2 uintptr
  94384 	var eDest int32
  94385 
  94386 	_ = pOrderBy
  94387 	_ = pLimit
  94388 
  94389 	pSrc = Xsqlite3SrcListDup(tls, db, pTabList, 0)
  94390 	pWhere2 = Xsqlite3ExprDup(tls, db, pWhere, 0)
  94391 
  94392 	if pSrc != 0 {
  94393 		libc.SetBitFieldPtr16Uint32(pSrc+8+36+4, uint32(1), 9, 0x200)
  94394 		(*SrcItem)(unsafe.Pointer(pSrc + 8)).FiCursor = -1
  94395 		(*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc+8)).FpTab)).FnTabRef--
  94396 		(*SrcItem)(unsafe.Pointer(pSrc + 8)).FpTab = uintptr(0)
  94397 	}
  94398 	if pPk != 0 {
  94399 		for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ {
  94400 			var pNew uintptr = exprRowColumn(tls, pParse, int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))))
  94401 			pList = Xsqlite3ExprListAppend(tls, pParse, pList, pNew)
  94402 		}
  94403 		if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  94404 			eDest = SRT_Table
  94405 		} else {
  94406 			eDest = SRT_Upfrom
  94407 		}
  94408 	} else if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW {
  94409 		for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  94410 			pList = Xsqlite3ExprListAppend(tls, pParse, pList, exprRowColumn(tls, pParse, i))
  94411 		}
  94412 		eDest = SRT_Table
  94413 	} else {
  94414 		if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  94415 			eDest = SRT_Table
  94416 		} else {
  94417 			eDest = SRT_Upfrom
  94418 		}
  94419 		pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0)))
  94420 	}
  94421 
  94422 	if pChanges != 0 {
  94423 		for i = 0; i < (*ExprList)(unsafe.Pointer(pChanges)).FnExpr; i++ {
  94424 			pList = Xsqlite3ExprListAppend(tls, pParse, pList,
  94425 				Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(i)*20)).FpExpr, 0))
  94426 		}
  94427 	}
  94428 	pSelect = Xsqlite3SelectNew(tls, pParse, pList,
  94429 		pSrc, pWhere2, pGrp, uintptr(0), pOrderBy2,
  94430 		uint32(SF_UFSrcCheck|SF_IncludeHidden|SF_UpdateFrom), pLimit2)
  94431 	if pSelect != 0 {
  94432 		*(*U32)(unsafe.Pointer(pSelect + 4)) |= U32(SF_OrderByReqd)
  94433 	}
  94434 	Xsqlite3SelectDestInit(tls, bp, eDest, iEph)
  94435 	(*SelectDest)(unsafe.Pointer(bp)).FiSDParm2 = func() int32 {
  94436 		if pPk != 0 {
  94437 			return int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  94438 		}
  94439 		return -1
  94440 	}()
  94441 	Xsqlite3Select(tls, pParse, pSelect, bp)
  94442 	Xsqlite3SelectDelete(tls, db, pSelect)
  94443 }
  94444 
  94445 // Process an UPDATE statement.
  94446 //
  94447 //	UPDATE OR IGNORE tbl SET a=b, c=d FROM tbl2... WHERE e<5 AND f NOT NULL;
  94448 //	       \_______/ \_/     \______/      \_____/       \________________/
  94449 //	        onError   |      pChanges         |                pWhere
  94450 //	                  \_______________________/
  94451 //	                            pTabList
  94452 func Xsqlite3Update(tls *libc.TLS, pParse uintptr, pTabList uintptr, pChanges uintptr, pWhere uintptr, onError int32, pOrderBy uintptr, pLimit uintptr, pUpsert uintptr) {
  94453 	bp := tls.Alloc(72)
  94454 	defer tls.Free(72)
  94455 
  94456 	var i int32
  94457 	var j int32
  94458 	var k int32
  94459 	var pTab uintptr
  94460 	var addrTop int32
  94461 	var pWInfo uintptr
  94462 	var v uintptr
  94463 	var pIdx uintptr
  94464 	var pPk uintptr
  94465 	var nIdx int32
  94466 	var nAllIdx int32
  94467 	var iBaseCur int32
  94468 	var iDataCur int32
  94469 	var iIdxCur int32
  94470 	var db uintptr
  94471 	var aRegIdx uintptr
  94472 	var aXRef uintptr
  94473 
  94474 	var aToOpen uintptr
  94475 	var chngPk U8
  94476 	var chngRowid U8
  94477 	var chngKey U8
  94478 	var pRowidExpr uintptr
  94479 	var iRowidExpr int32
  94480 
  94481 	var iDb int32
  94482 	var eOnePass int32
  94483 	var hasFK int32
  94484 	var labelBreak int32
  94485 	var labelContinue int32
  94486 	var flags int32
  94487 
  94488 	var isView int32
  94489 	var pTrigger uintptr
  94490 
  94491 	var newmask int32
  94492 	var iEph int32
  94493 	var nKey int32
  94494 
  94495 	var addrOpen int32
  94496 	var iPk int32
  94497 	var nPk I16
  94498 
  94499 	var bFinishSeek int32
  94500 	var nChangeFrom int32
  94501 
  94502 	var regRowCount int32
  94503 	var regOldRowid int32
  94504 	var regNewRowid int32
  94505 	var regNew int32
  94506 	var regOld int32
  94507 	var regRowSet int32
  94508 	var regKey int32
  94509 	var rc int32
  94510 	var hCol U8
  94511 	var bProgress int32
  94512 	var reg int32
  94513 	var pKeyInfo uintptr
  94514 	var nEphCol int32
  94515 	var iCur int32
  94516 	var addrOnce int32
  94517 	var colFlags U32
  94518 	var oldmask U32
  94519 	var nOff int32
  94520 	addrTop = 0
  94521 	pWInfo = uintptr(0)
  94522 	aRegIdx = uintptr(0)
  94523 	aXRef = uintptr(0)
  94524 	pRowidExpr = uintptr(0)
  94525 	iRowidExpr = -1
  94526 	iEph = 0
  94527 	nKey = 0
  94528 	addrOpen = 0
  94529 	iPk = 0
  94530 	nPk = int16(0)
  94531 	*(*int32)(unsafe.Pointer(bp + 68)) = 0
  94532 	bFinishSeek = 1
  94533 	nChangeFrom = 0
  94534 	regRowCount = 0
  94535 	regOldRowid = 0
  94536 	regNewRowid = 0
  94537 	regNew = 0
  94538 	regOld = 0
  94539 	regRowSet = 0
  94540 	regKey = 0
  94541 
  94542 	libc.Xmemset(tls, bp+16, 0, uint32(unsafe.Sizeof(AuthContext{})))
  94543 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  94544 
  94545 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  94546 		goto __1
  94547 	}
  94548 	goto update_cleanup
  94549 __1:
  94550 	;
  94551 	pTab = Xsqlite3SrcListLookup(tls, pParse, pTabList)
  94552 	if !(pTab == uintptr(0)) {
  94553 		goto __2
  94554 	}
  94555 	goto update_cleanup
  94556 __2:
  94557 	;
  94558 	iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  94559 
  94560 	pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_UPDATE, pChanges, bp+24)
  94561 	isView = libc.Bool32(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW)
  94562 
  94563 	if (*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1 {
  94564 		nChangeFrom = (*ExprList)(unsafe.Pointer(pChanges)).FnExpr
  94565 	} else {
  94566 		nChangeFrom = 0
  94567 	}
  94568 
  94569 	if !(Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0) {
  94570 		goto __3
  94571 	}
  94572 	goto update_cleanup
  94573 __3:
  94574 	;
  94575 	if !(Xsqlite3IsReadOnly(tls, pParse, pTab, *(*int32)(unsafe.Pointer(bp + 24))) != 0) {
  94576 		goto __4
  94577 	}
  94578 	goto update_cleanup
  94579 __4:
  94580 	;
  94581 	iBaseCur = libc.AssignInt32(&iDataCur, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1))
  94582 	iIdxCur = iDataCur + 1
  94583 	if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  94584 		pPk = uintptr(0)
  94585 	} else {
  94586 		pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  94587 	}
  94588 
  94589 	nIdx = 0
  94590 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  94591 __5:
  94592 	if !(pIdx != 0) {
  94593 		goto __7
  94594 	}
  94595 	if !(pPk == pIdx) {
  94596 		goto __8
  94597 	}
  94598 	iDataCur = (*Parse)(unsafe.Pointer(pParse)).FnTab
  94599 __8:
  94600 	;
  94601 	(*Parse)(unsafe.Pointer(pParse)).FnTab++
  94602 	goto __6
  94603 __6:
  94604 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  94605 	nIdx++
  94606 	goto __5
  94607 	goto __7
  94608 __7:
  94609 	;
  94610 	if !(pUpsert != 0) {
  94611 		goto __9
  94612 	}
  94613 
  94614 	iDataCur = (*Upsert)(unsafe.Pointer(pUpsert)).FiDataCur
  94615 	iIdxCur = (*Upsert)(unsafe.Pointer(pUpsert)).FiIdxCur
  94616 	(*Parse)(unsafe.Pointer(pParse)).FnTab = iBaseCur
  94617 __9:
  94618 	;
  94619 	(*SrcItem)(unsafe.Pointer(pTabList + 8)).FiCursor = iDataCur
  94620 
  94621 	aXRef = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(int32(0)))*uint32(int32((*Table)(unsafe.Pointer(pTab)).FnCol)+nIdx+1)+uint32(nIdx)+uint32(2)))
  94622 	if !(aXRef == uintptr(0)) {
  94623 		goto __10
  94624 	}
  94625 	goto update_cleanup
  94626 __10:
  94627 	;
  94628 	aRegIdx = aXRef + uintptr((*Table)(unsafe.Pointer(pTab)).FnCol)*4
  94629 	aToOpen = aRegIdx + uintptr(nIdx)*4 + uintptr(1)*4
  94630 	libc.Xmemset(tls, aToOpen, 1, uint32(nIdx+1))
  94631 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(nIdx+1))) = U8(0)
  94632 	i = 0
  94633 __11:
  94634 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  94635 		goto __13
  94636 	}
  94637 	*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) = -1
  94638 	goto __12
  94639 __12:
  94640 	i++
  94641 	goto __11
  94642 	goto __13
  94643 __13:
  94644 	;
  94645 	libc.Xmemset(tls, bp+28, 0, uint32(unsafe.Sizeof(NameContext{})))
  94646 	(*NameContext)(unsafe.Pointer(bp + 28)).FpParse = pParse
  94647 	(*NameContext)(unsafe.Pointer(bp + 28)).FpSrcList = pTabList
  94648 	*(*uintptr)(unsafe.Pointer(bp + 28 + 8)) = pUpsert
  94649 	(*NameContext)(unsafe.Pointer(bp + 28)).FncFlags = NC_UUpsert
  94650 
  94651 	v = Xsqlite3GetVdbe(tls, pParse)
  94652 	if !(v == uintptr(0)) {
  94653 		goto __14
  94654 	}
  94655 	goto update_cleanup
  94656 __14:
  94657 	;
  94658 	chngRowid = libc.AssignUint8(&chngPk, U8(0))
  94659 	i = 0
  94660 __15:
  94661 	if !(i < (*ExprList)(unsafe.Pointer(pChanges)).FnExpr) {
  94662 		goto __17
  94663 	}
  94664 	hCol = Xsqlite3StrIHash(tls, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(i)*20)).FzEName)
  94665 
  94666 	if !(nChangeFrom == 0 && Xsqlite3ResolveExprNames(tls, bp+28, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(i)*20)).FpExpr) != 0) {
  94667 		goto __18
  94668 	}
  94669 	goto update_cleanup
  94670 __18:
  94671 	;
  94672 	j = 0
  94673 __19:
  94674 	if !(j < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  94675 		goto __21
  94676 	}
  94677 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FhName) == int32(hCol) &&
  94678 		Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FzCnName, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(i)*20)).FzEName) == 0) {
  94679 		goto __22
  94680 	}
  94681 	if !(j == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  94682 		goto __23
  94683 	}
  94684 	chngRowid = U8(1)
  94685 	pRowidExpr = (*ExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*20)).FpExpr
  94686 	iRowidExpr = i
  94687 	goto __24
  94688 __23:
  94689 	if !(pPk != 0 && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_PRIMKEY != 0) {
  94690 		goto __25
  94691 	}
  94692 	chngPk = U8(1)
  94693 	goto __26
  94694 __25:
  94695 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_GENERATED != 0) {
  94696 		goto __27
  94697 	}
  94698 
  94699 	Xsqlite3ErrorMsg(tls, pParse,
  94700 		ts+20539,
  94701 		libc.VaList(bp, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FzCnName))
  94702 	goto update_cleanup
  94703 __27:
  94704 	;
  94705 __26:
  94706 	;
  94707 __24:
  94708 	;
  94709 	*(*int32)(unsafe.Pointer(aXRef + uintptr(j)*4)) = i
  94710 	goto __21
  94711 __22:
  94712 	;
  94713 	goto __20
  94714 __20:
  94715 	j++
  94716 	goto __19
  94717 	goto __21
  94718 __21:
  94719 	;
  94720 	if !(j >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  94721 		goto __28
  94722 	}
  94723 	if !(pPk == uintptr(0) && Xsqlite3IsRowid(tls, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(i)*20)).FzEName) != 0) {
  94724 		goto __29
  94725 	}
  94726 	j = -1
  94727 	chngRowid = U8(1)
  94728 	pRowidExpr = (*ExprList_item)(unsafe.Pointer(pChanges + 8 + uintptr(i)*20)).FpExpr
  94729 	iRowidExpr = i
  94730 	goto __30
  94731 __29:
  94732 	Xsqlite3ErrorMsg(tls, pParse, ts+20575, libc.VaList(bp+8, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(i)*20)).FzEName))
  94733 	(*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1)
  94734 	goto update_cleanup
  94735 __30:
  94736 	;
  94737 __28:
  94738 	;
  94739 	rc = Xsqlite3AuthCheck(tls, pParse, SQLITE_UPDATE, (*Table)(unsafe.Pointer(pTab)).FzName,
  94740 		func() uintptr {
  94741 			if j < 0 {
  94742 				return ts + 7713
  94743 			}
  94744 			return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16)).FzCnName
  94745 		}(),
  94746 		(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName)
  94747 	if !(rc == SQLITE_DENY) {
  94748 		goto __31
  94749 	}
  94750 	goto update_cleanup
  94751 	goto __32
  94752 __31:
  94753 	if !(rc == SQLITE_IGNORE) {
  94754 		goto __33
  94755 	}
  94756 	*(*int32)(unsafe.Pointer(aXRef + uintptr(j)*4)) = -1
  94757 __33:
  94758 	;
  94759 __32:
  94760 	;
  94761 	goto __16
  94762 __16:
  94763 	i++
  94764 	goto __15
  94765 	goto __17
  94766 __17:
  94767 	;
  94768 	chngKey = U8(int32(chngRowid) + int32(chngPk))
  94769 
  94770 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != 0) {
  94771 		goto __34
  94772 	}
  94773 
  94774 __35:
  94775 	bProgress = 0
  94776 	i = 0
  94777 __38:
  94778 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  94779 		goto __40
  94780 	}
  94781 	if !(*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) >= 0) {
  94782 		goto __41
  94783 	}
  94784 	goto __39
  94785 __41:
  94786 	;
  94787 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_GENERATED == 0) {
  94788 		goto __42
  94789 	}
  94790 	goto __39
  94791 __42:
  94792 	;
  94793 	if !(Xsqlite3ExprReferencesUpdatedColumn(tls,
  94794 		Xsqlite3ColumnExpr(tls, pTab, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16),
  94795 		aXRef, int32(chngRowid)) != 0) {
  94796 		goto __43
  94797 	}
  94798 	*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) = 99999
  94799 	bProgress = 1
  94800 __43:
  94801 	;
  94802 	goto __39
  94803 __39:
  94804 	i++
  94805 	goto __38
  94806 	goto __40
  94807 __40:
  94808 	;
  94809 	goto __36
  94810 __36:
  94811 	if bProgress != 0 {
  94812 		goto __35
  94813 	}
  94814 	goto __37
  94815 __37:
  94816 	;
  94817 __34:
  94818 	;
  94819 	(*SrcItem)(unsafe.Pointer(pTabList + 8)).FcolUsed = func() uint64 {
  94820 		if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
  94821 			return libc.Uint64(libc.Uint64FromInt32(-1))
  94822 		}
  94823 		return uint64(0)
  94824 	}()
  94825 
  94826 	hasFK = Xsqlite3FkRequired(tls, pParse, pTab, aXRef, int32(chngKey))
  94827 
  94828 	if !(onError == OE_Replace) {
  94829 		goto __44
  94830 	}
  94831 	*(*int32)(unsafe.Pointer(bp + 68)) = 1
  94832 __44:
  94833 	;
  94834 	nAllIdx = 0
  94835 	pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex
  94836 __45:
  94837 	if !(pIdx != 0) {
  94838 		goto __47
  94839 	}
  94840 	if !(chngKey != 0 || hasFK > 1 || pIdx == pPk ||
  94841 		indexWhereClauseMightChange(tls, pIdx, aXRef, int32(chngRowid)) != 0) {
  94842 		goto __48
  94843 	}
  94844 	reg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  94845 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  94846 	goto __49
  94847 __48:
  94848 	reg = 0
  94849 	i = 0
  94850 __50:
  94851 	if !(i < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) {
  94852 		goto __52
  94853 	}
  94854 	if !(indexColumnIsBeingUpdated(tls, pIdx, i, aXRef, int32(chngRowid)) != 0) {
  94855 		goto __53
  94856 	}
  94857 	reg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  94858 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
  94859 	if !(onError == OE_Default && int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Replace) {
  94860 		goto __54
  94861 	}
  94862 	*(*int32)(unsafe.Pointer(bp + 68)) = 1
  94863 __54:
  94864 	;
  94865 	goto __52
  94866 __53:
  94867 	;
  94868 	goto __51
  94869 __51:
  94870 	i++
  94871 	goto __50
  94872 	goto __52
  94873 __52:
  94874 	;
  94875 __49:
  94876 	;
  94877 	if !(reg == 0) {
  94878 		goto __55
  94879 	}
  94880 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(nAllIdx+1))) = U8(0)
  94881 __55:
  94882 	;
  94883 	*(*int32)(unsafe.Pointer(aRegIdx + uintptr(nAllIdx)*4)) = reg
  94884 	goto __46
  94885 __46:
  94886 	pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext
  94887 	nAllIdx++
  94888 	goto __45
  94889 	goto __47
  94890 __47:
  94891 	;
  94892 	*(*int32)(unsafe.Pointer(aRegIdx + uintptr(nAllIdx)*4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  94893 	if !(*(*int32)(unsafe.Pointer(bp + 68)) != 0) {
  94894 		goto __56
  94895 	}
  94896 
  94897 	libc.Xmemset(tls, aToOpen, 1, uint32(nIdx+1))
  94898 __56:
  94899 	;
  94900 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) {
  94901 		goto __57
  94902 	}
  94903 	Xsqlite3VdbeCountChanges(tls, v)
  94904 __57:
  94905 	;
  94906 	Xsqlite3BeginWriteOperation(tls, pParse, libc.Bool32(pTrigger != 0 || hasFK != 0), iDb)
  94907 
  94908 	if !!(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  94909 		goto __58
  94910 	}
  94911 
  94912 	regRowSet = *(*int32)(unsafe.Pointer(aRegIdx + uintptr(nAllIdx)*4))
  94913 	regOldRowid = libc.AssignInt32(&regNewRowid, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  94914 	if !(chngPk != 0 || pTrigger != 0 || hasFK != 0) {
  94915 		goto __59
  94916 	}
  94917 	regOld = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  94918 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  94919 __59:
  94920 	;
  94921 	if !(chngKey != 0 || pTrigger != 0 || hasFK != 0) {
  94922 		goto __60
  94923 	}
  94924 	regNewRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  94925 __60:
  94926 	;
  94927 	regNew = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  94928 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  94929 __58:
  94930 	;
  94931 	if !(isView != 0) {
  94932 		goto __61
  94933 	}
  94934 	Xsqlite3AuthContextPush(tls, pParse, bp+16, (*Table)(unsafe.Pointer(pTab)).FzName)
  94935 __61:
  94936 	;
  94937 	if !(nChangeFrom == 0 && isView != 0) {
  94938 		goto __62
  94939 	}
  94940 	Xsqlite3MaterializeView(tls, pParse, pTab,
  94941 		pWhere, pOrderBy, pLimit, iDataCur)
  94942 	pOrderBy = uintptr(0)
  94943 	pLimit = uintptr(0)
  94944 __62:
  94945 	;
  94946 	if !(nChangeFrom == 0 && Xsqlite3ResolveExprNames(tls, bp+28, pWhere) != 0) {
  94947 		goto __63
  94948 	}
  94949 	goto update_cleanup
  94950 __63:
  94951 	;
  94952 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  94953 		goto __64
  94954 	}
  94955 	updateVirtualTable(tls, pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,
  94956 		pWhere, onError)
  94957 	goto update_cleanup
  94958 __64:
  94959 	;
  94960 	labelContinue = libc.AssignInt32(&labelBreak, Xsqlite3VdbeMakeLabel(tls, pParse))
  94961 
  94962 	if !((*Sqlite3)(unsafe.Pointer(db)).Fflags&(uint64(0x00001)<<32) != uint64(0) &&
  94963 		!(int32((*Parse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) &&
  94964 		!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) &&
  94965 		!(int32((*Parse)(unsafe.Pointer(pParse)).FbReturning) != 0) &&
  94966 		pUpsert == uintptr(0)) {
  94967 		goto __65
  94968 	}
  94969 	regRowCount = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  94970 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regRowCount)
  94971 __65:
  94972 	;
  94973 	if !(nChangeFrom == 0 && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  94974 		goto __66
  94975 	}
  94976 	Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, regRowSet, regOldRowid)
  94977 	iEph = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  94978 	addrOpen = Xsqlite3VdbeAddOp3(tls, v, OP_OpenEphemeral, iEph, 0, regRowSet)
  94979 	goto __67
  94980 __66:
  94981 	;
  94982 	if pPk != 0 {
  94983 		nPk = int16((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  94984 	} else {
  94985 		nPk = int16(0)
  94986 	}
  94987 	iPk = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  94988 	*(*int32)(unsafe.Pointer(pParse + 44)) += int32(nPk)
  94989 	*(*int32)(unsafe.Pointer(pParse + 44)) += nChangeFrom
  94990 	regKey = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  94991 	if !(pUpsert == uintptr(0)) {
  94992 		goto __68
  94993 	}
  94994 	nEphCol = int32(nPk) + nChangeFrom + func() int32 {
  94995 		if isView != 0 {
  94996 			return int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  94997 		}
  94998 		return 0
  94999 	}()
  95000 	iEph = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  95001 	if !(pPk != 0) {
  95002 		goto __69
  95003 	}
  95004 	Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, iPk, iPk+int32(nPk)-1)
  95005 __69:
  95006 	;
  95007 	addrOpen = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iEph, nEphCol)
  95008 	if !(pPk != 0) {
  95009 		goto __70
  95010 	}
  95011 	pKeyInfo = Xsqlite3KeyInfoOfIndex(tls, pParse, pPk)
  95012 	if !(pKeyInfo != 0) {
  95013 		goto __71
  95014 	}
  95015 	(*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField = U16(nEphCol)
  95016 	Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -8)
  95017 __71:
  95018 	;
  95019 __70:
  95020 	;
  95021 	if !(nChangeFrom != 0) {
  95022 		goto __72
  95023 	}
  95024 	updateFromSelect(tls,
  95025 		pParse, iEph, pPk, pChanges, pTabList, pWhere, pOrderBy, pLimit)
  95026 	if !(isView != 0) {
  95027 		goto __73
  95028 	}
  95029 	iDataCur = iEph
  95030 __73:
  95031 	;
  95032 __72:
  95033 	;
  95034 __68:
  95035 	;
  95036 __67:
  95037 	;
  95038 	if !(nChangeFrom != 0) {
  95039 		goto __74
  95040 	}
  95041 	Xsqlite3MultiWrite(tls, pParse)
  95042 	eOnePass = ONEPASS_OFF
  95043 	nKey = int32(nPk)
  95044 	regKey = iPk
  95045 	goto __75
  95046 __74:
  95047 	if !(pUpsert != 0) {
  95048 		goto __76
  95049 	}
  95050 
  95051 	pWInfo = uintptr(0)
  95052 	eOnePass = ONEPASS_SINGLE
  95053 	Xsqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL)
  95054 	bFinishSeek = 0
  95055 	goto __77
  95056 __76:
  95057 	flags = WHERE_ONEPASS_DESIRED
  95058 	if !(!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) &&
  95059 		!(pTrigger != 0) &&
  95060 		!(hasFK != 0) &&
  95061 		!(chngKey != 0) &&
  95062 		!(*(*int32)(unsafe.Pointer(bp + 68)) != 0) &&
  95063 		(*NameContext)(unsafe.Pointer(bp+28)).FncFlags&NC_Subquery == 0) {
  95064 		goto __78
  95065 	}
  95066 	flags = flags | WHERE_ONEPASS_MULTIROW
  95067 __78:
  95068 	;
  95069 	pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uintptr(0), uint16(flags), iIdxCur)
  95070 	if !(pWInfo == uintptr(0)) {
  95071 		goto __79
  95072 	}
  95073 	goto update_cleanup
  95074 __79:
  95075 	;
  95076 	eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp+60)
  95077 	bFinishSeek = Xsqlite3WhereUsesDeferredSeek(tls, pWInfo)
  95078 	if !(eOnePass != ONEPASS_SINGLE) {
  95079 		goto __80
  95080 	}
  95081 	Xsqlite3MultiWrite(tls, pParse)
  95082 	if !(eOnePass == ONEPASS_MULTI) {
  95083 		goto __81
  95084 	}
  95085 	iCur = *(*int32)(unsafe.Pointer(bp + 60 + 1*4))
  95086 	if !(iCur >= 0 && iCur != iDataCur && *(*U8)(unsafe.Pointer(aToOpen + uintptr(iCur-iBaseCur))) != 0) {
  95087 		goto __82
  95088 	}
  95089 	eOnePass = ONEPASS_OFF
  95090 __82:
  95091 	;
  95092 __81:
  95093 	;
  95094 __80:
  95095 	;
  95096 __77:
  95097 	;
  95098 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  95099 		goto __83
  95100 	}
  95101 
  95102 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iDataCur, regOldRowid)
  95103 	if !(eOnePass == ONEPASS_OFF) {
  95104 		goto __85
  95105 	}
  95106 	*(*int32)(unsafe.Pointer(aRegIdx + uintptr(nAllIdx)*4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  95107 	Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iEph, regRowSet, regOldRowid)
  95108 	goto __86
  95109 __85:
  95110 	if !(addrOpen != 0) {
  95111 		goto __87
  95112 	}
  95113 	Xsqlite3VdbeChangeToNoop(tls, v, addrOpen)
  95114 __87:
  95115 	;
  95116 __86:
  95117 	;
  95118 	goto __84
  95119 __83:
  95120 	i = 0
  95121 __88:
  95122 	if !(i < int32(nPk)) {
  95123 		goto __90
  95124 	}
  95125 
  95126 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur,
  95127 		int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))), iPk+i)
  95128 	goto __89
  95129 __89:
  95130 	i++
  95131 	goto __88
  95132 	goto __90
  95133 __90:
  95134 	;
  95135 	if !(eOnePass != 0) {
  95136 		goto __91
  95137 	}
  95138 	if !(addrOpen != 0) {
  95139 		goto __93
  95140 	}
  95141 	Xsqlite3VdbeChangeToNoop(tls, v, addrOpen)
  95142 __93:
  95143 	;
  95144 	nKey = int32(nPk)
  95145 	regKey = iPk
  95146 	goto __92
  95147 __91:
  95148 	Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, iPk, int32(nPk), regKey,
  95149 		Xsqlite3IndexAffinityStr(tls, db, pPk), int32(nPk))
  95150 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iEph, regKey, iPk, int32(nPk))
  95151 __92:
  95152 	;
  95153 __84:
  95154 	;
  95155 __75:
  95156 	;
  95157 	if !(pUpsert == uintptr(0)) {
  95158 		goto __94
  95159 	}
  95160 	if !(nChangeFrom == 0 && eOnePass != ONEPASS_MULTI) {
  95161 		goto __95
  95162 	}
  95163 	Xsqlite3WhereEnd(tls, pWInfo)
  95164 __95:
  95165 	;
  95166 	if !!(isView != 0) {
  95167 		goto __96
  95168 	}
  95169 	addrOnce = 0
  95170 
  95171 	if !(eOnePass != ONEPASS_OFF) {
  95172 		goto __97
  95173 	}
  95174 	if !(*(*int32)(unsafe.Pointer(bp + 60)) >= 0) {
  95175 		goto __98
  95176 	}
  95177 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(*(*int32)(unsafe.Pointer(bp + 60))-iBaseCur))) = U8(0)
  95178 __98:
  95179 	;
  95180 	if !(*(*int32)(unsafe.Pointer(bp + 60 + 1*4)) >= 0) {
  95181 		goto __99
  95182 	}
  95183 	*(*U8)(unsafe.Pointer(aToOpen + uintptr(*(*int32)(unsafe.Pointer(bp + 60 + 1*4))-iBaseCur))) = U8(0)
  95184 __99:
  95185 	;
  95186 __97:
  95187 	;
  95188 	if !(eOnePass == ONEPASS_MULTI && nIdx-libc.Bool32(*(*int32)(unsafe.Pointer(bp + 60 + 1*4)) >= 0) > 0) {
  95189 		goto __100
  95190 	}
  95191 	addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
  95192 __100:
  95193 	;
  95194 	Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(0), iBaseCur,
  95195 		aToOpen, uintptr(0), uintptr(0))
  95196 	if !(addrOnce != 0) {
  95197 		goto __101
  95198 	}
  95199 	Xsqlite3VdbeJumpHereOrPopInst(tls, v, addrOnce)
  95200 __101:
  95201 	;
  95202 __96:
  95203 	;
  95204 	if !(eOnePass != ONEPASS_OFF) {
  95205 		goto __102
  95206 	}
  95207 	if !(*(*int32)(unsafe.Pointer(bp + 60)) != iDataCur &&
  95208 		*(*int32)(unsafe.Pointer(bp + 60 + 1*4)) != iDataCur) {
  95209 		goto __104
  95210 	}
  95211 
  95212 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelBreak, regKey, nKey)
  95213 
  95214 __104:
  95215 	;
  95216 	if !(eOnePass != ONEPASS_SINGLE) {
  95217 		goto __105
  95218 	}
  95219 	labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse)
  95220 __105:
  95221 	;
  95222 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, func() int32 {
  95223 		if pPk != 0 {
  95224 			return regKey
  95225 		}
  95226 		return regOldRowid
  95227 	}(), labelBreak)
  95228 
  95229 	goto __103
  95230 __102:
  95231 	if !(pPk != 0 || nChangeFrom != 0) {
  95232 		goto __106
  95233 	}
  95234 	labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse)
  95235 	Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iEph, labelBreak)
  95236 	addrTop = Xsqlite3VdbeCurrentAddr(tls, v)
  95237 	if !(nChangeFrom != 0) {
  95238 		goto __108
  95239 	}
  95240 	if !!(isView != 0) {
  95241 		goto __110
  95242 	}
  95243 	if !(pPk != 0) {
  95244 		goto __111
  95245 	}
  95246 	i = 0
  95247 __113:
  95248 	if !(i < int32(nPk)) {
  95249 		goto __115
  95250 	}
  95251 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, i, iPk+i)
  95252 	goto __114
  95253 __114:
  95254 	i++
  95255 	goto __113
  95256 	goto __115
  95257 __115:
  95258 	;
  95259 	Xsqlite3VdbeAddOp4Int(tls,
  95260 		v, OP_NotFound, iDataCur, labelContinue, iPk, int32(nPk))
  95261 	goto __112
  95262 __111:
  95263 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, regOldRowid)
  95264 	Xsqlite3VdbeAddOp3(tls,
  95265 		v, OP_NotExists, iDataCur, labelContinue, regOldRowid)
  95266 __112:
  95267 	;
  95268 __110:
  95269 	;
  95270 	goto __109
  95271 __108:
  95272 	Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iEph, regKey)
  95273 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, 0)
  95274 
  95275 __109:
  95276 	;
  95277 	goto __107
  95278 __106:
  95279 	Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iEph, labelBreak)
  95280 	labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse)
  95281 	addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, regOldRowid)
  95282 
  95283 	Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid)
  95284 
  95285 __107:
  95286 	;
  95287 __103:
  95288 	;
  95289 __94:
  95290 	;
  95291 	if !(chngRowid != 0) {
  95292 		goto __116
  95293 	}
  95294 
  95295 	if !(nChangeFrom == 0) {
  95296 		goto __117
  95297 	}
  95298 	Xsqlite3ExprCode(tls, pParse, pRowidExpr, regNewRowid)
  95299 	goto __118
  95300 __117:
  95301 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, iRowidExpr, regNewRowid)
  95302 __118:
  95303 	;
  95304 	Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regNewRowid)
  95305 __116:
  95306 	;
  95307 	if !(chngPk != 0 || hasFK != 0 || pTrigger != 0) {
  95308 		goto __119
  95309 	}
  95310 	oldmask = func() uint32 {
  95311 		if hasFK != 0 {
  95312 			return Xsqlite3FkOldmask(tls, pParse, pTab)
  95313 		}
  95314 		return uint32(0)
  95315 	}()
  95316 	oldmask = oldmask | Xsqlite3TriggerColmask(tls, pParse,
  95317 		pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError)
  95318 	i = 0
  95319 __120:
  95320 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  95321 		goto __122
  95322 	}
  95323 	colFlags = U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*16)).FcolFlags)
  95324 	k = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + regOld
  95325 	if !(oldmask == 0xffffffff ||
  95326 		i < 32 && oldmask&(uint32(1)<<i) != U32(0) ||
  95327 		colFlags&U32(COLFLAG_PRIMKEY) != U32(0)) {
  95328 		goto __123
  95329 	}
  95330 
  95331 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, i, k)
  95332 	goto __124
  95333 __123:
  95334 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k)
  95335 __124:
  95336 	;
  95337 	goto __121
  95338 __121:
  95339 	i++
  95340 	goto __120
  95341 	goto __122
  95342 __122:
  95343 	;
  95344 	if !(int32(chngRowid) == 0 && pPk == uintptr(0)) {
  95345 		goto __125
  95346 	}
  95347 	Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regOldRowid, regNewRowid)
  95348 __125:
  95349 	;
  95350 __119:
  95351 	;
  95352 	newmask = int32(Xsqlite3TriggerColmask(tls,
  95353 		pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError))
  95354 	i = 0
  95355 	k = regNew
  95356 __126:
  95357 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  95358 		goto __128
  95359 	}
  95360 	if !(i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  95361 		goto __129
  95362 	}
  95363 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k)
  95364 	goto __130
  95365 __129:
  95366 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_GENERATED != 0) {
  95367 		goto __131
  95368 	}
  95369 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0) {
  95370 		goto __133
  95371 	}
  95372 	k--
  95373 __133:
  95374 	;
  95375 	goto __132
  95376 __131:
  95377 	j = *(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4))
  95378 	if !(j >= 0) {
  95379 		goto __134
  95380 	}
  95381 	if !(nChangeFrom != 0) {
  95382 		goto __136
  95383 	}
  95384 	nOff = func() int32 {
  95385 		if isView != 0 {
  95386 			return int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  95387 		}
  95388 		return int32(nPk)
  95389 	}()
  95390 
  95391 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, nOff+j, k)
  95392 	goto __137
  95393 __136:
  95394 	Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(j)*20)).FpExpr, k)
  95395 __137:
  95396 	;
  95397 	goto __135
  95398 __134:
  95399 	if !(0 == *(*int32)(unsafe.Pointer(bp + 24))&TRIGGER_BEFORE || i > 31 || uint32(newmask)&(uint32(1)<<i) != 0) {
  95400 		goto __138
  95401 	}
  95402 
  95403 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, i, k)
  95404 	bFinishSeek = 0
  95405 	goto __139
  95406 __138:
  95407 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k)
  95408 __139:
  95409 	;
  95410 __135:
  95411 	;
  95412 __132:
  95413 	;
  95414 __130:
  95415 	;
  95416 	goto __127
  95417 __127:
  95418 	i++
  95419 	k++
  95420 	goto __126
  95421 	goto __128
  95422 __128:
  95423 	;
  95424 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != 0) {
  95425 		goto __140
  95426 	}
  95427 
  95428 	Xsqlite3ComputeGeneratedColumns(tls, pParse, regNew, pTab)
  95429 __140:
  95430 	;
  95431 	if !(*(*int32)(unsafe.Pointer(bp + 24))&TRIGGER_BEFORE != 0) {
  95432 		goto __141
  95433 	}
  95434 	Xsqlite3TableAffinity(tls, v, pTab, regNew)
  95435 	Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_UPDATE, pChanges,
  95436 		TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue)
  95437 
  95438 	if !!(isView != 0) {
  95439 		goto __142
  95440 	}
  95441 
  95442 	if !(pPk != 0) {
  95443 		goto __143
  95444 	}
  95445 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, nKey)
  95446 
  95447 	goto __144
  95448 __143:
  95449 	Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid)
  95450 
  95451 __144:
  95452 	;
  95453 	i = 0
  95454 	k = regNew
  95455 __145:
  95456 	if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
  95457 		goto __147
  95458 	}
  95459 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_GENERATED != 0) {
  95460 		goto __148
  95461 	}
  95462 	if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0) {
  95463 		goto __150
  95464 	}
  95465 	k--
  95466 __150:
  95467 	;
  95468 	goto __149
  95469 __148:
  95470 	if !(*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) < 0 && i != int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) {
  95471 		goto __151
  95472 	}
  95473 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, i, k)
  95474 __151:
  95475 	;
  95476 __149:
  95477 	;
  95478 	goto __146
  95479 __146:
  95480 	i++
  95481 	k++
  95482 	goto __145
  95483 	goto __147
  95484 __147:
  95485 	;
  95486 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated) != 0) {
  95487 		goto __152
  95488 	}
  95489 
  95490 	Xsqlite3ComputeGeneratedColumns(tls, pParse, regNew, pTab)
  95491 __152:
  95492 	;
  95493 __142:
  95494 	;
  95495 __141:
  95496 	;
  95497 	if !!(isView != 0) {
  95498 		goto __153
  95499 	}
  95500 
  95501 	Xsqlite3GenerateConstraintChecks(tls, pParse, pTab, aRegIdx, iDataCur, iIdxCur,
  95502 		regNewRowid, regOldRowid, chngKey, uint8(onError), labelContinue, bp+68,
  95503 		aXRef, uintptr(0))
  95504 
  95505 	if !(*(*int32)(unsafe.Pointer(bp + 68)) != 0 || chngKey != 0) {
  95506 		goto __154
  95507 	}
  95508 	if !(pPk != 0) {
  95509 		goto __155
  95510 	}
  95511 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, nKey)
  95512 	goto __156
  95513 __155:
  95514 	Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid)
  95515 __156:
  95516 	;
  95517 __154:
  95518 	;
  95519 	if !(hasFK != 0) {
  95520 		goto __157
  95521 	}
  95522 	Xsqlite3FkCheck(tls, pParse, pTab, regOldRowid, 0, aXRef, int32(chngKey))
  95523 __157:
  95524 	;
  95525 	Xsqlite3GenerateRowIndexDelete(tls, pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1)
  95526 
  95527 	if !(bFinishSeek != 0) {
  95528 		goto __158
  95529 	}
  95530 	Xsqlite3VdbeAddOp1(tls, v, OP_FinishSeek, iDataCur)
  95531 __158:
  95532 	;
  95533 	Xsqlite3VdbeAddOp3(tls, v, OP_Delete, iDataCur,
  95534 		OPFLAG_ISUPDATE|func() int32 {
  95535 			if hasFK > 1 || chngKey != 0 {
  95536 				return 0
  95537 			}
  95538 			return OPFLAG_ISNOOP
  95539 		}(),
  95540 		regNewRowid)
  95541 	if !(eOnePass == ONEPASS_MULTI) {
  95542 		goto __159
  95543 	}
  95544 
  95545 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION))
  95546 __159:
  95547 	;
  95548 	if !!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) {
  95549 		goto __160
  95550 	}
  95551 	Xsqlite3VdbeAppendP4(tls, v, pTab, -5)
  95552 __160:
  95553 	;
  95554 	if !(hasFK != 0) {
  95555 		goto __161
  95556 	}
  95557 	Xsqlite3FkCheck(tls, pParse, pTab, 0, regNewRowid, aXRef, int32(chngKey))
  95558 __161:
  95559 	;
  95560 	Xsqlite3CompleteInsertion(tls,
  95561 		pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx,
  95562 		OPFLAG_ISUPDATE|func() int32 {
  95563 			if eOnePass == ONEPASS_MULTI {
  95564 				return OPFLAG_SAVEPOSITION
  95565 			}
  95566 			return 0
  95567 		}(),
  95568 		0, 0)
  95569 
  95570 	if !(hasFK != 0) {
  95571 		goto __162
  95572 	}
  95573 	Xsqlite3FkActions(tls, pParse, pTab, pChanges, regOldRowid, aXRef, int32(chngKey))
  95574 __162:
  95575 	;
  95576 __153:
  95577 	;
  95578 	if !(regRowCount != 0) {
  95579 		goto __163
  95580 	}
  95581 	Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regRowCount, 1)
  95582 __163:
  95583 	;
  95584 	Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_UPDATE, pChanges,
  95585 		TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue)
  95586 
  95587 	if !(eOnePass == ONEPASS_SINGLE) {
  95588 		goto __164
  95589 	}
  95590 
  95591 	goto __165
  95592 __164:
  95593 	if !(eOnePass == ONEPASS_MULTI) {
  95594 		goto __166
  95595 	}
  95596 	Xsqlite3VdbeResolveLabel(tls, v, labelContinue)
  95597 	Xsqlite3WhereEnd(tls, pWInfo)
  95598 	goto __167
  95599 __166:
  95600 	Xsqlite3VdbeResolveLabel(tls, v, labelContinue)
  95601 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, iEph, addrTop)
  95602 __167:
  95603 	;
  95604 __165:
  95605 	;
  95606 	Xsqlite3VdbeResolveLabel(tls, v, labelBreak)
  95607 
  95608 	if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab == uintptr(0) && pUpsert == uintptr(0)) {
  95609 		goto __168
  95610 	}
  95611 	Xsqlite3AutoincrementEnd(tls, pParse)
  95612 __168:
  95613 	;
  95614 	if !(regRowCount != 0) {
  95615 		goto __169
  95616 	}
  95617 	Xsqlite3CodeChangeCount(tls, v, regRowCount, ts+20594)
  95618 __169:
  95619 	;
  95620 update_cleanup:
  95621 	Xsqlite3AuthContextPop(tls, bp+16)
  95622 	Xsqlite3DbFree(tls, db, aXRef)
  95623 	Xsqlite3SrcListDelete(tls, db, pTabList)
  95624 	Xsqlite3ExprListDelete(tls, db, pChanges)
  95625 	Xsqlite3ExprDelete(tls, db, pWhere)
  95626 	return
  95627 }
  95628 
  95629 func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, pChanges uintptr, pRowid uintptr, aXRef uintptr, pWhere uintptr, onError int32) {
  95630 	bp := tls.Alloc(8)
  95631 	defer tls.Free(8)
  95632 
  95633 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  95634 	var ephemTab int32
  95635 	var i int32
  95636 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  95637 	var pVTab uintptr = Xsqlite3GetVTable(tls, db, pTab)
  95638 	var pWInfo uintptr = uintptr(0)
  95639 	var nArg int32 = 2 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)
  95640 	var regArg int32
  95641 	var regRec int32
  95642 	var regRowid int32
  95643 	var iCsr int32 = (*SrcItem)(unsafe.Pointer(pSrc + 8)).FiCursor
  95644 
  95645 	var eOnePass int32
  95646 	var addr int32
  95647 
  95648 	ephemTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  95649 	addr = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, ephemTab, nArg)
  95650 	regArg = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  95651 	*(*int32)(unsafe.Pointer(pParse + 44)) += nArg
  95652 	if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1 {
  95653 		var pPk uintptr = uintptr(0)
  95654 		var pRow uintptr
  95655 		var pList uintptr
  95656 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  95657 			if pRowid != 0 {
  95658 				pRow = Xsqlite3ExprDup(tls, db, pRowid, 0)
  95659 			} else {
  95660 				pRow = Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0))
  95661 			}
  95662 		} else {
  95663 			var iPk I16
  95664 			pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  95665 
  95666 			iPk = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn))
  95667 			if *(*int32)(unsafe.Pointer(aXRef + uintptr(iPk)*4)) >= 0 {
  95668 				pRow = Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(*(*int32)(unsafe.Pointer(aXRef + uintptr(iPk)*4)))*20)).FpExpr, 0)
  95669 			} else {
  95670 				pRow = exprRowColumn(tls, pParse, int32(iPk))
  95671 			}
  95672 		}
  95673 		pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), pRow)
  95674 
  95675 		for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  95676 			if *(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) >= 0 {
  95677 				pList = Xsqlite3ExprListAppend(tls, pParse, pList,
  95678 					Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)))*20)).FpExpr, 0))
  95679 			} else {
  95680 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, exprRowColumn(tls, pParse, i))
  95681 			}
  95682 		}
  95683 
  95684 		updateFromSelect(tls, pParse, ephemTab, pPk, pList, pSrc, pWhere, uintptr(0), uintptr(0))
  95685 		Xsqlite3ExprListDelete(tls, db, pList)
  95686 		eOnePass = ONEPASS_OFF
  95687 	} else {
  95688 		regRec = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  95689 		regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  95690 
  95691 		pWInfo = Xsqlite3WhereBegin(tls,
  95692 			pParse, pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint16(WHERE_ONEPASS_DESIRED), 0)
  95693 		if pWInfo == uintptr(0) {
  95694 			return
  95695 		}
  95696 
  95697 		for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  95698 			if *(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) >= 0 {
  95699 				Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pChanges+8+uintptr(*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)))*20)).FpExpr, regArg+2+i)
  95700 			} else {
  95701 				Xsqlite3VdbeAddOp3(tls, v, OP_VColumn, iCsr, i, regArg+2+i)
  95702 				Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_NOCHNG))
  95703 			}
  95704 		}
  95705 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  95706 			Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCsr, regArg)
  95707 			if pRowid != 0 {
  95708 				Xsqlite3ExprCode(tls, pParse, pRowid, regArg+1)
  95709 			} else {
  95710 				Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCsr, regArg+1)
  95711 			}
  95712 		} else {
  95713 			var pPk uintptr
  95714 			var iPk I16
  95715 			pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
  95716 
  95717 			iPk = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn))
  95718 			Xsqlite3VdbeAddOp3(tls, v, OP_VColumn, iCsr, int32(iPk), regArg)
  95719 			Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, regArg+2+int32(iPk), regArg+1)
  95720 		}
  95721 
  95722 		eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp)
  95723 
  95724 		if eOnePass != 0 {
  95725 			Xsqlite3VdbeChangeToNoop(tls, v, addr)
  95726 			Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCsr)
  95727 		} else {
  95728 			Xsqlite3MultiWrite(tls, pParse)
  95729 			Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regArg, nArg, regRec)
  95730 			Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, ephemTab, regRowid)
  95731 			Xsqlite3VdbeAddOp3(tls, v, OP_Insert, ephemTab, regRec, regRowid)
  95732 		}
  95733 	}
  95734 
  95735 	if eOnePass == ONEPASS_OFF {
  95736 		if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc == 1 {
  95737 			Xsqlite3WhereEnd(tls, pWInfo)
  95738 		}
  95739 
  95740 		addr = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, ephemTab)
  95741 
  95742 		for i = 0; i < nArg; i++ {
  95743 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, ephemTab, i, regArg+i)
  95744 		}
  95745 	}
  95746 	Xsqlite3VtabMakeWritable(tls, pParse, pTab)
  95747 	Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 0, nArg, regArg, pVTab, -11)
  95748 	Xsqlite3VdbeChangeP5(tls, v, func() uint16 {
  95749 		if onError == OE_Default {
  95750 			return uint16(OE_Abort)
  95751 		}
  95752 		return uint16(onError)
  95753 	}())
  95754 	Xsqlite3MayAbort(tls, pParse)
  95755 
  95756 	if eOnePass == ONEPASS_OFF {
  95757 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, ephemTab, addr+1)
  95758 		Xsqlite3VdbeJumpHere(tls, v, addr)
  95759 		Xsqlite3VdbeAddOp2(tls, v, OP_Close, ephemTab, 0)
  95760 	} else {
  95761 		Xsqlite3WhereEnd(tls, pWInfo)
  95762 	}
  95763 }
  95764 
  95765 func upsertDelete(tls *libc.TLS, db uintptr, p uintptr) {
  95766 	for __ccgo := true; __ccgo; __ccgo = p != 0 {
  95767 		var pNext uintptr = (*Upsert)(unsafe.Pointer(p)).FpNextUpsert
  95768 		Xsqlite3ExprListDelete(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertTarget)
  95769 		Xsqlite3ExprDelete(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertTargetWhere)
  95770 		Xsqlite3ExprListDelete(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertSet)
  95771 		Xsqlite3ExprDelete(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertWhere)
  95772 		Xsqlite3DbFree(tls, db, (*Upsert)(unsafe.Pointer(p)).FpToFree)
  95773 		Xsqlite3DbFree(tls, db, p)
  95774 		p = pNext
  95775 	}
  95776 }
  95777 
  95778 func Xsqlite3UpsertDelete(tls *libc.TLS, db uintptr, p uintptr) {
  95779 	if p != 0 {
  95780 		upsertDelete(tls, db, p)
  95781 	}
  95782 }
  95783 
  95784 // Duplicate an Upsert object.
  95785 func Xsqlite3UpsertDup(tls *libc.TLS, db uintptr, p uintptr) uintptr {
  95786 	if p == uintptr(0) {
  95787 		return uintptr(0)
  95788 	}
  95789 	return Xsqlite3UpsertNew(tls, db,
  95790 		Xsqlite3ExprListDup(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertTarget, 0),
  95791 		Xsqlite3ExprDup(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertTargetWhere, 0),
  95792 		Xsqlite3ExprListDup(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertSet, 0),
  95793 		Xsqlite3ExprDup(tls, db, (*Upsert)(unsafe.Pointer(p)).FpUpsertWhere, 0),
  95794 		Xsqlite3UpsertDup(tls, db, (*Upsert)(unsafe.Pointer(p)).FpNextUpsert))
  95795 }
  95796 
  95797 // Create a new Upsert object.
  95798 func Xsqlite3UpsertNew(tls *libc.TLS, db uintptr, pTarget uintptr, pTargetWhere uintptr, pSet uintptr, pWhere uintptr, pNext uintptr) uintptr {
  95799 	var pNew uintptr
  95800 	pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Upsert{})))
  95801 	if pNew == uintptr(0) {
  95802 		Xsqlite3ExprListDelete(tls, db, pTarget)
  95803 		Xsqlite3ExprDelete(tls, db, pTargetWhere)
  95804 		Xsqlite3ExprListDelete(tls, db, pSet)
  95805 		Xsqlite3ExprDelete(tls, db, pWhere)
  95806 		Xsqlite3UpsertDelete(tls, db, pNext)
  95807 		return uintptr(0)
  95808 	} else {
  95809 		(*Upsert)(unsafe.Pointer(pNew)).FpUpsertTarget = pTarget
  95810 		(*Upsert)(unsafe.Pointer(pNew)).FpUpsertTargetWhere = pTargetWhere
  95811 		(*Upsert)(unsafe.Pointer(pNew)).FpUpsertSet = pSet
  95812 		(*Upsert)(unsafe.Pointer(pNew)).FpUpsertWhere = pWhere
  95813 		(*Upsert)(unsafe.Pointer(pNew)).FisDoUpdate = U8(libc.Bool32(pSet != uintptr(0)))
  95814 		(*Upsert)(unsafe.Pointer(pNew)).FpNextUpsert = pNext
  95815 	}
  95816 	return pNew
  95817 }
  95818 
  95819 // Analyze the ON CONFLICT clause described by pUpsert.  Resolve all
  95820 // symbols in the conflict-target.
  95821 //
  95822 // Return SQLITE_OK if everything works, or an error code is something
  95823 // is wrong.
  95824 func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr, pUpsert uintptr) int32 {
  95825 	bp := tls.Alloc(168)
  95826 	defer tls.Free(168)
  95827 
  95828 	var pTab uintptr
  95829 	var rc int32
  95830 	var iCursor int32
  95831 	var pIdx uintptr
  95832 	var pTarget uintptr
  95833 	var pTerm uintptr
  95834 
  95835 	var nClause int32 = 0
  95836 
  95837 	libc.Xmemset(tls, bp+16, 0, uint32(unsafe.Sizeof(NameContext{})))
  95838 	(*NameContext)(unsafe.Pointer(bp + 16)).FpParse = pParse
  95839 	(*NameContext)(unsafe.Pointer(bp + 16)).FpSrcList = pTabList
  95840 __1:
  95841 	if !(pUpsert != 0 && (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget != 0) {
  95842 		goto __3
  95843 	}
  95844 	{
  95845 		rc = Xsqlite3ResolveExprListNames(tls, bp+16, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget)
  95846 		if rc != 0 {
  95847 			return rc
  95848 		}
  95849 		rc = Xsqlite3ResolveExprNames(tls, bp+16, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere)
  95850 		if rc != 0 {
  95851 			return rc
  95852 		}
  95853 
  95854 		pTab = (*SrcItem)(unsafe.Pointer(pTabList + 8)).FpTab
  95855 		pTarget = (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget
  95856 		iCursor = (*SrcItem)(unsafe.Pointer(pTabList + 8)).FiCursor
  95857 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) &&
  95858 			(*ExprList)(unsafe.Pointer(pTarget)).FnExpr == 1 &&
  95859 			int32((*Expr)(unsafe.Pointer(libc.AssignUintptr(&pTerm, (*ExprList_item)(unsafe.Pointer(pTarget+8)).FpExpr))).Fop) == TK_COLUMN &&
  95860 			int32((*Expr)(unsafe.Pointer(pTerm)).FiColumn) == -1 {
  95861 			goto __2
  95862 		}
  95863 
  95864 		libc.Xmemset(tls, bp+48, 0, uint32(unsafe.Sizeof([2]Expr{})))
  95865 		(*Expr)(unsafe.Pointer(bp + 48)).Fop = U8(TK_COLLATE)
  95866 		(*Expr)(unsafe.Pointer(bp + 48)).FpLeft = bp + 48 + 1*52
  95867 		(*Expr)(unsafe.Pointer(bp + 48 + 1*52)).Fop = U8(TK_COLUMN)
  95868 		(*Expr)(unsafe.Pointer(bp + 48 + 1*52)).FiTable = (*SrcItem)(unsafe.Pointer(pTabList + 8)).FiCursor
  95869 
  95870 		for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
  95871 			var ii int32
  95872 			var jj int32
  95873 			var nn int32
  95874 			if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None) {
  95875 				continue
  95876 			}
  95877 			if (*ExprList)(unsafe.Pointer(pTarget)).FnExpr != int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) {
  95878 				continue
  95879 			}
  95880 			if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 {
  95881 				if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere == uintptr(0) {
  95882 					continue
  95883 				}
  95884 				if Xsqlite3ExprCompare(tls, pParse, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere,
  95885 					(*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCursor) != 0 {
  95886 					continue
  95887 				}
  95888 			}
  95889 			nn = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
  95890 			for ii = 0; ii < nn; ii++ {
  95891 				var pExpr uintptr
  95892 				*(*uintptr)(unsafe.Pointer(bp + 48 + 8)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*4))
  95893 				if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) == -2 {
  95894 					pExpr = (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(ii)*20)).FpExpr
  95895 					if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLLATE {
  95896 						(*Expr)(unsafe.Pointer(bp + 48)).FpLeft = pExpr
  95897 						pExpr = bp + 48
  95898 					}
  95899 				} else {
  95900 					(*Expr)(unsafe.Pointer(bp + 48)).FpLeft = bp + 48 + 1*52
  95901 					(*Expr)(unsafe.Pointer(bp + 48 + 1*52)).FiColumn = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))
  95902 					pExpr = bp + 48
  95903 				}
  95904 				for jj = 0; jj < nn; jj++ {
  95905 					if Xsqlite3ExprCompare(tls, pParse, (*ExprList_item)(unsafe.Pointer(pTarget+8+uintptr(jj)*20)).FpExpr, pExpr, iCursor) < 2 {
  95906 						break
  95907 					}
  95908 				}
  95909 				if jj >= nn {
  95910 					break
  95911 				}
  95912 			}
  95913 			if ii < nn {
  95914 				continue
  95915 			}
  95916 			(*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx = pIdx
  95917 			break
  95918 		}
  95919 		if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx == uintptr(0) {
  95920 			if nClause == 0 && (*Upsert)(unsafe.Pointer(pUpsert)).FpNextUpsert == uintptr(0) {
  95921 				*(*uint8)(unsafe.Pointer(bp + 152)) = uint8(0)
  95922 			} else {
  95923 				Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([16]uint8{})), bp+152, ts+20607, libc.VaList(bp, nClause+1))
  95924 			}
  95925 			Xsqlite3ErrorMsg(tls, pParse,
  95926 				ts+20611, libc.VaList(bp+8, bp+152))
  95927 			return SQLITE_ERROR
  95928 		}
  95929 
  95930 	}
  95931 	goto __2
  95932 __2:
  95933 	pUpsert = (*Upsert)(unsafe.Pointer(pUpsert)).FpNextUpsert
  95934 	nClause++
  95935 	goto __1
  95936 	goto __3
  95937 __3:
  95938 	;
  95939 	return SQLITE_OK
  95940 }
  95941 
  95942 // Return true if pUpsert is the last ON CONFLICT clause with a
  95943 // conflict target, or if pUpsert is followed by another ON CONFLICT
  95944 // clause that targets the INTEGER PRIMARY KEY.
  95945 func Xsqlite3UpsertNextIsIPK(tls *libc.TLS, pUpsert uintptr) int32 {
  95946 	var pNext uintptr
  95947 	if pUpsert == uintptr(0) {
  95948 		return 0
  95949 	}
  95950 	pNext = (*Upsert)(unsafe.Pointer(pUpsert)).FpNextUpsert
  95951 	if pNext == uintptr(0) {
  95952 		return 1
  95953 	}
  95954 	if (*Upsert)(unsafe.Pointer(pNext)).FpUpsertTarget == uintptr(0) {
  95955 		return 1
  95956 	}
  95957 	if (*Upsert)(unsafe.Pointer(pNext)).FpUpsertIdx == uintptr(0) {
  95958 		return 1
  95959 	}
  95960 	return 0
  95961 }
  95962 
  95963 // Given the list of ON CONFLICT clauses described by pUpsert, and
  95964 // a particular index pIdx, return a pointer to the particular ON CONFLICT
  95965 // clause that applies to the index.  Or, if the index is not subject to
  95966 // any ON CONFLICT clause, return NULL.
  95967 func Xsqlite3UpsertOfIndex(tls *libc.TLS, pUpsert uintptr, pIdx uintptr) uintptr {
  95968 	for pUpsert != 0 &&
  95969 		(*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget != uintptr(0) &&
  95970 		(*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx != pIdx {
  95971 		pUpsert = (*Upsert)(unsafe.Pointer(pUpsert)).FpNextUpsert
  95972 	}
  95973 	return pUpsert
  95974 }
  95975 
  95976 // Generate bytecode that does an UPDATE as part of an upsert.
  95977 //
  95978 // If pIdx is NULL, then the UNIQUE constraint that failed was the IPK.
  95979 // In this case parameter iCur is a cursor open on the table b-tree that
  95980 // currently points to the conflicting table row. Otherwise, if pIdx
  95981 // is not NULL, then pIdx is the constraint that failed and iCur is a
  95982 // cursor points to the conflicting row.
  95983 func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab uintptr, pIdx uintptr, iCur int32) {
  95984 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  95985 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  95986 	var pSrc uintptr
  95987 	var iDataCur int32
  95988 	var i int32
  95989 	var pTop uintptr = pUpsert
  95990 
  95991 	iDataCur = (*Upsert)(unsafe.Pointer(pUpsert)).FiDataCur
  95992 	pUpsert = Xsqlite3UpsertOfIndex(tls, pTop, pIdx)
  95993 
  95994 	if pIdx != 0 && iCur != iDataCur {
  95995 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
  95996 			var regRowid int32 = Xsqlite3GetTempReg(tls, pParse)
  95997 			Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iCur, regRowid)
  95998 			Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, iDataCur, 0, regRowid)
  95999 
  96000 			Xsqlite3ReleaseTempReg(tls, pParse, regRowid)
  96001 		} else {
  96002 			var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab)
  96003 			var nPk int32 = int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
  96004 			var iPk int32 = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  96005 			*(*int32)(unsafe.Pointer(pParse + 44)) += nPk
  96006 			for i = 0; i < nPk; i++ {
  96007 				var k int32
  96008 
  96009 				k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2))))
  96010 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, k, iPk+i)
  96011 
  96012 			}
  96013 
  96014 			i = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iDataCur, 0, iPk, nPk)
  96015 
  96016 			Xsqlite3VdbeAddOp4(tls, v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0,
  96017 				ts+12150, -1)
  96018 			Xsqlite3MayAbort(tls, pParse)
  96019 			Xsqlite3VdbeJumpHere(tls, v, i)
  96020 		}
  96021 	}
  96022 
  96023 	pSrc = Xsqlite3SrcListDup(tls, db, (*Upsert)(unsafe.Pointer(pTop)).FpUpsertSrc, 0)
  96024 
  96025 	for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ {
  96026 		if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*16)).Faffinity) == SQLITE_AFF_REAL {
  96027 			Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, (*Upsert)(unsafe.Pointer(pTop)).FregData+i)
  96028 		}
  96029 	}
  96030 	Xsqlite3Update(tls, pParse, pSrc, Xsqlite3ExprListDup(tls, db, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet, 0),
  96031 		Xsqlite3ExprDup(tls, db, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, 0), OE_Abort, uintptr(0), uintptr(0), pUpsert)
  96032 
  96033 }
  96034 
  96035 func execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) int32 {
  96036 	bp := tls.Alloc(4)
  96037 	defer tls.Free(4)
  96038 
  96039 	var rc int32
  96040 
  96041 	rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp, uintptr(0))
  96042 	if rc != SQLITE_OK {
  96043 		return rc
  96044 	}
  96045 	for SQLITE_ROW == libc.AssignInt32(&rc, Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))) {
  96046 		var zSubSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
  96047 
  96048 		if zSubSql != 0 &&
  96049 			(libc.Xstrncmp(tls, zSubSql, ts+20684, uint32(3)) == 0 || libc.Xstrncmp(tls, zSubSql, ts+20688, uint32(3)) == 0) {
  96050 			rc = execSql(tls, db, pzErrMsg, zSubSql)
  96051 			if rc != SQLITE_OK {
  96052 				break
  96053 			}
  96054 		}
  96055 	}
  96056 
  96057 	if rc == SQLITE_DONE {
  96058 		rc = SQLITE_OK
  96059 	}
  96060 	if rc != 0 {
  96061 		Xsqlite3SetString(tls, pzErrMsg, db, Xsqlite3_errmsg(tls, db))
  96062 	}
  96063 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
  96064 	return rc
  96065 }
  96066 
  96067 func execSqlF(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr, va uintptr) int32 {
  96068 	var z uintptr
  96069 	var ap Va_list
  96070 	_ = ap
  96071 	var rc int32
  96072 	ap = va
  96073 	z = Xsqlite3VMPrintf(tls, db, zSql, ap)
  96074 	_ = ap
  96075 	if z == uintptr(0) {
  96076 		return SQLITE_NOMEM
  96077 	}
  96078 	rc = execSql(tls, db, pzErrMsg, z)
  96079 	Xsqlite3DbFree(tls, db, z)
  96080 	return rc
  96081 }
  96082 
  96083 // The VACUUM command is used to clean up the database,
  96084 // collapse free space, etc.  It is modelled after the VACUUM command
  96085 // in PostgreSQL.  The VACUUM command works as follows:
  96086 //
  96087 //	(1)  Create a new transient database file
  96088 //	(2)  Copy all content from the database being vacuumed into
  96089 //	     the new transient database file
  96090 //	(3)  Copy content from the transient database back into the
  96091 //	     original database.
  96092 //
  96093 // The transient database requires temporary disk space approximately
  96094 // equal to the size of the original database.  The copy operation of
  96095 // step (3) requires additional temporary disk space approximately equal
  96096 // to the size of the original database for the rollback journal.
  96097 // Hence, temporary disk space that is approximately 2x the size of the
  96098 // original database is required.  Every page of the database is written
  96099 // approximately 3 times:  Once for step (2) and twice for step (3).
  96100 // Two writes per page are required in step (3) because the original
  96101 // database content must be written into the rollback journal prior to
  96102 // overwriting the database with the vacuumed content.
  96103 //
  96104 // Only 1x temporary space and only 1x writes would be required if
  96105 // the copy of step (3) were replaced by deleting the original database
  96106 // and renaming the transient database as the original.  But that will
  96107 // not work if other processes are attached to the original database.
  96108 // And a power loss in between deleting the original and renaming the
  96109 // transient would cause the database file to appear to be deleted
  96110 // following reboot.
  96111 func Xsqlite3Vacuum(tls *libc.TLS, pParse uintptr, pNm uintptr, pInto uintptr) {
  96112 	bp := tls.Alloc(4)
  96113 	defer tls.Free(4)
  96114 	*(*uintptr)(unsafe.Pointer(bp)) = pNm
  96115 
  96116 	var v uintptr
  96117 	var iDb int32
  96118 	var iIntoReg int32
  96119 	v = Xsqlite3GetVdbe(tls, pParse)
  96120 	iDb = 0
  96121 	if !(v == uintptr(0)) {
  96122 		goto __1
  96123 	}
  96124 	goto build_vacuum_end
  96125 __1:
  96126 	;
  96127 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
  96128 		goto __2
  96129 	}
  96130 	goto build_vacuum_end
  96131 __2:
  96132 	;
  96133 	if !(*(*uintptr)(unsafe.Pointer(bp)) != 0) {
  96134 		goto __3
  96135 	}
  96136 
  96137 	iDb = Xsqlite3TwoPartName(tls, pParse, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp)), bp)
  96138 	if !(iDb < 0) {
  96139 		goto __4
  96140 	}
  96141 	goto build_vacuum_end
  96142 __4:
  96143 	;
  96144 __3:
  96145 	;
  96146 	if !(iDb != 1) {
  96147 		goto __5
  96148 	}
  96149 	iIntoReg = 0
  96150 	if !(pInto != 0 && Xsqlite3ResolveSelfReference(tls, pParse, uintptr(0), 0, pInto, uintptr(0)) == 0) {
  96151 		goto __6
  96152 	}
  96153 	iIntoReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  96154 	Xsqlite3ExprCode(tls, pParse, pInto, iIntoReg)
  96155 __6:
  96156 	;
  96157 	Xsqlite3VdbeAddOp2(tls, v, OP_Vacuum, iDb, iIntoReg)
  96158 	Xsqlite3VdbeUsesBtree(tls, v, iDb)
  96159 __5:
  96160 	;
  96161 build_vacuum_end:
  96162 	Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pInto)
  96163 	return
  96164 }
  96165 
  96166 // This routine implements the OP_Vacuum opcode of the VDBE.
  96167 func Xsqlite3RunVacuum(tls *libc.TLS, pzErrMsg uintptr, db uintptr, iDb int32, pOut uintptr) int32 {
  96168 	bp := tls.Alloc(52)
  96169 	defer tls.Free(52)
  96170 
  96171 	var rc int32
  96172 	var pMain uintptr
  96173 	var pTemp uintptr
  96174 	var saved_mDbFlags U32
  96175 	var saved_flags U64
  96176 	var saved_nChange I64
  96177 	var saved_nTotalChange I64
  96178 	var saved_openFlags U32
  96179 	var saved_mTrace U8
  96180 	var pDb uintptr
  96181 	var isMemDb int32
  96182 	var nRes int32
  96183 	var nDb int32
  96184 	var zDbMain uintptr
  96185 	var zOut uintptr
  96186 	var pgflags U32
  96187 	var id uintptr
  96188 
  96189 	var i int32
  96190 	rc = SQLITE_OK
  96191 	pDb = uintptr(0)
  96192 	pgflags = U32(PAGER_SYNCHRONOUS_OFF)
  96193 
  96194 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) {
  96195 		goto __1
  96196 	}
  96197 	Xsqlite3SetString(tls, pzErrMsg, db, ts+20692)
  96198 	return SQLITE_ERROR
  96199 __1:
  96200 	;
  96201 	if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive > 1) {
  96202 		goto __2
  96203 	}
  96204 	Xsqlite3SetString(tls, pzErrMsg, db, ts+20732)
  96205 	return SQLITE_ERROR
  96206 __2:
  96207 	;
  96208 	saved_openFlags = (*Sqlite3)(unsafe.Pointer(db)).FopenFlags
  96209 	if !(pOut != 0) {
  96210 		goto __3
  96211 	}
  96212 	if !(Xsqlite3_value_type(tls, pOut) != SQLITE_TEXT) {
  96213 		goto __5
  96214 	}
  96215 	Xsqlite3SetString(tls, pzErrMsg, db, ts+20775)
  96216 	return SQLITE_ERROR
  96217 __5:
  96218 	;
  96219 	zOut = Xsqlite3_value_text(tls, pOut)
  96220 	*(*uint32)(unsafe.Pointer(db + 60)) &= libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_READONLY))
  96221 	*(*uint32)(unsafe.Pointer(db + 60)) |= uint32(SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
  96222 	goto __4
  96223 __3:
  96224 	zOut = ts + 1554
  96225 __4:
  96226 	;
  96227 	saved_flags = (*Sqlite3)(unsafe.Pointer(db)).Fflags
  96228 	saved_mDbFlags = (*Sqlite3)(unsafe.Pointer(db)).FmDbFlags
  96229 	saved_nChange = (*Sqlite3)(unsafe.Pointer(db)).FnChange
  96230 	saved_nTotalChange = (*Sqlite3)(unsafe.Pointer(db)).FnTotalChange
  96231 	saved_mTrace = (*Sqlite3)(unsafe.Pointer(db)).FmTrace
  96232 	*(*U64)(unsafe.Pointer(db + 32)) |= uint64(SQLITE_WriteSchema | SQLITE_IgnoreChecks)
  96233 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_PreferBuiltin | DBFLAG_Vacuum)
  96234 	*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_ForeignKeys|SQLITE_ReverseOrder|
  96235 		SQLITE_Defensive) | uint64(0x00001)<<32)
  96236 	(*Sqlite3)(unsafe.Pointer(db)).FmTrace = U8(0)
  96237 
  96238 	zDbMain = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  96239 	pMain = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
  96240 	isMemDb = Xsqlite3PagerIsMemdb(tls, Xsqlite3BtreePager(tls, pMain))
  96241 
  96242 	nDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb
  96243 	rc = execSqlF(tls, db, pzErrMsg, ts+20793, libc.VaList(bp, zOut))
  96244 	(*Sqlite3)(unsafe.Pointer(db)).FopenFlags = saved_openFlags
  96245 	if !(rc != SQLITE_OK) {
  96246 		goto __6
  96247 	}
  96248 	goto end_of_vacuum
  96249 __6:
  96250 	;
  96251 	pDb = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(nDb)*16
  96252 
  96253 	pTemp = (*Db)(unsafe.Pointer(pDb)).FpBt
  96254 	if !(pOut != 0) {
  96255 		goto __7
  96256 	}
  96257 	id = Xsqlite3PagerFile(tls, Xsqlite3BtreePager(tls, pTemp))
  96258 	*(*I64)(unsafe.Pointer(bp + 40)) = int64(0)
  96259 	if !((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods != uintptr(0) && (Xsqlite3OsFileSize(tls, id, bp+40) != SQLITE_OK || *(*I64)(unsafe.Pointer(bp + 40)) > int64(0))) {
  96260 		goto __8
  96261 	}
  96262 	rc = SQLITE_ERROR
  96263 	Xsqlite3SetString(tls, pzErrMsg, db, ts+20816)
  96264 	goto end_of_vacuum
  96265 __8:
  96266 	;
  96267 	*(*U32)(unsafe.Pointer(db + 24)) |= U32(DBFLAG_VacuumInto)
  96268 
  96269 	pgflags = U32(U64((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).Fsafety_level) | (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(PAGER_FLAGS_MASK))
  96270 __7:
  96271 	;
  96272 	nRes = Xsqlite3BtreeGetRequestedReserve(tls, pMain)
  96273 
  96274 	Xsqlite3BtreeSetCacheSize(tls, pTemp, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FpSchema)).Fcache_size)
  96275 	Xsqlite3BtreeSetSpillSize(tls, pTemp, Xsqlite3BtreeSetSpillSize(tls, pMain, 0))
  96276 	Xsqlite3BtreeSetPagerFlags(tls, pTemp, pgflags|U32(PAGER_CACHESPILL))
  96277 
  96278 	rc = execSql(tls, db, pzErrMsg, ts+14503)
  96279 	if !(rc != SQLITE_OK) {
  96280 		goto __9
  96281 	}
  96282 	goto end_of_vacuum
  96283 __9:
  96284 	;
  96285 	rc = Xsqlite3BtreeBeginTrans(tls, pMain, func() int32 {
  96286 		if pOut == uintptr(0) {
  96287 			return 2
  96288 		}
  96289 		return 0
  96290 	}(), uintptr(0))
  96291 	if !(rc != SQLITE_OK) {
  96292 		goto __10
  96293 	}
  96294 	goto end_of_vacuum
  96295 __10:
  96296 	;
  96297 	if !(Xsqlite3PagerGetJournalMode(tls, Xsqlite3BtreePager(tls, pMain)) ==
  96298 		PAGER_JOURNALMODE_WAL &&
  96299 		pOut == uintptr(0)) {
  96300 		goto __11
  96301 	}
  96302 	(*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = 0
  96303 __11:
  96304 	;
  96305 	if !(Xsqlite3BtreeSetPageSize(tls, pTemp, Xsqlite3BtreeGetPageSize(tls, pMain), nRes, 0) != 0 ||
  96306 		!(isMemDb != 0) && Xsqlite3BtreeSetPageSize(tls, pTemp, (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, nRes, 0) != 0 ||
  96307 		(*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  96308 		goto __12
  96309 	}
  96310 	rc = SQLITE_NOMEM
  96311 	goto end_of_vacuum
  96312 __12:
  96313 	;
  96314 	Xsqlite3BtreeSetAutoVacuum(tls, pTemp, func() int32 {
  96315 		if int32((*Sqlite3)(unsafe.Pointer(db)).FnextAutovac) >= 0 {
  96316 			return int32((*Sqlite3)(unsafe.Pointer(db)).FnextAutovac)
  96317 		}
  96318 		return Xsqlite3BtreeGetAutoVacuum(tls, pMain)
  96319 	}())
  96320 
  96321 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(nDb)
  96322 	rc = execSqlF(tls, db, pzErrMsg,
  96323 		ts+20843,
  96324 		libc.VaList(bp+8, zDbMain))
  96325 	if !(rc != SQLITE_OK) {
  96326 		goto __13
  96327 	}
  96328 	goto end_of_vacuum
  96329 __13:
  96330 	;
  96331 	rc = execSqlF(tls, db, pzErrMsg,
  96332 		ts+20951,
  96333 		libc.VaList(bp+16, zDbMain))
  96334 	if !(rc != SQLITE_OK) {
  96335 		goto __14
  96336 	}
  96337 	goto end_of_vacuum
  96338 __14:
  96339 	;
  96340 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(0)
  96341 
  96342 	rc = execSqlF(tls, db, pzErrMsg,
  96343 		ts+21005,
  96344 		libc.VaList(bp+24, zDbMain))
  96345 
  96346 	*(*U32)(unsafe.Pointer(db + 24)) &= libc.Uint32FromInt32(libc.CplInt32(DBFLAG_Vacuum))
  96347 	if !(rc != SQLITE_OK) {
  96348 		goto __15
  96349 	}
  96350 	goto end_of_vacuum
  96351 __15:
  96352 	;
  96353 	rc = execSqlF(tls, db, pzErrMsg,
  96354 		ts+21156,
  96355 		libc.VaList(bp+32, zDbMain))
  96356 	if !(rc != 0) {
  96357 		goto __16
  96358 	}
  96359 	goto end_of_vacuum
  96360 __16:
  96361 	;
  96362 	i = 0
  96363 __17:
  96364 	if !(i < int32(uint32(unsafe.Sizeof(aCopy))/uint32(unsafe.Sizeof(uint8(0))))) {
  96365 		goto __19
  96366 	}
  96367 
  96368 	Xsqlite3BtreeGetMeta(tls, pMain, int32(aCopy[i]), bp+48)
  96369 	rc = Xsqlite3BtreeUpdateMeta(tls, pTemp, int32(aCopy[i]), *(*U32)(unsafe.Pointer(bp + 48))+U32(aCopy[i+1]))
  96370 	if !(rc != SQLITE_OK) {
  96371 		goto __20
  96372 	}
  96373 	goto end_of_vacuum
  96374 __20:
  96375 	;
  96376 	goto __18
  96377 __18:
  96378 	i = i + 2
  96379 	goto __17
  96380 	goto __19
  96381 __19:
  96382 	;
  96383 	if !(pOut == uintptr(0)) {
  96384 		goto __21
  96385 	}
  96386 	rc = Xsqlite3BtreeCopyFile(tls, pMain, pTemp)
  96387 __21:
  96388 	;
  96389 	if !(rc != SQLITE_OK) {
  96390 		goto __22
  96391 	}
  96392 	goto end_of_vacuum
  96393 __22:
  96394 	;
  96395 	rc = Xsqlite3BtreeCommit(tls, pTemp)
  96396 	if !(rc != SQLITE_OK) {
  96397 		goto __23
  96398 	}
  96399 	goto end_of_vacuum
  96400 __23:
  96401 	;
  96402 	if !(pOut == uintptr(0)) {
  96403 		goto __24
  96404 	}
  96405 	Xsqlite3BtreeSetAutoVacuum(tls, pMain, Xsqlite3BtreeGetAutoVacuum(tls, pTemp))
  96406 __24:
  96407 	;
  96408 	if !(pOut == uintptr(0)) {
  96409 		goto __25
  96410 	}
  96411 	nRes = Xsqlite3BtreeGetRequestedReserve(tls, pTemp)
  96412 	rc = Xsqlite3BtreeSetPageSize(tls, pMain, Xsqlite3BtreeGetPageSize(tls, pTemp), nRes, 1)
  96413 __25:
  96414 	;
  96415 end_of_vacuum:
  96416 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(0)
  96417 	(*Sqlite3)(unsafe.Pointer(db)).FmDbFlags = saved_mDbFlags
  96418 	(*Sqlite3)(unsafe.Pointer(db)).Fflags = saved_flags
  96419 	(*Sqlite3)(unsafe.Pointer(db)).FnChange = saved_nChange
  96420 	(*Sqlite3)(unsafe.Pointer(db)).FnTotalChange = saved_nTotalChange
  96421 	(*Sqlite3)(unsafe.Pointer(db)).FmTrace = saved_mTrace
  96422 	Xsqlite3BtreeSetPageSize(tls, pMain, -1, 0, 1)
  96423 
  96424 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
  96425 
  96426 	if !(pDb != 0) {
  96427 		goto __26
  96428 	}
  96429 	Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer(pDb)).FpBt)
  96430 	(*Db)(unsafe.Pointer(pDb)).FpBt = uintptr(0)
  96431 	(*Db)(unsafe.Pointer(pDb)).FpSchema = uintptr(0)
  96432 __26:
  96433 	;
  96434 	Xsqlite3ResetAllSchemasOfConnection(tls, db)
  96435 
  96436 	return rc
  96437 }
  96438 
  96439 var aCopy = [10]uint8{
  96440 	uint8(BTREE_SCHEMA_VERSION), uint8(1),
  96441 	uint8(BTREE_DEFAULT_CACHE_SIZE), uint8(0),
  96442 	uint8(BTREE_TEXT_ENCODING), uint8(0),
  96443 	uint8(BTREE_USER_VERSION), uint8(0),
  96444 	uint8(BTREE_APPLICATION_ID), uint8(0),
  96445 }
  96446 
  96447 // Construct and install a Module object for a virtual table.  When this
  96448 // routine is called, it is guaranteed that all appropriate locks are held
  96449 // and the module is not already part of the connection.
  96450 //
  96451 // If there already exists a module with zName, replace it with the new one.
  96452 // If pModule==0, then delete the module zName if it exists.
  96453 func Xsqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, xDestroy uintptr) uintptr {
  96454 	var pMod uintptr
  96455 	var pDel uintptr
  96456 	var zCopy uintptr
  96457 	if pModule == uintptr(0) {
  96458 		zCopy = zName
  96459 		pMod = uintptr(0)
  96460 	} else {
  96461 		var nName int32 = Xsqlite3Strlen30(tls, zName)
  96462 		pMod = Xsqlite3Malloc(tls, uint64(uint32(unsafe.Sizeof(Module{}))+uint32(nName)+uint32(1)))
  96463 		if pMod == uintptr(0) {
  96464 			Xsqlite3OomFault(tls, db)
  96465 			return uintptr(0)
  96466 		}
  96467 		zCopy = pMod + 1*24
  96468 		libc.Xmemcpy(tls, zCopy, zName, uint32(nName+1))
  96469 		(*Module)(unsafe.Pointer(pMod)).FzName = zCopy
  96470 		(*Module)(unsafe.Pointer(pMod)).FpModule = pModule
  96471 		(*Module)(unsafe.Pointer(pMod)).FpAux = pAux
  96472 		(*Module)(unsafe.Pointer(pMod)).FxDestroy = xDestroy
  96473 		(*Module)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0)
  96474 		(*Module)(unsafe.Pointer(pMod)).FnRefModule = 1
  96475 	}
  96476 	pDel = Xsqlite3HashInsert(tls, db+404, zCopy, pMod)
  96477 	if pDel != 0 {
  96478 		if pDel == pMod {
  96479 			Xsqlite3OomFault(tls, db)
  96480 			Xsqlite3DbFree(tls, db, pDel)
  96481 			pMod = uintptr(0)
  96482 		} else {
  96483 			Xsqlite3VtabEponymousTableClear(tls, db, pDel)
  96484 			Xsqlite3VtabModuleUnref(tls, db, pDel)
  96485 		}
  96486 	}
  96487 	return pMod
  96488 }
  96489 
  96490 func createModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, xDestroy uintptr) int32 {
  96491 	var rc int32 = SQLITE_OK
  96492 
  96493 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  96494 	Xsqlite3VtabCreateModule(tls, db, zName, pModule, pAux, xDestroy)
  96495 	rc = Xsqlite3ApiExit(tls, db, rc)
  96496 	if rc != SQLITE_OK && xDestroy != 0 {
  96497 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDestroy})).f(tls, pAux)
  96498 	}
  96499 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  96500 	return rc
  96501 }
  96502 
  96503 // External API function used to create a new virtual-table module.
  96504 func Xsqlite3_create_module(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr) int32 {
  96505 	return createModule(tls, db, zName, pModule, pAux, uintptr(0))
  96506 }
  96507 
  96508 // External API function used to create a new virtual-table module.
  96509 func Xsqlite3_create_module_v2(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, xDestroy uintptr) int32 {
  96510 	return createModule(tls, db, zName, pModule, pAux, xDestroy)
  96511 }
  96512 
  96513 // External API to drop all virtual-table modules, except those named
  96514 // on the azNames list.
  96515 func Xsqlite3_drop_modules(tls *libc.TLS, db uintptr, azNames uintptr) int32 {
  96516 	var pThis uintptr
  96517 	var pNext uintptr
  96518 	for pThis = (*Hash)(unsafe.Pointer(db + 404)).Ffirst; pThis != 0; pThis = pNext {
  96519 		var pMod uintptr = (*HashElem)(unsafe.Pointer(pThis)).Fdata
  96520 		pNext = (*HashElem)(unsafe.Pointer(pThis)).Fnext
  96521 		if azNames != 0 {
  96522 			var ii int32
  96523 			for ii = 0; *(*uintptr)(unsafe.Pointer(azNames + uintptr(ii)*4)) != uintptr(0) && libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(azNames + uintptr(ii)*4)), (*Module)(unsafe.Pointer(pMod)).FzName) != 0; ii++ {
  96524 			}
  96525 			if *(*uintptr)(unsafe.Pointer(azNames + uintptr(ii)*4)) != uintptr(0) {
  96526 				continue
  96527 			}
  96528 		}
  96529 		createModule(tls, db, (*Module)(unsafe.Pointer(pMod)).FzName, uintptr(0), uintptr(0), uintptr(0))
  96530 	}
  96531 	return SQLITE_OK
  96532 }
  96533 
  96534 // Decrement the reference count on a Module object.  Destroy the
  96535 // module when the reference count reaches zero.
  96536 func Xsqlite3VtabModuleUnref(tls *libc.TLS, db uintptr, pMod uintptr) {
  96537 	(*Module)(unsafe.Pointer(pMod)).FnRefModule--
  96538 	if (*Module)(unsafe.Pointer(pMod)).FnRefModule == 0 {
  96539 		if (*Module)(unsafe.Pointer(pMod)).FxDestroy != 0 {
  96540 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Module)(unsafe.Pointer(pMod)).FxDestroy})).f(tls, (*Module)(unsafe.Pointer(pMod)).FpAux)
  96541 		}
  96542 
  96543 		Xsqlite3DbFree(tls, db, pMod)
  96544 	}
  96545 }
  96546 
  96547 // Lock the virtual table so that it cannot be disconnected.
  96548 // Locks nest.  Every lock should have a corresponding unlock.
  96549 // If an unlock is omitted, resources leaks will occur.
  96550 //
  96551 // If a disconnect is attempted while a virtual table is locked,
  96552 // the disconnect is deferred until all locks have been removed.
  96553 func Xsqlite3VtabLock(tls *libc.TLS, pVTab uintptr) {
  96554 	(*VTable)(unsafe.Pointer(pVTab)).FnRef++
  96555 }
  96556 
  96557 // pTab is a pointer to a Table structure representing a virtual-table.
  96558 // Return a pointer to the VTable object used by connection db to access
  96559 // this virtual-table, if one has been created, or NULL otherwise.
  96560 func Xsqlite3GetVTable(tls *libc.TLS, db uintptr, pTab uintptr) uintptr {
  96561 	var pVtab uintptr
  96562 
  96563 	for pVtab = *(*uintptr)(unsafe.Pointer(pTab + 44 + 8)); pVtab != 0 && (*VTable)(unsafe.Pointer(pVtab)).Fdb != db; pVtab = (*VTable)(unsafe.Pointer(pVtab)).FpNext {
  96564 	}
  96565 	return pVtab
  96566 }
  96567 
  96568 // Decrement the ref-count on a virtual table object. When the ref-count
  96569 // reaches zero, call the xDisconnect() method to delete the object.
  96570 func Xsqlite3VtabUnlock(tls *libc.TLS, pVTab uintptr) {
  96571 	var db uintptr = (*VTable)(unsafe.Pointer(pVTab)).Fdb
  96572 
  96573 	(*VTable)(unsafe.Pointer(pVTab)).FnRef--
  96574 	if (*VTable)(unsafe.Pointer(pVTab)).FnRef == 0 {
  96575 		var p uintptr = (*VTable)(unsafe.Pointer(pVTab)).FpVtab
  96576 		if p != 0 {
  96577 			(*struct {
  96578 				f func(*libc.TLS, uintptr) int32
  96579 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(p)).FpModule)).FxDisconnect})).f(tls, p)
  96580 		}
  96581 		Xsqlite3VtabModuleUnref(tls, (*VTable)(unsafe.Pointer(pVTab)).Fdb, (*VTable)(unsafe.Pointer(pVTab)).FpMod)
  96582 		Xsqlite3DbFree(tls, db, pVTab)
  96583 	}
  96584 }
  96585 
  96586 func vtabDisconnectAll(tls *libc.TLS, db uintptr, p uintptr) uintptr {
  96587 	var pRet uintptr = uintptr(0)
  96588 	var pVTable uintptr
  96589 
  96590 	pVTable = *(*uintptr)(unsafe.Pointer(p + 44 + 8))
  96591 	*(*uintptr)(unsafe.Pointer(p + 44 + 8)) = uintptr(0)
  96592 
  96593 	for pVTable != 0 {
  96594 		var db2 uintptr = (*VTable)(unsafe.Pointer(pVTable)).Fdb
  96595 		var pNext uintptr = (*VTable)(unsafe.Pointer(pVTable)).FpNext
  96596 
  96597 		if db2 == db {
  96598 			pRet = pVTable
  96599 			*(*uintptr)(unsafe.Pointer(p + 44 + 8)) = pRet
  96600 			(*VTable)(unsafe.Pointer(pRet)).FpNext = uintptr(0)
  96601 		} else {
  96602 			(*VTable)(unsafe.Pointer(pVTable)).FpNext = (*Sqlite3)(unsafe.Pointer(db2)).FpDisconnect
  96603 			(*Sqlite3)(unsafe.Pointer(db2)).FpDisconnect = pVTable
  96604 		}
  96605 		pVTable = pNext
  96606 	}
  96607 
  96608 	return pRet
  96609 }
  96610 
  96611 // Table *p is a virtual table. This function removes the VTable object
  96612 // for table *p associated with database connection db from the linked
  96613 // list in p->pVTab. It also decrements the VTable ref count. This is
  96614 // used when closing database connection db to free all of its VTable
  96615 // objects without disturbing the rest of the Schema object (which may
  96616 // be being used by other shared-cache connections).
  96617 func Xsqlite3VtabDisconnect(tls *libc.TLS, db uintptr, p uintptr) {
  96618 	var ppVTab uintptr
  96619 
  96620 	for ppVTab = p + 44 + 8; *(*uintptr)(unsafe.Pointer(ppVTab)) != 0; ppVTab = *(*uintptr)(unsafe.Pointer(ppVTab)) + 24 {
  96621 		if (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppVTab)))).Fdb == db {
  96622 			var pVTab uintptr = *(*uintptr)(unsafe.Pointer(ppVTab))
  96623 			*(*uintptr)(unsafe.Pointer(ppVTab)) = (*VTable)(unsafe.Pointer(pVTab)).FpNext
  96624 			Xsqlite3VtabUnlock(tls, pVTab)
  96625 			break
  96626 		}
  96627 	}
  96628 }
  96629 
  96630 // Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
  96631 //
  96632 // This function may only be called when the mutexes associated with all
  96633 // shared b-tree databases opened using connection db are held by the
  96634 // caller. This is done to protect the sqlite3.pDisconnect list. The
  96635 // sqlite3.pDisconnect list is accessed only as follows:
  96636 //
  96637 //  1. By this function. In this case, all BtShared mutexes and the mutex
  96638 //     associated with the database handle itself must be held.
  96639 //
  96640 //  2. By function vtabDisconnectAll(), when it adds a VTable entry to
  96641 //     the sqlite3.pDisconnect list. In this case either the BtShared mutex
  96642 //     associated with the database the virtual table is stored in is held
  96643 //     or, if the virtual table is stored in a non-sharable database, then
  96644 //     the database handle mutex is held.
  96645 //
  96646 // As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
  96647 // by multiple threads. It is thread-safe.
  96648 func Xsqlite3VtabUnlockList(tls *libc.TLS, db uintptr) {
  96649 	var p uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpDisconnect
  96650 
  96651 	if p != 0 {
  96652 		(*Sqlite3)(unsafe.Pointer(db)).FpDisconnect = uintptr(0)
  96653 		Xsqlite3ExpirePreparedStatements(tls, db, 0)
  96654 		for __ccgo := true; __ccgo; __ccgo = p != 0 {
  96655 			var pNext uintptr = (*VTable)(unsafe.Pointer(p)).FpNext
  96656 			Xsqlite3VtabUnlock(tls, p)
  96657 			p = pNext
  96658 		}
  96659 	}
  96660 }
  96661 
  96662 // Clear any and all virtual-table information from the Table record.
  96663 // This routine is called, for example, just before deleting the Table
  96664 // record.
  96665 //
  96666 // Since it is a virtual-table, the Table structure contains a pointer
  96667 // to the head of a linked list of VTable structures. Each VTable
  96668 // structure is associated with a single sqlite3* user of the schema.
  96669 // The reference count of the VTable structure associated with database
  96670 // connection db is decremented immediately (which may lead to the
  96671 // structure being xDisconnected and free). Any other VTable structures
  96672 // in the list are moved to the sqlite3.pDisconnect list of the associated
  96673 // database connection.
  96674 func Xsqlite3VtabClear(tls *libc.TLS, db uintptr, p uintptr) {
  96675 	if (*Sqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
  96676 		vtabDisconnectAll(tls, uintptr(0), p)
  96677 	}
  96678 	if *(*uintptr)(unsafe.Pointer(p + 44 + 4)) != 0 {
  96679 		var i int32
  96680 		for i = 0; i < *(*int32)(unsafe.Pointer(p + 44)); i++ {
  96681 			if i != 1 {
  96682 				Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44 + 4)) + uintptr(i)*4)))
  96683 			}
  96684 		}
  96685 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 44 + 4)))
  96686 	}
  96687 }
  96688 
  96689 func addModuleArgument(tls *libc.TLS, pParse uintptr, pTable uintptr, zArg uintptr) {
  96690 	bp := tls.Alloc(8)
  96691 	defer tls.Free(8)
  96692 
  96693 	var nBytes Sqlite3_int64
  96694 	var azModuleArg uintptr
  96695 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  96696 
  96697 	nBytes = Sqlite3_int64(uint32(unsafe.Sizeof(uintptr(0))) * uint32(2+*(*int32)(unsafe.Pointer(pTable + 44))))
  96698 	if *(*int32)(unsafe.Pointer(pTable + 44))+3 >= *(*int32)(unsafe.Pointer(db + 120 + 2*4)) {
  96699 		Xsqlite3ErrorMsg(tls, pParse, ts+12377, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName))
  96700 	}
  96701 	azModuleArg = Xsqlite3DbRealloc(tls, db, *(*uintptr)(unsafe.Pointer(pTable + 44 + 4)), uint64(nBytes))
  96702 	if azModuleArg == uintptr(0) {
  96703 		Xsqlite3DbFree(tls, db, zArg)
  96704 	} else {
  96705 		var i int32 = libc.PostIncInt32(&*(*int32)(unsafe.Pointer(pTable + 44)), 1)
  96706 		*(*uintptr)(unsafe.Pointer(azModuleArg + uintptr(i)*4)) = zArg
  96707 		*(*uintptr)(unsafe.Pointer(azModuleArg + uintptr(i+1)*4)) = uintptr(0)
  96708 		*(*uintptr)(unsafe.Pointer(pTable + 44 + 4)) = azModuleArg
  96709 	}
  96710 }
  96711 
  96712 // The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
  96713 // statement.  The module name has been parsed, but the optional list
  96714 // of parameters that follow the module name are still pending.
  96715 func Xsqlite3VtabBeginParse(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pModuleName uintptr, ifNotExists int32) {
  96716 	var pTable uintptr
  96717 	var db uintptr
  96718 
  96719 	Xsqlite3StartTable(tls, pParse, pName1, pName2, 0, 0, 1, ifNotExists)
  96720 	pTable = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  96721 	if pTable == uintptr(0) {
  96722 		return
  96723 	}
  96724 
  96725 	(*Table)(unsafe.Pointer(pTable)).FeTabType = U8(TABTYP_VTAB)
  96726 
  96727 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  96728 
  96729 	addModuleArgument(tls, pParse, pTable, Xsqlite3NameFromToken(tls, db, pModuleName))
  96730 	addModuleArgument(tls, pParse, pTable, uintptr(0))
  96731 	addModuleArgument(tls, pParse, pTable, Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTable)).FzName))
  96732 
  96733 	(*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fn = uint32((int32((*Token)(unsafe.Pointer(pModuleName)).Fz+uintptr((*Token)(unsafe.Pointer(pModuleName)).Fn)) - int32((*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) / 1)
  96734 
  96735 	if *(*uintptr)(unsafe.Pointer(pTable + 44 + 4)) != 0 {
  96736 		var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTable)).FpSchema)
  96737 
  96738 		Xsqlite3AuthCheck(tls, pParse, SQLITE_CREATE_VTABLE, (*Table)(unsafe.Pointer(pTable)).FzName,
  96739 			*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTable + 44 + 4)))), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*16)).FzDbSName)
  96740 	}
  96741 }
  96742 
  96743 func addArgumentToVtab(tls *libc.TLS, pParse uintptr) {
  96744 	if (*Parse)(unsafe.Pointer(pParse)).FsArg.Fz != 0 && (*Parse)(unsafe.Pointer(pParse)).FpNewTable != 0 {
  96745 		var z uintptr = (*Parse)(unsafe.Pointer(pParse)).FsArg.Fz
  96746 		var n int32 = int32((*Parse)(unsafe.Pointer(pParse)).FsArg.Fn)
  96747 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  96748 		addModuleArgument(tls, pParse, (*Parse)(unsafe.Pointer(pParse)).FpNewTable, Xsqlite3DbStrNDup(tls, db, z, uint64(n)))
  96749 	}
  96750 }
  96751 
  96752 // The parser calls this routine after the CREATE VIRTUAL TABLE statement
  96753 // has been completely parsed.
  96754 func Xsqlite3VtabFinishParse(tls *libc.TLS, pParse uintptr, pEnd uintptr) {
  96755 	bp := tls.Alloc(64)
  96756 	defer tls.Free(64)
  96757 
  96758 	var pTab uintptr = (*Parse)(unsafe.Pointer(pParse)).FpNewTable
  96759 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  96760 
  96761 	if pTab == uintptr(0) {
  96762 		return
  96763 	}
  96764 
  96765 	addArgumentToVtab(tls, pParse)
  96766 	(*Parse)(unsafe.Pointer(pParse)).FsArg.Fz = uintptr(0)
  96767 	if *(*int32)(unsafe.Pointer(pTab + 44)) < 1 {
  96768 		return
  96769 	}
  96770 
  96771 	if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) {
  96772 		var zStmt uintptr
  96773 		var zWhere uintptr
  96774 		var iDb int32
  96775 		var iReg int32
  96776 		var v uintptr
  96777 
  96778 		Xsqlite3MayAbort(tls, pParse)
  96779 
  96780 		if pEnd != 0 {
  96781 			(*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fn = uint32((int32((*Token)(unsafe.Pointer(pEnd)).Fz)-int32((*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz))/1) + (*Token)(unsafe.Pointer(pEnd)).Fn
  96782 		}
  96783 		zStmt = Xsqlite3MPrintf(tls, db, ts+21286, libc.VaList(bp, pParse+196))
  96784 
  96785 		iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  96786 		Xsqlite3NestedParse(tls, pParse,
  96787 			ts+21310,
  96788 			libc.VaList(bp+8, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName,
  96789 				(*Table)(unsafe.Pointer(pTab)).FzName,
  96790 				(*Table)(unsafe.Pointer(pTab)).FzName,
  96791 				zStmt,
  96792 				(*Parse)(unsafe.Pointer(pParse)).FregRowid))
  96793 		v = Xsqlite3GetVdbe(tls, pParse)
  96794 		Xsqlite3ChangeCookie(tls, pParse, iDb)
  96795 
  96796 		Xsqlite3VdbeAddOp0(tls, v, OP_Expire)
  96797 		zWhere = Xsqlite3MPrintf(tls, db, ts+21409, libc.VaList(bp+48, (*Table)(unsafe.Pointer(pTab)).FzName, zStmt))
  96798 		Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb, zWhere, uint16(0))
  96799 		Xsqlite3DbFree(tls, db, zStmt)
  96800 
  96801 		iReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  96802 		Xsqlite3VdbeLoadString(tls, v, iReg, (*Table)(unsafe.Pointer(pTab)).FzName)
  96803 		Xsqlite3VdbeAddOp2(tls, v, OP_VCreate, iDb, iReg)
  96804 	} else {
  96805 		var pOld uintptr
  96806 		var pSchema uintptr = (*Table)(unsafe.Pointer(pTab)).FpSchema
  96807 		var zName uintptr = (*Table)(unsafe.Pointer(pTab)).FzName
  96808 
  96809 		Xsqlite3MarkAllShadowTablesOf(tls, db, pTab)
  96810 		pOld = Xsqlite3HashInsert(tls, pSchema+8, zName, pTab)
  96811 		if pOld != 0 {
  96812 			Xsqlite3OomFault(tls, db)
  96813 
  96814 			return
  96815 		}
  96816 		(*Parse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0)
  96817 	}
  96818 }
  96819 
  96820 // The parser calls this routine when it sees the first token
  96821 // of an argument to the module name in a CREATE VIRTUAL TABLE statement.
  96822 func Xsqlite3VtabArgInit(tls *libc.TLS, pParse uintptr) {
  96823 	addArgumentToVtab(tls, pParse)
  96824 	(*Parse)(unsafe.Pointer(pParse)).FsArg.Fz = uintptr(0)
  96825 	(*Parse)(unsafe.Pointer(pParse)).FsArg.Fn = uint32(0)
  96826 }
  96827 
  96828 // The parser calls this routine for each token after the first token
  96829 // in an argument to the module name in a CREATE VIRTUAL TABLE statement.
  96830 func Xsqlite3VtabArgExtend(tls *libc.TLS, pParse uintptr, p uintptr) {
  96831 	var pArg uintptr = pParse + 260
  96832 	if (*Token)(unsafe.Pointer(pArg)).Fz == uintptr(0) {
  96833 		(*Token)(unsafe.Pointer(pArg)).Fz = (*Token)(unsafe.Pointer(p)).Fz
  96834 		(*Token)(unsafe.Pointer(pArg)).Fn = (*Token)(unsafe.Pointer(p)).Fn
  96835 	} else {
  96836 		(*Token)(unsafe.Pointer(pArg)).Fn = uint32((int32((*Token)(unsafe.Pointer(p)).Fz+uintptr((*Token)(unsafe.Pointer(p)).Fn)) - int32((*Token)(unsafe.Pointer(pArg)).Fz)) / 1)
  96837 	}
  96838 }
  96839 
  96840 func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, xConstruct uintptr, pzErr uintptr) int32 {
  96841 	bp := tls.Alloc(52)
  96842 	defer tls.Free(52)
  96843 
  96844 	var pVTable uintptr
  96845 	var rc int32
  96846 	var azArg uintptr
  96847 	var nArg int32 = *(*int32)(unsafe.Pointer(pTab + 44))
  96848 	*(*uintptr)(unsafe.Pointer(bp + 48)) = uintptr(0)
  96849 	var zModuleName uintptr
  96850 	var iDb int32
  96851 	var pCtx uintptr
  96852 
  96853 	azArg = *(*uintptr)(unsafe.Pointer(pTab + 44 + 4))
  96854 
  96855 	for pCtx = (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx; pCtx != 0; pCtx = (*VtabCtx)(unsafe.Pointer(pCtx)).FpPrior {
  96856 		if (*VtabCtx)(unsafe.Pointer(pCtx)).FpTab == pTab {
  96857 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db,
  96858 				ts+21428, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName))
  96859 			return SQLITE_LOCKED
  96860 		}
  96861 	}
  96862 
  96863 	zModuleName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName)
  96864 	if !(zModuleName != 0) {
  96865 		return SQLITE_NOMEM
  96866 	}
  96867 
  96868 	pVTable = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(VTable{})))
  96869 	if !(pVTable != 0) {
  96870 		Xsqlite3OomFault(tls, db)
  96871 		Xsqlite3DbFree(tls, db, zModuleName)
  96872 		return SQLITE_NOMEM
  96873 	}
  96874 	(*VTable)(unsafe.Pointer(pVTable)).Fdb = db
  96875 	(*VTable)(unsafe.Pointer(pVTable)).FpMod = pMod
  96876 	(*VTable)(unsafe.Pointer(pVTable)).FeVtabRisk = U8(SQLITE_VTABRISK_Normal)
  96877 
  96878 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
  96879 	*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 4)) + 1*4)) = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FzDbSName
  96880 
  96881 	(*VtabCtx)(unsafe.Pointer(bp + 32)).FpTab = pTab
  96882 	(*VtabCtx)(unsafe.Pointer(bp + 32)).FpVTable = pVTable
  96883 	(*VtabCtx)(unsafe.Pointer(bp + 32)).FpPrior = (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx
  96884 	(*VtabCtx)(unsafe.Pointer(bp + 32)).FbDeclared = 0
  96885 	(*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx = bp + 32
  96886 	(*Table)(unsafe.Pointer(pTab)).FnTabRef++
  96887 	rc = (*struct {
  96888 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32
  96889 	})(unsafe.Pointer(&struct{ uintptr }{xConstruct})).f(tls, db, (*Module)(unsafe.Pointer(pMod)).FpAux, nArg, azArg, pVTable+8, bp+48)
  96890 	Xsqlite3DeleteTable(tls, db, pTab)
  96891 	(*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx = (*VtabCtx)(unsafe.Pointer(bp + 32)).FpPrior
  96892 	if rc == SQLITE_NOMEM {
  96893 		Xsqlite3OomFault(tls, db)
  96894 	}
  96895 
  96896 	if SQLITE_OK != rc {
  96897 		if *(*uintptr)(unsafe.Pointer(bp + 48)) == uintptr(0) {
  96898 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+21470, libc.VaList(bp+8, zModuleName))
  96899 		} else {
  96900 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+3663, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(bp + 48))))
  96901 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 48)))
  96902 		}
  96903 		Xsqlite3DbFree(tls, db, pVTable)
  96904 	} else if (*VTable)(unsafe.Pointer(pVTable)).FpVtab != 0 {
  96905 		libc.Xmemset(tls, (*VTable)(unsafe.Pointer(pVTable)).FpVtab, 0, uint32(unsafe.Sizeof(Sqlite3_vtab{})))
  96906 		(*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTable)).FpVtab)).FpModule = (*Module)(unsafe.Pointer(pMod)).FpModule
  96907 		(*Module)(unsafe.Pointer(pMod)).FnRefModule++
  96908 		(*VTable)(unsafe.Pointer(pVTable)).FnRef = 1
  96909 		if (*VtabCtx)(unsafe.Pointer(bp+32)).FbDeclared == 0 {
  96910 			var zFormat uintptr = ts + 21500
  96911 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, zFormat, libc.VaList(bp+24, (*Table)(unsafe.Pointer(pTab)).FzName))
  96912 			Xsqlite3VtabUnlock(tls, pVTable)
  96913 			rc = SQLITE_ERROR
  96914 		} else {
  96915 			var iCol int32
  96916 			var oooHidden U16 = U16(0)
  96917 
  96918 			(*VTable)(unsafe.Pointer(pVTable)).FpNext = *(*uintptr)(unsafe.Pointer(pTab + 44 + 8))
  96919 			*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) = pVTable
  96920 
  96921 			for iCol = 0; iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol); iCol++ {
  96922 				var zType uintptr = Xsqlite3ColumnType(tls, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*16, ts+1554)
  96923 				var nType int32
  96924 				var i int32 = 0
  96925 				nType = Xsqlite3Strlen30(tls, zType)
  96926 				for i = 0; i < nType; i++ {
  96927 					if 0 == Xsqlite3_strnicmp(tls, ts+16158, zType+uintptr(i), 6) &&
  96928 						(i == 0 || int32(*(*uint8)(unsafe.Pointer(zType + uintptr(i-1)))) == ' ') &&
  96929 						(int32(*(*uint8)(unsafe.Pointer(zType + uintptr(i+6)))) == 0 || int32(*(*uint8)(unsafe.Pointer(zType + uintptr(i+6)))) == ' ') {
  96930 						break
  96931 					}
  96932 				}
  96933 				if i < nType {
  96934 					var j int32
  96935 					var nDel int32 = 6 + func() int32 {
  96936 						if *(*uint8)(unsafe.Pointer(zType + uintptr(i+6))) != 0 {
  96937 							return 1
  96938 						}
  96939 						return 0
  96940 					}()
  96941 					for j = i; j+nDel <= nType; j++ {
  96942 						*(*uint8)(unsafe.Pointer(zType + uintptr(j))) = *(*uint8)(unsafe.Pointer(zType + uintptr(j+nDel)))
  96943 					}
  96944 					if int32(*(*uint8)(unsafe.Pointer(zType + uintptr(i)))) == 0 && i > 0 {
  96945 						*(*uint8)(unsafe.Pointer(zType + uintptr(i-1))) = uint8(0)
  96946 					}
  96947 					*(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16 + 12)) |= U16(COLFLAG_HIDDEN)
  96948 					*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_HasHidden)
  96949 					oooHidden = U16(TF_OOOHidden)
  96950 				} else {
  96951 					*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(oooHidden)
  96952 				}
  96953 			}
  96954 		}
  96955 	}
  96956 
  96957 	Xsqlite3DbFree(tls, db, zModuleName)
  96958 	return rc
  96959 }
  96960 
  96961 // This function is invoked by the parser to call the xConnect() method
  96962 // of the virtual table pTab. If an error occurs, an error code is returned
  96963 // and an error left in pParse.
  96964 //
  96965 // This call is a no-op if table pTab is not a virtual table.
  96966 func Xsqlite3VtabCallConnect(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 {
  96967 	bp := tls.Alloc(20)
  96968 	defer tls.Free(20)
  96969 
  96970 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  96971 	var zMod uintptr
  96972 	var pMod uintptr
  96973 	var rc int32
  96974 
  96975 	if Xsqlite3GetVTable(tls, db, pTab) != 0 {
  96976 		return SQLITE_OK
  96977 	}
  96978 
  96979 	zMod = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 4))))
  96980 	pMod = Xsqlite3HashFind(tls, db+404, zMod)
  96981 
  96982 	if !(pMod != 0) {
  96983 		var zModule uintptr = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 4))))
  96984 		Xsqlite3ErrorMsg(tls, pParse, ts+21546, libc.VaList(bp, zModule))
  96985 		rc = SQLITE_ERROR
  96986 	} else {
  96987 		*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
  96988 		rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxConnect, bp+16)
  96989 		if rc != SQLITE_OK {
  96990 			Xsqlite3ErrorMsg(tls, pParse, ts+3663, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 16))))
  96991 			(*Parse)(unsafe.Pointer(pParse)).Frc = rc
  96992 		}
  96993 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 16)))
  96994 	}
  96995 
  96996 	return rc
  96997 }
  96998 
  96999 func growVTrans(tls *libc.TLS, db uintptr) int32 {
  97000 	var ARRAY_INCR int32 = 5
  97001 
  97002 	if (*Sqlite3)(unsafe.Pointer(db)).FnVTrans%ARRAY_INCR == 0 {
  97003 		var aVTrans uintptr
  97004 		var nBytes Sqlite3_int64 = Sqlite3_int64(unsafe.Sizeof(uintptr(0))) * (Sqlite3_int64((*Sqlite3)(unsafe.Pointer(db)).FnVTrans) + Sqlite3_int64(ARRAY_INCR))
  97005 		aVTrans = Xsqlite3DbRealloc(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaVTrans, uint64(nBytes))
  97006 		if !(aVTrans != 0) {
  97007 			return SQLITE_NOMEM
  97008 		}
  97009 		libc.Xmemset(tls, aVTrans+uintptr((*Sqlite3)(unsafe.Pointer(db)).FnVTrans)*4, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32(ARRAY_INCR))
  97010 		(*Sqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans
  97011 	}
  97012 
  97013 	return SQLITE_OK
  97014 }
  97015 
  97016 func addToVTrans(tls *libc.TLS, db uintptr, pVTab uintptr) {
  97017 	*(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(libc.PostIncInt32(&(*Sqlite3)(unsafe.Pointer(db)).FnVTrans, 1))*4)) = pVTab
  97018 	Xsqlite3VtabLock(tls, pVTab)
  97019 }
  97020 
  97021 // This function is invoked by the vdbe to call the xCreate method
  97022 // of the virtual table named zTab in database iDb.
  97023 //
  97024 // If an error occurs, *pzErr is set to point to an English language
  97025 // description of the error and an SQLITE_XXX error code is returned.
  97026 // In this case the caller must call sqlite3DbFree(db, ) on *pzErr.
  97027 func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, pzErr uintptr) int32 {
  97028 	bp := tls.Alloc(8)
  97029 	defer tls.Free(8)
  97030 
  97031 	var rc int32 = SQLITE_OK
  97032 	var pTab uintptr
  97033 	var pMod uintptr
  97034 	var zMod uintptr
  97035 
  97036 	pTab = Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName)
  97037 
  97038 	zMod = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTab + 44 + 4))))
  97039 	pMod = Xsqlite3HashFind(tls, db+404, zMod)
  97040 
  97041 	if pMod == uintptr(0) || (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxCreate == uintptr(0) || (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxDestroy == uintptr(0) {
  97042 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+21546, libc.VaList(bp, zMod))
  97043 		rc = SQLITE_ERROR
  97044 	} else {
  97045 		rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxCreate, pzErr)
  97046 	}
  97047 
  97048 	if rc == SQLITE_OK && Xsqlite3GetVTable(tls, db, pTab) != 0 {
  97049 		rc = growVTrans(tls, db)
  97050 		if rc == SQLITE_OK {
  97051 			addToVTrans(tls, db, Xsqlite3GetVTable(tls, db, pTab))
  97052 		}
  97053 	}
  97054 
  97055 	return rc
  97056 }
  97057 
  97058 // This function is used to set the schema of a virtual table.  It is only
  97059 // valid to call this function from within the xCreate() or xConnect() of a
  97060 // virtual table module.
  97061 func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int32 {
  97062 	bp := tls.Alloc(288)
  97063 	defer tls.Free(288)
  97064 
  97065 	var pCtx uintptr
  97066 	var rc int32 = SQLITE_OK
  97067 	var pTab uintptr
  97068 
  97069 	var initBusy int32
  97070 
  97071 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  97072 	pCtx = (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx
  97073 	if !(pCtx != 0) || (*VtabCtx)(unsafe.Pointer(pCtx)).FbDeclared != 0 {
  97074 		Xsqlite3Error(tls, db, SQLITE_MISUSE)
  97075 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  97076 		return Xsqlite3MisuseError(tls, 151102)
  97077 	}
  97078 	pTab = (*VtabCtx)(unsafe.Pointer(pCtx)).FpTab
  97079 
  97080 	Xsqlite3ParseObjectInit(tls, bp+8, db)
  97081 	(*Parse)(unsafe.Pointer(bp + 8)).FeParseMode = U8(PARSE_MODE_DECLARE_VTAB)
  97082 	(*Parse)(unsafe.Pointer(bp + 8)).FdisableTriggers = U8(1)
  97083 
  97084 	initBusy = int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy)
  97085 	(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(0)
  97086 	(*Parse)(unsafe.Pointer(bp + 8)).FnQueryLoop = U32(1)
  97087 	if SQLITE_OK == Xsqlite3RunParser(tls, bp+8, zCreateTable) &&
  97088 		(*Parse)(unsafe.Pointer(bp+8)).FpNewTable != uintptr(0) &&
  97089 		!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) &&
  97090 		int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+8)).FpNewTable)).FeTabType) == TABTYP_NORM {
  97091 		if !(int32((*Table)(unsafe.Pointer(pTab)).FaCol) != 0) {
  97092 			var pNew uintptr = (*Parse)(unsafe.Pointer(bp + 8)).FpNewTable
  97093 			var pIdx uintptr
  97094 			(*Table)(unsafe.Pointer(pTab)).FaCol = (*Table)(unsafe.Pointer(pNew)).FaCol
  97095 			Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(pNew + 44 + 8)))
  97096 			(*Table)(unsafe.Pointer(pTab)).FnNVCol = libc.AssignPtrInt16(pTab+34, (*Table)(unsafe.Pointer(pNew)).FnCol)
  97097 			*(*U32)(unsafe.Pointer(pTab + 28)) |= (*Table)(unsafe.Pointer(pNew)).FtabFlags & U32(TF_WithoutRowid|TF_NoVisibleRowid)
  97098 			(*Table)(unsafe.Pointer(pNew)).FnCol = int16(0)
  97099 			(*Table)(unsafe.Pointer(pNew)).FaCol = uintptr(0)
  97100 
  97101 			if !((*Table)(unsafe.Pointer(pNew)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) &&
  97102 				(*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(pCtx)).FpVTable)).FpMod)).FpModule)).FxUpdate != uintptr(0) &&
  97103 				int32((*Index)(unsafe.Pointer(Xsqlite3PrimaryKeyIndex(tls, pNew))).FnKeyCol) != 1 {
  97104 				rc = SQLITE_ERROR
  97105 			}
  97106 			pIdx = (*Table)(unsafe.Pointer(pNew)).FpIndex
  97107 			if pIdx != 0 {
  97108 				(*Table)(unsafe.Pointer(pTab)).FpIndex = pIdx
  97109 				(*Table)(unsafe.Pointer(pNew)).FpIndex = uintptr(0)
  97110 				(*Index)(unsafe.Pointer(pIdx)).FpTable = pTab
  97111 			}
  97112 		}
  97113 		(*VtabCtx)(unsafe.Pointer(pCtx)).FbDeclared = 1
  97114 	} else {
  97115 		Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR,
  97116 			func() uintptr {
  97117 				if (*Parse)(unsafe.Pointer(bp+8)).FzErrMsg != 0 {
  97118 					return ts + 3663
  97119 				}
  97120 				return uintptr(0)
  97121 			}(), libc.VaList(bp, (*Parse)(unsafe.Pointer(bp+8)).FzErrMsg))
  97122 		Xsqlite3DbFree(tls, db, (*Parse)(unsafe.Pointer(bp+8)).FzErrMsg)
  97123 		rc = SQLITE_ERROR
  97124 	}
  97125 	(*Parse)(unsafe.Pointer(bp + 8)).FeParseMode = U8(PARSE_MODE_NORMAL)
  97126 
  97127 	if (*Parse)(unsafe.Pointer(bp+8)).FpVdbe != 0 {
  97128 		Xsqlite3VdbeFinalize(tls, (*Parse)(unsafe.Pointer(bp+8)).FpVdbe)
  97129 	}
  97130 	Xsqlite3DeleteTable(tls, db, (*Parse)(unsafe.Pointer(bp+8)).FpNewTable)
  97131 	Xsqlite3ParseObjectReset(tls, bp+8)
  97132 	(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(initBusy)
  97133 
  97134 	rc = Xsqlite3ApiExit(tls, db, rc)
  97135 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  97136 	return rc
  97137 }
  97138 
  97139 // This function is invoked by the vdbe to call the xDestroy method
  97140 // of the virtual table named zTab in database iDb. This occurs
  97141 // when a DROP TABLE is mentioned.
  97142 //
  97143 // This call is a no-op if zTab is not a virtual table.
  97144 func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) int32 {
  97145 	var rc int32 = SQLITE_OK
  97146 	var pTab uintptr
  97147 
  97148 	pTab = Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*16)).FzDbSName)
  97149 	if pTab != uintptr(0) &&
  97150 		int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB &&
  97151 		*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) != uintptr(0) {
  97152 		var p uintptr
  97153 		var xDestroy uintptr
  97154 		for p = *(*uintptr)(unsafe.Pointer(pTab + 44 + 8)); p != 0; p = (*VTable)(unsafe.Pointer(p)).FpNext {
  97155 			if (*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(p)).FpVtab)).FnRef > 0 {
  97156 				return SQLITE_LOCKED
  97157 			}
  97158 		}
  97159 		p = vtabDisconnectAll(tls, db, pTab)
  97160 		xDestroy = (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(p)).FpMod)).FpModule)).FxDestroy
  97161 		if xDestroy == uintptr(0) {
  97162 			xDestroy = (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(p)).FpMod)).FpModule)).FxDisconnect
  97163 		}
  97164 
  97165 		(*Table)(unsafe.Pointer(pTab)).FnTabRef++
  97166 		rc = (*struct {
  97167 			f func(*libc.TLS, uintptr) int32
  97168 		})(unsafe.Pointer(&struct{ uintptr }{xDestroy})).f(tls, (*VTable)(unsafe.Pointer(p)).FpVtab)
  97169 
  97170 		if rc == SQLITE_OK {
  97171 			(*VTable)(unsafe.Pointer(p)).FpVtab = uintptr(0)
  97172 			*(*uintptr)(unsafe.Pointer(pTab + 44 + 8)) = uintptr(0)
  97173 			Xsqlite3VtabUnlock(tls, p)
  97174 		}
  97175 		Xsqlite3DeleteTable(tls, db, pTab)
  97176 	}
  97177 
  97178 	return rc
  97179 }
  97180 
  97181 func callFinaliser(tls *libc.TLS, db uintptr, offset int32) {
  97182 	var i int32
  97183 	if (*Sqlite3)(unsafe.Pointer(db)).FaVTrans != 0 {
  97184 		var aVTrans uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaVTrans
  97185 		(*Sqlite3)(unsafe.Pointer(db)).FaVTrans = uintptr(0)
  97186 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans; i++ {
  97187 			var pVTab uintptr = *(*uintptr)(unsafe.Pointer(aVTrans + uintptr(i)*4))
  97188 			var p uintptr = (*VTable)(unsafe.Pointer(pVTab)).FpVtab
  97189 			if p != 0 {
  97190 				var x uintptr
  97191 				x = *(*uintptr)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(p)).FpModule + uintptr(offset)))
  97192 				if x != 0 {
  97193 					(*struct {
  97194 						f func(*libc.TLS, uintptr) int32
  97195 					})(unsafe.Pointer(&struct{ uintptr }{x})).f(tls, p)
  97196 				}
  97197 			}
  97198 			(*VTable)(unsafe.Pointer(pVTab)).FiSavepoint = 0
  97199 			Xsqlite3VtabUnlock(tls, pVTab)
  97200 		}
  97201 		Xsqlite3DbFree(tls, db, aVTrans)
  97202 		(*Sqlite3)(unsafe.Pointer(db)).FnVTrans = 0
  97203 	}
  97204 }
  97205 
  97206 // Invoke the xSync method of all virtual tables in the sqlite3.aVTrans
  97207 // array. Return the error code for the first error that occurs, or
  97208 // SQLITE_OK if all xSync operations are successful.
  97209 //
  97210 // If an error message is available, leave it in p->zErrMsg.
  97211 func Xsqlite3VtabSync(tls *libc.TLS, db uintptr, p uintptr) int32 {
  97212 	var i int32
  97213 	var rc int32 = SQLITE_OK
  97214 	var aVTrans uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaVTrans
  97215 
  97216 	(*Sqlite3)(unsafe.Pointer(db)).FaVTrans = uintptr(0)
  97217 	for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans; i++ {
  97218 		var x uintptr
  97219 		var pVtab uintptr = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aVTrans + uintptr(i)*4)))).FpVtab
  97220 		if pVtab != 0 && libc.AssignUintptr(&x, (*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule)).FxSync) != uintptr(0) {
  97221 			rc = (*struct {
  97222 				f func(*libc.TLS, uintptr) int32
  97223 			})(unsafe.Pointer(&struct{ uintptr }{x})).f(tls, pVtab)
  97224 			Xsqlite3VtabImportErrmsg(tls, p, pVtab)
  97225 		}
  97226 	}
  97227 	(*Sqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans
  97228 	return rc
  97229 }
  97230 
  97231 // Invoke the xRollback method of all virtual tables in the
  97232 // sqlite3.aVTrans array. Then clear the array itself.
  97233 func Xsqlite3VtabRollback(tls *libc.TLS, db uintptr) int32 {
  97234 	callFinaliser(tls, db, int32(uintptr(0)+68))
  97235 	return SQLITE_OK
  97236 }
  97237 
  97238 // Invoke the xCommit method of all virtual tables in the
  97239 // sqlite3.aVTrans array. Then clear the array itself.
  97240 func Xsqlite3VtabCommit(tls *libc.TLS, db uintptr) int32 {
  97241 	callFinaliser(tls, db, int32(uintptr(0)+64))
  97242 	return SQLITE_OK
  97243 }
  97244 
  97245 // If the virtual table pVtab supports the transaction interface
  97246 // (xBegin/xRollback/xCommit and optionally xSync) and a transaction is
  97247 // not currently open, invoke the xBegin method now.
  97248 //
  97249 // If the xBegin call is successful, place the sqlite3_vtab pointer
  97250 // in the sqlite3.aVTrans array.
  97251 func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 {
  97252 	var rc int32 = SQLITE_OK
  97253 	var pModule uintptr
  97254 
  97255 	if (*Sqlite3)(unsafe.Pointer(db)).FnVTrans > 0 && (*Sqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0) {
  97256 		return SQLITE_LOCKED
  97257 	}
  97258 	if !(pVTab != 0) {
  97259 		return SQLITE_OK
  97260 	}
  97261 	pModule = (*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule
  97262 
  97263 	if (*Sqlite3_module)(unsafe.Pointer(pModule)).FxBegin != 0 {
  97264 		var i int32
  97265 
  97266 		for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans; i++ {
  97267 			if *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*4)) == pVTab {
  97268 				return SQLITE_OK
  97269 			}
  97270 		}
  97271 
  97272 		rc = growVTrans(tls, db)
  97273 		if rc == SQLITE_OK {
  97274 			rc = (*struct {
  97275 				f func(*libc.TLS, uintptr) int32
  97276 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule)).FxBegin})).f(tls, (*VTable)(unsafe.Pointer(pVTab)).FpVtab)
  97277 			if rc == SQLITE_OK {
  97278 				var iSvpt int32 = (*Sqlite3)(unsafe.Pointer(db)).FnStatement + (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint
  97279 				addToVTrans(tls, db, pVTab)
  97280 				if iSvpt != 0 && (*Sqlite3_module)(unsafe.Pointer(pModule)).FxSavepoint != 0 {
  97281 					(*VTable)(unsafe.Pointer(pVTab)).FiSavepoint = iSvpt
  97282 					rc = (*struct {
  97283 						f func(*libc.TLS, uintptr, int32) int32
  97284 					})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pModule)).FxSavepoint})).f(tls, (*VTable)(unsafe.Pointer(pVTab)).FpVtab, iSvpt-1)
  97285 				}
  97286 			}
  97287 		}
  97288 	}
  97289 	return rc
  97290 }
  97291 
  97292 // Invoke either the xSavepoint, xRollbackTo or xRelease method of all
  97293 // virtual tables that currently have an open transaction. Pass iSavepoint
  97294 // as the second argument to the virtual table method invoked.
  97295 //
  97296 // If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is
  97297 // SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is
  97298 // SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
  97299 // an open transaction is invoked.
  97300 //
  97301 // If any virtual table method returns an error code other than SQLITE_OK,
  97302 // processing is abandoned and the error returned to the caller of this
  97303 // function immediately. If all calls to virtual table methods are successful,
  97304 // SQLITE_OK is returned.
  97305 func Xsqlite3VtabSavepoint(tls *libc.TLS, db uintptr, op int32, iSavepoint int32) int32 {
  97306 	var rc int32 = SQLITE_OK
  97307 
  97308 	if (*Sqlite3)(unsafe.Pointer(db)).FaVTrans != 0 {
  97309 		var i int32
  97310 		for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans; i++ {
  97311 			var pVTab uintptr = *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*4))
  97312 			var pMod uintptr = (*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpMod)).FpModule
  97313 			if (*VTable)(unsafe.Pointer(pVTab)).FpVtab != 0 && (*Sqlite3_module)(unsafe.Pointer(pMod)).FiVersion >= 2 {
  97314 				var xMethod uintptr
  97315 				Xsqlite3VtabLock(tls, pVTab)
  97316 				switch op {
  97317 				case SAVEPOINT_BEGIN:
  97318 					xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxSavepoint
  97319 					(*VTable)(unsafe.Pointer(pVTab)).FiSavepoint = iSavepoint + 1
  97320 					break
  97321 					fallthrough
  97322 				case SAVEPOINT_ROLLBACK:
  97323 					xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxRollbackTo
  97324 					break
  97325 					fallthrough
  97326 				default:
  97327 					xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxRelease
  97328 					break
  97329 				}
  97330 				if xMethod != 0 && (*VTable)(unsafe.Pointer(pVTab)).FiSavepoint > iSavepoint {
  97331 					rc = (*struct {
  97332 						f func(*libc.TLS, uintptr, int32) int32
  97333 					})(unsafe.Pointer(&struct{ uintptr }{xMethod})).f(tls, (*VTable)(unsafe.Pointer(pVTab)).FpVtab, iSavepoint)
  97334 				}
  97335 				Xsqlite3VtabUnlock(tls, pVTab)
  97336 			}
  97337 		}
  97338 	}
  97339 	return rc
  97340 }
  97341 
  97342 // The first parameter (pDef) is a function implementation.  The
  97343 // second parameter (pExpr) is the first argument to this function.
  97344 // If pExpr is a column in a virtual table, then let the virtual
  97345 // table implementation have an opportunity to overload the function.
  97346 //
  97347 // This routine is used to allow virtual table implementations to
  97348 // overload MATCH, LIKE, GLOB, and REGEXP operators.
  97349 //
  97350 // Return either the pDef argument (indicating no change) or a
  97351 // new FuncDef structure that is marked as ephemeral using the
  97352 // SQLITE_FUNC_EPHEM flag.
  97353 func Xsqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg int32, pExpr uintptr) uintptr {
  97354 	bp := tls.Alloc(8)
  97355 	defer tls.Free(8)
  97356 
  97357 	var pTab uintptr
  97358 	var pVtab uintptr
  97359 	var pMod uintptr
  97360 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
  97361 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
  97362 	var pNew uintptr
  97363 	var rc int32 = 0
  97364 
  97365 	if pExpr == uintptr(0) {
  97366 		return pDef
  97367 	}
  97368 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN {
  97369 		return pDef
  97370 	}
  97371 
  97372 	pTab = *(*uintptr)(unsafe.Pointer(pExpr + 44))
  97373 	if pTab == uintptr(0) {
  97374 		return pDef
  97375 	}
  97376 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
  97377 		return pDef
  97378 	}
  97379 	pVtab = (*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, db, pTab))).FpVtab
  97380 
  97381 	pMod = (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule
  97382 	if (*Sqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction == uintptr(0) {
  97383 		return pDef
  97384 	}
  97385 
  97386 	rc = (*struct {
  97387 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32
  97388 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction})).f(tls, pVtab, nArg, (*FuncDef)(unsafe.Pointer(pDef)).FzName, bp, bp+4)
  97389 	if rc == 0 {
  97390 		return pDef
  97391 	}
  97392 
  97393 	pNew = Xsqlite3DbMallocZero(tls, db, uint64(uint32(unsafe.Sizeof(FuncDef{}))+
  97394 		uint32(Xsqlite3Strlen30(tls, (*FuncDef)(unsafe.Pointer(pDef)).FzName))+uint32(1)))
  97395 	if pNew == uintptr(0) {
  97396 		return pDef
  97397 	}
  97398 	*(*FuncDef)(unsafe.Pointer(pNew)) = *(*FuncDef)(unsafe.Pointer(pDef))
  97399 	(*FuncDef)(unsafe.Pointer(pNew)).FzName = pNew + 1*40
  97400 	libc.Xmemcpy(tls, pNew+1*40, (*FuncDef)(unsafe.Pointer(pDef)).FzName, uint32(Xsqlite3Strlen30(tls, (*FuncDef)(unsafe.Pointer(pDef)).FzName)+1))
  97401 	(*FuncDef)(unsafe.Pointer(pNew)).FxSFunc = *(*uintptr)(unsafe.Pointer(bp))
  97402 	(*FuncDef)(unsafe.Pointer(pNew)).FpUserData = *(*uintptr)(unsafe.Pointer(bp + 4))
  97403 	*(*U32)(unsafe.Pointer(pNew + 4)) |= U32(SQLITE_FUNC_EPHEM)
  97404 	return pNew
  97405 }
  97406 
  97407 // Make sure virtual table pTab is contained in the pParse->apVirtualLock[]
  97408 // array so that an OP_VBegin will get generated for it.  Add pTab to the
  97409 // array if it is missing.  If pTab is already in the array, this routine
  97410 // is a no-op.
  97411 func Xsqlite3VtabMakeWritable(tls *libc.TLS, pParse uintptr, pTab uintptr) {
  97412 	var pToplevel uintptr = func() uintptr {
  97413 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  97414 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  97415 		}
  97416 		return pParse
  97417 	}()
  97418 	var i int32
  97419 	var n int32
  97420 	var apVtabLock uintptr
  97421 
  97422 	for i = 0; i < (*Parse)(unsafe.Pointer(pToplevel)).FnVtabLock; i++ {
  97423 		if pTab == *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(pToplevel)).FapVtabLock + uintptr(i)*4)) {
  97424 			return
  97425 		}
  97426 	}
  97427 	n = int32(uint32((*Parse)(unsafe.Pointer(pToplevel)).FnVtabLock+1) * uint32(unsafe.Sizeof(uintptr(0))))
  97428 	apVtabLock = Xsqlite3Realloc(tls, (*Parse)(unsafe.Pointer(pToplevel)).FapVtabLock, uint64(n))
  97429 	if apVtabLock != 0 {
  97430 		(*Parse)(unsafe.Pointer(pToplevel)).FapVtabLock = apVtabLock
  97431 		*(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(pToplevel)).FapVtabLock + uintptr(libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pToplevel)).FnVtabLock, 1))*4)) = pTab
  97432 	} else {
  97433 		Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(pToplevel)).Fdb)
  97434 	}
  97435 }
  97436 
  97437 // Check to see if virtual table module pMod can be have an eponymous
  97438 // virtual table instance.  If it can, create one if one does not already
  97439 // exist. Return non-zero if either the eponymous virtual table instance
  97440 // exists when this routine returns or if an attempt to create it failed
  97441 // and an error message was left in pParse.
  97442 //
  97443 // An eponymous virtual table instance is one that is named after its
  97444 // module, and more importantly, does not require a CREATE VIRTUAL TABLE
  97445 // statement in order to come into existance.  Eponymous virtual table
  97446 // instances always exist.  They cannot be DROP-ed.
  97447 //
  97448 // Any virtual table module for which xConnect and xCreate are the same
  97449 // method can have an eponymous virtual table instance.
  97450 func Xsqlite3VtabEponymousTableInit(tls *libc.TLS, pParse uintptr, pMod uintptr) int32 {
  97451 	bp := tls.Alloc(12)
  97452 	defer tls.Free(12)
  97453 
  97454 	var pModule uintptr = (*Module)(unsafe.Pointer(pMod)).FpModule
  97455 	var pTab uintptr
  97456 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
  97457 	var rc int32
  97458 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  97459 	if (*Module)(unsafe.Pointer(pMod)).FpEpoTab != 0 {
  97460 		return 1
  97461 	}
  97462 	if (*Sqlite3_module)(unsafe.Pointer(pModule)).FxCreate != uintptr(0) && (*Sqlite3_module)(unsafe.Pointer(pModule)).FxCreate != (*Sqlite3_module)(unsafe.Pointer(pModule)).FxConnect {
  97463 		return 0
  97464 	}
  97465 	pTab = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))
  97466 	if pTab == uintptr(0) {
  97467 		return 0
  97468 	}
  97469 	(*Table)(unsafe.Pointer(pTab)).FzName = Xsqlite3DbStrDup(tls, db, (*Module)(unsafe.Pointer(pMod)).FzName)
  97470 	if (*Table)(unsafe.Pointer(pTab)).FzName == uintptr(0) {
  97471 		Xsqlite3DbFree(tls, db, pTab)
  97472 		return 0
  97473 	}
  97474 	(*Module)(unsafe.Pointer(pMod)).FpEpoTab = pTab
  97475 	(*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1)
  97476 	(*Table)(unsafe.Pointer(pTab)).FeTabType = U8(TABTYP_VTAB)
  97477 	(*Table)(unsafe.Pointer(pTab)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema
  97478 
  97479 	(*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1)
  97480 	*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_Eponymous)
  97481 	addModuleArgument(tls, pParse, pTab, Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName))
  97482 	addModuleArgument(tls, pParse, pTab, uintptr(0))
  97483 	addModuleArgument(tls, pParse, pTab, Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName))
  97484 	rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer(pModule)).FxConnect, bp+8)
  97485 	if rc != 0 {
  97486 		Xsqlite3ErrorMsg(tls, pParse, ts+3663, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 8))))
  97487 		Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8)))
  97488 		Xsqlite3VtabEponymousTableClear(tls, db, pMod)
  97489 	}
  97490 	return 1
  97491 }
  97492 
  97493 // Erase the eponymous virtual table instance associated with
  97494 // virtual table module pMod, if it exists.
  97495 func Xsqlite3VtabEponymousTableClear(tls *libc.TLS, db uintptr, pMod uintptr) {
  97496 	var pTab uintptr = (*Module)(unsafe.Pointer(pMod)).FpEpoTab
  97497 	if pTab != uintptr(0) {
  97498 		*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_Ephemeral)
  97499 		Xsqlite3DeleteTable(tls, db, pTab)
  97500 		(*Module)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0)
  97501 	}
  97502 }
  97503 
  97504 // Return the ON CONFLICT resolution mode in effect for the virtual
  97505 // table update operation currently in progress.
  97506 //
  97507 // The results of this routine are undefined unless it is called from
  97508 // within an xUpdate method.
  97509 func Xsqlite3_vtab_on_conflict(tls *libc.TLS, db uintptr) int32 {
  97510 	return int32(aMap[int32((*Sqlite3)(unsafe.Pointer(db)).FvtabOnConflict)-1])
  97511 }
  97512 
  97513 var aMap = [5]uint8{
  97514 	uint8(SQLITE_ROLLBACK), uint8(SQLITE_ABORT), uint8(SQLITE_FAIL), uint8(SQLITE_IGNORE), uint8(SQLITE_REPLACE),
  97515 }
  97516 
  97517 // Call from within the xCreate() or xConnect() methods to provide
  97518 // the SQLite core with additional information about the behavior
  97519 // of the virtual table being implemented.
  97520 func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 {
  97521 	var ap Va_list
  97522 	_ = ap
  97523 	var rc int32 = SQLITE_OK
  97524 	var p uintptr
  97525 
  97526 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  97527 	p = (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx
  97528 	if !(p != 0) {
  97529 		rc = Xsqlite3MisuseError(tls, 151593)
  97530 	} else {
  97531 		ap = va
  97532 		switch op {
  97533 		case SQLITE_VTAB_CONSTRAINT_SUPPORT:
  97534 			{
  97535 				(*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FbConstraint = U8(libc.VaInt32(&ap))
  97536 				break
  97537 
  97538 			}
  97539 			fallthrough
  97540 		case SQLITE_VTAB_INNOCUOUS:
  97541 			{
  97542 				(*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = U8(SQLITE_VTABRISK_Low)
  97543 				break
  97544 
  97545 			}
  97546 			fallthrough
  97547 		case SQLITE_VTAB_DIRECTONLY:
  97548 			{
  97549 				(*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = U8(SQLITE_VTABRISK_High)
  97550 				break
  97551 
  97552 			}
  97553 			fallthrough
  97554 		default:
  97555 			{
  97556 				rc = Xsqlite3MisuseError(tls, 151611)
  97557 				break
  97558 
  97559 			}
  97560 		}
  97561 		_ = ap
  97562 	}
  97563 
  97564 	if rc != SQLITE_OK {
  97565 		Xsqlite3Error(tls, db, rc)
  97566 	}
  97567 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
  97568 	return rc
  97569 }
  97570 
  97571 // Forward references
  97572 type WhereClause1 = struct {
  97573 	FpWInfo      uintptr
  97574 	FpOuter      uintptr
  97575 	Fop          U8
  97576 	FhasOr       U8
  97577 	F__ccgo_pad1 [2]byte
  97578 	FnTerm       int32
  97579 	FnSlot       int32
  97580 	FnBase       int32
  97581 	Fa           uintptr
  97582 	F__ccgo_pad2 [4]byte
  97583 	FaStatic     [8]WhereTerm
  97584 }
  97585 
  97586 // Forward references
  97587 type WhereClause = WhereClause1
  97588 type WhereMaskSet1 = struct {
  97589 	FbVarSelect int32
  97590 	Fn          int32
  97591 	Fix         [64]int32
  97592 }
  97593 
  97594 type WhereMaskSet = WhereMaskSet1
  97595 type WhereOrInfo1 = struct {
  97596 	Fwc        WhereClause
  97597 	Findexable Bitmask
  97598 }
  97599 
  97600 type WhereOrInfo = WhereOrInfo1
  97601 type WhereAndInfo1 = struct{ Fwc WhereClause }
  97602 
  97603 type WhereAndInfo = WhereAndInfo1
  97604 type WhereLevel1 = struct {
  97605 	FiLeftJoin   int32
  97606 	FiTabCur     int32
  97607 	FiIdxCur     int32
  97608 	FaddrBrk     int32
  97609 	FaddrNxt     int32
  97610 	FaddrSkip    int32
  97611 	FaddrCont    int32
  97612 	FaddrFirst   int32
  97613 	FaddrBody    int32
  97614 	FregBignull  int32
  97615 	FaddrBignull int32
  97616 	FregFilter   int32
  97617 	FpRJ         uintptr
  97618 	FiFrom       U8
  97619 	Fop          U8
  97620 	Fp3          U8
  97621 	Fp5          U8
  97622 	Fp1          int32
  97623 	Fp2          int32
  97624 	Fu           struct {
  97625 		Fin struct {
  97626 			FnIn     int32
  97627 			FaInLoop uintptr
  97628 		}
  97629 	}
  97630 	FpWLoop      uintptr
  97631 	F__ccgo_pad1 [4]byte
  97632 	FnotReady    Bitmask
  97633 }
  97634 
  97635 type WhereLevel = WhereLevel1
  97636 type WhereLoop1 = struct {
  97637 	Fprereq   Bitmask
  97638 	FmaskSelf Bitmask
  97639 	FiTab     U8
  97640 	FiSortIdx U8
  97641 	FrSetup   LogEst
  97642 	FrRun     LogEst
  97643 	FnOut     LogEst
  97644 	Fu        struct {
  97645 		Fbtree struct {
  97646 			FnEq          U16
  97647 			FnBtm         U16
  97648 			FnTop         U16
  97649 			FnDistinctCol U16
  97650 			FpIndex       uintptr
  97651 		}
  97652 		F__ccgo_pad1 [8]byte
  97653 	}
  97654 	FwsFlags     U32
  97655 	FnLTerm      U16
  97656 	FnSkip       U16
  97657 	FnLSlot      U16
  97658 	F__ccgo_pad1 [2]byte
  97659 	FaLTerm      uintptr
  97660 	FpNextLoop   uintptr
  97661 	FaLTermSpace [3]uintptr
  97662 	F__ccgo_pad2 [4]byte
  97663 }
  97664 
  97665 type WhereLoop = WhereLoop1
  97666 type WherePath1 = struct {
  97667 	FmaskLoop    Bitmask
  97668 	FrevLoop     Bitmask
  97669 	FnRow        LogEst
  97670 	FrCost       LogEst
  97671 	FrUnsorted   LogEst
  97672 	FisOrdered   I8
  97673 	F__ccgo_pad1 [1]byte
  97674 	FaLoop       uintptr
  97675 	F__ccgo_pad2 [4]byte
  97676 }
  97677 
  97678 type WherePath = WherePath1
  97679 type WhereTerm1 = struct {
  97680 	FpExpr      uintptr
  97681 	FpWC        uintptr
  97682 	FtruthProb  LogEst
  97683 	FwtFlags    U16
  97684 	FeOperator  U16
  97685 	FnChild     U8
  97686 	FeMatchOp   U8
  97687 	FiParent    int32
  97688 	FleftCursor int32
  97689 	Fu          struct {
  97690 		Fx struct {
  97691 			FleftColumn int32
  97692 			FiField     int32
  97693 		}
  97694 	}
  97695 	FprereqRight Bitmask
  97696 	FprereqAll   Bitmask
  97697 }
  97698 
  97699 type WhereTerm = WhereTerm1
  97700 type WhereLoopBuilder1 = struct {
  97701 	FpWInfo      uintptr
  97702 	FpWC         uintptr
  97703 	FpNew        uintptr
  97704 	FpOrSet      uintptr
  97705 	FpRec        uintptr
  97706 	FnRecValid   int32
  97707 	FbldFlags1   uint8
  97708 	FbldFlags2   uint8
  97709 	F__ccgo_pad1 [2]byte
  97710 	FiPlanLimit  uint32
  97711 }
  97712 
  97713 type WhereLoopBuilder = WhereLoopBuilder1
  97714 type WhereScan1 = struct {
  97715 	FpOrigWC     uintptr
  97716 	FpWC         uintptr
  97717 	FzCollName   uintptr
  97718 	FpIdxExpr    uintptr
  97719 	Fk           int32
  97720 	FopMask      U32
  97721 	Fidxaff      uint8
  97722 	FiEquiv      uint8
  97723 	FnEquiv      uint8
  97724 	F__ccgo_pad1 [1]byte
  97725 	FaiCur       [11]int32
  97726 	FaiColumn    [11]I16
  97727 	F__ccgo_pad2 [2]byte
  97728 }
  97729 
  97730 type WhereScan = WhereScan1
  97731 type WhereOrCost1 = struct {
  97732 	Fprereq      Bitmask
  97733 	FrRun        LogEst
  97734 	FnOut        LogEst
  97735 	F__ccgo_pad1 [4]byte
  97736 }
  97737 
  97738 type WhereOrCost = WhereOrCost1
  97739 type WhereOrSet1 = struct {
  97740 	Fn           U16
  97741 	F__ccgo_pad1 [6]byte
  97742 	Fa           [3]WhereOrCost
  97743 }
  97744 
  97745 type WhereOrSet = WhereOrSet1
  97746 type WhereMemBlock1 = struct {
  97747 	FpNext       uintptr
  97748 	F__ccgo_pad1 [4]byte
  97749 	Fsz          U64
  97750 }
  97751 
  97752 type WhereMemBlock = WhereMemBlock1
  97753 type WhereRightJoin1 = struct {
  97754 	FiMatch     int32
  97755 	FregBloom   int32
  97756 	FregReturn  int32
  97757 	FaddrSubrtn int32
  97758 	FendSubrtn  int32
  97759 }
  97760 
  97761 type WhereRightJoin = WhereRightJoin1
  97762 
  97763 // This object contains information needed to implement a single nested
  97764 // loop in WHERE clause.
  97765 //
  97766 // Contrast this object with WhereLoop.  This object describes the
  97767 // implementation of the loop.  WhereLoop describes the algorithm.
  97768 // This object contains a pointer to the WhereLoop algorithm as one of
  97769 // its elements.
  97770 //
  97771 // The WhereInfo object contains a single instance of this object for
  97772 // each term in the FROM clause (which is to say, for each of the
  97773 // nested loops as implemented).  The order of WhereLevel objects determines
  97774 // the loop nested order, with WhereInfo.a[0] being the outer loop and
  97775 // WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.
  97776 type InLoop = struct {
  97777 	FiCur        int32
  97778 	FaddrInTop   int32
  97779 	FiBase       int32
  97780 	FnPrefix     int32
  97781 	FeEndLoopOp  U8
  97782 	F__ccgo_pad1 [3]byte
  97783 }
  97784 
  97785 func explainIndexColumnName(tls *libc.TLS, pIdx uintptr, i int32) uintptr {
  97786 	i = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)))
  97787 	if i == -2 {
  97788 		return ts + 21565
  97789 	}
  97790 	if i == -1 {
  97791 		return ts + 16267
  97792 	}
  97793 	return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(i)*16)).FzCnName
  97794 }
  97795 
  97796 func explainAppendTerm(tls *libc.TLS, pStr uintptr, pIdx uintptr, nTerm int32, iTerm int32, bAnd int32, zOp uintptr) {
  97797 	var i int32
  97798 
  97799 	if bAnd != 0 {
  97800 		Xsqlite3_str_append(tls, pStr, ts+21572, 5)
  97801 	}
  97802 
  97803 	if nTerm > 1 {
  97804 		Xsqlite3_str_append(tls, pStr, ts+21578, 1)
  97805 	}
  97806 	for i = 0; i < nTerm; i++ {
  97807 		if i != 0 {
  97808 			Xsqlite3_str_append(tls, pStr, ts+12767, 1)
  97809 		}
  97810 		Xsqlite3_str_appendall(tls, pStr, explainIndexColumnName(tls, pIdx, iTerm+i))
  97811 	}
  97812 	if nTerm > 1 {
  97813 		Xsqlite3_str_append(tls, pStr, ts+4957, 1)
  97814 	}
  97815 
  97816 	Xsqlite3_str_append(tls, pStr, zOp, 1)
  97817 
  97818 	if nTerm > 1 {
  97819 		Xsqlite3_str_append(tls, pStr, ts+21578, 1)
  97820 	}
  97821 	for i = 0; i < nTerm; i++ {
  97822 		if i != 0 {
  97823 			Xsqlite3_str_append(tls, pStr, ts+12767, 1)
  97824 		}
  97825 		Xsqlite3_str_append(tls, pStr, ts+5008, 1)
  97826 	}
  97827 	if nTerm > 1 {
  97828 		Xsqlite3_str_append(tls, pStr, ts+4957, 1)
  97829 	}
  97830 }
  97831 
  97832 func explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) {
  97833 	bp := tls.Alloc(8)
  97834 	defer tls.Free(8)
  97835 
  97836 	var pIndex uintptr = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
  97837 	var nEq U16 = *(*U16)(unsafe.Pointer(pLoop + 24))
  97838 	var nSkip U16 = (*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip
  97839 	var i int32
  97840 	var j int32
  97841 
  97842 	if int32(nEq) == 0 && (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT) == U32(0) {
  97843 		return
  97844 	}
  97845 	Xsqlite3_str_append(tls, pStr, ts+21580, 2)
  97846 	for i = 0; i < int32(nEq); i++ {
  97847 		var z uintptr = explainIndexColumnName(tls, pIndex, i)
  97848 		if i != 0 {
  97849 			Xsqlite3_str_append(tls, pStr, ts+21572, 5)
  97850 		}
  97851 		Xsqlite3_str_appendf(tls, pStr, func() uintptr {
  97852 			if i >= int32(nSkip) {
  97853 				return ts + 21583
  97854 			}
  97855 			return ts + 21588
  97856 		}(), libc.VaList(bp, z))
  97857 	}
  97858 
  97859 	j = i
  97860 	if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BTM_LIMIT) != 0 {
  97861 		explainAppendTerm(tls, pStr, pIndex, int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 2))), j, i, ts+21596)
  97862 		i = 1
  97863 	}
  97864 	if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_TOP_LIMIT) != 0 {
  97865 		explainAppendTerm(tls, pStr, pIndex, int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 4))), j, i, ts+21598)
  97866 	}
  97867 	Xsqlite3_str_append(tls, pStr, ts+4957, 1)
  97868 }
  97869 
  97870 // This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
  97871 // command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was
  97872 // defined at compile-time. If it is not a no-op, a single OP_Explain opcode
  97873 // is added to the output to describe the table scan strategy in pLevel.
  97874 //
  97875 // If an OP_Explain opcode is added to the VM, its address is returned.
  97876 // Otherwise, if no OP_Explain is coded, zero is returned.
  97877 func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr, pLevel uintptr, wctrlFlags U16) int32 {
  97878 	bp := tls.Alloc(188)
  97879 	defer tls.Free(188)
  97880 
  97881 	var ret int32 = 0
  97882 	if int32((*Parse)(unsafe.Pointer(func() uintptr {
  97883 		if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  97884 			return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  97885 		}
  97886 		return pParse
  97887 	}())).Fexplain) == 2 {
  97888 		var pItem uintptr = pTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
  97889 		var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  97890 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  97891 		var isSearch int32
  97892 		var pLoop uintptr
  97893 		var flags U32
  97894 		var zMsg uintptr
  97895 
  97896 		pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
  97897 		flags = (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags
  97898 		if flags&U32(WHERE_MULTI_OR) != 0 || int32(wctrlFlags)&WHERE_OR_SUBCLAUSE != 0 {
  97899 			return 0
  97900 		}
  97901 
  97902 		isSearch = libc.Bool32(flags&U32(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT) != U32(0) ||
  97903 			flags&U32(WHERE_VIRTUALTABLE) == U32(0) && int32(*(*U16)(unsafe.Pointer(pLoop + 24))) > 0 ||
  97904 			int32(wctrlFlags)&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX) != 0)
  97905 
  97906 		Xsqlite3StrAccumInit(tls, bp+64, db, bp+88, int32(unsafe.Sizeof([100]uint8{})), SQLITE_MAX_LENGTH)
  97907 		(*StrAccum)(unsafe.Pointer(bp + 64)).FprintfFlags = U8(SQLITE_PRINTF_INTERNAL)
  97908 		Xsqlite3_str_appendf(tls, bp+64, ts+21600, libc.VaList(bp, func() uintptr {
  97909 			if isSearch != 0 {
  97910 				return ts + 21606
  97911 			}
  97912 			return ts + 21613
  97913 		}(), pItem))
  97914 		if flags&U32(WHERE_IPK|WHERE_VIRTUALTABLE) == U32(0) {
  97915 			var zFmt uintptr = uintptr(0)
  97916 			var pIdx uintptr
  97917 
  97918 			pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
  97919 
  97920 			if !((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) && int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
  97921 				if isSearch != 0 {
  97922 					zFmt = ts + 10976
  97923 				}
  97924 			} else if flags&U32(WHERE_PARTIALIDX) != 0 {
  97925 				zFmt = ts + 21618
  97926 			} else if flags&U32(WHERE_AUTO_INDEX) != 0 {
  97927 				zFmt = ts + 21651
  97928 			} else if flags&U32(WHERE_IDX_ONLY) != 0 {
  97929 				zFmt = ts + 21676
  97930 			} else {
  97931 				zFmt = ts + 21694
  97932 			}
  97933 			if zFmt != 0 {
  97934 				Xsqlite3_str_append(tls, bp+64, ts+21703, 7)
  97935 				Xsqlite3_str_appendf(tls, bp+64, zFmt, libc.VaList(bp+16, (*Index)(unsafe.Pointer(pIdx)).FzName))
  97936 				explainIndexRange(tls, bp+64, pLoop)
  97937 			}
  97938 		} else if flags&U32(WHERE_IPK) != U32(0) && flags&U32(WHERE_CONSTRAINT) != U32(0) {
  97939 			var cRangeOp uint8
  97940 			var zRowid uintptr = ts + 16267
  97941 			Xsqlite3_str_appendf(tls, bp+64, ts+21711, libc.VaList(bp+24, zRowid))
  97942 			if flags&U32(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) != 0 {
  97943 				cRangeOp = uint8('=')
  97944 			} else if flags&U32(WHERE_BOTH_LIMIT) == U32(WHERE_BOTH_LIMIT) {
  97945 				Xsqlite3_str_appendf(tls, bp+64, ts+21742, libc.VaList(bp+32, zRowid))
  97946 				cRangeOp = uint8('<')
  97947 			} else if flags&U32(WHERE_BTM_LIMIT) != 0 {
  97948 				cRangeOp = uint8('>')
  97949 			} else {
  97950 				cRangeOp = uint8('<')
  97951 			}
  97952 			Xsqlite3_str_appendf(tls, bp+64, ts+21752, libc.VaList(bp+40, int32(cRangeOp)))
  97953 		} else if flags&U32(WHERE_VIRTUALTABLE) != U32(0) {
  97954 			Xsqlite3_str_appendf(tls, bp+64, ts+21757,
  97955 				libc.VaList(bp+48, *(*int32)(unsafe.Pointer(pLoop + 24)), *(*uintptr)(unsafe.Pointer(pLoop + 24 + 12))))
  97956 		}
  97957 		if int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_LEFT != 0 {
  97958 			Xsqlite3_str_appendf(tls, bp+64, ts+21784, 0)
  97959 		}
  97960 		zMsg = Xsqlite3StrAccumFinish(tls, bp+64)
  97961 
  97962 		ret = Xsqlite3VdbeAddOp4(tls, v, OP_Explain, Xsqlite3VdbeCurrentAddr(tls, v),
  97963 			(*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -6)
  97964 	}
  97965 	return ret
  97966 }
  97967 
  97968 // Add a single OP_Explain opcode that describes a Bloom filter.
  97969 //
  97970 // Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or
  97971 // SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not
  97972 // required and this routine is a no-op.
  97973 //
  97974 // If an OP_Explain opcode is added to the VM, its address is returned.
  97975 // Otherwise, if no OP_Explain is coded, zero is returned.
  97976 func Xsqlite3WhereExplainBloomFilter(tls *libc.TLS, pParse uintptr, pWInfo uintptr, pLevel uintptr) int32 {
  97977 	bp := tls.Alloc(148)
  97978 	defer tls.Free(148)
  97979 
  97980 	var ret int32 = 0
  97981 	var pItem uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
  97982 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  97983 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  97984 	var zMsg uintptr
  97985 	var i int32
  97986 	var pLoop uintptr
  97987 
  97988 	Xsqlite3StrAccumInit(tls, bp+24, db, bp+48, int32(unsafe.Sizeof([100]uint8{})), SQLITE_MAX_LENGTH)
  97989 	(*StrAccum)(unsafe.Pointer(bp + 24)).FprintfFlags = U8(SQLITE_PRINTF_INTERNAL)
  97990 	Xsqlite3_str_appendf(tls, bp+24, ts+21795, libc.VaList(bp, pItem))
  97991 	pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
  97992 	if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK) != 0 {
  97993 		var pTab uintptr = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
  97994 		if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) >= 0 {
  97995 			Xsqlite3_str_appendf(tls, bp+24, ts+21583, libc.VaList(bp+8, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*16)).FzCnName))
  97996 		} else {
  97997 			Xsqlite3_str_appendf(tls, bp+24, ts+21816, 0)
  97998 		}
  97999 	} else {
  98000 		for i = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip); i < int32(*(*U16)(unsafe.Pointer(pLoop + 24))); i++ {
  98001 			var z uintptr = explainIndexColumnName(tls, *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8)), i)
  98002 			if i > int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip) {
  98003 				Xsqlite3_str_append(tls, bp+24, ts+21572, 5)
  98004 			}
  98005 			Xsqlite3_str_appendf(tls, bp+24, ts+21583, libc.VaList(bp+16, z))
  98006 		}
  98007 	}
  98008 	Xsqlite3_str_append(tls, bp+24, ts+4957, 1)
  98009 	zMsg = Xsqlite3StrAccumFinish(tls, bp+24)
  98010 	ret = Xsqlite3VdbeAddOp4(tls, v, OP_Explain, Xsqlite3VdbeCurrentAddr(tls, v),
  98011 		(*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -6)
  98012 
  98013 	return ret
  98014 }
  98015 
  98016 func disableTerm(tls *libc.TLS, pLevel uintptr, pTerm uintptr) {
  98017 	var nLoop int32 = 0
  98018 
  98019 	for int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_CODED == 0 &&
  98020 		((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0 || (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_OuterON) != U32(0)) &&
  98021 		(*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady&(*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll == uint64(0) {
  98022 		if nLoop != 0 && int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_LIKE != 0 {
  98023 			*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_LIKECOND)
  98024 		} else {
  98025 			*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_CODED)
  98026 		}
  98027 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FiParent < 0 {
  98028 			break
  98029 		}
  98030 		pTerm = (*WhereClause)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpWC)).Fa + uintptr((*WhereTerm)(unsafe.Pointer(pTerm)).FiParent)*48
  98031 
  98032 		(*WhereTerm)(unsafe.Pointer(pTerm)).FnChild--
  98033 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FnChild) != 0 {
  98034 			break
  98035 		}
  98036 		nLoop++
  98037 	}
  98038 }
  98039 
  98040 func codeApplyAffinity(tls *libc.TLS, pParse uintptr, base int32, n int32, zAff uintptr) {
  98041 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  98042 	if zAff == uintptr(0) {
  98043 		return
  98044 	}
  98045 
  98046 	for n > 0 && int32(*(*uint8)(unsafe.Pointer(zAff))) <= SQLITE_AFF_BLOB {
  98047 		n--
  98048 		base++
  98049 		zAff++
  98050 	}
  98051 	for n > 1 && int32(*(*uint8)(unsafe.Pointer(zAff + uintptr(n-1)))) <= SQLITE_AFF_BLOB {
  98052 		n--
  98053 	}
  98054 
  98055 	if n > 0 {
  98056 		Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, base, n, 0, zAff, n)
  98057 	}
  98058 }
  98059 
  98060 func updateRangeAffinityStr(tls *libc.TLS, pRight uintptr, n int32, zAff uintptr) {
  98061 	var i int32
  98062 	for i = 0; i < n; i++ {
  98063 		var p uintptr = Xsqlite3VectorFieldSubexpr(tls, pRight, i)
  98064 		if int32(Xsqlite3CompareAffinity(tls, p, *(*uint8)(unsafe.Pointer(zAff + uintptr(i))))) == SQLITE_AFF_BLOB ||
  98065 			Xsqlite3ExprNeedsNoAffinityChange(tls, p, *(*uint8)(unsafe.Pointer(zAff + uintptr(i)))) != 0 {
  98066 			*(*uint8)(unsafe.Pointer(zAff + uintptr(i))) = uint8(SQLITE_AFF_BLOB)
  98067 		}
  98068 	}
  98069 }
  98070 
  98071 func removeUnindexableInClauseTerms(tls *libc.TLS, pParse uintptr, iEq int32, pLoop uintptr, pX uintptr) uintptr {
  98072 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  98073 	var pSelect uintptr
  98074 	var pNew uintptr
  98075 	pNew = Xsqlite3ExprDup(tls, db, pX, 0)
  98076 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 {
  98077 		for pSelect = *(*uintptr)(unsafe.Pointer(pNew + 20)); pSelect != 0; pSelect = (*Select)(unsafe.Pointer(pSelect)).FpPrior {
  98078 			var pOrigRhs uintptr
  98079 			var pOrigLhs uintptr = uintptr(0)
  98080 			var pRhs uintptr = uintptr(0)
  98081 			var pLhs uintptr = uintptr(0)
  98082 			var i int32
  98083 
  98084 			pOrigRhs = (*Select)(unsafe.Pointer(pSelect)).FpEList
  98085 
  98086 			if pSelect == *(*uintptr)(unsafe.Pointer(pNew + 20)) {
  98087 				pOrigLhs = *(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pNew)).FpLeft + 20))
  98088 			}
  98089 			for i = iEq; i < int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm); i++ {
  98090 				if (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)))).FpExpr == pX {
  98091 					var iField int32
  98092 
  98093 					iField = *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)) + 24 + 4)) - 1
  98094 					if (*ExprList_item)(unsafe.Pointer(pOrigRhs+8+uintptr(iField)*20)).FpExpr == uintptr(0) {
  98095 						continue
  98096 					}
  98097 					pRhs = Xsqlite3ExprListAppend(tls, pParse, pRhs, (*ExprList_item)(unsafe.Pointer(pOrigRhs+8+uintptr(iField)*20)).FpExpr)
  98098 					(*ExprList_item)(unsafe.Pointer(pOrigRhs + 8 + uintptr(iField)*20)).FpExpr = uintptr(0)
  98099 					if pOrigLhs != 0 {
  98100 						pLhs = Xsqlite3ExprListAppend(tls, pParse, pLhs, (*ExprList_item)(unsafe.Pointer(pOrigLhs+8+uintptr(iField)*20)).FpExpr)
  98101 						(*ExprList_item)(unsafe.Pointer(pOrigLhs + 8 + uintptr(iField)*20)).FpExpr = uintptr(0)
  98102 					}
  98103 				}
  98104 			}
  98105 			Xsqlite3ExprListDelete(tls, db, pOrigRhs)
  98106 			if pOrigLhs != 0 {
  98107 				Xsqlite3ExprListDelete(tls, db, pOrigLhs)
  98108 				*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pNew)).FpLeft + 20)) = pLhs
  98109 			}
  98110 			(*Select)(unsafe.Pointer(pSelect)).FpEList = pRhs
  98111 			if pLhs != 0 && (*ExprList)(unsafe.Pointer(pLhs)).FnExpr == 1 {
  98112 				var p uintptr = (*ExprList_item)(unsafe.Pointer(pLhs + 8)).FpExpr
  98113 				(*ExprList_item)(unsafe.Pointer(pLhs + 8)).FpExpr = uintptr(0)
  98114 				Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pNew)).FpLeft)
  98115 				(*Expr)(unsafe.Pointer(pNew)).FpLeft = p
  98116 			}
  98117 			if (*Select)(unsafe.Pointer(pSelect)).FpOrderBy != 0 {
  98118 				var pOrderBy uintptr = (*Select)(unsafe.Pointer(pSelect)).FpOrderBy
  98119 				for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ {
  98120 					*(*U16)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20 + 16)) = U16(0)
  98121 				}
  98122 			}
  98123 
  98124 		}
  98125 	}
  98126 	return pNew
  98127 }
  98128 
  98129 func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintptr, iEq int32, bRev int32, iTarget int32) int32 {
  98130 	bp := tls.Alloc(4)
  98131 	defer tls.Free(4)
  98132 
  98133 	var pX uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
  98134 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  98135 	var iReg int32
  98136 
  98137 	if int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_EQ || int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_IS {
  98138 		iReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, iTarget)
  98139 	} else if int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_ISNULL {
  98140 		iReg = iTarget
  98141 		Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, iReg)
  98142 	} else {
  98143 		var eType int32 = IN_INDEX_NOOP
  98144 
  98145 		var pIn uintptr
  98146 		var pLoop uintptr = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
  98147 		var i int32
  98148 		var nEq int32 = 0
  98149 		var aiMap uintptr = uintptr(0)
  98150 
  98151 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_VIRTUALTABLE) == U32(0) &&
  98152 			*(*uintptr)(unsafe.Pointer(pLoop + 24 + 8)) != uintptr(0) &&
  98153 			*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLoop + 24 + 8)))).FaSortOrder + uintptr(iEq))) != 0 {
  98154 			bRev = libc.BoolInt32(!(bRev != 0))
  98155 		}
  98156 
  98157 		iReg = iTarget
  98158 
  98159 		for i = 0; i < iEq; i++ {
  98160 			if *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)) != 0 && (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)))).FpExpr == pX {
  98161 				disableTerm(tls, pLevel, pTerm)
  98162 				return iTarget
  98163 			}
  98164 		}
  98165 		for i = iEq; i < int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm); i++ {
  98166 			if (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)))).FpExpr == pX {
  98167 				nEq++
  98168 			}
  98169 		}
  98170 
  98171 		*(*int32)(unsafe.Pointer(bp)) = 0
  98172 		if !((*Expr)(unsafe.Pointer(pX)).Fflags&U32(EP_xIsSelect) != U32(0)) || (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 20)))).FpEList)).FnExpr == 1 {
  98173 			eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(IN_INDEX_LOOP), uintptr(0), uintptr(0), bp)
  98174 		} else {
  98175 			var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
  98176 			if (*Expr)(unsafe.Pointer(pExpr)).FiTable == 0 || !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Subrtn) != U32(0)) {
  98177 				var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
  98178 				pX = removeUnindexableInClauseTerms(tls, pParse, iEq, pLoop, pX)
  98179 				if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  98180 					aiMap = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(unsafe.Sizeof(int32(0)))*uint32(nEq)))
  98181 					eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(IN_INDEX_LOOP), uintptr(0), aiMap, bp)
  98182 					(*Expr)(unsafe.Pointer(pExpr)).FiTable = *(*int32)(unsafe.Pointer(bp))
  98183 				}
  98184 				Xsqlite3ExprDelete(tls, db, pX)
  98185 			} else {
  98186 				var n int32 = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pX)).FpLeft)
  98187 				aiMap = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(unsafe.Sizeof(int32(0)))*func() uint32 {
  98188 					if nEq > n {
  98189 						return uint32(nEq)
  98190 					}
  98191 					return uint32(n)
  98192 				}()))
  98193 				eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(IN_INDEX_LOOP), uintptr(0), aiMap, bp)
  98194 			}
  98195 			pX = pExpr
  98196 		}
  98197 
  98198 		if eType == IN_INDEX_INDEX_DESC {
  98199 			bRev = libc.BoolInt32(!(bRev != 0))
  98200 		}
  98201 		Xsqlite3VdbeAddOp2(tls, v, func() int32 {
  98202 			if bRev != 0 {
  98203 				return OP_Last
  98204 			}
  98205 			return OP_Rewind
  98206 		}(), *(*int32)(unsafe.Pointer(bp)), 0)
  98207 
  98208 		*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_IN_ABLE)
  98209 		if *(*int32)(unsafe.Pointer(pLevel + 64)) == 0 {
  98210 			(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt = Xsqlite3VdbeMakeLabel(tls, pParse)
  98211 		}
  98212 		if iEq > 0 && (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_SEEKSCAN) == U32(0) {
  98213 			*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_IN_EARLYOUT)
  98214 		}
  98215 
  98216 		i = *(*int32)(unsafe.Pointer(pLevel + 64))
  98217 		*(*int32)(unsafe.Pointer(pLevel + 64)) += nEq
  98218 		*(*uintptr)(unsafe.Pointer(pLevel + 64 + 4)) = Xsqlite3WhereRealloc(tls, (*WhereClause)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpWC)).FpWInfo,
  98219 			*(*uintptr)(unsafe.Pointer(pLevel + 64 + 4)),
  98220 			uint64(uint32(unsafe.Sizeof(InLoop{}))*uint32(*(*int32)(unsafe.Pointer(pLevel + 64)))))
  98221 		pIn = *(*uintptr)(unsafe.Pointer(pLevel + 64 + 4))
  98222 		if pIn != 0 {
  98223 			var iMap int32 = 0
  98224 			pIn += 20 * uintptr(i)
  98225 			for i = iEq; i < int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm); i++ {
  98226 				if (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)))).FpExpr == pX {
  98227 					var iOut int32 = iReg + i - iEq
  98228 					if eType == IN_INDEX_ROWID {
  98229 						*(*int32)(unsafe.Pointer(pIn + 4)) = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, *(*int32)(unsafe.Pointer(bp)), iOut)
  98230 					} else {
  98231 						var iCol int32
  98232 						if aiMap != 0 {
  98233 							iCol = *(*int32)(unsafe.Pointer(aiMap + uintptr(libc.PostIncInt32(&iMap, 1))*4))
  98234 						} else {
  98235 							iCol = 0
  98236 						}
  98237 						*(*int32)(unsafe.Pointer(pIn + 4)) = Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp)), iCol, iOut)
  98238 					}
  98239 					Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, iOut)
  98240 					if i == iEq {
  98241 						*(*int32)(unsafe.Pointer(pIn)) = *(*int32)(unsafe.Pointer(bp))
  98242 						*(*U8)(unsafe.Pointer(pIn + 16)) = func() uint8 {
  98243 							if bRev != 0 {
  98244 								return uint8(OP_Prev)
  98245 							}
  98246 							return uint8(OP_Next)
  98247 						}()
  98248 						if iEq > 0 {
  98249 							*(*int32)(unsafe.Pointer(pIn + 8)) = iReg - i
  98250 							*(*int32)(unsafe.Pointer(pIn + 12)) = i
  98251 						} else {
  98252 							*(*int32)(unsafe.Pointer(pIn + 12)) = 0
  98253 						}
  98254 					} else {
  98255 						*(*U8)(unsafe.Pointer(pIn + 16)) = U8(OP_Noop)
  98256 					}
  98257 					pIn += 20
  98258 				}
  98259 			}
  98260 
  98261 			if iEq > 0 &&
  98262 				(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_SEEKSCAN|WHERE_VIRTUALTABLE) == U32(0) {
  98263 				Xsqlite3VdbeAddOp3(tls, v, OP_SeekHit, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, iEq)
  98264 			}
  98265 		} else {
  98266 			*(*int32)(unsafe.Pointer(pLevel + 64)) = 0
  98267 		}
  98268 		Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, aiMap)
  98269 	}
  98270 
  98271 	if (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags&U32(WHERE_TRANSCONS) == U32(0) ||
  98272 		int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_EQUIV == 0 {
  98273 		disableTerm(tls, pLevel, pTerm)
  98274 	}
  98275 
  98276 	return iReg
  98277 }
  98278 
  98279 func codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev int32, nExtraReg int32, pzAff uintptr) int32 {
  98280 	var nEq U16
  98281 	var nSkip U16
  98282 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  98283 	var pIdx uintptr
  98284 	var pTerm uintptr
  98285 	var pLoop uintptr
  98286 	var j int32
  98287 	var regBase int32
  98288 	var nReg int32
  98289 	var zAff uintptr
  98290 
  98291 	pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
  98292 
  98293 	nEq = *(*U16)(unsafe.Pointer(pLoop + 24))
  98294 	nSkip = (*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip
  98295 	pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
  98296 
  98297 	regBase = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
  98298 	nReg = int32(*(*U16)(unsafe.Pointer(pLoop + 24))) + nExtraReg
  98299 	*(*int32)(unsafe.Pointer(pParse + 44)) += nReg
  98300 
  98301 	zAff = Xsqlite3DbStrDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx))
  98302 
  98303 	if nSkip != 0 {
  98304 		var iIdxCur int32 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur
  98305 		Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, regBase, regBase+int32(nSkip)-1)
  98306 		Xsqlite3VdbeAddOp1(tls, v, func() int32 {
  98307 			if bRev != 0 {
  98308 				return OP_Last
  98309 			}
  98310 			return OP_Rewind
  98311 		}(), iIdxCur)
  98312 
  98313 		j = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
  98314 
  98315 		(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip = Xsqlite3VdbeAddOp4Int(tls, v, func() int32 {
  98316 			if bRev != 0 {
  98317 				return OP_SeekLT
  98318 			}
  98319 			return OP_SeekGT
  98320 		}(),
  98321 			iIdxCur, 0, regBase, int32(nSkip))
  98322 
  98323 		Xsqlite3VdbeJumpHere(tls, v, j)
  98324 		for j = 0; j < int32(nSkip); j++ {
  98325 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, j, regBase+j)
  98326 
  98327 		}
  98328 	}
  98329 
  98330 	for j = int32(nSkip); j < int32(nEq); j++ {
  98331 		var r1 int32
  98332 		pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4))
  98333 
  98334 		r1 = codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, regBase+j)
  98335 		if r1 != regBase+j {
  98336 			if nReg == 1 {
  98337 				Xsqlite3ReleaseTempReg(tls, pParse, regBase)
  98338 				regBase = r1
  98339 			} else {
  98340 				Xsqlite3VdbeAddOp2(tls, v, OP_Copy, r1, regBase+j)
  98341 			}
  98342 		}
  98343 	}
  98344 	for j = int32(nSkip); j < int32(nEq); j++ {
  98345 		pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4))
  98346 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_IN != 0 {
  98347 			if (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_xIsSelect) != 0 {
  98348 				if zAff != 0 {
  98349 					*(*uint8)(unsafe.Pointer(zAff + uintptr(j))) = uint8(SQLITE_AFF_BLOB)
  98350 				}
  98351 			}
  98352 		} else if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_ISNULL == 0 {
  98353 			var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight
  98354 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_IS == 0 && Xsqlite3ExprCanBeNull(tls, pRight) != 0 {
  98355 				Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regBase+j, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk)
  98356 
  98357 			}
  98358 			if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 {
  98359 				if int32(Xsqlite3CompareAffinity(tls, pRight, *(*uint8)(unsafe.Pointer(zAff + uintptr(j))))) == SQLITE_AFF_BLOB {
  98360 					*(*uint8)(unsafe.Pointer(zAff + uintptr(j))) = uint8(SQLITE_AFF_BLOB)
  98361 				}
  98362 				if Xsqlite3ExprNeedsNoAffinityChange(tls, pRight, *(*uint8)(unsafe.Pointer(zAff + uintptr(j)))) != 0 {
  98363 					*(*uint8)(unsafe.Pointer(zAff + uintptr(j))) = uint8(SQLITE_AFF_BLOB)
  98364 				}
  98365 			}
  98366 		}
  98367 	}
  98368 	*(*uintptr)(unsafe.Pointer(pzAff)) = zAff
  98369 	return regBase
  98370 }
  98371 
  98372 func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, iIdxCur int32) {
  98373 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
  98374 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  98375 
  98376 	libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(1), 0, 0x1)
  98377 	Xsqlite3VdbeAddOp3(tls, v, OP_DeferredSeek, iIdxCur, 0, iCur)
  98378 	if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN) != 0 &&
  98379 		(*Parse)(unsafe.Pointer(func() uintptr {
  98380 			if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
  98381 				return (*Parse)(unsafe.Pointer(pParse)).FpToplevel
  98382 			}
  98383 			return pParse
  98384 		}())).FwriteMask == YDbMask(0) {
  98385 		var i int32
  98386 		var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable
  98387 		var ai uintptr = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(unsafe.Sizeof(U32(0)))*uint32(int32((*Table)(unsafe.Pointer(pTab)).FnCol)+1)))
  98388 		if ai != 0 {
  98389 			*(*U32)(unsafe.Pointer(ai)) = U32((*Table)(unsafe.Pointer(pTab)).FnCol)
  98390 			for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)-1; i++ {
  98391 				var x1 int32
  98392 				var x2 int32
  98393 
  98394 				x1 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)))
  98395 				x2 = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(x1)))
  98396 
  98397 				if x1 >= 0 {
  98398 					*(*U32)(unsafe.Pointer(ai + uintptr(x2+1)*4)) = U32(i + 1)
  98399 				}
  98400 			}
  98401 			Xsqlite3VdbeChangeP4(tls, v, -1, ai, -14)
  98402 		}
  98403 	}
  98404 }
  98405 
  98406 func codeExprOrVector(tls *libc.TLS, pParse uintptr, p uintptr, iReg int32, nReg int32) {
  98407 	if p != 0 && Xsqlite3ExprIsVector(tls, p) != 0 {
  98408 		if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_xIsSelect) != U32(0) {
  98409 			var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
  98410 			var iSelect int32
  98411 
  98412 			iSelect = Xsqlite3CodeSubselect(tls, pParse, p)
  98413 			Xsqlite3VdbeAddOp3(tls, v, OP_Copy, iSelect, iReg, nReg-1)
  98414 		} else {
  98415 			var i int32
  98416 			var pList uintptr
  98417 
  98418 			pList = *(*uintptr)(unsafe.Pointer(p + 20))
  98419 
  98420 			for i = 0; i < nReg; i++ {
  98421 				Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr, iReg+i)
  98422 			}
  98423 		}
  98424 	} else {
  98425 		Xsqlite3ExprCode(tls, pParse, p, iReg)
  98426 	}
  98427 }
  98428 
  98429 func whereApplyPartialIndexConstraints(tls *libc.TLS, pTruth uintptr, iTabCur int32, pWC uintptr) {
  98430 	var i int32
  98431 	var pTerm uintptr
  98432 	for int32((*Expr)(unsafe.Pointer(pTruth)).Fop) == TK_AND {
  98433 		whereApplyPartialIndexConstraints(tls, (*Expr)(unsafe.Pointer(pTruth)).FpLeft, iTabCur, pWC)
  98434 		pTruth = (*Expr)(unsafe.Pointer(pTruth)).FpRight
  98435 	}
  98436 	i = 0
  98437 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
  98438 __1:
  98439 	if !(i < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm) {
  98440 		goto __3
  98441 	}
  98442 	{
  98443 		var pExpr uintptr
  98444 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_CODED != 0 {
  98445 			goto __2
  98446 		}
  98447 		pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
  98448 		if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, pTruth, iTabCur) == 0 {
  98449 			*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_CODED)
  98450 		}
  98451 
  98452 	}
  98453 	goto __2
  98454 __2:
  98455 	i++
  98456 	pTerm += 48
  98457 	goto __1
  98458 	goto __3
  98459 __3:
  98460 }
  98461 
  98462 func filterPullDown(tls *libc.TLS, pParse uintptr, pWInfo uintptr, iLevel int32, addrNxt int32, notReady Bitmask) {
  98463 	bp := tls.Alloc(4)
  98464 	defer tls.Free(4)
  98465 
  98466 	for libc.PreIncInt32(&iLevel, 1) < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) {
  98467 		var pLevel uintptr = pWInfo + 760 + uintptr(iLevel)*88
  98468 		var pLoop uintptr = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
  98469 		if (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter == 0 {
  98470 			continue
  98471 		}
  98472 		if (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FnSkip != 0 {
  98473 			continue
  98474 		}
  98475 
  98476 		if (*WhereLoop)(unsafe.Pointer(pLoop)).Fprereq&notReady != 0 {
  98477 			continue
  98478 		}
  98479 
  98480 		(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk = addrNxt
  98481 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK) != 0 {
  98482 			var pTerm uintptr = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm))
  98483 			var regRowid int32
  98484 
  98485 			regRowid = Xsqlite3GetTempReg(tls, pParse)
  98486 			regRowid = codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, 0, regRowid)
  98487 			Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_MustBeInt, regRowid, addrNxt)
  98488 
  98489 			Xsqlite3VdbeAddOp4Int(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Filter, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter,
  98490 				addrNxt, regRowid, 1)
  98491 
  98492 		} else {
  98493 			var nEq U16 = *(*U16)(unsafe.Pointer(pLoop + 24))
  98494 			var r1 int32
  98495 
  98496 			r1 = codeAllEqualityTerms(tls, pParse, pLevel, 0, 0, bp)
  98497 			codeApplyAffinity(tls, pParse, r1, int32(nEq), *(*uintptr)(unsafe.Pointer(bp)))
  98498 			Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(bp)))
  98499 			Xsqlite3VdbeAddOp4Int(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Filter, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter,
  98500 				addrNxt, r1, int32(nEq))
  98501 
  98502 		}
  98503 		(*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter = 0
  98504 		(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk = 0
  98505 	}
  98506 }
  98507 
  98508 // Generate code for the start of the iLevel-th loop in the WHERE clause
  98509 // implementation described by pWInfo.
  98510 func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWInfo uintptr, iLevel int32, pLevel uintptr, notReady Bitmask) Bitmask {
  98511 	bp := tls.Alloc(72)
  98512 	defer tls.Free(72)
  98513 
  98514 	var j int32
  98515 	var k int32
  98516 	var iCur int32
  98517 	var addrNxt int32
  98518 	var bRev int32
  98519 	var pLoop uintptr
  98520 	var pWC uintptr
  98521 	var pTerm uintptr
  98522 	var db uintptr
  98523 	var pTabItem uintptr
  98524 	var addrBrk int32
  98525 	var addrHalt int32
  98526 	var addrCont int32
  98527 	var iRowidReg int32
  98528 	var iReleaseReg int32
  98529 	var pIdx uintptr
  98530 	var iLoop int32
  98531 	var regYield int32
  98532 	var iTab int32
  98533 	var iCache int32
  98534 	var pRight uintptr
  98535 	var iTarget int32
  98536 	var iFld int32
  98537 	var pLeft uintptr
  98538 	var pCompare uintptr
  98539 	var pRight1 uintptr
  98540 	var pOp uintptr
  98541 	var iIn int32
  98542 
  98543 	var iReg int32
  98544 	var addrNotFound int32
  98545 	var nConstraint int32
  98546 	var pX uintptr
  98547 	var r1 int32
  98548 
  98549 	var op int32
  98550 
  98551 	var pX1 uintptr
  98552 
  98553 	var testOp int32
  98554 	var start int32
  98555 	var memEndValue int32
  98556 	var pStart uintptr
  98557 	var pEnd uintptr
  98558 	var t uintptr
  98559 	var t1 U8
  98560 	var t2 U8
  98561 	var pRight2 uintptr
  98562 	var pRight3 uintptr
  98563 	var pPk uintptr
  98564 	var nEq U16
  98565 	var nBtm U16
  98566 	var nTop U16
  98567 	var regBase int32
  98568 	var pRangeStart uintptr
  98569 	var pRangeEnd uintptr
  98570 	var startEq int32
  98571 	var endEq int32
  98572 	var start_constraints int32
  98573 	var nConstraint1 int32
  98574 	var iIdxCur int32
  98575 	var nExtraReg int32
  98576 	var op1 int32
  98577 
  98578 	var zEndAff uintptr
  98579 	var bSeekPastNull U8
  98580 	var bStopAtNull U8
  98581 	var omitTable int32
  98582 	var regBignull int32
  98583 	var addrSeekScan int32
  98584 	var nNotReady int32
  98585 	var origSrc uintptr
  98586 	var pPk1 uintptr
  98587 	var pExpr uintptr
  98588 	var iTerm int32
  98589 	var iCol int32
  98590 	var pPk2 uintptr
  98591 	var nPk int32
  98592 	var iPk int32
  98593 	var r int32
  98594 	var iSet int32
  98595 	var pSubLoop uintptr
  98596 	var addrExplain int32
  98597 	_ = addrExplain
  98598 	var pSubWInfo uintptr
  98599 	var pOrExpr uintptr
  98600 	var pDelete uintptr
  98601 	var jmp1 int32
  98602 	var pOrTerm uintptr
  98603 
  98604 	var pOrWc uintptr
  98605 	var pOrTab uintptr
  98606 	var pCov uintptr
  98607 	var iCovCur int32
  98608 
  98609 	var regReturn int32
  98610 	var regRowset int32
  98611 	var regRowid int32
  98612 	var iLoopBody int32
  98613 	var iRetInit int32
  98614 	var untestedTerms int32
  98615 	var ii int32
  98616 	var pAndExpr uintptr
  98617 	var pTab uintptr
  98618 	var m Bitmask
  98619 	var pE uintptr
  98620 	var skipLikeAddr int32
  98621 	var iNext int32
  98622 	var pE1 uintptr
  98623 
  98624 	var pAlt uintptr
  98625 	var iCol1 int32
  98626 	var iPk1 int32
  98627 	var pPk3 uintptr
  98628 	var pTab1 uintptr
  98629 	var nPk1 int32
  98630 	var r2 int32
  98631 	var jmp11 int32
  98632 	var pRJ uintptr
  98633 
  98634 	var pRJ1 uintptr
  98635 	iRowidReg = 0
  98636 	iReleaseReg = 0
  98637 	pIdx = uintptr(0)
  98638 
  98639 	pWC = pWInfo + 80
  98640 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
  98641 	pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
  98642 	pTabItem = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
  98643 	iCur = (*SrcItem)(unsafe.Pointer(pTabItem)).FiCursor
  98644 	(*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady = notReady & ^Xsqlite3WhereGetMask(tls, pWInfo+496, iCur)
  98645 	bRev = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask >> iLevel & uint64(1))
  98646 
  98647 	addrBrk = libc.AssignPtrInt32(pLevel+12, libc.AssignPtrInt32(pLevel+16, Xsqlite3VdbeMakeLabel(tls, pParse)))
  98648 	addrCont = libc.AssignPtrInt32(pLevel+24, Xsqlite3VdbeMakeLabel(tls, pParse))
  98649 
  98650 	if !(int32((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0 && int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&JT_LEFT != 0) {
  98651 		goto __1
  98652 	}
  98653 	(*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  98654 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin)
  98655 
  98656 __1:
  98657 	;
  98658 	j = iLevel
  98659 __2:
  98660 	if !(j > 0) {
  98661 		goto __4
  98662 	}
  98663 	if !((*WhereLevel)(unsafe.Pointer(pWInfo+760+uintptr(j)*88)).FiLeftJoin != 0) {
  98664 		goto __5
  98665 	}
  98666 	goto __4
  98667 __5:
  98668 	;
  98669 	if !((*WhereLevel)(unsafe.Pointer(pWInfo+760+uintptr(j)*88)).FpRJ != 0) {
  98670 		goto __6
  98671 	}
  98672 	goto __4
  98673 __6:
  98674 	;
  98675 	goto __3
  98676 __3:
  98677 	j--
  98678 	goto __2
  98679 	goto __4
  98680 __4:
  98681 	;
  98682 	addrHalt = (*WhereLevel)(unsafe.Pointer(pWInfo + 760 + uintptr(j)*88)).FaddrBrk
  98683 
  98684 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pTabItem + 36 + 4))&0x20>>5)) != 0) {
  98685 		goto __7
  98686 	}
  98687 	regYield = (*SrcItem)(unsafe.Pointer(pTabItem)).FregReturn
  98688 	Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, (*SrcItem)(unsafe.Pointer(pTabItem)).FaddrFillSub)
  98689 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regYield, addrBrk)
  98690 
  98691 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Goto)
  98692 	goto __8
  98693 __7:
  98694 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_VIRTUALTABLE) != U32(0)) {
  98695 		goto __9
  98696 	}
  98697 	nConstraint = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm)
  98698 
  98699 	iReg = Xsqlite3GetTempRange(tls, pParse, nConstraint+2)
  98700 	addrNotFound = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk
  98701 	j = 0
  98702 __11:
  98703 	if !(j < nConstraint) {
  98704 		goto __13
  98705 	}
  98706 	iTarget = iReg + j + 2
  98707 	pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4))
  98708 	if !(pTerm == uintptr(0)) {
  98709 		goto __14
  98710 	}
  98711 	goto __12
  98712 __14:
  98713 	;
  98714 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_IN != 0) {
  98715 		goto __15
  98716 	}
  98717 	if !(func() uint32 {
  98718 		if j <= 31 {
  98719 			return uint32(1) << j
  98720 		}
  98721 		return uint32(0)
  98722 	}()&*(*U32)(unsafe.Pointer(pLoop + 24 + 16)) != 0) {
  98723 		goto __17
  98724 	}
  98725 	iTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  98726 	iCache = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  98727 	Xsqlite3CodeRhsOfIN(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, iTab)
  98728 	Xsqlite3VdbeAddOp3(tls, v, OP_VInitIn, iTab, iTarget, iCache)
  98729 	goto __18
  98730 __17:
  98731 	codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, iTarget)
  98732 	addrNotFound = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt
  98733 __18:
  98734 	;
  98735 	goto __16
  98736 __15:
  98737 	pRight = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight
  98738 	codeExprOrVector(tls, pParse, pRight, iTarget, 1)
  98739 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) == SQLITE_INDEX_CONSTRAINT_OFFSET &&
  98740 		U32(int32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x2>>1)) != 0) {
  98741 		goto __19
  98742 	}
  98743 
  98744 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Select)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FiOffset)
  98745 
  98746 __19:
  98747 	;
  98748 __16:
  98749 	;
  98750 	goto __12
  98751 __12:
  98752 	j++
  98753 	goto __11
  98754 	goto __13
  98755 __13:
  98756 	;
  98757 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(pLoop + 24)), iReg)
  98758 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nConstraint, iReg+1)
  98759 	Xsqlite3VdbeAddOp4(tls, v, OP_VFilter, iCur, addrNotFound, iReg,
  98760 		*(*uintptr)(unsafe.Pointer(pLoop + 24 + 12)),
  98761 		func() int32 {
  98762 			if U32(int32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x1>>0)) != 0 {
  98763 				return -6
  98764 			}
  98765 			return -1
  98766 		}())
  98767 
  98768 	libc.SetBitFieldPtr8Uint32(pLoop+24+4, U32(0), 0, 0x1)
  98769 
  98770 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  98771 		goto __20
  98772 	}
  98773 	*(*uintptr)(unsafe.Pointer(pLoop + 24 + 12)) = uintptr(0)
  98774 __20:
  98775 	;
  98776 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur
  98777 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = func() uint8 {
  98778 		if (*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass != 0 {
  98779 			return uint8(OP_Noop)
  98780 		}
  98781 		return uint8(OP_VNext)
  98782 	}()
  98783 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeCurrentAddr(tls, v)
  98784 
  98785 	j = 0
  98786 __21:
  98787 	if !(j < nConstraint) {
  98788 		goto __23
  98789 	}
  98790 	pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4))
  98791 	if !(j < 16 && int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 8)))>>j&1 != 0) {
  98792 		goto __24
  98793 	}
  98794 	disableTerm(tls, pLevel, pTerm)
  98795 	goto __22
  98796 __24:
  98797 	;
  98798 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_IN != 0 &&
  98799 		func() uint32 {
  98800 			if j <= 31 {
  98801 				return uint32(1) << j
  98802 			}
  98803 			return uint32(0)
  98804 		}()&*(*U32)(unsafe.Pointer(pLoop + 24 + 16)) == uint32(0) &&
  98805 		!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) {
  98806 		goto __25
  98807 	}
  98808 
  98809 	iIn = 0
  98810 __26:
  98811 	if !(iIn < *(*int32)(unsafe.Pointer(pLevel + 64))) {
  98812 		goto __28
  98813 	}
  98814 	pOp = Xsqlite3VdbeGetOp(tls, v, *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLevel + 64 + 4)) + uintptr(iIn)*20 + 4)))
  98815 	if !(int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column && (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iReg+j+2 ||
  98816 		int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid && (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 == iReg+j+2) {
  98817 		goto __29
  98818 	}
  98819 
  98820 	Xsqlite3VdbeAddOp3(tls, v, int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode), (*VdbeOp)(unsafe.Pointer(pOp)).Fp1, (*VdbeOp)(unsafe.Pointer(pOp)).Fp2, (*VdbeOp)(unsafe.Pointer(pOp)).Fp3)
  98821 	goto __28
  98822 __29:
  98823 	;
  98824 	goto __27
  98825 __27:
  98826 	iIn++
  98827 	goto __26
  98828 	goto __28
  98829 __28:
  98830 	;
  98831 	pCompare = Xsqlite3PExpr(tls, pParse, TK_EQ, uintptr(0), uintptr(0))
  98832 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
  98833 		goto __30
  98834 	}
  98835 	iFld = *(*int32)(unsafe.Pointer(pTerm + 24 + 4))
  98836 	pLeft = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft
  98837 
  98838 	if !(iFld > 0) {
  98839 		goto __31
  98840 	}
  98841 
  98842 	(*Expr)(unsafe.Pointer(pCompare)).FpLeft = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 20)) + 8 + uintptr(iFld-1)*20)).FpExpr
  98843 	goto __32
  98844 __31:
  98845 	(*Expr)(unsafe.Pointer(pCompare)).FpLeft = pLeft
  98846 __32:
  98847 	;
  98848 	(*Expr)(unsafe.Pointer(pCompare)).FpRight = libc.AssignUintptr(&pRight1, Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0)))
  98849 	if !(pRight1 != 0) {
  98850 		goto __33
  98851 	}
  98852 	(*Expr)(unsafe.Pointer(pRight1)).FiTable = iReg + j + 2
  98853 	Xsqlite3ExprIfFalse(tls,
  98854 		pParse, pCompare, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, SQLITE_JUMPIFNULL)
  98855 __33:
  98856 	;
  98857 	(*Expr)(unsafe.Pointer(pCompare)).FpLeft = uintptr(0)
  98858 __30:
  98859 	;
  98860 	Xsqlite3ExprDelete(tls, db, pCompare)
  98861 __25:
  98862 	;
  98863 	goto __22
  98864 __22:
  98865 	j++
  98866 	goto __21
  98867 	goto __23
  98868 __23:
  98869 	;
  98870 	goto __10
  98871 __9:
  98872 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK) != U32(0) &&
  98873 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_COLUMN_IN|WHERE_COLUMN_EQ) != U32(0)) {
  98874 		goto __34
  98875 	}
  98876 
  98877 	pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm))
  98878 
  98879 	iReleaseReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  98880 	iRowidReg = codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, bRev, iReleaseReg)
  98881 	if !(iRowidReg != iReleaseReg) {
  98882 		goto __36
  98883 	}
  98884 	Xsqlite3ReleaseTempReg(tls, pParse, iReleaseReg)
  98885 __36:
  98886 	;
  98887 	addrNxt = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt
  98888 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0) {
  98889 		goto __37
  98890 	}
  98891 	Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, iRowidReg, addrNxt)
  98892 
  98893 	Xsqlite3VdbeAddOp4Int(tls, v, OP_Filter, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt,
  98894 		iRowidReg, 1)
  98895 
  98896 	filterPullDown(tls, pParse, pWInfo, iLevel, addrNxt, notReady)
  98897 __37:
  98898 	;
  98899 	Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, iCur, addrNxt, iRowidReg)
  98900 
  98901 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Noop)
  98902 	goto __35
  98903 __34:
  98904 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK) != U32(0) &&
  98905 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_COLUMN_RANGE) != U32(0)) {
  98906 		goto __38
  98907 	}
  98908 
  98909 	testOp = OP_Noop
  98910 	memEndValue = 0
  98911 
  98912 	j = 0
  98913 	pStart = libc.AssignUintptr(&pEnd, uintptr(0))
  98914 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BTM_LIMIT) != 0) {
  98915 		goto __40
  98916 	}
  98917 	pStart = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*4))
  98918 __40:
  98919 	;
  98920 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_TOP_LIMIT) != 0) {
  98921 		goto __41
  98922 	}
  98923 	pEnd = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*4))
  98924 __41:
  98925 	;
  98926 	if !(bRev != 0) {
  98927 		goto __42
  98928 	}
  98929 	pTerm = pStart
  98930 	pStart = pEnd
  98931 	pEnd = pTerm
  98932 __42:
  98933 	;
  98934 	if !(pStart != 0) {
  98935 		goto __43
  98936 	}
  98937 
  98938 	*(*[4]U8)(unsafe.Pointer(bp + 8)) = [4]U8{
  98939 		U8(OP_SeekGT),
  98940 		U8(OP_SeekLE),
  98941 		U8(OP_SeekLT),
  98942 		U8(OP_SeekGE),
  98943 	}
  98944 
  98945 	pX = (*WhereTerm)(unsafe.Pointer(pStart)).FpExpr
  98946 
  98947 	if !(Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX)).FpRight) != 0) {
  98948 		goto __45
  98949 	}
  98950 	r1 = libc.AssignPtrInt32(bp+12, Xsqlite3GetTempReg(tls, pParse))
  98951 	codeExprOrVector(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, r1, 1)
  98952 
  98953 	op = int32(*(*U8)(unsafe.Pointer(bp + 8 + uintptr((int32((*Expr)(unsafe.Pointer(pX)).Fop)-TK_GT-1)&0x3|0x1))))
  98954 
  98955 	goto __46
  98956 __45:
  98957 	r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, bp+12)
  98958 	disableTerm(tls, pLevel, pStart)
  98959 	op = int32(*(*U8)(unsafe.Pointer(bp + 8 + uintptr(int32((*Expr)(unsafe.Pointer(pX)).Fop)-TK_GT))))
  98960 __46:
  98961 	;
  98962 	Xsqlite3VdbeAddOp3(tls, v, op, iCur, addrBrk, r1)
  98963 
  98964 	Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 12)))
  98965 	goto __44
  98966 __43:
  98967 	Xsqlite3VdbeAddOp2(tls, v, func() int32 {
  98968 		if bRev != 0 {
  98969 			return OP_Last
  98970 		}
  98971 		return OP_Rewind
  98972 	}(), iCur, addrHalt)
  98973 
  98974 __44:
  98975 	;
  98976 	if !(pEnd != 0) {
  98977 		goto __47
  98978 	}
  98979 	pX1 = (*WhereTerm)(unsafe.Pointer(pEnd)).FpExpr
  98980 
  98981 	memEndValue = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  98982 	codeExprOrVector(tls, pParse, (*Expr)(unsafe.Pointer(pX1)).FpRight, memEndValue, 1)
  98983 	if !(0 == Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX1)).FpRight) &&
  98984 		(int32((*Expr)(unsafe.Pointer(pX1)).Fop) == TK_LT || int32((*Expr)(unsafe.Pointer(pX1)).Fop) == TK_GT)) {
  98985 		goto __48
  98986 	}
  98987 	if bRev != 0 {
  98988 		testOp = OP_Le
  98989 	} else {
  98990 		testOp = OP_Ge
  98991 	}
  98992 	goto __49
  98993 __48:
  98994 	if bRev != 0 {
  98995 		testOp = OP_Lt
  98996 	} else {
  98997 		testOp = OP_Gt
  98998 	}
  98999 __49:
  99000 	;
  99001 	if !(0 == Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX1)).FpRight)) {
  99002 		goto __50
  99003 	}
  99004 	disableTerm(tls, pLevel, pEnd)
  99005 __50:
  99006 	;
  99007 __47:
  99008 	;
  99009 	start = Xsqlite3VdbeCurrentAddr(tls, v)
  99010 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = func() uint8 {
  99011 		if bRev != 0 {
  99012 			return uint8(OP_Prev)
  99013 		}
  99014 		return uint8(OP_Next)
  99015 	}()
  99016 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur
  99017 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = start
  99018 
  99019 	if !(testOp != OP_Noop) {
  99020 		goto __51
  99021 	}
  99022 	iRowidReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  99023 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCur, iRowidReg)
  99024 	Xsqlite3VdbeAddOp3(tls, v, testOp, memEndValue, addrBrk, iRowidReg)
  99025 
  99026 	Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_AFF_NUMERIC|SQLITE_JUMPIFNULL))
  99027 __51:
  99028 	;
  99029 	goto __39
  99030 __38:
  99031 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_INDEXED) != 0) {
  99032 		goto __52
  99033 	}
  99034 	nEq = *(*U16)(unsafe.Pointer(pLoop + 24))
  99035 	nBtm = *(*U16)(unsafe.Pointer(pLoop + 24 + 2))
  99036 	nTop = *(*U16)(unsafe.Pointer(pLoop + 24 + 4))
  99037 	pRangeStart = uintptr(0)
  99038 	pRangeEnd = uintptr(0)
  99039 	nExtraReg = 0
  99040 	zEndAff = uintptr(0)
  99041 	bSeekPastNull = U8(0)
  99042 	bStopAtNull = U8(0)
  99043 	regBignull = 0
  99044 	addrSeekScan = 0
  99045 
  99046 	pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
  99047 	iIdxCur = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur
  99048 
  99049 	j = int32(nEq)
  99050 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BTM_LIMIT) != 0) {
  99051 		goto __54
  99052 	}
  99053 	pRangeStart = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*4))
  99054 	nExtraReg = func() int32 {
  99055 		if nExtraReg > int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 2))) {
  99056 			return nExtraReg
  99057 		}
  99058 		return int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 2)))
  99059 	}()
  99060 
  99061 __54:
  99062 	;
  99063 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_TOP_LIMIT) != 0) {
  99064 		goto __55
  99065 	}
  99066 	pRangeEnd = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*4))
  99067 	nExtraReg = func() int32 {
  99068 		if nExtraReg > int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 4))) {
  99069 			return nExtraReg
  99070 		}
  99071 		return int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 4)))
  99072 	}()
  99073 	if !(pRangeStart == uintptr(0)) {
  99074 		goto __56
  99075 	}
  99076 	j = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(nEq)*2)))
  99077 	if !(j >= 0 && int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(j)*16 + 4))&0xf>>0) == 0 || j == -2) {
  99078 		goto __57
  99079 	}
  99080 	bSeekPastNull = U8(1)
  99081 __57:
  99082 	;
  99083 __56:
  99084 	;
  99085 __55:
  99086 	;
  99087 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_TOP_LIMIT|WHERE_BTM_LIMIT) == U32(0) &&
  99088 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BIGNULL_SORT) != U32(0)) {
  99089 		goto __58
  99090 	}
  99091 
  99092 	nExtraReg = 1
  99093 	bSeekPastNull = U8(1)
  99094 	(*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull = libc.AssignInt32(&regBignull, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1))
  99095 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0) {
  99096 		goto __59
  99097 	}
  99098 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regBignull)
  99099 __59:
  99100 	;
  99101 	(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull = Xsqlite3VdbeMakeLabel(tls, pParse)
  99102 __58:
  99103 	;
  99104 	if !(int32(nEq) < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) && bRev == libc.Bool32(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == SQLITE_SO_ASC)) {
  99105 		goto __60
  99106 	}
  99107 
  99108 	t = pRangeEnd
  99109 	pRangeEnd = pRangeStart
  99110 	pRangeStart = t
  99111 
  99112 	t1 = bSeekPastNull
  99113 	bSeekPastNull = bStopAtNull
  99114 	bStopAtNull = t1
  99115 
  99116 	t2 = U8(nBtm)
  99117 	nBtm = nTop
  99118 	nTop = U16(t2)
  99119 
  99120 __60:
  99121 	;
  99122 	if !(iLevel > 0 && (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_SEEKSCAN) != U32(0)) {
  99123 		goto __61
  99124 	}
  99125 
  99126 	Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, iIdxCur)
  99127 __61:
  99128 	;
  99129 	regBase = codeAllEqualityTerms(tls, pParse, pLevel, bRev, nExtraReg, bp+16)
  99130 
  99131 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0 && nTop != 0) {
  99132 		goto __62
  99133 	}
  99134 	zEndAff = Xsqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 16))+uintptr(nEq))
  99135 __62:
  99136 	;
  99137 	addrNxt = func() int32 {
  99138 		if regBignull != 0 {
  99139 			return (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull
  99140 		}
  99141 		return (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt
  99142 	}()
  99143 
  99144 	startEq = libc.Bool32(!(pRangeStart != 0) || int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator)&(int32(WO_EQ)<<(TK_LE-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) != 0)
  99145 	endEq = libc.Bool32(!(pRangeEnd != 0) || int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator)&(int32(WO_EQ)<<(TK_LE-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) != 0)
  99146 	start_constraints = libc.Bool32(pRangeStart != 0 || int32(nEq) > 0)
  99147 
  99148 	nConstraint1 = int32(nEq)
  99149 	if !(pRangeStart != 0) {
  99150 		goto __63
  99151 	}
  99152 	pRight2 = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pRangeStart)).FpExpr)).FpRight
  99153 	codeExprOrVector(tls, pParse, pRight2, regBase+int32(nEq), int32(nBtm))
  99154 
  99155 	if !(int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags)&TERM_VNULL == 0 &&
  99156 		Xsqlite3ExprCanBeNull(tls, pRight2) != 0) {
  99157 		goto __65
  99158 	}
  99159 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regBase+int32(nEq), addrNxt)
  99160 
  99161 __65:
  99162 	;
  99163 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) {
  99164 		goto __66
  99165 	}
  99166 	updateRangeAffinityStr(tls, pRight2, int32(nBtm), *(*uintptr)(unsafe.Pointer(bp + 16))+uintptr(nEq))
  99167 __66:
  99168 	;
  99169 	nConstraint1 = nConstraint1 + int32(nBtm)
  99170 
  99171 	if !(Xsqlite3ExprIsVector(tls, pRight2) == 0) {
  99172 		goto __67
  99173 	}
  99174 	disableTerm(tls, pLevel, pRangeStart)
  99175 	goto __68
  99176 __67:
  99177 	startEq = 1
  99178 __68:
  99179 	;
  99180 	bSeekPastNull = U8(0)
  99181 	goto __64
  99182 __63:
  99183 	if !(bSeekPastNull != 0) {
  99184 		goto __69
  99185 	}
  99186 	startEq = 0
  99187 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regBase+int32(nEq))
  99188 	start_constraints = 1
  99189 	nConstraint1++
  99190 	goto __70
  99191 __69:
  99192 	if !(regBignull != 0) {
  99193 		goto __71
  99194 	}
  99195 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regBase+int32(nEq))
  99196 	start_constraints = 1
  99197 	nConstraint1++
  99198 __71:
  99199 	;
  99200 __70:
  99201 	;
  99202 __64:
  99203 	;
  99204 	codeApplyAffinity(tls, pParse, regBase, nConstraint1-int32(bSeekPastNull), *(*uintptr)(unsafe.Pointer(bp + 16)))
  99205 	if !(int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip) > 0 && nConstraint1 == int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip)) {
  99206 		goto __72
  99207 	}
  99208 
  99209 	goto __73
  99210 __72:
  99211 	if !(regBignull != 0) {
  99212 		goto __74
  99213 	}
  99214 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regBignull)
  99215 
  99216 __74:
  99217 	;
  99218 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0) {
  99219 		goto __75
  99220 	}
  99221 	Xsqlite3VdbeAddOp4Int(tls, v, OP_Filter, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter, addrNxt,
  99222 		regBase, int32(nEq))
  99223 
  99224 	filterPullDown(tls, pParse, pWInfo, iLevel, addrNxt, notReady)
  99225 __75:
  99226 	;
  99227 	op1 = int32(aStartOp[start_constraints<<2+startEq<<1+bRev])
  99228 
  99229 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_SEEKSCAN) != U32(0) && op1 == OP_SeekGE) {
  99230 		goto __76
  99231 	}
  99232 
  99233 	addrSeekScan = Xsqlite3VdbeAddOp1(tls, v, OP_SeekScan,
  99234 		(int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst)))+9)/10)
  99235 	if !(pRangeStart != 0) {
  99236 		goto __77
  99237 	}
  99238 	Xsqlite3VdbeChangeP5(tls, v, uint16(1))
  99239 	Xsqlite3VdbeChangeP2(tls, v, addrSeekScan, Xsqlite3VdbeCurrentAddr(tls, v)+1)
  99240 	addrSeekScan = 0
  99241 __77:
  99242 	;
  99243 __76:
  99244 	;
  99245 	Xsqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1)
  99246 
  99247 	if !(regBignull != 0) {
  99248 		goto __78
  99249 	}
  99250 
  99251 	Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, Xsqlite3VdbeCurrentAddr(tls, v)+2)
  99252 	op1 = int32(aStartOp[libc.Bool32(nConstraint1 > 1)*4+2+bRev])
  99253 	Xsqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase,
  99254 		nConstraint1-startEq)
  99255 
  99256 __78:
  99257 	;
  99258 __73:
  99259 	;
  99260 	nConstraint1 = int32(nEq)
  99261 
  99262 	if !(pRangeEnd != 0) {
  99263 		goto __79
  99264 	}
  99265 	pRight3 = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FpExpr)).FpRight
  99266 	if !(addrSeekScan != 0) {
  99267 		goto __81
  99268 	}
  99269 
  99270 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeCurrentAddr(tls, v)
  99271 __81:
  99272 	;
  99273 	codeExprOrVector(tls, pParse, pRight3, regBase+int32(nEq), int32(nTop))
  99274 
  99275 	if !(int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags)&TERM_VNULL == 0 &&
  99276 		Xsqlite3ExprCanBeNull(tls, pRight3) != 0) {
  99277 		goto __82
  99278 	}
  99279 	Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regBase+int32(nEq), addrNxt)
  99280 
  99281 __82:
  99282 	;
  99283 	if !(zEndAff != 0) {
  99284 		goto __83
  99285 	}
  99286 	updateRangeAffinityStr(tls, pRight3, int32(nTop), zEndAff)
  99287 	codeApplyAffinity(tls, pParse, regBase+int32(nEq), int32(nTop), zEndAff)
  99288 	goto __84
  99289 __83:
  99290 	;
  99291 __84:
  99292 	;
  99293 	nConstraint1 = nConstraint1 + int32(nTop)
  99294 
  99295 	if !(Xsqlite3ExprIsVector(tls, pRight3) == 0) {
  99296 		goto __85
  99297 	}
  99298 	disableTerm(tls, pLevel, pRangeEnd)
  99299 	goto __86
  99300 __85:
  99301 	endEq = 1
  99302 __86:
  99303 	;
  99304 	goto __80
  99305 __79:
  99306 	if !(bStopAtNull != 0) {
  99307 		goto __87
  99308 	}
  99309 	if !(regBignull == 0) {
  99310 		goto __88
  99311 	}
  99312 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regBase+int32(nEq))
  99313 	endEq = 0
  99314 __88:
  99315 	;
  99316 	nConstraint1++
  99317 __87:
  99318 	;
  99319 __80:
  99320 	;
  99321 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) != 0) {
  99322 		goto __89
  99323 	}
  99324 	Xsqlite3DbNNFreeNN(tls, db, *(*uintptr)(unsafe.Pointer(bp + 16)))
  99325 __89:
  99326 	;
  99327 	if !(zEndAff != 0) {
  99328 		goto __90
  99329 	}
  99330 	Xsqlite3DbNNFreeNN(tls, db, zEndAff)
  99331 __90:
  99332 	;
  99333 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 == 0) {
  99334 		goto __91
  99335 	}
  99336 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeCurrentAddr(tls, v)
  99337 __91:
  99338 	;
  99339 	if !(nConstraint1 != 0) {
  99340 		goto __92
  99341 	}
  99342 	if !(regBignull != 0) {
  99343 		goto __93
  99344 	}
  99345 
  99346 	Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, regBignull, Xsqlite3VdbeCurrentAddr(tls, v)+3)
  99347 
  99348 __93:
  99349 	;
  99350 	op1 = int32(aEndOp[bRev*2+endEq])
  99351 	Xsqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase, nConstraint1)
  99352 
  99353 	if !(addrSeekScan != 0) {
  99354 		goto __94
  99355 	}
  99356 	Xsqlite3VdbeJumpHere(tls, v, addrSeekScan)
  99357 __94:
  99358 	;
  99359 __92:
  99360 	;
  99361 	if !(regBignull != 0) {
  99362 		goto __95
  99363 	}
  99364 
  99365 	Xsqlite3VdbeAddOp2(tls, v, OP_If, regBignull, Xsqlite3VdbeCurrentAddr(tls, v)+2)
  99366 
  99367 	op1 = int32(aEndOp[bRev*2+int32(bSeekPastNull)])
  99368 	Xsqlite3VdbeAddOp4Int(tls, v, op1, iIdxCur, addrNxt, regBase,
  99369 		nConstraint1+int32(bSeekPastNull))
  99370 
  99371 __95:
  99372 	;
  99373 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_EARLYOUT) != U32(0)) {
  99374 		goto __96
  99375 	}
  99376 	Xsqlite3VdbeAddOp3(tls, v, OP_SeekHit, iIdxCur, int32(nEq), int32(nEq))
  99377 __96:
  99378 	;
  99379 	omitTable = libc.Bool32((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IDX_ONLY) != U32(0) &&
  99380 		int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(WHERE_OR_SUBCLAUSE|WHERE_RIGHT_JOIN) == 0)
  99381 	if !(omitTable != 0) {
  99382 		goto __97
  99383 	}
  99384 
  99385 	goto __98
  99386 __97:
  99387 	if !((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  99388 		goto __99
  99389 	}
  99390 	codeDeferredSeek(tls, pWInfo, pIdx, iCur, iIdxCur)
  99391 	goto __100
  99392 __99:
  99393 	if !(iCur != iIdxCur) {
  99394 		goto __101
  99395 	}
  99396 	pPk = Xsqlite3PrimaryKeyIndex(tls, (*Index)(unsafe.Pointer(pIdx)).FpTable)
  99397 	iRowidReg = Xsqlite3GetTempRange(tls, pParse, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol))
  99398 	j = 0
  99399 __102:
  99400 	if !(j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) {
  99401 		goto __104
  99402 	}
  99403 	k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2))))
  99404 	Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, k, iRowidReg+j)
  99405 	goto __103
  99406 __103:
  99407 	j++
  99408 	goto __102
  99409 	goto __104
  99410 __104:
  99411 	;
  99412 	Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iCur, addrCont,
  99413 		iRowidReg, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol))
  99414 __101:
  99415 	;
  99416 __100:
  99417 	;
  99418 __98:
  99419 	;
  99420 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0) {
  99421 		goto __105
  99422 	}
  99423 
  99424 	if !((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0) {
  99425 		goto __107
  99426 	}
  99427 	whereApplyPartialIndexConstraints(tls, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, iCur, pWC)
  99428 __107:
  99429 	;
  99430 	goto __106
  99431 __105:
  99432 	;
  99433 __106:
  99434 	;
  99435 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_ONEROW) != 0) {
  99436 		goto __108
  99437 	}
  99438 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Noop)
  99439 	goto __109
  99440 __108:
  99441 	if !(bRev != 0) {
  99442 		goto __110
  99443 	}
  99444 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Prev)
  99445 	goto __111
  99446 __110:
  99447 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Next)
  99448 __111:
  99449 	;
  99450 __109:
  99451 	;
  99452 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iIdxCur
  99453 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp3 = func() uint8 {
  99454 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_UNQ_WANTED) != U32(0) {
  99455 			return uint8(1)
  99456 		}
  99457 		return uint8(0)
  99458 	}()
  99459 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_CONSTRAINT) == U32(0)) {
  99460 		goto __112
  99461 	}
  99462 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = U8(SQLITE_STMTSTATUS_FULLSCAN_STEP)
  99463 	goto __113
  99464 __112:
  99465 	;
  99466 __113:
  99467 	;
  99468 	if !(omitTable != 0) {
  99469 		goto __114
  99470 	}
  99471 	pIdx = uintptr(0)
  99472 __114:
  99473 	;
  99474 	goto __53
  99475 __52:
  99476 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_MULTI_OR) != 0) {
  99477 		goto __115
  99478 	}
  99479 	pCov = uintptr(0)
  99480 	iCovCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  99481 
  99482 	regReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  99483 	regRowset = 0
  99484 	regRowid = 0
  99485 	iLoopBody = Xsqlite3VdbeMakeLabel(tls, pParse)
  99486 	untestedTerms = 0
  99487 	pAndExpr = uintptr(0)
  99488 	pTab = (*SrcItem)(unsafe.Pointer(pTabItem)).FpTab
  99489 
  99490 	pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm))
  99491 
  99492 	pOrWc = *(*uintptr)(unsafe.Pointer(pTerm + 24))
  99493 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Return)
  99494 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = regReturn
  99495 
  99496 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) > 1) {
  99497 		goto __117
  99498 	}
  99499 	nNotReady = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - iLevel - 1
  99500 	pOrTab = Xsqlite3DbMallocRawNN(tls, db,
  99501 		uint64(uint32(unsafe.Sizeof(SrcList{}))+uint32(nNotReady)*uint32(unsafe.Sizeof(SrcItem{}))))
  99502 	if !(pOrTab == uintptr(0)) {
  99503 		goto __119
  99504 	}
  99505 	return notReady
  99506 __119:
  99507 	;
  99508 	(*SrcList)(unsafe.Pointer(pOrTab)).FnAlloc = U32(U8(nNotReady + 1))
  99509 	(*SrcList)(unsafe.Pointer(pOrTab)).FnSrc = int32((*SrcList)(unsafe.Pointer(pOrTab)).FnAlloc)
  99510 	libc.Xmemcpy(tls, pOrTab+8, pTabItem, uint32(unsafe.Sizeof(SrcItem{})))
  99511 	origSrc = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8
  99512 	k = 1
  99513 __120:
  99514 	if !(k <= nNotReady) {
  99515 		goto __122
  99516 	}
  99517 	libc.Xmemcpy(tls, pOrTab+8+uintptr(k)*72, origSrc+uintptr((*WhereLevel)(unsafe.Pointer(pLevel+uintptr(k)*88)).FiFrom)*72, uint32(unsafe.Sizeof(SrcItem{})))
  99518 	goto __121
  99519 __121:
  99520 	k++
  99521 	goto __120
  99522 	goto __122
  99523 __122:
  99524 	;
  99525 	goto __118
  99526 __117:
  99527 	pOrTab = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList
  99528 __118:
  99529 	;
  99530 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_DUPLICATES_OK == 0) {
  99531 		goto __123
  99532 	}
  99533 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  99534 		goto __124
  99535 	}
  99536 	regRowset = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  99537 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regRowset)
  99538 	goto __125
  99539 __124:
  99540 	pPk1 = Xsqlite3PrimaryKeyIndex(tls, pTab)
  99541 	regRowset = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
  99542 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, regRowset, int32((*Index)(unsafe.Pointer(pPk1)).FnKeyCol))
  99543 	Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk1)
  99544 __125:
  99545 	;
  99546 	regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
  99547 __123:
  99548 	;
  99549 	iRetInit = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regReturn)
  99550 
  99551 	if !((*WhereClause)(unsafe.Pointer(pWC)).FnTerm > 1) {
  99552 		goto __126
  99553 	}
  99554 	iTerm = 0
  99555 __127:
  99556 	if !(iTerm < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm) {
  99557 		goto __129
  99558 	}
  99559 	pExpr = (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iTerm)*48)).FpExpr
  99560 	if !((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*48 == pTerm) {
  99561 		goto __130
  99562 	}
  99563 	goto __128
  99564 __130:
  99565 	;
  99566 	if !(int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*48)).FwtFlags)&(TERM_VIRTUAL|TERM_CODED|TERM_SLICE) != 0) {
  99567 		goto __131
  99568 	}
  99569 	goto __128
  99570 __131:
  99571 	;
  99572 	if !(int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*48)).FeOperator)&WO_ALL == 0) {
  99573 		goto __132
  99574 	}
  99575 	goto __128
  99576 __132:
  99577 	;
  99578 	if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_Subquery) != U32(0)) {
  99579 		goto __133
  99580 	}
  99581 	goto __128
  99582 __133:
  99583 	;
  99584 	pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0)
  99585 	pAndExpr = Xsqlite3ExprAnd(tls, pParse, pAndExpr, pExpr)
  99586 	goto __128
  99587 __128:
  99588 	iTerm++
  99589 	goto __127
  99590 	goto __129
  99591 __129:
  99592 	;
  99593 	if !(pAndExpr != 0) {
  99594 		goto __134
  99595 	}
  99596 
  99597 	pAndExpr = Xsqlite3PExpr(tls, pParse, TK_AND|0x10000, uintptr(0), pAndExpr)
  99598 __134:
  99599 	;
  99600 __126:
  99601 	;
  99602 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+21824, 0)
  99603 	ii = 0
  99604 __135:
  99605 	if !(ii < (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm) {
  99606 		goto __137
  99607 	}
  99608 	pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr(ii)*48
  99609 	if !((*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur || int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&WO_AND != 0) {
  99610 		goto __138
  99611 	}
  99612 	pOrExpr = (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr
  99613 	jmp1 = 0
  99614 
  99615 	pDelete = libc.AssignUintptr(&pOrExpr, Xsqlite3ExprDup(tls, db, pOrExpr, 0))
  99616 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
  99617 		goto __139
  99618 	}
  99619 	Xsqlite3ExprDelete(tls, db, pDelete)
  99620 	goto __136
  99621 __139:
  99622 	;
  99623 	if !(pAndExpr != 0) {
  99624 		goto __140
  99625 	}
  99626 	(*Expr)(unsafe.Pointer(pAndExpr)).FpLeft = pOrExpr
  99627 	pOrExpr = pAndExpr
  99628 __140:
  99629 	;
  99630 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+21839, libc.VaList(bp, ii+1))
  99631 
  99632 	pSubWInfo = Xsqlite3WhereBegin(tls, pParse, pOrTab, pOrExpr, uintptr(0), uintptr(0), uintptr(0),
  99633 		uint16(WHERE_OR_SUBCLAUSE), iCovCur)
  99634 
  99635 	if !(pSubWInfo != 0) {
  99636 		goto __141
  99637 	}
  99638 	addrExplain = Xsqlite3WhereExplainOneScan(tls,
  99639 		pParse, pOrTab, pSubWInfo+760, uint16(0))
  99640 	_ = addrExplain
  99641 
  99642 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_DUPLICATES_OK == 0) {
  99643 		goto __142
  99644 	}
  99645 	iSet = func() int32 {
  99646 		if ii == (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm-1 {
  99647 			return -1
  99648 		}
  99649 		return ii
  99650 	}()
  99651 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
  99652 		goto __143
  99653 	}
  99654 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -1, regRowid)
  99655 	jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_RowSetTest, regRowset, 0,
  99656 		regRowid, iSet)
  99657 
  99658 	goto __144
  99659 __143:
  99660 	pPk2 = Xsqlite3PrimaryKeyIndex(tls, pTab)
  99661 	nPk = int32((*Index)(unsafe.Pointer(pPk2)).FnKeyCol)
  99662 
  99663 	r = Xsqlite3GetTempRange(tls, pParse, nPk)
  99664 	iPk = 0
  99665 __145:
  99666 	if !(iPk < nPk) {
  99667 		goto __147
  99668 	}
  99669 	iCol = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk2)).FaiColumn + uintptr(iPk)*2)))
  99670 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, iCol, r+iPk)
  99671 	goto __146
  99672 __146:
  99673 	iPk++
  99674 	goto __145
  99675 	goto __147
  99676 __147:
  99677 	;
  99678 	if !(iSet != 0) {
  99679 		goto __148
  99680 	}
  99681 	jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, regRowset, 0, r, nPk)
  99682 
  99683 __148:
  99684 	;
  99685 	if !(iSet >= 0) {
  99686 		goto __149
  99687 	}
  99688 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r, nPk, regRowid)
  99689 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, regRowset, regRowid,
  99690 		r, nPk)
  99691 	if !(iSet != 0) {
  99692 		goto __150
  99693 	}
  99694 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT))
  99695 __150:
  99696 	;
  99697 __149:
  99698 	;
  99699 	Xsqlite3ReleaseTempRange(tls, pParse, r, nPk)
  99700 __144:
  99701 	;
  99702 __142:
  99703 	;
  99704 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReturn, iLoopBody)
  99705 
  99706 	if !(jmp1 != 0) {
  99707 		goto __151
  99708 	}
  99709 	Xsqlite3VdbeJumpHere(tls, v, jmp1)
  99710 __151:
  99711 	;
  99712 	if !(uint32(int32(*(*uint8)(unsafe.Pointer(pSubWInfo + 48))&0x2>>1)) != 0) {
  99713 		goto __152
  99714 	}
  99715 	untestedTerms = 1
  99716 __152:
  99717 	;
  99718 	pSubLoop = (*WhereLevel)(unsafe.Pointer(pSubWInfo + 760)).FpWLoop
  99719 
  99720 	if !((*WhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags&U32(WHERE_INDEXED) != U32(0) &&
  99721 		(ii == 0 || *(*uintptr)(unsafe.Pointer(pSubLoop + 24 + 8)) == pCov) &&
  99722 		((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) || !(int32(*(*uint16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSubLoop + 24 + 8)) + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY))) {
  99723 		goto __153
  99724 	}
  99725 
  99726 	pCov = *(*uintptr)(unsafe.Pointer(pSubLoop + 24 + 8))
  99727 	goto __154
  99728 __153:
  99729 	pCov = uintptr(0)
  99730 __154:
  99731 	;
  99732 	if !(Xsqlite3WhereUsesDeferredSeek(tls, pSubWInfo) != 0) {
  99733 		goto __155
  99734 	}
  99735 	libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(1), 0, 0x1)
  99736 __155:
  99737 	;
  99738 	Xsqlite3WhereEnd(tls, pSubWInfo)
  99739 	Xsqlite3VdbeExplainPop(tls, pParse)
  99740 __141:
  99741 	;
  99742 	Xsqlite3ExprDelete(tls, db, pDelete)
  99743 __138:
  99744 	;
  99745 	goto __136
  99746 __136:
  99747 	ii++
  99748 	goto __135
  99749 	goto __137
  99750 __137:
  99751 	;
  99752 	Xsqlite3VdbeExplainPop(tls, pParse)
  99753 
  99754 	*(*uintptr)(unsafe.Pointer(pLevel + 64)) = pCov
  99755 	if !(pCov != 0) {
  99756 		goto __156
  99757 	}
  99758 	(*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = iCovCur
  99759 __156:
  99760 	;
  99761 	if !(pAndExpr != 0) {
  99762 		goto __157
  99763 	}
  99764 	(*Expr)(unsafe.Pointer(pAndExpr)).FpLeft = uintptr(0)
  99765 	Xsqlite3ExprDelete(tls, db, pAndExpr)
  99766 __157:
  99767 	;
  99768 	Xsqlite3VdbeChangeP1(tls, v, iRetInit, Xsqlite3VdbeCurrentAddr(tls, v))
  99769 	Xsqlite3VdbeGoto(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk)
  99770 	Xsqlite3VdbeResolveLabel(tls, v, iLoopBody)
  99771 
  99772 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeCurrentAddr(tls, v)
  99773 
  99774 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) > 1) {
  99775 		goto __158
  99776 	}
  99777 	Xsqlite3DbFreeNN(tls, db, pOrTab)
  99778 __158:
  99779 	;
  99780 	if !!(untestedTerms != 0) {
  99781 		goto __159
  99782 	}
  99783 	disableTerm(tls, pLevel, pTerm)
  99784 __159:
  99785 	;
  99786 	goto __116
  99787 __115:
  99788 	;
  99789 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pTabItem + 36 + 4))&0x40>>6)) != 0) {
  99790 		goto __160
  99791 	}
  99792 
  99793 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(OP_Noop)
  99794 	goto __161
  99795 __160:
  99796 	;
  99797 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fop = aStep[bRev]
  99798 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur
  99799 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = 1 + Xsqlite3VdbeAddOp2(tls, v, int32(aStart[bRev]), iCur, addrHalt)
  99800 
  99801 	(*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = U8(SQLITE_STMTSTATUS_FULLSCAN_STEP)
  99802 __161:
  99803 	;
  99804 __116:
  99805 	;
  99806 __53:
  99807 	;
  99808 __39:
  99809 	;
  99810 __35:
  99811 	;
  99812 __10:
  99813 	;
  99814 __8:
  99815 	;
  99816 	iLoop = func() int32 {
  99817 		if pIdx != 0 {
  99818 			return 1
  99819 		}
  99820 		return 2
  99821 	}()
  99822 __162:
  99823 	iNext = 0
  99824 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
  99825 	j = (*WhereClause)(unsafe.Pointer(pWC)).FnTerm
  99826 __165:
  99827 	if !(j > 0) {
  99828 		goto __167
  99829 	}
  99830 	skipLikeAddr = 0
  99831 
  99832 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(TERM_VIRTUAL|TERM_CODED) != 0) {
  99833 		goto __168
  99834 	}
  99835 	goto __166
  99836 __168:
  99837 	;
  99838 	if !((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady != uint64(0)) {
  99839 		goto __169
  99840 	}
  99841 
  99842 	libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(1), 1, 0x2)
  99843 	goto __166
  99844 __169:
  99845 	;
  99846 	pE = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
  99847 
  99848 	if !(int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0) {
  99849 		goto __170
  99850 	}
  99851 	if !!((*Expr)(unsafe.Pointer(pE)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0)) {
  99852 		goto __171
  99853 	}
  99854 
  99855 	goto __166
  99856 	goto __172
  99857 __171:
  99858 	if !(int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&JT_LEFT == JT_LEFT &&
  99859 		!((*Expr)(unsafe.Pointer(pE)).Fflags&U32(EP_OuterON) != U32(0))) {
  99860 		goto __173
  99861 	}
  99862 	goto __166
  99863 	goto __174
  99864 __173:
  99865 	m = Xsqlite3WhereGetMask(tls, pWInfo+496, *(*int32)(unsafe.Pointer(pE + 36)))
  99866 	if !(m&(*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady != 0) {
  99867 		goto __175
  99868 	}
  99869 
  99870 	goto __166
  99871 __175:
  99872 	;
  99873 __174:
  99874 	;
  99875 __172:
  99876 	;
  99877 __170:
  99878 	;
  99879 	if !(iLoop == 1 && !(Xsqlite3ExprCoveredByIndex(tls, pE, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, pIdx) != 0)) {
  99880 		goto __176
  99881 	}
  99882 	iNext = 2
  99883 	goto __166
  99884 __176:
  99885 	;
  99886 	if !(iLoop < 3 && int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VARSELECT != 0) {
  99887 		goto __177
  99888 	}
  99889 	if !(iNext == 0) {
  99890 		goto __178
  99891 	}
  99892 	iNext = 3
  99893 __178:
  99894 	;
  99895 	goto __166
  99896 __177:
  99897 	;
  99898 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_LIKECOND != 0) {
  99899 		goto __179
  99900 	}
  99901 
  99902 	goto __166
  99903 __179:
  99904 	;
  99905 	Xsqlite3ExprIfFalse(tls, pParse, pE, addrCont, SQLITE_JUMPIFNULL)
  99906 	if !(skipLikeAddr != 0) {
  99907 		goto __180
  99908 	}
  99909 	Xsqlite3VdbeJumpHere(tls, v, skipLikeAddr)
  99910 __180:
  99911 	;
  99912 	*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_CODED)
  99913 	goto __166
  99914 __166:
  99915 	j--
  99916 	pTerm += 48
  99917 	goto __165
  99918 	goto __167
  99919 __167:
  99920 	;
  99921 	iLoop = iNext
  99922 	goto __163
  99923 __163:
  99924 	if iLoop > 0 {
  99925 		goto __162
  99926 	}
  99927 	goto __164
  99928 __164:
  99929 	;
  99930 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
  99931 	j = (*WhereClause)(unsafe.Pointer(pWC)).FnBase
  99932 __181:
  99933 	if !(j > 0) {
  99934 		goto __183
  99935 	}
  99936 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(TERM_VIRTUAL|TERM_CODED) != 0) {
  99937 		goto __184
  99938 	}
  99939 	goto __182
  99940 __184:
  99941 	;
  99942 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(WO_EQ|WO_IS) == 0) {
  99943 		goto __185
  99944 	}
  99945 	goto __182
  99946 __185:
  99947 	;
  99948 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_EQUIV == 0) {
  99949 		goto __186
  99950 	}
  99951 	goto __182
  99952 __186:
  99953 	;
  99954 	if !((*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != iCur) {
  99955 		goto __187
  99956 	}
  99957 	goto __182
  99958 __187:
  99959 	;
  99960 	if !(int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0) {
  99961 		goto __188
  99962 	}
  99963 	goto __182
  99964 __188:
  99965 	;
  99966 	pE1 = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
  99967 
  99968 	pAlt = Xsqlite3WhereFindTerm(tls, pWC, iCur, *(*int32)(unsafe.Pointer(pTerm + 24)), notReady,
  99969 		uint32(WO_EQ|WO_IN|WO_IS), uintptr(0))
  99970 	if !(pAlt == uintptr(0)) {
  99971 		goto __189
  99972 	}
  99973 	goto __182
  99974 __189:
  99975 	;
  99976 	if !(int32((*WhereTerm)(unsafe.Pointer(pAlt)).FwtFlags)&TERM_CODED != 0) {
  99977 		goto __190
  99978 	}
  99979 	goto __182
  99980 __190:
  99981 	;
  99982 	if !(int32((*WhereTerm)(unsafe.Pointer(pAlt)).FeOperator)&WO_IN != 0 &&
  99983 		(*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags&U32(EP_xIsSelect) != U32(0) &&
  99984 		(*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr + 20)))).FpEList)).FnExpr > 1) {
  99985 		goto __191
  99986 	}
  99987 	goto __182
  99988 __191:
  99989 	;
  99990 	*(*Expr)(unsafe.Pointer(bp + 20)) = *(*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr))
  99991 	(*Expr)(unsafe.Pointer(bp + 20)).FpLeft = (*Expr)(unsafe.Pointer(pE1)).FpLeft
  99992 	Xsqlite3ExprIfFalse(tls, pParse, bp+20, addrCont, SQLITE_JUMPIFNULL)
  99993 	*(*U16)(unsafe.Pointer(pAlt + 10)) |= U16(TERM_CODED)
  99994 	goto __182
  99995 __182:
  99996 	j--
  99997 	pTerm += 48
  99998 	goto __181
  99999 	goto __183
 100000 __183:
 100001 	;
 100002 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0) {
 100003 		goto __192
 100004 	}
 100005 	jmp11 = 0
 100006 	pRJ = (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ
 100007 
 100008 	pTab1 = (*SrcItem)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72)).FpTab
 100009 	if !((*Table)(unsafe.Pointer(pTab1)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
 100010 		goto __193
 100011 	}
 100012 	r2 = Xsqlite3GetTempRange(tls, pParse, 2)
 100013 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab1, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, -1, r2+1)
 100014 	nPk1 = 1
 100015 	goto __194
 100016 __193:
 100017 	pPk3 = Xsqlite3PrimaryKeyIndex(tls, pTab1)
 100018 	nPk1 = int32((*Index)(unsafe.Pointer(pPk3)).FnKeyCol)
 100019 	r2 = Xsqlite3GetTempRange(tls, pParse, nPk1+1)
 100020 	iPk1 = 0
 100021 __195:
 100022 	if !(iPk1 < nPk1) {
 100023 		goto __197
 100024 	}
 100025 	iCol1 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk3)).FaiColumn + uintptr(iPk1)*2)))
 100026 	Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab1, iCur, iCol1, r2+1+iPk1)
 100027 	goto __196
 100028 __196:
 100029 	iPk1++
 100030 	goto __195
 100031 	goto __197
 100032 __197:
 100033 	;
 100034 __194:
 100035 	;
 100036 	jmp11 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, 0, r2+1, nPk1)
 100037 
 100038 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r2+1, nPk1, r2)
 100039 	Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, r2, r2+1, nPk1)
 100040 	Xsqlite3VdbeAddOp4Int(tls, v, OP_FilterAdd, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom, 0, r2+1, nPk1)
 100041 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT))
 100042 	Xsqlite3VdbeJumpHere(tls, v, jmp11)
 100043 	Xsqlite3ReleaseTempRange(tls, pParse, r2, nPk1+1)
 100044 __192:
 100045 	;
 100046 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0) {
 100047 		goto __198
 100048 	}
 100049 	(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst = Xsqlite3VdbeCurrentAddr(tls, v)
 100050 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin)
 100051 
 100052 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ == uintptr(0)) {
 100053 		goto __199
 100054 	}
 100055 	goto code_outer_join_constraints
 100056 __199:
 100057 	;
 100058 __198:
 100059 	;
 100060 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0) {
 100061 		goto __200
 100062 	}
 100063 	pRJ1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ
 100064 	Xsqlite3VdbeAddOp2(tls, v, OP_BeginSubrtn, 0, (*WhereRightJoin)(unsafe.Pointer(pRJ1)).FregReturn)
 100065 	(*WhereRightJoin)(unsafe.Pointer(pRJ1)).FaddrSubrtn = Xsqlite3VdbeCurrentAddr(tls, v)
 100066 
 100067 	(*Parse)(unsafe.Pointer(pParse)).FwithinRJSubrtn++
 100068 
 100069 code_outer_join_constraints:
 100070 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 100071 	j = 0
 100072 __201:
 100073 	if !(j < (*WhereClause)(unsafe.Pointer(pWC)).FnBase) {
 100074 		goto __203
 100075 	}
 100076 
 100077 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(TERM_VIRTUAL|TERM_CODED) != 0) {
 100078 		goto __204
 100079 	}
 100080 	goto __202
 100081 __204:
 100082 	;
 100083 	if !((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady != uint64(0)) {
 100084 		goto __205
 100085 	}
 100086 
 100087 	goto __202
 100088 __205:
 100089 	;
 100090 	if !(int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&JT_LTORJ != 0) {
 100091 		goto __206
 100092 	}
 100093 	goto __202
 100094 __206:
 100095 	;
 100096 	Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, SQLITE_JUMPIFNULL)
 100097 	*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_CODED)
 100098 	goto __202
 100099 __202:
 100100 	j++
 100101 	pTerm += 48
 100102 	goto __201
 100103 	goto __203
 100104 __203:
 100105 	;
 100106 __200:
 100107 	;
 100108 	return (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady
 100109 }
 100110 
 100111 var aStartOp = [8]U8{
 100112 	U8(0),
 100113 	U8(0),
 100114 	U8(OP_Rewind),
 100115 	U8(OP_Last),
 100116 	U8(OP_SeekGT),
 100117 	U8(OP_SeekLT),
 100118 	U8(OP_SeekGE),
 100119 	U8(OP_SeekLE),
 100120 }
 100121 var aEndOp = [4]U8{
 100122 	U8(OP_IdxGE),
 100123 	U8(OP_IdxGT),
 100124 	U8(OP_IdxLE),
 100125 	U8(OP_IdxLT),
 100126 }
 100127 var aStep = [2]U8{U8(OP_Next), U8(OP_Prev)}
 100128 var aStart = [2]U8{U8(OP_Rewind), U8(OP_Last)}
 100129 
 100130 // Generate the code for the loop that finds all non-matched terms
 100131 // for a RIGHT JOIN.
 100132 func Xsqlite3WhereRightJoinLoop(tls *libc.TLS, pWInfo uintptr, iLevel int32, pLevel uintptr) {
 100133 	bp := tls.Alloc(88)
 100134 	defer tls.Free(88)
 100135 
 100136 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 100137 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 100138 	var pRJ uintptr = (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ
 100139 	var pSubWhere uintptr = uintptr(0)
 100140 	var pWC uintptr = pWInfo + 80
 100141 	var pSubWInfo uintptr
 100142 	var pLoop uintptr = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 100143 	var pTabItem uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 100144 
 100145 	var mAll Bitmask = uint64(0)
 100146 	var k int32
 100147 
 100148 	Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+21848, libc.VaList(bp, (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pTabItem)).FpTab)).FzName))
 100149 
 100150 	for k = 0; k < iLevel; k++ {
 100151 		var iIdxCur int32
 100152 		mAll = mAll | (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pWInfo+760+uintptr(k)*88)).FpWLoop)).FmaskSelf
 100153 		Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pWInfo+760+uintptr(k)*88)).FiTabCur)
 100154 		iIdxCur = (*WhereLevel)(unsafe.Pointer(pWInfo + 760 + uintptr(k)*88)).FiIdxCur
 100155 		if iIdxCur != 0 {
 100156 			Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, iIdxCur)
 100157 		}
 100158 	}
 100159 	if int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&JT_LTORJ == 0 {
 100160 		mAll = mAll | (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf
 100161 		for k = 0; k < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm; k++ {
 100162 			var pTerm uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(k)*48
 100163 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&(TERM_VIRTUAL|TERM_SLICE) != 0 &&
 100164 				int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != WO_ROWVAL {
 100165 				break
 100166 			}
 100167 			if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & ^mAll != 0 {
 100168 				continue
 100169 			}
 100170 			if (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0) {
 100171 				continue
 100172 			}
 100173 			pSubWhere = Xsqlite3ExprAnd(tls, pParse, pSubWhere,
 100174 				Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, 0))
 100175 		}
 100176 	}
 100177 	(*SrcList)(unsafe.Pointer(bp + 8)).FnSrc = 1
 100178 	(*SrcList)(unsafe.Pointer(bp + 8)).FnAlloc = U32(1)
 100179 	libc.Xmemcpy(tls, bp+8+8, pTabItem, uint32(unsafe.Sizeof(SrcItem{})))
 100180 	(*SrcItem)(unsafe.Pointer(bp + 8 + 8)).Ffg.Fjointype = U8(0)
 100181 
 100182 	(*Parse)(unsafe.Pointer(pParse)).FwithinRJSubrtn++
 100183 	pSubWInfo = Xsqlite3WhereBegin(tls, pParse, bp+8, pSubWhere, uintptr(0), uintptr(0), uintptr(0),
 100184 		uint16(WHERE_RIGHT_JOIN), 0)
 100185 	if pSubWInfo != 0 {
 100186 		var iCur int32 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur
 100187 		var r int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 100188 		var nPk int32
 100189 		var jmp int32
 100190 		var addrCont int32 = Xsqlite3WhereContinueLabel(tls, pSubWInfo)
 100191 		var pTab uintptr = (*SrcItem)(unsafe.Pointer(pTabItem)).FpTab
 100192 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) {
 100193 			Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -1, r)
 100194 			nPk = 1
 100195 		} else {
 100196 			var iPk int32
 100197 			var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab)
 100198 			nPk = int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)
 100199 			*(*int32)(unsafe.Pointer(pParse + 44)) += nPk - 1
 100200 			for iPk = 0; iPk < nPk; iPk++ {
 100201 				var iCol int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(iPk)*2)))
 100202 				Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, iCol, r+iPk)
 100203 			}
 100204 		}
 100205 		jmp = Xsqlite3VdbeAddOp4Int(tls, v, OP_Filter, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom, 0, r, nPk)
 100206 
 100207 		Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, addrCont, r, nPk)
 100208 
 100209 		Xsqlite3VdbeJumpHere(tls, v, jmp)
 100210 		Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FaddrSubrtn)
 100211 		Xsqlite3WhereEnd(tls, pSubWInfo)
 100212 	}
 100213 	Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pSubWhere)
 100214 	Xsqlite3VdbeExplainPop(tls, pParse)
 100215 
 100216 	(*Parse)(unsafe.Pointer(pParse)).FwithinRJSubrtn--
 100217 }
 100218 
 100219 func whereOrInfoDelete(tls *libc.TLS, db uintptr, p uintptr) {
 100220 	Xsqlite3WhereClauseClear(tls, p)
 100221 	Xsqlite3DbFree(tls, db, p)
 100222 }
 100223 
 100224 func whereAndInfoDelete(tls *libc.TLS, db uintptr, p uintptr) {
 100225 	Xsqlite3WhereClauseClear(tls, p)
 100226 	Xsqlite3DbFree(tls, db, p)
 100227 }
 100228 
 100229 func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 {
 100230 	var pTerm uintptr
 100231 	var idx int32
 100232 
 100233 	if (*WhereClause)(unsafe.Pointer(pWC)).FnTerm >= (*WhereClause)(unsafe.Pointer(pWC)).FnSlot {
 100234 		var pOld uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 100235 		var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb
 100236 		(*WhereClause)(unsafe.Pointer(pWC)).Fa = Xsqlite3WhereMalloc(tls, (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo, uint64(uint32(unsafe.Sizeof(WhereTerm{}))*uint32((*WhereClause)(unsafe.Pointer(pWC)).FnSlot)*uint32(2)))
 100237 		if (*WhereClause)(unsafe.Pointer(pWC)).Fa == uintptr(0) {
 100238 			if int32(wtFlags)&TERM_DYNAMIC != 0 {
 100239 				Xsqlite3ExprDelete(tls, db, p)
 100240 			}
 100241 			(*WhereClause)(unsafe.Pointer(pWC)).Fa = pOld
 100242 			return 0
 100243 		}
 100244 		libc.Xmemcpy(tls, (*WhereClause)(unsafe.Pointer(pWC)).Fa, pOld, uint32(unsafe.Sizeof(WhereTerm{}))*uint32((*WhereClause)(unsafe.Pointer(pWC)).FnTerm))
 100245 		(*WhereClause)(unsafe.Pointer(pWC)).FnSlot = (*WhereClause)(unsafe.Pointer(pWC)).FnSlot * 2
 100246 	}
 100247 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(libc.AssignInt32(&idx, libc.PostIncInt32(&(*WhereClause)(unsafe.Pointer(pWC)).FnTerm, 1)))*48
 100248 	if int32(wtFlags)&TERM_VIRTUAL == 0 {
 100249 		(*WhereClause)(unsafe.Pointer(pWC)).FnBase = (*WhereClause)(unsafe.Pointer(pWC)).FnTerm
 100250 	}
 100251 	if p != 0 && (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_Unlikely) != U32(0) {
 100252 		(*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = LogEst(int32(Xsqlite3LogEst(tls, uint64((*Expr)(unsafe.Pointer(p)).FiTable))) - 270)
 100253 	} else {
 100254 		(*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(1)
 100255 	}
 100256 	(*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr = Xsqlite3ExprSkipCollateAndLikely(tls, p)
 100257 	(*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags = wtFlags
 100258 	(*WhereTerm)(unsafe.Pointer(pTerm)).FpWC = pWC
 100259 	(*WhereTerm)(unsafe.Pointer(pTerm)).FiParent = -1
 100260 	libc.Xmemset(tls, pTerm+12, 0,
 100261 		uint32(unsafe.Sizeof(WhereTerm{}))-uint32(uintptr(0)+12))
 100262 	return idx
 100263 }
 100264 
 100265 func allowedOp(tls *libc.TLS, op int32) int32 {
 100266 	return libc.Bool32(op == TK_IN || op >= TK_EQ && op <= TK_GE || op == TK_ISNULL || op == TK_IS)
 100267 }
 100268 
 100269 func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 {
 100270 	if int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_VECTOR ||
 100271 		int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fop) == TK_VECTOR ||
 100272 		Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight) != Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) {
 100273 		*(*U32)(unsafe.Pointer(pExpr + 4)) ^= U32(EP_Commuted)
 100274 	}
 100275 	{
 100276 		var t uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight
 100277 		(*Expr)(unsafe.Pointer(pExpr)).FpRight = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
 100278 		(*Expr)(unsafe.Pointer(pExpr)).FpLeft = t
 100279 	}
 100280 
 100281 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) >= TK_GT {
 100282 		(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - TK_GT ^ 2 + TK_GT)
 100283 	}
 100284 	return U16(0)
 100285 }
 100286 
 100287 func operatorMask(tls *libc.TLS, op int32) U16 {
 100288 	var c U16
 100289 
 100290 	if op == TK_IN {
 100291 		c = U16(WO_IN)
 100292 	} else if op == TK_ISNULL {
 100293 		c = U16(WO_ISNULL)
 100294 	} else if op == TK_IS {
 100295 		c = U16(WO_IS)
 100296 	} else {
 100297 		c = U16(int32(WO_EQ) << (op - TK_EQ))
 100298 	}
 100299 
 100300 	return c
 100301 }
 100302 
 100303 func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr, pisComplete uintptr, pnoCase uintptr) int32 {
 100304 	bp := tls.Alloc(16)
 100305 	defer tls.Free(16)
 100306 
 100307 	var z uintptr = uintptr(0)
 100308 	var pRight uintptr
 100309 	var pLeft uintptr
 100310 	var pList uintptr
 100311 	var c U8
 100312 	var cnt int32
 100313 
 100314 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 100315 	var pVal uintptr = uintptr(0)
 100316 	var op int32
 100317 	var rc int32
 100318 
 100319 	if !(Xsqlite3IsLikeFunction(tls, db, pExpr, pnoCase, bp) != 0) {
 100320 		return 0
 100321 	}
 100322 
 100323 	pList = *(*uintptr)(unsafe.Pointer(pExpr + 20))
 100324 	pLeft = (*ExprList_item)(unsafe.Pointer(pList + 8 + 1*20)).FpExpr
 100325 
 100326 	pRight = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer(pList+8)).FpExpr)
 100327 	op = int32((*Expr)(unsafe.Pointer(pRight)).Fop)
 100328 	if op == TK_VARIABLE && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_EnableQPSG) == uint64(0) {
 100329 		var pReprepare uintptr = (*Parse)(unsafe.Pointer(pParse)).FpReprepare
 100330 		var iCol int32 = int32((*Expr)(unsafe.Pointer(pRight)).FiColumn)
 100331 		pVal = Xsqlite3VdbeGetBoundValue(tls, pReprepare, iCol, uint8(SQLITE_AFF_BLOB))
 100332 		if pVal != 0 && Xsqlite3_value_type(tls, pVal) == SQLITE_TEXT {
 100333 			z = Xsqlite3_value_text(tls, pVal)
 100334 		}
 100335 		Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iCol)
 100336 
 100337 	} else if op == TK_STRING {
 100338 		z = *(*uintptr)(unsafe.Pointer(pRight + 8))
 100339 	}
 100340 	if z != 0 {
 100341 		cnt = 0
 100342 		for int32(libc.AssignUint8(&c, *(*U8)(unsafe.Pointer(z + uintptr(cnt))))) != 0 && int32(c) != int32(*(*U8)(unsafe.Pointer(bp))) && int32(c) != int32(*(*U8)(unsafe.Pointer(bp + 1))) && int32(c) != int32(*(*U8)(unsafe.Pointer(bp + 2))) {
 100343 			cnt++
 100344 			if int32(c) == int32(*(*U8)(unsafe.Pointer(bp + 3))) && int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt)))) != 0 {
 100345 				cnt++
 100346 			}
 100347 		}
 100348 
 100349 		if cnt != 0 && 255 != int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt-1)))) && (cnt > 1 || int32(*(*U8)(unsafe.Pointer(z))) != int32(*(*U8)(unsafe.Pointer(bp + 3)))) {
 100350 			var pPrefix uintptr
 100351 
 100352 			*(*int32)(unsafe.Pointer(pisComplete)) = libc.Bool32(int32(c) == int32(*(*U8)(unsafe.Pointer(bp))) && int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt+1)))) == 0)
 100353 
 100354 			pPrefix = Xsqlite3Expr(tls, db, TK_STRING, z)
 100355 			if pPrefix != 0 {
 100356 				var iFrom int32
 100357 				var iTo int32
 100358 				var zNew uintptr
 100359 
 100360 				zNew = *(*uintptr)(unsafe.Pointer(pPrefix + 8))
 100361 				*(*uint8)(unsafe.Pointer(zNew + uintptr(cnt))) = uint8(0)
 100362 				for iFrom = libc.AssignInt32(&iTo, 0); iFrom < cnt; iFrom++ {
 100363 					if int32(*(*uint8)(unsafe.Pointer(zNew + uintptr(iFrom)))) == int32(*(*U8)(unsafe.Pointer(bp + 3))) {
 100364 						iFrom++
 100365 					}
 100366 					*(*uint8)(unsafe.Pointer(zNew + uintptr(libc.PostIncInt32(&iTo, 1)))) = *(*uint8)(unsafe.Pointer(zNew + uintptr(iFrom)))
 100367 				}
 100368 				*(*uint8)(unsafe.Pointer(zNew + uintptr(iTo))) = uint8(0)
 100369 
 100370 				if int32((*Expr)(unsafe.Pointer(pLeft)).Fop) != TK_COLUMN ||
 100371 					int32(Xsqlite3ExprAffinity(tls, pLeft)) != SQLITE_AFF_TEXT ||
 100372 					(*Expr)(unsafe.Pointer(pLeft)).Fflags&U32(EP_WinFunc|EP_Subrtn) == U32(0) &&
 100373 						*(*uintptr)(unsafe.Pointer(pLeft + 44)) != 0 &&
 100374 						int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 44)))).FeTabType) == TABTYP_VTAB {
 100375 					var isNum int32
 100376 
 100377 					isNum = Xsqlite3AtoF(tls, zNew, bp+8, iTo, uint8(SQLITE_UTF8))
 100378 					if isNum <= 0 {
 100379 						if iTo == 1 && int32(*(*uint8)(unsafe.Pointer(zNew))) == '-' {
 100380 							isNum = +1
 100381 						} else {
 100382 							*(*uint8)(unsafe.Pointer(zNew + uintptr(iTo-1)))++
 100383 							isNum = Xsqlite3AtoF(tls, zNew, bp+8, iTo, uint8(SQLITE_UTF8))
 100384 							*(*uint8)(unsafe.Pointer(zNew + uintptr(iTo-1)))--
 100385 						}
 100386 					}
 100387 					if isNum > 0 {
 100388 						Xsqlite3ExprDelete(tls, db, pPrefix)
 100389 						Xsqlite3ValueFree(tls, pVal)
 100390 						return 0
 100391 					}
 100392 				}
 100393 			}
 100394 			*(*uintptr)(unsafe.Pointer(ppPrefix)) = pPrefix
 100395 
 100396 			if op == TK_VARIABLE {
 100397 				var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 100398 				Xsqlite3VdbeSetVarmask(tls, v, int32((*Expr)(unsafe.Pointer(pRight)).FiColumn))
 100399 
 100400 				if *(*int32)(unsafe.Pointer(pisComplete)) != 0 && *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 8)) + 1)) != 0 {
 100401 					var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
 100402 					Xsqlite3ExprCodeTarget(tls, pParse, pRight, r1)
 100403 					Xsqlite3VdbeChangeP3(tls, v, Xsqlite3VdbeCurrentAddr(tls, v)-1, 0)
 100404 					Xsqlite3ReleaseTempReg(tls, pParse, r1)
 100405 				}
 100406 			}
 100407 		} else {
 100408 			z = uintptr(0)
 100409 		}
 100410 	}
 100411 
 100412 	rc = libc.Bool32(z != uintptr(0))
 100413 	Xsqlite3ValueFree(tls, pVal)
 100414 	return rc
 100415 }
 100416 
 100417 func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uintptr, ppLeft uintptr, ppRight uintptr) int32 {
 100418 	bp := tls.Alloc(8)
 100419 	defer tls.Free(8)
 100420 
 100421 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION {
 100422 		var pList uintptr
 100423 		var pCol uintptr
 100424 		var i int32
 100425 
 100426 		pList = *(*uintptr)(unsafe.Pointer(pExpr + 20))
 100427 		if pList == uintptr(0) || (*ExprList)(unsafe.Pointer(pList)).FnExpr != 2 {
 100428 			return 0
 100429 		}
 100430 
 100431 		pCol = (*ExprList_item)(unsafe.Pointer(pList + 8 + 1*20)).FpExpr
 100432 
 100433 		if int32((*Expr)(unsafe.Pointer(pCol)).Fop) == TK_COLUMN && int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 44)))).FeTabType) == TABTYP_VTAB {
 100434 			for i = 0; i < int32(uint32(unsafe.Sizeof(aOp))/uint32(unsafe.Sizeof(Op2{}))); i++ {
 100435 				if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), aOp[i].FzOp) == 0 {
 100436 					*(*uint8)(unsafe.Pointer(peOp2)) = aOp[i].FeOp2
 100437 					*(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer(pList + 8)).FpExpr
 100438 					*(*uintptr)(unsafe.Pointer(ppLeft)) = pCol
 100439 					return 1
 100440 				}
 100441 			}
 100442 		}
 100443 
 100444 		pCol = (*ExprList_item)(unsafe.Pointer(pList + 8)).FpExpr
 100445 
 100446 		if int32((*Expr)(unsafe.Pointer(pCol)).Fop) == TK_COLUMN && int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 44)))).FeTabType) == TABTYP_VTAB {
 100447 			var pVtab uintptr
 100448 			var pMod uintptr
 100449 
 100450 			pVtab = (*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, db, *(*uintptr)(unsafe.Pointer(pCol + 44))))).FpVtab
 100451 
 100452 			pMod = (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule
 100453 			if (*Sqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction != uintptr(0) {
 100454 				i = (*struct {
 100455 					f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32
 100456 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction})).f(tls, pVtab, 2, *(*uintptr)(unsafe.Pointer(pExpr + 8)), bp, bp+4)
 100457 				if i >= SQLITE_INDEX_CONSTRAINT_FUNCTION {
 100458 					*(*uint8)(unsafe.Pointer(peOp2)) = uint8(i)
 100459 					*(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer(pList + 8 + 1*20)).FpExpr
 100460 					*(*uintptr)(unsafe.Pointer(ppLeft)) = pCol
 100461 					return 1
 100462 				}
 100463 			}
 100464 		}
 100465 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NE || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ISNOT || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL {
 100466 		var res int32 = 0
 100467 		var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
 100468 		var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight
 100469 
 100470 		if int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN && int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 44)))).FeTabType) == TABTYP_VTAB {
 100471 			res++
 100472 		}
 100473 
 100474 		if pRight != 0 && (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN && int32((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 44)))).FeTabType) == TABTYP_VTAB) {
 100475 			res++
 100476 			{
 100477 				var t uintptr = pLeft
 100478 				pLeft = pRight
 100479 				pRight = t
 100480 			}
 100481 
 100482 		}
 100483 		*(*uintptr)(unsafe.Pointer(ppLeft)) = pLeft
 100484 		*(*uintptr)(unsafe.Pointer(ppRight)) = pRight
 100485 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NE {
 100486 			*(*uint8)(unsafe.Pointer(peOp2)) = uint8(SQLITE_INDEX_CONSTRAINT_NE)
 100487 		}
 100488 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ISNOT {
 100489 			*(*uint8)(unsafe.Pointer(peOp2)) = uint8(SQLITE_INDEX_CONSTRAINT_ISNOT)
 100490 		}
 100491 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL {
 100492 			*(*uint8)(unsafe.Pointer(peOp2)) = uint8(SQLITE_INDEX_CONSTRAINT_ISNOTNULL)
 100493 		}
 100494 		return res
 100495 	}
 100496 	return 0
 100497 }
 100498 
 100499 type Op2 = struct {
 100500 	FzOp         uintptr
 100501 	FeOp2        uint8
 100502 	F__ccgo_pad1 [3]byte
 100503 }
 100504 
 100505 var aOp = [4]Op2{
 100506 	{FzOp: ts + 16116, FeOp2: uint8(SQLITE_INDEX_CONSTRAINT_MATCH)},
 100507 	{FzOp: ts + 15447, FeOp2: uint8(SQLITE_INDEX_CONSTRAINT_GLOB)},
 100508 	{FzOp: ts + 14967, FeOp2: uint8(SQLITE_INDEX_CONSTRAINT_LIKE)},
 100509 	{FzOp: ts + 21862, FeOp2: uint8(SQLITE_INDEX_CONSTRAINT_REGEXP)},
 100510 }
 100511 
 100512 func transferJoinMarkings(tls *libc.TLS, pDerived uintptr, pBase uintptr) {
 100513 	if pDerived != 0 && (*Expr)(unsafe.Pointer(pBase)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0) {
 100514 		*(*U32)(unsafe.Pointer(pDerived + 4)) |= (*Expr)(unsafe.Pointer(pBase)).Fflags & U32(EP_OuterON|EP_InnerON)
 100515 		*(*int32)(unsafe.Pointer(pDerived + 36)) = *(*int32)(unsafe.Pointer(pBase + 36))
 100516 	}
 100517 }
 100518 
 100519 func markTermAsChild(tls *libc.TLS, pWC uintptr, iChild int32, iParent int32) {
 100520 	(*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iChild)*48)).FiParent = iParent
 100521 	(*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iChild)*48)).FtruthProb = (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(iParent)*48)).FtruthProb
 100522 	(*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iParent)*48)).FnChild++
 100523 }
 100524 
 100525 func whereNthSubterm(tls *libc.TLS, pTerm uintptr, N int32) uintptr {
 100526 	if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != WO_AND {
 100527 		if N == 0 {
 100528 			return pTerm
 100529 		}
 100530 		return uintptr(0)
 100531 	}
 100532 	if N < (*WhereAndInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 24)))).Fwc.FnTerm {
 100533 		return (*WhereAndInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 24)))).Fwc.Fa + uintptr(N)*48
 100534 	}
 100535 	return uintptr(0)
 100536 }
 100537 
 100538 func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintptr, pTwo uintptr) {
 100539 	var eOp U16 = U16(int32((*WhereTerm)(unsafe.Pointer(pOne)).FeOperator) | int32((*WhereTerm)(unsafe.Pointer(pTwo)).FeOperator))
 100540 	var db uintptr
 100541 	var pNew uintptr
 100542 	var op int32
 100543 	var idxNew int32
 100544 
 100545 	if (int32((*WhereTerm)(unsafe.Pointer(pOne)).FwtFlags)|int32((*WhereTerm)(unsafe.Pointer(pTwo)).FwtFlags))&TERM_VNULL != 0 {
 100546 		return
 100547 	}
 100548 	if int32((*WhereTerm)(unsafe.Pointer(pOne)).FeOperator)&(WO_EQ|int32(WO_EQ)<<(TK_LT-TK_EQ)|int32(WO_EQ)<<(TK_LE-TK_EQ)|int32(WO_EQ)<<(TK_GT-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) == 0 {
 100549 		return
 100550 	}
 100551 	if int32((*WhereTerm)(unsafe.Pointer(pTwo)).FeOperator)&(WO_EQ|int32(WO_EQ)<<(TK_LT-TK_EQ)|int32(WO_EQ)<<(TK_LE-TK_EQ)|int32(WO_EQ)<<(TK_GT-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) == 0 {
 100552 		return
 100553 	}
 100554 	if int32(eOp)&(WO_EQ|int32(WO_EQ)<<(TK_LT-TK_EQ)|int32(WO_EQ)<<(TK_LE-TK_EQ)) != int32(eOp) &&
 100555 		int32(eOp)&(WO_EQ|int32(WO_EQ)<<(TK_GT-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) != int32(eOp) {
 100556 		return
 100557 	}
 100558 
 100559 	if Xsqlite3ExprCompare(tls, uintptr(0), (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOne)).FpExpr)).FpLeft, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTwo)).FpExpr)).FpLeft, -1) != 0 {
 100560 		return
 100561 	}
 100562 	if Xsqlite3ExprCompare(tls, uintptr(0), (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOne)).FpExpr)).FpRight, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTwo)).FpExpr)).FpRight, -1) != 0 {
 100563 		return
 100564 	}
 100565 
 100566 	if int32(eOp)&(int32(eOp)-1) != 0 {
 100567 		if int32(eOp)&(int32(WO_EQ)<<(TK_LT-TK_EQ)|int32(WO_EQ)<<(TK_LE-TK_EQ)) != 0 {
 100568 			eOp = U16(int32(WO_EQ) << (TK_LE - TK_EQ))
 100569 		} else {
 100570 			eOp = U16(int32(WO_EQ) << (TK_GE - TK_EQ))
 100571 		}
 100572 	}
 100573 	db = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb
 100574 	pNew = Xsqlite3ExprDup(tls, db, (*WhereTerm)(unsafe.Pointer(pOne)).FpExpr, 0)
 100575 	if pNew == uintptr(0) {
 100576 		return
 100577 	}
 100578 	for op = TK_EQ; int32(eOp) != int32(WO_EQ)<<(op-TK_EQ); op++ {
 100579 	}
 100580 	(*Expr)(unsafe.Pointer(pNew)).Fop = U8(op)
 100581 	idxNew = whereClauseInsert(tls, pWC, pNew, uint16(TERM_VIRTUAL|TERM_DYNAMIC))
 100582 	exprAnalyze(tls, pSrc, pWC, idxNew)
 100583 }
 100584 
 100585 func exprAnalyzeOrTerm(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) {
 100586 	var pWInfo uintptr = (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo
 100587 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 100588 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 100589 	var pTerm uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 100590 	var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 100591 	var i int32
 100592 	var pOrWc uintptr
 100593 	var pOrTerm uintptr
 100594 	var pOrInfo uintptr
 100595 	var chngToIN Bitmask
 100596 	var indexable Bitmask
 100597 
 100598 	*(*uintptr)(unsafe.Pointer(pTerm + 24)) = libc.AssignUintptr(&pOrInfo, Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(WhereOrInfo{}))))
 100599 	if pOrInfo == uintptr(0) {
 100600 		return
 100601 	}
 100602 	*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_ORINFO)
 100603 	pOrWc = pOrInfo
 100604 	libc.Xmemset(tls, pOrWc+32, 0, uint32(unsafe.Sizeof([8]WhereTerm{})))
 100605 	Xsqlite3WhereClauseInit(tls, pOrWc, pWInfo)
 100606 	Xsqlite3WhereSplit(tls, pOrWc, pExpr, uint8(TK_OR))
 100607 	Xsqlite3WhereExprAnalyze(tls, pSrc, pOrWc)
 100608 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 100609 		return
 100610 	}
 100611 
 100612 	indexable = libc.CplUint64(uint64(0))
 100613 	chngToIN = libc.CplUint64(uint64(0))
 100614 	i = (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1
 100615 	pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa
 100616 __1:
 100617 	if !(i >= 0 && indexable != 0) {
 100618 		goto __3
 100619 	}
 100620 	{
 100621 		if int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&WO_SINGLE == 0 {
 100622 			var pAndInfo uintptr
 100623 
 100624 			chngToIN = uint64(0)
 100625 			pAndInfo = Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(WhereAndInfo{})))
 100626 			if pAndInfo != 0 {
 100627 				var pAndWC uintptr
 100628 				var pAndTerm uintptr
 100629 				var j int32
 100630 				var b Bitmask = uint64(0)
 100631 				*(*uintptr)(unsafe.Pointer(pOrTerm + 24)) = pAndInfo
 100632 				*(*U16)(unsafe.Pointer(pOrTerm + 10)) |= U16(TERM_ANDINFO)
 100633 				(*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = U16(WO_AND)
 100634 				(*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor = -1
 100635 				pAndWC = pAndInfo
 100636 				libc.Xmemset(tls, pAndWC+32, 0, uint32(unsafe.Sizeof([8]WhereTerm{})))
 100637 				Xsqlite3WhereClauseInit(tls, pAndWC, (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)
 100638 				Xsqlite3WhereSplit(tls, pAndWC, (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, uint8(TK_AND))
 100639 				Xsqlite3WhereExprAnalyze(tls, pSrc, pAndWC)
 100640 				(*WhereClause)(unsafe.Pointer(pAndWC)).FpOuter = pWC
 100641 				if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
 100642 					j = 0
 100643 					pAndTerm = (*WhereClause)(unsafe.Pointer(pAndWC)).Fa
 100644 				__4:
 100645 					if !(j < (*WhereClause)(unsafe.Pointer(pAndWC)).FnTerm) {
 100646 						goto __6
 100647 					}
 100648 					{
 100649 						if allowedOp(tls, int32((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAndTerm)).FpExpr)).Fop)) != 0 ||
 100650 							int32((*WhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == WO_AUX {
 100651 							b = b | Xsqlite3WhereGetMask(tls, pWInfo+496, (*WhereTerm)(unsafe.Pointer(pAndTerm)).FleftCursor)
 100652 						}
 100653 
 100654 					}
 100655 					goto __5
 100656 				__5:
 100657 					j++
 100658 					pAndTerm += 48
 100659 					goto __4
 100660 					goto __6
 100661 				__6:
 100662 				}
 100663 				indexable = indexable & b
 100664 			}
 100665 		} else if int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&TERM_COPIED != 0 {
 100666 		} else {
 100667 			var b Bitmask
 100668 			b = Xsqlite3WhereGetMask(tls, pWInfo+496, (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor)
 100669 			if int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&TERM_VIRTUAL != 0 {
 100670 				var pOther uintptr = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr((*WhereTerm)(unsafe.Pointer(pOrTerm)).FiParent)*48
 100671 				b = b | Xsqlite3WhereGetMask(tls, pWInfo+496, (*WhereTerm)(unsafe.Pointer(pOther)).FleftCursor)
 100672 			}
 100673 			indexable = indexable & b
 100674 			if int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&WO_EQ == 0 {
 100675 				chngToIN = uint64(0)
 100676 			} else {
 100677 				chngToIN = chngToIN & b
 100678 			}
 100679 		}
 100680 
 100681 	}
 100682 	goto __2
 100683 __2:
 100684 	i--
 100685 	pOrTerm += 48
 100686 	goto __1
 100687 	goto __3
 100688 __3:
 100689 	;
 100690 	(*WhereOrInfo)(unsafe.Pointer(pOrInfo)).Findexable = indexable
 100691 	(*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(WO_OR)
 100692 	(*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -1
 100693 	if indexable != 0 {
 100694 		(*WhereClause)(unsafe.Pointer(pWC)).FhasOr = U8(1)
 100695 	}
 100696 
 100697 	if indexable != 0 && (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm == 2 {
 100698 		var iOne int32 = 0
 100699 		var pOne uintptr
 100700 		for libc.AssignUintptr(&pOne, whereNthSubterm(tls, (*WhereClause)(unsafe.Pointer(pOrWc)).Fa, libc.PostIncInt32(&iOne, 1))) != uintptr(0) {
 100701 			var iTwo int32 = 0
 100702 			var pTwo uintptr
 100703 			for libc.AssignUintptr(&pTwo, whereNthSubterm(tls, (*WhereClause)(unsafe.Pointer(pOrWc)).Fa+1*48, libc.PostIncInt32(&iTwo, 1))) != uintptr(0) {
 100704 				whereCombineDisjuncts(tls, pSrc, pWC, pOne, pTwo)
 100705 			}
 100706 		}
 100707 	}
 100708 
 100709 	if chngToIN != 0 {
 100710 		var okToChngToIN int32 = 0
 100711 		var iColumn int32 = -1
 100712 		var iCursor int32 = -1
 100713 		var j int32 = 0
 100714 
 100715 		for j = 0; j < 2 && !(okToChngToIN != 0); j++ {
 100716 			var pLeft uintptr = uintptr(0)
 100717 			pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa
 100718 			i = (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1
 100719 		__7:
 100720 			if !(i >= 0) {
 100721 				goto __9
 100722 			}
 100723 			{
 100724 				*(*U16)(unsafe.Pointer(pOrTerm + 10)) &= libc.Uint16FromInt32(libc.CplInt32(TERM_OK))
 100725 				if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCursor {
 100726 					goto __8
 100727 				}
 100728 				if chngToIN&Xsqlite3WhereGetMask(tls, pWInfo+496,
 100729 					(*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) == uint64(0) {
 100730 					goto __8
 100731 				}
 100732 
 100733 				iColumn = *(*int32)(unsafe.Pointer(pOrTerm + 24))
 100734 				iCursor = (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor
 100735 				pLeft = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft
 100736 				goto __9
 100737 
 100738 			}
 100739 			goto __8
 100740 		__8:
 100741 			i--
 100742 			pOrTerm += 48
 100743 			goto __7
 100744 			goto __9
 100745 		__9:
 100746 			;
 100747 			if i < 0 {
 100748 				break
 100749 			}
 100750 
 100751 			okToChngToIN = 1
 100752 		__10:
 100753 			if !(i >= 0 && okToChngToIN != 0) {
 100754 				goto __12
 100755 			}
 100756 			{
 100757 				if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor != iCursor {
 100758 					*(*U16)(unsafe.Pointer(pOrTerm + 10)) &= libc.Uint16FromInt32(libc.CplInt32(TERM_OK))
 100759 				} else if *(*int32)(unsafe.Pointer(pOrTerm + 24)) != iColumn || iColumn == -2 &&
 100760 					Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft, pLeft, -1) != 0 {
 100761 					okToChngToIN = 0
 100762 				} else {
 100763 					var affLeft int32
 100764 					var affRight int32
 100765 
 100766 					affRight = int32(Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight))
 100767 					affLeft = int32(Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft))
 100768 					if affRight != 0 && affRight != affLeft {
 100769 						okToChngToIN = 0
 100770 					} else {
 100771 						*(*U16)(unsafe.Pointer(pOrTerm + 10)) |= U16(TERM_OK)
 100772 					}
 100773 				}
 100774 
 100775 			}
 100776 			goto __11
 100777 		__11:
 100778 			i--
 100779 			pOrTerm += 48
 100780 			goto __10
 100781 			goto __12
 100782 		__12:
 100783 		}
 100784 
 100785 		if okToChngToIN != 0 {
 100786 			var pDup uintptr
 100787 			var pList uintptr = uintptr(0)
 100788 			var pLeft uintptr = uintptr(0)
 100789 			var pNew uintptr
 100790 
 100791 			i = (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1
 100792 			pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa
 100793 		__13:
 100794 			if !(i >= 0) {
 100795 				goto __15
 100796 			}
 100797 			{
 100798 				if int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags)&TERM_OK == 0 {
 100799 					goto __14
 100800 				}
 100801 
 100802 				pDup = Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpRight, 0)
 100803 				pList = Xsqlite3ExprListAppend(tls, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse, pList, pDup)
 100804 				pLeft = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft
 100805 
 100806 			}
 100807 			goto __14
 100808 		__14:
 100809 			i--
 100810 			pOrTerm += 48
 100811 			goto __13
 100812 			goto __15
 100813 		__15:
 100814 			;
 100815 			pDup = Xsqlite3ExprDup(tls, db, pLeft, 0)
 100816 			pNew = Xsqlite3PExpr(tls, pParse, TK_IN, pDup, uintptr(0))
 100817 			if pNew != 0 {
 100818 				var idxNew int32
 100819 				transferJoinMarkings(tls, pNew, pExpr)
 100820 
 100821 				*(*uintptr)(unsafe.Pointer(pNew + 20)) = pList
 100822 				idxNew = whereClauseInsert(tls, pWC, pNew, uint16(TERM_VIRTUAL|TERM_DYNAMIC))
 100823 
 100824 				exprAnalyze(tls, pSrc, pWC, idxNew)
 100825 
 100826 				markTermAsChild(tls, pWC, idxNew, idxTerm)
 100827 			} else {
 100828 				Xsqlite3ExprListDelete(tls, db, pList)
 100829 			}
 100830 		}
 100831 	}
 100832 }
 100833 
 100834 func termIsEquivalence(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 {
 100835 	var aff1 uint8
 100836 	var aff2 uint8
 100837 	var pColl uintptr
 100838 	if !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_Transitive) == U32(0)) {
 100839 		return 0
 100840 	}
 100841 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_EQ && int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_IS {
 100842 		return 0
 100843 	}
 100844 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) {
 100845 		return 0
 100846 	}
 100847 	aff1 = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
 100848 	aff2 = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
 100849 	if int32(aff1) != int32(aff2) &&
 100850 		(!(int32(aff1) >= SQLITE_AFF_NUMERIC) || !(int32(aff2) >= SQLITE_AFF_NUMERIC)) {
 100851 		return 0
 100852 	}
 100853 	pColl = Xsqlite3ExprCompareCollSeq(tls, pParse, pExpr)
 100854 	if Xsqlite3IsBinary(tls, pColl) != 0 {
 100855 		return 1
 100856 	}
 100857 	return Xsqlite3ExprCollSeqMatch(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
 100858 }
 100859 
 100860 func exprSelectUsage(tls *libc.TLS, pMaskSet uintptr, pS uintptr) Bitmask {
 100861 	var mask Bitmask = uint64(0)
 100862 	for pS != 0 {
 100863 		var pSrc uintptr = (*Select)(unsafe.Pointer(pS)).FpSrc
 100864 		mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Select)(unsafe.Pointer(pS)).FpEList)
 100865 		mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Select)(unsafe.Pointer(pS)).FpGroupBy)
 100866 		mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Select)(unsafe.Pointer(pS)).FpOrderBy)
 100867 		mask = mask | Xsqlite3WhereExprUsage(tls, pMaskSet, (*Select)(unsafe.Pointer(pS)).FpWhere)
 100868 		mask = mask | Xsqlite3WhereExprUsage(tls, pMaskSet, (*Select)(unsafe.Pointer(pS)).FpHaving)
 100869 		if pSrc != uintptr(0) {
 100870 			var i int32
 100871 			for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ {
 100872 				mask = mask | exprSelectUsage(tls, pMaskSet, (*SrcItem)(unsafe.Pointer(pSrc+8+uintptr(i)*72)).FpSelect)
 100873 				if int32(*(*uint16)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 36 + 4))&0x400>>10) == 0 {
 100874 					mask = mask | Xsqlite3WhereExprUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 48)))
 100875 				}
 100876 				if uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 36 + 4))&0x4>>2)) != 0 {
 100877 					mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(i)*72 + 64)))
 100878 				}
 100879 			}
 100880 		}
 100881 		pS = (*Select)(unsafe.Pointer(pS)).FpPrior
 100882 	}
 100883 	return mask
 100884 }
 100885 
 100886 func exprMightBeIndexed2(tls *libc.TLS, pFrom uintptr, aiCurCol uintptr, pExpr uintptr, j int32) int32 {
 100887 	var pIdx uintptr
 100888 	var i int32
 100889 	var iCur int32
 100890 	for __ccgo := true; __ccgo; __ccgo = libc.PreIncInt32(&j, 1) < (*SrcList)(unsafe.Pointer(pFrom)).FnSrc {
 100891 		iCur = (*SrcItem)(unsafe.Pointer(pFrom + 8 + uintptr(j)*72)).FiCursor
 100892 		for pIdx = (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pFrom + 8 + uintptr(j)*72)).FpTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
 100893 			if (*Index)(unsafe.Pointer(pIdx)).FaColExpr == uintptr(0) {
 100894 				continue
 100895 			}
 100896 			for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ {
 100897 				if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) != -2 {
 100898 					continue
 100899 				}
 100900 
 100901 				if Xsqlite3ExprCompareSkip(tls, pExpr, (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8+uintptr(i)*20)).FpExpr, iCur) == 0 &&
 100902 					int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_STRING {
 100903 					*(*int32)(unsafe.Pointer(aiCurCol)) = iCur
 100904 					*(*int32)(unsafe.Pointer(aiCurCol + 1*4)) = -2
 100905 					return 1
 100906 				}
 100907 			}
 100908 		}
 100909 	}
 100910 	return 0
 100911 }
 100912 
 100913 func exprMightBeIndexed(tls *libc.TLS, pFrom uintptr, aiCurCol uintptr, pExpr uintptr, op int32) int32 {
 100914 	var i int32
 100915 
 100916 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VECTOR && (op >= TK_GT && op <= TK_GE) {
 100917 		pExpr = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)) + 8)).FpExpr
 100918 	}
 100919 
 100920 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN {
 100921 		*(*int32)(unsafe.Pointer(aiCurCol)) = (*Expr)(unsafe.Pointer(pExpr)).FiTable
 100922 		*(*int32)(unsafe.Pointer(aiCurCol + 1*4)) = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
 100923 		return 1
 100924 	}
 100925 
 100926 	for i = 0; i < (*SrcList)(unsafe.Pointer(pFrom)).FnSrc; i++ {
 100927 		var pIdx uintptr
 100928 		for pIdx = (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pFrom + 8 + uintptr(i)*72)).FpTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
 100929 			if (*Index)(unsafe.Pointer(pIdx)).FaColExpr != 0 {
 100930 				return exprMightBeIndexed2(tls, pFrom, aiCurCol, pExpr, i)
 100931 			}
 100932 		}
 100933 	}
 100934 	return 0
 100935 }
 100936 
 100937 func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) {
 100938 	bp := tls.Alloc(32)
 100939 	defer tls.Free(32)
 100940 
 100941 	var pWInfo uintptr = (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo
 100942 	var pTerm uintptr
 100943 	var pMaskSet uintptr
 100944 	var pExpr uintptr
 100945 	var prereqLeft Bitmask
 100946 	var prereqAll Bitmask
 100947 	var extraRight Bitmask = uint64(0)
 100948 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 100949 	*(*int32)(unsafe.Pointer(bp + 12)) = 0
 100950 	*(*int32)(unsafe.Pointer(bp + 16)) = 0
 100951 	var op int32
 100952 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 100953 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 100954 	*(*uint8)(unsafe.Pointer(bp + 20)) = uint8(0)
 100955 	var nLeft int32
 100956 
 100957 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 100958 		return
 100959 	}
 100960 
 100961 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 100962 	pMaskSet = pWInfo + 496
 100963 	pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 100964 
 100965 	(*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 0
 100966 	prereqLeft = Xsqlite3WhereExprUsage(tls, pMaskSet, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
 100967 	op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop)
 100968 	if op == TK_IN {
 100969 		if Xsqlite3ExprCheckIN(tls, pParse, pExpr) != 0 {
 100970 			return
 100971 		}
 100972 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
 100973 			(*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 20)))
 100974 		} else {
 100975 			(*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 20)))
 100976 		}
 100977 		prereqAll = prereqLeft | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight
 100978 	} else {
 100979 		(*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = Xsqlite3WhereExprUsage(tls, pMaskSet, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
 100980 		if (*Expr)(unsafe.Pointer(pExpr)).FpLeft == uintptr(0) ||
 100981 			(*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect|EP_IfNullRow) != U32(0) ||
 100982 			*(*uintptr)(unsafe.Pointer(pExpr + 20)) != uintptr(0) {
 100983 			prereqAll = Xsqlite3WhereExprUsageNN(tls, pMaskSet, pExpr)
 100984 		} else {
 100985 			prereqAll = prereqLeft | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight
 100986 		}
 100987 	}
 100988 	if (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect != 0 {
 100989 		*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_VARSELECT)
 100990 	}
 100991 
 100992 	if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0) {
 100993 		var x Bitmask = Xsqlite3WhereGetMask(tls, pMaskSet, *(*int32)(unsafe.Pointer(pExpr + 36)))
 100994 		if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) {
 100995 			prereqAll = prereqAll | x
 100996 			extraRight = x - uint64(1)
 100997 
 100998 			if prereqAll>>1 >= x {
 100999 				Xsqlite3ErrorMsg(tls, pParse, ts+21869, 0)
 101000 				return
 101001 			}
 101002 		} else if prereqAll>>1 >= x {
 101003 			if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 0 && int32((*SrcItem)(unsafe.Pointer(pSrc+8)).Ffg.Fjointype)&JT_LTORJ != 0 {
 101004 				Xsqlite3ErrorMsg(tls, pParse, ts+21869, 0)
 101005 				return
 101006 			}
 101007 			*(*U32)(unsafe.Pointer(pExpr + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_InnerON))
 101008 		}
 101009 	}
 101010 	(*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = prereqAll
 101011 	(*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = -1
 101012 	(*WhereTerm)(unsafe.Pointer(pTerm)).FiParent = -1
 101013 	(*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0)
 101014 	if allowedOp(tls, op) != 0 {
 101015 		var pLeft uintptr = Xsqlite3ExprSkipCollate(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)
 101016 		var pRight uintptr = Xsqlite3ExprSkipCollate(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight)
 101017 		var opMask U16
 101018 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&prereqLeft == uint64(0) {
 101019 			opMask = uint16(WO_ALL)
 101020 		} else {
 101021 			opMask = uint16(WO_EQUIV)
 101022 		}
 101023 
 101024 		if *(*int32)(unsafe.Pointer(pTerm + 24 + 4)) > 0 {
 101025 			pLeft = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 20)) + 8 + uintptr(*(*int32)(unsafe.Pointer(pTerm + 24 + 4))-1)*20)).FpExpr
 101026 		}
 101027 
 101028 		if exprMightBeIndexed(tls, pSrc, bp, pLeft, op) != 0 {
 101029 			(*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = *(*int32)(unsafe.Pointer(bp))
 101030 
 101031 			*(*int32)(unsafe.Pointer(pTerm + 24)) = *(*int32)(unsafe.Pointer(bp + 1*4))
 101032 			(*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(int32(operatorMask(tls, op)) & int32(opMask))
 101033 		}
 101034 		if op == TK_IS {
 101035 			*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_IS)
 101036 		}
 101037 		if pRight != 0 &&
 101038 			exprMightBeIndexed(tls, pSrc, bp, pRight, op) != 0 &&
 101039 			!((*Expr)(unsafe.Pointer(pRight)).Fflags&U32(EP_FixedCol) != U32(0)) {
 101040 			var pNew uintptr
 101041 			var pDup uintptr
 101042 			var eExtraOp U16 = U16(0)
 101043 
 101044 			if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor >= 0 {
 101045 				var idxNew int32
 101046 				pDup = Xsqlite3ExprDup(tls, db, pExpr, 0)
 101047 				if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 101048 					Xsqlite3ExprDelete(tls, db, pDup)
 101049 					return
 101050 				}
 101051 				idxNew = whereClauseInsert(tls, pWC, pDup, uint16(TERM_VIRTUAL|TERM_DYNAMIC))
 101052 				if idxNew == 0 {
 101053 					return
 101054 				}
 101055 				pNew = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*48
 101056 				markTermAsChild(tls, pWC, idxNew, idxTerm)
 101057 				if op == TK_IS {
 101058 					*(*U16)(unsafe.Pointer(pNew + 10)) |= U16(TERM_IS)
 101059 				}
 101060 				pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101061 				*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_COPIED)
 101062 
 101063 				if termIsEquivalence(tls, pParse, pDup) != 0 {
 101064 					*(*U16)(unsafe.Pointer(pTerm + 12)) |= U16(WO_EQUIV)
 101065 					eExtraOp = U16(WO_EQUIV)
 101066 				}
 101067 			} else {
 101068 				pDup = pExpr
 101069 				pNew = pTerm
 101070 			}
 101071 			*(*U16)(unsafe.Pointer(pNew + 10)) |= U16(int32(exprCommute(tls, pParse, pDup)))
 101072 			(*WhereTerm)(unsafe.Pointer(pNew)).FleftCursor = *(*int32)(unsafe.Pointer(bp))
 101073 
 101074 			*(*int32)(unsafe.Pointer(pNew + 24)) = *(*int32)(unsafe.Pointer(bp + 1*4))
 101075 
 101076 			(*WhereTerm)(unsafe.Pointer(pNew)).FprereqRight = prereqLeft | extraRight
 101077 			(*WhereTerm)(unsafe.Pointer(pNew)).FprereqAll = prereqAll
 101078 			(*WhereTerm)(unsafe.Pointer(pNew)).FeOperator = U16((int32(operatorMask(tls, int32((*Expr)(unsafe.Pointer(pDup)).Fop))) + int32(eExtraOp)) & int32(opMask))
 101079 		} else if op == TK_ISNULL &&
 101080 			!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0)) &&
 101081 			0 == Xsqlite3ExprCanBeNull(tls, pLeft) {
 101082 			(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_TRUEFALSE)
 101083 			*(*uintptr)(unsafe.Pointer(pExpr + 8)) = ts + 7699
 101084 			*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_IsFalse)
 101085 			(*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll = uint64(0)
 101086 			(*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0)
 101087 		}
 101088 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_BETWEEN && int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND {
 101089 		var pList uintptr
 101090 		var i int32
 101091 
 101092 		pList = *(*uintptr)(unsafe.Pointer(pExpr + 20))
 101093 
 101094 		for i = 0; i < 2; i++ {
 101095 			var pNewExpr uintptr
 101096 			var idxNew int32
 101097 			pNewExpr = Xsqlite3PExpr(tls, pParse, int32(ops[i]),
 101098 				Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0),
 101099 				Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr, 0))
 101100 			transferJoinMarkings(tls, pNewExpr, pExpr)
 101101 			idxNew = whereClauseInsert(tls, pWC, pNewExpr, uint16(TERM_VIRTUAL|TERM_DYNAMIC))
 101102 
 101103 			exprAnalyze(tls, pSrc, pWC, idxNew)
 101104 			pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101105 			markTermAsChild(tls, pWC, idxNew, idxTerm)
 101106 		}
 101107 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_OR {
 101108 		exprAnalyzeOrTerm(tls, pSrc, pWC, idxTerm)
 101109 		pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101110 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL {
 101111 		if int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_COLUMN &&
 101112 			int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).FiColumn) >= 0 &&
 101113 			!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0)) {
 101114 			var pNewExpr uintptr
 101115 			var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft
 101116 			var idxNew int32
 101117 			var pNewTerm uintptr
 101118 
 101119 			pNewExpr = Xsqlite3PExpr(tls, pParse, TK_GT,
 101120 				Xsqlite3ExprDup(tls, db, pLeft, 0),
 101121 				Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0))
 101122 
 101123 			idxNew = whereClauseInsert(tls, pWC, pNewExpr,
 101124 				uint16(TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL))
 101125 			if idxNew != 0 {
 101126 				pNewTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*48
 101127 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = uint64(0)
 101128 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*Expr)(unsafe.Pointer(pLeft)).FiTable
 101129 				*(*int32)(unsafe.Pointer(pNewTerm + 24)) = int32((*Expr)(unsafe.Pointer(pLeft)).FiColumn)
 101130 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = U16(int32(WO_EQ) << (TK_GT - TK_EQ))
 101131 				markTermAsChild(tls, pWC, idxNew, idxTerm)
 101132 				pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101133 				*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_COPIED)
 101134 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll
 101135 			}
 101136 		}
 101137 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION &&
 101138 		int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND &&
 101139 		isLikeOrGlob(tls, pParse, pExpr, bp+8, bp+12, bp+16) != 0 {
 101140 		var pLeft uintptr
 101141 		var pStr2 uintptr
 101142 		var pNewExpr1 uintptr
 101143 		var pNewExpr2 uintptr
 101144 		var idxNew1 int32
 101145 		var idxNew2 int32
 101146 		var zCollSeqName uintptr
 101147 		var wtFlags U16 = U16(TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC)
 101148 
 101149 		pLeft = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)) + 8 + 1*20)).FpExpr
 101150 		pStr2 = Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8)), 0)
 101151 
 101152 		if *(*int32)(unsafe.Pointer(bp + 16)) != 0 && !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) {
 101153 			var i int32
 101154 			var c uint8
 101155 			*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_LIKE)
 101156 			for i = 0; int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 8)) + uintptr(i))))) != 0; i++ {
 101157 				*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)) + 8)) + uintptr(i))) = uint8(int32(c) & ^(int32(Xsqlite3CtypeMap[c]) & 0x20))
 101158 				*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(i))) = Xsqlite3UpperToLower[c]
 101159 			}
 101160 		}
 101161 
 101162 		if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
 101163 			var c U8
 101164 			var pC uintptr
 101165 			pC = *(*uintptr)(unsafe.Pointer(pStr2 + 8)) + uintptr(Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pStr2 + 8)))-1)
 101166 			c = *(*U8)(unsafe.Pointer(pC))
 101167 			if *(*int32)(unsafe.Pointer(bp + 16)) != 0 {
 101168 				if int32(c) == 'A'-1 {
 101169 					*(*int32)(unsafe.Pointer(bp + 12)) = 0
 101170 				}
 101171 				c = Xsqlite3UpperToLower[c]
 101172 			}
 101173 			*(*U8)(unsafe.Pointer(pC)) = U8(int32(c) + 1)
 101174 		}
 101175 		zCollSeqName = func() uintptr {
 101176 			if *(*int32)(unsafe.Pointer(bp + 16)) != 0 {
 101177 				return ts + 21910
 101178 			}
 101179 			return uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 101180 		}()
 101181 		pNewExpr1 = Xsqlite3ExprDup(tls, db, pLeft, 0)
 101182 		pNewExpr1 = Xsqlite3PExpr(tls, pParse, TK_GE,
 101183 			Xsqlite3ExprAddCollateString(tls, pParse, pNewExpr1, zCollSeqName),
 101184 			*(*uintptr)(unsafe.Pointer(bp + 8)))
 101185 		transferJoinMarkings(tls, pNewExpr1, pExpr)
 101186 		idxNew1 = whereClauseInsert(tls, pWC, pNewExpr1, wtFlags)
 101187 
 101188 		pNewExpr2 = Xsqlite3ExprDup(tls, db, pLeft, 0)
 101189 		pNewExpr2 = Xsqlite3PExpr(tls, pParse, TK_LT,
 101190 			Xsqlite3ExprAddCollateString(tls, pParse, pNewExpr2, zCollSeqName),
 101191 			pStr2)
 101192 		transferJoinMarkings(tls, pNewExpr2, pExpr)
 101193 		idxNew2 = whereClauseInsert(tls, pWC, pNewExpr2, wtFlags)
 101194 
 101195 		exprAnalyze(tls, pSrc, pWC, idxNew1)
 101196 		exprAnalyze(tls, pSrc, pWC, idxNew2)
 101197 		pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101198 		if *(*int32)(unsafe.Pointer(bp + 12)) != 0 {
 101199 			markTermAsChild(tls, pWC, idxNew1, idxTerm)
 101200 			markTermAsChild(tls, pWC, idxNew2, idxTerm)
 101201 		}
 101202 	}
 101203 
 101204 	if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_EQ || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS) &&
 101205 		libc.AssignInt32(&nLeft, Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)) > 1 &&
 101206 		Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) == nLeft &&
 101207 		((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags&U32(EP_xIsSelect) == U32(0) ||
 101208 			(*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fflags&U32(EP_xIsSelect) == U32(0)) &&
 101209 		int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND {
 101210 		var i int32
 101211 		for i = 0; i < nLeft; i++ {
 101212 			var idxNew int32
 101213 			var pNew uintptr
 101214 			var pLeft uintptr = Xsqlite3ExprForVectorField(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, i, nLeft)
 101215 			var pRight uintptr = Xsqlite3ExprForVectorField(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, i, nLeft)
 101216 
 101217 			pNew = Xsqlite3PExpr(tls, pParse, int32((*Expr)(unsafe.Pointer(pExpr)).Fop), pLeft, pRight)
 101218 			transferJoinMarkings(tls, pNew, pExpr)
 101219 			idxNew = whereClauseInsert(tls, pWC, pNew, uint16(TERM_DYNAMIC|TERM_SLICE))
 101220 			exprAnalyze(tls, pSrc, pWC, idxNew)
 101221 		}
 101222 		pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101223 		*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_CODED | TERM_VIRTUAL)
 101224 		(*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(WO_ROWVAL)
 101225 	} else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IN &&
 101226 		*(*int32)(unsafe.Pointer(pTerm + 24 + 4)) == 0 &&
 101227 		int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_VECTOR &&
 101228 		(*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) &&
 101229 		((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpPrior == uintptr(0) || (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FselFlags&U32(SF_Values) != 0) &&
 101230 		(*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FpWin == uintptr(0) &&
 101231 		int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND {
 101232 		var i int32
 101233 		for i = 0; i < Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft); i++ {
 101234 			var idxNew int32
 101235 			idxNew = whereClauseInsert(tls, pWC, pExpr, uint16(TERM_VIRTUAL|TERM_SLICE))
 101236 			*(*int32)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*48 + 24 + 4)) = i + 1
 101237 			exprAnalyze(tls, pSrc, pWC, idxNew)
 101238 			markTermAsChild(tls, pWC, idxNew, idxTerm)
 101239 		}
 101240 	} else if int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND {
 101241 		*(*uintptr)(unsafe.Pointer(bp + 28)) = uintptr(0)
 101242 		*(*uintptr)(unsafe.Pointer(bp + 24)) = uintptr(0)
 101243 		var res int32 = isAuxiliaryVtabOperator(tls, db, pExpr, bp+20, bp+24, bp+28)
 101244 		for libc.PostDecInt32(&res, 1) > 0 {
 101245 			var idxNew int32
 101246 			var pNewTerm uintptr
 101247 			var prereqColumn Bitmask
 101248 			var prereqExpr Bitmask
 101249 
 101250 			prereqExpr = Xsqlite3WhereExprUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(bp + 28)))
 101251 			prereqColumn = Xsqlite3WhereExprUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(bp + 24)))
 101252 			if prereqExpr&prereqColumn == uint64(0) {
 101253 				var pNewExpr uintptr
 101254 				pNewExpr = Xsqlite3PExpr(tls, pParse, TK_MATCH,
 101255 					uintptr(0), Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 28)), 0))
 101256 				if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0) && pNewExpr != 0 {
 101257 					*(*U32)(unsafe.Pointer(pNewExpr + 4)) |= U32(EP_OuterON)
 101258 					*(*int32)(unsafe.Pointer(pNewExpr + 36)) = *(*int32)(unsafe.Pointer(pExpr + 36))
 101259 				}
 101260 				idxNew = whereClauseInsert(tls, pWC, pNewExpr, uint16(TERM_VIRTUAL|TERM_DYNAMIC))
 101261 
 101262 				pNewTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*48
 101263 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = prereqExpr
 101264 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)))).FiTable
 101265 				*(*int32)(unsafe.Pointer(pNewTerm + 24)) = int32((*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24)))).FiColumn)
 101266 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = U16(WO_AUX)
 101267 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FeMatchOp = *(*uint8)(unsafe.Pointer(bp + 20))
 101268 				markTermAsChild(tls, pWC, idxNew, idxTerm)
 101269 				pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101270 				*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_COPIED)
 101271 				(*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll
 101272 			}
 101273 			{
 101274 				var t uintptr = *(*uintptr)(unsafe.Pointer(bp + 24))
 101275 				*(*uintptr)(unsafe.Pointer(bp + 24)) = *(*uintptr)(unsafe.Pointer(bp + 28))
 101276 				*(*uintptr)(unsafe.Pointer(bp + 28)) = t
 101277 			}
 101278 
 101279 		}
 101280 	}
 101281 
 101282 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*48
 101283 	*(*Bitmask)(unsafe.Pointer(pTerm + 32)) |= extraRight
 101284 }
 101285 
 101286 var ops = [2]U8{U8(TK_GE), U8(TK_LE)}
 101287 
 101288 // This routine identifies subexpressions in the WHERE clause where
 101289 // each subexpression is separated by the AND operator or some other
 101290 // operator specified in the op parameter.  The WhereClause structure
 101291 // is filled with pointers to subexpressions.  For example:
 101292 //
 101293 //	WHERE  a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22)
 101294 //	       \________/     \_______________/     \________________/
 101295 //	        slot[0]            slot[1]               slot[2]
 101296 //
 101297 // The original WHERE clause in pExpr is unaltered.  All this routine
 101298 // does is make slot[] entries point to substructure within pExpr.
 101299 //
 101300 // In the previous sentence and in the diagram, "slot[]" refers to
 101301 // the WhereClause.a[] array.  The slot[] array grows as needed to contain
 101302 // all terms of the WHERE clause.
 101303 func Xsqlite3WhereSplit(tls *libc.TLS, pWC uintptr, pExpr uintptr, op U8) {
 101304 	var pE2 uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr)
 101305 	(*WhereClause)(unsafe.Pointer(pWC)).Fop = op
 101306 
 101307 	if pE2 == uintptr(0) {
 101308 		return
 101309 	}
 101310 	if int32((*Expr)(unsafe.Pointer(pE2)).Fop) != int32(op) {
 101311 		whereClauseInsert(tls, pWC, pExpr, uint16(0))
 101312 	} else {
 101313 		Xsqlite3WhereSplit(tls, pWC, (*Expr)(unsafe.Pointer(pE2)).FpLeft, op)
 101314 		Xsqlite3WhereSplit(tls, pWC, (*Expr)(unsafe.Pointer(pE2)).FpRight, op)
 101315 	}
 101316 }
 101317 
 101318 func whereAddLimitExpr(tls *libc.TLS, pWC uintptr, iReg int32, pExpr uintptr, iCsr int32, eMatchOp int32) {
 101319 	bp := tls.Alloc(4)
 101320 	defer tls.Free(4)
 101321 
 101322 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse
 101323 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 101324 	var pNew uintptr
 101325 	*(*int32)(unsafe.Pointer(bp)) = 0
 101326 
 101327 	if Xsqlite3ExprIsInteger(tls, pExpr, bp) != 0 && *(*int32)(unsafe.Pointer(bp)) >= 0 {
 101328 		var pVal uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0))
 101329 		if pVal == uintptr(0) {
 101330 			return
 101331 		}
 101332 		*(*U32)(unsafe.Pointer(pVal + 4)) |= U32(EP_IntValue)
 101333 		*(*int32)(unsafe.Pointer(pVal + 8)) = *(*int32)(unsafe.Pointer(bp))
 101334 		pNew = Xsqlite3PExpr(tls, pParse, TK_MATCH, uintptr(0), pVal)
 101335 	} else {
 101336 		var pVal uintptr = Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0))
 101337 		if pVal == uintptr(0) {
 101338 			return
 101339 		}
 101340 		(*Expr)(unsafe.Pointer(pVal)).FiTable = iReg
 101341 		pNew = Xsqlite3PExpr(tls, pParse, TK_MATCH, uintptr(0), pVal)
 101342 	}
 101343 	if pNew != 0 {
 101344 		var pTerm uintptr
 101345 		var idx int32
 101346 		idx = whereClauseInsert(tls, pWC, pNew, uint16(TERM_DYNAMIC|TERM_VIRTUAL))
 101347 		pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idx)*48
 101348 		(*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = iCsr
 101349 		(*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(WO_AUX)
 101350 		(*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp = U8(eMatchOp)
 101351 	}
 101352 }
 101353 
 101354 // Possibly add terms corresponding to the LIMIT and OFFSET clauses of the
 101355 // SELECT statement passed as the second argument. These terms are only
 101356 // added if:
 101357 //
 101358 //  1. The SELECT statement has a LIMIT clause, and
 101359 //  2. The SELECT statement is not an aggregate or DISTINCT query, and
 101360 //  3. The SELECT statement has exactly one object in its from clause, and
 101361 //     that object is a virtual table, and
 101362 //  4. There are no terms in the WHERE clause that will not be passed
 101363 //     to the virtual table xBestIndex method.
 101364 //  5. The ORDER BY clause, if any, will be made available to the xBestIndex
 101365 //     method.
 101366 //
 101367 // LIMIT and OFFSET terms are ignored by most of the planner code. They
 101368 // exist only so that they may be passed to the xBestIndex method of the
 101369 // single virtual table in the FROM clause of the SELECT.
 101370 func Xsqlite3WhereAddLimit(tls *libc.TLS, pWC uintptr, p uintptr) {
 101371 	if (*Select)(unsafe.Pointer(p)).FpGroupBy == uintptr(0) &&
 101372 		(*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Distinct|SF_Aggregate) == U32(0) &&
 101373 		((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc == 1 && int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc+8)).FpTab)).FeTabType) == TABTYP_VTAB) {
 101374 		var pOrderBy uintptr = (*Select)(unsafe.Pointer(p)).FpOrderBy
 101375 		var iCsr int32 = (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FiCursor
 101376 		var ii int32
 101377 
 101378 		for ii = 0; ii < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm; ii++ {
 101379 			if int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(ii)*48)).FwtFlags)&TERM_CODED != 0 {
 101380 				continue
 101381 			}
 101382 			if (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(ii)*48)).FnChild != 0 {
 101383 				continue
 101384 			}
 101385 			if (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(ii)*48)).FleftCursor != iCsr {
 101386 				return
 101387 			}
 101388 		}
 101389 
 101390 		if pOrderBy != 0 {
 101391 			for ii = 0; ii < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; ii++ {
 101392 				var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(ii)*20)).FpExpr
 101393 				if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN {
 101394 					return
 101395 				}
 101396 				if (*Expr)(unsafe.Pointer(pExpr)).FiTable != iCsr {
 101397 					return
 101398 				}
 101399 				if int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(ii)*20)).Ffg.FsortFlags)&KEYINFO_ORDER_BIGNULL != 0 {
 101400 					return
 101401 				}
 101402 			}
 101403 		}
 101404 
 101405 		whereAddLimitExpr(tls, pWC, (*Select)(unsafe.Pointer(p)).FiLimit, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpLimit)).FpLeft,
 101406 			iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT)
 101407 		if (*Select)(unsafe.Pointer(p)).FiOffset > 0 {
 101408 			whereAddLimitExpr(tls, pWC, (*Select)(unsafe.Pointer(p)).FiOffset, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpLimit)).FpRight,
 101409 				iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET)
 101410 		}
 101411 	}
 101412 }
 101413 
 101414 // Initialize a preallocated WhereClause structure.
 101415 func Xsqlite3WhereClauseInit(tls *libc.TLS, pWC uintptr, pWInfo uintptr) {
 101416 	(*WhereClause)(unsafe.Pointer(pWC)).FpWInfo = pWInfo
 101417 	(*WhereClause)(unsafe.Pointer(pWC)).FhasOr = U8(0)
 101418 	(*WhereClause)(unsafe.Pointer(pWC)).FpOuter = uintptr(0)
 101419 	(*WhereClause)(unsafe.Pointer(pWC)).FnTerm = 0
 101420 	(*WhereClause)(unsafe.Pointer(pWC)).FnBase = 0
 101421 	(*WhereClause)(unsafe.Pointer(pWC)).FnSlot = int32(uint32(unsafe.Sizeof([8]WhereTerm{})) / uint32(unsafe.Sizeof(WhereTerm{})))
 101422 	(*WhereClause)(unsafe.Pointer(pWC)).Fa = pWC + 32
 101423 }
 101424 
 101425 // Deallocate a WhereClause structure.  The WhereClause structure
 101426 // itself is not freed.  This routine is the inverse of
 101427 // sqlite3WhereClauseInit().
 101428 func Xsqlite3WhereClauseClear(tls *libc.TLS, pWC uintptr) {
 101429 	var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb
 101430 
 101431 	if (*WhereClause)(unsafe.Pointer(pWC)).FnTerm > 0 {
 101432 		var a uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 101433 		var aLast uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pWC)).FnTerm-1)*48
 101434 		for 1 != 0 {
 101435 			if int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags)&TERM_DYNAMIC != 0 {
 101436 				Xsqlite3ExprDelete(tls, db, (*WhereTerm)(unsafe.Pointer(a)).FpExpr)
 101437 			}
 101438 			if int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags)&(TERM_ORINFO|TERM_ANDINFO) != 0 {
 101439 				if int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags)&TERM_ORINFO != 0 {
 101440 					whereOrInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 24)))
 101441 				} else {
 101442 					whereAndInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 24)))
 101443 				}
 101444 			}
 101445 			if a == aLast {
 101446 				break
 101447 			}
 101448 			a += 48
 101449 		}
 101450 	}
 101451 }
 101452 
 101453 func sqlite3WhereExprUsageFull(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmask {
 101454 	var mask Bitmask
 101455 	if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_IF_NULL_ROW {
 101456 		mask = Xsqlite3WhereGetMask(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FiTable)
 101457 	} else {
 101458 		mask = uint64(0)
 101459 	}
 101460 	if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 {
 101461 		mask = mask | Xsqlite3WhereExprUsageNN(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FpLeft)
 101462 	}
 101463 	if (*Expr)(unsafe.Pointer(p)).FpRight != 0 {
 101464 		mask = mask | Xsqlite3WhereExprUsageNN(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FpRight)
 101465 
 101466 	} else if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_xIsSelect) != U32(0) {
 101467 		if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_VarSelect) != U32(0) {
 101468 			(*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 1
 101469 		}
 101470 		mask = mask | exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 20)))
 101471 	} else if *(*uintptr)(unsafe.Pointer(p + 20)) != 0 {
 101472 		mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 20)))
 101473 	}
 101474 	if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION || int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AGG_FUNCTION) && (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_WinFunc) != U32(0) {
 101475 		mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FpPartition)
 101476 		mask = mask | Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FpOrderBy)
 101477 		mask = mask | Xsqlite3WhereExprUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 44)))).FpFilter)
 101478 	}
 101479 	return mask
 101480 }
 101481 
 101482 func Xsqlite3WhereExprUsageNN(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmask {
 101483 	if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN && !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_FixedCol) != U32(0)) {
 101484 		return Xsqlite3WhereGetMask(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FiTable)
 101485 	} else if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_TokenOnly|EP_Leaf) != U32(0) {
 101486 		return uint64(0)
 101487 	}
 101488 	return sqlite3WhereExprUsageFull(tls, pMaskSet, p)
 101489 }
 101490 
 101491 func Xsqlite3WhereExprUsage(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmask {
 101492 	if p != 0 {
 101493 		return Xsqlite3WhereExprUsageNN(tls, pMaskSet, p)
 101494 	}
 101495 	return uint64(0)
 101496 }
 101497 
 101498 func Xsqlite3WhereExprListUsage(tls *libc.TLS, pMaskSet uintptr, pList uintptr) Bitmask {
 101499 	var i int32
 101500 	var mask Bitmask = uint64(0)
 101501 	if pList != 0 {
 101502 		for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
 101503 			mask = mask | Xsqlite3WhereExprUsage(tls, pMaskSet, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr)
 101504 		}
 101505 	}
 101506 	return mask
 101507 }
 101508 
 101509 // Call exprAnalyze on all terms in a WHERE clause.
 101510 //
 101511 // Note that exprAnalyze() might add new virtual terms onto the
 101512 // end of the WHERE clause.  We do not want to analyze these new
 101513 // virtual terms, so start analyzing at the end and work forward
 101514 // so that the added virtual terms are never processed.
 101515 func Xsqlite3WhereExprAnalyze(tls *libc.TLS, pTabList uintptr, pWC uintptr) {
 101516 	var i int32
 101517 	for i = (*WhereClause)(unsafe.Pointer(pWC)).FnTerm - 1; i >= 0; i-- {
 101518 		exprAnalyze(tls, pTabList, pWC, i)
 101519 	}
 101520 }
 101521 
 101522 // For table-valued-functions, transform the function arguments into
 101523 // new WHERE clause terms.
 101524 //
 101525 // Each function argument translates into an equality constraint against
 101526 // a HIDDEN column in the table.
 101527 func Xsqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC uintptr) {
 101528 	bp := tls.Alloc(16)
 101529 	defer tls.Free(16)
 101530 
 101531 	var pTab uintptr
 101532 	var j int32
 101533 	var k int32
 101534 	var pArgs uintptr
 101535 	var pColRef uintptr
 101536 	var pTerm uintptr
 101537 	if int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x4>>2) == 0 {
 101538 		return
 101539 	}
 101540 	pTab = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
 101541 
 101542 	pArgs = *(*uintptr)(unsafe.Pointer(pItem + 64))
 101543 	if pArgs == uintptr(0) {
 101544 		return
 101545 	}
 101546 	for j = libc.AssignInt32(&k, 0); j < (*ExprList)(unsafe.Pointer(pArgs)).FnExpr; j++ {
 101547 		var pRhs uintptr
 101548 		var joinType U32
 101549 		for k < int32((*Table)(unsafe.Pointer(pTab)).FnCol) && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(k)*16)).FcolFlags)&COLFLAG_HIDDEN == 0 {
 101550 			k++
 101551 		}
 101552 		if k >= int32((*Table)(unsafe.Pointer(pTab)).FnCol) {
 101553 			Xsqlite3ErrorMsg(tls, pParse, ts+21917,
 101554 				libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, j))
 101555 			return
 101556 		}
 101557 		pColRef = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLUMN, uintptr(0), 0)
 101558 		if pColRef == uintptr(0) {
 101559 			return
 101560 		}
 101561 		(*Expr)(unsafe.Pointer(pColRef)).FiTable = (*SrcItem)(unsafe.Pointer(pItem)).FiCursor
 101562 		(*Expr)(unsafe.Pointer(pColRef)).FiColumn = YnVar(libc.PostIncInt32(&k, 1))
 101563 
 101564 		*(*uintptr)(unsafe.Pointer(pColRef + 44)) = pTab
 101565 		*(*Bitmask)(unsafe.Pointer(pItem + 56)) |= Xsqlite3ExprColUsed(tls, pColRef)
 101566 		pRhs = Xsqlite3PExpr(tls, pParse, TK_UPLUS,
 101567 			Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*ExprList_item)(unsafe.Pointer(pArgs+8+uintptr(j)*20)).FpExpr, 0), uintptr(0))
 101568 		pTerm = Xsqlite3PExpr(tls, pParse, TK_EQ, pColRef, pRhs)
 101569 		if int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0 {
 101570 			joinType = U32(EP_OuterON)
 101571 		} else {
 101572 			joinType = U32(EP_InnerON)
 101573 		}
 101574 		Xsqlite3SetJoinExpr(tls, pTerm, (*SrcItem)(unsafe.Pointer(pItem)).FiCursor, joinType)
 101575 		whereClauseInsert(tls, pWC, pTerm, uint16(TERM_DYNAMIC))
 101576 	}
 101577 }
 101578 
 101579 // Extra information appended to the end of sqlite3_index_info but not
 101580 // visible to the xBestIndex function, at least not directly.  The
 101581 // sqlite3_vtab_collation() interface knows how to reach it, however.
 101582 //
 101583 // This object is not an API and can be changed from one release to the
 101584 // next.  As long as allocateIndexInfo() and sqlite3_vtab_collation()
 101585 // agree on the structure, all will be well.
 101586 type HiddenIndexInfo1 = struct {
 101587 	FpWC       uintptr
 101588 	FpParse    uintptr
 101589 	FeDistinct int32
 101590 	FmIn       U32
 101591 	FmHandleIn U32
 101592 	FaRhs      [1]uintptr
 101593 }
 101594 
 101595 // Extra information appended to the end of sqlite3_index_info but not
 101596 // visible to the xBestIndex function, at least not directly.  The
 101597 // sqlite3_vtab_collation() interface knows how to reach it, however.
 101598 //
 101599 // This object is not an API and can be changed from one release to the
 101600 // next.  As long as allocateIndexInfo() and sqlite3_vtab_collation()
 101601 // agree on the structure, all will be well.
 101602 type HiddenIndexInfo = HiddenIndexInfo1
 101603 
 101604 // Return the estimated number of output rows from a WHERE clause
 101605 func Xsqlite3WhereOutputRowCount(tls *libc.TLS, pWInfo uintptr) LogEst {
 101606 	return (*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut
 101607 }
 101608 
 101609 // Return one of the WHERE_DISTINCT_xxxxx values to indicate how this
 101610 // WHERE clause returns outputs for DISTINCT processing.
 101611 func Xsqlite3WhereIsDistinct(tls *libc.TLS, pWInfo uintptr) int32 {
 101612 	return int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct)
 101613 }
 101614 
 101615 // Return the number of ORDER BY terms that are satisfied by the
 101616 // WHERE clause.  A return of 0 means that the output must be
 101617 // completely sorted.  A return equal to the number of ORDER BY
 101618 // terms means that no sorting is needed at all.  A return that
 101619 // is positive but less than the number of ORDER BY terms means that
 101620 // block sorting is required.
 101621 func Xsqlite3WhereIsOrdered(tls *libc.TLS, pWInfo uintptr) int32 {
 101622 	if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) < 0 {
 101623 		return 0
 101624 	}
 101625 	return int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat)
 101626 }
 101627 
 101628 // In the ORDER BY LIMIT optimization, if the inner-most loop is known
 101629 // to emit rows in increasing order, and if the last row emitted by the
 101630 // inner-most loop did not fit within the sorter, then we can skip all
 101631 // subsequent rows for the current iteration of the inner loop (because they
 101632 // will not fit in the sorter either) and continue with the second inner
 101633 // loop - the loop immediately outside the inner-most.
 101634 //
 101635 // When a row does not fit in the sorter (because the sorter already
 101636 // holds LIMIT+OFFSET rows that are smaller), then a jump is made to the
 101637 // label returned by this function.
 101638 //
 101639 // If the ORDER BY LIMIT optimization applies, the jump destination should
 101640 // be the continuation for the second-inner-most loop.  If the ORDER BY
 101641 // LIMIT optimization does not apply, then the jump destination should
 101642 // be the continuation for the inner-most loop.
 101643 //
 101644 // It is always safe for this routine to return the continuation of the
 101645 // inner-most loop, in the sense that a correct answer will result.
 101646 // Returning the continuation the second inner loop is an optimization
 101647 // that might make the code run a little faster, but should not change
 101648 // the final answer.
 101649 func Xsqlite3WhereOrderByLimitOptLabel(tls *libc.TLS, pWInfo uintptr) int32 {
 101650 	var pInner uintptr
 101651 	if !(int32(*(*uint8)(unsafe.Pointer(pWInfo + 48))&0x4>>2) != 0) {
 101652 		return (*WhereInfo)(unsafe.Pointer(pWInfo)).FiContinue
 101653 	}
 101654 	pInner = pWInfo + 760 + uintptr(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-1)*88
 101655 
 101656 	if (*WhereLevel)(unsafe.Pointer(pInner)).FpRJ != 0 {
 101657 		return (*WhereInfo)(unsafe.Pointer(pWInfo)).FiContinue
 101658 	}
 101659 	return (*WhereLevel)(unsafe.Pointer(pInner)).FaddrNxt
 101660 }
 101661 
 101662 // While generating code for the min/max optimization, after handling
 101663 // the aggregate-step call to min() or max(), check to see if any
 101664 // additional looping is required.  If the output order is such that
 101665 // we are certain that the correct answer has already been found, then
 101666 // code an OP_Goto to by pass subsequent processing.
 101667 //
 101668 // Any extra OP_Goto that is coded here is an optimization.  The
 101669 // correct answer should be obtained regardless.  This OP_Goto just
 101670 // makes the answer appear faster.
 101671 func Xsqlite3WhereMinMaxOptEarlyOut(tls *libc.TLS, v uintptr, pWInfo uintptr) {
 101672 	var pInner uintptr
 101673 	var i int32
 101674 	if !(int32(*(*uint8)(unsafe.Pointer(pWInfo + 48))&0x4>>2) != 0) {
 101675 		return
 101676 	}
 101677 	if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == 0 {
 101678 		return
 101679 	}
 101680 	for i = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - 1; i >= 0; i-- {
 101681 		pInner = pWInfo + 760 + uintptr(i)*88
 101682 		if (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pInner)).FpWLoop)).FwsFlags&U32(WHERE_COLUMN_IN) != U32(0) {
 101683 			Xsqlite3VdbeGoto(tls, v, (*WhereLevel)(unsafe.Pointer(pInner)).FaddrNxt)
 101684 			return
 101685 		}
 101686 	}
 101687 	Xsqlite3VdbeGoto(tls, v, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak)
 101688 }
 101689 
 101690 // Return the VDBE address or label to jump to in order to continue
 101691 // immediately with the next row of a WHERE clause.
 101692 func Xsqlite3WhereContinueLabel(tls *libc.TLS, pWInfo uintptr) int32 {
 101693 	return (*WhereInfo)(unsafe.Pointer(pWInfo)).FiContinue
 101694 }
 101695 
 101696 // Return the VDBE address or label to jump to in order to break
 101697 // out of a WHERE loop.
 101698 func Xsqlite3WhereBreakLabel(tls *libc.TLS, pWInfo uintptr) int32 {
 101699 	return (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak
 101700 }
 101701 
 101702 // Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to
 101703 // operate directly on the rowids returned by a WHERE clause.  Return
 101704 // ONEPASS_SINGLE (1) if the statement can operation directly because only
 101705 // a single row is to be changed.  Return ONEPASS_MULTI (2) if the one-pass
 101706 // optimization can be used on multiple
 101707 //
 101708 // If the ONEPASS optimization is used (if this routine returns true)
 101709 // then also write the indices of open cursors used by ONEPASS
 101710 // into aiCur[0] and aiCur[1].  iaCur[0] gets the cursor of the data
 101711 // table and iaCur[1] gets the cursor used by an auxiliary index.
 101712 // Either value may be -1, indicating that cursor is not used.
 101713 // Any cursors returned will have been opened for writing.
 101714 //
 101715 // aiCur[0] and aiCur[1] both get -1 if the where-clause logic is
 101716 // unable to use the ONEPASS optimization.
 101717 func Xsqlite3WhereOkOnePass(tls *libc.TLS, pWInfo uintptr, aiCur uintptr) int32 {
 101718 	libc.Xmemcpy(tls, aiCur, pWInfo+20, uint32(unsafe.Sizeof(int32(0)))*uint32(2))
 101719 	return int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass)
 101720 }
 101721 
 101722 // Return TRUE if the WHERE loop uses the OP_DeferredSeek opcode to move
 101723 // the data cursor to the row selected by the index cursor.
 101724 func Xsqlite3WhereUsesDeferredSeek(tls *libc.TLS, pWInfo uintptr) int32 {
 101725 	return int32(*(*uint8)(unsafe.Pointer(pWInfo + 48)) & 0x1 >> 0)
 101726 }
 101727 
 101728 func whereOrMove(tls *libc.TLS, pDest uintptr, pSrc uintptr) {
 101729 	(*WhereOrSet)(unsafe.Pointer(pDest)).Fn = (*WhereOrSet)(unsafe.Pointer(pSrc)).Fn
 101730 	libc.Xmemcpy(tls, pDest+8, pSrc+8, uint32((*WhereOrSet)(unsafe.Pointer(pDest)).Fn)*uint32(unsafe.Sizeof(WhereOrCost{})))
 101731 }
 101732 
 101733 func whereOrInsert(tls *libc.TLS, pSet uintptr, prereq Bitmask, rRun LogEst, nOut LogEst) int32 {
 101734 	var i U16
 101735 	var p uintptr
 101736 	i = (*WhereOrSet)(unsafe.Pointer(pSet)).Fn
 101737 	p = pSet + 8
 101738 __1:
 101739 	if !(int32(i) > 0) {
 101740 		goto __3
 101741 	}
 101742 	if !(int32(rRun) <= int32((*WhereOrCost)(unsafe.Pointer(p)).FrRun) && prereq&(*WhereOrCost)(unsafe.Pointer(p)).Fprereq == prereq) {
 101743 		goto __4
 101744 	}
 101745 	goto whereOrInsert_done
 101746 __4:
 101747 	;
 101748 	if !(int32((*WhereOrCost)(unsafe.Pointer(p)).FrRun) <= int32(rRun) && (*WhereOrCost)(unsafe.Pointer(p)).Fprereq&prereq == (*WhereOrCost)(unsafe.Pointer(p)).Fprereq) {
 101749 		goto __5
 101750 	}
 101751 	return 0
 101752 __5:
 101753 	;
 101754 	goto __2
 101755 __2:
 101756 	i--
 101757 	p += 16
 101758 	goto __1
 101759 	goto __3
 101760 __3:
 101761 	;
 101762 	if !(int32((*WhereOrSet)(unsafe.Pointer(pSet)).Fn) < N_OR_COST) {
 101763 		goto __6
 101764 	}
 101765 	p = pSet + 8 + uintptr(libc.PostIncUint16(&(*WhereOrSet)(unsafe.Pointer(pSet)).Fn, 1))*16
 101766 	(*WhereOrCost)(unsafe.Pointer(p)).FnOut = nOut
 101767 	goto __7
 101768 __6:
 101769 	p = pSet + 8
 101770 	i = U16(1)
 101771 __8:
 101772 	if !(int32(i) < int32((*WhereOrSet)(unsafe.Pointer(pSet)).Fn)) {
 101773 		goto __10
 101774 	}
 101775 	if !(int32((*WhereOrCost)(unsafe.Pointer(p)).FrRun) > int32((*WhereOrCost)(unsafe.Pointer(pSet+8+uintptr(i)*16)).FrRun)) {
 101776 		goto __11
 101777 	}
 101778 	p = pSet + 8 + uintptr(i)*16
 101779 __11:
 101780 	;
 101781 	goto __9
 101782 __9:
 101783 	i++
 101784 	goto __8
 101785 	goto __10
 101786 __10:
 101787 	;
 101788 	if !(int32((*WhereOrCost)(unsafe.Pointer(p)).FrRun) <= int32(rRun)) {
 101789 		goto __12
 101790 	}
 101791 	return 0
 101792 __12:
 101793 	;
 101794 __7:
 101795 	;
 101796 whereOrInsert_done:
 101797 	(*WhereOrCost)(unsafe.Pointer(p)).Fprereq = prereq
 101798 	(*WhereOrCost)(unsafe.Pointer(p)).FrRun = rRun
 101799 	if !(int32((*WhereOrCost)(unsafe.Pointer(p)).FnOut) > int32(nOut)) {
 101800 		goto __13
 101801 	}
 101802 	(*WhereOrCost)(unsafe.Pointer(p)).FnOut = nOut
 101803 __13:
 101804 	;
 101805 	return 1
 101806 }
 101807 
 101808 // Return the bitmask for the given cursor number.  Return 0 if
 101809 // iCursor is not in the set.
 101810 func Xsqlite3WhereGetMask(tls *libc.TLS, pMaskSet uintptr, iCursor int32) Bitmask {
 101811 	var i int32
 101812 
 101813 	if *(*int32)(unsafe.Pointer(pMaskSet + 8)) == iCursor {
 101814 		return uint64(1)
 101815 	}
 101816 	for i = 1; i < (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn; i++ {
 101817 		if *(*int32)(unsafe.Pointer(pMaskSet + 8 + uintptr(i)*4)) == iCursor {
 101818 			return uint64(1) << i
 101819 		}
 101820 	}
 101821 	return uint64(0)
 101822 }
 101823 
 101824 // Allocate memory that is automatically freed when pWInfo is freed.
 101825 func Xsqlite3WhereMalloc(tls *libc.TLS, pWInfo uintptr, nByte U64) uintptr {
 101826 	var pBlock uintptr
 101827 	pBlock = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb, nByte+U64(unsafe.Sizeof(WhereMemBlock{})))
 101828 	if pBlock != 0 {
 101829 		(*WhereMemBlock)(unsafe.Pointer(pBlock)).FpNext = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree
 101830 		(*WhereMemBlock)(unsafe.Pointer(pBlock)).Fsz = nByte
 101831 		(*WhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree = pBlock
 101832 		pBlock += 16
 101833 	}
 101834 	return pBlock
 101835 }
 101836 
 101837 func Xsqlite3WhereRealloc(tls *libc.TLS, pWInfo uintptr, pOld uintptr, nByte U64) uintptr {
 101838 	var pNew uintptr = Xsqlite3WhereMalloc(tls, pWInfo, nByte)
 101839 	if pNew != 0 && pOld != 0 {
 101840 		var pOldBlk uintptr = pOld
 101841 		pOldBlk -= 16
 101842 
 101843 		libc.Xmemcpy(tls, pNew, pOld, uint32((*WhereMemBlock)(unsafe.Pointer(pOldBlk)).Fsz))
 101844 	}
 101845 	return pNew
 101846 }
 101847 
 101848 func createMask(tls *libc.TLS, pMaskSet uintptr, iCursor int32) {
 101849 	*(*int32)(unsafe.Pointer(pMaskSet + 8 + uintptr(libc.PostIncInt32(&(*WhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn, 1))*4)) = iCursor
 101850 }
 101851 
 101852 func whereRightSubexprIsColumn(tls *libc.TLS, p uintptr) uintptr {
 101853 	p = Xsqlite3ExprSkipCollateAndLikely(tls, (*Expr)(unsafe.Pointer(p)).FpRight)
 101854 	if p != uintptr(0) && int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN && !((*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_FixedCol) != U32(0)) {
 101855 		return p
 101856 	}
 101857 	return uintptr(0)
 101858 }
 101859 
 101860 func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr {
 101861 	var iCur int32
 101862 	var iColumn I16
 101863 	var pX uintptr
 101864 	var pWC uintptr
 101865 	var pTerm uintptr
 101866 	var k int32 = (*WhereScan)(unsafe.Pointer(pScan)).Fk
 101867 
 101868 	pWC = (*WhereScan)(unsafe.Pointer(pScan)).FpWC
 101869 	for 1 != 0 {
 101870 		iColumn = *(*I16)(unsafe.Pointer(pScan + 72 + uintptr(int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv)-1)*2))
 101871 		iCur = *(*int32)(unsafe.Pointer(pScan + 28 + uintptr(int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv)-1)*4))
 101872 
 101873 		for __ccgo := true; __ccgo; __ccgo = pWC != uintptr(0) {
 101874 			pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(k)*48
 101875 		__1:
 101876 			if !(k < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm) {
 101877 				goto __3
 101878 			}
 101879 			{
 101880 				if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor == iCur &&
 101881 					*(*int32)(unsafe.Pointer(pTerm + 24)) == int32(iColumn) &&
 101882 					(int32(iColumn) != -2 ||
 101883 						Xsqlite3ExprCompareSkip(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft,
 101884 							(*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr, iCur) == 0) &&
 101885 					(int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= 1 || !((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_OuterON) != U32(0))) {
 101886 					if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_EQUIV != 0 &&
 101887 						int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv) < int32(uint32(unsafe.Sizeof([11]int32{}))/uint32(unsafe.Sizeof(int32(0)))) &&
 101888 						libc.AssignUintptr(&pX, whereRightSubexprIsColumn(tls, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)) != uintptr(0) {
 101889 						var j int32
 101890 						for j = 0; j < int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv); j++ {
 101891 							if *(*int32)(unsafe.Pointer(pScan + 28 + uintptr(j)*4)) == (*Expr)(unsafe.Pointer(pX)).FiTable &&
 101892 								int32(*(*I16)(unsafe.Pointer(pScan + 72 + uintptr(j)*2))) == int32((*Expr)(unsafe.Pointer(pX)).FiColumn) {
 101893 								break
 101894 							}
 101895 						}
 101896 						if j == int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv) {
 101897 							*(*int32)(unsafe.Pointer(pScan + 28 + uintptr(j)*4)) = (*Expr)(unsafe.Pointer(pX)).FiTable
 101898 							*(*I16)(unsafe.Pointer(pScan + 72 + uintptr(j)*2)) = (*Expr)(unsafe.Pointer(pX)).FiColumn
 101899 							(*WhereScan)(unsafe.Pointer(pScan)).FnEquiv++
 101900 						}
 101901 					}
 101902 					if U32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(*WhereScan)(unsafe.Pointer(pScan)).FopMask != U32(0) {
 101903 						if (*WhereScan)(unsafe.Pointer(pScan)).FzCollName != 0 && int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_ISNULL == 0 {
 101904 							var pColl uintptr
 101905 							var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse
 101906 							pX = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 101907 							if !(Xsqlite3IndexAffinityOk(tls, pX, (*WhereScan)(unsafe.Pointer(pScan)).Fidxaff) != 0) {
 101908 								goto __2
 101909 							}
 101910 
 101911 							pColl = Xsqlite3ExprCompareCollSeq(tls, pParse, pX)
 101912 							if pColl == uintptr(0) {
 101913 								pColl = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl
 101914 							}
 101915 							if Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, (*WhereScan)(unsafe.Pointer(pScan)).FzCollName) != 0 {
 101916 								goto __2
 101917 							}
 101918 						}
 101919 						if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(WO_EQ|WO_IS) != 0 &&
 101920 							func() bool {
 101921 								pX = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight
 101922 								return pX != uintptr(0)
 101923 							}() &&
 101924 							int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_COLUMN &&
 101925 							(*Expr)(unsafe.Pointer(pX)).FiTable == *(*int32)(unsafe.Pointer(pScan + 28)) &&
 101926 							int32((*Expr)(unsafe.Pointer(pX)).FiColumn) == int32(*(*I16)(unsafe.Pointer(pScan + 72))) {
 101927 							goto __2
 101928 						}
 101929 						(*WhereScan)(unsafe.Pointer(pScan)).FpWC = pWC
 101930 						(*WhereScan)(unsafe.Pointer(pScan)).Fk = k + 1
 101931 						return pTerm
 101932 					}
 101933 				}
 101934 
 101935 			}
 101936 			goto __2
 101937 		__2:
 101938 			k++
 101939 			pTerm += 48
 101940 			goto __1
 101941 			goto __3
 101942 		__3:
 101943 			;
 101944 			pWC = (*WhereClause)(unsafe.Pointer(pWC)).FpOuter
 101945 			k = 0
 101946 		}
 101947 		if int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv) >= int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv) {
 101948 			break
 101949 		}
 101950 		pWC = (*WhereScan)(unsafe.Pointer(pScan)).FpOrigWC
 101951 		k = 0
 101952 		(*WhereScan)(unsafe.Pointer(pScan)).FiEquiv++
 101953 	}
 101954 	return uintptr(0)
 101955 }
 101956 
 101957 func whereScanInitIndexExpr(tls *libc.TLS, pScan uintptr) uintptr {
 101958 	(*WhereScan)(unsafe.Pointer(pScan)).Fidxaff = Xsqlite3ExprAffinity(tls, (*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr)
 101959 	return whereScanNext(tls, pScan)
 101960 }
 101961 
 101962 func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColumn int32, opMask U32, pIdx uintptr) uintptr {
 101963 	(*WhereScan)(unsafe.Pointer(pScan)).FpOrigWC = pWC
 101964 	(*WhereScan)(unsafe.Pointer(pScan)).FpWC = pWC
 101965 	(*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = uintptr(0)
 101966 	(*WhereScan)(unsafe.Pointer(pScan)).Fidxaff = uint8(0)
 101967 	(*WhereScan)(unsafe.Pointer(pScan)).FzCollName = uintptr(0)
 101968 	(*WhereScan)(unsafe.Pointer(pScan)).FopMask = opMask
 101969 	(*WhereScan)(unsafe.Pointer(pScan)).Fk = 0
 101970 	*(*int32)(unsafe.Pointer(pScan + 28)) = iCur
 101971 	(*WhereScan)(unsafe.Pointer(pScan)).FnEquiv = uint8(1)
 101972 	(*WhereScan)(unsafe.Pointer(pScan)).FiEquiv = uint8(1)
 101973 	if pIdx != 0 {
 101974 		var j int32 = iColumn
 101975 		iColumn = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2)))
 101976 		if iColumn == int32((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FiPKey) {
 101977 			iColumn = -1
 101978 		} else if iColumn >= 0 {
 101979 			(*WhereScan)(unsafe.Pointer(pScan)).Fidxaff = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(iColumn)*16)).Faffinity
 101980 			(*WhereScan)(unsafe.Pointer(pScan)).FzCollName = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*4))
 101981 		} else if iColumn == -2 {
 101982 			(*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(j)*20)).FpExpr
 101983 			(*WhereScan)(unsafe.Pointer(pScan)).FzCollName = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*4))
 101984 			*(*I16)(unsafe.Pointer(pScan + 72)) = int16(-2)
 101985 			return whereScanInitIndexExpr(tls, pScan)
 101986 		}
 101987 	} else if iColumn == -2 {
 101988 		return uintptr(0)
 101989 	}
 101990 	*(*I16)(unsafe.Pointer(pScan + 72)) = I16(iColumn)
 101991 	return whereScanNext(tls, pScan)
 101992 }
 101993 
 101994 // Search for a term in the WHERE clause that is of the form "X <op> <expr>"
 101995 // where X is a reference to the iColumn of table iCur or of index pIdx
 101996 // if pIdx!=0 and <op> is one of the WO_xx operator codes specified by
 101997 // the op parameter.  Return a pointer to the term.  Return 0 if not found.
 101998 //
 101999 // If pIdx!=0 then it must be one of the indexes of table iCur.
 102000 // Search for terms matching the iColumn-th column of pIdx
 102001 // rather than the iColumn-th column of table iCur.
 102002 //
 102003 // The term returned might by Y=<expr> if there is another constraint in
 102004 // the WHERE clause that specifies that X=Y.  Any such constraints will be
 102005 // identified by the WO_EQUIV bit in the pTerm->eOperator field.  The
 102006 // aiCur[]/iaColumn[] arrays hold X and all its equivalents. There are 11
 102007 // slots in aiCur[]/aiColumn[] so that means we can look for X plus up to 10
 102008 // other equivalent values.  Hence a search for X will return <expr> if X=A1
 102009 // and A1=A2 and A2=A3 and ... and A9=A10 and A10=<expr>.
 102010 //
 102011 // If there are multiple terms in the WHERE clause of the form "X <op> <expr>"
 102012 // then try for the one with no dependencies on <expr> - in other words where
 102013 // <expr> is a constant expression of some kind.  Only return entries of
 102014 // the form "X <op> Y" where Y is a column in another table if no terms of
 102015 // the form "X <op> <const-expr>" exist.   If no terms with a constant RHS
 102016 // exist, try to return a term that does not use WO_EQUIV.
 102017 func Xsqlite3WhereFindTerm(tls *libc.TLS, pWC uintptr, iCur int32, iColumn int32, notReady Bitmask, op U32, pIdx uintptr) uintptr {
 102018 	bp := tls.Alloc(96)
 102019 	defer tls.Free(96)
 102020 
 102021 	var pResult uintptr = uintptr(0)
 102022 	var p uintptr
 102023 
 102024 	p = whereScanInit(tls, bp, pWC, iCur, iColumn, op, pIdx)
 102025 	op = op & U32(WO_EQ|WO_IS)
 102026 	for p != 0 {
 102027 		if (*WhereTerm)(unsafe.Pointer(p)).FprereqRight&notReady == uint64(0) {
 102028 			if (*WhereTerm)(unsafe.Pointer(p)).FprereqRight == uint64(0) && U32((*WhereTerm)(unsafe.Pointer(p)).FeOperator)&op != U32(0) {
 102029 				return p
 102030 			}
 102031 			if pResult == uintptr(0) {
 102032 				pResult = p
 102033 			}
 102034 		}
 102035 		p = whereScanNext(tls, bp)
 102036 	}
 102037 	return pResult
 102038 }
 102039 
 102040 func findIndexCol(tls *libc.TLS, pParse uintptr, pList uintptr, iBase int32, pIdx uintptr, iCol int32) int32 {
 102041 	var i int32
 102042 	var zColl uintptr = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(iCol)*4))
 102043 
 102044 	for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
 102045 		var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr)
 102046 		if p != uintptr(0) &&
 102047 			(int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN || int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AGG_COLUMN) &&
 102048 			int32((*Expr)(unsafe.Pointer(p)).FiColumn) == int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2))) &&
 102049 			(*Expr)(unsafe.Pointer(p)).FiTable == iBase {
 102050 			var pColl uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr)
 102051 			if 0 == Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, zColl) {
 102052 				return i
 102053 			}
 102054 		}
 102055 	}
 102056 
 102057 	return -1
 102058 }
 102059 
 102060 func indexColumnNotNull(tls *libc.TLS, pIdx uintptr, iCol int32) int32 {
 102061 	var j int32
 102062 
 102063 	j = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2)))
 102064 	if j >= 0 {
 102065 		return int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FaCol + uintptr(j)*16 + 4)) & 0xf >> 0)
 102066 	} else if j == -1 {
 102067 		return 1
 102068 	} else {
 102069 		return 0
 102070 
 102071 	}
 102072 	return int32(0)
 102073 }
 102074 
 102075 func isDistinctRedundant(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWC uintptr, pDistinct uintptr) int32 {
 102076 	var pTab uintptr
 102077 	var pIdx uintptr
 102078 	var i int32
 102079 	var iBase int32
 102080 
 102081 	if (*SrcList)(unsafe.Pointer(pTabList)).FnSrc != 1 {
 102082 		return 0
 102083 	}
 102084 	iBase = (*SrcItem)(unsafe.Pointer(pTabList + 8)).FiCursor
 102085 	pTab = (*SrcItem)(unsafe.Pointer(pTabList + 8)).FpTab
 102086 
 102087 	for i = 0; i < (*ExprList)(unsafe.Pointer(pDistinct)).FnExpr; i++ {
 102088 		var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pDistinct+8+uintptr(i)*20)).FpExpr)
 102089 		if p == uintptr(0) {
 102090 			continue
 102091 		}
 102092 		if int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_COLUMN && int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_AGG_COLUMN {
 102093 			continue
 102094 		}
 102095 		if (*Expr)(unsafe.Pointer(p)).FiTable == iBase && int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0 {
 102096 			return 1
 102097 		}
 102098 	}
 102099 
 102100 	for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
 102101 		if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None) {
 102102 			continue
 102103 		}
 102104 		if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 {
 102105 			continue
 102106 		}
 102107 		for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ {
 102108 			if uintptr(0) == Xsqlite3WhereFindTerm(tls, pWC, iBase, i, libc.CplUint64(uint64(0)), uint32(WO_EQ), pIdx) {
 102109 				if findIndexCol(tls, pParse, pDistinct, iBase, pIdx, i) < 0 {
 102110 					break
 102111 				}
 102112 				if indexColumnNotNull(tls, pIdx, i) == 0 {
 102113 					break
 102114 				}
 102115 			}
 102116 		}
 102117 		if i == int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) {
 102118 			return 1
 102119 		}
 102120 	}
 102121 
 102122 	return 0
 102123 }
 102124 
 102125 func estLog(tls *libc.TLS, N LogEst) LogEst {
 102126 	if int32(N) <= 10 {
 102127 		return int16(0)
 102128 	}
 102129 	return int16(int32(Xsqlite3LogEst(tls, uint64(N))) - 33)
 102130 }
 102131 
 102132 func translateColumnToCopy(tls *libc.TLS, pParse uintptr, iStart int32, iTabCur int32, iRegister int32, iAutoidxCur int32) {
 102133 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 102134 	var pOp uintptr = Xsqlite3VdbeGetOp(tls, v, iStart)
 102135 	var iEnd int32 = Xsqlite3VdbeCurrentAddr(tls, v)
 102136 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
 102137 		return
 102138 	}
 102139 __1:
 102140 	if !(iStart < iEnd) {
 102141 		goto __3
 102142 	}
 102143 	{
 102144 		if (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 != iTabCur {
 102145 			goto __2
 102146 		}
 102147 		if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column {
 102148 			(*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(OP_Copy)
 102149 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 + iRegister
 102150 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp3
 102151 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = 0
 102152 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp5 = U16(2)
 102153 		} else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid {
 102154 			(*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(OP_Sequence)
 102155 			(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = iAutoidxCur
 102156 		}
 102157 
 102158 	}
 102159 	goto __2
 102160 __2:
 102161 	iStart++
 102162 	pOp += 20
 102163 	goto __1
 102164 	goto __3
 102165 __3:
 102166 }
 102167 
 102168 func constraintCompatibleWithOuterJoin(tls *libc.TLS, pTerm uintptr, pSrc uintptr) int32 {
 102169 	if !((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_OuterON|EP_InnerON) != U32(0)) ||
 102170 		*(*int32)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 36)) != (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor {
 102171 		return 0
 102172 	}
 102173 	if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(JT_LEFT|JT_RIGHT) != 0 &&
 102174 		(*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_InnerON) != U32(0) {
 102175 		return 0
 102176 	}
 102177 	return 1
 102178 }
 102179 
 102180 func termCanDriveIndex(tls *libc.TLS, pTerm uintptr, pSrc uintptr, notReady Bitmask) int32 {
 102181 	var aff uint8
 102182 	if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor {
 102183 		return 0
 102184 	}
 102185 	if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(WO_EQ|WO_IS) == 0 {
 102186 		return 0
 102187 	}
 102188 
 102189 	if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0 &&
 102190 		!(constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) {
 102191 		return 0
 102192 	}
 102193 	if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&notReady != uint64(0) {
 102194 		return 0
 102195 	}
 102196 
 102197 	if *(*int32)(unsafe.Pointer(pTerm + 24)) < 0 {
 102198 		return 0
 102199 	}
 102200 	aff = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc)).FpTab)).FaCol + uintptr(*(*int32)(unsafe.Pointer(pTerm + 24)))*16)).Faffinity
 102201 	if !(Xsqlite3IndexAffinityOk(tls, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, aff) != 0) {
 102202 		return 0
 102203 	}
 102204 
 102205 	return 1
 102206 }
 102207 
 102208 func constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, pSrc uintptr, notReady Bitmask, pLevel uintptr) {
 102209 	bp := tls.Alloc(20)
 102210 	defer tls.Free(20)
 102211 
 102212 	var nKeyCol int32
 102213 	var pTerm uintptr
 102214 	var pWCEnd uintptr
 102215 	var pIdx uintptr
 102216 	var v uintptr
 102217 	var addrInit int32
 102218 	var pTable uintptr
 102219 	var addrTop int32
 102220 	var regRecord int32
 102221 	var n int32
 102222 	var i int32
 102223 	var mxBitCol int32
 102224 	var pColl uintptr
 102225 	var pLoop uintptr
 102226 
 102227 	var idxCols Bitmask
 102228 	var extraCols Bitmask
 102229 	var sentWarning U8
 102230 	var pPartial uintptr
 102231 	var iContinue int32
 102232 	var pTabItem uintptr
 102233 	var addrCounter int32
 102234 	var regBase int32
 102235 	var iCol int32
 102236 	var cMask Bitmask
 102237 	var pExpr uintptr
 102238 	var pX uintptr
 102239 	var iCol1 int32
 102240 	var cMask1 Bitmask
 102241 	var regYield int32
 102242 	sentWarning = U8(0)
 102243 	pPartial = uintptr(0)
 102244 	iContinue = 0
 102245 	addrCounter = 0
 102246 
 102247 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 102248 
 102249 	addrInit = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
 102250 
 102251 	nKeyCol = 0
 102252 	pTable = (*SrcItem)(unsafe.Pointer(pSrc)).FpTab
 102253 	pWCEnd = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pWC)).FnTerm)*48
 102254 	pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 102255 	idxCols = uint64(0)
 102256 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 102257 __1:
 102258 	if !(pTerm < pWCEnd) {
 102259 		goto __3
 102260 	}
 102261 	pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 102262 
 102263 	if !(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VIRTUAL == 0 &&
 102264 		Xsqlite3ExprIsTableConstraint(tls, pExpr, pSrc) != 0) {
 102265 		goto __4
 102266 	}
 102267 	pPartial = Xsqlite3ExprAnd(tls, pParse, pPartial,
 102268 		Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0))
 102269 __4:
 102270 	;
 102271 	if !(termCanDriveIndex(tls, pTerm, pSrc, notReady) != 0) {
 102272 		goto __5
 102273 	}
 102274 
 102275 	iCol = *(*int32)(unsafe.Pointer(pTerm + 24))
 102276 	if iCol >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) {
 102277 		cMask = uint64(1) << (int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) - 1)
 102278 	} else {
 102279 		cMask = uint64(1) << iCol
 102280 	}
 102281 
 102282 	if !!(sentWarning != 0) {
 102283 		goto __6
 102284 	}
 102285 	Xsqlite3_log(tls, SQLITE_WARNING|int32(1)<<8,
 102286 		ts+21953, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName,
 102287 			(*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FaCol+uintptr(iCol)*16)).FzCnName))
 102288 	sentWarning = U8(1)
 102289 __6:
 102290 	;
 102291 	if !(idxCols&cMask == uint64(0)) {
 102292 		goto __7
 102293 	}
 102294 	if !(whereLoopResize(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pLoop, nKeyCol+1) != 0) {
 102295 		goto __8
 102296 	}
 102297 	goto end_auto_index_create
 102298 __8:
 102299 	;
 102300 	*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&nKeyCol, 1))*4)) = pTerm
 102301 	idxCols = idxCols | cMask
 102302 __7:
 102303 	;
 102304 __5:
 102305 	;
 102306 	goto __2
 102307 __2:
 102308 	pTerm += 48
 102309 	goto __1
 102310 	goto __3
 102311 __3:
 102312 	;
 102313 	*(*U16)(unsafe.Pointer(pLoop + 24)) = libc.AssignPtrUint16(pLoop+48, U16(nKeyCol))
 102314 	(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = U32(WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED |
 102315 		WHERE_AUTO_INDEX)
 102316 
 102317 	extraCols = (*SrcItem)(unsafe.Pointer(pSrc)).FcolUsed & (^idxCols | uint64(1)<<(int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1))
 102318 	mxBitCol = func() int32 {
 102319 		if int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1 < int32((*Table)(unsafe.Pointer(pTable)).FnCol) {
 102320 			return int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) - 1
 102321 		}
 102322 		return int32((*Table)(unsafe.Pointer(pTable)).FnCol)
 102323 	}()
 102324 
 102325 	i = 0
 102326 __9:
 102327 	if !(i < mxBitCol) {
 102328 		goto __11
 102329 	}
 102330 	if !(extraCols&(uint64(1)<<i) != 0) {
 102331 		goto __12
 102332 	}
 102333 	nKeyCol++
 102334 __12:
 102335 	;
 102336 	goto __10
 102337 __10:
 102338 	i++
 102339 	goto __9
 102340 	goto __11
 102341 __11:
 102342 	;
 102343 	if !((*SrcItem)(unsafe.Pointer(pSrc)).FcolUsed&(uint64(1)<<(int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1)) != 0) {
 102344 		goto __13
 102345 	}
 102346 	nKeyCol = nKeyCol + (int32((*Table)(unsafe.Pointer(pTable)).FnCol) - int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) + 1)
 102347 __13:
 102348 	;
 102349 	pIdx = Xsqlite3AllocateIndexObject(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, int16(nKeyCol+1), 0, bp+16)
 102350 	if !(pIdx == uintptr(0)) {
 102351 		goto __14
 102352 	}
 102353 	goto end_auto_index_create
 102354 __14:
 102355 	;
 102356 	*(*uintptr)(unsafe.Pointer(pLoop + 24 + 8)) = pIdx
 102357 	(*Index)(unsafe.Pointer(pIdx)).FzName = ts + 21979
 102358 	(*Index)(unsafe.Pointer(pIdx)).FpTable = pTable
 102359 	n = 0
 102360 	idxCols = uint64(0)
 102361 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 102362 __15:
 102363 	if !(pTerm < pWCEnd) {
 102364 		goto __17
 102365 	}
 102366 	if !(termCanDriveIndex(tls, pTerm, pSrc, notReady) != 0) {
 102367 		goto __18
 102368 	}
 102369 
 102370 	iCol1 = *(*int32)(unsafe.Pointer(pTerm + 24))
 102371 	if iCol1 >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) {
 102372 		cMask1 = uint64(1) << (int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) - 1)
 102373 	} else {
 102374 		cMask1 = uint64(1) << iCol1
 102375 	}
 102376 
 102377 	if !(idxCols&cMask1 == uint64(0)) {
 102378 		goto __19
 102379 	}
 102380 	pX = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 102381 	idxCols = idxCols | cMask1
 102382 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = I16(*(*int32)(unsafe.Pointer(pTerm + 24)))
 102383 	pColl = Xsqlite3ExprCompareCollSeq(tls, pParse, pX)
 102384 
 102385 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*4)) = func() uintptr {
 102386 		if pColl != 0 {
 102387 			return (*CollSeq)(unsafe.Pointer(pColl)).FzName
 102388 		}
 102389 		return uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 102390 	}()
 102391 	n++
 102392 __19:
 102393 	;
 102394 __18:
 102395 	;
 102396 	goto __16
 102397 __16:
 102398 	pTerm += 48
 102399 	goto __15
 102400 	goto __17
 102401 __17:
 102402 	;
 102403 	i = 0
 102404 __20:
 102405 	if !(i < mxBitCol) {
 102406 		goto __22
 102407 	}
 102408 	if !(extraCols&(uint64(1)<<i) != 0) {
 102409 		goto __23
 102410 	}
 102411 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = I16(i)
 102412 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*4)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 102413 	n++
 102414 __23:
 102415 	;
 102416 	goto __21
 102417 __21:
 102418 	i++
 102419 	goto __20
 102420 	goto __22
 102421 __22:
 102422 	;
 102423 	if !((*SrcItem)(unsafe.Pointer(pSrc)).FcolUsed&(uint64(1)<<(int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1)) != 0) {
 102424 		goto __24
 102425 	}
 102426 	i = int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) - 1
 102427 __25:
 102428 	if !(i < int32((*Table)(unsafe.Pointer(pTable)).FnCol)) {
 102429 		goto __27
 102430 	}
 102431 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = I16(i)
 102432 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*4)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 102433 	n++
 102434 	goto __26
 102435 __26:
 102436 	i++
 102437 	goto __25
 102438 	goto __27
 102439 __27:
 102440 	;
 102441 __24:
 102442 	;
 102443 	*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = int16(-1)
 102444 	*(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*4)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 102445 
 102446 	(*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 102447 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenAutoindex, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, nKeyCol+1)
 102448 	Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx)
 102449 
 102450 	if !((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_BloomFilter) == U32(0)) {
 102451 		goto __28
 102452 	}
 102453 	(*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 102454 	Xsqlite3VdbeAddOp2(tls, v, OP_Blob, 10000, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter)
 102455 __28:
 102456 	;
 102457 	pTabItem = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 102458 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pTabItem + 36 + 4))&0x20>>5)) != 0) {
 102459 		goto __29
 102460 	}
 102461 	regYield = (*SrcItem)(unsafe.Pointer(pTabItem)).FregReturn
 102462 	addrCounter = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 0)
 102463 	Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, (*SrcItem)(unsafe.Pointer(pTabItem)).FaddrFillSub)
 102464 	addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, regYield)
 102465 
 102466 	goto __30
 102467 __29:
 102468 	addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur)
 102469 __30:
 102470 	;
 102471 	if !(pPartial != 0) {
 102472 		goto __31
 102473 	}
 102474 	iContinue = Xsqlite3VdbeMakeLabel(tls, pParse)
 102475 	Xsqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, SQLITE_JUMPIFNULL)
 102476 	*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_PARTIALIDX)
 102477 __31:
 102478 	;
 102479 	regRecord = Xsqlite3GetTempReg(tls, pParse)
 102480 	regBase = Xsqlite3GenerateIndexKey(tls,
 102481 		pParse, pIdx, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0)
 102482 	if !((*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0) {
 102483 		goto __32
 102484 	}
 102485 	Xsqlite3VdbeAddOp4Int(tls, v, OP_FilterAdd, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0,
 102486 		regBase, int32(*(*U16)(unsafe.Pointer(pLoop + 24))))
 102487 __32:
 102488 	;
 102489 	Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord)
 102490 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT))
 102491 	if !(pPartial != 0) {
 102492 		goto __33
 102493 	}
 102494 	Xsqlite3VdbeResolveLabel(tls, v, iContinue)
 102495 __33:
 102496 	;
 102497 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pTabItem + 36 + 4))&0x20>>5)) != 0) {
 102498 		goto __34
 102499 	}
 102500 	Xsqlite3VdbeChangeP2(tls, v, addrCounter, regBase+n)
 102501 
 102502 	translateColumnToCopy(tls, pParse, addrTop, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur,
 102503 		(*SrcItem)(unsafe.Pointer(pTabItem)).FregResult, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur)
 102504 	Xsqlite3VdbeGoto(tls, v, addrTop)
 102505 	libc.SetBitFieldPtr16Uint32(pTabItem+36+4, uint32(0), 5, 0x20)
 102506 	goto __35
 102507 __34:
 102508 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+1)
 102509 	Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_STMTSTATUS_AUTOINDEX))
 102510 __35:
 102511 	;
 102512 	Xsqlite3VdbeJumpHere(tls, v, addrTop)
 102513 	Xsqlite3ReleaseTempReg(tls, pParse, regRecord)
 102514 
 102515 	Xsqlite3VdbeJumpHere(tls, v, addrInit)
 102516 
 102517 end_auto_index_create:
 102518 	Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pPartial)
 102519 }
 102520 
 102521 func sqlite3ConstructBloomFilter(tls *libc.TLS, pWInfo uintptr, iLevel int32, pLevel uintptr, notReady Bitmask) {
 102522 	var addrOnce int32
 102523 	var addrTop int32
 102524 	var addrCont int32
 102525 	var pTerm uintptr
 102526 	var pWCEnd uintptr
 102527 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 102528 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 102529 	var pLoop uintptr = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 102530 	var iCur int32
 102531 	var saved_pIdxEpr uintptr
 102532 
 102533 	saved_pIdxEpr = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr
 102534 	(*Parse)(unsafe.Pointer(pParse)).FpIdxEpr = uintptr(0)
 102535 
 102536 	addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
 102537 	for __ccgo := true; __ccgo; __ccgo = iLevel < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) {
 102538 		var pItem uintptr
 102539 		var pTab uintptr
 102540 		var sz U64
 102541 		Xsqlite3WhereExplainBloomFilter(tls, pParse, pWInfo, pLevel)
 102542 		addrCont = Xsqlite3VdbeMakeLabel(tls, pParse)
 102543 		iCur = (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur
 102544 		(*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 102545 
 102546 		pItem = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 102547 
 102548 		pTab = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
 102549 
 102550 		sz = Xsqlite3LogEstToInt(tls, (*Table)(unsafe.Pointer(pTab)).FnRowLogEst)
 102551 		if sz < uint64(10000) {
 102552 			sz = uint64(10000)
 102553 		} else if sz > uint64(10000000) {
 102554 			sz = uint64(10000000)
 102555 		}
 102556 		Xsqlite3VdbeAddOp2(tls, v, OP_Blob, int32(sz), (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter)
 102557 
 102558 		addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iCur)
 102559 		pWCEnd = (*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + uintptr((*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.FnTerm)*48
 102560 		for pTerm = (*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa; pTerm < pWCEnd; pTerm += 48 {
 102561 			var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 102562 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VIRTUAL == 0 &&
 102563 				Xsqlite3ExprIsTableConstraint(tls, pExpr, pItem) != 0 {
 102564 				Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, SQLITE_JUMPIFNULL)
 102565 			}
 102566 		}
 102567 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK) != 0 {
 102568 			var r1 int32 = Xsqlite3GetTempReg(tls, pParse)
 102569 			Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCur, r1)
 102570 			Xsqlite3VdbeAddOp4Int(tls, v, OP_FilterAdd, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, r1, 1)
 102571 			Xsqlite3ReleaseTempReg(tls, pParse, r1)
 102572 		} else {
 102573 			var pIdx uintptr = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
 102574 			var n int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24)))
 102575 			var r1 int32 = Xsqlite3GetTempRange(tls, pParse, n)
 102576 			var jj int32
 102577 			for jj = 0; jj < n; jj++ {
 102578 				Xsqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iCur, jj, r1+jj)
 102579 			}
 102580 			Xsqlite3VdbeAddOp4Int(tls, v, OP_FilterAdd, (*WhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, r1, n)
 102581 			Xsqlite3ReleaseTempRange(tls, pParse, r1, n)
 102582 		}
 102583 		Xsqlite3VdbeResolveLabel(tls, v, addrCont)
 102584 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+1)
 102585 
 102586 		Xsqlite3VdbeJumpHere(tls, v, addrTop)
 102587 		*(*U32)(unsafe.Pointer(pLoop + 44)) &= libc.Uint32FromInt32(libc.CplInt32(WHERE_BLOOMFILTER))
 102588 		if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_BloomPulldown) != U32(0) {
 102589 			break
 102590 		}
 102591 		for libc.PreIncInt32(&iLevel, 1) < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) {
 102592 			var pTabItem uintptr
 102593 			pLevel = pWInfo + 760 + uintptr(iLevel)*88
 102594 			pTabItem = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 102595 			if int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ) != 0 {
 102596 				continue
 102597 			}
 102598 			pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 102599 			if pLoop == uintptr(0) {
 102600 				continue
 102601 			}
 102602 			if (*WhereLoop)(unsafe.Pointer(pLoop)).Fprereq&notReady != 0 {
 102603 				continue
 102604 			}
 102605 			if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BLOOMFILTER|WHERE_COLUMN_IN) ==
 102606 				U32(WHERE_BLOOMFILTER) {
 102607 				break
 102608 			}
 102609 		}
 102610 	}
 102611 	Xsqlite3VdbeJumpHere(tls, v, addrOnce)
 102612 	(*Parse)(unsafe.Pointer(pParse)).FpIdxEpr = saved_pIdxEpr
 102613 }
 102614 
 102615 func allocateIndexInfo(tls *libc.TLS, pWInfo uintptr, pWC uintptr, mUnusable Bitmask, pSrc uintptr, pmNoOmit uintptr) uintptr {
 102616 	var i int32
 102617 	var j int32
 102618 	var nTerm int32
 102619 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 102620 	var pIdxCons uintptr
 102621 	var pIdxOrderBy uintptr
 102622 	var pUsage uintptr
 102623 	var pHidden uintptr
 102624 	var pTerm uintptr
 102625 	var nOrderBy int32
 102626 	var pIdxInfo uintptr
 102627 	var mNoOmit U16 = U16(0)
 102628 	var pTab uintptr
 102629 	var eDistinct int32 = 0
 102630 	var pOrderBy uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy
 102631 
 102632 	pTab = (*SrcItem)(unsafe.Pointer(pSrc)).FpTab
 102633 
 102634 	i = libc.AssignInt32(&nTerm, 0)
 102635 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 102636 __1:
 102637 	if !(i < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm) {
 102638 		goto __3
 102639 	}
 102640 	{
 102641 		*(*U16)(unsafe.Pointer(pTerm + 10)) &= libc.Uint16FromInt32(libc.CplInt32(TERM_OK))
 102642 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor {
 102643 			goto __2
 102644 		}
 102645 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&mUnusable != 0 {
 102646 			goto __2
 102647 		}
 102648 
 102649 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&libc.CplInt32(WO_EQUIV) == 0 {
 102650 			goto __2
 102651 		}
 102652 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VNULL != 0 {
 102653 			goto __2
 102654 		}
 102655 
 102656 		if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0 &&
 102657 			!(constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) {
 102658 			goto __2
 102659 		}
 102660 		nTerm++
 102661 		*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_OK)
 102662 
 102663 	}
 102664 	goto __2
 102665 __2:
 102666 	i++
 102667 	pTerm += 48
 102668 	goto __1
 102669 	goto __3
 102670 __3:
 102671 	;
 102672 	nOrderBy = 0
 102673 	if pOrderBy != 0 {
 102674 		var n int32 = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr
 102675 		for i = 0; i < n; i++ {
 102676 			var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20)).FpExpr
 102677 			var pE2 uintptr
 102678 
 102679 			if Xsqlite3ExprIsConstant(tls, pExpr) != 0 {
 102680 				continue
 102681 			}
 102682 
 102683 			if int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).Ffg.FsortFlags)&KEYINFO_ORDER_BIGNULL != 0 {
 102684 				break
 102685 			}
 102686 
 102687 			if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN && (*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor {
 102688 				continue
 102689 			}
 102690 
 102691 			if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE &&
 102692 				int32((*Expr)(unsafe.Pointer(libc.AssignUintptr(&pE2, (*Expr)(unsafe.Pointer(pExpr)).FpLeft))).Fop) == TK_COLUMN &&
 102693 				(*Expr)(unsafe.Pointer(pE2)).FiTable == (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor {
 102694 				var zColl uintptr
 102695 
 102696 				(*Expr)(unsafe.Pointer(pExpr)).FiColumn = (*Expr)(unsafe.Pointer(pE2)).FiColumn
 102697 				if int32((*Expr)(unsafe.Pointer(pE2)).FiColumn) < 0 {
 102698 					continue
 102699 				}
 102700 				zColl = Xsqlite3ColumnColl(tls, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Expr)(unsafe.Pointer(pE2)).FiColumn)*16)
 102701 				if zColl == uintptr(0) {
 102702 					zColl = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 102703 				}
 102704 				if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), zColl) == 0 {
 102705 					continue
 102706 				}
 102707 			}
 102708 
 102709 			break
 102710 		}
 102711 		if i == n {
 102712 			nOrderBy = n
 102713 			if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_DISTINCTBY != 0 {
 102714 				eDistinct = 2 + libc.Bool32(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_SORTBYGROUP != 0)
 102715 			} else if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_GROUPBY != 0 {
 102716 				eDistinct = 1
 102717 			}
 102718 		}
 102719 	}
 102720 
 102721 	pIdxInfo = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(unsafe.Sizeof(Sqlite3_index_info{}))+
 102722 		(uint32(unsafe.Sizeof(sqlite3_index_constraint{}))+uint32(unsafe.Sizeof(sqlite3_index_constraint_usage{})))*uint32(nTerm)+
 102723 		uint32(unsafe.Sizeof(sqlite3_index_orderby{}))*uint32(nOrderBy)+uint32(unsafe.Sizeof(HiddenIndexInfo1{}))+
 102724 		uint32(unsafe.Sizeof(uintptr(0)))*uint32(nTerm)))
 102725 	if pIdxInfo == uintptr(0) {
 102726 		Xsqlite3ErrorMsg(tls, pParse, ts+1490, 0)
 102727 		return uintptr(0)
 102728 	}
 102729 	pHidden = pIdxInfo + 1*72
 102730 	pIdxCons = pHidden + 20 + uintptr(nTerm)*4
 102731 	pIdxOrderBy = pIdxCons + uintptr(nTerm)*12
 102732 	pUsage = pIdxOrderBy + uintptr(nOrderBy)*8
 102733 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint = pIdxCons
 102734 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy = pIdxOrderBy
 102735 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage = pUsage
 102736 	(*HiddenIndexInfo1)(unsafe.Pointer(pHidden)).FpWC = pWC
 102737 	(*HiddenIndexInfo1)(unsafe.Pointer(pHidden)).FpParse = pParse
 102738 	(*HiddenIndexInfo1)(unsafe.Pointer(pHidden)).FeDistinct = eDistinct
 102739 	(*HiddenIndexInfo1)(unsafe.Pointer(pHidden)).FmIn = U32(0)
 102740 	i = libc.AssignInt32(&j, 0)
 102741 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 102742 __4:
 102743 	if !(i < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm) {
 102744 		goto __6
 102745 	}
 102746 	{
 102747 		var op U16
 102748 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_OK == 0 {
 102749 			goto __5
 102750 		}
 102751 		(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).FiColumn = *(*int32)(unsafe.Pointer(pTerm + 24))
 102752 		(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).FiTermOffset = i
 102753 		op = U16(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ALL)
 102754 		if int32(op) == WO_IN {
 102755 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_SLICE == 0 {
 102756 				*(*U32)(unsafe.Pointer(pHidden + 12)) |= func() uint32 {
 102757 					if j <= 31 {
 102758 						return uint32(1) << j
 102759 					}
 102760 					return uint32(0)
 102761 				}()
 102762 			}
 102763 			op = U16(WO_EQ)
 102764 		}
 102765 		if int32(op) == WO_AUX {
 102766 			(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp
 102767 		} else if int32(op)&(WO_ISNULL|WO_IS) != 0 {
 102768 			if int32(op) == WO_ISNULL {
 102769 				(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(SQLITE_INDEX_CONSTRAINT_ISNULL)
 102770 			} else {
 102771 				(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(SQLITE_INDEX_CONSTRAINT_IS)
 102772 			}
 102773 		} else {
 102774 			(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = U8(op)
 102775 
 102776 			if int32(op)&(int32(WO_EQ)<<(TK_LT-TK_EQ)|int32(WO_EQ)<<(TK_LE-TK_EQ)|int32(WO_EQ)<<(TK_GT-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) != 0 &&
 102777 				Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight) != 0 {
 102778 				if j < 16 {
 102779 					mNoOmit = U16(int32(mNoOmit) | int32(1)<<j)
 102780 				}
 102781 				if int32(op) == int32(WO_EQ)<<(TK_LT-TK_EQ) {
 102782 					(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(int32(WO_EQ) << (TK_LE - TK_EQ))
 102783 				}
 102784 				if int32(op) == int32(WO_EQ)<<(TK_GT-TK_EQ) {
 102785 					(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(int32(WO_EQ) << (TK_GE - TK_EQ))
 102786 				}
 102787 			}
 102788 		}
 102789 
 102790 		j++
 102791 
 102792 	}
 102793 	goto __5
 102794 __5:
 102795 	i++
 102796 	pTerm += 48
 102797 	goto __4
 102798 	goto __6
 102799 __6:
 102800 	;
 102801 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint = j
 102802 	for i = libc.AssignInt32(&j, 0); i < nOrderBy; i++ {
 102803 		var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20)).FpExpr
 102804 		if Xsqlite3ExprIsConstant(tls, pExpr) != 0 {
 102805 			continue
 102806 		}
 102807 
 102808 		(*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(j)*8)).FiColumn = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)
 102809 		(*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(j)*8)).Fdesc = uint8(int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).Ffg.FsortFlags) & KEYINFO_ORDER_DESC)
 102810 		j++
 102811 	}
 102812 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy = j
 102813 
 102814 	*(*U16)(unsafe.Pointer(pmNoOmit)) = mNoOmit
 102815 	return pIdxInfo
 102816 }
 102817 
 102818 func freeIndexInfo(tls *libc.TLS, db uintptr, pIdxInfo uintptr) {
 102819 	var pHidden uintptr
 102820 	var i int32
 102821 
 102822 	pHidden = pIdxInfo + 1*72
 102823 
 102824 	for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ {
 102825 		Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(pHidden + 20 + uintptr(i)*4)))
 102826 		*(*uintptr)(unsafe.Pointer(pHidden + 20 + uintptr(i)*4)) = uintptr(0)
 102827 	}
 102828 	Xsqlite3DbFree(tls, db, pIdxInfo)
 102829 }
 102830 
 102831 func vtabBestIndex(tls *libc.TLS, pParse uintptr, pTab uintptr, p uintptr) int32 {
 102832 	bp := tls.Alloc(16)
 102833 	defer tls.Free(16)
 102834 
 102835 	var pVtab uintptr = (*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpVtab
 102836 	var rc int32
 102837 
 102838 	(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FnSchemaLock++
 102839 	rc = (*struct {
 102840 		f func(*libc.TLS, uintptr, uintptr) int32
 102841 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule)).FxBestIndex})).f(tls, pVtab, p)
 102842 	(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FnSchemaLock--
 102843 
 102844 	if rc != SQLITE_OK && rc != SQLITE_CONSTRAINT {
 102845 		if rc == SQLITE_NOMEM {
 102846 			Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb)
 102847 		} else if !(int32((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) != 0) {
 102848 			Xsqlite3ErrorMsg(tls, pParse, ts+3663, libc.VaList(bp, Xsqlite3ErrStr(tls, rc)))
 102849 		} else {
 102850 			Xsqlite3ErrorMsg(tls, pParse, ts+3663, libc.VaList(bp+8, (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg))
 102851 		}
 102852 	}
 102853 	Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg)
 102854 	(*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = uintptr(0)
 102855 	return rc
 102856 }
 102857 
 102858 func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, roundUp int32, aStat uintptr) int32 {
 102859 	var aSample uintptr = (*Index)(unsafe.Pointer(pIdx)).FaSample
 102860 	var iCol int32
 102861 	var i int32
 102862 	var iSample int32
 102863 	var iMin int32 = 0
 102864 	var iTest int32
 102865 	var res int32
 102866 	var nField int32
 102867 	var iLower TRowcnt = uint64(0)
 102868 
 102869 	_ = pParse
 102870 
 102871 	if !((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) && int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY {
 102872 		nField = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)
 102873 	} else {
 102874 		nField = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)
 102875 	}
 102876 	nField = func() int32 {
 102877 		if int32((*UnpackedRecord)(unsafe.Pointer(pRec)).FnField) < nField {
 102878 			return int32((*UnpackedRecord)(unsafe.Pointer(pRec)).FnField)
 102879 		}
 102880 		return nField
 102881 	}()
 102882 	iCol = 0
 102883 	iSample = (*Index)(unsafe.Pointer(pIdx)).FnSample * nField
 102884 	for __ccgo := true; __ccgo; __ccgo = res != 0 && iMin < iSample {
 102885 		var iSamp int32
 102886 		var n int32
 102887 
 102888 		iTest = (iMin + iSample) / 2
 102889 		iSamp = iTest / nField
 102890 		if iSamp > 0 {
 102891 			for n = iTest%nField + 1; n < nField; n++ {
 102892 				if *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp-1)*20)).FanLt + uintptr(n-1)*8)) != *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp)*20)).FanLt + uintptr(n-1)*8)) {
 102893 					break
 102894 				}
 102895 			}
 102896 		} else {
 102897 			n = iTest + 1
 102898 		}
 102899 
 102900 		(*UnpackedRecord)(unsafe.Pointer(pRec)).FnField = U16(n)
 102901 		res = Xsqlite3VdbeRecordCompare(tls, (*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp)*20)).Fn, (*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp)*20)).Fp, pRec)
 102902 		if res < 0 {
 102903 			iLower = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp)*20)).FanLt + uintptr(n-1)*8)) + *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp)*20)).FanEq + uintptr(n-1)*8))
 102904 			iMin = iTest + 1
 102905 		} else if res == 0 && n < nField {
 102906 			iLower = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(iSamp)*20)).FanLt + uintptr(n-1)*8))
 102907 			iMin = iTest + 1
 102908 			res = -1
 102909 		} else {
 102910 			iSample = iTest
 102911 			iCol = n - 1
 102912 		}
 102913 	}
 102914 	i = iSample / nField
 102915 
 102916 	if res == 0 {
 102917 		*(*TRowcnt)(unsafe.Pointer(aStat)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*20)).FanLt + uintptr(iCol)*8))
 102918 		*(*TRowcnt)(unsafe.Pointer(aStat + 1*8)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*20)).FanEq + uintptr(iCol)*8))
 102919 	} else {
 102920 		var iUpper TRowcnt
 102921 		var iGap TRowcnt
 102922 		if i >= (*Index)(unsafe.Pointer(pIdx)).FnSample {
 102923 			iUpper = (*Index)(unsafe.Pointer(pIdx)).FnRowEst0
 102924 		} else {
 102925 			iUpper = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*20)).FanLt + uintptr(iCol)*8))
 102926 		}
 102927 
 102928 		if iLower >= iUpper {
 102929 			iGap = uint64(0)
 102930 		} else {
 102931 			iGap = iUpper - iLower
 102932 		}
 102933 		if roundUp != 0 {
 102934 			iGap = iGap * uint64(2) / uint64(3)
 102935 		} else {
 102936 			iGap = iGap / uint64(3)
 102937 		}
 102938 		*(*TRowcnt)(unsafe.Pointer(aStat)) = iLower + iGap
 102939 		*(*TRowcnt)(unsafe.Pointer(aStat + 1*8)) = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr(nField-1)*8))
 102940 	}
 102941 
 102942 	(*UnpackedRecord)(unsafe.Pointer(pRec)).FnField = U16(nField)
 102943 	return i
 102944 }
 102945 
 102946 func whereRangeAdjust(tls *libc.TLS, pTerm uintptr, nNew LogEst) LogEst {
 102947 	var nRet LogEst = nNew
 102948 	if pTerm != 0 {
 102949 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 {
 102950 			nRet = LogEst(int32(nRet) + int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))
 102951 		} else if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VNULL == 0 {
 102952 			nRet = int16(int32(nRet) - 20)
 102953 		}
 102954 	}
 102955 	return nRet
 102956 }
 102957 
 102958 // Return the affinity for a single column of an index.
 102959 func Xsqlite3IndexColumnAffinity(tls *libc.TLS, db uintptr, pIdx uintptr, iCol int32) uint8 {
 102960 	if !(int32((*Index)(unsafe.Pointer(pIdx)).FzColAff) != 0) {
 102961 		if Xsqlite3IndexAffinityStr(tls, db, pIdx) == uintptr(0) {
 102962 			return uint8(SQLITE_AFF_BLOB)
 102963 		}
 102964 	}
 102965 
 102966 	return *(*uint8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FzColAff + uintptr(iCol)))
 102967 }
 102968 
 102969 func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper uintptr, pLoop uintptr, pbDone uintptr) int32 {
 102970 	bp := tls.Alloc(12)
 102971 	defer tls.Free(12)
 102972 
 102973 	var p uintptr = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
 102974 	var nEq int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24)))
 102975 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 102976 	var nLower int32 = -1
 102977 	var nUpper int32 = (*Index)(unsafe.Pointer(p)).FnSample + 1
 102978 	var rc int32 = SQLITE_OK
 102979 	var aff U8 = Xsqlite3IndexColumnAffinity(tls, db, p, nEq)
 102980 	var pColl uintptr
 102981 
 102982 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 102983 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 102984 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 102985 
 102986 	pColl = Xsqlite3LocateCollSeq(tls, pParse, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FazColl + uintptr(nEq)*4)))
 102987 	if pLower != 0 {
 102988 		rc = Xsqlite3Stat4ValueFromExpr(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight, aff, bp)
 102989 		nLower = 0
 102990 	}
 102991 	if pUpper != 0 && rc == SQLITE_OK {
 102992 		rc = Xsqlite3Stat4ValueFromExpr(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight, aff, bp+4)
 102993 		if *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
 102994 			nUpper = 0
 102995 		} else {
 102996 			nUpper = (*Index)(unsafe.Pointer(p)).FnSample
 102997 		}
 102998 	}
 102999 
 103000 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 || *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
 103001 		var i int32
 103002 		var nDiff int32
 103003 		for i = 0; rc == SQLITE_OK && i < (*Index)(unsafe.Pointer(p)).FnSample; i++ {
 103004 			rc = Xsqlite3Stat4Column(tls, db, (*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSample+uintptr(i)*20)).Fp, (*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSample+uintptr(i)*20)).Fn, nEq, bp+8)
 103005 			if rc == SQLITE_OK && *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 103006 				var res int32 = Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 8)), pColl)
 103007 				if res >= 0 {
 103008 					nLower++
 103009 				}
 103010 			}
 103011 			if rc == SQLITE_OK && *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
 103012 				var res int32 = Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), *(*uintptr)(unsafe.Pointer(bp + 8)), pColl)
 103013 				if res >= 0 {
 103014 					nUpper++
 103015 				}
 103016 			}
 103017 		}
 103018 		nDiff = nUpper - nLower
 103019 		if nDiff <= 0 {
 103020 			nDiff = 1
 103021 		}
 103022 
 103023 		if nDiff != 1 || pUpper == uintptr(0) || pLower == uintptr(0) {
 103024 			var nAdjust int32 = int32(Xsqlite3LogEst(tls, uint64((*Index)(unsafe.Pointer(p)).FnSample))) - int32(Xsqlite3LogEst(tls, uint64(nDiff)))
 103025 			*(*LogEst)(unsafe.Pointer(pLoop + 22)) -= LogEst(nAdjust)
 103026 			*(*int32)(unsafe.Pointer(pbDone)) = 1
 103027 
 103028 		}
 103029 
 103030 	} else {
 103031 	}
 103032 
 103033 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
 103034 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 103035 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 103036 
 103037 	return rc
 103038 }
 103039 
 103040 func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower uintptr, pUpper uintptr, pLoop uintptr) int32 {
 103041 	bp := tls.Alloc(32)
 103042 	defer tls.Free(32)
 103043 
 103044 	var rc int32 = SQLITE_OK
 103045 	var nOut int32 = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnOut)
 103046 	var nNew LogEst
 103047 
 103048 	var p uintptr = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
 103049 	var nEq int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24)))
 103050 
 103051 	if (*Index)(unsafe.Pointer(p)).FnSample > 0 && nEq < (*Index)(unsafe.Pointer(p)).FnSampleCol &&
 103052 		(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) {
 103053 		if nEq == (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid {
 103054 			*(*uintptr)(unsafe.Pointer(bp + 16)) = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec
 103055 
 103056 			var nBtm int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 2)))
 103057 			var nTop int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 4)))
 103058 
 103059 			var iLower TRowcnt
 103060 			var iUpper TRowcnt
 103061 			var iLwrIdx int32 = -2
 103062 			var iUprIdx int32 = -1
 103063 
 103064 			if *(*uintptr)(unsafe.Pointer(bp + 16)) != 0 {
 103065 				(*UnpackedRecord)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)))).FnField = U16((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid)
 103066 			}
 103067 
 103068 			if nEq == 0 {
 103069 				iLower = uint64(0)
 103070 				iUpper = (*Index)(unsafe.Pointer(p)).FnRowEst0
 103071 			} else {
 103072 				whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 16)), 0, bp)
 103073 				iLower = *(*TRowcnt)(unsafe.Pointer(bp))
 103074 				iUpper = *(*TRowcnt)(unsafe.Pointer(bp)) + *(*TRowcnt)(unsafe.Pointer(bp + 1*8))
 103075 			}
 103076 
 103077 			if *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSortOrder + uintptr(nEq))) != 0 {
 103078 				{
 103079 					var t uintptr = pLower
 103080 					pLower = pUpper
 103081 					pUpper = t
 103082 				}
 103083 
 103084 				{
 103085 					var t int32 = nBtm
 103086 					nBtm = nTop
 103087 					nTop = t
 103088 				}
 103089 
 103090 			}
 103091 
 103092 			if pLower != 0 {
 103093 				var pExpr uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight
 103094 				rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp+16, pExpr, nBtm, nEq, bp+20)
 103095 				if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 20)) != 0 {
 103096 					var iNew TRowcnt
 103097 					var mask U16 = U16(int32(WO_EQ)<<(TK_GT-TK_EQ) | int32(WO_EQ)<<(TK_LE-TK_EQ))
 103098 					if Xsqlite3ExprVectorSize(tls, pExpr) > *(*int32)(unsafe.Pointer(bp + 20)) {
 103099 						mask = U16(int32(WO_EQ)<<(TK_LE-TK_EQ) | int32(WO_EQ)<<(TK_LT-TK_EQ))
 103100 					}
 103101 					iLwrIdx = whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 16)), 0, bp)
 103102 					iNew = *(*TRowcnt)(unsafe.Pointer(bp)) + func() uint64 {
 103103 						if int32((*WhereTerm)(unsafe.Pointer(pLower)).FeOperator)&int32(mask) != 0 {
 103104 							return *(*TRowcnt)(unsafe.Pointer(bp + 1*8))
 103105 						}
 103106 						return uint64(0)
 103107 					}()
 103108 					if iNew > iLower {
 103109 						iLower = iNew
 103110 					}
 103111 					nOut--
 103112 					pLower = uintptr(0)
 103113 				}
 103114 			}
 103115 
 103116 			if pUpper != 0 {
 103117 				var pExpr uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight
 103118 				rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp+16, pExpr, nTop, nEq, bp+24)
 103119 				if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
 103120 					var iNew TRowcnt
 103121 					var mask U16 = U16(int32(WO_EQ)<<(TK_GT-TK_EQ) | int32(WO_EQ)<<(TK_LE-TK_EQ))
 103122 					if Xsqlite3ExprVectorSize(tls, pExpr) > *(*int32)(unsafe.Pointer(bp + 24)) {
 103123 						mask = U16(int32(WO_EQ)<<(TK_LE-TK_EQ) | int32(WO_EQ)<<(TK_LT-TK_EQ))
 103124 					}
 103125 					iUprIdx = whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 16)), 1, bp)
 103126 					iNew = *(*TRowcnt)(unsafe.Pointer(bp)) + func() uint64 {
 103127 						if int32((*WhereTerm)(unsafe.Pointer(pUpper)).FeOperator)&int32(mask) != 0 {
 103128 							return *(*TRowcnt)(unsafe.Pointer(bp + 1*8))
 103129 						}
 103130 						return uint64(0)
 103131 					}()
 103132 					if iNew < iUpper {
 103133 						iUpper = iNew
 103134 					}
 103135 					nOut--
 103136 					pUpper = uintptr(0)
 103137 				}
 103138 			}
 103139 
 103140 			(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = *(*uintptr)(unsafe.Pointer(bp + 16))
 103141 			if rc == SQLITE_OK {
 103142 				if iUpper > iLower {
 103143 					nNew = Xsqlite3LogEst(tls, iUpper-iLower)
 103144 
 103145 					if iLwrIdx == iUprIdx {
 103146 						nNew = int16(int32(nNew) - 20)
 103147 					}
 103148 				} else {
 103149 					nNew = int16(10)
 103150 				}
 103151 				if int32(nNew) < nOut {
 103152 					nOut = int32(nNew)
 103153 				}
 103154 
 103155 			}
 103156 		} else {
 103157 			*(*int32)(unsafe.Pointer(bp + 28)) = 0
 103158 			rc = whereRangeSkipScanEst(tls, pParse, pLower, pUpper, pLoop, bp+28)
 103159 			if *(*int32)(unsafe.Pointer(bp + 28)) != 0 {
 103160 				return rc
 103161 			}
 103162 		}
 103163 	}
 103164 
 103165 	nNew = whereRangeAdjust(tls, pLower, int16(nOut))
 103166 	nNew = whereRangeAdjust(tls, pUpper, nNew)
 103167 
 103168 	if pLower != 0 && int32((*WhereTerm)(unsafe.Pointer(pLower)).FtruthProb) > 0 && pUpper != 0 && int32((*WhereTerm)(unsafe.Pointer(pUpper)).FtruthProb) > 0 {
 103169 		nNew = int16(int32(nNew) - 20)
 103170 	}
 103171 
 103172 	nOut = nOut - (libc.Bool32(pLower != uintptr(0)) + libc.Bool32(pUpper != uintptr(0)))
 103173 	if int32(nNew) < 10 {
 103174 		nNew = int16(10)
 103175 	}
 103176 	if int32(nNew) < nOut {
 103177 		nOut = int32(nNew)
 103178 	}
 103179 	(*WhereLoop)(unsafe.Pointer(pLoop)).FnOut = LogEst(nOut)
 103180 	return rc
 103181 }
 103182 
 103183 func whereEqualScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pExpr uintptr, pnRow uintptr) int32 {
 103184 	bp := tls.Alloc(24)
 103185 	defer tls.Free(24)
 103186 
 103187 	var p uintptr = *(*uintptr)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24 + 8))
 103188 	var nEq int32 = int32(*(*U16)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24)))
 103189 	*(*uintptr)(unsafe.Pointer(bp)) = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec
 103190 	var rc int32
 103191 
 103192 	if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid < nEq-1 {
 103193 		return SQLITE_NOTFOUND
 103194 	}
 103195 
 103196 	if nEq >= int32((*Index)(unsafe.Pointer(p)).FnColumn) {
 103197 		*(*TRowcnt)(unsafe.Pointer(pnRow)) = uint64(1)
 103198 		return SQLITE_OK
 103199 	}
 103200 
 103201 	rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp, pExpr, 1, nEq-1, bp+4)
 103202 	(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = *(*uintptr)(unsafe.Pointer(bp))
 103203 	if rc != SQLITE_OK {
 103204 		return rc
 103205 	}
 103206 	if *(*int32)(unsafe.Pointer(bp + 4)) == 0 {
 103207 		return SQLITE_NOTFOUND
 103208 	}
 103209 	(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nEq
 103210 
 103211 	whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp)), 0, bp+8)
 103212 
 103213 	*(*TRowcnt)(unsafe.Pointer(pnRow)) = *(*TRowcnt)(unsafe.Pointer(bp + 8 + 1*8))
 103214 
 103215 	return rc
 103216 }
 103217 
 103218 func whereInScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pList uintptr, pnRow uintptr) int32 {
 103219 	bp := tls.Alloc(8)
 103220 	defer tls.Free(8)
 103221 
 103222 	var p uintptr = *(*uintptr)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24 + 8))
 103223 	var nRow0 I64 = I64(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaiRowLogEst))))
 103224 	var nRecValid int32 = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid
 103225 	var rc int32 = SQLITE_OK
 103226 
 103227 	var nRowEst TRowcnt = uint64(0)
 103228 	var i int32
 103229 
 103230 	for i = 0; rc == SQLITE_OK && i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ {
 103231 		*(*TRowcnt)(unsafe.Pointer(bp)) = TRowcnt(nRow0)
 103232 		rc = whereEqualScanEst(tls, pParse, pBuilder, (*ExprList_item)(unsafe.Pointer(pList+8+uintptr(i)*20)).FpExpr, bp)
 103233 		nRowEst = nRowEst + *(*TRowcnt)(unsafe.Pointer(bp))
 103234 		(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nRecValid
 103235 	}
 103236 
 103237 	if rc == SQLITE_OK {
 103238 		if nRowEst > TRowcnt(nRow0) {
 103239 			nRowEst = TRowcnt(nRow0)
 103240 		}
 103241 		*(*TRowcnt)(unsafe.Pointer(pnRow)) = nRowEst
 103242 
 103243 	}
 103244 
 103245 	return rc
 103246 }
 103247 
 103248 func whereLoopInit(tls *libc.TLS, p uintptr) {
 103249 	(*WhereLoop)(unsafe.Pointer(p)).FaLTerm = p + 64
 103250 	(*WhereLoop)(unsafe.Pointer(p)).FnLTerm = U16(0)
 103251 	(*WhereLoop)(unsafe.Pointer(p)).FnLSlot = U16(int32(uint32(unsafe.Sizeof([3]uintptr{})) / uint32(unsafe.Sizeof(uintptr(0)))))
 103252 	(*WhereLoop)(unsafe.Pointer(p)).FwsFlags = U32(0)
 103253 }
 103254 
 103255 func whereLoopClearUnion(tls *libc.TLS, db uintptr, p uintptr) {
 103256 	if (*WhereLoop)(unsafe.Pointer(p)).FwsFlags&U32(WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) != 0 {
 103257 		if (*WhereLoop)(unsafe.Pointer(p)).FwsFlags&U32(WHERE_VIRTUALTABLE) != U32(0) && U32(int32(*(*uint8)(unsafe.Pointer(p + 24 + 4))&0x1>>0)) != 0 {
 103258 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(p + 24 + 12)))
 103259 			libc.SetBitFieldPtr8Uint32(p+24+4, U32(0), 0, 0x1)
 103260 			*(*uintptr)(unsafe.Pointer(p + 24 + 12)) = uintptr(0)
 103261 		} else if (*WhereLoop)(unsafe.Pointer(p)).FwsFlags&U32(WHERE_AUTO_INDEX) != U32(0) && *(*uintptr)(unsafe.Pointer(p + 24 + 8)) != uintptr(0) {
 103262 			Xsqlite3DbFree(tls, db, (*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 24 + 8)))).FzColAff)
 103263 			Xsqlite3DbFreeNN(tls, db, *(*uintptr)(unsafe.Pointer(p + 24 + 8)))
 103264 			*(*uintptr)(unsafe.Pointer(p + 24 + 8)) = uintptr(0)
 103265 		}
 103266 	}
 103267 }
 103268 
 103269 func whereLoopClear(tls *libc.TLS, db uintptr, p uintptr) {
 103270 	if (*WhereLoop)(unsafe.Pointer(p)).FaLTerm != p+64 {
 103271 		Xsqlite3DbFreeNN(tls, db, (*WhereLoop)(unsafe.Pointer(p)).FaLTerm)
 103272 		(*WhereLoop)(unsafe.Pointer(p)).FaLTerm = p + 64
 103273 		(*WhereLoop)(unsafe.Pointer(p)).FnLSlot = U16(int32(uint32(unsafe.Sizeof([3]uintptr{})) / uint32(unsafe.Sizeof(uintptr(0)))))
 103274 	}
 103275 	whereLoopClearUnion(tls, db, p)
 103276 	(*WhereLoop)(unsafe.Pointer(p)).FnLTerm = U16(0)
 103277 	(*WhereLoop)(unsafe.Pointer(p)).FwsFlags = U32(0)
 103278 }
 103279 
 103280 func whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) int32 {
 103281 	var paNew uintptr
 103282 	if int32((*WhereLoop)(unsafe.Pointer(p)).FnLSlot) >= n {
 103283 		return SQLITE_OK
 103284 	}
 103285 	n = (n + 7) & libc.CplInt32(7)
 103286 	paNew = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(unsafe.Sizeof(uintptr(0)))*uint32(n)))
 103287 	if paNew == uintptr(0) {
 103288 		return SQLITE_NOMEM
 103289 	}
 103290 	libc.Xmemcpy(tls, paNew, (*WhereLoop)(unsafe.Pointer(p)).FaLTerm, uint32(unsafe.Sizeof(uintptr(0)))*uint32((*WhereLoop)(unsafe.Pointer(p)).FnLSlot))
 103291 	if (*WhereLoop)(unsafe.Pointer(p)).FaLTerm != p+64 {
 103292 		Xsqlite3DbFreeNN(tls, db, (*WhereLoop)(unsafe.Pointer(p)).FaLTerm)
 103293 	}
 103294 	(*WhereLoop)(unsafe.Pointer(p)).FaLTerm = paNew
 103295 	(*WhereLoop)(unsafe.Pointer(p)).FnLSlot = U16(n)
 103296 	return SQLITE_OK
 103297 }
 103298 
 103299 func whereLoopXfer(tls *libc.TLS, db uintptr, pTo uintptr, pFrom uintptr) int32 {
 103300 	whereLoopClearUnion(tls, db, pTo)
 103301 	if int32((*WhereLoop)(unsafe.Pointer(pFrom)).FnLTerm) > int32((*WhereLoop)(unsafe.Pointer(pTo)).FnLSlot) &&
 103302 		whereLoopResize(tls, db, pTo, int32((*WhereLoop)(unsafe.Pointer(pFrom)).FnLTerm)) != 0 {
 103303 		libc.Xmemset(tls, pTo, 0, uint32(uintptr(0)+52))
 103304 		return SQLITE_NOMEM
 103305 	}
 103306 	libc.Xmemcpy(tls, pTo, pFrom, uint32(uintptr(0)+52))
 103307 	libc.Xmemcpy(tls, (*WhereLoop)(unsafe.Pointer(pTo)).FaLTerm, (*WhereLoop)(unsafe.Pointer(pFrom)).FaLTerm, uint32((*WhereLoop)(unsafe.Pointer(pTo)).FnLTerm)*uint32(unsafe.Sizeof(uintptr(0))))
 103308 	if (*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags&U32(WHERE_VIRTUALTABLE) != 0 {
 103309 		libc.SetBitFieldPtr8Uint32(pFrom+24+4, U32(0), 0, 0x1)
 103310 	} else if (*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags&U32(WHERE_AUTO_INDEX) != U32(0) {
 103311 		*(*uintptr)(unsafe.Pointer(pFrom + 24 + 8)) = uintptr(0)
 103312 	}
 103313 	return SQLITE_OK
 103314 }
 103315 
 103316 func whereLoopDelete(tls *libc.TLS, db uintptr, p uintptr) {
 103317 	whereLoopClear(tls, db, p)
 103318 	Xsqlite3DbNNFreeNN(tls, db, p)
 103319 }
 103320 
 103321 func whereInfoFree(tls *libc.TLS, db uintptr, pWInfo uintptr) {
 103322 	Xsqlite3WhereClauseClear(tls, pWInfo+80)
 103323 	for (*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops != 0 {
 103324 		var p uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops
 103325 		(*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops = (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop
 103326 		whereLoopDelete(tls, db, p)
 103327 	}
 103328 	for (*WhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree != 0 {
 103329 		var pNext uintptr = (*WhereMemBlock)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree)).FpNext
 103330 		Xsqlite3DbNNFreeNN(tls, db, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree)
 103331 		(*WhereInfo)(unsafe.Pointer(pWInfo)).FpMemToFree = pNext
 103332 	}
 103333 	Xsqlite3DbNNFreeNN(tls, db, pWInfo)
 103334 }
 103335 
 103336 func whereLoopCheaperProperSubset(tls *libc.TLS, pX uintptr, pY uintptr) int32 {
 103337 	var i int32
 103338 	var j int32
 103339 	if int32((*WhereLoop)(unsafe.Pointer(pX)).FnLTerm)-int32((*WhereLoop)(unsafe.Pointer(pX)).FnSkip) >= int32((*WhereLoop)(unsafe.Pointer(pY)).FnLTerm)-int32((*WhereLoop)(unsafe.Pointer(pY)).FnSkip) {
 103340 		return 0
 103341 	}
 103342 	if int32((*WhereLoop)(unsafe.Pointer(pX)).FrRun) > int32((*WhereLoop)(unsafe.Pointer(pY)).FrRun) && int32((*WhereLoop)(unsafe.Pointer(pX)).FnOut) > int32((*WhereLoop)(unsafe.Pointer(pY)).FnOut) {
 103343 		return 0
 103344 	}
 103345 	if int32((*WhereLoop)(unsafe.Pointer(pY)).FnSkip) > int32((*WhereLoop)(unsafe.Pointer(pX)).FnSkip) {
 103346 		return 0
 103347 	}
 103348 	for i = int32((*WhereLoop)(unsafe.Pointer(pX)).FnLTerm) - 1; i >= 0; i-- {
 103349 		if *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pX)).FaLTerm + uintptr(i)*4)) == uintptr(0) {
 103350 			continue
 103351 		}
 103352 		for j = int32((*WhereLoop)(unsafe.Pointer(pY)).FnLTerm) - 1; j >= 0; j-- {
 103353 			if *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pY)).FaLTerm + uintptr(j)*4)) == *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pX)).FaLTerm + uintptr(i)*4)) {
 103354 				break
 103355 			}
 103356 		}
 103357 		if j < 0 {
 103358 			return 0
 103359 		}
 103360 	}
 103361 	if (*WhereLoop)(unsafe.Pointer(pX)).FwsFlags&U32(WHERE_IDX_ONLY) != U32(0) &&
 103362 		(*WhereLoop)(unsafe.Pointer(pY)).FwsFlags&U32(WHERE_IDX_ONLY) == U32(0) {
 103363 		return 0
 103364 	}
 103365 	return 1
 103366 }
 103367 
 103368 func whereLoopAdjustCost(tls *libc.TLS, p uintptr, pTemplate uintptr) {
 103369 	if (*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags&U32(WHERE_INDEXED) == U32(0) {
 103370 		return
 103371 	}
 103372 	for ; p != 0; p = (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop {
 103373 		if int32((*WhereLoop)(unsafe.Pointer(p)).FiTab) != int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FiTab) {
 103374 			continue
 103375 		}
 103376 		if (*WhereLoop)(unsafe.Pointer(p)).FwsFlags&U32(WHERE_INDEXED) == U32(0) {
 103377 			continue
 103378 		}
 103379 		if whereLoopCheaperProperSubset(tls, p, pTemplate) != 0 {
 103380 			(*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun = func() int16 {
 103381 				if int32((*WhereLoop)(unsafe.Pointer(p)).FrRun) < int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun) {
 103382 					return (*WhereLoop)(unsafe.Pointer(p)).FrRun
 103383 				}
 103384 				return (*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun
 103385 			}()
 103386 			(*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut = func() int16 {
 103387 				if int32((*WhereLoop)(unsafe.Pointer(p)).FnOut)-1 < int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut) {
 103388 					return int16(int32((*WhereLoop)(unsafe.Pointer(p)).FnOut) - 1)
 103389 				}
 103390 				return (*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut
 103391 			}()
 103392 		} else if whereLoopCheaperProperSubset(tls, pTemplate, p) != 0 {
 103393 			(*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun = func() int16 {
 103394 				if int32((*WhereLoop)(unsafe.Pointer(p)).FrRun) > int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun) {
 103395 					return (*WhereLoop)(unsafe.Pointer(p)).FrRun
 103396 				}
 103397 				return (*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun
 103398 			}()
 103399 			(*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut = func() int16 {
 103400 				if int32((*WhereLoop)(unsafe.Pointer(p)).FnOut)+1 > int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut) {
 103401 					return int16(int32((*WhereLoop)(unsafe.Pointer(p)).FnOut) + 1)
 103402 				}
 103403 				return (*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut
 103404 			}()
 103405 		}
 103406 	}
 103407 }
 103408 
 103409 func whereLoopFindLesser(tls *libc.TLS, ppPrev uintptr, pTemplate uintptr) uintptr {
 103410 	var p uintptr
 103411 	p = *(*uintptr)(unsafe.Pointer(ppPrev))
 103412 __1:
 103413 	if !(p != 0) {
 103414 		goto __3
 103415 	}
 103416 	{
 103417 		if int32((*WhereLoop)(unsafe.Pointer(p)).FiTab) != int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FiTab) || int32((*WhereLoop)(unsafe.Pointer(p)).FiSortIdx) != int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FiSortIdx) {
 103418 			goto __2
 103419 		}
 103420 
 103421 		if (*WhereLoop)(unsafe.Pointer(p)).FwsFlags&U32(WHERE_AUTO_INDEX) != U32(0) &&
 103422 			int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnSkip) == 0 &&
 103423 			(*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags&U32(WHERE_INDEXED) != U32(0) &&
 103424 			(*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags&U32(WHERE_COLUMN_EQ) != U32(0) &&
 103425 			(*WhereLoop)(unsafe.Pointer(p)).Fprereq&(*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq == (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq {
 103426 			goto __3
 103427 		}
 103428 
 103429 		if (*WhereLoop)(unsafe.Pointer(p)).Fprereq&(*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq == (*WhereLoop)(unsafe.Pointer(p)).Fprereq &&
 103430 			int32((*WhereLoop)(unsafe.Pointer(p)).FrSetup) <= int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FrSetup) &&
 103431 			int32((*WhereLoop)(unsafe.Pointer(p)).FrRun) <= int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun) &&
 103432 			int32((*WhereLoop)(unsafe.Pointer(p)).FnOut) <= int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut) {
 103433 			return uintptr(0)
 103434 		}
 103435 
 103436 		if (*WhereLoop)(unsafe.Pointer(p)).Fprereq&(*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq == (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq &&
 103437 			int32((*WhereLoop)(unsafe.Pointer(p)).FrRun) >= int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun) &&
 103438 			int32((*WhereLoop)(unsafe.Pointer(p)).FnOut) >= int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut) {
 103439 			goto __3
 103440 		}
 103441 
 103442 	}
 103443 	goto __2
 103444 __2:
 103445 	ppPrev = p + 60
 103446 	p = *(*uintptr)(unsafe.Pointer(ppPrev))
 103447 	goto __1
 103448 	goto __3
 103449 __3:
 103450 	;
 103451 	return ppPrev
 103452 }
 103453 
 103454 func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 {
 103455 	var ppPrev uintptr
 103456 	var p uintptr
 103457 	var pWInfo uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 103458 	var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb
 103459 	var rc int32
 103460 
 103461 	if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit == uint32(0) {
 103462 		if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != 0 {
 103463 			(*WhereOrSet)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet)).Fn = U16(0)
 103464 		}
 103465 		return SQLITE_DONE
 103466 	}
 103467 	(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit--
 103468 
 103469 	whereLoopAdjustCost(tls, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops, pTemplate)
 103470 
 103471 	if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != uintptr(0) {
 103472 		if (*WhereLoop)(unsafe.Pointer(pTemplate)).FnLTerm != 0 {
 103473 			whereOrInsert(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet, (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq, (*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun,
 103474 				(*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut)
 103475 		}
 103476 		return SQLITE_OK
 103477 	}
 103478 
 103479 	ppPrev = whereLoopFindLesser(tls, pWInfo+60, pTemplate)
 103480 
 103481 	if ppPrev == uintptr(0) {
 103482 		return SQLITE_OK
 103483 	} else {
 103484 		p = *(*uintptr)(unsafe.Pointer(ppPrev))
 103485 	}
 103486 
 103487 	if p == uintptr(0) {
 103488 		*(*uintptr)(unsafe.Pointer(ppPrev)) = libc.AssignUintptr(&p, Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(WhereLoop{}))))
 103489 		if p == uintptr(0) {
 103490 			return SQLITE_NOMEM
 103491 		}
 103492 		whereLoopInit(tls, p)
 103493 		(*WhereLoop)(unsafe.Pointer(p)).FpNextLoop = uintptr(0)
 103494 	} else {
 103495 		var ppTail uintptr = p + 60
 103496 		var pToDel uintptr
 103497 		for *(*uintptr)(unsafe.Pointer(ppTail)) != 0 {
 103498 			ppTail = whereLoopFindLesser(tls, ppTail, pTemplate)
 103499 			if ppTail == uintptr(0) {
 103500 				break
 103501 			}
 103502 			pToDel = *(*uintptr)(unsafe.Pointer(ppTail))
 103503 			if pToDel == uintptr(0) {
 103504 				break
 103505 			}
 103506 			*(*uintptr)(unsafe.Pointer(ppTail)) = (*WhereLoop)(unsafe.Pointer(pToDel)).FpNextLoop
 103507 			whereLoopDelete(tls, db, pToDel)
 103508 		}
 103509 	}
 103510 	rc = whereLoopXfer(tls, db, p, pTemplate)
 103511 	if (*WhereLoop)(unsafe.Pointer(p)).FwsFlags&U32(WHERE_VIRTUALTABLE) == U32(0) {
 103512 		var pIndex uintptr = *(*uintptr)(unsafe.Pointer(p + 24 + 8))
 103513 		if pIndex != 0 && int32(*(*uint16)(unsafe.Pointer(pIndex + 56))&0x3>>0) == SQLITE_IDXTYPE_IPK {
 103514 			*(*uintptr)(unsafe.Pointer(p + 24 + 8)) = uintptr(0)
 103515 		}
 103516 	}
 103517 	return rc
 103518 }
 103519 
 103520 func whereLoopOutputAdjust(tls *libc.TLS, pWC uintptr, pLoop uintptr, nRow LogEst) {
 103521 	bp := tls.Alloc(4)
 103522 	defer tls.Free(4)
 103523 
 103524 	var pTerm uintptr
 103525 	var pX uintptr
 103526 	var notAllowed Bitmask = ^((*WhereLoop)(unsafe.Pointer(pLoop)).Fprereq | (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf)
 103527 	var i int32
 103528 	var j int32
 103529 	var iReduce LogEst = int16(0)
 103530 
 103531 	i = (*WhereClause)(unsafe.Pointer(pWC)).FnBase
 103532 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 103533 __1:
 103534 	if !(i > 0) {
 103535 		goto __3
 103536 	}
 103537 	{
 103538 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&notAllowed != uint64(0) {
 103539 			goto __2
 103540 		}
 103541 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf == uint64(0) {
 103542 			goto __2
 103543 		}
 103544 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VIRTUAL != 0 {
 103545 			goto __2
 103546 		}
 103547 		for j = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) - 1; j >= 0; j-- {
 103548 			pX = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4))
 103549 			if pX == uintptr(0) {
 103550 				continue
 103551 			}
 103552 			if pX == pTerm {
 103553 				break
 103554 			}
 103555 			if (*WhereTerm)(unsafe.Pointer(pX)).FiParent >= 0 && (*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr((*WhereTerm)(unsafe.Pointer(pX)).FiParent)*48 == pTerm {
 103556 				break
 103557 			}
 103558 		}
 103559 		if j < 0 {
 103560 			Xsqlite3ProgressCheck(tls, (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)
 103561 			if (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf == (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll {
 103562 				if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&0x3f != 0 ||
 103563 					int32((*SrcItem)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList+8+uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*72)).Ffg.Fjointype)&
 103564 						(JT_LEFT|JT_LTORJ) == 0 {
 103565 					*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_SELFCULL)
 103566 				}
 103567 			}
 103568 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 {
 103569 				*(*LogEst)(unsafe.Pointer(pLoop + 22)) += LogEst(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))
 103570 			} else {
 103571 				(*WhereLoop)(unsafe.Pointer(pLoop)).FnOut--
 103572 				if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(WO_EQ|WO_IS) != 0 &&
 103573 					int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_HIGHTRUTH == 0 {
 103574 					var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight
 103575 					*(*int32)(unsafe.Pointer(bp)) = 0
 103576 
 103577 					if Xsqlite3ExprIsInteger(tls, pRight, bp) != 0 && *(*int32)(unsafe.Pointer(bp)) >= -1 && *(*int32)(unsafe.Pointer(bp)) <= 1 {
 103578 						*(*int32)(unsafe.Pointer(bp)) = 10
 103579 					} else {
 103580 						*(*int32)(unsafe.Pointer(bp)) = 20
 103581 					}
 103582 					if int32(iReduce) < *(*int32)(unsafe.Pointer(bp)) {
 103583 						*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_HEURTRUTH)
 103584 						iReduce = LogEst(*(*int32)(unsafe.Pointer(bp)))
 103585 					}
 103586 				}
 103587 			}
 103588 		}
 103589 
 103590 	}
 103591 	goto __2
 103592 __2:
 103593 	i--
 103594 	pTerm += 48
 103595 	goto __1
 103596 	goto __3
 103597 __3:
 103598 	;
 103599 	if int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnOut) > int32(nRow)-int32(iReduce) {
 103600 		(*WhereLoop)(unsafe.Pointer(pLoop)).FnOut = LogEst(int32(nRow) - int32(iReduce))
 103601 	}
 103602 }
 103603 
 103604 func whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr, nEq int32, pTerm uintptr) int32 {
 103605 	var nCmp int32 = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft)
 103606 	var i int32
 103607 
 103608 	nCmp = func() int32 {
 103609 		if nCmp < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)-nEq {
 103610 			return nCmp
 103611 		}
 103612 		return int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) - nEq
 103613 	}()
 103614 	for i = 1; i < nCmp; i++ {
 103615 		var aff uint8
 103616 		var idxaff uint8 = uint8(0)
 103617 		var pColl uintptr
 103618 		var pLhs uintptr
 103619 		var pRhs uintptr
 103620 
 103621 		pLhs = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + 20)) + 8 + uintptr(i)*20)).FpExpr
 103622 		pRhs = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight
 103623 		if (*Expr)(unsafe.Pointer(pRhs)).Fflags&U32(EP_xIsSelect) != U32(0) {
 103624 			pRhs = (*ExprList_item)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 20)))).FpEList + 8 + uintptr(i)*20)).FpExpr
 103625 		} else {
 103626 			pRhs = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 20)) + 8 + uintptr(i)*20)).FpExpr
 103627 		}
 103628 
 103629 		if int32((*Expr)(unsafe.Pointer(pLhs)).Fop) != TK_COLUMN ||
 103630 			(*Expr)(unsafe.Pointer(pLhs)).FiTable != iCur ||
 103631 			int32((*Expr)(unsafe.Pointer(pLhs)).FiColumn) != int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i+nEq)*2))) ||
 103632 			int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i+nEq)))) != int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) {
 103633 			break
 103634 		}
 103635 
 103636 		aff = Xsqlite3CompareAffinity(tls, pRhs, Xsqlite3ExprAffinity(tls, pLhs))
 103637 		idxaff = Xsqlite3TableColumnAffinity(tls, (*Index)(unsafe.Pointer(pIdx)).FpTable, int32((*Expr)(unsafe.Pointer(pLhs)).FiColumn))
 103638 		if int32(aff) != int32(idxaff) {
 103639 			break
 103640 		}
 103641 
 103642 		pColl = Xsqlite3BinaryCompareCollSeq(tls, pParse, pLhs, pRhs)
 103643 		if pColl == uintptr(0) {
 103644 			break
 103645 		}
 103646 		if Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i+nEq)*4))) != 0 {
 103647 			break
 103648 		}
 103649 	}
 103650 	return i
 103651 }
 103652 
 103653 func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProbe uintptr, nInMul LogEst) int32 {
 103654 	bp := tls.Alloc(104)
 103655 	defer tls.Free(104)
 103656 
 103657 	var pWInfo uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 103658 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 103659 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 103660 	var pNew uintptr
 103661 	var pTerm uintptr
 103662 	var opMask int32
 103663 
 103664 	var saved_prereq Bitmask
 103665 	var saved_nLTerm U16
 103666 	var saved_nEq U16
 103667 	var saved_nBtm U16
 103668 	var saved_nTop U16
 103669 	var saved_nSkip U16
 103670 	var saved_wsFlags U32
 103671 	var saved_nOut LogEst
 103672 	var rc int32 = SQLITE_OK
 103673 	var rSize LogEst
 103674 	var rLogSize LogEst
 103675 	var pTop uintptr = uintptr(0)
 103676 	var pBtm uintptr = uintptr(0)
 103677 
 103678 	pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 103679 
 103680 	if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 {
 103681 		return (*Parse)(unsafe.Pointer(pParse)).Frc
 103682 	}
 103683 
 103684 	if (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags&U32(WHERE_BTM_LIMIT) != 0 {
 103685 		opMask = int32(WO_EQ)<<(TK_LT-TK_EQ) | int32(WO_EQ)<<(TK_LE-TK_EQ)
 103686 	} else {
 103687 		opMask = WO_EQ | WO_IN | int32(WO_EQ)<<(TK_GT-TK_EQ) | int32(WO_EQ)<<(TK_GE-TK_EQ) | int32(WO_EQ)<<(TK_LT-TK_EQ) | int32(WO_EQ)<<(TK_LE-TK_EQ) | WO_ISNULL | WO_IS
 103688 	}
 103689 	if uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x4>>2)) != 0 {
 103690 		opMask = opMask & libc.CplInt32(int32(WO_EQ)<<(TK_GT-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)|int32(WO_EQ)<<(TK_LT-TK_EQ)|int32(WO_EQ)<<(TK_LE-TK_EQ))
 103691 	}
 103692 
 103693 	saved_nEq = *(*U16)(unsafe.Pointer(pNew + 24))
 103694 	saved_nBtm = *(*U16)(unsafe.Pointer(pNew + 24 + 2))
 103695 	saved_nTop = *(*U16)(unsafe.Pointer(pNew + 24 + 4))
 103696 	saved_nSkip = (*WhereLoop)(unsafe.Pointer(pNew)).FnSkip
 103697 	saved_nLTerm = (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm
 103698 	saved_wsFlags = (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags
 103699 	saved_prereq = (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq
 103700 	saved_nOut = (*WhereLoop)(unsafe.Pointer(pNew)).FnOut
 103701 	pTerm = whereScanInit(tls, bp, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor, int32(saved_nEq),
 103702 		uint32(opMask), pProbe)
 103703 	(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0)
 103704 	rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst))
 103705 	rLogSize = estLog(tls, rSize)
 103706 	for ; rc == SQLITE_OK && pTerm != uintptr(0); pTerm = whereScanNext(tls, bp) {
 103707 		var eOp U16 = (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator
 103708 		var rCostIdx LogEst
 103709 		var nOutUnadjusted LogEst
 103710 		var nIn int32 = 0
 103711 		var nRecValid int32 = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid
 103712 		if (int32(eOp) == WO_ISNULL || int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VNULL != 0) &&
 103713 			indexColumnNotNull(tls, pProbe, int32(saved_nEq)) != 0 {
 103714 			continue
 103715 		}
 103716 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != 0 {
 103717 			continue
 103718 		}
 103719 
 103720 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_LIKEOPT != 0 && int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == int32(WO_EQ)<<(TK_LT-TK_EQ) {
 103721 			continue
 103722 		}
 103723 
 103724 		if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0 &&
 103725 			!(constraintCompatibleWithOuterJoin(tls, pTerm, pSrc) != 0) {
 103726 			continue
 103727 		}
 103728 		if int32((*Index)(unsafe.Pointer(pProbe)).FonError) != OE_None && int32(saved_nEq) == int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol)-1 {
 103729 			*(*uint8)(unsafe.Pointer(pBuilder + 24)) |= uint8(SQLITE_BLDF1_UNIQUE)
 103730 		} else {
 103731 			*(*uint8)(unsafe.Pointer(pBuilder + 24)) |= uint8(SQLITE_BLDF1_INDEXED)
 103732 		}
 103733 		(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags
 103734 		*(*U16)(unsafe.Pointer(pNew + 24)) = saved_nEq
 103735 		*(*U16)(unsafe.Pointer(pNew + 24 + 2)) = saved_nBtm
 103736 		*(*U16)(unsafe.Pointer(pNew + 24 + 4)) = saved_nTop
 103737 		(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = saved_nLTerm
 103738 		if int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm) >= int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLSlot) &&
 103739 			whereLoopResize(tls, db, pNew, int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1) != 0 {
 103740 			break
 103741 		}
 103742 		*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*4)) = pTerm
 103743 		(*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = (saved_prereq | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight) & ^(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf
 103744 
 103745 		if int32(eOp)&WO_IN != 0 {
 103746 			var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 103747 			if (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_xIsSelect) != U32(0) {
 103748 				var i int32
 103749 				nIn = 46
 103750 
 103751 				for i = 0; i < int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)-1; i++ {
 103752 					if *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(i)*4)) != 0 && (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(i)*4)))).FpExpr == pExpr {
 103753 						nIn = 0
 103754 					}
 103755 				}
 103756 			} else if *(*uintptr)(unsafe.Pointer(pExpr + 20)) != 0 && (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FnExpr != 0 {
 103757 				nIn = int32(Xsqlite3LogEst(tls, uint64((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 20)))).FnExpr)))
 103758 			}
 103759 			if uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x80>>7)) != 0 && int32(rLogSize) >= 10 {
 103760 				var M LogEst
 103761 				var logK LogEst
 103762 				var x LogEst
 103763 
 103764 				M = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(saved_nEq)*2))
 103765 				logK = estLog(tls, int16(nIn))
 103766 
 103767 				x = LogEst(int32(M) + int32(logK) + 10 - (nIn + int32(rLogSize)))
 103768 				if int32(x) >= 0 {
 103769 				} else if int32(nInMul) < 2 && (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_SeekScan) == U32(0) {
 103770 					*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_IN_SEEKSCAN)
 103771 				} else {
 103772 					continue
 103773 				}
 103774 			}
 103775 			*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_COLUMN_IN)
 103776 		} else if int32(eOp)&(WO_EQ|WO_IS) != 0 {
 103777 			var iCol int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiColumn + uintptr(saved_nEq)*2)))
 103778 			*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_COLUMN_EQ)
 103779 
 103780 			if iCol == -1 ||
 103781 				iCol >= 0 && int32(nInMul) == 0 && int32(saved_nEq) == int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol)-1 {
 103782 				if iCol == -1 || uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x8>>3)) != 0 ||
 103783 					int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) == 1 && (*Index)(unsafe.Pointer(pProbe)).FonError != 0 && int32(eOp) == WO_EQ {
 103784 					*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_ONEROW)
 103785 				} else {
 103786 					*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_UNQ_WANTED)
 103787 				}
 103788 			}
 103789 			if int32((*WhereScan)(unsafe.Pointer(bp)).FiEquiv) > 1 {
 103790 				*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_TRANSCONS)
 103791 			}
 103792 		} else if int32(eOp)&WO_ISNULL != 0 {
 103793 			*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_COLUMN_NULL)
 103794 		} else {
 103795 			var nVecLen int32 = whereRangeVectorLen(tls,
 103796 				pParse, (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor, pProbe, int32(saved_nEq), pTerm)
 103797 			if int32(eOp)&(int32(WO_EQ)<<(TK_GT-TK_EQ)|int32(WO_EQ)<<(TK_GE-TK_EQ)) != 0 {
 103798 				*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_COLUMN_RANGE | WHERE_BTM_LIMIT)
 103799 				*(*U16)(unsafe.Pointer(pNew + 24 + 2)) = U16(nVecLen)
 103800 				pBtm = pTerm
 103801 				pTop = uintptr(0)
 103802 				if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_LIKEOPT != 0 {
 103803 					pTop = pTerm + 1*48
 103804 
 103805 					if whereLoopResize(tls, db, pNew, int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1) != 0 {
 103806 						break
 103807 					}
 103808 					*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*4)) = pTop
 103809 					*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_TOP_LIMIT)
 103810 					*(*U16)(unsafe.Pointer(pNew + 24 + 4)) = U16(1)
 103811 				}
 103812 			} else {
 103813 				*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_COLUMN_RANGE | WHERE_TOP_LIMIT)
 103814 				*(*U16)(unsafe.Pointer(pNew + 24 + 4)) = U16(nVecLen)
 103815 				pTop = pTerm
 103816 				if (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags&U32(WHERE_BTM_LIMIT) != U32(0) {
 103817 					pBtm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)-2)*4))
 103818 				} else {
 103819 					pBtm = uintptr(0)
 103820 				}
 103821 			}
 103822 		}
 103823 
 103824 		if (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags&U32(WHERE_COLUMN_RANGE) != 0 {
 103825 			whereRangeScanEst(tls, pParse, pBuilder, pBtm, pTop, pNew)
 103826 		} else {
 103827 			var nEq int32 = int32(libc.PreIncUint16(&*(*U16)(unsafe.Pointer(pNew + 24)), 1))
 103828 
 103829 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 && int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiColumn + uintptr(saved_nEq)*2))) >= 0 {
 103830 				*(*LogEst)(unsafe.Pointer(pNew + 22)) += LogEst(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))
 103831 				*(*LogEst)(unsafe.Pointer(pNew + 22)) -= LogEst(nIn)
 103832 			} else {
 103833 				*(*TRowcnt)(unsafe.Pointer(bp + 96)) = uint64(0)
 103834 				if int32(nInMul) == 0 &&
 103835 					(*Index)(unsafe.Pointer(pProbe)).FnSample != 0 &&
 103836 					int32(*(*U16)(unsafe.Pointer(pNew + 24))) <= (*Index)(unsafe.Pointer(pProbe)).FnSampleCol &&
 103837 					(int32(eOp)&WO_IN == 0 || (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_xIsSelect) == U32(0)) &&
 103838 					(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_Stat4) == U32(0) {
 103839 					var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 103840 					if int32(eOp)&(WO_EQ|WO_ISNULL|WO_IS) != 0 {
 103841 						rc = whereEqualScanEst(tls, pParse, pBuilder, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+96)
 103842 					} else {
 103843 						rc = whereInScanEst(tls, pParse, pBuilder, *(*uintptr)(unsafe.Pointer(pExpr + 20)), bp+96)
 103844 					}
 103845 					if rc == SQLITE_NOTFOUND {
 103846 						rc = SQLITE_OK
 103847 					}
 103848 					if rc != SQLITE_OK {
 103849 						break
 103850 					}
 103851 					if *(*TRowcnt)(unsafe.Pointer(bp + 96)) != 0 {
 103852 						(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = Xsqlite3LogEst(tls, *(*TRowcnt)(unsafe.Pointer(bp + 96)))
 103853 						if nEq == 1 &&
 103854 							int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut)+10 > int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst))) {
 103855 							*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_HIGHTRUTH)
 103856 							if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_HEURTRUTH != 0 {
 103857 								*(*uint8)(unsafe.Pointer(pBuilder + 25)) |= uint8(SQLITE_BLDF2_2NDPASS)
 103858 							}
 103859 						}
 103860 						if int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) > int32(saved_nOut) {
 103861 							(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut
 103862 						}
 103863 						*(*LogEst)(unsafe.Pointer(pNew + 22)) -= LogEst(nIn)
 103864 					}
 103865 				}
 103866 				if *(*TRowcnt)(unsafe.Pointer(bp + 96)) == uint64(0) {
 103867 					*(*LogEst)(unsafe.Pointer(pNew + 22)) += LogEst(int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(nEq)*2))) - int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(nEq-1)*2))))
 103868 					if int32(eOp)&WO_ISNULL != 0 {
 103869 						*(*LogEst)(unsafe.Pointer(pNew + 22)) += int16(10)
 103870 					}
 103871 				}
 103872 			}
 103873 		}
 103874 
 103875 		if int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x3>>0) == SQLITE_IDXTYPE_IPK {
 103876 			rCostIdx = LogEst(int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 16)
 103877 		} else {
 103878 			rCostIdx = LogEst(int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 1 + 15*int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow)/int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc)).FpTab)).FszTabRow))
 103879 		}
 103880 		(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, rLogSize, rCostIdx)
 103881 		if (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags&U32(WHERE_IDX_ONLY|WHERE_IPK|WHERE_EXPRIDX) == U32(0) {
 103882 			(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, (*WhereLoop)(unsafe.Pointer(pNew)).FrRun, int16(int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut)+16))
 103883 		}
 103884 
 103885 		nOutUnadjusted = (*WhereLoop)(unsafe.Pointer(pNew)).FnOut
 103886 		*(*LogEst)(unsafe.Pointer(pNew + 20)) += LogEst(int32(nInMul) + nIn)
 103887 		*(*LogEst)(unsafe.Pointer(pNew + 22)) += LogEst(int32(nInMul) + nIn)
 103888 		whereLoopOutputAdjust(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, pNew, rSize)
 103889 		rc = whereLoopInsert(tls, pBuilder, pNew)
 103890 
 103891 		if (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags&U32(WHERE_COLUMN_RANGE) != 0 {
 103892 			(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut
 103893 		} else {
 103894 			(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = nOutUnadjusted
 103895 		}
 103896 
 103897 		if (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags&U32(WHERE_TOP_LIMIT) == U32(0) &&
 103898 			int32(*(*U16)(unsafe.Pointer(pNew + 24))) < int32((*Index)(unsafe.Pointer(pProbe)).FnColumn) &&
 103899 			(int32(*(*U16)(unsafe.Pointer(pNew + 24))) < int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) || int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x3>>0) != SQLITE_IDXTYPE_PRIMARYKEY) {
 103900 			if int32(*(*U16)(unsafe.Pointer(pNew + 24))) > 3 {
 103901 				Xsqlite3ProgressCheck(tls, pParse)
 103902 			}
 103903 			whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(int32(nInMul)+nIn))
 103904 		}
 103905 		(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut
 103906 		(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nRecValid
 103907 	}
 103908 	(*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = saved_prereq
 103909 	*(*U16)(unsafe.Pointer(pNew + 24)) = saved_nEq
 103910 	*(*U16)(unsafe.Pointer(pNew + 24 + 2)) = saved_nBtm
 103911 	*(*U16)(unsafe.Pointer(pNew + 24 + 4)) = saved_nTop
 103912 	(*WhereLoop)(unsafe.Pointer(pNew)).FnSkip = saved_nSkip
 103913 	(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags
 103914 	(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut
 103915 	(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = saved_nLTerm
 103916 
 103917 	if int32(saved_nEq) == int32(saved_nSkip) &&
 103918 		int32(saved_nEq)+1 < int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) &&
 103919 		int32(saved_nEq) == int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm) &&
 103920 		int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x40>>6) == 0 &&
 103921 		int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x80>>7) != 0 &&
 103922 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_SkipScan) == U32(0) &&
 103923 		int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(int32(saved_nEq)+1)*2))) >= 42 &&
 103924 		libc.AssignInt32(&rc, whereLoopResize(tls, db, pNew, int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)) == SQLITE_OK {
 103925 		var nIter LogEst
 103926 		*(*U16)(unsafe.Pointer(pNew + 24))++
 103927 		(*WhereLoop)(unsafe.Pointer(pNew)).FnSkip++
 103928 		*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*4)) = uintptr(0)
 103929 		*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_SKIPSCAN)
 103930 		nIter = LogEst(int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(saved_nEq)*2))) - int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(int32(saved_nEq)+1)*2))))
 103931 		*(*LogEst)(unsafe.Pointer(pNew + 22)) -= LogEst(int32(nIter))
 103932 
 103933 		nIter = int16(int32(nIter) + 5)
 103934 		whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(int32(nIter)+int32(nInMul)))
 103935 		(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut
 103936 		*(*U16)(unsafe.Pointer(pNew + 24)) = saved_nEq
 103937 		(*WhereLoop)(unsafe.Pointer(pNew)).FnSkip = saved_nSkip
 103938 		(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags
 103939 	}
 103940 
 103941 	return rc
 103942 }
 103943 
 103944 func indexMightHelpWithOrderBy(tls *libc.TLS, pBuilder uintptr, pIndex uintptr, iCursor int32) int32 {
 103945 	var pOB uintptr
 103946 	var aColExpr uintptr
 103947 	var ii int32
 103948 	var jj int32
 103949 
 103950 	if uint32(int32(*(*uint16)(unsafe.Pointer(pIndex + 56))&0x4>>2)) != 0 {
 103951 		return 0
 103952 	}
 103953 	if libc.AssignUintptr(&pOB, (*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpOrderBy) == uintptr(0) {
 103954 		return 0
 103955 	}
 103956 	for ii = 0; ii < (*ExprList)(unsafe.Pointer(pOB)).FnExpr; ii++ {
 103957 		var pExpr uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pOB+8+uintptr(ii)*20)).FpExpr)
 103958 		if pExpr == uintptr(0) {
 103959 			continue
 103960 		}
 103961 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN && (*Expr)(unsafe.Pointer(pExpr)).FiTable == iCursor {
 103962 			if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 {
 103963 				return 1
 103964 			}
 103965 			for jj = 0; jj < int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol); jj++ {
 103966 				if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(jj)*2))) {
 103967 					return 1
 103968 				}
 103969 			}
 103970 		} else if libc.AssignUintptr(&aColExpr, (*Index)(unsafe.Pointer(pIndex)).FaColExpr) != uintptr(0) {
 103971 			for jj = 0; jj < int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol); jj++ {
 103972 				if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(jj)*2))) != -2 {
 103973 					continue
 103974 				}
 103975 				if Xsqlite3ExprCompareSkip(tls, pExpr, (*ExprList_item)(unsafe.Pointer(aColExpr+8+uintptr(jj)*20)).FpExpr, iCursor) == 0 {
 103976 					return 1
 103977 				}
 103978 			}
 103979 		}
 103980 	}
 103981 	return 0
 103982 }
 103983 
 103984 func whereUsablePartialIndex(tls *libc.TLS, iTab int32, jointype U8, pWC uintptr, pWhere uintptr) int32 {
 103985 	var i int32
 103986 	var pTerm uintptr
 103987 	var pParse uintptr
 103988 
 103989 	if int32(jointype)&JT_LTORJ != 0 {
 103990 		return 0
 103991 	}
 103992 	pParse = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse
 103993 	for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == TK_AND {
 103994 		if !(whereUsablePartialIndex(tls, iTab, jointype, pWC, (*Expr)(unsafe.Pointer(pWhere)).FpLeft) != 0) {
 103995 			return 0
 103996 		}
 103997 		pWhere = (*Expr)(unsafe.Pointer(pWhere)).FpRight
 103998 	}
 103999 	if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableQPSG) != 0 {
 104000 		pParse = uintptr(0)
 104001 	}
 104002 	i = 0
 104003 	pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa
 104004 __1:
 104005 	if !(i < (*WhereClause)(unsafe.Pointer(pWC)).FnTerm) {
 104006 		goto __3
 104007 	}
 104008 	{
 104009 		var pExpr uintptr
 104010 		pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr
 104011 		if (!((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0)) || *(*int32)(unsafe.Pointer(pExpr + 36)) == iTab) &&
 104012 			(int32(jointype)&JT_OUTER == 0 || (*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_OuterON) != U32(0)) &&
 104013 			Xsqlite3ExprImpliesExpr(tls, pParse, pExpr, pWhere, iTab) != 0 &&
 104014 			int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&TERM_VNULL == 0 {
 104015 			return 1
 104016 		}
 104017 
 104018 	}
 104019 	goto __2
 104020 __2:
 104021 	i++
 104022 	pTerm += 48
 104023 	goto __1
 104024 	goto __3
 104025 __3:
 104026 	;
 104027 	return 0
 104028 }
 104029 
 104030 func exprIsCoveredByIndex(tls *libc.TLS, pExpr uintptr, pIdx uintptr, iTabCur int32) int32 {
 104031 	var i int32
 104032 	for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); i++ {
 104033 		if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) == -2 &&
 104034 			Xsqlite3ExprCompare(tls, uintptr(0), pExpr, (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8+uintptr(i)*20)).FpExpr, iTabCur) == 0 {
 104035 			return 1
 104036 		}
 104037 	}
 104038 	return 0
 104039 }
 104040 
 104041 // Structure passed to the whereIsCoveringIndex Walker callback.
 104042 type CoveringIndexCheck = CoveringIndexCheck1
 104043 
 104044 func whereIsCoveringIndexWalkCallback(tls *libc.TLS, pWalk uintptr, pExpr uintptr) int32 {
 104045 	var i int32
 104046 	var pIdx uintptr
 104047 	var aiColumn uintptr
 104048 	var nColumn U16
 104049 	var pCk uintptr
 104050 
 104051 	pCk = *(*uintptr)(unsafe.Pointer(pWalk + 24))
 104052 	pIdx = (*CoveringIndexCheck)(unsafe.Pointer(pCk)).FpIdx
 104053 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN || int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN {
 104054 		if (*Expr)(unsafe.Pointer(pExpr)).FiTable != (*CoveringIndexCheck)(unsafe.Pointer(pCk)).FiTabCur {
 104055 			return WRC_Continue
 104056 		}
 104057 		pIdx = (*CoveringIndexCheck1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalk + 24)))).FpIdx
 104058 		aiColumn = (*Index)(unsafe.Pointer(pIdx)).FaiColumn
 104059 		nColumn = (*Index)(unsafe.Pointer(pIdx)).FnColumn
 104060 		for i = 0; i < int32(nColumn); i++ {
 104061 			if int32(*(*I16)(unsafe.Pointer(aiColumn + uintptr(i)*2))) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) {
 104062 				return WRC_Continue
 104063 			}
 104064 		}
 104065 		(*CoveringIndexCheck)(unsafe.Pointer(pCk)).FbUnidx = U8(1)
 104066 		return WRC_Abort
 104067 	} else if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x800>>11)) != 0 &&
 104068 		exprIsCoveredByIndex(tls, pExpr, pIdx, (*CoveringIndexCheck1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalk + 24)))).FiTabCur) != 0 {
 104069 		(*CoveringIndexCheck)(unsafe.Pointer(pCk)).FbExpr = U8(1)
 104070 		return WRC_Prune
 104071 	}
 104072 	return WRC_Continue
 104073 }
 104074 
 104075 func whereIsCoveringIndex(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iTabCur int32) U32 {
 104076 	bp := tls.Alloc(40)
 104077 	defer tls.Free(40)
 104078 
 104079 	var i int32
 104080 	var rc int32
 104081 
 104082 	if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect == uintptr(0) {
 104083 		return U32(0)
 104084 	}
 104085 	if int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x800>>11) == 0 {
 104086 		for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); i++ {
 104087 			if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2))) >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1 {
 104088 				break
 104089 			}
 104090 		}
 104091 		if i >= int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) {
 104092 			return U32(0)
 104093 		}
 104094 	}
 104095 	(*CoveringIndexCheck1)(unsafe.Pointer(bp + 28)).FpIdx = pIdx
 104096 	(*CoveringIndexCheck1)(unsafe.Pointer(bp + 28)).FiTabCur = iTabCur
 104097 	(*CoveringIndexCheck1)(unsafe.Pointer(bp + 28)).FbExpr = U8(0)
 104098 	(*CoveringIndexCheck1)(unsafe.Pointer(bp + 28)).FbUnidx = U8(0)
 104099 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
 104100 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
 104101 		f func(*libc.TLS, uintptr, uintptr) int32
 104102 	}{whereIsCoveringIndexWalkCallback}))
 104103 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
 104104 		f func(*libc.TLS, uintptr, uintptr) int32
 104105 	}{Xsqlite3SelectWalkNoop}))
 104106 	*(*uintptr)(unsafe.Pointer(bp + 24)) = bp + 28
 104107 	Xsqlite3WalkSelect(tls, bp, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)
 104108 	if (*CoveringIndexCheck1)(unsafe.Pointer(bp+28)).FbUnidx != 0 {
 104109 		rc = 0
 104110 	} else if (*CoveringIndexCheck1)(unsafe.Pointer(bp+28)).FbExpr != 0 {
 104111 		rc = WHERE_EXPRIDX
 104112 	} else {
 104113 		rc = WHERE_IDX_ONLY
 104114 	}
 104115 	return U32(rc)
 104116 }
 104117 
 104118 func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 {
 104119 	bp := tls.Alloc(102)
 104120 	defer tls.Free(102)
 104121 
 104122 	var pWInfo uintptr
 104123 	var pProbe uintptr
 104124 
 104125 	*(*I16)(unsafe.Pointer(bp + 96)) = int16(-1)
 104126 	var pTabList uintptr
 104127 	var pSrc uintptr
 104128 	var pNew uintptr
 104129 	var rc int32 = SQLITE_OK
 104130 	var iSortIdx int32 = 1
 104131 	var b int32
 104132 	var rSize LogEst
 104133 	var pWC uintptr
 104134 	var pTab uintptr
 104135 
 104136 	pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 104137 	pWInfo = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 104138 	pTabList = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList
 104139 	pSrc = pTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*72
 104140 	pTab = (*SrcItem)(unsafe.Pointer(pSrc)).FpTab
 104141 	pWC = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC
 104142 
 104143 	if uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x2>>1)) != 0 {
 104144 		pProbe = *(*uintptr)(unsafe.Pointer(pSrc + 68))
 104145 	} else if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
 104146 		pProbe = (*Table)(unsafe.Pointer(pTab)).FpIndex
 104147 	} else {
 104148 		var pFirst uintptr
 104149 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Index{})))
 104150 		(*Index)(unsafe.Pointer(bp)).FnKeyCol = U16(1)
 104151 		(*Index)(unsafe.Pointer(bp)).FnColumn = U16(1)
 104152 		(*Index)(unsafe.Pointer(bp)).FaiColumn = bp + 96
 104153 		(*Index)(unsafe.Pointer(bp)).FaiRowLogEst = bp + 98
 104154 		(*Index)(unsafe.Pointer(bp)).FonError = U8(OE_Replace)
 104155 		(*Index)(unsafe.Pointer(bp)).FpTable = pTab
 104156 		(*Index)(unsafe.Pointer(bp)).FszIdxRow = int16(3)
 104157 		libc.SetBitFieldPtr16Uint32(bp+56, uint32(SQLITE_IDXTYPE_IPK), 0, 0x3)
 104158 		*(*LogEst)(unsafe.Pointer(bp + 98)) = (*Table)(unsafe.Pointer(pTab)).FnRowLogEst
 104159 		*(*LogEst)(unsafe.Pointer(bp + 98 + 1*2)) = int16(0)
 104160 		pFirst = (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc)).FpTab)).FpIndex
 104161 		if int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x1>>0) == 0 {
 104162 			(*Index)(unsafe.Pointer(bp)).FpNext = pFirst
 104163 		}
 104164 		pProbe = bp
 104165 	}
 104166 	rSize = (*Table)(unsafe.Pointer(pTab)).FnRowLogEst
 104167 
 104168 	if !(int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet) != 0) &&
 104169 		int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(WHERE_RIGHT_JOIN|WHERE_OR_SUBCLAUSE) == 0 &&
 104170 		(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags&uint64(SQLITE_AutoIndex) != uint64(0) &&
 104171 		!(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x2>>1) != 0) &&
 104172 		!(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x1>>0) != 0) &&
 104173 		(*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) &&
 104174 		!(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x8>>3) != 0) &&
 104175 		!(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x40>>6) != 0) &&
 104176 		int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&JT_RIGHT == 0 {
 104177 		var rLogSize LogEst
 104178 		var pTerm uintptr
 104179 		var pWCEnd uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pWC)).FnTerm)*48
 104180 		rLogSize = estLog(tls, rSize)
 104181 		for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; rc == SQLITE_OK && pTerm < pWCEnd; pTerm += 48 {
 104182 			if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != 0 {
 104183 				continue
 104184 			}
 104185 			if termCanDriveIndex(tls, pTerm, pSrc, uint64(0)) != 0 {
 104186 				*(*U16)(unsafe.Pointer(pNew + 24)) = U16(1)
 104187 				(*WhereLoop)(unsafe.Pointer(pNew)).FnSkip = U16(0)
 104188 				*(*uintptr)(unsafe.Pointer(pNew + 24 + 8)) = uintptr(0)
 104189 				(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(1)
 104190 				*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm
 104191 
 104192 				(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = LogEst(int32(rLogSize) + int32(rSize))
 104193 				if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Ephemeral) == U32(0) {
 104194 					*(*LogEst)(unsafe.Pointer(pNew + 18)) += int16(28)
 104195 				} else {
 104196 					*(*LogEst)(unsafe.Pointer(pNew + 18)) -= int16(25)
 104197 
 104198 				}
 104199 
 104200 				if int32((*WhereLoop)(unsafe.Pointer(pNew)).FrSetup) < 0 {
 104201 					(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0)
 104202 				}
 104203 
 104204 				(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = int16(43)
 104205 				(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, rLogSize, (*WhereLoop)(unsafe.Pointer(pNew)).FnOut)
 104206 				(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_AUTO_INDEX)
 104207 				(*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight
 104208 				rc = whereLoopInsert(tls, pBuilder, pNew)
 104209 			}
 104210 		}
 104211 	}
 104212 
 104213 __1:
 104214 	if !(rc == SQLITE_OK && pProbe != 0) {
 104215 		goto __3
 104216 	}
 104217 	{
 104218 		if (*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0) &&
 104219 			!(whereUsablePartialIndex(tls, (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor, (*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype, pWC,
 104220 				(*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere) != 0) {
 104221 			goto __2
 104222 		}
 104223 		if uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x100>>8)) != 0 {
 104224 			goto __2
 104225 		}
 104226 		rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst))
 104227 		*(*U16)(unsafe.Pointer(pNew + 24)) = U16(0)
 104228 		*(*U16)(unsafe.Pointer(pNew + 24 + 2)) = U16(0)
 104229 		*(*U16)(unsafe.Pointer(pNew + 24 + 4)) = U16(0)
 104230 		(*WhereLoop)(unsafe.Pointer(pNew)).FnSkip = U16(0)
 104231 		(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(0)
 104232 		(*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = U8(0)
 104233 		(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0)
 104234 		(*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq
 104235 		(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize
 104236 		*(*uintptr)(unsafe.Pointer(pNew + 24 + 8)) = pProbe
 104237 		b = indexMightHelpWithOrderBy(tls, pBuilder, pProbe, (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor)
 104238 
 104239 		if int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x3>>0) == SQLITE_IDXTYPE_IPK {
 104240 			(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_IPK)
 104241 
 104242 			(*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = func() uint8 {
 104243 				if b != 0 {
 104244 					return uint8(iSortIdx)
 104245 				}
 104246 				return uint8(0)
 104247 			}()
 104248 
 104249 			(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = LogEst(int32(rSize) + 16 - 2*libc.Bool32((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasStat4) != U32(0)))
 104250 			if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW || (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Ephemeral) != U32(0) {
 104251 				*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_VIEWSCAN)
 104252 			}
 104253 
 104254 			whereLoopOutputAdjust(tls, pWC, pNew, rSize)
 104255 			rc = whereLoopInsert(tls, pBuilder, pNew)
 104256 			(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize
 104257 			if rc != 0 {
 104258 				goto __3
 104259 			}
 104260 		} else {
 104261 			var m Bitmask
 104262 			if uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x20>>5)) != 0 {
 104263 				m = uint64(0)
 104264 				(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_IDX_ONLY | WHERE_INDEXED)
 104265 			} else {
 104266 				m = (*SrcItem)(unsafe.Pointer(pSrc)).FcolUsed & (*Index)(unsafe.Pointer(pProbe)).FcolNotIdxed
 104267 				(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_INDEXED)
 104268 				if m == uint64(1)<<(int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1) || uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x800>>11)) != 0 && !(int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x400>>10) != 0) && m != uint64(0) {
 104269 					var isCov U32 = whereIsCoveringIndex(tls, pWInfo, pProbe, (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor)
 104270 					if isCov == U32(0) {
 104271 					} else {
 104272 						m = uint64(0)
 104273 						*(*U32)(unsafe.Pointer(pNew + 44)) |= isCov
 104274 						if isCov&U32(WHERE_IDX_ONLY) != 0 {
 104275 						} else {
 104276 						}
 104277 					}
 104278 				} else if m == uint64(0) {
 104279 					(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_IDX_ONLY | WHERE_INDEXED)
 104280 				}
 104281 			}
 104282 
 104283 			if b != 0 ||
 104284 				!((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) ||
 104285 				(*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0) ||
 104286 				uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x2>>1)) != 0 ||
 104287 				m == uint64(0) &&
 104288 					int32(*(*uint16)(unsafe.Pointer(pProbe + 56))&0x4>>2) == 0 &&
 104289 					int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow) < int32((*Table)(unsafe.Pointer(pTab)).FszTabRow) &&
 104290 					int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_ONEPASS_DESIRED == 0 &&
 104291 					Xsqlite3Config.FbUseCis != 0 &&
 104292 					(*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).FdbOptFlags&U32(SQLITE_CoverIdxScan) == U32(0) {
 104293 				(*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = func() uint8 {
 104294 					if b != 0 {
 104295 						return uint8(iSortIdx)
 104296 					}
 104297 					return uint8(0)
 104298 				}()
 104299 
 104300 				(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = LogEst(int32(rSize) + 1 + 15*int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow)/int32((*Table)(unsafe.Pointer(pTab)).FszTabRow))
 104301 				if m != uint64(0) {
 104302 					var nLookup LogEst = LogEst(int32(rSize) + 16)
 104303 					var ii int32
 104304 					var iCur int32 = (*SrcItem)(unsafe.Pointer(pSrc)).FiCursor
 104305 					var pWC2 uintptr = pWInfo + 80
 104306 					for ii = 0; ii < (*WhereClause)(unsafe.Pointer(pWC2)).FnTerm; ii++ {
 104307 						var pTerm uintptr = (*WhereClause)(unsafe.Pointer(pWC2)).Fa + uintptr(ii)*48
 104308 						if !(Xsqlite3ExprCoveredByIndex(tls, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, iCur, pProbe) != 0) {
 104309 							break
 104310 						}
 104311 
 104312 						if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 {
 104313 							nLookup = LogEst(int32(nLookup) + int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))
 104314 						} else {
 104315 							nLookup--
 104316 							if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(WO_EQ|WO_IS) != 0 {
 104317 								nLookup = int16(int32(nLookup) - 19)
 104318 							}
 104319 						}
 104320 					}
 104321 
 104322 					(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, (*WhereLoop)(unsafe.Pointer(pNew)).FrRun, nLookup)
 104323 				}
 104324 
 104325 				whereLoopOutputAdjust(tls, pWC, pNew, rSize)
 104326 				if int32((*SrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&JT_RIGHT != 0 && (*Index)(unsafe.Pointer(pProbe)).FaColExpr != 0 {
 104327 				} else {
 104328 					rc = whereLoopInsert(tls, pBuilder, pNew)
 104329 				}
 104330 				(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = rSize
 104331 				if rc != 0 {
 104332 					goto __3
 104333 				}
 104334 			}
 104335 		}
 104336 
 104337 		(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1 = uint8(0)
 104338 		rc = whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(0))
 104339 		if int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == SQLITE_BLDF1_INDEXED {
 104340 			*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_StatsUsed)
 104341 		}
 104342 		Xsqlite3Stat4ProbeFree(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec)
 104343 		(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = 0
 104344 		(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = uintptr(0)
 104345 
 104346 	}
 104347 	goto __2
 104348 __2:
 104349 	pProbe = func() uintptr {
 104350 		if uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x2>>1)) != 0 {
 104351 			return uintptr(0)
 104352 		}
 104353 		return (*Index)(unsafe.Pointer(pProbe)).FpNext
 104354 	}()
 104355 	iSortIdx++
 104356 	goto __1
 104357 	goto __3
 104358 __3:
 104359 	;
 104360 	return rc
 104361 }
 104362 
 104363 func isLimitTerm(tls *libc.TLS, pTerm uintptr) int32 {
 104364 	return libc.Bool32(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) >= SQLITE_INDEX_CONSTRAINT_LIMIT &&
 104365 		int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) <= SQLITE_INDEX_CONSTRAINT_OFFSET)
 104366 }
 104367 
 104368 func whereLoopAddVirtualOne(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUsable Bitmask, mExclude U16, pIdxInfo uintptr, mNoOmit U16, pbIn uintptr, pbRetryLimit uintptr) int32 {
 104369 	bp := tls.Alloc(16)
 104370 	defer tls.Free(16)
 104371 
 104372 	var pWC uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC
 104373 	var pHidden uintptr = pIdxInfo + 1*72
 104374 	var pIdxCons uintptr
 104375 	var pUsage uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage
 104376 	var i int32
 104377 	var mxTerm int32
 104378 	var rc int32 = SQLITE_OK
 104379 	var pNew uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 104380 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpParse
 104381 	var pSrc uintptr = (*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*72
 104382 	var nConstraint int32 = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint
 104383 
 104384 	*(*int32)(unsafe.Pointer(pbIn)) = 0
 104385 	(*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = mPrereq
 104386 
 104387 	pIdxCons = *(*uintptr)(unsafe.Pointer(pIdxInfo + 4))
 104388 	i = 0
 104389 __1:
 104390 	if !(i < nConstraint) {
 104391 		goto __3
 104392 	}
 104393 	{
 104394 		var pTerm uintptr = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).FiTermOffset)*48
 104395 		(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable = uint8(0)
 104396 		if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight&mUsable == (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight &&
 104397 			int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&int32(mExclude) == 0 &&
 104398 			(pbRetryLimit != 0 || !(isLimitTerm(tls, pTerm) != 0)) {
 104399 			(*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable = uint8(1)
 104400 		}
 104401 
 104402 	}
 104403 	goto __2
 104404 __2:
 104405 	i++
 104406 	pIdxCons += 12
 104407 	goto __1
 104408 	goto __3
 104409 __3:
 104410 	;
 104411 	libc.Xmemset(tls, pUsage, 0, uint32(unsafe.Sizeof(sqlite3_index_constraint_usage{}))*uint32(nConstraint))
 104412 
 104413 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = uintptr(0)
 104414 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0
 104415 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 0
 104416 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1e99) / float64(2)
 104417 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(25)
 104418 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 0
 104419 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FcolUsed = Sqlite3_uint64(Sqlite3_int64((*SrcItem)(unsafe.Pointer(pSrc)).FcolUsed))
 104420 	(*HiddenIndexInfo)(unsafe.Pointer(pHidden)).FmHandleIn = U32(0)
 104421 
 104422 	rc = vtabBestIndex(tls, pParse, (*SrcItem)(unsafe.Pointer(pSrc)).FpTab, pIdxInfo)
 104423 	if rc != 0 {
 104424 		if rc == SQLITE_CONSTRAINT {
 104425 			return SQLITE_OK
 104426 		}
 104427 		return rc
 104428 	}
 104429 
 104430 	mxTerm = -1
 104431 
 104432 	libc.Xmemset(tls, (*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32(nConstraint))
 104433 	libc.Xmemset(tls, pNew+24, 0, uint32(unsafe.Sizeof(struct {
 104434 		FidxNum      int32
 104435 		FneedFree    uint8
 104436 		F__ccgo_pad1 [1]byte
 104437 		FisOrdered   I8
 104438 		F__ccgo_pad2 [1]byte
 104439 		FomitMask    U16
 104440 		F__ccgo_pad3 [2]byte
 104441 		FidxStr      uintptr
 104442 		FmHandleIn   U32
 104443 	}{})))
 104444 	pIdxCons = *(*uintptr)(unsafe.Pointer(pIdxInfo + 4))
 104445 	i = 0
 104446 __4:
 104447 	if !(i < nConstraint) {
 104448 		goto __6
 104449 	}
 104450 	{
 104451 		var iTerm int32
 104452 		if libc.AssignInt32(&iTerm, (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage+uintptr(i)*8)).FargvIndex-1) >= 0 {
 104453 			var pTerm uintptr
 104454 			var j int32 = (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).FiTermOffset
 104455 			if iTerm >= nConstraint ||
 104456 				j < 0 ||
 104457 				j >= (*WhereClause)(unsafe.Pointer(pWC)).FnTerm ||
 104458 				*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(iTerm)*4)) != uintptr(0) ||
 104459 				int32((*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable) == 0 {
 104460 				Xsqlite3ErrorMsg(tls, pParse, ts+21990, libc.VaList(bp, (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc)).FpTab)).FzName))
 104461 
 104462 				return SQLITE_ERROR
 104463 			}
 104464 
 104465 			pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(j)*48
 104466 			*(*Bitmask)(unsafe.Pointer(pNew)) |= (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight
 104467 
 104468 			*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(iTerm)*4)) = pTerm
 104469 			if iTerm > mxTerm {
 104470 				mxTerm = iTerm
 104471 			}
 104472 
 104473 			if (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage+uintptr(i)*8)).Fomit != 0 {
 104474 				if i < 16 && int32(1)<<i&int32(mNoOmit) == 0 {
 104475 					*(*U16)(unsafe.Pointer(pNew + 24 + 8)) |= U16(int32(1) << iTerm)
 104476 				} else {
 104477 				}
 104478 				if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp) == SQLITE_INDEX_CONSTRAINT_OFFSET {
 104479 					libc.SetBitFieldPtr8Uint32(pNew+24+4, U32(1), 1, 0x2)
 104480 				}
 104481 			}
 104482 			if func() uint32 {
 104483 				if i <= 31 {
 104484 					return uint32(1) << i
 104485 				}
 104486 				return uint32(0)
 104487 			}()&(*HiddenIndexInfo)(unsafe.Pointer(pHidden)).FmHandleIn != 0 {
 104488 				*(*U32)(unsafe.Pointer(pNew + 24 + 16)) |= uint32(1) << iTerm
 104489 			} else if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_IN != 0 {
 104490 				(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 0
 104491 				*(*int32)(unsafe.Pointer(pIdxInfo + 56)) &= libc.CplInt32(SQLITE_INDEX_SCAN_UNIQUE)
 104492 				*(*int32)(unsafe.Pointer(pbIn)) = 1
 104493 			}
 104494 
 104495 			if isLimitTerm(tls, pTerm) != 0 && *(*int32)(unsafe.Pointer(pbIn)) != 0 {
 104496 				if (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr != 0 {
 104497 					Xsqlite3_free(tls, (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr)
 104498 					(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = uintptr(0)
 104499 					(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 0
 104500 				}
 104501 				*(*int32)(unsafe.Pointer(pbRetryLimit)) = 1
 104502 				return SQLITE_OK
 104503 			}
 104504 		}
 104505 
 104506 	}
 104507 	goto __5
 104508 __5:
 104509 	i++
 104510 	pIdxCons += 12
 104511 	goto __4
 104512 	goto __6
 104513 __6:
 104514 	;
 104515 	(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(mxTerm + 1)
 104516 	for i = 0; i <= mxTerm; i++ {
 104517 		if *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(i)*4)) == uintptr(0) {
 104518 			Xsqlite3ErrorMsg(tls, pParse, ts+21990, libc.VaList(bp+8, (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pSrc)).FpTab)).FzName))
 104519 
 104520 			return SQLITE_ERROR
 104521 		}
 104522 	}
 104523 
 104524 	*(*int32)(unsafe.Pointer(pNew + 24)) = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum
 104525 	libc.SetBitFieldPtr8Uint32(pNew+24+4, U32((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr), 0, 0x1)
 104526 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 0
 104527 	*(*uintptr)(unsafe.Pointer(pNew + 24 + 12)) = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr
 104528 	*(*I8)(unsafe.Pointer(pNew + 24 + 6)) = func() int8 {
 104529 		if (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed != 0 {
 104530 			return int8((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy)
 104531 		}
 104532 		return int8(0)
 104533 	}()
 104534 	(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0)
 104535 	(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstFromDouble(tls, (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost)
 104536 	(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = Xsqlite3LogEst(tls, uint64((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows))
 104537 
 104538 	if (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags&SQLITE_INDEX_SCAN_UNIQUE != 0 {
 104539 		*(*U32)(unsafe.Pointer(pNew + 44)) |= U32(WHERE_ONEROW)
 104540 	} else {
 104541 		*(*U32)(unsafe.Pointer(pNew + 44)) &= libc.Uint32FromInt32(libc.CplInt32(WHERE_ONEROW))
 104542 	}
 104543 	rc = whereLoopInsert(tls, pBuilder, pNew)
 104544 	if U32(int32(*(*uint8)(unsafe.Pointer(pNew + 24 + 4))&0x1>>0)) != 0 {
 104545 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pNew + 24 + 12)))
 104546 		libc.SetBitFieldPtr8Uint32(pNew+24+4, U32(0), 0, 0x1)
 104547 	}
 104548 
 104549 	return rc
 104550 }
 104551 
 104552 // Return the collating sequence for a constraint passed into xBestIndex.
 104553 //
 104554 // pIdxInfo must be an sqlite3_index_info structure passed into xBestIndex.
 104555 // This routine depends on there being a HiddenIndexInfo structure immediately
 104556 // following the sqlite3_index_info structure.
 104557 //
 104558 // Return a pointer to the collation name:
 104559 //
 104560 //  1. If there is an explicit COLLATE operator on the constaint, return it.
 104561 //
 104562 //  2. Else, if the column has an alternative collation, return that.
 104563 //
 104564 //  3. Otherwise, return "BINARY".
 104565 func Xsqlite3_vtab_collation(tls *libc.TLS, pIdxInfo uintptr, iCons int32) uintptr {
 104566 	var pHidden uintptr = pIdxInfo + 1*72
 104567 	var zRet uintptr = uintptr(0)
 104568 	if iCons >= 0 && iCons < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint {
 104569 		var pC uintptr = uintptr(0)
 104570 		var iTerm int32 = (*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(iCons)*12)).FiTermOffset
 104571 		var pX uintptr = (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer((*HiddenIndexInfo)(unsafe.Pointer(pHidden)).FpWC)).Fa + uintptr(iTerm)*48)).FpExpr
 104572 		if (*Expr)(unsafe.Pointer(pX)).FpLeft != 0 {
 104573 			pC = Xsqlite3ExprCompareCollSeq(tls, (*HiddenIndexInfo)(unsafe.Pointer(pHidden)).FpParse, pX)
 104574 		}
 104575 		zRet = func() uintptr {
 104576 			if pC != 0 {
 104577 				return (*CollSeq)(unsafe.Pointer(pC)).FzName
 104578 			}
 104579 			return uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 104580 		}()
 104581 	}
 104582 	return zRet
 104583 }
 104584 
 104585 // Return true if constraint iCons is really an IN(...) constraint, or
 104586 // false otherwise. If iCons is an IN(...) constraint, set (if bHandle!=0)
 104587 // or clear (if bHandle==0) the flag to handle it using an iterator.
 104588 func Xsqlite3_vtab_in(tls *libc.TLS, pIdxInfo uintptr, iCons int32, bHandle int32) int32 {
 104589 	var pHidden uintptr = pIdxInfo + 1*72
 104590 	var m U32 = func() uint32 {
 104591 		if iCons <= 31 {
 104592 			return uint32(1) << iCons
 104593 		}
 104594 		return uint32(0)
 104595 	}()
 104596 	if m&(*HiddenIndexInfo)(unsafe.Pointer(pHidden)).FmIn != 0 {
 104597 		if bHandle == 0 {
 104598 			*(*U32)(unsafe.Pointer(pHidden + 16)) &= ^m
 104599 		} else if bHandle > 0 {
 104600 			*(*U32)(unsafe.Pointer(pHidden + 16)) |= m
 104601 		}
 104602 		return 1
 104603 	}
 104604 	return 0
 104605 }
 104606 
 104607 // This interface is callable from within the xBestIndex callback only.
 104608 //
 104609 // If possible, set (*ppVal) to point to an object containing the value
 104610 // on the right-hand-side of constraint iCons.
 104611 func Xsqlite3_vtab_rhs_value(tls *libc.TLS, pIdxInfo uintptr, iCons int32, ppVal uintptr) int32 {
 104612 	var pH uintptr = pIdxInfo + 1*72
 104613 	var pVal uintptr = uintptr(0)
 104614 	var rc int32 = SQLITE_OK
 104615 	if iCons < 0 || iCons >= (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint {
 104616 		rc = SQLITE_MISUSE
 104617 	} else {
 104618 		if *(*uintptr)(unsafe.Pointer(pH + 20 + uintptr(iCons)*4)) == uintptr(0) {
 104619 			var pTerm uintptr = (*WhereClause)(unsafe.Pointer((*HiddenIndexInfo)(unsafe.Pointer(pH)).FpWC)).Fa + uintptr((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(iCons)*12)).FiTermOffset)*48
 104620 			rc = Xsqlite3ValueFromExpr(tls,
 104621 				(*Parse)(unsafe.Pointer((*HiddenIndexInfo)(unsafe.Pointer(pH)).FpParse)).Fdb, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight, (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*HiddenIndexInfo)(unsafe.Pointer(pH)).FpParse)).Fdb)).Fenc,
 104622 				uint8(SQLITE_AFF_BLOB), pH+20+uintptr(iCons)*4)
 104623 
 104624 		}
 104625 		pVal = *(*uintptr)(unsafe.Pointer(pH + 20 + uintptr(iCons)*4))
 104626 	}
 104627 	*(*uintptr)(unsafe.Pointer(ppVal)) = pVal
 104628 
 104629 	if rc == SQLITE_OK && pVal == uintptr(0) {
 104630 		rc = SQLITE_NOTFOUND
 104631 	}
 104632 
 104633 	return rc
 104634 }
 104635 
 104636 // Return true if ORDER BY clause may be handled as DISTINCT.
 104637 func Xsqlite3_vtab_distinct(tls *libc.TLS, pIdxInfo uintptr) int32 {
 104638 	var pHidden uintptr = pIdxInfo + 1*72
 104639 
 104640 	return (*HiddenIndexInfo)(unsafe.Pointer(pHidden)).FeDistinct
 104641 }
 104642 
 104643 func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable Bitmask) int32 {
 104644 	bp := tls.Alloc(12)
 104645 	defer tls.Free(12)
 104646 
 104647 	var rc int32 = SQLITE_OK
 104648 	var pWInfo uintptr
 104649 	var pParse uintptr
 104650 	var pWC uintptr
 104651 	var pSrc uintptr
 104652 	var p uintptr
 104653 	var nConstraint int32
 104654 
 104655 	var pNew uintptr
 104656 	var mBest Bitmask
 104657 
 104658 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
 104659 
 104660 	pWInfo = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 104661 	pParse = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 104662 	pWC = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC
 104663 	pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 104664 	pSrc = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*72
 104665 
 104666 	p = allocateIndexInfo(tls, pWInfo, pWC, mUnusable, pSrc, bp)
 104667 	if p == uintptr(0) {
 104668 		return SQLITE_NOMEM
 104669 	}
 104670 	(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0)
 104671 	(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_VIRTUALTABLE)
 104672 	(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(0)
 104673 	libc.SetBitFieldPtr8Uint32(pNew+24+4, U32(0), 0, 0x1)
 104674 	nConstraint = (*Sqlite3_index_info)(unsafe.Pointer(p)).FnConstraint
 104675 	if whereLoopResize(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pNew, nConstraint) != 0 {
 104676 		freeIndexInfo(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p)
 104677 		return SQLITE_NOMEM
 104678 	}
 104679 
 104680 	rc = whereLoopAddVirtualOne(tls,
 104681 		pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), uint16(0), p, *(*U16)(unsafe.Pointer(bp)), bp+4, bp+8)
 104682 	if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
 104683 		rc = whereLoopAddVirtualOne(tls,
 104684 			pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), uint16(0), p, *(*U16)(unsafe.Pointer(bp)), bp+4, uintptr(0))
 104685 	}
 104686 
 104687 	if rc == SQLITE_OK && (libc.AssignUint64(&mBest, (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq) != uint64(0) || *(*int32)(unsafe.Pointer(bp + 4)) != 0) {
 104688 		var seenZero int32 = 0
 104689 		var seenZeroNoIN int32 = 0
 104690 		var mPrev Bitmask = uint64(0)
 104691 		var mBestNoIn Bitmask = uint64(0)
 104692 
 104693 		if *(*int32)(unsafe.Pointer(bp + 4)) != 0 {
 104694 			rc = whereLoopAddVirtualOne(tls,
 104695 				pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), uint16(WO_IN), p, *(*U16)(unsafe.Pointer(bp)), bp+4, uintptr(0))
 104696 
 104697 			mBestNoIn = (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq
 104698 			if mBestNoIn == uint64(0) {
 104699 				seenZero = 1
 104700 				seenZeroNoIN = 1
 104701 			}
 104702 		}
 104703 
 104704 		for rc == SQLITE_OK {
 104705 			var i int32
 104706 			var mNext Bitmask = libc.Uint64(libc.Uint64FromInt32(-1))
 104707 
 104708 			for i = 0; i < nConstraint; i++ {
 104709 				var mThis Bitmask = (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(p)).FaConstraint+uintptr(i)*12)).FiTermOffset)*48)).FprereqRight & ^mPrereq
 104710 				if mThis > mPrev && mThis < mNext {
 104711 					mNext = mThis
 104712 				}
 104713 			}
 104714 			mPrev = mNext
 104715 			if mNext == libc.Uint64(libc.Uint64FromInt32(-1)) {
 104716 				break
 104717 			}
 104718 			if mNext == mBest || mNext == mBestNoIn {
 104719 				continue
 104720 			}
 104721 
 104722 			rc = whereLoopAddVirtualOne(tls,
 104723 				pBuilder, mPrereq, mNext|mPrereq, uint16(0), p, *(*U16)(unsafe.Pointer(bp)), bp+4, uintptr(0))
 104724 			if (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq == mPrereq {
 104725 				seenZero = 1
 104726 				if *(*int32)(unsafe.Pointer(bp + 4)) == 0 {
 104727 					seenZeroNoIN = 1
 104728 				}
 104729 			}
 104730 		}
 104731 
 104732 		if rc == SQLITE_OK && seenZero == 0 {
 104733 			rc = whereLoopAddVirtualOne(tls,
 104734 				pBuilder, mPrereq, mPrereq, uint16(0), p, *(*U16)(unsafe.Pointer(bp)), bp+4, uintptr(0))
 104735 			if *(*int32)(unsafe.Pointer(bp + 4)) == 0 {
 104736 				seenZeroNoIN = 1
 104737 			}
 104738 		}
 104739 
 104740 		if rc == SQLITE_OK && seenZeroNoIN == 0 {
 104741 			rc = whereLoopAddVirtualOne(tls,
 104742 				pBuilder, mPrereq, mPrereq, uint16(WO_IN), p, *(*U16)(unsafe.Pointer(bp)), bp+4, uintptr(0))
 104743 		}
 104744 	}
 104745 
 104746 	if (*Sqlite3_index_info)(unsafe.Pointer(p)).FneedToFreeIdxStr != 0 {
 104747 		Xsqlite3_free(tls, (*Sqlite3_index_info)(unsafe.Pointer(p)).FidxStr)
 104748 	}
 104749 	freeIndexInfo(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p)
 104750 
 104751 	return rc
 104752 }
 104753 
 104754 func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable Bitmask) int32 {
 104755 	bp := tls.Alloc(616)
 104756 	defer tls.Free(616)
 104757 
 104758 	var pWInfo uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 104759 	var pWC uintptr
 104760 	var pNew uintptr
 104761 	var pTerm uintptr
 104762 	var pWCEnd uintptr
 104763 	var rc int32 = SQLITE_OK
 104764 	var iCur int32
 104765 
 104766 	var pItem uintptr
 104767 
 104768 	pWC = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC
 104769 	pWCEnd = (*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pWC)).FnTerm)*48
 104770 	pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 104771 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(WhereOrSet{})))
 104772 	pItem = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*72
 104773 	iCur = (*SrcItem)(unsafe.Pointer(pItem)).FiCursor
 104774 
 104775 	if int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_RIGHT != 0 {
 104776 		return SQLITE_OK
 104777 	}
 104778 
 104779 	for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; pTerm < pWCEnd && rc == SQLITE_OK; pTerm += 48 {
 104780 		if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&WO_OR != 0 &&
 104781 			(*WhereOrInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 24)))).Findexable&(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf != uint64(0) {
 104782 			var pOrWC uintptr = *(*uintptr)(unsafe.Pointer(pTerm + 24))
 104783 			var pOrWCEnd uintptr = (*WhereClause)(unsafe.Pointer(pOrWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pOrWC)).FnTerm)*48
 104784 			var pOrTerm uintptr
 104785 			var once int32 = 1
 104786 			var i int32
 104787 			var j int32
 104788 
 104789 			*(*WhereLoopBuilder)(unsafe.Pointer(bp + 528)) = *(*WhereLoopBuilder)(unsafe.Pointer(pBuilder))
 104790 			(*WhereLoopBuilder)(unsafe.Pointer(bp + 528)).FpOrSet = bp + 56
 104791 
 104792 			for pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWC)).Fa; pOrTerm < pOrWCEnd; pOrTerm += 48 {
 104793 				if int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator)&WO_AND != 0 {
 104794 					(*WhereLoopBuilder)(unsafe.Pointer(bp + 528)).FpWC = *(*uintptr)(unsafe.Pointer(pOrTerm + 24))
 104795 				} else if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur {
 104796 					(*WhereClause)(unsafe.Pointer(bp + 112)).FpWInfo = (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo
 104797 					(*WhereClause)(unsafe.Pointer(bp + 112)).FpOuter = pWC
 104798 					(*WhereClause)(unsafe.Pointer(bp + 112)).Fop = U8(TK_AND)
 104799 					(*WhereClause)(unsafe.Pointer(bp + 112)).FnTerm = 1
 104800 					(*WhereClause)(unsafe.Pointer(bp + 112)).FnBase = 1
 104801 					(*WhereClause)(unsafe.Pointer(bp + 112)).Fa = pOrTerm
 104802 					(*WhereLoopBuilder)(unsafe.Pointer(bp + 528)).FpWC = bp + 112
 104803 				} else {
 104804 					continue
 104805 				}
 104806 				(*WhereOrSet)(unsafe.Pointer(bp + 56)).Fn = U16(0)
 104807 				if int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpTab)).FeTabType) == TABTYP_VTAB {
 104808 					rc = whereLoopAddVirtual(tls, bp+528, mPrereq, mUnusable)
 104809 				} else {
 104810 					rc = whereLoopAddBtree(tls, bp+528, mPrereq)
 104811 				}
 104812 				if rc == SQLITE_OK {
 104813 					rc = whereLoopAddOr(tls, bp+528, mPrereq, mUnusable)
 104814 				}
 104815 
 104816 				if int32((*WhereOrSet)(unsafe.Pointer(bp+56)).Fn) == 0 {
 104817 					(*WhereOrSet)(unsafe.Pointer(bp)).Fn = U16(0)
 104818 					break
 104819 				} else if once != 0 {
 104820 					whereOrMove(tls, bp, bp+56)
 104821 					once = 0
 104822 				} else {
 104823 					whereOrMove(tls, bp+560, bp)
 104824 					(*WhereOrSet)(unsafe.Pointer(bp)).Fn = U16(0)
 104825 					for i = 0; i < int32((*WhereOrSet)(unsafe.Pointer(bp+560)).Fn); i++ {
 104826 						for j = 0; j < int32((*WhereOrSet)(unsafe.Pointer(bp+56)).Fn); j++ {
 104827 							whereOrInsert(tls, bp, (*WhereOrCost)(unsafe.Pointer(bp+560+8+uintptr(i)*16)).Fprereq|(*WhereOrCost)(unsafe.Pointer(bp+56+8+uintptr(j)*16)).Fprereq,
 104828 								Xsqlite3LogEstAdd(tls, (*WhereOrCost)(unsafe.Pointer(bp+560+8+uintptr(i)*16)).FrRun, (*WhereOrCost)(unsafe.Pointer(bp+56+8+uintptr(j)*16)).FrRun),
 104829 								Xsqlite3LogEstAdd(tls, (*WhereOrCost)(unsafe.Pointer(bp+560+8+uintptr(i)*16)).FnOut, (*WhereOrCost)(unsafe.Pointer(bp+56+8+uintptr(j)*16)).FnOut))
 104830 						}
 104831 					}
 104832 				}
 104833 			}
 104834 			(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(1)
 104835 			*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm
 104836 			(*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(WHERE_MULTI_OR)
 104837 			(*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0)
 104838 			(*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = U8(0)
 104839 			libc.Xmemset(tls, pNew+24, 0, uint32(unsafe.Sizeof(struct {
 104840 				Fbtree struct {
 104841 					FnEq          U16
 104842 					FnBtm         U16
 104843 					FnTop         U16
 104844 					FnDistinctCol U16
 104845 					FpIndex       uintptr
 104846 				}
 104847 				F__ccgo_pad1 [8]byte
 104848 			}{})))
 104849 			for i = 0; rc == SQLITE_OK && i < int32((*WhereOrSet)(unsafe.Pointer(bp)).Fn); i++ {
 104850 				(*WhereLoop)(unsafe.Pointer(pNew)).FrRun = LogEst(int32((*WhereOrCost)(unsafe.Pointer(bp+8+uintptr(i)*16)).FrRun) + 1)
 104851 				(*WhereLoop)(unsafe.Pointer(pNew)).FnOut = (*WhereOrCost)(unsafe.Pointer(bp + 8 + uintptr(i)*16)).FnOut
 104852 				(*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = (*WhereOrCost)(unsafe.Pointer(bp + 8 + uintptr(i)*16)).Fprereq
 104853 				rc = whereLoopInsert(tls, pBuilder, pNew)
 104854 			}
 104855 
 104856 		}
 104857 	}
 104858 	return rc
 104859 }
 104860 
 104861 func whereLoopAddAll(tls *libc.TLS, pBuilder uintptr) int32 {
 104862 	var pWInfo uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 104863 	var mPrereq Bitmask = uint64(0)
 104864 	var mPrior Bitmask = uint64(0)
 104865 	var iTab int32
 104866 	var pTabList uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList
 104867 	var pItem uintptr
 104868 	var pEnd uintptr = pTabList + 8 + uintptr((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)*72
 104869 	var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb
 104870 	var rc int32 = SQLITE_OK
 104871 	var bFirstPastRJ int32 = 0
 104872 	var hasRightJoin int32 = 0
 104873 	var pNew uintptr
 104874 
 104875 	pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 104876 
 104877 	(*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = uint32(SQLITE_QUERY_PLANNER_LIMIT)
 104878 	iTab = 0
 104879 	pItem = pTabList + 8
 104880 __1:
 104881 	if !(pItem < pEnd) {
 104882 		goto __3
 104883 	}
 104884 	{
 104885 		var mUnusable Bitmask = uint64(0)
 104886 		(*WhereLoop)(unsafe.Pointer(pNew)).FiTab = U8(iTab)
 104887 		*(*uint32)(unsafe.Pointer(pBuilder + 28)) += uint32(SQLITE_QUERY_PLANNER_LIMIT_INCR)
 104888 		(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf = Xsqlite3WhereGetMask(tls, pWInfo+496, (*SrcItem)(unsafe.Pointer(pItem)).FiCursor)
 104889 		if bFirstPastRJ != 0 ||
 104890 			int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(JT_OUTER|JT_CROSS|JT_LTORJ) != 0 {
 104891 			if int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_LTORJ != 0 {
 104892 				hasRightJoin = 1
 104893 			}
 104894 			mPrereq = mPrereq | mPrior
 104895 			bFirstPastRJ = libc.Bool32(int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&JT_RIGHT != 0)
 104896 		} else if !(hasRightJoin != 0) {
 104897 			mPrereq = uint64(0)
 104898 		}
 104899 		if int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pItem)).FpTab)).FeTabType) == TABTYP_VTAB {
 104900 			var p uintptr
 104901 			for p = pItem + 1*72; p < pEnd; p += 72 {
 104902 				if mUnusable != 0 || int32((*SrcItem)(unsafe.Pointer(p)).Ffg.Fjointype)&(JT_OUTER|JT_CROSS) != 0 {
 104903 					mUnusable = mUnusable | Xsqlite3WhereGetMask(tls, pWInfo+496, (*SrcItem)(unsafe.Pointer(p)).FiCursor)
 104904 				}
 104905 			}
 104906 			rc = whereLoopAddVirtual(tls, pBuilder, mPrereq, mUnusable)
 104907 		} else {
 104908 			rc = whereLoopAddBtree(tls, pBuilder, mPrereq)
 104909 		}
 104910 		if rc == SQLITE_OK && (*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0 {
 104911 			rc = whereLoopAddOr(tls, pBuilder, mPrereq, mUnusable)
 104912 		}
 104913 		mPrior = mPrior | (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf
 104914 		if rc != 0 || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 104915 			if rc == SQLITE_DONE {
 104916 				Xsqlite3_log(tls, SQLITE_WARNING, ts+22016, 0)
 104917 				rc = SQLITE_OK
 104918 			} else {
 104919 				goto __3
 104920 			}
 104921 		}
 104922 
 104923 	}
 104924 	goto __2
 104925 __2:
 104926 	iTab++
 104927 	pItem += 72
 104928 	goto __1
 104929 	goto __3
 104930 __3:
 104931 	;
 104932 	whereLoopClear(tls, db, pNew)
 104933 	return rc
 104934 }
 104935 
 104936 func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, pPath uintptr, wctrlFlags U16, nLoop U16, pLast uintptr, pRevMask uintptr) I8 {
 104937 	var revSet U8
 104938 	var rev U8
 104939 	var revIdx U8
 104940 	var isOrderDistinct U8
 104941 	var distinctColumns U8
 104942 	var isMatch U8
 104943 	var eqOpMask U16
 104944 	var nKeyCol U16
 104945 	var nColumn U16
 104946 	var nOrderBy U16
 104947 	var iLoop int32
 104948 	var i int32
 104949 	var j int32
 104950 	var iCur int32
 104951 	var iColumn int32
 104952 	var pLoop uintptr = uintptr(0)
 104953 	var pTerm uintptr
 104954 	var pOBExpr uintptr
 104955 	var pColl uintptr
 104956 	var pIndex uintptr
 104957 	var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb
 104958 	var obSat Bitmask = uint64(0)
 104959 	var obDone Bitmask
 104960 	var orderDistinctMask Bitmask
 104961 	var ready Bitmask
 104962 
 104963 	if nLoop != 0 && (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_OrderByIdxJoin) != U32(0) {
 104964 		return int8(0)
 104965 	}
 104966 
 104967 	nOrderBy = U16((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr)
 104968 
 104969 	if int32(nOrderBy) > int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))-1 {
 104970 		return int8(0)
 104971 	}
 104972 	isOrderDistinct = U8(1)
 104973 	obDone = uint64(1)<<int32(nOrderBy) - uint64(1)
 104974 	orderDistinctMask = uint64(0)
 104975 	ready = uint64(0)
 104976 	eqOpMask = U16(WO_EQ | WO_IS | WO_ISNULL)
 104977 	if int32(wctrlFlags)&(WHERE_ORDERBY_LIMIT|WHERE_ORDERBY_MAX|WHERE_ORDERBY_MIN) != 0 {
 104978 		eqOpMask = U16(int32(eqOpMask) | WO_IN)
 104979 	}
 104980 	for iLoop = 0; isOrderDistinct != 0 && obSat < obDone && iLoop <= int32(nLoop); iLoop++ {
 104981 		if iLoop > 0 {
 104982 			ready = ready | (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf
 104983 		}
 104984 		if iLoop < int32(nLoop) {
 104985 			pLoop = *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pPath)).FaLoop + uintptr(iLoop)*4))
 104986 			if int32(wctrlFlags)&WHERE_ORDERBY_LIMIT != 0 {
 104987 				continue
 104988 			}
 104989 		} else {
 104990 			pLoop = pLast
 104991 		}
 104992 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_VIRTUALTABLE) != 0 {
 104993 			if *(*I8)(unsafe.Pointer(pLoop + 24 + 6)) != 0 &&
 104994 				int32(wctrlFlags)&(WHERE_DISTINCTBY|WHERE_SORTBYGROUP) != WHERE_DISTINCTBY {
 104995 				obSat = obDone
 104996 			}
 104997 			break
 104998 		} else if int32(wctrlFlags)&WHERE_DISTINCTBY != 0 {
 104999 			*(*U16)(unsafe.Pointer(pLoop + 24 + 6)) = U16(0)
 105000 		}
 105001 		iCur = (*SrcItem)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*72)).FiCursor
 105002 
 105003 		for i = 0; i < int32(nOrderBy); i++ {
 105004 			if uint64(1)<<i&obSat != 0 {
 105005 				continue
 105006 			}
 105007 			pOBExpr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).FpExpr)
 105008 			if pOBExpr == uintptr(0) {
 105009 				continue
 105010 			}
 105011 			if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_COLUMN && int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_AGG_COLUMN {
 105012 				continue
 105013 			}
 105014 			if (*Expr)(unsafe.Pointer(pOBExpr)).FiTable != iCur {
 105015 				continue
 105016 			}
 105017 			pTerm = Xsqlite3WhereFindTerm(tls, pWInfo+80, iCur, int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn),
 105018 				^ready, uint32(eqOpMask), uintptr(0))
 105019 			if pTerm == uintptr(0) {
 105020 				continue
 105021 			}
 105022 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == WO_IN {
 105023 				for j = 0; j < int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) && pTerm != *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4)); j++ {
 105024 				}
 105025 				if j >= int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) {
 105026 					continue
 105027 				}
 105028 			}
 105029 			if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator)&(WO_EQ|WO_IS) != 0 && int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn) >= 0 {
 105030 				var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 105031 				var pColl1 uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).FpExpr)
 105032 				var pColl2 uintptr = Xsqlite3ExprCompareCollSeq(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)
 105033 
 105034 				if pColl2 == uintptr(0) || Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pColl1)).FzName, (*CollSeq)(unsafe.Pointer(pColl2)).FzName) != 0 {
 105035 					continue
 105036 				}
 105037 
 105038 			}
 105039 			obSat = obSat | uint64(1)<<i
 105040 		}
 105041 
 105042 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_ONEROW) == U32(0) {
 105043 			if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK) != 0 {
 105044 				pIndex = uintptr(0)
 105045 				nKeyCol = U16(0)
 105046 				nColumn = U16(1)
 105047 			} else if libc.AssignUintptr(&pIndex, *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))) == uintptr(0) || uint32(int32(*(*uint16)(unsafe.Pointer(pIndex + 56))&0x4>>2)) != 0 {
 105048 				return int8(0)
 105049 			} else {
 105050 				nKeyCol = (*Index)(unsafe.Pointer(pIndex)).FnKeyCol
 105051 				nColumn = (*Index)(unsafe.Pointer(pIndex)).FnColumn
 105052 
 105053 				isOrderDistinct = U8(libc.Bool32(int32((*Index)(unsafe.Pointer(pIndex)).FonError) != OE_None &&
 105054 					(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_SKIPSCAN) == U32(0)))
 105055 			}
 105056 
 105057 			rev = libc.AssignUint8(&revSet, U8(0))
 105058 			distinctColumns = U8(0)
 105059 			for j = 0; j < int32(nColumn); j++ {
 105060 				var bOnce U8 = U8(1)
 105061 
 105062 				if j < int32(*(*U16)(unsafe.Pointer(pLoop + 24))) && j >= int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip) {
 105063 					var eOp U16 = (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4)))).FeOperator
 105064 
 105065 					if int32(eOp)&int32(eqOpMask) != 0 {
 105066 						if int32(eOp)&(WO_ISNULL|WO_IS) != 0 {
 105067 							isOrderDistinct = U8(0)
 105068 						}
 105069 						continue
 105070 					} else if int32(eOp)&WO_IN != 0 {
 105071 						var pX uintptr = (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4)))).FpExpr
 105072 						for i = j + 1; i < int32(*(*U16)(unsafe.Pointer(pLoop + 24))); i++ {
 105073 							if (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*4)))).FpExpr == pX {
 105074 								bOnce = U8(0)
 105075 								break
 105076 							}
 105077 						}
 105078 					}
 105079 				}
 105080 
 105081 				if pIndex != 0 {
 105082 					iColumn = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(j)*2)))
 105083 					revIdx = U8(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(j)))) & KEYINFO_ORDER_DESC)
 105084 					if iColumn == int32((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FiPKey) {
 105085 						iColumn = -1
 105086 					}
 105087 				} else {
 105088 					iColumn = -1
 105089 					revIdx = U8(0)
 105090 				}
 105091 
 105092 				if isOrderDistinct != 0 {
 105093 					if iColumn >= 0 &&
 105094 						j >= int32(*(*U16)(unsafe.Pointer(pLoop + 24))) &&
 105095 						int32(*(*uint8)(unsafe.Pointer((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FaCol + uintptr(iColumn)*16 + 4))&0xf>>0) == 0 {
 105096 						isOrderDistinct = U8(0)
 105097 					}
 105098 					if iColumn == -2 {
 105099 						isOrderDistinct = U8(0)
 105100 					}
 105101 				}
 105102 
 105103 				isMatch = U8(0)
 105104 				for i = 0; bOnce != 0 && i < int32(nOrderBy); i++ {
 105105 					if uint64(1)<<i&obSat != 0 {
 105106 						continue
 105107 					}
 105108 					pOBExpr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).FpExpr)
 105109 
 105110 					if pOBExpr == uintptr(0) {
 105111 						continue
 105112 					}
 105113 					if int32(wctrlFlags)&(WHERE_GROUPBY|WHERE_DISTINCTBY) == 0 {
 105114 						bOnce = U8(0)
 105115 					}
 105116 					if iColumn >= -1 {
 105117 						if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_COLUMN && int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_AGG_COLUMN {
 105118 							continue
 105119 						}
 105120 						if (*Expr)(unsafe.Pointer(pOBExpr)).FiTable != iCur {
 105121 							continue
 105122 						}
 105123 						if int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn) != iColumn {
 105124 							continue
 105125 						}
 105126 					} else {
 105127 						var pIxExpr uintptr = (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaColExpr + 8 + uintptr(j)*20)).FpExpr
 105128 						if Xsqlite3ExprCompareSkip(tls, pOBExpr, pIxExpr, iCur) != 0 {
 105129 							continue
 105130 						}
 105131 					}
 105132 					if iColumn != -1 {
 105133 						pColl = Xsqlite3ExprNNCollSeq(tls, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse, (*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).FpExpr)
 105134 						if Xsqlite3StrICmp(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FazColl + uintptr(j)*4))) != 0 {
 105135 							continue
 105136 						}
 105137 					}
 105138 					if int32(wctrlFlags)&WHERE_DISTINCTBY != 0 {
 105139 						*(*U16)(unsafe.Pointer(pLoop + 24 + 6)) = U16(j + 1)
 105140 					}
 105141 					isMatch = U8(1)
 105142 					break
 105143 				}
 105144 				if isMatch != 0 && int32(wctrlFlags)&WHERE_GROUPBY == 0 {
 105145 					if revSet != 0 {
 105146 						if int32(rev)^int32(revIdx) !=
 105147 							int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).Ffg.FsortFlags)&KEYINFO_ORDER_DESC {
 105148 							isMatch = U8(0)
 105149 						}
 105150 					} else {
 105151 						rev = U8(int32(revIdx) ^ int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).Ffg.FsortFlags)&KEYINFO_ORDER_DESC)
 105152 						if rev != 0 {
 105153 							*(*Bitmask)(unsafe.Pointer(pRevMask)) |= uint64(1) << iLoop
 105154 						}
 105155 						revSet = U8(1)
 105156 					}
 105157 				}
 105158 				if isMatch != 0 && int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8+uintptr(i)*20)).Ffg.FsortFlags)&KEYINFO_ORDER_BIGNULL != 0 {
 105159 					if j == int32(*(*U16)(unsafe.Pointer(pLoop + 24))) {
 105160 						*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_BIGNULL_SORT)
 105161 					} else {
 105162 						isMatch = U8(0)
 105163 					}
 105164 				}
 105165 				if isMatch != 0 {
 105166 					if iColumn == -1 {
 105167 						distinctColumns = U8(1)
 105168 					}
 105169 					obSat = obSat | uint64(1)<<i
 105170 				} else {
 105171 					if j == 0 || j < int32(nKeyCol) {
 105172 						isOrderDistinct = U8(0)
 105173 					}
 105174 					break
 105175 				}
 105176 			}
 105177 			if distinctColumns != 0 {
 105178 				isOrderDistinct = U8(1)
 105179 			}
 105180 		}
 105181 
 105182 		if isOrderDistinct != 0 {
 105183 			orderDistinctMask = orderDistinctMask | (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf
 105184 			for i = 0; i < int32(nOrderBy); i++ {
 105185 				var p uintptr
 105186 				var mTerm Bitmask
 105187 				if uint64(1)<<i&obSat != 0 {
 105188 					continue
 105189 				}
 105190 				p = (*ExprList_item)(unsafe.Pointer(pOrderBy + 8 + uintptr(i)*20)).FpExpr
 105191 				mTerm = Xsqlite3WhereExprUsage(tls, pWInfo+496, p)
 105192 				if mTerm == uint64(0) && !(Xsqlite3ExprIsConstant(tls, p) != 0) {
 105193 					continue
 105194 				}
 105195 				if mTerm & ^orderDistinctMask == uint64(0) {
 105196 					obSat = obSat | uint64(1)<<i
 105197 				}
 105198 			}
 105199 		}
 105200 	}
 105201 	if obSat == obDone {
 105202 		return I8(nOrderBy)
 105203 	}
 105204 	if !(isOrderDistinct != 0) {
 105205 		for i = int32(nOrderBy) - 1; i > 0; i-- {
 105206 			var m Bitmask
 105207 			if i < int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) {
 105208 				m = uint64(1)<<i - uint64(1)
 105209 			} else {
 105210 				m = uint64(0)
 105211 			}
 105212 			if obSat&m == m {
 105213 				return I8(i)
 105214 			}
 105215 		}
 105216 		return int8(0)
 105217 	}
 105218 	return int8(-1)
 105219 }
 105220 
 105221 // If the WHERE_GROUPBY flag is set in the mask passed to sqlite3WhereBegin(),
 105222 // the planner assumes that the specified pOrderBy list is actually a GROUP
 105223 // BY clause - and so any order that groups rows as required satisfies the
 105224 // request.
 105225 //
 105226 // Normally, in this case it is not possible for the caller to determine
 105227 // whether or not the rows are really being delivered in sorted order, or
 105228 // just in some other order that provides the required grouping. However,
 105229 // if the WHERE_SORTBYGROUP flag is also passed to sqlite3WhereBegin(), then
 105230 // this function may be called on the returned WhereInfo object. It returns
 105231 // true if the rows really will be sorted in the specified order, or false
 105232 // otherwise.
 105233 //
 105234 // For example, assuming:
 105235 //
 105236 //	CREATE INDEX i1 ON t1(x, Y);
 105237 //
 105238 // then
 105239 //
 105240 //	SELECT * FROM t1 GROUP BY x,y ORDER BY x,y;   -- IsSorted()==1
 105241 //	SELECT * FROM t1 GROUP BY y,x ORDER BY y,x;   -- IsSorted()==0
 105242 func Xsqlite3WhereIsSorted(tls *libc.TLS, pWInfo uintptr) int32 {
 105243 	return int32(*(*uint8)(unsafe.Pointer(pWInfo + 48)) & 0x8 >> 3)
 105244 }
 105245 
 105246 func whereSortingCost(tls *libc.TLS, pWInfo uintptr, nRow LogEst, nOrderBy int32, nSorted int32) LogEst {
 105247 	var rSortCost LogEst
 105248 	var nCol LogEst
 105249 
 105250 	nCol = Xsqlite3LogEst(tls, uint64(((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FpEList)).FnExpr+59)/30))
 105251 	rSortCost = LogEst(int32(nRow) + int32(nCol))
 105252 	if nSorted > 0 {
 105253 		rSortCost = LogEst(int32(rSortCost) + (int32(Xsqlite3LogEst(tls, uint64((nOrderBy-nSorted)*100/nOrderBy))) - 66))
 105254 	}
 105255 
 105256 	if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_USE_LIMIT != 0 {
 105257 		rSortCost = int16(int32(rSortCost) + 10)
 105258 		if nSorted != 0 {
 105259 			rSortCost = int16(int32(rSortCost) + 6)
 105260 		}
 105261 		if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit) < int32(nRow) {
 105262 			nRow = (*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit
 105263 		}
 105264 	} else if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_WANT_DISTINCT != 0 {
 105265 		if int32(nRow) > 10 {
 105266 			nRow = int16(int32(nRow) - 10)
 105267 		}
 105268 	}
 105269 	rSortCost = LogEst(int32(rSortCost) + int32(estLog(tls, nRow)))
 105270 	return rSortCost
 105271 }
 105272 
 105273 func wherePathSolver(tls *libc.TLS, pWInfo uintptr, nRowEst LogEst) int32 {
 105274 	bp := tls.Alloc(32)
 105275 	defer tls.Free(32)
 105276 
 105277 	var mxChoice int32
 105278 	var nLoop int32
 105279 	var pParse uintptr
 105280 	var iLoop int32
 105281 	var ii int32
 105282 	var jj int32
 105283 	var mxI int32 = 0
 105284 	var nOrderBy int32
 105285 	var mxCost LogEst = int16(0)
 105286 	var mxUnsorted LogEst = int16(0)
 105287 	var nTo int32
 105288 	var nFrom int32
 105289 	var aFrom uintptr
 105290 	var aTo uintptr
 105291 	var pFrom uintptr
 105292 	var pTo uintptr
 105293 	var pWLoop uintptr
 105294 	var pX uintptr
 105295 	var aSortCost uintptr = uintptr(0)
 105296 	var pSpace uintptr
 105297 	var nSpace int32
 105298 
 105299 	pParse = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 105300 	nLoop = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)
 105301 
 105302 	if nLoop <= 1 {
 105303 		mxChoice = 1
 105304 	} else {
 105305 		mxChoice = func() int32 {
 105306 			if nLoop == 2 {
 105307 				return 5
 105308 			}
 105309 			return 10
 105310 		}()
 105311 	}
 105312 
 105313 	if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0) || int32(nRowEst) == 0 {
 105314 		nOrderBy = 0
 105315 	} else {
 105316 		nOrderBy = (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr
 105317 	}
 105318 
 105319 	nSpace = int32((uint32(unsafe.Sizeof(WherePath{})) + uint32(unsafe.Sizeof(uintptr(0)))*uint32(nLoop)) * uint32(mxChoice) * uint32(2))
 105320 	nSpace = int32(uint32(nSpace) + uint32(unsafe.Sizeof(LogEst(0)))*uint32(nOrderBy))
 105321 	pSpace = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(nSpace))
 105322 	if pSpace == uintptr(0) {
 105323 		return SQLITE_NOMEM
 105324 	}
 105325 	aTo = pSpace
 105326 	aFrom = aTo + uintptr(mxChoice)*32
 105327 	libc.Xmemset(tls, aFrom, 0, uint32(unsafe.Sizeof(WherePath{})))
 105328 	pX = aFrom + uintptr(mxChoice)*32
 105329 	ii = mxChoice * 2
 105330 	pFrom = aTo
 105331 __1:
 105332 	if !(ii > 0) {
 105333 		goto __3
 105334 	}
 105335 	{
 105336 		(*WherePath)(unsafe.Pointer(pFrom)).FaLoop = pX
 105337 
 105338 	}
 105339 	goto __2
 105340 __2:
 105341 	ii--
 105342 	pFrom += 32
 105343 	pX += 4 * uintptr(nLoop)
 105344 	goto __1
 105345 	goto __3
 105346 __3:
 105347 	;
 105348 	if nOrderBy != 0 {
 105349 		aSortCost = pX
 105350 		libc.Xmemset(tls, aSortCost, 0, uint32(unsafe.Sizeof(LogEst(0)))*uint32(nOrderBy))
 105351 	}
 105352 
 105353 	(*WherePath)(unsafe.Pointer(aFrom)).FnRow = func() int16 {
 105354 		if (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop < U32(48) {
 105355 			return int16((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop)
 105356 		}
 105357 		return int16(48)
 105358 	}()
 105359 	nFrom = 1
 105360 
 105361 	if nOrderBy != 0 {
 105362 		(*WherePath)(unsafe.Pointer(aFrom)).FisOrdered = func() int8 {
 105363 			if nLoop > 0 {
 105364 				return int8(-1)
 105365 			}
 105366 			return int8(nOrderBy)
 105367 		}()
 105368 	}
 105369 
 105370 	for iLoop = 0; iLoop < nLoop; iLoop++ {
 105371 		nTo = 0
 105372 		ii = 0
 105373 		pFrom = aFrom
 105374 	__4:
 105375 		if !(ii < nFrom) {
 105376 			goto __6
 105377 		}
 105378 		{
 105379 			for pWLoop = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops; pWLoop != 0; pWLoop = (*WhereLoop)(unsafe.Pointer(pWLoop)).FpNextLoop {
 105380 				var nOut LogEst
 105381 				var rCost LogEst
 105382 				var rUnsorted LogEst
 105383 				var isOrdered I8
 105384 				var maskNew Bitmask
 105385 
 105386 				if (*WhereLoop)(unsafe.Pointer(pWLoop)).Fprereq & ^(*WherePath)(unsafe.Pointer(pFrom)).FmaskLoop != uint64(0) {
 105387 					continue
 105388 				}
 105389 				if (*WhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf&(*WherePath)(unsafe.Pointer(pFrom)).FmaskLoop != uint64(0) {
 105390 					continue
 105391 				}
 105392 				if (*WhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags&U32(WHERE_AUTO_INDEX) != U32(0) && int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow) < 3 {
 105393 					continue
 105394 				}
 105395 
 105396 				rUnsorted = Xsqlite3LogEstAdd(tls, (*WhereLoop)(unsafe.Pointer(pWLoop)).FrSetup, int16(int32((*WhereLoop)(unsafe.Pointer(pWLoop)).FrRun)+int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow)))
 105397 				rUnsorted = Xsqlite3LogEstAdd(tls, rUnsorted, (*WherePath)(unsafe.Pointer(pFrom)).FrUnsorted)
 105398 				nOut = LogEst(int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow) + int32((*WhereLoop)(unsafe.Pointer(pWLoop)).FnOut))
 105399 				maskNew = (*WherePath)(unsafe.Pointer(pFrom)).FmaskLoop | (*WhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf
 105400 				isOrdered = (*WherePath)(unsafe.Pointer(pFrom)).FisOrdered
 105401 				if int32(isOrdered) < 0 {
 105402 					*(*Bitmask)(unsafe.Pointer(bp)) = uint64(0)
 105403 					isOrdered = wherePathSatisfiesOrderBy(tls, pWInfo,
 105404 						(*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, (*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags,
 105405 						uint16(iLoop), pWLoop, bp)
 105406 				} else {
 105407 					*(*Bitmask)(unsafe.Pointer(bp)) = (*WherePath)(unsafe.Pointer(pFrom)).FrevLoop
 105408 				}
 105409 				if int32(isOrdered) >= 0 && int32(isOrdered) < nOrderBy {
 105410 					if int32(*(*LogEst)(unsafe.Pointer(aSortCost + uintptr(isOrdered)*2))) == 0 {
 105411 						*(*LogEst)(unsafe.Pointer(aSortCost + uintptr(isOrdered)*2)) = whereSortingCost(tls,
 105412 							pWInfo, nRowEst, nOrderBy, int32(isOrdered))
 105413 					}
 105414 
 105415 					rCost = LogEst(int32(Xsqlite3LogEstAdd(tls, rUnsorted, *(*LogEst)(unsafe.Pointer(aSortCost + uintptr(isOrdered)*2)))) + 3)
 105416 
 105417 				} else {
 105418 					rCost = rUnsorted
 105419 					rUnsorted = int16(int32(rUnsorted) - 2)
 105420 				}
 105421 
 105422 				if iLoop == 0 && (*WhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags&U32(WHERE_VIEWSCAN) != U32(0) {
 105423 					rCost = int16(int32(rCost) + -10)
 105424 					nOut = int16(int32(nOut) + -30)
 105425 				}
 105426 
 105427 				jj = 0
 105428 				pTo = aTo
 105429 			__7:
 105430 				if !(jj < nTo) {
 105431 					goto __9
 105432 				}
 105433 				{
 105434 					if (*WherePath)(unsafe.Pointer(pTo)).FmaskLoop == maskNew &&
 105435 						(int32((*WherePath)(unsafe.Pointer(pTo)).FisOrdered)^int32(isOrdered))&0x80 == 0 {
 105436 						goto __9
 105437 					}
 105438 
 105439 				}
 105440 				goto __8
 105441 			__8:
 105442 				jj++
 105443 				pTo += 32
 105444 				goto __7
 105445 				goto __9
 105446 			__9:
 105447 				;
 105448 				if jj >= nTo {
 105449 					if nTo >= mxChoice &&
 105450 						(int32(rCost) > int32(mxCost) || int32(rCost) == int32(mxCost) && int32(rUnsorted) >= int32(mxUnsorted)) {
 105451 						continue
 105452 					}
 105453 
 105454 					if nTo < mxChoice {
 105455 						jj = libc.PostIncInt32(&nTo, 1)
 105456 					} else {
 105457 						jj = mxI
 105458 					}
 105459 					pTo = aTo + uintptr(jj)*32
 105460 				} else {
 105461 					if int32((*WherePath)(unsafe.Pointer(pTo)).FrCost) < int32(rCost) ||
 105462 						int32((*WherePath)(unsafe.Pointer(pTo)).FrCost) == int32(rCost) &&
 105463 							(int32((*WherePath)(unsafe.Pointer(pTo)).FnRow) < int32(nOut) ||
 105464 								int32((*WherePath)(unsafe.Pointer(pTo)).FnRow) == int32(nOut) && int32((*WherePath)(unsafe.Pointer(pTo)).FrUnsorted) <= int32(rUnsorted)) {
 105465 						continue
 105466 					}
 105467 
 105468 				}
 105469 
 105470 				(*WherePath)(unsafe.Pointer(pTo)).FmaskLoop = (*WherePath)(unsafe.Pointer(pFrom)).FmaskLoop | (*WhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf
 105471 				(*WherePath)(unsafe.Pointer(pTo)).FrevLoop = *(*Bitmask)(unsafe.Pointer(bp))
 105472 				(*WherePath)(unsafe.Pointer(pTo)).FnRow = nOut
 105473 				(*WherePath)(unsafe.Pointer(pTo)).FrCost = rCost
 105474 				(*WherePath)(unsafe.Pointer(pTo)).FrUnsorted = rUnsorted
 105475 				(*WherePath)(unsafe.Pointer(pTo)).FisOrdered = isOrdered
 105476 				libc.Xmemcpy(tls, (*WherePath)(unsafe.Pointer(pTo)).FaLoop, (*WherePath)(unsafe.Pointer(pFrom)).FaLoop, uint32(unsafe.Sizeof(uintptr(0)))*uint32(iLoop))
 105477 				*(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*4)) = pWLoop
 105478 				if nTo >= mxChoice {
 105479 					mxI = 0
 105480 					mxCost = (*WherePath)(unsafe.Pointer(aTo)).FrCost
 105481 					mxUnsorted = (*WherePath)(unsafe.Pointer(aTo)).FnRow
 105482 					jj = 1
 105483 					pTo = aTo + 1*32
 105484 				__10:
 105485 					if !(jj < mxChoice) {
 105486 						goto __12
 105487 					}
 105488 					{
 105489 						if int32((*WherePath)(unsafe.Pointer(pTo)).FrCost) > int32(mxCost) ||
 105490 							int32((*WherePath)(unsafe.Pointer(pTo)).FrCost) == int32(mxCost) && int32((*WherePath)(unsafe.Pointer(pTo)).FrUnsorted) > int32(mxUnsorted) {
 105491 							mxCost = (*WherePath)(unsafe.Pointer(pTo)).FrCost
 105492 							mxUnsorted = (*WherePath)(unsafe.Pointer(pTo)).FrUnsorted
 105493 							mxI = jj
 105494 						}
 105495 
 105496 					}
 105497 					goto __11
 105498 				__11:
 105499 					jj++
 105500 					pTo += 32
 105501 					goto __10
 105502 					goto __12
 105503 				__12:
 105504 				}
 105505 			}
 105506 
 105507 		}
 105508 		goto __5
 105509 	__5:
 105510 		ii++
 105511 		pFrom += 32
 105512 		goto __4
 105513 		goto __6
 105514 	__6:
 105515 		;
 105516 		pFrom = aTo
 105517 		aTo = aFrom
 105518 		aFrom = pFrom
 105519 		nFrom = nTo
 105520 	}
 105521 
 105522 	if nFrom == 0 {
 105523 		Xsqlite3ErrorMsg(tls, pParse, ts+22051, 0)
 105524 		Xsqlite3DbFreeNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pSpace)
 105525 		return SQLITE_ERROR
 105526 	}
 105527 
 105528 	pFrom = aFrom
 105529 	for ii = 1; ii < nFrom; ii++ {
 105530 		if int32((*WherePath)(unsafe.Pointer(pFrom)).FrCost) > int32((*WherePath)(unsafe.Pointer(aFrom+uintptr(ii)*32)).FrCost) {
 105531 			pFrom = aFrom + uintptr(ii)*32
 105532 		}
 105533 	}
 105534 
 105535 	for iLoop = 0; iLoop < nLoop; iLoop++ {
 105536 		var pLevel uintptr = pWInfo + 760 + uintptr(iLoop)*88
 105537 		(*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop = libc.AssignUintptr(&pWLoop, *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(iLoop)*4)))
 105538 		(*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom = (*WhereLoop)(unsafe.Pointer(pWLoop)).FiTab
 105539 		(*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur = (*SrcItem)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72)).FiCursor
 105540 	}
 105541 	if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_WANT_DISTINCT != 0 &&
 105542 		int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_DISTINCTBY == 0 &&
 105543 		int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_NOOP &&
 105544 		nRowEst != 0 {
 105545 		var rc int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet, pFrom,
 105546 			uint16(WHERE_DISTINCTBY), uint16(nLoop-1), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-1)*4)), bp+8))
 105547 		if rc == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet)).FnExpr {
 105548 			(*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(WHERE_DISTINCT_ORDERED)
 105549 		}
 105550 	}
 105551 	libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(0), 2, 0x4)
 105552 	if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 {
 105553 		(*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = (*WherePath)(unsafe.Pointer(pFrom)).FisOrdered
 105554 		if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_DISTINCTBY != 0 {
 105555 			if int32((*WherePath)(unsafe.Pointer(pFrom)).FisOrdered) == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr {
 105556 				(*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(WHERE_DISTINCT_ORDERED)
 105557 			}
 105558 			if (*Select)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FpOrderBy != 0 &&
 105559 				int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) > (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FpOrderBy)).FnExpr {
 105560 				(*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect)).FpOrderBy)).FnExpr)
 105561 			}
 105562 		} else {
 105563 			(*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = (*WherePath)(unsafe.Pointer(pFrom)).FrevLoop
 105564 			if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) <= 0 {
 105565 				(*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8(0)
 105566 				if nLoop > 0 {
 105567 					var wsFlags U32 = (*WhereLoop)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-1)*4)))).FwsFlags
 105568 					if wsFlags&U32(WHERE_ONEROW) == U32(0) &&
 105569 						wsFlags&U32(WHERE_IPK|WHERE_COLUMN_IN) != U32(WHERE_IPK|WHERE_COLUMN_IN) {
 105570 						*(*Bitmask)(unsafe.Pointer(bp + 16)) = uint64(0)
 105571 						var rc int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom,
 105572 							uint16(WHERE_ORDERBY_LIMIT), uint16(nLoop-1), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-1)*4)), bp+16))
 105573 
 105574 						if rc == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr {
 105575 							libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(1), 2, 0x4)
 105576 							(*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = *(*Bitmask)(unsafe.Pointer(bp + 16))
 105577 						}
 105578 					}
 105579 				}
 105580 			} else if nLoop != 0 &&
 105581 				int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == 1 &&
 105582 				int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX) != 0 {
 105583 				libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(1), 2, 0x4)
 105584 			}
 105585 		}
 105586 		if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_SORTBYGROUP != 0 &&
 105587 			int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr && nLoop > 0 {
 105588 			*(*Bitmask)(unsafe.Pointer(bp + 24)) = uint64(0)
 105589 			var nOrder int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy,
 105590 				pFrom, uint16(0), uint16(nLoop-1), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr(nLoop-1)*4)), bp+24))
 105591 
 105592 			if nOrder == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr {
 105593 				libc.SetBitFieldPtr8Uint32(pWInfo+48, uint32(1), 3, 0x8)
 105594 				(*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = *(*Bitmask)(unsafe.Pointer(bp + 24))
 105595 			}
 105596 		}
 105597 	}
 105598 
 105599 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = (*WherePath)(unsafe.Pointer(pFrom)).FnRow
 105600 
 105601 	Xsqlite3DbFreeNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pSpace)
 105602 	return SQLITE_OK
 105603 }
 105604 
 105605 func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 {
 105606 	bp := tls.Alloc(96)
 105607 	defer tls.Free(96)
 105608 
 105609 	var pWInfo uintptr
 105610 	var pItem uintptr
 105611 	var pWC uintptr
 105612 	var pTerm uintptr
 105613 	var pLoop uintptr
 105614 	var iCur int32
 105615 	var j int32
 105616 	var pTab uintptr
 105617 	var pIdx uintptr
 105618 
 105619 	pWInfo = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo
 105620 	if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_OR_SUBCLAUSE != 0 {
 105621 		return 0
 105622 	}
 105623 
 105624 	pItem = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8
 105625 	pTab = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
 105626 	if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
 105627 		return 0
 105628 	}
 105629 	if uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x2>>1)) != 0 || uint32(int32(*(*uint16)(unsafe.Pointer(pItem + 36 + 4))&0x1>>0)) != 0 {
 105630 		return 0
 105631 	}
 105632 	iCur = (*SrcItem)(unsafe.Pointer(pItem)).FiCursor
 105633 	pWC = pWInfo + 80
 105634 	pLoop = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew
 105635 	(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = U32(0)
 105636 	(*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip = U16(0)
 105637 	pTerm = whereScanInit(tls, bp, pWC, iCur, -1, uint32(WO_EQ|WO_IS), uintptr(0))
 105638 	for pTerm != 0 && (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight != 0 {
 105639 		pTerm = whereScanNext(tls, bp)
 105640 	}
 105641 	if pTerm != 0 {
 105642 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = U32(WHERE_COLUMN_EQ | WHERE_IPK | WHERE_ONEROW)
 105643 		*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) = pTerm
 105644 		(*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = U16(1)
 105645 		*(*U16)(unsafe.Pointer(pLoop + 24)) = U16(1)
 105646 
 105647 		(*WhereLoop)(unsafe.Pointer(pLoop)).FrRun = int16(33)
 105648 	} else {
 105649 		for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext {
 105650 			var opMask int32
 105651 
 105652 			if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) != OE_None) ||
 105653 				(*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) ||
 105654 				int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) > int32(uint32(unsafe.Sizeof([3]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))) {
 105655 				continue
 105656 			}
 105657 			if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x8>>3)) != 0 {
 105658 				opMask = WO_EQ | WO_IS
 105659 			} else {
 105660 				opMask = WO_EQ
 105661 			}
 105662 			for j = 0; j < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); j++ {
 105663 				pTerm = whereScanInit(tls, bp, pWC, iCur, j, uint32(opMask), pIdx)
 105664 				for pTerm != 0 && (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight != 0 {
 105665 					pTerm = whereScanNext(tls, bp)
 105666 				}
 105667 				if pTerm == uintptr(0) {
 105668 					break
 105669 				}
 105670 
 105671 				*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*4)) = pTerm
 105672 			}
 105673 			if j != int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) {
 105674 				continue
 105675 			}
 105676 			(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = U32(WHERE_COLUMN_EQ | WHERE_ONEROW | WHERE_INDEXED)
 105677 			if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x20>>5)) != 0 || (*SrcItem)(unsafe.Pointer(pItem)).FcolUsed&(*Index)(unsafe.Pointer(pIdx)).FcolNotIdxed == uint64(0) {
 105678 				*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_IDX_ONLY)
 105679 			}
 105680 			(*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = U16(j)
 105681 			*(*U16)(unsafe.Pointer(pLoop + 24)) = U16(j)
 105682 			*(*uintptr)(unsafe.Pointer(pLoop + 24 + 8)) = pIdx
 105683 
 105684 			(*WhereLoop)(unsafe.Pointer(pLoop)).FrRun = int16(39)
 105685 			break
 105686 		}
 105687 	}
 105688 	if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags != 0 {
 105689 		(*WhereLoop)(unsafe.Pointer(pLoop)).FnOut = int16(1)
 105690 		(*WhereLevel)(unsafe.Pointer(pWInfo + 760)).FpWLoop = pLoop
 105691 
 105692 		(*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf = uint64(1)
 105693 		(*WhereLevel)(unsafe.Pointer(pWInfo + 760)).FiTabCur = iCur
 105694 		(*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = int16(1)
 105695 		if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 {
 105696 			(*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr)
 105697 		}
 105698 		if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_WANT_DISTINCT != 0 {
 105699 			(*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(WHERE_DISTINCT_UNIQUE)
 105700 		}
 105701 		if int32((*WhereScan)(unsafe.Pointer(bp)).FiEquiv) > 1 {
 105702 			*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_TRANSCONS)
 105703 		}
 105704 		return 1
 105705 	}
 105706 	return 0
 105707 }
 105708 
 105709 func exprNodeIsDeterministic(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
 105710 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION && libc.Bool32((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_ConstFunc) != U32(0)) == 0 {
 105711 		(*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0)
 105712 		return WRC_Abort
 105713 	}
 105714 	return WRC_Continue
 105715 }
 105716 
 105717 func exprIsDeterministic(tls *libc.TLS, p uintptr) int32 {
 105718 	bp := tls.Alloc(28)
 105719 	defer tls.Free(28)
 105720 
 105721 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
 105722 	(*Walker)(unsafe.Pointer(bp)).FeCode = U16(1)
 105723 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
 105724 		f func(*libc.TLS, uintptr, uintptr) int32
 105725 	}{exprNodeIsDeterministic}))
 105726 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
 105727 		f func(*libc.TLS, uintptr, uintptr) int32
 105728 	}{Xsqlite3SelectWalkFail}))
 105729 	Xsqlite3WalkExpr(tls, bp, p)
 105730 	return int32((*Walker)(unsafe.Pointer(bp)).FeCode)
 105731 }
 105732 
 105733 func whereOmitNoopJoin(tls *libc.TLS, pWInfo uintptr, notReady Bitmask) Bitmask {
 105734 	var i int32
 105735 	var tabUsed Bitmask
 105736 
 105737 	tabUsed = Xsqlite3WhereExprListUsage(tls, pWInfo+496, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet)
 105738 	if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 {
 105739 		tabUsed = tabUsed | Xsqlite3WhereExprListUsage(tls, pWInfo+496, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)
 105740 	}
 105741 	for i = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - 1; i >= 1; i-- {
 105742 		var pTerm uintptr
 105743 		var pEnd uintptr
 105744 		var pItem uintptr
 105745 		var pLoop uintptr
 105746 		pLoop = (*WhereLevel)(unsafe.Pointer(pWInfo + 760 + uintptr(i)*88)).FpWLoop
 105747 		pItem = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*72
 105748 		if int32((*SrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&(JT_LEFT|JT_RIGHT) != JT_LEFT {
 105749 			continue
 105750 		}
 105751 		if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_WANT_DISTINCT == 0 &&
 105752 			(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_ONEROW) == U32(0) {
 105753 			continue
 105754 		}
 105755 		if tabUsed&(*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) {
 105756 			continue
 105757 		}
 105758 		pEnd = (*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa + uintptr((*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.FnTerm)*48
 105759 		for pTerm = (*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa; pTerm < pEnd; pTerm += 48 {
 105760 			if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) {
 105761 				if !((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags&U32(EP_OuterON) != U32(0)) ||
 105762 					*(*int32)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr + 36)) != (*SrcItem)(unsafe.Pointer(pItem)).FiCursor {
 105763 					break
 105764 				}
 105765 			}
 105766 		}
 105767 		if pTerm < pEnd {
 105768 			continue
 105769 		}
 105770 
 105771 		notReady = notReady & ^(*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf
 105772 		for pTerm = (*WhereInfo)(unsafe.Pointer(pWInfo)).FsWC.Fa; pTerm < pEnd; pTerm += 48 {
 105773 			if (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll&(*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf != uint64(0) {
 105774 				*(*U16)(unsafe.Pointer(pTerm + 10)) |= U16(TERM_CODED)
 105775 			}
 105776 		}
 105777 		if i != int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-1 {
 105778 			var nByte int32 = int32(uint32(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-1-i) * uint32(unsafe.Sizeof(WhereLevel{})))
 105779 			libc.Xmemmove(tls, pWInfo+760+uintptr(i)*88, pWInfo+760+uintptr(i+1)*88, uint32(nByte))
 105780 		}
 105781 		(*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel--
 105782 
 105783 	}
 105784 	return notReady
 105785 }
 105786 
 105787 func whereCheckIfBloomFilterIsUseful(tls *libc.TLS, pWInfo uintptr) {
 105788 	var i int32
 105789 	var nSearch LogEst = int16(0)
 105790 
 105791 	for i = 0; i < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel); i++ {
 105792 		var pLoop uintptr = (*WhereLevel)(unsafe.Pointer(pWInfo + 760 + uintptr(i)*88)).FpWLoop
 105793 		var reqFlags uint32 = uint32(WHERE_SELFCULL | WHERE_COLUMN_EQ)
 105794 		var pItem uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*72
 105795 		var pTab uintptr = (*SrcItem)(unsafe.Pointer(pItem)).FpTab
 105796 		if (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasStat1) == U32(0) {
 105797 			break
 105798 		}
 105799 		*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_StatsUsed)
 105800 		if i >= 1 &&
 105801 			(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&reqFlags == reqFlags &&
 105802 			(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IPK|WHERE_INDEXED) != U32(0) {
 105803 			if int32(nSearch) > int32((*Table)(unsafe.Pointer(pTab)).FnRowLogEst) {
 105804 				*(*U32)(unsafe.Pointer(pLoop + 44)) |= U32(WHERE_BLOOMFILTER)
 105805 				*(*U32)(unsafe.Pointer(pLoop + 44)) &= libc.Uint32FromInt32(libc.CplInt32(WHERE_IDX_ONLY))
 105806 
 105807 			}
 105808 		}
 105809 		nSearch = LogEst(int32(nSearch) + int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnOut))
 105810 	}
 105811 }
 105812 
 105813 func whereIndexedExprCleanup(tls *libc.TLS, db uintptr, pObject uintptr) {
 105814 	var pParse uintptr = pObject
 105815 	for (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr != uintptr(0) {
 105816 		var p uintptr = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr
 105817 		(*Parse)(unsafe.Pointer(pParse)).FpIdxEpr = (*IndexedExpr)(unsafe.Pointer(p)).FpIENext
 105818 		Xsqlite3ExprDelete(tls, db, (*IndexedExpr)(unsafe.Pointer(p)).FpExpr)
 105819 		Xsqlite3DbFreeNN(tls, db, p)
 105820 	}
 105821 }
 105822 
 105823 func whereAddIndexedExpr(tls *libc.TLS, pParse uintptr, pIdx uintptr, iIdxCur int32, pTabItem uintptr) {
 105824 	var i int32
 105825 	var p uintptr
 105826 	var pTab uintptr
 105827 
 105828 	pTab = (*Index)(unsafe.Pointer(pIdx)).FpTable
 105829 	for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnColumn); i++ {
 105830 		var pExpr uintptr
 105831 		var j int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)))
 105832 		var bMaybeNullRow int32
 105833 		if j == -2 {
 105834 			pExpr = (*ExprList_item)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 + uintptr(i)*20)).FpExpr
 105835 
 105836 			bMaybeNullRow = libc.Bool32(int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(JT_LEFT|JT_LTORJ|JT_RIGHT) != 0)
 105837 		} else if j >= 0 && int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)).FcolFlags)&COLFLAG_VIRTUAL != 0 {
 105838 			pExpr = Xsqlite3ColumnExpr(tls, pTab, (*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16)
 105839 			bMaybeNullRow = 0
 105840 		} else {
 105841 			continue
 105842 		}
 105843 		if Xsqlite3ExprIsConstant(tls, pExpr) != 0 {
 105844 			continue
 105845 		}
 105846 		p = Xsqlite3DbMallocRaw(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(IndexedExpr{})))
 105847 		if p == uintptr(0) {
 105848 			break
 105849 		}
 105850 		(*IndexedExpr)(unsafe.Pointer(p)).FpIENext = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr
 105851 		(*IndexedExpr)(unsafe.Pointer(p)).FpExpr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)
 105852 		(*IndexedExpr)(unsafe.Pointer(p)).FiDataCur = (*SrcItem)(unsafe.Pointer(pTabItem)).FiCursor
 105853 		(*IndexedExpr)(unsafe.Pointer(p)).FiIdxCur = iIdxCur
 105854 		(*IndexedExpr)(unsafe.Pointer(p)).FiIdxCol = i
 105855 		(*IndexedExpr)(unsafe.Pointer(p)).FbMaybeNullRow = U8(bMaybeNullRow)
 105856 		if Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx) != 0 {
 105857 			(*IndexedExpr)(unsafe.Pointer(p)).Faff = *(*uint8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FzColAff + uintptr(i)))
 105858 		}
 105859 		(*Parse)(unsafe.Pointer(pParse)).FpIdxEpr = p
 105860 		if (*IndexedExpr)(unsafe.Pointer(p)).FpIENext == uintptr(0) {
 105861 			Xsqlite3ParserAddCleanup(tls, pParse, *(*uintptr)(unsafe.Pointer(&struct {
 105862 				f func(*libc.TLS, uintptr, uintptr)
 105863 			}{whereIndexedExprCleanup})), pParse)
 105864 		}
 105865 	}
 105866 }
 105867 
 105868 // Generate the beginning of the loop used for WHERE clause processing.
 105869 // The return value is a pointer to an opaque structure that contains
 105870 // information needed to terminate the loop.  Later, the calling routine
 105871 // should invoke sqlite3WhereEnd() with the return value of this function
 105872 // in order to complete the WHERE clause processing.
 105873 //
 105874 // If an error occurs, this routine returns NULL.
 105875 //
 105876 // The basic idea is to do a nested loop, one loop for each table in
 105877 // the FROM clause of a select.  (INSERT and UPDATE statements are the
 105878 // same as a SELECT with only a single table in the FROM clause.)  For
 105879 // example, if the SQL is this:
 105880 //
 105881 //	SELECT * FROM t1, t2, t3 WHERE ...;
 105882 //
 105883 // Then the code generated is conceptually like the following:
 105884 //
 105885 //	foreach row1 in t1 do       \    Code generated
 105886 //	  foreach row2 in t2 do      |-- by sqlite3WhereBegin()
 105887 //	    foreach row3 in t3 do   /
 105888 //	      ...
 105889 //	    end                     \    Code generated
 105890 //	  end                        |-- by sqlite3WhereEnd()
 105891 //	end                         /
 105892 //
 105893 // Note that the loops might not be nested in the order in which they
 105894 // appear in the FROM clause if a different order is better able to make
 105895 // use of indices.  Note also that when the IN operator appears in
 105896 // the WHERE clause, it might result in additional nested loops for
 105897 // scanning through all values on the right-hand side of the IN.
 105898 //
 105899 // There are Btree cursors associated with each table.  t1 uses cursor
 105900 // number pTabList->a[0].iCursor.  t2 uses the cursor pTabList->a[1].iCursor.
 105901 // And so forth.  This routine generates code to open those VDBE cursors
 105902 // and sqlite3WhereEnd() generates the code to close them.
 105903 //
 105904 // The code that sqlite3WhereBegin() generates leaves the cursors named
 105905 // in pTabList pointing at their appropriate entries.  The [...] code
 105906 // can use OP_Column and OP_Rowid opcodes on these cursors to extract
 105907 // data from the various tables of the loop.
 105908 //
 105909 // If the WHERE clause is empty, the foreach loops must each scan their
 105910 // entire tables.  Thus a three-way join is an O(N^3) operation.  But if
 105911 // the tables have indices and there are terms in the WHERE clause that
 105912 // refer to those indices, a complete table scan can be avoided and the
 105913 // code will run much faster.  Most of the work of this routine is checking
 105914 // to see if there are indices that can be used to speed up the loop.
 105915 //
 105916 // Terms of the WHERE clause are also used to limit which rows actually
 105917 // make it to the "..." in the middle of the loop.  After each "foreach",
 105918 // terms of the WHERE clause that use only terms in that loop and outer
 105919 // loops are evaluated and if false a jump is made around all subsequent
 105920 // inner loops (or around the "..." if the test occurs within the inner-
 105921 // most loop)
 105922 //
 105923 // # OUTER JOINS
 105924 //
 105925 // An outer join of tables t1 and t2 is conceptally coded as follows:
 105926 //
 105927 //	foreach row1 in t1 do
 105928 //	  flag = 0
 105929 //	  foreach row2 in t2 do
 105930 //	    start:
 105931 //	      ...
 105932 //	      flag = 1
 105933 //	  end
 105934 //	  if flag==0 then
 105935 //	    move the row2 cursor to a null row
 105936 //	    goto start
 105937 //	  fi
 105938 //	end
 105939 //
 105940 // # ORDER BY CLAUSE PROCESSING
 105941 //
 105942 // pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause
 105943 // if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement
 105944 // if there is one.  If there is no ORDER BY clause or if this routine
 105945 // is called from an UPDATE or DELETE statement, then pOrderBy is NULL.
 105946 //
 105947 // The iIdxCur parameter is the cursor number of an index.  If
 105948 // WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index
 105949 // to use for OR clause processing.  The WHERE clause should use this
 105950 // specific cursor.  If WHERE_ONEPASS_DESIRED is set, then iIdxCur is
 105951 // the first cursor in an array of cursors for all indices.  iIdxCur should
 105952 // be used to compute the appropriate cursor depending on which index is
 105953 // used.
 105954 func Xsqlite3WhereBegin(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWhere uintptr, pOrderBy uintptr, pResultSet uintptr, pSelect uintptr, wctrlFlags U16, iAuxArg int32) uintptr {
 105955 	bp := tls.Alloc(40)
 105956 	defer tls.Free(40)
 105957 
 105958 	var nByteWInfo int32
 105959 	var nTabList int32
 105960 	var pWInfo uintptr
 105961 	var v uintptr
 105962 	var notReady Bitmask
 105963 
 105964 	var pMaskSet uintptr
 105965 	var pLevel uintptr
 105966 	var pLoop uintptr
 105967 	var ii int32
 105968 	var db uintptr
 105969 	var rc int32
 105970 	var bFordelete U8
 105971 	var pT uintptr
 105972 	var p uintptr
 105973 	var wsFlags int32
 105974 	var bOnerow int32
 105975 	var pVTab uintptr
 105976 	var iCur int32
 105977 
 105978 	var b Bitmask
 105979 	var n int32
 105980 	var op int32
 105981 	var pJ uintptr
 105982 	var pIx uintptr
 105983 	var iIndexCur int32
 105984 	var op1 int32
 105985 	var pInfo uintptr
 105986 	var pPk uintptr
 105987 	var pRJ uintptr
 105988 	var pTab uintptr
 105989 	var iDb int32
 105990 	var pTabItem uintptr
 105991 	var iOnce int32
 105992 	var addrExplain int32
 105993 	_ = addrExplain
 105994 	var wsFlags1 int32
 105995 	var pSrc uintptr
 105996 	v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 105997 	bFordelete = U8(0)
 105998 
 105999 	db = (*Parse)(unsafe.Pointer(pParse)).Fdb
 106000 	libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof(WhereLoopBuilder{})))
 106001 
 106002 	if !(pOrderBy != 0 && (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr >= int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))) {
 106003 		goto __1
 106004 	}
 106005 	pOrderBy = uintptr(0)
 106006 __1:
 106007 	;
 106008 	if !((*SrcList)(unsafe.Pointer(pTabList)).FnSrc > int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))) {
 106009 		goto __2
 106010 	}
 106011 	Xsqlite3ErrorMsg(tls, pParse, ts+22069, libc.VaList(bp, int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8))))
 106012 	return uintptr(0)
 106013 __2:
 106014 	;
 106015 	if int32(wctrlFlags)&WHERE_OR_SUBCLAUSE != 0 {
 106016 		nTabList = 1
 106017 	} else {
 106018 		nTabList = (*SrcList)(unsafe.Pointer(pTabList)).FnSrc
 106019 	}
 106020 
 106021 	nByteWInfo = int32((uint32(unsafe.Sizeof(WhereInfo{})) + uint32(nTabList-1)*uint32(unsafe.Sizeof(WhereLevel{})) + uint32(7)) & libc.Uint32FromInt32(libc.CplInt32(7)))
 106022 	pWInfo = Xsqlite3DbMallocRawNN(tls, db, uint64(uint32(nByteWInfo)+uint32(unsafe.Sizeof(WhereLoop{}))))
 106023 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 106024 		goto __3
 106025 	}
 106026 	Xsqlite3DbFree(tls, db, pWInfo)
 106027 	pWInfo = uintptr(0)
 106028 	goto whereBeginError
 106029 __3:
 106030 	;
 106031 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse = pParse
 106032 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList = pTabList
 106033 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pOrderBy
 106034 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet = pResultSet
 106035 	*(*int32)(unsafe.Pointer(pWInfo + 20)) = libc.AssignPtrInt32(pWInfo+20+1*4, -1)
 106036 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = U8(nTabList)
 106037 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak = libc.AssignPtrInt32(pWInfo+28, Xsqlite3VdbeMakeLabel(tls, pParse))
 106038 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags = wctrlFlags
 106039 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit = LogEst(iAuxArg)
 106040 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop = int32((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop)
 106041 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpSelect = pSelect
 106042 	libc.Xmemset(tls, pWInfo+45, 0,
 106043 		uint32(uintptr(0)+80)-uint32(uintptr(0)+45))
 106044 	libc.Xmemset(tls, pWInfo+760, 0, uint32(unsafe.Sizeof(WhereLoop{}))+uint32(nTabList)*uint32(unsafe.Sizeof(WhereLevel{})))
 106045 
 106046 	pMaskSet = pWInfo + 496
 106047 	(*WhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn = 0
 106048 	*(*int32)(unsafe.Pointer(pMaskSet + 8)) = -99
 106049 
 106050 	(*WhereLoopBuilder)(unsafe.Pointer(bp + 8)).FpWInfo = pWInfo
 106051 	(*WhereLoopBuilder)(unsafe.Pointer(bp + 8)).FpWC = pWInfo + 80
 106052 	(*WhereLoopBuilder)(unsafe.Pointer(bp + 8)).FpNew = pWInfo + uintptr(nByteWInfo)
 106053 
 106054 	whereLoopInit(tls, (*WhereLoopBuilder)(unsafe.Pointer(bp+8)).FpNew)
 106055 
 106056 	Xsqlite3WhereClauseInit(tls, pWInfo+80, pWInfo)
 106057 	Xsqlite3WhereSplit(tls, pWInfo+80, pWhere, uint8(TK_AND))
 106058 
 106059 	if !(nTabList == 0) {
 106060 		goto __4
 106061 	}
 106062 	if !(pOrderBy != 0) {
 106063 		goto __6
 106064 	}
 106065 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr)
 106066 __6:
 106067 	;
 106068 	if !(int32(wctrlFlags)&WHERE_WANT_DISTINCT != 0 &&
 106069 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_DistinctOpt) == U32(0)) {
 106070 		goto __7
 106071 	}
 106072 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(WHERE_DISTINCT_UNIQUE)
 106073 __7:
 106074 	;
 106075 	Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+22097, 0)
 106076 	goto __5
 106077 __4:
 106078 	ii = 0
 106079 __8:
 106080 	createMask(tls, pMaskSet, (*SrcItem)(unsafe.Pointer(pTabList+8+uintptr(ii)*72)).FiCursor)
 106081 	Xsqlite3WhereTabFuncArgs(tls, pParse, pTabList+8+uintptr(ii)*72, pWInfo+80)
 106082 	goto __9
 106083 __9:
 106084 	if libc.PreIncInt32(&ii, 1) < (*SrcList)(unsafe.Pointer(pTabList)).FnSrc {
 106085 		goto __8
 106086 	}
 106087 	goto __10
 106088 __10:
 106089 	;
 106090 __5:
 106091 	;
 106092 	Xsqlite3WhereExprAnalyze(tls, pTabList, pWInfo+80)
 106093 	if !(pSelect != 0 && (*Select)(unsafe.Pointer(pSelect)).FpLimit != 0) {
 106094 		goto __11
 106095 	}
 106096 	Xsqlite3WhereAddLimit(tls, pWInfo+80, pSelect)
 106097 __11:
 106098 	;
 106099 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
 106100 		goto __12
 106101 	}
 106102 	goto whereBeginError
 106103 __12:
 106104 	;
 106105 	ii = 0
 106106 __13:
 106107 	if !(ii < (*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(bp+8)).FpWC)).FnBase) {
 106108 		goto __15
 106109 	}
 106110 	pT = (*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(bp+8)).FpWC)).Fa + uintptr(ii)*48
 106111 	if !(int32((*WhereTerm)(unsafe.Pointer(pT)).FwtFlags)&TERM_VIRTUAL != 0) {
 106112 		goto __16
 106113 	}
 106114 	goto __14
 106115 __16:
 106116 	;
 106117 	if !((*WhereTerm)(unsafe.Pointer(pT)).FprereqAll == uint64(0) && (nTabList == 0 || exprIsDeterministic(tls, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr) != 0)) {
 106118 		goto __17
 106119 	}
 106120 	Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, SQLITE_JUMPIFNULL)
 106121 	*(*U16)(unsafe.Pointer(pT + 10)) |= U16(TERM_CODED)
 106122 __17:
 106123 	;
 106124 	goto __14
 106125 __14:
 106126 	ii++
 106127 	goto __13
 106128 	goto __15
 106129 __15:
 106130 	;
 106131 	if !(int32(wctrlFlags)&WHERE_WANT_DISTINCT != 0) {
 106132 		goto __18
 106133 	}
 106134 	if !((*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_DistinctOpt) != U32(0)) {
 106135 		goto __19
 106136 	}
 106137 
 106138 	wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & libc.CplInt32(WHERE_WANT_DISTINCT))
 106139 	*(*U16)(unsafe.Pointer(pWInfo + 40)) &= libc.Uint16FromInt32(libc.CplInt32(WHERE_WANT_DISTINCT))
 106140 	goto __20
 106141 __19:
 106142 	if !(isDistinctRedundant(tls, pParse, pTabList, pWInfo+80, pResultSet) != 0) {
 106143 		goto __21
 106144 	}
 106145 
 106146 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(WHERE_DISTINCT_UNIQUE)
 106147 	goto __22
 106148 __21:
 106149 	if !(pOrderBy == uintptr(0)) {
 106150 		goto __23
 106151 	}
 106152 
 106153 	*(*U16)(unsafe.Pointer(pWInfo + 40)) |= U16(WHERE_DISTINCTBY)
 106154 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pResultSet
 106155 __23:
 106156 	;
 106157 __22:
 106158 	;
 106159 __20:
 106160 	;
 106161 __18:
 106162 	;
 106163 	if !(nTabList != 1 || whereShortCut(tls, bp+8) == 0) {
 106164 		goto __24
 106165 	}
 106166 	rc = whereLoopAddAll(tls, bp+8)
 106167 	if !(rc != 0) {
 106168 		goto __25
 106169 	}
 106170 	goto whereBeginError
 106171 __25:
 106172 	;
 106173 	if !(int32((*WhereLoopBuilder)(unsafe.Pointer(bp+8)).FbldFlags2)&SQLITE_BLDF2_2NDPASS != 0) {
 106174 		goto __26
 106175 	}
 106176 
 106177 __27:
 106178 	if !((*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops != 0) {
 106179 		goto __28
 106180 	}
 106181 	p = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops
 106182 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FpLoops = (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop
 106183 	whereLoopDelete(tls, db, p)
 106184 	goto __27
 106185 __28:
 106186 	;
 106187 	rc = whereLoopAddAll(tls, bp+8)
 106188 	if !(rc != 0) {
 106189 		goto __29
 106190 	}
 106191 	goto whereBeginError
 106192 __29:
 106193 	;
 106194 __26:
 106195 	;
 106196 	wherePathSolver(tls, pWInfo, int16(0))
 106197 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 106198 		goto __30
 106199 	}
 106200 	goto whereBeginError
 106201 __30:
 106202 	;
 106203 	if !((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0) {
 106204 		goto __31
 106205 	}
 106206 	wherePathSolver(tls, pWInfo, int16(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut)+1))
 106207 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 106208 		goto __32
 106209 	}
 106210 	goto whereBeginError
 106211 __32:
 106212 	;
 106213 __31:
 106214 	;
 106215 __24:
 106216 	;
 106217 	if !((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0) && (*Sqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ReverseOrder) != uint64(0)) {
 106218 		goto __33
 106219 	}
 106220 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = libc.Uint64(libc.Uint64FromInt32(-1))
 106221 __33:
 106222 	;
 106223 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
 106224 		goto __34
 106225 	}
 106226 	goto whereBeginError
 106227 __34:
 106228 	;
 106229 	notReady = libc.CplUint64(uint64(0))
 106230 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= 2 &&
 106231 		pResultSet != uintptr(0) &&
 106232 		0 == int32(wctrlFlags)&WHERE_AGG_DISTINCT &&
 106233 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_OmitNoopJoin) == U32(0)) {
 106234 		goto __35
 106235 	}
 106236 	notReady = whereOmitNoopJoin(tls, pWInfo, notReady)
 106237 	nTabList = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)
 106238 
 106239 __35:
 106240 	;
 106241 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= 2 &&
 106242 		(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_BloomFilter) == U32(0)) {
 106243 		goto __36
 106244 	}
 106245 	whereCheckIfBloomFilterIsUseful(tls, pWInfo)
 106246 __36:
 106247 	;
 106248 	*(*U32)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse + 140)) += U32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut)
 106249 
 106250 	if !(int32(wctrlFlags)&WHERE_ONEPASS_DESIRED != 0) {
 106251 		goto __37
 106252 	}
 106253 	wsFlags = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pWInfo + 760)).FpWLoop)).FwsFlags)
 106254 	bOnerow = libc.Bool32(wsFlags&WHERE_ONEROW != 0)
 106255 
 106256 	if !(bOnerow != 0 || 0 != int32(wctrlFlags)&WHERE_ONEPASS_MULTIROW &&
 106257 		!(int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pTabList+8)).FpTab)).FeTabType) == TABTYP_VTAB) &&
 106258 		(0 == wsFlags&WHERE_MULTI_OR || int32(wctrlFlags)&WHERE_DUPLICATES_OK != 0)) {
 106259 		goto __38
 106260 	}
 106261 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass = func() uint8 {
 106262 		if bOnerow != 0 {
 106263 			return uint8(ONEPASS_SINGLE)
 106264 		}
 106265 		return uint8(ONEPASS_MULTI)
 106266 	}()
 106267 	if !((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pTabList+8)).FpTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) && wsFlags&WHERE_IDX_ONLY != 0) {
 106268 		goto __39
 106269 	}
 106270 	if !(int32(wctrlFlags)&WHERE_ONEPASS_MULTIROW != 0) {
 106271 		goto __40
 106272 	}
 106273 	bFordelete = U8(OPFLAG_FORDELETE)
 106274 __40:
 106275 	;
 106276 	(*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pWInfo + 760)).FpWLoop)).FwsFlags = U32(wsFlags & libc.CplInt32(WHERE_IDX_ONLY))
 106277 __39:
 106278 	;
 106279 __38:
 106280 	;
 106281 __37:
 106282 	;
 106283 	ii = 0
 106284 	pLevel = pWInfo + 760
 106285 __41:
 106286 	if !(ii < nTabList) {
 106287 		goto __43
 106288 	}
 106289 
 106290 	pTabItem = pTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 106291 	pTab = (*SrcItem)(unsafe.Pointer(pTabItem)).FpTab
 106292 	iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema)
 106293 	pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 106294 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Ephemeral) != U32(0) || int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
 106295 		goto __44
 106296 	}
 106297 
 106298 	goto __45
 106299 __44:
 106300 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_VIRTUALTABLE) != U32(0)) {
 106301 		goto __46
 106302 	}
 106303 	pVTab = Xsqlite3GetVTable(tls, db, pTab)
 106304 	iCur = (*SrcItem)(unsafe.Pointer(pTabItem)).FiCursor
 106305 	Xsqlite3VdbeAddOp4(tls, v, OP_VOpen, iCur, 0, 0, pVTab, -11)
 106306 	goto __47
 106307 __46:
 106308 	if !(int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB) {
 106309 		goto __48
 106310 	}
 106311 
 106312 	goto __49
 106313 __48:
 106314 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IDX_ONLY) == U32(0) &&
 106315 		int32(wctrlFlags)&WHERE_OR_SUBCLAUSE == 0 ||
 106316 		int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&(JT_LTORJ|JT_RIGHT) != 0) {
 106317 		goto __50
 106318 	}
 106319 	op = OP_OpenRead
 106320 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF) {
 106321 		goto __52
 106322 	}
 106323 	op = OP_OpenWrite
 106324 	*(*int32)(unsafe.Pointer(pWInfo + 20)) = (*SrcItem)(unsafe.Pointer(pTabItem)).FiCursor
 106325 __52:
 106326 	;
 106327 	Xsqlite3OpenTable(tls, pParse, (*SrcItem)(unsafe.Pointer(pTabItem)).FiCursor, iDb, pTab, op)
 106328 
 106329 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF &&
 106330 		int32((*Table)(unsafe.Pointer(pTab)).FnCol) < int32(uint32(unsafe.Sizeof(Bitmask(0)))*uint32(8)) &&
 106331 		(*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_HasGenerated|TF_WithoutRowid) == U32(0) &&
 106332 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_AUTO_INDEX|WHERE_BLOOMFILTER) == U32(0)) {
 106333 		goto __53
 106334 	}
 106335 
 106336 	b = (*SrcItem)(unsafe.Pointer(pTabItem)).FcolUsed
 106337 	n = 0
 106338 __54:
 106339 	if !(b != 0) {
 106340 		goto __56
 106341 	}
 106342 	goto __55
 106343 __55:
 106344 	b = b >> 1
 106345 	n++
 106346 	goto __54
 106347 	goto __56
 106348 __56:
 106349 	;
 106350 	Xsqlite3VdbeChangeP4(tls, v, -1, uintptr(n), -3)
 106351 
 106352 __53:
 106353 	;
 106354 	Xsqlite3VdbeChangeP5(tls, v, uint16(bFordelete))
 106355 
 106356 	goto __51
 106357 __50:
 106358 	Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab)).FzName)
 106359 __51:
 106360 	;
 106361 __49:
 106362 	;
 106363 __47:
 106364 	;
 106365 __45:
 106366 	;
 106367 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_INDEXED) != 0) {
 106368 		goto __57
 106369 	}
 106370 	pIx = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
 106371 	op1 = OP_OpenRead
 106372 
 106373 	if !(!((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) && int32(*(*uint16)(unsafe.Pointer(pIx + 56))&0x3>>0) == SQLITE_IDXTYPE_PRIMARYKEY &&
 106374 		int32(wctrlFlags)&WHERE_OR_SUBCLAUSE != 0) {
 106375 		goto __58
 106376 	}
 106377 
 106378 	iIndexCur = (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur
 106379 	op1 = 0
 106380 	goto __59
 106381 __58:
 106382 	if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF) {
 106383 		goto __60
 106384 	}
 106385 	pJ = (*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pTabItem)).FpTab)).FpIndex
 106386 	iIndexCur = iAuxArg
 106387 
 106388 __62:
 106389 	if !(pJ != 0 && pJ != pIx) {
 106390 		goto __63
 106391 	}
 106392 	iIndexCur++
 106393 	pJ = (*Index)(unsafe.Pointer(pJ)).FpNext
 106394 	goto __62
 106395 __63:
 106396 	;
 106397 	op1 = OP_OpenWrite
 106398 	*(*int32)(unsafe.Pointer(pWInfo + 20 + 1*4)) = iIndexCur
 106399 	goto __61
 106400 __60:
 106401 	if !(iAuxArg != 0 && int32(wctrlFlags)&WHERE_OR_SUBCLAUSE != 0) {
 106402 		goto __64
 106403 	}
 106404 	iIndexCur = iAuxArg
 106405 	op1 = OP_ReopenIdx
 106406 	goto __65
 106407 __64:
 106408 	iIndexCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 106409 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pIx + 56))&0x800>>11)) != 0 && (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags&U32(SQLITE_IndexedExpr) == U32(0)) {
 106410 		goto __66
 106411 	}
 106412 	whereAddIndexedExpr(tls, pParse, pIx, iIndexCur, pTabItem)
 106413 __66:
 106414 	;
 106415 __65:
 106416 	;
 106417 __61:
 106418 	;
 106419 __59:
 106420 	;
 106421 	(*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = iIndexCur
 106422 
 106423 	if !(op1 != 0) {
 106424 		goto __67
 106425 	}
 106426 	Xsqlite3VdbeAddOp3(tls, v, op1, iIndexCur, int32((*Index)(unsafe.Pointer(pIx)).Ftnum), iDb)
 106427 	Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIx)
 106428 	if !((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_CONSTRAINT) != U32(0) &&
 106429 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_COLUMN_RANGE|WHERE_SKIPSCAN) == U32(0) &&
 106430 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_BIGNULL_SORT) == U32(0) &&
 106431 		(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_SEEKSCAN) == U32(0) &&
 106432 		int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags)&WHERE_ORDERBY_MIN == 0 &&
 106433 		int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != WHERE_DISTINCT_ORDERED) {
 106434 		goto __68
 106435 	}
 106436 	Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SEEKEQ))
 106437 __68:
 106438 	;
 106439 __67:
 106440 	;
 106441 __57:
 106442 	;
 106443 	if !(iDb >= 0) {
 106444 		goto __69
 106445 	}
 106446 	Xsqlite3CodeVerifySchema(tls, pParse, iDb)
 106447 __69:
 106448 	;
 106449 	if !(int32((*SrcItem)(unsafe.Pointer(pTabItem)).Ffg.Fjointype)&JT_RIGHT != 0 &&
 106450 		libc.AssignPtrUintptr(pLevel+48, Xsqlite3WhereMalloc(tls, pWInfo, uint64(unsafe.Sizeof(WhereRightJoin{})))) != uintptr(0)) {
 106451 		goto __70
 106452 	}
 106453 	pRJ = (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ
 106454 	(*WhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 106455 	(*WhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 106456 	Xsqlite3VdbeAddOp2(tls, v, OP_Blob, 65536, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FregBloom)
 106457 	(*WhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 106458 	Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn)
 106459 
 106460 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
 106461 		goto __71
 106462 	}
 106463 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, 1)
 106464 	pInfo = Xsqlite3KeyInfoAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 1, 0)
 106465 	if !(pInfo != 0) {
 106466 		goto __73
 106467 	}
 106468 	*(*uintptr)(unsafe.Pointer(pInfo + 20)) = uintptr(0)
 106469 	*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pInfo)).FaSortFlags)) = U8(0)
 106470 	Xsqlite3VdbeAppendP4(tls, v, pInfo, -8)
 106471 __73:
 106472 	;
 106473 	goto __72
 106474 __71:
 106475 	pPk = Xsqlite3PrimaryKeyIndex(tls, pTab)
 106476 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FiMatch, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol))
 106477 	Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk)
 106478 __72:
 106479 	;
 106480 	*(*U32)(unsafe.Pointer(pLoop + 44)) &= libc.Uint32FromInt32(libc.CplInt32(WHERE_IDX_ONLY))
 106481 
 106482 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8(0)
 106483 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(WHERE_DISTINCT_UNORDERED)
 106484 __70:
 106485 	;
 106486 	goto __42
 106487 __42:
 106488 	ii++
 106489 	pLevel += 88
 106490 	goto __41
 106491 	goto __43
 106492 __43:
 106493 	;
 106494 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FiTop = Xsqlite3VdbeCurrentAddr(tls, v)
 106495 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 106496 		goto __74
 106497 	}
 106498 	goto whereBeginError
 106499 __74:
 106500 	;
 106501 	ii = 0
 106502 __75:
 106503 	if !(ii < nTabList) {
 106504 		goto __77
 106505 	}
 106506 	if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) {
 106507 		goto __78
 106508 	}
 106509 	goto whereBeginError
 106510 __78:
 106511 	;
 106512 	pLevel = pWInfo + 760 + uintptr(ii)*88
 106513 	wsFlags1 = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags)
 106514 	pSrc = pTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 106515 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x10>>4)) != 0) {
 106516 		goto __79
 106517 	}
 106518 	if !(uint32(int32(*(*uint16)(unsafe.Pointer(pSrc + 36 + 4))&0x8>>3)) != 0) {
 106519 		goto __80
 106520 	}
 106521 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SrcItem)(unsafe.Pointer(pSrc)).FregReturn, (*SrcItem)(unsafe.Pointer(pSrc)).FaddrFillSub)
 106522 	goto __81
 106523 __80:
 106524 	iOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once)
 106525 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SrcItem)(unsafe.Pointer(pSrc)).FregReturn, (*SrcItem)(unsafe.Pointer(pSrc)).FaddrFillSub)
 106526 	Xsqlite3VdbeJumpHere(tls, v, iOnce)
 106527 __81:
 106528 	;
 106529 __79:
 106530 	;
 106531 	if !(wsFlags1&(WHERE_AUTO_INDEX|WHERE_BLOOMFILTER) != 0) {
 106532 		goto __82
 106533 	}
 106534 	if !(wsFlags1&WHERE_AUTO_INDEX != 0) {
 106535 		goto __83
 106536 	}
 106537 	constructAutomaticIndex(tls, pParse, pWInfo+80,
 106538 		pTabList+8+uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72, notReady, pLevel)
 106539 	goto __84
 106540 __83:
 106541 	sqlite3ConstructBloomFilter(tls, pWInfo, ii, pLevel, notReady)
 106542 __84:
 106543 	;
 106544 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 106545 		goto __85
 106546 	}
 106547 	goto whereBeginError
 106548 __85:
 106549 	;
 106550 __82:
 106551 	;
 106552 	addrExplain = Xsqlite3WhereExplainOneScan(tls,
 106553 		pParse, pTabList, pLevel, wctrlFlags)
 106554 	(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody = Xsqlite3VdbeCurrentAddr(tls, v)
 106555 	notReady = Xsqlite3WhereCodeOneLoopStart(tls, pParse, v, pWInfo, ii, pLevel, notReady)
 106556 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont
 106557 	if !(wsFlags1&WHERE_MULTI_OR == 0 && int32(wctrlFlags)&WHERE_OR_SUBCLAUSE == 0) {
 106558 		goto __86
 106559 	}
 106560 	_ = addrExplain
 106561 __86:
 106562 	;
 106563 	goto __76
 106564 __76:
 106565 	ii++
 106566 	goto __75
 106567 	goto __77
 106568 __77:
 106569 	;
 106570 	(*WhereInfo)(unsafe.Pointer(pWInfo)).FiEndWhere = Xsqlite3VdbeCurrentAddr(tls, v)
 106571 	return pWInfo
 106572 
 106573 whereBeginError:
 106574 	if !(pWInfo != 0) {
 106575 		goto __87
 106576 	}
 106577 	(*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = U32((*WhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop)
 106578 	whereInfoFree(tls, db, pWInfo)
 106579 __87:
 106580 	;
 106581 	return uintptr(0)
 106582 }
 106583 
 106584 // Generate the end of the WHERE loop.  See comments on
 106585 // sqlite3WhereBegin() for additional information.
 106586 func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) {
 106587 	var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse
 106588 	var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe
 106589 	var i int32
 106590 	var pLevel uintptr
 106591 	var pLoop uintptr
 106592 	var pTabList uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList
 106593 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 106594 	var iEnd int32 = Xsqlite3VdbeCurrentAddr(tls, v)
 106595 	var nRJ int32 = 0
 106596 
 106597 	for i = int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - 1; i >= 0; i-- {
 106598 		var addr int32
 106599 		pLevel = pWInfo + 760 + uintptr(i)*88
 106600 		if (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 {
 106601 			var pRJ uintptr = (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ
 106602 			Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont)
 106603 			(*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont = 0
 106604 			(*WhereRightJoin)(unsafe.Pointer(pRJ)).FendSubrtn = Xsqlite3VdbeCurrentAddr(tls, v)
 106605 			Xsqlite3VdbeAddOp3(tls, v, OP_Return, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FregReturn, (*WhereRightJoin)(unsafe.Pointer(pRJ)).FaddrSubrtn, 1)
 106606 
 106607 			nRJ++
 106608 		}
 106609 		pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 106610 		if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) != OP_Noop {
 106611 			var addrSeek int32 = 0
 106612 			var pIdx uintptr
 106613 			var n int32
 106614 			if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_ORDERED &&
 106615 				i == int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)-1 &&
 106616 				(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_INDEXED) != U32(0) &&
 106617 				uint32(int32(*(*uint16)(unsafe.Pointer(libc.AssignUintptr(&pIdx, *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))) + 56))&0x80>>7)) != 0 &&
 106618 				libc.AssignInt32(&n, int32(*(*U16)(unsafe.Pointer(pLoop + 24 + 6)))) > 0 &&
 106619 				int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(n)*2))) >= 36 {
 106620 				var r1 int32 = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 106621 				var j int32
 106622 				var op int32
 106623 				for j = 0; j < n; j++ {
 106624 					Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, r1+j)
 106625 				}
 106626 				*(*int32)(unsafe.Pointer(pParse + 44)) += n + 1
 106627 				if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == OP_Prev {
 106628 					op = OP_SeekLT
 106629 				} else {
 106630 					op = OP_SeekGT
 106631 				}
 106632 				addrSeek = Xsqlite3VdbeAddOp4Int(tls, v, op, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, r1, n)
 106633 
 106634 				Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2)
 106635 			}
 106636 
 106637 			if (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont != 0 {
 106638 				Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont)
 106639 			}
 106640 			Xsqlite3VdbeAddOp3(tls, v, int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop), (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2, int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fp3))
 106641 			Xsqlite3VdbeChangeP5(tls, v, uint16((*WhereLevel)(unsafe.Pointer(pLevel)).Fp5))
 106642 
 106643 			if (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull != 0 {
 106644 				Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull)
 106645 				Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2-1)
 106646 
 106647 			}
 106648 			if addrSeek != 0 {
 106649 				Xsqlite3VdbeJumpHere(tls, v, addrSeek)
 106650 			}
 106651 		} else if (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont != 0 {
 106652 			Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont)
 106653 		}
 106654 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_ABLE) != U32(0) && *(*int32)(unsafe.Pointer(pLevel + 64)) > 0 {
 106655 			var pIn uintptr
 106656 			var j int32
 106657 			Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt)
 106658 			j = *(*int32)(unsafe.Pointer(pLevel + 64))
 106659 			pIn = *(*uintptr)(unsafe.Pointer(pLevel + 64 + 4)) + uintptr(j-1)*20
 106660 		__1:
 106661 			if !(j > 0) {
 106662 				goto __3
 106663 			}
 106664 			{
 106665 				Xsqlite3VdbeJumpHere(tls, v, *(*int32)(unsafe.Pointer(pIn + 4))+1)
 106666 				if int32(*(*U8)(unsafe.Pointer(pIn + 16))) != OP_Noop {
 106667 					if *(*int32)(unsafe.Pointer(pIn + 12)) != 0 {
 106668 						var bEarlyOut int32 = libc.Bool32((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_VIRTUALTABLE) == U32(0) &&
 106669 							(*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_IN_EARLYOUT) != U32(0))
 106670 						if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 {
 106671 							Xsqlite3VdbeAddOp2(tls, v, OP_IfNotOpen, *(*int32)(unsafe.Pointer(pIn)),
 106672 								Xsqlite3VdbeCurrentAddr(tls, v)+2+bEarlyOut)
 106673 
 106674 						}
 106675 						if bEarlyOut != 0 {
 106676 							Xsqlite3VdbeAddOp4Int(tls, v, OP_IfNoHope, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur,
 106677 								Xsqlite3VdbeCurrentAddr(tls, v)+2,
 106678 								*(*int32)(unsafe.Pointer(pIn + 8)), *(*int32)(unsafe.Pointer(pIn + 12)))
 106679 
 106680 							Xsqlite3VdbeJumpHere(tls, v, *(*int32)(unsafe.Pointer(pIn + 4))+1)
 106681 						}
 106682 					}
 106683 					Xsqlite3VdbeAddOp2(tls, v, int32(*(*U8)(unsafe.Pointer(pIn + 16))), *(*int32)(unsafe.Pointer(pIn)), *(*int32)(unsafe.Pointer(pIn + 4)))
 106684 
 106685 				}
 106686 				Xsqlite3VdbeJumpHere(tls, v, *(*int32)(unsafe.Pointer(pIn + 4))-1)
 106687 
 106688 			}
 106689 			goto __2
 106690 		__2:
 106691 			j--
 106692 			pIn -= 20
 106693 			goto __1
 106694 			goto __3
 106695 		__3:
 106696 		}
 106697 		Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk)
 106698 		if (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 {
 106699 			Xsqlite3VdbeAddOp3(tls, v, OP_Return, (*WhereRightJoin)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ)).FregReturn, 0, 1)
 106700 
 106701 		}
 106702 		if (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip != 0 {
 106703 			Xsqlite3VdbeGoto(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip)
 106704 
 106705 			Xsqlite3VdbeJumpHere(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip)
 106706 			Xsqlite3VdbeJumpHere(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip-2)
 106707 		}
 106708 		if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 {
 106709 			var ws int32 = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags)
 106710 			addr = Xsqlite3VdbeAddOp1(tls, v, OP_IfPos, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin)
 106711 
 106712 			if ws&WHERE_IDX_ONLY == 0 {
 106713 				Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur)
 106714 			}
 106715 			if ws&WHERE_INDEXED != 0 ||
 106716 				ws&WHERE_MULTI_OR != 0 && *(*uintptr)(unsafe.Pointer(pLevel + 64)) != 0 {
 106717 				if ws&WHERE_MULTI_OR != 0 {
 106718 					var pIx uintptr = *(*uintptr)(unsafe.Pointer(pLevel + 64))
 106719 					var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIx)).FpSchema)
 106720 					Xsqlite3VdbeAddOp3(tls, v, OP_ReopenIdx, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, int32((*Index)(unsafe.Pointer(pIx)).Ftnum), iDb)
 106721 					Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIx)
 106722 				}
 106723 				Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur)
 106724 			}
 106725 			if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == OP_Return {
 106726 				Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst)
 106727 			} else {
 106728 				Xsqlite3VdbeGoto(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst)
 106729 			}
 106730 			Xsqlite3VdbeJumpHere(tls, v, addr)
 106731 		}
 106732 
 106733 	}
 106734 
 106735 	i = 0
 106736 	pLevel = pWInfo + 760
 106737 __4:
 106738 	if !(i < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)) {
 106739 		goto __6
 106740 	}
 106741 	{
 106742 		var k int32
 106743 		var last int32
 106744 		var pOp uintptr
 106745 		var pLastOp uintptr
 106746 		var pIdx uintptr = uintptr(0)
 106747 		var pTabItem uintptr = pTabList + 8 + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*72
 106748 		var pTab uintptr = (*SrcItem)(unsafe.Pointer(pTabItem)).FpTab
 106749 
 106750 		pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop
 106751 
 106752 		if (*WhereLevel)(unsafe.Pointer(pLevel)).FpRJ != 0 {
 106753 			Xsqlite3WhereRightJoinLoop(tls, pWInfo, i, pLevel)
 106754 			goto __5
 106755 		}
 106756 
 106757 		if uint32(int32(*(*uint16)(unsafe.Pointer(pTabItem + 36 + 4))&0x20>>5)) != 0 {
 106758 			translateColumnToCopy(tls, pParse, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur,
 106759 				(*SrcItem)(unsafe.Pointer(pTabItem)).FregResult, 0)
 106760 			goto __5
 106761 		}
 106762 
 106763 		if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_INDEXED|WHERE_IDX_ONLY) != 0 {
 106764 			pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 + 8))
 106765 		} else if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&U32(WHERE_MULTI_OR) != 0 {
 106766 			pIdx = *(*uintptr)(unsafe.Pointer(pLevel + 64))
 106767 		}
 106768 		if pIdx != 0 &&
 106769 			!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
 106770 			if int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF || !((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
 106771 				last = iEnd
 106772 			} else {
 106773 				last = (*WhereInfo)(unsafe.Pointer(pWInfo)).FiEndWhere
 106774 			}
 106775 			if uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 56))&0x800>>11)) != 0 {
 106776 				var p uintptr = (*Parse)(unsafe.Pointer(pParse)).FpIdxEpr
 106777 				for p != 0 {
 106778 					if (*IndexedExpr)(unsafe.Pointer(p)).FiIdxCur == (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur {
 106779 						(*IndexedExpr)(unsafe.Pointer(p)).FiDataCur = -1
 106780 						(*IndexedExpr)(unsafe.Pointer(p)).FiIdxCur = -1
 106781 					}
 106782 					p = (*IndexedExpr)(unsafe.Pointer(p)).FpIENext
 106783 				}
 106784 			}
 106785 			k = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody + 1
 106786 			pOp = Xsqlite3VdbeGetOp(tls, v, k)
 106787 			pLastOp = pOp + uintptr(last-k)*20
 106788 
 106789 			for __ccgo := true; __ccgo; __ccgo = libc.PreIncUintptr(&pOp, 20) < pLastOp {
 106790 				if (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 != (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur {
 106791 				} else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column ||
 106792 					int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Offset {
 106793 					var x int32 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp2
 106794 
 106795 					if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Offset {
 106796 					} else if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0)) {
 106797 						var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab)
 106798 						x = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(x)*2)))
 106799 
 106800 					} else {
 106801 						x = int32(Xsqlite3StorageColumnToTable(tls, pTab, int16(x)))
 106802 					}
 106803 					x = int32(Xsqlite3TableColumnToIndex(tls, pIdx, int16(x)))
 106804 					if x >= 0 {
 106805 						(*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = x
 106806 						(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur
 106807 
 106808 					} else {
 106809 					}
 106810 				} else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid {
 106811 					(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur
 106812 					(*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(OP_IdxRowid)
 106813 
 106814 				} else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_IfNullRow {
 106815 					(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur
 106816 
 106817 				}
 106818 			}
 106819 		}
 106820 
 106821 	}
 106822 	goto __5
 106823 __5:
 106824 	i++
 106825 	pLevel += 88
 106826 	goto __4
 106827 	goto __6
 106828 __6:
 106829 	;
 106830 	Xsqlite3VdbeResolveLabel(tls, v, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak)
 106831 
 106832 	(*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = U32((*WhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop)
 106833 	whereInfoFree(tls, db, pWInfo)
 106834 	*(*U8)(unsafe.Pointer(pParse + 26)) -= U8(nRJ)
 106835 	return
 106836 }
 106837 
 106838 func row_numberStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 106839 	var p uintptr = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(I64(0))))
 106840 	if p != 0 {
 106841 		*(*I64)(unsafe.Pointer(p))++
 106842 	}
 106843 	_ = nArg
 106844 	_ = apArg
 106845 }
 106846 
 106847 func row_numberValueFunc(tls *libc.TLS, pCtx uintptr) {
 106848 	var p uintptr = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(I64(0))))
 106849 	Xsqlite3_result_int64(tls, pCtx, func() int64 {
 106850 		if p != 0 {
 106851 			return *(*I64)(unsafe.Pointer(p))
 106852 		}
 106853 		return int64(0)
 106854 	}())
 106855 }
 106856 
 106857 // Context object type used by rank(), dense_rank(), percent_rank() and
 106858 // cume_dist().
 106859 type CallCount = struct {
 106860 	FnValue I64
 106861 	FnStep  I64
 106862 	FnTotal I64
 106863 }
 106864 
 106865 func dense_rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 106866 	var p uintptr
 106867 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 106868 	if p != 0 {
 106869 		(*CallCount)(unsafe.Pointer(p)).FnStep = int64(1)
 106870 	}
 106871 	_ = nArg
 106872 	_ = apArg
 106873 }
 106874 
 106875 func dense_rankValueFunc(tls *libc.TLS, pCtx uintptr) {
 106876 	var p uintptr
 106877 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 106878 	if p != 0 {
 106879 		if (*CallCount)(unsafe.Pointer(p)).FnStep != 0 {
 106880 			(*CallCount)(unsafe.Pointer(p)).FnValue++
 106881 			(*CallCount)(unsafe.Pointer(p)).FnStep = int64(0)
 106882 		}
 106883 		Xsqlite3_result_int64(tls, pCtx, (*CallCount)(unsafe.Pointer(p)).FnValue)
 106884 	}
 106885 }
 106886 
 106887 // Implementation of built-in window function nth_value(). This
 106888 // implementation is used in "slow mode" only - when the EXCLUDE clause
 106889 // is not set to the default value "NO OTHERS".
 106890 type NthValueCtx = struct {
 106891 	FnStep       I64
 106892 	FpValue      uintptr
 106893 	F__ccgo_pad1 [4]byte
 106894 }
 106895 
 106896 func nth_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 106897 	var p uintptr
 106898 	var fVal float64
 106899 	var iVal I64
 106900 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NthValueCtx{})))
 106901 	if !(p != 0) {
 106902 		goto __1
 106903 	}
 106904 	switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*4))) {
 106905 	case SQLITE_INTEGER:
 106906 		goto __3
 106907 	case SQLITE_FLOAT:
 106908 		goto __4
 106909 	default:
 106910 		goto __5
 106911 	}
 106912 	goto __2
 106913 __3:
 106914 	iVal = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*4)))
 106915 	goto __2
 106916 __4:
 106917 	fVal = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*4)))
 106918 	if !(float64(I64(fVal)) != fVal) {
 106919 		goto __6
 106920 	}
 106921 	goto error_out
 106922 __6:
 106923 	;
 106924 	iVal = I64(fVal)
 106925 	goto __2
 106926 
 106927 __5:
 106928 	goto error_out
 106929 __2:
 106930 	;
 106931 	if !(iVal <= int64(0)) {
 106932 		goto __7
 106933 	}
 106934 	goto error_out
 106935 __7:
 106936 	;
 106937 	(*NthValueCtx)(unsafe.Pointer(p)).FnStep++
 106938 	if !(iVal == (*NthValueCtx)(unsafe.Pointer(p)).FnStep) {
 106939 		goto __8
 106940 	}
 106941 	(*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg)))
 106942 	if !!(int32((*NthValueCtx)(unsafe.Pointer(p)).FpValue) != 0) {
 106943 		goto __9
 106944 	}
 106945 	Xsqlite3_result_error_nomem(tls, pCtx)
 106946 __9:
 106947 	;
 106948 __8:
 106949 	;
 106950 __1:
 106951 	;
 106952 	_ = nArg
 106953 	_ = apArg
 106954 	return
 106955 
 106956 error_out:
 106957 	Xsqlite3_result_error(tls,
 106958 		pCtx, ts+22115, -1)
 106959 }
 106960 
 106961 func nth_valueFinalizeFunc(tls *libc.TLS, pCtx uintptr) {
 106962 	var p uintptr
 106963 	p = Xsqlite3_aggregate_context(tls, pCtx, 0)
 106964 	if p != 0 && (*NthValueCtx)(unsafe.Pointer(p)).FpValue != 0 {
 106965 		Xsqlite3_result_value(tls, pCtx, (*NthValueCtx)(unsafe.Pointer(p)).FpValue)
 106966 		Xsqlite3_value_free(tls, (*NthValueCtx)(unsafe.Pointer(p)).FpValue)
 106967 		(*NthValueCtx)(unsafe.Pointer(p)).FpValue = uintptr(0)
 106968 	}
 106969 }
 106970 
 106971 func first_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 106972 	var p uintptr
 106973 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NthValueCtx{})))
 106974 	if p != 0 && (*NthValueCtx)(unsafe.Pointer(p)).FpValue == uintptr(0) {
 106975 		(*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg)))
 106976 		if !(int32((*NthValueCtx)(unsafe.Pointer(p)).FpValue) != 0) {
 106977 			Xsqlite3_result_error_nomem(tls, pCtx)
 106978 		}
 106979 	}
 106980 	_ = nArg
 106981 	_ = apArg
 106982 }
 106983 
 106984 func first_valueFinalizeFunc(tls *libc.TLS, pCtx uintptr) {
 106985 	var p uintptr
 106986 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NthValueCtx{})))
 106987 	if p != 0 && (*NthValueCtx)(unsafe.Pointer(p)).FpValue != 0 {
 106988 		Xsqlite3_result_value(tls, pCtx, (*NthValueCtx)(unsafe.Pointer(p)).FpValue)
 106989 		Xsqlite3_value_free(tls, (*NthValueCtx)(unsafe.Pointer(p)).FpValue)
 106990 		(*NthValueCtx)(unsafe.Pointer(p)).FpValue = uintptr(0)
 106991 	}
 106992 }
 106993 
 106994 func rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 106995 	var p uintptr
 106996 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 106997 	if p != 0 {
 106998 		(*CallCount)(unsafe.Pointer(p)).FnStep++
 106999 		if (*CallCount)(unsafe.Pointer(p)).FnValue == int64(0) {
 107000 			(*CallCount)(unsafe.Pointer(p)).FnValue = (*CallCount)(unsafe.Pointer(p)).FnStep
 107001 		}
 107002 	}
 107003 	_ = nArg
 107004 	_ = apArg
 107005 }
 107006 
 107007 func rankValueFunc(tls *libc.TLS, pCtx uintptr) {
 107008 	var p uintptr
 107009 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 107010 	if p != 0 {
 107011 		Xsqlite3_result_int64(tls, pCtx, (*CallCount)(unsafe.Pointer(p)).FnValue)
 107012 		(*CallCount)(unsafe.Pointer(p)).FnValue = int64(0)
 107013 	}
 107014 }
 107015 
 107016 func percent_rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107017 	var p uintptr
 107018 	_ = nArg
 107019 	_ = apArg
 107020 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 107021 	if p != 0 {
 107022 		(*CallCount)(unsafe.Pointer(p)).FnTotal++
 107023 	}
 107024 }
 107025 
 107026 func percent_rankInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107027 	var p uintptr
 107028 	_ = nArg
 107029 	_ = apArg
 107030 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 107031 	(*CallCount)(unsafe.Pointer(p)).FnStep++
 107032 }
 107033 
 107034 func percent_rankValueFunc(tls *libc.TLS, pCtx uintptr) {
 107035 	var p uintptr
 107036 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 107037 	if p != 0 {
 107038 		(*CallCount)(unsafe.Pointer(p)).FnValue = (*CallCount)(unsafe.Pointer(p)).FnStep
 107039 		if (*CallCount)(unsafe.Pointer(p)).FnTotal > int64(1) {
 107040 			var r float64 = float64((*CallCount)(unsafe.Pointer(p)).FnValue) / float64((*CallCount)(unsafe.Pointer(p)).FnTotal-int64(1))
 107041 			Xsqlite3_result_double(tls, pCtx, r)
 107042 		} else {
 107043 			Xsqlite3_result_double(tls, pCtx, 0.0)
 107044 		}
 107045 	}
 107046 }
 107047 
 107048 func cume_distStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107049 	var p uintptr
 107050 	_ = nArg
 107051 	_ = apArg
 107052 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 107053 	if p != 0 {
 107054 		(*CallCount)(unsafe.Pointer(p)).FnTotal++
 107055 	}
 107056 }
 107057 
 107058 func cume_distInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107059 	var p uintptr
 107060 	_ = nArg
 107061 	_ = apArg
 107062 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(CallCount{})))
 107063 	(*CallCount)(unsafe.Pointer(p)).FnStep++
 107064 }
 107065 
 107066 func cume_distValueFunc(tls *libc.TLS, pCtx uintptr) {
 107067 	var p uintptr
 107068 	p = Xsqlite3_aggregate_context(tls, pCtx, 0)
 107069 	if p != 0 {
 107070 		var r float64 = float64((*CallCount)(unsafe.Pointer(p)).FnStep) / float64((*CallCount)(unsafe.Pointer(p)).FnTotal)
 107071 		Xsqlite3_result_double(tls, pCtx, r)
 107072 	}
 107073 }
 107074 
 107075 // Context object for ntile() window function.
 107076 type NtileCtx = struct {
 107077 	FnTotal I64
 107078 	FnParam I64
 107079 	FiRow   I64
 107080 }
 107081 
 107082 func ntileStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107083 	var p uintptr
 107084 	_ = nArg
 107085 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NtileCtx{})))
 107086 	if p != 0 {
 107087 		if (*NtileCtx)(unsafe.Pointer(p)).FnTotal == int64(0) {
 107088 			(*NtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg)))
 107089 			if (*NtileCtx)(unsafe.Pointer(p)).FnParam <= int64(0) {
 107090 				Xsqlite3_result_error(tls,
 107091 					pCtx, ts+22171, -1)
 107092 			}
 107093 		}
 107094 		(*NtileCtx)(unsafe.Pointer(p)).FnTotal++
 107095 	}
 107096 }
 107097 
 107098 func ntileInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107099 	var p uintptr
 107100 	_ = nArg
 107101 	_ = apArg
 107102 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NtileCtx{})))
 107103 	(*NtileCtx)(unsafe.Pointer(p)).FiRow++
 107104 }
 107105 
 107106 func ntileValueFunc(tls *libc.TLS, pCtx uintptr) {
 107107 	var p uintptr
 107108 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NtileCtx{})))
 107109 	if p != 0 && (*NtileCtx)(unsafe.Pointer(p)).FnParam > int64(0) {
 107110 		var nSize int32 = int32((*NtileCtx)(unsafe.Pointer(p)).FnTotal / (*NtileCtx)(unsafe.Pointer(p)).FnParam)
 107111 		if nSize == 0 {
 107112 			Xsqlite3_result_int64(tls, pCtx, (*NtileCtx)(unsafe.Pointer(p)).FiRow+int64(1))
 107113 		} else {
 107114 			var nLarge I64 = (*NtileCtx)(unsafe.Pointer(p)).FnTotal - (*NtileCtx)(unsafe.Pointer(p)).FnParam*I64(nSize)
 107115 			var iSmall I64 = nLarge * I64(nSize+1)
 107116 			var iRow I64 = (*NtileCtx)(unsafe.Pointer(p)).FiRow
 107117 
 107118 			if iRow < iSmall {
 107119 				Xsqlite3_result_int64(tls, pCtx, int64(1)+iRow/I64(nSize+1))
 107120 			} else {
 107121 				Xsqlite3_result_int64(tls, pCtx, int64(1)+nLarge+(iRow-iSmall)/I64(nSize))
 107122 			}
 107123 		}
 107124 	}
 107125 }
 107126 
 107127 // Context object for last_value() window function.
 107128 type LastValueCtx = struct {
 107129 	FpVal uintptr
 107130 	FnVal int32
 107131 }
 107132 
 107133 func last_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107134 	var p uintptr
 107135 	_ = nArg
 107136 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(LastValueCtx{})))
 107137 	if p != 0 {
 107138 		Xsqlite3_value_free(tls, (*LastValueCtx)(unsafe.Pointer(p)).FpVal)
 107139 		(*LastValueCtx)(unsafe.Pointer(p)).FpVal = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg)))
 107140 		if (*LastValueCtx)(unsafe.Pointer(p)).FpVal == uintptr(0) {
 107141 			Xsqlite3_result_error_nomem(tls, pCtx)
 107142 		} else {
 107143 			(*LastValueCtx)(unsafe.Pointer(p)).FnVal++
 107144 		}
 107145 	}
 107146 }
 107147 
 107148 func last_valueInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 107149 	var p uintptr
 107150 	_ = nArg
 107151 	_ = apArg
 107152 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(LastValueCtx{})))
 107153 	if p != 0 {
 107154 		(*LastValueCtx)(unsafe.Pointer(p)).FnVal--
 107155 		if (*LastValueCtx)(unsafe.Pointer(p)).FnVal == 0 {
 107156 			Xsqlite3_value_free(tls, (*LastValueCtx)(unsafe.Pointer(p)).FpVal)
 107157 			(*LastValueCtx)(unsafe.Pointer(p)).FpVal = uintptr(0)
 107158 		}
 107159 	}
 107160 }
 107161 
 107162 func last_valueValueFunc(tls *libc.TLS, pCtx uintptr) {
 107163 	var p uintptr
 107164 	p = Xsqlite3_aggregate_context(tls, pCtx, 0)
 107165 	if p != 0 && (*LastValueCtx)(unsafe.Pointer(p)).FpVal != 0 {
 107166 		Xsqlite3_result_value(tls, pCtx, (*LastValueCtx)(unsafe.Pointer(p)).FpVal)
 107167 	}
 107168 }
 107169 
 107170 func last_valueFinalizeFunc(tls *libc.TLS, pCtx uintptr) {
 107171 	var p uintptr
 107172 	p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(LastValueCtx{})))
 107173 	if p != 0 && (*LastValueCtx)(unsafe.Pointer(p)).FpVal != 0 {
 107174 		Xsqlite3_result_value(tls, pCtx, (*LastValueCtx)(unsafe.Pointer(p)).FpVal)
 107175 		Xsqlite3_value_free(tls, (*LastValueCtx)(unsafe.Pointer(p)).FpVal)
 107176 		(*LastValueCtx)(unsafe.Pointer(p)).FpVal = uintptr(0)
 107177 	}
 107178 }
 107179 
 107180 var row_numberName = *(*[11]uint8)(unsafe.Pointer(ts + 22216))
 107181 var dense_rankName = *(*[11]uint8)(unsafe.Pointer(ts + 22227))
 107182 var rankName = *(*[5]uint8)(unsafe.Pointer(ts + 22238))
 107183 var percent_rankName = *(*[13]uint8)(unsafe.Pointer(ts + 22243))
 107184 var cume_distName = *(*[10]uint8)(unsafe.Pointer(ts + 22256))
 107185 var ntileName = *(*[6]uint8)(unsafe.Pointer(ts + 22266))
 107186 var last_valueName = *(*[11]uint8)(unsafe.Pointer(ts + 22272))
 107187 var nth_valueName = *(*[10]uint8)(unsafe.Pointer(ts + 22283))
 107188 var first_valueName = *(*[12]uint8)(unsafe.Pointer(ts + 22293))
 107189 var leadName = *(*[5]uint8)(unsafe.Pointer(ts + 22305))
 107190 var lagName = *(*[4]uint8)(unsafe.Pointer(ts + 22310))
 107191 
 107192 func noopStepFunc(tls *libc.TLS, p uintptr, n int32, a uintptr) {
 107193 	_ = p
 107194 	_ = n
 107195 	_ = a
 107196 
 107197 }
 107198 
 107199 func noopValueFunc(tls *libc.TLS, p uintptr) {
 107200 	_ = p
 107201 }
 107202 
 107203 // Register those built-in window functions that are not also aggregates.
 107204 func Xsqlite3WindowFunctions(tls *libc.TLS) {
 107205 	Xsqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&aWindowFuncs)), int32(uint32(unsafe.Sizeof(aWindowFuncs))/uint32(unsafe.Sizeof(FuncDef{}))))
 107206 }
 107207 
 107208 var aWindowFuncs = [15]FuncDef{
 107209 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107210 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107211 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107212 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107213 	{FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107214 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107215 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107216 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107217 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107218 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107219 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107220 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107221 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107222 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0},
 107223 	{FnArg: int8(3), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | SQLITE_FUNC_WINDOW | 0), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}}
 107224 
 107225 func windowFind(tls *libc.TLS, pParse uintptr, pList uintptr, zName uintptr) uintptr {
 107226 	bp := tls.Alloc(8)
 107227 	defer tls.Free(8)
 107228 
 107229 	var p uintptr
 107230 	for p = pList; p != 0; p = (*Window)(unsafe.Pointer(p)).FpNextWin {
 107231 		if Xsqlite3StrICmp(tls, (*Window)(unsafe.Pointer(p)).FzName, zName) == 0 {
 107232 			break
 107233 		}
 107234 	}
 107235 	if p == uintptr(0) {
 107236 		Xsqlite3ErrorMsg(tls, pParse, ts+22314, libc.VaList(bp, zName))
 107237 	}
 107238 	return p
 107239 }
 107240 
 107241 // This function is called immediately after resolving the function name
 107242 // for a window function within a SELECT statement. Argument pList is a
 107243 // linked list of WINDOW definitions for the current SELECT statement.
 107244 // Argument pFunc is the function definition just resolved and pWin
 107245 // is the Window object representing the associated OVER clause. This
 107246 // function updates the contents of pWin as follows:
 107247 //
 107248 //   - If the OVER clause refered to a named window (as in "max(x) OVER win"),
 107249 //     search list pList for a matching WINDOW definition, and update pWin
 107250 //     accordingly. If no such WINDOW clause can be found, leave an error
 107251 //     in pParse.
 107252 //
 107253 //   - If the function is a built-in window function that requires the
 107254 //     window to be coerced (see "BUILT-IN WINDOW FUNCTIONS" at the top
 107255 //     of this file), pWin is updated here.
 107256 func Xsqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uintptr, pFunc uintptr) {
 107257 	bp := tls.Alloc(128)
 107258 	defer tls.Free(128)
 107259 
 107260 	if (*Window)(unsafe.Pointer(pWin)).FzName != 0 && int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) == 0 {
 107261 		var p uintptr = windowFind(tls, pParse, pList, (*Window)(unsafe.Pointer(pWin)).FzName)
 107262 		if p == uintptr(0) {
 107263 			return
 107264 		}
 107265 		(*Window)(unsafe.Pointer(pWin)).FpPartition = Xsqlite3ExprListDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Window)(unsafe.Pointer(p)).FpPartition, 0)
 107266 		(*Window)(unsafe.Pointer(pWin)).FpOrderBy = Xsqlite3ExprListDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Window)(unsafe.Pointer(p)).FpOrderBy, 0)
 107267 		(*Window)(unsafe.Pointer(pWin)).FpStart = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Window)(unsafe.Pointer(p)).FpStart, 0)
 107268 		(*Window)(unsafe.Pointer(pWin)).FpEnd = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Window)(unsafe.Pointer(p)).FpEnd, 0)
 107269 		(*Window)(unsafe.Pointer(pWin)).FeStart = (*Window)(unsafe.Pointer(p)).FeStart
 107270 		(*Window)(unsafe.Pointer(pWin)).FeEnd = (*Window)(unsafe.Pointer(p)).FeEnd
 107271 		(*Window)(unsafe.Pointer(pWin)).FeFrmType = (*Window)(unsafe.Pointer(p)).FeFrmType
 107272 		(*Window)(unsafe.Pointer(pWin)).FeExclude = (*Window)(unsafe.Pointer(p)).FeExclude
 107273 	} else {
 107274 		Xsqlite3WindowChain(tls, pParse, pWin, pList)
 107275 	}
 107276 	if int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) == TK_RANGE &&
 107277 		((*Window)(unsafe.Pointer(pWin)).FpStart != 0 || (*Window)(unsafe.Pointer(pWin)).FpEnd != 0) &&
 107278 		((*Window)(unsafe.Pointer(pWin)).FpOrderBy == uintptr(0) || (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOrderBy)).FnExpr != 1) {
 107279 		Xsqlite3ErrorMsg(tls, pParse,
 107280 			ts+22333, 0)
 107281 	} else if (*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&U32(SQLITE_FUNC_WINDOW) != 0 {
 107282 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 107283 		if (*Window)(unsafe.Pointer(pWin)).FpFilter != 0 {
 107284 			Xsqlite3ErrorMsg(tls, pParse,
 107285 				ts+22404, 0)
 107286 		} else {
 107287 			*(*[8]WindowUpdate)(unsafe.Pointer(bp)) = [8]WindowUpdate{
 107288 				{FzFunc: uintptr(unsafe.Pointer(&row_numberName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT},
 107289 				{FzFunc: uintptr(unsafe.Pointer(&dense_rankName)), FeFrmType: TK_RANGE, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT},
 107290 				{FzFunc: uintptr(unsafe.Pointer(&rankName)), FeFrmType: TK_RANGE, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT},
 107291 				{FzFunc: uintptr(unsafe.Pointer(&percent_rankName)), FeFrmType: TK_GROUPS, FeStart: TK_CURRENT, FeEnd: TK_UNBOUNDED},
 107292 				{FzFunc: uintptr(unsafe.Pointer(&cume_distName)), FeFrmType: TK_GROUPS, FeStart: TK_FOLLOWING, FeEnd: TK_UNBOUNDED},
 107293 				{FzFunc: uintptr(unsafe.Pointer(&ntileName)), FeFrmType: TK_ROWS, FeStart: TK_CURRENT, FeEnd: TK_UNBOUNDED},
 107294 				{FzFunc: uintptr(unsafe.Pointer(&leadName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_UNBOUNDED},
 107295 				{FzFunc: uintptr(unsafe.Pointer(&lagName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT},
 107296 			}
 107297 			var i int32
 107298 			for i = 0; i < int32(uint32(unsafe.Sizeof([8]WindowUpdate{}))/uint32(unsafe.Sizeof(WindowUpdate{}))); i++ {
 107299 				if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == (*WindowUpdate)(unsafe.Pointer(bp+uintptr(i)*16)).FzFunc {
 107300 					Xsqlite3ExprDelete(tls, db, (*Window)(unsafe.Pointer(pWin)).FpStart)
 107301 					Xsqlite3ExprDelete(tls, db, (*Window)(unsafe.Pointer(pWin)).FpEnd)
 107302 					(*Window)(unsafe.Pointer(pWin)).FpEnd = libc.AssignPtrUintptr(pWin+24, uintptr(0))
 107303 					(*Window)(unsafe.Pointer(pWin)).FeFrmType = U8((*WindowUpdate)(unsafe.Pointer(bp + uintptr(i)*16)).FeFrmType)
 107304 					(*Window)(unsafe.Pointer(pWin)).FeStart = U8((*WindowUpdate)(unsafe.Pointer(bp + uintptr(i)*16)).FeStart)
 107305 					(*Window)(unsafe.Pointer(pWin)).FeEnd = U8((*WindowUpdate)(unsafe.Pointer(bp + uintptr(i)*16)).FeEnd)
 107306 					(*Window)(unsafe.Pointer(pWin)).FeExclude = U8(0)
 107307 					if int32((*Window)(unsafe.Pointer(pWin)).FeStart) == TK_FOLLOWING {
 107308 						(*Window)(unsafe.Pointer(pWin)).FpStart = Xsqlite3Expr(tls, db, TK_INTEGER, ts+7938)
 107309 					}
 107310 					break
 107311 				}
 107312 			}
 107313 		}
 107314 	}
 107315 	(*Window)(unsafe.Pointer(pWin)).FpWFunc = pFunc
 107316 }
 107317 
 107318 type WindowUpdate = struct {
 107319 	FzFunc    uintptr
 107320 	FeFrmType int32
 107321 	FeStart   int32
 107322 	FeEnd     int32
 107323 }
 107324 
 107325 // Context object passed through sqlite3WalkExprList() to
 107326 // selectWindowRewriteExprCb() by selectWindowRewriteEList().
 107327 type WindowRewrite = WindowRewrite1
 107328 
 107329 func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
 107330 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
 107331 	var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse
 107332 
 107333 	if (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect != 0 {
 107334 		if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN {
 107335 			return WRC_Continue
 107336 		} else {
 107337 			var nSrc int32 = (*SrcList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSrc)).FnSrc
 107338 			var i int32
 107339 			for i = 0; i < nSrc; i++ {
 107340 				if (*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SrcItem)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSrc+8+uintptr(i)*72)).FiCursor {
 107341 					break
 107342 				}
 107343 			}
 107344 			if i == nSrc {
 107345 				return WRC_Continue
 107346 			}
 107347 		}
 107348 	}
 107349 
 107350 	{
 107351 		switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) {
 107352 		case TK_FUNCTION:
 107353 			if !((*Expr)(unsafe.Pointer(pExpr)).Fflags&U32(EP_WinFunc) != U32(0)) {
 107354 				break
 107355 			} else {
 107356 				var pWin uintptr
 107357 				for pWin = (*WindowRewrite1)(unsafe.Pointer(p)).FpWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 107358 					if *(*uintptr)(unsafe.Pointer(pExpr + 44)) == pWin {
 107359 						return WRC_Prune
 107360 					}
 107361 				}
 107362 			}
 107363 			fallthrough
 107364 
 107365 		case TK_AGG_FUNCTION:
 107366 			fallthrough
 107367 		case TK_COLUMN:
 107368 			{
 107369 				var iCol int32 = -1
 107370 				if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
 107371 					return WRC_Abort
 107372 				}
 107373 				if (*WindowRewrite1)(unsafe.Pointer(p)).FpSub != 0 {
 107374 					var i int32
 107375 					for i = 0; i < (*ExprList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSub)).FnExpr; i++ {
 107376 						if 0 == Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSub+8+uintptr(i)*20)).FpExpr, pExpr, -1) {
 107377 							iCol = i
 107378 							break
 107379 						}
 107380 					}
 107381 				}
 107382 				if iCol < 0 {
 107383 					var pDup uintptr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)
 107384 					if pDup != 0 && int32((*Expr)(unsafe.Pointer(pDup)).Fop) == TK_AGG_FUNCTION {
 107385 						(*Expr)(unsafe.Pointer(pDup)).Fop = U8(TK_FUNCTION)
 107386 					}
 107387 					(*WindowRewrite1)(unsafe.Pointer(p)).FpSub = Xsqlite3ExprListAppend(tls, pParse, (*WindowRewrite1)(unsafe.Pointer(p)).FpSub, pDup)
 107388 				}
 107389 				if (*WindowRewrite1)(unsafe.Pointer(p)).FpSub != 0 {
 107390 					var f int32 = int32((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(EP_Collate))
 107391 
 107392 					*(*U32)(unsafe.Pointer(pExpr + 4)) |= U32(EP_Static)
 107393 					Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
 107394 					*(*U32)(unsafe.Pointer(pExpr + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_Static))
 107395 					libc.Xmemset(tls, pExpr, 0, uint32(unsafe.Sizeof(Expr{})))
 107396 
 107397 					(*Expr)(unsafe.Pointer(pExpr)).Fop = U8(TK_COLUMN)
 107398 					(*Expr)(unsafe.Pointer(pExpr)).FiColumn = func() int16 {
 107399 						if iCol < 0 {
 107400 							return int16((*ExprList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSub)).FnExpr - 1)
 107401 						}
 107402 						return int16(iCol)
 107403 					}()
 107404 					(*Expr)(unsafe.Pointer(pExpr)).FiTable = (*Window)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpWin)).FiEphCsr
 107405 					*(*uintptr)(unsafe.Pointer(pExpr + 44)) = (*WindowRewrite1)(unsafe.Pointer(p)).FpTab
 107406 					(*Expr)(unsafe.Pointer(pExpr)).Fflags = U32(f)
 107407 				}
 107408 				if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
 107409 					return WRC_Abort
 107410 				}
 107411 				break
 107412 
 107413 			}
 107414 
 107415 		default:
 107416 			break
 107417 		}
 107418 	}
 107419 
 107420 	return WRC_Continue
 107421 }
 107422 
 107423 func selectWindowRewriteSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 {
 107424 	var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 24))
 107425 	var pSave uintptr = (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect
 107426 	if pSave == pSelect {
 107427 		return WRC_Continue
 107428 	} else {
 107429 		(*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect = pSelect
 107430 		Xsqlite3WalkSelect(tls, pWalker, pSelect)
 107431 		(*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect = pSave
 107432 	}
 107433 	return WRC_Prune
 107434 }
 107435 
 107436 func selectWindowRewriteEList(tls *libc.TLS, pParse uintptr, pWin uintptr, pSrc uintptr, pEList uintptr, pTab uintptr, ppSub uintptr) {
 107437 	bp := tls.Alloc(48)
 107438 	defer tls.Free(48)
 107439 
 107440 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
 107441 	libc.Xmemset(tls, bp+28, 0, uint32(unsafe.Sizeof(WindowRewrite{})))
 107442 
 107443 	(*WindowRewrite)(unsafe.Pointer(bp + 28)).FpSub = *(*uintptr)(unsafe.Pointer(ppSub))
 107444 	(*WindowRewrite)(unsafe.Pointer(bp + 28)).FpWin = pWin
 107445 	(*WindowRewrite)(unsafe.Pointer(bp + 28)).FpSrc = pSrc
 107446 	(*WindowRewrite)(unsafe.Pointer(bp + 28)).FpTab = pTab
 107447 
 107448 	(*Walker)(unsafe.Pointer(bp)).FpParse = pParse
 107449 	(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
 107450 		f func(*libc.TLS, uintptr, uintptr) int32
 107451 	}{selectWindowRewriteExprCb}))
 107452 	(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
 107453 		f func(*libc.TLS, uintptr, uintptr) int32
 107454 	}{selectWindowRewriteSelectCb}))
 107455 	*(*uintptr)(unsafe.Pointer(bp + 24)) = bp + 28
 107456 
 107457 	Xsqlite3WalkExprList(tls, bp, pEList)
 107458 
 107459 	*(*uintptr)(unsafe.Pointer(ppSub)) = (*WindowRewrite)(unsafe.Pointer(bp + 28)).FpSub
 107460 }
 107461 
 107462 func exprListAppendList(tls *libc.TLS, pParse uintptr, pList uintptr, pAppend uintptr, bIntToNull int32) uintptr {
 107463 	bp := tls.Alloc(4)
 107464 	defer tls.Free(4)
 107465 
 107466 	if pAppend != 0 {
 107467 		var i int32
 107468 		var nInit int32
 107469 		if pList != 0 {
 107470 			nInit = (*ExprList)(unsafe.Pointer(pList)).FnExpr
 107471 		} else {
 107472 			nInit = 0
 107473 		}
 107474 		for i = 0; i < (*ExprList)(unsafe.Pointer(pAppend)).FnExpr; i++ {
 107475 			var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 107476 			var pDup uintptr = Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer(pAppend+8+uintptr(i)*20)).FpExpr, 0)
 107477 			if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 107478 				Xsqlite3ExprDelete(tls, db, pDup)
 107479 				break
 107480 			}
 107481 			if bIntToNull != 0 {
 107482 				var pSub uintptr
 107483 				pSub = Xsqlite3ExprSkipCollateAndLikely(tls, pDup)
 107484 				if Xsqlite3ExprIsInteger(tls, pSub, bp) != 0 {
 107485 					(*Expr)(unsafe.Pointer(pSub)).Fop = U8(TK_NULL)
 107486 					*(*U32)(unsafe.Pointer(pSub + 4)) &= libc.Uint32FromInt32(libc.CplInt32(EP_IntValue | EP_IsTrue | EP_IsFalse))
 107487 					*(*uintptr)(unsafe.Pointer(pSub + 8)) = uintptr(0)
 107488 				}
 107489 			}
 107490 			pList = Xsqlite3ExprListAppend(tls, pParse, pList, pDup)
 107491 			if pList != 0 {
 107492 				(*ExprList_item)(unsafe.Pointer(pList + 8 + uintptr(nInit+i)*20)).Ffg.FsortFlags = (*ExprList_item)(unsafe.Pointer(pAppend + 8 + uintptr(i)*20)).Ffg.FsortFlags
 107493 			}
 107494 		}
 107495 	}
 107496 	return pList
 107497 }
 107498 
 107499 func sqlite3WindowExtraAggFuncDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
 107500 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION &&
 107501 		int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) >= (*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth {
 107502 		(*Expr)(unsafe.Pointer(pExpr)).Fop2++
 107503 	}
 107504 	return WRC_Continue
 107505 }
 107506 
 107507 func disallowAggregatesInOrderByCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 {
 107508 	bp := tls.Alloc(8)
 107509 	defer tls.Free(8)
 107510 
 107511 	if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION && (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) {
 107512 		Xsqlite3ErrorMsg(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse,
 107513 			ts+22467, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pExpr + 8))))
 107514 	}
 107515 	return WRC_Continue
 107516 }
 107517 
 107518 // If the SELECT statement passed as the second argument does not invoke
 107519 // any SQL window functions, this function is a no-op. Otherwise, it
 107520 // rewrites the SELECT statement so that window function xStep functions
 107521 // are invoked in the correct order as described under "SELECT REWRITING"
 107522 // at the top of this file.
 107523 func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 {
 107524 	bp := tls.Alloc(32)
 107525 	defer tls.Free(32)
 107526 
 107527 	var rc int32 = SQLITE_OK
 107528 	if (*Select)(unsafe.Pointer(p)).FpWin != 0 &&
 107529 		(*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0) &&
 107530 		(*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_WinRewrite) == U32(0) &&
 107531 		!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
 107532 		var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 107533 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 107534 		var pSub uintptr = uintptr(0)
 107535 		var pSrc uintptr = (*Select)(unsafe.Pointer(p)).FpSrc
 107536 		var pWhere uintptr = (*Select)(unsafe.Pointer(p)).FpWhere
 107537 		var pGroupBy uintptr = (*Select)(unsafe.Pointer(p)).FpGroupBy
 107538 		var pHaving uintptr = (*Select)(unsafe.Pointer(p)).FpHaving
 107539 		var pSort uintptr = uintptr(0)
 107540 
 107541 		*(*uintptr)(unsafe.Pointer(bp + 28)) = uintptr(0)
 107542 		var pMWin uintptr = (*Select)(unsafe.Pointer(p)).FpWin
 107543 		var pWin uintptr
 107544 		var pTab uintptr
 107545 
 107546 		var selFlags U32 = (*Select)(unsafe.Pointer(p)).FselFlags
 107547 
 107548 		pTab = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))
 107549 		if pTab == uintptr(0) {
 107550 			return Xsqlite3ErrorToParser(tls, db, SQLITE_NOMEM)
 107551 		}
 107552 		Xsqlite3AggInfoPersistWalkerInit(tls, bp, pParse)
 107553 		Xsqlite3WalkSelect(tls, bp, p)
 107554 		if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_Aggregate) == U32(0) {
 107555 			(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
 107556 				f func(*libc.TLS, uintptr, uintptr) int32
 107557 			}{disallowAggregatesInOrderByCb}))
 107558 			(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = uintptr(0)
 107559 			Xsqlite3WalkExprList(tls, bp, (*Select)(unsafe.Pointer(p)).FpOrderBy)
 107560 		}
 107561 
 107562 		(*Select)(unsafe.Pointer(p)).FpSrc = uintptr(0)
 107563 		(*Select)(unsafe.Pointer(p)).FpWhere = uintptr(0)
 107564 		(*Select)(unsafe.Pointer(p)).FpGroupBy = uintptr(0)
 107565 		(*Select)(unsafe.Pointer(p)).FpHaving = uintptr(0)
 107566 		*(*U32)(unsafe.Pointer(p + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_Aggregate))
 107567 		*(*U32)(unsafe.Pointer(p + 4)) |= U32(SF_WinRewrite)
 107568 
 107569 		pSort = exprListAppendList(tls, pParse, uintptr(0), (*Window)(unsafe.Pointer(pMWin)).FpPartition, 1)
 107570 		pSort = exprListAppendList(tls, pParse, pSort, (*Window)(unsafe.Pointer(pMWin)).FpOrderBy, 1)
 107571 		if pSort != 0 && (*Select)(unsafe.Pointer(p)).FpOrderBy != 0 && (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy)).FnExpr <= (*ExprList)(unsafe.Pointer(pSort)).FnExpr {
 107572 			var nSave int32 = (*ExprList)(unsafe.Pointer(pSort)).FnExpr
 107573 			(*ExprList)(unsafe.Pointer(pSort)).FnExpr = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy)).FnExpr
 107574 			if Xsqlite3ExprListCompare(tls, pSort, (*Select)(unsafe.Pointer(p)).FpOrderBy, -1) == 0 {
 107575 				Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpOrderBy)
 107576 				(*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0)
 107577 			}
 107578 			(*ExprList)(unsafe.Pointer(pSort)).FnExpr = nSave
 107579 		}
 107580 
 107581 		(*Window)(unsafe.Pointer(pMWin)).FiEphCsr = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 107582 		*(*int32)(unsafe.Pointer(pParse + 40)) += 3
 107583 
 107584 		selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*Select)(unsafe.Pointer(p)).FpEList, pTab, bp+28)
 107585 		selectWindowRewriteEList(tls, pParse, pMWin, pSrc, (*Select)(unsafe.Pointer(p)).FpOrderBy, pTab, bp+28)
 107586 		(*Window)(unsafe.Pointer(pMWin)).FnBufferCol = func() int32 {
 107587 			if *(*uintptr)(unsafe.Pointer(bp + 28)) != 0 {
 107588 				return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 28)))).FnExpr
 107589 			}
 107590 			return 0
 107591 		}()
 107592 
 107593 		*(*uintptr)(unsafe.Pointer(bp + 28)) = exprListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 28)), (*Window)(unsafe.Pointer(pMWin)).FpPartition, 0)
 107594 		*(*uintptr)(unsafe.Pointer(bp + 28)) = exprListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 28)), (*Window)(unsafe.Pointer(pMWin)).FpOrderBy, 0)
 107595 
 107596 		for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 107597 			var pArgs uintptr
 107598 
 107599 			pArgs = *(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20))
 107600 			if (*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpWFunc)).FfuncFlags&U32(SQLITE_FUNC_SUBTYPE) != 0 {
 107601 				selectWindowRewriteEList(tls, pParse, pMWin, pSrc, pArgs, pTab, bp+28)
 107602 				(*Window)(unsafe.Pointer(pWin)).FiArgCol = func() int32 {
 107603 					if *(*uintptr)(unsafe.Pointer(bp + 28)) != 0 {
 107604 						return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 28)))).FnExpr
 107605 					}
 107606 					return 0
 107607 				}()
 107608 				(*Window)(unsafe.Pointer(pWin)).FbExprArgs = U8(1)
 107609 			} else {
 107610 				(*Window)(unsafe.Pointer(pWin)).FiArgCol = func() int32 {
 107611 					if *(*uintptr)(unsafe.Pointer(bp + 28)) != 0 {
 107612 						return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 28)))).FnExpr
 107613 					}
 107614 					return 0
 107615 				}()
 107616 				*(*uintptr)(unsafe.Pointer(bp + 28)) = exprListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 28)), pArgs, 0)
 107617 			}
 107618 			if (*Window)(unsafe.Pointer(pWin)).FpFilter != 0 {
 107619 				var pFilter uintptr = Xsqlite3ExprDup(tls, db, (*Window)(unsafe.Pointer(pWin)).FpFilter, 0)
 107620 				*(*uintptr)(unsafe.Pointer(bp + 28)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 28)), pFilter)
 107621 			}
 107622 			(*Window)(unsafe.Pointer(pWin)).FregAccum = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 107623 			(*Window)(unsafe.Pointer(pWin)).FregResult = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 107624 			Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum)
 107625 		}
 107626 
 107627 		if *(*uintptr)(unsafe.Pointer(bp + 28)) == uintptr(0) {
 107628 			*(*uintptr)(unsafe.Pointer(bp + 28)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0),
 107629 				Xsqlite3Expr(tls, db, TK_INTEGER, ts+7519))
 107630 		}
 107631 
 107632 		pSub = Xsqlite3SelectNew(tls,
 107633 			pParse, *(*uintptr)(unsafe.Pointer(bp + 28)), pSrc, pWhere, pGroupBy, pHaving, pSort, uint32(0), uintptr(0))
 107634 
 107635 		(*Select)(unsafe.Pointer(p)).FpSrc = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0))
 107636 
 107637 		if (*Select)(unsafe.Pointer(p)).FpSrc != 0 {
 107638 			var pTab2 uintptr
 107639 			(*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpSelect = pSub
 107640 			libc.SetBitFieldPtr16Uint32((*Select)(unsafe.Pointer(p)).FpSrc+8+36+4, uint32(1), 3, 0x8)
 107641 			Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer(p)).FpSrc)
 107642 			*(*U32)(unsafe.Pointer(pSub + 4)) |= U32(SF_Expanded | SF_OrderByReqd)
 107643 			pTab2 = Xsqlite3ResultSetOfSelect(tls, pParse, pSub, uint8(SQLITE_AFF_NONE))
 107644 			*(*U32)(unsafe.Pointer(pSub + 4)) |= selFlags & U32(SF_Aggregate)
 107645 			if pTab2 == uintptr(0) {
 107646 				rc = SQLITE_NOMEM
 107647 			} else {
 107648 				libc.Xmemcpy(tls, pTab, pTab2, uint32(unsafe.Sizeof(Table{})))
 107649 				*(*U32)(unsafe.Pointer(pTab + 28)) |= U32(TF_Ephemeral)
 107650 				(*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpTab = pTab
 107651 				pTab = pTab2
 107652 				libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Walker{})))
 107653 				(*Walker)(unsafe.Pointer(bp)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct {
 107654 					f func(*libc.TLS, uintptr, uintptr) int32
 107655 				}{sqlite3WindowExtraAggFuncDepth}))
 107656 				(*Walker)(unsafe.Pointer(bp)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct {
 107657 					f func(*libc.TLS, uintptr, uintptr) int32
 107658 				}{Xsqlite3WalkerDepthIncrease}))
 107659 				(*Walker)(unsafe.Pointer(bp)).FxSelectCallback2 = *(*uintptr)(unsafe.Pointer(&struct {
 107660 					f func(*libc.TLS, uintptr, uintptr)
 107661 				}{Xsqlite3WalkerDepthDecrease}))
 107662 				Xsqlite3WalkSelect(tls, bp, pSub)
 107663 			}
 107664 		} else {
 107665 			Xsqlite3SelectDelete(tls, db, pSub)
 107666 		}
 107667 		if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 107668 			rc = SQLITE_NOMEM
 107669 		}
 107670 
 107671 		Xsqlite3ParserAddCleanup(tls, pParse, *(*uintptr)(unsafe.Pointer(&struct {
 107672 			f func(*libc.TLS, uintptr, uintptr)
 107673 		}{Xsqlite3DbFree})), pTab)
 107674 	}
 107675 
 107676 	return rc
 107677 }
 107678 
 107679 // Unlink the Window object from the Select to which it is attached,
 107680 // if it is attached.
 107681 func Xsqlite3WindowUnlinkFromSelect(tls *libc.TLS, p uintptr) {
 107682 	if (*Window)(unsafe.Pointer(p)).FppThis != 0 {
 107683 		*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(p)).FppThis)) = (*Window)(unsafe.Pointer(p)).FpNextWin
 107684 		if (*Window)(unsafe.Pointer(p)).FpNextWin != 0 {
 107685 			(*Window)(unsafe.Pointer((*Window)(unsafe.Pointer(p)).FpNextWin)).FppThis = (*Window)(unsafe.Pointer(p)).FppThis
 107686 		}
 107687 		(*Window)(unsafe.Pointer(p)).FppThis = uintptr(0)
 107688 	}
 107689 }
 107690 
 107691 // Free the Window object passed as the second argument.
 107692 func Xsqlite3WindowDelete(tls *libc.TLS, db uintptr, p uintptr) {
 107693 	if p != 0 {
 107694 		Xsqlite3WindowUnlinkFromSelect(tls, p)
 107695 		Xsqlite3ExprDelete(tls, db, (*Window)(unsafe.Pointer(p)).FpFilter)
 107696 		Xsqlite3ExprListDelete(tls, db, (*Window)(unsafe.Pointer(p)).FpPartition)
 107697 		Xsqlite3ExprListDelete(tls, db, (*Window)(unsafe.Pointer(p)).FpOrderBy)
 107698 		Xsqlite3ExprDelete(tls, db, (*Window)(unsafe.Pointer(p)).FpEnd)
 107699 		Xsqlite3ExprDelete(tls, db, (*Window)(unsafe.Pointer(p)).FpStart)
 107700 		Xsqlite3DbFree(tls, db, (*Window)(unsafe.Pointer(p)).FzName)
 107701 		Xsqlite3DbFree(tls, db, (*Window)(unsafe.Pointer(p)).FzBase)
 107702 		Xsqlite3DbFree(tls, db, p)
 107703 	}
 107704 }
 107705 
 107706 // Free the linked list of Window objects starting at the second argument.
 107707 func Xsqlite3WindowListDelete(tls *libc.TLS, db uintptr, p uintptr) {
 107708 	for p != 0 {
 107709 		var pNext uintptr = (*Window)(unsafe.Pointer(p)).FpNextWin
 107710 		Xsqlite3WindowDelete(tls, db, p)
 107711 		p = pNext
 107712 	}
 107713 }
 107714 
 107715 func sqlite3WindowOffsetExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr {
 107716 	if 0 == Xsqlite3ExprIsConstant(tls, pExpr) {
 107717 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
 107718 			Xsqlite3RenameExprUnmap(tls, pParse, pExpr)
 107719 		}
 107720 		Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr)
 107721 		pExpr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_NULL, uintptr(0), 0)
 107722 	}
 107723 	return pExpr
 107724 }
 107725 
 107726 // Allocate and return a new Window object describing a Window Definition.
 107727 func Xsqlite3WindowAlloc(tls *libc.TLS, pParse uintptr, eType int32, eStart int32, pStart uintptr, eEnd int32, pEnd uintptr, eExclude U8) uintptr {
 107728 	var pWin uintptr
 107729 	var bImplicitFrame int32
 107730 	pWin = uintptr(0)
 107731 	bImplicitFrame = 0
 107732 
 107733 	if !(eType == 0) {
 107734 		goto __1
 107735 	}
 107736 	bImplicitFrame = 1
 107737 	eType = TK_RANGE
 107738 __1:
 107739 	;
 107740 	if !(eStart == TK_CURRENT && eEnd == TK_PRECEDING ||
 107741 		eStart == TK_FOLLOWING && (eEnd == TK_PRECEDING || eEnd == TK_CURRENT)) {
 107742 		goto __2
 107743 	}
 107744 	Xsqlite3ErrorMsg(tls, pParse, ts+22493, 0)
 107745 	goto windowAllocErr
 107746 __2:
 107747 	;
 107748 	pWin = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{})))
 107749 	if !(pWin == uintptr(0)) {
 107750 		goto __3
 107751 	}
 107752 	goto windowAllocErr
 107753 __3:
 107754 	;
 107755 	(*Window)(unsafe.Pointer(pWin)).FeFrmType = U8(eType)
 107756 	(*Window)(unsafe.Pointer(pWin)).FeStart = U8(eStart)
 107757 	(*Window)(unsafe.Pointer(pWin)).FeEnd = U8(eEnd)
 107758 	if !(int32(eExclude) == 0 && (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FdbOptFlags&U32(SQLITE_WindowFunc) != U32(0)) {
 107759 		goto __4
 107760 	}
 107761 	eExclude = U8(TK_NO)
 107762 __4:
 107763 	;
 107764 	(*Window)(unsafe.Pointer(pWin)).FeExclude = eExclude
 107765 	(*Window)(unsafe.Pointer(pWin)).FbImplicitFrame = U8(bImplicitFrame)
 107766 	(*Window)(unsafe.Pointer(pWin)).FpEnd = sqlite3WindowOffsetExpr(tls, pParse, pEnd)
 107767 	(*Window)(unsafe.Pointer(pWin)).FpStart = sqlite3WindowOffsetExpr(tls, pParse, pStart)
 107768 	return pWin
 107769 
 107770 windowAllocErr:
 107771 	Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pEnd)
 107772 	Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pStart)
 107773 	return uintptr(0)
 107774 }
 107775 
 107776 // Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window
 107777 // pWin. Also, if parameter pBase is not NULL, set pWin->zBase to the
 107778 // equivalent nul-terminated string.
 107779 func Xsqlite3WindowAssemble(tls *libc.TLS, pParse uintptr, pWin uintptr, pPartition uintptr, pOrderBy uintptr, pBase uintptr) uintptr {
 107780 	if pWin != 0 {
 107781 		(*Window)(unsafe.Pointer(pWin)).FpPartition = pPartition
 107782 		(*Window)(unsafe.Pointer(pWin)).FpOrderBy = pOrderBy
 107783 		if pBase != 0 {
 107784 			(*Window)(unsafe.Pointer(pWin)).FzBase = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(pBase)).Fz, uint64((*Token)(unsafe.Pointer(pBase)).Fn))
 107785 		}
 107786 	} else {
 107787 		Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pPartition)
 107788 		Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pOrderBy)
 107789 	}
 107790 	return pWin
 107791 }
 107792 
 107793 // Window *pWin has just been created from a WINDOW clause. Tokne pBase
 107794 // is the base window. Earlier windows from the same WINDOW clause are
 107795 // stored in the linked list starting at pWin->pNextWin. This function
 107796 // either updates *pWin according to the base specification, or else
 107797 // leaves an error in pParse.
 107798 func Xsqlite3WindowChain(tls *libc.TLS, pParse uintptr, pWin uintptr, pList uintptr) {
 107799 	bp := tls.Alloc(16)
 107800 	defer tls.Free(16)
 107801 
 107802 	if (*Window)(unsafe.Pointer(pWin)).FzBase != 0 {
 107803 		var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 107804 		var pExist uintptr = windowFind(tls, pParse, pList, (*Window)(unsafe.Pointer(pWin)).FzBase)
 107805 		if pExist != 0 {
 107806 			var zErr uintptr = uintptr(0)
 107807 
 107808 			if (*Window)(unsafe.Pointer(pWin)).FpPartition != 0 {
 107809 				zErr = ts + 22525
 107810 			} else if (*Window)(unsafe.Pointer(pExist)).FpOrderBy != 0 && (*Window)(unsafe.Pointer(pWin)).FpOrderBy != 0 {
 107811 				zErr = ts + 22542
 107812 			} else if int32((*Window)(unsafe.Pointer(pExist)).FbImplicitFrame) == 0 {
 107813 				zErr = ts + 22558
 107814 			}
 107815 			if zErr != 0 {
 107816 				Xsqlite3ErrorMsg(tls, pParse,
 107817 					ts+22578, libc.VaList(bp, zErr, (*Window)(unsafe.Pointer(pWin)).FzBase))
 107818 			} else {
 107819 				(*Window)(unsafe.Pointer(pWin)).FpPartition = Xsqlite3ExprListDup(tls, db, (*Window)(unsafe.Pointer(pExist)).FpPartition, 0)
 107820 				if (*Window)(unsafe.Pointer(pExist)).FpOrderBy != 0 {
 107821 					(*Window)(unsafe.Pointer(pWin)).FpOrderBy = Xsqlite3ExprListDup(tls, db, (*Window)(unsafe.Pointer(pExist)).FpOrderBy, 0)
 107822 				}
 107823 				Xsqlite3DbFree(tls, db, (*Window)(unsafe.Pointer(pWin)).FzBase)
 107824 				(*Window)(unsafe.Pointer(pWin)).FzBase = uintptr(0)
 107825 			}
 107826 		}
 107827 	}
 107828 }
 107829 
 107830 // Attach window object pWin to expression p.
 107831 func Xsqlite3WindowAttach(tls *libc.TLS, pParse uintptr, p uintptr, pWin uintptr) {
 107832 	if p != 0 {
 107833 		*(*uintptr)(unsafe.Pointer(p + 44)) = pWin
 107834 		*(*U32)(unsafe.Pointer(p + 4)) |= U32(EP_WinFunc)
 107835 		(*Window)(unsafe.Pointer(pWin)).FpOwner = p
 107836 		if (*Expr)(unsafe.Pointer(p)).Fflags&U32(EP_Distinct) != 0 && int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) != TK_FILTER {
 107837 			Xsqlite3ErrorMsg(tls, pParse,
 107838 				ts+22611, 0)
 107839 		}
 107840 	} else {
 107841 		Xsqlite3WindowDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pWin)
 107842 	}
 107843 }
 107844 
 107845 // Possibly link window pWin into the list at pSel->pWin (window functions
 107846 // to be processed as part of SELECT statement pSel). The window is linked
 107847 // in if either (a) there are no other windows already linked to this
 107848 // SELECT, or (b) the windows already linked use a compatible window frame.
 107849 func Xsqlite3WindowLink(tls *libc.TLS, pSel uintptr, pWin uintptr) {
 107850 	if pSel != 0 {
 107851 		if uintptr(0) == (*Select)(unsafe.Pointer(pSel)).FpWin || 0 == Xsqlite3WindowCompare(tls, uintptr(0), (*Select)(unsafe.Pointer(pSel)).FpWin, pWin, 0) {
 107852 			(*Window)(unsafe.Pointer(pWin)).FpNextWin = (*Select)(unsafe.Pointer(pSel)).FpWin
 107853 			if (*Select)(unsafe.Pointer(pSel)).FpWin != 0 {
 107854 				(*Window)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpWin)).FppThis = pWin + 36
 107855 			}
 107856 			(*Select)(unsafe.Pointer(pSel)).FpWin = pWin
 107857 			(*Window)(unsafe.Pointer(pWin)).FppThis = pSel + 68
 107858 		} else {
 107859 			if Xsqlite3ExprListCompare(tls, (*Window)(unsafe.Pointer(pWin)).FpPartition, (*Window)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpWin)).FpPartition, -1) != 0 {
 107860 				*(*U32)(unsafe.Pointer(pSel + 4)) |= U32(SF_MultiPart)
 107861 			}
 107862 		}
 107863 	}
 107864 }
 107865 
 107866 // Return 0 if the two window objects are identical, 1 if they are
 107867 // different, or 2 if it cannot be determined if the objects are identical
 107868 // or not. Identical window objects can be processed in a single scan.
 107869 func Xsqlite3WindowCompare(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr, bFilter int32) int32 {
 107870 	var res int32
 107871 	if p1 == uintptr(0) || p2 == uintptr(0) {
 107872 		return 1
 107873 	}
 107874 	if int32((*Window)(unsafe.Pointer(p1)).FeFrmType) != int32((*Window)(unsafe.Pointer(p2)).FeFrmType) {
 107875 		return 1
 107876 	}
 107877 	if int32((*Window)(unsafe.Pointer(p1)).FeStart) != int32((*Window)(unsafe.Pointer(p2)).FeStart) {
 107878 		return 1
 107879 	}
 107880 	if int32((*Window)(unsafe.Pointer(p1)).FeEnd) != int32((*Window)(unsafe.Pointer(p2)).FeEnd) {
 107881 		return 1
 107882 	}
 107883 	if int32((*Window)(unsafe.Pointer(p1)).FeExclude) != int32((*Window)(unsafe.Pointer(p2)).FeExclude) {
 107884 		return 1
 107885 	}
 107886 	if Xsqlite3ExprCompare(tls, pParse, (*Window)(unsafe.Pointer(p1)).FpStart, (*Window)(unsafe.Pointer(p2)).FpStart, -1) != 0 {
 107887 		return 1
 107888 	}
 107889 	if Xsqlite3ExprCompare(tls, pParse, (*Window)(unsafe.Pointer(p1)).FpEnd, (*Window)(unsafe.Pointer(p2)).FpEnd, -1) != 0 {
 107890 		return 1
 107891 	}
 107892 	if libc.AssignInt32(&res, Xsqlite3ExprListCompare(tls, (*Window)(unsafe.Pointer(p1)).FpPartition, (*Window)(unsafe.Pointer(p2)).FpPartition, -1)) != 0 {
 107893 		return res
 107894 	}
 107895 	if libc.AssignInt32(&res, Xsqlite3ExprListCompare(tls, (*Window)(unsafe.Pointer(p1)).FpOrderBy, (*Window)(unsafe.Pointer(p2)).FpOrderBy, -1)) != 0 {
 107896 		return res
 107897 	}
 107898 	if bFilter != 0 {
 107899 		if libc.AssignInt32(&res, Xsqlite3ExprCompare(tls, pParse, (*Window)(unsafe.Pointer(p1)).FpFilter, (*Window)(unsafe.Pointer(p2)).FpFilter, -1)) != 0 {
 107900 			return res
 107901 		}
 107902 	}
 107903 	return 0
 107904 }
 107905 
 107906 // This is called by code in select.c before it calls sqlite3WhereBegin()
 107907 // to begin iterating through the sub-query results. It is used to allocate
 107908 // and initialize registers and cursors used by sqlite3WindowCodeStep().
 107909 func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) {
 107910 	var nEphExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8)).FpSelect)).FpEList)).FnExpr
 107911 	var pMWin uintptr = (*Select)(unsafe.Pointer(pSelect)).FpWin
 107912 	var pWin uintptr
 107913 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 107914 
 107915 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr)
 107916 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr+1, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr)
 107917 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr+2, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr)
 107918 	Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr+3, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr)
 107919 
 107920 	if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 {
 107921 		var nExpr int32 = (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr
 107922 		(*Window)(unsafe.Pointer(pMWin)).FregPart = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 107923 		*(*int32)(unsafe.Pointer(pParse + 44)) += nExpr
 107924 		Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pMWin)).FregPart, (*Window)(unsafe.Pointer(pMWin)).FregPart+nExpr-1)
 107925 	}
 107926 
 107927 	(*Window)(unsafe.Pointer(pMWin)).FregOne = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 107928 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregOne)
 107929 
 107930 	if (*Window)(unsafe.Pointer(pMWin)).FeExclude != 0 {
 107931 		(*Window)(unsafe.Pointer(pMWin)).FregStartRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 107932 		(*Window)(unsafe.Pointer(pMWin)).FregEndRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 107933 		(*Window)(unsafe.Pointer(pMWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 107934 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid)
 107935 		Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid)
 107936 		Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pMWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr)
 107937 		return
 107938 	}
 107939 
 107940 	for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 107941 		var p uintptr = (*Window)(unsafe.Pointer(pWin)).FpWFunc
 107942 		if (*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(SQLITE_FUNC_MINMAX) != 0 && int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED {
 107943 			var pList uintptr
 107944 			var pKeyInfo uintptr
 107945 
 107946 			pList = *(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20))
 107947 			pKeyInfo = Xsqlite3KeyInfoFromExprList(tls, pParse, pList, 0, 0)
 107948 			(*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 107949 			(*Window)(unsafe.Pointer(pWin)).FregApp = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 107950 			*(*int32)(unsafe.Pointer(pParse + 44)) += 3
 107951 			if pKeyInfo != 0 && int32(*(*uint8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpWFunc)).FzName + 1))) == 'i' {
 107952 				*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)) = U8(KEYINFO_ORDER_DESC)
 107953 			}
 107954 			Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 2)
 107955 			Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -8)
 107956 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pWin)).FregApp+1)
 107957 		} else if (*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) || (*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&first_valueName)) {
 107958 			(*Window)(unsafe.Pointer(pWin)).FregApp = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 107959 			(*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 107960 			*(*int32)(unsafe.Pointer(pParse + 44)) += 2
 107961 			Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr)
 107962 		} else if (*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&leadName)) || (*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&lagName)) {
 107963 			(*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)
 107964 			Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr)
 107965 		}
 107966 	}
 107967 }
 107968 
 107969 func windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) {
 107970 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 107971 	var regZero int32 = Xsqlite3GetTempReg(tls, pParse)
 107972 
 107973 	Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regZero)
 107974 	if eCond >= WINDOW_STARTING_NUM {
 107975 		var regString int32 = Xsqlite3GetTempReg(tls, pParse)
 107976 		Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, regString, 0, ts+1554, -1)
 107977 		Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regString, Xsqlite3VdbeCurrentAddr(tls, v)+2, reg)
 107978 		Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_AFF_NUMERIC|SQLITE_JUMPIFNULL))
 107979 
 107980 	} else {
 107981 		Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, reg, Xsqlite3VdbeCurrentAddr(tls, v)+2)
 107982 
 107983 	}
 107984 	Xsqlite3VdbeAddOp3(tls, v, aOp1[eCond], regZero, Xsqlite3VdbeCurrentAddr(tls, v)+2, reg)
 107985 	Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_AFF_NUMERIC))
 107986 
 107987 	Xsqlite3MayAbort(tls, pParse)
 107988 	Xsqlite3VdbeAddOp2(tls, v, OP_Halt, SQLITE_ERROR, OE_Abort)
 107989 	Xsqlite3VdbeAppendP4(tls, v, azErr[eCond], -1)
 107990 	Xsqlite3ReleaseTempReg(tls, pParse, regZero)
 107991 }
 107992 
 107993 var azErr = [5]uintptr{
 107994 	ts + 22658,
 107995 	ts + 22711,
 107996 	ts + 22115,
 107997 	ts + 22762,
 107998 	ts + 22814,
 107999 }
 108000 var aOp1 = [5]int32{OP_Ge, OP_Ge, OP_Gt, OP_Ge, OP_Ge}
 108001 
 108002 func windowArgCount(tls *libc.TLS, pWin uintptr) int32 {
 108003 	var pList uintptr
 108004 
 108005 	pList = *(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20))
 108006 	return func() int32 {
 108007 		if pList != 0 {
 108008 			return (*ExprList)(unsafe.Pointer(pList)).FnExpr
 108009 		}
 108010 		return 0
 108011 	}()
 108012 }
 108013 
 108014 type WindowCodeArg1 = struct {
 108015 	FpParse    uintptr
 108016 	FpMWin     uintptr
 108017 	FpVdbe     uintptr
 108018 	FaddrGosub int32
 108019 	FregGosub  int32
 108020 	FregArg    int32
 108021 	FeDelete   int32
 108022 	FregRowid  int32
 108023 	Fstart     WindowCsrAndReg
 108024 	Fcurrent   WindowCsrAndReg
 108025 	Fend       WindowCsrAndReg
 108026 }
 108027 
 108028 type WindowCodeArg = WindowCodeArg1
 108029 type WindowCsrAndReg1 = struct {
 108030 	Fcsr int32
 108031 	Freg int32
 108032 }
 108033 
 108034 type WindowCsrAndReg = WindowCsrAndReg1
 108035 
 108036 func windowReadPeerValues(tls *libc.TLS, p uintptr, csr int32, reg int32) {
 108037 	var pMWin uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpMWin
 108038 	var pOrderBy uintptr = (*Window)(unsafe.Pointer(pMWin)).FpOrderBy
 108039 	if pOrderBy != 0 {
 108040 		var v uintptr = Xsqlite3GetVdbe(tls, (*WindowCodeArg)(unsafe.Pointer(p)).FpParse)
 108041 		var pPart uintptr = (*Window)(unsafe.Pointer(pMWin)).FpPartition
 108042 		var iColOff int32 = (*Window)(unsafe.Pointer(pMWin)).FnBufferCol + func() int32 {
 108043 			if pPart != 0 {
 108044 				return (*ExprList)(unsafe.Pointer(pPart)).FnExpr
 108045 			}
 108046 			return 0
 108047 		}()
 108048 		var i int32
 108049 		for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ {
 108050 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, iColOff+i, reg+i)
 108051 		}
 108052 	}
 108053 }
 108054 
 108055 func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse int32, reg int32) {
 108056 	var pParse uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpParse
 108057 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 108058 	var pWin uintptr
 108059 	for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108060 		var pFunc uintptr = (*Window)(unsafe.Pointer(pWin)).FpWFunc
 108061 		var regArg int32
 108062 		var nArg int32
 108063 		if (*Window)(unsafe.Pointer(pWin)).FbExprArgs != 0 {
 108064 			nArg = 0
 108065 		} else {
 108066 			nArg = windowArgCount(tls, pWin)
 108067 		}
 108068 		var i int32
 108069 
 108070 		for i = 0; i < nArg; i++ {
 108071 			if i != 1 || (*FuncDef)(unsafe.Pointer(pFunc)).FzName != uintptr(unsafe.Pointer(&nth_valueName)) {
 108072 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol+i, reg+i)
 108073 			} else {
 108074 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, (*Window)(unsafe.Pointer(pWin)).FiArgCol+i, reg+i)
 108075 			}
 108076 		}
 108077 		regArg = reg
 108078 
 108079 		if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0 &&
 108080 			(*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&U32(SQLITE_FUNC_MINMAX) != 0 &&
 108081 			int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED {
 108082 			var addrIsNull int32 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regArg)
 108083 
 108084 			if bInverse == 0 {
 108085 				Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pWin)).FregApp+1, 1)
 108086 				Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, regArg, (*Window)(unsafe.Pointer(pWin)).FregApp)
 108087 				Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*Window)(unsafe.Pointer(pWin)).FregApp, 2, (*Window)(unsafe.Pointer(pWin)).FregApp+2)
 108088 				Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pWin)).FregApp+2)
 108089 			} else {
 108090 				Xsqlite3VdbeAddOp4Int(tls, v, OP_SeekGE, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, regArg, 1)
 108091 
 108092 				Xsqlite3VdbeAddOp1(tls, v, OP_Delete, (*Window)(unsafe.Pointer(pWin)).FcsrApp)
 108093 				Xsqlite3VdbeJumpHere(tls, v, Xsqlite3VdbeCurrentAddr(tls, v)-2)
 108094 			}
 108095 			Xsqlite3VdbeJumpHere(tls, v, addrIsNull)
 108096 		} else if (*Window)(unsafe.Pointer(pWin)).FregApp != 0 {
 108097 			Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pWin)).FregApp+1-bInverse, 1)
 108098 		} else if (*FuncDef)(unsafe.Pointer(pFunc)).FxSFunc != *(*uintptr)(unsafe.Pointer(&struct {
 108099 			f func(*libc.TLS, uintptr, int32, uintptr)
 108100 		}{noopStepFunc})) {
 108101 			var addrIf int32 = 0
 108102 			if (*Window)(unsafe.Pointer(pWin)).FpFilter != 0 {
 108103 				var regTmp int32
 108104 
 108105 				regTmp = Xsqlite3GetTempReg(tls, pParse)
 108106 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol+nArg, regTmp)
 108107 				addrIf = Xsqlite3VdbeAddOp3(tls, v, OP_IfNot, regTmp, 0, 1)
 108108 
 108109 				Xsqlite3ReleaseTempReg(tls, pParse, regTmp)
 108110 			}
 108111 
 108112 			if (*Window)(unsafe.Pointer(pWin)).FbExprArgs != 0 {
 108113 				var iOp int32 = Xsqlite3VdbeCurrentAddr(tls, v)
 108114 				var iEnd int32
 108115 
 108116 				nArg = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20)))).FnExpr
 108117 				regArg = Xsqlite3GetTempRange(tls, pParse, nArg)
 108118 				Xsqlite3ExprCodeExprList(tls, pParse, *(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20)), regArg, 0, uint8(0))
 108119 
 108120 				for iEnd = Xsqlite3VdbeCurrentAddr(tls, v); iOp < iEnd; iOp++ {
 108121 					var pOp uintptr = Xsqlite3VdbeGetOp(tls, v, iOp)
 108122 					if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column && (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 == (*Window)(unsafe.Pointer(pMWin)).FiEphCsr {
 108123 						(*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = csr
 108124 					}
 108125 				}
 108126 			}
 108127 			if (*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&U32(SQLITE_FUNC_NEEDCOLL) != 0 {
 108128 				var pColl uintptr
 108129 
 108130 				pColl = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20))+8)).FpExpr)
 108131 				Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, 0, 0, 0, pColl, -2)
 108132 			}
 108133 			Xsqlite3VdbeAddOp3(tls, v, func() int32 {
 108134 				if bInverse != 0 {
 108135 					return OP_AggInverse
 108136 				}
 108137 				return OP_AggStep
 108138 			}(),
 108139 				bInverse, regArg, (*Window)(unsafe.Pointer(pWin)).FregAccum)
 108140 			Xsqlite3VdbeAppendP4(tls, v, pFunc, -7)
 108141 			Xsqlite3VdbeChangeP5(tls, v, uint16(U8(nArg)))
 108142 			if (*Window)(unsafe.Pointer(pWin)).FbExprArgs != 0 {
 108143 				Xsqlite3ReleaseTempRange(tls, pParse, regArg, nArg)
 108144 			}
 108145 			if addrIf != 0 {
 108146 				Xsqlite3VdbeJumpHere(tls, v, addrIf)
 108147 			}
 108148 		}
 108149 	}
 108150 }
 108151 
 108152 func windowAggFinal(tls *libc.TLS, p uintptr, bFin int32) {
 108153 	var pParse uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpParse
 108154 	var pMWin uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpMWin
 108155 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 108156 	var pWin uintptr
 108157 
 108158 	for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108159 		if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0 &&
 108160 			(*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpWFunc)).FfuncFlags&U32(SQLITE_FUNC_MINMAX) != 0 &&
 108161 			int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED {
 108162 			Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108163 			Xsqlite3VdbeAddOp1(tls, v, OP_Last, (*Window)(unsafe.Pointer(pWin)).FcsrApp)
 108164 
 108165 			Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108166 			Xsqlite3VdbeJumpHere(tls, v, Xsqlite3VdbeCurrentAddr(tls, v)-2)
 108167 		} else if (*Window)(unsafe.Pointer(pWin)).FregApp != 0 {
 108168 		} else {
 108169 			var nArg int32 = windowArgCount(tls, pWin)
 108170 			if bFin != 0 {
 108171 				Xsqlite3VdbeAddOp2(tls, v, OP_AggFinal, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg)
 108172 				Xsqlite3VdbeAppendP4(tls, v, (*Window)(unsafe.Pointer(pWin)).FpWFunc, -7)
 108173 				Xsqlite3VdbeAddOp2(tls, v, OP_Copy, (*Window)(unsafe.Pointer(pWin)).FregAccum, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108174 				Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum)
 108175 			} else {
 108176 				Xsqlite3VdbeAddOp3(tls, v, OP_AggValue, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108177 				Xsqlite3VdbeAppendP4(tls, v, (*Window)(unsafe.Pointer(pWin)).FpWFunc, -7)
 108178 			}
 108179 		}
 108180 	}
 108181 }
 108182 
 108183 func windowFullScan(tls *libc.TLS, p uintptr) {
 108184 	var pWin uintptr
 108185 	var pParse uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpParse
 108186 	var pMWin uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpMWin
 108187 	var v uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpVdbe
 108188 
 108189 	var regCRowid int32 = 0
 108190 	var regCPeer int32 = 0
 108191 	var regRowid int32 = 0
 108192 	var regPeer int32 = 0
 108193 
 108194 	var nPeer int32
 108195 	var lblNext int32
 108196 	var lblBrk int32
 108197 	var addrNext int32
 108198 	var csr int32
 108199 
 108200 	csr = (*Window)(unsafe.Pointer(pMWin)).FcsrApp
 108201 	nPeer = func() int32 {
 108202 		if (*Window)(unsafe.Pointer(pMWin)).FpOrderBy != 0 {
 108203 			return (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pMWin)).FpOrderBy)).FnExpr
 108204 		}
 108205 		return 0
 108206 	}()
 108207 
 108208 	lblNext = Xsqlite3VdbeMakeLabel(tls, pParse)
 108209 	lblBrk = Xsqlite3VdbeMakeLabel(tls, pParse)
 108210 
 108211 	regCRowid = Xsqlite3GetTempReg(tls, pParse)
 108212 	regRowid = Xsqlite3GetTempReg(tls, pParse)
 108213 	if nPeer != 0 {
 108214 		regCPeer = Xsqlite3GetTempRange(tls, pParse, nPeer)
 108215 		regPeer = Xsqlite3GetTempRange(tls, pParse, nPeer)
 108216 	}
 108217 
 108218 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCRowid)
 108219 	windowReadPeerValues(tls, p, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCPeer)
 108220 
 108221 	for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108222 		Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum)
 108223 	}
 108224 
 108225 	Xsqlite3VdbeAddOp3(tls, v, OP_SeekGE, csr, lblBrk, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid)
 108226 
 108227 	addrNext = Xsqlite3VdbeCurrentAddr(tls, v)
 108228 	Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, csr, regRowid)
 108229 	Xsqlite3VdbeAddOp3(tls, v, OP_Gt, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, lblBrk, regRowid)
 108230 
 108231 	if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == TK_CURRENT {
 108232 		Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regCRowid, lblNext, regRowid)
 108233 
 108234 	} else if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) != TK_NO {
 108235 		var addr int32
 108236 		var addrEq int32 = 0
 108237 		var pKeyInfo uintptr = uintptr(0)
 108238 
 108239 		if (*Window)(unsafe.Pointer(pMWin)).FpOrderBy != 0 {
 108240 			pKeyInfo = Xsqlite3KeyInfoFromExprList(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpOrderBy, 0, 0)
 108241 		}
 108242 		if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == TK_TIES {
 108243 			addrEq = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regCRowid, 0, regRowid)
 108244 
 108245 		}
 108246 		if pKeyInfo != 0 {
 108247 			windowReadPeerValues(tls, p, csr, regPeer)
 108248 			Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regPeer, regCPeer, nPeer)
 108249 			Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -8)
 108250 			addr = Xsqlite3VdbeCurrentAddr(tls, v) + 1
 108251 			Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addr, lblNext, addr)
 108252 
 108253 		} else {
 108254 			Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblNext)
 108255 		}
 108256 		if addrEq != 0 {
 108257 			Xsqlite3VdbeJumpHere(tls, v, addrEq)
 108258 		}
 108259 	}
 108260 
 108261 	windowAggStep(tls, p, pMWin, csr, 0, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg)
 108262 
 108263 	Xsqlite3VdbeResolveLabel(tls, v, lblNext)
 108264 	Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, addrNext)
 108265 
 108266 	Xsqlite3VdbeJumpHere(tls, v, addrNext-1)
 108267 	Xsqlite3VdbeJumpHere(tls, v, addrNext+1)
 108268 	Xsqlite3ReleaseTempReg(tls, pParse, regRowid)
 108269 	Xsqlite3ReleaseTempReg(tls, pParse, regCRowid)
 108270 	if nPeer != 0 {
 108271 		Xsqlite3ReleaseTempRange(tls, pParse, regPeer, nPeer)
 108272 		Xsqlite3ReleaseTempRange(tls, pParse, regCPeer, nPeer)
 108273 	}
 108274 
 108275 	windowAggFinal(tls, p, 1)
 108276 
 108277 }
 108278 
 108279 func windowReturnOneRow(tls *libc.TLS, p uintptr) {
 108280 	var pMWin uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpMWin
 108281 	var v uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpVdbe
 108282 
 108283 	if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 {
 108284 		windowFullScan(tls, p)
 108285 	} else {
 108286 		var pParse uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpParse
 108287 		var pWin uintptr
 108288 
 108289 		for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108290 			var pFunc uintptr = (*Window)(unsafe.Pointer(pWin)).FpWFunc
 108291 
 108292 			if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) ||
 108293 				(*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&first_valueName)) {
 108294 				var csr int32 = (*Window)(unsafe.Pointer(pWin)).FcsrApp
 108295 				var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
 108296 				var tmpReg int32 = Xsqlite3GetTempReg(tls, pParse)
 108297 				Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108298 
 108299 				if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) {
 108300 					Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, (*Window)(unsafe.Pointer(pWin)).FiArgCol+1, tmpReg)
 108301 					windowCheckValue(tls, pParse, tmpReg, 2)
 108302 				} else {
 108303 					Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, tmpReg)
 108304 				}
 108305 				Xsqlite3VdbeAddOp3(tls, v, OP_Add, tmpReg, (*Window)(unsafe.Pointer(pWin)).FregApp, tmpReg)
 108306 				Xsqlite3VdbeAddOp3(tls, v, OP_Gt, (*Window)(unsafe.Pointer(pWin)).FregApp+1, lbl, tmpReg)
 108307 
 108308 				Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, csr, 0, tmpReg)
 108309 
 108310 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108311 				Xsqlite3VdbeResolveLabel(tls, v, lbl)
 108312 				Xsqlite3ReleaseTempReg(tls, pParse, tmpReg)
 108313 			} else if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) || (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&lagName)) {
 108314 				var nArg int32 = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 20)))).FnExpr
 108315 				var csr int32 = (*Window)(unsafe.Pointer(pWin)).FcsrApp
 108316 				var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
 108317 				var tmpReg int32 = Xsqlite3GetTempReg(tls, pParse)
 108318 				var iEph int32 = (*Window)(unsafe.Pointer(pMWin)).FiEphCsr
 108319 
 108320 				if nArg < 3 {
 108321 					Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108322 				} else {
 108323 					Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, (*Window)(unsafe.Pointer(pWin)).FiArgCol+2, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108324 				}
 108325 				Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, tmpReg)
 108326 				if nArg < 2 {
 108327 					var val int32 = func() int32 {
 108328 						if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) {
 108329 							return 1
 108330 						}
 108331 						return -1
 108332 					}()
 108333 					Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, tmpReg, val)
 108334 				} else {
 108335 					var op int32 = func() int32 {
 108336 						if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) {
 108337 							return OP_Add
 108338 						}
 108339 						return OP_Subtract
 108340 					}()
 108341 					var tmpReg2 int32 = Xsqlite3GetTempReg(tls, pParse)
 108342 					Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, (*Window)(unsafe.Pointer(pWin)).FiArgCol+1, tmpReg2)
 108343 					Xsqlite3VdbeAddOp3(tls, v, op, tmpReg2, tmpReg, tmpReg)
 108344 					Xsqlite3ReleaseTempReg(tls, pParse, tmpReg2)
 108345 				}
 108346 
 108347 				Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, csr, lbl, tmpReg)
 108348 
 108349 				Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult)
 108350 				Xsqlite3VdbeResolveLabel(tls, v, lbl)
 108351 				Xsqlite3ReleaseTempReg(tls, pParse, tmpReg)
 108352 			}
 108353 		}
 108354 	}
 108355 	Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WindowCodeArg)(unsafe.Pointer(p)).FregGosub, (*WindowCodeArg)(unsafe.Pointer(p)).FaddrGosub)
 108356 }
 108357 
 108358 func windowInitAccum(tls *libc.TLS, pParse uintptr, pMWin uintptr) int32 {
 108359 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 108360 	var regArg int32
 108361 	var nArg int32 = 0
 108362 	var pWin uintptr
 108363 	for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108364 		var pFunc uintptr = (*Window)(unsafe.Pointer(pWin)).FpWFunc
 108365 
 108366 		Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum)
 108367 		nArg = func() int32 {
 108368 			if nArg > windowArgCount(tls, pWin) {
 108369 				return nArg
 108370 			}
 108371 			return windowArgCount(tls, pWin)
 108372 		}()
 108373 		if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0 {
 108374 			if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) || (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&first_valueName)) {
 108375 				Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pWin)).FregApp)
 108376 				Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pWin)).FregApp+1)
 108377 			}
 108378 
 108379 			if (*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags&U32(SQLITE_FUNC_MINMAX) != 0 && (*Window)(unsafe.Pointer(pWin)).FcsrApp != 0 {
 108380 				Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*Window)(unsafe.Pointer(pWin)).FcsrApp)
 108381 				Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pWin)).FregApp+1)
 108382 			}
 108383 		}
 108384 	}
 108385 	regArg = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 108386 	*(*int32)(unsafe.Pointer(pParse + 44)) += nArg
 108387 	return regArg
 108388 }
 108389 
 108390 func windowCacheFrame(tls *libc.TLS, pMWin uintptr) int32 {
 108391 	var pWin uintptr
 108392 	if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 {
 108393 		return 1
 108394 	}
 108395 	for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108396 		var pFunc uintptr = (*Window)(unsafe.Pointer(pWin)).FpWFunc
 108397 		if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) ||
 108398 			(*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&first_valueName)) ||
 108399 			(*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) ||
 108400 			(*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&lagName)) {
 108401 			return 1
 108402 		}
 108403 	}
 108404 	return 0
 108405 }
 108406 
 108407 func windowIfNewPeer(tls *libc.TLS, pParse uintptr, pOrderBy uintptr, regNew int32, regOld int32, addr int32) {
 108408 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 108409 	if pOrderBy != 0 {
 108410 		var nVal int32 = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr
 108411 		var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, pOrderBy, 0, 0)
 108412 		Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regOld, regNew, nVal)
 108413 		Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -8)
 108414 		Xsqlite3VdbeAddOp3(tls, v, OP_Jump,
 108415 			Xsqlite3VdbeCurrentAddr(tls, v)+1, addr, Xsqlite3VdbeCurrentAddr(tls, v)+1)
 108416 
 108417 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNew, regOld, nVal-1)
 108418 	} else {
 108419 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addr)
 108420 	}
 108421 }
 108422 
 108423 func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal int32, csr2 int32, lbl int32) {
 108424 	var pParse uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpParse
 108425 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 108426 	var pOrderBy uintptr = (*Window)(unsafe.Pointer((*WindowCodeArg)(unsafe.Pointer(p)).FpMWin)).FpOrderBy
 108427 	var reg1 int32 = Xsqlite3GetTempReg(tls, pParse)
 108428 	var reg2 int32 = Xsqlite3GetTempReg(tls, pParse)
 108429 	var regString int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 108430 	var arith int32 = OP_Add
 108431 	var addrGe int32
 108432 	var addrDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
 108433 	var pColl uintptr
 108434 
 108435 	windowReadPeerValues(tls, p, csr1, reg1)
 108436 	windowReadPeerValues(tls, p, csr2, reg2)
 108437 
 108438 	if int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8)).Ffg.FsortFlags)&KEYINFO_ORDER_DESC != 0 {
 108439 		switch op {
 108440 		case OP_Ge:
 108441 			op = OP_Le
 108442 			break
 108443 			fallthrough
 108444 		case OP_Gt:
 108445 			op = OP_Lt
 108446 			break
 108447 			fallthrough
 108448 		default:
 108449 			op = OP_Ge
 108450 			break
 108451 		}
 108452 		arith = OP_Subtract
 108453 	}
 108454 
 108455 	if int32((*ExprList_item)(unsafe.Pointer(pOrderBy+8)).Ffg.FsortFlags)&KEYINFO_ORDER_BIGNULL != 0 {
 108456 		var addr int32 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, reg1)
 108457 		switch op {
 108458 		case OP_Ge:
 108459 			Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lbl)
 108460 			break
 108461 			fallthrough
 108462 		case OP_Gt:
 108463 			Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, reg2, lbl)
 108464 
 108465 			break
 108466 			fallthrough
 108467 		case OP_Le:
 108468 			Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, reg2, lbl)
 108469 
 108470 			break
 108471 			fallthrough
 108472 		default:
 108473 			break
 108474 		}
 108475 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrDone)
 108476 
 108477 		Xsqlite3VdbeJumpHere(tls, v, addr)
 108478 		Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, reg2,
 108479 			func() int32 {
 108480 				if op == OP_Gt || op == OP_Ge {
 108481 					return addrDone
 108482 				}
 108483 				return lbl
 108484 			}())
 108485 
 108486 	}
 108487 
 108488 	Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, regString, 0, ts+1554, -1)
 108489 	addrGe = Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regString, 0, reg1)
 108490 
 108491 	if op == OP_Ge && arith == OP_Add || op == OP_Le && arith == OP_Subtract {
 108492 		Xsqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1)
 108493 	}
 108494 	Xsqlite3VdbeAddOp3(tls, v, arith, regVal, reg1, reg1)
 108495 	Xsqlite3VdbeJumpHere(tls, v, addrGe)
 108496 
 108497 	Xsqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1)
 108498 	pColl = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(pOrderBy+8)).FpExpr)
 108499 	Xsqlite3VdbeAppendP4(tls, v, pColl, -2)
 108500 	Xsqlite3VdbeChangeP5(tls, v, uint16(SQLITE_NULLEQ))
 108501 	Xsqlite3VdbeResolveLabel(tls, v, addrDone)
 108502 
 108503 	Xsqlite3ReleaseTempReg(tls, pParse, reg1)
 108504 	Xsqlite3ReleaseTempReg(tls, pParse, reg2)
 108505 
 108506 }
 108507 
 108508 func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOnEof int32) int32 {
 108509 	var csr int32
 108510 	var reg int32
 108511 	var pParse uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpParse
 108512 	var pMWin uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpMWin
 108513 	var ret int32 = 0
 108514 	var v uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpVdbe
 108515 	var addrContinue int32 = 0
 108516 	var bPeer int32 = libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_ROWS)
 108517 
 108518 	var lblDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
 108519 	var addrNextRange int32 = 0
 108520 
 108521 	if op == WINDOW_AGGINVERSE && int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_UNBOUNDED {
 108522 		return 0
 108523 	}
 108524 
 108525 	if regCountdown > 0 {
 108526 		if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 108527 			addrNextRange = Xsqlite3VdbeCurrentAddr(tls, v)
 108528 
 108529 			if op == WINDOW_AGGINVERSE {
 108530 				if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING {
 108531 					windowCodeRangeTest(tls,
 108532 						p, OP_Le, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, lblDone)
 108533 				} else {
 108534 					windowCodeRangeTest(tls,
 108535 						p, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone)
 108536 				}
 108537 			} else {
 108538 				windowCodeRangeTest(tls,
 108539 					p, OP_Gt, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone)
 108540 			}
 108541 		} else {
 108542 			Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, regCountdown, lblDone, 1)
 108543 
 108544 		}
 108545 	}
 108546 
 108547 	if op == WINDOW_RETURN_ROW && (*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0 {
 108548 		windowAggFinal(tls, p, 0)
 108549 	}
 108550 	addrContinue = Xsqlite3VdbeCurrentAddr(tls, v)
 108551 
 108552 	if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) && regCountdown != 0 &&
 108553 		int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 108554 		var regRowid1 int32 = Xsqlite3GetTempReg(tls, pParse)
 108555 		var regRowid2 int32 = Xsqlite3GetTempReg(tls, pParse)
 108556 		if op == WINDOW_AGGINVERSE {
 108557 			Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regRowid1)
 108558 			Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid2)
 108559 			Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regRowid2, lblDone, regRowid1)
 108560 
 108561 		} else if (*WindowCodeArg)(unsafe.Pointer(p)).FregRowid != 0 {
 108562 			Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid1)
 108563 			Xsqlite3VdbeAddOp3(tls, v, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(p)).FregRowid, lblDone, regRowid1)
 108564 
 108565 		}
 108566 		Xsqlite3ReleaseTempReg(tls, pParse, regRowid1)
 108567 		Xsqlite3ReleaseTempReg(tls, pParse, regRowid2)
 108568 
 108569 	}
 108570 
 108571 	switch op {
 108572 	case WINDOW_RETURN_ROW:
 108573 		csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr
 108574 		reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Freg
 108575 		windowReturnOneRow(tls, p)
 108576 		break
 108577 
 108578 	case WINDOW_AGGINVERSE:
 108579 		csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr
 108580 		reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Freg
 108581 		if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 {
 108582 			Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid, 1)
 108583 		} else {
 108584 			windowAggStep(tls, p, pMWin, csr, 1, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg)
 108585 		}
 108586 		break
 108587 
 108588 	default:
 108589 		csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr
 108590 		reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Freg
 108591 		if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 {
 108592 			Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, 1)
 108593 		} else {
 108594 			windowAggStep(tls, p, pMWin, csr, 0, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg)
 108595 		}
 108596 		break
 108597 	}
 108598 
 108599 	if op == (*WindowCodeArg)(unsafe.Pointer(p)).FeDelete {
 108600 		Xsqlite3VdbeAddOp1(tls, v, OP_Delete, csr)
 108601 		Xsqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_SAVEPOSITION))
 108602 	}
 108603 
 108604 	if jumpOnEof != 0 {
 108605 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, Xsqlite3VdbeCurrentAddr(tls, v)+2)
 108606 
 108607 		ret = Xsqlite3VdbeAddOp0(tls, v, OP_Goto)
 108608 	} else {
 108609 		Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, Xsqlite3VdbeCurrentAddr(tls, v)+1+bPeer)
 108610 
 108611 		if bPeer != 0 {
 108612 			Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblDone)
 108613 		}
 108614 	}
 108615 
 108616 	if bPeer != 0 {
 108617 		var nReg int32 = func() int32 {
 108618 			if (*Window)(unsafe.Pointer(pMWin)).FpOrderBy != 0 {
 108619 				return (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pMWin)).FpOrderBy)).FnExpr
 108620 			}
 108621 			return 0
 108622 		}()
 108623 		var regTmp int32 = func() int32 {
 108624 			if nReg != 0 {
 108625 				return Xsqlite3GetTempRange(tls, pParse, nReg)
 108626 			}
 108627 			return 0
 108628 		}()
 108629 		windowReadPeerValues(tls, p, csr, regTmp)
 108630 		windowIfNewPeer(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpOrderBy, regTmp, reg, addrContinue)
 108631 		Xsqlite3ReleaseTempRange(tls, pParse, regTmp, nReg)
 108632 	}
 108633 
 108634 	if addrNextRange != 0 {
 108635 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrNextRange)
 108636 	}
 108637 	Xsqlite3VdbeResolveLabel(tls, v, lblDone)
 108638 	return ret
 108639 }
 108640 
 108641 // Allocate and return a duplicate of the Window object indicated by the
 108642 // third argument. Set the Window.pOwner field of the new object to
 108643 // pOwner.
 108644 func Xsqlite3WindowDup(tls *libc.TLS, db uintptr, pOwner uintptr, p uintptr) uintptr {
 108645 	var pNew uintptr = uintptr(0)
 108646 	if p != 0 {
 108647 		pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Window{})))
 108648 		if pNew != 0 {
 108649 			(*Window)(unsafe.Pointer(pNew)).FzName = Xsqlite3DbStrDup(tls, db, (*Window)(unsafe.Pointer(p)).FzName)
 108650 			(*Window)(unsafe.Pointer(pNew)).FzBase = Xsqlite3DbStrDup(tls, db, (*Window)(unsafe.Pointer(p)).FzBase)
 108651 			(*Window)(unsafe.Pointer(pNew)).FpFilter = Xsqlite3ExprDup(tls, db, (*Window)(unsafe.Pointer(p)).FpFilter, 0)
 108652 			(*Window)(unsafe.Pointer(pNew)).FpWFunc = (*Window)(unsafe.Pointer(p)).FpWFunc
 108653 			(*Window)(unsafe.Pointer(pNew)).FpPartition = Xsqlite3ExprListDup(tls, db, (*Window)(unsafe.Pointer(p)).FpPartition, 0)
 108654 			(*Window)(unsafe.Pointer(pNew)).FpOrderBy = Xsqlite3ExprListDup(tls, db, (*Window)(unsafe.Pointer(p)).FpOrderBy, 0)
 108655 			(*Window)(unsafe.Pointer(pNew)).FeFrmType = (*Window)(unsafe.Pointer(p)).FeFrmType
 108656 			(*Window)(unsafe.Pointer(pNew)).FeEnd = (*Window)(unsafe.Pointer(p)).FeEnd
 108657 			(*Window)(unsafe.Pointer(pNew)).FeStart = (*Window)(unsafe.Pointer(p)).FeStart
 108658 			(*Window)(unsafe.Pointer(pNew)).FeExclude = (*Window)(unsafe.Pointer(p)).FeExclude
 108659 			(*Window)(unsafe.Pointer(pNew)).FregResult = (*Window)(unsafe.Pointer(p)).FregResult
 108660 			(*Window)(unsafe.Pointer(pNew)).FregAccum = (*Window)(unsafe.Pointer(p)).FregAccum
 108661 			(*Window)(unsafe.Pointer(pNew)).FiArgCol = (*Window)(unsafe.Pointer(p)).FiArgCol
 108662 			(*Window)(unsafe.Pointer(pNew)).FiEphCsr = (*Window)(unsafe.Pointer(p)).FiEphCsr
 108663 			(*Window)(unsafe.Pointer(pNew)).FbExprArgs = (*Window)(unsafe.Pointer(p)).FbExprArgs
 108664 			(*Window)(unsafe.Pointer(pNew)).FpStart = Xsqlite3ExprDup(tls, db, (*Window)(unsafe.Pointer(p)).FpStart, 0)
 108665 			(*Window)(unsafe.Pointer(pNew)).FpEnd = Xsqlite3ExprDup(tls, db, (*Window)(unsafe.Pointer(p)).FpEnd, 0)
 108666 			(*Window)(unsafe.Pointer(pNew)).FpOwner = pOwner
 108667 			(*Window)(unsafe.Pointer(pNew)).FbImplicitFrame = (*Window)(unsafe.Pointer(p)).FbImplicitFrame
 108668 		}
 108669 	}
 108670 	return pNew
 108671 }
 108672 
 108673 // Return a copy of the linked list of Window objects passed as the
 108674 // second argument.
 108675 func Xsqlite3WindowListDup(tls *libc.TLS, db uintptr, p uintptr) uintptr {
 108676 	bp := tls.Alloc(4)
 108677 	defer tls.Free(4)
 108678 
 108679 	var pWin uintptr
 108680 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 108681 	var pp uintptr = bp
 108682 
 108683 	for pWin = p; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin {
 108684 		*(*uintptr)(unsafe.Pointer(pp)) = Xsqlite3WindowDup(tls, db, uintptr(0), pWin)
 108685 		if *(*uintptr)(unsafe.Pointer(pp)) == uintptr(0) {
 108686 			break
 108687 		}
 108688 		pp = *(*uintptr)(unsafe.Pointer(pp)) + 36
 108689 	}
 108690 
 108691 	return *(*uintptr)(unsafe.Pointer(bp))
 108692 }
 108693 
 108694 func windowExprGtZero(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 {
 108695 	bp := tls.Alloc(4)
 108696 	defer tls.Free(4)
 108697 
 108698 	var ret int32 = 0
 108699 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 108700 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 108701 	Xsqlite3ValueFromExpr(tls, db, pExpr, (*Sqlite3)(unsafe.Pointer(db)).Fenc, uint8(SQLITE_AFF_NUMERIC), bp)
 108702 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 && Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(bp))) > 0 {
 108703 		ret = 1
 108704 	}
 108705 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
 108706 	return ret
 108707 }
 108708 
 108709 // sqlite3WhereBegin() has already been called for the SELECT statement
 108710 // passed as the second argument when this function is invoked. It generates
 108711 // code to populate the Window.regResult register for each window function
 108712 // and invoke the sub-routine at instruction addrGosub once for each row.
 108713 // sqlite3WhereEnd() is always called before returning.
 108714 //
 108715 // This function handles several different types of window frames, which
 108716 // require slightly different processing. The following pseudo code is
 108717 // used to implement window frames of the form:
 108718 //
 108719 //	ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
 108720 //
 108721 // Other window frame types use variants of the following:
 108722 //
 108723 //	... loop started by sqlite3WhereBegin() ...
 108724 //	  if( new partition ){
 108725 //	    Gosub flush
 108726 //	  }
 108727 //	  Insert new row into eph table.
 108728 //
 108729 //	  if( first row of partition ){
 108730 //	    // Rewind three cursors, all open on the eph table.
 108731 //	    Rewind(csrEnd);
 108732 //	    Rewind(csrStart);
 108733 //	    Rewind(csrCurrent);
 108734 //
 108735 //	    regEnd = <expr2>          // FOLLOWING expression
 108736 //	    regStart = <expr1>        // PRECEDING expression
 108737 //	  }else{
 108738 //	    // First time this branch is taken, the eph table contains two
 108739 //	    // rows. The first row in the partition, which all three cursors
 108740 //	    // currently point to, and the following row.
 108741 //	    AGGSTEP
 108742 //	    if( (regEnd--)<=0 ){
 108743 //	      RETURN_ROW
 108744 //	      if( (regStart--)<=0 ){
 108745 //	        AGGINVERSE
 108746 //	      }
 108747 //	    }
 108748 //	  }
 108749 //	}
 108750 //	flush:
 108751 //	  AGGSTEP
 108752 //	  while( 1 ){
 108753 //	    RETURN ROW
 108754 //	    if( csrCurrent is EOF ) break;
 108755 //	    if( (regStart--)<=0 ){
 108756 //	      AggInverse(csrStart)
 108757 //	      Next(csrStart)
 108758 //	    }
 108759 //	  }
 108760 //
 108761 // The pseudo-code above uses the following shorthand:
 108762 //
 108763 //	AGGSTEP:    invoke the aggregate xStep() function for each window function
 108764 //	            with arguments read from the current row of cursor csrEnd, then
 108765 //	            step cursor csrEnd forward one row (i.e. sqlite3BtreeNext()).
 108766 //
 108767 //	RETURN_ROW: return a row to the caller based on the contents of the
 108768 //	            current row of csrCurrent and the current state of all
 108769 //	            aggregates. Then step cursor csrCurrent forward one row.
 108770 //
 108771 //	AGGINVERSE: invoke the aggregate xInverse() function for each window
 108772 //	            functions with arguments read from the current row of cursor
 108773 //	            csrStart. Then step csrStart forward one row.
 108774 //
 108775 // There are two other ROWS window frames that are handled significantly
 108776 // differently from the above - "BETWEEN <expr> PRECEDING AND <expr> PRECEDING"
 108777 // and "BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING". These are special
 108778 // cases because they change the order in which the three cursors (csrStart,
 108779 // csrCurrent and csrEnd) iterate through the ephemeral table. Cases that
 108780 // use UNBOUNDED or CURRENT ROW are much simpler variations on one of these
 108781 // three.
 108782 //
 108783 //	ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
 108784 //
 108785 //	  ... loop started by sqlite3WhereBegin() ...
 108786 //	    if( new partition ){
 108787 //	      Gosub flush
 108788 //	    }
 108789 //	    Insert new row into eph table.
 108790 //	    if( first row of partition ){
 108791 //	      Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108792 //	      regEnd = <expr2>
 108793 //	      regStart = <expr1>
 108794 //	    }else{
 108795 //	      if( (regEnd--)<=0 ){
 108796 //	        AGGSTEP
 108797 //	      }
 108798 //	      RETURN_ROW
 108799 //	      if( (regStart--)<=0 ){
 108800 //	        AGGINVERSE
 108801 //	      }
 108802 //	    }
 108803 //	  }
 108804 //	  flush:
 108805 //	    if( (regEnd--)<=0 ){
 108806 //	      AGGSTEP
 108807 //	    }
 108808 //	    RETURN_ROW
 108809 //
 108810 //
 108811 //	ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
 108812 //
 108813 //	  ... loop started by sqlite3WhereBegin() ...
 108814 //	  if( new partition ){
 108815 //	    Gosub flush
 108816 //	  }
 108817 //	  Insert new row into eph table.
 108818 //	  if( first row of partition ){
 108819 //	    Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108820 //	    regEnd = <expr2>
 108821 //	    regStart = regEnd - <expr1>
 108822 //	  }else{
 108823 //	    AGGSTEP
 108824 //	    if( (regEnd--)<=0 ){
 108825 //	      RETURN_ROW
 108826 //	    }
 108827 //	    if( (regStart--)<=0 ){
 108828 //	      AGGINVERSE
 108829 //	    }
 108830 //	  }
 108831 //	}
 108832 //	flush:
 108833 //	  AGGSTEP
 108834 //	  while( 1 ){
 108835 //	    if( (regEnd--)<=0 ){
 108836 //	      RETURN_ROW
 108837 //	      if( eof ) break;
 108838 //	    }
 108839 //	    if( (regStart--)<=0 ){
 108840 //	      AGGINVERSE
 108841 //	      if( eof ) break
 108842 //	    }
 108843 //	  }
 108844 //	  while( !eof csrCurrent ){
 108845 //	    RETURN_ROW
 108846 //	  }
 108847 //
 108848 // For the most part, the patterns above are adapted to support UNBOUNDED by
 108849 // assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and
 108850 // CURRENT ROW by assuming that it is equivilent to "0 PRECEDING/FOLLOWING".
 108851 // This is optimized of course - branches that will never be taken and
 108852 // conditions that are always true are omitted from the VM code. The only
 108853 // exceptional case is:
 108854 //
 108855 //	ROWS BETWEEN <expr1> FOLLOWING AND UNBOUNDED FOLLOWING
 108856 //
 108857 //	  ... loop started by sqlite3WhereBegin() ...
 108858 //	  if( new partition ){
 108859 //	    Gosub flush
 108860 //	  }
 108861 //	  Insert new row into eph table.
 108862 //	  if( first row of partition ){
 108863 //	    Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108864 //	    regStart = <expr1>
 108865 //	  }else{
 108866 //	    AGGSTEP
 108867 //	  }
 108868 //	}
 108869 //	flush:
 108870 //	  AGGSTEP
 108871 //	  while( 1 ){
 108872 //	    if( (regStart--)<=0 ){
 108873 //	      AGGINVERSE
 108874 //	      if( eof ) break
 108875 //	    }
 108876 //	    RETURN_ROW
 108877 //	  }
 108878 //	  while( !eof csrCurrent ){
 108879 //	    RETURN_ROW
 108880 //	  }
 108881 //
 108882 // Also requiring special handling are the cases:
 108883 //
 108884 //	ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
 108885 //	ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
 108886 //
 108887 // when (expr1 < expr2). This is detected at runtime, not by this function.
 108888 // To handle this case, the pseudo-code programs depicted above are modified
 108889 // slightly to be:
 108890 //
 108891 //	... loop started by sqlite3WhereBegin() ...
 108892 //	if( new partition ){
 108893 //	  Gosub flush
 108894 //	}
 108895 //	Insert new row into eph table.
 108896 //	if( first row of partition ){
 108897 //	  Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108898 //	  regEnd = <expr2>
 108899 //	  regStart = <expr1>
 108900 //	  if( regEnd < regStart ){
 108901 //	    RETURN_ROW
 108902 //	    delete eph table contents
 108903 //	    continue
 108904 //	  }
 108905 //	...
 108906 //
 108907 // The new "continue" statement in the above jumps to the next iteration
 108908 // of the outer loop - the one started by sqlite3WhereBegin().
 108909 //
 108910 // The various GROUPS cases are implemented using the same patterns as
 108911 // ROWS. The VM code is modified slightly so that:
 108912 //
 108913 //  1. The else branch in the main loop is only taken if the row just
 108914 //     added to the ephemeral table is the start of a new group. In
 108915 //     other words, it becomes:
 108916 //
 108917 //     ... loop started by sqlite3WhereBegin() ...
 108918 //     if( new partition ){
 108919 //     Gosub flush
 108920 //     }
 108921 //     Insert new row into eph table.
 108922 //     if( first row of partition ){
 108923 //     Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108924 //     regEnd = <expr2>
 108925 //     regStart = <expr1>
 108926 //     }else if( new group ){
 108927 //     ...
 108928 //     }
 108929 //     }
 108930 //
 108931 //  2. Instead of processing a single row, each RETURN_ROW, AGGSTEP or
 108932 //     AGGINVERSE step processes the current row of the relevant cursor and
 108933 //     all subsequent rows belonging to the same group.
 108934 //
 108935 // RANGE window frames are a little different again. As for GROUPS, the
 108936 // main loop runs once per group only. And RETURN_ROW, AGGSTEP and AGGINVERSE
 108937 // deal in groups instead of rows. As for ROWS and GROUPS, there are three
 108938 // basic cases:
 108939 //
 108940 //	RANGE BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
 108941 //
 108942 //	  ... loop started by sqlite3WhereBegin() ...
 108943 //	    if( new partition ){
 108944 //	      Gosub flush
 108945 //	    }
 108946 //	    Insert new row into eph table.
 108947 //	    if( first row of partition ){
 108948 //	      Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108949 //	      regEnd = <expr2>
 108950 //	      regStart = <expr1>
 108951 //	    }else{
 108952 //	      AGGSTEP
 108953 //	      while( (csrCurrent.key + regEnd) < csrEnd.key ){
 108954 //	        RETURN_ROW
 108955 //	        while( csrStart.key + regStart) < csrCurrent.key ){
 108956 //	          AGGINVERSE
 108957 //	        }
 108958 //	      }
 108959 //	    }
 108960 //	  }
 108961 //	  flush:
 108962 //	    AGGSTEP
 108963 //	    while( 1 ){
 108964 //	      RETURN ROW
 108965 //	      if( csrCurrent is EOF ) break;
 108966 //	        while( csrStart.key + regStart) < csrCurrent.key ){
 108967 //	          AGGINVERSE
 108968 //	        }
 108969 //	      }
 108970 //	    }
 108971 //
 108972 // In the above notation, "csr.key" means the current value of the ORDER BY
 108973 // expression (there is only ever 1 for a RANGE that uses an <expr> FOLLOWING
 108974 // or <expr PRECEDING) read from cursor csr.
 108975 //
 108976 //	RANGE BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
 108977 //
 108978 //	  ... loop started by sqlite3WhereBegin() ...
 108979 //	    if( new partition ){
 108980 //	      Gosub flush
 108981 //	    }
 108982 //	    Insert new row into eph table.
 108983 //	    if( first row of partition ){
 108984 //	      Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 108985 //	      regEnd = <expr2>
 108986 //	      regStart = <expr1>
 108987 //	    }else{
 108988 //	      while( (csrEnd.key + regEnd) <= csrCurrent.key ){
 108989 //	        AGGSTEP
 108990 //	      }
 108991 //	      while( (csrStart.key + regStart) < csrCurrent.key ){
 108992 //	        AGGINVERSE
 108993 //	      }
 108994 //	      RETURN_ROW
 108995 //	    }
 108996 //	  }
 108997 //	  flush:
 108998 //	    while( (csrEnd.key + regEnd) <= csrCurrent.key ){
 108999 //	      AGGSTEP
 109000 //	    }
 109001 //	    while( (csrStart.key + regStart) < csrCurrent.key ){
 109002 //	      AGGINVERSE
 109003 //	    }
 109004 //	    RETURN_ROW
 109005 //
 109006 //	RANGE BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
 109007 //
 109008 //	  ... loop started by sqlite3WhereBegin() ...
 109009 //	    if( new partition ){
 109010 //	      Gosub flush
 109011 //	    }
 109012 //	    Insert new row into eph table.
 109013 //	    if( first row of partition ){
 109014 //	      Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
 109015 //	      regEnd = <expr2>
 109016 //	      regStart = <expr1>
 109017 //	    }else{
 109018 //	      AGGSTEP
 109019 //	      while( (csrCurrent.key + regEnd) < csrEnd.key ){
 109020 //	        while( (csrCurrent.key + regStart) > csrStart.key ){
 109021 //	          AGGINVERSE
 109022 //	        }
 109023 //	        RETURN_ROW
 109024 //	      }
 109025 //	    }
 109026 //	  }
 109027 //	  flush:
 109028 //	    AGGSTEP
 109029 //	    while( 1 ){
 109030 //	      while( (csrCurrent.key + regStart) > csrStart.key ){
 109031 //	        AGGINVERSE
 109032 //	        if( eof ) break "while( 1 )" loop.
 109033 //	      }
 109034 //	      RETURN_ROW
 109035 //	    }
 109036 //	    while( !eof csrCurrent ){
 109037 //	      RETURN_ROW
 109038 //	    }
 109039 //
 109040 // The text above leaves out many details. Refer to the code and comments
 109041 // below for a more complete picture.
 109042 func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uintptr, regGosub int32, addrGosub int32) {
 109043 	bp := tls.Alloc(56)
 109044 	defer tls.Free(56)
 109045 
 109046 	var pMWin uintptr = (*Select)(unsafe.Pointer(p)).FpWin
 109047 	var pOrderBy uintptr = (*Window)(unsafe.Pointer(pMWin)).FpOrderBy
 109048 	var v uintptr = Xsqlite3GetVdbe(tls, pParse)
 109049 	var csrWrite int32
 109050 	var csrInput int32 = (*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FiCursor
 109051 	var nInput int32 = int32((*Table)(unsafe.Pointer((*SrcItem)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc + 8)).FpTab)).FnCol)
 109052 	var iInput int32
 109053 	var addrNe int32
 109054 	var addrGosubFlush int32 = 0
 109055 	var addrInteger int32 = 0
 109056 	var addrEmpty int32
 109057 	var regNew int32
 109058 	var regRecord int32
 109059 	var regNewPeer int32 = 0
 109060 	var regPeer int32 = 0
 109061 	var regFlushPart int32 = 0
 109062 
 109063 	var lblWhereEnd int32
 109064 	var regStart int32 = 0
 109065 	var regEnd int32 = 0
 109066 
 109067 	lblWhereEnd = Xsqlite3VdbeMakeLabel(tls, pParse)
 109068 
 109069 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(WindowCodeArg{})))
 109070 	(*WindowCodeArg)(unsafe.Pointer(bp)).FpParse = pParse
 109071 	(*WindowCodeArg)(unsafe.Pointer(bp)).FpMWin = pMWin
 109072 	(*WindowCodeArg)(unsafe.Pointer(bp)).FpVdbe = v
 109073 	(*WindowCodeArg)(unsafe.Pointer(bp)).FregGosub = regGosub
 109074 	(*WindowCodeArg)(unsafe.Pointer(bp)).FaddrGosub = addrGosub
 109075 	(*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr = (*Window)(unsafe.Pointer(pMWin)).FiEphCsr
 109076 	csrWrite = (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr + 1
 109077 	(*WindowCodeArg)(unsafe.Pointer(bp)).Fstart.Fcsr = (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr + 2
 109078 	(*WindowCodeArg)(unsafe.Pointer(bp)).Fend.Fcsr = (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr + 3
 109079 
 109080 	switch int32((*Window)(unsafe.Pointer(pMWin)).FeStart) {
 109081 	case TK_FOLLOWING:
 109082 		if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE &&
 109083 			windowExprGtZero(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpStart) != 0 {
 109084 			(*WindowCodeArg)(unsafe.Pointer(bp)).FeDelete = WINDOW_RETURN_ROW
 109085 		}
 109086 		break
 109087 	case TK_UNBOUNDED:
 109088 		if windowCacheFrame(tls, pMWin) == 0 {
 109089 			if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING {
 109090 				if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE &&
 109091 					windowExprGtZero(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpEnd) != 0 {
 109092 					(*WindowCodeArg)(unsafe.Pointer(bp)).FeDelete = WINDOW_AGGSTEP
 109093 				}
 109094 			} else {
 109095 				(*WindowCodeArg)(unsafe.Pointer(bp)).FeDelete = WINDOW_RETURN_ROW
 109096 			}
 109097 		}
 109098 		break
 109099 	default:
 109100 		(*WindowCodeArg)(unsafe.Pointer(bp)).FeDelete = WINDOW_AGGINVERSE
 109101 		break
 109102 	}
 109103 
 109104 	regNew = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 109105 	*(*int32)(unsafe.Pointer(pParse + 44)) += nInput
 109106 	regRecord = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 109107 	(*WindowCodeArg)(unsafe.Pointer(bp)).FregRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 109108 
 109109 	if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING || int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING {
 109110 		regStart = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 109111 	}
 109112 	if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING || int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_FOLLOWING {
 109113 		regEnd = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 109114 	}
 109115 
 109116 	if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_ROWS {
 109117 		var nPeer int32 = func() int32 {
 109118 			if pOrderBy != 0 {
 109119 				return (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr
 109120 			}
 109121 			return 0
 109122 		}()
 109123 		regNewPeer = regNew + (*Window)(unsafe.Pointer(pMWin)).FnBufferCol
 109124 		if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 {
 109125 			regNewPeer = regNewPeer + (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr
 109126 		}
 109127 		regPeer = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 109128 		*(*int32)(unsafe.Pointer(pParse + 44)) += nPeer
 109129 		(*WindowCodeArg)(unsafe.Pointer(bp)).Fstart.Freg = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 109130 		*(*int32)(unsafe.Pointer(pParse + 44)) += nPeer
 109131 		(*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Freg = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 109132 		*(*int32)(unsafe.Pointer(pParse + 44)) += nPeer
 109133 		(*WindowCodeArg)(unsafe.Pointer(bp)).Fend.Freg = (*Parse)(unsafe.Pointer(pParse)).FnMem + 1
 109134 		*(*int32)(unsafe.Pointer(pParse + 44)) += nPeer
 109135 	}
 109136 
 109137 	for iInput = 0; iInput < nInput; iInput++ {
 109138 		Xsqlite3VdbeAddOp3(tls, v, OP_Column, csrInput, iInput, regNew+iInput)
 109139 	}
 109140 	Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regNew, nInput, regRecord)
 109141 
 109142 	if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 {
 109143 		var addr int32
 109144 		var pPart uintptr = (*Window)(unsafe.Pointer(pMWin)).FpPartition
 109145 		var nPart int32 = (*ExprList)(unsafe.Pointer(pPart)).FnExpr
 109146 		var regNewPart int32 = regNew + (*Window)(unsafe.Pointer(pMWin)).FnBufferCol
 109147 		var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, pPart, 0, 0)
 109148 
 109149 		regFlushPart = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)
 109150 		addr = Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, nPart)
 109151 		Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -8)
 109152 		Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addr+2, addr+4, addr+2)
 109153 
 109154 		addrGosubFlush = Xsqlite3VdbeAddOp1(tls, v, OP_Gosub, regFlushPart)
 109155 
 109156 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, nPart-1)
 109157 	}
 109158 
 109159 	Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, csrWrite, (*WindowCodeArg)(unsafe.Pointer(bp)).FregRowid)
 109160 	Xsqlite3VdbeAddOp3(tls, v, OP_Insert, csrWrite, regRecord, (*WindowCodeArg)(unsafe.Pointer(bp)).FregRowid)
 109161 	addrNe = Xsqlite3VdbeAddOp3(tls, v, OP_Ne, (*Window)(unsafe.Pointer(pMWin)).FregOne, 0, (*WindowCodeArg)(unsafe.Pointer(bp)).FregRowid)
 109162 
 109163 	(*WindowCodeArg)(unsafe.Pointer(bp)).FregArg = windowInitAccum(tls, pParse, pMWin)
 109164 
 109165 	if regStart != 0 {
 109166 		Xsqlite3ExprCode(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpStart, regStart)
 109167 		windowCheckValue(tls, pParse, regStart, 0+func() int32 {
 109168 			if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 109169 				return 3
 109170 			}
 109171 			return 0
 109172 		}())
 109173 	}
 109174 	if regEnd != 0 {
 109175 		Xsqlite3ExprCode(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpEnd, regEnd)
 109176 		windowCheckValue(tls, pParse, regEnd, 1+func() int32 {
 109177 			if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 109178 				return 3
 109179 			}
 109180 			return 0
 109181 		}())
 109182 	}
 109183 
 109184 	if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE && int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) && regStart != 0 {
 109185 		var op int32 = func() int32 {
 109186 			if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING {
 109187 				return OP_Ge
 109188 			}
 109189 			return OP_Le
 109190 		}()
 109191 		var addrGe int32 = Xsqlite3VdbeAddOp3(tls, v, op, regStart, 0, regEnd)
 109192 
 109193 		windowAggFinal(tls, bp, 0)
 109194 		Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr)
 109195 		windowReturnOneRow(tls, bp)
 109196 		Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr)
 109197 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblWhereEnd)
 109198 		Xsqlite3VdbeJumpHere(tls, v, addrGe)
 109199 	}
 109200 	if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING && int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE && regEnd != 0 {
 109201 		Xsqlite3VdbeAddOp3(tls, v, OP_Subtract, regStart, regEnd, regStart)
 109202 	}
 109203 
 109204 	if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) != TK_UNBOUNDED {
 109205 		Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp)).Fstart.Fcsr)
 109206 	}
 109207 	Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr)
 109208 	Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp)).Fend.Fcsr)
 109209 	if regPeer != 0 && pOrderBy != 0 {
 109210 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNewPeer, regPeer, (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr-1)
 109211 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp)).Fstart.Freg, (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr-1)
 109212 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Freg, (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr-1)
 109213 		Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp)).Fend.Freg, (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr-1)
 109214 	}
 109215 
 109216 	Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblWhereEnd)
 109217 
 109218 	Xsqlite3VdbeJumpHere(tls, v, addrNe)
 109219 
 109220 	if regPeer != 0 {
 109221 		windowIfNewPeer(tls, pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd)
 109222 	}
 109223 	if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING {
 109224 		windowCodeOp(tls, bp, WINDOW_AGGSTEP, 0, 0)
 109225 		if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != TK_UNBOUNDED {
 109226 			if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 109227 				var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse)
 109228 				var addrNext int32 = Xsqlite3VdbeCurrentAddr(tls, v)
 109229 				windowCodeRangeTest(tls, bp, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp)).Fend.Fcsr, lbl)
 109230 				windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109231 				windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 0)
 109232 				Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrNext)
 109233 				Xsqlite3VdbeResolveLabel(tls, v, lbl)
 109234 			} else {
 109235 				windowCodeOp(tls, bp, WINDOW_RETURN_ROW, regEnd, 0)
 109236 				windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109237 			}
 109238 		}
 109239 	} else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING {
 109240 		var bRPS int32 = libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING && int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE)
 109241 		windowCodeOp(tls, bp, WINDOW_AGGSTEP, regEnd, 0)
 109242 		if bRPS != 0 {
 109243 			windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109244 		}
 109245 		windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 0)
 109246 		if !(bRPS != 0) {
 109247 			windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109248 		}
 109249 	} else {
 109250 		var addr int32 = 0
 109251 		windowCodeOp(tls, bp, WINDOW_AGGSTEP, 0, 0)
 109252 		if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != TK_UNBOUNDED {
 109253 			if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 109254 				var lbl int32 = 0
 109255 				addr = Xsqlite3VdbeCurrentAddr(tls, v)
 109256 				if regEnd != 0 {
 109257 					lbl = Xsqlite3VdbeMakeLabel(tls, pParse)
 109258 					windowCodeRangeTest(tls, bp, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp)).Fend.Fcsr, lbl)
 109259 				}
 109260 				windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 0)
 109261 				windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109262 				if regEnd != 0 {
 109263 					Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addr)
 109264 					Xsqlite3VdbeResolveLabel(tls, v, lbl)
 109265 				}
 109266 			} else {
 109267 				if regEnd != 0 {
 109268 					addr = Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, regEnd, 0, 1)
 109269 
 109270 				}
 109271 				windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 0)
 109272 				windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109273 				if regEnd != 0 {
 109274 					Xsqlite3VdbeJumpHere(tls, v, addr)
 109275 				}
 109276 			}
 109277 		}
 109278 	}
 109279 
 109280 	Xsqlite3VdbeResolveLabel(tls, v, lblWhereEnd)
 109281 	Xsqlite3WhereEnd(tls, pWInfo)
 109282 
 109283 	if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 {
 109284 		addrInteger = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regFlushPart)
 109285 		Xsqlite3VdbeJumpHere(tls, v, addrGosubFlush)
 109286 	}
 109287 
 109288 	(*WindowCodeArg)(unsafe.Pointer(bp)).FregRowid = 0
 109289 	addrEmpty = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, csrWrite)
 109290 
 109291 	if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING {
 109292 		var bRPS int32 = libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING && int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE)
 109293 		windowCodeOp(tls, bp, WINDOW_AGGSTEP, regEnd, 0)
 109294 		if bRPS != 0 {
 109295 			windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109296 		}
 109297 		windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 0)
 109298 	} else if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING {
 109299 		var addrStart int32
 109300 		var addrBreak1 int32
 109301 		var addrBreak2 int32
 109302 		var addrBreak3 int32
 109303 		windowCodeOp(tls, bp, WINDOW_AGGSTEP, 0, 0)
 109304 		if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE {
 109305 			addrStart = Xsqlite3VdbeCurrentAddr(tls, v)
 109306 			addrBreak2 = windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 1)
 109307 			addrBreak1 = windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 1)
 109308 		} else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_UNBOUNDED {
 109309 			addrStart = Xsqlite3VdbeCurrentAddr(tls, v)
 109310 			addrBreak1 = windowCodeOp(tls, bp, WINDOW_RETURN_ROW, regStart, 1)
 109311 			addrBreak2 = windowCodeOp(tls, bp, WINDOW_AGGINVERSE, 0, 1)
 109312 		} else {
 109313 			addrStart = Xsqlite3VdbeCurrentAddr(tls, v)
 109314 			addrBreak1 = windowCodeOp(tls, bp, WINDOW_RETURN_ROW, regEnd, 1)
 109315 			addrBreak2 = windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 1)
 109316 		}
 109317 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart)
 109318 		Xsqlite3VdbeJumpHere(tls, v, addrBreak2)
 109319 		addrStart = Xsqlite3VdbeCurrentAddr(tls, v)
 109320 		addrBreak3 = windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 1)
 109321 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart)
 109322 		Xsqlite3VdbeJumpHere(tls, v, addrBreak1)
 109323 		Xsqlite3VdbeJumpHere(tls, v, addrBreak3)
 109324 	} else {
 109325 		var addrBreak int32
 109326 		var addrStart int32
 109327 		windowCodeOp(tls, bp, WINDOW_AGGSTEP, 0, 0)
 109328 		addrStart = Xsqlite3VdbeCurrentAddr(tls, v)
 109329 		addrBreak = windowCodeOp(tls, bp, WINDOW_RETURN_ROW, 0, 1)
 109330 		windowCodeOp(tls, bp, WINDOW_AGGINVERSE, regStart, 0)
 109331 		Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart)
 109332 		Xsqlite3VdbeJumpHere(tls, v, addrBreak)
 109333 	}
 109334 	Xsqlite3VdbeJumpHere(tls, v, addrEmpty)
 109335 
 109336 	Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*WindowCodeArg)(unsafe.Pointer(bp)).Fcurrent.Fcsr)
 109337 	if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 {
 109338 		if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 {
 109339 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid)
 109340 			Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid)
 109341 		}
 109342 		Xsqlite3VdbeChangeP1(tls, v, addrInteger, Xsqlite3VdbeCurrentAddr(tls, v))
 109343 		Xsqlite3VdbeAddOp1(tls, v, OP_Return, regFlushPart)
 109344 	}
 109345 }
 109346 
 109347 // An instance of the following structure describes the event of a
 109348 // TRIGGER.  "a" is the event type, one of TK_UPDATE, TK_INSERT,
 109349 // TK_DELETE, or TK_INSTEAD.  If the event is of the form
 109350 //
 109351 //	UPDATE ON (a,b,c)
 109352 //
 109353 // Then the "b" IdList records the list "a,b,c".
 109354 type TrigEvent = struct {
 109355 	Fa int32
 109356 	Fb uintptr
 109357 }
 109358 
 109359 type FrameBound = struct {
 109360 	FeType int32
 109361 	FpExpr uintptr
 109362 }
 109363 
 109364 func disableLookaside(tls *libc.TLS, pParse uintptr) {
 109365 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 109366 	(*Parse)(unsafe.Pointer(pParse)).FdisableLookaside++
 109367 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++
 109368 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
 109369 }
 109370 
 109371 func parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) {
 109372 	bp := tls.Alloc(16)
 109373 	defer tls.Free(16)
 109374 
 109375 	if (*Select)(unsafe.Pointer(p)).FpPrior != 0 {
 109376 		var pNext uintptr = uintptr(0)
 109377 		var pLoop uintptr = p
 109378 		var mxSelect int32
 109379 		var cnt int32 = 1
 109380 		for 1 != 0 {
 109381 			(*Select)(unsafe.Pointer(pLoop)).FpNext = pNext
 109382 			*(*U32)(unsafe.Pointer(pLoop + 4)) |= U32(SF_Compound)
 109383 			pNext = pLoop
 109384 			pLoop = (*Select)(unsafe.Pointer(pLoop)).FpPrior
 109385 			if pLoop == uintptr(0) {
 109386 				break
 109387 			}
 109388 			cnt++
 109389 			if (*Select)(unsafe.Pointer(pLoop)).FpOrderBy != 0 || (*Select)(unsafe.Pointer(pLoop)).FpLimit != 0 {
 109390 				Xsqlite3ErrorMsg(tls, pParse, ts+22864,
 109391 					libc.VaList(bp, func() uintptr {
 109392 						if (*Select)(unsafe.Pointer(pLoop)).FpOrderBy != uintptr(0) {
 109393 							return ts + 22906
 109394 						}
 109395 						return ts + 22915
 109396 					}(),
 109397 						Xsqlite3SelectOpName(tls, int32((*Select)(unsafe.Pointer(pNext)).Fop))))
 109398 				break
 109399 			}
 109400 		}
 109401 		if (*Select)(unsafe.Pointer(p)).FselFlags&U32(SF_MultiValue) == U32(0) && libc.AssignInt32(&mxSelect, *(*int32)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb + 120 + 4*4))) > 0 && cnt > mxSelect {
 109402 			Xsqlite3ErrorMsg(tls, pParse, ts+22921, 0)
 109403 		}
 109404 	}
 109405 
 109406 }
 109407 
 109408 func attachWithToSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, pWith uintptr) uintptr {
 109409 	if pSelect != 0 {
 109410 		(*Select)(unsafe.Pointer(pSelect)).FpWith = pWith
 109411 		parserDoubleLinkSelect(tls, pParse, pSelect)
 109412 	} else {
 109413 		Xsqlite3WithDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pWith)
 109414 	}
 109415 	return pSelect
 109416 
 109417 }
 109418 
 109419 func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr {
 109420 	bp := tls.Alloc(8)
 109421 	defer tls.Free(8)
 109422 	*(*Token)(unsafe.Pointer(bp)) = t
 109423 
 109424 	var p uintptr = Xsqlite3DbMallocRawNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(uint32(unsafe.Sizeof(Expr{}))+(*Token)(unsafe.Pointer(bp)).Fn+uint32(1)))
 109425 	if p != 0 {
 109426 		(*Expr)(unsafe.Pointer(p)).Fop = U8(op)
 109427 		(*Expr)(unsafe.Pointer(p)).FaffExpr = uint8(0)
 109428 		(*Expr)(unsafe.Pointer(p)).Fflags = U32(EP_Leaf)
 109429 
 109430 		(*Expr)(unsafe.Pointer(p)).FpLeft = libc.AssignPtrUintptr(p+16, uintptr(0))
 109431 		(*Expr)(unsafe.Pointer(p)).FpAggInfo = uintptr(0)
 109432 		libc.Xmemset(tls, p+20, 0, uint32(unsafe.Sizeof(struct{ FpList uintptr }{})))
 109433 		libc.Xmemset(tls, p+44, 0, uint32(unsafe.Sizeof(struct {
 109434 			FpTab        uintptr
 109435 			F__ccgo_pad1 [4]byte
 109436 		}{})))
 109437 		(*Expr)(unsafe.Pointer(p)).Fop2 = U8(0)
 109438 		(*Expr)(unsafe.Pointer(p)).FiTable = 0
 109439 		(*Expr)(unsafe.Pointer(p)).FiColumn = int16(0)
 109440 		*(*uintptr)(unsafe.Pointer(p + 8)) = p + 1*52
 109441 		libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 8)), (*Token)(unsafe.Pointer(bp)).Fz, (*Token)(unsafe.Pointer(bp)).Fn)
 109442 		*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8)) + uintptr((*Token)(unsafe.Pointer(bp)).Fn))) = uint8(0)
 109443 		*(*int32)(unsafe.Pointer(p + 36)) = (int32((*Token)(unsafe.Pointer(bp)).Fz) - int32((*Parse)(unsafe.Pointer(pParse)).FzTail)) / 1
 109444 		if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8))))])&0x80 != 0 {
 109445 			Xsqlite3DequoteExpr(tls, p)
 109446 		}
 109447 		(*Expr)(unsafe.Pointer(p)).FnHeight = 1
 109448 		if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
 109449 			return Xsqlite3RenameTokenMap(tls, pParse, p, bp)
 109450 		}
 109451 	}
 109452 	return p
 109453 
 109454 }
 109455 
 109456 func binaryToUnaryIfNull(tls *libc.TLS, pParse uintptr, pY uintptr, pA uintptr, op int32) {
 109457 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 109458 	if pA != 0 && pY != 0 && int32((*Expr)(unsafe.Pointer(pY)).Fop) == TK_NULL && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
 109459 		(*Expr)(unsafe.Pointer(pA)).Fop = U8(op)
 109460 		Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pA)).FpRight)
 109461 		(*Expr)(unsafe.Pointer(pA)).FpRight = uintptr(0)
 109462 	}
 109463 
 109464 }
 109465 
 109466 func parserAddExprIdListTerm(tls *libc.TLS, pParse uintptr, pPrior uintptr, pIdToken uintptr, hasCollate int32, sortOrder int32) uintptr {
 109467 	bp := tls.Alloc(16)
 109468 	defer tls.Free(16)
 109469 
 109470 	var p uintptr = Xsqlite3ExprListAppend(tls, pParse, pPrior, uintptr(0))
 109471 	if (hasCollate != 0 || sortOrder != -1) &&
 109472 		int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Finit.Fbusy) == 0 {
 109473 		Xsqlite3ErrorMsg(tls, pParse, ts+22955,
 109474 			libc.VaList(bp, (*Token)(unsafe.Pointer(pIdToken)).Fn, (*Token)(unsafe.Pointer(pIdToken)).Fz))
 109475 	}
 109476 	Xsqlite3ExprListSetName(tls, pParse, p, pIdToken, 1)
 109477 	return p
 109478 
 109479 }
 109480 
 109481 // The next sections is a series of control #defines.
 109482 // various aspects of the generated parser.
 109483 //
 109484 //	YYCODETYPE         is the data type used to store the integer codes
 109485 //	                   that represent terminal and non-terminal symbols.
 109486 //	                   "unsigned char" is used if there are fewer than
 109487 //	                   256 symbols.  Larger types otherwise.
 109488 //	YYNOCODE           is a number of type YYCODETYPE that is not used for
 109489 //	                   any terminal or nonterminal symbol.
 109490 //	YYFALLBACK         If defined, this indicates that one or more tokens
 109491 //	                   (also known as: "terminal symbols") have fall-back
 109492 //	                   values which should be used if the original symbol
 109493 //	                   would not parse.  This permits keywords to sometimes
 109494 //	                   be used as identifiers, for example.
 109495 //	YYACTIONTYPE       is the data type used for "action codes" - numbers
 109496 //	                   that indicate what to do in response to the next
 109497 //	                   token.
 109498 //	sqlite3ParserTOKENTYPE     is the data type used for minor type for terminal
 109499 //	                   symbols.  Background: A "minor type" is a semantic
 109500 //	                   value associated with a terminal or non-terminal
 109501 //	                   symbols.  For example, for an "ID" terminal symbol,
 109502 //	                   the minor type might be the name of the identifier.
 109503 //	                   Each non-terminal can have a different minor type.
 109504 //	                   Terminal symbols all have the same minor type, though.
 109505 //	                   This macros defines the minor type for terminal
 109506 //	                   symbols.
 109507 //	YYMINORTYPE        is the data type used for all minor types.
 109508 //	                   This is typically a union of many types, one of
 109509 //	                   which is sqlite3ParserTOKENTYPE.  The entry in the union
 109510 //	                   for terminal symbols is called "yy0".
 109511 //	YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
 109512 //	                   zero the stack is dynamically sized using realloc()
 109513 //	sqlite3ParserARG_SDECL     A static variable declaration for the %extra_argument
 109514 //	sqlite3ParserARG_PDECL     A parameter declaration for the %extra_argument
 109515 //	sqlite3ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter
 109516 //	sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser
 109517 //	sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser
 109518 //	sqlite3ParserCTX_*         As sqlite3ParserARG_ except for %extra_context
 109519 //	YYERRORSYMBOL      is the code number of the error symbol.  If not
 109520 //	                   defined, then do no error processing.
 109521 //	YYNSTATE           the combined number of states.
 109522 //	YYNRULE            the number of rules in the grammar
 109523 //	YYNTOKEN           Number of terminal symbols
 109524 //	YY_MAX_SHIFT       Maximum value for shift actions
 109525 //	YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
 109526 //	YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
 109527 //	YY_ERROR_ACTION    The yy_action[] code for syntax error
 109528 //	YY_ACCEPT_ACTION   The yy_action[] code for accept
 109529 //	YY_NO_ACTION       The yy_action[] code for no-op
 109530 //	YY_MIN_REDUCE      Minimum value for reduce actions
 109531 //	YY_MAX_REDUCE      Maximum value for reduce actions
 109532 //
 109533 // ************ Begin control #defines ****************************************
 109534 type YYMINORTYPE = struct {
 109535 	Fyyinit      int32
 109536 	F__ccgo_pad1 [4]byte
 109537 }
 109538 
 109539 var yy_action = [2098]uint16{
 109540 	uint16(568), uint16(208), uint16(568), uint16(118), uint16(115), uint16(229), uint16(568), uint16(118), uint16(115), uint16(229),
 109541 	uint16(568), uint16(1314), uint16(377), uint16(1293), uint16(408), uint16(562), uint16(562), uint16(562), uint16(568), uint16(409),
 109542 	uint16(378), uint16(1314), uint16(1276), uint16(41), uint16(41), uint16(41), uint16(41), uint16(208), uint16(1526), uint16(71),
 109543 	uint16(71), uint16(971), uint16(419), uint16(41), uint16(41), uint16(491), uint16(303), uint16(279), uint16(303), uint16(972),
 109544 	uint16(397), uint16(71), uint16(71), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050), uint16(1053),
 109545 	uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(476), uint16(409),
 109546 	uint16(1241), uint16(1), uint16(1), uint16(575), uint16(2), uint16(1245), uint16(550), uint16(118), uint16(115), uint16(229),
 109547 	uint16(317), uint16(480), uint16(146), uint16(480), uint16(524), uint16(118), uint16(115), uint16(229), uint16(529), uint16(1327),
 109548 	uint16(417), uint16(523), uint16(142), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050), uint16(1053),
 109549 	uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(118), uint16(115),
 109550 	uint16(229), uint16(327), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120),
 109551 	uint16(120), uint16(119), uint16(116), uint16(444), uint16(284), uint16(284), uint16(284), uint16(284), uint16(442), uint16(442),
 109552 	uint16(442), uint16(1567), uint16(376), uint16(1569), uint16(1192), uint16(375), uint16(1163), uint16(565), uint16(1163), uint16(565),
 109553 	uint16(409), uint16(1567), uint16(537), uint16(259), uint16(226), uint16(444), uint16(101), uint16(145), uint16(449), uint16(316),
 109554 	uint16(559), uint16(240), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120),
 109555 	uint16(120), uint16(119), uint16(116), uint16(444), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050),
 109556 	uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(142),
 109557 	uint16(294), uint16(1192), uint16(339), uint16(448), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444),
 109558 	uint16(127), uint16(1192), uint16(1193), uint16(1194), uint16(148), uint16(441), uint16(440), uint16(568), uint16(119), uint16(116),
 109559 	uint16(444), uint16(124), uint16(124), uint16(124), uint16(124), uint16(117), uint16(122), uint16(122), uint16(122), uint16(122),
 109560 	uint16(121), uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(454), uint16(113),
 109561 	uint16(13), uint16(13), uint16(546), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120),
 109562 	uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(422), uint16(316), uint16(559), uint16(1192), uint16(1193),
 109563 	uint16(1194), uint16(149), uint16(1224), uint16(409), uint16(1224), uint16(124), uint16(124), uint16(124), uint16(124), uint16(122),
 109564 	uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116),
 109565 	uint16(444), uint16(465), uint16(342), uint16(1037), uint16(1037), uint16(1051), uint16(1054), uint16(125), uint16(126), uint16(80),
 109566 	uint16(1217), uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124),
 109567 	uint16(124), uint16(124), uint16(1279), uint16(522), uint16(222), uint16(1192), uint16(568), uint16(409), uint16(224), uint16(514),
 109568 	uint16(175), uint16(82), uint16(83), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120),
 109569 	uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(1007), uint16(16), uint16(16), uint16(1192), uint16(133),
 109570 	uint16(133), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040),
 109571 	uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(122), uint16(122), uint16(122), uint16(122),
 109572 	uint16(121), uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(1041), uint16(546),
 109573 	uint16(1192), uint16(373), uint16(1192), uint16(1193), uint16(1194), uint16(252), uint16(1434), uint16(399), uint16(504), uint16(501),
 109574 	uint16(500), uint16(111), uint16(560), uint16(566), uint16(4), uint16(926), uint16(926), uint16(433), uint16(499), uint16(340),
 109575 	uint16(460), uint16(328), uint16(360), uint16(394), uint16(1237), uint16(1192), uint16(1193), uint16(1194), uint16(563), uint16(568),
 109576 	uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120), uint16(120), uint16(119),
 109577 	uint16(116), uint16(444), uint16(284), uint16(284), uint16(369), uint16(1580), uint16(1607), uint16(441), uint16(440), uint16(154),
 109578 	uint16(409), uint16(445), uint16(71), uint16(71), uint16(1286), uint16(565), uint16(1221), uint16(1192), uint16(1193), uint16(1194),
 109579 	uint16(85), uint16(1223), uint16(271), uint16(557), uint16(543), uint16(515), uint16(1561), uint16(568), uint16(98), uint16(1222),
 109580 	uint16(6), uint16(1278), uint16(472), uint16(142), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050),
 109581 	uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(550),
 109582 	uint16(13), uint16(13), uint16(1027), uint16(507), uint16(1224), uint16(1192), uint16(1224), uint16(549), uint16(109), uint16(109),
 109583 	uint16(222), uint16(568), uint16(1238), uint16(175), uint16(568), uint16(427), uint16(110), uint16(197), uint16(445), uint16(570),
 109584 	uint16(569), uint16(430), uint16(1552), uint16(1017), uint16(325), uint16(551), uint16(1192), uint16(270), uint16(287), uint16(368),
 109585 	uint16(510), uint16(363), uint16(509), uint16(257), uint16(71), uint16(71), uint16(543), uint16(71), uint16(71), uint16(359),
 109586 	uint16(316), uint16(559), uint16(1613), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120),
 109587 	uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27),
 109588 	uint16(284), uint16(284), uint16(1192), uint16(1193), uint16(1194), uint16(1158), uint16(568), uint16(1612), uint16(409), uint16(901),
 109589 	uint16(190), uint16(550), uint16(356), uint16(565), uint16(550), uint16(937), uint16(533), uint16(517), uint16(1158), uint16(516),
 109590 	uint16(413), uint16(1158), uint16(552), uint16(1192), uint16(1193), uint16(1194), uint16(568), uint16(544), uint16(1554), uint16(51),
 109591 	uint16(51), uint16(214), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050), uint16(1053), uint16(1040),
 109592 	uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(1192), uint16(474), uint16(135),
 109593 	uint16(135), uint16(409), uint16(284), uint16(284), uint16(1490), uint16(505), uint16(121), uint16(121), uint16(120), uint16(120),
 109594 	uint16(120), uint16(119), uint16(116), uint16(444), uint16(1007), uint16(565), uint16(518), uint16(217), uint16(541), uint16(1561),
 109595 	uint16(316), uint16(559), uint16(142), uint16(6), uint16(532), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217),
 109596 	uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124),
 109597 	uint16(1555), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120), uint16(120),
 109598 	uint16(119), uint16(116), uint16(444), uint16(485), uint16(1192), uint16(1193), uint16(1194), uint16(482), uint16(281), uint16(1267),
 109599 	uint16(957), uint16(252), uint16(1192), uint16(373), uint16(504), uint16(501), uint16(500), uint16(1192), uint16(340), uint16(571),
 109600 	uint16(1192), uint16(571), uint16(409), uint16(292), uint16(499), uint16(957), uint16(876), uint16(191), uint16(480), uint16(316),
 109601 	uint16(559), uint16(384), uint16(290), uint16(380), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121),
 109602 	uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(125), uint16(126), uint16(80), uint16(1217),
 109603 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109604 	uint16(124), uint16(409), uint16(394), uint16(1136), uint16(1192), uint16(869), uint16(100), uint16(284), uint16(284), uint16(1192),
 109605 	uint16(1193), uint16(1194), uint16(373), uint16(1093), uint16(1192), uint16(1193), uint16(1194), uint16(1192), uint16(1193), uint16(1194),
 109606 	uint16(565), uint16(455), uint16(32), uint16(373), uint16(233), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217),
 109607 	uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124),
 109608 	uint16(1433), uint16(959), uint16(568), uint16(228), uint16(958), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109609 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(1158), uint16(228), uint16(1192),
 109610 	uint16(157), uint16(1192), uint16(1193), uint16(1194), uint16(1553), uint16(13), uint16(13), uint16(301), uint16(957), uint16(1232),
 109611 	uint16(1158), uint16(153), uint16(409), uint16(1158), uint16(373), uint16(1583), uint16(1176), uint16(5), uint16(369), uint16(1580),
 109612 	uint16(429), uint16(1238), uint16(3), uint16(957), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121),
 109613 	uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(125), uint16(126), uint16(80), uint16(1217),
 109614 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109615 	uint16(124), uint16(409), uint16(208), uint16(567), uint16(1192), uint16(1028), uint16(1192), uint16(1193), uint16(1194), uint16(1192),
 109616 	uint16(388), uint16(852), uint16(155), uint16(1552), uint16(286), uint16(402), uint16(1098), uint16(1098), uint16(488), uint16(568),
 109617 	uint16(465), uint16(342), uint16(1319), uint16(1319), uint16(1552), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217),
 109618 	uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124),
 109619 	uint16(129), uint16(568), uint16(13), uint16(13), uint16(374), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109620 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(302), uint16(568), uint16(453),
 109621 	uint16(528), uint16(1192), uint16(1193), uint16(1194), uint16(13), uint16(13), uint16(1192), uint16(1193), uint16(1194), uint16(1297),
 109622 	uint16(463), uint16(1267), uint16(409), uint16(1317), uint16(1317), uint16(1552), uint16(1012), uint16(453), uint16(452), uint16(200),
 109623 	uint16(299), uint16(71), uint16(71), uint16(1265), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121),
 109624 	uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(125), uint16(126), uint16(80), uint16(1217),
 109625 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109626 	uint16(124), uint16(409), uint16(227), uint16(1073), uint16(1158), uint16(284), uint16(284), uint16(419), uint16(312), uint16(278),
 109627 	uint16(278), uint16(285), uint16(285), uint16(1419), uint16(406), uint16(405), uint16(382), uint16(1158), uint16(565), uint16(568),
 109628 	uint16(1158), uint16(1196), uint16(565), uint16(1600), uint16(565), uint16(125), uint16(126), uint16(80), uint16(1217), uint16(1217),
 109629 	uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124), uint16(124),
 109630 	uint16(453), uint16(1482), uint16(13), uint16(13), uint16(1536), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109631 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(201), uint16(568), uint16(354),
 109632 	uint16(1586), uint16(575), uint16(2), uint16(1245), uint16(840), uint16(841), uint16(842), uint16(1562), uint16(317), uint16(1212),
 109633 	uint16(146), uint16(6), uint16(409), uint16(255), uint16(254), uint16(253), uint16(206), uint16(1327), uint16(9), uint16(1196),
 109634 	uint16(262), uint16(71), uint16(71), uint16(424), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121), uint16(121),
 109635 	uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(125), uint16(126), uint16(80), uint16(1217),
 109636 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109637 	uint16(124), uint16(568), uint16(284), uint16(284), uint16(568), uint16(1213), uint16(409), uint16(574), uint16(313), uint16(1245),
 109638 	uint16(349), uint16(1296), uint16(352), uint16(419), uint16(317), uint16(565), uint16(146), uint16(491), uint16(525), uint16(1643),
 109639 	uint16(395), uint16(371), uint16(491), uint16(1327), uint16(70), uint16(70), uint16(1295), uint16(71), uint16(71), uint16(240),
 109640 	uint16(1325), uint16(104), uint16(80), uint16(1217), uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123),
 109641 	uint16(123), uint16(124), uint16(124), uint16(124), uint16(124), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109642 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(1114), uint16(284), uint16(284),
 109643 	uint16(428), uint16(448), uint16(1525), uint16(1213), uint16(439), uint16(284), uint16(284), uint16(1489), uint16(1352), uint16(311),
 109644 	uint16(474), uint16(565), uint16(1115), uint16(971), uint16(491), uint16(491), uint16(217), uint16(1263), uint16(565), uint16(1538),
 109645 	uint16(568), uint16(972), uint16(207), uint16(568), uint16(1027), uint16(240), uint16(383), uint16(1116), uint16(519), uint16(122),
 109646 	uint16(122), uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116),
 109647 	uint16(444), uint16(1018), uint16(107), uint16(71), uint16(71), uint16(1017), uint16(13), uint16(13), uint16(912), uint16(568),
 109648 	uint16(1495), uint16(568), uint16(284), uint16(284), uint16(97), uint16(526), uint16(491), uint16(448), uint16(913), uint16(1326),
 109649 	uint16(1322), uint16(545), uint16(409), uint16(284), uint16(284), uint16(565), uint16(151), uint16(209), uint16(1495), uint16(1497),
 109650 	uint16(262), uint16(450), uint16(55), uint16(55), uint16(56), uint16(56), uint16(565), uint16(1017), uint16(1017), uint16(1019),
 109651 	uint16(443), uint16(332), uint16(409), uint16(527), uint16(12), uint16(295), uint16(125), uint16(126), uint16(80), uint16(1217),
 109652 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109653 	uint16(124), uint16(347), uint16(409), uint16(864), uint16(1534), uint16(1213), uint16(125), uint16(126), uint16(80), uint16(1217),
 109654 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109655 	uint16(124), uint16(1137), uint16(1641), uint16(474), uint16(1641), uint16(371), uint16(125), uint16(114), uint16(80), uint16(1217),
 109656 	uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123), uint16(124), uint16(124), uint16(124),
 109657 	uint16(124), uint16(1495), uint16(329), uint16(474), uint16(331), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109658 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(203), uint16(1419), uint16(568),
 109659 	uint16(1294), uint16(864), uint16(464), uint16(1213), uint16(436), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109660 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(553), uint16(1137), uint16(1642),
 109661 	uint16(539), uint16(1642), uint16(15), uint16(15), uint16(892), uint16(122), uint16(122), uint16(122), uint16(122), uint16(121),
 109662 	uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444), uint16(568), uint16(298), uint16(538),
 109663 	uint16(1135), uint16(1419), uint16(1559), uint16(1560), uint16(1331), uint16(409), uint16(6), uint16(6), uint16(1169), uint16(1268),
 109664 	uint16(415), uint16(320), uint16(284), uint16(284), uint16(1419), uint16(508), uint16(565), uint16(525), uint16(300), uint16(457),
 109665 	uint16(43), uint16(43), uint16(568), uint16(893), uint16(12), uint16(565), uint16(330), uint16(478), uint16(425), uint16(407),
 109666 	uint16(126), uint16(80), uint16(1217), uint16(1217), uint16(1050), uint16(1053), uint16(1040), uint16(1040), uint16(123), uint16(123),
 109667 	uint16(124), uint16(124), uint16(124), uint16(124), uint16(568), uint16(57), uint16(57), uint16(288), uint16(1192), uint16(1419),
 109668 	uint16(496), uint16(458), uint16(392), uint16(392), uint16(391), uint16(273), uint16(389), uint16(1135), uint16(1558), uint16(849),
 109669 	uint16(1169), uint16(407), uint16(6), uint16(568), uint16(321), uint16(1158), uint16(470), uint16(44), uint16(44), uint16(1557),
 109670 	uint16(1114), uint16(426), uint16(234), uint16(6), uint16(323), uint16(256), uint16(540), uint16(256), uint16(1158), uint16(431),
 109671 	uint16(568), uint16(1158), uint16(322), uint16(17), uint16(487), uint16(1115), uint16(58), uint16(58), uint16(122), uint16(122),
 109672 	uint16(122), uint16(122), uint16(121), uint16(121), uint16(120), uint16(120), uint16(120), uint16(119), uint16(116), uint16(444),
 109673 	uint16(1116), uint16(216), uint16(481), uint16(59), uint16(59), uint16(1192), uint16(1193), uint16(1194), uint16(111), uint16(560),
 109674 	uint16(324), uint16(4), uint16(236), uint16(456), uint16(526), uint16(568), uint16(237), uint16(456), uint16(568), uint16(437),
 109675 	uint16(168), uint16(556), uint16(420), uint16(141), uint16(479), uint16(563), uint16(568), uint16(293), uint16(568), uint16(1095),
 109676 	uint16(568), uint16(293), uint16(568), uint16(1095), uint16(531), uint16(568), uint16(872), uint16(8), uint16(60), uint16(60),
 109677 	uint16(235), uint16(61), uint16(61), uint16(568), uint16(414), uint16(568), uint16(414), uint16(568), uint16(445), uint16(62),
 109678 	uint16(62), uint16(45), uint16(45), uint16(46), uint16(46), uint16(47), uint16(47), uint16(199), uint16(49), uint16(49),
 109679 	uint16(557), uint16(568), uint16(359), uint16(568), uint16(100), uint16(486), uint16(50), uint16(50), uint16(63), uint16(63),
 109680 	uint16(64), uint16(64), uint16(561), uint16(415), uint16(535), uint16(410), uint16(568), uint16(1027), uint16(568), uint16(534),
 109681 	uint16(316), uint16(559), uint16(316), uint16(559), uint16(65), uint16(65), uint16(14), uint16(14), uint16(568), uint16(1027),
 109682 	uint16(568), uint16(512), uint16(932), uint16(872), uint16(1018), uint16(109), uint16(109), uint16(931), uint16(1017), uint16(66),
 109683 	uint16(66), uint16(131), uint16(131), uint16(110), uint16(451), uint16(445), uint16(570), uint16(569), uint16(416), uint16(177),
 109684 	uint16(1017), uint16(132), uint16(132), uint16(67), uint16(67), uint16(568), uint16(467), uint16(568), uint16(932), uint16(471),
 109685 	uint16(1364), uint16(283), uint16(226), uint16(931), uint16(315), uint16(1363), uint16(407), uint16(568), uint16(459), uint16(407),
 109686 	uint16(1017), uint16(1017), uint16(1019), uint16(239), uint16(407), uint16(86), uint16(213), uint16(1350), uint16(52), uint16(52),
 109687 	uint16(68), uint16(68), uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27), uint16(1585), uint16(1180), uint16(447),
 109688 	uint16(69), uint16(69), uint16(288), uint16(97), uint16(108), uint16(1541), uint16(106), uint16(392), uint16(392), uint16(391),
 109689 	uint16(273), uint16(389), uint16(568), uint16(879), uint16(849), uint16(883), uint16(568), uint16(111), uint16(560), uint16(466),
 109690 	uint16(4), uint16(568), uint16(152), uint16(30), uint16(38), uint16(568), uint16(1132), uint16(234), uint16(396), uint16(323),
 109691 	uint16(111), uint16(560), uint16(527), uint16(4), uint16(563), uint16(53), uint16(53), uint16(322), uint16(568), uint16(163),
 109692 	uint16(163), uint16(568), uint16(337), uint16(468), uint16(164), uint16(164), uint16(333), uint16(563), uint16(76), uint16(76),
 109693 	uint16(568), uint16(289), uint16(1514), uint16(568), uint16(31), uint16(1513), uint16(568), uint16(445), uint16(338), uint16(483),
 109694 	uint16(100), uint16(54), uint16(54), uint16(344), uint16(72), uint16(72), uint16(296), uint16(236), uint16(1080), uint16(557),
 109695 	uint16(445), uint16(879), uint16(1360), uint16(134), uint16(134), uint16(168), uint16(73), uint16(73), uint16(141), uint16(161),
 109696 	uint16(161), uint16(1574), uint16(557), uint16(535), uint16(568), uint16(319), uint16(568), uint16(348), uint16(536), uint16(1009),
 109697 	uint16(473), uint16(261), uint16(261), uint16(891), uint16(890), uint16(235), uint16(535), uint16(568), uint16(1027), uint16(568),
 109698 	uint16(475), uint16(534), uint16(261), uint16(367), uint16(109), uint16(109), uint16(521), uint16(136), uint16(136), uint16(130),
 109699 	uint16(130), uint16(1027), uint16(110), uint16(366), uint16(445), uint16(570), uint16(569), uint16(109), uint16(109), uint16(1017),
 109700 	uint16(162), uint16(162), uint16(156), uint16(156), uint16(568), uint16(110), uint16(1080), uint16(445), uint16(570), uint16(569),
 109701 	uint16(410), uint16(351), uint16(1017), uint16(568), uint16(353), uint16(316), uint16(559), uint16(568), uint16(343), uint16(568),
 109702 	uint16(100), uint16(497), uint16(357), uint16(258), uint16(100), uint16(898), uint16(899), uint16(140), uint16(140), uint16(355),
 109703 	uint16(1310), uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27), uint16(139), uint16(139), uint16(362), uint16(451),
 109704 	uint16(137), uint16(137), uint16(138), uint16(138), uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27), uint16(1180),
 109705 	uint16(447), uint16(568), uint16(372), uint16(288), uint16(111), uint16(560), uint16(1021), uint16(4), uint16(392), uint16(392),
 109706 	uint16(391), uint16(273), uint16(389), uint16(568), uint16(1141), uint16(849), uint16(568), uint16(1076), uint16(568), uint16(258),
 109707 	uint16(492), uint16(563), uint16(568), uint16(211), uint16(75), uint16(75), uint16(555), uint16(962), uint16(234), uint16(261),
 109708 	uint16(323), uint16(111), uint16(560), uint16(929), uint16(4), uint16(113), uint16(77), uint16(77), uint16(322), uint16(74),
 109709 	uint16(74), uint16(42), uint16(42), uint16(1373), uint16(445), uint16(48), uint16(48), uint16(1418), uint16(563), uint16(974),
 109710 	uint16(975), uint16(1092), uint16(1091), uint16(1092), uint16(1091), uint16(862), uint16(557), uint16(150), uint16(930), uint16(1346),
 109711 	uint16(113), uint16(1358), uint16(554), uint16(1424), uint16(1021), uint16(1275), uint16(1266), uint16(1254), uint16(236), uint16(1253),
 109712 	uint16(1255), uint16(445), uint16(1593), uint16(1343), uint16(308), uint16(276), uint16(168), uint16(309), uint16(11), uint16(141),
 109713 	uint16(393), uint16(310), uint16(232), uint16(557), uint16(1405), uint16(1027), uint16(335), uint16(291), uint16(1400), uint16(219),
 109714 	uint16(336), uint16(109), uint16(109), uint16(936), uint16(297), uint16(1410), uint16(235), uint16(341), uint16(477), uint16(110),
 109715 	uint16(502), uint16(445), uint16(570), uint16(569), uint16(1393), uint16(1409), uint16(1017), uint16(400), uint16(1293), uint16(365),
 109716 	uint16(223), uint16(1486), uint16(1027), uint16(1485), uint16(1355), uint16(1356), uint16(1354), uint16(1353), uint16(109), uint16(109),
 109717 	uint16(204), uint16(1596), uint16(1232), uint16(558), uint16(265), uint16(218), uint16(110), uint16(205), uint16(445), uint16(570),
 109718 	uint16(569), uint16(410), uint16(387), uint16(1017), uint16(1533), uint16(179), uint16(316), uint16(559), uint16(1017), uint16(1017),
 109719 	uint16(1019), uint16(1020), uint16(27), uint16(230), uint16(1531), uint16(1229), uint16(79), uint16(560), uint16(85), uint16(4),
 109720 	uint16(418), uint16(215), uint16(548), uint16(81), uint16(84), uint16(188), uint16(1406), uint16(173), uint16(181), uint16(461),
 109721 	uint16(451), uint16(35), uint16(462), uint16(563), uint16(183), uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27),
 109722 	uint16(184), uint16(1491), uint16(185), uint16(186), uint16(495), uint16(242), uint16(98), uint16(398), uint16(1412), uint16(36),
 109723 	uint16(1411), uint16(484), uint16(91), uint16(469), uint16(401), uint16(1414), uint16(445), uint16(192), uint16(1480), uint16(246),
 109724 	uint16(1502), uint16(490), uint16(346), uint16(277), uint16(248), uint16(196), uint16(493), uint16(511), uint16(557), uint16(350),
 109725 	uint16(1256), uint16(249), uint16(250), uint16(403), uint16(1313), uint16(1312), uint16(111), uint16(560), uint16(432), uint16(4),
 109726 	uint16(1311), uint16(1304), uint16(93), uint16(1611), uint16(883), uint16(1610), uint16(224), uint16(404), uint16(434), uint16(520),
 109727 	uint16(263), uint16(435), uint16(1579), uint16(563), uint16(1283), uint16(1282), uint16(364), uint16(1027), uint16(306), uint16(1281),
 109728 	uint16(264), uint16(1609), uint16(1565), uint16(109), uint16(109), uint16(370), uint16(1303), uint16(307), uint16(1564), uint16(438),
 109729 	uint16(128), uint16(110), uint16(1378), uint16(445), uint16(570), uint16(569), uint16(445), uint16(546), uint16(1017), uint16(10),
 109730 	uint16(1466), uint16(105), uint16(381), uint16(1377), uint16(34), uint16(572), uint16(99), uint16(1336), uint16(557), uint16(314),
 109731 	uint16(1186), uint16(530), uint16(272), uint16(274), uint16(379), uint16(210), uint16(1335), uint16(547), uint16(385), uint16(386),
 109732 	uint16(275), uint16(573), uint16(1251), uint16(1246), uint16(411), uint16(412), uint16(1518), uint16(165), uint16(178), uint16(1519),
 109733 	uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27), uint16(1517), uint16(1516), uint16(1027), uint16(78), uint16(147),
 109734 	uint16(166), uint16(220), uint16(221), uint16(109), uint16(109), uint16(836), uint16(304), uint16(167), uint16(446), uint16(212),
 109735 	uint16(318), uint16(110), uint16(231), uint16(445), uint16(570), uint16(569), uint16(144), uint16(1090), uint16(1017), uint16(1088),
 109736 	uint16(326), uint16(180), uint16(169), uint16(1212), uint16(182), uint16(334), uint16(238), uint16(915), uint16(241), uint16(1104),
 109737 	uint16(187), uint16(170), uint16(171), uint16(421), uint16(87), uint16(88), uint16(423), uint16(189), uint16(89), uint16(90),
 109738 	uint16(172), uint16(1107), uint16(243), uint16(1103), uint16(244), uint16(158), uint16(18), uint16(245), uint16(345), uint16(247),
 109739 	uint16(1017), uint16(1017), uint16(1019), uint16(1020), uint16(27), uint16(261), uint16(1096), uint16(193), uint16(1226), uint16(489),
 109740 	uint16(194), uint16(37), uint16(366), uint16(851), uint16(494), uint16(251), uint16(195), uint16(506), uint16(92), uint16(19),
 109741 	uint16(498), uint16(358), uint16(20), uint16(503), uint16(881), uint16(361), uint16(94), uint16(894), uint16(305), uint16(159),
 109742 	uint16(513), uint16(39), uint16(95), uint16(1174), uint16(160), uint16(1056), uint16(966), uint16(1143), uint16(96), uint16(174),
 109743 	uint16(1142), uint16(225), uint16(280), uint16(282), uint16(198), uint16(960), uint16(113), uint16(1164), uint16(1160), uint16(260),
 109744 	uint16(21), uint16(22), uint16(23), uint16(1162), uint16(1168), uint16(1167), uint16(1148), uint16(24), uint16(33), uint16(25),
 109745 	uint16(202), uint16(542), uint16(26), uint16(100), uint16(1071), uint16(102), uint16(1057), uint16(103), uint16(7), uint16(1055),
 109746 	uint16(1059), uint16(1113), uint16(1060), uint16(1112), uint16(266), uint16(267), uint16(28), uint16(40), uint16(390), uint16(1022),
 109747 	uint16(863), uint16(112), uint16(29), uint16(564), uint16(1182), uint16(1181), uint16(268), uint16(176), uint16(143), uint16(925),
 109748 	uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(1242),
 109749 	uint16(1242), uint16(1242), uint16(1242), uint16(1242), uint16(269), uint16(1602), uint16(1242), uint16(1601),
 109750 }
 109751 var yy_lookahead = [2283]uint16{
 109752 	uint16(193), uint16(193), uint16(193), uint16(274), uint16(275), uint16(276), uint16(193), uint16(274), uint16(275), uint16(276),
 109753 	uint16(193), uint16(223), uint16(219), uint16(225), uint16(206), uint16(210), uint16(211), uint16(212), uint16(193), uint16(19),
 109754 	uint16(219), uint16(233), uint16(216), uint16(216), uint16(217), uint16(216), uint16(217), uint16(193), uint16(295), uint16(216),
 109755 	uint16(217), uint16(31), uint16(193), uint16(216), uint16(217), uint16(193), uint16(228), uint16(213), uint16(230), uint16(39),
 109756 	uint16(206), uint16(216), uint16(217), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47), uint16(48), uint16(49),
 109757 	uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(193), uint16(19),
 109758 	uint16(185), uint16(186), uint16(187), uint16(188), uint16(189), uint16(190), uint16(253), uint16(274), uint16(275), uint16(276),
 109759 	uint16(195), uint16(193), uint16(197), uint16(193), uint16(261), uint16(274), uint16(275), uint16(276), uint16(253), uint16(204),
 109760 	uint16(238), uint16(204), uint16(81), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47), uint16(48), uint16(49),
 109761 	uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(274), uint16(275),
 109762 	uint16(276), uint16(262), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109),
 109763 	uint16(110), uint16(111), uint16(112), uint16(113), uint16(239), uint16(240), uint16(239), uint16(240), uint16(210), uint16(211),
 109764 	uint16(212), uint16(314), uint16(315), uint16(314), uint16(59), uint16(316), uint16(86), uint16(252), uint16(88), uint16(252),
 109765 	uint16(19), uint16(314), uint16(315), uint16(256), uint16(257), uint16(113), uint16(25), uint16(72), uint16(296), uint16(138),
 109766 	uint16(139), uint16(266), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109),
 109767 	uint16(110), uint16(111), uint16(112), uint16(113), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47), uint16(48),
 109768 	uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(81),
 109769 	uint16(292), uint16(59), uint16(292), uint16(298), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113),
 109770 	uint16(69), uint16(116), uint16(117), uint16(118), uint16(72), uint16(106), uint16(107), uint16(193), uint16(111), uint16(112),
 109771 	uint16(113), uint16(54), uint16(55), uint16(56), uint16(57), uint16(58), uint16(102), uint16(103), uint16(104), uint16(105),
 109772 	uint16(106), uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(120), uint16(25),
 109773 	uint16(216), uint16(217), uint16(145), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108),
 109774 	uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(231), uint16(138), uint16(139), uint16(116), uint16(117),
 109775 	uint16(118), uint16(164), uint16(153), uint16(19), uint16(155), uint16(54), uint16(55), uint16(56), uint16(57), uint16(102),
 109776 	uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112),
 109777 	uint16(113), uint16(128), uint16(129), uint16(46), uint16(47), uint16(48), uint16(49), uint16(43), uint16(44), uint16(45),
 109778 	uint16(46), uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55),
 109779 	uint16(56), uint16(57), uint16(216), uint16(193), uint16(25), uint16(59), uint16(193), uint16(19), uint16(165), uint16(166),
 109780 	uint16(193), uint16(67), uint16(24), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108),
 109781 	uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(73), uint16(216), uint16(217), uint16(59), uint16(216),
 109782 	uint16(217), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47), uint16(48), uint16(49), uint16(50), uint16(51),
 109783 	uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(102), uint16(103), uint16(104), uint16(105),
 109784 	uint16(106), uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(121), uint16(145),
 109785 	uint16(59), uint16(193), uint16(116), uint16(117), uint16(118), uint16(119), uint16(273), uint16(204), uint16(122), uint16(123),
 109786 	uint16(124), uint16(19), uint16(20), uint16(134), uint16(22), uint16(136), uint16(137), uint16(19), uint16(132), uint16(127),
 109787 	uint16(128), uint16(129), uint16(24), uint16(22), uint16(23), uint16(116), uint16(117), uint16(118), uint16(36), uint16(193),
 109788 	uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109), uint16(110), uint16(111),
 109789 	uint16(112), uint16(113), uint16(239), uint16(240), uint16(311), uint16(312), uint16(215), uint16(106), uint16(107), uint16(241),
 109790 	uint16(19), uint16(59), uint16(216), uint16(217), uint16(223), uint16(252), uint16(115), uint16(116), uint16(117), uint16(118),
 109791 	uint16(151), uint16(120), uint16(26), uint16(71), uint16(193), uint16(308), uint16(309), uint16(193), uint16(149), uint16(128),
 109792 	uint16(313), uint16(216), uint16(269), uint16(81), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47), uint16(48),
 109793 	uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(253),
 109794 	uint16(216), uint16(217), uint16(100), uint16(95), uint16(153), uint16(59), uint16(155), uint16(261), uint16(106), uint16(107),
 109795 	uint16(25), uint16(193), uint16(101), uint16(193), uint16(193), uint16(231), uint16(114), uint16(25), uint16(116), uint16(117),
 109796 	uint16(118), uint16(113), uint16(304), uint16(121), uint16(193), uint16(204), uint16(59), uint16(119), uint16(120), uint16(121),
 109797 	uint16(122), uint16(123), uint16(124), uint16(125), uint16(216), uint16(217), uint16(193), uint16(216), uint16(217), uint16(131),
 109798 	uint16(138), uint16(139), uint16(230), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108),
 109799 	uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(153), uint16(154), uint16(155), uint16(156), uint16(157),
 109800 	uint16(239), uint16(240), uint16(116), uint16(117), uint16(118), uint16(76), uint16(193), uint16(23), uint16(19), uint16(25),
 109801 	uint16(22), uint16(253), uint16(23), uint16(252), uint16(253), uint16(108), uint16(87), uint16(204), uint16(89), uint16(261),
 109802 	uint16(198), uint16(92), uint16(261), uint16(116), uint16(117), uint16(118), uint16(193), uint16(306), uint16(307), uint16(216),
 109803 	uint16(217), uint16(150), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47), uint16(48), uint16(49), uint16(50),
 109804 	uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(59), uint16(193), uint16(216),
 109805 	uint16(217), uint16(19), uint16(239), uint16(240), uint16(283), uint16(23), uint16(106), uint16(107), uint16(108), uint16(109),
 109806 	uint16(110), uint16(111), uint16(112), uint16(113), uint16(73), uint16(252), uint16(253), uint16(142), uint16(308), uint16(309),
 109807 	uint16(138), uint16(139), uint16(81), uint16(313), uint16(145), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47),
 109808 	uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57),
 109809 	uint16(307), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109), uint16(110),
 109810 	uint16(111), uint16(112), uint16(113), uint16(281), uint16(116), uint16(117), uint16(118), uint16(285), uint16(23), uint16(193),
 109811 	uint16(25), uint16(119), uint16(59), uint16(193), uint16(122), uint16(123), uint16(124), uint16(59), uint16(127), uint16(203),
 109812 	uint16(59), uint16(205), uint16(19), uint16(268), uint16(132), uint16(25), uint16(23), uint16(22), uint16(193), uint16(138),
 109813 	uint16(139), uint16(249), uint16(204), uint16(251), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107),
 109814 	uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(43), uint16(44), uint16(45), uint16(46),
 109815 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109816 	uint16(57), uint16(19), uint16(22), uint16(23), uint16(59), uint16(23), uint16(25), uint16(239), uint16(240), uint16(116),
 109817 	uint16(117), uint16(118), uint16(193), uint16(11), uint16(116), uint16(117), uint16(118), uint16(116), uint16(117), uint16(118),
 109818 	uint16(252), uint16(269), uint16(22), uint16(193), uint16(15), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47),
 109819 	uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57),
 109820 	uint16(273), uint16(143), uint16(193), uint16(118), uint16(143), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109821 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(76), uint16(118), uint16(59),
 109822 	uint16(241), uint16(116), uint16(117), uint16(118), uint16(304), uint16(216), uint16(217), uint16(292), uint16(143), uint16(60),
 109823 	uint16(89), uint16(241), uint16(19), uint16(92), uint16(193), uint16(193), uint16(23), uint16(22), uint16(311), uint16(312),
 109824 	uint16(231), uint16(101), uint16(22), uint16(143), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107),
 109825 	uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(43), uint16(44), uint16(45), uint16(46),
 109826 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109827 	uint16(57), uint16(19), uint16(193), uint16(193), uint16(59), uint16(23), uint16(116), uint16(117), uint16(118), uint16(59),
 109828 	uint16(201), uint16(21), uint16(241), uint16(304), uint16(22), uint16(206), uint16(127), uint16(128), uint16(129), uint16(193),
 109829 	uint16(128), uint16(129), uint16(235), uint16(236), uint16(304), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47),
 109830 	uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57),
 109831 	uint16(22), uint16(193), uint16(216), uint16(217), uint16(193), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109832 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(231), uint16(193), uint16(193),
 109833 	uint16(193), uint16(116), uint16(117), uint16(118), uint16(216), uint16(217), uint16(116), uint16(117), uint16(118), uint16(226),
 109834 	uint16(80), uint16(193), uint16(19), uint16(235), uint16(236), uint16(304), uint16(23), uint16(211), uint16(212), uint16(231),
 109835 	uint16(204), uint16(216), uint16(217), uint16(205), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107),
 109836 	uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(43), uint16(44), uint16(45), uint16(46),
 109837 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109838 	uint16(57), uint16(19), uint16(193), uint16(123), uint16(76), uint16(239), uint16(240), uint16(193), uint16(253), uint16(239),
 109839 	uint16(240), uint16(239), uint16(240), uint16(193), uint16(106), uint16(107), uint16(193), uint16(89), uint16(252), uint16(193),
 109840 	uint16(92), uint16(59), uint16(252), uint16(141), uint16(252), uint16(43), uint16(44), uint16(45), uint16(46), uint16(47),
 109841 	uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56), uint16(57),
 109842 	uint16(284), uint16(161), uint16(216), uint16(217), uint16(193), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109843 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(231), uint16(193), uint16(16),
 109844 	uint16(187), uint16(188), uint16(189), uint16(190), uint16(7), uint16(8), uint16(9), uint16(309), uint16(195), uint16(25),
 109845 	uint16(197), uint16(313), uint16(19), uint16(127), uint16(128), uint16(129), uint16(262), uint16(204), uint16(22), uint16(117),
 109846 	uint16(24), uint16(216), uint16(217), uint16(263), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106), uint16(107),
 109847 	uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(43), uint16(44), uint16(45), uint16(46),
 109848 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109849 	uint16(57), uint16(193), uint16(239), uint16(240), uint16(193), uint16(59), uint16(19), uint16(188), uint16(253), uint16(190),
 109850 	uint16(77), uint16(226), uint16(79), uint16(193), uint16(195), uint16(252), uint16(197), uint16(193), uint16(19), uint16(301),
 109851 	uint16(302), uint16(193), uint16(193), uint16(204), uint16(216), uint16(217), uint16(226), uint16(216), uint16(217), uint16(266),
 109852 	uint16(204), uint16(159), uint16(45), uint16(46), uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52),
 109853 	uint16(53), uint16(54), uint16(55), uint16(56), uint16(57), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109854 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(12), uint16(239), uint16(240),
 109855 	uint16(232), uint16(298), uint16(238), uint16(117), uint16(253), uint16(239), uint16(240), uint16(238), uint16(259), uint16(260),
 109856 	uint16(193), uint16(252), uint16(27), uint16(31), uint16(193), uint16(193), uint16(142), uint16(204), uint16(252), uint16(193),
 109857 	uint16(193), uint16(39), uint16(262), uint16(193), uint16(100), uint16(266), uint16(278), uint16(42), uint16(204), uint16(102),
 109858 	uint16(103), uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112),
 109859 	uint16(113), uint16(117), uint16(159), uint16(216), uint16(217), uint16(121), uint16(216), uint16(217), uint16(63), uint16(193),
 109860 	uint16(193), uint16(193), uint16(239), uint16(240), uint16(115), uint16(116), uint16(193), uint16(298), uint16(73), uint16(238),
 109861 	uint16(238), uint16(231), uint16(19), uint16(239), uint16(240), uint16(252), uint16(22), uint16(24), uint16(211), uint16(212),
 109862 	uint16(24), uint16(193), uint16(216), uint16(217), uint16(216), uint16(217), uint16(252), uint16(153), uint16(154), uint16(155),
 109863 	uint16(253), uint16(16), uint16(19), uint16(144), uint16(213), uint16(268), uint16(43), uint16(44), uint16(45), uint16(46),
 109864 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109865 	uint16(57), uint16(238), uint16(19), uint16(59), uint16(193), uint16(59), uint16(43), uint16(44), uint16(45), uint16(46),
 109866 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109867 	uint16(57), uint16(22), uint16(23), uint16(193), uint16(25), uint16(193), uint16(43), uint16(44), uint16(45), uint16(46),
 109868 	uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53), uint16(54), uint16(55), uint16(56),
 109869 	uint16(57), uint16(284), uint16(77), uint16(193), uint16(79), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109870 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(286), uint16(193), uint16(193),
 109871 	uint16(193), uint16(117), uint16(291), uint16(117), uint16(232), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109872 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(204), uint16(22), uint16(23),
 109873 	uint16(66), uint16(25), uint16(216), uint16(217), uint16(35), uint16(102), uint16(103), uint16(104), uint16(105), uint16(106),
 109874 	uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113), uint16(193), uint16(268), uint16(85),
 109875 	uint16(101), uint16(193), uint16(309), uint16(309), uint16(240), uint16(19), uint16(313), uint16(313), uint16(94), uint16(208),
 109876 	uint16(209), uint16(193), uint16(239), uint16(240), uint16(193), uint16(66), uint16(252), uint16(19), uint16(268), uint16(244),
 109877 	uint16(216), uint16(217), uint16(193), uint16(74), uint16(213), uint16(252), uint16(161), uint16(19), uint16(263), uint16(254),
 109878 	uint16(44), uint16(45), uint16(46), uint16(47), uint16(48), uint16(49), uint16(50), uint16(51), uint16(52), uint16(53),
 109879 	uint16(54), uint16(55), uint16(56), uint16(57), uint16(193), uint16(216), uint16(217), uint16(5), uint16(59), uint16(193),
 109880 	uint16(19), uint16(244), uint16(10), uint16(11), uint16(12), uint16(13), uint16(14), uint16(101), uint16(309), uint16(17),
 109881 	uint16(146), uint16(254), uint16(313), uint16(193), uint16(193), uint16(76), uint16(115), uint16(216), uint16(217), uint16(309),
 109882 	uint16(12), uint16(263), uint16(30), uint16(313), uint16(32), uint16(46), uint16(87), uint16(46), uint16(89), uint16(130),
 109883 	uint16(193), uint16(92), uint16(40), uint16(22), uint16(263), uint16(27), uint16(216), uint16(217), uint16(102), uint16(103),
 109884 	uint16(104), uint16(105), uint16(106), uint16(107), uint16(108), uint16(109), uint16(110), uint16(111), uint16(112), uint16(113),
 109885 	uint16(42), uint16(150), uint16(291), uint16(216), uint16(217), uint16(116), uint16(117), uint16(118), uint16(19), uint16(20),
 109886 	uint16(193), uint16(22), uint16(70), uint16(260), uint16(116), uint16(193), uint16(24), uint16(264), uint16(193), uint16(263),
 109887 	uint16(78), uint16(63), uint16(61), uint16(81), uint16(116), uint16(36), uint16(193), uint16(260), uint16(193), uint16(29),
 109888 	uint16(193), uint16(264), uint16(193), uint16(33), uint16(145), uint16(193), uint16(59), uint16(48), uint16(216), uint16(217),
 109889 	uint16(98), uint16(216), uint16(217), uint16(193), uint16(115), uint16(193), uint16(115), uint16(193), uint16(59), uint16(216),
 109890 	uint16(217), uint16(216), uint16(217), uint16(216), uint16(217), uint16(216), uint16(217), uint16(255), uint16(216), uint16(217),
 109891 	uint16(71), uint16(193), uint16(131), uint16(193), uint16(25), uint16(65), uint16(216), uint16(217), uint16(216), uint16(217),
 109892 	uint16(216), uint16(217), uint16(208), uint16(209), uint16(85), uint16(133), uint16(193), uint16(100), uint16(193), uint16(90),
 109893 	uint16(138), uint16(139), uint16(138), uint16(139), uint16(216), uint16(217), uint16(216), uint16(217), uint16(193), uint16(100),
 109894 	uint16(193), uint16(108), uint16(135), uint16(116), uint16(117), uint16(106), uint16(107), uint16(140), uint16(121), uint16(216),
 109895 	uint16(217), uint16(216), uint16(217), uint16(114), uint16(162), uint16(116), uint16(117), uint16(118), uint16(299), uint16(300),
 109896 	uint16(121), uint16(216), uint16(217), uint16(216), uint16(217), uint16(193), uint16(244), uint16(193), uint16(135), uint16(244),
 109897 	uint16(193), uint16(256), uint16(257), uint16(140), uint16(244), uint16(193), uint16(254), uint16(193), uint16(193), uint16(254),
 109898 	uint16(153), uint16(154), uint16(155), uint16(141), uint16(254), uint16(149), uint16(150), uint16(258), uint16(216), uint16(217),
 109899 	uint16(216), uint16(217), uint16(153), uint16(154), uint16(155), uint16(156), uint16(157), uint16(0), uint16(1), uint16(2),
 109900 	uint16(216), uint16(217), uint16(5), uint16(115), uint16(158), uint16(193), uint16(160), uint16(10), uint16(11), uint16(12),
 109901 	uint16(13), uint16(14), uint16(193), uint16(59), uint16(17), uint16(126), uint16(193), uint16(19), uint16(20), uint16(129),
 109902 	uint16(22), uint16(193), uint16(22), uint16(22), uint16(24), uint16(193), uint16(23), uint16(30), uint16(25), uint16(32),
 109903 	uint16(19), uint16(20), uint16(144), uint16(22), uint16(36), uint16(216), uint16(217), uint16(40), uint16(193), uint16(216),
 109904 	uint16(217), uint16(193), uint16(152), uint16(129), uint16(216), uint16(217), uint16(193), uint16(36), uint16(216), uint16(217),
 109905 	uint16(193), uint16(99), uint16(193), uint16(193), uint16(53), uint16(193), uint16(193), uint16(59), uint16(23), uint16(193),
 109906 	uint16(25), uint16(216), uint16(217), uint16(193), uint16(216), uint16(217), uint16(152), uint16(70), uint16(59), uint16(71),
 109907 	uint16(59), uint16(117), uint16(193), uint16(216), uint16(217), uint16(78), uint16(216), uint16(217), uint16(81), uint16(216),
 109908 	uint16(217), uint16(318), uint16(71), uint16(85), uint16(193), uint16(133), uint16(193), uint16(193), uint16(90), uint16(23),
 109909 	uint16(23), uint16(25), uint16(25), uint16(120), uint16(121), uint16(98), uint16(85), uint16(193), uint16(100), uint16(193),
 109910 	uint16(23), uint16(90), uint16(25), uint16(121), uint16(106), uint16(107), uint16(19), uint16(216), uint16(217), uint16(216),
 109911 	uint16(217), uint16(100), uint16(114), uint16(131), uint16(116), uint16(117), uint16(118), uint16(106), uint16(107), uint16(121),
 109912 	uint16(216), uint16(217), uint16(216), uint16(217), uint16(193), uint16(114), uint16(117), uint16(116), uint16(117), uint16(118),
 109913 	uint16(133), uint16(193), uint16(121), uint16(193), uint16(193), uint16(138), uint16(139), uint16(193), uint16(23), uint16(193),
 109914 	uint16(25), uint16(23), uint16(23), uint16(25), uint16(25), uint16(7), uint16(8), uint16(216), uint16(217), uint16(193),
 109915 	uint16(193), uint16(153), uint16(154), uint16(155), uint16(156), uint16(157), uint16(216), uint16(217), uint16(193), uint16(162),
 109916 	uint16(216), uint16(217), uint16(216), uint16(217), uint16(153), uint16(154), uint16(155), uint16(156), uint16(157), uint16(1),
 109917 	uint16(2), uint16(193), uint16(193), uint16(5), uint16(19), uint16(20), uint16(59), uint16(22), uint16(10), uint16(11),
 109918 	uint16(12), uint16(13), uint16(14), uint16(193), uint16(97), uint16(17), uint16(193), uint16(23), uint16(193), uint16(25),
 109919 	uint16(288), uint16(36), uint16(193), uint16(242), uint16(216), uint16(217), uint16(236), uint16(23), uint16(30), uint16(25),
 109920 	uint16(32), uint16(19), uint16(20), uint16(23), uint16(22), uint16(25), uint16(216), uint16(217), uint16(40), uint16(216),
 109921 	uint16(217), uint16(216), uint16(217), uint16(193), uint16(59), uint16(216), uint16(217), uint16(193), uint16(36), uint16(83),
 109922 	uint16(84), uint16(153), uint16(153), uint16(155), uint16(155), uint16(23), uint16(71), uint16(25), uint16(23), uint16(193),
 109923 	uint16(25), uint16(193), uint16(193), uint16(193), uint16(117), uint16(193), uint16(193), uint16(193), uint16(70), uint16(193),
 109924 	uint16(193), uint16(59), uint16(193), uint16(255), uint16(255), uint16(287), uint16(78), uint16(255), uint16(243), uint16(81),
 109925 	uint16(191), uint16(255), uint16(297), uint16(71), uint16(271), uint16(100), uint16(293), uint16(245), uint16(267), uint16(214),
 109926 	uint16(246), uint16(106), uint16(107), uint16(108), uint16(246), uint16(271), uint16(98), uint16(245), uint16(293), uint16(114),
 109927 	uint16(220), uint16(116), uint16(117), uint16(118), uint16(267), uint16(271), uint16(121), uint16(271), uint16(225), uint16(219),
 109928 	uint16(229), uint16(219), uint16(100), uint16(219), uint16(259), uint16(259), uint16(259), uint16(259), uint16(106), uint16(107),
 109929 	uint16(249), uint16(196), uint16(60), uint16(280), uint16(141), uint16(243), uint16(114), uint16(249), uint16(116), uint16(117),
 109930 	uint16(118), uint16(133), uint16(245), uint16(121), uint16(200), uint16(297), uint16(138), uint16(139), uint16(153), uint16(154),
 109931 	uint16(155), uint16(156), uint16(157), uint16(297), uint16(200), uint16(38), uint16(19), uint16(20), uint16(151), uint16(22),
 109932 	uint16(200), uint16(150), uint16(140), uint16(294), uint16(294), uint16(22), uint16(272), uint16(43), uint16(234), uint16(18),
 109933 	uint16(162), uint16(270), uint16(200), uint16(36), uint16(237), uint16(153), uint16(154), uint16(155), uint16(156), uint16(157),
 109934 	uint16(237), uint16(283), uint16(237), uint16(237), uint16(18), uint16(199), uint16(149), uint16(246), uint16(272), uint16(270),
 109935 	uint16(272), uint16(200), uint16(158), uint16(246), uint16(246), uint16(234), uint16(59), uint16(234), uint16(246), uint16(199),
 109936 	uint16(290), uint16(62), uint16(289), uint16(200), uint16(199), uint16(22), uint16(221), uint16(115), uint16(71), uint16(200),
 109937 	uint16(200), uint16(199), uint16(199), uint16(221), uint16(218), uint16(218), uint16(19), uint16(20), uint16(64), uint16(22),
 109938 	uint16(218), uint16(227), uint16(22), uint16(224), uint16(126), uint16(224), uint16(165), uint16(221), uint16(24), uint16(305),
 109939 	uint16(200), uint16(113), uint16(312), uint16(36), uint16(218), uint16(220), uint16(218), uint16(100), uint16(282), uint16(218),
 109940 	uint16(91), uint16(218), uint16(317), uint16(106), uint16(107), uint16(221), uint16(227), uint16(282), uint16(317), uint16(82),
 109941 	uint16(148), uint16(114), uint16(265), uint16(116), uint16(117), uint16(118), uint16(59), uint16(145), uint16(121), uint16(22),
 109942 	uint16(277), uint16(158), uint16(200), uint16(265), uint16(25), uint16(202), uint16(147), uint16(250), uint16(71), uint16(279),
 109943 	uint16(13), uint16(146), uint16(194), uint16(194), uint16(249), uint16(248), uint16(250), uint16(140), uint16(247), uint16(246),
 109944 	uint16(6), uint16(192), uint16(192), uint16(192), uint16(303), uint16(303), uint16(213), uint16(207), uint16(300), uint16(213),
 109945 	uint16(153), uint16(154), uint16(155), uint16(156), uint16(157), uint16(213), uint16(213), uint16(100), uint16(213), uint16(222),
 109946 	uint16(207), uint16(214), uint16(214), uint16(106), uint16(107), uint16(4), uint16(222), uint16(207), uint16(3), uint16(22),
 109947 	uint16(163), uint16(114), uint16(15), uint16(116), uint16(117), uint16(118), uint16(16), uint16(23), uint16(121), uint16(23),
 109948 	uint16(139), uint16(151), uint16(130), uint16(25), uint16(142), uint16(16), uint16(24), uint16(20), uint16(144), uint16(1),
 109949 	uint16(142), uint16(130), uint16(130), uint16(61), uint16(53), uint16(53), uint16(37), uint16(151), uint16(53), uint16(53),
 109950 	uint16(130), uint16(116), uint16(34), uint16(1), uint16(141), uint16(5), uint16(22), uint16(115), uint16(161), uint16(141),
 109951 	uint16(153), uint16(154), uint16(155), uint16(156), uint16(157), uint16(25), uint16(68), uint16(68), uint16(75), uint16(41),
 109952 	uint16(115), uint16(24), uint16(131), uint16(20), uint16(19), uint16(125), uint16(22), uint16(96), uint16(22), uint16(22),
 109953 	uint16(67), uint16(23), uint16(22), uint16(67), uint16(59), uint16(24), uint16(22), uint16(28), uint16(67), uint16(23),
 109954 	uint16(22), uint16(22), uint16(149), uint16(23), uint16(23), uint16(23), uint16(116), uint16(23), uint16(25), uint16(37),
 109955 	uint16(97), uint16(141), uint16(23), uint16(23), uint16(22), uint16(143), uint16(25), uint16(75), uint16(88), uint16(34),
 109956 	uint16(34), uint16(34), uint16(34), uint16(86), uint16(75), uint16(93), uint16(23), uint16(34), uint16(22), uint16(34),
 109957 	uint16(25), uint16(24), uint16(34), uint16(25), uint16(23), uint16(142), uint16(23), uint16(142), uint16(44), uint16(23),
 109958 	uint16(23), uint16(23), uint16(11), uint16(23), uint16(25), uint16(22), uint16(22), uint16(22), uint16(15), uint16(23),
 109959 	uint16(23), uint16(22), uint16(22), uint16(25), uint16(1), uint16(1), uint16(141), uint16(25), uint16(23), uint16(135),
 109960 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109961 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(141), uint16(141), uint16(319), uint16(141), uint16(319), uint16(319),
 109962 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109963 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109964 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109965 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109966 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109967 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109968 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109969 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109970 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109971 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109972 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109973 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109974 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109975 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109976 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109977 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109978 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109979 	uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319), uint16(319),
 109980 	uint16(319), uint16(319), uint16(319),
 109981 }
 109982 var yy_shift_ofst = [576]uint16{
 109983 	uint16(1648), uint16(1477), uint16(1272), uint16(322), uint16(322), uint16(1), uint16(1319), uint16(1478), uint16(1491), uint16(1837),
 109984 	uint16(1837), uint16(1837), uint16(471), uint16(0), uint16(0), uint16(214), uint16(1093), uint16(1837), uint16(1837), uint16(1837),
 109985 	uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837),
 109986 	uint16(271), uint16(271), uint16(1219), uint16(1219), uint16(216), uint16(88), uint16(1), uint16(1), uint16(1), uint16(1),
 109987 	uint16(1), uint16(40), uint16(111), uint16(258), uint16(361), uint16(469), uint16(512), uint16(583), uint16(622), uint16(693),
 109988 	uint16(732), uint16(803), uint16(842), uint16(913), uint16(1073), uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093),
 109989 	uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093), uint16(1093),
 109990 	uint16(1093), uint16(1093), uint16(1093), uint16(1113), uint16(1093), uint16(1216), uint16(957), uint16(957), uint16(1635), uint16(1662),
 109991 	uint16(1777), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837),
 109992 	uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837),
 109993 	uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837),
 109994 	uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837),
 109995 	uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837), uint16(1837),
 109996 	uint16(137), uint16(181), uint16(181), uint16(181), uint16(181), uint16(181), uint16(181), uint16(181), uint16(94), uint16(430),
 109997 	uint16(66), uint16(65), uint16(112), uint16(366), uint16(533), uint16(533), uint16(740), uint16(1261), uint16(533), uint16(533),
 109998 	uint16(79), uint16(79), uint16(533), uint16(412), uint16(412), uint16(412), uint16(77), uint16(412), uint16(123), uint16(113),
 109999 	uint16(113), uint16(22), uint16(22), uint16(2098), uint16(2098), uint16(328), uint16(328), uint16(328), uint16(239), uint16(468),
 110000 	uint16(468), uint16(468), uint16(468), uint16(1015), uint16(1015), uint16(409), uint16(366), uint16(1129), uint16(1186), uint16(533),
 110001 	uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533),
 110002 	uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(969),
 110003 	uint16(621), uint16(621), uint16(533), uint16(642), uint16(788), uint16(788), uint16(1228), uint16(1228), uint16(822), uint16(822),
 110004 	uint16(67), uint16(1274), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(1307),
 110005 	uint16(954), uint16(954), uint16(585), uint16(472), uint16(640), uint16(387), uint16(695), uint16(538), uint16(541), uint16(700),
 110006 	uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533),
 110007 	uint16(222), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533),
 110008 	uint16(533), uint16(533), uint16(533), uint16(1179), uint16(1179), uint16(1179), uint16(533), uint16(533), uint16(533), uint16(565),
 110009 	uint16(533), uint16(533), uint16(533), uint16(916), uint16(1144), uint16(533), uint16(533), uint16(1288), uint16(533), uint16(533),
 110010 	uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(533), uint16(639), uint16(1330), uint16(209), uint16(1076),
 110011 	uint16(1076), uint16(1076), uint16(1076), uint16(580), uint16(209), uint16(209), uint16(1313), uint16(768), uint16(917), uint16(649),
 110012 	uint16(1181), uint16(1316), uint16(405), uint16(1316), uint16(1238), uint16(249), uint16(1181), uint16(1181), uint16(249), uint16(1181),
 110013 	uint16(405), uint16(1238), uint16(1369), uint16(464), uint16(1259), uint16(1012), uint16(1012), uint16(1012), uint16(1368), uint16(1368),
 110014 	uint16(1368), uint16(1368), uint16(184), uint16(184), uint16(1326), uint16(904), uint16(1287), uint16(1480), uint16(1712), uint16(1712),
 110015 	uint16(1633), uint16(1633), uint16(1757), uint16(1757), uint16(1633), uint16(1647), uint16(1651), uint16(1783), uint16(1764), uint16(1791),
 110016 	uint16(1791), uint16(1791), uint16(1791), uint16(1633), uint16(1806), uint16(1677), uint16(1651), uint16(1651), uint16(1677), uint16(1783),
 110017 	uint16(1764), uint16(1677), uint16(1764), uint16(1677), uint16(1633), uint16(1806), uint16(1674), uint16(1779), uint16(1633), uint16(1806),
 110018 	uint16(1823), uint16(1633), uint16(1806), uint16(1633), uint16(1806), uint16(1823), uint16(1732), uint16(1732), uint16(1732), uint16(1794),
 110019 	uint16(1840), uint16(1840), uint16(1823), uint16(1732), uint16(1738), uint16(1732), uint16(1794), uint16(1732), uint16(1732), uint16(1701),
 110020 	uint16(1844), uint16(1758), uint16(1758), uint16(1823), uint16(1633), uint16(1789), uint16(1789), uint16(1807), uint16(1807), uint16(1742),
 110021 	uint16(1752), uint16(1877), uint16(1633), uint16(1743), uint16(1742), uint16(1759), uint16(1765), uint16(1677), uint16(1879), uint16(1897),
 110022 	uint16(1897), uint16(1914), uint16(1914), uint16(1914), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098),
 110023 	uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(2098), uint16(207),
 110024 	uint16(1095), uint16(331), uint16(620), uint16(903), uint16(806), uint16(1074), uint16(1483), uint16(1432), uint16(1481), uint16(1322),
 110025 	uint16(1370), uint16(1394), uint16(1515), uint16(1291), uint16(1546), uint16(1547), uint16(1557), uint16(1595), uint16(1598), uint16(1599),
 110026 	uint16(1434), uint16(1453), uint16(1618), uint16(1462), uint16(1567), uint16(1489), uint16(1644), uint16(1654), uint16(1616), uint16(1660),
 110027 	uint16(1548), uint16(1549), uint16(1682), uint16(1685), uint16(1597), uint16(742), uint16(1941), uint16(1945), uint16(1927), uint16(1787),
 110028 	uint16(1937), uint16(1940), uint16(1934), uint16(1936), uint16(1821), uint16(1810), uint16(1832), uint16(1938), uint16(1938), uint16(1942),
 110029 	uint16(1822), uint16(1947), uint16(1824), uint16(1949), uint16(1968), uint16(1828), uint16(1841), uint16(1938), uint16(1842), uint16(1912),
 110030 	uint16(1939), uint16(1938), uint16(1826), uint16(1921), uint16(1922), uint16(1925), uint16(1926), uint16(1850), uint16(1865), uint16(1948),
 110031 	uint16(1843), uint16(1982), uint16(1980), uint16(1964), uint16(1872), uint16(1827), uint16(1928), uint16(1970), uint16(1929), uint16(1923),
 110032 	uint16(1958), uint16(1848), uint16(1885), uint16(1977), uint16(1983), uint16(1985), uint16(1871), uint16(1880), uint16(1984), uint16(1943),
 110033 	uint16(1986), uint16(1987), uint16(1988), uint16(1990), uint16(1946), uint16(1955), uint16(1991), uint16(1911), uint16(1989), uint16(1994),
 110034 	uint16(1951), uint16(1992), uint16(1996), uint16(1873), uint16(1998), uint16(2000), uint16(2001), uint16(2002), uint16(2003), uint16(2004),
 110035 	uint16(1999), uint16(1933), uint16(1890), uint16(2009), uint16(2010), uint16(1910), uint16(2005), uint16(2012), uint16(1892), uint16(2011),
 110036 	uint16(2006), uint16(2007), uint16(2008), uint16(2013), uint16(1950), uint16(1962), uint16(1957), uint16(2014), uint16(1969), uint16(1952),
 110037 	uint16(2015), uint16(2023), uint16(2026), uint16(2027), uint16(2025), uint16(2028), uint16(2018), uint16(1913), uint16(1915), uint16(2031),
 110038 	uint16(2011), uint16(2033), uint16(2036), uint16(2037), uint16(2038), uint16(2039), uint16(2040), uint16(2043), uint16(2051), uint16(2044),
 110039 	uint16(2045), uint16(2046), uint16(2047), uint16(2049), uint16(2050), uint16(2048), uint16(1944), uint16(1935), uint16(1953), uint16(1954),
 110040 	uint16(1956), uint16(2052), uint16(2055), uint16(2053), uint16(2073), uint16(2074),
 110041 }
 110042 var yy_reduce_ofst = [409]int16{
 110043 	int16(-125), int16(733), int16(789), int16(241), int16(293), int16(-123), int16(-193), int16(-191), int16(-183), int16(-187),
 110044 	int16(166), int16(238), int16(133), int16(-207), int16(-199), int16(-267), int16(-176), int16(-6), int16(204), int16(489),
 110045 	int16(576), int16(-175), int16(598), int16(686), int16(615), int16(725), int16(860), int16(778), int16(781), int16(857),
 110046 	int16(616), int16(887), int16(87), int16(240), int16(-192), int16(408), int16(626), int16(796), int16(843), int16(854),
 110047 	int16(1003), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271),
 110048 	int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271),
 110049 	int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271),
 110050 	int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(80), int16(83),
 110051 	int16(313), int16(886), int16(888), int16(996), int16(1034), int16(1059), int16(1081), int16(1100), int16(1117), int16(1152),
 110052 	int16(1155), int16(1163), int16(1165), int16(1167), int16(1169), int16(1172), int16(1180), int16(1182), int16(1184), int16(1198),
 110053 	int16(1200), int16(1213), int16(1215), int16(1225), int16(1227), int16(1252), int16(1254), int16(1264), int16(1299), int16(1303),
 110054 	int16(1308), int16(1312), int16(1325), int16(1328), int16(1337), int16(1340), int16(1343), int16(1371), int16(1373), int16(1384),
 110055 	int16(1386), int16(1411), int16(1420), int16(1424), int16(1426), int16(1458), int16(1470), int16(1473), int16(1475), int16(1479),
 110056 	int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271), int16(-271),
 110057 	int16(-271), int16(138), int16(459), int16(396), int16(-158), int16(470), int16(302), int16(-212), int16(521), int16(201),
 110058 	int16(-195), int16(-92), int16(559), int16(630), int16(632), int16(630), int16(-271), int16(632), int16(901), int16(63),
 110059 	int16(407), int16(-271), int16(-271), int16(-271), int16(-271), int16(161), int16(161), int16(161), int16(251), int16(335),
 110060 	int16(847), int16(960), int16(980), int16(537), int16(588), int16(618), int16(628), int16(688), int16(688), int16(-166),
 110061 	int16(-161), int16(674), int16(790), int16(794), int16(799), int16(851), int16(852), int16(-122), int16(680), int16(-120),
 110062 	int16(995), int16(1038), int16(415), int16(1051), int16(893), int16(798), int16(962), int16(400), int16(1086), int16(779),
 110063 	int16(923), int16(924), int16(263), int16(1041), int16(979), int16(990), int16(1083), int16(1097), int16(1031), int16(1194),
 110064 	int16(362), int16(994), int16(1139), int16(1005), int16(1037), int16(1202), int16(1205), int16(1195), int16(1210), int16(-194),
 110065 	int16(56), int16(185), int16(-135), int16(232), int16(522), int16(560), int16(601), int16(617), int16(669), int16(683),
 110066 	int16(711), int16(856), int16(908), int16(941), int16(1048), int16(1101), int16(1147), int16(1257), int16(1262), int16(1265),
 110067 	int16(392), int16(1292), int16(1333), int16(1339), int16(1342), int16(1346), int16(1350), int16(1359), int16(1374), int16(1418),
 110068 	int16(1421), int16(1436), int16(1437), int16(593), int16(755), int16(770), int16(997), int16(1445), int16(1459), int16(1209),
 110069 	int16(1500), int16(1504), int16(1516), int16(1132), int16(1243), int16(1518), int16(1519), int16(1440), int16(1520), int16(560),
 110070 	int16(1522), int16(1523), int16(1524), int16(1526), int16(1527), int16(1529), int16(1382), int16(1438), int16(1431), int16(1468),
 110071 	int16(1469), int16(1472), int16(1476), int16(1209), int16(1431), int16(1431), int16(1485), int16(1525), int16(1539), int16(1435),
 110072 	int16(1463), int16(1471), int16(1492), int16(1487), int16(1443), int16(1494), int16(1474), int16(1484), int16(1498), int16(1486),
 110073 	int16(1502), int16(1455), int16(1530), int16(1531), int16(1533), int16(1540), int16(1542), int16(1544), int16(1505), int16(1506),
 110074 	int16(1507), int16(1508), int16(1521), int16(1528), int16(1493), int16(1537), int16(1532), int16(1575), int16(1488), int16(1496),
 110075 	int16(1584), int16(1594), int16(1509), int16(1510), int16(1600), int16(1538), int16(1534), int16(1541), int16(1574), int16(1577),
 110076 	int16(1583), int16(1585), int16(1586), int16(1612), int16(1626), int16(1581), int16(1556), int16(1558), int16(1587), int16(1559),
 110077 	int16(1601), int16(1588), int16(1603), int16(1592), int16(1631), int16(1640), int16(1550), int16(1553), int16(1643), int16(1645),
 110078 	int16(1625), int16(1649), int16(1652), int16(1650), int16(1653), int16(1632), int16(1636), int16(1637), int16(1642), int16(1634),
 110079 	int16(1639), int16(1641), int16(1646), int16(1656), int16(1655), int16(1658), int16(1659), int16(1661), int16(1663), int16(1560),
 110080 	int16(1564), int16(1596), int16(1605), int16(1664), int16(1670), int16(1565), int16(1571), int16(1627), int16(1638), int16(1657),
 110081 	int16(1665), int16(1623), int16(1702), int16(1630), int16(1666), int16(1667), int16(1671), int16(1673), int16(1703), int16(1718),
 110082 	int16(1719), int16(1729), int16(1730), int16(1731), int16(1621), int16(1622), int16(1628), int16(1720), int16(1713), int16(1716),
 110083 	int16(1722), int16(1723), int16(1733), int16(1717), int16(1724), int16(1727), int16(1728), int16(1725), int16(1740),
 110084 }
 110085 var yy_default = [576]uint16{
 110086 	uint16(1647), uint16(1647), uint16(1647), uint16(1475), uint16(1240), uint16(1351), uint16(1240), uint16(1240), uint16(1240), uint16(1475),
 110087 	uint16(1475), uint16(1475), uint16(1240), uint16(1381), uint16(1381), uint16(1528), uint16(1273), uint16(1240), uint16(1240), uint16(1240),
 110088 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1474), uint16(1240), uint16(1240),
 110089 	uint16(1240), uint16(1240), uint16(1563), uint16(1563), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110090 	uint16(1240), uint16(1240), uint16(1390), uint16(1240), uint16(1397), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110091 	uint16(1476), uint16(1477), uint16(1240), uint16(1240), uint16(1240), uint16(1527), uint16(1529), uint16(1492), uint16(1404), uint16(1403),
 110092 	uint16(1402), uint16(1401), uint16(1510), uint16(1369), uint16(1395), uint16(1388), uint16(1392), uint16(1470), uint16(1471), uint16(1469),
 110093 	uint16(1473), uint16(1477), uint16(1476), uint16(1240), uint16(1391), uint16(1438), uint16(1454), uint16(1437), uint16(1240), uint16(1240),
 110094 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110095 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110096 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110097 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110098 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110099 	uint16(1446), uint16(1453), uint16(1452), uint16(1451), uint16(1460), uint16(1450), uint16(1447), uint16(1440), uint16(1439), uint16(1441),
 110100 	uint16(1442), uint16(1240), uint16(1240), uint16(1264), uint16(1240), uint16(1240), uint16(1261), uint16(1315), uint16(1240), uint16(1240),
 110101 	uint16(1240), uint16(1240), uint16(1240), uint16(1547), uint16(1546), uint16(1240), uint16(1443), uint16(1240), uint16(1273), uint16(1432),
 110102 	uint16(1431), uint16(1457), uint16(1444), uint16(1456), uint16(1455), uint16(1535), uint16(1599), uint16(1598), uint16(1493), uint16(1240),
 110103 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1563), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110104 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110105 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1371),
 110106 	uint16(1563), uint16(1563), uint16(1240), uint16(1273), uint16(1563), uint16(1563), uint16(1372), uint16(1372), uint16(1269), uint16(1269),
 110107 	uint16(1375), uint16(1240), uint16(1542), uint16(1342), uint16(1342), uint16(1342), uint16(1342), uint16(1351), uint16(1342), uint16(1240),
 110108 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110109 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1532), uint16(1530), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110110 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110111 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110112 	uint16(1240), uint16(1240), uint16(1240), uint16(1347), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110113 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1592), uint16(1240), uint16(1505), uint16(1329), uint16(1347),
 110114 	uint16(1347), uint16(1347), uint16(1347), uint16(1349), uint16(1330), uint16(1328), uint16(1341), uint16(1274), uint16(1247), uint16(1639),
 110115 	uint16(1407), uint16(1396), uint16(1348), uint16(1396), uint16(1636), uint16(1394), uint16(1407), uint16(1407), uint16(1394), uint16(1407),
 110116 	uint16(1348), uint16(1636), uint16(1290), uint16(1615), uint16(1285), uint16(1381), uint16(1381), uint16(1381), uint16(1371), uint16(1371),
 110117 	uint16(1371), uint16(1371), uint16(1375), uint16(1375), uint16(1472), uint16(1348), uint16(1341), uint16(1240), uint16(1639), uint16(1639),
 110118 	uint16(1357), uint16(1357), uint16(1638), uint16(1638), uint16(1357), uint16(1493), uint16(1623), uint16(1416), uint16(1318), uint16(1324),
 110119 	uint16(1324), uint16(1324), uint16(1324), uint16(1357), uint16(1258), uint16(1394), uint16(1623), uint16(1623), uint16(1394), uint16(1416),
 110120 	uint16(1318), uint16(1394), uint16(1318), uint16(1394), uint16(1357), uint16(1258), uint16(1509), uint16(1633), uint16(1357), uint16(1258),
 110121 	uint16(1483), uint16(1357), uint16(1258), uint16(1357), uint16(1258), uint16(1483), uint16(1316), uint16(1316), uint16(1316), uint16(1305),
 110122 	uint16(1240), uint16(1240), uint16(1483), uint16(1316), uint16(1290), uint16(1316), uint16(1305), uint16(1316), uint16(1316), uint16(1581),
 110123 	uint16(1240), uint16(1487), uint16(1487), uint16(1483), uint16(1357), uint16(1573), uint16(1573), uint16(1384), uint16(1384), uint16(1389),
 110124 	uint16(1375), uint16(1478), uint16(1357), uint16(1240), uint16(1389), uint16(1387), uint16(1385), uint16(1394), uint16(1308), uint16(1595),
 110125 	uint16(1595), uint16(1591), uint16(1591), uint16(1591), uint16(1644), uint16(1644), uint16(1542), uint16(1608), uint16(1273), uint16(1273),
 110126 	uint16(1273), uint16(1273), uint16(1608), uint16(1292), uint16(1292), uint16(1274), uint16(1274), uint16(1273), uint16(1608), uint16(1240),
 110127 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1603), uint16(1240), uint16(1537), uint16(1494), uint16(1361),
 110128 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110129 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1548), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110130 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1421), uint16(1240), uint16(1243), uint16(1539), uint16(1240),
 110131 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1398), uint16(1399), uint16(1362),
 110132 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1413), uint16(1240), uint16(1240),
 110133 	uint16(1240), uint16(1408), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110134 	uint16(1635), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1508), uint16(1507), uint16(1240),
 110135 	uint16(1240), uint16(1359), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110136 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1288), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110137 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110138 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1386),
 110139 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110140 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1578), uint16(1376), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110141 	uint16(1626), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240),
 110142 	uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1240), uint16(1619), uint16(1332), uint16(1423), uint16(1240), uint16(1422),
 110143 	uint16(1426), uint16(1262), uint16(1240), uint16(1252), uint16(1240), uint16(1240),
 110144 }
 110145 
 110146 var yyFallback = [185]uint16{
 110147 	uint16(0),
 110148 	uint16(0),
 110149 	uint16(59),
 110150 	uint16(59),
 110151 	uint16(59),
 110152 	uint16(59),
 110153 	uint16(0),
 110154 	uint16(59),
 110155 	uint16(59),
 110156 	uint16(59),
 110157 	uint16(0),
 110158 	uint16(59),
 110159 	uint16(59),
 110160 	uint16(59),
 110161 	uint16(59),
 110162 	uint16(0),
 110163 	uint16(0),
 110164 	uint16(0),
 110165 	uint16(59),
 110166 	uint16(0),
 110167 	uint16(0),
 110168 	uint16(59),
 110169 	uint16(0),
 110170 	uint16(0),
 110171 	uint16(0),
 110172 	uint16(0),
 110173 	uint16(59),
 110174 	uint16(59),
 110175 	uint16(59),
 110176 	uint16(59),
 110177 	uint16(59),
 110178 	uint16(59),
 110179 	uint16(59),
 110180 	uint16(59),
 110181 	uint16(59),
 110182 	uint16(59),
 110183 	uint16(59),
 110184 	uint16(59),
 110185 	uint16(59),
 110186 	uint16(59),
 110187 	uint16(59),
 110188 	uint16(59),
 110189 	uint16(59),
 110190 	uint16(0),
 110191 	uint16(0),
 110192 	uint16(0),
 110193 	uint16(59),
 110194 	uint16(59),
 110195 	uint16(0),
 110196 	uint16(0),
 110197 	uint16(0),
 110198 	uint16(0),
 110199 	uint16(0),
 110200 	uint16(0),
 110201 	uint16(0),
 110202 	uint16(0),
 110203 	uint16(0),
 110204 	uint16(0),
 110205 	uint16(0),
 110206 	uint16(0),
 110207 	uint16(59),
 110208 	uint16(59),
 110209 	uint16(59),
 110210 	uint16(59),
 110211 	uint16(59),
 110212 	uint16(59),
 110213 	uint16(59),
 110214 	uint16(59),
 110215 	uint16(59),
 110216 	uint16(59),
 110217 	uint16(59),
 110218 	uint16(59),
 110219 	uint16(59),
 110220 	uint16(59),
 110221 	uint16(59),
 110222 	uint16(59),
 110223 	uint16(59),
 110224 	uint16(59),
 110225 	uint16(59),
 110226 	uint16(59),
 110227 	uint16(59),
 110228 	uint16(59),
 110229 	uint16(59),
 110230 	uint16(59),
 110231 	uint16(59),
 110232 	uint16(59),
 110233 	uint16(59),
 110234 	uint16(59),
 110235 	uint16(59),
 110236 	uint16(59),
 110237 	uint16(59),
 110238 	uint16(59),
 110239 	uint16(59),
 110240 	uint16(59),
 110241 	uint16(59),
 110242 	uint16(59),
 110243 	uint16(59),
 110244 	uint16(59),
 110245 	uint16(59),
 110246 	uint16(59),
 110247 	uint16(59),
 110248 	uint16(0),
 110249 	uint16(0),
 110250 	uint16(0),
 110251 	uint16(0),
 110252 	uint16(0),
 110253 	uint16(0),
 110254 	uint16(0),
 110255 	uint16(0),
 110256 	uint16(0),
 110257 	uint16(0),
 110258 	uint16(0),
 110259 	uint16(0),
 110260 	uint16(0),
 110261 	uint16(0),
 110262 	uint16(0),
 110263 	uint16(0),
 110264 	uint16(0),
 110265 	uint16(0),
 110266 	uint16(0),
 110267 	uint16(0),
 110268 	uint16(0),
 110269 	uint16(0),
 110270 	uint16(0),
 110271 	uint16(0),
 110272 	uint16(0),
 110273 	uint16(0),
 110274 	uint16(0),
 110275 	uint16(0),
 110276 	uint16(0),
 110277 	uint16(0),
 110278 	uint16(0),
 110279 	uint16(0),
 110280 	uint16(0),
 110281 	uint16(0),
 110282 	uint16(0),
 110283 	uint16(0),
 110284 	uint16(0),
 110285 	uint16(0),
 110286 	uint16(0),
 110287 	uint16(0),
 110288 	uint16(0),
 110289 	uint16(0),
 110290 	uint16(0),
 110291 	uint16(0),
 110292 	uint16(0),
 110293 	uint16(0),
 110294 	uint16(0),
 110295 	uint16(0),
 110296 	uint16(0),
 110297 	uint16(0),
 110298 	uint16(0),
 110299 	uint16(0),
 110300 	uint16(0),
 110301 	uint16(0),
 110302 	uint16(0),
 110303 	uint16(0),
 110304 	uint16(0),
 110305 	uint16(0),
 110306 	uint16(0),
 110307 	uint16(0),
 110308 	uint16(0),
 110309 	uint16(0),
 110310 	uint16(0),
 110311 	uint16(0),
 110312 	uint16(0),
 110313 	uint16(0),
 110314 	uint16(0),
 110315 	uint16(0),
 110316 	uint16(0),
 110317 	uint16(0),
 110318 	uint16(0),
 110319 	uint16(0),
 110320 	uint16(0),
 110321 	uint16(0),
 110322 	uint16(0),
 110323 	uint16(0),
 110324 	uint16(0),
 110325 	uint16(0),
 110326 	uint16(0),
 110327 	uint16(0),
 110328 	uint16(0),
 110329 	uint16(0),
 110330 	uint16(0),
 110331 	uint16(0),
 110332 }
 110333 
 110334 type yyStackEntry = struct {
 110335 	Fstateno uint16
 110336 	Fmajor   uint16
 110337 	Fminor   YYMINORTYPE
 110338 }
 110339 
 110340 type YyStackEntry = yyStackEntry
 110341 
 110342 type yyParser = struct {
 110343 	Fyytos      uintptr
 110344 	FpParse     uintptr
 110345 	Fyystack    [100]YyStackEntry
 110346 	FyystackEnd uintptr
 110347 }
 110348 
 110349 type YyParser = yyParser
 110350 
 110351 // Initialize a new parser that has already been allocated.
 110352 func Xsqlite3ParserInit(tls *libc.TLS, yypRawParser uintptr, pParse uintptr) {
 110353 	var yypParser uintptr = yypRawParser
 110354 	(*YyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
 110355 	(*YyParser)(unsafe.Pointer(yypParser)).Fyytos = yypParser + 8
 110356 	(*YyStackEntry)(unsafe.Pointer(yypParser + 8)).Fstateno = uint16(0)
 110357 	(*YyStackEntry)(unsafe.Pointer(yypParser + 8)).Fmajor = uint16(0)
 110358 	(*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd = yypParser + 8 + 99*12
 110359 }
 110360 
 110361 func yy_destructor(tls *libc.TLS, yypParser uintptr, yymajor uint16, yypminor uintptr) {
 110362 	var pParse uintptr = (*YyParser)(unsafe.Pointer(yypParser)).FpParse
 110363 	switch int32(yymajor) {
 110364 	case 204:
 110365 		fallthrough
 110366 	case 239:
 110367 		fallthrough
 110368 	case 240:
 110369 		fallthrough
 110370 	case 252:
 110371 		{
 110372 			Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110373 		}
 110374 		break
 110375 	case 216:
 110376 		fallthrough
 110377 	case 217:
 110378 		fallthrough
 110379 	case 246:
 110380 		fallthrough
 110381 	case 248:
 110382 		fallthrough
 110383 	case 267:
 110384 		fallthrough
 110385 	case 278:
 110386 		fallthrough
 110387 	case 280:
 110388 		fallthrough
 110389 	case 283:
 110390 		fallthrough
 110391 	case 290:
 110392 		fallthrough
 110393 	case 295:
 110394 		fallthrough
 110395 	case 311:
 110396 		{
 110397 			Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110398 		}
 110399 		break
 110400 	case 221:
 110401 		fallthrough
 110402 	case 231:
 110403 		fallthrough
 110404 	case 232:
 110405 		fallthrough
 110406 	case 244:
 110407 		fallthrough
 110408 	case 247:
 110409 		fallthrough
 110410 	case 249:
 110411 		fallthrough
 110412 	case 253:
 110413 		fallthrough
 110414 	case 254:
 110415 		fallthrough
 110416 	case 261:
 110417 		fallthrough
 110418 	case 268:
 110419 		fallthrough
 110420 	case 277:
 110421 		fallthrough
 110422 	case 279:
 110423 		fallthrough
 110424 	case 310:
 110425 		{
 110426 			Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110427 		}
 110428 		break
 110429 	case 238:
 110430 		fallthrough
 110431 	case 245:
 110432 		fallthrough
 110433 	case 256:
 110434 		fallthrough
 110435 	case 257:
 110436 		fallthrough
 110437 	case 262:
 110438 		{
 110439 			Xsqlite3SrcListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110440 		}
 110441 		break
 110442 	case 241:
 110443 		{
 110444 			Xsqlite3WithDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110445 		}
 110446 		break
 110447 	case 251:
 110448 		fallthrough
 110449 	case 306:
 110450 		{
 110451 			Xsqlite3WindowListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110452 		}
 110453 		break
 110454 	case 263:
 110455 		fallthrough
 110456 	case 270:
 110457 		{
 110458 			Xsqlite3IdListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110459 		}
 110460 		break
 110461 	case 273:
 110462 		fallthrough
 110463 	case 307:
 110464 		fallthrough
 110465 	case 308:
 110466 		fallthrough
 110467 	case 309:
 110468 		fallthrough
 110469 	case 312:
 110470 		{
 110471 			Xsqlite3WindowDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110472 		}
 110473 		break
 110474 	case 286:
 110475 		fallthrough
 110476 	case 291:
 110477 		{
 110478 			Xsqlite3DeleteTriggerStep(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yypminor)))
 110479 		}
 110480 		break
 110481 	case 288:
 110482 		{
 110483 			Xsqlite3IdListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*TrigEvent)(unsafe.Pointer(yypminor)).Fb)
 110484 		}
 110485 		break
 110486 	case 314:
 110487 		fallthrough
 110488 	case 315:
 110489 		fallthrough
 110490 	case 316:
 110491 		{
 110492 			Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*FrameBound)(unsafe.Pointer(yypminor)).FpExpr)
 110493 		}
 110494 		break
 110495 
 110496 	default:
 110497 		break
 110498 	}
 110499 }
 110500 
 110501 func yy_pop_parser_stack(tls *libc.TLS, pParser uintptr) {
 110502 	var yytos uintptr
 110503 
 110504 	yytos = libc.PostDecUintptr(&(*YyParser)(unsafe.Pointer(pParser)).Fyytos, 12)
 110505 	yy_destructor(tls, pParser, (*YyStackEntry)(unsafe.Pointer(yytos)).Fmajor, yytos+4)
 110506 }
 110507 
 110508 // Clear all secondary memory allocations from the parser
 110509 func Xsqlite3ParserFinalize(tls *libc.TLS, p uintptr) {
 110510 	var pParser uintptr = p
 110511 	for (*YyParser)(unsafe.Pointer(pParser)).Fyytos > pParser+8 {
 110512 		yy_pop_parser_stack(tls, pParser)
 110513 	}
 110514 }
 110515 
 110516 func yy_find_shift_action(tls *libc.TLS, iLookAhead uint16, stateno uint16) uint16 {
 110517 	var i int32
 110518 
 110519 	if int32(stateno) > YY_MAX_SHIFT {
 110520 		return stateno
 110521 	}
 110522 
 110523 	for __ccgo := true; __ccgo; __ccgo = 1 != 0 {
 110524 		i = int32(yy_shift_ofst[stateno])
 110525 
 110526 		i = i + int32(iLookAhead)
 110527 
 110528 		if int32(yy_lookahead[i]) != int32(iLookAhead) {
 110529 			var iFallback uint16
 110530 
 110531 			iFallback = yyFallback[iLookAhead]
 110532 			if int32(iFallback) != 0 {
 110533 				iLookAhead = iFallback
 110534 				continue
 110535 			}
 110536 			{
 110537 				var j int32 = i - int32(iLookAhead) + YYWILDCARD
 110538 
 110539 				if int32(yy_lookahead[j]) == YYWILDCARD && int32(iLookAhead) > 0 {
 110540 					return yy_action[j]
 110541 				}
 110542 
 110543 			}
 110544 			return yy_default[stateno]
 110545 		} else {
 110546 			return yy_action[i]
 110547 		}
 110548 	}
 110549 	return uint16(0)
 110550 }
 110551 
 110552 func yy_find_reduce_action(tls *libc.TLS, stateno uint16, iLookAhead uint16) uint16 {
 110553 	var i int32
 110554 
 110555 	i = int32(yy_reduce_ofst[stateno])
 110556 
 110557 	i = i + int32(iLookAhead)
 110558 
 110559 	return yy_action[i]
 110560 }
 110561 
 110562 func yyStackOverflow(tls *libc.TLS, yypParser uintptr) {
 110563 	var pParse uintptr = (*YyParser)(unsafe.Pointer(yypParser)).FpParse
 110564 	for (*YyParser)(unsafe.Pointer(yypParser)).Fyytos > yypParser+8 {
 110565 		yy_pop_parser_stack(tls, yypParser)
 110566 	}
 110567 
 110568 	Xsqlite3ErrorMsg(tls, pParse, ts+22993, 0)
 110569 
 110570 	(*YyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
 110571 }
 110572 
 110573 func yy_shift(tls *libc.TLS, yypParser uintptr, yyNewState uint16, yyMajor uint16, yyMinor Token) {
 110574 	var yytos uintptr
 110575 	(*YyParser)(unsafe.Pointer(yypParser)).Fyytos += 12
 110576 	if (*YyParser)(unsafe.Pointer(yypParser)).Fyytos > (*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd {
 110577 		(*YyParser)(unsafe.Pointer(yypParser)).Fyytos -= 12
 110578 		yyStackOverflow(tls, yypParser)
 110579 		return
 110580 	}
 110581 	if int32(yyNewState) > YY_MAX_SHIFT {
 110582 		yyNewState = uint16(int32(yyNewState) + (YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE))
 110583 	}
 110584 	yytos = (*YyParser)(unsafe.Pointer(yypParser)).Fyytos
 110585 	(*YyStackEntry)(unsafe.Pointer(yytos)).Fstateno = yyNewState
 110586 	(*YyStackEntry)(unsafe.Pointer(yytos)).Fmajor = yyMajor
 110587 	*(*Token)(unsafe.Pointer(yytos + 4)) = yyMinor
 110588 
 110589 }
 110590 
 110591 var yyRuleInfoLhs = [405]uint16{
 110592 	uint16(189),
 110593 	uint16(189),
 110594 	uint16(188),
 110595 	uint16(190),
 110596 	uint16(191),
 110597 	uint16(191),
 110598 	uint16(191),
 110599 	uint16(191),
 110600 	uint16(190),
 110601 	uint16(190),
 110602 	uint16(190),
 110603 	uint16(190),
 110604 	uint16(190),
 110605 	uint16(195),
 110606 	uint16(197),
 110607 	uint16(199),
 110608 	uint16(199),
 110609 	uint16(198),
 110610 	uint16(198),
 110611 	uint16(196),
 110612 	uint16(196),
 110613 	uint16(203),
 110614 	uint16(203),
 110615 	uint16(205),
 110616 	uint16(205),
 110617 	uint16(206),
 110618 	uint16(208),
 110619 	uint16(208),
 110620 	uint16(208),
 110621 	uint16(209),
 110622 	uint16(213),
 110623 	uint16(214),
 110624 	uint16(215),
 110625 	uint16(215),
 110626 	uint16(215),
 110627 	uint16(215),
 110628 	uint16(215),
 110629 	uint16(215),
 110630 	uint16(215),
 110631 	uint16(215),
 110632 	uint16(215),
 110633 	uint16(215),
 110634 	uint16(215),
 110635 	uint16(215),
 110636 	uint16(215),
 110637 	uint16(224),
 110638 	uint16(224),
 110639 	uint16(220),
 110640 	uint16(220),
 110641 	uint16(222),
 110642 	uint16(222),
 110643 	uint16(225),
 110644 	uint16(225),
 110645 	uint16(225),
 110646 	uint16(225),
 110647 	uint16(226),
 110648 	uint16(226),
 110649 	uint16(226),
 110650 	uint16(226),
 110651 	uint16(226),
 110652 	uint16(223),
 110653 	uint16(223),
 110654 	uint16(227),
 110655 	uint16(227),
 110656 	uint16(227),
 110657 	uint16(202),
 110658 	uint16(229),
 110659 	uint16(230),
 110660 	uint16(230),
 110661 	uint16(230),
 110662 	uint16(230),
 110663 	uint16(230),
 110664 	uint16(233),
 110665 	uint16(218),
 110666 	uint16(218),
 110667 	uint16(234),
 110668 	uint16(234),
 110669 	uint16(235),
 110670 	uint16(235),
 110671 	uint16(190),
 110672 	uint16(237),
 110673 	uint16(237),
 110674 	uint16(190),
 110675 	uint16(190),
 110676 	uint16(190),
 110677 	uint16(204),
 110678 	uint16(204),
 110679 	uint16(204),
 110680 	uint16(239),
 110681 	uint16(242),
 110682 	uint16(242),
 110683 	uint16(242),
 110684 	uint16(240),
 110685 	uint16(240),
 110686 	uint16(252),
 110687 	uint16(252),
 110688 	uint16(243),
 110689 	uint16(243),
 110690 	uint16(243),
 110691 	uint16(254),
 110692 	uint16(244),
 110693 	uint16(244),
 110694 	uint16(244),
 110695 	uint16(255),
 110696 	uint16(255),
 110697 	uint16(245),
 110698 	uint16(245),
 110699 	uint16(257),
 110700 	uint16(257),
 110701 	uint16(256),
 110702 	uint16(256),
 110703 	uint16(256),
 110704 	uint16(256),
 110705 	uint16(256),
 110706 	uint16(200),
 110707 	uint16(200),
 110708 	uint16(238),
 110709 	uint16(238),
 110710 	uint16(262),
 110711 	uint16(262),
 110712 	uint16(262),
 110713 	uint16(262),
 110714 	uint16(258),
 110715 	uint16(258),
 110716 	uint16(258),
 110717 	uint16(258),
 110718 	uint16(259),
 110719 	uint16(259),
 110720 	uint16(259),
 110721 	uint16(264),
 110722 	uint16(260),
 110723 	uint16(260),
 110724 	uint16(249),
 110725 	uint16(249),
 110726 	uint16(231),
 110727 	uint16(231),
 110728 	uint16(219),
 110729 	uint16(219),
 110730 	uint16(219),
 110731 	uint16(265),
 110732 	uint16(265),
 110733 	uint16(265),
 110734 	uint16(247),
 110735 	uint16(247),
 110736 	uint16(248),
 110737 	uint16(248),
 110738 	uint16(250),
 110739 	uint16(250),
 110740 	uint16(250),
 110741 	uint16(250),
 110742 	uint16(190),
 110743 	uint16(246),
 110744 	uint16(246),
 110745 	uint16(267),
 110746 	uint16(267),
 110747 	uint16(267),
 110748 	uint16(267),
 110749 	uint16(190),
 110750 	uint16(268),
 110751 	uint16(268),
 110752 	uint16(268),
 110753 	uint16(268),
 110754 	uint16(190),
 110755 	uint16(190),
 110756 	uint16(271),
 110757 	uint16(271),
 110758 	uint16(271),
 110759 	uint16(271),
 110760 	uint16(271),
 110761 	uint16(271),
 110762 	uint16(272),
 110763 	uint16(269),
 110764 	uint16(269),
 110765 	uint16(270),
 110766 	uint16(270),
 110767 	uint16(263),
 110768 	uint16(263),
 110769 	uint16(217),
 110770 	uint16(217),
 110771 	uint16(217),
 110772 	uint16(217),
 110773 	uint16(217),
 110774 	uint16(216),
 110775 	uint16(216),
 110776 	uint16(216),
 110777 	uint16(217),
 110778 	uint16(217),
 110779 	uint16(217),
 110780 	uint16(217),
 110781 	uint16(217),
 110782 	uint16(217),
 110783 	uint16(217),
 110784 	uint16(216),
 110785 	uint16(217),
 110786 	uint16(217),
 110787 	uint16(217),
 110788 	uint16(217),
 110789 	uint16(217),
 110790 	uint16(217),
 110791 	uint16(217),
 110792 	uint16(217),
 110793 	uint16(217),
 110794 	uint16(274),
 110795 	uint16(217),
 110796 	uint16(217),
 110797 	uint16(217),
 110798 	uint16(217),
 110799 	uint16(217),
 110800 	uint16(217),
 110801 	uint16(217),
 110802 	uint16(217),
 110803 	uint16(217),
 110804 	uint16(217),
 110805 	uint16(217),
 110806 	uint16(217),
 110807 	uint16(275),
 110808 	uint16(275),
 110809 	uint16(217),
 110810 	uint16(276),
 110811 	uint16(276),
 110812 	uint16(217),
 110813 	uint16(217),
 110814 	uint16(217),
 110815 	uint16(217),
 110816 	uint16(217),
 110817 	uint16(217),
 110818 	uint16(279),
 110819 	uint16(279),
 110820 	uint16(280),
 110821 	uint16(280),
 110822 	uint16(278),
 110823 	uint16(278),
 110824 	uint16(261),
 110825 	uint16(253),
 110826 	uint16(253),
 110827 	uint16(277),
 110828 	uint16(277),
 110829 	uint16(190),
 110830 	uint16(281),
 110831 	uint16(281),
 110832 	uint16(221),
 110833 	uint16(221),
 110834 	uint16(232),
 110835 	uint16(232),
 110836 	uint16(282),
 110837 	uint16(282),
 110838 	uint16(190),
 110839 	uint16(190),
 110840 	uint16(190),
 110841 	uint16(283),
 110842 	uint16(283),
 110843 	uint16(190),
 110844 	uint16(190),
 110845 	uint16(190),
 110846 	uint16(190),
 110847 	uint16(190),
 110848 	uint16(211),
 110849 	uint16(212),
 110850 	uint16(190),
 110851 	uint16(285),
 110852 	uint16(287),
 110853 	uint16(287),
 110854 	uint16(287),
 110855 	uint16(288),
 110856 	uint16(288),
 110857 	uint16(288),
 110858 	uint16(290),
 110859 	uint16(290),
 110860 	uint16(286),
 110861 	uint16(286),
 110862 	uint16(292),
 110863 	uint16(293),
 110864 	uint16(293),
 110865 	uint16(291),
 110866 	uint16(291),
 110867 	uint16(291),
 110868 	uint16(291),
 110869 	uint16(217),
 110870 	uint16(217),
 110871 	uint16(236),
 110872 	uint16(236),
 110873 	uint16(236),
 110874 	uint16(190),
 110875 	uint16(190),
 110876 	uint16(190),
 110877 	uint16(295),
 110878 	uint16(295),
 110879 	uint16(190),
 110880 	uint16(190),
 110881 	uint16(190),
 110882 	uint16(190),
 110883 	uint16(190),
 110884 	uint16(190),
 110885 	uint16(190),
 110886 	uint16(296),
 110887 	uint16(190),
 110888 	uint16(190),
 110889 	uint16(190),
 110890 	uint16(298),
 110891 	uint16(300),
 110892 	uint16(301),
 110893 	uint16(301),
 110894 	uint16(302),
 110895 	uint16(266),
 110896 	uint16(266),
 110897 	uint16(305),
 110898 	uint16(305),
 110899 	uint16(305),
 110900 	uint16(304),
 110901 	uint16(241),
 110902 	uint16(241),
 110903 	uint16(306),
 110904 	uint16(306),
 110905 	uint16(307),
 110906 	uint16(308),
 110907 	uint16(308),
 110908 	uint16(308),
 110909 	uint16(308),
 110910 	uint16(308),
 110911 	uint16(308),
 110912 	uint16(309),
 110913 	uint16(309),
 110914 	uint16(309),
 110915 	uint16(313),
 110916 	uint16(315),
 110917 	uint16(315),
 110918 	uint16(316),
 110919 	uint16(316),
 110920 	uint16(314),
 110921 	uint16(314),
 110922 	uint16(317),
 110923 	uint16(317),
 110924 	uint16(318),
 110925 	uint16(318),
 110926 	uint16(318),
 110927 	uint16(251),
 110928 	uint16(273),
 110929 	uint16(273),
 110930 	uint16(273),
 110931 	uint16(312),
 110932 	uint16(312),
 110933 	uint16(311),
 110934 	uint16(185),
 110935 	uint16(186),
 110936 	uint16(186),
 110937 	uint16(187),
 110938 	uint16(187),
 110939 	uint16(187),
 110940 	uint16(192),
 110941 	uint16(192),
 110942 	uint16(192),
 110943 	uint16(194),
 110944 	uint16(194),
 110945 	uint16(190),
 110946 	uint16(203),
 110947 	uint16(201),
 110948 	uint16(201),
 110949 	uint16(193),
 110950 	uint16(193),
 110951 	uint16(193),
 110952 	uint16(208),
 110953 	uint16(209),
 110954 	uint16(210),
 110955 	uint16(210),
 110956 	uint16(207),
 110957 	uint16(207),
 110958 	uint16(215),
 110959 	uint16(215),
 110960 	uint16(215),
 110961 	uint16(202),
 110962 	uint16(228),
 110963 	uint16(228),
 110964 	uint16(229),
 110965 	uint16(233),
 110966 	uint16(235),
 110967 	uint16(239),
 110968 	uint16(240),
 110969 	uint16(254),
 110970 	uint16(255),
 110971 	uint16(264),
 110972 	uint16(272),
 110973 	uint16(217),
 110974 	uint16(274),
 110975 	uint16(261),
 110976 	uint16(284),
 110977 	uint16(284),
 110978 	uint16(284),
 110979 	uint16(284),
 110980 	uint16(284),
 110981 	uint16(211),
 110982 	uint16(289),
 110983 	uint16(289),
 110984 	uint16(292),
 110985 	uint16(293),
 110986 	uint16(294),
 110987 	uint16(294),
 110988 	uint16(297),
 110989 	uint16(297),
 110990 	uint16(299),
 110991 	uint16(299),
 110992 	uint16(300),
 110993 	uint16(303),
 110994 	uint16(303),
 110995 	uint16(303),
 110996 	uint16(266),
 110997 }
 110998 
 110999 var yyRuleInfoNRhs = [405]int8{
 111000 	int8(-1),
 111001 	int8(-3),
 111002 	int8(-1),
 111003 	int8(-3),
 111004 	int8(0),
 111005 	int8(-1),
 111006 	int8(-1),
 111007 	int8(-1),
 111008 	int8(-2),
 111009 	int8(-2),
 111010 	int8(-2),
 111011 	int8(-3),
 111012 	int8(-5),
 111013 	int8(-6),
 111014 	int8(-1),
 111015 	int8(0),
 111016 	int8(-3),
 111017 	int8(-1),
 111018 	int8(0),
 111019 	int8(-5),
 111020 	int8(-2),
 111021 	int8(0),
 111022 	int8(-3),
 111023 	int8(-2),
 111024 	int8(-1),
 111025 	int8(-2),
 111026 	int8(0),
 111027 	int8(-4),
 111028 	int8(-6),
 111029 	int8(-2),
 111030 	int8(0),
 111031 	int8(0),
 111032 	int8(-2),
 111033 	int8(-3),
 111034 	int8(-4),
 111035 	int8(-4),
 111036 	int8(-4),
 111037 	int8(-3),
 111038 	int8(-3),
 111039 	int8(-5),
 111040 	int8(-2),
 111041 	int8(-4),
 111042 	int8(-4),
 111043 	int8(-1),
 111044 	int8(-2),
 111045 	int8(-3),
 111046 	int8(-4),
 111047 	int8(0),
 111048 	int8(-1),
 111049 	int8(0),
 111050 	int8(-2),
 111051 	int8(-2),
 111052 	int8(-3),
 111053 	int8(-3),
 111054 	int8(-3),
 111055 	int8(-2),
 111056 	int8(-2),
 111057 	int8(-1),
 111058 	int8(-1),
 111059 	int8(-2),
 111060 	int8(-3),
 111061 	int8(-2),
 111062 	int8(0),
 111063 	int8(-2),
 111064 	int8(-2),
 111065 	int8(0),
 111066 	int8(-1),
 111067 	int8(-2),
 111068 	int8(-7),
 111069 	int8(-5),
 111070 	int8(-5),
 111071 	int8(-10),
 111072 	int8(0),
 111073 	int8(0),
 111074 	int8(-3),
 111075 	int8(0),
 111076 	int8(-2),
 111077 	int8(-1),
 111078 	int8(-1),
 111079 	int8(-4),
 111080 	int8(-2),
 111081 	int8(0),
 111082 	int8(-9),
 111083 	int8(-4),
 111084 	int8(-1),
 111085 	int8(-3),
 111086 	int8(-4),
 111087 	int8(-1),
 111088 	int8(-3),
 111089 	int8(-1),
 111090 	int8(-2),
 111091 	int8(-1),
 111092 	int8(-9),
 111093 	int8(-10),
 111094 	int8(-4),
 111095 	int8(-5),
 111096 	int8(-1),
 111097 	int8(-1),
 111098 	int8(0),
 111099 	int8(0),
 111100 	int8(-5),
 111101 	int8(-3),
 111102 	int8(-5),
 111103 	int8(-2),
 111104 	int8(0),
 111105 	int8(0),
 111106 	int8(-2),
 111107 	int8(-2),
 111108 	int8(0),
 111109 	int8(-5),
 111110 	int8(-6),
 111111 	int8(-8),
 111112 	int8(-6),
 111113 	int8(-6),
 111114 	int8(0),
 111115 	int8(-2),
 111116 	int8(-1),
 111117 	int8(-3),
 111118 	int8(-1),
 111119 	int8(-3),
 111120 	int8(-5),
 111121 	int8(-3),
 111122 	int8(-1),
 111123 	int8(-2),
 111124 	int8(-3),
 111125 	int8(-4),
 111126 	int8(-2),
 111127 	int8(-4),
 111128 	int8(0),
 111129 	int8(0),
 111130 	int8(-3),
 111131 	int8(-2),
 111132 	int8(0),
 111133 	int8(-3),
 111134 	int8(-5),
 111135 	int8(-3),
 111136 	int8(-1),
 111137 	int8(-1),
 111138 	int8(0),
 111139 	int8(-2),
 111140 	int8(-2),
 111141 	int8(0),
 111142 	int8(0),
 111143 	int8(-3),
 111144 	int8(0),
 111145 	int8(-2),
 111146 	int8(0),
 111147 	int8(-2),
 111148 	int8(-4),
 111149 	int8(-4),
 111150 	int8(-6),
 111151 	int8(0),
 111152 	int8(-2),
 111153 	int8(0),
 111154 	int8(-2),
 111155 	int8(-2),
 111156 	int8(-4),
 111157 	int8(-9),
 111158 	int8(-5),
 111159 	int8(-7),
 111160 	int8(-3),
 111161 	int8(-5),
 111162 	int8(-7),
 111163 	int8(-8),
 111164 	int8(0),
 111165 	int8(-2),
 111166 	int8(-12),
 111167 	int8(-9),
 111168 	int8(-5),
 111169 	int8(-8),
 111170 	int8(-2),
 111171 	int8(-2),
 111172 	int8(-1),
 111173 	int8(0),
 111174 	int8(-3),
 111175 	int8(-3),
 111176 	int8(-1),
 111177 	int8(-3),
 111178 	int8(-1),
 111179 	int8(-1),
 111180 	int8(-3),
 111181 	int8(-5),
 111182 	int8(-1),
 111183 	int8(-1),
 111184 	int8(-1),
 111185 	int8(-1),
 111186 	int8(-3),
 111187 	int8(-6),
 111188 	int8(-5),
 111189 	int8(-4),
 111190 	int8(-6),
 111191 	int8(-5),
 111192 	int8(-1),
 111193 	int8(-5),
 111194 	int8(-3),
 111195 	int8(-3),
 111196 	int8(-3),
 111197 	int8(-3),
 111198 	int8(-3),
 111199 	int8(-3),
 111200 	int8(-3),
 111201 	int8(-3),
 111202 	int8(-2),
 111203 	int8(-3),
 111204 	int8(-5),
 111205 	int8(-2),
 111206 	int8(-3),
 111207 	int8(-3),
 111208 	int8(-4),
 111209 	int8(-6),
 111210 	int8(-5),
 111211 	int8(-2),
 111212 	int8(-2),
 111213 	int8(-2),
 111214 	int8(-3),
 111215 	int8(-1),
 111216 	int8(-2),
 111217 	int8(-5),
 111218 	int8(-1),
 111219 	int8(-2),
 111220 	int8(-5),
 111221 	int8(-3),
 111222 	int8(-5),
 111223 	int8(-5),
 111224 	int8(-4),
 111225 	int8(-5),
 111226 	int8(-5),
 111227 	int8(-4),
 111228 	int8(-2),
 111229 	int8(0),
 111230 	int8(-1),
 111231 	int8(0),
 111232 	int8(0),
 111233 	int8(-3),
 111234 	int8(-1),
 111235 	int8(0),
 111236 	int8(-3),
 111237 	int8(-12),
 111238 	int8(-1),
 111239 	int8(0),
 111240 	int8(0),
 111241 	int8(-3),
 111242 	int8(-5),
 111243 	int8(-3),
 111244 	int8(0),
 111245 	int8(-2),
 111246 	int8(-4),
 111247 	int8(-2),
 111248 	int8(-3),
 111249 	int8(-2),
 111250 	int8(0),
 111251 	int8(-3),
 111252 	int8(-5),
 111253 	int8(-6),
 111254 	int8(-5),
 111255 	int8(-6),
 111256 	int8(-2),
 111257 	int8(-2),
 111258 	int8(-5),
 111259 	int8(-11),
 111260 	int8(-1),
 111261 	int8(-2),
 111262 	int8(0),
 111263 	int8(-1),
 111264 	int8(-1),
 111265 	int8(-3),
 111266 	int8(0),
 111267 	int8(-2),
 111268 	int8(-3),
 111269 	int8(-2),
 111270 	int8(-3),
 111271 	int8(-3),
 111272 	int8(-2),
 111273 	int8(-9),
 111274 	int8(-8),
 111275 	int8(-6),
 111276 	int8(-3),
 111277 	int8(-4),
 111278 	int8(-6),
 111279 	int8(-1),
 111280 	int8(-1),
 111281 	int8(-1),
 111282 	int8(-4),
 111283 	int8(-6),
 111284 	int8(-3),
 111285 	int8(0),
 111286 	int8(-2),
 111287 	int8(-1),
 111288 	int8(-3),
 111289 	int8(-1),
 111290 	int8(-3),
 111291 	int8(-6),
 111292 	int8(-7),
 111293 	int8(-6),
 111294 	int8(-1),
 111295 	int8(-8),
 111296 	int8(-1),
 111297 	int8(-4),
 111298 	int8(-8),
 111299 	int8(0),
 111300 	int8(-1),
 111301 	int8(-3),
 111302 	int8(-1),
 111303 	int8(-2),
 111304 	int8(-3),
 111305 	int8(-1),
 111306 	int8(-2),
 111307 	int8(-3),
 111308 	int8(-6),
 111309 	int8(-1),
 111310 	int8(-3),
 111311 	int8(-1),
 111312 	int8(-3),
 111313 	int8(-5),
 111314 	int8(-5),
 111315 	int8(-6),
 111316 	int8(-4),
 111317 	int8(-5),
 111318 	int8(-1),
 111319 	int8(-2),
 111320 	int8(0),
 111321 	int8(-3),
 111322 	int8(-6),
 111323 	int8(-1),
 111324 	int8(-1),
 111325 	int8(-2),
 111326 	int8(-1),
 111327 	int8(-2),
 111328 	int8(-2),
 111329 	int8(-2),
 111330 	int8(0),
 111331 	int8(-2),
 111332 	int8(-2),
 111333 	int8(-2),
 111334 	int8(-1),
 111335 	int8(-2),
 111336 	int8(-2),
 111337 	int8(-1),
 111338 	int8(-1),
 111339 	int8(-4),
 111340 	int8(-2),
 111341 	int8(-5),
 111342 	int8(-1),
 111343 	int8(-2),
 111344 	int8(-1),
 111345 	int8(-1),
 111346 	int8(-2),
 111347 	int8(-3),
 111348 	int8(0),
 111349 	int8(-1),
 111350 	int8(-2),
 111351 	int8(-1),
 111352 	int8(0),
 111353 	int8(-2),
 111354 	int8(-1),
 111355 	int8(-4),
 111356 	int8(-2),
 111357 	int8(-1),
 111358 	int8(-1),
 111359 	int8(-1),
 111360 	int8(-1),
 111361 	int8(-1),
 111362 	int8(-1),
 111363 	int8(-1),
 111364 	int8(-2),
 111365 	int8(0),
 111366 	int8(-2),
 111367 	int8(-4),
 111368 	int8(-2),
 111369 	int8(-2),
 111370 	int8(-3),
 111371 	int8(-1),
 111372 	int8(0),
 111373 	int8(-1),
 111374 	int8(-1),
 111375 	int8(-1),
 111376 	int8(-1),
 111377 	int8(-2),
 111378 	int8(-1),
 111379 	int8(-1),
 111380 	int8(0),
 111381 	int8(-1),
 111382 	int8(-1),
 111383 	int8(-1),
 111384 	int8(-1),
 111385 	int8(-1),
 111386 	int8(-1),
 111387 	int8(-1),
 111388 	int8(-1),
 111389 	int8(-1),
 111390 	int8(0),
 111391 	int8(-3),
 111392 	int8(-1),
 111393 	int8(0),
 111394 	int8(-1),
 111395 	int8(0),
 111396 	int8(0),
 111397 	int8(-1),
 111398 	int8(-1),
 111399 	int8(-3),
 111400 	int8(-2),
 111401 	int8(0),
 111402 	int8(-4),
 111403 	int8(-2),
 111404 	int8(0),
 111405 }
 111406 
 111407 func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead int32, yyLookaheadToken Token, pParse uintptr) uint16 {
 111408 	bp := tls.Alloc(108)
 111409 	defer tls.Free(108)
 111410 
 111411 	var yygoto int32
 111412 	var yyact uint16
 111413 	var yymsp uintptr
 111414 	var yysize int32
 111415 
 111416 	_ = yyLookahead
 111417 	_ = yyLookaheadToken
 111418 	yymsp = (*YyParser)(unsafe.Pointer(yypParser)).Fyytos
 111419 
 111420 	{
 111421 		switch yyruleno {
 111422 		case uint32(0):
 111423 			{
 111424 				(*Parse)(unsafe.Pointer(pParse)).Fexplain = U8(1)
 111425 			}
 111426 			break
 111427 		case uint32(1):
 111428 			{
 111429 				(*Parse)(unsafe.Pointer(pParse)).Fexplain = U8(2)
 111430 			}
 111431 			break
 111432 		case uint32(2):
 111433 			{
 111434 				Xsqlite3FinishCoding(tls, pParse)
 111435 			}
 111436 			break
 111437 		case uint32(3):
 111438 			{
 111439 				Xsqlite3BeginTransaction(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111440 			}
 111441 			break
 111442 		case uint32(4):
 111443 			{
 111444 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = TK_DEFERRED
 111445 			}
 111446 			break
 111447 		case uint32(5):
 111448 			fallthrough
 111449 		case uint32(6):
 111450 			fallthrough
 111451 		case uint32(7):
 111452 			fallthrough
 111453 		case uint32(323):
 111454 			{
 111455 				*(*int32)(unsafe.Pointer(yymsp + 4)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor)
 111456 			}
 111457 			break
 111458 		case uint32(8):
 111459 			fallthrough
 111460 		case uint32(9):
 111461 			{
 111462 				Xsqlite3EndTransaction(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12)).Fmajor))
 111463 			}
 111464 			break
 111465 		case uint32(10):
 111466 			{
 111467 				Xsqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, yymsp+4)
 111468 			}
 111469 			break
 111470 		case uint32(11):
 111471 			{
 111472 				Xsqlite3Savepoint(tls, pParse, SAVEPOINT_RELEASE, yymsp+4)
 111473 			}
 111474 			break
 111475 		case uint32(12):
 111476 			{
 111477 				Xsqlite3Savepoint(tls, pParse, SAVEPOINT_ROLLBACK, yymsp+4)
 111478 			}
 111479 			break
 111480 		case uint32(13):
 111481 			{
 111482 				Xsqlite3StartTable(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4, yymsp+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 111483 			}
 111484 			break
 111485 		case uint32(14):
 111486 			{
 111487 				disableLookaside(tls, pParse)
 111488 			}
 111489 			break
 111490 		case uint32(15):
 111491 			fallthrough
 111492 		case uint32(18):
 111493 			fallthrough
 111494 		case uint32(47):
 111495 			fallthrough
 111496 		case uint32(62):
 111497 			fallthrough
 111498 		case uint32(72):
 111499 			fallthrough
 111500 		case uint32(81):
 111501 			fallthrough
 111502 		case uint32(98):
 111503 			fallthrough
 111504 		case uint32(244):
 111505 			{
 111506 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = 0
 111507 			}
 111508 			break
 111509 		case uint32(16):
 111510 			{
 111511 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = 1
 111512 			}
 111513 			break
 111514 		case uint32(17):
 111515 			{
 111516 				*(*int32)(unsafe.Pointer(yymsp + 4)) = libc.Bool32(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Finit.Fbusy) == 0)
 111517 			}
 111518 			break
 111519 		case uint32(19):
 111520 			{
 111521 				Xsqlite3EndTable(tls, pParse, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4, *(*U32)(unsafe.Pointer(yymsp + 4)), uintptr(0))
 111522 			}
 111523 			break
 111524 		case uint32(20):
 111525 			{
 111526 				Xsqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint32(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 111527 				Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 111528 			}
 111529 			break
 111530 		case uint32(21):
 111531 			{
 111532 				*(*U32)(unsafe.Pointer(yymsp + 1*12 + 4)) = U32(0)
 111533 			}
 111534 			break
 111535 		case uint32(22):
 111536 			{
 111537 				*(*U32)(unsafe.Pointer(bp + 40)) = *(*U32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) | *(*U32)(unsafe.Pointer(yymsp + 4))
 111538 			}
 111539 			*(*U32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*U32)(unsafe.Pointer(bp + 40))
 111540 			break
 111541 		case uint32(23):
 111542 			{
 111543 				if (*Token)(unsafe.Pointer(yymsp+4)).Fn == uint32(5) && Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(yymsp+4)).Fz, ts+16267, 5) == 0 {
 111544 					*(*U32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = U32(TF_WithoutRowid | TF_NoVisibleRowid)
 111545 				} else {
 111546 					*(*U32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = U32(0)
 111547 					Xsqlite3ErrorMsg(tls, pParse, ts+23015, libc.VaList(bp, (*Token)(unsafe.Pointer(yymsp+4)).Fn, (*Token)(unsafe.Pointer(yymsp+4)).Fz))
 111548 				}
 111549 			}
 111550 			break
 111551 		case uint32(24):
 111552 			{
 111553 				if (*Token)(unsafe.Pointer(yymsp+4)).Fn == uint32(6) && Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(yymsp+4)).Fz, ts+16180, 6) == 0 {
 111554 					*(*U32)(unsafe.Pointer(bp + 40)) = U32(TF_Strict)
 111555 				} else {
 111556 					*(*U32)(unsafe.Pointer(bp + 40)) = U32(0)
 111557 					Xsqlite3ErrorMsg(tls, pParse, ts+23015, libc.VaList(bp+16, (*Token)(unsafe.Pointer(yymsp+4)).Fn, (*Token)(unsafe.Pointer(yymsp+4)).Fz))
 111558 				}
 111559 			}
 111560 			*(*U32)(unsafe.Pointer(yymsp + 4)) = *(*U32)(unsafe.Pointer(bp + 40))
 111561 			break
 111562 		case uint32(25):
 111563 			{
 111564 				Xsqlite3AddColumn(tls, pParse, *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*Token)(unsafe.Pointer(yymsp + 4)))
 111565 			}
 111566 			break
 111567 		case uint32(26):
 111568 			fallthrough
 111569 		case uint32(65):
 111570 			fallthrough
 111571 		case uint32(104):
 111572 			{
 111573 				(*Token)(unsafe.Pointer(yymsp + 1*12 + 4)).Fn = uint32(0)
 111574 				(*Token)(unsafe.Pointer(yymsp + 1*12 + 4)).Fz = uintptr(0)
 111575 			}
 111576 			break
 111577 		case uint32(27):
 111578 			{
 111579 				(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)).Fn = uint32((int32((*Token)(unsafe.Pointer(yymsp+4)).Fz+uintptr((*Token)(unsafe.Pointer(yymsp+4)).Fn)) - int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*12+4)).Fz)) / 1)
 111580 			}
 111581 			break
 111582 		case uint32(28):
 111583 			{
 111584 				(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)).Fn = uint32((int32((*Token)(unsafe.Pointer(yymsp+4)).Fz+uintptr((*Token)(unsafe.Pointer(yymsp+4)).Fn)) - int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*12+4)).Fz)) / 1)
 111585 			}
 111586 			break
 111587 		case uint32(29):
 111588 			{
 111589 				(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)).Fn = (*Token)(unsafe.Pointer(yymsp+4)).Fn + uint32((int32((*Token)(unsafe.Pointer(yymsp+4)).Fz)-int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz))/1)
 111590 			}
 111591 			break
 111592 		case uint32(30):
 111593 			{
 111594 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = yyLookaheadToken.Fz
 111595 			}
 111596 			break
 111597 		case uint32(31):
 111598 			{
 111599 				*(*Token)(unsafe.Pointer(yymsp + 1*12 + 4)) = yyLookaheadToken
 111600 			}
 111601 			break
 111602 		case uint32(32):
 111603 			fallthrough
 111604 		case uint32(67):
 111605 			{
 111606 				(*Parse)(unsafe.Pointer(pParse)).FconstraintName = *(*Token)(unsafe.Pointer(yymsp + 4))
 111607 			}
 111608 			break
 111609 		case uint32(33):
 111610 			{
 111611 				Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz+uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fn))
 111612 			}
 111613 			break
 111614 		case uint32(34):
 111615 			{
 111616 				Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*12+4)).Fz+uintptr(1), (*Token)(unsafe.Pointer(yymsp+4)).Fz)
 111617 			}
 111618 			break
 111619 		case uint32(35):
 111620 			{
 111621 				Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*12+4)).Fz, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz+uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fn))
 111622 			}
 111623 			break
 111624 		case uint32(36):
 111625 			{
 111626 				var p uintptr = Xsqlite3PExpr(tls, pParse, TK_UMINUS, *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0))
 111627 				Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*12+4)).Fz, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz+uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fn))
 111628 			}
 111629 			break
 111630 		case uint32(37):
 111631 			{
 111632 				var p uintptr = tokenExpr(tls, pParse, TK_STRING, *(*Token)(unsafe.Pointer(yymsp + 4)))
 111633 				if p != 0 {
 111634 					Xsqlite3ExprIdToTrueFalse(tls, p)
 111635 
 111636 				}
 111637 				Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+4)).Fz, (*Token)(unsafe.Pointer(yymsp+4)).Fz+uintptr((*Token)(unsafe.Pointer(yymsp+4)).Fn))
 111638 			}
 111639 			break
 111640 		case uint32(38):
 111641 			{
 111642 				Xsqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 4)))
 111643 			}
 111644 			break
 111645 		case uint32(39):
 111646 			{
 111647 				Xsqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 111648 			}
 111649 			break
 111650 		case uint32(40):
 111651 			{
 111652 				Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 4)), uintptr(0), uintptr(0), 0, 0,
 111653 					uint8(SQLITE_IDXTYPE_UNIQUE))
 111654 			}
 111655 			break
 111656 		case uint32(41):
 111657 			{
 111658 				Xsqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*12+4)).Fz, (*Token)(unsafe.Pointer(yymsp+4)).Fz)
 111659 			}
 111660 			break
 111661 		case uint32(42):
 111662 			{
 111663 				Xsqlite3CreateForeignKey(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-2)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)))
 111664 			}
 111665 			break
 111666 		case uint32(43):
 111667 			{
 111668 				Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 4)))
 111669 			}
 111670 			break
 111671 		case uint32(44):
 111672 			{
 111673 				Xsqlite3AddCollateType(tls, pParse, yymsp+4)
 111674 			}
 111675 			break
 111676 		case uint32(45):
 111677 			{
 111678 				Xsqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0))
 111679 			}
 111680 			break
 111681 		case uint32(46):
 111682 			{
 111683 				Xsqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), yymsp+4)
 111684 			}
 111685 			break
 111686 		case uint32(48):
 111687 			{
 111688 				*(*int32)(unsafe.Pointer(yymsp + 4)) = 1
 111689 			}
 111690 			break
 111691 		case uint32(49):
 111692 			{
 111693 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = OE_None * 0x0101
 111694 			}
 111695 			break
 111696 		case uint32(50):
 111697 			{
 111698 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) & ^*(*int32)(unsafe.Pointer(yymsp + 4 + 4)) | *(*int32)(unsafe.Pointer(yymsp + 4))
 111699 			}
 111700 			break
 111701 		case uint32(51):
 111702 			{
 111703 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = 0
 111704 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4 + 4)) = 0x000000
 111705 			}
 111706 			break
 111707 		case uint32(52):
 111708 			{
 111709 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = 0
 111710 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4 + 4)) = 0x000000
 111711 			}
 111712 			break
 111713 		case uint32(53):
 111714 			{
 111715 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*int32)(unsafe.Pointer(yymsp + 4))
 111716 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4 + 4)) = 0x0000ff
 111717 			}
 111718 			break
 111719 		case uint32(54):
 111720 			{
 111721 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*int32)(unsafe.Pointer(yymsp + 4)) << 8
 111722 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4 + 4)) = 0x00ff00
 111723 			}
 111724 			break
 111725 		case uint32(55):
 111726 			{
 111727 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = OE_SetNull
 111728 			}
 111729 			break
 111730 		case uint32(56):
 111731 			{
 111732 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = OE_SetDflt
 111733 			}
 111734 			break
 111735 		case uint32(57):
 111736 			{
 111737 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Cascade
 111738 			}
 111739 			break
 111740 		case uint32(58):
 111741 			{
 111742 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Restrict
 111743 			}
 111744 			break
 111745 		case uint32(59):
 111746 			{
 111747 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = OE_None
 111748 			}
 111749 			break
 111750 		case uint32(60):
 111751 			{
 111752 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = 0
 111753 			}
 111754 			break
 111755 		case uint32(61):
 111756 			fallthrough
 111757 		case uint32(76):
 111758 			fallthrough
 111759 		case uint32(171):
 111760 			{
 111761 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*int32)(unsafe.Pointer(yymsp + 4))
 111762 			}
 111763 			break
 111764 		case uint32(63):
 111765 			fallthrough
 111766 		case uint32(80):
 111767 			fallthrough
 111768 		case uint32(216):
 111769 			fallthrough
 111770 		case uint32(219):
 111771 			fallthrough
 111772 		case uint32(245):
 111773 			{
 111774 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = 1
 111775 			}
 111776 			break
 111777 		case uint32(64):
 111778 			{
 111779 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = 0
 111780 			}
 111781 			break
 111782 		case uint32(66):
 111783 			{
 111784 				(*Parse)(unsafe.Pointer(pParse)).FconstraintName.Fn = uint32(0)
 111785 			}
 111786 			break
 111787 		case uint32(68):
 111788 			{
 111789 				Xsqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), 0)
 111790 			}
 111791 			break
 111792 		case uint32(69):
 111793 			{
 111794 				Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)), uintptr(0), uintptr(0), 0, 0,
 111795 					uint8(SQLITE_IDXTYPE_UNIQUE))
 111796 			}
 111797 			break
 111798 		case uint32(70):
 111799 			{
 111800 				Xsqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*12+4)).Fz, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz)
 111801 			}
 111802 			break
 111803 		case uint32(71):
 111804 			{
 111805 				Xsqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), yymsp+libc.UintptrFromInt32(-3)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111806 				Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 4)))
 111807 			}
 111808 			break
 111809 		case uint32(73):
 111810 			fallthrough
 111811 		case uint32(75):
 111812 			{
 111813 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = OE_Default
 111814 			}
 111815 			break
 111816 		case uint32(74):
 111817 			{
 111818 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*int32)(unsafe.Pointer(yymsp + 4))
 111819 			}
 111820 			break
 111821 		case uint32(77):
 111822 			{
 111823 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Ignore
 111824 			}
 111825 			break
 111826 		case uint32(78):
 111827 			fallthrough
 111828 		case uint32(172):
 111829 			{
 111830 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Replace
 111831 			}
 111832 			break
 111833 		case uint32(79):
 111834 			{
 111835 				Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111836 			}
 111837 			break
 111838 		case uint32(82):
 111839 			{
 111840 				Xsqlite3CreateView(tls, pParse, yymsp+libc.UintptrFromInt32(-8)*12+4, yymsp+libc.UintptrFromInt32(-4)*12+4, yymsp+libc.UintptrFromInt32(-3)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)))
 111841 			}
 111842 			break
 111843 		case uint32(83):
 111844 			{
 111845 				Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), 1, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111846 			}
 111847 			break
 111848 		case uint32(84):
 111849 			{
 111850 				*(*SelectDest)(unsafe.Pointer(bp + 48)) = SelectDest{FeDest: U8(SRT_Output)}
 111851 				Xsqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), bp+48)
 111852 				Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 111853 			}
 111854 			break
 111855 		case uint32(85):
 111856 			{
 111857 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111858 			}
 111859 			break
 111860 		case uint32(86):
 111861 			{
 111862 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111863 			}
 111864 			break
 111865 		case uint32(87):
 111866 			{
 111867 				var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 111868 				if p != 0 {
 111869 					parserDoubleLinkSelect(tls, pParse, p)
 111870 				}
 111871 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = p
 111872 			}
 111873 			break
 111874 		case uint32(88):
 111875 			{
 111876 				var pRhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 111877 				var pLhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4))
 111878 				if pRhs != 0 && (*Select)(unsafe.Pointer(pRhs)).FpPrior != 0 {
 111879 					var pFrom uintptr
 111880 
 111881 					(*Token)(unsafe.Pointer(bp + 76)).Fn = uint32(0)
 111882 					parserDoubleLinkSelect(tls, pParse, pRhs)
 111883 					pFrom = Xsqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+76, pRhs, uintptr(0))
 111884 					pRhs = Xsqlite3SelectNew(tls, pParse, uintptr(0), pFrom, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0))
 111885 				}
 111886 				if pRhs != 0 {
 111887 					(*Select)(unsafe.Pointer(pRhs)).Fop = U8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111888 					(*Select)(unsafe.Pointer(pRhs)).FpPrior = pLhs
 111889 					if pLhs != 0 {
 111890 						*(*U32)(unsafe.Pointer(pLhs + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))
 111891 					}
 111892 					*(*U32)(unsafe.Pointer(pRhs + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))
 111893 					if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) != TK_ALL {
 111894 						(*Parse)(unsafe.Pointer(pParse)).FhasCompound = U8(1)
 111895 					}
 111896 				} else {
 111897 					Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pLhs)
 111898 				}
 111899 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = pRhs
 111900 			}
 111901 			break
 111902 		case uint32(89):
 111903 			fallthrough
 111904 		case uint32(91):
 111905 			{
 111906 				*(*int32)(unsafe.Pointer(yymsp + 4)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor)
 111907 			}
 111908 			break
 111909 		case uint32(90):
 111910 			{
 111911 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = TK_ALL
 111912 			}
 111913 			break
 111914 		case uint32(92):
 111915 			{
 111916 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4))), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 111917 			}
 111918 			break
 111919 		case uint32(93):
 111920 			{
 111921 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*12 + 4)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4))), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 111922 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*12 + 4)) != 0 {
 111923 					(*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*12 + 4)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4))
 111924 				} else {
 111925 					Xsqlite3WindowListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 111926 				}
 111927 			}
 111928 			break
 111929 		case uint32(94):
 111930 			{
 111931 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0))
 111932 			}
 111933 			break
 111934 		case uint32(95):
 111935 			{
 111936 				var pRight uintptr
 111937 				var pLeft uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4))
 111938 				pRight = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values|SF_MultiValue), uintptr(0))
 111939 				if pLeft != 0 {
 111940 					*(*U32)(unsafe.Pointer(pLeft + 4)) &= libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))
 111941 				}
 111942 				if pRight != 0 {
 111943 					(*Select)(unsafe.Pointer(pRight)).Fop = U8(TK_ALL)
 111944 					(*Select)(unsafe.Pointer(pRight)).FpPrior = pLeft
 111945 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = pRight
 111946 				} else {
 111947 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = pLeft
 111948 				}
 111949 			}
 111950 			break
 111951 		case uint32(96):
 111952 			{
 111953 				*(*int32)(unsafe.Pointer(yymsp + 4)) = SF_Distinct
 111954 			}
 111955 			break
 111956 		case uint32(97):
 111957 			{
 111958 				*(*int32)(unsafe.Pointer(yymsp + 4)) = SF_All
 111959 			}
 111960 			break
 111961 		case uint32(99):
 111962 			fallthrough
 111963 		case uint32(132):
 111964 			fallthrough
 111965 		case uint32(142):
 111966 			fallthrough
 111967 		case uint32(232):
 111968 			fallthrough
 111969 		case uint32(235):
 111970 			fallthrough
 111971 		case uint32(240):
 111972 			{
 111973 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = uintptr(0)
 111974 			}
 111975 			break
 111976 		case uint32(100):
 111977 			{
 111978 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 111979 				if (*Token)(unsafe.Pointer(yymsp+4)).Fn > uint32(0) {
 111980 					Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), yymsp+4, 1)
 111981 				}
 111982 				Xsqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 111983 			}
 111984 			break
 111985 		case uint32(101):
 111986 			{
 111987 				var p uintptr = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ASTERISK, uintptr(0))
 111988 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), p)
 111989 			}
 111990 			break
 111991 		case uint32(102):
 111992 			{
 111993 				var pRight uintptr = Xsqlite3PExpr(tls, pParse, TK_ASTERISK, uintptr(0), uintptr(0))
 111994 				var pLeft uintptr = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 111995 				var pDot uintptr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pRight)
 111996 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), pDot)
 111997 			}
 111998 			break
 111999 		case uint32(103):
 112000 			fallthrough
 112001 		case uint32(115):
 112002 			fallthrough
 112003 		case uint32(256):
 112004 			fallthrough
 112005 		case uint32(257):
 112006 			{
 112007 				*(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*Token)(unsafe.Pointer(yymsp + 4))
 112008 			}
 112009 			break
 112010 		case uint32(105):
 112011 			fallthrough
 112012 		case uint32(108):
 112013 			{
 112014 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = uintptr(0)
 112015 			}
 112016 			break
 112017 		case uint32(106):
 112018 			{
 112019 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112020 				Xsqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112021 			}
 112022 			break
 112023 		case uint32(107):
 112024 			{
 112025 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) != 0 && (*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FnSrc > 0 {
 112026 					(*SrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) + 8 + uintptr((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FnSrc-1)*72)).Ffg.Fjointype = U8(*(*int32)(unsafe.Pointer(yymsp + 4)))
 112027 				}
 112028 			}
 112029 			break
 112030 		case uint32(109):
 112031 			{
 112032 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4, uintptr(0), yymsp+4)
 112033 			}
 112034 			break
 112035 		case uint32(110):
 112036 			{
 112037 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), yymsp+libc.UintptrFromInt32(-4)*12+4, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4, uintptr(0), yymsp+4)
 112038 				Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), yymsp+libc.UintptrFromInt32(-1)*12+4)
 112039 			}
 112040 			break
 112041 		case uint32(111):
 112042 			{
 112043 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)), yymsp+libc.UintptrFromInt32(-6)*12+4, yymsp+libc.UintptrFromInt32(-5)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4, uintptr(0), yymsp+4)
 112044 				Xsqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))
 112045 			}
 112046 			break
 112047 		case uint32(112):
 112048 			{
 112049 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), uintptr(0), uintptr(0), yymsp+libc.UintptrFromInt32(-1)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), yymsp+4)
 112050 
 112051 			}
 112052 			break
 112053 		case uint32(113):
 112054 			{
 112055 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) == uintptr(0) && (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fn == uint32(0) && (*OnOrUsing)(unsafe.Pointer(yymsp+4)).FpOn == uintptr(0) && (*OnOrUsing)(unsafe.Pointer(yymsp+4)).FpUsing == uintptr(0) {
 112056 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4))
 112057 				} else if (*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))).FnSrc == 1 {
 112058 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), uintptr(0), uintptr(0), yymsp+libc.UintptrFromInt32(-1)*12+4, uintptr(0), yymsp+4)
 112059 					if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) != 0 {
 112060 						var pNew uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) + 8 + uintptr((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)))).FnSrc-1)*72
 112061 						var pOld uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) + 8
 112062 						(*SrcItem)(unsafe.Pointer(pNew)).FzName = (*SrcItem)(unsafe.Pointer(pOld)).FzName
 112063 						(*SrcItem)(unsafe.Pointer(pNew)).FzDatabase = (*SrcItem)(unsafe.Pointer(pOld)).FzDatabase
 112064 						(*SrcItem)(unsafe.Pointer(pNew)).FpSelect = (*SrcItem)(unsafe.Pointer(pOld)).FpSelect
 112065 						if (*SrcItem)(unsafe.Pointer(pNew)).FpSelect != 0 && (*Select)(unsafe.Pointer((*SrcItem)(unsafe.Pointer(pNew)).FpSelect)).FselFlags&U32(SF_NestedFrom) != U32(0) {
 112066 							libc.SetBitFieldPtr16Uint32(pNew+36+4, uint32(1), 13, 0x2000)
 112067 						}
 112068 						if uint32(int32(*(*uint16)(unsafe.Pointer(pOld + 36 + 4))&0x4>>2)) != 0 {
 112069 							*(*uintptr)(unsafe.Pointer(pNew + 64)) = *(*uintptr)(unsafe.Pointer(pOld + 64))
 112070 							*(*uintptr)(unsafe.Pointer(pOld + 64)) = uintptr(0)
 112071 							libc.SetBitFieldPtr16Uint32(pOld+36+4, uint32(0), 2, 0x4)
 112072 							libc.SetBitFieldPtr16Uint32(pNew+36+4, uint32(1), 2, 0x4)
 112073 						}
 112074 						(*SrcItem)(unsafe.Pointer(pOld)).FzName = libc.AssignPtrUintptr(pOld+4, uintptr(0))
 112075 						(*SrcItem)(unsafe.Pointer(pOld)).FpSelect = uintptr(0)
 112076 					}
 112077 					Xsqlite3SrcListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))
 112078 				} else {
 112079 					var pSubquery uintptr
 112080 					Xsqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))
 112081 					pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0))
 112082 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), uintptr(0), uintptr(0), yymsp+libc.UintptrFromInt32(-1)*12+4, pSubquery, yymsp+4)
 112083 				}
 112084 
 112085 			}
 112086 			break
 112087 		case uint32(114):
 112088 			fallthrough
 112089 		case uint32(129):
 112090 			{
 112091 				(*Token)(unsafe.Pointer(yymsp + 1*12 + 4)).Fz = uintptr(0)
 112092 				(*Token)(unsafe.Pointer(yymsp + 1*12 + 4)).Fn = uint32(0)
 112093 			}
 112094 			break
 112095 		case uint32(116):
 112096 			{
 112097 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+4, uintptr(0))
 112098 				if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && *(*uintptr)(unsafe.Pointer(bp + 40)) != 0 {
 112099 					Xsqlite3RenameTokenMap(tls, pParse, (*SrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40))+8)).FzName, yymsp+4)
 112100 				}
 112101 			}
 112102 			*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112103 			break
 112104 		case uint32(117):
 112105 			{
 112106 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+4)
 112107 				if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && *(*uintptr)(unsafe.Pointer(bp + 40)) != 0 {
 112108 					Xsqlite3RenameTokenMap(tls, pParse, (*SrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40))+8)).FzName, yymsp+4)
 112109 				}
 112110 			}
 112111 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112112 			break
 112113 		case uint32(118):
 112114 			{
 112115 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+4, uintptr(0))
 112116 			}
 112117 			break
 112118 		case uint32(119):
 112119 			{
 112120 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+4)
 112121 			}
 112122 			break
 112123 		case uint32(120):
 112124 			{
 112125 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-4)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4)
 112126 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) != 0 {
 112127 					(*SrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 8)).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, yymsp+4)
 112128 				}
 112129 			}
 112130 			break
 112131 		case uint32(121):
 112132 			{
 112133 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-2)*12+4, uintptr(0))
 112134 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) != 0 {
 112135 					(*SrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) + 8)).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, yymsp+4)
 112136 				}
 112137 			}
 112138 			break
 112139 		case uint32(122):
 112140 			{
 112141 				*(*int32)(unsafe.Pointer(yymsp + 4)) = JT_INNER
 112142 			}
 112143 			break
 112144 		case uint32(123):
 112145 			{
 112146 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = Xsqlite3JoinType(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4, uintptr(0), uintptr(0))
 112147 			}
 112148 			break
 112149 		case uint32(124):
 112150 			{
 112151 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3JoinType(tls, pParse, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4, uintptr(0))
 112152 			}
 112153 			break
 112154 		case uint32(125):
 112155 			{
 112156 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3JoinType(tls, pParse, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4)
 112157 			}
 112158 			break
 112159 		case uint32(126):
 112160 			{
 112161 				(*OnOrUsing)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)).FpOn = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112162 				(*OnOrUsing)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)).FpUsing = uintptr(0)
 112163 			}
 112164 			break
 112165 		case uint32(127):
 112166 			{
 112167 				(*OnOrUsing)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)).FpOn = uintptr(0)
 112168 				(*OnOrUsing)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)).FpUsing = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112169 			}
 112170 			break
 112171 		case uint32(128):
 112172 			{
 112173 				(*OnOrUsing)(unsafe.Pointer(yymsp + 1*12 + 4)).FpOn = uintptr(0)
 112174 				(*OnOrUsing)(unsafe.Pointer(yymsp + 1*12 + 4)).FpUsing = uintptr(0)
 112175 			}
 112176 			break
 112177 		case uint32(130):
 112178 			{
 112179 				*(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*Token)(unsafe.Pointer(yymsp + 4))
 112180 			}
 112181 			break
 112182 		case uint32(131):
 112183 			{
 112184 				(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)).Fz = uintptr(0)
 112185 				(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)).Fn = uint32(1)
 112186 			}
 112187 			break
 112188 		case uint32(133):
 112189 			fallthrough
 112190 		case uint32(143):
 112191 			{
 112192 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112193 			}
 112194 			break
 112195 		case uint32(134):
 112196 			{
 112197 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112198 				Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)))
 112199 			}
 112200 			break
 112201 		case uint32(135):
 112202 			{
 112203 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112204 				Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)))
 112205 			}
 112206 			break
 112207 		case uint32(136):
 112208 			{
 112209 				*(*int32)(unsafe.Pointer(yymsp + 4)) = SQLITE_SO_ASC
 112210 			}
 112211 			break
 112212 		case uint32(137):
 112213 			{
 112214 				*(*int32)(unsafe.Pointer(yymsp + 4)) = SQLITE_SO_DESC
 112215 			}
 112216 			break
 112217 		case uint32(138):
 112218 			fallthrough
 112219 		case uint32(141):
 112220 			{
 112221 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = -1
 112222 			}
 112223 			break
 112224 		case uint32(139):
 112225 			{
 112226 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = SQLITE_SO_ASC
 112227 			}
 112228 			break
 112229 		case uint32(140):
 112230 			{
 112231 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = SQLITE_SO_DESC
 112232 			}
 112233 			break
 112234 		case uint32(144):
 112235 			fallthrough
 112236 		case uint32(146):
 112237 			fallthrough
 112238 		case uint32(151):
 112239 			fallthrough
 112240 		case uint32(153):
 112241 			fallthrough
 112242 		case uint32(229):
 112243 			fallthrough
 112244 		case uint32(231):
 112245 			fallthrough
 112246 		case uint32(250):
 112247 			{
 112248 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = uintptr(0)
 112249 			}
 112250 			break
 112251 		case uint32(145):
 112252 			fallthrough
 112253 		case uint32(152):
 112254 			fallthrough
 112255 		case uint32(154):
 112256 			fallthrough
 112257 		case uint32(228):
 112258 			fallthrough
 112259 		case uint32(249):
 112260 			{
 112261 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112262 			}
 112263 			break
 112264 		case uint32(147):
 112265 			{
 112266 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0))
 112267 			}
 112268 			break
 112269 		case uint32(148):
 112270 			{
 112271 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112272 			}
 112273 			break
 112274 		case uint32(149):
 112275 			{
 112276 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112277 			}
 112278 			break
 112279 		case uint32(150):
 112280 			{
 112281 				Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), yymsp+libc.UintptrFromInt32(-1)*12+4)
 112282 				Xsqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0), uintptr(0))
 112283 			}
 112284 			break
 112285 		case uint32(155):
 112286 			{
 112287 				Xsqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112288 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = uintptr(0)
 112289 			}
 112290 			break
 112291 		case uint32(156):
 112292 			{
 112293 				Xsqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112294 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4))
 112295 			}
 112296 			break
 112297 		case uint32(157):
 112298 			{
 112299 				Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), yymsp+libc.UintptrFromInt32(-4)*12+4)
 112300 				Xsqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), ts+23042)
 112301 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) != 0 {
 112302 					var pFromClause uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112303 					if (*SrcList)(unsafe.Pointer(pFromClause)).FnSrc > 1 {
 112304 						var pSubquery uintptr
 112305 
 112306 						pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), pFromClause, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0))
 112307 						(*Token)(unsafe.Pointer(bp + 84)).Fn = uint32(0)
 112308 						(*Token)(unsafe.Pointer(bp + 84)).Fz = uintptr(0)
 112309 						pFromClause = Xsqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+84, pSubquery, uintptr(0))
 112310 					}
 112311 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), pFromClause)
 112312 				}
 112313 				Xsqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), uintptr(0), uintptr(0), uintptr(0))
 112314 			}
 112315 			break
 112316 		case uint32(158):
 112317 			{
 112318 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112319 				Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), yymsp+libc.UintptrFromInt32(-2)*12+4, 1)
 112320 			}
 112321 			break
 112322 		case uint32(159):
 112323 			{
 112324 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)) = Xsqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112325 			}
 112326 			break
 112327 		case uint32(160):
 112328 			{
 112329 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112330 				Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 40)), yymsp+libc.UintptrFromInt32(-2)*12+4, 1)
 112331 			}
 112332 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112333 			break
 112334 		case uint32(161):
 112335 			{
 112336 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112337 			}
 112338 			break
 112339 		case uint32(162):
 112340 			{
 112341 				Xsqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112342 			}
 112343 			break
 112344 		case uint32(163):
 112345 			{
 112346 				Xsqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), uintptr(0))
 112347 			}
 112348 			break
 112349 		case uint32(164):
 112350 			{
 112351 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = uintptr(0)
 112352 			}
 112353 			break
 112354 		case uint32(165):
 112355 			{
 112356 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = uintptr(0)
 112357 				Xsqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112358 			}
 112359 			break
 112360 		case uint32(166):
 112361 			{
 112362 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-11)*12 + 4)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112363 			}
 112364 			break
 112365 		case uint32(167):
 112366 			{
 112367 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112368 			}
 112369 			break
 112370 		case uint32(168):
 112371 			{
 112372 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
 112373 			}
 112374 			break
 112375 		case uint32(169):
 112376 			{
 112377 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0))
 112378 			}
 112379 			break
 112380 		case uint32(170):
 112381 			{
 112382 				Xsqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112383 			}
 112384 			break
 112385 		case uint32(173):
 112386 			{
 112387 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = uintptr(0)
 112388 			}
 112389 			break
 112390 		case uint32(174):
 112391 			{
 112392 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112393 			}
 112394 			break
 112395 		case uint32(175):
 112396 			{
 112397 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), yymsp+4)
 112398 			}
 112399 			break
 112400 		case uint32(176):
 112401 			{
 112402 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = Xsqlite3IdListAppend(tls, pParse, uintptr(0), yymsp+4)
 112403 			}
 112404 			break
 112405 		case uint32(177):
 112406 			{
 112407 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112408 			}
 112409 			break
 112410 		case uint32(178):
 112411 			fallthrough
 112412 		case uint32(179):
 112413 			{
 112414 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + 4)))
 112415 			}
 112416 			break
 112417 		case uint32(180):
 112418 			{
 112419 				var temp1 uintptr = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112420 				var temp2 uintptr = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + 4)))
 112421 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3PExpr(tls, pParse, TK_DOT, temp1, temp2)
 112422 			}
 112423 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112424 			break
 112425 		case uint32(181):
 112426 			{
 112427 				var temp1 uintptr = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 112428 				var temp2 uintptr = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112429 				var temp3 uintptr = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + 4)))
 112430 				var temp4 uintptr = Xsqlite3PExpr(tls, pParse, TK_DOT, temp2, temp3)
 112431 				if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME {
 112432 					Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), temp1)
 112433 				}
 112434 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3PExpr(tls, pParse, TK_DOT, temp1, temp4)
 112435 			}
 112436 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112437 			break
 112438 		case uint32(182):
 112439 			fallthrough
 112440 		case uint32(183):
 112441 			{
 112442 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = tokenExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor), *(*Token)(unsafe.Pointer(yymsp + 4)))
 112443 			}
 112444 			break
 112445 		case uint32(184):
 112446 			{
 112447 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, yymsp+4, 1)
 112448 				if *(*uintptr)(unsafe.Pointer(bp + 40)) != 0 {
 112449 					*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40)) + 36)) = (int32((*Token)(unsafe.Pointer(yymsp+4)).Fz) - int32((*Parse)(unsafe.Pointer(pParse)).FzTail)) / 1
 112450 				}
 112451 			}
 112452 			*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112453 			break
 112454 		case uint32(185):
 112455 			{
 112456 				if !(int32(*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp + 4)).Fz))) == '#' && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+4)).Fz + 1))])&0x04 != 0) {
 112457 					var n U32 = (*Token)(unsafe.Pointer(yymsp + 4)).Fn
 112458 					*(*uintptr)(unsafe.Pointer(yymsp + 4)) = tokenExpr(tls, pParse, TK_VARIABLE, *(*Token)(unsafe.Pointer(yymsp + 4)))
 112459 					Xsqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), n)
 112460 				} else {
 112461 					*(*Token)(unsafe.Pointer(bp + 92)) = *(*Token)(unsafe.Pointer(yymsp + 4))
 112462 
 112463 					if int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 {
 112464 						Xsqlite3ErrorMsg(tls, pParse, ts+23051, libc.VaList(bp+32, bp+92))
 112465 						*(*uintptr)(unsafe.Pointer(yymsp + 4)) = uintptr(0)
 112466 					} else {
 112467 						*(*uintptr)(unsafe.Pointer(yymsp + 4)) = Xsqlite3PExpr(tls, pParse, TK_REGISTER, uintptr(0), uintptr(0))
 112468 						if *(*uintptr)(unsafe.Pointer(yymsp + 4)) != 0 {
 112469 							Xsqlite3GetInt32(tls, (*Token)(unsafe.Pointer(bp+92)).Fz+1, *(*uintptr)(unsafe.Pointer(yymsp + 4))+28)
 112470 						}
 112471 					}
 112472 				}
 112473 			}
 112474 			break
 112475 		case uint32(186):
 112476 			{
 112477 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), yymsp+4, 1)
 112478 			}
 112479 			break
 112480 		case uint32(187):
 112481 			{
 112482 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_CAST, yymsp+libc.UintptrFromInt32(-1)*12+4, 1)
 112483 				Xsqlite3ExprAttachSubtrees(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), uintptr(0))
 112484 			}
 112485 			break
 112486 		case uint32(188):
 112487 			{
 112488 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), yymsp+libc.UintptrFromInt32(-4)*12+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112489 			}
 112490 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112491 			break
 112492 		case uint32(189):
 112493 			{
 112494 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-3)*12+4, 0)
 112495 			}
 112496 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112497 			break
 112498 		case uint32(190):
 112499 			{
 112500 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), yymsp+libc.UintptrFromInt32(-5)*12+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))
 112501 				Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 40)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112502 			}
 112503 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112504 			break
 112505 		case uint32(191):
 112506 			{
 112507 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-4)*12+4, 0)
 112508 				Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 40)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112509 			}
 112510 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112511 			break
 112512 		case uint32(192):
 112513 			{
 112514 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+4, 0)
 112515 			}
 112516 			*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112517 			break
 112518 		case uint32(193):
 112519 			{
 112520 				var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112521 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_VECTOR, uintptr(0), uintptr(0))
 112522 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) != 0 {
 112523 					*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 20)) = pList
 112524 					if (*ExprList)(unsafe.Pointer(pList)).FnExpr != 0 {
 112525 						*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 4)) |= (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pList+8)).FpExpr)).Fflags & U32(EP_Collate|EP_Subquery|EP_HasFunc)
 112526 					}
 112527 				} else {
 112528 					Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList)
 112529 				}
 112530 			}
 112531 			break
 112532 		case uint32(194):
 112533 			{
 112534 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112535 			}
 112536 			break
 112537 		case uint32(195):
 112538 			fallthrough
 112539 		case uint32(196):
 112540 			fallthrough
 112541 		case uint32(197):
 112542 			fallthrough
 112543 		case uint32(198):
 112544 			fallthrough
 112545 		case uint32(199):
 112546 			fallthrough
 112547 		case uint32(200):
 112548 			fallthrough
 112549 		case uint32(201):
 112550 			{
 112551 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112552 			}
 112553 			break
 112554 		case uint32(202):
 112555 			{
 112556 				*(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*Token)(unsafe.Pointer(yymsp + 4))
 112557 				*(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4 + 4)) |= 0x80000000
 112558 			}
 112559 			break
 112560 		case uint32(203):
 112561 			{
 112562 				var pList uintptr
 112563 				var bNot int32 = int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fn & 0x80000000)
 112564 				*(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4 + 4)) &= uint32(0x7fffffff)
 112565 				pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112566 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112567 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3ExprFunction(tls, pParse, pList, yymsp+libc.UintptrFromInt32(-1)*12+4, 0)
 112568 				if bNot != 0 {
 112569 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), uintptr(0))
 112570 				}
 112571 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) != 0 {
 112572 					*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) + 4)) |= U32(EP_InfixFunc)
 112573 				}
 112574 			}
 112575 			break
 112576 		case uint32(204):
 112577 			{
 112578 				var pList uintptr
 112579 				var bNot int32 = int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*12+4)).Fn & 0x80000000)
 112580 				*(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4 + 4)) &= uint32(0x7fffffff)
 112581 				pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112582 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 112583 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112584 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprFunction(tls, pParse, pList, yymsp+libc.UintptrFromInt32(-3)*12+4, 0)
 112585 				if bNot != 0 {
 112586 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112587 				}
 112588 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) != 0 {
 112589 					*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 4)) |= U32(EP_InfixFunc)
 112590 				}
 112591 			}
 112592 			break
 112593 		case uint32(205):
 112594 			{
 112595 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0))
 112596 			}
 112597 			break
 112598 		case uint32(206):
 112599 			{
 112600 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOTNULL, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), uintptr(0))
 112601 			}
 112602 			break
 112603 		case uint32(207):
 112604 			{
 112605 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_IS, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112606 				binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), TK_ISNULL)
 112607 			}
 112608 			break
 112609 		case uint32(208):
 112610 			{
 112611 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_ISNOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112612 				binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), TK_NOTNULL)
 112613 			}
 112614 			break
 112615 		case uint32(209):
 112616 			{
 112617 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_IS, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112618 				binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), TK_ISNULL)
 112619 			}
 112620 			break
 112621 		case uint32(210):
 112622 			{
 112623 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_ISNOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112624 				binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), TK_NOTNULL)
 112625 			}
 112626 			break
 112627 		case uint32(211):
 112628 			fallthrough
 112629 		case uint32(212):
 112630 			{
 112631 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0))
 112632 			}
 112633 			break
 112634 		case uint32(213):
 112635 			{
 112636 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = Xsqlite3PExpr(tls, pParse, func() int32 {
 112637 					if int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12)).Fmajor) == TK_PLUS {
 112638 						return TK_UPLUS
 112639 					}
 112640 					return TK_UMINUS
 112641 				}(), *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0))
 112642 
 112643 			}
 112644 			break
 112645 		case uint32(214):
 112646 			{
 112647 				var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112648 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112649 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3ExprFunction(tls, pParse, pList, yymsp+libc.UintptrFromInt32(-1)*12+4, 0)
 112650 			}
 112651 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112652 			break
 112653 		case uint32(215):
 112654 			fallthrough
 112655 		case uint32(218):
 112656 			{
 112657 				*(*int32)(unsafe.Pointer(yymsp + 4)) = 0
 112658 			}
 112659 			break
 112660 		case uint32(217):
 112661 			{
 112662 				var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112663 				pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112664 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_BETWEEN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112665 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) != 0 {
 112666 					*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 20)) = pList
 112667 				} else {
 112668 					Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList)
 112669 				}
 112670 				if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) != 0 {
 112671 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112672 				}
 112673 			}
 112674 			break
 112675 		case uint32(220):
 112676 			{
 112677 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) == uintptr(0) {
 112678 					Xsqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 112679 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_STRING, func() uintptr {
 112680 						if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) != 0 {
 112681 							return ts + 7694
 112682 						}
 112683 						return ts + 7699
 112684 					}())
 112685 					if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) != 0 {
 112686 						Xsqlite3ExprIdToTrueFalse(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 112687 					}
 112688 				} else {
 112689 					var pRHS uintptr = (*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) + 8)).FpExpr
 112690 					if (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FnExpr == 1 && Xsqlite3ExprIsConstant(tls, pRHS) != 0 && int32((*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))).Fop) != TK_VECTOR {
 112691 						(*ExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) + 8)).FpExpr = uintptr(0)
 112692 						Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112693 						pRHS = Xsqlite3PExpr(tls, pParse, TK_UPLUS, pRHS, uintptr(0))
 112694 						*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_EQ, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), pRHS)
 112695 					} else if (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FnExpr == 1 && int32((*Expr)(unsafe.Pointer(pRHS)).Fop) == TK_SELECT {
 112696 						*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112697 						Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(pRHS + 20)))
 112698 						*(*uintptr)(unsafe.Pointer(pRHS + 20)) = uintptr(0)
 112699 						Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112700 					} else {
 112701 						*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112702 						if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) == uintptr(0) {
 112703 							Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112704 						} else if int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))).FpLeft)).Fop) == TK_VECTOR {
 112705 							var nExpr int32 = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))).FpLeft + 20)))).FnExpr
 112706 							var pSelectRHS uintptr = Xsqlite3ExprListToValues(tls, pParse, nExpr, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112707 							if pSelectRHS != 0 {
 112708 								parserDoubleLinkSelect(tls, pParse, pSelectRHS)
 112709 								Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), pSelectRHS)
 112710 							}
 112711 						} else {
 112712 							*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 20)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112713 							Xsqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 112714 						}
 112715 					}
 112716 					if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) != 0 {
 112717 						*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112718 					}
 112719 				}
 112720 
 112721 			}
 112722 			break
 112723 		case uint32(221):
 112724 			{
 112725 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_SELECT, uintptr(0), uintptr(0))
 112726 				Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112727 
 112728 			}
 112729 			break
 112730 		case uint32(222):
 112731 			{
 112732 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112733 				Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112734 				if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) != 0 {
 112735 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112736 				}
 112737 
 112738 			}
 112739 			break
 112740 		case uint32(223):
 112741 			{
 112742 				var pSrc uintptr = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4)
 112743 				var pSelect uintptr = Xsqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0))
 112744 				if *(*uintptr)(unsafe.Pointer(yymsp + 4)) != 0 {
 112745 					Xsqlite3SrcListFuncArgs(tls, pParse, func() uintptr {
 112746 						if pSelect != 0 {
 112747 							return pSrc
 112748 						}
 112749 						return uintptr(0)
 112750 					}(), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112751 				}
 112752 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112753 				Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), pSelect)
 112754 				if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) != 0 {
 112755 					*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), uintptr(0))
 112756 				}
 112757 
 112758 			}
 112759 			break
 112760 		case uint32(224):
 112761 			{
 112762 				var p uintptr
 112763 				p = libc.AssignPtrUintptr(yymsp+libc.UintptrFromInt32(-3)*12+4, Xsqlite3PExpr(tls, pParse, TK_EXISTS, uintptr(0), uintptr(0)))
 112764 				Xsqlite3PExprAddSelect(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112765 
 112766 			}
 112767 			break
 112768 		case uint32(225):
 112769 			{
 112770 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_CASE, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), uintptr(0))
 112771 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) != 0 {
 112772 					*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) + 20)) = func() uintptr {
 112773 						if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) != 0 {
 112774 							return Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112775 						}
 112776 						return *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4))
 112777 					}()
 112778 					Xsqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 112779 				} else {
 112780 					Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112781 					Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112782 				}
 112783 			}
 112784 			break
 112785 		case uint32(226):
 112786 			{
 112787 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112788 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112789 			}
 112790 			break
 112791 		case uint32(227):
 112792 			{
 112793 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 112794 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112795 			}
 112796 			break
 112797 		case uint32(230):
 112798 			{
 112799 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112800 			}
 112801 			break
 112802 		case uint32(233):
 112803 			{
 112804 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112805 			}
 112806 			break
 112807 		case uint32(234):
 112808 			{
 112809 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112810 			}
 112811 			break
 112812 		case uint32(236):
 112813 			fallthrough
 112814 		case uint32(241):
 112815 			{
 112816 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112817 			}
 112818 			break
 112819 		case uint32(237):
 112820 			{
 112821 				Xsqlite3CreateIndex(tls, pParse, yymsp+libc.UintptrFromInt32(-7)*12+4, yymsp+libc.UintptrFromInt32(-6)*12+4,
 112822 					Xsqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-4)*12+4, uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*12 + 4)),
 112823 					yymsp+libc.UintptrFromInt32(-11)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + 4)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4)), uint8(SQLITE_IDXTYPE_APPDEF))
 112824 				if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME && (*Parse)(unsafe.Pointer(pParse)).FpNewIndex != 0 {
 112825 					Xsqlite3RenameTokenMap(tls, pParse, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, yymsp+libc.UintptrFromInt32(-4)*12+4)
 112826 				}
 112827 			}
 112828 			break
 112829 		case uint32(238):
 112830 			fallthrough
 112831 		case uint32(280):
 112832 			{
 112833 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Abort
 112834 			}
 112835 			break
 112836 		case uint32(239):
 112837 			{
 112838 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = OE_None
 112839 			}
 112840 			break
 112841 		case uint32(242):
 112842 			{
 112843 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), yymsp+libc.UintptrFromInt32(-2)*12+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)))
 112844 			}
 112845 			break
 112846 		case uint32(243):
 112847 			{
 112848 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = parserAddExprIdListTerm(tls, pParse, uintptr(0), yymsp+libc.UintptrFromInt32(-2)*12+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + 4)))
 112849 			}
 112850 			break
 112851 		case uint32(246):
 112852 			{
 112853 				Xsqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 112854 			}
 112855 			break
 112856 		case uint32(247):
 112857 			{
 112858 				Xsqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112859 			}
 112860 			break
 112861 		case uint32(248):
 112862 			{
 112863 				Xsqlite3Vacuum(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112864 			}
 112865 			break
 112866 		case uint32(251):
 112867 			{
 112868 				Xsqlite3Pragma(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4, yymsp+4, uintptr(0), 0)
 112869 			}
 112870 			break
 112871 		case uint32(252):
 112872 			{
 112873 				Xsqlite3Pragma(tls, pParse, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+4, 0)
 112874 			}
 112875 			break
 112876 		case uint32(253):
 112877 			{
 112878 				Xsqlite3Pragma(tls, pParse, yymsp+libc.UintptrFromInt32(-4)*12+4, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4, 0)
 112879 			}
 112880 			break
 112881 		case uint32(254):
 112882 			{
 112883 				Xsqlite3Pragma(tls, pParse, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+4, 1)
 112884 			}
 112885 			break
 112886 		case uint32(255):
 112887 			{
 112888 				Xsqlite3Pragma(tls, pParse, yymsp+libc.UintptrFromInt32(-4)*12+4, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-1)*12+4, 1)
 112889 			}
 112890 			break
 112891 		case uint32(258):
 112892 			{
 112893 				(*Token)(unsafe.Pointer(bp + 100)).Fz = (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)).Fz
 112894 				(*Token)(unsafe.Pointer(bp + 100)).Fn = uint32((int32((*Token)(unsafe.Pointer(yymsp+4)).Fz)-int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*12+4)).Fz))/1) + (*Token)(unsafe.Pointer(yymsp+4)).Fn
 112895 				Xsqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), bp+100)
 112896 			}
 112897 			break
 112898 		case uint32(259):
 112899 			{
 112900 				Xsqlite3BeginTrigger(tls, pParse, yymsp+libc.UintptrFromInt32(-7)*12+4, yymsp+libc.UintptrFromInt32(-6)*12+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*12+4)).Fa, (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*12+4)).Fb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*12 + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4)))
 112901 				*(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*12 + 4)) = func() Token1 {
 112902 					if (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-6)*12+4)).Fn == uint32(0) {
 112903 						return *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4))
 112904 					}
 112905 					return *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4))
 112906 				}()
 112907 			}
 112908 			break
 112909 		case uint32(260):
 112910 			{
 112911 				*(*int32)(unsafe.Pointer(yymsp + 4)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor)
 112912 			}
 112913 			break
 112914 		case uint32(261):
 112915 			{
 112916 				*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = TK_INSTEAD
 112917 			}
 112918 			break
 112919 		case uint32(262):
 112920 			{
 112921 				*(*int32)(unsafe.Pointer(yymsp + 1*12 + 4)) = TK_BEFORE
 112922 			}
 112923 			break
 112924 		case uint32(263):
 112925 			fallthrough
 112926 		case uint32(264):
 112927 			{
 112928 				(*TrigEvent)(unsafe.Pointer(yymsp + 4)).Fa = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor)
 112929 				(*TrigEvent)(unsafe.Pointer(yymsp + 4)).Fb = uintptr(0)
 112930 			}
 112931 			break
 112932 		case uint32(265):
 112933 			{
 112934 				(*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)).Fa = TK_UPDATE
 112935 				(*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)).Fb = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112936 			}
 112937 			break
 112938 		case uint32(266):
 112939 			fallthrough
 112940 		case uint32(285):
 112941 			{
 112942 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = uintptr(0)
 112943 			}
 112944 			break
 112945 		case uint32(267):
 112946 			fallthrough
 112947 		case uint32(286):
 112948 			{
 112949 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 112950 			}
 112951 			break
 112952 		case uint32(268):
 112953 			{
 112954 				(*TriggerStep)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))).FpLast)).FpNext = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112955 				(*TriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112956 			}
 112957 			break
 112958 		case uint32(269):
 112959 			{
 112960 				(*TriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 112961 			}
 112962 			break
 112963 		case uint32(270):
 112964 			{
 112965 				*(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*Token)(unsafe.Pointer(yymsp + 4))
 112966 				Xsqlite3ErrorMsg(tls, pParse,
 112967 					ts+23075, 0)
 112968 			}
 112969 			break
 112970 		case uint32(271):
 112971 			{
 112972 				Xsqlite3ErrorMsg(tls, pParse,
 112973 					ts+23170, 0)
 112974 			}
 112975 			break
 112976 		case uint32(272):
 112977 			{
 112978 				Xsqlite3ErrorMsg(tls, pParse,
 112979 					ts+23254, 0)
 112980 			}
 112981 			break
 112982 		case uint32(273):
 112983 			{
 112984 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3TriggerUpdateStep(tls, pParse, yymsp+libc.UintptrFromInt32(-6)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4))), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-8)*12+4)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112985 			}
 112986 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112987 			break
 112988 		case uint32(274):
 112989 			{
 112990 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3TriggerInsertStep(tls, pParse, yymsp+libc.UintptrFromInt32(-4)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*12 + 4))), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112991 			}
 112992 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112993 			break
 112994 		case uint32(275):
 112995 			{
 112996 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3TriggerDeleteStep(tls, pParse, yymsp+libc.UintptrFromInt32(-3)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*12+4)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 112997 			}
 112998 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 112999 			break
 113000 		case uint32(276):
 113001 			{
 113002 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3TriggerSelectStep(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113003 			}
 113004 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113005 			break
 113006 		case uint32(277):
 113007 			{
 113008 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3PExpr(tls, pParse, TK_RAISE, uintptr(0), uintptr(0))
 113009 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) != 0 {
 113010 					(*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))).FaffExpr = uint8(OE_Ignore)
 113011 				}
 113012 			}
 113013 			break
 113014 		case uint32(278):
 113015 			{
 113016 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_RAISE, yymsp+libc.UintptrFromInt32(-1)*12+4, 1)
 113017 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) != 0 {
 113018 					(*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)))).FaffExpr = uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))
 113019 				}
 113020 			}
 113021 			break
 113022 		case uint32(279):
 113023 			{
 113024 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Rollback
 113025 			}
 113026 			break
 113027 		case uint32(281):
 113028 			{
 113029 				*(*int32)(unsafe.Pointer(yymsp + 4)) = OE_Fail
 113030 			}
 113031 			break
 113032 		case uint32(282):
 113033 			{
 113034 				Xsqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 113035 			}
 113036 			break
 113037 		case uint32(283):
 113038 			{
 113039 				Xsqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113040 			}
 113041 			break
 113042 		case uint32(284):
 113043 			{
 113044 				Xsqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113045 			}
 113046 			break
 113047 		case uint32(287):
 113048 			{
 113049 				Xsqlite3Reindex(tls, pParse, uintptr(0), uintptr(0))
 113050 			}
 113051 			break
 113052 		case uint32(288):
 113053 			{
 113054 				Xsqlite3Reindex(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4, yymsp+4)
 113055 			}
 113056 			break
 113057 		case uint32(289):
 113058 			{
 113059 				Xsqlite3Analyze(tls, pParse, uintptr(0), uintptr(0))
 113060 			}
 113061 			break
 113062 		case uint32(290):
 113063 			{
 113064 				Xsqlite3Analyze(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4, yymsp+4)
 113065 			}
 113066 			break
 113067 		case uint32(291):
 113068 			{
 113069 				Xsqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), yymsp+4)
 113070 			}
 113071 			break
 113072 		case uint32(292):
 113073 			{
 113074 				(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)).Fn = uint32((int32((*Parse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).Fz))/1) + (*Parse)(unsafe.Pointer(pParse)).FsLastToken.Fn
 113075 				Xsqlite3AlterFinishAddColumn(tls, pParse, yymsp+libc.UintptrFromInt32(-1)*12+4)
 113076 			}
 113077 			break
 113078 		case uint32(293):
 113079 			{
 113080 				Xsqlite3AlterDropColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)), yymsp+4)
 113081 			}
 113082 			break
 113083 		case uint32(294):
 113084 			{
 113085 				disableLookaside(tls, pParse)
 113086 				Xsqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113087 			}
 113088 			break
 113089 		case uint32(295):
 113090 			{
 113091 				Xsqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+4)
 113092 			}
 113093 			break
 113094 		case uint32(296):
 113095 			{
 113096 				Xsqlite3VtabFinishParse(tls, pParse, uintptr(0))
 113097 			}
 113098 			break
 113099 		case uint32(297):
 113100 			{
 113101 				Xsqlite3VtabFinishParse(tls, pParse, yymsp+4)
 113102 			}
 113103 			break
 113104 		case uint32(298):
 113105 			{
 113106 				Xsqlite3VtabBeginParse(tls, pParse, yymsp+libc.UintptrFromInt32(-3)*12+4, yymsp+libc.UintptrFromInt32(-2)*12+4, yymsp+4, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 113107 			}
 113108 			break
 113109 		case uint32(299):
 113110 			{
 113111 				Xsqlite3VtabArgInit(tls, pParse)
 113112 			}
 113113 			break
 113114 		case uint32(300):
 113115 			fallthrough
 113116 		case uint32(301):
 113117 			fallthrough
 113118 		case uint32(302):
 113119 			{
 113120 				Xsqlite3VtabArgExtend(tls, pParse, yymsp+4)
 113121 			}
 113122 			break
 113123 		case uint32(303):
 113124 			fallthrough
 113125 		case uint32(304):
 113126 			{
 113127 				Xsqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), uint8(1))
 113128 			}
 113129 			break
 113130 		case uint32(305):
 113131 			{
 113132 				*(*U8)(unsafe.Pointer(yymsp + 4)) = U8(M10d_Any)
 113133 			}
 113134 			break
 113135 		case uint32(306):
 113136 			{
 113137 				*(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = U8(M10d_Yes)
 113138 			}
 113139 			break
 113140 		case uint32(307):
 113141 			{
 113142 				*(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = U8(M10d_No)
 113143 			}
 113144 			break
 113145 		case uint32(308):
 113146 			{
 113147 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = Xsqlite3CteNew(tls, pParse, yymsp+libc.UintptrFromInt32(-5)*12+4, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)))
 113148 			}
 113149 			break
 113150 		case uint32(309):
 113151 			{
 113152 				*(*uintptr)(unsafe.Pointer(yymsp + 4)) = Xsqlite3WithAdd(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113153 			}
 113154 			break
 113155 		case uint32(310):
 113156 			{
 113157 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = Xsqlite3WithAdd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113158 			}
 113159 			break
 113160 		case uint32(311):
 113161 			{
 113162 				*(*uintptr)(unsafe.Pointer(bp + 40)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 113163 			}
 113164 			*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113165 			break
 113166 		case uint32(312):
 113167 			{
 113168 				Xsqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 113169 				(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 4)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4))
 113170 				*(*uintptr)(unsafe.Pointer(bp + 40)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 113171 			}
 113172 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113173 			break
 113174 		case uint32(313):
 113175 			{
 113176 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) != 0 {
 113177 					(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FzName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*12+4)).Fz, uint64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*12+4)).Fn))
 113178 				}
 113179 				*(*uintptr)(unsafe.Pointer(bp + 40)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 113180 			}
 113181 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113182 			break
 113183 		case uint32(314):
 113184 			{
 113185 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0))
 113186 			}
 113187 			break
 113188 		case uint32(315):
 113189 			{
 113190 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), yymsp+libc.UintptrFromInt32(-5)*12+4)
 113191 			}
 113192 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113193 			break
 113194 		case uint32(316):
 113195 			{
 113196 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), uintptr(0))
 113197 			}
 113198 			break
 113199 		case uint32(317):
 113200 			{
 113201 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)), yymsp+libc.UintptrFromInt32(-4)*12+4)
 113202 			}
 113203 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113204 			break
 113205 		case uint32(318):
 113206 			fallthrough
 113207 		case uint32(337):
 113208 			{
 113209 				*(*uintptr)(unsafe.Pointer(bp + 40)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 113210 			}
 113211 			*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113212 			break
 113213 		case uint32(319):
 113214 			{
 113215 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 4)), uintptr(0), uintptr(0), yymsp+libc.UintptrFromInt32(-1)*12+4)
 113216 			}
 113217 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113218 			break
 113219 		case uint32(320):
 113220 			{
 113221 				*(*uintptr)(unsafe.Pointer(yymsp + 1*12 + 4)) = Xsqlite3WindowAlloc(tls, pParse, 0, TK_UNBOUNDED, uintptr(0), TK_CURRENT, uintptr(0), uint8(0))
 113222 			}
 113223 			break
 113224 		case uint32(321):
 113225 			{
 113226 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).FpExpr, TK_CURRENT, uintptr(0), *(*U8)(unsafe.Pointer(yymsp + 4)))
 113227 			}
 113228 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113229 			break
 113230 		case uint32(322):
 113231 			{
 113232 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*12+4)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*12+4)).FpExpr, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*12+4)).FpExpr, *(*U8)(unsafe.Pointer(yymsp + 4)))
 113233 			}
 113234 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113235 			break
 113236 		case uint32(324):
 113237 			fallthrough
 113238 		case uint32(326):
 113239 			{
 113240 				*(*FrameBound)(unsafe.Pointer(bp + 40)) = *(*FrameBound)(unsafe.Pointer(yymsp + 4))
 113241 			}
 113242 			*(*FrameBound)(unsafe.Pointer(yymsp + 4)) = *(*FrameBound)(unsafe.Pointer(bp + 40))
 113243 			break
 113244 		case uint32(325):
 113245 			fallthrough
 113246 		case uint32(327):
 113247 			fallthrough
 113248 		case uint32(329):
 113249 			{
 113250 				(*FrameBound)(unsafe.Pointer(bp + 40)).FeType = int32((*YyStackEntry)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12)).Fmajor)
 113251 				(*FrameBound)(unsafe.Pointer(bp + 40)).FpExpr = uintptr(0)
 113252 			}
 113253 			*(*FrameBound)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*FrameBound)(unsafe.Pointer(bp + 40))
 113254 			break
 113255 		case uint32(328):
 113256 			{
 113257 				(*FrameBound)(unsafe.Pointer(bp + 40)).FeType = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor)
 113258 				(*FrameBound)(unsafe.Pointer(bp + 40)).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 113259 			}
 113260 			*(*FrameBound)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*FrameBound)(unsafe.Pointer(bp + 40))
 113261 			break
 113262 		case uint32(330):
 113263 			{
 113264 				*(*U8)(unsafe.Pointer(yymsp + 1*12 + 4)) = U8(0)
 113265 			}
 113266 			break
 113267 		case uint32(331):
 113268 			{
 113269 				*(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*U8)(unsafe.Pointer(yymsp + 4))
 113270 			}
 113271 			break
 113272 		case uint32(332):
 113273 			fallthrough
 113274 		case uint32(333):
 113275 			{
 113276 				*(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = U8((*YyStackEntry)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12)).Fmajor)
 113277 			}
 113278 			break
 113279 		case uint32(334):
 113280 			{
 113281 				*(*U8)(unsafe.Pointer(yymsp + 4)) = U8((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor)
 113282 			}
 113283 			break
 113284 		case uint32(335):
 113285 			{
 113286 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 113287 			}
 113288 			break
 113289 		case uint32(336):
 113290 			{
 113291 				if *(*uintptr)(unsafe.Pointer(yymsp + 4)) != 0 {
 113292 					(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 4)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 113293 				} else {
 113294 					Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 113295 				}
 113296 				*(*uintptr)(unsafe.Pointer(bp + 40)) = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 113297 			}
 113298 			*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113299 			break
 113300 		case uint32(338):
 113301 			{
 113302 				*(*uintptr)(unsafe.Pointer(bp + 40)) = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{})))
 113303 				if *(*uintptr)(unsafe.Pointer(bp + 40)) != 0 {
 113304 					(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40)))).FeFrmType = U8(TK_FILTER)
 113305 					(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 4))
 113306 				} else {
 113307 					Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 4)))
 113308 				}
 113309 			}
 113310 			*(*uintptr)(unsafe.Pointer(yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp + 40))
 113311 			break
 113312 		case uint32(339):
 113313 			{
 113314 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 113315 
 113316 			}
 113317 			break
 113318 		case uint32(340):
 113319 			{
 113320 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{})))
 113321 				if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)) != 0 {
 113322 					(*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4)))).FzName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(yymsp+4)).Fz, uint64((*Token)(unsafe.Pointer(yymsp+4)).Fn))
 113323 				}
 113324 			}
 113325 			break
 113326 		case uint32(341):
 113327 			{
 113328 				*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 113329 			}
 113330 			break
 113331 		default:
 113332 			break
 113333 
 113334 		}
 113335 	}
 113336 
 113337 	yygoto = int32(yyRuleInfoLhs[yyruleno])
 113338 	yysize = int32(yyRuleInfoNRhs[yyruleno])
 113339 	yyact = yy_find_reduce_action(tls, (*YyStackEntry)(unsafe.Pointer(yymsp+uintptr(yysize)*12)).Fstateno, uint16(yygoto))
 113340 
 113341 	yymsp += 12 * uintptr(yysize+1)
 113342 	(*YyParser)(unsafe.Pointer(yypParser)).Fyytos = yymsp
 113343 	(*YyStackEntry)(unsafe.Pointer(yymsp)).Fstateno = yyact
 113344 	(*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor = uint16(yygoto)
 113345 
 113346 	return yyact
 113347 }
 113348 
 113349 func yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, yyminor Token) {
 113350 	bp := tls.Alloc(16)
 113351 	defer tls.Free(16)
 113352 	*(*Token)(unsafe.Pointer(bp + 8)) = yyminor
 113353 
 113354 	var pParse uintptr = (*YyParser)(unsafe.Pointer(yypParser)).FpParse
 113355 
 113356 	_ = yymajor
 113357 	if *(*uint8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp + 8)).Fz)) != 0 {
 113358 		Xsqlite3ErrorMsg(tls, pParse, ts+23051, libc.VaList(bp, bp+8))
 113359 	} else {
 113360 		Xsqlite3ErrorMsg(tls, pParse, ts+23339, 0)
 113361 	}
 113362 
 113363 	(*YyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
 113364 }
 113365 
 113366 func yy_accept(tls *libc.TLS, yypParser uintptr) {
 113367 	var pParse uintptr = (*YyParser)(unsafe.Pointer(yypParser)).FpParse
 113368 
 113369 	(*YyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
 113370 }
 113371 
 113372 // The main parser program.
 113373 // The first argument is a pointer to a structure obtained from
 113374 // "sqlite3ParserAlloc" which describes the current state of the parser.
 113375 // The second argument is the major token number.  The third is
 113376 // the minor token.  The fourth optional argument is whatever the
 113377 // user wants (and specified in the grammar) and is available for
 113378 // use by the action routines.
 113379 //
 113380 // Inputs:
 113381 // <ul>
 113382 // <li> A pointer to the parser (an opaque structure.)
 113383 // <li> The major token number.
 113384 // <li> The minor token number.
 113385 // <li> An option argument of a grammar-specified type.
 113386 // </ul>
 113387 //
 113388 // Outputs:
 113389 // None.
 113390 func Xsqlite3Parser(tls *libc.TLS, yyp uintptr, yymajor int32, yyminor Token) {
 113391 	bp := tls.Alloc(8)
 113392 	defer tls.Free(8)
 113393 
 113394 	var yyact uint16
 113395 	var yypParser uintptr = yyp
 113396 	var pParse uintptr = (*YyParser)(unsafe.Pointer(yypParser)).FpParse
 113397 
 113398 	yyact = (*YyStackEntry)(unsafe.Pointer((*YyParser)(unsafe.Pointer(yypParser)).Fyytos)).Fstateno
 113399 
 113400 	for 1 != 0 {
 113401 		yyact = yy_find_shift_action(tls, uint16(yymajor), yyact)
 113402 		if int32(yyact) >= YY_MIN_REDUCE {
 113403 			var yyruleno uint32 = uint32(int32(yyact) - YY_MIN_REDUCE)
 113404 
 113405 			if int32(yyRuleInfoNRhs[yyruleno]) == 0 {
 113406 				if (*YyParser)(unsafe.Pointer(yypParser)).Fyytos >= (*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd {
 113407 					yyStackOverflow(tls, yypParser)
 113408 					break
 113409 				}
 113410 			}
 113411 			yyact = yy_reduce(tls, yypParser, yyruleno, yymajor, yyminor, pParse)
 113412 		} else if int32(yyact) <= YY_MAX_SHIFTREDUCE {
 113413 			yy_shift(tls, yypParser, yyact, uint16(yymajor), yyminor)
 113414 			break
 113415 		} else if int32(yyact) == YY_ACCEPT_ACTION {
 113416 			(*YyParser)(unsafe.Pointer(yypParser)).Fyytos -= 12
 113417 			yy_accept(tls, yypParser)
 113418 			return
 113419 		} else {
 113420 			*(*Token)(unsafe.Pointer(bp)) = yyminor
 113421 
 113422 			yy_syntax_error(tls, yypParser, yymajor, yyminor)
 113423 			yy_destructor(tls, yypParser, uint16(yymajor), bp)
 113424 			break
 113425 		}
 113426 	}
 113427 	return
 113428 }
 113429 
 113430 // Return the fallback token corresponding to canonical token iToken, or
 113431 // 0 if iToken has no fallback.
 113432 func Xsqlite3ParserFallback(tls *libc.TLS, iToken int32) int32 {
 113433 	return int32(yyFallback[iToken])
 113434 }
 113435 
 113436 var aiClass = [256]uint8{
 113437 	uint8(29), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(7), uint8(7), uint8(28), uint8(7), uint8(7), uint8(28), uint8(28),
 113438 	uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28), uint8(28),
 113439 	uint8(7), uint8(15), uint8(8), uint8(5), uint8(4), uint8(22), uint8(24), uint8(8), uint8(17), uint8(18), uint8(21), uint8(20), uint8(23), uint8(11), uint8(26), uint8(16),
 113440 	uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(3), uint8(5), uint8(19), uint8(12), uint8(14), uint8(13), uint8(6),
 113441 	uint8(5), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1),
 113442 	uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(2), uint8(2), uint8(9), uint8(28), uint8(28), uint8(28), uint8(2),
 113443 	uint8(8), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1),
 113444 	uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(2), uint8(2), uint8(28), uint8(10), uint8(28), uint8(25), uint8(28),
 113445 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113446 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113447 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113448 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113449 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113450 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113451 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(30),
 113452 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 113453 }
 113454 
 113455 var zKWText = [666]uint8{
 113456 	uint8('R'), uint8('E'), uint8('I'), uint8('N'), uint8('D'), uint8('E'), uint8('X'), uint8('E'), uint8('D'), uint8('E'), uint8('S'), uint8('C'), uint8('A'), uint8('P'), uint8('E'), uint8('A'), uint8('C'), uint8('H'),
 113457 	uint8('E'), uint8('C'), uint8('K'), uint8('E'), uint8('Y'), uint8('B'), uint8('E'), uint8('F'), uint8('O'), uint8('R'), uint8('E'), uint8('I'), uint8('G'), uint8('N'), uint8('O'), uint8('R'), uint8('E'), uint8('G'),
 113458 	uint8('E'), uint8('X'), uint8('P'), uint8('L'), uint8('A'), uint8('I'), uint8('N'), uint8('S'), uint8('T'), uint8('E'), uint8('A'), uint8('D'), uint8('D'), uint8('A'), uint8('T'), uint8('A'), uint8('B'), uint8('A'),
 113459 	uint8('S'), uint8('E'), uint8('L'), uint8('E'), uint8('C'), uint8('T'), uint8('A'), uint8('B'), uint8('L'), uint8('E'), uint8('F'), uint8('T'), uint8('H'), uint8('E'), uint8('N'), uint8('D'), uint8('E'), uint8('F'),
 113460 	uint8('E'), uint8('R'), uint8('R'), uint8('A'), uint8('B'), uint8('L'), uint8('E'), uint8('L'), uint8('S'), uint8('E'), uint8('X'), uint8('C'), uint8('L'), uint8('U'), uint8('D'), uint8('E'), uint8('L'), uint8('E'),
 113461 	uint8('T'), uint8('E'), uint8('M'), uint8('P'), uint8('O'), uint8('R'), uint8('A'), uint8('R'), uint8('Y'), uint8('I'), uint8('S'), uint8('N'), uint8('U'), uint8('L'), uint8('L'), uint8('S'), uint8('A'), uint8('V'),
 113462 	uint8('E'), uint8('P'), uint8('O'), uint8('I'), uint8('N'), uint8('T'), uint8('E'), uint8('R'), uint8('S'), uint8('E'), uint8('C'), uint8('T'), uint8('I'), uint8('E'), uint8('S'), uint8('N'), uint8('O'), uint8('T'),
 113463 	uint8('N'), uint8('U'), uint8('L'), uint8('L'), uint8('I'), uint8('K'), uint8('E'), uint8('X'), uint8('C'), uint8('E'), uint8('P'), uint8('T'), uint8('R'), uint8('A'), uint8('N'), uint8('S'), uint8('A'), uint8('C'),
 113464 	uint8('T'), uint8('I'), uint8('O'), uint8('N'), uint8('A'), uint8('T'), uint8('U'), uint8('R'), uint8('A'), uint8('L'), uint8('T'), uint8('E'), uint8('R'), uint8('A'), uint8('I'), uint8('S'), uint8('E'), uint8('X'),
 113465 	uint8('C'), uint8('L'), uint8('U'), uint8('S'), uint8('I'), uint8('V'), uint8('E'), uint8('X'), uint8('I'), uint8('S'), uint8('T'), uint8('S'), uint8('C'), uint8('O'), uint8('N'), uint8('S'), uint8('T'), uint8('R'),
 113466 	uint8('A'), uint8('I'), uint8('N'), uint8('T'), uint8('O'), uint8('F'), uint8('F'), uint8('S'), uint8('E'), uint8('T'), uint8('R'), uint8('I'), uint8('G'), uint8('G'), uint8('E'), uint8('R'), uint8('A'), uint8('N'),
 113467 	uint8('G'), uint8('E'), uint8('N'), uint8('E'), uint8('R'), uint8('A'), uint8('T'), uint8('E'), uint8('D'), uint8('E'), uint8('T'), uint8('A'), uint8('C'), uint8('H'), uint8('A'), uint8('V'), uint8('I'), uint8('N'),
 113468 	uint8('G'), uint8('L'), uint8('O'), uint8('B'), uint8('E'), uint8('G'), uint8('I'), uint8('N'), uint8('N'), uint8('E'), uint8('R'), uint8('E'), uint8('F'), uint8('E'), uint8('R'), uint8('E'), uint8('N'), uint8('C'),
 113469 	uint8('E'), uint8('S'), uint8('U'), uint8('N'), uint8('I'), uint8('Q'), uint8('U'), uint8('E'), uint8('R'), uint8('Y'), uint8('W'), uint8('I'), uint8('T'), uint8('H'), uint8('O'), uint8('U'), uint8('T'), uint8('E'),
 113470 	uint8('R'), uint8('E'), uint8('L'), uint8('E'), uint8('A'), uint8('S'), uint8('E'), uint8('A'), uint8('T'), uint8('T'), uint8('A'), uint8('C'), uint8('H'), uint8('B'), uint8('E'), uint8('T'), uint8('W'), uint8('E'),
 113471 	uint8('E'), uint8('N'), uint8('O'), uint8('T'), uint8('H'), uint8('I'), uint8('N'), uint8('G'), uint8('R'), uint8('O'), uint8('U'), uint8('P'), uint8('S'), uint8('C'), uint8('A'), uint8('S'), uint8('C'), uint8('A'),
 113472 	uint8('D'), uint8('E'), uint8('F'), uint8('A'), uint8('U'), uint8('L'), uint8('T'), uint8('C'), uint8('A'), uint8('S'), uint8('E'), uint8('C'), uint8('O'), uint8('L'), uint8('L'), uint8('A'), uint8('T'), uint8('E'),
 113473 	uint8('C'), uint8('R'), uint8('E'), uint8('A'), uint8('T'), uint8('E'), uint8('C'), uint8('U'), uint8('R'), uint8('R'), uint8('E'), uint8('N'), uint8('T'), uint8('_'), uint8('D'), uint8('A'), uint8('T'), uint8('E'),
 113474 	uint8('I'), uint8('M'), uint8('M'), uint8('E'), uint8('D'), uint8('I'), uint8('A'), uint8('T'), uint8('E'), uint8('J'), uint8('O'), uint8('I'), uint8('N'), uint8('S'), uint8('E'), uint8('R'), uint8('T'), uint8('M'),
 113475 	uint8('A'), uint8('T'), uint8('C'), uint8('H'), uint8('P'), uint8('L'), uint8('A'), uint8('N'), uint8('A'), uint8('L'), uint8('Y'), uint8('Z'), uint8('E'), uint8('P'), uint8('R'), uint8('A'), uint8('G'), uint8('M'),
 113476 	uint8('A'), uint8('T'), uint8('E'), uint8('R'), uint8('I'), uint8('A'), uint8('L'), uint8('I'), uint8('Z'), uint8('E'), uint8('D'), uint8('E'), uint8('F'), uint8('E'), uint8('R'), uint8('R'), uint8('E'), uint8('D'),
 113477 	uint8('I'), uint8('S'), uint8('T'), uint8('I'), uint8('N'), uint8('C'), uint8('T'), uint8('U'), uint8('P'), uint8('D'), uint8('A'), uint8('T'), uint8('E'), uint8('V'), uint8('A'), uint8('L'), uint8('U'), uint8('E'),
 113478 	uint8('S'), uint8('V'), uint8('I'), uint8('R'), uint8('T'), uint8('U'), uint8('A'), uint8('L'), uint8('W'), uint8('A'), uint8('Y'), uint8('S'), uint8('W'), uint8('H'), uint8('E'), uint8('N'), uint8('W'), uint8('H'),
 113479 	uint8('E'), uint8('R'), uint8('E'), uint8('C'), uint8('U'), uint8('R'), uint8('S'), uint8('I'), uint8('V'), uint8('E'), uint8('A'), uint8('B'), uint8('O'), uint8('R'), uint8('T'), uint8('A'), uint8('F'), uint8('T'),
 113480 	uint8('E'), uint8('R'), uint8('E'), uint8('N'), uint8('A'), uint8('M'), uint8('E'), uint8('A'), uint8('N'), uint8('D'), uint8('R'), uint8('O'), uint8('P'), uint8('A'), uint8('R'), uint8('T'), uint8('I'), uint8('T'),
 113481 	uint8('I'), uint8('O'), uint8('N'), uint8('A'), uint8('U'), uint8('T'), uint8('O'), uint8('I'), uint8('N'), uint8('C'), uint8('R'), uint8('E'), uint8('M'), uint8('E'), uint8('N'), uint8('T'), uint8('C'), uint8('A'),
 113482 	uint8('S'), uint8('T'), uint8('C'), uint8('O'), uint8('L'), uint8('U'), uint8('M'), uint8('N'), uint8('C'), uint8('O'), uint8('M'), uint8('M'), uint8('I'), uint8('T'), uint8('C'), uint8('O'), uint8('N'), uint8('F'),
 113483 	uint8('L'), uint8('I'), uint8('C'), uint8('T'), uint8('C'), uint8('R'), uint8('O'), uint8('S'), uint8('S'), uint8('C'), uint8('U'), uint8('R'), uint8('R'), uint8('E'), uint8('N'), uint8('T'), uint8('_'), uint8('T'),
 113484 	uint8('I'), uint8('M'), uint8('E'), uint8('S'), uint8('T'), uint8('A'), uint8('M'), uint8('P'), uint8('R'), uint8('E'), uint8('C'), uint8('E'), uint8('D'), uint8('I'), uint8('N'), uint8('G'), uint8('F'), uint8('A'),
 113485 	uint8('I'), uint8('L'), uint8('A'), uint8('S'), uint8('T'), uint8('F'), uint8('I'), uint8('L'), uint8('T'), uint8('E'), uint8('R'), uint8('E'), uint8('P'), uint8('L'), uint8('A'), uint8('C'), uint8('E'), uint8('F'),
 113486 	uint8('I'), uint8('R'), uint8('S'), uint8('T'), uint8('F'), uint8('O'), uint8('L'), uint8('L'), uint8('O'), uint8('W'), uint8('I'), uint8('N'), uint8('G'), uint8('F'), uint8('R'), uint8('O'), uint8('M'), uint8('F'),
 113487 	uint8('U'), uint8('L'), uint8('L'), uint8('I'), uint8('M'), uint8('I'), uint8('T'), uint8('I'), uint8('F'), uint8('O'), uint8('R'), uint8('D'), uint8('E'), uint8('R'), uint8('E'), uint8('S'), uint8('T'), uint8('R'),
 113488 	uint8('I'), uint8('C'), uint8('T'), uint8('O'), uint8('T'), uint8('H'), uint8('E'), uint8('R'), uint8('S'), uint8('O'), uint8('V'), uint8('E'), uint8('R'), uint8('E'), uint8('T'), uint8('U'), uint8('R'), uint8('N'),
 113489 	uint8('I'), uint8('N'), uint8('G'), uint8('R'), uint8('I'), uint8('G'), uint8('H'), uint8('T'), uint8('R'), uint8('O'), uint8('L'), uint8('L'), uint8('B'), uint8('A'), uint8('C'), uint8('K'), uint8('R'), uint8('O'),
 113490 	uint8('W'), uint8('S'), uint8('U'), uint8('N'), uint8('B'), uint8('O'), uint8('U'), uint8('N'), uint8('D'), uint8('E'), uint8('D'), uint8('U'), uint8('N'), uint8('I'), uint8('O'), uint8('N'), uint8('U'), uint8('S'),
 113491 	uint8('I'), uint8('N'), uint8('G'), uint8('V'), uint8('A'), uint8('C'), uint8('U'), uint8('U'), uint8('M'), uint8('V'), uint8('I'), uint8('E'), uint8('W'), uint8('I'), uint8('N'), uint8('D'), uint8('O'), uint8('W'),
 113492 	uint8('B'), uint8('Y'), uint8('I'), uint8('N'), uint8('I'), uint8('T'), uint8('I'), uint8('A'), uint8('L'), uint8('L'), uint8('Y'), uint8('P'), uint8('R'), uint8('I'), uint8('M'), uint8('A'), uint8('R'), uint8('Y'),
 113493 }
 113494 
 113495 var aKWHash = [127]uint8{
 113496 	uint8(84), uint8(92), uint8(134), uint8(82), uint8(105), uint8(29), uint8(0), uint8(0), uint8(94), uint8(0), uint8(85), uint8(72), uint8(0),
 113497 	uint8(53), uint8(35), uint8(86), uint8(15), uint8(0), uint8(42), uint8(97), uint8(54), uint8(89), uint8(135), uint8(19), uint8(0), uint8(0),
 113498 	uint8(140), uint8(0), uint8(40), uint8(129), uint8(0), uint8(22), uint8(107), uint8(0), uint8(9), uint8(0), uint8(0), uint8(123), uint8(80),
 113499 	uint8(0), uint8(78), uint8(6), uint8(0), uint8(65), uint8(103), uint8(147), uint8(0), uint8(136), uint8(115), uint8(0), uint8(0), uint8(48),
 113500 	uint8(0), uint8(90), uint8(24), uint8(0), uint8(17), uint8(0), uint8(27), uint8(70), uint8(23), uint8(26), uint8(5), uint8(60), uint8(142),
 113501 	uint8(110), uint8(122), uint8(0), uint8(73), uint8(91), uint8(71), uint8(145), uint8(61), uint8(120), uint8(74), uint8(0), uint8(49), uint8(0),
 113502 	uint8(11), uint8(41), uint8(0), uint8(113), uint8(0), uint8(0), uint8(0), uint8(109), uint8(10), uint8(111), uint8(116), uint8(125), uint8(14),
 113503 	uint8(50), uint8(124), uint8(0), uint8(100), uint8(0), uint8(18), uint8(121), uint8(144), uint8(56), uint8(130), uint8(139), uint8(88), uint8(83),
 113504 	uint8(37), uint8(30), uint8(126), uint8(0), uint8(0), uint8(108), uint8(51), uint8(131), uint8(128), uint8(0), uint8(34), uint8(0), uint8(0),
 113505 	uint8(132), uint8(0), uint8(98), uint8(38), uint8(39), uint8(0), uint8(20), uint8(45), uint8(117), uint8(93),
 113506 }
 113507 
 113508 var aKWNext = [147]uint8{
 113509 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(4), uint8(0), uint8(43), uint8(0), uint8(0), uint8(106), uint8(114), uint8(0), uint8(0),
 113510 	uint8(0), uint8(2), uint8(0), uint8(0), uint8(143), uint8(0), uint8(0), uint8(0), uint8(13), uint8(0), uint8(0), uint8(0), uint8(0),
 113511 	uint8(141), uint8(0), uint8(0), uint8(119), uint8(52), uint8(0), uint8(0), uint8(137), uint8(12), uint8(0), uint8(0), uint8(62), uint8(0),
 113512 	uint8(138), uint8(0), uint8(133), uint8(0), uint8(0), uint8(36), uint8(0), uint8(0), uint8(28), uint8(77), uint8(0), uint8(0), uint8(0),
 113513 	uint8(0), uint8(59), uint8(0), uint8(47), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 113514 	uint8(0), uint8(69), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(146), uint8(3), uint8(0), uint8(58), uint8(0), uint8(1),
 113515 	uint8(75), uint8(0), uint8(0), uint8(0), uint8(31), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(127), uint8(0), uint8(104),
 113516 	uint8(0), uint8(64), uint8(66), uint8(63), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(46), uint8(0), uint8(16), uint8(8),
 113517 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(81), uint8(101), uint8(0),
 113518 	uint8(112), uint8(21), uint8(7), uint8(67), uint8(0), uint8(79), uint8(96), uint8(118), uint8(0), uint8(0), uint8(68), uint8(0), uint8(0),
 113519 	uint8(99), uint8(44), uint8(0), uint8(55), uint8(0), uint8(76), uint8(0), uint8(95), uint8(32), uint8(33), uint8(57), uint8(25), uint8(0),
 113520 	uint8(102), uint8(0), uint8(0), uint8(87),
 113521 }
 113522 
 113523 var aKWLen = [147]uint8{
 113524 	uint8(7), uint8(7), uint8(5), uint8(4), uint8(6), uint8(4), uint8(5), uint8(3), uint8(6), uint8(7), uint8(3), uint8(6), uint8(6),
 113525 	uint8(7), uint8(7), uint8(3), uint8(8), uint8(2), uint8(6), uint8(5), uint8(4), uint8(4), uint8(3), uint8(10), uint8(4), uint8(7),
 113526 	uint8(6), uint8(9), uint8(4), uint8(2), uint8(6), uint8(5), uint8(9), uint8(9), uint8(4), uint8(7), uint8(3), uint8(2), uint8(4),
 113527 	uint8(4), uint8(6), uint8(11), uint8(6), uint8(2), uint8(7), uint8(5), uint8(5), uint8(9), uint8(6), uint8(10), uint8(4), uint8(6),
 113528 	uint8(2), uint8(3), uint8(7), uint8(5), uint8(9), uint8(6), uint8(6), uint8(4), uint8(5), uint8(5), uint8(10), uint8(6), uint8(5),
 113529 	uint8(7), uint8(4), uint8(5), uint8(7), uint8(6), uint8(7), uint8(7), uint8(6), uint8(5), uint8(7), uint8(3), uint8(7), uint8(4),
 113530 	uint8(7), uint8(6), uint8(12), uint8(9), uint8(4), uint8(6), uint8(5), uint8(4), uint8(7), uint8(6), uint8(12), uint8(8), uint8(8),
 113531 	uint8(2), uint8(6), uint8(6), uint8(7), uint8(6), uint8(4), uint8(5), uint8(9), uint8(5), uint8(5), uint8(6), uint8(3), uint8(4),
 113532 	uint8(9), uint8(13), uint8(2), uint8(2), uint8(4), uint8(6), uint8(6), uint8(8), uint8(5), uint8(17), uint8(12), uint8(7), uint8(9),
 113533 	uint8(4), uint8(4), uint8(6), uint8(7), uint8(5), uint8(9), uint8(4), uint8(4), uint8(5), uint8(2), uint8(5), uint8(8), uint8(6),
 113534 	uint8(4), uint8(9), uint8(5), uint8(8), uint8(4), uint8(3), uint8(9), uint8(5), uint8(5), uint8(6), uint8(4), uint8(6), uint8(2),
 113535 	uint8(2), uint8(9), uint8(3), uint8(7),
 113536 }
 113537 
 113538 var aKWOffset = [147]uint16{
 113539 	uint16(0), uint16(2), uint16(2), uint16(8), uint16(9), uint16(14), uint16(16), uint16(20), uint16(23), uint16(25), uint16(25), uint16(29), uint16(33),
 113540 	uint16(36), uint16(41), uint16(46), uint16(48), uint16(53), uint16(54), uint16(59), uint16(62), uint16(65), uint16(67), uint16(69), uint16(78), uint16(81),
 113541 	uint16(86), uint16(90), uint16(90), uint16(94), uint16(99), uint16(101), uint16(105), uint16(111), uint16(119), uint16(123), uint16(123), uint16(123), uint16(126),
 113542 	uint16(129), uint16(132), uint16(137), uint16(142), uint16(146), uint16(147), uint16(152), uint16(156), uint16(160), uint16(168), uint16(174), uint16(181), uint16(184),
 113543 	uint16(184), uint16(187), uint16(189), uint16(195), uint16(198), uint16(206), uint16(211), uint16(216), uint16(219), uint16(222), uint16(226), uint16(236), uint16(239),
 113544 	uint16(244), uint16(244), uint16(248), uint16(252), uint16(259), uint16(265), uint16(271), uint16(277), uint16(277), uint16(283), uint16(284), uint16(288), uint16(295),
 113545 	uint16(299), uint16(306), uint16(312), uint16(324), uint16(333), uint16(335), uint16(341), uint16(346), uint16(348), uint16(355), uint16(359), uint16(370), uint16(377),
 113546 	uint16(378), uint16(385), uint16(391), uint16(397), uint16(402), uint16(408), uint16(412), uint16(415), uint16(424), uint16(429), uint16(433), uint16(439), uint16(441),
 113547 	uint16(444), uint16(453), uint16(455), uint16(457), uint16(466), uint16(470), uint16(476), uint16(482), uint16(490), uint16(495), uint16(495), uint16(495), uint16(511),
 113548 	uint16(520), uint16(523), uint16(527), uint16(532), uint16(539), uint16(544), uint16(553), uint16(557), uint16(560), uint16(565), uint16(567), uint16(571), uint16(579),
 113549 	uint16(585), uint16(588), uint16(597), uint16(602), uint16(610), uint16(610), uint16(614), uint16(623), uint16(628), uint16(633), uint16(639), uint16(642), uint16(645),
 113550 	uint16(648), uint16(650), uint16(655), uint16(659),
 113551 }
 113552 
 113553 var aKWCode = [147]uint8{
 113554 	uint8(TK_REINDEX), uint8(TK_INDEXED), uint8(TK_INDEX), uint8(TK_DESC), uint8(TK_ESCAPE),
 113555 	uint8(TK_EACH), uint8(TK_CHECK), uint8(TK_KEY), uint8(TK_BEFORE), uint8(TK_FOREIGN),
 113556 	uint8(TK_FOR), uint8(TK_IGNORE), uint8(TK_LIKE_KW), uint8(TK_EXPLAIN), uint8(TK_INSTEAD),
 113557 	uint8(TK_ADD), uint8(TK_DATABASE), uint8(TK_AS), uint8(TK_SELECT), uint8(TK_TABLE),
 113558 	uint8(TK_JOIN_KW), uint8(TK_THEN), uint8(TK_END), uint8(TK_DEFERRABLE), uint8(TK_ELSE),
 113559 	uint8(TK_EXCLUDE), uint8(TK_DELETE), uint8(TK_TEMP), uint8(TK_TEMP), uint8(TK_OR),
 113560 	uint8(TK_ISNULL), uint8(TK_NULLS), uint8(TK_SAVEPOINT), uint8(TK_INTERSECT), uint8(TK_TIES),
 113561 	uint8(TK_NOTNULL), uint8(TK_NOT), uint8(TK_NO), uint8(TK_NULL), uint8(TK_LIKE_KW),
 113562 	uint8(TK_EXCEPT), uint8(TK_TRANSACTION), uint8(TK_ACTION), uint8(TK_ON), uint8(TK_JOIN_KW),
 113563 	uint8(TK_ALTER), uint8(TK_RAISE), uint8(TK_EXCLUSIVE), uint8(TK_EXISTS), uint8(TK_CONSTRAINT),
 113564 	uint8(TK_INTO), uint8(TK_OFFSET), uint8(TK_OF), uint8(TK_SET), uint8(TK_TRIGGER),
 113565 	uint8(TK_RANGE), uint8(TK_GENERATED), uint8(TK_DETACH), uint8(TK_HAVING), uint8(TK_LIKE_KW),
 113566 	uint8(TK_BEGIN), uint8(TK_JOIN_KW), uint8(TK_REFERENCES), uint8(TK_UNIQUE), uint8(TK_QUERY),
 113567 	uint8(TK_WITHOUT), uint8(TK_WITH), uint8(TK_JOIN_KW), uint8(TK_RELEASE), uint8(TK_ATTACH),
 113568 	uint8(TK_BETWEEN), uint8(TK_NOTHING), uint8(TK_GROUPS), uint8(TK_GROUP), uint8(TK_CASCADE),
 113569 	uint8(TK_ASC), uint8(TK_DEFAULT), uint8(TK_CASE), uint8(TK_COLLATE), uint8(TK_CREATE),
 113570 	uint8(TK_CTIME_KW), uint8(TK_IMMEDIATE), uint8(TK_JOIN), uint8(TK_INSERT), uint8(TK_MATCH),
 113571 	uint8(TK_PLAN), uint8(TK_ANALYZE), uint8(TK_PRAGMA), uint8(TK_MATERIALIZED), uint8(TK_DEFERRED),
 113572 	uint8(TK_DISTINCT), uint8(TK_IS), uint8(TK_UPDATE), uint8(TK_VALUES), uint8(TK_VIRTUAL),
 113573 	uint8(TK_ALWAYS), uint8(TK_WHEN), uint8(TK_WHERE), uint8(TK_RECURSIVE), uint8(TK_ABORT),
 113574 	uint8(TK_AFTER), uint8(TK_RENAME), uint8(TK_AND), uint8(TK_DROP), uint8(TK_PARTITION),
 113575 	uint8(TK_AUTOINCR), uint8(TK_TO), uint8(TK_IN), uint8(TK_CAST), uint8(TK_COLUMNKW),
 113576 	uint8(TK_COMMIT), uint8(TK_CONFLICT), uint8(TK_JOIN_KW), uint8(TK_CTIME_KW), uint8(TK_CTIME_KW),
 113577 	uint8(TK_CURRENT), uint8(TK_PRECEDING), uint8(TK_FAIL), uint8(TK_LAST), uint8(TK_FILTER),
 113578 	uint8(TK_REPLACE), uint8(TK_FIRST), uint8(TK_FOLLOWING), uint8(TK_FROM), uint8(TK_JOIN_KW),
 113579 	uint8(TK_LIMIT), uint8(TK_IF), uint8(TK_ORDER), uint8(TK_RESTRICT), uint8(TK_OTHERS),
 113580 	uint8(TK_OVER), uint8(TK_RETURNING), uint8(TK_JOIN_KW), uint8(TK_ROLLBACK), uint8(TK_ROWS),
 113581 	uint8(TK_ROW), uint8(TK_UNBOUNDED), uint8(TK_UNION), uint8(TK_USING), uint8(TK_VACUUM),
 113582 	uint8(TK_VIEW), uint8(TK_WINDOW), uint8(TK_DO), uint8(TK_BY), uint8(TK_INITIALLY),
 113583 	uint8(TK_ALL), uint8(TK_PRIMARY),
 113584 }
 113585 
 113586 func keywordCode(tls *libc.TLS, z uintptr, n int32, pType uintptr) int32 {
 113587 	var i int32
 113588 	var j int32
 113589 	var zKW uintptr
 113590 	if n >= 2 {
 113591 		i = (int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(z))])*4 ^ int32(Xsqlite3UpperToLower[*(*uint8)(unsafe.Pointer(z + uintptr(n-1)))])*3 ^ n*1) % 127
 113592 		for i = int32(aKWHash[i]) - 1; i >= 0; i = int32(aKWNext[i]) - 1 {
 113593 			if int32(aKWLen[i]) != n {
 113594 				continue
 113595 			}
 113596 			zKW = uintptr(unsafe.Pointer(&zKWText)) + uintptr(aKWOffset[i])
 113597 			if int32(*(*uint8)(unsafe.Pointer(z)))&libc.CplInt32(0x20) != int32(*(*uint8)(unsafe.Pointer(zKW))) {
 113598 				continue
 113599 			}
 113600 			if int32(*(*uint8)(unsafe.Pointer(z + 1)))&libc.CplInt32(0x20) != int32(*(*uint8)(unsafe.Pointer(zKW + 1))) {
 113601 				continue
 113602 			}
 113603 			j = 2
 113604 			for j < n && int32(*(*uint8)(unsafe.Pointer(z + uintptr(j))))&libc.CplInt32(0x20) == int32(*(*uint8)(unsafe.Pointer(zKW + uintptr(j)))) {
 113605 				j++
 113606 			}
 113607 			if j < n {
 113608 				continue
 113609 			}
 113610 
 113611 			*(*int32)(unsafe.Pointer(pType)) = int32(aKWCode[i])
 113612 			break
 113613 		}
 113614 	}
 113615 	return n
 113616 }
 113617 
 113618 func Xsqlite3KeywordCode(tls *libc.TLS, z uintptr, n int32) int32 {
 113619 	bp := tls.Alloc(4)
 113620 	defer tls.Free(4)
 113621 
 113622 	*(*int32)(unsafe.Pointer(bp)) = TK_ID
 113623 	keywordCode(tls, z, n, bp)
 113624 	return *(*int32)(unsafe.Pointer(bp))
 113625 }
 113626 
 113627 func Xsqlite3_keyword_name(tls *libc.TLS, i int32, pzName uintptr, pnName uintptr) int32 {
 113628 	if i < 0 || i >= SQLITE_N_KEYWORD {
 113629 		return SQLITE_ERROR
 113630 	}
 113631 	*(*uintptr)(unsafe.Pointer(pzName)) = uintptr(unsafe.Pointer(&zKWText)) + uintptr(aKWOffset[i])
 113632 	*(*int32)(unsafe.Pointer(pnName)) = int32(aKWLen[i])
 113633 	return SQLITE_OK
 113634 }
 113635 
 113636 func Xsqlite3_keyword_count(tls *libc.TLS) int32 {
 113637 	return SQLITE_N_KEYWORD
 113638 }
 113639 
 113640 func Xsqlite3_keyword_check(tls *libc.TLS, zName uintptr, nName int32) int32 {
 113641 	return libc.Bool32(TK_ID != Xsqlite3KeywordCode(tls, zName, nName))
 113642 }
 113643 
 113644 // Make the IdChar function accessible from ctime.c and alter.c
 113645 func Xsqlite3IsIdChar(tls *libc.TLS, c U8) int32 {
 113646 	return libc.Bool32(int32(Xsqlite3CtypeMap[c])&0x46 != 0)
 113647 }
 113648 
 113649 func getToken(tls *libc.TLS, pz uintptr) int32 {
 113650 	bp := tls.Alloc(4)
 113651 	defer tls.Free(4)
 113652 
 113653 	var z uintptr = *(*uintptr)(unsafe.Pointer(pz))
 113654 
 113655 	for __ccgo := true; __ccgo; __ccgo = *(*int32)(unsafe.Pointer(bp)) == TK_SPACE {
 113656 		z += uintptr(Xsqlite3GetToken(tls, z, bp))
 113657 	}
 113658 	if *(*int32)(unsafe.Pointer(bp)) == TK_ID ||
 113659 		*(*int32)(unsafe.Pointer(bp)) == TK_STRING ||
 113660 		*(*int32)(unsafe.Pointer(bp)) == TK_JOIN_KW ||
 113661 		*(*int32)(unsafe.Pointer(bp)) == TK_WINDOW ||
 113662 		*(*int32)(unsafe.Pointer(bp)) == TK_OVER ||
 113663 		Xsqlite3ParserFallback(tls, *(*int32)(unsafe.Pointer(bp))) == TK_ID {
 113664 		*(*int32)(unsafe.Pointer(bp)) = TK_ID
 113665 	}
 113666 	*(*uintptr)(unsafe.Pointer(pz)) = z
 113667 	return *(*int32)(unsafe.Pointer(bp))
 113668 }
 113669 
 113670 func analyzeWindowKeyword(tls *libc.TLS, z uintptr) int32 {
 113671 	bp := tls.Alloc(4)
 113672 	defer tls.Free(4)
 113673 	*(*uintptr)(unsafe.Pointer(bp)) = z
 113674 
 113675 	var t int32
 113676 	t = getToken(tls, bp)
 113677 	if t != TK_ID {
 113678 		return TK_ID
 113679 	}
 113680 	t = getToken(tls, bp)
 113681 	if t != TK_AS {
 113682 		return TK_ID
 113683 	}
 113684 	return TK_WINDOW
 113685 }
 113686 
 113687 func analyzeOverKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 {
 113688 	bp := tls.Alloc(4)
 113689 	defer tls.Free(4)
 113690 	*(*uintptr)(unsafe.Pointer(bp)) = z
 113691 
 113692 	if lastToken == TK_RP {
 113693 		var t int32 = getToken(tls, bp)
 113694 		if t == TK_LP || t == TK_ID {
 113695 			return TK_OVER
 113696 		}
 113697 	}
 113698 	return TK_ID
 113699 }
 113700 
 113701 func analyzeFilterKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 {
 113702 	bp := tls.Alloc(4)
 113703 	defer tls.Free(4)
 113704 	*(*uintptr)(unsafe.Pointer(bp)) = z
 113705 
 113706 	if lastToken == TK_RP && getToken(tls, bp) == TK_LP {
 113707 		return TK_FILTER
 113708 	}
 113709 	return TK_ID
 113710 }
 113711 
 113712 // Return the length (in bytes) of the token that begins at z[0].
 113713 // Store the token type in *tokenType before returning.
 113714 func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 {
 113715 	var i int32
 113716 	var c int32
 113717 	switch int32(aiClass[*(*uint8)(unsafe.Pointer(z))]) {
 113718 	case CC_SPACE:
 113719 		{
 113720 			for i = 1; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x01 != 0; i++ {
 113721 			}
 113722 			*(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE
 113723 			return i
 113724 
 113725 		}
 113726 	case CC_MINUS:
 113727 		{
 113728 			if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '-' {
 113729 				for i = 2; libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) != 0 && c != '\n'; i++ {
 113730 				}
 113731 				*(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE
 113732 				return i
 113733 			} else if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '>' {
 113734 				*(*int32)(unsafe.Pointer(tokenType)) = TK_PTR
 113735 				return 2 + libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + 2))) == '>')
 113736 			}
 113737 			*(*int32)(unsafe.Pointer(tokenType)) = TK_MINUS
 113738 			return 1
 113739 
 113740 		}
 113741 	case CC_LP:
 113742 		{
 113743 			*(*int32)(unsafe.Pointer(tokenType)) = TK_LP
 113744 			return 1
 113745 
 113746 		}
 113747 	case CC_RP:
 113748 		{
 113749 			*(*int32)(unsafe.Pointer(tokenType)) = TK_RP
 113750 			return 1
 113751 
 113752 		}
 113753 	case CC_SEMI:
 113754 		{
 113755 			*(*int32)(unsafe.Pointer(tokenType)) = TK_SEMI
 113756 			return 1
 113757 
 113758 		}
 113759 	case CC_PLUS:
 113760 		{
 113761 			*(*int32)(unsafe.Pointer(tokenType)) = TK_PLUS
 113762 			return 1
 113763 
 113764 		}
 113765 	case CC_STAR:
 113766 		{
 113767 			*(*int32)(unsafe.Pointer(tokenType)) = TK_STAR
 113768 			return 1
 113769 
 113770 		}
 113771 	case CC_SLASH:
 113772 		{
 113773 			if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '*' || int32(*(*uint8)(unsafe.Pointer(z + 2))) == 0 {
 113774 				*(*int32)(unsafe.Pointer(tokenType)) = TK_SLASH
 113775 				return 1
 113776 			}
 113777 			i = 3
 113778 			c = int32(*(*uint8)(unsafe.Pointer(z + 2)))
 113779 			for ; (c != '*' || int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '/') && libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) != 0; i++ {
 113780 			}
 113781 			if c != 0 {
 113782 				i++
 113783 			}
 113784 			*(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE
 113785 			return i
 113786 
 113787 		}
 113788 	case CC_PERCENT:
 113789 		{
 113790 			*(*int32)(unsafe.Pointer(tokenType)) = TK_REM
 113791 			return 1
 113792 
 113793 		}
 113794 	case CC_EQ:
 113795 		{
 113796 			*(*int32)(unsafe.Pointer(tokenType)) = TK_EQ
 113797 			return 1 + libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + 1))) == '=')
 113798 
 113799 		}
 113800 	case CC_LT:
 113801 		{
 113802 			if libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1)))) == '=' {
 113803 				*(*int32)(unsafe.Pointer(tokenType)) = TK_LE
 113804 				return 2
 113805 			} else if c == '>' {
 113806 				*(*int32)(unsafe.Pointer(tokenType)) = TK_NE
 113807 				return 2
 113808 			} else if c == '<' {
 113809 				*(*int32)(unsafe.Pointer(tokenType)) = TK_LSHIFT
 113810 				return 2
 113811 			} else {
 113812 				*(*int32)(unsafe.Pointer(tokenType)) = TK_LT
 113813 				return 1
 113814 			}
 113815 
 113816 		}
 113817 		fallthrough
 113818 	case CC_GT:
 113819 		{
 113820 			if libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1)))) == '=' {
 113821 				*(*int32)(unsafe.Pointer(tokenType)) = TK_GE
 113822 				return 2
 113823 			} else if c == '>' {
 113824 				*(*int32)(unsafe.Pointer(tokenType)) = TK_RSHIFT
 113825 				return 2
 113826 			} else {
 113827 				*(*int32)(unsafe.Pointer(tokenType)) = TK_GT
 113828 				return 1
 113829 			}
 113830 
 113831 		}
 113832 		fallthrough
 113833 	case CC_BANG:
 113834 		{
 113835 			if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '=' {
 113836 				*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 113837 				return 1
 113838 			} else {
 113839 				*(*int32)(unsafe.Pointer(tokenType)) = TK_NE
 113840 				return 2
 113841 			}
 113842 
 113843 		}
 113844 		fallthrough
 113845 	case CC_PIPE:
 113846 		{
 113847 			if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '|' {
 113848 				*(*int32)(unsafe.Pointer(tokenType)) = TK_BITOR
 113849 				return 1
 113850 			} else {
 113851 				*(*int32)(unsafe.Pointer(tokenType)) = TK_CONCAT
 113852 				return 2
 113853 			}
 113854 
 113855 		}
 113856 		fallthrough
 113857 	case CC_COMMA:
 113858 		{
 113859 			*(*int32)(unsafe.Pointer(tokenType)) = TK_COMMA
 113860 			return 1
 113861 
 113862 		}
 113863 	case CC_AND:
 113864 		{
 113865 			*(*int32)(unsafe.Pointer(tokenType)) = TK_BITAND
 113866 			return 1
 113867 
 113868 		}
 113869 	case CC_TILDA:
 113870 		{
 113871 			*(*int32)(unsafe.Pointer(tokenType)) = TK_BITNOT
 113872 			return 1
 113873 
 113874 		}
 113875 	case CC_QUOTE:
 113876 		{
 113877 			var delim int32 = int32(*(*uint8)(unsafe.Pointer(z)))
 113878 
 113879 			for i = 1; libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) != 0; i++ {
 113880 				if c == delim {
 113881 					if int32(*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))) == delim {
 113882 						i++
 113883 					} else {
 113884 						break
 113885 					}
 113886 				}
 113887 			}
 113888 			if c == '\'' {
 113889 				*(*int32)(unsafe.Pointer(tokenType)) = TK_STRING
 113890 				return i + 1
 113891 			} else if c != 0 {
 113892 				*(*int32)(unsafe.Pointer(tokenType)) = TK_ID
 113893 				return i + 1
 113894 			} else {
 113895 				*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 113896 				return i
 113897 			}
 113898 
 113899 		}
 113900 		fallthrough
 113901 	case CC_DOT:
 113902 		{
 113903 			if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 1))])&0x04 != 0) {
 113904 				*(*int32)(unsafe.Pointer(tokenType)) = TK_DOT
 113905 				return 1
 113906 			}
 113907 
 113908 		}
 113909 		fallthrough
 113910 	case CC_DIGIT:
 113911 		{
 113912 			*(*int32)(unsafe.Pointer(tokenType)) = TK_INTEGER
 113913 			if int32(*(*uint8)(unsafe.Pointer(z))) == '0' && (int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'x' || int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'X') && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 2))])&0x08 != 0 {
 113914 				for i = 3; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x08 != 0; i++ {
 113915 				}
 113916 				return i
 113917 			}
 113918 			for i = 0; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x04 != 0; i++ {
 113919 			}
 113920 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == '.' {
 113921 				i++
 113922 				for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x04 != 0 {
 113923 					i++
 113924 				}
 113925 				*(*int32)(unsafe.Pointer(tokenType)) = TK_FLOAT
 113926 			}
 113927 			if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'e' || int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'E') && (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))])&0x04 != 0 ||
 113928 				(int32(*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))) == '+' || int32(*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))) == '-') && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i+2)))])&0x04 != 0) {
 113929 				i = i + 2
 113930 				for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x04 != 0 {
 113931 					i++
 113932 				}
 113933 				*(*int32)(unsafe.Pointer(tokenType)) = TK_FLOAT
 113934 			}
 113935 			for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x46 != 0 {
 113936 				*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 113937 				i++
 113938 			}
 113939 			return i
 113940 
 113941 		}
 113942 	case CC_QUOTE2:
 113943 		{
 113944 			i = 1
 113945 			c = int32(*(*uint8)(unsafe.Pointer(z)))
 113946 			for ; c != ']' && libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) != 0; i++ {
 113947 			}
 113948 			*(*int32)(unsafe.Pointer(tokenType)) = func() int32 {
 113949 				if c == ']' {
 113950 					return TK_ID
 113951 				}
 113952 				return TK_ILLEGAL
 113953 			}()
 113954 			return i
 113955 
 113956 		}
 113957 	case CC_VARNUM:
 113958 		{
 113959 			*(*int32)(unsafe.Pointer(tokenType)) = TK_VARIABLE
 113960 			for i = 1; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x04 != 0; i++ {
 113961 			}
 113962 			return i
 113963 
 113964 		}
 113965 	case CC_DOLLAR:
 113966 		fallthrough
 113967 	case CC_VARALPHA:
 113968 		{
 113969 			var n int32 = 0
 113970 
 113971 			*(*int32)(unsafe.Pointer(tokenType)) = TK_VARIABLE
 113972 			for i = 1; libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) != 0; i++ {
 113973 				if int32(Xsqlite3CtypeMap[uint8(c)])&0x46 != 0 {
 113974 					n++
 113975 				} else if c == '(' && n > 0 {
 113976 					for __ccgo := true; __ccgo; __ccgo = libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) != 0 && !(int32(Xsqlite3CtypeMap[uint8(c)])&0x01 != 0) && c != ')' {
 113977 						i++
 113978 					}
 113979 					if c == ')' {
 113980 						i++
 113981 					} else {
 113982 						*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 113983 					}
 113984 					break
 113985 				} else if c == ':' && int32(*(*uint8)(unsafe.Pointer(z + uintptr(i+1)))) == ':' {
 113986 					i++
 113987 				} else {
 113988 					break
 113989 				}
 113990 			}
 113991 			if n == 0 {
 113992 				*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 113993 			}
 113994 			return i
 113995 
 113996 		}
 113997 	case CC_KYWD0:
 113998 		{
 113999 			for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= CC_KYWD; i++ {
 114000 			}
 114001 			if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x46 != 0 {
 114002 				i++
 114003 				break
 114004 			}
 114005 			*(*int32)(unsafe.Pointer(tokenType)) = TK_ID
 114006 			return keywordCode(tls, z, i, tokenType)
 114007 
 114008 		}
 114009 	case CC_X:
 114010 		{
 114011 			if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '\'' {
 114012 				*(*int32)(unsafe.Pointer(tokenType)) = TK_BLOB
 114013 				for i = 2; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x08 != 0; i++ {
 114014 				}
 114015 				if int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'' || i%2 != 0 {
 114016 					*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 114017 					for *(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0 && int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'' {
 114018 						i++
 114019 					}
 114020 				}
 114021 				if *(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0 {
 114022 					i++
 114023 				}
 114024 				return i
 114025 			}
 114026 
 114027 		}
 114028 		fallthrough
 114029 	case CC_KYWD:
 114030 		fallthrough
 114031 	case CC_ID:
 114032 		{
 114033 			i = 1
 114034 			break
 114035 
 114036 		}
 114037 	case CC_BOM:
 114038 		{
 114039 			if int32(*(*uint8)(unsafe.Pointer(z + 1))) == 0xbb && int32(*(*uint8)(unsafe.Pointer(z + 2))) == 0xbf {
 114040 				*(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE
 114041 				return 3
 114042 			}
 114043 			i = 1
 114044 			break
 114045 
 114046 		}
 114047 	case CC_NUL:
 114048 		{
 114049 			*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 114050 			return 0
 114051 
 114052 		}
 114053 	default:
 114054 		{
 114055 			*(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL
 114056 			return 1
 114057 
 114058 		}
 114059 	}
 114060 	for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x46 != 0 {
 114061 		i++
 114062 	}
 114063 	*(*int32)(unsafe.Pointer(tokenType)) = TK_ID
 114064 	return i
 114065 }
 114066 
 114067 // Run the parser on the given SQL string.
 114068 func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr) int32 {
 114069 	bp := tls.Alloc(1256)
 114070 	defer tls.Free(1256)
 114071 
 114072 	var nErr int32 = 0
 114073 	var pEngine uintptr
 114074 	var n int32 = 0
 114075 
 114076 	var lastTokenParsed int32 = -1
 114077 	var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb
 114078 	var mxSqlLen int32
 114079 	var pParentParse uintptr = uintptr(0)
 114080 
 114081 	mxSqlLen = *(*int32)(unsafe.Pointer(db + 120 + 1*4))
 114082 	if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 {
 114083 		libc.AtomicStoreNInt32(db+312, int32(0), 0)
 114084 	}
 114085 	(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_OK
 114086 	(*Parse)(unsafe.Pointer(pParse)).FzTail = zSql
 114087 	pEngine = bp + 32
 114088 	Xsqlite3ParserInit(tls, pEngine, pParse)
 114089 
 114090 	pParentParse = (*Sqlite3)(unsafe.Pointer(db)).FpParse
 114091 	(*Sqlite3)(unsafe.Pointer(db)).FpParse = pParse
 114092 	for 1 != 0 {
 114093 		n = Xsqlite3GetToken(tls, zSql, bp+1244)
 114094 		mxSqlLen = mxSqlLen - n
 114095 		if mxSqlLen < 0 {
 114096 			(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_TOOBIG
 114097 			(*Parse)(unsafe.Pointer(pParse)).FnErr++
 114098 			break
 114099 		}
 114100 		if *(*int32)(unsafe.Pointer(bp + 1244)) >= TK_WINDOW {
 114101 			if libc.AtomicLoadNInt32(db+312, 0) != 0 {
 114102 				(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_INTERRUPT
 114103 				(*Parse)(unsafe.Pointer(pParse)).FnErr++
 114104 				break
 114105 			}
 114106 			if *(*int32)(unsafe.Pointer(bp + 1244)) == TK_SPACE {
 114107 				zSql += uintptr(n)
 114108 				continue
 114109 			}
 114110 			if int32(*(*uint8)(unsafe.Pointer(zSql))) == 0 {
 114111 				if lastTokenParsed == TK_SEMI {
 114112 					*(*int32)(unsafe.Pointer(bp + 1244)) = 0
 114113 				} else if lastTokenParsed == 0 {
 114114 					break
 114115 				} else {
 114116 					*(*int32)(unsafe.Pointer(bp + 1244)) = TK_SEMI
 114117 				}
 114118 				n = 0
 114119 			} else if *(*int32)(unsafe.Pointer(bp + 1244)) == TK_WINDOW {
 114120 				*(*int32)(unsafe.Pointer(bp + 1244)) = analyzeWindowKeyword(tls, zSql+6)
 114121 			} else if *(*int32)(unsafe.Pointer(bp + 1244)) == TK_OVER {
 114122 				*(*int32)(unsafe.Pointer(bp + 1244)) = analyzeOverKeyword(tls, zSql+4, lastTokenParsed)
 114123 			} else if *(*int32)(unsafe.Pointer(bp + 1244)) == TK_FILTER {
 114124 				*(*int32)(unsafe.Pointer(bp + 1244)) = analyzeFilterKeyword(tls, zSql+6, lastTokenParsed)
 114125 			} else {
 114126 				(*Token)(unsafe.Pointer(bp + 1248)).Fz = zSql
 114127 				(*Token)(unsafe.Pointer(bp + 1248)).Fn = uint32(n)
 114128 				Xsqlite3ErrorMsg(tls, pParse, ts+23356, libc.VaList(bp, bp+1248))
 114129 				break
 114130 			}
 114131 		}
 114132 		(*Parse)(unsafe.Pointer(pParse)).FsLastToken.Fz = zSql
 114133 		(*Parse)(unsafe.Pointer(pParse)).FsLastToken.Fn = uint32(n)
 114134 		Xsqlite3Parser(tls, pEngine, *(*int32)(unsafe.Pointer(bp + 1244)), (*Parse)(unsafe.Pointer(pParse)).FsLastToken)
 114135 		lastTokenParsed = *(*int32)(unsafe.Pointer(bp + 1244))
 114136 		zSql += uintptr(n)
 114137 
 114138 		if (*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_OK {
 114139 			break
 114140 		}
 114141 	}
 114142 
 114143 	Xsqlite3ParserFinalize(tls, pEngine)
 114144 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 114145 		(*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
 114146 	}
 114147 	if (*Parse)(unsafe.Pointer(pParse)).FzErrMsg != 0 || (*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_OK && (*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_DONE {
 114148 		if (*Parse)(unsafe.Pointer(pParse)).FzErrMsg == uintptr(0) {
 114149 			(*Parse)(unsafe.Pointer(pParse)).FzErrMsg = Xsqlite3MPrintf(tls, db, ts+3663, libc.VaList(bp+8, Xsqlite3ErrStr(tls, (*Parse)(unsafe.Pointer(pParse)).Frc)))
 114150 		}
 114151 		Xsqlite3_log(tls, (*Parse)(unsafe.Pointer(pParse)).Frc, ts+23381, libc.VaList(bp+16, (*Parse)(unsafe.Pointer(pParse)).FzErrMsg, (*Parse)(unsafe.Pointer(pParse)).FzTail))
 114152 		nErr++
 114153 	}
 114154 	(*Parse)(unsafe.Pointer(pParse)).FzTail = zSql
 114155 	Xsqlite3_free(tls, (*Parse)(unsafe.Pointer(pParse)).FapVtabLock)
 114156 
 114157 	if (*Parse)(unsafe.Pointer(pParse)).FpNewTable != 0 && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) {
 114158 		Xsqlite3DeleteTable(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTable)
 114159 	}
 114160 	if (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger != 0 && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) {
 114161 		Xsqlite3DeleteTrigger(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger)
 114162 	}
 114163 	if (*Parse)(unsafe.Pointer(pParse)).FpVList != 0 {
 114164 		Xsqlite3DbNNFreeNN(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpVList)
 114165 	}
 114166 	(*Sqlite3)(unsafe.Pointer(db)).FpParse = pParentParse
 114167 
 114168 	return nErr
 114169 }
 114170 
 114171 // Return TRUE if the given SQL string ends in a semicolon.
 114172 //
 114173 // Special handling is require for CREATE TRIGGER statements.
 114174 // Whenever the CREATE TRIGGER keywords are seen, the statement
 114175 // must end with ";END;".
 114176 //
 114177 // This implementation uses a state machine with 8 states:
 114178 //
 114179 //	(0) INVALID   We have not yet seen a non-whitespace character.
 114180 //
 114181 //	(1) START     At the beginning or end of an SQL statement.  This routine
 114182 //	              returns 1 if it ends in the START state and 0 if it ends
 114183 //	              in any other state.
 114184 //
 114185 //	(2) NORMAL    We are in the middle of statement which ends with a single
 114186 //	              semicolon.
 114187 //
 114188 //	(3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of
 114189 //	              a statement.
 114190 //
 114191 //	(4) CREATE    The keyword CREATE has been seen at the beginning of a
 114192 //	              statement, possibly preceded by EXPLAIN and/or followed by
 114193 //	              TEMP or TEMPORARY
 114194 //
 114195 //	(5) TRIGGER   We are in the middle of a trigger definition that must be
 114196 //	              ended by a semicolon, the keyword END, and another semicolon.
 114197 //
 114198 //	(6) SEMI      We've seen the first semicolon in the ";END;" that occurs at
 114199 //	              the end of a trigger definition.
 114200 //
 114201 //	(7) END       We've seen the ";END" of the ";END;" that occurs at the end
 114202 //	              of a trigger definition.
 114203 //
 114204 // Transitions between states above are determined by tokens extracted
 114205 // from the input.  The following tokens are significant:
 114206 //
 114207 //	(0) tkSEMI      A semicolon.
 114208 //	(1) tkWS        Whitespace.
 114209 //	(2) tkOTHER     Any other SQL token.
 114210 //	(3) tkEXPLAIN   The "explain" keyword.
 114211 //	(4) tkCREATE    The "create" keyword.
 114212 //	(5) tkTEMP      The "temp" or "temporary" keyword.
 114213 //	(6) tkTRIGGER   The "trigger" keyword.
 114214 //	(7) tkEND       The "end" keyword.
 114215 //
 114216 // Whitespace never causes a state transition and is always ignored.
 114217 // This means that a SQL string of all whitespace is invalid.
 114218 //
 114219 // If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
 114220 // to recognize the end of a trigger can be omitted.  All we have to do
 114221 // is look for a semicolon that is not part of an string or comment.
 114222 func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 {
 114223 	var state U8 = U8(0)
 114224 	var token U8
 114225 
 114226 	for *(*uint8)(unsafe.Pointer(zSql)) != 0 {
 114227 		switch int32(*(*uint8)(unsafe.Pointer(zSql))) {
 114228 		case ';':
 114229 			{
 114230 				token = U8(TkSEMI)
 114231 				break
 114232 
 114233 			}
 114234 		case ' ':
 114235 			fallthrough
 114236 		case '\r':
 114237 			fallthrough
 114238 		case '\t':
 114239 			fallthrough
 114240 		case '\n':
 114241 			fallthrough
 114242 		case '\f':
 114243 			{
 114244 				token = U8(TkWS)
 114245 				break
 114246 
 114247 			}
 114248 		case '/':
 114249 			{
 114250 				if int32(*(*uint8)(unsafe.Pointer(zSql + 1))) != '*' {
 114251 					token = U8(TkOTHER)
 114252 					break
 114253 				}
 114254 				zSql += uintptr(2)
 114255 				for *(*uint8)(unsafe.Pointer(zSql)) != 0 && (int32(*(*uint8)(unsafe.Pointer(zSql))) != '*' || int32(*(*uint8)(unsafe.Pointer(zSql + 1))) != '/') {
 114256 					zSql++
 114257 				}
 114258 				if int32(*(*uint8)(unsafe.Pointer(zSql))) == 0 {
 114259 					return 0
 114260 				}
 114261 				zSql++
 114262 				token = U8(TkWS)
 114263 				break
 114264 
 114265 			}
 114266 		case '-':
 114267 			{
 114268 				if int32(*(*uint8)(unsafe.Pointer(zSql + 1))) != '-' {
 114269 					token = U8(TkOTHER)
 114270 					break
 114271 				}
 114272 				for *(*uint8)(unsafe.Pointer(zSql)) != 0 && int32(*(*uint8)(unsafe.Pointer(zSql))) != '\n' {
 114273 					zSql++
 114274 				}
 114275 				if int32(*(*uint8)(unsafe.Pointer(zSql))) == 0 {
 114276 					return libc.Bool32(int32(state) == 1)
 114277 				}
 114278 				token = U8(TkWS)
 114279 				break
 114280 
 114281 			}
 114282 		case '[':
 114283 			{
 114284 				zSql++
 114285 				for *(*uint8)(unsafe.Pointer(zSql)) != 0 && int32(*(*uint8)(unsafe.Pointer(zSql))) != ']' {
 114286 					zSql++
 114287 				}
 114288 				if int32(*(*uint8)(unsafe.Pointer(zSql))) == 0 {
 114289 					return 0
 114290 				}
 114291 				token = U8(TkOTHER)
 114292 				break
 114293 
 114294 			}
 114295 		case '`':
 114296 			fallthrough
 114297 		case '"':
 114298 			fallthrough
 114299 		case '\'':
 114300 			{
 114301 				var c int32 = int32(*(*uint8)(unsafe.Pointer(zSql)))
 114302 				zSql++
 114303 				for *(*uint8)(unsafe.Pointer(zSql)) != 0 && int32(*(*uint8)(unsafe.Pointer(zSql))) != c {
 114304 					zSql++
 114305 				}
 114306 				if int32(*(*uint8)(unsafe.Pointer(zSql))) == 0 {
 114307 					return 0
 114308 				}
 114309 				token = U8(TkOTHER)
 114310 				break
 114311 
 114312 			}
 114313 		default:
 114314 			{
 114315 				if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zSql))])&0x46 != 0 {
 114316 					var nId int32
 114317 					for nId = 1; int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zSql + uintptr(nId)))])&0x46 != 0; nId++ {
 114318 					}
 114319 					switch int32(*(*uint8)(unsafe.Pointer(zSql))) {
 114320 					case 'c':
 114321 						fallthrough
 114322 					case 'C':
 114323 						{
 114324 							if nId == 6 && Xsqlite3_strnicmp(tls, zSql, ts+23392, 6) == 0 {
 114325 								token = U8(TkCREATE)
 114326 							} else {
 114327 								token = U8(TkOTHER)
 114328 							}
 114329 							break
 114330 
 114331 						}
 114332 						fallthrough
 114333 					case 't':
 114334 						fallthrough
 114335 					case 'T':
 114336 						{
 114337 							if nId == 7 && Xsqlite3_strnicmp(tls, zSql, ts+19978, 7) == 0 {
 114338 								token = U8(TkTRIGGER)
 114339 							} else if nId == 4 && Xsqlite3_strnicmp(tls, zSql, ts+23399, 4) == 0 {
 114340 								token = U8(TkTEMP)
 114341 							} else if nId == 9 && Xsqlite3_strnicmp(tls, zSql, ts+23404, 9) == 0 {
 114342 								token = U8(TkTEMP)
 114343 							} else {
 114344 								token = U8(TkOTHER)
 114345 							}
 114346 							break
 114347 
 114348 						}
 114349 						fallthrough
 114350 					case 'e':
 114351 						fallthrough
 114352 					case 'E':
 114353 						{
 114354 							if nId == 3 && Xsqlite3_strnicmp(tls, zSql, ts+23414, 3) == 0 {
 114355 								token = U8(TkEND)
 114356 							} else if nId == 7 && Xsqlite3_strnicmp(tls, zSql, ts+23418, 7) == 0 {
 114357 								token = U8(TkEXPLAIN)
 114358 							} else {
 114359 								token = U8(TkOTHER)
 114360 							}
 114361 							break
 114362 
 114363 						}
 114364 						fallthrough
 114365 					default:
 114366 						{
 114367 							token = U8(TkOTHER)
 114368 							break
 114369 
 114370 						}
 114371 					}
 114372 					zSql += uintptr(nId - 1)
 114373 				} else {
 114374 					token = U8(TkOTHER)
 114375 				}
 114376 				break
 114377 
 114378 			}
 114379 		}
 114380 		state = *(*U8)(unsafe.Pointer(uintptr(unsafe.Pointer(&trans)) + uintptr(state)*8 + uintptr(token)))
 114381 		zSql++
 114382 	}
 114383 	return libc.Bool32(int32(state) == 1)
 114384 }
 114385 
 114386 var trans = [8][8]U8{
 114387 	{U8(1), U8(0), U8(2), U8(3), U8(4), U8(2), U8(2), U8(2)},
 114388 	{U8(1), U8(1), U8(2), U8(3), U8(4), U8(2), U8(2), U8(2)},
 114389 	{U8(1), U8(2), U8(2), U8(2), U8(2), U8(2), U8(2), U8(2)},
 114390 	{U8(1), U8(3), U8(3), U8(2), U8(4), U8(2), U8(2), U8(2)},
 114391 	{U8(1), U8(4), U8(2), U8(2), U8(2), U8(4), U8(5), U8(2)},
 114392 	{U8(6), U8(5), U8(5), U8(5), U8(5), U8(5), U8(5), U8(5)},
 114393 	{U8(6), U8(6), U8(5), U8(5), U8(5), U8(5), U8(5), U8(7)},
 114394 	{U8(1), U8(7), U8(5), U8(5), U8(5), U8(5), U8(5), U8(5)},
 114395 }
 114396 
 114397 // This routine is the same as the sqlite3_complete() routine described
 114398 // above, except that the parameter is required to be UTF-16 encoded, not
 114399 // UTF-8.
 114400 func Xsqlite3_complete16(tls *libc.TLS, zSql uintptr) int32 {
 114401 	var pVal uintptr
 114402 	var zSql8 uintptr
 114403 	var rc int32
 114404 
 114405 	rc = Xsqlite3_initialize(tls)
 114406 	if rc != 0 {
 114407 		return rc
 114408 	}
 114409 	pVal = Xsqlite3ValueNew(tls, uintptr(0))
 114410 	Xsqlite3ValueSetStr(tls, pVal, -1, zSql, uint8(SQLITE_UTF16LE), uintptr(0))
 114411 	zSql8 = Xsqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8))
 114412 	if zSql8 != 0 {
 114413 		rc = Xsqlite3_complete(tls, zSql8)
 114414 	} else {
 114415 		rc = SQLITE_NOMEM
 114416 	}
 114417 	Xsqlite3ValueFree(tls, pVal)
 114418 	return rc & 0xff
 114419 }
 114420 
 114421 func sqlite3TestExtInit(tls *libc.TLS, db uintptr) int32 {
 114422 	_ = db
 114423 	return Xsqlite3FaultSim(tls, 500)
 114424 }
 114425 
 114426 var sqlite3BuiltinExtensions = [4]uintptr{
 114427 	0,
 114428 	0,
 114429 	0,
 114430 	0,
 114431 }
 114432 
 114433 // IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
 114434 // a pointer to the to the sqlite3_version[] string constant.
 114435 func Xsqlite3_libversion(tls *libc.TLS) uintptr {
 114436 	return uintptr(unsafe.Pointer(&Xsqlite3_version))
 114437 }
 114438 
 114439 // IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
 114440 // returns an integer equal to SQLITE_VERSION_NUMBER.
 114441 func Xsqlite3_libversion_number(tls *libc.TLS) int32 {
 114442 	return SQLITE_VERSION_NUMBER
 114443 }
 114444 
 114445 // IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
 114446 // zero if and only if SQLite was compiled with mutexing code omitted due to
 114447 // the SQLITE_THREADSAFE compile-time option being set to 0.
 114448 func Xsqlite3_threadsafe(tls *libc.TLS) int32 {
 114449 	return SQLITE_THREADSAFE
 114450 }
 114451 
 114452 // If the following global variable points to a string which is the
 114453 // name of a directory, then that directory will be used to store
 114454 // temporary files.
 114455 //
 114456 // See also the "PRAGMA temp_store_directory" SQL command.
 114457 var Xsqlite3_temp_directory uintptr = uintptr(0)
 114458 
 114459 // If the following global variable points to a string which is the
 114460 // name of a directory, then that directory will be used to store
 114461 // all database files specified with a relative pathname.
 114462 //
 114463 // See also the "PRAGMA data_store_directory" SQL command.
 114464 var Xsqlite3_data_directory uintptr = uintptr(0)
 114465 
 114466 var mu mutex
 114467 
 114468 func init() { mu.recursive = true }
 114469 
 114470 func Xsqlite3_initialize(tls *libc.TLS) int32 {
 114471 	mu.enter(tls.ID)
 114472 	defer mu.leave(tls.ID)
 114473 
 114474 	var pMainMtx uintptr
 114475 	var rc int32
 114476 
 114477 	if Xsqlite3Config.FisInit != 0 {
 114478 		return SQLITE_OK
 114479 	}
 114480 
 114481 	rc = Xsqlite3MutexInit(tls)
 114482 	if rc != 0 {
 114483 		return rc
 114484 	}
 114485 
 114486 	pMainMtx = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)
 114487 	Xsqlite3_mutex_enter(tls, pMainMtx)
 114488 	Xsqlite3Config.FisMutexInit = 1
 114489 	if !(Xsqlite3Config.FisMallocInit != 0) {
 114490 		rc = Xsqlite3MallocInit(tls)
 114491 	}
 114492 	if rc == SQLITE_OK {
 114493 		Xsqlite3Config.FisMallocInit = 1
 114494 		if !(int32(Xsqlite3Config.FpInitMutex) != 0) {
 114495 			Xsqlite3Config.FpInitMutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE)
 114496 			if Xsqlite3Config.FbCoreMutex != 0 && !(int32(Xsqlite3Config.FpInitMutex) != 0) {
 114497 				rc = SQLITE_NOMEM
 114498 			}
 114499 		}
 114500 	}
 114501 	if rc == SQLITE_OK {
 114502 		Xsqlite3Config.FnRefInitMutex++
 114503 	}
 114504 	Xsqlite3_mutex_leave(tls, pMainMtx)
 114505 
 114506 	if rc != SQLITE_OK {
 114507 		return rc
 114508 	}
 114509 
 114510 	Xsqlite3_mutex_enter(tls, Xsqlite3Config.FpInitMutex)
 114511 	if Xsqlite3Config.FisInit == 0 && Xsqlite3Config.FinProgress == 0 {
 114512 		Xsqlite3Config.FinProgress = 1
 114513 		libc.Xmemset(tls, uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)), 0, uint32(unsafe.Sizeof(Xsqlite3BuiltinFunctions)))
 114514 		Xsqlite3RegisterBuiltinFunctions(tls)
 114515 		if Xsqlite3Config.FisPCacheInit == 0 {
 114516 			rc = Xsqlite3PcacheInitialize(tls)
 114517 		}
 114518 		if rc == SQLITE_OK {
 114519 			Xsqlite3Config.FisPCacheInit = 1
 114520 			rc = Xsqlite3OsInit(tls)
 114521 		}
 114522 		if rc == SQLITE_OK {
 114523 			rc = Xsqlite3MemdbInit(tls)
 114524 		}
 114525 		if rc == SQLITE_OK {
 114526 			Xsqlite3PCacheBufferSetup(tls, Xsqlite3Config.FpPage,
 114527 				Xsqlite3Config.FszPage, Xsqlite3Config.FnPage)
 114528 
 114529 			Xsqlite3Config.FisInit = 1
 114530 		}
 114531 		Xsqlite3Config.FinProgress = 0
 114532 	}
 114533 	Xsqlite3_mutex_leave(tls, Xsqlite3Config.FpInitMutex)
 114534 
 114535 	Xsqlite3_mutex_enter(tls, pMainMtx)
 114536 	Xsqlite3Config.FnRefInitMutex--
 114537 	if Xsqlite3Config.FnRefInitMutex <= 0 {
 114538 		Xsqlite3_mutex_free(tls, Xsqlite3Config.FpInitMutex)
 114539 		Xsqlite3Config.FpInitMutex = uintptr(0)
 114540 	}
 114541 	Xsqlite3_mutex_leave(tls, pMainMtx)
 114542 
 114543 	return rc
 114544 }
 114545 
 114546 // Undo the effects of sqlite3_initialize().  Must not be called while
 114547 // there are outstanding database connections or memory allocations or
 114548 // while any part of SQLite is otherwise in use in any thread.  This
 114549 // routine is not threadsafe.  But it is safe to invoke this routine
 114550 // on when SQLite is already shut down.  If SQLite is already shut down
 114551 // when this routine is invoked, then this routine is a harmless no-op.
 114552 func Xsqlite3_shutdown(tls *libc.TLS) int32 {
 114553 	if Xsqlite3Config.FisInit != 0 {
 114554 		Xsqlite3_os_end(tls)
 114555 		Xsqlite3_reset_auto_extension(tls)
 114556 		Xsqlite3Config.FisInit = 0
 114557 	}
 114558 	if Xsqlite3Config.FisPCacheInit != 0 {
 114559 		Xsqlite3PcacheShutdown(tls)
 114560 		Xsqlite3Config.FisPCacheInit = 0
 114561 	}
 114562 	if Xsqlite3Config.FisMallocInit != 0 {
 114563 		Xsqlite3MallocEnd(tls)
 114564 		Xsqlite3Config.FisMallocInit = 0
 114565 
 114566 		Xsqlite3_data_directory = uintptr(0)
 114567 		Xsqlite3_temp_directory = uintptr(0)
 114568 	}
 114569 	if Xsqlite3Config.FisMutexInit != 0 {
 114570 		Xsqlite3MutexEnd(tls)
 114571 		Xsqlite3Config.FisMutexInit = 0
 114572 	}
 114573 
 114574 	return SQLITE_OK
 114575 }
 114576 
 114577 // This API allows applications to modify the global configuration of
 114578 // the SQLite library at run-time.
 114579 //
 114580 // This routine should only be called when there are no outstanding
 114581 // database connections or memory allocations.  This routine is not
 114582 // threadsafe.  Failure to heed these warnings can lead to unpredictable
 114583 // behavior.
 114584 func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 {
 114585 	var ap Va_list
 114586 	_ = ap
 114587 	var rc int32 = SQLITE_OK
 114588 
 114589 	if Xsqlite3Config.FisInit != 0 {
 114590 		return Xsqlite3MisuseError(tls, 174426)
 114591 	}
 114592 
 114593 	ap = va
 114594 	switch op {
 114595 	case SQLITE_CONFIG_SINGLETHREAD:
 114596 		{
 114597 			Xsqlite3Config.FbCoreMutex = U8(0)
 114598 			Xsqlite3Config.FbFullMutex = U8(0)
 114599 			break
 114600 
 114601 		}
 114602 	case SQLITE_CONFIG_MULTITHREAD:
 114603 		{
 114604 			Xsqlite3Config.FbCoreMutex = U8(1)
 114605 			Xsqlite3Config.FbFullMutex = U8(0)
 114606 			break
 114607 
 114608 		}
 114609 	case SQLITE_CONFIG_SERIALIZED:
 114610 		{
 114611 			Xsqlite3Config.FbCoreMutex = U8(1)
 114612 			Xsqlite3Config.FbFullMutex = U8(1)
 114613 			break
 114614 
 114615 		}
 114616 	case SQLITE_CONFIG_MUTEX:
 114617 		{
 114618 			Xsqlite3Config.Fmutex = *(*Sqlite3_mutex_methods)(unsafe.Pointer(libc.VaUintptr(&ap)))
 114619 			break
 114620 
 114621 		}
 114622 	case SQLITE_CONFIG_GETMUTEX:
 114623 		{
 114624 			*(*Sqlite3_mutex_methods)(unsafe.Pointer(libc.VaUintptr(&ap))) = Xsqlite3Config.Fmutex
 114625 			break
 114626 
 114627 		}
 114628 
 114629 	case SQLITE_CONFIG_MALLOC:
 114630 		{
 114631 			Xsqlite3Config.Fm = *(*Sqlite3_mem_methods)(unsafe.Pointer(libc.VaUintptr(&ap)))
 114632 			break
 114633 
 114634 		}
 114635 	case SQLITE_CONFIG_GETMALLOC:
 114636 		{
 114637 			if Xsqlite3Config.Fm.FxMalloc == uintptr(0) {
 114638 				Xsqlite3MemSetDefault(tls)
 114639 			}
 114640 			*(*Sqlite3_mem_methods)(unsafe.Pointer(libc.VaUintptr(&ap))) = Xsqlite3Config.Fm
 114641 			break
 114642 
 114643 		}
 114644 	case SQLITE_CONFIG_MEMSTATUS:
 114645 		{
 114646 			Xsqlite3Config.FbMemstat = libc.VaInt32(&ap)
 114647 			break
 114648 
 114649 		}
 114650 	case SQLITE_CONFIG_SMALL_MALLOC:
 114651 		{
 114652 			Xsqlite3Config.FbSmallMalloc = U8(libc.VaInt32(&ap))
 114653 			break
 114654 
 114655 		}
 114656 	case SQLITE_CONFIG_PAGECACHE:
 114657 		{
 114658 			Xsqlite3Config.FpPage = libc.VaUintptr(&ap)
 114659 			Xsqlite3Config.FszPage = libc.VaInt32(&ap)
 114660 			Xsqlite3Config.FnPage = libc.VaInt32(&ap)
 114661 			break
 114662 
 114663 		}
 114664 	case SQLITE_CONFIG_PCACHE_HDRSZ:
 114665 		{
 114666 			*(*int32)(unsafe.Pointer(libc.VaUintptr(&ap))) = Xsqlite3HeaderSizeBtree(tls) + Xsqlite3HeaderSizePcache(tls) + Xsqlite3HeaderSizePcache1(tls)
 114667 			break
 114668 
 114669 		}
 114670 
 114671 	case SQLITE_CONFIG_PCACHE:
 114672 		{
 114673 			break
 114674 
 114675 		}
 114676 	case SQLITE_CONFIG_GETPCACHE:
 114677 		{
 114678 			rc = SQLITE_ERROR
 114679 			break
 114680 
 114681 		}
 114682 
 114683 	case SQLITE_CONFIG_PCACHE2:
 114684 		{
 114685 			Xsqlite3Config.Fpcache2 = *(*Sqlite3_pcache_methods2)(unsafe.Pointer(libc.VaUintptr(&ap)))
 114686 			break
 114687 
 114688 		}
 114689 	case SQLITE_CONFIG_GETPCACHE2:
 114690 		{
 114691 			if Xsqlite3Config.Fpcache2.FxInit == uintptr(0) {
 114692 				Xsqlite3PCacheSetDefault(tls)
 114693 			}
 114694 			*(*Sqlite3_pcache_methods2)(unsafe.Pointer(libc.VaUintptr(&ap))) = Xsqlite3Config.Fpcache2
 114695 			break
 114696 
 114697 		}
 114698 
 114699 	case SQLITE_CONFIG_LOOKASIDE:
 114700 		{
 114701 			Xsqlite3Config.FszLookaside = libc.VaInt32(&ap)
 114702 			Xsqlite3Config.FnLookaside = libc.VaInt32(&ap)
 114703 			break
 114704 
 114705 		}
 114706 
 114707 	case SQLITE_CONFIG_LOG:
 114708 		{
 114709 			Xsqlite3Config.FxLog = libc.VaUintptr(&ap)
 114710 			Xsqlite3Config.FpLogArg = libc.VaUintptr(&ap)
 114711 			break
 114712 
 114713 		}
 114714 
 114715 	case SQLITE_CONFIG_URI:
 114716 		{
 114717 			Xsqlite3Config.FbOpenUri = U8(libc.VaInt32(&ap))
 114718 			break
 114719 
 114720 		}
 114721 
 114722 	case SQLITE_CONFIG_COVERING_INDEX_SCAN:
 114723 		{
 114724 			Xsqlite3Config.FbUseCis = U8(libc.VaInt32(&ap))
 114725 			break
 114726 
 114727 		}
 114728 
 114729 	case SQLITE_CONFIG_MMAP_SIZE:
 114730 		{
 114731 			var szMmap Sqlite3_int64 = libc.VaInt64(&ap)
 114732 			var mxMmap Sqlite3_int64 = libc.VaInt64(&ap)
 114733 
 114734 			if mxMmap < int64(0) || mxMmap > int64(SQLITE_MAX_MMAP_SIZE) {
 114735 				mxMmap = int64(SQLITE_MAX_MMAP_SIZE)
 114736 			}
 114737 			if szMmap < int64(0) {
 114738 				szMmap = int64(SQLITE_DEFAULT_MMAP_SIZE)
 114739 			}
 114740 			if szMmap > mxMmap {
 114741 				szMmap = mxMmap
 114742 			}
 114743 			Xsqlite3Config.FmxMmap = mxMmap
 114744 			Xsqlite3Config.FszMmap = szMmap
 114745 			break
 114746 
 114747 		}
 114748 
 114749 	case SQLITE_CONFIG_PMASZ:
 114750 		{
 114751 			Xsqlite3Config.FszPma = libc.VaUint32(&ap)
 114752 			break
 114753 
 114754 		}
 114755 
 114756 	case SQLITE_CONFIG_STMTJRNL_SPILL:
 114757 		{
 114758 			Xsqlite3Config.FnStmtSpill = libc.VaInt32(&ap)
 114759 			break
 114760 
 114761 		}
 114762 
 114763 	case SQLITE_CONFIG_MEMDB_MAXSIZE:
 114764 		{
 114765 			Xsqlite3Config.FmxMemdbSize = libc.VaInt64(&ap)
 114766 			break
 114767 
 114768 		}
 114769 
 114770 	default:
 114771 		{
 114772 			rc = SQLITE_ERROR
 114773 			break
 114774 
 114775 		}
 114776 	}
 114777 	_ = ap
 114778 	return rc
 114779 }
 114780 
 114781 func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32) int32 {
 114782 	var pStart uintptr
 114783 	var szAlloc Sqlite3_int64 = Sqlite3_int64(sz) * Sqlite3_int64(cnt)
 114784 	var nBig int32
 114785 	var nSm int32
 114786 
 114787 	if Xsqlite3LookasideUsed(tls, db, uintptr(0)) > 0 {
 114788 		return SQLITE_BUSY
 114789 	}
 114790 
 114791 	if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced != 0 {
 114792 		Xsqlite3_free(tls, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart)
 114793 	}
 114794 
 114795 	sz = sz & libc.CplInt32(7)
 114796 	if sz <= int32(unsafe.Sizeof(uintptr(0))) {
 114797 		sz = 0
 114798 	}
 114799 	if cnt < 0 {
 114800 		cnt = 0
 114801 	}
 114802 	if sz == 0 || cnt == 0 {
 114803 		sz = 0
 114804 		pStart = uintptr(0)
 114805 	} else if pBuf == uintptr(0) {
 114806 		Xsqlite3BeginBenignMalloc(tls)
 114807 		pStart = Xsqlite3Malloc(tls, uint64(szAlloc))
 114808 		Xsqlite3EndBenignMalloc(tls)
 114809 		if pStart != 0 {
 114810 			szAlloc = Sqlite3_int64(Xsqlite3MallocSize(tls, pStart))
 114811 		}
 114812 	} else {
 114813 		pStart = pBuf
 114814 	}
 114815 	if sz >= LOOKASIDE_SMALL*3 {
 114816 		nBig = int32(szAlloc / Sqlite3_int64(3*LOOKASIDE_SMALL+sz))
 114817 		nSm = int32((szAlloc - Sqlite3_int64(sz*nBig)) / int64(LOOKASIDE_SMALL))
 114818 	} else if sz >= LOOKASIDE_SMALL*2 {
 114819 		nBig = int32(szAlloc / Sqlite3_int64(LOOKASIDE_SMALL+sz))
 114820 		nSm = int32((szAlloc - Sqlite3_int64(sz*nBig)) / int64(LOOKASIDE_SMALL))
 114821 	} else if sz > 0 {
 114822 		nBig = int32(szAlloc / Sqlite3_int64(sz))
 114823 		nSm = 0
 114824 	} else {
 114825 		nBig = libc.AssignInt32(&nSm, 0)
 114826 	}
 114827 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart = pStart
 114828 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = uintptr(0)
 114829 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = uintptr(0)
 114830 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(sz)
 114831 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue = U16(sz)
 114832 	if pStart != 0 {
 114833 		var i int32
 114834 		var p uintptr
 114835 
 114836 		p = pStart
 114837 		for i = 0; i < nBig; i++ {
 114838 			(*LookasideSlot)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit
 114839 			(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = p
 114840 			p = p + uintptr(sz)
 114841 		}
 114842 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = uintptr(0)
 114843 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = uintptr(0)
 114844 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle = p
 114845 		for i = 0; i < nSm; i++ {
 114846 			(*LookasideSlot)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit
 114847 			(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = p
 114848 			p = p + 128
 114849 		}
 114850 
 114851 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = p
 114852 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = U32(0)
 114853 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced = func() uint8 {
 114854 			if pBuf == uintptr(0) {
 114855 				return uint8(1)
 114856 			}
 114857 			return uint8(0)
 114858 		}()
 114859 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot = U32(nBig + nSm)
 114860 	} else {
 114861 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart = uintptr(0)
 114862 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = uintptr(0)
 114863 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = uintptr(0)
 114864 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle = uintptr(0)
 114865 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = uintptr(0)
 114866 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = U32(1)
 114867 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
 114868 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced = U8(0)
 114869 		(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot = U32(0)
 114870 	}
 114871 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpTrueEnd = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd
 114872 
 114873 	return SQLITE_OK
 114874 }
 114875 
 114876 // Return the mutex associated with a database connection.
 114877 func Xsqlite3_db_mutex(tls *libc.TLS, db uintptr) uintptr {
 114878 	return (*Sqlite3)(unsafe.Pointer(db)).Fmutex
 114879 }
 114880 
 114881 // Free up as much memory as we can from the given database
 114882 // connection.
 114883 func Xsqlite3_db_release_memory(tls *libc.TLS, db uintptr) int32 {
 114884 	var i int32
 114885 
 114886 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 114887 	Xsqlite3BtreeEnterAll(tls, db)
 114888 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
 114889 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
 114890 		if pBt != 0 {
 114891 			var pPager uintptr = Xsqlite3BtreePager(tls, pBt)
 114892 			Xsqlite3PagerShrink(tls, pPager)
 114893 		}
 114894 	}
 114895 	Xsqlite3BtreeLeaveAll(tls, db)
 114896 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 114897 	return SQLITE_OK
 114898 }
 114899 
 114900 // Flush any dirty pages in the pager-cache for any attached database
 114901 // to disk.
 114902 func Xsqlite3_db_cacheflush(tls *libc.TLS, db uintptr) int32 {
 114903 	var i int32
 114904 	var rc int32 = SQLITE_OK
 114905 	var bSeenBusy int32 = 0
 114906 
 114907 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 114908 	Xsqlite3BtreeEnterAll(tls, db)
 114909 	for i = 0; rc == SQLITE_OK && i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
 114910 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
 114911 		if pBt != 0 && Xsqlite3BtreeTxnState(tls, pBt) == SQLITE_TXN_WRITE {
 114912 			var pPager uintptr = Xsqlite3BtreePager(tls, pBt)
 114913 			rc = Xsqlite3PagerFlush(tls, pPager)
 114914 			if rc == SQLITE_BUSY {
 114915 				bSeenBusy = 1
 114916 				rc = SQLITE_OK
 114917 			}
 114918 		}
 114919 	}
 114920 	Xsqlite3BtreeLeaveAll(tls, db)
 114921 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 114922 	return func() int32 {
 114923 		if rc == SQLITE_OK && bSeenBusy != 0 {
 114924 			return SQLITE_BUSY
 114925 		}
 114926 		return rc
 114927 	}()
 114928 }
 114929 
 114930 // Configuration settings for an individual database connection
 114931 func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 {
 114932 	var ap Va_list
 114933 	_ = ap
 114934 	var rc int32
 114935 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 114936 	ap = va
 114937 	switch op {
 114938 	case SQLITE_DBCONFIG_MAINDBNAME:
 114939 		{
 114940 			(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName = libc.VaUintptr(&ap)
 114941 			rc = SQLITE_OK
 114942 			break
 114943 
 114944 		}
 114945 	case SQLITE_DBCONFIG_LOOKASIDE:
 114946 		{
 114947 			var pBuf uintptr = libc.VaUintptr(&ap)
 114948 			var sz int32 = libc.VaInt32(&ap)
 114949 			var cnt int32 = libc.VaInt32(&ap)
 114950 			rc = setupLookaside(tls, db, pBuf, sz, cnt)
 114951 			break
 114952 
 114953 		}
 114954 	default:
 114955 		{
 114956 			var i uint32
 114957 			rc = SQLITE_ERROR
 114958 			for i = uint32(0); i < uint32(int32(uint32(unsafe.Sizeof(aFlagOp))/uint32(unsafe.Sizeof(struct {
 114959 				Fop   int32
 114960 				Fmask U32
 114961 			}{})))); i++ {
 114962 				if aFlagOp[i].Fop == op {
 114963 					var onoff int32 = libc.VaInt32(&ap)
 114964 					var pRes uintptr = libc.VaUintptr(&ap)
 114965 					var oldFlags U64 = (*Sqlite3)(unsafe.Pointer(db)).Fflags
 114966 					if onoff > 0 {
 114967 						*(*U64)(unsafe.Pointer(db + 32)) |= U64(aFlagOp[i].Fmask)
 114968 					} else if onoff == 0 {
 114969 						*(*U64)(unsafe.Pointer(db + 32)) &= ^U64(aFlagOp[i].Fmask)
 114970 					}
 114971 					if oldFlags != (*Sqlite3)(unsafe.Pointer(db)).Fflags {
 114972 						Xsqlite3ExpirePreparedStatements(tls, db, 0)
 114973 					}
 114974 					if pRes != 0 {
 114975 						*(*int32)(unsafe.Pointer(pRes)) = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).Fflags&U64(aFlagOp[i].Fmask) != uint64(0))
 114976 					}
 114977 					rc = SQLITE_OK
 114978 					break
 114979 				}
 114980 			}
 114981 			break
 114982 
 114983 		}
 114984 	}
 114985 	_ = ap
 114986 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 114987 	return rc
 114988 }
 114989 
 114990 var aFlagOp = [16]struct {
 114991 	Fop   int32
 114992 	Fmask U32
 114993 }{
 114994 	{Fop: SQLITE_DBCONFIG_ENABLE_FKEY, Fmask: U32(SQLITE_ForeignKeys)},
 114995 	{Fop: SQLITE_DBCONFIG_ENABLE_TRIGGER, Fmask: U32(SQLITE_EnableTrigger)},
 114996 	{Fop: SQLITE_DBCONFIG_ENABLE_VIEW, Fmask: SQLITE_EnableView},
 114997 	{Fop: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, Fmask: U32(SQLITE_Fts3Tokenizer)},
 114998 	{Fop: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, Fmask: U32(SQLITE_LoadExtension)},
 114999 	{Fop: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, Fmask: U32(SQLITE_NoCkptOnClose)},
 115000 	{Fop: SQLITE_DBCONFIG_ENABLE_QPSG, Fmask: U32(SQLITE_EnableQPSG)},
 115001 	{Fop: SQLITE_DBCONFIG_TRIGGER_EQP, Fmask: U32(SQLITE_TriggerEQP)},
 115002 	{Fop: SQLITE_DBCONFIG_RESET_DATABASE, Fmask: U32(SQLITE_ResetDatabase)},
 115003 	{Fop: SQLITE_DBCONFIG_DEFENSIVE, Fmask: U32(SQLITE_Defensive)},
 115004 	{Fop: SQLITE_DBCONFIG_WRITABLE_SCHEMA, Fmask: U32(SQLITE_WriteSchema | SQLITE_NoSchemaError)},
 115005 	{Fop: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, Fmask: U32(SQLITE_LegacyAlter)},
 115006 	{Fop: SQLITE_DBCONFIG_DQS_DDL, Fmask: U32(SQLITE_DqsDDL)},
 115007 	{Fop: SQLITE_DBCONFIG_DQS_DML, Fmask: U32(SQLITE_DqsDML)},
 115008 	{Fop: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, Fmask: U32(SQLITE_LegacyFileFmt)},
 115009 	{Fop: SQLITE_DBCONFIG_TRUSTED_SCHEMA, Fmask: U32(SQLITE_TrustedSchema)},
 115010 }
 115011 
 115012 func binCollFunc(tls *libc.TLS, NotUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) int32 {
 115013 	var rc int32
 115014 	var n int32
 115015 	_ = NotUsed
 115016 	if nKey1 < nKey2 {
 115017 		n = nKey1
 115018 	} else {
 115019 		n = nKey2
 115020 	}
 115021 
 115022 	rc = libc.Xmemcmp(tls, pKey1, pKey2, uint32(n))
 115023 	if rc == 0 {
 115024 		rc = nKey1 - nKey2
 115025 	}
 115026 	return rc
 115027 }
 115028 
 115029 func rtrimCollFunc(tls *libc.TLS, pUser uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) int32 {
 115030 	var pK1 uintptr = pKey1
 115031 	var pK2 uintptr = pKey2
 115032 	for nKey1 != 0 && int32(*(*U8)(unsafe.Pointer(pK1 + uintptr(nKey1-1)))) == ' ' {
 115033 		nKey1--
 115034 	}
 115035 	for nKey2 != 0 && int32(*(*U8)(unsafe.Pointer(pK2 + uintptr(nKey2-1)))) == ' ' {
 115036 		nKey2--
 115037 	}
 115038 	return binCollFunc(tls, pUser, nKey1, pKey1, nKey2, pKey2)
 115039 }
 115040 
 115041 // Return true if CollSeq is the default built-in BINARY.
 115042 func Xsqlite3IsBinary(tls *libc.TLS, p uintptr) int32 {
 115043 	return libc.Bool32(p == uintptr(0) || (*CollSeq)(unsafe.Pointer(p)).FxCmp == *(*uintptr)(unsafe.Pointer(&struct {
 115044 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
 115045 	}{binCollFunc})))
 115046 }
 115047 
 115048 func nocaseCollatingFunc(tls *libc.TLS, NotUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) int32 {
 115049 	var r int32 = Xsqlite3_strnicmp(tls,
 115050 		pKey1, pKey2, func() int32 {
 115051 			if nKey1 < nKey2 {
 115052 				return nKey1
 115053 			}
 115054 			return nKey2
 115055 		}())
 115056 	_ = NotUsed
 115057 	if 0 == r {
 115058 		r = nKey1 - nKey2
 115059 	}
 115060 	return r
 115061 }
 115062 
 115063 // Return the ROWID of the most recent insert
 115064 func Xsqlite3_last_insert_rowid(tls *libc.TLS, db uintptr) Sqlite_int64 {
 115065 	return (*Sqlite3)(unsafe.Pointer(db)).FlastRowid
 115066 }
 115067 
 115068 // Set the value returned by the sqlite3_last_insert_rowid() API function.
 115069 func Xsqlite3_set_last_insert_rowid(tls *libc.TLS, db uintptr, iRowid Sqlite3_int64) {
 115070 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115071 	(*Sqlite3)(unsafe.Pointer(db)).FlastRowid = iRowid
 115072 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115073 }
 115074 
 115075 // Return the number of changes in the most recent call to sqlite3_exec().
 115076 func Xsqlite3_changes64(tls *libc.TLS, db uintptr) Sqlite3_int64 {
 115077 	return (*Sqlite3)(unsafe.Pointer(db)).FnChange
 115078 }
 115079 
 115080 func Xsqlite3_changes(tls *libc.TLS, db uintptr) int32 {
 115081 	return int32(Xsqlite3_changes64(tls, db))
 115082 }
 115083 
 115084 // Return the number of changes since the database handle was opened.
 115085 func Xsqlite3_total_changes64(tls *libc.TLS, db uintptr) Sqlite3_int64 {
 115086 	return (*Sqlite3)(unsafe.Pointer(db)).FnTotalChange
 115087 }
 115088 
 115089 func Xsqlite3_total_changes(tls *libc.TLS, db uintptr) int32 {
 115090 	return int32(Xsqlite3_total_changes64(tls, db))
 115091 }
 115092 
 115093 // Close all open savepoints. This function only manipulates fields of the
 115094 // database handle object, it does not close any savepoints that may be open
 115095 // at the b-tree/pager level.
 115096 func Xsqlite3CloseSavepoints(tls *libc.TLS, db uintptr) {
 115097 	for (*Sqlite3)(unsafe.Pointer(db)).FpSavepoint != 0 {
 115098 		var pTmp uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpSavepoint
 115099 		(*Sqlite3)(unsafe.Pointer(db)).FpSavepoint = (*Savepoint)(unsafe.Pointer(pTmp)).FpNext
 115100 		Xsqlite3DbFree(tls, db, pTmp)
 115101 	}
 115102 	(*Sqlite3)(unsafe.Pointer(db)).FnSavepoint = 0
 115103 	(*Sqlite3)(unsafe.Pointer(db)).FnStatement = 0
 115104 	(*Sqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = U8(0)
 115105 }
 115106 
 115107 func functionDestroy(tls *libc.TLS, db uintptr, p uintptr) {
 115108 	var pDestructor uintptr
 115109 
 115110 	pDestructor = *(*uintptr)(unsafe.Pointer(p + 36))
 115111 	if pDestructor != 0 {
 115112 		(*FuncDestructor)(unsafe.Pointer(pDestructor)).FnRef--
 115113 		if (*FuncDestructor)(unsafe.Pointer(pDestructor)).FnRef == 0 {
 115114 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*FuncDestructor)(unsafe.Pointer(pDestructor)).FxDestroy})).f(tls, (*FuncDestructor)(unsafe.Pointer(pDestructor)).FpUserData)
 115115 			Xsqlite3DbFree(tls, db, pDestructor)
 115116 		}
 115117 	}
 115118 }
 115119 
 115120 func disconnectAllVtab(tls *libc.TLS, db uintptr) {
 115121 	var i int32
 115122 	var p uintptr
 115123 	Xsqlite3BtreeEnterAll(tls, db)
 115124 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
 115125 		var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpSchema
 115126 		if pSchema != 0 {
 115127 			for p = (*Hash)(unsafe.Pointer(pSchema + 8)).Ffirst; p != 0; p = (*HashElem)(unsafe.Pointer(p)).Fnext {
 115128 				var pTab uintptr = (*HashElem)(unsafe.Pointer(p)).Fdata
 115129 				if int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VTAB {
 115130 					Xsqlite3VtabDisconnect(tls, db, pTab)
 115131 				}
 115132 			}
 115133 		}
 115134 	}
 115135 	for p = (*Hash)(unsafe.Pointer(db + 404)).Ffirst; p != 0; p = (*HashElem)(unsafe.Pointer(p)).Fnext {
 115136 		var pMod uintptr = (*HashElem)(unsafe.Pointer(p)).Fdata
 115137 		if (*Module)(unsafe.Pointer(pMod)).FpEpoTab != 0 {
 115138 			Xsqlite3VtabDisconnect(tls, db, (*Module)(unsafe.Pointer(pMod)).FpEpoTab)
 115139 		}
 115140 	}
 115141 	Xsqlite3VtabUnlockList(tls, db)
 115142 	Xsqlite3BtreeLeaveAll(tls, db)
 115143 }
 115144 
 115145 func connectionIsBusy(tls *libc.TLS, db uintptr) int32 {
 115146 	var j int32
 115147 
 115148 	if (*Sqlite3)(unsafe.Pointer(db)).FpVdbe != 0 {
 115149 		return 1
 115150 	}
 115151 	for j = 0; j < (*Sqlite3)(unsafe.Pointer(db)).FnDb; j++ {
 115152 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*16)).FpBt
 115153 		if pBt != 0 && Xsqlite3BtreeIsInBackup(tls, pBt) != 0 {
 115154 			return 1
 115155 		}
 115156 	}
 115157 	return 0
 115158 }
 115159 
 115160 func sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) int32 {
 115161 	if !(db != 0) {
 115162 		return SQLITE_OK
 115163 	}
 115164 	if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) {
 115165 		return Xsqlite3MisuseError(tls, 175200)
 115166 	}
 115167 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115168 	if int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace)&SQLITE_TRACE_CLOSE != 0 {
 115169 		(*struct {
 115170 			f func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32
 115171 		})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(db + 216))})).f(tls, uint32(SQLITE_TRACE_CLOSE), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0))
 115172 	}
 115173 
 115174 	disconnectAllVtab(tls, db)
 115175 
 115176 	Xsqlite3VtabRollback(tls, db)
 115177 
 115178 	if !(forceZombie != 0) && connectionIsBusy(tls, db) != 0 {
 115179 		Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY,
 115180 			ts+23426, 0)
 115181 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115182 		return SQLITE_BUSY
 115183 	}
 115184 
 115185 	(*Sqlite3)(unsafe.Pointer(db)).FeOpenState = U8(SQLITE_STATE_ZOMBIE)
 115186 	Xsqlite3LeaveMutexAndCloseZombie(tls, db)
 115187 	return SQLITE_OK
 115188 }
 115189 
 115190 // Return the transaction state for a single databse, or the maximum
 115191 // transaction state over all attached databases if zSchema is null.
 115192 func Xsqlite3_txn_state(tls *libc.TLS, db uintptr, zSchema uintptr) int32 {
 115193 	var iDb int32
 115194 	var nDb int32
 115195 	var iTxn int32 = -1
 115196 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115197 	if zSchema != 0 {
 115198 		nDb = libc.AssignInt32(&iDb, Xsqlite3FindDbName(tls, db, zSchema))
 115199 		if iDb < 0 {
 115200 			nDb--
 115201 		}
 115202 	} else {
 115203 		iDb = 0
 115204 		nDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb - 1
 115205 	}
 115206 	for ; iDb <= nDb; iDb++ {
 115207 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
 115208 		var x int32
 115209 		if pBt != uintptr(0) {
 115210 			x = Xsqlite3BtreeTxnState(tls, pBt)
 115211 		} else {
 115212 			x = SQLITE_TXN_NONE
 115213 		}
 115214 		if x > iTxn {
 115215 			iTxn = x
 115216 		}
 115217 	}
 115218 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115219 	return iTxn
 115220 }
 115221 
 115222 // Two variations on the public interface for closing a database
 115223 // connection. The sqlite3_close() version returns SQLITE_BUSY and
 115224 // leaves the connection open if there are unfinalized prepared
 115225 // statements or unfinished sqlite3_backups.  The sqlite3_close_v2()
 115226 // version forces the connection to become a zombie if there are
 115227 // unclosed resources, and arranges for deallocation when the last
 115228 // prepare statement or sqlite3_backup closes.
 115229 func Xsqlite3_close(tls *libc.TLS, db uintptr) int32 {
 115230 	return sqlite3Close(tls, db, 0)
 115231 }
 115232 
 115233 func Xsqlite3_close_v2(tls *libc.TLS, db uintptr) int32 {
 115234 	return sqlite3Close(tls, db, 1)
 115235 }
 115236 
 115237 // Close the mutex on database connection db.
 115238 //
 115239 // Furthermore, if database connection db is a zombie (meaning that there
 115240 // has been a prior call to sqlite3_close(db) or sqlite3_close_v2(db)) and
 115241 // every sqlite3_stmt has now been finalized and every sqlite3_backup has
 115242 // finished, then free all resources.
 115243 func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) {
 115244 	var i uintptr
 115245 	var j int32
 115246 
 115247 	if int32((*Sqlite3)(unsafe.Pointer(db)).FeOpenState) != SQLITE_STATE_ZOMBIE || connectionIsBusy(tls, db) != 0 {
 115248 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115249 		return
 115250 	}
 115251 
 115252 	Xsqlite3RollbackAll(tls, db, SQLITE_OK)
 115253 
 115254 	Xsqlite3CloseSavepoints(tls, db)
 115255 
 115256 	for j = 0; j < (*Sqlite3)(unsafe.Pointer(db)).FnDb; j++ {
 115257 		var pDb uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(j)*16
 115258 		if (*Db1)(unsafe.Pointer(pDb)).FpBt != 0 {
 115259 			Xsqlite3BtreeClose(tls, (*Db1)(unsafe.Pointer(pDb)).FpBt)
 115260 			(*Db1)(unsafe.Pointer(pDb)).FpBt = uintptr(0)
 115261 			if j != 1 {
 115262 				(*Db1)(unsafe.Pointer(pDb)).FpSchema = uintptr(0)
 115263 			}
 115264 		}
 115265 	}
 115266 
 115267 	if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema != 0 {
 115268 		Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema)
 115269 	}
 115270 	Xsqlite3VtabUnlockList(tls, db)
 115271 
 115272 	Xsqlite3CollapseDatabaseArray(tls, db)
 115273 
 115274 	Xsqlite3ConnectionClosed(tls, db)
 115275 
 115276 	for i = (*Hash)(unsafe.Pointer(db + 432)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
 115277 		var pNext uintptr
 115278 		var p uintptr
 115279 		p = (*HashElem)(unsafe.Pointer(i)).Fdata
 115280 		for __ccgo := true; __ccgo; __ccgo = p != 0 {
 115281 			functionDestroy(tls, db, p)
 115282 			pNext = (*FuncDef)(unsafe.Pointer(p)).FpNext
 115283 			Xsqlite3DbFree(tls, db, p)
 115284 			p = pNext
 115285 		}
 115286 	}
 115287 	Xsqlite3HashClear(tls, db+432)
 115288 	for i = (*Hash)(unsafe.Pointer(db + 448)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
 115289 		var pColl uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
 115290 
 115291 		for j = 0; j < 3; j++ {
 115292 			if (*CollSeq)(unsafe.Pointer(pColl+uintptr(j)*20)).FxDel != 0 {
 115293 				(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*CollSeq)(unsafe.Pointer(pColl + uintptr(j)*20)).FxDel})).f(tls, (*CollSeq)(unsafe.Pointer(pColl+uintptr(j)*20)).FpUser)
 115294 			}
 115295 		}
 115296 		Xsqlite3DbFree(tls, db, pColl)
 115297 	}
 115298 	Xsqlite3HashClear(tls, db+448)
 115299 	for i = (*Hash)(unsafe.Pointer(db + 404)).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext {
 115300 		var pMod uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata
 115301 		Xsqlite3VtabEponymousTableClear(tls, db, pMod)
 115302 		Xsqlite3VtabModuleUnref(tls, db, pMod)
 115303 	}
 115304 	Xsqlite3HashClear(tls, db+404)
 115305 
 115306 	Xsqlite3Error(tls, db, SQLITE_OK)
 115307 	Xsqlite3ValueFree(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
 115308 	Xsqlite3CloseExtensions(tls, db)
 115309 
 115310 	(*Sqlite3)(unsafe.Pointer(db)).FeOpenState = U8(SQLITE_STATE_ERROR)
 115311 
 115312 	Xsqlite3DbFree(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*16)).FpSchema)
 115313 	if (*Sqlite3)(unsafe.Pointer(db)).FxAutovacDestr != 0 {
 115314 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxAutovacDestr})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg)
 115315 	}
 115316 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115317 	(*Sqlite3)(unsafe.Pointer(db)).FeOpenState = U8(SQLITE_STATE_CLOSED)
 115318 	Xsqlite3_mutex_free(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115319 
 115320 	if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced != 0 {
 115321 		Xsqlite3_free(tls, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart)
 115322 	}
 115323 	Xsqlite3_free(tls, db)
 115324 }
 115325 
 115326 // Rollback all database files.  If tripCode is not SQLITE_OK, then
 115327 // any write cursors are invalidated ("tripped" - as in "tripping a circuit
 115328 // breaker") and made to return tripCode if there are any further
 115329 // attempts to use that cursor.  Read cursors remain open and valid
 115330 // but are "saved" in case the table pages are moved around.
 115331 func Xsqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) {
 115332 	var i int32
 115333 	var inTrans int32 = 0
 115334 	var schemaChange int32
 115335 
 115336 	Xsqlite3BeginBenignMalloc(tls)
 115337 
 115338 	Xsqlite3BtreeEnterAll(tls, db)
 115339 	schemaChange = libc.Bool32((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags&U32(DBFLAG_SchemaChange) != U32(0) && int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0)
 115340 
 115341 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ {
 115342 		var p uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*16)).FpBt
 115343 		if p != 0 {
 115344 			if Xsqlite3BtreeTxnState(tls, p) == SQLITE_TXN_WRITE {
 115345 				inTrans = 1
 115346 			}
 115347 			Xsqlite3BtreeRollback(tls, p, tripCode, libc.BoolInt32(!(schemaChange != 0)))
 115348 		}
 115349 	}
 115350 	Xsqlite3VtabRollback(tls, db)
 115351 	Xsqlite3EndBenignMalloc(tls)
 115352 
 115353 	if schemaChange != 0 {
 115354 		Xsqlite3ExpirePreparedStatements(tls, db, 0)
 115355 		Xsqlite3ResetAllSchemasOfConnection(tls, db)
 115356 	}
 115357 	Xsqlite3BtreeLeaveAll(tls, db)
 115358 
 115359 	(*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = int64(0)
 115360 	(*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0)
 115361 	*(*U64)(unsafe.Pointer(db + 32)) &= libc.CplUint64(uint64(SQLITE_DeferFKs) | uint64(0x00002)<<32)
 115362 
 115363 	if (*Sqlite3)(unsafe.Pointer(db)).FxRollbackCallback != 0 && (inTrans != 0 || !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0)) {
 115364 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxRollbackCallback})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpRollbackArg)
 115365 	}
 115366 }
 115367 
 115368 // Return a static string that describes the kind of error specified in the
 115369 // argument.
 115370 func Xsqlite3ErrStr(tls *libc.TLS, rc int32) uintptr {
 115371 	var zErr uintptr = ts + 23494
 115372 	switch rc {
 115373 	case SQLITE_ABORT | int32(2)<<8:
 115374 		{
 115375 			zErr = ts + 23508
 115376 			break
 115377 
 115378 		}
 115379 	case SQLITE_ROW:
 115380 		{
 115381 			zErr = ts + 23530
 115382 			break
 115383 
 115384 		}
 115385 	case SQLITE_DONE:
 115386 		{
 115387 			zErr = ts + 23552
 115388 			break
 115389 
 115390 		}
 115391 	default:
 115392 		{
 115393 			rc = rc & 0xff
 115394 			if rc >= 0 && rc < int32(uint32(unsafe.Sizeof(aMsg))/uint32(unsafe.Sizeof(uintptr(0)))) && aMsg[rc] != uintptr(0) {
 115395 				zErr = aMsg[rc]
 115396 			}
 115397 			break
 115398 
 115399 		}
 115400 	}
 115401 	return zErr
 115402 }
 115403 
 115404 var aMsg = [29]uintptr{
 115405 	ts + 23575,
 115406 	ts + 23588,
 115407 	uintptr(0),
 115408 	ts + 23604,
 115409 	ts + 23629,
 115410 	ts + 23643,
 115411 	ts + 23662,
 115412 	ts + 1490,
 115413 	ts + 23687,
 115414 	ts + 23724,
 115415 	ts + 23736,
 115416 	ts + 23751,
 115417 	ts + 23784,
 115418 	ts + 23802,
 115419 	ts + 23827,
 115420 	ts + 23856,
 115421 	uintptr(0),
 115422 	ts + 5838,
 115423 	ts + 5334,
 115424 	ts + 23873,
 115425 	ts + 23891,
 115426 	ts + 23909,
 115427 	uintptr(0),
 115428 	ts + 23943,
 115429 	uintptr(0),
 115430 	ts + 23964,
 115431 	ts + 23990,
 115432 	ts + 24013,
 115433 	ts + 24034,
 115434 }
 115435 
 115436 func sqliteDefaultBusyCallback(tls *libc.TLS, ptr uintptr, count int32) int32 {
 115437 	var db uintptr = ptr
 115438 	var tmout int32 = (*Sqlite3)(unsafe.Pointer(db)).FbusyTimeout
 115439 	var delay int32
 115440 	var prior int32
 115441 
 115442 	if count < int32(uint32(unsafe.Sizeof(delays))/uint32(unsafe.Sizeof(U8(0)))) {
 115443 		delay = int32(delays[count])
 115444 		prior = int32(totals[count])
 115445 	} else {
 115446 		delay = int32(delays[int32(uint32(unsafe.Sizeof(delays))/uint32(unsafe.Sizeof(U8(0))))-1])
 115447 		prior = int32(totals[int32(uint32(unsafe.Sizeof(delays))/uint32(unsafe.Sizeof(U8(0))))-1]) + delay*(count-(int32(uint32(unsafe.Sizeof(delays))/uint32(unsafe.Sizeof(U8(0))))-1))
 115448 	}
 115449 	if prior+delay > tmout {
 115450 		delay = tmout - prior
 115451 		if delay <= 0 {
 115452 			return 0
 115453 		}
 115454 	}
 115455 	Xsqlite3OsSleep(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, delay*1000)
 115456 	return 1
 115457 }
 115458 
 115459 var delays = [12]U8{U8(1), U8(2), U8(5), U8(10), U8(15), U8(20), U8(25), U8(25), U8(25), U8(50), U8(50), U8(100)}
 115460 var totals = [12]U8{U8(0), U8(1), U8(3), U8(8), U8(18), U8(33), U8(53), U8(78), U8(103), U8(128), U8(178), U8(228)}
 115461 
 115462 // Invoke the given busy handler.
 115463 //
 115464 // This routine is called when an operation failed to acquire a
 115465 // lock on VFS file pFile.
 115466 //
 115467 // If this routine returns non-zero, the lock is retried.  If it
 115468 // returns 0, the operation aborts with an SQLITE_BUSY error.
 115469 func Xsqlite3InvokeBusyHandler(tls *libc.TLS, p uintptr) int32 {
 115470 	var rc int32
 115471 	if (*BusyHandler)(unsafe.Pointer(p)).FxBusyHandler == uintptr(0) || (*BusyHandler)(unsafe.Pointer(p)).FnBusy < 0 {
 115472 		return 0
 115473 	}
 115474 	rc = (*struct {
 115475 		f func(*libc.TLS, uintptr, int32) int32
 115476 	})(unsafe.Pointer(&struct{ uintptr }{(*BusyHandler)(unsafe.Pointer(p)).FxBusyHandler})).f(tls, (*BusyHandler)(unsafe.Pointer(p)).FpBusyArg, (*BusyHandler)(unsafe.Pointer(p)).FnBusy)
 115477 	if rc == 0 {
 115478 		(*BusyHandler)(unsafe.Pointer(p)).FnBusy = -1
 115479 	} else {
 115480 		(*BusyHandler)(unsafe.Pointer(p)).FnBusy++
 115481 	}
 115482 	return rc
 115483 }
 115484 
 115485 // This routine sets the busy callback for an Sqlite database to the
 115486 // given callback function with the given argument.
 115487 func Xsqlite3_busy_handler(tls *libc.TLS, db uintptr, xBusy uintptr, pArg uintptr) int32 {
 115488 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115489 	(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FxBusyHandler = xBusy
 115490 	(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FpBusyArg = pArg
 115491 	(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
 115492 	(*Sqlite3)(unsafe.Pointer(db)).FbusyTimeout = 0
 115493 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115494 	return SQLITE_OK
 115495 }
 115496 
 115497 // This routine sets the progress callback for an Sqlite database to the
 115498 // given callback function with the given argument. The progress callback will
 115499 // be invoked every nOps opcodes.
 115500 func Xsqlite3_progress_handler(tls *libc.TLS, db uintptr, nOps int32, xProgress uintptr, pArg uintptr) {
 115501 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115502 	if nOps > 0 {
 115503 		(*Sqlite3)(unsafe.Pointer(db)).FxProgress = xProgress
 115504 		(*Sqlite3)(unsafe.Pointer(db)).FnProgressOps = uint32(nOps)
 115505 		(*Sqlite3)(unsafe.Pointer(db)).FpProgressArg = pArg
 115506 	} else {
 115507 		(*Sqlite3)(unsafe.Pointer(db)).FxProgress = uintptr(0)
 115508 		(*Sqlite3)(unsafe.Pointer(db)).FnProgressOps = uint32(0)
 115509 		(*Sqlite3)(unsafe.Pointer(db)).FpProgressArg = uintptr(0)
 115510 	}
 115511 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115512 }
 115513 
 115514 // This routine installs a default busy handler that waits for the
 115515 // specified number of milliseconds before returning 0.
 115516 func Xsqlite3_busy_timeout(tls *libc.TLS, db uintptr, ms int32) int32 {
 115517 	if ms > 0 {
 115518 		Xsqlite3_busy_handler(tls, db, *(*uintptr)(unsafe.Pointer(&struct {
 115519 			f func(*libc.TLS, uintptr, int32) int32
 115520 		}{sqliteDefaultBusyCallback})),
 115521 			db)
 115522 		(*Sqlite3)(unsafe.Pointer(db)).FbusyTimeout = ms
 115523 	} else {
 115524 		Xsqlite3_busy_handler(tls, db, uintptr(0), uintptr(0))
 115525 	}
 115526 	return SQLITE_OK
 115527 }
 115528 
 115529 // Cause any pending operation to stop at its earliest opportunity.
 115530 func Xsqlite3_interrupt(tls *libc.TLS, db uintptr) {
 115531 	libc.AtomicStoreNInt32(db+312, int32(1), 0)
 115532 }
 115533 
 115534 // Return true or false depending on whether or not an interrupt is
 115535 // pending on connection db.
 115536 func Xsqlite3_is_interrupted(tls *libc.TLS, db uintptr) int32 {
 115537 	return libc.Bool32(libc.AtomicLoadNInt32(db+312, 0) != 0)
 115538 }
 115539 
 115540 // This function is exactly the same as sqlite3_create_function(), except
 115541 // that it is designed to be called by internal code. The difference is
 115542 // that if a malloc() fails in sqlite3_create_function(), an error code
 115543 // is returned and the mallocFailed flag cleared.
 115544 func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg int32, enc int32, pUserData uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr, xValue uintptr, xInverse uintptr, pDestructor uintptr) int32 {
 115545 	var p uintptr
 115546 	var extraFlags int32
 115547 
 115548 	if zFunctionName == uintptr(0) ||
 115549 		xSFunc != uintptr(0) && xFinal != uintptr(0) ||
 115550 		libc.Bool32(xFinal == uintptr(0)) != libc.Bool32(xStep == uintptr(0)) ||
 115551 		libc.Bool32(xValue == uintptr(0)) != libc.Bool32(xInverse == uintptr(0)) ||
 115552 		(nArg < -1 || nArg > SQLITE_MAX_FUNCTION_ARG) ||
 115553 		255 < Xsqlite3Strlen30(tls, zFunctionName) {
 115554 		return Xsqlite3MisuseError(tls, 175847)
 115555 	}
 115556 
 115557 	extraFlags = enc & (SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY | SQLITE_SUBTYPE | SQLITE_INNOCUOUS)
 115558 	enc = enc & (SQLITE_FUNC_ENCMASK | SQLITE_ANY)
 115559 
 115560 	extraFlags = extraFlags ^ SQLITE_FUNC_UNSAFE
 115561 
 115562 	switch enc {
 115563 	case SQLITE_UTF16:
 115564 		enc = SQLITE_UTF16LE
 115565 		break
 115566 	case SQLITE_ANY:
 115567 		{
 115568 			var rc int32
 115569 			rc = Xsqlite3CreateFunc(tls, db, zFunctionName, nArg,
 115570 				SQLITE_UTF8|extraFlags^SQLITE_FUNC_UNSAFE,
 115571 				pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor)
 115572 			if rc == SQLITE_OK {
 115573 				rc = Xsqlite3CreateFunc(tls, db, zFunctionName, nArg,
 115574 					SQLITE_UTF16LE|extraFlags^SQLITE_FUNC_UNSAFE,
 115575 					pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor)
 115576 			}
 115577 			if rc != SQLITE_OK {
 115578 				return rc
 115579 			}
 115580 			enc = SQLITE_UTF16BE
 115581 			break
 115582 
 115583 		}
 115584 	case SQLITE_UTF8:
 115585 		fallthrough
 115586 	case SQLITE_UTF16LE:
 115587 		fallthrough
 115588 	case SQLITE_UTF16BE:
 115589 		break
 115590 	default:
 115591 		enc = SQLITE_UTF8
 115592 		break
 115593 	}
 115594 
 115595 	p = Xsqlite3FindFunction(tls, db, zFunctionName, nArg, U8(enc), uint8(0))
 115596 	if p != 0 && (*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(SQLITE_FUNC_ENCMASK) == U32(enc) && int32((*FuncDef)(unsafe.Pointer(p)).FnArg) == nArg {
 115597 		if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 {
 115598 			Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY,
 115599 				ts+24050, 0)
 115600 
 115601 			return SQLITE_BUSY
 115602 		} else {
 115603 			Xsqlite3ExpirePreparedStatements(tls, db, 0)
 115604 		}
 115605 	} else if xSFunc == uintptr(0) && xFinal == uintptr(0) {
 115606 		return SQLITE_OK
 115607 	}
 115608 
 115609 	p = Xsqlite3FindFunction(tls, db, zFunctionName, nArg, U8(enc), uint8(1))
 115610 
 115611 	if !(p != 0) {
 115612 		return SQLITE_NOMEM
 115613 	}
 115614 
 115615 	functionDestroy(tls, db, p)
 115616 
 115617 	if pDestructor != 0 {
 115618 		(*FuncDestructor)(unsafe.Pointer(pDestructor)).FnRef++
 115619 	}
 115620 	*(*uintptr)(unsafe.Pointer(p + 36)) = pDestructor
 115621 	(*FuncDef)(unsafe.Pointer(p)).FfuncFlags = (*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(SQLITE_FUNC_ENCMASK) | U32(extraFlags)
 115622 
 115623 	(*FuncDef)(unsafe.Pointer(p)).FxSFunc = func() uintptr {
 115624 		if xSFunc != 0 {
 115625 			return xSFunc
 115626 		}
 115627 		return xStep
 115628 	}()
 115629 	(*FuncDef)(unsafe.Pointer(p)).FxFinalize = xFinal
 115630 	(*FuncDef)(unsafe.Pointer(p)).FxValue = xValue
 115631 	(*FuncDef)(unsafe.Pointer(p)).FxInverse = xInverse
 115632 	(*FuncDef)(unsafe.Pointer(p)).FpUserData = pUserData
 115633 	(*FuncDef)(unsafe.Pointer(p)).FnArg = I8(U16(nArg))
 115634 	return SQLITE_OK
 115635 }
 115636 
 115637 func createFunctionApi(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr, xValue uintptr, xInverse uintptr, xDestroy uintptr) int32 {
 115638 	var rc int32
 115639 	var pArg uintptr
 115640 	rc = SQLITE_ERROR
 115641 	pArg = uintptr(0)
 115642 
 115643 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115644 	if !(xDestroy != 0) {
 115645 		goto __1
 115646 	}
 115647 	pArg = Xsqlite3Malloc(tls, uint64(unsafe.Sizeof(FuncDestructor{})))
 115648 	if !!(pArg != 0) {
 115649 		goto __2
 115650 	}
 115651 	Xsqlite3OomFault(tls, db)
 115652 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDestroy})).f(tls, p)
 115653 	goto out
 115654 __2:
 115655 	;
 115656 	(*FuncDestructor)(unsafe.Pointer(pArg)).FnRef = 0
 115657 	(*FuncDestructor)(unsafe.Pointer(pArg)).FxDestroy = xDestroy
 115658 	(*FuncDestructor)(unsafe.Pointer(pArg)).FpUserData = p
 115659 __1:
 115660 	;
 115661 	rc = Xsqlite3CreateFunc(tls, db, zFunc, nArg, enc, p,
 115662 		xSFunc, xStep, xFinal, xValue, xInverse, pArg)
 115663 	if !(pArg != 0 && (*FuncDestructor)(unsafe.Pointer(pArg)).FnRef == 0) {
 115664 		goto __3
 115665 	}
 115666 
 115667 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDestroy})).f(tls, p)
 115668 	Xsqlite3_free(tls, pArg)
 115669 __3:
 115670 	;
 115671 out:
 115672 	rc = Xsqlite3ApiExit(tls, db, rc)
 115673 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115674 	return rc
 115675 }
 115676 
 115677 // Create new user functions.
 115678 func Xsqlite3_create_function(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr) int32 {
 115679 	return createFunctionApi(tls, db, zFunc, nArg, enc, p, xSFunc, xStep,
 115680 		xFinal, uintptr(0), uintptr(0), uintptr(0))
 115681 }
 115682 
 115683 func Xsqlite3_create_function_v2(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr, xDestroy uintptr) int32 {
 115684 	return createFunctionApi(tls, db, zFunc, nArg, enc, p, xSFunc, xStep,
 115685 		xFinal, uintptr(0), uintptr(0), xDestroy)
 115686 }
 115687 
 115688 func Xsqlite3_create_window_function(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, xStep uintptr, xFinal uintptr, xValue uintptr, xInverse uintptr, xDestroy uintptr) int32 {
 115689 	return createFunctionApi(tls, db, zFunc, nArg, enc, p, uintptr(0), xStep,
 115690 		xFinal, xValue, xInverse, xDestroy)
 115691 }
 115692 
 115693 func Xsqlite3_create_function16(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg int32, eTextRep int32, p uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr) int32 {
 115694 	var rc int32
 115695 	var zFunc8 uintptr
 115696 
 115697 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115698 
 115699 	zFunc8 = Xsqlite3Utf16to8(tls, db, zFunctionName, -1, uint8(SQLITE_UTF16LE))
 115700 	rc = Xsqlite3CreateFunc(tls, db, zFunc8, nArg, eTextRep, p, xSFunc, xStep, xFinal, uintptr(0), uintptr(0), uintptr(0))
 115701 	Xsqlite3DbFree(tls, db, zFunc8)
 115702 	rc = Xsqlite3ApiExit(tls, db, rc)
 115703 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115704 	return rc
 115705 }
 115706 
 115707 func sqlite3InvalidFunction(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
 115708 	bp := tls.Alloc(8)
 115709 	defer tls.Free(8)
 115710 
 115711 	var zName uintptr = Xsqlite3_user_data(tls, context)
 115712 	var zErr uintptr
 115713 	_ = NotUsed
 115714 	_ = NotUsed2
 115715 	zErr = Xsqlite3_mprintf(tls,
 115716 		ts+24113, libc.VaList(bp, zName))
 115717 	Xsqlite3_result_error(tls, context, zErr, -1)
 115718 	Xsqlite3_free(tls, zErr)
 115719 }
 115720 
 115721 // Declare that a function has been overloaded by a virtual table.
 115722 //
 115723 // If the function already exists as a regular global function, then
 115724 // this routine is a no-op.  If the function does not exist, then create
 115725 // a new one that always throws a run-time error.
 115726 //
 115727 // When virtual tables intend to provide an overloaded function, they
 115728 // should call this routine to make sure the global function exists.
 115729 // A global function must exist in order for name resolution to work
 115730 // properly.
 115731 func Xsqlite3_overload_function(tls *libc.TLS, db uintptr, zName uintptr, nArg int32) int32 {
 115732 	bp := tls.Alloc(8)
 115733 	defer tls.Free(8)
 115734 
 115735 	var rc int32
 115736 	var zCopy uintptr
 115737 
 115738 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115739 	rc = libc.Bool32(Xsqlite3FindFunction(tls, db, zName, nArg, uint8(SQLITE_UTF8), uint8(0)) != uintptr(0))
 115740 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115741 	if rc != 0 {
 115742 		return SQLITE_OK
 115743 	}
 115744 	zCopy = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, zName))
 115745 	if zCopy == uintptr(0) {
 115746 		return SQLITE_NOMEM
 115747 	}
 115748 	return Xsqlite3_create_function_v2(tls, db, zName, nArg, SQLITE_UTF8,
 115749 		zCopy, *(*uintptr)(unsafe.Pointer(&struct {
 115750 			f func(*libc.TLS, uintptr, int32, uintptr)
 115751 		}{sqlite3InvalidFunction})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 115752 }
 115753 
 115754 // Register a trace function.  The pArg from the previously registered trace
 115755 // is returned.
 115756 //
 115757 // A NULL trace function means that no tracing is executes.  A non-NULL
 115758 // trace is a pointer to a function that is invoked at the start of each
 115759 // SQL statement.
 115760 func Xsqlite3_trace(tls *libc.TLS, db uintptr, xTrace uintptr, pArg uintptr) uintptr {
 115761 	var pOld uintptr
 115762 
 115763 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115764 	pOld = (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg
 115765 	(*Sqlite3)(unsafe.Pointer(db)).FmTrace = func() uint8 {
 115766 		if xTrace != 0 {
 115767 			return uint8(SQLITE_TRACE_LEGACY)
 115768 		}
 115769 		return uint8(0)
 115770 	}()
 115771 	*(*uintptr)(unsafe.Pointer(db + 216)) = xTrace
 115772 	(*Sqlite3)(unsafe.Pointer(db)).FpTraceArg = pArg
 115773 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115774 	return pOld
 115775 }
 115776 
 115777 // Register a trace callback using the version-2 interface.
 115778 func Xsqlite3_trace_v2(tls *libc.TLS, db uintptr, mTrace uint32, xTrace uintptr, pArg uintptr) int32 {
 115779 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115780 	if mTrace == uint32(0) {
 115781 		xTrace = uintptr(0)
 115782 	}
 115783 	if xTrace == uintptr(0) {
 115784 		mTrace = uint32(0)
 115785 	}
 115786 	(*Sqlite3)(unsafe.Pointer(db)).FmTrace = U8(mTrace)
 115787 	*(*uintptr)(unsafe.Pointer(db + 216)) = xTrace
 115788 	(*Sqlite3)(unsafe.Pointer(db)).FpTraceArg = pArg
 115789 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115790 	return SQLITE_OK
 115791 }
 115792 
 115793 // Register a profile function.  The pArg from the previously registered
 115794 // profile function is returned.
 115795 //
 115796 // A NULL profile function means that no profiling is executes.  A non-NULL
 115797 // profile is a pointer to a function that is invoked at the conclusion of
 115798 // each SQL statement that is run.
 115799 func Xsqlite3_profile(tls *libc.TLS, db uintptr, xProfile uintptr, pArg uintptr) uintptr {
 115800 	var pOld uintptr
 115801 
 115802 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115803 	pOld = (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg
 115804 	(*Sqlite3)(unsafe.Pointer(db)).FxProfile = xProfile
 115805 	(*Sqlite3)(unsafe.Pointer(db)).FpProfileArg = pArg
 115806 	*(*U8)(unsafe.Pointer(db + 94)) &= U8(SQLITE_TRACE_NONLEGACY_MASK)
 115807 	if (*Sqlite3)(unsafe.Pointer(db)).FxProfile != 0 {
 115808 		*(*U8)(unsafe.Pointer(db + 94)) |= U8(SQLITE_TRACE_XPROFILE)
 115809 	}
 115810 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115811 	return pOld
 115812 }
 115813 
 115814 // Register a function to be invoked when a transaction commits.
 115815 // If the invoked function returns non-zero, then the commit becomes a
 115816 // rollback.
 115817 func Xsqlite3_commit_hook(tls *libc.TLS, db uintptr, xCallback uintptr, pArg uintptr) uintptr {
 115818 	var pOld uintptr
 115819 
 115820 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115821 	pOld = (*Sqlite3)(unsafe.Pointer(db)).FpCommitArg
 115822 	(*Sqlite3)(unsafe.Pointer(db)).FxCommitCallback = xCallback
 115823 	(*Sqlite3)(unsafe.Pointer(db)).FpCommitArg = pArg
 115824 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115825 	return pOld
 115826 }
 115827 
 115828 // Register a callback to be invoked each time a row is updated,
 115829 // inserted or deleted using this database connection.
 115830 func Xsqlite3_update_hook(tls *libc.TLS, db uintptr, xCallback uintptr, pArg uintptr) uintptr {
 115831 	var pRet uintptr
 115832 
 115833 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115834 	pRet = (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg
 115835 	(*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback = xCallback
 115836 	(*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg = pArg
 115837 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115838 	return pRet
 115839 }
 115840 
 115841 // Register a callback to be invoked each time a transaction is rolled
 115842 // back by this database connection.
 115843 func Xsqlite3_rollback_hook(tls *libc.TLS, db uintptr, xCallback uintptr, pArg uintptr) uintptr {
 115844 	var pRet uintptr
 115845 
 115846 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115847 	pRet = (*Sqlite3)(unsafe.Pointer(db)).FpRollbackArg
 115848 	(*Sqlite3)(unsafe.Pointer(db)).FxRollbackCallback = xCallback
 115849 	(*Sqlite3)(unsafe.Pointer(db)).FpRollbackArg = pArg
 115850 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115851 	return pRet
 115852 }
 115853 
 115854 // Register a callback to be invoked each time a row is updated,
 115855 // inserted or deleted using this database connection.
 115856 func Xsqlite3_preupdate_hook(tls *libc.TLS, db uintptr, xCallback uintptr, pArg uintptr) uintptr {
 115857 	var pRet uintptr
 115858 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115859 	pRet = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdateArg
 115860 	(*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback = xCallback
 115861 	(*Sqlite3)(unsafe.Pointer(db)).FpPreUpdateArg = pArg
 115862 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115863 	return pRet
 115864 }
 115865 
 115866 // Register a function to be invoked prior to each autovacuum that
 115867 // determines the number of pages to vacuum.
 115868 func Xsqlite3_autovacuum_pages(tls *libc.TLS, db uintptr, xCallback uintptr, pArg uintptr, xDestructor uintptr) int32 {
 115869 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115870 	if (*Sqlite3)(unsafe.Pointer(db)).FxAutovacDestr != 0 {
 115871 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3)(unsafe.Pointer(db)).FxAutovacDestr})).f(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg)
 115872 	}
 115873 	(*Sqlite3)(unsafe.Pointer(db)).FxAutovacPages = xCallback
 115874 	(*Sqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg = pArg
 115875 	(*Sqlite3)(unsafe.Pointer(db)).FxAutovacDestr = xDestructor
 115876 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115877 	return SQLITE_OK
 115878 }
 115879 
 115880 // The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
 115881 // Invoke sqlite3_wal_checkpoint if the number of frames in the log file
 115882 // is greater than sqlite3.pWalArg cast to an integer (the value configured by
 115883 // wal_autocheckpoint()).
 115884 func Xsqlite3WalDefaultHook(tls *libc.TLS, pClientData uintptr, db uintptr, zDb uintptr, nFrame int32) int32 {
 115885 	if nFrame >= int32(pClientData) {
 115886 		Xsqlite3BeginBenignMalloc(tls)
 115887 		Xsqlite3_wal_checkpoint(tls, db, zDb)
 115888 		Xsqlite3EndBenignMalloc(tls)
 115889 	}
 115890 	return SQLITE_OK
 115891 }
 115892 
 115893 // Configure an sqlite3_wal_hook() callback to automatically checkpoint
 115894 // a database after committing a transaction if there are nFrame or
 115895 // more frames in the log file. Passing zero or a negative value as the
 115896 // nFrame parameter disables automatic checkpoints entirely.
 115897 //
 115898 // The callback registered by this function replaces any existing callback
 115899 // registered using sqlite3_wal_hook(). Likewise, registering a callback
 115900 // using sqlite3_wal_hook() disables the automatic checkpoint mechanism
 115901 // configured by this function.
 115902 func Xsqlite3_wal_autocheckpoint(tls *libc.TLS, db uintptr, nFrame int32) int32 {
 115903 	if nFrame > 0 {
 115904 		Xsqlite3_wal_hook(tls, db, *(*uintptr)(unsafe.Pointer(&struct {
 115905 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32
 115906 		}{Xsqlite3WalDefaultHook})), uintptr(nFrame))
 115907 	} else {
 115908 		Xsqlite3_wal_hook(tls, db, uintptr(0), uintptr(0))
 115909 	}
 115910 	return SQLITE_OK
 115911 }
 115912 
 115913 // Register a callback to be invoked each time a transaction is written
 115914 // into the write-ahead-log by this database connection.
 115915 func Xsqlite3_wal_hook(tls *libc.TLS, db uintptr, xCallback uintptr, pArg uintptr) uintptr {
 115916 	var pRet uintptr
 115917 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115918 	pRet = (*Sqlite3)(unsafe.Pointer(db)).FpWalArg
 115919 	(*Sqlite3)(unsafe.Pointer(db)).FxWalCallback = xCallback
 115920 	(*Sqlite3)(unsafe.Pointer(db)).FpWalArg = pArg
 115921 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115922 	return pRet
 115923 }
 115924 
 115925 // Checkpoint database zDb.
 115926 func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 {
 115927 	bp := tls.Alloc(8)
 115928 	defer tls.Free(8)
 115929 
 115930 	var rc int32
 115931 	var iDb int32
 115932 
 115933 	if pnLog != 0 {
 115934 		*(*int32)(unsafe.Pointer(pnLog)) = -1
 115935 	}
 115936 	if pnCkpt != 0 {
 115937 		*(*int32)(unsafe.Pointer(pnCkpt)) = -1
 115938 	}
 115939 
 115940 	if eMode < SQLITE_CHECKPOINT_PASSIVE || eMode > SQLITE_CHECKPOINT_TRUNCATE {
 115941 		return SQLITE_MISUSE
 115942 	}
 115943 
 115944 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115945 	if zDb != 0 && *(*uint8)(unsafe.Pointer(zDb)) != 0 {
 115946 		iDb = Xsqlite3FindDbName(tls, db, zDb)
 115947 	} else {
 115948 		iDb = SQLITE_MAX_ATTACHED + 2
 115949 	}
 115950 	if iDb < 0 {
 115951 		rc = SQLITE_ERROR
 115952 		Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, ts+24164, libc.VaList(bp, zDb))
 115953 	} else {
 115954 		(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
 115955 		rc = Xsqlite3Checkpoint(tls, db, iDb, eMode, pnLog, pnCkpt)
 115956 		Xsqlite3Error(tls, db, rc)
 115957 	}
 115958 	rc = Xsqlite3ApiExit(tls, db, rc)
 115959 
 115960 	if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 {
 115961 		libc.AtomicStoreNInt32(db+312, int32(0), 0)
 115962 	}
 115963 
 115964 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 115965 	return rc
 115966 }
 115967 
 115968 // Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
 115969 // to contains a zero-length string, all attached databases are
 115970 // checkpointed.
 115971 func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) int32 {
 115972 	return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0))
 115973 }
 115974 
 115975 // Run a checkpoint on database iDb. This is a no-op if database iDb is
 115976 // not currently open in WAL mode.
 115977 //
 115978 // If a transaction is open on the database being checkpointed, this
 115979 // function returns SQLITE_LOCKED and a checkpoint is not attempted. If
 115980 // an error occurs while running the checkpoint, an SQLite error code is
 115981 // returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.
 115982 //
 115983 // The mutex on database handle db should be held by the caller. The mutex
 115984 // associated with the specific b-tree being checkpointed is taken by
 115985 // this function while the checkpoint is running.
 115986 //
 115987 // If iDb is passed SQLITE_MAX_DB then all attached databases are
 115988 // checkpointed. If an error is encountered it is returned immediately -
 115989 // no attempt is made to checkpoint any remaining databases.
 115990 //
 115991 // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART
 115992 // or TRUNCATE.
 115993 func Xsqlite3Checkpoint(tls *libc.TLS, db uintptr, iDb int32, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 {
 115994 	var rc int32 = SQLITE_OK
 115995 	var i int32
 115996 	var bBusy int32 = 0
 115997 
 115998 	for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb && rc == SQLITE_OK; i++ {
 115999 		if i == iDb || iDb == SQLITE_MAX_ATTACHED+2 {
 116000 			rc = Xsqlite3BtreeCheckpoint(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*16)).FpBt, eMode, pnLog, pnCkpt)
 116001 			pnLog = uintptr(0)
 116002 			pnCkpt = uintptr(0)
 116003 			if rc == SQLITE_BUSY {
 116004 				bBusy = 1
 116005 				rc = SQLITE_OK
 116006 			}
 116007 		}
 116008 	}
 116009 
 116010 	if rc == SQLITE_OK && bBusy != 0 {
 116011 		return SQLITE_BUSY
 116012 	}
 116013 	return rc
 116014 }
 116015 
 116016 // This function returns true if main-memory should be used instead of
 116017 // a temporary file for transient pager files and statement journals.
 116018 // The value returned depends on the value of db->temp_store (runtime
 116019 // parameter) and the compile time value of SQLITE_TEMP_STORE. The
 116020 // following table describes the relationship between these two values
 116021 // and this functions return value.
 116022 //
 116023 //	SQLITE_TEMP_STORE     db->temp_store     Location of temporary database
 116024 //	-----------------     --------------     ------------------------------
 116025 //	0                     any                file      (return 0)
 116026 //	1                     1                  file      (return 0)
 116027 //	1                     2                  memory    (return 1)
 116028 //	1                     0                  file      (return 0)
 116029 //	2                     1                  file      (return 0)
 116030 //	2                     2                  memory    (return 1)
 116031 //	2                     0                  memory    (return 1)
 116032 //	3                     any                memory    (return 1)
 116033 func Xsqlite3TempInMemory(tls *libc.TLS, db uintptr) int32 {
 116034 	return libc.Bool32(int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == 2)
 116035 }
 116036 
 116037 // Return UTF-8 encoded English language explanation of the most recent
 116038 // error.
 116039 func Xsqlite3_errmsg(tls *libc.TLS, db uintptr) uintptr {
 116040 	var z uintptr
 116041 	if !(db != 0) {
 116042 		return Xsqlite3ErrStr(tls, SQLITE_NOMEM)
 116043 	}
 116044 	if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) {
 116045 		return Xsqlite3ErrStr(tls, Xsqlite3MisuseError(tls, 176592))
 116046 	}
 116047 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116048 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 116049 		z = Xsqlite3ErrStr(tls, SQLITE_NOMEM)
 116050 	} else {
 116051 		if (*Sqlite3)(unsafe.Pointer(db)).FerrCode != 0 {
 116052 			z = Xsqlite3_value_text(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
 116053 		} else {
 116054 			z = uintptr(0)
 116055 		}
 116056 
 116057 		if z == uintptr(0) {
 116058 			z = Xsqlite3ErrStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FerrCode)
 116059 		}
 116060 	}
 116061 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116062 	return z
 116063 }
 116064 
 116065 // Return the byte offset of the most recent error
 116066 func Xsqlite3_error_offset(tls *libc.TLS, db uintptr) int32 {
 116067 	var iOffset int32 = -1
 116068 	if db != 0 && Xsqlite3SafetyCheckSickOrOk(tls, db) != 0 && (*Sqlite3)(unsafe.Pointer(db)).FerrCode != 0 {
 116069 		Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116070 		iOffset = (*Sqlite3)(unsafe.Pointer(db)).FerrByteOffset
 116071 		Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116072 	}
 116073 	return iOffset
 116074 }
 116075 
 116076 // Return UTF-16 encoded English language explanation of the most recent
 116077 // error.
 116078 func Xsqlite3_errmsg16(tls *libc.TLS, db uintptr) uintptr {
 116079 	var z uintptr
 116080 	if !(db != 0) {
 116081 		return uintptr(unsafe.Pointer(&outOfMem))
 116082 	}
 116083 	if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) {
 116084 		return uintptr(unsafe.Pointer(&misuse))
 116085 	}
 116086 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116087 	if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 116088 		z = uintptr(unsafe.Pointer(&outOfMem))
 116089 	} else {
 116090 		z = Xsqlite3_value_text16(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
 116091 		if z == uintptr(0) {
 116092 			Xsqlite3ErrorWithMsg(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FerrCode, Xsqlite3ErrStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FerrCode), 0)
 116093 			z = Xsqlite3_value_text16(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr)
 116094 		}
 116095 
 116096 		Xsqlite3OomClear(tls, db)
 116097 	}
 116098 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116099 	return z
 116100 }
 116101 
 116102 var outOfMem = [14]U16{
 116103 	U16('o'), U16('u'), U16('t'), U16(' '), U16('o'), U16('f'), U16(' '), U16('m'), U16('e'), U16('m'), U16('o'), U16('r'), U16('y'), U16(0),
 116104 }
 116105 var misuse = [34]U16{
 116106 	U16('b'), U16('a'), U16('d'), U16(' '), U16('p'), U16('a'), U16('r'), U16('a'), U16('m'), U16('e'), U16('t'), U16('e'), U16('r'), U16(' '),
 116107 	U16('o'), U16('r'), U16(' '), U16('o'), U16('t'), U16('h'), U16('e'), U16('r'), U16(' '), U16('A'), U16('P'), U16('I'), U16(' '),
 116108 	U16('m'), U16('i'), U16('s'), U16('u'), U16('s'), U16('e'), U16(0),
 116109 }
 116110 
 116111 // Return the most recent error code generated by an SQLite routine. If NULL is
 116112 // passed to this function, we assume a malloc() failed during sqlite3_open().
 116113 func Xsqlite3_errcode(tls *libc.TLS, db uintptr) int32 {
 116114 	if db != 0 && !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) {
 116115 		return Xsqlite3MisuseError(tls, 176671)
 116116 	}
 116117 	if !(db != 0) || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 116118 		return SQLITE_NOMEM
 116119 	}
 116120 	return (*Sqlite3)(unsafe.Pointer(db)).FerrCode & (*Sqlite3)(unsafe.Pointer(db)).FerrMask
 116121 }
 116122 
 116123 func Xsqlite3_extended_errcode(tls *libc.TLS, db uintptr) int32 {
 116124 	if db != 0 && !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) {
 116125 		return Xsqlite3MisuseError(tls, 176680)
 116126 	}
 116127 	if !(db != 0) || (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
 116128 		return SQLITE_NOMEM
 116129 	}
 116130 	return (*Sqlite3)(unsafe.Pointer(db)).FerrCode
 116131 }
 116132 
 116133 func Xsqlite3_system_errno(tls *libc.TLS, db uintptr) int32 {
 116134 	if db != 0 {
 116135 		return (*Sqlite3)(unsafe.Pointer(db)).FiSysErrno
 116136 	}
 116137 	return 0
 116138 }
 116139 
 116140 // Return a string that describes the kind of error specified in the
 116141 // argument.  For now, this simply calls the internal sqlite3ErrStr()
 116142 // function.
 116143 func Xsqlite3_errstr(tls *libc.TLS, rc int32) uintptr {
 116144 	return Xsqlite3ErrStr(tls, rc)
 116145 }
 116146 
 116147 func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uintptr, xCompare uintptr, xDel uintptr) int32 {
 116148 	var pColl uintptr
 116149 	var enc2 int32
 116150 
 116151 	enc2 = int32(enc)
 116152 
 116153 	if enc2 == SQLITE_UTF16 || enc2 == SQLITE_UTF16_ALIGNED {
 116154 		enc2 = SQLITE_UTF16LE
 116155 	}
 116156 	if enc2 < SQLITE_UTF8 || enc2 > SQLITE_UTF16BE {
 116157 		return Xsqlite3MisuseError(tls, 176728)
 116158 	}
 116159 
 116160 	pColl = Xsqlite3FindCollSeq(tls, db, U8(enc2), zName, 0)
 116161 	if pColl != 0 && (*CollSeq)(unsafe.Pointer(pColl)).FxCmp != 0 {
 116162 		if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 {
 116163 			Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY,
 116164 				ts+24185, 0)
 116165 			return SQLITE_BUSY
 116166 		}
 116167 		Xsqlite3ExpirePreparedStatements(tls, db, 0)
 116168 
 116169 		if int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc)&libc.CplInt32(SQLITE_UTF16_ALIGNED) == enc2 {
 116170 			var aColl uintptr = Xsqlite3HashFind(tls, db+448, zName)
 116171 			var j int32
 116172 			for j = 0; j < 3; j++ {
 116173 				var p uintptr = aColl + uintptr(j)*20
 116174 				if int32((*CollSeq)(unsafe.Pointer(p)).Fenc) == int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc) {
 116175 					if (*CollSeq)(unsafe.Pointer(p)).FxDel != 0 {
 116176 						(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*CollSeq)(unsafe.Pointer(p)).FxDel})).f(tls, (*CollSeq)(unsafe.Pointer(p)).FpUser)
 116177 					}
 116178 					(*CollSeq)(unsafe.Pointer(p)).FxCmp = uintptr(0)
 116179 				}
 116180 			}
 116181 		}
 116182 	}
 116183 
 116184 	pColl = Xsqlite3FindCollSeq(tls, db, U8(enc2), zName, 1)
 116185 	if pColl == uintptr(0) {
 116186 		return SQLITE_NOMEM
 116187 	}
 116188 	(*CollSeq)(unsafe.Pointer(pColl)).FxCmp = xCompare
 116189 	(*CollSeq)(unsafe.Pointer(pColl)).FpUser = pCtx
 116190 	(*CollSeq)(unsafe.Pointer(pColl)).FxDel = xDel
 116191 	(*CollSeq)(unsafe.Pointer(pColl)).Fenc = U8(enc2 | int32(enc)&SQLITE_UTF16_ALIGNED)
 116192 	Xsqlite3Error(tls, db, SQLITE_OK)
 116193 	return SQLITE_OK
 116194 }
 116195 
 116196 var aHardLimit = [12]int32{
 116197 	SQLITE_MAX_LENGTH,
 116198 	SQLITE_MAX_SQL_LENGTH,
 116199 	SQLITE_MAX_COLUMN,
 116200 	SQLITE_MAX_EXPR_DEPTH,
 116201 	SQLITE_MAX_COMPOUND_SELECT,
 116202 	SQLITE_MAX_VDBE_OP,
 116203 	SQLITE_MAX_FUNCTION_ARG,
 116204 	SQLITE_MAX_ATTACHED,
 116205 	SQLITE_MAX_LIKE_PATTERN_LENGTH,
 116206 	SQLITE_MAX_VARIABLE_NUMBER,
 116207 	SQLITE_MAX_TRIGGER_DEPTH,
 116208 	SQLITE_MAX_WORKER_THREADS,
 116209 }
 116210 
 116211 // Change the value of a limit.  Report the old value.
 116212 // If an invalid limit index is supplied, report -1.
 116213 // Make no changes but still report the old value if the
 116214 // new limit is negative.
 116215 //
 116216 // A new lower limit does not shrink existing constructs.
 116217 // It merely prevents new constructs that exceed the limit
 116218 // from forming.
 116219 func Xsqlite3_limit(tls *libc.TLS, db uintptr, limitId int32, newLimit int32) int32 {
 116220 	var oldLimit int32
 116221 
 116222 	if limitId < 0 || limitId >= SQLITE_LIMIT_WORKER_THREADS+1 {
 116223 		return -1
 116224 	}
 116225 	oldLimit = *(*int32)(unsafe.Pointer(db + 120 + uintptr(limitId)*4))
 116226 	if newLimit >= 0 {
 116227 		if newLimit > aHardLimit[limitId] {
 116228 			newLimit = aHardLimit[limitId]
 116229 		} else if newLimit < 1 && limitId == SQLITE_LIMIT_LENGTH {
 116230 			newLimit = 1
 116231 		}
 116232 		*(*int32)(unsafe.Pointer(db + 120 + uintptr(limitId)*4)) = newLimit
 116233 	}
 116234 	return oldLimit
 116235 }
 116236 
 116237 // This function is used to parse both URIs and non-URI filenames passed by the
 116238 // user to API functions sqlite3_open() or sqlite3_open_v2(), and for database
 116239 // URIs specified as part of ATTACH statements.
 116240 //
 116241 // The first argument to this function is the name of the VFS to use (or
 116242 // a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx"
 116243 // query parameter. The second argument contains the URI (or non-URI filename)
 116244 // itself. When this function is called the *pFlags variable should contain
 116245 // the default flags to open the database handle with. The value stored in
 116246 // *pFlags may be updated before returning if the URI filename contains
 116247 // "cache=xxx" or "mode=xxx" query parameters.
 116248 //
 116249 // If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to
 116250 // the VFS that should be used to open the database file. *pzFile is set to
 116251 // point to a buffer containing the name of the file to open.  The value
 116252 // stored in *pzFile is a database name acceptable to sqlite3_uri_parameter()
 116253 // and is in the same format as names created using sqlite3_create_filename().
 116254 // The caller must invoke sqlite3_free_filename() (not sqlite3_free()!) on
 116255 // the value returned in *pzFile to avoid a memory leak.
 116256 //
 116257 // If an error occurs, then an SQLite error code is returned and *pzErrMsg
 116258 // may be set to point to a buffer containing an English language error
 116259 // message. It is the responsibility of the caller to eventually release
 116260 // this buffer by calling sqlite3_free().
 116261 func Xsqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags uintptr, ppVfs uintptr, pzFile uintptr, pzErrMsg uintptr) int32 {
 116262 	bp := tls.Alloc(56)
 116263 	defer tls.Free(56)
 116264 
 116265 	var rc int32
 116266 	var flags uint32
 116267 	var zVfs uintptr
 116268 	var zFile uintptr
 116269 	var c uint8
 116270 	var nUri int32
 116271 	var octet int32
 116272 	var z uintptr
 116273 	var i int32
 116274 	var mode int32
 116275 	var aMode uintptr
 116276 	var zModeType uintptr
 116277 	var mask int32
 116278 	var limit int32
 116279 	var nOpt int32
 116280 	var zVal uintptr
 116281 	var nVal int32
 116282 	var zOpt uintptr
 116283 	var eState int32
 116284 	var iIn int32
 116285 	var iOut int32
 116286 	var nByte U64
 116287 	rc = SQLITE_OK
 116288 	flags = *(*uint32)(unsafe.Pointer(pFlags))
 116289 	zVfs = zDefaultVfs
 116290 	nUri = Xsqlite3Strlen30(tls, zUri)
 116291 
 116292 	if !((flags&uint32(SQLITE_OPEN_URI) != 0 ||
 116293 		Xsqlite3Config.FbOpenUri != 0) &&
 116294 		nUri >= 5 && libc.Xmemcmp(tls, zUri, ts+24253, uint32(5)) == 0) {
 116295 		goto __1
 116296 	}
 116297 	iOut = 0
 116298 	nByte = U64(nUri + 8)
 116299 
 116300 	flags = flags | uint32(SQLITE_OPEN_URI)
 116301 
 116302 	iIn = 0
 116303 __3:
 116304 	if !(iIn < nUri) {
 116305 		goto __5
 116306 	}
 116307 	nByte = nByte + U64(libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn)))) == '&'))
 116308 	goto __4
 116309 __4:
 116310 	iIn++
 116311 	goto __3
 116312 	goto __5
 116313 __5:
 116314 	;
 116315 	zFile = Xsqlite3_malloc64(tls, nByte)
 116316 	if !!(zFile != 0) {
 116317 		goto __6
 116318 	}
 116319 	return SQLITE_NOMEM
 116320 __6:
 116321 	;
 116322 	libc.Xmemset(tls, zFile, 0, uint32(4))
 116323 	zFile += uintptr(4)
 116324 
 116325 	iIn = 5
 116326 
 116327 	if !(int32(*(*uint8)(unsafe.Pointer(zUri + 5))) == '/' && int32(*(*uint8)(unsafe.Pointer(zUri + 6))) == '/') {
 116328 		goto __7
 116329 	}
 116330 	iIn = 7
 116331 __8:
 116332 	if !(*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn))) != 0 && int32(*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn)))) != '/') {
 116333 		goto __9
 116334 	}
 116335 	iIn++
 116336 	goto __8
 116337 __9:
 116338 	;
 116339 	if !(iIn != 7 && (iIn != 16 || libc.Xmemcmp(tls, ts+24259, zUri+7, uint32(9)) != 0)) {
 116340 		goto __10
 116341 	}
 116342 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+24269,
 116343 		libc.VaList(bp, iIn-7, zUri+7))
 116344 	rc = SQLITE_ERROR
 116345 	goto parse_uri_out
 116346 __10:
 116347 	;
 116348 __7:
 116349 	;
 116350 	eState = 0
 116351 __11:
 116352 	if !(int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(zUri + uintptr(iIn))))) != 0 && int32(c) != '#') {
 116353 		goto __12
 116354 	}
 116355 	iIn++
 116356 	if !(int32(c) == '%' &&
 116357 		int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn)))])&0x08 != 0 &&
 116358 		int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn+1)))])&0x08 != 0) {
 116359 		goto __13
 116360 	}
 116361 	octet = int32(Xsqlite3HexToInt(tls, int32(*(*uint8)(unsafe.Pointer(zUri + uintptr(libc.PostIncInt32(&iIn, 1))))))) << 4
 116362 	octet = octet + int32(Xsqlite3HexToInt(tls, int32(*(*uint8)(unsafe.Pointer(zUri + uintptr(libc.PostIncInt32(&iIn, 1)))))))
 116363 
 116364 	if !(octet == 0) {
 116365 		goto __15
 116366 	}
 116367 
 116368 __16:
 116369 	if !(int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(zUri + uintptr(iIn))))) != 0 && int32(c) != '#' &&
 116370 		(eState != 0 || int32(c) != '?') &&
 116371 		(eState != 1 || int32(c) != '=' && int32(c) != '&') &&
 116372 		(eState != 2 || int32(c) != '&')) {
 116373 		goto __17
 116374 	}
 116375 	iIn++
 116376 	goto __16
 116377 __17:
 116378 	;
 116379 	goto __11
 116380 __15:
 116381 	;
 116382 	c = uint8(octet)
 116383 	goto __14
 116384 __13:
 116385 	if !(eState == 1 && (int32(c) == '&' || int32(c) == '=')) {
 116386 		goto __18
 116387 	}
 116388 	if !(int32(*(*uint8)(unsafe.Pointer(zFile + uintptr(iOut-1)))) == 0) {
 116389 		goto __20
 116390 	}
 116391 
 116392 __21:
 116393 	if !(*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn))) != 0 && int32(*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn)))) != '#' && int32(*(*uint8)(unsafe.Pointer(zUri + uintptr(iIn-1)))) != '&') {
 116394 		goto __22
 116395 	}
 116396 	iIn++
 116397 	goto __21
 116398 __22:
 116399 	;
 116400 	goto __11
 116401 __20:
 116402 	;
 116403 	if !(int32(c) == '&') {
 116404 		goto __23
 116405 	}
 116406 	*(*uint8)(unsafe.Pointer(zFile + uintptr(libc.PostIncInt32(&iOut, 1)))) = uint8(0)
 116407 	goto __24
 116408 __23:
 116409 	eState = 2
 116410 __24:
 116411 	;
 116412 	c = uint8(0)
 116413 	goto __19
 116414 __18:
 116415 	if !(eState == 0 && int32(c) == '?' || eState == 2 && int32(c) == '&') {
 116416 		goto __25
 116417 	}
 116418 	c = uint8(0)
 116419 	eState = 1
 116420 __25:
 116421 	;
 116422 __19:
 116423 	;
 116424 __14:
 116425 	;
 116426 	*(*uint8)(unsafe.Pointer(zFile + uintptr(libc.PostIncInt32(&iOut, 1)))) = c
 116427 	goto __11
 116428 __12:
 116429 	;
 116430 	if !(eState == 1) {
 116431 		goto __26
 116432 	}
 116433 	*(*uint8)(unsafe.Pointer(zFile + uintptr(libc.PostIncInt32(&iOut, 1)))) = uint8(0)
 116434 __26:
 116435 	;
 116436 	libc.Xmemset(tls, zFile+uintptr(iOut), 0, uint32(4))
 116437 
 116438 	zOpt = zFile + uintptr(Xsqlite3Strlen30(tls, zFile)+1)
 116439 __27:
 116440 	if !(*(*uint8)(unsafe.Pointer(zOpt)) != 0) {
 116441 		goto __28
 116442 	}
 116443 	nOpt = Xsqlite3Strlen30(tls, zOpt)
 116444 	zVal = zOpt + uintptr(nOpt+1)
 116445 	nVal = Xsqlite3Strlen30(tls, zVal)
 116446 
 116447 	if !(nOpt == 3 && libc.Xmemcmp(tls, ts+24297, zOpt, uint32(3)) == 0) {
 116448 		goto __29
 116449 	}
 116450 	zVfs = zVal
 116451 	goto __30
 116452 __29:
 116453 	aMode = uintptr(0)
 116454 	zModeType = uintptr(0)
 116455 	mask = 0
 116456 	limit = 0
 116457 
 116458 	if !(nOpt == 5 && libc.Xmemcmp(tls, ts+24301, zOpt, uint32(5)) == 0) {
 116459 		goto __31
 116460 	}
 116461 
 116462 	mask = SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_PRIVATECACHE
 116463 	aMode = uintptr(unsafe.Pointer(&aCacheMode))
 116464 	limit = mask
 116465 	zModeType = ts + 24301
 116466 __31:
 116467 	;
 116468 	if !(nOpt == 4 && libc.Xmemcmp(tls, ts+24307, zOpt, uint32(4)) == 0) {
 116469 		goto __32
 116470 	}
 116471 
 116472 	mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE |
 116473 		SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY
 116474 	aMode = uintptr(unsafe.Pointer(&aOpenMode))
 116475 	limit = int32(uint32(mask) & flags)
 116476 	zModeType = ts + 3272
 116477 __32:
 116478 	;
 116479 	if !(aMode != 0) {
 116480 		goto __33
 116481 	}
 116482 	mode = 0
 116483 	i = 0
 116484 __34:
 116485 	if !((*OpenMode)(unsafe.Pointer(aMode+uintptr(i)*8)).Fz != 0) {
 116486 		goto __36
 116487 	}
 116488 	z = (*OpenMode)(unsafe.Pointer(aMode + uintptr(i)*8)).Fz
 116489 	if !(nVal == Xsqlite3Strlen30(tls, z) && 0 == libc.Xmemcmp(tls, zVal, z, uint32(nVal))) {
 116490 		goto __37
 116491 	}
 116492 	mode = (*OpenMode)(unsafe.Pointer(aMode + uintptr(i)*8)).Fmode
 116493 	goto __36
 116494 __37:
 116495 	;
 116496 	goto __35
 116497 __35:
 116498 	i++
 116499 	goto __34
 116500 	goto __36
 116501 __36:
 116502 	;
 116503 	if !(mode == 0) {
 116504 		goto __38
 116505 	}
 116506 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+24312, libc.VaList(bp+16, zModeType, zVal))
 116507 	rc = SQLITE_ERROR
 116508 	goto parse_uri_out
 116509 __38:
 116510 	;
 116511 	if !(mode&libc.CplInt32(SQLITE_OPEN_MEMORY) > limit) {
 116512 		goto __39
 116513 	}
 116514 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+24332,
 116515 		libc.VaList(bp+32, zModeType, zVal))
 116516 	rc = SQLITE_PERM
 116517 	goto parse_uri_out
 116518 __39:
 116519 	;
 116520 	flags = flags&uint32(^mask) | uint32(mode)
 116521 __33:
 116522 	;
 116523 __30:
 116524 	;
 116525 	zOpt = zVal + uintptr(nVal+1)
 116526 	goto __27
 116527 __28:
 116528 	;
 116529 	goto __2
 116530 __1:
 116531 	zFile = Xsqlite3_malloc64(tls, uint64(nUri+8))
 116532 	if !!(zFile != 0) {
 116533 		goto __40
 116534 	}
 116535 	return SQLITE_NOMEM
 116536 __40:
 116537 	;
 116538 	libc.Xmemset(tls, zFile, 0, uint32(4))
 116539 	zFile += uintptr(4)
 116540 	if !(nUri != 0) {
 116541 		goto __41
 116542 	}
 116543 	libc.Xmemcpy(tls, zFile, zUri, uint32(nUri))
 116544 __41:
 116545 	;
 116546 	libc.Xmemset(tls, zFile+uintptr(nUri), 0, uint32(4))
 116547 	flags = flags & libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_URI))
 116548 __2:
 116549 	;
 116550 	*(*uintptr)(unsafe.Pointer(ppVfs)) = Xsqlite3_vfs_find(tls, zVfs)
 116551 	if !(*(*uintptr)(unsafe.Pointer(ppVfs)) == uintptr(0)) {
 116552 		goto __42
 116553 	}
 116554 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+24356, libc.VaList(bp+48, zVfs))
 116555 	rc = SQLITE_ERROR
 116556 __42:
 116557 	;
 116558 parse_uri_out:
 116559 	if !(rc != SQLITE_OK) {
 116560 		goto __43
 116561 	}
 116562 	Xsqlite3_free_filename(tls, zFile)
 116563 	zFile = uintptr(0)
 116564 __43:
 116565 	;
 116566 	*(*uint32)(unsafe.Pointer(pFlags)) = flags
 116567 	*(*uintptr)(unsafe.Pointer(pzFile)) = zFile
 116568 	return rc
 116569 }
 116570 
 116571 type OpenMode = struct {
 116572 	Fz    uintptr
 116573 	Fmode int32
 116574 }
 116575 
 116576 var aCacheMode = [3]OpenMode{
 116577 	{Fz: ts + 24372, Fmode: SQLITE_OPEN_SHAREDCACHE},
 116578 	{Fz: ts + 24379, Fmode: SQLITE_OPEN_PRIVATECACHE},
 116579 	{},
 116580 }
 116581 var aOpenMode = [5]OpenMode{
 116582 	{Fz: ts + 24387, Fmode: SQLITE_OPEN_READONLY},
 116583 	{Fz: ts + 24390, Fmode: SQLITE_OPEN_READWRITE},
 116584 	{Fz: ts + 24393, Fmode: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE},
 116585 	{Fz: ts + 17362, Fmode: SQLITE_OPEN_MEMORY},
 116586 	{},
 116587 }
 116588 
 116589 func uriParameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) uintptr {
 116590 	zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 116591 	for zFilename != uintptr(0) && *(*uint8)(unsafe.Pointer(zFilename)) != 0 {
 116592 		var x int32 = libc.Xstrcmp(tls, zFilename, zParam)
 116593 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 116594 		if x == 0 {
 116595 			return zFilename
 116596 		}
 116597 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 116598 	}
 116599 	return uintptr(0)
 116600 }
 116601 
 116602 func openDatabase(tls *libc.TLS, zFilename uintptr, ppDb uintptr, flags uint32, zVfs uintptr) int32 {
 116603 	bp := tls.Alloc(20)
 116604 	defer tls.Free(20)
 116605 	*(*uint32)(unsafe.Pointer(bp + 8)) = flags
 116606 
 116607 	var db uintptr
 116608 	var rc int32
 116609 	var isThreadsafe int32
 116610 
 116611 	var i int32
 116612 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 116613 	*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 116614 
 116615 	*(*uintptr)(unsafe.Pointer(ppDb)) = uintptr(0)
 116616 	rc = Xsqlite3_initialize(tls)
 116617 	if !(rc != 0) {
 116618 		goto __1
 116619 	}
 116620 	return rc
 116621 __1:
 116622 	;
 116623 	if !(int32(Xsqlite3Config.FbCoreMutex) == 0) {
 116624 		goto __2
 116625 	}
 116626 	isThreadsafe = 0
 116627 	goto __3
 116628 __2:
 116629 	if !(*(*uint32)(unsafe.Pointer(bp + 8))&uint32(SQLITE_OPEN_NOMUTEX) != 0) {
 116630 		goto __4
 116631 	}
 116632 	isThreadsafe = 0
 116633 	goto __5
 116634 __4:
 116635 	if !(*(*uint32)(unsafe.Pointer(bp + 8))&uint32(SQLITE_OPEN_FULLMUTEX) != 0) {
 116636 		goto __6
 116637 	}
 116638 	isThreadsafe = 1
 116639 	goto __7
 116640 __6:
 116641 	isThreadsafe = int32(Xsqlite3Config.FbFullMutex)
 116642 __7:
 116643 	;
 116644 __5:
 116645 	;
 116646 __3:
 116647 	;
 116648 	if !(*(*uint32)(unsafe.Pointer(bp + 8))&uint32(SQLITE_OPEN_PRIVATECACHE) != 0) {
 116649 		goto __8
 116650 	}
 116651 	*(*uint32)(unsafe.Pointer(bp + 8)) &= libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_SHAREDCACHE))
 116652 	goto __9
 116653 __8:
 116654 	if !(Xsqlite3Config.FsharedCacheEnabled != 0) {
 116655 		goto __10
 116656 	}
 116657 	*(*uint32)(unsafe.Pointer(bp + 8)) |= uint32(SQLITE_OPEN_SHAREDCACHE)
 116658 __10:
 116659 	;
 116660 __9:
 116661 	;
 116662 	*(*uint32)(unsafe.Pointer(bp + 8)) &= libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_TRANSIENT_DB | SQLITE_OPEN_MAIN_JOURNAL | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_SUPER_JOURNAL | SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_WAL))
 116663 
 116664 	db = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Sqlite3{})))
 116665 	if !(db == uintptr(0)) {
 116666 		goto __11
 116667 	}
 116668 	goto opendb_out
 116669 __11:
 116670 	;
 116671 	if !(isThreadsafe != 0) {
 116672 		goto __12
 116673 	}
 116674 	(*Sqlite3)(unsafe.Pointer(db)).Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE)
 116675 	if !((*Sqlite3)(unsafe.Pointer(db)).Fmutex == uintptr(0)) {
 116676 		goto __13
 116677 	}
 116678 	Xsqlite3_free(tls, db)
 116679 	db = uintptr(0)
 116680 	goto opendb_out
 116681 __13:
 116682 	;
 116683 	if !(isThreadsafe == 0) {
 116684 		goto __14
 116685 	}
 116686 
 116687 __14:
 116688 	;
 116689 __12:
 116690 	;
 116691 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116692 	(*Sqlite3)(unsafe.Pointer(db)).FerrMask = func() int32 {
 116693 		if *(*uint32)(unsafe.Pointer(bp + 8))&uint32(SQLITE_OPEN_EXRESCODE) != uint32(0) {
 116694 			return libc.Int32FromUint32(0xffffffff)
 116695 		}
 116696 		return 0xff
 116697 	}()
 116698 	(*Sqlite3)(unsafe.Pointer(db)).FnDb = 2
 116699 	(*Sqlite3)(unsafe.Pointer(db)).FeOpenState = U8(SQLITE_STATE_BUSY)
 116700 	(*Sqlite3)(unsafe.Pointer(db)).FaDb = db + 476
 116701 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = U32(1)
 116702 	(*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0)
 116703 
 116704 	libc.Xmemcpy(tls, db+120, uintptr(unsafe.Pointer(&aHardLimit)), uint32(unsafe.Sizeof([12]int32{})))
 116705 	*(*int32)(unsafe.Pointer(db + 120 + 11*4)) = SQLITE_DEFAULT_WORKER_THREADS
 116706 	(*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1)
 116707 	(*Sqlite3)(unsafe.Pointer(db)).FnextAutovac = int8(-1)
 116708 	(*Sqlite3)(unsafe.Pointer(db)).FszMmap = Xsqlite3Config.FszMmap
 116709 	(*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = 0
 116710 	(*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit = uintptr(unsafe.Pointer(&Xsqlite3StdType))
 116711 	*(*U64)(unsafe.Pointer(db + 32)) |= uint64(uint32(SQLITE_ShortColNames|
 116712 		SQLITE_EnableTrigger) |
 116713 		SQLITE_EnableView |
 116714 		uint32(SQLITE_CacheSpill) |
 116715 		uint32(SQLITE_TrustedSchema) |
 116716 		uint32(SQLITE_DqsDML) |
 116717 		uint32(SQLITE_DqsDDL) |
 116718 		uint32(SQLITE_AutoIndex))
 116719 	Xsqlite3HashInit(tls, db+448)
 116720 	Xsqlite3HashInit(tls, db+404)
 116721 
 116722 	createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(SQLITE_UTF8), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 116723 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
 116724 	}{binCollFunc})), uintptr(0))
 116725 	createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(SQLITE_UTF16BE), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 116726 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
 116727 	}{binCollFunc})), uintptr(0))
 116728 	createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(SQLITE_UTF16LE), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 116729 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
 116730 	}{binCollFunc})), uintptr(0))
 116731 	createCollation(tls, db, ts+21910, uint8(SQLITE_UTF8), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 116732 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
 116733 	}{nocaseCollatingFunc})), uintptr(0))
 116734 	createCollation(tls, db, ts+24397, uint8(SQLITE_UTF8), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 116735 		f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32
 116736 	}{rtrimCollFunc})), uintptr(0))
 116737 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 116738 		goto __15
 116739 	}
 116740 	goto opendb_out
 116741 __15:
 116742 	;
 116743 	(*Sqlite3)(unsafe.Pointer(db)).FopenFlags = *(*uint32)(unsafe.Pointer(bp + 8))
 116744 
 116745 	if !(int32(1)<<(*(*uint32)(unsafe.Pointer(bp + 8))&uint32(7))&0x46 == 0) {
 116746 		goto __16
 116747 	}
 116748 	rc = Xsqlite3MisuseError(tls, 177397)
 116749 	goto __17
 116750 __16:
 116751 	rc = Xsqlite3ParseUri(tls, zVfs, zFilename, bp+8, db, bp+12, bp+16)
 116752 __17:
 116753 	;
 116754 	if !(rc != SQLITE_OK) {
 116755 		goto __18
 116756 	}
 116757 	if !(rc == SQLITE_NOMEM) {
 116758 		goto __19
 116759 	}
 116760 	Xsqlite3OomFault(tls, db)
 116761 __19:
 116762 	;
 116763 	Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr {
 116764 		if *(*uintptr)(unsafe.Pointer(bp + 16)) != 0 {
 116765 			return ts + 3663
 116766 		}
 116767 		return uintptr(0)
 116768 	}(), libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 16))))
 116769 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
 116770 	goto opendb_out
 116771 __18:
 116772 	;
 116773 	rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, *(*uintptr)(unsafe.Pointer(bp + 12)), db, (*Sqlite3)(unsafe.Pointer(db)).FaDb+4, 0,
 116774 		int32(*(*uint32)(unsafe.Pointer(bp + 8))|uint32(SQLITE_OPEN_MAIN_DB)))
 116775 	if !(rc != SQLITE_OK) {
 116776 		goto __20
 116777 	}
 116778 	if !(rc == SQLITE_IOERR|int32(12)<<8) {
 116779 		goto __21
 116780 	}
 116781 	rc = SQLITE_NOMEM
 116782 __21:
 116783 	;
 116784 	Xsqlite3Error(tls, db, rc)
 116785 	goto opendb_out
 116786 __20:
 116787 	;
 116788 	Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)
 116789 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)
 116790 	if !!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) {
 116791 		goto __22
 116792 	}
 116793 	Xsqlite3SetTextEncoding(tls, db, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fenc)
 116794 __22:
 116795 	;
 116796 	Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)
 116797 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FpSchema = Xsqlite3SchemaGet(tls, db, uintptr(0))
 116798 
 116799 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName = ts + 6441
 116800 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).Fsafety_level = U8(SQLITE_DEFAULT_SYNCHRONOUS + 1)
 116801 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).FzDbSName = ts + 23399
 116802 	(*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*16)).Fsafety_level = U8(PAGER_SYNCHRONOUS_OFF)
 116803 
 116804 	(*Sqlite3)(unsafe.Pointer(db)).FeOpenState = U8(SQLITE_STATE_OPEN)
 116805 	if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
 116806 		goto __23
 116807 	}
 116808 	goto opendb_out
 116809 __23:
 116810 	;
 116811 	Xsqlite3Error(tls, db, SQLITE_OK)
 116812 	Xsqlite3RegisterPerConnectionBuiltinFunctions(tls, db)
 116813 	rc = Xsqlite3_errcode(tls, db)
 116814 
 116815 	i = 0
 116816 __24:
 116817 	if !(rc == SQLITE_OK && i < int32(uint32(unsafe.Sizeof(sqlite3BuiltinExtensions))/uint32(unsafe.Sizeof(uintptr(0))))) {
 116818 		goto __26
 116819 	}
 116820 	rc = (*struct {
 116821 		f func(*libc.TLS, uintptr) int32
 116822 	})(unsafe.Pointer(&struct{ uintptr }{sqlite3BuiltinExtensions[i]})).f(tls, db)
 116823 	goto __25
 116824 __25:
 116825 	i++
 116826 	goto __24
 116827 	goto __26
 116828 __26:
 116829 	;
 116830 	if !(rc == SQLITE_OK) {
 116831 		goto __27
 116832 	}
 116833 	Xsqlite3AutoLoadExtensions(tls, db)
 116834 	rc = Xsqlite3_errcode(tls, db)
 116835 	if !(rc != SQLITE_OK) {
 116836 		goto __28
 116837 	}
 116838 	goto opendb_out
 116839 __28:
 116840 	;
 116841 __27:
 116842 	;
 116843 	if !(rc != 0) {
 116844 		goto __29
 116845 	}
 116846 	Xsqlite3Error(tls, db, rc)
 116847 __29:
 116848 	;
 116849 	setupLookaside(tls, db, uintptr(0), Xsqlite3Config.FszLookaside,
 116850 		Xsqlite3Config.FnLookaside)
 116851 
 116852 	Xsqlite3_wal_autocheckpoint(tls, db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT)
 116853 
 116854 opendb_out:
 116855 	if !(db != 0) {
 116856 		goto __30
 116857 	}
 116858 
 116859 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116860 __30:
 116861 	;
 116862 	rc = Xsqlite3_errcode(tls, db)
 116863 
 116864 	if !(rc&0xff == SQLITE_NOMEM) {
 116865 		goto __31
 116866 	}
 116867 	Xsqlite3_close(tls, db)
 116868 	db = uintptr(0)
 116869 	goto __32
 116870 __31:
 116871 	if !(rc != SQLITE_OK) {
 116872 		goto __33
 116873 	}
 116874 	(*Sqlite3)(unsafe.Pointer(db)).FeOpenState = U8(SQLITE_STATE_SICK)
 116875 __33:
 116876 	;
 116877 __32:
 116878 	;
 116879 	*(*uintptr)(unsafe.Pointer(ppDb)) = db
 116880 	Xsqlite3_free_filename(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 116881 	return rc
 116882 }
 116883 
 116884 // Open a new database handle.
 116885 func Xsqlite3_open(tls *libc.TLS, zFilename uintptr, ppDb uintptr) int32 {
 116886 	return openDatabase(tls, zFilename, ppDb,
 116887 		uint32(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE), uintptr(0))
 116888 }
 116889 
 116890 func Xsqlite3_open_v2(tls *libc.TLS, filename uintptr, ppDb uintptr, flags int32, zVfs uintptr) int32 {
 116891 	return openDatabase(tls, filename, ppDb, uint32(flags), zVfs)
 116892 }
 116893 
 116894 // Open a new database handle.
 116895 func Xsqlite3_open16(tls *libc.TLS, zFilename uintptr, ppDb uintptr) int32 {
 116896 	var zFilename8 uintptr
 116897 	var pVal uintptr
 116898 	var rc int32
 116899 
 116900 	*(*uintptr)(unsafe.Pointer(ppDb)) = uintptr(0)
 116901 	rc = Xsqlite3_initialize(tls)
 116902 	if rc != 0 {
 116903 		return rc
 116904 	}
 116905 	if zFilename == uintptr(0) {
 116906 		zFilename = ts + 24403
 116907 	}
 116908 	pVal = Xsqlite3ValueNew(tls, uintptr(0))
 116909 	Xsqlite3ValueSetStr(tls, pVal, -1, zFilename, uint8(SQLITE_UTF16LE), uintptr(0))
 116910 	zFilename8 = Xsqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8))
 116911 	if zFilename8 != 0 {
 116912 		rc = openDatabase(tls, zFilename8, ppDb,
 116913 			uint32(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE), uintptr(0))
 116914 
 116915 		if rc == SQLITE_OK && !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppDb)))).FaDb)).FpSchema)).FschemaFlags)&DB_SchemaLoaded == DB_SchemaLoaded) {
 116916 			(*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppDb)))).FaDb)).FpSchema)).Fenc = libc.AssignPtrUint8(*(*uintptr)(unsafe.Pointer(ppDb))+84, U8(SQLITE_UTF16LE))
 116917 		}
 116918 	} else {
 116919 		rc = SQLITE_NOMEM
 116920 	}
 116921 	Xsqlite3ValueFree(tls, pVal)
 116922 
 116923 	return rc & 0xff
 116924 }
 116925 
 116926 // Register a new collation sequence with the database handle db.
 116927 func Xsqlite3_create_collation(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, xCompare uintptr) int32 {
 116928 	return Xsqlite3_create_collation_v2(tls, db, zName, enc, pCtx, xCompare, uintptr(0))
 116929 }
 116930 
 116931 // Register a new collation sequence with the database handle db.
 116932 func Xsqlite3_create_collation_v2(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, xCompare uintptr, xDel uintptr) int32 {
 116933 	var rc int32
 116934 
 116935 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116936 
 116937 	rc = createCollation(tls, db, zName, U8(enc), pCtx, xCompare, xDel)
 116938 	rc = Xsqlite3ApiExit(tls, db, rc)
 116939 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116940 	return rc
 116941 }
 116942 
 116943 // Register a new collation sequence with the database handle db.
 116944 func Xsqlite3_create_collation16(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, xCompare uintptr) int32 {
 116945 	var rc int32 = SQLITE_OK
 116946 	var zName8 uintptr
 116947 
 116948 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116949 
 116950 	zName8 = Xsqlite3Utf16to8(tls, db, zName, -1, uint8(SQLITE_UTF16LE))
 116951 	if zName8 != 0 {
 116952 		rc = createCollation(tls, db, zName8, U8(enc), pCtx, xCompare, uintptr(0))
 116953 		Xsqlite3DbFree(tls, db, zName8)
 116954 	}
 116955 	rc = Xsqlite3ApiExit(tls, db, rc)
 116956 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116957 	return rc
 116958 }
 116959 
 116960 // Register a collation sequence factory callback with the database handle
 116961 // db. Replace any previously installed collation sequence factory.
 116962 func Xsqlite3_collation_needed(tls *libc.TLS, db uintptr, pCollNeededArg uintptr, xCollNeeded uintptr) int32 {
 116963 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116964 	(*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded = xCollNeeded
 116965 	(*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = uintptr(0)
 116966 	(*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg
 116967 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116968 	return SQLITE_OK
 116969 }
 116970 
 116971 // Register a collation sequence factory callback with the database handle
 116972 // db. Replace any previously installed collation sequence factory.
 116973 func Xsqlite3_collation_needed16(tls *libc.TLS, db uintptr, pCollNeededArg uintptr, xCollNeeded16 uintptr) int32 {
 116974 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116975 	(*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded = uintptr(0)
 116976 	(*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = xCollNeeded16
 116977 	(*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg
 116978 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 116979 	return SQLITE_OK
 116980 }
 116981 
 116982 // This function is now an anachronism. It used to be used to recover from a
 116983 // malloc() failure, but SQLite now does this automatically.
 116984 func Xsqlite3_global_recover(tls *libc.TLS) int32 {
 116985 	return SQLITE_OK
 116986 }
 116987 
 116988 // Test to see whether or not the database connection is in autocommit
 116989 // mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on
 116990 // by default.  Autocommit is disabled by a BEGIN statement and reenabled
 116991 // by the next COMMIT or ROLLBACK.
 116992 func Xsqlite3_get_autocommit(tls *libc.TLS, db uintptr) int32 {
 116993 	return int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit)
 116994 }
 116995 
 116996 // The following routines are substitutes for constants SQLITE_CORRUPT,
 116997 // SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error
 116998 // constants.  They serve two purposes:
 116999 //
 117000 //  1. Serve as a convenient place to set a breakpoint in a debugger
 117001 //     to detect when version error conditions occurs.
 117002 //
 117003 //  2. Invoke sqlite3_log() to provide the source code location where
 117004 //     a low-level error is first detected.
 117005 func Xsqlite3ReportError(tls *libc.TLS, iErr int32, lineno int32, zType uintptr) int32 {
 117006 	bp := tls.Alloc(24)
 117007 	defer tls.Free(24)
 117008 
 117009 	Xsqlite3_log(tls, iErr, ts+24406,
 117010 		libc.VaList(bp, zType, lineno, uintptr(20)+Xsqlite3_sourceid(tls)))
 117011 	return iErr
 117012 }
 117013 
 117014 func Xsqlite3CorruptError(tls *libc.TLS, lineno int32) int32 {
 117015 	return Xsqlite3ReportError(tls, SQLITE_CORRUPT, lineno, ts+24431)
 117016 }
 117017 
 117018 func Xsqlite3MisuseError(tls *libc.TLS, lineno int32) int32 {
 117019 	return Xsqlite3ReportError(tls, SQLITE_MISUSE, lineno, ts+24451)
 117020 }
 117021 
 117022 func Xsqlite3CantopenError(tls *libc.TLS, lineno int32) int32 {
 117023 	return Xsqlite3ReportError(tls, SQLITE_CANTOPEN, lineno, ts+24458)
 117024 }
 117025 
 117026 // This is a convenience routine that makes sure that all thread-specific
 117027 // data for this thread has been deallocated.
 117028 //
 117029 // SQLite no longer uses thread-specific data so this routine is now a
 117030 // no-op.  It is retained for historical compatibility.
 117031 func Xsqlite3_thread_cleanup(tls *libc.TLS) {
 117032 }
 117033 
 117034 // Return meta information about a specific column of a database table.
 117035 // See comment in sqlite3.h (sqlite.h.in) for details.
 117036 func Xsqlite3_table_column_metadata(tls *libc.TLS, db uintptr, zDbName uintptr, zTableName uintptr, zColumnName uintptr, pzDataType uintptr, pzCollSeq uintptr, pNotNull uintptr, pPrimaryKey uintptr, pAutoinc uintptr) int32 {
 117037 	bp := tls.Alloc(28)
 117038 	defer tls.Free(28)
 117039 
 117040 	var rc int32
 117041 
 117042 	var pTab uintptr
 117043 	var pCol uintptr
 117044 	var iCol int32
 117045 	var zDataType uintptr
 117046 	var zCollSeq uintptr
 117047 	var notnull int32
 117048 	var primarykey int32
 117049 	var autoinc int32
 117050 	*(*uintptr)(unsafe.Pointer(bp + 24)) = uintptr(0)
 117051 	pTab = uintptr(0)
 117052 	pCol = uintptr(0)
 117053 	iCol = 0
 117054 	zDataType = uintptr(0)
 117055 	zCollSeq = uintptr(0)
 117056 	notnull = 0
 117057 	primarykey = 0
 117058 	autoinc = 0
 117059 
 117060 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117061 	Xsqlite3BtreeEnterAll(tls, db)
 117062 	rc = Xsqlite3Init(tls, db, bp+24)
 117063 	if !(SQLITE_OK != rc) {
 117064 		goto __1
 117065 	}
 117066 	goto error_out
 117067 __1:
 117068 	;
 117069 	pTab = Xsqlite3FindTable(tls, db, zTableName, zDbName)
 117070 	if !(!(pTab != 0) || int32((*Table)(unsafe.Pointer(pTab)).FeTabType) == TABTYP_VIEW) {
 117071 		goto __2
 117072 	}
 117073 	pTab = uintptr(0)
 117074 	goto error_out
 117075 __2:
 117076 	;
 117077 	if !(zColumnName == uintptr(0)) {
 117078 		goto __3
 117079 	}
 117080 
 117081 	goto __4
 117082 __3:
 117083 	iCol = 0
 117084 __5:
 117085 	if !(iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
 117086 		goto __7
 117087 	}
 117088 	pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16
 117089 	if !(0 == Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzCnName, zColumnName)) {
 117090 		goto __8
 117091 	}
 117092 	goto __7
 117093 __8:
 117094 	;
 117095 	goto __6
 117096 __6:
 117097 	iCol++
 117098 	goto __5
 117099 	goto __7
 117100 __7:
 117101 	;
 117102 	if !(iCol == int32((*Table)(unsafe.Pointer(pTab)).FnCol)) {
 117103 		goto __9
 117104 	}
 117105 	if !((*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_WithoutRowid) == U32(0) && Xsqlite3IsRowid(tls, zColumnName) != 0) {
 117106 		goto __10
 117107 	}
 117108 	iCol = int32((*Table)(unsafe.Pointer(pTab)).FiPKey)
 117109 	if iCol >= 0 {
 117110 		pCol = (*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16
 117111 	} else {
 117112 		pCol = uintptr(0)
 117113 	}
 117114 	goto __11
 117115 __10:
 117116 	pTab = uintptr(0)
 117117 	goto error_out
 117118 __11:
 117119 	;
 117120 __9:
 117121 	;
 117122 __4:
 117123 	;
 117124 	if !(pCol != 0) {
 117125 		goto __12
 117126 	}
 117127 	zDataType = Xsqlite3ColumnType(tls, pCol, uintptr(0))
 117128 	zCollSeq = Xsqlite3ColumnColl(tls, pCol)
 117129 	notnull = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(pCol + 4))&0xf>>0) != 0)
 117130 	primarykey = libc.Bool32(int32((*Column)(unsafe.Pointer(pCol)).FcolFlags)&COLFLAG_PRIMKEY != 0)
 117131 	autoinc = libc.Bool32(int32((*Table)(unsafe.Pointer(pTab)).FiPKey) == iCol && (*Table)(unsafe.Pointer(pTab)).FtabFlags&U32(TF_Autoincrement) != U32(0))
 117132 	goto __13
 117133 __12:
 117134 	zDataType = ts + 1119
 117135 	primarykey = 1
 117136 __13:
 117137 	;
 117138 	if !!(zCollSeq != 0) {
 117139 		goto __14
 117140 	}
 117141 	zCollSeq = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))
 117142 __14:
 117143 	;
 117144 error_out:
 117145 	Xsqlite3BtreeLeaveAll(tls, db)
 117146 
 117147 	if !(pzDataType != 0) {
 117148 		goto __15
 117149 	}
 117150 	*(*uintptr)(unsafe.Pointer(pzDataType)) = zDataType
 117151 __15:
 117152 	;
 117153 	if !(pzCollSeq != 0) {
 117154 		goto __16
 117155 	}
 117156 	*(*uintptr)(unsafe.Pointer(pzCollSeq)) = zCollSeq
 117157 __16:
 117158 	;
 117159 	if !(pNotNull != 0) {
 117160 		goto __17
 117161 	}
 117162 	*(*int32)(unsafe.Pointer(pNotNull)) = notnull
 117163 __17:
 117164 	;
 117165 	if !(pPrimaryKey != 0) {
 117166 		goto __18
 117167 	}
 117168 	*(*int32)(unsafe.Pointer(pPrimaryKey)) = primarykey
 117169 __18:
 117170 	;
 117171 	if !(pAutoinc != 0) {
 117172 		goto __19
 117173 	}
 117174 	*(*int32)(unsafe.Pointer(pAutoinc)) = autoinc
 117175 __19:
 117176 	;
 117177 	if !(SQLITE_OK == rc && !(pTab != 0)) {
 117178 		goto __20
 117179 	}
 117180 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 24)))
 117181 	*(*uintptr)(unsafe.Pointer(bp + 24)) = Xsqlite3MPrintf(tls, db, ts+24475, libc.VaList(bp, zTableName,
 117182 		zColumnName))
 117183 	rc = SQLITE_ERROR
 117184 __20:
 117185 	;
 117186 	Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr {
 117187 		if *(*uintptr)(unsafe.Pointer(bp + 24)) != 0 {
 117188 			return ts + 3663
 117189 		}
 117190 		return uintptr(0)
 117191 	}(), libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(bp + 24))))
 117192 	Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 24)))
 117193 	rc = Xsqlite3ApiExit(tls, db, rc)
 117194 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117195 	return rc
 117196 }
 117197 
 117198 // Sleep for a little while.  Return the amount of time slept.
 117199 func Xsqlite3_sleep(tls *libc.TLS, ms int32) int32 {
 117200 	var pVfs uintptr
 117201 	var rc int32
 117202 	pVfs = Xsqlite3_vfs_find(tls, uintptr(0))
 117203 	if pVfs == uintptr(0) {
 117204 		return 0
 117205 	}
 117206 
 117207 	rc = Xsqlite3OsSleep(tls, pVfs, 1000*ms) / 1000
 117208 	return rc
 117209 }
 117210 
 117211 // Enable or disable the extended result codes.
 117212 func Xsqlite3_extended_result_codes(tls *libc.TLS, db uintptr, onoff int32) int32 {
 117213 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117214 	(*Sqlite3)(unsafe.Pointer(db)).FerrMask = func() int32 {
 117215 		if onoff != 0 {
 117216 			return libc.Int32FromUint32(0xffffffff)
 117217 		}
 117218 		return 0xff
 117219 	}()
 117220 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117221 	return SQLITE_OK
 117222 }
 117223 
 117224 // Invoke the xFileControl method on a particular database.
 117225 func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, pArg uintptr) int32 {
 117226 	var rc int32 = SQLITE_ERROR
 117227 	var pBtree uintptr
 117228 
 117229 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117230 	pBtree = Xsqlite3DbNameToBtree(tls, db, zDbName)
 117231 	if pBtree != 0 {
 117232 		var pPager uintptr
 117233 		var fd uintptr
 117234 		Xsqlite3BtreeEnter(tls, pBtree)
 117235 		pPager = Xsqlite3BtreePager(tls, pBtree)
 117236 
 117237 		fd = Xsqlite3PagerFile(tls, pPager)
 117238 
 117239 		if op == SQLITE_FCNTL_FILE_POINTER {
 117240 			*(*uintptr)(unsafe.Pointer(pArg)) = fd
 117241 			rc = SQLITE_OK
 117242 		} else if op == SQLITE_FCNTL_VFS_POINTER {
 117243 			*(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3PagerVfs(tls, pPager)
 117244 			rc = SQLITE_OK
 117245 		} else if op == SQLITE_FCNTL_JOURNAL_POINTER {
 117246 			*(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3PagerJrnlFile(tls, pPager)
 117247 			rc = SQLITE_OK
 117248 		} else if op == SQLITE_FCNTL_DATA_VERSION {
 117249 			*(*uint32)(unsafe.Pointer(pArg)) = Xsqlite3PagerDataVersion(tls, pPager)
 117250 			rc = SQLITE_OK
 117251 		} else if op == SQLITE_FCNTL_RESERVE_BYTES {
 117252 			var iNew int32 = *(*int32)(unsafe.Pointer(pArg))
 117253 			*(*int32)(unsafe.Pointer(pArg)) = Xsqlite3BtreeGetRequestedReserve(tls, pBtree)
 117254 			if iNew >= 0 && iNew <= 255 {
 117255 				Xsqlite3BtreeSetPageSize(tls, pBtree, 0, iNew, 0)
 117256 			}
 117257 			rc = SQLITE_OK
 117258 		} else if op == SQLITE_FCNTL_RESET_CACHE {
 117259 			Xsqlite3BtreeClearCache(tls, pBtree)
 117260 			rc = SQLITE_OK
 117261 		} else {
 117262 			var nSave int32 = (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy
 117263 			rc = Xsqlite3OsFileControl(tls, fd, op, pArg)
 117264 			(*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = nSave
 117265 		}
 117266 		Xsqlite3BtreeLeave(tls, pBtree)
 117267 	}
 117268 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117269 	return rc
 117270 }
 117271 
 117272 // Interface to the testing logic.
 117273 func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 {
 117274 	var rc int32 = 0
 117275 	var ap Va_list
 117276 	_ = ap
 117277 	ap = va
 117278 	switch op {
 117279 	case SQLITE_TESTCTRL_PRNG_SAVE:
 117280 		{
 117281 			Xsqlite3PrngSaveState(tls)
 117282 			break
 117283 
 117284 		}
 117285 
 117286 	case SQLITE_TESTCTRL_PRNG_RESTORE:
 117287 		{
 117288 			Xsqlite3PrngRestoreState(tls)
 117289 			break
 117290 
 117291 		}
 117292 
 117293 	case SQLITE_TESTCTRL_PRNG_SEED:
 117294 		{
 117295 			var x int32 = libc.VaInt32(&ap)
 117296 			var y int32
 117297 			var db uintptr = libc.VaUintptr(&ap)
 117298 
 117299 			if db != 0 && libc.AssignInt32(&y, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fschema_cookie) != 0 {
 117300 				x = y
 117301 			}
 117302 			Xsqlite3Config.FiPrngSeed = uint32(x)
 117303 			Xsqlite3_randomness(tls, 0, uintptr(0))
 117304 			break
 117305 
 117306 		}
 117307 
 117308 	case SQLITE_TESTCTRL_BITVEC_TEST:
 117309 		{
 117310 			var sz int32 = libc.VaInt32(&ap)
 117311 			var aProg uintptr = libc.VaUintptr(&ap)
 117312 			rc = Xsqlite3BitvecBuiltinTest(tls, sz, aProg)
 117313 			break
 117314 
 117315 		}
 117316 
 117317 	case SQLITE_TESTCTRL_FAULT_INSTALL:
 117318 		{
 117319 			Xsqlite3Config.FxTestCallback = libc.VaUintptr(&ap)
 117320 			rc = Xsqlite3FaultSim(tls, 0)
 117321 			break
 117322 
 117323 		}
 117324 
 117325 	case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
 117326 		{
 117327 			var xBenignBegin uintptr
 117328 			var xBenignEnd uintptr
 117329 			xBenignBegin = libc.VaUintptr(&ap)
 117330 			xBenignEnd = libc.VaUintptr(&ap)
 117331 			Xsqlite3BenignMallocHooks(tls, xBenignBegin, xBenignEnd)
 117332 			break
 117333 
 117334 		}
 117335 
 117336 	case SQLITE_TESTCTRL_PENDING_BYTE:
 117337 		{
 117338 			rc = Xsqlite3PendingByte
 117339 			{
 117340 				var newVal uint32 = libc.VaUint32(&ap)
 117341 				if newVal != 0 {
 117342 					Xsqlite3PendingByte = int32(newVal)
 117343 				}
 117344 
 117345 			}
 117346 			break
 117347 
 117348 		}
 117349 
 117350 	case SQLITE_TESTCTRL_ASSERT:
 117351 		{
 117352 			var x int32 = 0
 117353 
 117354 			rc = x
 117355 			break
 117356 
 117357 		}
 117358 
 117359 	case SQLITE_TESTCTRL_ALWAYS:
 117360 		{
 117361 			var x int32 = libc.VaInt32(&ap)
 117362 			if x != 0 {
 117363 				rc = x
 117364 			} else {
 117365 				rc = 0
 117366 			}
 117367 			break
 117368 
 117369 		}
 117370 
 117371 	case SQLITE_TESTCTRL_BYTEORDER:
 117372 		{
 117373 			rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN
 117374 			break
 117375 
 117376 		}
 117377 
 117378 	case SQLITE_TESTCTRL_OPTIMIZATIONS:
 117379 		{
 117380 			var db uintptr = libc.VaUintptr(&ap)
 117381 			(*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags = libc.VaUint32(&ap)
 117382 			break
 117383 
 117384 		}
 117385 
 117386 	case SQLITE_TESTCTRL_LOCALTIME_FAULT:
 117387 		{
 117388 			Xsqlite3Config.FbLocaltimeFault = libc.VaInt32(&ap)
 117389 			if Xsqlite3Config.FbLocaltimeFault == 2 {
 117390 				Xsqlite3Config.FxAltLocaltime = libc.VaUintptr(&ap)
 117391 			} else {
 117392 				Xsqlite3Config.FxAltLocaltime = uintptr(0)
 117393 			}
 117394 			break
 117395 
 117396 		}
 117397 
 117398 	case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
 117399 		{
 117400 			var db uintptr = libc.VaUintptr(&ap)
 117401 			*(*U32)(unsafe.Pointer(db + 24)) ^= U32(DBFLAG_InternalFunc)
 117402 			break
 117403 
 117404 		}
 117405 
 117406 	case SQLITE_TESTCTRL_NEVER_CORRUPT:
 117407 		{
 117408 			Xsqlite3Config.FneverCorrupt = libc.VaInt32(&ap)
 117409 			break
 117410 
 117411 		}
 117412 
 117413 	case SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS:
 117414 		{
 117415 			Xsqlite3Config.FbExtraSchemaChecks = U8(libc.VaInt32(&ap))
 117416 			break
 117417 
 117418 		}
 117419 
 117420 	case SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD:
 117421 		{
 117422 			Xsqlite3Config.FiOnceResetThreshold = libc.VaInt32(&ap)
 117423 			break
 117424 
 117425 		}
 117426 
 117427 	case SQLITE_TESTCTRL_VDBE_COVERAGE:
 117428 		{
 117429 			break
 117430 
 117431 		}
 117432 
 117433 	case SQLITE_TESTCTRL_SORTER_MMAP:
 117434 		{
 117435 			var db uintptr = libc.VaUintptr(&ap)
 117436 			(*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap = libc.VaInt32(&ap)
 117437 			break
 117438 
 117439 		}
 117440 
 117441 	case SQLITE_TESTCTRL_ISINIT:
 117442 		{
 117443 			if Xsqlite3Config.FisInit == 0 {
 117444 				rc = SQLITE_ERROR
 117445 			}
 117446 			break
 117447 
 117448 		}
 117449 
 117450 	case SQLITE_TESTCTRL_IMPOSTER:
 117451 		{
 117452 			var db uintptr = libc.VaUintptr(&ap)
 117453 			var iDb int32
 117454 			Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117455 			iDb = Xsqlite3FindDbName(tls, db, libc.VaUintptr(&ap))
 117456 			if iDb >= 0 {
 117457 				(*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(iDb)
 117458 				(*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(libc.AssignBitFieldPtr8Uint32(db+172+8, uint32(libc.VaInt32(&ap)), 1, 1, 0x2))
 117459 				(*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum = Pgno(libc.VaInt32(&ap))
 117460 				if int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0 && (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum > Pgno(0) {
 117461 					Xsqlite3ResetAllSchemasOfConnection(tls, db)
 117462 				}
 117463 			}
 117464 			Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117465 			break
 117466 
 117467 		}
 117468 
 117469 	case SQLITE_TESTCTRL_RESULT_INTREAL:
 117470 		{
 117471 			var pCtx uintptr = libc.VaUintptr(&ap)
 117472 			Xsqlite3ResultIntReal(tls, pCtx)
 117473 			break
 117474 
 117475 		}
 117476 
 117477 	case SQLITE_TESTCTRL_SEEK_COUNT:
 117478 		{
 117479 			var db uintptr = libc.VaUintptr(&ap)
 117480 			_ = db
 117481 			var pn uintptr = libc.VaUintptr(&ap)
 117482 			*(*U64)(unsafe.Pointer(pn)) = uint64(0)
 117483 			_ = db
 117484 			break
 117485 
 117486 		}
 117487 
 117488 	case SQLITE_TESTCTRL_TRACEFLAGS:
 117489 		{
 117490 			var opTrace int32 = libc.VaInt32(&ap)
 117491 			var ptr uintptr = libc.VaUintptr(&ap)
 117492 			switch opTrace {
 117493 			case 0:
 117494 				*(*U32)(unsafe.Pointer(ptr)) = Xsqlite3TreeTrace
 117495 				break
 117496 			case 1:
 117497 				Xsqlite3TreeTrace = *(*U32)(unsafe.Pointer(ptr))
 117498 				break
 117499 			case 2:
 117500 				*(*U32)(unsafe.Pointer(ptr)) = Xsqlite3WhereTrace
 117501 				break
 117502 			case 3:
 117503 				Xsqlite3WhereTrace = *(*U32)(unsafe.Pointer(ptr))
 117504 				break
 117505 			}
 117506 			break
 117507 
 117508 		}
 117509 
 117510 	case SQLITE_TESTCTRL_LOGEST:
 117511 		{
 117512 			var rIn float64 = libc.VaFloat64(&ap)
 117513 			var rLogEst LogEst = Xsqlite3LogEstFromDouble(tls, rIn)
 117514 			var pI1 uintptr = libc.VaUintptr(&ap)
 117515 			var pU64 uintptr = libc.VaUintptr(&ap)
 117516 			var pI2 uintptr = libc.VaUintptr(&ap)
 117517 			*(*int32)(unsafe.Pointer(pI1)) = int32(rLogEst)
 117518 			*(*U64)(unsafe.Pointer(pU64)) = Xsqlite3LogEstToInt(tls, rLogEst)
 117519 			*(*int32)(unsafe.Pointer(pI2)) = int32(Xsqlite3LogEst(tls, *(*U64)(unsafe.Pointer(pU64))))
 117520 			break
 117521 
 117522 		}
 117523 
 117524 	}
 117525 	_ = ap
 117526 	return rc
 117527 }
 117528 
 117529 func databaseName(tls *libc.TLS, zName uintptr) uintptr {
 117530 	for int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-1)))) != 0 || int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-2)))) != 0 || int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-3)))) != 0 || int32(*(*uint8)(unsafe.Pointer(zName + libc.UintptrFromInt32(-4)))) != 0 {
 117531 		zName--
 117532 	}
 117533 	return zName
 117534 }
 117535 
 117536 func appendText(tls *libc.TLS, p uintptr, z uintptr) uintptr {
 117537 	var n Size_t = libc.Xstrlen(tls, z)
 117538 	libc.Xmemcpy(tls, p, z, n+Size_t(1))
 117539 	return p + uintptr(n) + uintptr(1)
 117540 }
 117541 
 117542 // Allocate memory to hold names for a database, journal file, WAL file,
 117543 // and query parameters.  The pointer returned is valid for use by
 117544 // sqlite3_filename_database() and sqlite3_uri_parameter() and related
 117545 // functions.
 117546 //
 117547 // Memory layout must be compatible with that generated by the pager
 117548 // and expected by sqlite3_uri_parameter() and databaseName().
 117549 func Xsqlite3_create_filename(tls *libc.TLS, zDatabase uintptr, zJournal uintptr, zWal uintptr, nParam int32, azParam uintptr) uintptr {
 117550 	var nByte Sqlite3_int64
 117551 	var i int32
 117552 	var pResult uintptr
 117553 	var p uintptr
 117554 	nByte = Sqlite3_int64(libc.Xstrlen(tls, zDatabase) + libc.Xstrlen(tls, zJournal) + libc.Xstrlen(tls, zWal) + Size_t(10))
 117555 	for i = 0; i < nParam*2; i++ {
 117556 		nByte = nByte + Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(azParam + uintptr(i)*4)))+Size_t(1))
 117557 	}
 117558 	pResult = libc.AssignUintptr(&p, Xsqlite3_malloc64(tls, uint64(nByte)))
 117559 	if p == uintptr(0) {
 117560 		return uintptr(0)
 117561 	}
 117562 	libc.Xmemset(tls, p, 0, uint32(4))
 117563 	p += uintptr(4)
 117564 	p = appendText(tls, p, zDatabase)
 117565 	for i = 0; i < nParam*2; i++ {
 117566 		p = appendText(tls, p, *(*uintptr)(unsafe.Pointer(azParam + uintptr(i)*4)))
 117567 	}
 117568 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))) = uint8(0)
 117569 	p = appendText(tls, p, zJournal)
 117570 	p = appendText(tls, p, zWal)
 117571 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))) = uint8(0)
 117572 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))) = uint8(0)
 117573 
 117574 	return pResult + uintptr(4)
 117575 }
 117576 
 117577 // Free memory obtained from sqlite3_create_filename().  It is a severe
 117578 // error to call this routine with any parameter other than a pointer
 117579 // previously obtained from sqlite3_create_filename() or a NULL pointer.
 117580 func Xsqlite3_free_filename(tls *libc.TLS, p uintptr) {
 117581 	if p == uintptr(0) {
 117582 		return
 117583 	}
 117584 	p = databaseName(tls, p)
 117585 	Xsqlite3_free(tls, p-uintptr(4))
 117586 }
 117587 
 117588 // This is a utility routine, useful to VFS implementations, that checks
 117589 // to see if a database file was a URI that contained a specific query
 117590 // parameter, and if so obtains the value of the query parameter.
 117591 //
 117592 // The zFilename argument is the filename pointer passed into the xOpen()
 117593 // method of a VFS implementation.  The zParam argument is the name of the
 117594 // query parameter we seek.  This routine returns the value of the zParam
 117595 // parameter if it exists.  If the parameter does not exist, this routine
 117596 // returns a NULL pointer.
 117597 func Xsqlite3_uri_parameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) uintptr {
 117598 	if zFilename == uintptr(0) || zParam == uintptr(0) {
 117599 		return uintptr(0)
 117600 	}
 117601 	zFilename = databaseName(tls, zFilename)
 117602 	return uriParameter(tls, zFilename, zParam)
 117603 }
 117604 
 117605 // Return a pointer to the name of Nth query parameter of the filename.
 117606 func Xsqlite3_uri_key(tls *libc.TLS, zFilename uintptr, N int32) uintptr {
 117607 	if zFilename == uintptr(0) || N < 0 {
 117608 		return uintptr(0)
 117609 	}
 117610 	zFilename = databaseName(tls, zFilename)
 117611 	zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117612 	for zFilename != 0 && *(*uint8)(unsafe.Pointer(zFilename)) != 0 && libc.PostDecInt32(&N, 1) > 0 {
 117613 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117614 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117615 	}
 117616 	if *(*uint8)(unsafe.Pointer(zFilename)) != 0 {
 117617 		return zFilename
 117618 	}
 117619 	return uintptr(0)
 117620 }
 117621 
 117622 // Return a boolean value for a query parameter.
 117623 func Xsqlite3_uri_boolean(tls *libc.TLS, zFilename uintptr, zParam uintptr, bDflt int32) int32 {
 117624 	var z uintptr = Xsqlite3_uri_parameter(tls, zFilename, zParam)
 117625 	bDflt = libc.Bool32(bDflt != 0)
 117626 	if z != 0 {
 117627 		return int32(Xsqlite3GetBoolean(tls, z, uint8(bDflt)))
 117628 	}
 117629 	return bDflt
 117630 }
 117631 
 117632 // Return a 64-bit integer value for a query parameter.
 117633 func Xsqlite3_uri_int64(tls *libc.TLS, zFilename uintptr, zParam uintptr, bDflt Sqlite3_int64) Sqlite3_int64 {
 117634 	bp := tls.Alloc(8)
 117635 	defer tls.Free(8)
 117636 
 117637 	var z uintptr = Xsqlite3_uri_parameter(tls, zFilename, zParam)
 117638 
 117639 	if z != 0 && Xsqlite3DecOrHexToI64(tls, z, bp) == 0 {
 117640 		bDflt = *(*Sqlite3_int64)(unsafe.Pointer(bp))
 117641 	}
 117642 	return bDflt
 117643 }
 117644 
 117645 // Translate a filename that was handed to a VFS routine into the corresponding
 117646 // database, journal, or WAL file.
 117647 //
 117648 // It is an error to pass this routine a filename string that was not
 117649 // passed into the VFS from the SQLite core.  Doing so is similar to
 117650 // passing free() a pointer that was not obtained from malloc() - it is
 117651 // an error that we cannot easily detect but that will likely cause memory
 117652 // corruption.
 117653 func Xsqlite3_filename_database(tls *libc.TLS, zFilename uintptr) uintptr {
 117654 	if zFilename == uintptr(0) {
 117655 		return uintptr(0)
 117656 	}
 117657 	return databaseName(tls, zFilename)
 117658 }
 117659 
 117660 func Xsqlite3_filename_journal(tls *libc.TLS, zFilename uintptr) uintptr {
 117661 	if zFilename == uintptr(0) {
 117662 		return uintptr(0)
 117663 	}
 117664 	zFilename = databaseName(tls, zFilename)
 117665 	zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117666 	for zFilename != 0 && *(*uint8)(unsafe.Pointer(zFilename)) != 0 {
 117667 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117668 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117669 	}
 117670 	return zFilename + uintptr(1)
 117671 }
 117672 
 117673 func Xsqlite3_filename_wal(tls *libc.TLS, zFilename uintptr) uintptr {
 117674 	zFilename = Xsqlite3_filename_journal(tls, zFilename)
 117675 	if zFilename != 0 {
 117676 		zFilename += uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)
 117677 	}
 117678 	return zFilename
 117679 }
 117680 
 117681 // Return the Btree pointer identified by zDbName.  Return NULL if not found.
 117682 func Xsqlite3DbNameToBtree(tls *libc.TLS, db uintptr, zDbName uintptr) uintptr {
 117683 	var iDb int32
 117684 	if zDbName != 0 {
 117685 		iDb = Xsqlite3FindDbName(tls, db, zDbName)
 117686 	} else {
 117687 		iDb = 0
 117688 	}
 117689 	if iDb < 0 {
 117690 		return uintptr(0)
 117691 	}
 117692 	return (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
 117693 }
 117694 
 117695 // Return the name of the N-th database schema.  Return NULL if N is out
 117696 // of range.
 117697 func Xsqlite3_db_name(tls *libc.TLS, db uintptr, N int32) uintptr {
 117698 	if N < 0 || N >= (*Sqlite3)(unsafe.Pointer(db)).FnDb {
 117699 		return uintptr(0)
 117700 	} else {
 117701 		return (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(N)*16)).FzDbSName
 117702 	}
 117703 	return uintptr(0)
 117704 }
 117705 
 117706 // Return the filename of the database associated with a database
 117707 // connection.
 117708 func Xsqlite3_db_filename(tls *libc.TLS, db uintptr, zDbName uintptr) uintptr {
 117709 	var pBt uintptr
 117710 	pBt = Xsqlite3DbNameToBtree(tls, db, zDbName)
 117711 	if pBt != 0 {
 117712 		return Xsqlite3BtreeGetFilename(tls, pBt)
 117713 	}
 117714 	return uintptr(0)
 117715 }
 117716 
 117717 // Return 1 if database is read-only or 0 if read/write.  Return -1 if
 117718 // no such database exists.
 117719 func Xsqlite3_db_readonly(tls *libc.TLS, db uintptr, zDbName uintptr) int32 {
 117720 	var pBt uintptr
 117721 	pBt = Xsqlite3DbNameToBtree(tls, db, zDbName)
 117722 	if pBt != 0 {
 117723 		return Xsqlite3BtreeIsReadonly(tls, pBt)
 117724 	}
 117725 	return -1
 117726 }
 117727 
 117728 // Obtain a snapshot handle for the snapshot of database zDb currently
 117729 // being read by handle db.
 117730 func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot uintptr) int32 {
 117731 	var rc int32 = SQLITE_ERROR
 117732 
 117733 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117734 
 117735 	if int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 {
 117736 		var iDb int32 = Xsqlite3FindDbName(tls, db, zDb)
 117737 		if iDb == 0 || iDb > 1 {
 117738 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
 117739 			if SQLITE_TXN_WRITE != Xsqlite3BtreeTxnState(tls, pBt) {
 117740 				rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0))
 117741 				if rc == SQLITE_OK {
 117742 					rc = Xsqlite3PagerSnapshotGet(tls, Xsqlite3BtreePager(tls, pBt), ppSnapshot)
 117743 				}
 117744 			}
 117745 		}
 117746 	}
 117747 
 117748 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117749 	return rc
 117750 }
 117751 
 117752 // Open a read-transaction on the snapshot idendified by pSnapshot.
 117753 func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot uintptr) int32 {
 117754 	var rc int32 = SQLITE_ERROR
 117755 
 117756 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117757 	if int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 {
 117758 		var iDb int32
 117759 		iDb = Xsqlite3FindDbName(tls, db, zDb)
 117760 		if iDb == 0 || iDb > 1 {
 117761 			var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
 117762 			if Xsqlite3BtreeTxnState(tls, pBt) != SQLITE_TXN_WRITE {
 117763 				var pPager uintptr = Xsqlite3BtreePager(tls, pBt)
 117764 				var bUnlock int32 = 0
 117765 				if Xsqlite3BtreeTxnState(tls, pBt) != SQLITE_TXN_NONE {
 117766 					if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 {
 117767 						rc = Xsqlite3PagerSnapshotCheck(tls, pPager, pSnapshot)
 117768 						if rc == SQLITE_OK {
 117769 							bUnlock = 1
 117770 							rc = Xsqlite3BtreeCommit(tls, pBt)
 117771 						}
 117772 					}
 117773 				} else {
 117774 					rc = SQLITE_OK
 117775 				}
 117776 				if rc == SQLITE_OK {
 117777 					rc = Xsqlite3PagerSnapshotOpen(tls, pPager, pSnapshot)
 117778 				}
 117779 				if rc == SQLITE_OK {
 117780 					rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0))
 117781 					Xsqlite3PagerSnapshotOpen(tls, pPager, uintptr(0))
 117782 				}
 117783 				if bUnlock != 0 {
 117784 					Xsqlite3PagerSnapshotUnlock(tls, pPager)
 117785 				}
 117786 			}
 117787 		}
 117788 	}
 117789 
 117790 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117791 	return rc
 117792 }
 117793 
 117794 // Recover as many snapshots as possible from the wal file associated with
 117795 // schema zDb of database db.
 117796 func Xsqlite3_snapshot_recover(tls *libc.TLS, db uintptr, zDb uintptr) int32 {
 117797 	var rc int32 = SQLITE_ERROR
 117798 	var iDb int32
 117799 
 117800 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117801 	iDb = Xsqlite3FindDbName(tls, db, zDb)
 117802 	if iDb == 0 || iDb > 1 {
 117803 		var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*16)).FpBt
 117804 		if SQLITE_TXN_NONE == Xsqlite3BtreeTxnState(tls, pBt) {
 117805 			rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0))
 117806 			if rc == SQLITE_OK {
 117807 				rc = Xsqlite3PagerSnapshotRecover(tls, Xsqlite3BtreePager(tls, pBt))
 117808 				Xsqlite3BtreeCommit(tls, pBt)
 117809 			}
 117810 		}
 117811 	}
 117812 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117813 	return rc
 117814 }
 117815 
 117816 // Free a snapshot handle obtained from sqlite3_snapshot_get().
 117817 func Xsqlite3_snapshot_free(tls *libc.TLS, pSnapshot uintptr) {
 117818 	Xsqlite3_free(tls, pSnapshot)
 117819 }
 117820 
 117821 // Given the name of a compile-time option, return true if that option
 117822 // was used and false if not.
 117823 //
 117824 // The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
 117825 // is not required for a match.
 117826 func Xsqlite3_compileoption_used(tls *libc.TLS, zOptName uintptr) int32 {
 117827 	bp := tls.Alloc(4)
 117828 	defer tls.Free(4)
 117829 
 117830 	var i int32
 117831 	var n int32
 117832 
 117833 	var azCompileOpt uintptr
 117834 
 117835 	azCompileOpt = Xsqlite3CompileOptions(tls, bp)
 117836 
 117837 	if Xsqlite3_strnicmp(tls, zOptName, ts+24503, 7) == 0 {
 117838 		zOptName += uintptr(7)
 117839 	}
 117840 	n = Xsqlite3Strlen30(tls, zOptName)
 117841 
 117842 	for i = 0; i < *(*int32)(unsafe.Pointer(bp)); i++ {
 117843 		if Xsqlite3_strnicmp(tls, zOptName, *(*uintptr)(unsafe.Pointer(azCompileOpt + uintptr(i)*4)), n) == 0 &&
 117844 			Xsqlite3IsIdChar(tls, *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(azCompileOpt + uintptr(i)*4)) + uintptr(n)))) == 0 {
 117845 			return 1
 117846 		}
 117847 	}
 117848 	return 0
 117849 }
 117850 
 117851 // Return the N-th compile-time option string.  If N is out of range,
 117852 // return a NULL pointer.
 117853 func Xsqlite3_compileoption_get(tls *libc.TLS, N int32) uintptr {
 117854 	bp := tls.Alloc(4)
 117855 	defer tls.Free(4)
 117856 
 117857 	var azCompileOpt uintptr
 117858 	azCompileOpt = Xsqlite3CompileOptions(tls, bp)
 117859 	if N >= 0 && N < *(*int32)(unsafe.Pointer(bp)) {
 117860 		return *(*uintptr)(unsafe.Pointer(azCompileOpt + uintptr(N)*4))
 117861 	}
 117862 	return uintptr(0)
 117863 }
 117864 
 117865 var sqlite3BlockedList uintptr = uintptr(0)
 117866 
 117867 func removeFromBlockedList(tls *libc.TLS, db uintptr) {
 117868 	var pp uintptr
 117869 
 117870 	for pp = uintptr(unsafe.Pointer(&sqlite3BlockedList)); *(*uintptr)(unsafe.Pointer(pp)) != 0; pp = *(*uintptr)(unsafe.Pointer(pp)) + 564 {
 117871 		if *(*uintptr)(unsafe.Pointer(pp)) == db {
 117872 			*(*uintptr)(unsafe.Pointer(pp)) = (*Sqlite3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNextBlocked
 117873 			break
 117874 		}
 117875 	}
 117876 }
 117877 
 117878 func addToBlockedList(tls *libc.TLS, db uintptr) {
 117879 	var pp uintptr
 117880 
 117881 	for pp = uintptr(unsafe.Pointer(&sqlite3BlockedList)); *(*uintptr)(unsafe.Pointer(pp)) != 0 && (*Sqlite3)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FxUnlockNotify != (*Sqlite3)(unsafe.Pointer(db)).FxUnlockNotify; pp = *(*uintptr)(unsafe.Pointer(pp)) + 564 {
 117882 	}
 117883 	(*Sqlite3)(unsafe.Pointer(db)).FpNextBlocked = *(*uintptr)(unsafe.Pointer(pp))
 117884 	*(*uintptr)(unsafe.Pointer(pp)) = db
 117885 }
 117886 
 117887 func enterMutex(tls *libc.TLS) {
 117888 	Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN))
 117889 
 117890 }
 117891 
 117892 func leaveMutex(tls *libc.TLS) {
 117893 	Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN))
 117894 }
 117895 
 117896 // Register an unlock-notify callback.
 117897 //
 117898 // This is called after connection "db" has attempted some operation
 117899 // but has received an SQLITE_LOCKED error because another connection
 117900 // (call it pOther) in the same process was busy using the same shared
 117901 // cache.  pOther is found by looking at db->pBlockingConnection.
 117902 //
 117903 // If there is no blocking connection, the callback is invoked immediately,
 117904 // before this routine returns.
 117905 //
 117906 // If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate
 117907 // a deadlock.
 117908 //
 117909 // Otherwise, make arrangements to invoke xNotify when pOther drops
 117910 // its locks.
 117911 //
 117912 // Each call to this routine overrides any prior callbacks registered
 117913 // on the same "db".  If xNotify==0 then any prior callbacks are immediately
 117914 // cancelled.
 117915 func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, xNotify uintptr, pArg uintptr) int32 {
 117916 	bp := tls.Alloc(4)
 117917 	defer tls.Free(4)
 117918 	*(*uintptr)(unsafe.Pointer(bp)) = pArg
 117919 
 117920 	var rc int32 = SQLITE_OK
 117921 
 117922 	Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117923 	enterMutex(tls)
 117924 
 117925 	if xNotify == uintptr(0) {
 117926 		removeFromBlockedList(tls, db)
 117927 		(*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection = uintptr(0)
 117928 		(*Sqlite3)(unsafe.Pointer(db)).FpUnlockConnection = uintptr(0)
 117929 		(*Sqlite3)(unsafe.Pointer(db)).FxUnlockNotify = uintptr(0)
 117930 		(*Sqlite3)(unsafe.Pointer(db)).FpUnlockArg = uintptr(0)
 117931 	} else if uintptr(0) == (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection {
 117932 		(*struct {
 117933 			f func(*libc.TLS, uintptr, int32)
 117934 		})(unsafe.Pointer(&struct{ uintptr }{xNotify})).f(tls, bp, 1)
 117935 	} else {
 117936 		var p uintptr
 117937 
 117938 		for p = (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection; p != 0 && p != db; p = (*Sqlite3)(unsafe.Pointer(p)).FpUnlockConnection {
 117939 		}
 117940 		if p != 0 {
 117941 			rc = SQLITE_LOCKED
 117942 		} else {
 117943 			(*Sqlite3)(unsafe.Pointer(db)).FpUnlockConnection = (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection
 117944 			(*Sqlite3)(unsafe.Pointer(db)).FxUnlockNotify = xNotify
 117945 			(*Sqlite3)(unsafe.Pointer(db)).FpUnlockArg = *(*uintptr)(unsafe.Pointer(bp))
 117946 			removeFromBlockedList(tls, db)
 117947 			addToBlockedList(tls, db)
 117948 		}
 117949 	}
 117950 
 117951 	leaveMutex(tls)
 117952 
 117953 	Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr {
 117954 		if rc != 0 {
 117955 			return ts + 24511
 117956 		}
 117957 		return uintptr(0)
 117958 	}(), 0)
 117959 	Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex)
 117960 	return rc
 117961 }
 117962 
 117963 // This function is called while stepping or preparing a statement
 117964 // associated with connection db. The operation will return SQLITE_LOCKED
 117965 // to the user because it requires a lock that will not be available
 117966 // until connection pBlocker concludes its current transaction.
 117967 func Xsqlite3ConnectionBlocked(tls *libc.TLS, db uintptr, pBlocker uintptr) {
 117968 	enterMutex(tls)
 117969 	if (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection == uintptr(0) && (*Sqlite3)(unsafe.Pointer(db)).FpUnlockConnection == uintptr(0) {
 117970 		addToBlockedList(tls, db)
 117971 	}
 117972 	(*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection = pBlocker
 117973 	leaveMutex(tls)
 117974 }
 117975 
 117976 // This function is called when
 117977 // the transaction opened by database db has just finished. Locks held
 117978 // by database connection db have been released.
 117979 //
 117980 // This function loops through each entry in the blocked connections
 117981 // list and does the following:
 117982 //
 117983 //  1. If the sqlite3.pBlockingConnection member of a list entry is
 117984 //     set to db, then set pBlockingConnection=0.
 117985 //
 117986 //  2. If the sqlite3.pUnlockConnection member of a list entry is
 117987 //     set to db, then invoke the configured unlock-notify callback and
 117988 //     set pUnlockConnection=0.
 117989 //
 117990 //  3. If the two steps above mean that pBlockingConnection==0 and
 117991 //     pUnlockConnection==0, remove the entry from the blocked connections
 117992 //     list.
 117993 func Xsqlite3ConnectionUnlocked(tls *libc.TLS, db uintptr) {
 117994 	bp := tls.Alloc(64)
 117995 	defer tls.Free(64)
 117996 
 117997 	var xUnlockNotify uintptr = uintptr(0)
 117998 	var nArg int32 = 0
 117999 	var pp uintptr
 118000 	var aArg uintptr
 118001 	var aDyn uintptr = uintptr(0)
 118002 
 118003 	aArg = bp
 118004 	enterMutex(tls)
 118005 
 118006 	for pp = uintptr(unsafe.Pointer(&sqlite3BlockedList)); *(*uintptr)(unsafe.Pointer(pp)) != 0; {
 118007 		var p uintptr = *(*uintptr)(unsafe.Pointer(pp))
 118008 
 118009 		if (*Sqlite3)(unsafe.Pointer(p)).FpBlockingConnection == db {
 118010 			(*Sqlite3)(unsafe.Pointer(p)).FpBlockingConnection = uintptr(0)
 118011 		}
 118012 
 118013 		if (*Sqlite3)(unsafe.Pointer(p)).FpUnlockConnection == db {
 118014 			if (*Sqlite3)(unsafe.Pointer(p)).FxUnlockNotify != xUnlockNotify && nArg != 0 {
 118015 				(*struct {
 118016 					f func(*libc.TLS, uintptr, int32)
 118017 				})(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})).f(tls, aArg, nArg)
 118018 				nArg = 0
 118019 			}
 118020 
 118021 			Xsqlite3BeginBenignMalloc(tls)
 118022 
 118023 			if !(aDyn != 0) && nArg == int32(uint32(unsafe.Sizeof([16]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))) ||
 118024 				aDyn != 0 && nArg == int32(uint32(Xsqlite3MallocSize(tls, aDyn))/uint32(unsafe.Sizeof(uintptr(0)))) {
 118025 				var pNew uintptr = Xsqlite3Malloc(tls, uint64(uint32(nArg)*uint32(unsafe.Sizeof(uintptr(0)))*uint32(2)))
 118026 				if pNew != 0 {
 118027 					libc.Xmemcpy(tls, pNew, aArg, uint32(nArg)*uint32(unsafe.Sizeof(uintptr(0))))
 118028 					Xsqlite3_free(tls, aDyn)
 118029 					aDyn = libc.AssignUintptr(&aArg, pNew)
 118030 				} else {
 118031 					(*struct {
 118032 						f func(*libc.TLS, uintptr, int32)
 118033 					})(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})).f(tls, aArg, nArg)
 118034 					nArg = 0
 118035 				}
 118036 			}
 118037 			Xsqlite3EndBenignMalloc(tls)
 118038 
 118039 			*(*uintptr)(unsafe.Pointer(aArg + uintptr(libc.PostIncInt32(&nArg, 1))*4)) = (*Sqlite3)(unsafe.Pointer(p)).FpUnlockArg
 118040 			xUnlockNotify = (*Sqlite3)(unsafe.Pointer(p)).FxUnlockNotify
 118041 			(*Sqlite3)(unsafe.Pointer(p)).FpUnlockConnection = uintptr(0)
 118042 			(*Sqlite3)(unsafe.Pointer(p)).FxUnlockNotify = uintptr(0)
 118043 			(*Sqlite3)(unsafe.Pointer(p)).FpUnlockArg = uintptr(0)
 118044 		}
 118045 
 118046 		if (*Sqlite3)(unsafe.Pointer(p)).FpBlockingConnection == uintptr(0) && (*Sqlite3)(unsafe.Pointer(p)).FpUnlockConnection == uintptr(0) {
 118047 			*(*uintptr)(unsafe.Pointer(pp)) = (*Sqlite3)(unsafe.Pointer(p)).FpNextBlocked
 118048 			(*Sqlite3)(unsafe.Pointer(p)).FpNextBlocked = uintptr(0)
 118049 		} else {
 118050 			pp = p + 564
 118051 		}
 118052 	}
 118053 
 118054 	if nArg != 0 {
 118055 		(*struct {
 118056 			f func(*libc.TLS, uintptr, int32)
 118057 		})(unsafe.Pointer(&struct{ uintptr }{xUnlockNotify})).f(tls, aArg, nArg)
 118058 	}
 118059 	Xsqlite3_free(tls, aDyn)
 118060 	leaveMutex(tls)
 118061 }
 118062 
 118063 // This is called when the database connection passed as an argument is
 118064 // being closed. The connection is removed from the blocked list.
 118065 func Xsqlite3ConnectionClosed(tls *libc.TLS, db uintptr) {
 118066 	Xsqlite3ConnectionUnlocked(tls, db)
 118067 	enterMutex(tls)
 118068 	removeFromBlockedList(tls, db)
 118069 
 118070 	leaveMutex(tls)
 118071 }
 118072 
 118073 var jsonIsSpace = [256]uint8{
 118074 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(1), uint8(1), uint8(0), uint8(0), uint8(1), uint8(0), uint8(0),
 118075 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118076 	uint8(1), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118077 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118078 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118079 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118080 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118081 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118082 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118083 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118084 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118085 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118086 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118087 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118088 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118089 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118090 }
 118091 
 118092 // Objects
 118093 type JsonString1 = struct {
 118094 	FpCtx        uintptr
 118095 	FzBuf        uintptr
 118096 	FnAlloc      U64
 118097 	FnUsed       U64
 118098 	FbStatic     U8
 118099 	FbErr        U8
 118100 	FzSpace      [100]uint8
 118101 	F__ccgo_pad1 [2]byte
 118102 }
 118103 
 118104 // Objects
 118105 type JsonString = JsonString1
 118106 type JsonNode1 = struct {
 118107 	FeType       U8
 118108 	FjnFlags     U8
 118109 	FeU          U8
 118110 	F__ccgo_pad1 [1]byte
 118111 	Fn           U32
 118112 	Fu           struct{ FzJContent uintptr }
 118113 }
 118114 
 118115 type JsonNode = JsonNode1
 118116 type JsonParse1 = struct {
 118117 	FnNode  U32
 118118 	FnAlloc U32
 118119 	FaNode  uintptr
 118120 	FzJson  uintptr
 118121 	FaUp    uintptr
 118122 	Foom    U8
 118123 	FnErr   U8
 118124 	FiDepth U16
 118125 	FnJson  int32
 118126 	FiHold  U32
 118127 }
 118128 
 118129 type JsonParse = JsonParse1
 118130 
 118131 var jsonType = [8]uintptr{
 118132 	ts + 6181, ts + 7694, ts + 7699, ts + 6191, ts + 6186, ts + 8005, ts + 24534, ts + 24540,
 118133 }
 118134 
 118135 func jsonZero(tls *libc.TLS, p uintptr) {
 118136 	(*JsonString)(unsafe.Pointer(p)).FzBuf = p + 26
 118137 	(*JsonString)(unsafe.Pointer(p)).FnAlloc = U64(unsafe.Sizeof([100]uint8{}))
 118138 	(*JsonString)(unsafe.Pointer(p)).FnUsed = uint64(0)
 118139 	(*JsonString)(unsafe.Pointer(p)).FbStatic = U8(1)
 118140 }
 118141 
 118142 func jsonInit(tls *libc.TLS, p uintptr, pCtx uintptr) {
 118143 	(*JsonString)(unsafe.Pointer(p)).FpCtx = pCtx
 118144 	(*JsonString)(unsafe.Pointer(p)).FbErr = U8(0)
 118145 	jsonZero(tls, p)
 118146 }
 118147 
 118148 func jsonReset(tls *libc.TLS, p uintptr) {
 118149 	if !(int32((*JsonString)(unsafe.Pointer(p)).FbStatic) != 0) {
 118150 		Xsqlite3_free(tls, (*JsonString)(unsafe.Pointer(p)).FzBuf)
 118151 	}
 118152 	jsonZero(tls, p)
 118153 }
 118154 
 118155 func jsonOom(tls *libc.TLS, p uintptr) {
 118156 	(*JsonString)(unsafe.Pointer(p)).FbErr = U8(1)
 118157 	Xsqlite3_result_error_nomem(tls, (*JsonString)(unsafe.Pointer(p)).FpCtx)
 118158 	jsonReset(tls, p)
 118159 }
 118160 
 118161 func jsonGrow(tls *libc.TLS, p uintptr, N U32) int32 {
 118162 	var nTotal U64
 118163 	if U64(N) < (*JsonString)(unsafe.Pointer(p)).FnAlloc {
 118164 		nTotal = (*JsonString)(unsafe.Pointer(p)).FnAlloc * uint64(2)
 118165 	} else {
 118166 		nTotal = (*JsonString)(unsafe.Pointer(p)).FnAlloc + U64(N) + uint64(10)
 118167 	}
 118168 	var zNew uintptr
 118169 	if (*JsonString)(unsafe.Pointer(p)).FbStatic != 0 {
 118170 		if (*JsonString)(unsafe.Pointer(p)).FbErr != 0 {
 118171 			return 1
 118172 		}
 118173 		zNew = Xsqlite3_malloc64(tls, nTotal)
 118174 		if zNew == uintptr(0) {
 118175 			jsonOom(tls, p)
 118176 			return SQLITE_NOMEM
 118177 		}
 118178 		libc.Xmemcpy(tls, zNew, (*JsonString)(unsafe.Pointer(p)).FzBuf, Size_t((*JsonString)(unsafe.Pointer(p)).FnUsed))
 118179 		(*JsonString)(unsafe.Pointer(p)).FzBuf = zNew
 118180 		(*JsonString)(unsafe.Pointer(p)).FbStatic = U8(0)
 118181 	} else {
 118182 		zNew = Xsqlite3_realloc64(tls, (*JsonString)(unsafe.Pointer(p)).FzBuf, nTotal)
 118183 		if zNew == uintptr(0) {
 118184 			jsonOom(tls, p)
 118185 			return SQLITE_NOMEM
 118186 		}
 118187 		(*JsonString)(unsafe.Pointer(p)).FzBuf = zNew
 118188 	}
 118189 	(*JsonString)(unsafe.Pointer(p)).FnAlloc = nTotal
 118190 	return SQLITE_OK
 118191 }
 118192 
 118193 func jsonAppendRaw(tls *libc.TLS, p uintptr, zIn uintptr, N U32) {
 118194 	if N == U32(0) {
 118195 		return
 118196 	}
 118197 	if U64(N)+(*JsonString)(unsafe.Pointer(p)).FnUsed >= (*JsonString)(unsafe.Pointer(p)).FnAlloc && jsonGrow(tls, p, N) != 0 {
 118198 		return
 118199 	}
 118200 	libc.Xmemcpy(tls, (*JsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*JsonString)(unsafe.Pointer(p)).FnUsed), zIn, N)
 118201 	*(*U64)(unsafe.Pointer(p + 16)) += U64(N)
 118202 }
 118203 
 118204 func jsonPrintf(tls *libc.TLS, N int32, p uintptr, zFormat uintptr, va uintptr) {
 118205 	var ap Va_list
 118206 	_ = ap
 118207 	if (*JsonString)(unsafe.Pointer(p)).FnUsed+U64(N) >= (*JsonString)(unsafe.Pointer(p)).FnAlloc && jsonGrow(tls, p, uint32(N)) != 0 {
 118208 		return
 118209 	}
 118210 	ap = va
 118211 	Xsqlite3_vsnprintf(tls, N, (*JsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*JsonString)(unsafe.Pointer(p)).FnUsed), zFormat, ap)
 118212 	_ = ap
 118213 	*(*U64)(unsafe.Pointer(p + 16)) += U64(int32(libc.Xstrlen(tls, (*JsonString)(unsafe.Pointer(p)).FzBuf+uintptr((*JsonString)(unsafe.Pointer(p)).FnUsed))))
 118214 }
 118215 
 118216 func jsonAppendChar(tls *libc.TLS, p uintptr, c uint8) {
 118217 	if (*JsonString)(unsafe.Pointer(p)).FnUsed >= (*JsonString)(unsafe.Pointer(p)).FnAlloc && jsonGrow(tls, p, uint32(1)) != 0 {
 118218 		return
 118219 	}
 118220 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = c
 118221 }
 118222 
 118223 func jsonAppendSeparator(tls *libc.TLS, p uintptr) {
 118224 	var c uint8
 118225 	if (*JsonString)(unsafe.Pointer(p)).FnUsed == uint64(0) {
 118226 		return
 118227 	}
 118228 	c = *(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr((*JsonString)(unsafe.Pointer(p)).FnUsed-uint64(1))))
 118229 	if int32(c) != '[' && int32(c) != '{' {
 118230 		jsonAppendChar(tls, p, uint8(','))
 118231 	}
 118232 }
 118233 
 118234 func jsonAppendString(tls *libc.TLS, p uintptr, zIn uintptr, N U32) {
 118235 	var i U32
 118236 	var c uint8
 118237 	if !(zIn == uintptr(0) || U64(N)+(*JsonString)(unsafe.Pointer(p)).FnUsed+uint64(2) >= (*JsonString)(unsafe.Pointer(p)).FnAlloc && jsonGrow(tls, p, N+U32(2)) != 0) {
 118238 		goto __1
 118239 	}
 118240 	return
 118241 __1:
 118242 	;
 118243 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('"')
 118244 	i = U32(0)
 118245 __2:
 118246 	if !(i < N) {
 118247 		goto __4
 118248 	}
 118249 	c = *(*uint8)(unsafe.Pointer(zIn + uintptr(i)))
 118250 	if !(int32(c) == '"' || int32(c) == '\\') {
 118251 		goto __5
 118252 	}
 118253 json_simple_escape:
 118254 	if !((*JsonString)(unsafe.Pointer(p)).FnUsed+U64(N)+uint64(3)-U64(i) > (*JsonString)(unsafe.Pointer(p)).FnAlloc && jsonGrow(tls, p, N+U32(3)-i) != 0) {
 118255 		goto __7
 118256 	}
 118257 	return
 118258 __7:
 118259 	;
 118260 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('\\')
 118261 	goto __6
 118262 __5:
 118263 	if !(int32(c) <= 0x1f) {
 118264 		goto __8
 118265 	}
 118266 
 118267 	if !(aSpecial[c] != 0) {
 118268 		goto __9
 118269 	}
 118270 	c = aSpecial[c]
 118271 	goto json_simple_escape
 118272 __9:
 118273 	;
 118274 	if !((*JsonString)(unsafe.Pointer(p)).FnUsed+U64(N)+uint64(7)+U64(i) > (*JsonString)(unsafe.Pointer(p)).FnAlloc && jsonGrow(tls, p, N+U32(7)-i) != 0) {
 118275 		goto __10
 118276 	}
 118277 	return
 118278 __10:
 118279 	;
 118280 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('\\')
 118281 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('u')
 118282 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('0')
 118283 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('0')
 118284 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('0' + int32(c)>>4)
 118285 	c = *(*uint8)(unsafe.Pointer(ts + 24547 + uintptr(int32(c)&0xf)))
 118286 __8:
 118287 	;
 118288 __6:
 118289 	;
 118290 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = c
 118291 	goto __3
 118292 __3:
 118293 	i++
 118294 	goto __2
 118295 	goto __4
 118296 __4:
 118297 	;
 118298 	*(*uint8)(unsafe.Pointer((*JsonString)(unsafe.Pointer(p)).FzBuf + uintptr(libc.PostIncUint64(&(*JsonString)(unsafe.Pointer(p)).FnUsed, 1)))) = uint8('"')
 118299 
 118300 }
 118301 
 118302 var aSpecial = [32]uint8{
 118303 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8('b'), uint8('t'), uint8('n'), uint8(0), uint8('f'), uint8('r'), uint8(0), uint8(0),
 118304 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 118305 }
 118306 
 118307 func jsonAppendValue(tls *libc.TLS, p uintptr, pValue uintptr) {
 118308 	switch Xsqlite3_value_type(tls, pValue) {
 118309 	case SQLITE_NULL:
 118310 		{
 118311 			jsonAppendRaw(tls, p, ts+6181, uint32(4))
 118312 			break
 118313 
 118314 		}
 118315 	case SQLITE_INTEGER:
 118316 		fallthrough
 118317 	case SQLITE_FLOAT:
 118318 		{
 118319 			var z uintptr = Xsqlite3_value_text(tls, pValue)
 118320 			var n U32 = U32(Xsqlite3_value_bytes(tls, pValue))
 118321 			jsonAppendRaw(tls, p, z, n)
 118322 			break
 118323 
 118324 		}
 118325 	case SQLITE_TEXT:
 118326 		{
 118327 			var z uintptr = Xsqlite3_value_text(tls, pValue)
 118328 			var n U32 = U32(Xsqlite3_value_bytes(tls, pValue))
 118329 			if Xsqlite3_value_subtype(tls, pValue) == uint32(JSON_SUBTYPE) {
 118330 				jsonAppendRaw(tls, p, z, n)
 118331 			} else {
 118332 				jsonAppendString(tls, p, z, n)
 118333 			}
 118334 			break
 118335 
 118336 		}
 118337 	default:
 118338 		{
 118339 			if int32((*JsonString)(unsafe.Pointer(p)).FbErr) == 0 {
 118340 				Xsqlite3_result_error(tls, (*JsonString)(unsafe.Pointer(p)).FpCtx, ts+24564, -1)
 118341 				(*JsonString)(unsafe.Pointer(p)).FbErr = U8(2)
 118342 				jsonReset(tls, p)
 118343 			}
 118344 			break
 118345 
 118346 		}
 118347 	}
 118348 }
 118349 
 118350 func jsonResult(tls *libc.TLS, p uintptr) {
 118351 	if int32((*JsonString)(unsafe.Pointer(p)).FbErr) == 0 {
 118352 		Xsqlite3_result_text64(tls, (*JsonString)(unsafe.Pointer(p)).FpCtx, (*JsonString)(unsafe.Pointer(p)).FzBuf, (*JsonString)(unsafe.Pointer(p)).FnUsed,
 118353 			func() uintptr {
 118354 				if (*JsonString)(unsafe.Pointer(p)).FbStatic != 0 {
 118355 					return libc.UintptrFromInt32(-1)
 118356 				}
 118357 				return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))
 118358 			}(),
 118359 			uint8(SQLITE_UTF8))
 118360 		jsonZero(tls, p)
 118361 	}
 118362 
 118363 }
 118364 
 118365 func jsonNodeSize(tls *libc.TLS, pNode uintptr) U32 {
 118366 	if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) >= JSON_ARRAY {
 118367 		return (*JsonNode)(unsafe.Pointer(pNode)).Fn + U32(1)
 118368 	}
 118369 	return uint32(1)
 118370 }
 118371 
 118372 func jsonParseReset(tls *libc.TLS, pParse uintptr) {
 118373 	Xsqlite3_free(tls, (*JsonParse)(unsafe.Pointer(pParse)).FaNode)
 118374 	(*JsonParse)(unsafe.Pointer(pParse)).FaNode = uintptr(0)
 118375 	(*JsonParse)(unsafe.Pointer(pParse)).FnNode = U32(0)
 118376 	(*JsonParse)(unsafe.Pointer(pParse)).FnAlloc = U32(0)
 118377 	Xsqlite3_free(tls, (*JsonParse)(unsafe.Pointer(pParse)).FaUp)
 118378 	(*JsonParse)(unsafe.Pointer(pParse)).FaUp = uintptr(0)
 118379 }
 118380 
 118381 func jsonParseFree(tls *libc.TLS, pParse uintptr) {
 118382 	jsonParseReset(tls, pParse)
 118383 	Xsqlite3_free(tls, pParse)
 118384 }
 118385 
 118386 func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr) {
 118387 	if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&(JNODE_REPLACE|JNODE_PATCH) != 0 {
 118388 		if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_REPLACE != 0 && aReplace != uintptr(0) {
 118389 			jsonAppendValue(tls, pOut, *(*uintptr)(unsafe.Pointer(aReplace + uintptr(*(*U32)(unsafe.Pointer(pNode + 8)))*4)))
 118390 			return
 118391 		}
 118392 
 118393 		pNode = *(*uintptr)(unsafe.Pointer(pNode + 8))
 118394 	}
 118395 	switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) {
 118396 	default:
 118397 		{
 118398 			jsonAppendRaw(tls, pOut, ts+6181, uint32(4))
 118399 			break
 118400 
 118401 		}
 118402 	case JSON_TRUE:
 118403 		{
 118404 			jsonAppendRaw(tls, pOut, ts+7694, uint32(4))
 118405 			break
 118406 
 118407 		}
 118408 	case JSON_FALSE:
 118409 		{
 118410 			jsonAppendRaw(tls, pOut, ts+7699, uint32(5))
 118411 			break
 118412 
 118413 		}
 118414 	case JSON_STRING:
 118415 		{
 118416 			if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_RAW != 0 {
 118417 				jsonAppendString(tls, pOut, *(*uintptr)(unsafe.Pointer(pNode + 8)), (*JsonNode)(unsafe.Pointer(pNode)).Fn)
 118418 				break
 118419 			}
 118420 
 118421 		}
 118422 		fallthrough
 118423 	case JSON_REAL:
 118424 		fallthrough
 118425 	case JSON_INT:
 118426 		{
 118427 			jsonAppendRaw(tls, pOut, *(*uintptr)(unsafe.Pointer(pNode + 8)), (*JsonNode)(unsafe.Pointer(pNode)).Fn)
 118428 			break
 118429 
 118430 		}
 118431 	case JSON_ARRAY:
 118432 		{
 118433 			var j U32 = U32(1)
 118434 			jsonAppendChar(tls, pOut, uint8('['))
 118435 			for {
 118436 				for j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn {
 118437 					if int32((*JsonNode)(unsafe.Pointer(pNode+uintptr(j)*12)).FjnFlags)&JNODE_REMOVE == 0 {
 118438 						jsonAppendSeparator(tls, pOut)
 118439 						jsonRenderNode(tls, pNode+uintptr(j)*12, pOut, aReplace)
 118440 					}
 118441 					j = j + jsonNodeSize(tls, pNode+uintptr(j)*12)
 118442 				}
 118443 				if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_APPEND == 0 {
 118444 					break
 118445 				}
 118446 
 118447 				pNode = pNode + uintptr(*(*U32)(unsafe.Pointer(pNode + 8)))*12
 118448 				j = U32(1)
 118449 			}
 118450 			jsonAppendChar(tls, pOut, uint8(']'))
 118451 			break
 118452 
 118453 		}
 118454 	case JSON_OBJECT:
 118455 		{
 118456 			var j U32 = U32(1)
 118457 			jsonAppendChar(tls, pOut, uint8('{'))
 118458 			for {
 118459 				for j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn {
 118460 					if int32((*JsonNode)(unsafe.Pointer(pNode+uintptr(j+U32(1))*12)).FjnFlags)&JNODE_REMOVE == 0 {
 118461 						jsonAppendSeparator(tls, pOut)
 118462 						jsonRenderNode(tls, pNode+uintptr(j)*12, pOut, aReplace)
 118463 						jsonAppendChar(tls, pOut, uint8(':'))
 118464 						jsonRenderNode(tls, pNode+uintptr(j+U32(1))*12, pOut, aReplace)
 118465 					}
 118466 					j = j + (U32(1) + jsonNodeSize(tls, pNode+uintptr(j+U32(1))*12))
 118467 				}
 118468 				if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_APPEND == 0 {
 118469 					break
 118470 				}
 118471 
 118472 				pNode = pNode + uintptr(*(*U32)(unsafe.Pointer(pNode + 8)))*12
 118473 				j = U32(1)
 118474 			}
 118475 			jsonAppendChar(tls, pOut, uint8('}'))
 118476 			break
 118477 
 118478 		}
 118479 	}
 118480 }
 118481 
 118482 func jsonReturnJson(tls *libc.TLS, pNode uintptr, pCtx uintptr, aReplace uintptr) {
 118483 	bp := tls.Alloc(128)
 118484 	defer tls.Free(128)
 118485 
 118486 	jsonInit(tls, bp, pCtx)
 118487 	jsonRenderNode(tls, pNode, bp, aReplace)
 118488 	jsonResult(tls, bp)
 118489 	Xsqlite3_result_subtype(tls, pCtx, uint32(JSON_SUBTYPE))
 118490 }
 118491 
 118492 func jsonHexToInt(tls *libc.TLS, h int32) U8 {
 118493 	h = h + 9*(1&(h>>6))
 118494 	return U8(h & 0xf)
 118495 }
 118496 
 118497 func jsonHexToInt4(tls *libc.TLS, z uintptr) U32 {
 118498 	var v U32
 118499 
 118500 	v = U32(int32(jsonHexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z)))))<<12 +
 118501 		int32(jsonHexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z + 1)))))<<8 +
 118502 		int32(jsonHexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z + 2)))))<<4 +
 118503 		int32(jsonHexToInt(tls, int32(*(*uint8)(unsafe.Pointer(z + 3))))))
 118504 	return v
 118505 }
 118506 
 118507 func jsonReturn(tls *libc.TLS, pNode uintptr, pCtx uintptr, aReplace uintptr) {
 118508 	bp := tls.Alloc(8)
 118509 	defer tls.Free(8)
 118510 
 118511 	var v uint32
 118512 	var i Sqlite3_int64
 118513 	var z uintptr
 118514 
 118515 	var z1 uintptr
 118516 	var vlo U32
 118517 	var v1 U32
 118518 	var c uint8
 118519 
 118520 	var i1 U32
 118521 	var n U32
 118522 	var z2 uintptr
 118523 	var zOut uintptr
 118524 	var j U32
 118525 	switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) {
 118526 	default:
 118527 		goto __2
 118528 	case JSON_TRUE:
 118529 		goto __3
 118530 	case JSON_FALSE:
 118531 		goto __4
 118532 	case JSON_INT:
 118533 		goto __5
 118534 	case JSON_REAL:
 118535 		goto __6
 118536 	case JSON_STRING:
 118537 		goto __7
 118538 	case JSON_ARRAY:
 118539 		goto __8
 118540 	case JSON_OBJECT:
 118541 		goto __9
 118542 	}
 118543 	goto __1
 118544 __2:
 118545 	;
 118546 	Xsqlite3_result_null(tls, pCtx)
 118547 	goto __1
 118548 
 118549 __3:
 118550 	Xsqlite3_result_int(tls, pCtx, 1)
 118551 	goto __1
 118552 
 118553 __4:
 118554 	Xsqlite3_result_int(tls, pCtx, 0)
 118555 	goto __1
 118556 
 118557 __5:
 118558 	i = int64(0)
 118559 
 118560 	z = *(*uintptr)(unsafe.Pointer(pNode + 8))
 118561 	if !(int32(*(*uint8)(unsafe.Pointer(z))) == '-') {
 118562 		goto __10
 118563 	}
 118564 	z++
 118565 __10:
 118566 	;
 118567 __11:
 118568 	if !(int32(*(*uint8)(unsafe.Pointer(z))) >= '0' && int32(*(*uint8)(unsafe.Pointer(z))) <= '9') {
 118569 		goto __12
 118570 	}
 118571 	v = uint32(int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) - '0')
 118572 	if !(i >= (int64(0xffffffff)|int64(0x7fffffff)<<32)/int64(10)) {
 118573 		goto __13
 118574 	}
 118575 	if !(i > (int64(0xffffffff)|int64(0x7fffffff)<<32)/int64(10)) {
 118576 		goto __14
 118577 	}
 118578 	goto int_as_real
 118579 __14:
 118580 	;
 118581 	if !(int32(*(*uint8)(unsafe.Pointer(z))) >= '0' && int32(*(*uint8)(unsafe.Pointer(z))) <= '9') {
 118582 		goto __15
 118583 	}
 118584 	goto int_as_real
 118585 __15:
 118586 	;
 118587 	if !(v == uint32(9)) {
 118588 		goto __16
 118589 	}
 118590 	goto int_as_real
 118591 __16:
 118592 	;
 118593 	if !(v == uint32(8)) {
 118594 		goto __17
 118595 	}
 118596 	if !(int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8))))) == '-') {
 118597 		goto __18
 118598 	}
 118599 	Xsqlite3_result_int64(tls, pCtx, int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32))
 118600 	goto int_done
 118601 	goto __19
 118602 __18:
 118603 	goto int_as_real
 118604 __19:
 118605 	;
 118606 __17:
 118607 	;
 118608 __13:
 118609 	;
 118610 	i = i*int64(10) + Sqlite3_int64(v)
 118611 	goto __11
 118612 __12:
 118613 	;
 118614 	if !(int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8))))) == '-') {
 118615 		goto __20
 118616 	}
 118617 	i = -i
 118618 __20:
 118619 	;
 118620 	Xsqlite3_result_int64(tls, pCtx, i)
 118621 int_done:
 118622 	goto __1
 118623 int_as_real:
 118624 	;
 118625 __6:
 118626 	;
 118627 	z1 = *(*uintptr)(unsafe.Pointer(pNode + 8))
 118628 	Xsqlite3AtoF(tls, z1, bp, Xsqlite3Strlen30(tls, z1), uint8(SQLITE_UTF8))
 118629 	Xsqlite3_result_double(tls, pCtx, *(*float64)(unsafe.Pointer(bp)))
 118630 	goto __1
 118631 
 118632 __7:
 118633 	;
 118634 	if !(int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_ESCAPE == 0) {
 118635 		goto __21
 118636 	}
 118637 
 118638 	Xsqlite3_result_text(tls, pCtx, *(*uintptr)(unsafe.Pointer(pNode + 8))+uintptr(1), int32((*JsonNode)(unsafe.Pointer(pNode)).Fn-U32(2)),
 118639 		libc.UintptrFromInt32(-1))
 118640 	goto __22
 118641 __21:
 118642 	n = (*JsonNode)(unsafe.Pointer(pNode)).Fn
 118643 
 118644 	z2 = *(*uintptr)(unsafe.Pointer(pNode + 8))
 118645 	zOut = Xsqlite3_malloc(tls, int32(n+U32(1)))
 118646 	if !(zOut == uintptr(0)) {
 118647 		goto __23
 118648 	}
 118649 	Xsqlite3_result_error_nomem(tls, pCtx)
 118650 	goto __1
 118651 __23:
 118652 	;
 118653 	i1 = U32(1)
 118654 	j = U32(0)
 118655 __24:
 118656 	if !(i1 < n-U32(1)) {
 118657 		goto __26
 118658 	}
 118659 	c = *(*uint8)(unsafe.Pointer(z2 + uintptr(i1)))
 118660 	if !(int32(c) != '\\') {
 118661 		goto __27
 118662 	}
 118663 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = c
 118664 	goto __28
 118665 __27:
 118666 	c = *(*uint8)(unsafe.Pointer(z2 + uintptr(libc.PreIncUint32(&i1, 1))))
 118667 	if !(int32(c) == 'u') {
 118668 		goto __29
 118669 	}
 118670 	v1 = jsonHexToInt4(tls, z2+uintptr(i1)+uintptr(1))
 118671 	i1 = i1 + U32(4)
 118672 	if !(v1 == U32(0)) {
 118673 		goto __31
 118674 	}
 118675 	goto __26
 118676 __31:
 118677 	;
 118678 	if !(v1 <= U32(0x7f)) {
 118679 		goto __32
 118680 	}
 118681 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(v1)
 118682 	goto __33
 118683 __32:
 118684 	if !(v1 <= U32(0x7ff)) {
 118685 		goto __34
 118686 	}
 118687 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0xc0) | v1>>6)
 118688 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0x80) | v1&U32(0x3f))
 118689 	goto __35
 118690 __34:
 118691 	if !(v1&U32(0xfc00) == U32(0xd800) &&
 118692 		i1 < n-U32(6) &&
 118693 		int32(*(*uint8)(unsafe.Pointer(z2 + uintptr(i1+U32(1))))) == '\\' &&
 118694 		int32(*(*uint8)(unsafe.Pointer(z2 + uintptr(i1+U32(2))))) == 'u' &&
 118695 		libc.AssignUint32(&vlo, jsonHexToInt4(tls, z2+uintptr(i1)+uintptr(3)))&U32(0xfc00) == U32(0xdc00)) {
 118696 		goto __36
 118697 	}
 118698 
 118699 	v1 = v1&U32(0x3ff)<<10 + vlo&U32(0x3ff) + U32(0x10000)
 118700 	i1 = i1 + U32(6)
 118701 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0xf0) | v1>>18)
 118702 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0x80) | v1>>12&U32(0x3f))
 118703 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0x80) | v1>>6&U32(0x3f))
 118704 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0x80) | v1&U32(0x3f))
 118705 	goto __37
 118706 __36:
 118707 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0xe0) | v1>>12)
 118708 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0x80) | v1>>6&U32(0x3f))
 118709 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = uint8(U32(0x80) | v1&U32(0x3f))
 118710 __37:
 118711 	;
 118712 __35:
 118713 	;
 118714 __33:
 118715 	;
 118716 	goto __30
 118717 __29:
 118718 	if !(int32(c) == 'b') {
 118719 		goto __38
 118720 	}
 118721 	c = uint8('\b')
 118722 	goto __39
 118723 __38:
 118724 	if !(int32(c) == 'f') {
 118725 		goto __40
 118726 	}
 118727 	c = uint8('\f')
 118728 	goto __41
 118729 __40:
 118730 	if !(int32(c) == 'n') {
 118731 		goto __42
 118732 	}
 118733 	c = uint8('\n')
 118734 	goto __43
 118735 __42:
 118736 	if !(int32(c) == 'r') {
 118737 		goto __44
 118738 	}
 118739 	c = uint8('\r')
 118740 	goto __45
 118741 __44:
 118742 	if !(int32(c) == 't') {
 118743 		goto __46
 118744 	}
 118745 	c = uint8('\t')
 118746 __46:
 118747 	;
 118748 __45:
 118749 	;
 118750 __43:
 118751 	;
 118752 __41:
 118753 	;
 118754 __39:
 118755 	;
 118756 	*(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncUint32(&j, 1)))) = c
 118757 __30:
 118758 	;
 118759 __28:
 118760 	;
 118761 	goto __25
 118762 __25:
 118763 	i1++
 118764 	goto __24
 118765 	goto __26
 118766 __26:
 118767 	;
 118768 	*(*uint8)(unsafe.Pointer(zOut + uintptr(j))) = uint8(0)
 118769 	Xsqlite3_result_text(tls, pCtx, zOut, int32(j), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 118770 __22:
 118771 	;
 118772 	goto __1
 118773 
 118774 __8:
 118775 __9:
 118776 	jsonReturnJson(tls, pNode, pCtx, aReplace)
 118777 	goto __1
 118778 
 118779 __1:
 118780 }
 118781 
 118782 func jsonParseAddNodeExpand(tls *libc.TLS, pParse uintptr, eType U32, n U32, zContent uintptr) int32 {
 118783 	var nNew U32
 118784 	var pNew uintptr
 118785 
 118786 	if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 118787 		return -1
 118788 	}
 118789 	nNew = (*JsonParse)(unsafe.Pointer(pParse)).FnAlloc*U32(2) + U32(10)
 118790 	pNew = Xsqlite3_realloc64(tls, (*JsonParse)(unsafe.Pointer(pParse)).FaNode, uint64(uint32(unsafe.Sizeof(JsonNode{}))*nNew))
 118791 	if pNew == uintptr(0) {
 118792 		(*JsonParse)(unsafe.Pointer(pParse)).Foom = U8(1)
 118793 		return -1
 118794 	}
 118795 	(*JsonParse)(unsafe.Pointer(pParse)).FnAlloc = nNew
 118796 	(*JsonParse)(unsafe.Pointer(pParse)).FaNode = pNew
 118797 
 118798 	return jsonParseAddNode(tls, pParse, eType, n, zContent)
 118799 }
 118800 
 118801 func jsonParseAddNode(tls *libc.TLS, pParse uintptr, eType U32, n U32, zContent uintptr) int32 {
 118802 	var p uintptr
 118803 	if (*JsonParse)(unsafe.Pointer(pParse)).FaNode == uintptr(0) || (*JsonParse)(unsafe.Pointer(pParse)).FnNode >= (*JsonParse)(unsafe.Pointer(pParse)).FnAlloc {
 118804 		return jsonParseAddNodeExpand(tls, pParse, eType, n, zContent)
 118805 	}
 118806 	p = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr((*JsonParse)(unsafe.Pointer(pParse)).FnNode)*12
 118807 	(*JsonNode)(unsafe.Pointer(p)).FeType = U8(eType)
 118808 	(*JsonNode)(unsafe.Pointer(p)).FjnFlags = U8(0)
 118809 
 118810 	(*JsonNode)(unsafe.Pointer(p)).Fn = n
 118811 	*(*uintptr)(unsafe.Pointer(p + 8)) = zContent
 118812 	return int32(libc.PostIncUint32(&(*JsonParse)(unsafe.Pointer(pParse)).FnNode, 1))
 118813 }
 118814 
 118815 func jsonIs4Hex(tls *libc.TLS, z uintptr) int32 {
 118816 	var i int32
 118817 	for i = 0; i < 4; i++ {
 118818 		if !(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))])&0x08 != 0) {
 118819 			return 0
 118820 		}
 118821 	}
 118822 	return 1
 118823 }
 118824 
 118825 func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 {
 118826 	var c uint8
 118827 	var j U32
 118828 	var iThis int32
 118829 	var x int32
 118830 	var pNode uintptr
 118831 	var z uintptr = (*JsonParse)(unsafe.Pointer(pParse)).FzJson
 118832 	for jsonIsSpace[*(*uint8)(unsafe.Pointer(z + uintptr(i)))] != 0 {
 118833 		i++
 118834 	}
 118835 	if int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(z + uintptr(i))))) == '{' {
 118836 		iThis = jsonParseAddNode(tls, pParse, uint32(JSON_OBJECT), uint32(0), uintptr(0))
 118837 		if iThis < 0 {
 118838 			return -1
 118839 		}
 118840 		for j = i + U32(1); ; j++ {
 118841 			for jsonIsSpace[*(*uint8)(unsafe.Pointer(z + uintptr(j)))] != 0 {
 118842 				j++
 118843 			}
 118844 			if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > JSON_MAX_DEPTH {
 118845 				return -1
 118846 			}
 118847 			x = jsonParseValue(tls, pParse, j)
 118848 			if x < 0 {
 118849 				(*JsonParse)(unsafe.Pointer(pParse)).FiDepth--
 118850 				if x == -2 && (*JsonParse)(unsafe.Pointer(pParse)).FnNode == U32(iThis)+U32(1) {
 118851 					return int32(j + U32(1))
 118852 				}
 118853 				return -1
 118854 			}
 118855 			if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 118856 				return -1
 118857 			}
 118858 			pNode = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1))*12
 118859 			if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) != JSON_STRING {
 118860 				return -1
 118861 			}
 118862 			*(*U8)(unsafe.Pointer(pNode + 1)) |= U8(JNODE_LABEL)
 118863 			j = U32(x)
 118864 			for jsonIsSpace[*(*uint8)(unsafe.Pointer(z + uintptr(j)))] != 0 {
 118865 				j++
 118866 			}
 118867 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j)))) != ':' {
 118868 				return -1
 118869 			}
 118870 			j++
 118871 			x = jsonParseValue(tls, pParse, j)
 118872 			(*JsonParse)(unsafe.Pointer(pParse)).FiDepth--
 118873 			if x < 0 {
 118874 				return -1
 118875 			}
 118876 			j = U32(x)
 118877 			for jsonIsSpace[*(*uint8)(unsafe.Pointer(z + uintptr(j)))] != 0 {
 118878 				j++
 118879 			}
 118880 			c = *(*uint8)(unsafe.Pointer(z + uintptr(j)))
 118881 			if int32(c) == ',' {
 118882 				continue
 118883 			}
 118884 			if int32(c) != '}' {
 118885 				return -1
 118886 			}
 118887 			break
 118888 		}
 118889 		(*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iThis)*12)).Fn = (*JsonParse)(unsafe.Pointer(pParse)).FnNode - U32(iThis) - U32(1)
 118890 		return int32(j + U32(1))
 118891 	} else if int32(c) == '[' {
 118892 		iThis = jsonParseAddNode(tls, pParse, uint32(JSON_ARRAY), uint32(0), uintptr(0))
 118893 		if iThis < 0 {
 118894 			return -1
 118895 		}
 118896 		libc.Xmemset(tls, (*JsonParse)(unsafe.Pointer(pParse)).FaNode+uintptr(iThis)*12+8, 0, uint32(unsafe.Sizeof(struct{ FzJContent uintptr }{})))
 118897 		for j = i + U32(1); ; j++ {
 118898 			for jsonIsSpace[*(*uint8)(unsafe.Pointer(z + uintptr(j)))] != 0 {
 118899 				j++
 118900 			}
 118901 			if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > JSON_MAX_DEPTH {
 118902 				return -1
 118903 			}
 118904 			x = jsonParseValue(tls, pParse, j)
 118905 			(*JsonParse)(unsafe.Pointer(pParse)).FiDepth--
 118906 			if x < 0 {
 118907 				if x == -3 && (*JsonParse)(unsafe.Pointer(pParse)).FnNode == U32(iThis)+U32(1) {
 118908 					return int32(j + U32(1))
 118909 				}
 118910 				return -1
 118911 			}
 118912 			j = U32(x)
 118913 			for jsonIsSpace[*(*uint8)(unsafe.Pointer(z + uintptr(j)))] != 0 {
 118914 				j++
 118915 			}
 118916 			c = *(*uint8)(unsafe.Pointer(z + uintptr(j)))
 118917 			if int32(c) == ',' {
 118918 				continue
 118919 			}
 118920 			if int32(c) != ']' {
 118921 				return -1
 118922 			}
 118923 			break
 118924 		}
 118925 		(*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iThis)*12)).Fn = (*JsonParse)(unsafe.Pointer(pParse)).FnNode - U32(iThis) - U32(1)
 118926 		return int32(j + U32(1))
 118927 	} else if int32(c) == '"' {
 118928 		var jnFlags U8 = U8(0)
 118929 		j = i + U32(1)
 118930 		for {
 118931 			c = *(*uint8)(unsafe.Pointer(z + uintptr(j)))
 118932 			if int32(c)&libc.CplInt32(0x1f) == 0 {
 118933 				return -1
 118934 			}
 118935 			if int32(c) == '\\' {
 118936 				c = *(*uint8)(unsafe.Pointer(z + uintptr(libc.PreIncUint32(&j, 1))))
 118937 				if int32(c) == '"' || int32(c) == '\\' || int32(c) == '/' || int32(c) == 'b' || int32(c) == 'f' ||
 118938 					int32(c) == 'n' || int32(c) == 'r' || int32(c) == 't' ||
 118939 					int32(c) == 'u' && jsonIs4Hex(tls, z+uintptr(j)+uintptr(1)) != 0 {
 118940 					jnFlags = U8(JNODE_ESCAPE)
 118941 				} else {
 118942 					return -1
 118943 				}
 118944 			} else if int32(c) == '"' {
 118945 				break
 118946 			}
 118947 			j++
 118948 		}
 118949 		jsonParseAddNode(tls, pParse, uint32(JSON_STRING), j+U32(1)-i, z+uintptr(i))
 118950 		if !(int32((*JsonParse)(unsafe.Pointer(pParse)).Foom) != 0) {
 118951 			(*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1))*12)).FjnFlags = jnFlags
 118952 		}
 118953 		return int32(j + U32(1))
 118954 	} else if int32(c) == 'n' &&
 118955 		libc.Xstrncmp(tls, z+uintptr(i), ts+6181, uint32(4)) == 0 &&
 118956 		!(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i+U32(4))))])&0x06 != 0) {
 118957 		jsonParseAddNode(tls, pParse, uint32(JSON_NULL), uint32(0), uintptr(0))
 118958 		return int32(i + U32(4))
 118959 	} else if int32(c) == 't' &&
 118960 		libc.Xstrncmp(tls, z+uintptr(i), ts+7694, uint32(4)) == 0 &&
 118961 		!(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i+U32(4))))])&0x06 != 0) {
 118962 		jsonParseAddNode(tls, pParse, uint32(JSON_TRUE), uint32(0), uintptr(0))
 118963 		return int32(i + U32(4))
 118964 	} else if int32(c) == 'f' &&
 118965 		libc.Xstrncmp(tls, z+uintptr(i), ts+7699, uint32(5)) == 0 &&
 118966 		!(int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i+U32(5))))])&0x06 != 0) {
 118967 		jsonParseAddNode(tls, pParse, uint32(JSON_FALSE), uint32(0), uintptr(0))
 118968 		return int32(i + U32(5))
 118969 	} else if int32(c) == '-' || int32(c) >= '0' && int32(c) <= '9' {
 118970 		var seenDP U8 = U8(0)
 118971 		var seenE U8 = U8(0)
 118972 
 118973 		if int32(c) <= '0' {
 118974 			if int32(c) == '-' {
 118975 				j = i + U32(1)
 118976 			} else {
 118977 				j = i
 118978 			}
 118979 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j)))) == '0' && int32(*(*uint8)(unsafe.Pointer(z + uintptr(j+U32(1))))) >= '0' && int32(*(*uint8)(unsafe.Pointer(z + uintptr(j+U32(1))))) <= '9' {
 118980 				return -1
 118981 			}
 118982 		}
 118983 		j = i + U32(1)
 118984 		for ; ; j++ {
 118985 			c = *(*uint8)(unsafe.Pointer(z + uintptr(j)))
 118986 			if int32(c) >= '0' && int32(c) <= '9' {
 118987 				continue
 118988 			}
 118989 			if int32(c) == '.' {
 118990 				if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j-U32(1))))) == '-' {
 118991 					return -1
 118992 				}
 118993 				if seenDP != 0 {
 118994 					return -1
 118995 				}
 118996 				seenDP = U8(1)
 118997 				continue
 118998 			}
 118999 			if int32(c) == 'e' || int32(c) == 'E' {
 119000 				if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j-U32(1))))) < '0' {
 119001 					return -1
 119002 				}
 119003 				if seenE != 0 {
 119004 					return -1
 119005 				}
 119006 				seenDP = libc.AssignUint8(&seenE, U8(1))
 119007 				c = *(*uint8)(unsafe.Pointer(z + uintptr(j+U32(1))))
 119008 				if int32(c) == '+' || int32(c) == '-' {
 119009 					j++
 119010 					c = *(*uint8)(unsafe.Pointer(z + uintptr(j+U32(1))))
 119011 				}
 119012 				if int32(c) < '0' || int32(c) > '9' {
 119013 					return -1
 119014 				}
 119015 				continue
 119016 			}
 119017 			break
 119018 		}
 119019 		if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j-U32(1))))) < '0' {
 119020 			return -1
 119021 		}
 119022 		jsonParseAddNode(tls, pParse, func() uint32 {
 119023 			if seenDP != 0 {
 119024 				return uint32(JSON_REAL)
 119025 			}
 119026 			return uint32(JSON_INT)
 119027 		}(),
 119028 			j-i, z+uintptr(i))
 119029 		return int32(j)
 119030 	} else if int32(c) == '}' {
 119031 		return -2
 119032 	} else if int32(c) == ']' {
 119033 		return -3
 119034 	} else if int32(c) == 0 {
 119035 		return 0
 119036 	} else {
 119037 		return -1
 119038 	}
 119039 	return int32(0)
 119040 }
 119041 
 119042 func jsonParse(tls *libc.TLS, pParse uintptr, pCtx uintptr, zJson uintptr) int32 {
 119043 	var i int32
 119044 	libc.Xmemset(tls, pParse, 0, uint32(unsafe.Sizeof(JsonParse{})))
 119045 	if zJson == uintptr(0) {
 119046 		return 1
 119047 	}
 119048 	(*JsonParse)(unsafe.Pointer(pParse)).FzJson = zJson
 119049 	i = jsonParseValue(tls, pParse, uint32(0))
 119050 	if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119051 		i = -1
 119052 	}
 119053 	if i > 0 {
 119054 		for jsonIsSpace[*(*uint8)(unsafe.Pointer(zJson + uintptr(i)))] != 0 {
 119055 			i++
 119056 		}
 119057 		if *(*uint8)(unsafe.Pointer(zJson + uintptr(i))) != 0 {
 119058 			i = -1
 119059 		}
 119060 	}
 119061 	if i <= 0 {
 119062 		if pCtx != uintptr(0) {
 119063 			if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119064 				Xsqlite3_result_error_nomem(tls, pCtx)
 119065 			} else {
 119066 				Xsqlite3_result_error(tls, pCtx, ts+24593, -1)
 119067 			}
 119068 		}
 119069 		jsonParseReset(tls, pParse)
 119070 		return 1
 119071 	}
 119072 	return 0
 119073 }
 119074 
 119075 func jsonParseFillInParentage(tls *libc.TLS, pParse uintptr, i U32, iParent U32) {
 119076 	var pNode uintptr = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(i)*12
 119077 	var j U32
 119078 	*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaUp + uintptr(i)*4)) = iParent
 119079 	switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) {
 119080 	case JSON_ARRAY:
 119081 		{
 119082 			for j = U32(1); j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; j = j + jsonNodeSize(tls, pNode+uintptr(j)*12) {
 119083 				jsonParseFillInParentage(tls, pParse, i+j, i)
 119084 			}
 119085 			break
 119086 
 119087 		}
 119088 	case JSON_OBJECT:
 119089 		{
 119090 			for j = U32(1); j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; j = j + (jsonNodeSize(tls, pNode+uintptr(j)*12+uintptr(1)*12) + U32(1)) {
 119091 				*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaUp + uintptr(i+j)*4)) = i
 119092 				jsonParseFillInParentage(tls, pParse, i+j+U32(1), i)
 119093 			}
 119094 			break
 119095 
 119096 		}
 119097 	default:
 119098 		{
 119099 			break
 119100 
 119101 		}
 119102 	}
 119103 }
 119104 
 119105 func jsonParseFindParents(tls *libc.TLS, pParse uintptr) int32 {
 119106 	var aUp uintptr
 119107 
 119108 	aUp = libc.AssignPtrUintptr(pParse+16, Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(U32(0)))*(*JsonParse)(unsafe.Pointer(pParse)).FnNode)))
 119109 	if aUp == uintptr(0) {
 119110 		(*JsonParse)(unsafe.Pointer(pParse)).Foom = U8(1)
 119111 		return SQLITE_NOMEM
 119112 	}
 119113 	jsonParseFillInParentage(tls, pParse, uint32(0), uint32(0))
 119114 	return SQLITE_OK
 119115 }
 119116 
 119117 func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) uintptr {
 119118 	var zJson uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
 119119 	var nJson int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
 119120 	var p uintptr
 119121 	var pMatch uintptr = uintptr(0)
 119122 	var iKey int32
 119123 	var iMinKey int32 = 0
 119124 	var iMinHold U32 = 0xffffffff
 119125 	var iMaxHold U32 = U32(0)
 119126 	if zJson == uintptr(0) {
 119127 		return uintptr(0)
 119128 	}
 119129 	for iKey = 0; iKey < JSON_CACHE_SZ; iKey++ {
 119130 		p = Xsqlite3_get_auxdata(tls, pCtx, -429938+iKey)
 119131 		if p == uintptr(0) {
 119132 			iMinKey = iKey
 119133 			break
 119134 		}
 119135 		if pMatch == uintptr(0) &&
 119136 			(*JsonParse)(unsafe.Pointer(p)).FnJson == nJson &&
 119137 			libc.Xmemcmp(tls, (*JsonParse)(unsafe.Pointer(p)).FzJson, zJson, uint32(nJson)) == 0 {
 119138 			(*JsonParse)(unsafe.Pointer(p)).FnErr = U8(0)
 119139 			pMatch = p
 119140 		} else if (*JsonParse)(unsafe.Pointer(p)).FiHold < iMinHold {
 119141 			iMinHold = (*JsonParse)(unsafe.Pointer(p)).FiHold
 119142 			iMinKey = iKey
 119143 		}
 119144 		if (*JsonParse)(unsafe.Pointer(p)).FiHold > iMaxHold {
 119145 			iMaxHold = (*JsonParse)(unsafe.Pointer(p)).FiHold
 119146 		}
 119147 	}
 119148 	if pMatch != 0 {
 119149 		(*JsonParse)(unsafe.Pointer(pMatch)).FnErr = U8(0)
 119150 		(*JsonParse)(unsafe.Pointer(pMatch)).FiHold = iMaxHold + U32(1)
 119151 		return pMatch
 119152 	}
 119153 	p = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(JsonParse{}))+uint32(nJson)+uint32(1)))
 119154 	if p == uintptr(0) {
 119155 		Xsqlite3_result_error_nomem(tls, pCtx)
 119156 		return uintptr(0)
 119157 	}
 119158 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(JsonParse{})))
 119159 	(*JsonParse)(unsafe.Pointer(p)).FzJson = p + 1*32
 119160 	libc.Xmemcpy(tls, (*JsonParse)(unsafe.Pointer(p)).FzJson, zJson, uint32(nJson+1))
 119161 	if jsonParse(tls, p, pErrCtx, (*JsonParse)(unsafe.Pointer(p)).FzJson) != 0 {
 119162 		Xsqlite3_free(tls, p)
 119163 		return uintptr(0)
 119164 	}
 119165 	(*JsonParse)(unsafe.Pointer(p)).FnJson = nJson
 119166 	(*JsonParse)(unsafe.Pointer(p)).FiHold = iMaxHold + U32(1)
 119167 	Xsqlite3_set_auxdata(tls, pCtx, -429938+iMinKey, p,
 119168 		*(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{jsonParseFree})))
 119169 	return Xsqlite3_get_auxdata(tls, pCtx, -429938+iMinKey)
 119170 }
 119171 
 119172 func jsonLabelCompare(tls *libc.TLS, pNode uintptr, zKey uintptr, nKey U32) int32 {
 119173 	if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_RAW != 0 {
 119174 		if (*JsonNode)(unsafe.Pointer(pNode)).Fn != nKey {
 119175 			return 0
 119176 		}
 119177 		return libc.Bool32(libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(pNode + 8)), zKey, nKey) == 0)
 119178 	} else {
 119179 		if (*JsonNode)(unsafe.Pointer(pNode)).Fn != nKey+U32(2) {
 119180 			return 0
 119181 		}
 119182 		return libc.Bool32(libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(pNode + 8))+uintptr(1), zKey, nKey) == 0)
 119183 	}
 119184 	return int32(0)
 119185 }
 119186 
 119187 func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pApnd uintptr, pzErr uintptr) uintptr {
 119188 	var i U32
 119189 	var j U32
 119190 	var nKey U32
 119191 	var zKey uintptr
 119192 	var pRoot uintptr = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12
 119193 	if int32(*(*uint8)(unsafe.Pointer(zPath))) == 0 {
 119194 		return pRoot
 119195 	}
 119196 	if int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags)&JNODE_REPLACE != 0 {
 119197 		return uintptr(0)
 119198 	}
 119199 	if int32(*(*uint8)(unsafe.Pointer(zPath))) == '.' {
 119200 		if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_OBJECT {
 119201 			return uintptr(0)
 119202 		}
 119203 		zPath++
 119204 		if int32(*(*uint8)(unsafe.Pointer(zPath))) == '"' {
 119205 			zKey = zPath + uintptr(1)
 119206 			for i = U32(1); *(*uint8)(unsafe.Pointer(zPath + uintptr(i))) != 0 && int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(i)))) != '"'; i++ {
 119207 			}
 119208 			nKey = i - U32(1)
 119209 			if *(*uint8)(unsafe.Pointer(zPath + uintptr(i))) != 0 {
 119210 				i++
 119211 			} else {
 119212 				*(*uintptr)(unsafe.Pointer(pzErr)) = zPath
 119213 				return uintptr(0)
 119214 			}
 119215 
 119216 		} else {
 119217 			zKey = zPath
 119218 			for i = U32(0); *(*uint8)(unsafe.Pointer(zPath + uintptr(i))) != 0 && int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(i)))) != '.' && int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(i)))) != '['; i++ {
 119219 			}
 119220 			nKey = i
 119221 			if nKey == U32(0) {
 119222 				*(*uintptr)(unsafe.Pointer(pzErr)) = zPath
 119223 				return uintptr(0)
 119224 			}
 119225 		}
 119226 		j = U32(1)
 119227 		for {
 119228 			for j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn {
 119229 				if jsonLabelCompare(tls, pRoot+uintptr(j)*12, zKey, nKey) != 0 {
 119230 					return jsonLookupStep(tls, pParse, iRoot+j+U32(1), zPath+uintptr(i), pApnd, pzErr)
 119231 				}
 119232 				j++
 119233 				j = j + jsonNodeSize(tls, pRoot+uintptr(j)*12)
 119234 			}
 119235 			if int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags)&JNODE_APPEND == 0 {
 119236 				break
 119237 			}
 119238 
 119239 			iRoot = iRoot + *(*U32)(unsafe.Pointer(pRoot + 8))
 119240 			pRoot = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12
 119241 			j = U32(1)
 119242 		}
 119243 		if pApnd != 0 {
 119244 			var iStart U32
 119245 			var iLabel U32
 119246 			var pNode uintptr
 119247 			iStart = U32(jsonParseAddNode(tls, pParse, uint32(JSON_OBJECT), uint32(2), uintptr(0)))
 119248 			iLabel = U32(jsonParseAddNode(tls, pParse, uint32(JSON_STRING), nKey, zKey))
 119249 			zPath += uintptr(i)
 119250 			pNode = jsonLookupAppend(tls, pParse, zPath, pApnd, pzErr)
 119251 			if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119252 				return uintptr(0)
 119253 			}
 119254 			if pNode != 0 {
 119255 				pRoot = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12
 119256 
 119257 				*(*U32)(unsafe.Pointer(pRoot + 8)) = iStart - iRoot
 119258 				*(*U8)(unsafe.Pointer(pRoot + 1)) |= U8(JNODE_APPEND)
 119259 
 119260 				*(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iLabel)*12 + 1)) |= U8(JNODE_RAW)
 119261 			}
 119262 			return pNode
 119263 		}
 119264 	} else if int32(*(*uint8)(unsafe.Pointer(zPath))) == '[' {
 119265 		i = U32(0)
 119266 		j = U32(1)
 119267 		for int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zPath + uintptr(j)))])&0x04 != 0 {
 119268 			i = i*U32(10) + U32(*(*uint8)(unsafe.Pointer(zPath + uintptr(j)))) - U32('0')
 119269 			j++
 119270 		}
 119271 		if j < U32(2) || int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(j)))) != ']' {
 119272 			if int32(*(*uint8)(unsafe.Pointer(zPath + 1))) == '#' {
 119273 				var pBase uintptr = pRoot
 119274 				var iBase int32 = int32(iRoot)
 119275 				if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_ARRAY {
 119276 					return uintptr(0)
 119277 				}
 119278 				for {
 119279 					for j <= (*JsonNode)(unsafe.Pointer(pBase)).Fn {
 119280 						if int32((*JsonNode)(unsafe.Pointer(pBase+uintptr(j)*12)).FjnFlags)&JNODE_REMOVE == 0 {
 119281 							i++
 119282 						}
 119283 						j = j + jsonNodeSize(tls, pBase+uintptr(j)*12)
 119284 					}
 119285 					if int32((*JsonNode)(unsafe.Pointer(pBase)).FjnFlags)&JNODE_APPEND == 0 {
 119286 						break
 119287 					}
 119288 
 119289 					iBase = int32(U32(iBase) + *(*U32)(unsafe.Pointer(pBase + 8)))
 119290 					pBase = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iBase)*12
 119291 					j = U32(1)
 119292 				}
 119293 				j = U32(2)
 119294 				if int32(*(*uint8)(unsafe.Pointer(zPath + 2))) == '-' && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zPath + 3))])&0x04 != 0 {
 119295 					var x uint32 = uint32(0)
 119296 					j = U32(3)
 119297 					for __ccgo := true; __ccgo; __ccgo = int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zPath + uintptr(j)))])&0x04 != 0 {
 119298 						x = x*uint32(10) + uint32(*(*uint8)(unsafe.Pointer(zPath + uintptr(j)))) - uint32('0')
 119299 						j++
 119300 					}
 119301 					if x > i {
 119302 						return uintptr(0)
 119303 					}
 119304 					i = i - x
 119305 				}
 119306 				if int32(*(*uint8)(unsafe.Pointer(zPath + uintptr(j)))) != ']' {
 119307 					*(*uintptr)(unsafe.Pointer(pzErr)) = zPath
 119308 					return uintptr(0)
 119309 				}
 119310 			} else {
 119311 				*(*uintptr)(unsafe.Pointer(pzErr)) = zPath
 119312 				return uintptr(0)
 119313 			}
 119314 		}
 119315 		if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_ARRAY {
 119316 			return uintptr(0)
 119317 		}
 119318 		zPath += uintptr(j + U32(1))
 119319 		j = U32(1)
 119320 		for {
 119321 			for j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn && (i > U32(0) || int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*12)).FjnFlags)&JNODE_REMOVE != 0) {
 119322 				if int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*12)).FjnFlags)&JNODE_REMOVE == 0 {
 119323 					i--
 119324 				}
 119325 				j = j + jsonNodeSize(tls, pRoot+uintptr(j)*12)
 119326 			}
 119327 			if int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags)&JNODE_APPEND == 0 {
 119328 				break
 119329 			}
 119330 
 119331 			iRoot = iRoot + *(*U32)(unsafe.Pointer(pRoot + 8))
 119332 			pRoot = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12
 119333 			j = U32(1)
 119334 		}
 119335 		if j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn {
 119336 			return jsonLookupStep(tls, pParse, iRoot+j, zPath, pApnd, pzErr)
 119337 		}
 119338 		if i == U32(0) && pApnd != 0 {
 119339 			var iStart U32
 119340 			var pNode uintptr
 119341 			iStart = U32(jsonParseAddNode(tls, pParse, uint32(JSON_ARRAY), uint32(1), uintptr(0)))
 119342 			pNode = jsonLookupAppend(tls, pParse, zPath, pApnd, pzErr)
 119343 			if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119344 				return uintptr(0)
 119345 			}
 119346 			if pNode != 0 {
 119347 				pRoot = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12
 119348 
 119349 				*(*U32)(unsafe.Pointer(pRoot + 8)) = iStart - iRoot
 119350 				*(*U8)(unsafe.Pointer(pRoot + 1)) |= U8(JNODE_APPEND)
 119351 
 119352 			}
 119353 			return pNode
 119354 		}
 119355 	} else {
 119356 		*(*uintptr)(unsafe.Pointer(pzErr)) = zPath
 119357 	}
 119358 	return uintptr(0)
 119359 }
 119360 
 119361 func jsonLookupAppend(tls *libc.TLS, pParse uintptr, zPath uintptr, pApnd uintptr, pzErr uintptr) uintptr {
 119362 	*(*int32)(unsafe.Pointer(pApnd)) = 1
 119363 	if int32(*(*uint8)(unsafe.Pointer(zPath))) == 0 {
 119364 		jsonParseAddNode(tls, pParse, uint32(JSON_NULL), uint32(0), uintptr(0))
 119365 		if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119366 			return uintptr(0)
 119367 		}
 119368 		return (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1))*12
 119369 	}
 119370 	if int32(*(*uint8)(unsafe.Pointer(zPath))) == '.' {
 119371 		jsonParseAddNode(tls, pParse, uint32(JSON_OBJECT), uint32(0), uintptr(0))
 119372 	} else if libc.Xstrncmp(tls, zPath, ts+24608, uint32(3)) == 0 {
 119373 		jsonParseAddNode(tls, pParse, uint32(JSON_ARRAY), uint32(0), uintptr(0))
 119374 	} else {
 119375 		return uintptr(0)
 119376 	}
 119377 	if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119378 		return uintptr(0)
 119379 	}
 119380 	return jsonLookupStep(tls, pParse, (*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1), zPath, pApnd, pzErr)
 119381 }
 119382 
 119383 func jsonPathSyntaxError(tls *libc.TLS, zErr uintptr) uintptr {
 119384 	bp := tls.Alloc(8)
 119385 	defer tls.Free(8)
 119386 
 119387 	return Xsqlite3_mprintf(tls, ts+24612, libc.VaList(bp, zErr))
 119388 }
 119389 
 119390 func jsonLookup(tls *libc.TLS, pParse uintptr, zPath uintptr, pApnd uintptr, pCtx uintptr) uintptr {
 119391 	bp := tls.Alloc(4)
 119392 	defer tls.Free(4)
 119393 
 119394 	var pNode uintptr
 119395 	var zMsg uintptr
 119396 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 119397 	pNode = uintptr(0)
 119398 
 119399 	if !(zPath == uintptr(0)) {
 119400 		goto __1
 119401 	}
 119402 	return uintptr(0)
 119403 __1:
 119404 	;
 119405 	if !(int32(*(*uint8)(unsafe.Pointer(zPath))) != '$') {
 119406 		goto __2
 119407 	}
 119408 	*(*uintptr)(unsafe.Pointer(bp)) = zPath
 119409 	goto lookup_err
 119410 __2:
 119411 	;
 119412 	zPath++
 119413 	pNode = jsonLookupStep(tls, pParse, uint32(0), zPath, pApnd, bp)
 119414 	if !(*(*uintptr)(unsafe.Pointer(bp)) == uintptr(0)) {
 119415 		goto __3
 119416 	}
 119417 	return pNode
 119418 __3:
 119419 	;
 119420 lookup_err:
 119421 	(*JsonParse)(unsafe.Pointer(pParse)).FnErr++
 119422 
 119423 	zMsg = jsonPathSyntaxError(tls, *(*uintptr)(unsafe.Pointer(bp)))
 119424 	if !(zMsg != 0) {
 119425 		goto __4
 119426 	}
 119427 	Xsqlite3_result_error(tls, pCtx, zMsg, -1)
 119428 	Xsqlite3_free(tls, zMsg)
 119429 	goto __5
 119430 __4:
 119431 	Xsqlite3_result_error_nomem(tls, pCtx)
 119432 __5:
 119433 	;
 119434 	return uintptr(0)
 119435 }
 119436 
 119437 func jsonWrongNumArgs(tls *libc.TLS, pCtx uintptr, zFuncName uintptr) {
 119438 	bp := tls.Alloc(8)
 119439 	defer tls.Free(8)
 119440 
 119441 	var zMsg uintptr = Xsqlite3_mprintf(tls, ts+24638,
 119442 		libc.VaList(bp, zFuncName))
 119443 	Xsqlite3_result_error(tls, pCtx, zMsg, -1)
 119444 	Xsqlite3_free(tls, zMsg)
 119445 }
 119446 
 119447 func jsonRemoveAllNulls(tls *libc.TLS, pNode uintptr) {
 119448 	var i int32
 119449 	var n int32
 119450 
 119451 	n = int32((*JsonNode)(unsafe.Pointer(pNode)).Fn)
 119452 	for i = 2; i <= n; i = int32(U32(i) + (jsonNodeSize(tls, pNode+uintptr(i)*12) + U32(1))) {
 119453 		switch int32((*JsonNode)(unsafe.Pointer(pNode + uintptr(i)*12)).FeType) {
 119454 		case JSON_NULL:
 119455 			*(*U8)(unsafe.Pointer(pNode + uintptr(i)*12 + 1)) |= U8(JNODE_REMOVE)
 119456 			break
 119457 		case JSON_OBJECT:
 119458 			jsonRemoveAllNulls(tls, pNode+uintptr(i)*12)
 119459 			break
 119460 		}
 119461 	}
 119462 }
 119463 
 119464 func jsonQuoteFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119465 	bp := tls.Alloc(128)
 119466 	defer tls.Free(128)
 119467 
 119468 	_ = argc
 119469 
 119470 	jsonInit(tls, bp, ctx)
 119471 	jsonAppendValue(tls, bp, *(*uintptr)(unsafe.Pointer(argv)))
 119472 	jsonResult(tls, bp)
 119473 	Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE))
 119474 }
 119475 
 119476 func jsonArrayFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119477 	bp := tls.Alloc(128)
 119478 	defer tls.Free(128)
 119479 
 119480 	var i int32
 119481 
 119482 	jsonInit(tls, bp, ctx)
 119483 	jsonAppendChar(tls, bp, uint8('['))
 119484 	for i = 0; i < argc; i++ {
 119485 		jsonAppendSeparator(tls, bp)
 119486 		jsonAppendValue(tls, bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 119487 	}
 119488 	jsonAppendChar(tls, bp, uint8(']'))
 119489 	jsonResult(tls, bp)
 119490 	Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE))
 119491 }
 119492 
 119493 func jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119494 	var p uintptr
 119495 	var n Sqlite3_int64 = int64(0)
 119496 	var i U32
 119497 	var pNode uintptr
 119498 
 119499 	p = jsonParseCached(tls, ctx, argv, ctx)
 119500 	if p == uintptr(0) {
 119501 		return
 119502 	}
 119503 
 119504 	if argc == 2 {
 119505 		var zPath uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 119506 		pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx)
 119507 	} else {
 119508 		pNode = (*JsonParse)(unsafe.Pointer(p)).FaNode
 119509 	}
 119510 	if pNode == uintptr(0) {
 119511 		return
 119512 	}
 119513 	if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) == JSON_ARRAY {
 119514 		for i = U32(1); i <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; n++ {
 119515 			i = i + jsonNodeSize(tls, pNode+uintptr(i)*12)
 119516 		}
 119517 	}
 119518 	Xsqlite3_result_int64(tls, ctx, n)
 119519 }
 119520 
 119521 func jsonExtractFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119522 	bp := tls.Alloc(128)
 119523 	defer tls.Free(128)
 119524 
 119525 	var p uintptr
 119526 	var pNode uintptr
 119527 	var zPath uintptr
 119528 	var flags int32 = int32(Xsqlite3_user_data(tls, ctx))
 119529 
 119530 	if argc < 2 {
 119531 		return
 119532 	}
 119533 	p = jsonParseCached(tls, ctx, argv, ctx)
 119534 	if p == uintptr(0) {
 119535 		return
 119536 	}
 119537 	if argc == 2 {
 119538 		zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 119539 		if zPath == uintptr(0) {
 119540 			return
 119541 		}
 119542 		if flags&JSON_ABPATH != 0 {
 119543 			if int32(*(*uint8)(unsafe.Pointer(zPath))) != '$' {
 119544 				jsonInit(tls, bp, ctx)
 119545 				if int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zPath))])&0x04 != 0 {
 119546 					jsonAppendRaw(tls, bp, ts+24681, uint32(2))
 119547 					jsonAppendRaw(tls, bp, zPath, uint32(int32(libc.Xstrlen(tls, zPath))))
 119548 					jsonAppendRaw(tls, bp, ts+4998, uint32(2))
 119549 				} else {
 119550 					jsonAppendRaw(tls, bp, ts+24684, uint32(1+libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zPath))) != '[')))
 119551 					jsonAppendRaw(tls, bp, zPath, uint32(int32(libc.Xstrlen(tls, zPath))))
 119552 					jsonAppendChar(tls, bp, uint8(0))
 119553 				}
 119554 				if (*JsonString)(unsafe.Pointer(bp)).FbErr != 0 {
 119555 					pNode = uintptr(0)
 119556 				} else {
 119557 					pNode = jsonLookup(tls, p, (*JsonString)(unsafe.Pointer(bp)).FzBuf, uintptr(0), ctx)
 119558 				}
 119559 				jsonReset(tls, bp)
 119560 			} else {
 119561 				pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx)
 119562 			}
 119563 			if pNode != 0 {
 119564 				if flags&JSON_JSON != 0 {
 119565 					jsonReturnJson(tls, pNode, ctx, uintptr(0))
 119566 				} else {
 119567 					jsonReturn(tls, pNode, ctx, uintptr(0))
 119568 					Xsqlite3_result_subtype(tls, ctx, uint32(0))
 119569 				}
 119570 			}
 119571 		} else {
 119572 			pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx)
 119573 			if int32((*JsonParse)(unsafe.Pointer(p)).FnErr) == 0 && pNode != 0 {
 119574 				jsonReturn(tls, pNode, ctx, uintptr(0))
 119575 			}
 119576 		}
 119577 	} else {
 119578 		var i int32
 119579 		jsonInit(tls, bp, ctx)
 119580 		jsonAppendChar(tls, bp, uint8('['))
 119581 		for i = 1; i < argc; i++ {
 119582 			zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 119583 			pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx)
 119584 			if (*JsonParse)(unsafe.Pointer(p)).FnErr != 0 {
 119585 				break
 119586 			}
 119587 			jsonAppendSeparator(tls, bp)
 119588 			if pNode != 0 {
 119589 				jsonRenderNode(tls, pNode, bp, uintptr(0))
 119590 			} else {
 119591 				jsonAppendRaw(tls, bp, ts+6181, uint32(4))
 119592 			}
 119593 		}
 119594 		if i == argc {
 119595 			jsonAppendChar(tls, bp, uint8(']'))
 119596 			jsonResult(tls, bp)
 119597 			Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE))
 119598 		}
 119599 		jsonReset(tls, bp)
 119600 	}
 119601 }
 119602 
 119603 func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) uintptr {
 119604 	var i U32
 119605 	var j U32
 119606 	var iRoot U32
 119607 	var pTarget uintptr
 119608 	if int32((*JsonNode)(unsafe.Pointer(pPatch)).FeType) != JSON_OBJECT {
 119609 		return pPatch
 119610 	}
 119611 
 119612 	pTarget = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*12
 119613 
 119614 	if int32((*JsonNode)(unsafe.Pointer(pTarget)).FeType) != JSON_OBJECT {
 119615 		jsonRemoveAllNulls(tls, pPatch)
 119616 		return pPatch
 119617 	}
 119618 	iRoot = iTarget
 119619 	for i = U32(1); i < (*JsonNode)(unsafe.Pointer(pPatch)).Fn; i = i + (jsonNodeSize(tls, pPatch+uintptr(i+U32(1))*12) + U32(1)) {
 119620 		var nKey U32
 119621 		var zKey uintptr
 119622 
 119623 		nKey = (*JsonNode)(unsafe.Pointer(pPatch + uintptr(i)*12)).Fn
 119624 		zKey = *(*uintptr)(unsafe.Pointer(pPatch + uintptr(i)*12 + 8))
 119625 
 119626 		for j = U32(1); j < (*JsonNode)(unsafe.Pointer(pTarget)).Fn; j = j + (jsonNodeSize(tls, pTarget+uintptr(j+U32(1))*12) + U32(1)) {
 119627 			if (*JsonNode)(unsafe.Pointer(pTarget+uintptr(j)*12)).Fn == nKey && libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(pTarget + uintptr(j)*12 + 8)), zKey, nKey) == 0 {
 119628 				if int32((*JsonNode)(unsafe.Pointer(pTarget+uintptr(j+U32(1))*12)).FjnFlags)&(JNODE_REMOVE|JNODE_PATCH) != 0 {
 119629 					break
 119630 				}
 119631 				if int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr(i+U32(1))*12)).FeType) == JSON_NULL {
 119632 					*(*U8)(unsafe.Pointer(pTarget + uintptr(j+U32(1))*12 + 1)) |= U8(JNODE_REMOVE)
 119633 				} else {
 119634 					var pNew uintptr = jsonMergePatch(tls, pParse, iTarget+j+U32(1), pPatch+uintptr(i+U32(1))*12)
 119635 					if pNew == uintptr(0) {
 119636 						return uintptr(0)
 119637 					}
 119638 					pTarget = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*12
 119639 					if pNew != pTarget+uintptr(j+U32(1))*12 {
 119640 						*(*uintptr)(unsafe.Pointer(pTarget + uintptr(j+U32(1))*12 + 8)) = pNew
 119641 						*(*U8)(unsafe.Pointer(pTarget + uintptr(j+U32(1))*12 + 1)) |= U8(JNODE_PATCH)
 119642 					}
 119643 				}
 119644 				break
 119645 			}
 119646 		}
 119647 		if j >= (*JsonNode)(unsafe.Pointer(pTarget)).Fn && int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr(i+U32(1))*12)).FeType) != JSON_NULL {
 119648 			var iStart int32
 119649 			var iPatch int32
 119650 			iStart = jsonParseAddNode(tls, pParse, uint32(JSON_OBJECT), uint32(2), uintptr(0))
 119651 			jsonParseAddNode(tls, pParse, uint32(JSON_STRING), nKey, zKey)
 119652 			iPatch = jsonParseAddNode(tls, pParse, uint32(JSON_TRUE), uint32(0), uintptr(0))
 119653 			if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
 119654 				return uintptr(0)
 119655 			}
 119656 			jsonRemoveAllNulls(tls, pPatch)
 119657 			pTarget = (*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*12
 119658 
 119659 			*(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12 + 1)) |= U8(JNODE_APPEND)
 119660 
 119661 			*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*12 + 8)) = U32(iStart) - iRoot
 119662 			iRoot = U32(iStart)
 119663 
 119664 			*(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*12 + 1)) |= U8(JNODE_PATCH)
 119665 			*(*uintptr)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*12 + 8)) = pPatch + uintptr(i+U32(1))*12
 119666 		}
 119667 	}
 119668 	return pTarget
 119669 }
 119670 
 119671 func jsonPatchFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119672 	bp := tls.Alloc(64)
 119673 	defer tls.Free(64)
 119674 
 119675 	var pResult uintptr
 119676 
 119677 	_ = argc
 119678 	if jsonParse(tls, bp, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0 {
 119679 		return
 119680 	}
 119681 	if jsonParse(tls, bp+32, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))) != 0 {
 119682 		jsonParseReset(tls, bp)
 119683 		return
 119684 	}
 119685 	pResult = jsonMergePatch(tls, bp, uint32(0), (*JsonParse)(unsafe.Pointer(bp+32)).FaNode)
 119686 
 119687 	if pResult != 0 {
 119688 		jsonReturnJson(tls, pResult, ctx, uintptr(0))
 119689 	} else {
 119690 		Xsqlite3_result_error_nomem(tls, ctx)
 119691 	}
 119692 	jsonParseReset(tls, bp)
 119693 	jsonParseReset(tls, bp+32)
 119694 }
 119695 
 119696 func jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119697 	bp := tls.Alloc(128)
 119698 	defer tls.Free(128)
 119699 
 119700 	var i int32
 119701 
 119702 	var z uintptr
 119703 	var n U32
 119704 
 119705 	if argc&1 != 0 {
 119706 		Xsqlite3_result_error(tls, ctx,
 119707 			ts+24687, -1)
 119708 		return
 119709 	}
 119710 	jsonInit(tls, bp, ctx)
 119711 	jsonAppendChar(tls, bp, uint8('{'))
 119712 	for i = 0; i < argc; i = i + 2 {
 119713 		if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4))) != SQLITE_TEXT {
 119714 			Xsqlite3_result_error(tls, ctx, ts+24738, -1)
 119715 			jsonReset(tls, bp)
 119716 			return
 119717 		}
 119718 		jsonAppendSeparator(tls, bp)
 119719 		z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 119720 		n = U32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4))))
 119721 		jsonAppendString(tls, bp, z, n)
 119722 		jsonAppendChar(tls, bp, uint8(':'))
 119723 		jsonAppendValue(tls, bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i+1)*4)))
 119724 	}
 119725 	jsonAppendChar(tls, bp, uint8('}'))
 119726 	jsonResult(tls, bp)
 119727 	Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE))
 119728 }
 119729 
 119730 func jsonRemoveFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119731 	bp := tls.Alloc(32)
 119732 	defer tls.Free(32)
 119733 
 119734 	var pNode uintptr
 119735 	var zPath uintptr
 119736 	var i U32
 119737 
 119738 	if !(argc < 1) {
 119739 		goto __1
 119740 	}
 119741 	return
 119742 __1:
 119743 	;
 119744 	if !(jsonParse(tls, bp, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) {
 119745 		goto __2
 119746 	}
 119747 	return
 119748 __2:
 119749 	;
 119750 	i = U32(1)
 119751 __3:
 119752 	if !(i < U32(argc)) {
 119753 		goto __5
 119754 	}
 119755 	zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 119756 	if !(zPath == uintptr(0)) {
 119757 		goto __6
 119758 	}
 119759 	goto remove_done
 119760 __6:
 119761 	;
 119762 	pNode = jsonLookup(tls, bp, zPath, uintptr(0), ctx)
 119763 	if !((*JsonParse)(unsafe.Pointer(bp)).FnErr != 0) {
 119764 		goto __7
 119765 	}
 119766 	goto remove_done
 119767 __7:
 119768 	;
 119769 	if !(pNode != 0) {
 119770 		goto __8
 119771 	}
 119772 	*(*U8)(unsafe.Pointer(pNode + 1)) |= U8(JNODE_REMOVE)
 119773 __8:
 119774 	;
 119775 	goto __4
 119776 __4:
 119777 	i++
 119778 	goto __3
 119779 	goto __5
 119780 __5:
 119781 	;
 119782 	if !(int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp)).FaNode)).FjnFlags)&JNODE_REMOVE == 0) {
 119783 		goto __9
 119784 	}
 119785 	jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp)).FaNode, ctx, uintptr(0))
 119786 __9:
 119787 	;
 119788 remove_done:
 119789 	jsonParseReset(tls, bp)
 119790 }
 119791 
 119792 func jsonReplaceFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119793 	bp := tls.Alloc(32)
 119794 	defer tls.Free(32)
 119795 
 119796 	var pNode uintptr
 119797 	var zPath uintptr
 119798 	var i U32
 119799 
 119800 	if !(argc < 1) {
 119801 		goto __1
 119802 	}
 119803 	return
 119804 __1:
 119805 	;
 119806 	if !(argc&1 == 0) {
 119807 		goto __2
 119808 	}
 119809 	jsonWrongNumArgs(tls, ctx, ts+15380)
 119810 	return
 119811 __2:
 119812 	;
 119813 	if !(jsonParse(tls, bp, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) {
 119814 		goto __3
 119815 	}
 119816 	return
 119817 __3:
 119818 	;
 119819 	i = U32(1)
 119820 __4:
 119821 	if !(i < U32(argc)) {
 119822 		goto __6
 119823 	}
 119824 	zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 119825 	pNode = jsonLookup(tls, bp, zPath, uintptr(0), ctx)
 119826 	if !((*JsonParse)(unsafe.Pointer(bp)).FnErr != 0) {
 119827 		goto __7
 119828 	}
 119829 	goto replace_err
 119830 __7:
 119831 	;
 119832 	if !(pNode != 0) {
 119833 		goto __8
 119834 	}
 119835 
 119836 	*(*U8)(unsafe.Pointer(pNode + 1)) |= U8(int32(U8(JNODE_REPLACE)))
 119837 
 119838 	*(*U32)(unsafe.Pointer(pNode + 8)) = i + U32(1)
 119839 __8:
 119840 	;
 119841 	goto __5
 119842 __5:
 119843 	i = i + U32(2)
 119844 	goto __4
 119845 	goto __6
 119846 __6:
 119847 	;
 119848 	if !(int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp)).FaNode)).FjnFlags)&JNODE_REPLACE != 0) {
 119849 		goto __9
 119850 	}
 119851 
 119852 	Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp)).FaNode + 8)))*4)))
 119853 	goto __10
 119854 __9:
 119855 	jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp)).FaNode, ctx, argv)
 119856 __10:
 119857 	;
 119858 replace_err:
 119859 	jsonParseReset(tls, bp)
 119860 }
 119861 
 119862 func jsonSetFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119863 	bp := tls.Alloc(36)
 119864 	defer tls.Free(36)
 119865 
 119866 	var pNode uintptr
 119867 	var zPath uintptr
 119868 	var i U32
 119869 
 119870 	var bIsSet int32
 119871 	bIsSet = libc.Bool32(Xsqlite3_user_data(tls, ctx) != uintptr(0))
 119872 
 119873 	if !(argc < 1) {
 119874 		goto __1
 119875 	}
 119876 	return
 119877 __1:
 119878 	;
 119879 	if !(argc&1 == 0) {
 119880 		goto __2
 119881 	}
 119882 	jsonWrongNumArgs(tls, ctx, func() uintptr {
 119883 		if bIsSet != 0 {
 119884 			return ts + 24772
 119885 		}
 119886 		return ts + 24776
 119887 	}())
 119888 	return
 119889 __2:
 119890 	;
 119891 	if !(jsonParse(tls, bp, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) {
 119892 		goto __3
 119893 	}
 119894 	return
 119895 __3:
 119896 	;
 119897 	i = U32(1)
 119898 __4:
 119899 	if !(i < U32(argc)) {
 119900 		goto __6
 119901 	}
 119902 	zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 119903 	*(*int32)(unsafe.Pointer(bp + 32)) = 0
 119904 	pNode = jsonLookup(tls, bp, zPath, bp+32, ctx)
 119905 	if !((*JsonParse)(unsafe.Pointer(bp)).Foom != 0) {
 119906 		goto __7
 119907 	}
 119908 	Xsqlite3_result_error_nomem(tls, ctx)
 119909 	goto jsonSetDone
 119910 	goto __8
 119911 __7:
 119912 	if !((*JsonParse)(unsafe.Pointer(bp)).FnErr != 0) {
 119913 		goto __9
 119914 	}
 119915 	goto jsonSetDone
 119916 	goto __10
 119917 __9:
 119918 	if !(pNode != 0 && (*(*int32)(unsafe.Pointer(bp + 32)) != 0 || bIsSet != 0)) {
 119919 		goto __11
 119920 	}
 119921 
 119922 	*(*U8)(unsafe.Pointer(pNode + 1)) |= U8(int32(U8(JNODE_REPLACE)))
 119923 	*(*U32)(unsafe.Pointer(pNode + 8)) = i + U32(1)
 119924 __11:
 119925 	;
 119926 __10:
 119927 	;
 119928 __8:
 119929 	;
 119930 	goto __5
 119931 __5:
 119932 	i = i + U32(2)
 119933 	goto __4
 119934 	goto __6
 119935 __6:
 119936 	;
 119937 	if !(int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp)).FaNode)).FjnFlags)&JNODE_REPLACE != 0) {
 119938 		goto __12
 119939 	}
 119940 
 119941 	Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp)).FaNode + 8)))*4)))
 119942 	goto __13
 119943 __12:
 119944 	jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp)).FaNode, ctx, argv)
 119945 __13:
 119946 	;
 119947 jsonSetDone:
 119948 	jsonParseReset(tls, bp)
 119949 }
 119950 
 119951 func jsonTypeFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119952 	var p uintptr
 119953 	var zPath uintptr
 119954 	var pNode uintptr
 119955 
 119956 	p = jsonParseCached(tls, ctx, argv, ctx)
 119957 	if p == uintptr(0) {
 119958 		return
 119959 	}
 119960 	if argc == 2 {
 119961 		zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 119962 		pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx)
 119963 	} else {
 119964 		pNode = (*JsonParse)(unsafe.Pointer(p)).FaNode
 119965 	}
 119966 	if pNode != 0 {
 119967 		Xsqlite3_result_text(tls, ctx, jsonType[(*JsonNode)(unsafe.Pointer(pNode)).FeType], -1, uintptr(0))
 119968 	}
 119969 }
 119970 
 119971 func jsonValidFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119972 	var p uintptr
 119973 	_ = argc
 119974 	p = jsonParseCached(tls, ctx, argv, uintptr(0))
 119975 	Xsqlite3_result_int(tls, ctx, libc.Bool32(p != uintptr(0)))
 119976 }
 119977 
 119978 func jsonArrayStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 119979 	var pStr uintptr
 119980 	_ = argc
 119981 	pStr = Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(JsonString{})))
 119982 	if pStr != 0 {
 119983 		if (*JsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) {
 119984 			jsonInit(tls, pStr, ctx)
 119985 			jsonAppendChar(tls, pStr, uint8('['))
 119986 		} else if (*JsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) {
 119987 			jsonAppendChar(tls, pStr, uint8(','))
 119988 		}
 119989 		(*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx
 119990 		jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv)))
 119991 	}
 119992 }
 119993 
 119994 func jsonArrayCompute(tls *libc.TLS, ctx uintptr, isFinal int32) {
 119995 	var pStr uintptr
 119996 	pStr = Xsqlite3_aggregate_context(tls, ctx, 0)
 119997 	if pStr != 0 {
 119998 		(*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx
 119999 		jsonAppendChar(tls, pStr, uint8(']'))
 120000 		if (*JsonString)(unsafe.Pointer(pStr)).FbErr != 0 {
 120001 			if int32((*JsonString)(unsafe.Pointer(pStr)).FbErr) == 1 {
 120002 				Xsqlite3_result_error_nomem(tls, ctx)
 120003 			}
 120004 
 120005 		} else if isFinal != 0 {
 120006 			Xsqlite3_result_text(tls, ctx, (*JsonString)(unsafe.Pointer(pStr)).FzBuf, int32((*JsonString)(unsafe.Pointer(pStr)).FnUsed),
 120007 				func() uintptr {
 120008 					if (*JsonString)(unsafe.Pointer(pStr)).FbStatic != 0 {
 120009 						return libc.UintptrFromInt32(-1)
 120010 					}
 120011 					return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))
 120012 				}())
 120013 			(*JsonString)(unsafe.Pointer(pStr)).FbStatic = U8(1)
 120014 		} else {
 120015 			Xsqlite3_result_text(tls, ctx, (*JsonString)(unsafe.Pointer(pStr)).FzBuf, int32((*JsonString)(unsafe.Pointer(pStr)).FnUsed), libc.UintptrFromInt32(-1))
 120016 			(*JsonString)(unsafe.Pointer(pStr)).FnUsed--
 120017 		}
 120018 	} else {
 120019 		Xsqlite3_result_text(tls, ctx, ts+24783, 2, uintptr(0))
 120020 	}
 120021 	Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE))
 120022 }
 120023 
 120024 func jsonArrayValue(tls *libc.TLS, ctx uintptr) {
 120025 	jsonArrayCompute(tls, ctx, 0)
 120026 }
 120027 
 120028 func jsonArrayFinal(tls *libc.TLS, ctx uintptr) {
 120029 	jsonArrayCompute(tls, ctx, 1)
 120030 }
 120031 
 120032 func jsonGroupInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 120033 	var i uint32
 120034 	var inStr int32 = 0
 120035 	var nNest int32 = 0
 120036 	var z uintptr
 120037 	var c uint8
 120038 	var pStr uintptr
 120039 	_ = argc
 120040 	_ = argv
 120041 	pStr = Xsqlite3_aggregate_context(tls, ctx, 0)
 120042 
 120043 	if !(pStr != 0) {
 120044 		return
 120045 	}
 120046 	z = (*JsonString)(unsafe.Pointer(pStr)).FzBuf
 120047 	for i = uint32(1); U64(i) < (*JsonString)(unsafe.Pointer(pStr)).FnUsed && (int32(libc.AssignUint8(&c, *(*uint8)(unsafe.Pointer(z + uintptr(i))))) != ',' || inStr != 0 || nNest != 0); i++ {
 120048 		if int32(c) == '"' {
 120049 			inStr = libc.BoolInt32(!(inStr != 0))
 120050 		} else if int32(c) == '\\' {
 120051 			i++
 120052 		} else if !(inStr != 0) {
 120053 			if int32(c) == '{' || int32(c) == '[' {
 120054 				nNest++
 120055 			}
 120056 			if int32(c) == '}' || int32(c) == ']' {
 120057 				nNest--
 120058 			}
 120059 		}
 120060 	}
 120061 	if U64(i) < (*JsonString)(unsafe.Pointer(pStr)).FnUsed {
 120062 		*(*U64)(unsafe.Pointer(pStr + 16)) -= U64(i)
 120063 		libc.Xmemmove(tls, z+1, z+uintptr(i+uint32(1)), Size_t((*JsonString)(unsafe.Pointer(pStr)).FnUsed)-Size_t(1))
 120064 		*(*uint8)(unsafe.Pointer(z + uintptr((*JsonString)(unsafe.Pointer(pStr)).FnUsed))) = uint8(0)
 120065 	} else {
 120066 		(*JsonString)(unsafe.Pointer(pStr)).FnUsed = uint64(1)
 120067 	}
 120068 }
 120069 
 120070 func jsonObjectStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
 120071 	var pStr uintptr
 120072 	var z uintptr
 120073 	var n U32
 120074 	_ = argc
 120075 	pStr = Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(JsonString{})))
 120076 	if pStr != 0 {
 120077 		if (*JsonString)(unsafe.Pointer(pStr)).FzBuf == uintptr(0) {
 120078 			jsonInit(tls, pStr, ctx)
 120079 			jsonAppendChar(tls, pStr, uint8('{'))
 120080 		} else if (*JsonString)(unsafe.Pointer(pStr)).FnUsed > uint64(1) {
 120081 			jsonAppendChar(tls, pStr, uint8(','))
 120082 		}
 120083 		(*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx
 120084 		z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
 120085 		n = U32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))))
 120086 		jsonAppendString(tls, pStr, z, n)
 120087 		jsonAppendChar(tls, pStr, uint8(':'))
 120088 		jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 120089 	}
 120090 }
 120091 
 120092 func jsonObjectCompute(tls *libc.TLS, ctx uintptr, isFinal int32) {
 120093 	var pStr uintptr
 120094 	pStr = Xsqlite3_aggregate_context(tls, ctx, 0)
 120095 	if pStr != 0 {
 120096 		jsonAppendChar(tls, pStr, uint8('}'))
 120097 		if (*JsonString)(unsafe.Pointer(pStr)).FbErr != 0 {
 120098 			if int32((*JsonString)(unsafe.Pointer(pStr)).FbErr) == 1 {
 120099 				Xsqlite3_result_error_nomem(tls, ctx)
 120100 			}
 120101 
 120102 		} else if isFinal != 0 {
 120103 			Xsqlite3_result_text(tls, ctx, (*JsonString)(unsafe.Pointer(pStr)).FzBuf, int32((*JsonString)(unsafe.Pointer(pStr)).FnUsed),
 120104 				func() uintptr {
 120105 					if (*JsonString)(unsafe.Pointer(pStr)).FbStatic != 0 {
 120106 						return libc.UintptrFromInt32(-1)
 120107 					}
 120108 					return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))
 120109 				}())
 120110 			(*JsonString)(unsafe.Pointer(pStr)).FbStatic = U8(1)
 120111 		} else {
 120112 			Xsqlite3_result_text(tls, ctx, (*JsonString)(unsafe.Pointer(pStr)).FzBuf, int32((*JsonString)(unsafe.Pointer(pStr)).FnUsed), libc.UintptrFromInt32(-1))
 120113 			(*JsonString)(unsafe.Pointer(pStr)).FnUsed--
 120114 		}
 120115 	} else {
 120116 		Xsqlite3_result_text(tls, ctx, ts+24786, 2, uintptr(0))
 120117 	}
 120118 	Xsqlite3_result_subtype(tls, ctx, uint32(JSON_SUBTYPE))
 120119 }
 120120 
 120121 func jsonObjectValue(tls *libc.TLS, ctx uintptr) {
 120122 	jsonObjectCompute(tls, ctx, 0)
 120123 }
 120124 
 120125 func jsonObjectFinal(tls *libc.TLS, ctx uintptr) {
 120126 	jsonObjectCompute(tls, ctx, 1)
 120127 }
 120128 
 120129 // ***************************************************************************
 120130 //
 120131 // The json_each virtual table
 120132 type JsonEachCursor1 = struct {
 120133 	Fbase        Sqlite3_vtab_cursor
 120134 	FiRowid      U32
 120135 	FiBegin      U32
 120136 	Fi           U32
 120137 	FiEnd        U32
 120138 	FeType       U8
 120139 	FbRecursive  U8
 120140 	F__ccgo_pad1 [2]byte
 120141 	FzJson       uintptr
 120142 	FzRoot       uintptr
 120143 	FsParse      JsonParse
 120144 }
 120145 
 120146 // ***************************************************************************
 120147 //
 120148 // The json_each virtual table
 120149 type JsonEachCursor = JsonEachCursor1
 120150 
 120151 func jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 120152 	var pNew uintptr
 120153 	var rc int32
 120154 
 120155 	_ = pzErr
 120156 	_ = argv
 120157 	_ = argc
 120158 	_ = pAux
 120159 	rc = Xsqlite3_declare_vtab(tls, db,
 120160 		ts+24789)
 120161 	if rc == SQLITE_OK {
 120162 		pNew = libc.AssignPtrUintptr(ppVtab, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Sqlite3_vtab{}))))
 120163 		if pNew == uintptr(0) {
 120164 			return SQLITE_NOMEM
 120165 		}
 120166 		libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Sqlite3_vtab{})))
 120167 		Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0)
 120168 	}
 120169 	return rc
 120170 }
 120171 
 120172 func jsonEachDisconnect(tls *libc.TLS, pVtab uintptr) int32 {
 120173 	Xsqlite3_free(tls, pVtab)
 120174 	return SQLITE_OK
 120175 }
 120176 
 120177 func jsonEachOpenEach(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 {
 120178 	var pCur uintptr
 120179 
 120180 	_ = p
 120181 	pCur = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(JsonEachCursor{})))
 120182 	if pCur == uintptr(0) {
 120183 		return SQLITE_NOMEM
 120184 	}
 120185 	libc.Xmemset(tls, pCur, 0, uint32(unsafe.Sizeof(JsonEachCursor{})))
 120186 	*(*uintptr)(unsafe.Pointer(ppCursor)) = pCur
 120187 	return SQLITE_OK
 120188 }
 120189 
 120190 func jsonEachOpenTree(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 {
 120191 	var rc int32 = jsonEachOpenEach(tls, p, ppCursor)
 120192 	if rc == SQLITE_OK {
 120193 		var pCur uintptr = *(*uintptr)(unsafe.Pointer(ppCursor))
 120194 		(*JsonEachCursor)(unsafe.Pointer(pCur)).FbRecursive = U8(1)
 120195 	}
 120196 	return rc
 120197 }
 120198 
 120199 func jsonEachCursorReset(tls *libc.TLS, p uintptr) {
 120200 	Xsqlite3_free(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzJson)
 120201 	Xsqlite3_free(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot)
 120202 	jsonParseReset(tls, p+32)
 120203 	(*JsonEachCursor)(unsafe.Pointer(p)).FiRowid = U32(0)
 120204 	(*JsonEachCursor)(unsafe.Pointer(p)).Fi = U32(0)
 120205 	(*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = U32(0)
 120206 	(*JsonEachCursor)(unsafe.Pointer(p)).FeType = U8(0)
 120207 	(*JsonEachCursor)(unsafe.Pointer(p)).FzJson = uintptr(0)
 120208 	(*JsonEachCursor)(unsafe.Pointer(p)).FzRoot = uintptr(0)
 120209 }
 120210 
 120211 func jsonEachClose(tls *libc.TLS, cur uintptr) int32 {
 120212 	var p uintptr = cur
 120213 	jsonEachCursorReset(tls, p)
 120214 	Xsqlite3_free(tls, cur)
 120215 	return SQLITE_OK
 120216 }
 120217 
 120218 func jsonEachEof(tls *libc.TLS, cur uintptr) int32 {
 120219 	var p uintptr = cur
 120220 	return libc.Bool32((*JsonEachCursor)(unsafe.Pointer(p)).Fi >= (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd)
 120221 }
 120222 
 120223 func jsonEachNext(tls *libc.TLS, cur uintptr) int32 {
 120224 	var p uintptr = cur
 120225 	if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 {
 120226 		if int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*12)).FjnFlags)&JNODE_LABEL != 0 {
 120227 			(*JsonEachCursor)(unsafe.Pointer(p)).Fi++
 120228 		}
 120229 		(*JsonEachCursor)(unsafe.Pointer(p)).Fi++
 120230 		(*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++
 120231 		if (*JsonEachCursor)(unsafe.Pointer(p)).Fi < (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd {
 120232 			var iUp U32 = *(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4))
 120233 			var pUp uintptr = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(iUp)*12
 120234 			(*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer(pUp)).FeType
 120235 			if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == JSON_ARRAY {
 120236 				if iUp == (*JsonEachCursor)(unsafe.Pointer(p)).Fi-U32(1) {
 120237 					*(*U32)(unsafe.Pointer(pUp + 8)) = U32(0)
 120238 				} else {
 120239 					*(*U32)(unsafe.Pointer(pUp + 8))++
 120240 				}
 120241 			}
 120242 		}
 120243 	} else {
 120244 		switch int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) {
 120245 		case JSON_ARRAY:
 120246 			{
 120247 				*(*U32)(unsafe.Pointer(p + 12)) += jsonNodeSize(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*12)
 120248 				(*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++
 120249 				break
 120250 
 120251 			}
 120252 			fallthrough
 120253 		case JSON_OBJECT:
 120254 			{
 120255 				*(*U32)(unsafe.Pointer(p + 12)) += U32(1) + jsonNodeSize(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi+U32(1))*12)
 120256 				(*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++
 120257 				break
 120258 
 120259 			}
 120260 			fallthrough
 120261 		default:
 120262 			{
 120263 				(*JsonEachCursor)(unsafe.Pointer(p)).Fi = (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd
 120264 				break
 120265 
 120266 			}
 120267 		}
 120268 	}
 120269 	return SQLITE_OK
 120270 }
 120271 
 120272 func jsonAppendObjectPathElement(tls *libc.TLS, pStr uintptr, pNode uintptr) {
 120273 	bp := tls.Alloc(16)
 120274 	defer tls.Free(16)
 120275 
 120276 	var jj int32
 120277 	var nn int32
 120278 	var z uintptr
 120279 
 120280 	z = *(*uintptr)(unsafe.Pointer(pNode + 8))
 120281 	nn = int32((*JsonNode)(unsafe.Pointer(pNode)).Fn)
 120282 
 120283 	if nn > 2 && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 1))])&0x02 != 0 {
 120284 		for jj = 2; jj < nn-1 && int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(jj)))])&0x06 != 0; jj++ {
 120285 		}
 120286 		if jj == nn-1 {
 120287 			z++
 120288 			nn = nn - 2
 120289 		}
 120290 	}
 120291 	jsonPrintf(tls, nn+2, pStr, ts+24872, libc.VaList(bp, nn, z))
 120292 }
 120293 
 120294 func jsonEachComputePath(tls *libc.TLS, p uintptr, pStr uintptr, i U32) {
 120295 	bp := tls.Alloc(8)
 120296 	defer tls.Free(8)
 120297 
 120298 	var pNode uintptr
 120299 	var pUp uintptr
 120300 	var iUp U32
 120301 	if i == U32(0) {
 120302 		jsonAppendChar(tls, pStr, uint8('$'))
 120303 		return
 120304 	}
 120305 	iUp = *(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr(i)*4))
 120306 	jsonEachComputePath(tls, p, pStr, iUp)
 120307 	pNode = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(i)*12
 120308 	pUp = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(iUp)*12
 120309 	if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == JSON_ARRAY {
 120310 		jsonPrintf(tls, 30, pStr, ts+24878, libc.VaList(bp, *(*U32)(unsafe.Pointer(pUp + 8))))
 120311 	} else {
 120312 		if int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags)&JNODE_LABEL == 0 {
 120313 			pNode -= 12
 120314 		}
 120315 		jsonAppendObjectPathElement(tls, pStr, pNode)
 120316 	}
 120317 }
 120318 
 120319 func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 {
 120320 	bp := tls.Alloc(264)
 120321 	defer tls.Free(264)
 120322 
 120323 	var p uintptr = cur
 120324 	var pThis uintptr = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*12
 120325 	switch i {
 120326 	case JEACH_KEY:
 120327 		{
 120328 			if (*JsonEachCursor)(unsafe.Pointer(p)).Fi == U32(0) {
 120329 				break
 120330 			}
 120331 			if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_OBJECT {
 120332 				jsonReturn(tls, pThis, ctx, uintptr(0))
 120333 			} else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_ARRAY {
 120334 				var iKey U32
 120335 				if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 {
 120336 					if (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid == U32(0) {
 120337 						break
 120338 					}
 120339 
 120340 					iKey = *(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))*12 + 8))
 120341 				} else {
 120342 					iKey = (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid
 120343 				}
 120344 				Xsqlite3_result_int64(tls, ctx, Sqlite3_int64(iKey))
 120345 			}
 120346 			break
 120347 
 120348 		}
 120349 	case JEACH_VALUE:
 120350 		{
 120351 			if int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags)&JNODE_LABEL != 0 {
 120352 				pThis += 12
 120353 			}
 120354 			jsonReturn(tls, pThis, ctx, uintptr(0))
 120355 			break
 120356 
 120357 		}
 120358 	case JEACH_TYPE:
 120359 		{
 120360 			if int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags)&JNODE_LABEL != 0 {
 120361 				pThis += 12
 120362 			}
 120363 			Xsqlite3_result_text(tls, ctx, jsonType[(*JsonNode)(unsafe.Pointer(pThis)).FeType], -1, uintptr(0))
 120364 			break
 120365 
 120366 		}
 120367 	case JEACH_ATOM:
 120368 		{
 120369 			if int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags)&JNODE_LABEL != 0 {
 120370 				pThis += 12
 120371 			}
 120372 			if int32((*JsonNode)(unsafe.Pointer(pThis)).FeType) >= JSON_ARRAY {
 120373 				break
 120374 			}
 120375 			jsonReturn(tls, pThis, ctx, uintptr(0))
 120376 			break
 120377 
 120378 		}
 120379 	case JEACH_ID:
 120380 		{
 120381 			Xsqlite3_result_int64(tls, ctx,
 120382 				Sqlite3_int64((*JsonEachCursor)(unsafe.Pointer(p)).Fi)+Sqlite3_int64(libc.Bool32(int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags)&JNODE_LABEL != 0)))
 120383 			break
 120384 
 120385 		}
 120386 	case JEACH_PARENT:
 120387 		{
 120388 			if (*JsonEachCursor)(unsafe.Pointer(p)).Fi > (*JsonEachCursor)(unsafe.Pointer(p)).FiBegin && (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 {
 120389 				Xsqlite3_result_int64(tls, ctx, Sqlite3_int64(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4))))
 120390 			}
 120391 			break
 120392 
 120393 		}
 120394 	case JEACH_FULLKEY:
 120395 		{
 120396 			jsonInit(tls, bp+8, ctx)
 120397 			if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 {
 120398 				jsonEachComputePath(tls, p, bp+8, (*JsonEachCursor)(unsafe.Pointer(p)).Fi)
 120399 			} else {
 120400 				if (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot != 0 {
 120401 					jsonAppendRaw(tls, bp+8, (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot, uint32(int32(libc.Xstrlen(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot))))
 120402 				} else {
 120403 					jsonAppendChar(tls, bp+8, uint8('$'))
 120404 				}
 120405 				if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_ARRAY {
 120406 					jsonPrintf(tls, 30, bp+8, ts+24878, libc.VaList(bp, (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid))
 120407 				} else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_OBJECT {
 120408 					jsonAppendObjectPathElement(tls, bp+8, pThis)
 120409 				}
 120410 			}
 120411 			jsonResult(tls, bp+8)
 120412 			break
 120413 
 120414 		}
 120415 	case JEACH_PATH:
 120416 		{
 120417 			if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 {
 120418 				jsonInit(tls, bp+136, ctx)
 120419 				jsonEachComputePath(tls, p, bp+136, *(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))
 120420 				jsonResult(tls, bp+136)
 120421 				break
 120422 			}
 120423 
 120424 		}
 120425 		fallthrough
 120426 	default:
 120427 		{
 120428 			var zRoot uintptr = (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot
 120429 			if zRoot == uintptr(0) {
 120430 				zRoot = ts + 24883
 120431 			}
 120432 			Xsqlite3_result_text(tls, ctx, zRoot, -1, uintptr(0))
 120433 			break
 120434 
 120435 		}
 120436 	case JEACH_JSON:
 120437 		{
 120438 			Xsqlite3_result_text(tls, ctx, (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson, -1, uintptr(0))
 120439 			break
 120440 
 120441 		}
 120442 	}
 120443 	return SQLITE_OK
 120444 }
 120445 
 120446 func jsonEachRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 {
 120447 	var p uintptr = cur
 120448 	*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Sqlite_int64((*JsonEachCursor)(unsafe.Pointer(p)).FiRowid)
 120449 	return SQLITE_OK
 120450 }
 120451 
 120452 func jsonEachBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 {
 120453 	bp := tls.Alloc(8)
 120454 	defer tls.Free(8)
 120455 
 120456 	var i int32
 120457 
 120458 	var unusableMask int32 = 0
 120459 	var idxMask int32 = 0
 120460 	var pConstraint uintptr
 120461 
 120462 	_ = tab
 120463 	*(*int32)(unsafe.Pointer(bp)) = libc.AssignPtrInt32(bp+1*4, -1)
 120464 	pConstraint = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint
 120465 	i = 0
 120466 __1:
 120467 	if !(i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) {
 120468 		goto __3
 120469 	}
 120470 	{
 120471 		var iCol int32
 120472 		var iMask int32
 120473 		if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < JEACH_JSON {
 120474 			goto __2
 120475 		}
 120476 		iCol = (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - JEACH_JSON
 120477 
 120478 		iMask = int32(1) << iCol
 120479 		if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 {
 120480 			unusableMask = unusableMask | iMask
 120481 		} else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ {
 120482 			*(*int32)(unsafe.Pointer(bp + uintptr(iCol)*4)) = i
 120483 			idxMask = idxMask | iMask
 120484 		}
 120485 
 120486 	}
 120487 	goto __2
 120488 __2:
 120489 	i++
 120490 	pConstraint += 12
 120491 	goto __1
 120492 	goto __3
 120493 __3:
 120494 	;
 120495 	if (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy > 0 &&
 120496 		(*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn < 0 &&
 120497 		int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0 {
 120498 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1
 120499 	}
 120500 
 120501 	if unusableMask & ^idxMask != 0 {
 120502 		return SQLITE_CONSTRAINT
 120503 	}
 120504 	if *(*int32)(unsafe.Pointer(bp)) < 0 {
 120505 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0
 120506 	} else {
 120507 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1.0
 120508 		i = *(*int32)(unsafe.Pointer(bp))
 120509 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1
 120510 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1)
 120511 		if *(*int32)(unsafe.Pointer(bp + 1*4)) < 0 {
 120512 			(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1
 120513 		} else {
 120514 			i = *(*int32)(unsafe.Pointer(bp + 1*4))
 120515 			(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 2
 120516 			(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1)
 120517 			(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 3
 120518 		}
 120519 	}
 120520 	return SQLITE_OK
 120521 }
 120522 
 120523 func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 {
 120524 	bp := tls.Alloc(4)
 120525 	defer tls.Free(4)
 120526 
 120527 	var p uintptr = cur
 120528 	var z uintptr
 120529 	var zRoot uintptr = uintptr(0)
 120530 	var n Sqlite3_int64
 120531 
 120532 	_ = idxStr
 120533 	_ = argc
 120534 	jsonEachCursorReset(tls, p)
 120535 	if idxNum == 0 {
 120536 		return SQLITE_OK
 120537 	}
 120538 	z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
 120539 	if z == uintptr(0) {
 120540 		return SQLITE_OK
 120541 	}
 120542 	n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))))
 120543 	(*JsonEachCursor)(unsafe.Pointer(p)).FzJson = Xsqlite3_malloc64(tls, uint64(n+int64(1)))
 120544 	if (*JsonEachCursor)(unsafe.Pointer(p)).FzJson == uintptr(0) {
 120545 		return SQLITE_NOMEM
 120546 	}
 120547 	libc.Xmemcpy(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzJson, z, Size_t(n)+Size_t(1))
 120548 	if jsonParse(tls, p+32, uintptr(0), (*JsonEachCursor)(unsafe.Pointer(p)).FzJson) != 0 {
 120549 		var rc int32 = SQLITE_NOMEM
 120550 		if int32((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.Foom) == 0 {
 120551 			Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg)
 120552 			(*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+24593, 0)
 120553 			if (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 {
 120554 				rc = SQLITE_ERROR
 120555 			}
 120556 		}
 120557 		jsonEachCursorReset(tls, p)
 120558 		return rc
 120559 	} else if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 && jsonParseFindParents(tls, p+32) != 0 {
 120560 		jsonEachCursorReset(tls, p)
 120561 		return SQLITE_NOMEM
 120562 	} else {
 120563 		var pNode uintptr = uintptr(0)
 120564 		if idxNum == 3 {
 120565 			*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 120566 			zRoot = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 120567 			if zRoot == uintptr(0) {
 120568 				return SQLITE_OK
 120569 			}
 120570 			n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))))
 120571 			(*JsonEachCursor)(unsafe.Pointer(p)).FzRoot = Xsqlite3_malloc64(tls, uint64(n+int64(1)))
 120572 			if (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot == uintptr(0) {
 120573 				return SQLITE_NOMEM
 120574 			}
 120575 			libc.Xmemcpy(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot, zRoot, Size_t(n)+Size_t(1))
 120576 			if int32(*(*uint8)(unsafe.Pointer(zRoot))) != '$' {
 120577 				*(*uintptr)(unsafe.Pointer(bp)) = zRoot
 120578 			} else {
 120579 				pNode = jsonLookupStep(tls, p+32, uint32(0), (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot+uintptr(1), uintptr(0), bp)
 120580 			}
 120581 			if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 120582 				Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg)
 120583 				(*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = jsonPathSyntaxError(tls, *(*uintptr)(unsafe.Pointer(bp)))
 120584 				jsonEachCursorReset(tls, p)
 120585 				if (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 {
 120586 					return SQLITE_ERROR
 120587 				}
 120588 				return SQLITE_NOMEM
 120589 			} else if pNode == uintptr(0) {
 120590 				return SQLITE_OK
 120591 			}
 120592 		} else {
 120593 			pNode = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode
 120594 		}
 120595 		(*JsonEachCursor)(unsafe.Pointer(p)).FiBegin = libc.AssignPtrUint32(p+12, U32((int32(pNode)-int32((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode))/12))
 120596 		(*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer(pNode)).FeType
 120597 		if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) >= JSON_ARRAY {
 120598 			*(*U32)(unsafe.Pointer(pNode + 8)) = U32(0)
 120599 			(*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = (*JsonEachCursor)(unsafe.Pointer(p)).Fi + (*JsonNode)(unsafe.Pointer(pNode)).Fn + U32(1)
 120600 			if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 {
 120601 				(*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))*12)).FeType
 120602 				if (*JsonEachCursor)(unsafe.Pointer(p)).Fi > U32(0) && int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi-U32(1))*12)).FjnFlags)&JNODE_LABEL != 0 {
 120603 					(*JsonEachCursor)(unsafe.Pointer(p)).Fi--
 120604 				}
 120605 			} else {
 120606 				(*JsonEachCursor)(unsafe.Pointer(p)).Fi++
 120607 			}
 120608 		} else {
 120609 			(*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = (*JsonEachCursor)(unsafe.Pointer(p)).Fi + U32(1)
 120610 		}
 120611 	}
 120612 	return SQLITE_OK
 120613 }
 120614 
 120615 var jsonEachModule = Sqlite3_module{
 120616 	FxConnect:    0,
 120617 	FxBestIndex:  0,
 120618 	FxDisconnect: 0,
 120619 	FxOpen:       0,
 120620 	FxClose:      0,
 120621 	FxFilter:     0,
 120622 	FxNext:       0,
 120623 	FxEof:        0,
 120624 	FxColumn:     0,
 120625 	FxRowid:      0,
 120626 }
 120627 
 120628 var jsonTreeModule = Sqlite3_module{
 120629 	FxConnect:    0,
 120630 	FxBestIndex:  0,
 120631 	FxDisconnect: 0,
 120632 	FxOpen:       0,
 120633 	FxClose:      0,
 120634 	FxFilter:     0,
 120635 	FxNext:       0,
 120636 	FxEof:        0,
 120637 	FxColumn:     0,
 120638 	FxRowid:      0,
 120639 }
 120640 
 120641 // Register JSON functions.
 120642 func Xsqlite3RegisterJsonFunctions(tls *libc.TLS) {
 120643 	Xsqlite3InsertBuiltinFuncs(tls, uintptr(unsafe.Pointer(&aJsonFunc)), int32(uint32(unsafe.Sizeof(aJsonFunc))/uint32(unsafe.Sizeof(FuncDef{}))))
 120644 }
 120645 
 120646 var aJsonFunc = [19]FuncDef{
 120647 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24885},
 120648 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24890},
 120649 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24901},
 120650 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24901},
 120651 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24919},
 120652 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: uintptr(JSON_JSON), FxSFunc: 0, FzName: ts + 24932},
 120653 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: uintptr(JSON_SQL), FxSFunc: 0, FzName: ts + 24935},
 120654 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24939},
 120655 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24951},
 120656 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24963},
 120657 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24974},
 120658 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24985},
 120659 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 24997},
 120660 	{FnArg: int8(-1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FpUserData: uintptr(JSON_ISSET), FxSFunc: 0, FzName: ts + 25010},
 120661 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 25019},
 120662 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 25019},
 120663 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_DETERMINISTIC | SQLITE_FUNC_CONSTANT | SQLITE_UTF8), FxSFunc: 0, FzName: ts + 25029},
 120664 	{FnArg: int8(1), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_SUBTYPE | SQLITE_UTF8 | SQLITE_DETERMINISTIC), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 25040},
 120665 	{FnArg: int8(2), FfuncFlags: U32(SQLITE_FUNC_BUILTIN | SQLITE_UTF8 | 0*SQLITE_FUNC_NEEDCOLL | SQLITE_SUBTYPE | SQLITE_UTF8 | SQLITE_DETERMINISTIC), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 25057}}
 120666 
 120667 // Register the JSON table-valued functions
 120668 func Xsqlite3JsonTableFunctions(tls *libc.TLS, db uintptr) int32 {
 120669 	var rc int32 = SQLITE_OK
 120670 	var i uint32
 120671 	for i = uint32(0); i < uint32(unsafe.Sizeof(aMod))/uint32(unsafe.Sizeof(struct {
 120672 		FzName   uintptr
 120673 		FpModule uintptr
 120674 	}{})) && rc == SQLITE_OK; i++ {
 120675 		rc = Xsqlite3_create_module(tls, db, aMod[i].FzName, aMod[i].FpModule, uintptr(0))
 120676 	}
 120677 	return rc
 120678 }
 120679 
 120680 var aMod = [2]struct {
 120681 	FzName   uintptr
 120682 	FpModule uintptr
 120683 }{
 120684 	{FzName: ts + 25075, FpModule: 0},
 120685 	{FzName: ts + 25085, FpModule: 0},
 120686 }
 120687 
 120688 type Rtree1 = struct {
 120689 	Fbase            Sqlite3_vtab
 120690 	Fdb              uintptr
 120691 	FiNodeSize       int32
 120692 	FnDim            U8
 120693 	FnDim2           U8
 120694 	FeCoordType      U8
 120695 	FnBytesPerCell   U8
 120696 	FinWrTrans       U8
 120697 	FnAux            U8
 120698 	FnAuxNotNull     U8
 120699 	F__ccgo_pad1     [1]byte
 120700 	FiDepth          int32
 120701 	FzDb             uintptr
 120702 	FzName           uintptr
 120703 	FnBusy           U32
 120704 	F__ccgo_pad2     [4]byte
 120705 	FnRowEst         I64
 120706 	FnCursor         U32
 120707 	FnNodeRef        U32
 120708 	FzReadAuxSql     uintptr
 120709 	FpDeleted        uintptr
 120710 	FiReinsertHeight int32
 120711 	FpNodeBlob       uintptr
 120712 	FpWriteNode      uintptr
 120713 	FpDeleteNode     uintptr
 120714 	FpReadRowid      uintptr
 120715 	FpWriteRowid     uintptr
 120716 	FpDeleteRowid    uintptr
 120717 	FpReadParent     uintptr
 120718 	FpWriteParent    uintptr
 120719 	FpDeleteParent   uintptr
 120720 	FpWriteAux       uintptr
 120721 	FaHash           [97]uintptr
 120722 }
 120723 
 120724 type Rtree = Rtree1
 120725 type RtreeCursor1 = struct {
 120726 	Fbase        Sqlite3_vtab_cursor
 120727 	FatEOF       U8
 120728 	FbPoint      U8
 120729 	FbAuxValid   U8
 120730 	F__ccgo_pad1 [1]byte
 120731 	FiStrategy   int32
 120732 	FnConstraint int32
 120733 	FaConstraint uintptr
 120734 	FnPointAlloc int32
 120735 	FnPoint      int32
 120736 	FmxLevel     int32
 120737 	FaPoint      uintptr
 120738 	FpReadAux    uintptr
 120739 	FsPoint      RtreeSearchPoint
 120740 	FaNode       [5]uintptr
 120741 	FanQueue     [41]U32
 120742 }
 120743 
 120744 type RtreeCursor = RtreeCursor1
 120745 type RtreeNode1 = struct {
 120746 	FpParent     uintptr
 120747 	F__ccgo_pad1 [4]byte
 120748 	FiNode       I64
 120749 	FnRef        int32
 120750 	FisDirty     int32
 120751 	FzData       uintptr
 120752 	FpNext       uintptr
 120753 }
 120754 
 120755 type RtreeNode = RtreeNode1
 120756 type RtreeCell1 = struct {
 120757 	FiRowid I64
 120758 	FaCoord [10]RtreeCoord
 120759 }
 120760 
 120761 type RtreeCell = RtreeCell1
 120762 type RtreeConstraint1 = struct {
 120763 	FiCoord      int32
 120764 	Fop          int32
 120765 	Fu           struct{ FrValue RtreeDValue }
 120766 	FpInfo       uintptr
 120767 	F__ccgo_pad1 [4]byte
 120768 }
 120769 
 120770 type RtreeConstraint = RtreeConstraint1
 120771 type RtreeMatchArg1 = struct {
 120772 	FiSize       U32
 120773 	Fcb          RtreeGeomCallback
 120774 	FnParam      int32
 120775 	FapSqlParam  uintptr
 120776 	F__ccgo_pad1 [4]byte
 120777 	FaParam      [1]RtreeDValue
 120778 }
 120779 
 120780 type RtreeMatchArg = RtreeMatchArg1
 120781 type RtreeGeomCallback1 = struct {
 120782 	FxGeom       uintptr
 120783 	FxQueryFunc  uintptr
 120784 	FxDestructor uintptr
 120785 	FpContext    uintptr
 120786 }
 120787 
 120788 type RtreeGeomCallback = RtreeGeomCallback1
 120789 type RtreeCoord1 = struct{ Ff RtreeValue }
 120790 
 120791 type RtreeCoord = RtreeCoord1
 120792 type RtreeSearchPoint1 = struct {
 120793 	FrScore      RtreeDValue
 120794 	Fid          Sqlite3_int64
 120795 	FiLevel      U8
 120796 	FeWithin     U8
 120797 	FiCell       U8
 120798 	F__ccgo_pad1 [5]byte
 120799 }
 120800 
 120801 type RtreeSearchPoint = RtreeSearchPoint1
 120802 
 120803 // If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will
 120804 // only deal with integer coordinates.  No floating point operations
 120805 // will be done.
 120806 type RtreeDValue = float64
 120807 type RtreeValue = float32
 120808 
 120809 func readInt16(tls *libc.TLS, p uintptr) int32 {
 120810 	return int32(*(*U8)(unsafe.Pointer(p)))<<8 + int32(*(*U8)(unsafe.Pointer(p + 1)))
 120811 }
 120812 
 120813 func readCoord(tls *libc.TLS, p uintptr, pCoord uintptr) {
 120814 	*(*U32)(unsafe.Pointer(pCoord)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(p)))
 120815 }
 120816 
 120817 func readInt64(tls *libc.TLS, p uintptr) I64 {
 120818 	bp := tls.Alloc(8)
 120819 	defer tls.Free(8)
 120820 
 120821 	libc.Xmemcpy(tls, bp, p, uint32(8))
 120822 	return I64(libc.X__builtin_bswap64(tls, *(*U64)(unsafe.Pointer(bp))))
 120823 }
 120824 
 120825 func writeInt16(tls *libc.TLS, p uintptr, i int32) {
 120826 	*(*U8)(unsafe.Pointer(p)) = U8(i >> 8 & 0xFF)
 120827 	*(*U8)(unsafe.Pointer(p + 1)) = U8(i >> 0 & 0xFF)
 120828 }
 120829 
 120830 func writeCoord(tls *libc.TLS, p uintptr, pCoord uintptr) int32 {
 120831 	bp := tls.Alloc(4)
 120832 	defer tls.Free(4)
 120833 
 120834 	*(*U32)(unsafe.Pointer(bp)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(pCoord)))
 120835 	libc.Xmemcpy(tls, p, bp, uint32(4))
 120836 	return 4
 120837 }
 120838 
 120839 func writeInt64(tls *libc.TLS, p uintptr, i I64) int32 {
 120840 	bp := tls.Alloc(8)
 120841 	defer tls.Free(8)
 120842 	*(*I64)(unsafe.Pointer(bp)) = i
 120843 
 120844 	*(*I64)(unsafe.Pointer(bp)) = I64(libc.X__builtin_bswap64(tls, U64(*(*I64)(unsafe.Pointer(bp)))))
 120845 	libc.Xmemcpy(tls, p, bp, uint32(8))
 120846 	return 8
 120847 }
 120848 
 120849 func nodeReference(tls *libc.TLS, p uintptr) {
 120850 	if p != 0 {
 120851 		(*RtreeNode)(unsafe.Pointer(p)).FnRef++
 120852 	}
 120853 }
 120854 
 120855 func nodeZero(tls *libc.TLS, pRtree uintptr, p uintptr) {
 120856 	libc.Xmemset(tls, (*RtreeNode)(unsafe.Pointer(p)).FzData+2, 0, uint32((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize-2))
 120857 	(*RtreeNode)(unsafe.Pointer(p)).FisDirty = 1
 120858 }
 120859 
 120860 func nodeHash(tls *libc.TLS, iNode I64) uint32 {
 120861 	return uint32(iNode) % uint32(HASHSIZE)
 120862 }
 120863 
 120864 func nodeHashLookup(tls *libc.TLS, pRtree uintptr, iNode I64) uintptr {
 120865 	var p uintptr
 120866 	for p = *(*uintptr)(unsafe.Pointer(pRtree + 116 + uintptr(nodeHash(tls, iNode))*4)); p != 0 && (*RtreeNode)(unsafe.Pointer(p)).FiNode != iNode; p = (*RtreeNode)(unsafe.Pointer(p)).FpNext {
 120867 	}
 120868 	return p
 120869 }
 120870 
 120871 func nodeHashInsert(tls *libc.TLS, pRtree uintptr, pNode uintptr) {
 120872 	var iHash int32
 120873 
 120874 	iHash = int32(nodeHash(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode))
 120875 	(*RtreeNode)(unsafe.Pointer(pNode)).FpNext = *(*uintptr)(unsafe.Pointer(pRtree + 116 + uintptr(iHash)*4))
 120876 	*(*uintptr)(unsafe.Pointer(pRtree + 116 + uintptr(iHash)*4)) = pNode
 120877 }
 120878 
 120879 func nodeHashDelete(tls *libc.TLS, pRtree uintptr, pNode uintptr) {
 120880 	var pp uintptr
 120881 	if (*RtreeNode)(unsafe.Pointer(pNode)).FiNode != int64(0) {
 120882 		pp = pRtree + 116 + uintptr(nodeHash(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode))*4
 120883 		for ; *(*uintptr)(unsafe.Pointer(pp)) != pNode; pp = *(*uintptr)(unsafe.Pointer(pp)) + 28 {
 120884 		}
 120885 		*(*uintptr)(unsafe.Pointer(pp)) = (*RtreeNode)(unsafe.Pointer(pNode)).FpNext
 120886 		(*RtreeNode)(unsafe.Pointer(pNode)).FpNext = uintptr(0)
 120887 	}
 120888 }
 120889 
 120890 func nodeNew(tls *libc.TLS, pRtree uintptr, pParent uintptr) uintptr {
 120891 	var pNode uintptr
 120892 	pNode = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(RtreeNode{}))+uint32((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)))
 120893 	if pNode != 0 {
 120894 		libc.Xmemset(tls, pNode, 0, uint32(unsafe.Sizeof(RtreeNode{}))+uint32((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize))
 120895 		(*RtreeNode)(unsafe.Pointer(pNode)).FzData = pNode + 1*32
 120896 		(*RtreeNode)(unsafe.Pointer(pNode)).FnRef = 1
 120897 		(*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef++
 120898 		(*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent
 120899 		(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1
 120900 		nodeReference(tls, pParent)
 120901 	}
 120902 	return pNode
 120903 }
 120904 
 120905 func nodeBlobReset(tls *libc.TLS, pRtree uintptr) {
 120906 	if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob != 0 && int32((*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans) == 0 && (*Rtree)(unsafe.Pointer(pRtree)).FnCursor == U32(0) {
 120907 		var pBlob uintptr = (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob
 120908 		(*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob = uintptr(0)
 120909 		Xsqlite3_blob_close(tls, pBlob)
 120910 	}
 120911 }
 120912 
 120913 func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNode uintptr) int32 {
 120914 	bp := tls.Alloc(8)
 120915 	defer tls.Free(8)
 120916 
 120917 	var rc int32 = SQLITE_OK
 120918 	var pNode uintptr = uintptr(0)
 120919 
 120920 	if libc.AssignUintptr(&pNode, nodeHashLookup(tls, pRtree, iNode)) != uintptr(0) {
 120921 		if pParent != 0 && pParent != (*RtreeNode)(unsafe.Pointer(pNode)).FpParent {
 120922 			return SQLITE_CORRUPT | int32(1)<<8
 120923 		}
 120924 		(*RtreeNode)(unsafe.Pointer(pNode)).FnRef++
 120925 		*(*uintptr)(unsafe.Pointer(ppNode)) = pNode
 120926 		return SQLITE_OK
 120927 	}
 120928 
 120929 	if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob != 0 {
 120930 		var pBlob uintptr = (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob
 120931 		(*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob = uintptr(0)
 120932 		rc = Xsqlite3_blob_reopen(tls, pBlob, iNode)
 120933 		(*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob = pBlob
 120934 		if rc != 0 {
 120935 			nodeBlobReset(tls, pRtree)
 120936 			if rc == SQLITE_NOMEM {
 120937 				return SQLITE_NOMEM
 120938 			}
 120939 		}
 120940 	}
 120941 	if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob == uintptr(0) {
 120942 		var zTab uintptr = Xsqlite3_mprintf(tls, ts+25095, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzName))
 120943 		if zTab == uintptr(0) {
 120944 			return SQLITE_NOMEM
 120945 		}
 120946 		rc = Xsqlite3_blob_open(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, zTab, ts+25103, iNode, 0,
 120947 			pRtree+76)
 120948 		Xsqlite3_free(tls, zTab)
 120949 	}
 120950 	if rc != 0 {
 120951 		nodeBlobReset(tls, pRtree)
 120952 		*(*uintptr)(unsafe.Pointer(ppNode)) = uintptr(0)
 120953 
 120954 		if rc == SQLITE_ERROR {
 120955 			rc = SQLITE_CORRUPT | int32(1)<<8
 120956 
 120957 		}
 120958 	} else if (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize == Xsqlite3_blob_bytes(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob) {
 120959 		pNode = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(RtreeNode{}))+uint32((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)))
 120960 		if !(pNode != 0) {
 120961 			rc = SQLITE_NOMEM
 120962 		} else {
 120963 			(*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent
 120964 			(*RtreeNode)(unsafe.Pointer(pNode)).FzData = pNode + 1*32
 120965 			(*RtreeNode)(unsafe.Pointer(pNode)).FnRef = 1
 120966 			(*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef++
 120967 			(*RtreeNode)(unsafe.Pointer(pNode)).FiNode = iNode
 120968 			(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 0
 120969 			(*RtreeNode)(unsafe.Pointer(pNode)).FpNext = uintptr(0)
 120970 			rc = Xsqlite3_blob_read(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob, (*RtreeNode)(unsafe.Pointer(pNode)).FzData,
 120971 				(*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize, 0)
 120972 		}
 120973 	}
 120974 
 120975 	if rc == SQLITE_OK && pNode != 0 && iNode == int64(1) {
 120976 		(*Rtree)(unsafe.Pointer(pRtree)).FiDepth = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData)
 120977 		if (*Rtree)(unsafe.Pointer(pRtree)).FiDepth > RTREE_MAX_DEPTH {
 120978 			rc = SQLITE_CORRUPT | int32(1)<<8
 120979 
 120980 		}
 120981 	}
 120982 
 120983 	if pNode != 0 && rc == SQLITE_OK {
 120984 		if readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2) > ((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize-4)/int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) {
 120985 			rc = SQLITE_CORRUPT | int32(1)<<8
 120986 
 120987 		}
 120988 	}
 120989 
 120990 	if rc == SQLITE_OK {
 120991 		if pNode != uintptr(0) {
 120992 			nodeReference(tls, pParent)
 120993 			nodeHashInsert(tls, pRtree, pNode)
 120994 		} else {
 120995 			rc = SQLITE_CORRUPT | int32(1)<<8
 120996 
 120997 		}
 120998 		*(*uintptr)(unsafe.Pointer(ppNode)) = pNode
 120999 	} else {
 121000 		if pNode != 0 {
 121001 			(*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef--
 121002 			Xsqlite3_free(tls, pNode)
 121003 		}
 121004 		*(*uintptr)(unsafe.Pointer(ppNode)) = uintptr(0)
 121005 	}
 121006 
 121007 	return rc
 121008 }
 121009 
 121010 func nodeOverwriteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iCell int32) {
 121011 	var ii int32
 121012 	var p uintptr = (*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(4+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*iCell)
 121013 	p += uintptr(writeInt64(tls, p, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid))
 121014 	for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2); ii++ {
 121015 		p += uintptr(writeCoord(tls, p, pCell+8+uintptr(ii)*4))
 121016 	}
 121017 	(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1
 121018 }
 121019 
 121020 func nodeDeleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32) {
 121021 	var pDst uintptr = (*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(4+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*iCell)
 121022 	var pSrc uintptr = pDst + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)
 121023 	var nByte int32 = (readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2) - iCell - 1) * int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)
 121024 	libc.Xmemmove(tls, pDst, pSrc, uint32(nByte))
 121025 	writeInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2, readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)-1)
 121026 	(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1
 121027 }
 121028 
 121029 func nodeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) int32 {
 121030 	var nCell int32
 121031 	var nMaxCell int32
 121032 
 121033 	nMaxCell = ((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)
 121034 	nCell = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)
 121035 
 121036 	if nCell < nMaxCell {
 121037 		nodeOverwriteCell(tls, pRtree, pNode, pCell, nCell)
 121038 		writeInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2, nCell+1)
 121039 		(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1
 121040 	}
 121041 
 121042 	return libc.Bool32(nCell == nMaxCell)
 121043 }
 121044 
 121045 func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 {
 121046 	var rc int32 = SQLITE_OK
 121047 	if (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty != 0 {
 121048 		var p uintptr = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteNode
 121049 		if (*RtreeNode)(unsafe.Pointer(pNode)).FiNode != 0 {
 121050 			Xsqlite3_bind_int64(tls, p, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 121051 		} else {
 121052 			Xsqlite3_bind_null(tls, p, 1)
 121053 		}
 121054 		Xsqlite3_bind_blob(tls, p, 2, (*RtreeNode)(unsafe.Pointer(pNode)).FzData, (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize, uintptr(0))
 121055 		Xsqlite3_step(tls, p)
 121056 		(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 0
 121057 		rc = Xsqlite3_reset(tls, p)
 121058 		Xsqlite3_bind_null(tls, p, 2)
 121059 		if (*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(0) && rc == SQLITE_OK {
 121060 			(*RtreeNode)(unsafe.Pointer(pNode)).FiNode = Xsqlite3_last_insert_rowid(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb)
 121061 			nodeHashInsert(tls, pRtree, pNode)
 121062 		}
 121063 	}
 121064 	return rc
 121065 }
 121066 
 121067 func nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 {
 121068 	var rc int32 = SQLITE_OK
 121069 	if pNode != 0 {
 121070 		(*RtreeNode)(unsafe.Pointer(pNode)).FnRef--
 121071 		if (*RtreeNode)(unsafe.Pointer(pNode)).FnRef == 0 {
 121072 			(*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef--
 121073 			if (*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) {
 121074 				(*Rtree)(unsafe.Pointer(pRtree)).FiDepth = -1
 121075 			}
 121076 			if (*RtreeNode)(unsafe.Pointer(pNode)).FpParent != 0 {
 121077 				rc = nodeRelease(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pNode)).FpParent)
 121078 			}
 121079 			if rc == SQLITE_OK {
 121080 				rc = nodeWrite(tls, pRtree, pNode)
 121081 			}
 121082 			nodeHashDelete(tls, pRtree, pNode)
 121083 			Xsqlite3_free(tls, pNode)
 121084 		}
 121085 	}
 121086 	return rc
 121087 }
 121088 
 121089 func nodeGetRowid(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32) I64 {
 121090 	return readInt64(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+uintptr(4+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*iCell))
 121091 }
 121092 
 121093 func nodeGetCoord(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iCoord int32, pCoord uintptr) {
 121094 	readCoord(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+uintptr(12+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*iCell+4*iCoord), pCoord)
 121095 }
 121096 
 121097 func nodeGetCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, pCell uintptr) {
 121098 	var pData uintptr
 121099 	var pCoord uintptr
 121100 	var ii int32 = 0
 121101 	(*RtreeCell)(unsafe.Pointer(pCell)).FiRowid = nodeGetRowid(tls, pRtree, pNode, iCell)
 121102 	pData = (*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(12+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*iCell)
 121103 	pCoord = pCell + 8
 121104 	for __ccgo := true; __ccgo; __ccgo = ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) {
 121105 		readCoord(tls, pData, pCoord+uintptr(ii)*4)
 121106 		readCoord(tls, pData+uintptr(4), pCoord+uintptr(ii+1)*4)
 121107 		pData += uintptr(8)
 121108 		ii = ii + 2
 121109 	}
 121110 }
 121111 
 121112 func rtreeCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 121113 	return rtreeInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 1)
 121114 }
 121115 
 121116 func rtreeConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 121117 	return rtreeInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 0)
 121118 }
 121119 
 121120 func rtreeReference(tls *libc.TLS, pRtree uintptr) {
 121121 	(*Rtree)(unsafe.Pointer(pRtree)).FnBusy++
 121122 }
 121123 
 121124 func rtreeRelease(tls *libc.TLS, pRtree uintptr) {
 121125 	(*Rtree)(unsafe.Pointer(pRtree)).FnBusy--
 121126 	if (*Rtree)(unsafe.Pointer(pRtree)).FnBusy == U32(0) {
 121127 		(*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0)
 121128 
 121129 		nodeBlobReset(tls, pRtree)
 121130 
 121131 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteNode)
 121132 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode)
 121133 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 121134 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
 121135 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid)
 121136 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent)
 121137 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteParent)
 121138 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent)
 121139 		Xsqlite3_finalize(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux)
 121140 		Xsqlite3_free(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql)
 121141 		Xsqlite3_free(tls, pRtree)
 121142 	}
 121143 }
 121144 
 121145 func rtreeDisconnect(tls *libc.TLS, pVtab uintptr) int32 {
 121146 	rtreeRelease(tls, pVtab)
 121147 	return SQLITE_OK
 121148 }
 121149 
 121150 func rtreeDestroy(tls *libc.TLS, pVtab uintptr) int32 {
 121151 	bp := tls.Alloc(48)
 121152 	defer tls.Free(48)
 121153 
 121154 	var pRtree uintptr = pVtab
 121155 	var rc int32
 121156 	var zCreate uintptr = Xsqlite3_mprintf(tls,
 121157 		ts+25108,
 121158 		libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName,
 121159 			(*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName,
 121160 			(*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName))
 121161 	if !(zCreate != 0) {
 121162 		rc = SQLITE_NOMEM
 121163 	} else {
 121164 		nodeBlobReset(tls, pRtree)
 121165 		rc = Xsqlite3_exec(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zCreate, uintptr(0), uintptr(0), uintptr(0))
 121166 		Xsqlite3_free(tls, zCreate)
 121167 	}
 121168 	if rc == SQLITE_OK {
 121169 		rtreeRelease(tls, pRtree)
 121170 	}
 121171 
 121172 	return rc
 121173 }
 121174 
 121175 func rtreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 {
 121176 	var rc int32 = SQLITE_NOMEM
 121177 	var pRtree uintptr = pVTab
 121178 	var pCsr uintptr
 121179 
 121180 	pCsr = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(RtreeCursor{})))
 121181 	if pCsr != 0 {
 121182 		libc.Xmemset(tls, pCsr, 0, uint32(unsafe.Sizeof(RtreeCursor{})))
 121183 		(*RtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab
 121184 		rc = SQLITE_OK
 121185 		(*Rtree)(unsafe.Pointer(pRtree)).FnCursor++
 121186 	}
 121187 	*(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr
 121188 
 121189 	return rc
 121190 }
 121191 
 121192 func resetCursor(tls *libc.TLS, pCsr uintptr) {
 121193 	var pRtree uintptr = (*RtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 121194 	var ii int32
 121195 	var pStmt uintptr
 121196 	if (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint != 0 {
 121197 		var i int32
 121198 		for i = 0; i < (*RtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint; i++ {
 121199 			var pInfo uintptr = (*RtreeConstraint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(i)*24)).FpInfo
 121200 			if pInfo != 0 {
 121201 				if (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FxDelUser != 0 {
 121202 					(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FxDelUser})).f(tls, (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpUser)
 121203 				}
 121204 				Xsqlite3_free(tls, pInfo)
 121205 			}
 121206 		}
 121207 		Xsqlite3_free(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint)
 121208 		(*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = uintptr(0)
 121209 	}
 121210 	for ii = 0; ii < RTREE_CACHE_SZ; ii++ {
 121211 		nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(pCsr + 64 + uintptr(ii)*4)))
 121212 	}
 121213 	Xsqlite3_free(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaPoint)
 121214 	pStmt = (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux
 121215 	libc.Xmemset(tls, pCsr, 0, uint32(unsafe.Sizeof(RtreeCursor{})))
 121216 	(*RtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pRtree
 121217 	(*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux = pStmt
 121218 
 121219 }
 121220 
 121221 func rtreeClose(tls *libc.TLS, cur uintptr) int32 {
 121222 	var pRtree uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab
 121223 	var pCsr uintptr = cur
 121224 
 121225 	resetCursor(tls, pCsr)
 121226 	Xsqlite3_finalize(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
 121227 	Xsqlite3_free(tls, pCsr)
 121228 	(*Rtree)(unsafe.Pointer(pRtree)).FnCursor--
 121229 	nodeBlobReset(tls, pRtree)
 121230 	return SQLITE_OK
 121231 }
 121232 
 121233 func rtreeEof(tls *libc.TLS, cur uintptr) int32 {
 121234 	var pCsr uintptr = cur
 121235 	return int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FatEOF)
 121236 }
 121237 
 121238 func rtreeCallbackConstraint(tls *libc.TLS, pConstraint uintptr, eInt int32, pCellData uintptr, pSearch uintptr, prScore uintptr, peWithin uintptr) int32 {
 121239 	bp := tls.Alloc(92)
 121240 	defer tls.Free(92)
 121241 
 121242 	var pInfo uintptr = (*RtreeConstraint)(unsafe.Pointer(pConstraint)).FpInfo
 121243 	var nCoord int32 = (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnCoord
 121244 	var rc int32
 121245 
 121246 	if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == RTREE_QUERY && int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) == 1 {
 121247 		(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FiRowid = readInt64(tls, pCellData)
 121248 	}
 121249 	pCellData += uintptr(8)
 121250 	if eInt == 0 {
 121251 		switch nCoord {
 121252 		case 10:
 121253 			readCoord(tls, pCellData+uintptr(36), bp)
 121254 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 9*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121255 			readCoord(tls, pCellData+uintptr(32), bp)
 121256 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 8*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121257 			fallthrough
 121258 		case 8:
 121259 			readCoord(tls, pCellData+uintptr(28), bp)
 121260 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 7*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121261 			readCoord(tls, pCellData+uintptr(24), bp)
 121262 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 6*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121263 			fallthrough
 121264 		case 6:
 121265 			readCoord(tls, pCellData+uintptr(20), bp)
 121266 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 5*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121267 			readCoord(tls, pCellData+uintptr(16), bp)
 121268 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 4*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121269 			fallthrough
 121270 		case 4:
 121271 			readCoord(tls, pCellData+uintptr(12), bp)
 121272 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 3*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121273 			readCoord(tls, pCellData+uintptr(8), bp)
 121274 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 2*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121275 			fallthrough
 121276 		default:
 121277 			readCoord(tls, pCellData+uintptr(4), bp)
 121278 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 1*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121279 			readCoord(tls, pCellData, bp)
 121280 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121281 		}
 121282 	} else {
 121283 		switch nCoord {
 121284 		case 10:
 121285 			readCoord(tls, pCellData+uintptr(36), bp)
 121286 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 9*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121287 			readCoord(tls, pCellData+uintptr(32), bp)
 121288 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 8*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121289 			fallthrough
 121290 		case 8:
 121291 			readCoord(tls, pCellData+uintptr(28), bp)
 121292 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 7*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121293 			readCoord(tls, pCellData+uintptr(24), bp)
 121294 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 6*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121295 			fallthrough
 121296 		case 6:
 121297 			readCoord(tls, pCellData+uintptr(20), bp)
 121298 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 5*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121299 			readCoord(tls, pCellData+uintptr(16), bp)
 121300 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 4*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121301 			fallthrough
 121302 		case 4:
 121303 			readCoord(tls, pCellData+uintptr(12), bp)
 121304 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 3*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121305 			readCoord(tls, pCellData+uintptr(8), bp)
 121306 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 2*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121307 			fallthrough
 121308 		default:
 121309 			readCoord(tls, pCellData+uintptr(4), bp)
 121310 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 + 1*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121311 			readCoord(tls, pCellData, bp)
 121312 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121313 		}
 121314 	}
 121315 	if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == RTREE_MATCH {
 121316 		*(*int32)(unsafe.Pointer(bp + 88)) = 0
 121317 		rc = (*struct {
 121318 			f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
 121319 		})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(pConstraint + 8))})).f(tls, pInfo,
 121320 			nCoord, bp+8, bp+88)
 121321 		if *(*int32)(unsafe.Pointer(bp + 88)) == 0 {
 121322 			*(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN
 121323 		}
 121324 		*(*Sqlite3_rtree_dbl)(unsafe.Pointer(prScore)) = 0.0
 121325 	} else {
 121326 		(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FaCoord = bp + 8
 121327 		(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FiLevel = int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) - 1
 121328 		(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrScore = libc.AssignPtrFloat64(pInfo+48, (*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FrScore)
 121329 		(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeWithin = libc.AssignPtrInt32(pInfo+56, int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FeWithin))
 121330 		rc = (*struct {
 121331 			f func(*libc.TLS, uintptr) int32
 121332 		})(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(pConstraint + 8))})).f(tls, pInfo)
 121333 		if (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeWithin < *(*int32)(unsafe.Pointer(peWithin)) {
 121334 			*(*int32)(unsafe.Pointer(peWithin)) = (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FeWithin
 121335 		}
 121336 		if (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrScore < *(*Sqlite3_rtree_dbl)(unsafe.Pointer(prScore)) || *(*Sqlite3_rtree_dbl)(unsafe.Pointer(prScore)) < 0.0 {
 121337 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(prScore)) = (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FrScore
 121338 		}
 121339 	}
 121340 	return rc
 121341 }
 121342 
 121343 func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) {
 121344 	bp := tls.Alloc(16)
 121345 	defer tls.Free(16)
 121346 
 121347 	var val Sqlite3_rtree_dbl
 121348 
 121349 	pCellData += uintptr(8 + 4*((*RtreeConstraint)(unsafe.Pointer(p)).FiCoord&0xfe))
 121350 
 121351 	switch (*RtreeConstraint)(unsafe.Pointer(p)).Fop {
 121352 	case RTREE_TRUE:
 121353 		return
 121354 	case RTREE_FALSE:
 121355 		break
 121356 	case RTREE_EQ:
 121357 		{
 121358 			*(*U32)(unsafe.Pointer(bp)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(pCellData)))
 121359 			if eInt != 0 {
 121360 				val = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121361 			} else {
 121362 				val = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121363 			}
 121364 		}
 121365 
 121366 		if *(*RtreeDValue)(unsafe.Pointer(p + 8)) >= val {
 121367 			pCellData += uintptr(4)
 121368 			{
 121369 				*(*U32)(unsafe.Pointer(bp + 4)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(pCellData)))
 121370 				if eInt != 0 {
 121371 					val = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp + 4)))
 121372 				} else {
 121373 					val = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp + 4)))
 121374 				}
 121375 			}
 121376 
 121377 			if *(*RtreeDValue)(unsafe.Pointer(p + 8)) <= val {
 121378 				return
 121379 			}
 121380 		}
 121381 		break
 121382 	case RTREE_LE:
 121383 		fallthrough
 121384 	case RTREE_LT:
 121385 		{
 121386 			*(*U32)(unsafe.Pointer(bp + 8)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(pCellData)))
 121387 			if eInt != 0 {
 121388 				val = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp + 8)))
 121389 			} else {
 121390 				val = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp + 8)))
 121391 			}
 121392 		}
 121393 
 121394 		if *(*RtreeDValue)(unsafe.Pointer(p + 8)) >= val {
 121395 			return
 121396 		}
 121397 		break
 121398 
 121399 	default:
 121400 		pCellData += uintptr(4)
 121401 		{
 121402 			*(*U32)(unsafe.Pointer(bp + 12)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(pCellData)))
 121403 			if eInt != 0 {
 121404 				val = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp + 12)))
 121405 			} else {
 121406 				val = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp + 12)))
 121407 			}
 121408 		}
 121409 
 121410 		if *(*RtreeDValue)(unsafe.Pointer(p + 8)) <= val {
 121411 			return
 121412 		}
 121413 		break
 121414 	}
 121415 	*(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN
 121416 }
 121417 
 121418 func rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) {
 121419 	bp := tls.Alloc(4)
 121420 	defer tls.Free(4)
 121421 
 121422 	var xN RtreeDValue
 121423 
 121424 	pCellData += uintptr(8 + (*RtreeConstraint)(unsafe.Pointer(p)).FiCoord*4)
 121425 
 121426 	{
 121427 		*(*U32)(unsafe.Pointer(bp)) = libc.X__builtin_bswap32(tls, *(*U32)(unsafe.Pointer(pCellData)))
 121428 		if eInt != 0 {
 121429 			xN = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp)))
 121430 		} else {
 121431 			xN = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp)))
 121432 		}
 121433 	}
 121434 
 121435 	switch (*RtreeConstraint)(unsafe.Pointer(p)).Fop {
 121436 	case RTREE_TRUE:
 121437 		return
 121438 	case RTREE_FALSE:
 121439 		break
 121440 	case RTREE_LE:
 121441 		if xN <= *(*RtreeDValue)(unsafe.Pointer(p + 8)) {
 121442 			return
 121443 		}
 121444 		break
 121445 	case RTREE_LT:
 121446 		if xN < *(*RtreeDValue)(unsafe.Pointer(p + 8)) {
 121447 			return
 121448 		}
 121449 		break
 121450 	case RTREE_GE:
 121451 		if xN >= *(*RtreeDValue)(unsafe.Pointer(p + 8)) {
 121452 			return
 121453 		}
 121454 		break
 121455 	case RTREE_GT:
 121456 		if xN > *(*RtreeDValue)(unsafe.Pointer(p + 8)) {
 121457 			return
 121458 		}
 121459 		break
 121460 	default:
 121461 		if xN == *(*RtreeDValue)(unsafe.Pointer(p + 8)) {
 121462 			return
 121463 		}
 121464 		break
 121465 	}
 121466 	*(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN
 121467 }
 121468 
 121469 func nodeRowidIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, iRowid I64, piIndex uintptr) int32 {
 121470 	var ii int32
 121471 	var nCell int32 = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)
 121472 
 121473 	for ii = 0; ii < nCell; ii++ {
 121474 		if nodeGetRowid(tls, pRtree, pNode, ii) == iRowid {
 121475 			*(*int32)(unsafe.Pointer(piIndex)) = ii
 121476 			return SQLITE_OK
 121477 		}
 121478 	}
 121479 
 121480 	return SQLITE_CORRUPT | int32(1)<<8
 121481 }
 121482 
 121483 func nodeParentIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, piIndex uintptr) int32 {
 121484 	var pParent uintptr = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent
 121485 	if pParent != 0 {
 121486 		return nodeRowidIndex(tls, pRtree, pParent, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode, piIndex)
 121487 	} else {
 121488 		*(*int32)(unsafe.Pointer(piIndex)) = -1
 121489 		return SQLITE_OK
 121490 	}
 121491 	return int32(0)
 121492 }
 121493 
 121494 func rtreeSearchPointCompare(tls *libc.TLS, pA uintptr, pB uintptr) int32 {
 121495 	if (*RtreeSearchPoint)(unsafe.Pointer(pA)).FrScore < (*RtreeSearchPoint)(unsafe.Pointer(pB)).FrScore {
 121496 		return -1
 121497 	}
 121498 	if (*RtreeSearchPoint)(unsafe.Pointer(pA)).FrScore > (*RtreeSearchPoint)(unsafe.Pointer(pB)).FrScore {
 121499 		return +1
 121500 	}
 121501 	if int32((*RtreeSearchPoint)(unsafe.Pointer(pA)).FiLevel) < int32((*RtreeSearchPoint)(unsafe.Pointer(pB)).FiLevel) {
 121502 		return -1
 121503 	}
 121504 	if int32((*RtreeSearchPoint)(unsafe.Pointer(pA)).FiLevel) > int32((*RtreeSearchPoint)(unsafe.Pointer(pB)).FiLevel) {
 121505 		return +1
 121506 	}
 121507 	return 0
 121508 }
 121509 
 121510 func rtreeSearchPointSwap(tls *libc.TLS, p uintptr, i int32, j int32) {
 121511 	var t = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(i)*24))
 121512 
 121513 	*(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(i)*24)) = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(j)*24))
 121514 	*(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(j)*24)) = t
 121515 	i++
 121516 	j++
 121517 	if i < RTREE_CACHE_SZ {
 121518 		if j >= RTREE_CACHE_SZ {
 121519 			nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer(p)).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4)))
 121520 			*(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4)) = uintptr(0)
 121521 		} else {
 121522 			var pTemp uintptr = *(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4))
 121523 			*(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer(p + 64 + uintptr(j)*4))
 121524 			*(*uintptr)(unsafe.Pointer(p + 64 + uintptr(j)*4)) = pTemp
 121525 		}
 121526 	}
 121527 }
 121528 
 121529 func rtreeSearchPointFirst(tls *libc.TLS, pCur uintptr) uintptr {
 121530 	if (*RtreeCursor)(unsafe.Pointer(pCur)).FbPoint != 0 {
 121531 		return pCur + 40
 121532 	}
 121533 	if (*RtreeCursor)(unsafe.Pointer(pCur)).FnPoint != 0 {
 121534 		return (*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint
 121535 	}
 121536 	return uintptr(0)
 121537 }
 121538 
 121539 func rtreeNodeOfFirstSearchPoint(tls *libc.TLS, pCur uintptr, pRC uintptr) uintptr {
 121540 	var id Sqlite3_int64
 121541 	var ii int32 = 1 - int32((*RtreeCursor)(unsafe.Pointer(pCur)).FbPoint)
 121542 
 121543 	if *(*uintptr)(unsafe.Pointer(pCur + 64 + uintptr(ii)*4)) == uintptr(0) {
 121544 		if ii != 0 {
 121545 			id = (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint)).Fid
 121546 		} else {
 121547 			id = (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.Fid
 121548 		}
 121549 		*(*int32)(unsafe.Pointer(pRC)) = nodeAcquire(tls, (*RtreeCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab, id, uintptr(0), pCur+64+uintptr(ii)*4)
 121550 	}
 121551 	return *(*uintptr)(unsafe.Pointer(pCur + 64 + uintptr(ii)*4))
 121552 }
 121553 
 121554 func rtreeEnqueue(tls *libc.TLS, pCur uintptr, rScore RtreeDValue, iLevel U8) uintptr {
 121555 	var i int32
 121556 	var j int32
 121557 	var pNew uintptr
 121558 	if (*RtreeCursor)(unsafe.Pointer(pCur)).FnPoint >= (*RtreeCursor)(unsafe.Pointer(pCur)).FnPointAlloc {
 121559 		var nNew int32 = (*RtreeCursor)(unsafe.Pointer(pCur)).FnPointAlloc*2 + 8
 121560 		pNew = Xsqlite3_realloc64(tls, (*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint, uint64(uint32(nNew)*uint32(unsafe.Sizeof(RtreeSearchPoint{}))))
 121561 		if pNew == uintptr(0) {
 121562 			return uintptr(0)
 121563 		}
 121564 		(*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint = pNew
 121565 		(*RtreeCursor)(unsafe.Pointer(pCur)).FnPointAlloc = nNew
 121566 	}
 121567 	i = libc.PostIncInt32(&(*RtreeCursor)(unsafe.Pointer(pCur)).FnPoint, 1)
 121568 	pNew = (*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(i)*24
 121569 	(*RtreeSearchPoint)(unsafe.Pointer(pNew)).FrScore = rScore
 121570 	(*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiLevel = iLevel
 121571 
 121572 	for i > 0 {
 121573 		var pParent uintptr
 121574 		j = (i - 1) / 2
 121575 		pParent = (*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(j)*24
 121576 		if rtreeSearchPointCompare(tls, pNew, pParent) >= 0 {
 121577 			break
 121578 		}
 121579 		rtreeSearchPointSwap(tls, pCur, j, i)
 121580 		i = j
 121581 		pNew = pParent
 121582 	}
 121583 	return pNew
 121584 }
 121585 
 121586 func rtreeSearchPointNew(tls *libc.TLS, pCur uintptr, rScore RtreeDValue, iLevel U8) uintptr {
 121587 	var pNew uintptr
 121588 	var pFirst uintptr
 121589 	pFirst = rtreeSearchPointFirst(tls, pCur)
 121590 	*(*U32)(unsafe.Pointer(pCur + 84 + uintptr(iLevel)*4))++
 121591 	if pFirst == uintptr(0) ||
 121592 		(*RtreeSearchPoint)(unsafe.Pointer(pFirst)).FrScore > rScore ||
 121593 		(*RtreeSearchPoint)(unsafe.Pointer(pFirst)).FrScore == rScore && int32((*RtreeSearchPoint)(unsafe.Pointer(pFirst)).FiLevel) > int32(iLevel) {
 121594 		if (*RtreeCursor)(unsafe.Pointer(pCur)).FbPoint != 0 {
 121595 			var ii int32
 121596 			pNew = rtreeEnqueue(tls, pCur, rScore, iLevel)
 121597 			if pNew == uintptr(0) {
 121598 				return uintptr(0)
 121599 			}
 121600 			ii = (int32(pNew)-int32((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint))/24 + 1
 121601 
 121602 			if ii < RTREE_CACHE_SZ {
 121603 				*(*uintptr)(unsafe.Pointer(pCur + 64 + uintptr(ii)*4)) = *(*uintptr)(unsafe.Pointer(pCur + 64))
 121604 			} else {
 121605 				nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer(pCur + 64)))
 121606 			}
 121607 			*(*uintptr)(unsafe.Pointer(pCur + 64)) = uintptr(0)
 121608 			*(*RtreeSearchPoint)(unsafe.Pointer(pNew)) = (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint
 121609 		}
 121610 		(*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.FrScore = rScore
 121611 		(*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.FiLevel = iLevel
 121612 		(*RtreeCursor)(unsafe.Pointer(pCur)).FbPoint = U8(1)
 121613 		return pCur + 40
 121614 	} else {
 121615 		return rtreeEnqueue(tls, pCur, rScore, iLevel)
 121616 	}
 121617 	return uintptr(0)
 121618 }
 121619 
 121620 func rtreeSearchPointPop(tls *libc.TLS, p uintptr) {
 121621 	var i int32
 121622 	var j int32
 121623 	var k int32
 121624 	var n int32
 121625 	i = 1 - int32((*RtreeCursor)(unsafe.Pointer(p)).FbPoint)
 121626 
 121627 	if *(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4)) != 0 {
 121628 		nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer(p)).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4)))
 121629 		*(*uintptr)(unsafe.Pointer(p + 64 + uintptr(i)*4)) = uintptr(0)
 121630 	}
 121631 	if (*RtreeCursor)(unsafe.Pointer(p)).FbPoint != 0 {
 121632 		*(*U32)(unsafe.Pointer(p + 84 + uintptr((*RtreeCursor)(unsafe.Pointer(p)).FsPoint.FiLevel)*4))--
 121633 		(*RtreeCursor)(unsafe.Pointer(p)).FbPoint = U8(0)
 121634 	} else if (*RtreeCursor)(unsafe.Pointer(p)).FnPoint != 0 {
 121635 		*(*U32)(unsafe.Pointer(p + 84 + uintptr((*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint)).FiLevel)*4))--
 121636 		n = libc.PreDecInt32(&(*RtreeCursor)(unsafe.Pointer(p)).FnPoint, 1)
 121637 		*(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint)) = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(n)*24))
 121638 		if n < RTREE_CACHE_SZ-1 {
 121639 			*(*uintptr)(unsafe.Pointer(p + 64 + 1*4)) = *(*uintptr)(unsafe.Pointer(p + 64 + uintptr(n+1)*4))
 121640 			*(*uintptr)(unsafe.Pointer(p + 64 + uintptr(n+1)*4)) = uintptr(0)
 121641 		}
 121642 		i = 0
 121643 		for libc.AssignInt32(&j, i*2+1) < n {
 121644 			k = j + 1
 121645 			if k < n && rtreeSearchPointCompare(tls, (*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(k)*24, (*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(j)*24) < 0 {
 121646 				if rtreeSearchPointCompare(tls, (*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(k)*24, (*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(i)*24) < 0 {
 121647 					rtreeSearchPointSwap(tls, p, i, k)
 121648 					i = k
 121649 				} else {
 121650 					break
 121651 				}
 121652 			} else {
 121653 				if rtreeSearchPointCompare(tls, (*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(j)*24, (*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(i)*24) < 0 {
 121654 					rtreeSearchPointSwap(tls, p, i, j)
 121655 					i = j
 121656 				} else {
 121657 					break
 121658 				}
 121659 			}
 121660 		}
 121661 	}
 121662 }
 121663 
 121664 func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 {
 121665 	bp := tls.Alloc(20)
 121666 	defer tls.Free(20)
 121667 
 121668 	var p uintptr
 121669 	var pRtree uintptr = (*RtreeCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab
 121670 	var pNode uintptr
 121671 
 121672 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 121673 	var nCell int32
 121674 	var nConstraint int32 = (*RtreeCursor)(unsafe.Pointer(pCur)).FnConstraint
 121675 	var ii int32
 121676 	var eInt int32
 121677 	var x RtreeSearchPoint
 121678 
 121679 	eInt = libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_INT32)
 121680 	for libc.AssignUintptr(&p, rtreeSearchPointFirst(tls, pCur)) != uintptr(0) && int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) > 0 {
 121681 		var pCellData uintptr
 121682 		pNode = rtreeNodeOfFirstSearchPoint(tls, pCur, bp)
 121683 		if *(*int32)(unsafe.Pointer(bp)) != 0 {
 121684 			return *(*int32)(unsafe.Pointer(bp))
 121685 		}
 121686 		nCell = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)
 121687 
 121688 		pCellData = (*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(4+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))
 121689 		for int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell) < nCell {
 121690 			*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8)) = Sqlite3_rtree_dbl(-1)
 121691 			*(*int32)(unsafe.Pointer(bp + 16)) = FULLY_WITHIN
 121692 			for ii = 0; ii < nConstraint; ii++ {
 121693 				var pConstraint uintptr = (*RtreeCursor)(unsafe.Pointer(pCur)).FaConstraint + uintptr(ii)*24
 121694 				if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop >= RTREE_MATCH {
 121695 					*(*int32)(unsafe.Pointer(bp)) = rtreeCallbackConstraint(tls, pConstraint, eInt, pCellData, p,
 121696 						bp+8, bp+16)
 121697 					if *(*int32)(unsafe.Pointer(bp)) != 0 {
 121698 						return *(*int32)(unsafe.Pointer(bp))
 121699 					}
 121700 				} else if int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) == 1 {
 121701 					rtreeLeafConstraint(tls, pConstraint, eInt, pCellData, bp+16)
 121702 				} else {
 121703 					rtreeNonleafConstraint(tls, pConstraint, eInt, pCellData, bp+16)
 121704 				}
 121705 				if *(*int32)(unsafe.Pointer(bp + 16)) == NOT_WITHIN {
 121706 					(*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell++
 121707 					pCellData += uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)
 121708 					break
 121709 				}
 121710 			}
 121711 			if *(*int32)(unsafe.Pointer(bp + 16)) == NOT_WITHIN {
 121712 				continue
 121713 			}
 121714 			(*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell++
 121715 			x.FiLevel = U8(int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) - 1)
 121716 			if x.FiLevel != 0 {
 121717 				x.Fid = readInt64(tls, pCellData)
 121718 				for ii = 0; ii < (*RtreeCursor)(unsafe.Pointer(pCur)).FnPoint; ii++ {
 121719 					if (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint+uintptr(ii)*24)).Fid == x.Fid {
 121720 						return SQLITE_CORRUPT | int32(1)<<8
 121721 					}
 121722 				}
 121723 				x.FiCell = U8(0)
 121724 			} else {
 121725 				x.Fid = (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid
 121726 				x.FiCell = U8(int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell) - 1)
 121727 			}
 121728 			if int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell) >= nCell {
 121729 				rtreeSearchPointPop(tls, pCur)
 121730 			}
 121731 			if *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8)) < 0.0 {
 121732 				*(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8)) = 0.0
 121733 			}
 121734 			p = rtreeSearchPointNew(tls, pCur, *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8)), x.FiLevel)
 121735 			if p == uintptr(0) {
 121736 				return SQLITE_NOMEM
 121737 			}
 121738 			(*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(*(*int32)(unsafe.Pointer(bp + 16)))
 121739 			(*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = x.Fid
 121740 			(*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = x.FiCell
 121741 
 121742 			break
 121743 		}
 121744 		if int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell) >= nCell {
 121745 			rtreeSearchPointPop(tls, pCur)
 121746 		}
 121747 	}
 121748 	(*RtreeCursor)(unsafe.Pointer(pCur)).FatEOF = U8(libc.Bool32(p == uintptr(0)))
 121749 	return SQLITE_OK
 121750 }
 121751 
 121752 func rtreeNext(tls *libc.TLS, pVtabCursor uintptr) int32 {
 121753 	var pCsr uintptr = pVtabCursor
 121754 	var rc int32 = SQLITE_OK
 121755 
 121756 	if (*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid != 0 {
 121757 		(*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(0)
 121758 		Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
 121759 	}
 121760 	rtreeSearchPointPop(tls, pCsr)
 121761 	rc = rtreeStepToLeaf(tls, pCsr)
 121762 	return rc
 121763 }
 121764 
 121765 func rtreeRowid(tls *libc.TLS, pVtabCursor uintptr, pRowid uintptr) int32 {
 121766 	bp := tls.Alloc(4)
 121767 	defer tls.Free(4)
 121768 
 121769 	var pCsr uintptr = pVtabCursor
 121770 	var p uintptr = rtreeSearchPointFirst(tls, pCsr)
 121771 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 121772 	var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp)
 121773 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK && p != 0 {
 121774 		*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = nodeGetRowid(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))
 121775 	}
 121776 	return *(*int32)(unsafe.Pointer(bp))
 121777 }
 121778 
 121779 func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 {
 121780 	bp := tls.Alloc(8)
 121781 	defer tls.Free(8)
 121782 
 121783 	var pRtree uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab
 121784 	var pCsr uintptr = cur
 121785 	var p uintptr = rtreeSearchPointFirst(tls, pCsr)
 121786 
 121787 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 121788 	var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp)
 121789 
 121790 	if *(*int32)(unsafe.Pointer(bp)) != 0 {
 121791 		return *(*int32)(unsafe.Pointer(bp))
 121792 	}
 121793 	if p == uintptr(0) {
 121794 		return SQLITE_OK
 121795 	}
 121796 	if i == 0 {
 121797 		Xsqlite3_result_int64(tls, ctx, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell)))
 121798 	} else if i <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) {
 121799 		nodeGetCoord(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell), i-1, bp+4)
 121800 		if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 121801 			Xsqlite3_result_double(tls, ctx, float64(*(*RtreeValue)(unsafe.Pointer(bp + 4))))
 121802 		} else {
 121803 			Xsqlite3_result_int(tls, ctx, *(*int32)(unsafe.Pointer(bp + 4)))
 121804 		}
 121805 	} else {
 121806 		if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid) != 0) {
 121807 			if (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux == uintptr(0) {
 121808 				*(*int32)(unsafe.Pointer(bp)) = Xsqlite3_prepare_v3(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, (*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql, -1, uint32(0),
 121809 					pCsr+36, uintptr(0))
 121810 				if *(*int32)(unsafe.Pointer(bp)) != 0 {
 121811 					return *(*int32)(unsafe.Pointer(bp))
 121812 				}
 121813 			}
 121814 			Xsqlite3_bind_int64(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, 1,
 121815 				nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell)))
 121816 			*(*int32)(unsafe.Pointer(bp)) = Xsqlite3_step(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
 121817 			if *(*int32)(unsafe.Pointer(bp)) == SQLITE_ROW {
 121818 				(*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(1)
 121819 			} else {
 121820 				Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
 121821 				if *(*int32)(unsafe.Pointer(bp)) == SQLITE_DONE {
 121822 					*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 121823 				}
 121824 				return *(*int32)(unsafe.Pointer(bp))
 121825 			}
 121826 		}
 121827 		Xsqlite3_result_value(tls, ctx,
 121828 			Xsqlite3_column_value(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, i-int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)+1))
 121829 	}
 121830 	return SQLITE_OK
 121831 }
 121832 
 121833 func findLeafNode(tls *libc.TLS, pRtree uintptr, iRowid I64, ppLeaf uintptr, piNode uintptr) int32 {
 121834 	var rc int32
 121835 	*(*uintptr)(unsafe.Pointer(ppLeaf)) = uintptr(0)
 121836 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, iRowid)
 121837 	if Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) == SQLITE_ROW {
 121838 		var iNode I64 = Xsqlite3_column_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 0)
 121839 		if piNode != 0 {
 121840 			*(*Sqlite3_int64)(unsafe.Pointer(piNode)) = iNode
 121841 		}
 121842 		rc = nodeAcquire(tls, pRtree, iNode, uintptr(0), ppLeaf)
 121843 		Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 121844 	} else {
 121845 		rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 121846 	}
 121847 	return rc
 121848 }
 121849 
 121850 func deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) int32 {
 121851 	var pBlob uintptr
 121852 	var pSrc uintptr
 121853 	var pInfo uintptr
 121854 
 121855 	pSrc = Xsqlite3_value_pointer(tls, pValue, ts+25190)
 121856 	if pSrc == uintptr(0) {
 121857 		return SQLITE_ERROR
 121858 	}
 121859 	pInfo = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(Sqlite3_rtree_query_info{}))+(*RtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize))
 121860 	if !(pInfo != 0) {
 121861 		return SQLITE_NOMEM
 121862 	}
 121863 	libc.Xmemset(tls, pInfo, 0, uint32(unsafe.Sizeof(Sqlite3_rtree_query_info{})))
 121864 	pBlob = pInfo + 1*80
 121865 	libc.Xmemcpy(tls, pBlob, pSrc, (*RtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)
 121866 	(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpContext = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FpContext
 121867 	(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnParam = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam
 121868 	(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FaParam = pBlob + 32
 121869 	(*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FapSqlParam = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam
 121870 
 121871 	if (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom != 0 {
 121872 		*(*uintptr)(unsafe.Pointer(pCons + 8)) = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom
 121873 	} else {
 121874 		(*RtreeConstraint)(unsafe.Pointer(pCons)).Fop = RTREE_QUERY
 121875 		*(*uintptr)(unsafe.Pointer(pCons + 8)) = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxQueryFunc
 121876 	}
 121877 	(*RtreeConstraint)(unsafe.Pointer(pCons)).FpInfo = pInfo
 121878 	return SQLITE_OK
 121879 }
 121880 
 121881 func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 {
 121882 	bp := tls.Alloc(24)
 121883 	defer tls.Free(24)
 121884 
 121885 	var pRtree uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab
 121886 	var pCsr uintptr = pVtabCursor
 121887 	*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 121888 	var ii int32
 121889 	var rc int32 = SQLITE_OK
 121890 	*(*int32)(unsafe.Pointer(bp + 16)) = 0
 121891 
 121892 	rtreeReference(tls, pRtree)
 121893 
 121894 	resetCursor(tls, pCsr)
 121895 
 121896 	(*RtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum
 121897 	if idxNum == 1 {
 121898 		var p uintptr
 121899 		var iRowid I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
 121900 		*(*I64)(unsafe.Pointer(bp + 8)) = int64(0)
 121901 		var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv)))
 121902 		if eType == SQLITE_INTEGER ||
 121903 			eType == SQLITE_FLOAT && Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) == float64(iRowid) {
 121904 			rc = findLeafNode(tls, pRtree, iRowid, bp, bp+8)
 121905 		} else {
 121906 			rc = SQLITE_OK
 121907 			*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 121908 		}
 121909 		if rc == SQLITE_OK && *(*uintptr)(unsafe.Pointer(bp)) != uintptr(0) {
 121910 			p = rtreeSearchPointNew(tls, pCsr, 0.0, uint8(0))
 121911 
 121912 			*(*uintptr)(unsafe.Pointer(pCsr + 64)) = *(*uintptr)(unsafe.Pointer(bp))
 121913 			(*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = *(*I64)(unsafe.Pointer(bp + 8))
 121914 			(*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(PARTLY_WITHIN)
 121915 			rc = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)), iRowid, bp+16)
 121916 			(*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = U8(*(*int32)(unsafe.Pointer(bp + 16)))
 121917 
 121918 		} else {
 121919 			(*RtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = U8(1)
 121920 		}
 121921 	} else {
 121922 		rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+20)
 121923 		if rc == SQLITE_OK && argc > 0 {
 121924 			(*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(RtreeConstraint{}))*uint32(argc)))
 121925 			(*RtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = argc
 121926 			if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) != 0) {
 121927 				rc = SQLITE_NOMEM
 121928 			} else {
 121929 				libc.Xmemset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, uint32(unsafe.Sizeof(RtreeConstraint{}))*uint32(argc))
 121930 				libc.Xmemset(tls, pCsr+84, 0, uint32(unsafe.Sizeof(U32(0)))*uint32((*Rtree)(unsafe.Pointer(pRtree)).FiDepth+1))
 121931 
 121932 				for ii = 0; ii < argc; ii++ {
 121933 					var p uintptr = (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint + uintptr(ii)*24
 121934 					var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*4)))
 121935 					(*RtreeConstraint)(unsafe.Pointer(p)).Fop = int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(ii*2))))
 121936 					(*RtreeConstraint)(unsafe.Pointer(p)).FiCoord = int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(ii*2+1)))) - '0'
 121937 					if (*RtreeConstraint)(unsafe.Pointer(p)).Fop >= RTREE_MATCH {
 121938 						rc = deserializeGeometry(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*4)), p)
 121939 						if rc != SQLITE_OK {
 121940 							break
 121941 						}
 121942 						(*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FnCoord = int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)
 121943 						(*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FanQueue = pCsr + 84
 121944 						(*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FmxLevel = (*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1
 121945 					} else if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 121946 						*(*RtreeDValue)(unsafe.Pointer(p + 8)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*4)))
 121947 					} else {
 121948 						*(*RtreeDValue)(unsafe.Pointer(p + 8)) = 0.0
 121949 						if eType == SQLITE_NULL {
 121950 							(*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_FALSE
 121951 						} else if (*RtreeConstraint)(unsafe.Pointer(p)).Fop == RTREE_LT || (*RtreeConstraint)(unsafe.Pointer(p)).Fop == RTREE_LE {
 121952 							(*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_TRUE
 121953 						} else {
 121954 							(*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_FALSE
 121955 						}
 121956 					}
 121957 				}
 121958 			}
 121959 		}
 121960 		if rc == SQLITE_OK {
 121961 			var pNew uintptr
 121962 
 121963 			pNew = rtreeSearchPointNew(tls, pCsr, 0.0, U8((*Rtree)(unsafe.Pointer(pRtree)).FiDepth+1))
 121964 			if pNew == uintptr(0) {
 121965 				return SQLITE_NOMEM
 121966 			}
 121967 			(*RtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1)
 121968 			(*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = U8(0)
 121969 			(*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = U8(PARTLY_WITHIN)
 121970 
 121971 			*(*uintptr)(unsafe.Pointer(pCsr + 64)) = *(*uintptr)(unsafe.Pointer(bp + 20))
 121972 			*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 121973 
 121974 			rc = rtreeStepToLeaf(tls, pCsr)
 121975 		}
 121976 	}
 121977 
 121978 	nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 20)))
 121979 	rtreeRelease(tls, pRtree)
 121980 	return rc
 121981 }
 121982 
 121983 func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 {
 121984 	bp := tls.Alloc(49)
 121985 	defer tls.Free(49)
 121986 
 121987 	var pRtree uintptr = tab
 121988 	var rc int32 = SQLITE_OK
 121989 	var ii int32
 121990 	var bMatch int32 = 0
 121991 	var nRow I64
 121992 
 121993 	var iIdx int32 = 0
 121994 
 121995 	libc.Xmemset(tls, bp+8, 0, uint32(unsafe.Sizeof([41]uint8{})))
 121996 
 121997 	for ii = 0; ii < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ {
 121998 		if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(ii)*12)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH {
 121999 			bMatch = 1
 122000 		}
 122001 	}
 122002 
 122003 	for ii = 0; ii < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint && iIdx < int32(uint32(unsafe.Sizeof([41]uint8{}))-uint32(1)); ii++ {
 122004 		var p uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12
 122005 
 122006 		if bMatch == 0 && (*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 &&
 122007 			(*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= 0 && int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ {
 122008 			var jj int32
 122009 			for jj = 0; jj < ii; jj++ {
 122010 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8)).FargvIndex = 0
 122011 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8)).Fomit = uint8(0)
 122012 			}
 122013 			(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1
 122014 			(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8)).FargvIndex = 1
 122015 			(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(jj)*8)).Fomit = uint8(1)
 122016 
 122017 			(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 30.0
 122018 			(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1)
 122019 			(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE
 122020 			return SQLITE_OK
 122021 		}
 122022 
 122023 		if (*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 &&
 122024 			((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn > 0 && (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) ||
 122025 				int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) {
 122026 			var op U8
 122027 			switch int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) {
 122028 			case SQLITE_INDEX_CONSTRAINT_EQ:
 122029 				op = U8(RTREE_EQ)
 122030 				break
 122031 				fallthrough
 122032 			case SQLITE_INDEX_CONSTRAINT_GT:
 122033 				op = U8(RTREE_GT)
 122034 				break
 122035 				fallthrough
 122036 			case SQLITE_INDEX_CONSTRAINT_LE:
 122037 				op = U8(RTREE_LE)
 122038 				break
 122039 				fallthrough
 122040 			case SQLITE_INDEX_CONSTRAINT_LT:
 122041 				op = U8(RTREE_LT)
 122042 				break
 122043 				fallthrough
 122044 			case SQLITE_INDEX_CONSTRAINT_GE:
 122045 				op = U8(RTREE_GE)
 122046 				break
 122047 				fallthrough
 122048 			case SQLITE_INDEX_CONSTRAINT_MATCH:
 122049 				op = U8(RTREE_MATCH)
 122050 				break
 122051 				fallthrough
 122052 			default:
 122053 				op = U8(0)
 122054 				break
 122055 			}
 122056 			if op != 0 {
 122057 				*(*uint8)(unsafe.Pointer(bp + 8 + uintptr(libc.PostIncInt32(&iIdx, 1)))) = op
 122058 				*(*uint8)(unsafe.Pointer(bp + 8 + uintptr(libc.PostIncInt32(&iIdx, 1)))) = uint8((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn - 1 + '0')
 122059 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8)).FargvIndex = iIdx / 2
 122060 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8)).Fomit = uint8(1)
 122061 			}
 122062 		}
 122063 	}
 122064 
 122065 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 2
 122066 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1
 122067 	if iIdx > 0 && uintptr(0) == libc.AssignPtrUintptr(pIdxInfo+24, Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, bp+8))) {
 122068 		return SQLITE_NOMEM
 122069 	}
 122070 
 122071 	nRow = (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst >> (iIdx / 2)
 122072 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 6.0 * float64(nRow)
 122073 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = nRow
 122074 
 122075 	return rc
 122076 }
 122077 
 122078 func cellArea(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue {
 122079 	var area RtreeDValue = RtreeDValue(1)
 122080 
 122081 	if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122082 		switch int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) {
 122083 		case 5:
 122084 			area = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(p + 8 + 9*4)) - *(*RtreeValue)(unsafe.Pointer(p + 8 + 8*4)))
 122085 			fallthrough
 122086 		case 4:
 122087 			area = area * float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + 7*4))-*(*RtreeValue)(unsafe.Pointer(p + 8 + 6*4)))
 122088 			fallthrough
 122089 		case 3:
 122090 			area = area * float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + 5*4))-*(*RtreeValue)(unsafe.Pointer(p + 8 + 4*4)))
 122091 			fallthrough
 122092 		case 2:
 122093 			area = area * float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + 3*4))-*(*RtreeValue)(unsafe.Pointer(p + 8 + 2*4)))
 122094 			fallthrough
 122095 		default:
 122096 			area = area * float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + 1*4))-*(*RtreeValue)(unsafe.Pointer(p + 8)))
 122097 		}
 122098 	} else {
 122099 		switch int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) {
 122100 		case 5:
 122101 			area = RtreeDValue(I64(*(*int32)(unsafe.Pointer(p + 8 + 9*4))) - I64(*(*int32)(unsafe.Pointer(p + 8 + 8*4))))
 122102 			fallthrough
 122103 		case 4:
 122104 			area = area * float64(I64(*(*int32)(unsafe.Pointer(p + 8 + 7*4)))-I64(*(*int32)(unsafe.Pointer(p + 8 + 6*4))))
 122105 			fallthrough
 122106 		case 3:
 122107 			area = area * float64(I64(*(*int32)(unsafe.Pointer(p + 8 + 5*4)))-I64(*(*int32)(unsafe.Pointer(p + 8 + 4*4))))
 122108 			fallthrough
 122109 		case 2:
 122110 			area = area * float64(I64(*(*int32)(unsafe.Pointer(p + 8 + 3*4)))-I64(*(*int32)(unsafe.Pointer(p + 8 + 2*4))))
 122111 			fallthrough
 122112 		default:
 122113 			area = area * float64(I64(*(*int32)(unsafe.Pointer(p + 8 + 1*4)))-I64(*(*int32)(unsafe.Pointer(p + 8))))
 122114 		}
 122115 	}
 122116 	return area
 122117 }
 122118 
 122119 func cellMargin(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue {
 122120 	var margin RtreeDValue = RtreeDValue(0)
 122121 	var ii int32 = int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) - 2
 122122 	for __ccgo := true; __ccgo; __ccgo = ii >= 0 {
 122123 		margin = margin + (func() float64 {
 122124 			if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122125 				return float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + uintptr(ii+1)*4)))
 122126 			}
 122127 			return float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(ii+1)*4)))
 122128 		}() - func() float64 {
 122129 			if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122130 				return float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + uintptr(ii)*4)))
 122131 			}
 122132 			return float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(ii)*4)))
 122133 		}())
 122134 		ii = ii - 2
 122135 	}
 122136 	return margin
 122137 }
 122138 
 122139 func cellUnion(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) {
 122140 	var ii int32 = 0
 122141 	if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122142 		for __ccgo := true; __ccgo; __ccgo = ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) {
 122143 			*(*RtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) = func() float32 {
 122144 				if *(*RtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) < *(*RtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4)) {
 122145 					return *(*RtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4))
 122146 				}
 122147 				return *(*RtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4))
 122148 			}()
 122149 			*(*RtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii+1)*4)) = func() float32 {
 122150 				if *(*RtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii+1)*4)) > *(*RtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii+1)*4)) {
 122151 					return *(*RtreeValue)(unsafe.Pointer(p1 + 8 + uintptr(ii+1)*4))
 122152 				}
 122153 				return *(*RtreeValue)(unsafe.Pointer(p2 + 8 + uintptr(ii+1)*4))
 122154 			}()
 122155 			ii = ii + 2
 122156 		}
 122157 	} else {
 122158 		for __ccgo1 := true; __ccgo1; __ccgo1 = ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) {
 122159 			*(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) = func() int32 {
 122160 				if *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4)) < *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4)) {
 122161 					return *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii)*4))
 122162 				}
 122163 				return *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii)*4))
 122164 			}()
 122165 			*(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii+1)*4)) = func() int32 {
 122166 				if *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii+1)*4)) > *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii+1)*4)) {
 122167 					return *(*int32)(unsafe.Pointer(p1 + 8 + uintptr(ii+1)*4))
 122168 				}
 122169 				return *(*int32)(unsafe.Pointer(p2 + 8 + uintptr(ii+1)*4))
 122170 			}()
 122171 			ii = ii + 2
 122172 		}
 122173 	}
 122174 }
 122175 
 122176 func cellContains(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) int32 {
 122177 	var ii int32
 122178 	var isInt int32 = libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_INT32)
 122179 	for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2); ii = ii + 2 {
 122180 		var a1 uintptr = p1 + 8 + uintptr(ii)*4
 122181 		var a2 uintptr = p2 + 8 + uintptr(ii)*4
 122182 		if !(isInt != 0) && (*(*RtreeValue)(unsafe.Pointer(a2)) < *(*RtreeValue)(unsafe.Pointer(a1)) || *(*RtreeValue)(unsafe.Pointer(a2 + 1*4)) > *(*RtreeValue)(unsafe.Pointer(a1 + 1*4))) ||
 122183 			isInt != 0 && (*(*int32)(unsafe.Pointer(a2)) < *(*int32)(unsafe.Pointer(a1)) || *(*int32)(unsafe.Pointer(a2 + 1*4)) > *(*int32)(unsafe.Pointer(a1 + 1*4))) {
 122184 			return 0
 122185 		}
 122186 	}
 122187 	return 1
 122188 }
 122189 
 122190 func cellGrowth(tls *libc.TLS, pRtree uintptr, p uintptr, pCell uintptr) RtreeDValue {
 122191 	bp := tls.Alloc(48)
 122192 	defer tls.Free(48)
 122193 
 122194 	var area RtreeDValue
 122195 
 122196 	libc.Xmemcpy(tls, bp, p, uint32(unsafe.Sizeof(RtreeCell{})))
 122197 	area = cellArea(tls, pRtree, bp)
 122198 	cellUnion(tls, pRtree, bp, pCell)
 122199 	return cellArea(tls, pRtree, bp) - area
 122200 }
 122201 
 122202 func cellOverlap(tls *libc.TLS, pRtree uintptr, p uintptr, aCell uintptr, nCell int32) RtreeDValue {
 122203 	var ii int32
 122204 	var overlap RtreeDValue = 0.0
 122205 	for ii = 0; ii < nCell; ii++ {
 122206 		var jj int32
 122207 		var o RtreeDValue = RtreeDValue(1)
 122208 		for jj = 0; jj < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2); jj = jj + 2 {
 122209 			var x1 RtreeDValue
 122210 			var x2 RtreeDValue
 122211 			x1 = func() float64 {
 122212 				if func() float64 {
 122213 					if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122214 						return float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj)*4)))
 122215 					}
 122216 					return float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj)*4)))
 122217 				}() > func() float64 {
 122218 					if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122219 						return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4)))
 122220 					}
 122221 					return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4)))
 122222 				}() {
 122223 					return func() float64 {
 122224 						if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122225 							return float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj)*4)))
 122226 						}
 122227 						return float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj)*4)))
 122228 					}()
 122229 				}
 122230 				return func() float64 {
 122231 					if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122232 						return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4)))
 122233 					}
 122234 					return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj)*4)))
 122235 				}()
 122236 			}()
 122237 			x2 = func() float64 {
 122238 				if func() float64 {
 122239 					if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122240 						return float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj+1)*4)))
 122241 					}
 122242 					return float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj+1)*4)))
 122243 				}() < func() float64 {
 122244 					if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122245 						return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+1)*4)))
 122246 					}
 122247 					return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+1)*4)))
 122248 				}() {
 122249 					return func() float64 {
 122250 						if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122251 							return float64(*(*RtreeValue)(unsafe.Pointer(p + 8 + uintptr(jj+1)*4)))
 122252 						}
 122253 						return float64(*(*int32)(unsafe.Pointer(p + 8 + uintptr(jj+1)*4)))
 122254 					}()
 122255 				}
 122256 				return func() float64 {
 122257 					if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122258 						return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+1)*4)))
 122259 					}
 122260 					return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(jj+1)*4)))
 122261 				}()
 122262 			}()
 122263 			if x2 < x1 {
 122264 				o = RtreeDValue(0)
 122265 				break
 122266 			} else {
 122267 				o = o * (x2 - x1)
 122268 			}
 122269 		}
 122270 		overlap = overlap + o
 122271 	}
 122272 	return overlap
 122273 }
 122274 
 122275 func sChooseLeaf(tls *libc.TLS, pRtree uintptr, pCell uintptr, iHeight int32, ppLeaf uintptr) int32 {
 122276 	bp := tls.Alloc(60)
 122277 	defer tls.Free(60)
 122278 
 122279 	var rc int32
 122280 	var ii int32
 122281 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 122282 	rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp)
 122283 
 122284 	for ii = 0; rc == SQLITE_OK && ii < (*Rtree)(unsafe.Pointer(pRtree)).FiDepth-iHeight; ii++ {
 122285 		var iCell int32
 122286 		var iBest Sqlite3_int64 = int64(0)
 122287 
 122288 		var fMinGrowth RtreeDValue = 0.0
 122289 		var fMinArea RtreeDValue = 0.0
 122290 
 122291 		var nCell int32 = readInt16(tls, (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzData+2)
 122292 
 122293 		*(*uintptr)(unsafe.Pointer(bp + 56)) = uintptr(0)
 122294 
 122295 		var aCell uintptr = uintptr(0)
 122296 
 122297 		for iCell = 0; iCell < nCell; iCell++ {
 122298 			var bBest int32 = 0
 122299 			var growth RtreeDValue
 122300 			var area RtreeDValue
 122301 			nodeGetCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)), iCell, bp+8)
 122302 			growth = cellGrowth(tls, pRtree, bp+8, pCell)
 122303 			area = cellArea(tls, pRtree, bp+8)
 122304 			if iCell == 0 || growth < fMinGrowth || growth == fMinGrowth && area < fMinArea {
 122305 				bBest = 1
 122306 			}
 122307 			if bBest != 0 {
 122308 				fMinGrowth = growth
 122309 				fMinArea = area
 122310 				iBest = (*RtreeCell)(unsafe.Pointer(bp + 8)).FiRowid
 122311 			}
 122312 		}
 122313 
 122314 		Xsqlite3_free(tls, aCell)
 122315 		rc = nodeAcquire(tls, pRtree, iBest, *(*uintptr)(unsafe.Pointer(bp)), bp+56)
 122316 		nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)))
 122317 		*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(bp + 56))
 122318 	}
 122319 
 122320 	*(*uintptr)(unsafe.Pointer(ppLeaf)) = *(*uintptr)(unsafe.Pointer(bp))
 122321 	return rc
 122322 }
 122323 
 122324 func sAdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) int32 {
 122325 	bp := tls.Alloc(56)
 122326 	defer tls.Free(56)
 122327 
 122328 	var p uintptr = pNode
 122329 	var cnt int32 = 0
 122330 	var rc int32
 122331 	for (*RtreeNode)(unsafe.Pointer(p)).FpParent != 0 {
 122332 		var pParent uintptr = (*RtreeNode)(unsafe.Pointer(p)).FpParent
 122333 
 122334 		cnt++
 122335 		if cnt > 100 {
 122336 			return SQLITE_CORRUPT | int32(1)<<8
 122337 		}
 122338 		rc = nodeParentIndex(tls, pRtree, p, bp)
 122339 		if rc != SQLITE_OK {
 122340 			return SQLITE_CORRUPT | int32(1)<<8
 122341 		}
 122342 
 122343 		nodeGetCell(tls, pRtree, pParent, *(*int32)(unsafe.Pointer(bp)), bp+8)
 122344 		if !(cellContains(tls, pRtree, bp+8, pCell) != 0) {
 122345 			cellUnion(tls, pRtree, bp+8, pCell)
 122346 			nodeOverwriteCell(tls, pRtree, pParent, bp+8, *(*int32)(unsafe.Pointer(bp)))
 122347 		}
 122348 
 122349 		p = pParent
 122350 	}
 122351 	return SQLITE_OK
 122352 }
 122353 
 122354 func rowidWrite(tls *libc.TLS, pRtree uintptr, iRowid Sqlite3_int64, iNode Sqlite3_int64) int32 {
 122355 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid, 1, iRowid)
 122356 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid, 2, iNode)
 122357 	Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
 122358 	return Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
 122359 }
 122360 
 122361 func parentWrite(tls *libc.TLS, pRtree uintptr, iNode Sqlite3_int64, iPar Sqlite3_int64) int32 {
 122362 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteParent, 1, iNode)
 122363 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteParent, 2, iPar)
 122364 	Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteParent)
 122365 	return Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteParent)
 122366 }
 122367 
 122368 func sSortByDistance(tls *libc.TLS, aIdx uintptr, nIdx int32, aDistance uintptr, aSpare uintptr) {
 122369 	if nIdx > 1 {
 122370 		var iLeft int32 = 0
 122371 		var iRight int32 = 0
 122372 
 122373 		var nLeft int32 = nIdx / 2
 122374 		var nRight int32 = nIdx - nLeft
 122375 		var aLeft uintptr = aIdx
 122376 		var aRight uintptr = aIdx + uintptr(nLeft)*4
 122377 
 122378 		sSortByDistance(tls, aLeft, nLeft, aDistance, aSpare)
 122379 		sSortByDistance(tls, aRight, nRight, aDistance, aSpare)
 122380 
 122381 		libc.Xmemcpy(tls, aSpare, aLeft, uint32(unsafe.Sizeof(int32(0)))*uint32(nLeft))
 122382 		aLeft = aSpare
 122383 
 122384 		for iLeft < nLeft || iRight < nRight {
 122385 			if iLeft == nLeft {
 122386 				*(*int32)(unsafe.Pointer(aIdx + uintptr(iLeft+iRight)*4)) = *(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4))
 122387 				iRight++
 122388 			} else if iRight == nRight {
 122389 				*(*int32)(unsafe.Pointer(aIdx + uintptr(iLeft+iRight)*4)) = *(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4))
 122390 				iLeft++
 122391 			} else {
 122392 				var fLeft RtreeDValue = *(*RtreeDValue)(unsafe.Pointer(aDistance + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*8))
 122393 				var fRight RtreeDValue = *(*RtreeDValue)(unsafe.Pointer(aDistance + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*8))
 122394 				if fLeft < fRight {
 122395 					*(*int32)(unsafe.Pointer(aIdx + uintptr(iLeft+iRight)*4)) = *(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4))
 122396 					iLeft++
 122397 				} else {
 122398 					*(*int32)(unsafe.Pointer(aIdx + uintptr(iLeft+iRight)*4)) = *(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4))
 122399 					iRight++
 122400 				}
 122401 			}
 122402 		}
 122403 
 122404 	}
 122405 }
 122406 
 122407 func sSortByDimension(tls *libc.TLS, pRtree uintptr, aIdx uintptr, nIdx int32, iDim int32, aCell uintptr, aSpare uintptr) {
 122408 	if nIdx > 1 {
 122409 		var iLeft int32 = 0
 122410 		var iRight int32 = 0
 122411 
 122412 		var nLeft int32 = nIdx / 2
 122413 		var nRight int32 = nIdx - nLeft
 122414 		var aLeft uintptr = aIdx
 122415 		var aRight uintptr = aIdx + uintptr(nLeft)*4
 122416 
 122417 		sSortByDimension(tls, pRtree, aLeft, nLeft, iDim, aCell, aSpare)
 122418 		sSortByDimension(tls, pRtree, aRight, nRight, iDim, aCell, aSpare)
 122419 
 122420 		libc.Xmemcpy(tls, aSpare, aLeft, uint32(unsafe.Sizeof(int32(0)))*uint32(nLeft))
 122421 		aLeft = aSpare
 122422 		for iLeft < nLeft || iRight < nRight {
 122423 			var xleft1 RtreeDValue = func() float64 {
 122424 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122425 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*2)*4)))
 122426 				}
 122427 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*2)*4)))
 122428 			}()
 122429 			var xleft2 RtreeDValue = func() float64 {
 122430 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122431 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*2+1)*4)))
 122432 				}
 122433 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 + uintptr(iDim*2+1)*4)))
 122434 			}()
 122435 			var xright1 RtreeDValue = func() float64 {
 122436 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122437 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*2)*4)))
 122438 				}
 122439 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*2)*4)))
 122440 			}()
 122441 			var xright2 RtreeDValue = func() float64 {
 122442 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122443 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*2+1)*4)))
 122444 				}
 122445 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 + uintptr(iDim*2+1)*4)))
 122446 			}()
 122447 			if iLeft != nLeft && (iRight == nRight ||
 122448 				xleft1 < xright1 ||
 122449 				xleft1 == xright1 && xleft2 < xright2) {
 122450 				*(*int32)(unsafe.Pointer(aIdx + uintptr(iLeft+iRight)*4)) = *(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4))
 122451 				iLeft++
 122452 			} else {
 122453 				*(*int32)(unsafe.Pointer(aIdx + uintptr(iLeft+iRight)*4)) = *(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4))
 122454 				iRight++
 122455 			}
 122456 		}
 122457 
 122458 	}
 122459 }
 122460 
 122461 func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32, pLeft uintptr, pRight uintptr, pBboxLeft uintptr, pBboxRight uintptr) int32 {
 122462 	bp := tls.Alloc(96)
 122463 	defer tls.Free(96)
 122464 
 122465 	var aaSorted uintptr
 122466 	var aSpare uintptr
 122467 	var ii int32
 122468 
 122469 	var iBestDim int32 = 0
 122470 	var iBestSplit int32 = 0
 122471 	var fBestMargin RtreeDValue = 0.0
 122472 
 122473 	var nByte Sqlite3_int64 = Sqlite3_int64(uint32(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim)+1) * (uint32(unsafe.Sizeof(uintptr(0))) + uint32(nCell)*uint32(unsafe.Sizeof(int32(0)))))
 122474 
 122475 	aaSorted = Xsqlite3_malloc64(tls, uint64(nByte))
 122476 	if !(aaSorted != 0) {
 122477 		return SQLITE_NOMEM
 122478 	}
 122479 
 122480 	aSpare = aaSorted + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*4 + uintptr(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*nCell)*4
 122481 	libc.Xmemset(tls, aaSorted, 0, uint32(nByte))
 122482 	for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); ii++ {
 122483 		var jj int32
 122484 		*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)) = aaSorted + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*4 + uintptr(ii*nCell)*4
 122485 		for jj = 0; jj < nCell; jj++ {
 122486 			*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)) + uintptr(jj)*4)) = jj
 122487 		}
 122488 		sSortByDimension(tls, pRtree, *(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)), nCell, ii, aCell, aSpare)
 122489 	}
 122490 
 122491 	for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); ii++ {
 122492 		var margin RtreeDValue = 0.0
 122493 		var fBestOverlap RtreeDValue = 0.0
 122494 		var fBestArea RtreeDValue = 0.0
 122495 		var iBestLeft int32 = 0
 122496 		var nLeft int32
 122497 
 122498 		for nLeft = ((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) / 3; nLeft <= nCell-((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize-4)/int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/3; nLeft++ {
 122499 			var kk int32
 122500 			var overlap RtreeDValue
 122501 			var area RtreeDValue
 122502 
 122503 			libc.Xmemcpy(tls, bp, aCell+uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)))))*48, uint32(unsafe.Sizeof(RtreeCell{})))
 122504 			libc.Xmemcpy(tls, bp+48, aCell+uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)) + uintptr(nCell-1)*4)))*48, uint32(unsafe.Sizeof(RtreeCell{})))
 122505 			for kk = 1; kk < nCell-1; kk++ {
 122506 				if kk < nLeft {
 122507 					cellUnion(tls, pRtree, bp, aCell+uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)) + uintptr(kk)*4)))*48)
 122508 				} else {
 122509 					cellUnion(tls, pRtree, bp+48, aCell+uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*4)) + uintptr(kk)*4)))*48)
 122510 				}
 122511 			}
 122512 			margin = margin + cellMargin(tls, pRtree, bp)
 122513 			margin = margin + cellMargin(tls, pRtree, bp+48)
 122514 			overlap = cellOverlap(tls, pRtree, bp, bp+48, 1)
 122515 			area = cellArea(tls, pRtree, bp) + cellArea(tls, pRtree, bp+48)
 122516 			if nLeft == ((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize-4)/int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/3 ||
 122517 				overlap < fBestOverlap ||
 122518 				overlap == fBestOverlap && area < fBestArea {
 122519 				iBestLeft = nLeft
 122520 				fBestOverlap = overlap
 122521 				fBestArea = area
 122522 			}
 122523 		}
 122524 
 122525 		if ii == 0 || margin < fBestMargin {
 122526 			iBestDim = ii
 122527 			fBestMargin = margin
 122528 			iBestSplit = iBestLeft
 122529 		}
 122530 	}
 122531 
 122532 	libc.Xmemcpy(tls, pBboxLeft, aCell+uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*4)))))*48, uint32(unsafe.Sizeof(RtreeCell{})))
 122533 	libc.Xmemcpy(tls, pBboxRight, aCell+uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*4)) + uintptr(iBestSplit)*4)))*48, uint32(unsafe.Sizeof(RtreeCell{})))
 122534 	for ii = 0; ii < nCell; ii++ {
 122535 		var pTarget uintptr
 122536 		if ii < iBestSplit {
 122537 			pTarget = pLeft
 122538 		} else {
 122539 			pTarget = pRight
 122540 		}
 122541 		var pBbox uintptr
 122542 		if ii < iBestSplit {
 122543 			pBbox = pBboxLeft
 122544 		} else {
 122545 			pBbox = pBboxRight
 122546 		}
 122547 		var pCell uintptr = aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*4)) + uintptr(ii)*4)))*48
 122548 		nodeInsertCell(tls, pRtree, pTarget, pCell)
 122549 		cellUnion(tls, pRtree, pBbox, pCell)
 122550 	}
 122551 
 122552 	Xsqlite3_free(tls, aaSorted)
 122553 	return SQLITE_OK
 122554 }
 122555 
 122556 func updateMapping(tls *libc.TLS, pRtree uintptr, iRowid I64, pNode uintptr, iHeight int32) int32 {
 122557 	var xSetMapping uintptr
 122558 	xSetMapping = func() uintptr {
 122559 		if iHeight == 0 {
 122560 			return *(*uintptr)(unsafe.Pointer(&struct {
 122561 				f func(*libc.TLS, uintptr, Sqlite3_int64, Sqlite3_int64) int32
 122562 			}{rowidWrite}))
 122563 		}
 122564 		return *(*uintptr)(unsafe.Pointer(&struct {
 122565 			f func(*libc.TLS, uintptr, Sqlite3_int64, Sqlite3_int64) int32
 122566 		}{parentWrite}))
 122567 	}()
 122568 	if iHeight > 0 {
 122569 		var pChild uintptr = nodeHashLookup(tls, pRtree, iRowid)
 122570 		var p uintptr
 122571 		for p = pNode; p != 0; p = (*RtreeNode)(unsafe.Pointer(p)).FpParent {
 122572 			if p == pChild {
 122573 				return SQLITE_CORRUPT | int32(1)<<8
 122574 			}
 122575 		}
 122576 		if pChild != 0 {
 122577 			nodeRelease(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pChild)).FpParent)
 122578 			nodeReference(tls, pNode)
 122579 			(*RtreeNode)(unsafe.Pointer(pChild)).FpParent = pNode
 122580 		}
 122581 	}
 122582 	if pNode == uintptr(0) {
 122583 		return SQLITE_ERROR
 122584 	}
 122585 	return (*struct {
 122586 		f func(*libc.TLS, uintptr, Sqlite3_int64, Sqlite3_int64) int32
 122587 	})(unsafe.Pointer(&struct{ uintptr }{xSetMapping})).f(tls, pRtree, iRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 122588 }
 122589 
 122590 func sSplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) int32 {
 122591 	bp := tls.Alloc(100)
 122592 	defer tls.Free(100)
 122593 
 122594 	var i int32
 122595 	var newCellIsRight int32
 122596 	var rc int32
 122597 	var nCell int32
 122598 	var aCell uintptr
 122599 	var aiUsed uintptr
 122600 	var pLeft uintptr
 122601 	var pRight uintptr
 122602 
 122603 	var pParent uintptr
 122604 
 122605 	var iRowid I64
 122606 	var iRowid1 I64
 122607 	newCellIsRight = 0
 122608 	rc = SQLITE_OK
 122609 	nCell = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)
 122610 	pLeft = uintptr(0)
 122611 	pRight = uintptr(0)
 122612 
 122613 	aCell = Xsqlite3_malloc64(tls, uint64((uint32(unsafe.Sizeof(RtreeCell{}))+uint32(unsafe.Sizeof(int32(0))))*uint32(nCell+1)))
 122614 	if !!(aCell != 0) {
 122615 		goto __1
 122616 	}
 122617 	rc = SQLITE_NOMEM
 122618 	goto splitnode_out
 122619 __1:
 122620 	;
 122621 	aiUsed = aCell + uintptr(nCell+1)*48
 122622 	libc.Xmemset(tls, aiUsed, 0, uint32(unsafe.Sizeof(int32(0)))*uint32(nCell+1))
 122623 	i = 0
 122624 __2:
 122625 	if !(i < nCell) {
 122626 		goto __4
 122627 	}
 122628 	nodeGetCell(tls, pRtree, pNode, i, aCell+uintptr(i)*48)
 122629 	goto __3
 122630 __3:
 122631 	i++
 122632 	goto __2
 122633 	goto __4
 122634 __4:
 122635 	;
 122636 	nodeZero(tls, pRtree, pNode)
 122637 	libc.Xmemcpy(tls, aCell+uintptr(nCell)*48, pCell, uint32(unsafe.Sizeof(RtreeCell{})))
 122638 	nCell++
 122639 
 122640 	if !((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1)) {
 122641 		goto __5
 122642 	}
 122643 	pRight = nodeNew(tls, pRtree, pNode)
 122644 	pLeft = nodeNew(tls, pRtree, pNode)
 122645 	(*Rtree)(unsafe.Pointer(pRtree)).FiDepth++
 122646 	(*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1
 122647 	writeInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData, (*Rtree)(unsafe.Pointer(pRtree)).FiDepth)
 122648 	goto __6
 122649 __5:
 122650 	pLeft = pNode
 122651 	pRight = nodeNew(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent)
 122652 	(*RtreeNode)(unsafe.Pointer(pLeft)).FnRef++
 122653 __6:
 122654 	;
 122655 	if !(!(pLeft != 0) || !(pRight != 0)) {
 122656 		goto __7
 122657 	}
 122658 	rc = SQLITE_NOMEM
 122659 	goto splitnode_out
 122660 __7:
 122661 	;
 122662 	libc.Xmemset(tls, (*RtreeNode)(unsafe.Pointer(pLeft)).FzData, 0, uint32((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize))
 122663 	libc.Xmemset(tls, (*RtreeNode)(unsafe.Pointer(pRight)).FzData, 0, uint32((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize))
 122664 
 122665 	rc = splitNodeStartree(tls, pRtree, aCell, nCell, pLeft, pRight,
 122666 		bp, bp+48)
 122667 	if !(rc != SQLITE_OK) {
 122668 		goto __8
 122669 	}
 122670 	goto splitnode_out
 122671 __8:
 122672 	;
 122673 	if !(SQLITE_OK != libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pRight)) ||
 122674 		int64(0) == (*RtreeNode)(unsafe.Pointer(pLeft)).FiNode && SQLITE_OK != libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pLeft))) {
 122675 		goto __9
 122676 	}
 122677 	goto splitnode_out
 122678 __9:
 122679 	;
 122680 	(*RtreeCell)(unsafe.Pointer(bp + 48)).FiRowid = (*RtreeNode)(unsafe.Pointer(pRight)).FiNode
 122681 	(*RtreeCell)(unsafe.Pointer(bp)).FiRowid = (*RtreeNode)(unsafe.Pointer(pLeft)).FiNode
 122682 
 122683 	if !((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1)) {
 122684 		goto __10
 122685 	}
 122686 	rc = rtreeInsertCell(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent, bp, iHeight+1)
 122687 	if !(rc != SQLITE_OK) {
 122688 		goto __12
 122689 	}
 122690 	goto splitnode_out
 122691 __12:
 122692 	;
 122693 	goto __11
 122694 __10:
 122695 	pParent = (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent
 122696 	rc = nodeParentIndex(tls, pRtree, pLeft, bp+96)
 122697 	if !(rc == SQLITE_OK) {
 122698 		goto __13
 122699 	}
 122700 	nodeOverwriteCell(tls, pRtree, pParent, bp, *(*int32)(unsafe.Pointer(bp + 96)))
 122701 	rc = sAdjustTree(tls, pRtree, pParent, bp)
 122702 
 122703 __13:
 122704 	;
 122705 	if !(rc != SQLITE_OK) {
 122706 		goto __14
 122707 	}
 122708 	goto splitnode_out
 122709 __14:
 122710 	;
 122711 __11:
 122712 	;
 122713 	if !(libc.AssignInt32(&rc, rtreeInsertCell(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pRight)).FpParent, bp+48, iHeight+1)) != 0) {
 122714 		goto __15
 122715 	}
 122716 	goto splitnode_out
 122717 __15:
 122718 	;
 122719 	i = 0
 122720 __16:
 122721 	if !(i < readInt16(tls, (*RtreeNode)(unsafe.Pointer(pRight)).FzData+2)) {
 122722 		goto __18
 122723 	}
 122724 	iRowid = nodeGetRowid(tls, pRtree, pRight, i)
 122725 	rc = updateMapping(tls, pRtree, iRowid, pRight, iHeight)
 122726 	if !(iRowid == (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid) {
 122727 		goto __19
 122728 	}
 122729 	newCellIsRight = 1
 122730 __19:
 122731 	;
 122732 	if !(rc != SQLITE_OK) {
 122733 		goto __20
 122734 	}
 122735 	goto splitnode_out
 122736 __20:
 122737 	;
 122738 	goto __17
 122739 __17:
 122740 	i++
 122741 	goto __16
 122742 	goto __18
 122743 __18:
 122744 	;
 122745 	if !((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1)) {
 122746 		goto __21
 122747 	}
 122748 	i = 0
 122749 __23:
 122750 	if !(i < readInt16(tls, (*RtreeNode)(unsafe.Pointer(pLeft)).FzData+2)) {
 122751 		goto __25
 122752 	}
 122753 	iRowid1 = nodeGetRowid(tls, pRtree, pLeft, i)
 122754 	rc = updateMapping(tls, pRtree, iRowid1, pLeft, iHeight)
 122755 	if !(rc != SQLITE_OK) {
 122756 		goto __26
 122757 	}
 122758 	goto splitnode_out
 122759 __26:
 122760 	;
 122761 	goto __24
 122762 __24:
 122763 	i++
 122764 	goto __23
 122765 	goto __25
 122766 __25:
 122767 	;
 122768 	goto __22
 122769 __21:
 122770 	if !(newCellIsRight == 0) {
 122771 		goto __27
 122772 	}
 122773 	rc = updateMapping(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid, pLeft, iHeight)
 122774 __27:
 122775 	;
 122776 __22:
 122777 	;
 122778 	if !(rc == SQLITE_OK) {
 122779 		goto __28
 122780 	}
 122781 	rc = nodeRelease(tls, pRtree, pRight)
 122782 	pRight = uintptr(0)
 122783 __28:
 122784 	;
 122785 	if !(rc == SQLITE_OK) {
 122786 		goto __29
 122787 	}
 122788 	rc = nodeRelease(tls, pRtree, pLeft)
 122789 	pLeft = uintptr(0)
 122790 __29:
 122791 	;
 122792 splitnode_out:
 122793 	nodeRelease(tls, pRtree, pRight)
 122794 	nodeRelease(tls, pRtree, pLeft)
 122795 	Xsqlite3_free(tls, aCell)
 122796 	return rc
 122797 }
 122798 
 122799 func fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) int32 {
 122800 	var rc int32 = SQLITE_OK
 122801 	var pChild uintptr = pLeaf
 122802 	for rc == SQLITE_OK && (*RtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1) && (*RtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0) {
 122803 		var rc2 int32 = SQLITE_OK
 122804 		Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent, 1, (*RtreeNode)(unsafe.Pointer(pChild)).FiNode)
 122805 		rc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent)
 122806 		if rc == SQLITE_ROW {
 122807 			var pTest uintptr
 122808 			var iNode I64
 122809 
 122810 			iNode = Xsqlite3_column_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent, 0)
 122811 			for pTest = pLeaf; pTest != 0 && (*RtreeNode)(unsafe.Pointer(pTest)).FiNode != iNode; pTest = (*RtreeNode)(unsafe.Pointer(pTest)).FpParent {
 122812 			}
 122813 			if pTest == uintptr(0) {
 122814 				rc2 = nodeAcquire(tls, pRtree, iNode, uintptr(0), pChild)
 122815 			}
 122816 		}
 122817 		rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent)
 122818 		if rc == SQLITE_OK {
 122819 			rc = rc2
 122820 		}
 122821 		if rc == SQLITE_OK && !(int32((*RtreeNode)(unsafe.Pointer(pChild)).FpParent) != 0) {
 122822 			rc = SQLITE_CORRUPT | int32(1)<<8
 122823 		}
 122824 		pChild = (*RtreeNode)(unsafe.Pointer(pChild)).FpParent
 122825 	}
 122826 	return rc
 122827 }
 122828 
 122829 func removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) int32 {
 122830 	bp := tls.Alloc(4)
 122831 	defer tls.Free(4)
 122832 
 122833 	var rc int32
 122834 	var rc2 int32
 122835 	var pParent uintptr = uintptr(0)
 122836 
 122837 	rc = nodeParentIndex(tls, pRtree, pNode, bp)
 122838 	if rc == SQLITE_OK {
 122839 		pParent = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent
 122840 		(*RtreeNode)(unsafe.Pointer(pNode)).FpParent = uintptr(0)
 122841 		rc = deleteCell(tls, pRtree, pParent, *(*int32)(unsafe.Pointer(bp)), iHeight+1)
 122842 
 122843 	}
 122844 	rc2 = nodeRelease(tls, pRtree, pParent)
 122845 	if rc == SQLITE_OK {
 122846 		rc = rc2
 122847 	}
 122848 	if rc != SQLITE_OK {
 122849 		return rc
 122850 	}
 122851 
 122852 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 122853 	Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode)
 122854 	if SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode)) {
 122855 		return rc
 122856 	}
 122857 
 122858 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 122859 	Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent)
 122860 	if SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent)) {
 122861 		return rc
 122862 	}
 122863 
 122864 	nodeHashDelete(tls, pRtree, pNode)
 122865 	(*RtreeNode)(unsafe.Pointer(pNode)).FiNode = I64(iHeight)
 122866 	(*RtreeNode)(unsafe.Pointer(pNode)).FpNext = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted
 122867 	(*RtreeNode)(unsafe.Pointer(pNode)).FnRef++
 122868 	(*Rtree)(unsafe.Pointer(pRtree)).FpDeleted = pNode
 122869 
 122870 	return SQLITE_OK
 122871 }
 122872 
 122873 func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 {
 122874 	bp := tls.Alloc(100)
 122875 	defer tls.Free(100)
 122876 
 122877 	var pParent uintptr = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent
 122878 	var rc int32 = SQLITE_OK
 122879 	if pParent != 0 {
 122880 		var nCell int32 = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)
 122881 
 122882 		nodeGetCell(tls, pRtree, pNode, 0, bp)
 122883 		for *(*int32)(unsafe.Pointer(bp + 96)) = 1; *(*int32)(unsafe.Pointer(bp + 96)) < nCell; *(*int32)(unsafe.Pointer(bp + 96))++ {
 122884 			nodeGetCell(tls, pRtree, pNode, *(*int32)(unsafe.Pointer(bp + 96)), bp+48)
 122885 			cellUnion(tls, pRtree, bp, bp+48)
 122886 		}
 122887 		(*RtreeCell)(unsafe.Pointer(bp)).FiRowid = (*RtreeNode)(unsafe.Pointer(pNode)).FiNode
 122888 		rc = nodeParentIndex(tls, pRtree, pNode, bp+96)
 122889 		if rc == SQLITE_OK {
 122890 			nodeOverwriteCell(tls, pRtree, pParent, bp, *(*int32)(unsafe.Pointer(bp + 96)))
 122891 			rc = fixBoundingBox(tls, pRtree, pParent)
 122892 		}
 122893 	}
 122894 	return rc
 122895 }
 122896 
 122897 func deleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iHeight int32) int32 {
 122898 	var pParent uintptr
 122899 	var rc int32
 122900 
 122901 	if SQLITE_OK != libc.AssignInt32(&rc, fixLeafParent(tls, pRtree, pNode)) {
 122902 		return rc
 122903 	}
 122904 
 122905 	nodeDeleteCell(tls, pRtree, pNode, iCell)
 122906 
 122907 	pParent = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent
 122908 
 122909 	if pParent != 0 {
 122910 		if readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2) < ((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize-4)/int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/3 {
 122911 			rc = removeNode(tls, pRtree, pNode, iHeight)
 122912 		} else {
 122913 			rc = fixBoundingBox(tls, pRtree, pNode)
 122914 		}
 122915 	}
 122916 
 122917 	return rc
 122918 }
 122919 
 122920 func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) int32 {
 122921 	bp := tls.Alloc(44)
 122922 	defer tls.Free(44)
 122923 
 122924 	var aOrder uintptr
 122925 	var aSpare uintptr
 122926 	var aCell uintptr
 122927 	var aDistance uintptr
 122928 	var nCell int32
 122929 
 122930 	var iDim int32
 122931 	var ii int32
 122932 	var rc int32 = SQLITE_OK
 122933 	var n int32
 122934 
 122935 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(RtreeDValue(0)))*uint32(RTREE_MAX_DIMENSIONS))
 122936 
 122937 	nCell = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2) + 1
 122938 	n = (nCell + 1) & libc.CplInt32(1)
 122939 
 122940 	aCell = Xsqlite3_malloc64(tls, uint64(uint32(n)*(uint32(unsafe.Sizeof(RtreeCell{}))+uint32(unsafe.Sizeof(int32(0)))+uint32(unsafe.Sizeof(int32(0)))+uint32(unsafe.Sizeof(RtreeDValue(0))))))
 122941 	if !(aCell != 0) {
 122942 		return SQLITE_NOMEM
 122943 	}
 122944 	aOrder = aCell + uintptr(n)*48
 122945 	aSpare = aOrder + uintptr(n)*4
 122946 	aDistance = aSpare + uintptr(n)*4
 122947 
 122948 	for ii = 0; ii < nCell; ii++ {
 122949 		if ii == nCell-1 {
 122950 			libc.Xmemcpy(tls, aCell+uintptr(ii)*48, pCell, uint32(unsafe.Sizeof(RtreeCell{})))
 122951 		} else {
 122952 			nodeGetCell(tls, pRtree, pNode, ii, aCell+uintptr(ii)*48)
 122953 		}
 122954 		*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)) = ii
 122955 		for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ {
 122956 			*(*RtreeDValue)(unsafe.Pointer(bp + uintptr(iDim)*8)) += func() float64 {
 122957 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122958 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2)*4)))
 122959 				}
 122960 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2)*4)))
 122961 			}()
 122962 			*(*RtreeDValue)(unsafe.Pointer(bp + uintptr(iDim)*8)) += func() float64 {
 122963 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122964 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2+1)*4)))
 122965 				}
 122966 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2+1)*4)))
 122967 			}()
 122968 		}
 122969 	}
 122970 	for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ {
 122971 		*(*RtreeDValue)(unsafe.Pointer(bp + uintptr(iDim)*8)) = *(*RtreeDValue)(unsafe.Pointer(bp + uintptr(iDim)*8)) / (float64(nCell) * RtreeDValue(2))
 122972 	}
 122973 
 122974 	for ii = 0; ii < nCell; ii++ {
 122975 		*(*RtreeDValue)(unsafe.Pointer(aDistance + uintptr(ii)*8)) = 0.0
 122976 		for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ {
 122977 			var coord RtreeDValue = func() float64 {
 122978 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122979 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2+1)*4)))
 122980 				}
 122981 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2+1)*4)))
 122982 			}() - func() float64 {
 122983 				if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 {
 122984 					return float64(*(*RtreeValue)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2)*4)))
 122985 				}
 122986 				return float64(*(*int32)(unsafe.Pointer(aCell + uintptr(ii)*48 + 8 + uintptr(iDim*2)*4)))
 122987 			}()
 122988 			*(*RtreeDValue)(unsafe.Pointer(aDistance + uintptr(ii)*8)) += (coord - *(*RtreeDValue)(unsafe.Pointer(bp + uintptr(iDim)*8))) * (coord - *(*RtreeDValue)(unsafe.Pointer(bp + uintptr(iDim)*8)))
 122989 		}
 122990 	}
 122991 
 122992 	sSortByDistance(tls, aOrder, nCell, aDistance, aSpare)
 122993 	nodeZero(tls, pRtree, pNode)
 122994 
 122995 	for ii = 0; rc == SQLITE_OK && ii < nCell-(((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize-4)/int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)/3+1); ii++ {
 122996 		var p uintptr = aCell + uintptr(*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)))*48
 122997 		nodeInsertCell(tls, pRtree, pNode, p)
 122998 		if (*RtreeCell)(unsafe.Pointer(p)).FiRowid == (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid {
 122999 			if iHeight == 0 {
 123000 				rc = rowidWrite(tls, pRtree, (*RtreeCell)(unsafe.Pointer(p)).FiRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 123001 			} else {
 123002 				rc = parentWrite(tls, pRtree, (*RtreeCell)(unsafe.Pointer(p)).FiRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 123003 			}
 123004 		}
 123005 	}
 123006 	if rc == SQLITE_OK {
 123007 		rc = fixBoundingBox(tls, pRtree, pNode)
 123008 	}
 123009 	for ; rc == SQLITE_OK && ii < nCell; ii++ {
 123010 		var p uintptr = aCell + uintptr(*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)))*48
 123011 		rc = sChooseLeaf(tls, pRtree, p, iHeight, bp+40)
 123012 		if rc == SQLITE_OK {
 123013 			var rc2 int32
 123014 			rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 40)), p, iHeight)
 123015 			rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 40)))
 123016 			if rc == SQLITE_OK {
 123017 				rc = rc2
 123018 			}
 123019 		}
 123020 	}
 123021 
 123022 	Xsqlite3_free(tls, aCell)
 123023 	return rc
 123024 }
 123025 
 123026 func rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) int32 {
 123027 	var rc int32 = SQLITE_OK
 123028 	if iHeight > 0 {
 123029 		var pChild uintptr = nodeHashLookup(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid)
 123030 		if pChild != 0 {
 123031 			nodeRelease(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pChild)).FpParent)
 123032 			nodeReference(tls, pNode)
 123033 			(*RtreeNode)(unsafe.Pointer(pChild)).FpParent = pNode
 123034 		}
 123035 	}
 123036 	if nodeInsertCell(tls, pRtree, pNode, pCell) != 0 {
 123037 		if iHeight <= (*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight || (*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) {
 123038 			rc = sSplitNode(tls, pRtree, pNode, pCell, iHeight)
 123039 		} else {
 123040 			(*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = iHeight
 123041 			rc = sReinsert(tls, pRtree, pNode, pCell, iHeight)
 123042 		}
 123043 	} else {
 123044 		rc = sAdjustTree(tls, pRtree, pNode, pCell)
 123045 		if rc == SQLITE_OK {
 123046 			if iHeight == 0 {
 123047 				rc = rowidWrite(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 123048 			} else {
 123049 				rc = parentWrite(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode)
 123050 			}
 123051 		}
 123052 	}
 123053 	return rc
 123054 }
 123055 
 123056 func reinsertNodeContent(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 {
 123057 	bp := tls.Alloc(52)
 123058 	defer tls.Free(52)
 123059 
 123060 	var ii int32
 123061 	var rc int32 = SQLITE_OK
 123062 	var nCell int32 = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData+2)
 123063 
 123064 	for ii = 0; rc == SQLITE_OK && ii < nCell; ii++ {
 123065 		nodeGetCell(tls, pRtree, pNode, ii, bp)
 123066 
 123067 		rc = sChooseLeaf(tls, pRtree, bp, int32((*RtreeNode)(unsafe.Pointer(pNode)).FiNode), bp+48)
 123068 		if rc == SQLITE_OK {
 123069 			var rc2 int32
 123070 			rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48)), bp, int32((*RtreeNode)(unsafe.Pointer(pNode)).FiNode))
 123071 			rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48)))
 123072 			if rc == SQLITE_OK {
 123073 				rc = rc2
 123074 			}
 123075 		}
 123076 	}
 123077 	return rc
 123078 }
 123079 
 123080 func rtreeNewRowid(tls *libc.TLS, pRtree uintptr, piRowid uintptr) int32 {
 123081 	var rc int32
 123082 	Xsqlite3_bind_null(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid, 1)
 123083 	Xsqlite3_bind_null(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid, 2)
 123084 	Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
 123085 	rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
 123086 	*(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb)
 123087 	return rc
 123088 }
 123089 
 123090 func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int32 {
 123091 	bp := tls.Alloc(16)
 123092 	defer tls.Free(16)
 123093 
 123094 	var rc int32
 123095 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 123096 
 123097 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 123098 
 123099 	rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp)
 123100 
 123101 	if rc == SQLITE_OK {
 123102 		rc = findLeafNode(tls, pRtree, iDelete, bp+4, uintptr(0))
 123103 	}
 123104 
 123105 	if rc == SQLITE_OK && *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
 123106 		var rc2 int32
 123107 		rc = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 4)), iDelete, bp+8)
 123108 		if rc == SQLITE_OK {
 123109 			rc = deleteCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), 0)
 123110 		}
 123111 		rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 4)))
 123112 		if rc == SQLITE_OK {
 123113 			rc = rc2
 123114 		}
 123115 	}
 123116 
 123117 	if rc == SQLITE_OK {
 123118 		Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid, 1, iDelete)
 123119 		Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid)
 123120 		rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid)
 123121 	}
 123122 
 123123 	if rc == SQLITE_OK && (*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 0 && readInt16(tls, (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzData+2) == 1 {
 123124 		var rc2 int32
 123125 		*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 123126 		var iChild I64 = nodeGetRowid(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)), 0)
 123127 		rc = nodeAcquire(tls, pRtree, iChild, *(*uintptr)(unsafe.Pointer(bp)), bp+12)
 123128 		if rc == SQLITE_OK {
 123129 			rc = removeNode(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 12)), (*Rtree)(unsafe.Pointer(pRtree)).FiDepth-1)
 123130 		}
 123131 		rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 12)))
 123132 		if rc == SQLITE_OK {
 123133 			rc = rc2
 123134 		}
 123135 		if rc == SQLITE_OK {
 123136 			(*Rtree)(unsafe.Pointer(pRtree)).FiDepth--
 123137 			writeInt16(tls, (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzData, (*Rtree)(unsafe.Pointer(pRtree)).FiDepth)
 123138 			(*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FisDirty = 1
 123139 		}
 123140 	}
 123141 
 123142 	for *(*uintptr)(unsafe.Pointer(bp + 4)) = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted; *(*uintptr)(unsafe.Pointer(bp + 4)) != 0; *(*uintptr)(unsafe.Pointer(bp + 4)) = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted {
 123143 		if rc == SQLITE_OK {
 123144 			rc = reinsertNodeContent(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 4)))
 123145 		}
 123146 		(*Rtree)(unsafe.Pointer(pRtree)).FpDeleted = (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpNext
 123147 		(*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef--
 123148 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 123149 	}
 123150 
 123151 	if rc == SQLITE_OK {
 123152 		rc = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)))
 123153 	} else {
 123154 		nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)))
 123155 	}
 123156 
 123157 	return rc
 123158 }
 123159 
 123160 func rtreeValueDown(tls *libc.TLS, v uintptr) RtreeValue {
 123161 	var d float64 = Xsqlite3_value_double(tls, v)
 123162 	var f float32 = float32(d)
 123163 	if float64(f) > d {
 123164 		f = float32(d * func() float64 {
 123165 			if d < float64(0) {
 123166 				return float64(1.0) + float64(1.0)/8388608.0
 123167 			}
 123168 			return float64(1.0) - float64(1.0)/8388608.0
 123169 		}())
 123170 	}
 123171 	return f
 123172 }
 123173 
 123174 func rtreeValueUp(tls *libc.TLS, v uintptr) RtreeValue {
 123175 	var d float64 = Xsqlite3_value_double(tls, v)
 123176 	var f float32 = float32(d)
 123177 	if float64(f) < d {
 123178 		f = float32(d * func() float64 {
 123179 			if d < float64(0) {
 123180 				return float64(1.0) - float64(1.0)/8388608.0
 123181 			}
 123182 			return float64(1.0) + float64(1.0)/8388608.0
 123183 		}())
 123184 	}
 123185 	return f
 123186 }
 123187 
 123188 func rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) int32 {
 123189 	bp := tls.Alloc(60)
 123190 	defer tls.Free(60)
 123191 
 123192 	*(*uintptr)(unsafe.Pointer(bp + 56)) = uintptr(0)
 123193 	var zSql uintptr
 123194 	var rc int32
 123195 
 123196 	zSql = Xsqlite3_mprintf(tls, ts+25204, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName))
 123197 	if zSql != 0 {
 123198 		rc = Xsqlite3_prepare_v2(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zSql, -1, bp+56, uintptr(0))
 123199 	} else {
 123200 		rc = SQLITE_NOMEM
 123201 	}
 123202 	Xsqlite3_free(tls, zSql)
 123203 
 123204 	if rc == SQLITE_OK {
 123205 		if iCol == 0 {
 123206 			var zCol uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 56)), 0)
 123207 			(*Rtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls,
 123208 				ts+25224, libc.VaList(bp+16, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zCol))
 123209 		} else {
 123210 			var zCol1 uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 56)), iCol)
 123211 			var zCol2 uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 56)), iCol+1)
 123212 			(*Rtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls,
 123213 				ts+25256, libc.VaList(bp+32, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zCol1, zCol2))
 123214 		}
 123215 	}
 123216 
 123217 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56)))
 123218 	return func() int32 {
 123219 		if rc == SQLITE_OK {
 123220 			return SQLITE_CONSTRAINT
 123221 		}
 123222 		return rc
 123223 	}()
 123224 }
 123225 
 123226 func rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowid uintptr) int32 {
 123227 	bp := tls.Alloc(52)
 123228 	defer tls.Free(52)
 123229 
 123230 	var pRtree uintptr
 123231 	var rc int32
 123232 
 123233 	var bHaveRowid int32
 123234 	var steprc int32
 123235 	var ii int32
 123236 	var nn int32
 123237 	var rc2 int32
 123238 	var pUp uintptr
 123239 	var jj int32
 123240 
 123241 	pRtree = pVtab
 123242 	rc = SQLITE_OK
 123243 	bHaveRowid = 0
 123244 
 123245 	if !((*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0) {
 123246 		goto __1
 123247 	}
 123248 
 123249 	return SQLITE_LOCKED | int32(2)<<8
 123250 __1:
 123251 	;
 123252 	rtreeReference(tls, pRtree)
 123253 
 123254 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(RtreeCell{})))
 123255 
 123256 	if !(nData > 1) {
 123257 		goto __2
 123258 	}
 123259 	nn = nData - 4
 123260 
 123261 	if !(nn > int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)) {
 123262 		goto __3
 123263 	}
 123264 	nn = int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)
 123265 __3:
 123266 	;
 123267 	if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32) {
 123268 		goto __4
 123269 	}
 123270 	ii = 0
 123271 __6:
 123272 	if !(ii < nn) {
 123273 		goto __8
 123274 	}
 123275 	*(*RtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) = rtreeValueDown(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(ii+3)*4)))
 123276 	*(*RtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii+1)*4)) = rtreeValueUp(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(ii+4)*4)))
 123277 	if !(*(*RtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) > *(*RtreeValue)(unsafe.Pointer(bp + 8 + uintptr(ii+1)*4))) {
 123278 		goto __9
 123279 	}
 123280 	rc = rtreeConstraintError(tls, pRtree, ii+1)
 123281 	goto constraint
 123282 __9:
 123283 	;
 123284 	goto __7
 123285 __7:
 123286 	ii = ii + 2
 123287 	goto __6
 123288 	goto __8
 123289 __8:
 123290 	;
 123291 	goto __5
 123292 __4:
 123293 	ii = 0
 123294 __10:
 123295 	if !(ii < nn) {
 123296 		goto __12
 123297 	}
 123298 	*(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(ii+3)*4)))
 123299 	*(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii+1)*4)) = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(ii+4)*4)))
 123300 	if !(*(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii)*4)) > *(*int32)(unsafe.Pointer(bp + 8 + uintptr(ii+1)*4))) {
 123301 		goto __13
 123302 	}
 123303 	rc = rtreeConstraintError(tls, pRtree, ii+1)
 123304 	goto constraint
 123305 __13:
 123306 	;
 123307 	goto __11
 123308 __11:
 123309 	ii = ii + 2
 123310 	goto __10
 123311 	goto __12
 123312 __12:
 123313 	;
 123314 __5:
 123315 	;
 123316 	if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 2*4))) != SQLITE_NULL) {
 123317 		goto __14
 123318 	}
 123319 	(*RtreeCell)(unsafe.Pointer(bp)).FiRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + 2*4)))
 123320 	if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) == SQLITE_NULL ||
 123321 		Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData))) != (*RtreeCell)(unsafe.Pointer(bp)).FiRowid) {
 123322 		goto __15
 123323 	}
 123324 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, (*RtreeCell)(unsafe.Pointer(bp)).FiRowid)
 123325 	steprc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 123326 	rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 123327 	if !(SQLITE_ROW == steprc) {
 123328 		goto __16
 123329 	}
 123330 	if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == SQLITE_REPLACE) {
 123331 		goto __17
 123332 	}
 123333 	rc = rtreeDeleteRowid(tls, pRtree, (*RtreeCell)(unsafe.Pointer(bp)).FiRowid)
 123334 	goto __18
 123335 __17:
 123336 	rc = rtreeConstraintError(tls, pRtree, 0)
 123337 	goto constraint
 123338 __18:
 123339 	;
 123340 __16:
 123341 	;
 123342 __15:
 123343 	;
 123344 	bHaveRowid = 1
 123345 __14:
 123346 	;
 123347 __2:
 123348 	;
 123349 	if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) != SQLITE_NULL) {
 123350 		goto __19
 123351 	}
 123352 	rc = rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData))))
 123353 __19:
 123354 	;
 123355 	if !(rc == SQLITE_OK && nData > 1) {
 123356 		goto __20
 123357 	}
 123358 
 123359 	*(*uintptr)(unsafe.Pointer(bp + 48)) = uintptr(0)
 123360 
 123361 	if !(bHaveRowid == 0) {
 123362 		goto __21
 123363 	}
 123364 	rc = rtreeNewRowid(tls, pRtree, bp)
 123365 __21:
 123366 	;
 123367 	*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*RtreeCell)(unsafe.Pointer(bp)).FiRowid
 123368 
 123369 	if !(rc == SQLITE_OK) {
 123370 		goto __22
 123371 	}
 123372 	rc = sChooseLeaf(tls, pRtree, bp, 0, bp+48)
 123373 __22:
 123374 	;
 123375 	if !(rc == SQLITE_OK) {
 123376 		goto __23
 123377 	}
 123378 	(*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = -1
 123379 	rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48)), bp, 0)
 123380 	rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48)))
 123381 	if !(rc == SQLITE_OK) {
 123382 		goto __24
 123383 	}
 123384 	rc = rc2
 123385 __24:
 123386 	;
 123387 __23:
 123388 	;
 123389 	if !(rc == SQLITE_OK && (*Rtree)(unsafe.Pointer(pRtree)).FnAux != 0) {
 123390 		goto __25
 123391 	}
 123392 	pUp = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux
 123393 	Xsqlite3_bind_int64(tls, pUp, 1, *(*Sqlite_int64)(unsafe.Pointer(pRowid)))
 123394 	jj = 0
 123395 __26:
 123396 	if !(jj < int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux)) {
 123397 		goto __28
 123398 	}
 123399 	Xsqlite3_bind_value(tls, pUp, jj+2, *(*uintptr)(unsafe.Pointer(aData + uintptr(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)+3+jj)*4)))
 123400 	goto __27
 123401 __27:
 123402 	jj++
 123403 	goto __26
 123404 	goto __28
 123405 __28:
 123406 	;
 123407 	Xsqlite3_step(tls, pUp)
 123408 	rc = Xsqlite3_reset(tls, pUp)
 123409 __25:
 123410 	;
 123411 __20:
 123412 	;
 123413 constraint:
 123414 	rtreeRelease(tls, pRtree)
 123415 	return rc
 123416 }
 123417 
 123418 func rtreeBeginTransaction(tls *libc.TLS, pVtab uintptr) int32 {
 123419 	var pRtree uintptr = pVtab
 123420 
 123421 	(*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans++
 123422 	return SQLITE_OK
 123423 }
 123424 
 123425 func rtreeEndTransaction(tls *libc.TLS, pVtab uintptr) int32 {
 123426 	var pRtree uintptr = pVtab
 123427 	(*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0)
 123428 	nodeBlobReset(tls, pRtree)
 123429 	return SQLITE_OK
 123430 }
 123431 
 123432 func rtreeRename(tls *libc.TLS, pVtab uintptr, zNewName uintptr) int32 {
 123433 	bp := tls.Alloc(72)
 123434 	defer tls.Free(72)
 123435 
 123436 	var pRtree uintptr = pVtab
 123437 	var rc int32 = SQLITE_NOMEM
 123438 	var zSql uintptr = Xsqlite3_mprintf(tls,
 123439 		ts+25293, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName))
 123440 	if zSql != 0 {
 123441 		nodeBlobReset(tls, pRtree)
 123442 		rc = Xsqlite3_exec(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zSql, uintptr(0), uintptr(0), uintptr(0))
 123443 		Xsqlite3_free(tls, zSql)
 123444 	}
 123445 	return rc
 123446 }
 123447 
 123448 func rtreeSavepoint(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 {
 123449 	var pRtree uintptr = pVtab
 123450 	var iwt U8 = (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans
 123451 	_ = iSavepoint
 123452 	(*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0)
 123453 	nodeBlobReset(tls, pRtree)
 123454 	(*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = iwt
 123455 	return SQLITE_OK
 123456 }
 123457 
 123458 func rtreeQueryStat1(tls *libc.TLS, db uintptr, pRtree uintptr) int32 {
 123459 	bp := tls.Alloc(20)
 123460 	defer tls.Free(20)
 123461 
 123462 	var zFmt uintptr = ts + 25438
 123463 	var zSql uintptr
 123464 
 123465 	var rc int32
 123466 	var nRow I64 = int64(RTREE_MIN_ROWEST)
 123467 
 123468 	rc = Xsqlite3_table_column_metadata(tls,
 123469 		db, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, ts+11348, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
 123470 	if rc != SQLITE_OK {
 123471 		(*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(RTREE_DEFAULT_ROWEST)
 123472 		if rc == SQLITE_ERROR {
 123473 			return SQLITE_OK
 123474 		}
 123475 		return rc
 123476 	}
 123477 	zSql = Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName))
 123478 	if zSql == uintptr(0) {
 123479 		rc = SQLITE_NOMEM
 123480 	} else {
 123481 		rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+16, uintptr(0))
 123482 		if rc == SQLITE_OK {
 123483 			if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) == SQLITE_ROW {
 123484 				nRow = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 0)
 123485 			}
 123486 			rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
 123487 		}
 123488 		Xsqlite3_free(tls, zSql)
 123489 	}
 123490 	(*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = func() int64 {
 123491 		if nRow > int64(RTREE_MIN_ROWEST) {
 123492 			return nRow
 123493 		}
 123494 		return int64(RTREE_MIN_ROWEST)
 123495 	}()
 123496 	return rc
 123497 }
 123498 
 123499 func rtreeShadowName(tls *libc.TLS, zName uintptr) int32 {
 123500 	var i uint32
 123501 	for i = uint32(0); i < uint32(unsafe.Sizeof(azName1))/uint32(unsafe.Sizeof(uintptr(0))); i++ {
 123502 		if Xsqlite3_stricmp(tls, zName, azName1[i]) == 0 {
 123503 			return 1
 123504 		}
 123505 	}
 123506 	return 0
 123507 }
 123508 
 123509 var azName1 = [3]uintptr{
 123510 	ts + 25494, ts + 5060, ts + 16267,
 123511 }
 123512 
 123513 var rtreeModule = Sqlite3_module{
 123514 	FiVersion:    3,
 123515 	FxCreate:     0,
 123516 	FxConnect:    0,
 123517 	FxBestIndex:  0,
 123518 	FxDisconnect: 0,
 123519 	FxDestroy:    0,
 123520 	FxOpen:       0,
 123521 	FxClose:      0,
 123522 	FxFilter:     0,
 123523 	FxNext:       0,
 123524 	FxEof:        0,
 123525 	FxColumn:     0,
 123526 	FxRowid:      0,
 123527 	FxUpdate:     0,
 123528 	FxBegin:      0,
 123529 	FxSync:       0,
 123530 	FxCommit:     0,
 123531 	FxRollback:   0,
 123532 	FxRename:     0,
 123533 	FxSavepoint:  0,
 123534 	FxShadowName: 0,
 123535 }
 123536 
 123537 func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefix uintptr, isCreate int32) int32 {
 123538 	bp := tls.Alloc(200)
 123539 	defer tls.Free(200)
 123540 
 123541 	var rc int32 = SQLITE_OK
 123542 
 123543 	var i int32
 123544 	var f int32 = SQLITE_PREPARE_PERSISTENT | SQLITE_PREPARE_NO_VTAB
 123545 
 123546 	(*Rtree)(unsafe.Pointer(pRtree)).Fdb = db
 123547 
 123548 	if isCreate != 0 {
 123549 		var zCreate uintptr
 123550 		var p uintptr = Xsqlite3_str_new(tls, db)
 123551 		var ii int32
 123552 		Xsqlite3_str_appendf(tls, p,
 123553 			ts+25499,
 123554 			libc.VaList(bp, zDb, zPrefix))
 123555 		for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux); ii++ {
 123556 			Xsqlite3_str_appendf(tls, p, ts+25561, libc.VaList(bp+16, ii))
 123557 		}
 123558 		Xsqlite3_str_appendf(tls, p,
 123559 			ts+25566,
 123560 			libc.VaList(bp+24, zDb, zPrefix))
 123561 		Xsqlite3_str_appendf(tls, p,
 123562 			ts+25630,
 123563 			libc.VaList(bp+40, zDb, zPrefix))
 123564 		Xsqlite3_str_appendf(tls, p,
 123565 			ts+25700,
 123566 			libc.VaList(bp+56, zDb, zPrefix, (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize))
 123567 		zCreate = Xsqlite3_str_finish(tls, p)
 123568 		if !(zCreate != 0) {
 123569 			return SQLITE_NOMEM
 123570 		}
 123571 		rc = Xsqlite3_exec(tls, db, zCreate, uintptr(0), uintptr(0), uintptr(0))
 123572 		Xsqlite3_free(tls, zCreate)
 123573 		if rc != SQLITE_OK {
 123574 			return rc
 123575 		}
 123576 	}
 123577 
 123578 	*(*uintptr)(unsafe.Pointer(bp + 168)) = pRtree + 80
 123579 	*(*uintptr)(unsafe.Pointer(bp + 168 + 1*4)) = pRtree + 84
 123580 	*(*uintptr)(unsafe.Pointer(bp + 168 + 2*4)) = pRtree + 88
 123581 	*(*uintptr)(unsafe.Pointer(bp + 168 + 3*4)) = pRtree + 92
 123582 	*(*uintptr)(unsafe.Pointer(bp + 168 + 4*4)) = pRtree + 96
 123583 	*(*uintptr)(unsafe.Pointer(bp + 168 + 5*4)) = pRtree + 100
 123584 	*(*uintptr)(unsafe.Pointer(bp + 168 + 6*4)) = pRtree + 104
 123585 	*(*uintptr)(unsafe.Pointer(bp + 168 + 7*4)) = pRtree + 108
 123586 
 123587 	rc = rtreeQueryStat1(tls, db, pRtree)
 123588 	for i = 0; i < N_STATEMENT && rc == SQLITE_OK; i++ {
 123589 		var zSql uintptr
 123590 		var zFormat uintptr
 123591 		if i != 3 || int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) == 0 {
 123592 			zFormat = azSql[i]
 123593 		} else {
 123594 			zFormat = ts + 25749
 123595 		}
 123596 		zSql = Xsqlite3_mprintf(tls, zFormat, libc.VaList(bp+80, zDb, zPrefix))
 123597 		if zSql != 0 {
 123598 			rc = Xsqlite3_prepare_v3(tls, db, zSql, -1, uint32(f), *(*uintptr)(unsafe.Pointer(bp + 168 + uintptr(i)*4)), uintptr(0))
 123599 		} else {
 123600 			rc = SQLITE_NOMEM
 123601 		}
 123602 		Xsqlite3_free(tls, zSql)
 123603 	}
 123604 	if (*Rtree)(unsafe.Pointer(pRtree)).FnAux != 0 {
 123605 		(*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql = Xsqlite3_mprintf(tls,
 123606 			ts+25857,
 123607 			libc.VaList(bp+96, zDb, zPrefix))
 123608 		if (*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql == uintptr(0) {
 123609 			rc = SQLITE_NOMEM
 123610 		} else {
 123611 			var p uintptr = Xsqlite3_str_new(tls, db)
 123612 			var ii int32
 123613 			var zSql uintptr
 123614 			Xsqlite3_str_appendf(tls, p, ts+25902, libc.VaList(bp+112, zDb, zPrefix))
 123615 			for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux); ii++ {
 123616 				if ii != 0 {
 123617 					Xsqlite3_str_append(tls, p, ts+12767, 1)
 123618 				}
 123619 				if ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnAuxNotNull) {
 123620 					Xsqlite3_str_appendf(tls, p, ts+25929, libc.VaList(bp+128, ii, ii+2, ii))
 123621 				} else {
 123622 					Xsqlite3_str_appendf(tls, p, ts+25951, libc.VaList(bp+152, ii, ii+2))
 123623 				}
 123624 			}
 123625 			Xsqlite3_str_appendf(tls, p, ts+25959, 0)
 123626 			zSql = Xsqlite3_str_finish(tls, p)
 123627 			if zSql == uintptr(0) {
 123628 				rc = SQLITE_NOMEM
 123629 			} else {
 123630 				rc = Xsqlite3_prepare_v3(tls, db, zSql, -1, uint32(f), pRtree+112, uintptr(0))
 123631 				Xsqlite3_free(tls, zSql)
 123632 			}
 123633 		}
 123634 	}
 123635 
 123636 	return rc
 123637 }
 123638 
 123639 var azSql = [8]uintptr{
 123640 	ts + 25975,
 123641 	ts + 26028,
 123642 	ts + 26073,
 123643 	ts + 26125,
 123644 	ts + 26179,
 123645 	ts + 26224,
 123646 	ts + 26282,
 123647 	ts + 26337,
 123648 }
 123649 
 123650 func getIntFromStmt(tls *libc.TLS, db uintptr, zSql uintptr, piVal uintptr) int32 {
 123651 	bp := tls.Alloc(4)
 123652 	defer tls.Free(4)
 123653 
 123654 	var rc int32 = SQLITE_NOMEM
 123655 	if zSql != 0 {
 123656 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 123657 		rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp, uintptr(0))
 123658 		if rc == SQLITE_OK {
 123659 			if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 123660 				*(*int32)(unsafe.Pointer(piVal)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
 123661 			}
 123662 			rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 123663 		}
 123664 	}
 123665 	return rc
 123666 }
 123667 
 123668 func getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzErr uintptr) int32 {
 123669 	bp := tls.Alloc(52)
 123670 	defer tls.Free(52)
 123671 
 123672 	var rc int32
 123673 	var zSql uintptr
 123674 	if isCreate != 0 {
 123675 		*(*int32)(unsafe.Pointer(bp + 48)) = 0
 123676 		zSql = Xsqlite3_mprintf(tls, ts+26384, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb))
 123677 		rc = getIntFromStmt(tls, db, zSql, bp+48)
 123678 		if rc == SQLITE_OK {
 123679 			(*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = *(*int32)(unsafe.Pointer(bp + 48)) - 64
 123680 			if 4+int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*RTREE_MAXCELLS < (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize {
 123681 				(*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = 4 + int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)*RTREE_MAXCELLS
 123682 			}
 123683 		} else {
 123684 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db)))
 123685 		}
 123686 	} else {
 123687 		zSql = Xsqlite3_mprintf(tls,
 123688 			ts+26404,
 123689 			libc.VaList(bp+16, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName))
 123690 		rc = getIntFromStmt(tls, db, zSql, pRtree+16)
 123691 		if rc != SQLITE_OK {
 123692 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+32, Xsqlite3_errmsg(tls, db)))
 123693 		} else if (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize < 512-64 {
 123694 			rc = SQLITE_CORRUPT | int32(1)<<8
 123695 
 123696 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+26461,
 123697 				libc.VaList(bp+40, (*Rtree)(unsafe.Pointer(pRtree)).FzName))
 123698 		}
 123699 	}
 123700 
 123701 	Xsqlite3_free(tls, zSql)
 123702 	return rc
 123703 }
 123704 
 123705 func rtreeTokenLength(tls *libc.TLS, z uintptr) int32 {
 123706 	bp := tls.Alloc(4)
 123707 	defer tls.Free(4)
 123708 
 123709 	*(*int32)(unsafe.Pointer(bp)) = 0
 123710 	return Xsqlite3GetToken(tls, z, bp)
 123711 }
 123712 
 123713 func rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) int32 {
 123714 	bp := tls.Alloc(116)
 123715 	defer tls.Free(116)
 123716 
 123717 	var rc int32
 123718 	var pRtree uintptr
 123719 	var nDb int32
 123720 	var nName int32
 123721 	var eCoordType int32
 123722 	var pSql uintptr
 123723 	var zSql uintptr
 123724 	var ii int32
 123725 	var iErr int32
 123726 
 123727 	var zArg uintptr
 123728 	rc = SQLITE_OK
 123729 	eCoordType = func() int32 {
 123730 		if pAux != 0 {
 123731 			return RTREE_COORD_INT32
 123732 		}
 123733 		return RTREE_COORD_REAL32
 123734 	}()
 123735 	ii = 4
 123736 	*(*[5]uintptr)(unsafe.Pointer(bp + 96)) = [5]uintptr{
 123737 		uintptr(0),
 123738 		ts + 26496,
 123739 		ts + 26539,
 123740 		ts + 26574,
 123741 		ts + 26610,
 123742 	}
 123743 
 123744 	if !(argc < 6 || argc > RTREE_MAX_AUX_COLUMN+3) {
 123745 		goto __1
 123746 	}
 123747 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 96 + uintptr(2+libc.Bool32(argc >= 6))*4))))
 123748 	return SQLITE_ERROR
 123749 __1:
 123750 	;
 123751 	Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_CONSTRAINT_SUPPORT, libc.VaList(bp+8, 1))
 123752 
 123753 	nDb = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))))
 123754 	nName = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
 123755 	pRtree = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(Rtree{}))+uint32(nDb)+uint32(nName)+uint32(2)))
 123756 	if !!(pRtree != 0) {
 123757 		goto __2
 123758 	}
 123759 	return SQLITE_NOMEM
 123760 __2:
 123761 	;
 123762 	libc.Xmemset(tls, pRtree, 0, uint32(unsafe.Sizeof(Rtree{}))+uint32(nDb)+uint32(nName)+uint32(2))
 123763 	(*Rtree)(unsafe.Pointer(pRtree)).FnBusy = U32(1)
 123764 	(*Rtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&rtreeModule))
 123765 	(*Rtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*504
 123766 	(*Rtree)(unsafe.Pointer(pRtree)).FzName = (*Rtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+1)
 123767 	(*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = U8(eCoordType)
 123768 	libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + 1*4)), uint32(nDb))
 123769 	libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + 2*4)), uint32(nName))
 123770 
 123771 	pSql = Xsqlite3_str_new(tls, db)
 123772 	Xsqlite3_str_appendf(tls, pSql, ts+26647,
 123773 		libc.VaList(bp+16, rtreeTokenLength(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4))), *(*uintptr)(unsafe.Pointer(argv + 3*4))))
 123774 	ii = 4
 123775 __3:
 123776 	if !(ii < argc) {
 123777 		goto __5
 123778 	}
 123779 	zArg = *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*4))
 123780 	if !(int32(*(*uint8)(unsafe.Pointer(zArg))) == '+') {
 123781 		goto __6
 123782 	}
 123783 	(*Rtree)(unsafe.Pointer(pRtree)).FnAux++
 123784 	Xsqlite3_str_appendf(tls, pSql, ts+26671, libc.VaList(bp+32, rtreeTokenLength(tls, zArg+uintptr(1)), zArg+uintptr(1)))
 123785 	goto __7
 123786 __6:
 123787 	if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) > 0) {
 123788 		goto __8
 123789 	}
 123790 	goto __5
 123791 	goto __9
 123792 __8:
 123793 	(*Rtree)(unsafe.Pointer(pRtree)).FnDim2++
 123794 	Xsqlite3_str_appendf(tls, pSql, azFormat[eCoordType],
 123795 		libc.VaList(bp+48, rtreeTokenLength(tls, zArg), zArg))
 123796 __9:
 123797 	;
 123798 __7:
 123799 	;
 123800 	goto __4
 123801 __4:
 123802 	ii++
 123803 	goto __3
 123804 	goto __5
 123805 __5:
 123806 	;
 123807 	Xsqlite3_str_appendf(tls, pSql, ts+26677, 0)
 123808 	zSql = Xsqlite3_str_finish(tls, pSql)
 123809 	if !!(zSql != 0) {
 123810 		goto __10
 123811 	}
 123812 	rc = SQLITE_NOMEM
 123813 	goto __11
 123814 __10:
 123815 	if !(ii < argc) {
 123816 		goto __12
 123817 	}
 123818 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(bp + 96 + 4*4))))
 123819 	rc = SQLITE_ERROR
 123820 	goto __13
 123821 __12:
 123822 	if !(SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql))) {
 123823 		goto __14
 123824 	}
 123825 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+72, Xsqlite3_errmsg(tls, db)))
 123826 __14:
 123827 	;
 123828 __13:
 123829 	;
 123830 __11:
 123831 	;
 123832 	Xsqlite3_free(tls, zSql)
 123833 	if !(rc != 0) {
 123834 		goto __15
 123835 	}
 123836 	goto rtreeInit_fail
 123837 __15:
 123838 	;
 123839 	(*Rtree)(unsafe.Pointer(pRtree)).FnDim = U8(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) / 2)
 123840 	if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) < 1) {
 123841 		goto __16
 123842 	}
 123843 	iErr = 2
 123844 	goto __17
 123845 __16:
 123846 	if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) > RTREE_MAX_DIMENSIONS*2) {
 123847 		goto __18
 123848 	}
 123849 	iErr = 3
 123850 	goto __19
 123851 __18:
 123852 	if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)%2 != 0) {
 123853 		goto __20
 123854 	}
 123855 	iErr = 1
 123856 	goto __21
 123857 __20:
 123858 	iErr = 0
 123859 __21:
 123860 	;
 123861 __19:
 123862 	;
 123863 __17:
 123864 	;
 123865 	if !(iErr != 0) {
 123866 		goto __22
 123867 	}
 123868 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+80, *(*uintptr)(unsafe.Pointer(bp + 96 + uintptr(iErr)*4))))
 123869 	goto rtreeInit_fail
 123870 __22:
 123871 	;
 123872 	(*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = U8(8 + int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)*4)
 123873 
 123874 	rc = getNodeSize(tls, db, pRtree, isCreate, pzErr)
 123875 	if !(rc != 0) {
 123876 		goto __23
 123877 	}
 123878 	goto rtreeInit_fail
 123879 __23:
 123880 	;
 123881 	rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + 1*4)), *(*uintptr)(unsafe.Pointer(argv + 2*4)), isCreate)
 123882 	if !(rc != 0) {
 123883 		goto __24
 123884 	}
 123885 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+88, Xsqlite3_errmsg(tls, db)))
 123886 	goto rtreeInit_fail
 123887 __24:
 123888 	;
 123889 	*(*uintptr)(unsafe.Pointer(ppVtab)) = pRtree
 123890 	return SQLITE_OK
 123891 
 123892 rtreeInit_fail:
 123893 	if !(rc == SQLITE_OK) {
 123894 		goto __25
 123895 	}
 123896 	rc = SQLITE_ERROR
 123897 __25:
 123898 	;
 123899 	rtreeRelease(tls, pRtree)
 123900 	return rc
 123901 }
 123902 
 123903 var azFormat = [2]uintptr{ts + 26680, ts + 26691}
 123904 
 123905 func rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) {
 123906 	bp := tls.Alloc(600)
 123907 	defer tls.Free(600)
 123908 
 123909 	var ii int32
 123910 	var nData int32
 123911 	var errCode int32
 123912 	var pOut uintptr
 123913 
 123914 	_ = nArg
 123915 	libc.Xmemset(tls, bp+16, 0, uint32(unsafe.Sizeof(RtreeNode{})))
 123916 	libc.Xmemset(tls, bp+48, 0, uint32(unsafe.Sizeof(Rtree{})))
 123917 	(*Rtree)(unsafe.Pointer(bp + 48)).FnDim = U8(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apArg))))
 123918 	if int32((*Rtree)(unsafe.Pointer(bp+48)).FnDim) < 1 || int32((*Rtree)(unsafe.Pointer(bp+48)).FnDim) > 5 {
 123919 		return
 123920 	}
 123921 	(*Rtree)(unsafe.Pointer(bp + 48)).FnDim2 = U8(int32((*Rtree)(unsafe.Pointer(bp+48)).FnDim) * 2)
 123922 	(*Rtree)(unsafe.Pointer(bp + 48)).FnBytesPerCell = U8(8 + 8*int32((*Rtree)(unsafe.Pointer(bp+48)).FnDim))
 123923 	(*RtreeNode)(unsafe.Pointer(bp + 16)).FzData = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*4)))
 123924 	if (*RtreeNode)(unsafe.Pointer(bp+16)).FzData == uintptr(0) {
 123925 		return
 123926 	}
 123927 	nData = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*4)))
 123928 	if nData < 4 {
 123929 		return
 123930 	}
 123931 	if nData < readInt16(tls, (*RtreeNode)(unsafe.Pointer(bp+16)).FzData+2)*int32((*Rtree)(unsafe.Pointer(bp+48)).FnBytesPerCell) {
 123932 		return
 123933 	}
 123934 
 123935 	pOut = Xsqlite3_str_new(tls, uintptr(0))
 123936 	for ii = 0; ii < readInt16(tls, (*RtreeNode)(unsafe.Pointer(bp+16)).FzData+2); ii++ {
 123937 		var jj int32
 123938 
 123939 		nodeGetCell(tls, bp+48, bp+16, ii, bp+552)
 123940 		if ii > 0 {
 123941 			Xsqlite3_str_append(tls, pOut, ts+10920, 1)
 123942 		}
 123943 		Xsqlite3_str_appendf(tls, pOut, ts+26701, libc.VaList(bp, (*RtreeCell)(unsafe.Pointer(bp+552)).FiRowid))
 123944 		for jj = 0; jj < int32((*Rtree)(unsafe.Pointer(bp+48)).FnDim2); jj++ {
 123945 			Xsqlite3_str_appendf(tls, pOut, ts+26707, libc.VaList(bp+8, float64(*(*RtreeValue)(unsafe.Pointer(bp + 552 + 8 + uintptr(jj)*4)))))
 123946 		}
 123947 		Xsqlite3_str_append(tls, pOut, ts+26711, 1)
 123948 	}
 123949 	errCode = Xsqlite3_str_errcode(tls, pOut)
 123950 	Xsqlite3_result_text(tls, ctx, Xsqlite3_str_finish(tls, pOut), -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 123951 	Xsqlite3_result_error_code(tls, ctx, errCode)
 123952 }
 123953 
 123954 func rtreedepth(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) {
 123955 	_ = nArg
 123956 	if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg))) != SQLITE_BLOB ||
 123957 		Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg))) < 2 {
 123958 		Xsqlite3_result_error(tls, ctx, ts+26713, -1)
 123959 	} else {
 123960 		var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg)))
 123961 		if zBlob != 0 {
 123962 			Xsqlite3_result_int(tls, ctx, readInt16(tls, zBlob))
 123963 		} else {
 123964 			Xsqlite3_result_error_nomem(tls, ctx)
 123965 		}
 123966 	}
 123967 }
 123968 
 123969 // Context object passed between the various routines that make up the
 123970 // implementation of integrity-check function rtreecheck().
 123971 type RtreeCheck1 = struct {
 123972 	Fdb            uintptr
 123973 	FzDb           uintptr
 123974 	FzTab          uintptr
 123975 	FbInt          int32
 123976 	FnDim          int32
 123977 	FpGetNode      uintptr
 123978 	FaCheckMapping [2]uintptr
 123979 	FnLeaf         int32
 123980 	FnNonLeaf      int32
 123981 	Frc            int32
 123982 	FzReport       uintptr
 123983 	FnErr          int32
 123984 }
 123985 
 123986 // Context object passed between the various routines that make up the
 123987 // implementation of integrity-check function rtreecheck().
 123988 type RtreeCheck = RtreeCheck1
 123989 
 123990 func rtreeCheckReset(tls *libc.TLS, pCheck uintptr, pStmt uintptr) {
 123991 	var rc int32 = Xsqlite3_reset(tls, pStmt)
 123992 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
 123993 		(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = rc
 123994 	}
 123995 }
 123996 
 123997 func rtreeCheckPrepare(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) uintptr {
 123998 	bp := tls.Alloc(4)
 123999 	defer tls.Free(4)
 124000 
 124001 	var ap Va_list
 124002 	_ = ap
 124003 	var z uintptr
 124004 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 124005 
 124006 	ap = va
 124007 	z = Xsqlite3_vmprintf(tls, zFmt, ap)
 124008 
 124009 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
 124010 		if z == uintptr(0) {
 124011 			(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM
 124012 		} else {
 124013 			(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_prepare_v2(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).Fdb, z, -1, bp, uintptr(0))
 124014 		}
 124015 	}
 124016 
 124017 	Xsqlite3_free(tls, z)
 124018 	_ = ap
 124019 	return *(*uintptr)(unsafe.Pointer(bp))
 124020 }
 124021 
 124022 func rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) {
 124023 	bp := tls.Alloc(24)
 124024 	defer tls.Free(24)
 124025 
 124026 	var ap Va_list
 124027 	_ = ap
 124028 	ap = va
 124029 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && (*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr < RTREE_CHECK_MAX_ERROR {
 124030 		var z uintptr = Xsqlite3_vmprintf(tls, zFmt, ap)
 124031 		if z == uintptr(0) {
 124032 			(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM
 124033 		} else {
 124034 			(*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport = Xsqlite3_mprintf(tls, ts+26746,
 124035 				libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport, func() uintptr {
 124036 					if (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport != 0 {
 124037 						return ts + 4062
 124038 					}
 124039 					return ts + 1554
 124040 				}(), z))
 124041 			if (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport == uintptr(0) {
 124042 				(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM
 124043 			}
 124044 		}
 124045 		(*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr++
 124046 	}
 124047 	_ = ap
 124048 }
 124049 
 124050 func rtreeCheckGetNode(tls *libc.TLS, pCheck uintptr, iNode I64, pnNode uintptr) uintptr {
 124051 	bp := tls.Alloc(24)
 124052 	defer tls.Free(24)
 124053 
 124054 	var pRet uintptr = uintptr(0)
 124055 
 124056 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0) {
 124057 		(*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode = rtreeCheckPrepare(tls, pCheck,
 124058 			ts+26753,
 124059 			libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab))
 124060 	}
 124061 
 124062 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
 124063 		Xsqlite3_bind_int64(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 1, iNode)
 124064 		if Xsqlite3_step(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == SQLITE_ROW {
 124065 			var nNode int32 = Xsqlite3_column_bytes(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0)
 124066 			var pNode uintptr = Xsqlite3_column_blob(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0)
 124067 			pRet = Xsqlite3_malloc64(tls, uint64(nNode))
 124068 			if pRet == uintptr(0) {
 124069 				(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM
 124070 			} else {
 124071 				libc.Xmemcpy(tls, pRet, pNode, uint32(nNode))
 124072 				*(*int32)(unsafe.Pointer(pnNode)) = nNode
 124073 			}
 124074 		}
 124075 		rtreeCheckReset(tls, pCheck, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode)
 124076 		if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && pRet == uintptr(0) {
 124077 			rtreeCheckAppendMsg(tls, pCheck, ts+26798, libc.VaList(bp+16, iNode))
 124078 		}
 124079 	}
 124080 
 124081 	return pRet
 124082 }
 124083 
 124084 func rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey I64, iVal I64) {
 124085 	bp := tls.Alloc(88)
 124086 	defer tls.Free(88)
 124087 
 124088 	var rc int32
 124089 	var pStmt uintptr
 124090 	*(*[2]uintptr)(unsafe.Pointer(bp + 80)) = [2]uintptr{
 124091 		ts + 26830,
 124092 		ts + 26884,
 124093 	}
 124094 
 124095 	if *(*uintptr)(unsafe.Pointer(pCheck + 24 + uintptr(bLeaf)*4)) == uintptr(0) {
 124096 		*(*uintptr)(unsafe.Pointer(pCheck + 24 + uintptr(bLeaf)*4)) = rtreeCheckPrepare(tls, pCheck,
 124097 			*(*uintptr)(unsafe.Pointer(bp + 80 + uintptr(bLeaf)*4)), libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab))
 124098 	}
 124099 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc != SQLITE_OK {
 124100 		return
 124101 	}
 124102 
 124103 	pStmt = *(*uintptr)(unsafe.Pointer(pCheck + 24 + uintptr(bLeaf)*4))
 124104 	Xsqlite3_bind_int64(tls, pStmt, 1, iKey)
 124105 	rc = Xsqlite3_step(tls, pStmt)
 124106 	if rc == SQLITE_DONE {
 124107 		rtreeCheckAppendMsg(tls, pCheck, ts+26932,
 124108 			libc.VaList(bp+16, iKey, iVal, func() uintptr {
 124109 				if bLeaf != 0 {
 124110 					return ts + 26977
 124111 				}
 124112 				return ts + 26985
 124113 			}()))
 124114 	} else if rc == SQLITE_ROW {
 124115 		var ii I64 = Xsqlite3_column_int64(tls, pStmt, 0)
 124116 		if ii != iVal {
 124117 			rtreeCheckAppendMsg(tls, pCheck,
 124118 				ts+26994,
 124119 				libc.VaList(bp+40, iKey, ii, func() uintptr {
 124120 					if bLeaf != 0 {
 124121 						return ts + 26977
 124122 					}
 124123 					return ts + 26985
 124124 				}(), iKey, iVal))
 124125 		}
 124126 	}
 124127 	rtreeCheckReset(tls, pCheck, pStmt)
 124128 }
 124129 
 124130 func rtreeCheckCellCoord(tls *libc.TLS, pCheck uintptr, iNode I64, iCell int32, pCell uintptr, pParent uintptr) {
 124131 	bp := tls.Alloc(64)
 124132 	defer tls.Free(64)
 124133 
 124134 	var i int32
 124135 
 124136 	for i = 0; i < (*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim; i++ {
 124137 		readCoord(tls, pCell+uintptr(4*2*i), bp+48)
 124138 		readCoord(tls, pCell+uintptr(4*(2*i+1)), bp+52)
 124139 
 124140 		if func() int32 {
 124141 			if (*RtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 {
 124142 				return libc.Bool32(*(*int32)(unsafe.Pointer(bp + 48)) > *(*int32)(unsafe.Pointer(bp + 52)))
 124143 			}
 124144 			return libc.Bool32(*(*RtreeValue)(unsafe.Pointer(bp + 48)) > *(*RtreeValue)(unsafe.Pointer(bp + 52)))
 124145 		}() != 0 {
 124146 			rtreeCheckAppendMsg(tls, pCheck,
 124147 				ts+27052, libc.VaList(bp, i, iCell, iNode))
 124148 		}
 124149 
 124150 		if pParent != 0 {
 124151 			readCoord(tls, pParent+uintptr(4*2*i), bp+56)
 124152 			readCoord(tls, pParent+uintptr(4*(2*i+1)), bp+60)
 124153 
 124154 			if func() int32 {
 124155 				if (*RtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 {
 124156 					return libc.Bool32(*(*int32)(unsafe.Pointer(bp + 48)) < *(*int32)(unsafe.Pointer(bp + 56)))
 124157 				}
 124158 				return libc.Bool32(*(*RtreeValue)(unsafe.Pointer(bp + 48)) < *(*RtreeValue)(unsafe.Pointer(bp + 56)))
 124159 			}() != 0 ||
 124160 				func() int32 {
 124161 					if (*RtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 {
 124162 						return libc.Bool32(*(*int32)(unsafe.Pointer(bp + 52)) > *(*int32)(unsafe.Pointer(bp + 60)))
 124163 					}
 124164 					return libc.Bool32(*(*RtreeValue)(unsafe.Pointer(bp + 52)) > *(*RtreeValue)(unsafe.Pointer(bp + 60)))
 124165 				}() != 0 {
 124166 				rtreeCheckAppendMsg(tls, pCheck,
 124167 					ts+27100, libc.VaList(bp+24, i, iCell, iNode))
 124168 			}
 124169 		}
 124170 	}
 124171 }
 124172 
 124173 func rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr, iNode I64) {
 124174 	bp := tls.Alloc(52)
 124175 	defer tls.Free(52)
 124176 
 124177 	var aNode uintptr = uintptr(0)
 124178 	*(*int32)(unsafe.Pointer(bp + 48)) = 0
 124179 
 124180 	aNode = rtreeCheckGetNode(tls, pCheck, iNode, bp+48)
 124181 	if aNode != 0 {
 124182 		if *(*int32)(unsafe.Pointer(bp + 48)) < 4 {
 124183 			rtreeCheckAppendMsg(tls, pCheck,
 124184 				ts+27167, libc.VaList(bp, iNode, *(*int32)(unsafe.Pointer(bp + 48))))
 124185 		} else {
 124186 			var nCell int32
 124187 			var i int32
 124188 			if aParent == uintptr(0) {
 124189 				iDepth = readInt16(tls, aNode)
 124190 				if iDepth > RTREE_MAX_DEPTH {
 124191 					rtreeCheckAppendMsg(tls, pCheck, ts+27201, libc.VaList(bp+16, iDepth))
 124192 					Xsqlite3_free(tls, aNode)
 124193 					return
 124194 				}
 124195 			}
 124196 			nCell = readInt16(tls, aNode+2)
 124197 			if 4+nCell*(8+(*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim*2*4) > *(*int32)(unsafe.Pointer(bp + 48)) {
 124198 				rtreeCheckAppendMsg(tls, pCheck,
 124199 					ts+27231,
 124200 					libc.VaList(bp+24, iNode, nCell, *(*int32)(unsafe.Pointer(bp + 48))))
 124201 			} else {
 124202 				for i = 0; i < nCell; i++ {
 124203 					var pCell uintptr = aNode + uintptr(4+i*(8+(*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim*2*4))
 124204 					var iVal I64 = readInt64(tls, pCell)
 124205 					rtreeCheckCellCoord(tls, pCheck, iNode, i, pCell+8, aParent)
 124206 
 124207 					if iDepth > 0 {
 124208 						rtreeCheckMapping(tls, pCheck, 0, iVal, iNode)
 124209 						rtreeCheckNode(tls, pCheck, iDepth-1, pCell+8, iVal)
 124210 						(*RtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf++
 124211 					} else {
 124212 						rtreeCheckMapping(tls, pCheck, 1, iVal, iNode)
 124213 						(*RtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf++
 124214 					}
 124215 				}
 124216 			}
 124217 		}
 124218 		Xsqlite3_free(tls, aNode)
 124219 	}
 124220 }
 124221 
 124222 func rtreeCheckCount(tls *libc.TLS, pCheck uintptr, zTbl uintptr, nExpect I64) {
 124223 	bp := tls.Alloc(48)
 124224 	defer tls.Free(48)
 124225 
 124226 	if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
 124227 		var pCount uintptr
 124228 		pCount = rtreeCheckPrepare(tls, pCheck, ts+27286,
 124229 			libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab, zTbl))
 124230 		if pCount != 0 {
 124231 			if Xsqlite3_step(tls, pCount) == SQLITE_ROW {
 124232 				var nActual I64 = Xsqlite3_column_int64(tls, pCount, 0)
 124233 				if nActual != nExpect {
 124234 					rtreeCheckAppendMsg(tls, pCheck,
 124235 						ts+27317, libc.VaList(bp+24, zTbl, nExpect, nActual))
 124236 				}
 124237 			}
 124238 			(*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_finalize(tls, pCount)
 124239 		}
 124240 	}
 124241 }
 124242 
 124243 func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzReport uintptr) int32 {
 124244 	bp := tls.Alloc(84)
 124245 	defer tls.Free(84)
 124246 
 124247 	var pStmt uintptr = uintptr(0)
 124248 	var bEnd int32 = 0
 124249 	var nAux int32 = 0
 124250 
 124251 	libc.Xmemset(tls, bp+32, 0, uint32(unsafe.Sizeof(RtreeCheck{})))
 124252 	(*RtreeCheck)(unsafe.Pointer(bp + 32)).Fdb = db
 124253 	(*RtreeCheck)(unsafe.Pointer(bp + 32)).FzDb = zDb
 124254 	(*RtreeCheck)(unsafe.Pointer(bp + 32)).FzTab = zTab
 124255 
 124256 	if Xsqlite3_get_autocommit(tls, db) != 0 {
 124257 		(*RtreeCheck)(unsafe.Pointer(bp + 32)).Frc = Xsqlite3_exec(tls, db, ts+14503, uintptr(0), uintptr(0), uintptr(0))
 124258 		bEnd = 1
 124259 	}
 124260 
 124261 	if (*RtreeCheck)(unsafe.Pointer(bp+32)).Frc == SQLITE_OK {
 124262 		pStmt = rtreeCheckPrepare(tls, bp+32, ts+27384, libc.VaList(bp, zDb, zTab))
 124263 		if pStmt != 0 {
 124264 			nAux = Xsqlite3_column_count(tls, pStmt) - 2
 124265 			Xsqlite3_finalize(tls, pStmt)
 124266 		} else if (*RtreeCheck)(unsafe.Pointer(bp+32)).Frc != SQLITE_NOMEM {
 124267 			(*RtreeCheck)(unsafe.Pointer(bp + 32)).Frc = SQLITE_OK
 124268 		}
 124269 	}
 124270 
 124271 	pStmt = rtreeCheckPrepare(tls, bp+32, ts+25204, libc.VaList(bp+16, zDb, zTab))
 124272 	if pStmt != 0 {
 124273 		var rc int32
 124274 		(*RtreeCheck)(unsafe.Pointer(bp + 32)).FnDim = (Xsqlite3_column_count(tls, pStmt) - 1 - nAux) / 2
 124275 		if (*RtreeCheck)(unsafe.Pointer(bp+32)).FnDim < 1 {
 124276 			rtreeCheckAppendMsg(tls, bp+32, ts+27412, 0)
 124277 		} else if SQLITE_ROW == Xsqlite3_step(tls, pStmt) {
 124278 			(*RtreeCheck)(unsafe.Pointer(bp + 32)).FbInt = libc.Bool32(Xsqlite3_column_type(tls, pStmt, 1) == SQLITE_INTEGER)
 124279 		}
 124280 		rc = Xsqlite3_finalize(tls, pStmt)
 124281 		if rc != SQLITE_CORRUPT {
 124282 			(*RtreeCheck)(unsafe.Pointer(bp + 32)).Frc = rc
 124283 		}
 124284 	}
 124285 
 124286 	if (*RtreeCheck)(unsafe.Pointer(bp+32)).FnDim >= 1 {
 124287 		if (*RtreeCheck)(unsafe.Pointer(bp+32)).Frc == SQLITE_OK {
 124288 			rtreeCheckNode(tls, bp+32, 0, uintptr(0), int64(1))
 124289 		}
 124290 		rtreeCheckCount(tls, bp+32, ts+27443, int64((*RtreeCheck)(unsafe.Pointer(bp+32)).FnLeaf))
 124291 		rtreeCheckCount(tls, bp+32, ts+27450, int64((*RtreeCheck)(unsafe.Pointer(bp+32)).FnNonLeaf))
 124292 	}
 124293 
 124294 	Xsqlite3_finalize(tls, (*RtreeCheck)(unsafe.Pointer(bp+32)).FpGetNode)
 124295 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 24)))
 124296 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 24 + 1*4)))
 124297 
 124298 	if bEnd != 0 {
 124299 		var rc int32 = Xsqlite3_exec(tls, db, ts+27458, uintptr(0), uintptr(0), uintptr(0))
 124300 		if (*RtreeCheck)(unsafe.Pointer(bp+32)).Frc == SQLITE_OK {
 124301 			(*RtreeCheck)(unsafe.Pointer(bp + 32)).Frc = rc
 124302 		}
 124303 	}
 124304 	*(*uintptr)(unsafe.Pointer(pzReport)) = (*RtreeCheck)(unsafe.Pointer(bp + 32)).FzReport
 124305 	return (*RtreeCheck)(unsafe.Pointer(bp + 32)).Frc
 124306 }
 124307 
 124308 func rtreecheck(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) {
 124309 	bp := tls.Alloc(4)
 124310 	defer tls.Free(4)
 124311 
 124312 	if nArg != 1 && nArg != 2 {
 124313 		Xsqlite3_result_error(tls, ctx,
 124314 			ts+27462, -1)
 124315 	} else {
 124316 		var rc int32
 124317 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 124318 		var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg)))
 124319 		var zTab uintptr
 124320 		if nArg == 1 {
 124321 			zTab = zDb
 124322 			zDb = ts + 6441
 124323 		} else {
 124324 			zTab = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*4)))
 124325 		}
 124326 		rc = rtreeCheckTable(tls, Xsqlite3_context_db_handle(tls, ctx), zDb, zTab, bp)
 124327 		if rc == SQLITE_OK {
 124328 			Xsqlite3_result_text(tls, ctx, func() uintptr {
 124329 				if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 124330 					return *(*uintptr)(unsafe.Pointer(bp))
 124331 				}
 124332 				return ts + 18059
 124333 			}(), -1, libc.UintptrFromInt32(-1))
 124334 		} else {
 124335 			Xsqlite3_result_error_code(tls, ctx, rc)
 124336 		}
 124337 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp)))
 124338 	}
 124339 }
 124340 
 124341 // Datatype for coordinates
 124342 type GeoCoord = float32
 124343 
 124344 // Internal representation of a polygon.
 124345 //
 124346 // The polygon consists of a sequence of vertexes.  There is a line
 124347 // segment between each pair of vertexes, and one final segment from
 124348 // the last vertex back to the first.  (This differs from the GeoJSON
 124349 // standard in which the final vertex is a repeat of the first.)
 124350 //
 124351 // The polygon follows the right-hand rule.  The area to the right of
 124352 // each segment is "outside" and the area to the left is "inside".
 124353 //
 124354 // The on-disk representation consists of a 4-byte header followed by
 124355 // the values.  The 4-byte header is:
 124356 //
 124357 //	encoding    (1 byte)   0=big-endian, 1=little-endian
 124358 //	nvertex     (3 bytes)  Number of vertexes as a big-endian integer
 124359 //
 124360 // Enough space is allocated for 4 coordinates, to work around over-zealous
 124361 // warnings coming from some compiler (notably, clang). In reality, the size
 124362 // of each GeoPoly memory allocate is adjusted as necessary so that the
 124363 // GeoPoly.a[] array at the end is the appropriate size.
 124364 type GeoPoly1 = struct {
 124365 	FnVertex int32
 124366 	Fhdr     [4]uint8
 124367 	Fa       [8]GeoCoord
 124368 }
 124369 
 124370 // Internal representation of a polygon.
 124371 //
 124372 // The polygon consists of a sequence of vertexes.  There is a line
 124373 // segment between each pair of vertexes, and one final segment from
 124374 // the last vertex back to the first.  (This differs from the GeoJSON
 124375 // standard in which the final vertex is a repeat of the first.)
 124376 //
 124377 // The polygon follows the right-hand rule.  The area to the right of
 124378 // each segment is "outside" and the area to the left is "inside".
 124379 //
 124380 // The on-disk representation consists of a 4-byte header followed by
 124381 // the values.  The 4-byte header is:
 124382 //
 124383 //	encoding    (1 byte)   0=big-endian, 1=little-endian
 124384 //	nvertex     (3 bytes)  Number of vertexes as a big-endian integer
 124385 //
 124386 // Enough space is allocated for 4 coordinates, to work around over-zealous
 124387 // warnings coming from some compiler (notably, clang). In reality, the size
 124388 // of each GeoPoly memory allocate is adjusted as necessary so that the
 124389 // GeoPoly.a[] array at the end is the appropriate size.
 124390 type GeoPoly = GeoPoly1
 124391 
 124392 // State of a parse of a GeoJSON input.
 124393 type GeoParse1 = struct {
 124394 	Fz       uintptr
 124395 	FnVertex int32
 124396 	FnAlloc  int32
 124397 	FnErr    int32
 124398 	Fa       uintptr
 124399 }
 124400 
 124401 // State of a parse of a GeoJSON input.
 124402 type GeoParse = GeoParse1
 124403 
 124404 func geopolySwab32(tls *libc.TLS, a uintptr) {
 124405 	var t uint8 = *(*uint8)(unsafe.Pointer(a))
 124406 	*(*uint8)(unsafe.Pointer(a)) = *(*uint8)(unsafe.Pointer(a + 3))
 124407 	*(*uint8)(unsafe.Pointer(a + 3)) = t
 124408 	t = *(*uint8)(unsafe.Pointer(a + 1))
 124409 	*(*uint8)(unsafe.Pointer(a + 1)) = *(*uint8)(unsafe.Pointer(a + 2))
 124410 	*(*uint8)(unsafe.Pointer(a + 2)) = t
 124411 }
 124412 
 124413 func geopolySkipSpace(tls *libc.TLS, p uintptr) uint8 {
 124414 	for jsonIsSpace[*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz))] != 0 {
 124415 		(*GeoParse)(unsafe.Pointer(p)).Fz++
 124416 	}
 124417 	return *(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz))
 124418 }
 124419 
 124420 func geopolyParseNumber(tls *libc.TLS, p uintptr, pVal uintptr) int32 {
 124421 	bp := tls.Alloc(8)
 124422 	defer tls.Free(8)
 124423 
 124424 	var c uint8 = geopolySkipSpace(tls, p)
 124425 	var z uintptr = (*GeoParse)(unsafe.Pointer(p)).Fz
 124426 	var j int32 = 0
 124427 	var seenDP int32 = 0
 124428 	var seenE int32 = 0
 124429 	if int32(c) == '-' {
 124430 		j = 1
 124431 		c = *(*uint8)(unsafe.Pointer(z + uintptr(j)))
 124432 	}
 124433 	if int32(c) == '0' && int32(*(*uint8)(unsafe.Pointer(z + uintptr(j+1)))) >= '0' && int32(*(*uint8)(unsafe.Pointer(z + uintptr(j+1)))) <= '9' {
 124434 		return 0
 124435 	}
 124436 	for ; ; j++ {
 124437 		c = *(*uint8)(unsafe.Pointer(z + uintptr(j)))
 124438 		if int32(Xsqlite3CtypeMap[c])&0x04 != 0 {
 124439 			continue
 124440 		}
 124441 		if int32(c) == '.' {
 124442 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j-1)))) == '-' {
 124443 				return 0
 124444 			}
 124445 			if seenDP != 0 {
 124446 				return 0
 124447 			}
 124448 			seenDP = 1
 124449 			continue
 124450 		}
 124451 		if int32(c) == 'e' || int32(c) == 'E' {
 124452 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j-1)))) < '0' {
 124453 				return 0
 124454 			}
 124455 			if seenE != 0 {
 124456 				return -1
 124457 			}
 124458 			seenDP = libc.AssignInt32(&seenE, 1)
 124459 			c = *(*uint8)(unsafe.Pointer(z + uintptr(j+1)))
 124460 			if int32(c) == '+' || int32(c) == '-' {
 124461 				j++
 124462 				c = *(*uint8)(unsafe.Pointer(z + uintptr(j+1)))
 124463 			}
 124464 			if int32(c) < '0' || int32(c) > '9' {
 124465 				return 0
 124466 			}
 124467 			continue
 124468 		}
 124469 		break
 124470 	}
 124471 	if int32(*(*uint8)(unsafe.Pointer(z + uintptr(j-1)))) < '0' {
 124472 		return 0
 124473 	}
 124474 	if pVal != 0 {
 124475 		Xsqlite3AtoF(tls, (*GeoParse)(unsafe.Pointer(p)).Fz, bp, j, uint8(SQLITE_UTF8))
 124476 		*(*GeoCoord)(unsafe.Pointer(pVal)) = GeoCoord(*(*float64)(unsafe.Pointer(bp)))
 124477 	}
 124478 	*(*uintptr)(unsafe.Pointer(p)) += uintptr(j)
 124479 	return 1
 124480 }
 124481 
 124482 func geopolyParseJson(tls *libc.TLS, z uintptr, pRc uintptr) uintptr {
 124483 	bp := tls.Alloc(24)
 124484 	defer tls.Free(24)
 124485 
 124486 	var rc int32
 124487 	var aNew uintptr
 124488 	var ii int32
 124489 	var c uint8
 124490 	var pOut uintptr
 124491 
 124492 	rc = SQLITE_OK
 124493 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(GeoParse{})))
 124494 	(*GeoParse)(unsafe.Pointer(bp)).Fz = z
 124495 	if !(int32(geopolySkipSpace(tls, bp)) == '[') {
 124496 		goto __1
 124497 	}
 124498 	(*GeoParse)(unsafe.Pointer(bp)).Fz++
 124499 __2:
 124500 	if !(int32(geopolySkipSpace(tls, bp)) == '[') {
 124501 		goto __3
 124502 	}
 124503 	ii = 0
 124504 	(*GeoParse)(unsafe.Pointer(bp)).Fz++
 124505 	if !((*GeoParse)(unsafe.Pointer(bp)).FnVertex >= (*GeoParse)(unsafe.Pointer(bp)).FnAlloc) {
 124506 		goto __4
 124507 	}
 124508 	(*GeoParse)(unsafe.Pointer(bp)).FnAlloc = (*GeoParse)(unsafe.Pointer(bp)).FnAlloc*2 + 16
 124509 	aNew = Xsqlite3_realloc64(tls, (*GeoParse)(unsafe.Pointer(bp)).Fa, uint64(uint32((*GeoParse)(unsafe.Pointer(bp)).FnAlloc)*uint32(unsafe.Sizeof(GeoCoord(0)))*uint32(2)))
 124510 	if !(aNew == uintptr(0)) {
 124511 		goto __5
 124512 	}
 124513 	rc = SQLITE_NOMEM
 124514 	(*GeoParse)(unsafe.Pointer(bp)).FnErr++
 124515 	goto __3
 124516 __5:
 124517 	;
 124518 	(*GeoParse)(unsafe.Pointer(bp)).Fa = aNew
 124519 __4:
 124520 	;
 124521 __6:
 124522 	if !(geopolyParseNumber(tls, bp, func() uintptr {
 124523 		if ii <= 1 {
 124524 			return (*GeoParse)(unsafe.Pointer(bp)).Fa + uintptr((*GeoParse)(unsafe.Pointer(bp)).FnVertex*2+ii)*4
 124525 		}
 124526 		return uintptr(0)
 124527 	}()) != 0) {
 124528 		goto __7
 124529 	}
 124530 	ii++
 124531 	if !(ii == 2) {
 124532 		goto __8
 124533 	}
 124534 	(*GeoParse)(unsafe.Pointer(bp)).FnVertex++
 124535 __8:
 124536 	;
 124537 	c = geopolySkipSpace(tls, bp)
 124538 	(*GeoParse)(unsafe.Pointer(bp)).Fz++
 124539 	if !(int32(c) == ',') {
 124540 		goto __9
 124541 	}
 124542 	goto __6
 124543 __9:
 124544 	;
 124545 	if !(int32(c) == ']' && ii >= 2) {
 124546 		goto __10
 124547 	}
 124548 	goto __7
 124549 __10:
 124550 	;
 124551 	(*GeoParse)(unsafe.Pointer(bp)).FnErr++
 124552 	rc = SQLITE_ERROR
 124553 	goto parse_json_err
 124554 	goto __6
 124555 __7:
 124556 	;
 124557 	if !(int32(geopolySkipSpace(tls, bp)) == ',') {
 124558 		goto __11
 124559 	}
 124560 	(*GeoParse)(unsafe.Pointer(bp)).Fz++
 124561 	goto __2
 124562 __11:
 124563 	;
 124564 	goto __3
 124565 	goto __2
 124566 __3:
 124567 	;
 124568 	if !(int32(geopolySkipSpace(tls, bp)) == ']' &&
 124569 		(*GeoParse)(unsafe.Pointer(bp)).FnVertex >= 4 &&
 124570 		*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp)).Fa)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp)).Fa + uintptr((*GeoParse)(unsafe.Pointer(bp)).FnVertex*2-2)*4)) &&
 124571 		*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp)).Fa + 1*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp)).Fa + uintptr((*GeoParse)(unsafe.Pointer(bp)).FnVertex*2-1)*4)) &&
 124572 		func() bool { (*GeoParse)(unsafe.Pointer(bp)).Fz++; return int32(geopolySkipSpace(tls, bp)) == 0 }()) {
 124573 		goto __12
 124574 	}
 124575 	*(*int32)(unsafe.Pointer(bp + 20)) = 1
 124576 	(*GeoParse)(unsafe.Pointer(bp)).FnVertex--
 124577 	pOut = Xsqlite3_malloc64(tls, uint64(Sqlite3_int64(unsafe.Sizeof(GeoPoly{}))+int64(uint32(unsafe.Sizeof(GeoCoord(0)))*uint32(2))*(Sqlite3_int64((*GeoParse)(unsafe.Pointer(bp)).FnVertex)-int64(4))))
 124578 	*(*int32)(unsafe.Pointer(bp + 20)) = 1
 124579 	if !(pOut == uintptr(0)) {
 124580 		goto __14
 124581 	}
 124582 	goto parse_json_err
 124583 __14:
 124584 	;
 124585 	(*GeoPoly)(unsafe.Pointer(pOut)).FnVertex = (*GeoParse)(unsafe.Pointer(bp)).FnVertex
 124586 	libc.Xmemcpy(tls, pOut+8, (*GeoParse)(unsafe.Pointer(bp)).Fa, uint32((*GeoParse)(unsafe.Pointer(bp)).FnVertex*2)*uint32(unsafe.Sizeof(GeoCoord(0))))
 124587 	*(*uint8)(unsafe.Pointer(pOut + 4)) = *(*uint8)(unsafe.Pointer(bp + 20))
 124588 	*(*uint8)(unsafe.Pointer(pOut + 4 + 1)) = uint8((*GeoParse)(unsafe.Pointer(bp)).FnVertex >> 16 & 0xff)
 124589 	*(*uint8)(unsafe.Pointer(pOut + 4 + 2)) = uint8((*GeoParse)(unsafe.Pointer(bp)).FnVertex >> 8 & 0xff)
 124590 	*(*uint8)(unsafe.Pointer(pOut + 4 + 3)) = uint8((*GeoParse)(unsafe.Pointer(bp)).FnVertex & 0xff)
 124591 	Xsqlite3_free(tls, (*GeoParse)(unsafe.Pointer(bp)).Fa)
 124592 	if !(pRc != 0) {
 124593 		goto __15
 124594 	}
 124595 	*(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK
 124596 __15:
 124597 	;
 124598 	return pOut
 124599 	goto __13
 124600 __12:
 124601 	(*GeoParse)(unsafe.Pointer(bp)).FnErr++
 124602 	rc = SQLITE_ERROR
 124603 __13:
 124604 	;
 124605 __1:
 124606 	;
 124607 parse_json_err:
 124608 	if !(pRc != 0) {
 124609 		goto __16
 124610 	}
 124611 	*(*int32)(unsafe.Pointer(pRc)) = rc
 124612 __16:
 124613 	;
 124614 	Xsqlite3_free(tls, (*GeoParse)(unsafe.Pointer(bp)).Fa)
 124615 	return uintptr(0)
 124616 }
 124617 
 124618 func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) uintptr {
 124619 	bp := tls.Alloc(4)
 124620 	defer tls.Free(4)
 124621 
 124622 	var p uintptr = uintptr(0)
 124623 	var nByte int32
 124624 
 124625 	if Xsqlite3_value_type(tls, pVal) == SQLITE_BLOB &&
 124626 		libc.AssignInt32(&nByte, Xsqlite3_value_bytes(tls, pVal)) >= int32(uint32(4)+uint32(6)*uint32(unsafe.Sizeof(GeoCoord(0)))) {
 124627 		var a uintptr = Xsqlite3_value_blob(tls, pVal)
 124628 		var nVertex int32
 124629 		if a == uintptr(0) {
 124630 			if pCtx != 0 {
 124631 				Xsqlite3_result_error_nomem(tls, pCtx)
 124632 			}
 124633 			return uintptr(0)
 124634 		}
 124635 		nVertex = int32(*(*uint8)(unsafe.Pointer(a + 1)))<<16 + int32(*(*uint8)(unsafe.Pointer(a + 2)))<<8 + int32(*(*uint8)(unsafe.Pointer(a + 3)))
 124636 		if (int32(*(*uint8)(unsafe.Pointer(a))) == 0 || int32(*(*uint8)(unsafe.Pointer(a))) == 1) &&
 124637 			uint32(nVertex*2)*uint32(unsafe.Sizeof(GeoCoord(0)))+uint32(4) == uint32(nByte) {
 124638 			p = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(GeoPoly{}))+uint32((nVertex-1)*2)*uint32(unsafe.Sizeof(GeoCoord(0)))))
 124639 			if p == uintptr(0) {
 124640 				if pRc != 0 {
 124641 					*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 124642 				}
 124643 				if pCtx != 0 {
 124644 					Xsqlite3_result_error_nomem(tls, pCtx)
 124645 				}
 124646 			} else {
 124647 				*(*int32)(unsafe.Pointer(bp)) = 1
 124648 				(*GeoPoly)(unsafe.Pointer(p)).FnVertex = nVertex
 124649 				libc.Xmemcpy(tls, p+4, a, uint32(nByte))
 124650 				if int32(*(*uint8)(unsafe.Pointer(a))) != int32(*(*uint8)(unsafe.Pointer(bp))) {
 124651 					var ii int32
 124652 					for ii = 0; ii < nVertex; ii++ {
 124653 						geopolySwab32(tls, p+8+uintptr(ii*2)*4)
 124654 						geopolySwab32(tls, p+8+uintptr(ii*2+1)*4)
 124655 					}
 124656 					*(*uint8)(unsafe.Pointer(p + 4)) ^= uint8(1)
 124657 				}
 124658 			}
 124659 		}
 124660 		if pRc != 0 {
 124661 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK
 124662 		}
 124663 		return p
 124664 	} else if Xsqlite3_value_type(tls, pVal) == SQLITE_TEXT {
 124665 		var zJson uintptr = Xsqlite3_value_text(tls, pVal)
 124666 		if zJson == uintptr(0) {
 124667 			if pRc != 0 {
 124668 				*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 124669 			}
 124670 			return uintptr(0)
 124671 		}
 124672 		return geopolyParseJson(tls, zJson, pRc)
 124673 	} else {
 124674 		if pRc != 0 {
 124675 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_ERROR
 124676 		}
 124677 		return uintptr(0)
 124678 	}
 124679 	return uintptr(0)
 124680 }
 124681 
 124682 func geopolyBlobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124683 	var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 124684 	_ = argc
 124685 	if p != 0 {
 124686 		Xsqlite3_result_blob(tls, context, p+4,
 124687 			4+8*(*GeoPoly)(unsafe.Pointer(p)).FnVertex, libc.UintptrFromInt32(-1))
 124688 		Xsqlite3_free(tls, p)
 124689 	}
 124690 }
 124691 
 124692 func geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124693 	bp := tls.Alloc(32)
 124694 	defer tls.Free(32)
 124695 
 124696 	var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 124697 	_ = argc
 124698 	if p != 0 {
 124699 		var db uintptr = Xsqlite3_context_db_handle(tls, context)
 124700 		var x uintptr = Xsqlite3_str_new(tls, db)
 124701 		var i int32
 124702 		Xsqlite3_str_append(tls, x, ts+27513, 1)
 124703 		for i = 0; i < (*GeoPoly)(unsafe.Pointer(p)).FnVertex; i++ {
 124704 			Xsqlite3_str_appendf(tls, x, ts+27515, libc.VaList(bp, float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(i*2)*4))), float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(i*2+1)*4)))))
 124705 		}
 124706 		Xsqlite3_str_appendf(tls, x, ts+27526, libc.VaList(bp+16, float64(*(*GeoCoord)(unsafe.Pointer(p + 8))), float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + 1*4)))))
 124707 		Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 124708 		Xsqlite3_free(tls, p)
 124709 	}
 124710 }
 124711 
 124712 func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124713 	bp := tls.Alloc(48)
 124714 	defer tls.Free(48)
 124715 
 124716 	var p uintptr
 124717 	if argc < 1 {
 124718 		return
 124719 	}
 124720 	p = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 124721 	if p != 0 {
 124722 		var db uintptr = Xsqlite3_context_db_handle(tls, context)
 124723 		var x uintptr = Xsqlite3_str_new(tls, db)
 124724 		var i int32
 124725 		var cSep uint8 = uint8('\'')
 124726 		Xsqlite3_str_appendf(tls, x, ts+27537, 0)
 124727 		for i = 0; i < (*GeoPoly)(unsafe.Pointer(p)).FnVertex; i++ {
 124728 			Xsqlite3_str_appendf(tls, x, ts+27555, libc.VaList(bp, int32(cSep), float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(i*2)*4))), float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(i*2+1)*4)))))
 124729 			cSep = uint8(' ')
 124730 		}
 124731 		Xsqlite3_str_appendf(tls, x, ts+27563, libc.VaList(bp+24, float64(*(*GeoCoord)(unsafe.Pointer(p + 8))), float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + 1*4)))))
 124732 		for i = 1; i < argc; i++ {
 124733 			var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*4)))
 124734 			if z != 0 && *(*uint8)(unsafe.Pointer(z)) != 0 {
 124735 				Xsqlite3_str_appendf(tls, x, ts+27571, libc.VaList(bp+40, z))
 124736 			}
 124737 		}
 124738 		Xsqlite3_str_appendf(tls, x, ts+27575, 0)
 124739 		Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 124740 		Xsqlite3_free(tls, p)
 124741 	}
 124742 }
 124743 
 124744 func geopolyXformFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124745 	var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 124746 	var A float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 124747 	var B float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
 124748 	var C float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4)))
 124749 	var D float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 4*4)))
 124750 	var E float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 5*4)))
 124751 	var F float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 6*4)))
 124752 	var x1 GeoCoord
 124753 	var y1 GeoCoord
 124754 	var x0 GeoCoord
 124755 	var y0 GeoCoord
 124756 	var ii int32
 124757 	_ = argc
 124758 	if p != 0 {
 124759 		for ii = 0; ii < (*GeoPoly)(unsafe.Pointer(p)).FnVertex; ii++ {
 124760 			x0 = *(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2)*4))
 124761 			y0 = *(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2+1)*4))
 124762 			x1 = GeoCoord(A*float64(x0) + B*float64(y0) + E)
 124763 			y1 = GeoCoord(C*float64(x0) + D*float64(y0) + F)
 124764 			*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2)*4)) = x1
 124765 			*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2+1)*4)) = y1
 124766 		}
 124767 		Xsqlite3_result_blob(tls, context, p+4,
 124768 			4+8*(*GeoPoly)(unsafe.Pointer(p)).FnVertex, libc.UintptrFromInt32(-1))
 124769 		Xsqlite3_free(tls, p)
 124770 	}
 124771 }
 124772 
 124773 func geopolyArea(tls *libc.TLS, p uintptr) float64 {
 124774 	var rArea float64 = 0.0
 124775 	var ii int32
 124776 	for ii = 0; ii < (*GeoPoly)(unsafe.Pointer(p)).FnVertex-1; ii++ {
 124777 		rArea = rArea + float64((*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2)*4))-*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr((ii+1)*2)*4)))*
 124778 			(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2+1)*4))+*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr((ii+1)*2+1)*4))))*
 124779 			0.5
 124780 	}
 124781 	rArea = rArea + float64((*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2)*4))-*(*GeoCoord)(unsafe.Pointer(p + 8)))*
 124782 		(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2+1)*4))+*(*GeoCoord)(unsafe.Pointer(p + 8 + 1*4))))*
 124783 		0.5
 124784 	return rArea
 124785 }
 124786 
 124787 func geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124788 	var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 124789 	_ = argc
 124790 	if p != 0 {
 124791 		Xsqlite3_result_double(tls, context, geopolyArea(tls, p))
 124792 		Xsqlite3_free(tls, p)
 124793 	}
 124794 }
 124795 
 124796 func geopolyCcwFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124797 	var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 124798 	_ = argc
 124799 	if p != 0 {
 124800 		if geopolyArea(tls, p) < 0.0 {
 124801 			var ii int32
 124802 			var jj int32
 124803 			ii = 1
 124804 			jj = (*GeoPoly)(unsafe.Pointer(p)).FnVertex - 1
 124805 		__1:
 124806 			if !(ii < jj) {
 124807 				goto __3
 124808 			}
 124809 			{
 124810 				var t GeoCoord = *(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2)*4))
 124811 				*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2)*4)) = *(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(jj*2)*4))
 124812 				*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(jj*2)*4)) = t
 124813 				t = *(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2+1)*4))
 124814 				*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(ii*2+1)*4)) = *(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(jj*2+1)*4))
 124815 				*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(jj*2+1)*4)) = t
 124816 
 124817 			}
 124818 			goto __2
 124819 		__2:
 124820 			ii++
 124821 			jj--
 124822 			goto __1
 124823 			goto __3
 124824 		__3:
 124825 		}
 124826 		Xsqlite3_result_blob(tls, context, p+4,
 124827 			4+8*(*GeoPoly)(unsafe.Pointer(p)).FnVertex, libc.UintptrFromInt32(-1))
 124828 		Xsqlite3_free(tls, p)
 124829 	}
 124830 }
 124831 
 124832 func geopolySine(tls *libc.TLS, r float64) float64 {
 124833 	if r >= float64(1.5)*3.1415926535897932385 {
 124834 		r = r - float64(2.0)*3.1415926535897932385
 124835 	}
 124836 	if r >= float64(0.5)*3.1415926535897932385 {
 124837 		return -geopolySine(tls, r-3.1415926535897932385)
 124838 	} else {
 124839 		var r2 float64 = r * r
 124840 		var r3 float64 = r2 * r
 124841 		var r5 float64 = r3 * r2
 124842 		return 0.9996949*r - 0.1656700*r3 + 0.0075134*r5
 124843 	}
 124844 	return float64(0)
 124845 }
 124846 
 124847 func geopolyRegularFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 124848 	bp := tls.Alloc(4)
 124849 	defer tls.Free(4)
 124850 
 124851 	var x float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))
 124852 	var y float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 124853 	var r float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
 124854 	var n int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 3*4)))
 124855 
 124856 	var p uintptr
 124857 	_ = argc
 124858 
 124859 	if n < 3 || r <= 0.0 {
 124860 		return
 124861 	}
 124862 	if n > 1000 {
 124863 		n = 1000
 124864 	}
 124865 	p = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(GeoPoly{}))+uint32((n-1)*2)*uint32(unsafe.Sizeof(GeoCoord(0)))))
 124866 	if p == uintptr(0) {
 124867 		Xsqlite3_result_error_nomem(tls, context)
 124868 		return
 124869 	}
 124870 	*(*int32)(unsafe.Pointer(bp)) = 1
 124871 	*(*uint8)(unsafe.Pointer(p + 4)) = *(*uint8)(unsafe.Pointer(bp))
 124872 	*(*uint8)(unsafe.Pointer(p + 4 + 1)) = uint8(0)
 124873 	*(*uint8)(unsafe.Pointer(p + 4 + 2)) = uint8(n >> 8 & 0xff)
 124874 	*(*uint8)(unsafe.Pointer(p + 4 + 3)) = uint8(n & 0xff)
 124875 	for *(*int32)(unsafe.Pointer(bp)) = 0; *(*int32)(unsafe.Pointer(bp)) < n; *(*int32)(unsafe.Pointer(bp))++ {
 124876 		var rAngle float64 = float64(2.0) * 3.1415926535897932385 * float64(*(*int32)(unsafe.Pointer(bp))) / float64(n)
 124877 		*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(*(*int32)(unsafe.Pointer(bp))*2)*4)) = GeoCoord(x - r*geopolySine(tls, rAngle-float64(0.5)*3.1415926535897932385))
 124878 		*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(*(*int32)(unsafe.Pointer(bp))*2+1)*4)) = GeoCoord(y + r*geopolySine(tls, rAngle))
 124879 	}
 124880 	Xsqlite3_result_blob(tls, context, p+4, 4+8*n, libc.UintptrFromInt32(-1))
 124881 	Xsqlite3_free(tls, p)
 124882 }
 124883 
 124884 func geopolyBBox(tls *libc.TLS, context uintptr, pPoly uintptr, aCoord uintptr, pRc uintptr) uintptr {
 124885 	bp := tls.Alloc(4)
 124886 	defer tls.Free(4)
 124887 
 124888 	var pOut uintptr
 124889 	var p uintptr
 124890 	var mnX float32
 124891 	var mxX float32
 124892 	var mnY float32
 124893 	var mxY float32
 124894 	var r float64
 124895 
 124896 	pOut = uintptr(0)
 124897 	if !(pPoly == uintptr(0) && aCoord != uintptr(0)) {
 124898 		goto __1
 124899 	}
 124900 	p = uintptr(0)
 124901 	mnX = *(*RtreeValue)(unsafe.Pointer(aCoord))
 124902 	mxX = *(*RtreeValue)(unsafe.Pointer(aCoord + 1*4))
 124903 	mnY = *(*RtreeValue)(unsafe.Pointer(aCoord + 2*4))
 124904 	mxY = *(*RtreeValue)(unsafe.Pointer(aCoord + 3*4))
 124905 	goto geopolyBboxFill
 124906 	goto __2
 124907 __1:
 124908 	p = geopolyFuncParam(tls, context, pPoly, pRc)
 124909 __2:
 124910 	;
 124911 	if !(p != 0) {
 124912 		goto __3
 124913 	}
 124914 	mnX = libc.AssignFloat32(&mxX, *(*GeoCoord)(unsafe.Pointer(p + 8)))
 124915 	mnY = libc.AssignFloat32(&mxY, *(*GeoCoord)(unsafe.Pointer(p + 8 + 1*4)))
 124916 	*(*int32)(unsafe.Pointer(bp)) = 1
 124917 __5:
 124918 	if !(*(*int32)(unsafe.Pointer(bp)) < (*GeoPoly)(unsafe.Pointer(p)).FnVertex) {
 124919 		goto __7
 124920 	}
 124921 	r = float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(*(*int32)(unsafe.Pointer(bp))*2)*4)))
 124922 	if !(r < float64(mnX)) {
 124923 		goto __8
 124924 	}
 124925 	mnX = float32(r)
 124926 	goto __9
 124927 __8:
 124928 	if !(r > float64(mxX)) {
 124929 		goto __10
 124930 	}
 124931 	mxX = float32(r)
 124932 __10:
 124933 	;
 124934 __9:
 124935 	;
 124936 	r = float64(*(*GeoCoord)(unsafe.Pointer(p + 8 + uintptr(*(*int32)(unsafe.Pointer(bp))*2+1)*4)))
 124937 	if !(r < float64(mnY)) {
 124938 		goto __11
 124939 	}
 124940 	mnY = float32(r)
 124941 	goto __12
 124942 __11:
 124943 	if !(r > float64(mxY)) {
 124944 		goto __13
 124945 	}
 124946 	mxY = float32(r)
 124947 __13:
 124948 	;
 124949 __12:
 124950 	;
 124951 	goto __6
 124952 __6:
 124953 	*(*int32)(unsafe.Pointer(bp))++
 124954 	goto __5
 124955 	goto __7
 124956 __7:
 124957 	;
 124958 	if !(pRc != 0) {
 124959 		goto __14
 124960 	}
 124961 	*(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK
 124962 __14:
 124963 	;
 124964 	if !(aCoord == uintptr(0)) {
 124965 		goto __15
 124966 	}
 124967 geopolyBboxFill:
 124968 	pOut = Xsqlite3_realloc64(tls, p, uint64(uint32(unsafe.Sizeof(GeoPoly{}))+uint32(unsafe.Sizeof(GeoCoord(0)))*uint32(2)*uint32(4-4)))
 124969 	if !(pOut == uintptr(0)) {
 124970 		goto __17
 124971 	}
 124972 	Xsqlite3_free(tls, p)
 124973 	if !(context != 0) {
 124974 		goto __18
 124975 	}
 124976 	Xsqlite3_result_error_nomem(tls, context)
 124977 __18:
 124978 	;
 124979 	if !(pRc != 0) {
 124980 		goto __19
 124981 	}
 124982 	*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 124983 __19:
 124984 	;
 124985 	return uintptr(0)
 124986 __17:
 124987 	;
 124988 	(*GeoPoly)(unsafe.Pointer(pOut)).FnVertex = 4
 124989 	*(*int32)(unsafe.Pointer(bp)) = 1
 124990 	*(*uint8)(unsafe.Pointer(pOut + 4)) = *(*uint8)(unsafe.Pointer(bp))
 124991 	*(*uint8)(unsafe.Pointer(pOut + 4 + 1)) = uint8(0)
 124992 	*(*uint8)(unsafe.Pointer(pOut + 4 + 2)) = uint8(0)
 124993 	*(*uint8)(unsafe.Pointer(pOut + 4 + 3)) = uint8(4)
 124994 	*(*GeoCoord)(unsafe.Pointer(pOut + 8)) = mnX
 124995 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 1*4)) = mnY
 124996 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 2*4)) = mxX
 124997 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 3*4)) = mnY
 124998 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 4*4)) = mxX
 124999 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 5*4)) = mxY
 125000 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 6*4)) = mnX
 125001 	*(*GeoCoord)(unsafe.Pointer(pOut + 8 + 7*4)) = mxY
 125002 	goto __16
 125003 __15:
 125004 	Xsqlite3_free(tls, p)
 125005 	*(*RtreeValue)(unsafe.Pointer(aCoord)) = mnX
 125006 	*(*RtreeValue)(unsafe.Pointer(aCoord + 1*4)) = mxX
 125007 	*(*RtreeValue)(unsafe.Pointer(aCoord + 2*4)) = mnY
 125008 	*(*RtreeValue)(unsafe.Pointer(aCoord + 3*4)) = mxY
 125009 __16:
 125010 	;
 125011 	goto __4
 125012 __3:
 125013 	if !(aCoord != 0) {
 125014 		goto __20
 125015 	}
 125016 	libc.Xmemset(tls, aCoord, 0, uint32(unsafe.Sizeof(RtreeCoord{}))*uint32(4))
 125017 __20:
 125018 	;
 125019 __4:
 125020 	;
 125021 	return pOut
 125022 }
 125023 
 125024 func geopolyBBoxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 125025 	var p uintptr = geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0), uintptr(0))
 125026 	_ = argc
 125027 	if p != 0 {
 125028 		Xsqlite3_result_blob(tls, context, p+4,
 125029 			4+8*(*GeoPoly)(unsafe.Pointer(p)).FnVertex, libc.UintptrFromInt32(-1))
 125030 		Xsqlite3_free(tls, p)
 125031 	}
 125032 }
 125033 
 125034 // State vector for the geopoly_group_bbox() aggregate function.
 125035 type GeoBBox1 = struct {
 125036 	FisInit int32
 125037 	Fa      [4]RtreeCoord
 125038 }
 125039 
 125040 // State vector for the geopoly_group_bbox() aggregate function.
 125041 type GeoBBox = GeoBBox1
 125042 
 125043 func geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 125044 	bp := tls.Alloc(20)
 125045 	defer tls.Free(20)
 125046 
 125047 	*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_OK
 125048 	_ = argc
 125049 	geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv)), bp, bp+16)
 125050 	if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 125051 		var pBBox uintptr
 125052 		pBBox = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(GeoBBox{})))
 125053 		if pBBox == uintptr(0) {
 125054 			return
 125055 		}
 125056 		if (*GeoBBox)(unsafe.Pointer(pBBox)).FisInit == 0 {
 125057 			(*GeoBBox)(unsafe.Pointer(pBBox)).FisInit = 1
 125058 			libc.Xmemcpy(tls, pBBox+4, bp, uint32(unsafe.Sizeof(RtreeCoord{}))*uint32(4))
 125059 		} else {
 125060 			if *(*RtreeValue)(unsafe.Pointer(bp)) < *(*RtreeValue)(unsafe.Pointer(pBBox + 4)) {
 125061 				*(*RtreeCoord)(unsafe.Pointer(pBBox + 4)) = *(*RtreeCoord)(unsafe.Pointer(bp))
 125062 			}
 125063 			if *(*RtreeValue)(unsafe.Pointer(bp + 1*4)) > *(*RtreeValue)(unsafe.Pointer(pBBox + 4 + 1*4)) {
 125064 				*(*RtreeCoord)(unsafe.Pointer(pBBox + 4 + 1*4)) = *(*RtreeCoord)(unsafe.Pointer(bp + 1*4))
 125065 			}
 125066 			if *(*RtreeValue)(unsafe.Pointer(bp + 2*4)) < *(*RtreeValue)(unsafe.Pointer(pBBox + 4 + 2*4)) {
 125067 				*(*RtreeCoord)(unsafe.Pointer(pBBox + 4 + 2*4)) = *(*RtreeCoord)(unsafe.Pointer(bp + 2*4))
 125068 			}
 125069 			if *(*RtreeValue)(unsafe.Pointer(bp + 3*4)) > *(*RtreeValue)(unsafe.Pointer(pBBox + 4 + 3*4)) {
 125070 				*(*RtreeCoord)(unsafe.Pointer(pBBox + 4 + 3*4)) = *(*RtreeCoord)(unsafe.Pointer(bp + 3*4))
 125071 			}
 125072 		}
 125073 	}
 125074 }
 125075 
 125076 func geopolyBBoxFinal(tls *libc.TLS, context uintptr) {
 125077 	var p uintptr
 125078 	var pBBox uintptr
 125079 	pBBox = Xsqlite3_aggregate_context(tls, context, 0)
 125080 	if pBBox == uintptr(0) {
 125081 		return
 125082 	}
 125083 	p = geopolyBBox(tls, context, uintptr(0), pBBox+4, uintptr(0))
 125084 	if p != 0 {
 125085 		Xsqlite3_result_blob(tls, context, p+4,
 125086 			4+8*(*GeoPoly)(unsafe.Pointer(p)).FnVertex, libc.UintptrFromInt32(-1))
 125087 		Xsqlite3_free(tls, p)
 125088 	}
 125089 }
 125090 
 125091 func pointBeneathLine(tls *libc.TLS, x0 float64, y0 float64, x1 float64, y1 float64, x2 float64, y2 float64) int32 {
 125092 	var y float64
 125093 	if x0 == x1 && y0 == y1 {
 125094 		return 2
 125095 	}
 125096 	if x1 < x2 {
 125097 		if x0 <= x1 || x0 > x2 {
 125098 			return 0
 125099 		}
 125100 	} else if x1 > x2 {
 125101 		if x0 <= x2 || x0 > x1 {
 125102 			return 0
 125103 		}
 125104 	} else {
 125105 		if x0 != x1 {
 125106 			return 0
 125107 		}
 125108 		if y0 < y1 && y0 < y2 {
 125109 			return 0
 125110 		}
 125111 		if y0 > y1 && y0 > y2 {
 125112 			return 0
 125113 		}
 125114 		return 2
 125115 	}
 125116 	y = y1 + (y2-y1)*(x0-x1)/(x2-x1)
 125117 	if y0 == y {
 125118 		return 2
 125119 	}
 125120 	if y0 < y {
 125121 		return 1
 125122 	}
 125123 	return 0
 125124 }
 125125 
 125126 func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 125127 	var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 125128 	var x0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 125129 	var y0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4)))
 125130 	var v int32 = 0
 125131 	var cnt int32 = 0
 125132 	var ii int32
 125133 	_ = argc
 125134 
 125135 	if p1 == uintptr(0) {
 125136 		return
 125137 	}
 125138 	for ii = 0; ii < (*GeoPoly)(unsafe.Pointer(p1)).FnVertex-1; ii++ {
 125139 		v = pointBeneathLine(tls, x0, y0, float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + uintptr(ii*2)*4))), float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + uintptr(ii*2+1)*4))),
 125140 			float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + uintptr((ii+1)*2)*4))), float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + uintptr((ii+1)*2+1)*4))))
 125141 		if v == 2 {
 125142 			break
 125143 		}
 125144 		cnt = cnt + v
 125145 	}
 125146 	if v != 2 {
 125147 		v = pointBeneathLine(tls, x0, y0, float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + uintptr(ii*2)*4))), float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + uintptr(ii*2+1)*4))),
 125148 			float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8))), float64(*(*GeoCoord)(unsafe.Pointer(p1 + 8 + 1*4))))
 125149 	}
 125150 	if v == 2 {
 125151 		Xsqlite3_result_int(tls, context, 1)
 125152 	} else if (v+cnt)&1 == 0 {
 125153 		Xsqlite3_result_int(tls, context, 0)
 125154 	} else {
 125155 		Xsqlite3_result_int(tls, context, 2)
 125156 	}
 125157 	Xsqlite3_free(tls, p1)
 125158 }
 125159 
 125160 func geopolyWithinFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 125161 	var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 125162 	var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*4)), uintptr(0))
 125163 	_ = argc
 125164 	if p1 != 0 && p2 != 0 {
 125165 		var x int32 = geopolyOverlap(tls, p1, p2)
 125166 		if x < 0 {
 125167 			Xsqlite3_result_error_nomem(tls, context)
 125168 		} else {
 125169 			Xsqlite3_result_int(tls, context, func() int32 {
 125170 				if x == 2 {
 125171 					return 1
 125172 				}
 125173 				return func() int32 {
 125174 					if x == 4 {
 125175 						return 2
 125176 					}
 125177 					return 0
 125178 				}()
 125179 			}())
 125180 		}
 125181 	}
 125182 	Xsqlite3_free(tls, p1)
 125183 	Xsqlite3_free(tls, p2)
 125184 }
 125185 
 125186 // Objects used by the overlap algorihm.
 125187 type GeoEvent1 = struct {
 125188 	Fx           float64
 125189 	FeType       int32
 125190 	FpSeg        uintptr
 125191 	FpNext       uintptr
 125192 	F__ccgo_pad1 [4]byte
 125193 }
 125194 
 125195 // Objects used by the overlap algorihm.
 125196 type GeoEvent = GeoEvent1
 125197 type GeoSegment1 = struct {
 125198 	FC           float64
 125199 	FB           float64
 125200 	Fy           float64
 125201 	Fy0          float32
 125202 	Fside        uint8
 125203 	F__ccgo_pad1 [3]byte
 125204 	Fidx         uint32
 125205 	FpNext       uintptr
 125206 }
 125207 
 125208 type GeoSegment = GeoSegment1
 125209 type GeoOverlap1 = struct {
 125210 	FaEvent   uintptr
 125211 	FaSegment uintptr
 125212 	FnEvent   int32
 125213 	FnSegment int32
 125214 }
 125215 
 125216 type GeoOverlap = GeoOverlap1
 125217 
 125218 func geopolyAddOneSegment(tls *libc.TLS, p uintptr, x0 GeoCoord, y0 GeoCoord, x1 GeoCoord, y1 GeoCoord, side uint8, idx uint32) {
 125219 	var pSeg uintptr
 125220 	var pEvent uintptr
 125221 	if x0 == x1 {
 125222 		return
 125223 	}
 125224 	if x0 > x1 {
 125225 		var t GeoCoord = x0
 125226 		x0 = x1
 125227 		x1 = t
 125228 		t = y0
 125229 		y0 = y1
 125230 		y1 = t
 125231 	}
 125232 	pSeg = (*GeoOverlap)(unsafe.Pointer(p)).FaSegment + uintptr((*GeoOverlap)(unsafe.Pointer(p)).FnSegment)*40
 125233 	(*GeoOverlap)(unsafe.Pointer(p)).FnSegment++
 125234 	(*GeoSegment)(unsafe.Pointer(pSeg)).FC = float64((y1 - y0) / (x1 - x0))
 125235 	(*GeoSegment)(unsafe.Pointer(pSeg)).FB = float64(y1) - float64(x1)*(*GeoSegment)(unsafe.Pointer(pSeg)).FC
 125236 	(*GeoSegment)(unsafe.Pointer(pSeg)).Fy0 = y0
 125237 	(*GeoSegment)(unsafe.Pointer(pSeg)).Fside = side
 125238 	(*GeoSegment)(unsafe.Pointer(pSeg)).Fidx = idx
 125239 	pEvent = (*GeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr((*GeoOverlap)(unsafe.Pointer(p)).FnEvent)*24
 125240 	(*GeoOverlap)(unsafe.Pointer(p)).FnEvent++
 125241 	(*GeoEvent)(unsafe.Pointer(pEvent)).Fx = float64(x0)
 125242 	(*GeoEvent)(unsafe.Pointer(pEvent)).FeType = 0
 125243 	(*GeoEvent)(unsafe.Pointer(pEvent)).FpSeg = pSeg
 125244 	pEvent = (*GeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr((*GeoOverlap)(unsafe.Pointer(p)).FnEvent)*24
 125245 	(*GeoOverlap)(unsafe.Pointer(p)).FnEvent++
 125246 	(*GeoEvent)(unsafe.Pointer(pEvent)).Fx = float64(x1)
 125247 	(*GeoEvent)(unsafe.Pointer(pEvent)).FeType = 1
 125248 	(*GeoEvent)(unsafe.Pointer(pEvent)).FpSeg = pSeg
 125249 }
 125250 
 125251 func geopolyAddSegments(tls *libc.TLS, p uintptr, pPoly uintptr, side uint8) {
 125252 	var i uint32
 125253 	var x uintptr
 125254 	for i = uint32(0); i < uint32((*GeoPoly)(unsafe.Pointer(pPoly)).FnVertex)-uint32(1); i++ {
 125255 		x = pPoly + 8 + uintptr(i*uint32(2))*4
 125256 		geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x)), *(*GeoCoord)(unsafe.Pointer(x + 1*4)), *(*GeoCoord)(unsafe.Pointer(x + 2*4)), *(*GeoCoord)(unsafe.Pointer(x + 3*4)), side, i)
 125257 	}
 125258 	x = pPoly + 8 + uintptr(i*uint32(2))*4
 125259 	geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x)), *(*GeoCoord)(unsafe.Pointer(x + 1*4)), *(*GeoCoord)(unsafe.Pointer(pPoly + 8)), *(*GeoCoord)(unsafe.Pointer(pPoly + 8 + 1*4)), side, i)
 125260 }
 125261 
 125262 func geopolyEventMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) uintptr {
 125263 	bp := tls.Alloc(24)
 125264 	defer tls.Free(24)
 125265 
 125266 	var pLast uintptr
 125267 	(*GeoEvent)(unsafe.Pointer(bp)).FpNext = uintptr(0)
 125268 	pLast = bp
 125269 	for pRight != 0 && pLeft != 0 {
 125270 		if (*GeoEvent)(unsafe.Pointer(pRight)).Fx <= (*GeoEvent)(unsafe.Pointer(pLeft)).Fx {
 125271 			(*GeoEvent)(unsafe.Pointer(pLast)).FpNext = pRight
 125272 			pLast = pRight
 125273 			pRight = (*GeoEvent)(unsafe.Pointer(pRight)).FpNext
 125274 		} else {
 125275 			(*GeoEvent)(unsafe.Pointer(pLast)).FpNext = pLeft
 125276 			pLast = pLeft
 125277 			pLeft = (*GeoEvent)(unsafe.Pointer(pLeft)).FpNext
 125278 		}
 125279 	}
 125280 	(*GeoEvent)(unsafe.Pointer(pLast)).FpNext = func() uintptr {
 125281 		if pRight != 0 {
 125282 			return pRight
 125283 		}
 125284 		return pLeft
 125285 	}()
 125286 	return (*GeoEvent)(unsafe.Pointer(bp)).FpNext
 125287 }
 125288 
 125289 func geopolySortEventsByX(tls *libc.TLS, aEvent uintptr, nEvent int32) uintptr {
 125290 	bp := tls.Alloc(200)
 125291 	defer tls.Free(200)
 125292 
 125293 	var mx int32 = 0
 125294 	var i int32
 125295 	var j int32
 125296 	var p uintptr
 125297 
 125298 	for i = 0; i < nEvent; i++ {
 125299 		p = aEvent + uintptr(i)*24
 125300 		(*GeoEvent)(unsafe.Pointer(p)).FpNext = uintptr(0)
 125301 		for j = 0; j < mx && *(*uintptr)(unsafe.Pointer(bp + uintptr(j)*4)) != 0; j++ {
 125302 			p = geopolyEventMerge(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(j)*4)), p)
 125303 			*(*uintptr)(unsafe.Pointer(bp + uintptr(j)*4)) = uintptr(0)
 125304 		}
 125305 		*(*uintptr)(unsafe.Pointer(bp + uintptr(j)*4)) = p
 125306 		if j >= mx {
 125307 			mx = j + 1
 125308 		}
 125309 	}
 125310 	p = uintptr(0)
 125311 	for i = 0; i < mx; i++ {
 125312 		p = geopolyEventMerge(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)), p)
 125313 	}
 125314 	return p
 125315 }
 125316 
 125317 func geopolySegmentMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) uintptr {
 125318 	bp := tls.Alloc(40)
 125319 	defer tls.Free(40)
 125320 
 125321 	var pLast uintptr
 125322 	(*GeoSegment)(unsafe.Pointer(bp)).FpNext = uintptr(0)
 125323 	pLast = bp
 125324 	for pRight != 0 && pLeft != 0 {
 125325 		var r float64 = (*GeoSegment)(unsafe.Pointer(pRight)).Fy - (*GeoSegment)(unsafe.Pointer(pLeft)).Fy
 125326 		if r == 0.0 {
 125327 			r = (*GeoSegment)(unsafe.Pointer(pRight)).FC - (*GeoSegment)(unsafe.Pointer(pLeft)).FC
 125328 		}
 125329 		if r < 0.0 {
 125330 			(*GeoSegment)(unsafe.Pointer(pLast)).FpNext = pRight
 125331 			pLast = pRight
 125332 			pRight = (*GeoSegment)(unsafe.Pointer(pRight)).FpNext
 125333 		} else {
 125334 			(*GeoSegment)(unsafe.Pointer(pLast)).FpNext = pLeft
 125335 			pLast = pLeft
 125336 			pLeft = (*GeoSegment)(unsafe.Pointer(pLeft)).FpNext
 125337 		}
 125338 	}
 125339 	(*GeoSegment)(unsafe.Pointer(pLast)).FpNext = func() uintptr {
 125340 		if pRight != 0 {
 125341 			return pRight
 125342 		}
 125343 		return pLeft
 125344 	}()
 125345 	return (*GeoSegment)(unsafe.Pointer(bp)).FpNext
 125346 }
 125347 
 125348 func geopolySortSegmentsByYAndC(tls *libc.TLS, pList uintptr) uintptr {
 125349 	bp := tls.Alloc(200)
 125350 	defer tls.Free(200)
 125351 
 125352 	var mx int32 = 0
 125353 	var i int32
 125354 	var p uintptr
 125355 
 125356 	for pList != 0 {
 125357 		p = pList
 125358 		pList = (*GeoSegment)(unsafe.Pointer(pList)).FpNext
 125359 		(*GeoSegment)(unsafe.Pointer(p)).FpNext = uintptr(0)
 125360 		for i = 0; i < mx && *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) != 0; i++ {
 125361 			p = geopolySegmentMerge(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)), p)
 125362 			*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = uintptr(0)
 125363 		}
 125364 		*(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)) = p
 125365 		if i >= mx {
 125366 			mx = i + 1
 125367 		}
 125368 	}
 125369 	p = uintptr(0)
 125370 	for i = 0; i < mx; i++ {
 125371 		p = geopolySegmentMerge(tls, *(*uintptr)(unsafe.Pointer(bp + uintptr(i)*4)), p)
 125372 	}
 125373 	return p
 125374 }
 125375 
 125376 func geopolyOverlap(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 {
 125377 	bp := tls.Alloc(4)
 125378 	defer tls.Free(4)
 125379 
 125380 	var nVertex Sqlite3_int64
 125381 	var p uintptr
 125382 	var nByte Sqlite3_int64
 125383 	var pThisEvent uintptr
 125384 	var rX float64
 125385 	var rc int32
 125386 	var needSort int32
 125387 	var pActive uintptr
 125388 	var pSeg uintptr
 125389 
 125390 	var y float64
 125391 	var pPrev uintptr
 125392 	var iMask int32
 125393 	nVertex = Sqlite3_int64((*GeoPoly)(unsafe.Pointer(p1)).FnVertex + (*GeoPoly)(unsafe.Pointer(p2)).FnVertex + 2)
 125394 	rc = 0
 125395 	needSort = 0
 125396 	pActive = uintptr(0)
 125397 
 125398 	nByte = Sqlite3_int64(unsafe.Sizeof(GeoEvent{}))*nVertex*int64(2) +
 125399 		Sqlite3_int64(unsafe.Sizeof(GeoSegment{}))*nVertex +
 125400 		Sqlite3_int64(unsafe.Sizeof(GeoOverlap{}))
 125401 	p = Xsqlite3_malloc64(tls, uint64(nByte))
 125402 	if !(p == uintptr(0)) {
 125403 		goto __1
 125404 	}
 125405 	return -1
 125406 __1:
 125407 	;
 125408 	(*GeoOverlap)(unsafe.Pointer(p)).FaEvent = p + 1*16
 125409 	(*GeoOverlap)(unsafe.Pointer(p)).FaSegment = (*GeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr(nVertex*int64(2))*24
 125410 	(*GeoOverlap)(unsafe.Pointer(p)).FnEvent = libc.AssignPtrInt32(p+12, 0)
 125411 	geopolyAddSegments(tls, p, p1, uint8(1))
 125412 	geopolyAddSegments(tls, p, p2, uint8(2))
 125413 	pThisEvent = geopolySortEventsByX(tls, (*GeoOverlap)(unsafe.Pointer(p)).FaEvent, (*GeoOverlap)(unsafe.Pointer(p)).FnEvent)
 125414 	if pThisEvent != 0 && (*GeoEvent)(unsafe.Pointer(pThisEvent)).Fx == 0.0 {
 125415 		rX = -1.0
 125416 	} else {
 125417 		rX = 0.0
 125418 	}
 125419 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([4]uint8{})))
 125420 __2:
 125421 	if !(pThisEvent != 0) {
 125422 		goto __3
 125423 	}
 125424 	if !((*GeoEvent)(unsafe.Pointer(pThisEvent)).Fx != rX) {
 125425 		goto __4
 125426 	}
 125427 	pPrev = uintptr(0)
 125428 	iMask = 0
 125429 
 125430 	rX = (*GeoEvent)(unsafe.Pointer(pThisEvent)).Fx
 125431 	if !(needSort != 0) {
 125432 		goto __5
 125433 	}
 125434 
 125435 	pActive = geopolySortSegmentsByYAndC(tls, pActive)
 125436 	needSort = 0
 125437 __5:
 125438 	;
 125439 	pSeg = pActive
 125440 __6:
 125441 	if !(pSeg != 0) {
 125442 		goto __8
 125443 	}
 125444 	if !(pPrev != 0) {
 125445 		goto __9
 125446 	}
 125447 	if !((*GeoSegment)(unsafe.Pointer(pPrev)).Fy != (*GeoSegment)(unsafe.Pointer(pSeg)).Fy) {
 125448 		goto __10
 125449 	}
 125450 
 125451 	*(*uint8)(unsafe.Pointer(bp + uintptr(iMask))) = uint8(1)
 125452 __10:
 125453 	;
 125454 __9:
 125455 	;
 125456 	iMask = iMask ^ int32((*GeoSegment)(unsafe.Pointer(pSeg)).Fside)
 125457 	pPrev = pSeg
 125458 	goto __7
 125459 __7:
 125460 	pSeg = (*GeoSegment)(unsafe.Pointer(pSeg)).FpNext
 125461 	goto __6
 125462 	goto __8
 125463 __8:
 125464 	;
 125465 	pPrev = uintptr(0)
 125466 	pSeg = pActive
 125467 __11:
 125468 	if !(pSeg != 0) {
 125469 		goto __13
 125470 	}
 125471 	y = (*GeoSegment)(unsafe.Pointer(pSeg)).FC*rX + (*GeoSegment)(unsafe.Pointer(pSeg)).FB
 125472 
 125473 	(*GeoSegment)(unsafe.Pointer(pSeg)).Fy = y
 125474 	if !(pPrev != 0) {
 125475 		goto __14
 125476 	}
 125477 	if !((*GeoSegment)(unsafe.Pointer(pPrev)).Fy > (*GeoSegment)(unsafe.Pointer(pSeg)).Fy && int32((*GeoSegment)(unsafe.Pointer(pPrev)).Fside) != int32((*GeoSegment)(unsafe.Pointer(pSeg)).Fside)) {
 125478 		goto __15
 125479 	}
 125480 	rc = 1
 125481 
 125482 	goto geopolyOverlapDone
 125483 	goto __16
 125484 __15:
 125485 	if !((*GeoSegment)(unsafe.Pointer(pPrev)).Fy != (*GeoSegment)(unsafe.Pointer(pSeg)).Fy) {
 125486 		goto __17
 125487 	}
 125488 
 125489 	*(*uint8)(unsafe.Pointer(bp + uintptr(iMask))) = uint8(1)
 125490 __17:
 125491 	;
 125492 __16:
 125493 	;
 125494 __14:
 125495 	;
 125496 	iMask = iMask ^ int32((*GeoSegment)(unsafe.Pointer(pSeg)).Fside)
 125497 	pPrev = pSeg
 125498 	goto __12
 125499 __12:
 125500 	pSeg = (*GeoSegment)(unsafe.Pointer(pSeg)).FpNext
 125501 	goto __11
 125502 	goto __13
 125503 __13:
 125504 	;
 125505 __4:
 125506 	;
 125507 	if !((*GeoEvent)(unsafe.Pointer(pThisEvent)).FeType == 0) {
 125508 		goto __18
 125509 	}
 125510 
 125511 	pSeg = (*GeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg
 125512 	(*GeoSegment)(unsafe.Pointer(pSeg)).Fy = float64((*GeoSegment)(unsafe.Pointer(pSeg)).Fy0)
 125513 	(*GeoSegment)(unsafe.Pointer(pSeg)).FpNext = pActive
 125514 	pActive = pSeg
 125515 	needSort = 1
 125516 	goto __19
 125517 __18:
 125518 	if !(pActive == (*GeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg) {
 125519 		goto __20
 125520 	}
 125521 	if pActive != 0 {
 125522 		pActive = (*GeoSegment)(unsafe.Pointer(pActive)).FpNext
 125523 	} else {
 125524 		pActive = uintptr(0)
 125525 	}
 125526 	goto __21
 125527 __20:
 125528 	pSeg = pActive
 125529 __22:
 125530 	if !(pSeg != 0) {
 125531 		goto __24
 125532 	}
 125533 	if !((*GeoSegment)(unsafe.Pointer(pSeg)).FpNext == (*GeoEvent)(unsafe.Pointer(pThisEvent)).FpSeg) {
 125534 		goto __25
 125535 	}
 125536 	(*GeoSegment)(unsafe.Pointer(pSeg)).FpNext = func() uintptr {
 125537 		if (*GeoSegment)(unsafe.Pointer(pSeg)).FpNext != 0 {
 125538 			return (*GeoSegment)(unsafe.Pointer((*GeoSegment)(unsafe.Pointer(pSeg)).FpNext)).FpNext
 125539 		}
 125540 		return uintptr(0)
 125541 	}()
 125542 	goto __24
 125543 __25:
 125544 	;
 125545 	goto __23
 125546 __23:
 125547 	pSeg = (*GeoSegment)(unsafe.Pointer(pSeg)).FpNext
 125548 	goto __22
 125549 	goto __24
 125550 __24:
 125551 	;
 125552 __21:
 125553 	;
 125554 __19:
 125555 	;
 125556 	pThisEvent = (*GeoEvent)(unsafe.Pointer(pThisEvent)).FpNext
 125557 	goto __2
 125558 __3:
 125559 	;
 125560 	if !(int32(*(*uint8)(unsafe.Pointer(bp + 3))) == 0) {
 125561 		goto __26
 125562 	}
 125563 	rc = 0
 125564 	goto __27
 125565 __26:
 125566 	if !(int32(*(*uint8)(unsafe.Pointer(bp + 1))) != 0 && int32(*(*uint8)(unsafe.Pointer(bp + 2))) == 0) {
 125567 		goto __28
 125568 	}
 125569 	rc = 3
 125570 	goto __29
 125571 __28:
 125572 	if !(int32(*(*uint8)(unsafe.Pointer(bp + 1))) == 0 && int32(*(*uint8)(unsafe.Pointer(bp + 2))) != 0) {
 125573 		goto __30
 125574 	}
 125575 	rc = 2
 125576 	goto __31
 125577 __30:
 125578 	if !(int32(*(*uint8)(unsafe.Pointer(bp + 1))) == 0 && int32(*(*uint8)(unsafe.Pointer(bp + 2))) == 0) {
 125579 		goto __32
 125580 	}
 125581 	rc = 4
 125582 	goto __33
 125583 __32:
 125584 	rc = 1
 125585 __33:
 125586 	;
 125587 __31:
 125588 	;
 125589 __29:
 125590 	;
 125591 __27:
 125592 	;
 125593 geopolyOverlapDone:
 125594 	Xsqlite3_free(tls, p)
 125595 	return rc
 125596 }
 125597 
 125598 func geopolyOverlapFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 125599 	var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0))
 125600 	var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*4)), uintptr(0))
 125601 	_ = argc
 125602 	if p1 != 0 && p2 != 0 {
 125603 		var x int32 = geopolyOverlap(tls, p1, p2)
 125604 		if x < 0 {
 125605 			Xsqlite3_result_error_nomem(tls, context)
 125606 		} else {
 125607 			Xsqlite3_result_int(tls, context, x)
 125608 		}
 125609 	}
 125610 	Xsqlite3_free(tls, p1)
 125611 	Xsqlite3_free(tls, p2)
 125612 }
 125613 
 125614 func geopolyDebugFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 125615 	_ = context
 125616 	_ = argc
 125617 	_ = argv
 125618 }
 125619 
 125620 func geopolyInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr, isCreate int32) int32 {
 125621 	bp := tls.Alloc(32)
 125622 	defer tls.Free(32)
 125623 
 125624 	var rc int32
 125625 	var pRtree uintptr
 125626 	var nDb Sqlite3_int64
 125627 	var nName Sqlite3_int64
 125628 	var pSql uintptr
 125629 	var zSql uintptr
 125630 	var ii int32
 125631 	rc = SQLITE_OK
 125632 	_ = pAux
 125633 
 125634 	Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_CONSTRAINT_SUPPORT, libc.VaList(bp, 1))
 125635 
 125636 	nDb = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))))
 125637 	nName = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*4))))
 125638 	pRtree = Xsqlite3_malloc64(tls, uint64(Sqlite3_int64(unsafe.Sizeof(Rtree{}))+nDb+nName+int64(2)))
 125639 	if !!(pRtree != 0) {
 125640 		goto __1
 125641 	}
 125642 	return SQLITE_NOMEM
 125643 __1:
 125644 	;
 125645 	libc.Xmemset(tls, pRtree, 0, uint32(Sqlite3_int64(unsafe.Sizeof(Rtree{}))+nDb+nName+int64(2)))
 125646 	(*Rtree)(unsafe.Pointer(pRtree)).FnBusy = U32(1)
 125647 	(*Rtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&rtreeModule))
 125648 	(*Rtree)(unsafe.Pointer(pRtree)).FzDb = pRtree + 1*504
 125649 	(*Rtree)(unsafe.Pointer(pRtree)).FzName = (*Rtree)(unsafe.Pointer(pRtree)).FzDb + uintptr(nDb+int64(1))
 125650 	(*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = U8(RTREE_COORD_REAL32)
 125651 	(*Rtree)(unsafe.Pointer(pRtree)).FnDim = U8(2)
 125652 	(*Rtree)(unsafe.Pointer(pRtree)).FnDim2 = U8(4)
 125653 	libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + 1*4)), uint32(nDb))
 125654 	libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + 2*4)), uint32(nName))
 125655 
 125656 	pSql = Xsqlite3_str_new(tls, db)
 125657 	Xsqlite3_str_appendf(tls, pSql, ts+27588, 0)
 125658 	(*Rtree)(unsafe.Pointer(pRtree)).FnAux = U8(1)
 125659 	(*Rtree)(unsafe.Pointer(pRtree)).FnAuxNotNull = U8(1)
 125660 	ii = 3
 125661 __2:
 125662 	if !(ii < argc) {
 125663 		goto __4
 125664 	}
 125665 	(*Rtree)(unsafe.Pointer(pRtree)).FnAux++
 125666 	Xsqlite3_str_appendf(tls, pSql, ts+27610, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*4))))
 125667 	goto __3
 125668 __3:
 125669 	ii++
 125670 	goto __2
 125671 	goto __4
 125672 __4:
 125673 	;
 125674 	Xsqlite3_str_appendf(tls, pSql, ts+26677, 0)
 125675 	zSql = Xsqlite3_str_finish(tls, pSql)
 125676 	if !!(zSql != 0) {
 125677 		goto __5
 125678 	}
 125679 	rc = SQLITE_NOMEM
 125680 	goto __6
 125681 __5:
 125682 	if !(SQLITE_OK != libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql))) {
 125683 		goto __7
 125684 	}
 125685 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db)))
 125686 __7:
 125687 	;
 125688 __6:
 125689 	;
 125690 	Xsqlite3_free(tls, zSql)
 125691 	if !(rc != 0) {
 125692 		goto __8
 125693 	}
 125694 	goto geopolyInit_fail
 125695 __8:
 125696 	;
 125697 	(*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell = U8(8 + int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)*4)
 125698 
 125699 	rc = getNodeSize(tls, db, pRtree, isCreate, pzErr)
 125700 	if !(rc != 0) {
 125701 		goto __9
 125702 	}
 125703 	goto geopolyInit_fail
 125704 __9:
 125705 	;
 125706 	rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + 1*4)), *(*uintptr)(unsafe.Pointer(argv + 2*4)), isCreate)
 125707 	if !(rc != 0) {
 125708 		goto __10
 125709 	}
 125710 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+24, Xsqlite3_errmsg(tls, db)))
 125711 	goto geopolyInit_fail
 125712 __10:
 125713 	;
 125714 	*(*uintptr)(unsafe.Pointer(ppVtab)) = pRtree
 125715 	return SQLITE_OK
 125716 
 125717 geopolyInit_fail:
 125718 	if !(rc == SQLITE_OK) {
 125719 		goto __11
 125720 	}
 125721 	rc = SQLITE_ERROR
 125722 __11:
 125723 	;
 125724 	rtreeRelease(tls, pRtree)
 125725 	return rc
 125726 }
 125727 
 125728 func geopolyCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 125729 	return geopolyInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 1)
 125730 }
 125731 
 125732 func geopolyConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 125733 	return geopolyInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 0)
 125734 }
 125735 
 125736 func geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 {
 125737 	bp := tls.Alloc(44)
 125738 	defer tls.Free(44)
 125739 
 125740 	var pRtree uintptr
 125741 	var pCsr uintptr
 125742 
 125743 	var p uintptr
 125744 	var iRowid I64
 125745 
 125746 	var p1 uintptr
 125747 	var pNew uintptr
 125748 	pRtree = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab
 125749 	pCsr = pVtabCursor
 125750 	*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 125751 	*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_OK
 125752 	*(*int32)(unsafe.Pointer(bp + 16)) = 0
 125753 	_ = idxStr
 125754 
 125755 	rtreeReference(tls, pRtree)
 125756 
 125757 	resetCursor(tls, pCsr)
 125758 
 125759 	(*RtreeCursor)(unsafe.Pointer(pCsr)).FiStrategy = idxNum
 125760 	if !(idxNum == 1) {
 125761 		goto __1
 125762 	}
 125763 	iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
 125764 	*(*I64)(unsafe.Pointer(bp + 8)) = int64(0)
 125765 	*(*int32)(unsafe.Pointer(bp + 40)) = findLeafNode(tls, pRtree, iRowid, bp, bp+8)
 125766 	if !(*(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && *(*uintptr)(unsafe.Pointer(bp)) != uintptr(0)) {
 125767 		goto __3
 125768 	}
 125769 	p = rtreeSearchPointNew(tls, pCsr, 0.0, uint8(0))
 125770 
 125771 	*(*uintptr)(unsafe.Pointer(pCsr + 64)) = *(*uintptr)(unsafe.Pointer(bp))
 125772 	(*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = *(*I64)(unsafe.Pointer(bp + 8))
 125773 	(*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(PARTLY_WITHIN)
 125774 	*(*int32)(unsafe.Pointer(bp + 40)) = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp)), iRowid, bp+16)
 125775 	(*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = U8(*(*int32)(unsafe.Pointer(bp + 16)))
 125776 
 125777 	goto __4
 125778 __3:
 125779 	(*RtreeCursor)(unsafe.Pointer(pCsr)).FatEOF = U8(1)
 125780 __4:
 125781 	;
 125782 	goto __2
 125783 __1:
 125784 	*(*int32)(unsafe.Pointer(bp + 40)) = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+20)
 125785 	if !(*(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && idxNum <= 3) {
 125786 		goto __5
 125787 	}
 125788 
 125789 	geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(argv)), bp+24, bp+40)
 125790 	if !(*(*int32)(unsafe.Pointer(bp + 40)) != 0) {
 125791 		goto __6
 125792 	}
 125793 	goto geopoly_filter_end
 125794 __6:
 125795 	;
 125796 	(*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = libc.AssignUintptr(&p1, Xsqlite3_malloc(tls, int32(uint32(unsafe.Sizeof(RtreeConstraint{}))*uint32(4))))
 125797 	(*RtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = 4
 125798 	if !(p1 == uintptr(0)) {
 125799 		goto __7
 125800 	}
 125801 	*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_NOMEM
 125802 	goto __8
 125803 __7:
 125804 	libc.Xmemset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, uint32(unsafe.Sizeof(RtreeConstraint{}))*uint32(4))
 125805 	libc.Xmemset(tls, pCsr+84, 0, uint32(unsafe.Sizeof(U32(0)))*uint32((*Rtree)(unsafe.Pointer(pRtree)).FiDepth+1))
 125806 	if !(idxNum == 2) {
 125807 		goto __9
 125808 	}
 125809 
 125810 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B'
 125811 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0
 125812 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24 + 1*4)))
 125813 	p1 += 24
 125814 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D'
 125815 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 1
 125816 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24)))
 125817 	p1 += 24
 125818 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B'
 125819 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 2
 125820 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24 + 3*4)))
 125821 	p1 += 24
 125822 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D'
 125823 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 3
 125824 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24 + 2*4)))
 125825 	goto __10
 125826 __9:
 125827 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D'
 125828 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0
 125829 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24)))
 125830 	p1 += 24
 125831 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B'
 125832 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 1
 125833 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24 + 1*4)))
 125834 	p1 += 24
 125835 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D'
 125836 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 2
 125837 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24 + 2*4)))
 125838 	p1 += 24
 125839 	(*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B'
 125840 	(*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 3
 125841 	*(*RtreeDValue)(unsafe.Pointer(p1 + 8)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 24 + 3*4)))
 125842 __10:
 125843 	;
 125844 __8:
 125845 	;
 125846 __5:
 125847 	;
 125848 	if !(*(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK) {
 125849 		goto __11
 125850 	}
 125851 	pNew = rtreeSearchPointNew(tls, pCsr, 0.0, U8((*Rtree)(unsafe.Pointer(pRtree)).FiDepth+1))
 125852 	if !(pNew == uintptr(0)) {
 125853 		goto __12
 125854 	}
 125855 	*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_NOMEM
 125856 	goto geopoly_filter_end
 125857 __12:
 125858 	;
 125859 	(*RtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1)
 125860 	(*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = U8(0)
 125861 	(*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = U8(PARTLY_WITHIN)
 125862 
 125863 	*(*uintptr)(unsafe.Pointer(pCsr + 64)) = *(*uintptr)(unsafe.Pointer(bp + 20))
 125864 	*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 125865 
 125866 	*(*int32)(unsafe.Pointer(bp + 40)) = rtreeStepToLeaf(tls, pCsr)
 125867 __11:
 125868 	;
 125869 __2:
 125870 	;
 125871 geopoly_filter_end:
 125872 	nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 20)))
 125873 	rtreeRelease(tls, pRtree)
 125874 	return *(*int32)(unsafe.Pointer(bp + 40))
 125875 }
 125876 
 125877 func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 {
 125878 	var ii int32
 125879 	var iRowidTerm int32 = -1
 125880 	var iFuncTerm int32 = -1
 125881 	var idxNum int32 = 0
 125882 	_ = tab
 125883 
 125884 	for ii = 0; ii < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ {
 125885 		var p uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12
 125886 		if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) {
 125887 			continue
 125888 		}
 125889 		if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0 && int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ {
 125890 			iRowidTerm = ii
 125891 			break
 125892 		}
 125893 		if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 && int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= SQLITE_INDEX_CONSTRAINT_FUNCTION {
 125894 			iFuncTerm = ii
 125895 			idxNum = int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - SQLITE_INDEX_CONSTRAINT_FUNCTION + 2
 125896 		}
 125897 	}
 125898 
 125899 	if iRowidTerm >= 0 {
 125900 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1
 125901 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = ts + 16267
 125902 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).FargvIndex = 1
 125903 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).Fomit = uint8(1)
 125904 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 30.0
 125905 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1)
 125906 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE
 125907 		return SQLITE_OK
 125908 	}
 125909 	if iFuncTerm >= 0 {
 125910 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum
 125911 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = ts + 27614
 125912 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8)).FargvIndex = 1
 125913 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8)).Fomit = uint8(0)
 125914 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 300.0
 125915 		(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10)
 125916 		return SQLITE_OK
 125917 	}
 125918 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 4
 125919 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = ts + 27620
 125920 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 3000000.0
 125921 	(*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000)
 125922 	return SQLITE_OK
 125923 }
 125924 
 125925 func geopolyColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 {
 125926 	bp := tls.Alloc(4)
 125927 	defer tls.Free(4)
 125928 
 125929 	var pRtree uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab
 125930 	var pCsr uintptr = cur
 125931 	var p uintptr = rtreeSearchPointFirst(tls, pCsr)
 125932 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 125933 	var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp)
 125934 
 125935 	if *(*int32)(unsafe.Pointer(bp)) != 0 {
 125936 		return *(*int32)(unsafe.Pointer(bp))
 125937 	}
 125938 	if p == uintptr(0) {
 125939 		return SQLITE_OK
 125940 	}
 125941 	if i == 0 && Xsqlite3_vtab_nochange(tls, ctx) != 0 {
 125942 		return SQLITE_OK
 125943 	}
 125944 	if i <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) {
 125945 		if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid) != 0) {
 125946 			if (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux == uintptr(0) {
 125947 				*(*int32)(unsafe.Pointer(bp)) = Xsqlite3_prepare_v3(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, (*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql, -1, uint32(0),
 125948 					pCsr+36, uintptr(0))
 125949 				if *(*int32)(unsafe.Pointer(bp)) != 0 {
 125950 					return *(*int32)(unsafe.Pointer(bp))
 125951 				}
 125952 			}
 125953 			Xsqlite3_bind_int64(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, 1,
 125954 				nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell)))
 125955 			*(*int32)(unsafe.Pointer(bp)) = Xsqlite3_step(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
 125956 			if *(*int32)(unsafe.Pointer(bp)) == SQLITE_ROW {
 125957 				(*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(1)
 125958 			} else {
 125959 				Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
 125960 				if *(*int32)(unsafe.Pointer(bp)) == SQLITE_DONE {
 125961 					*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 125962 				}
 125963 				return *(*int32)(unsafe.Pointer(bp))
 125964 			}
 125965 		}
 125966 		Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, i+2))
 125967 	}
 125968 	return SQLITE_OK
 125969 }
 125970 
 125971 func geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowid uintptr) int32 {
 125972 	bp := tls.Alloc(56)
 125973 	defer tls.Free(56)
 125974 
 125975 	var pRtree uintptr
 125976 
 125977 	var oldRowid I64
 125978 	var oldRowidValid int32
 125979 	var newRowid I64
 125980 	var newRowidValid int32
 125981 	var coordChange int32
 125982 	var steprc int32
 125983 	var rc2 int32
 125984 
 125985 	var p uintptr
 125986 	var pUp uintptr
 125987 	var jj int32
 125988 	var nChange int32
 125989 	pRtree = pVtab
 125990 	*(*int32)(unsafe.Pointer(bp + 48)) = SQLITE_OK
 125991 	coordChange = 0
 125992 
 125993 	if !((*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0) {
 125994 		goto __1
 125995 	}
 125996 
 125997 	return SQLITE_LOCKED | int32(2)<<8
 125998 __1:
 125999 	;
 126000 	rtreeReference(tls, pRtree)
 126001 
 126002 	oldRowidValid = libc.Bool32(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) != SQLITE_NULL)
 126003 
 126004 	if oldRowidValid != 0 {
 126005 		oldRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData)))
 126006 	} else {
 126007 		oldRowid = int64(0)
 126008 	}
 126009 	newRowidValid = libc.Bool32(nData > 1 && Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 1*4))) != SQLITE_NULL)
 126010 	if newRowidValid != 0 {
 126011 		newRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + 1*4)))
 126012 	} else {
 126013 		newRowid = int64(0)
 126014 	}
 126015 	(*RtreeCell)(unsafe.Pointer(bp)).FiRowid = newRowid
 126016 
 126017 	if !(nData > 1 &&
 126018 		(!(oldRowidValid != 0) ||
 126019 			!(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + 2*4))) != 0) ||
 126020 			oldRowid != newRowid)) {
 126021 		goto __2
 126022 	}
 126023 
 126024 	geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + 2*4)), bp+8, bp+48)
 126025 	if !(*(*int32)(unsafe.Pointer(bp + 48)) != 0) {
 126026 		goto __3
 126027 	}
 126028 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_ERROR) {
 126029 		goto __4
 126030 	}
 126031 	(*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+27629, 0)
 126032 __4:
 126033 	;
 126034 	goto geopoly_update_end
 126035 __3:
 126036 	;
 126037 	coordChange = 1
 126038 
 126039 	if !(newRowidValid != 0 && (!(oldRowidValid != 0) || oldRowid != newRowid)) {
 126040 		goto __5
 126041 	}
 126042 	Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, (*RtreeCell)(unsafe.Pointer(bp)).FiRowid)
 126043 	steprc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 126044 	*(*int32)(unsafe.Pointer(bp + 48)) = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid)
 126045 	if !(SQLITE_ROW == steprc) {
 126046 		goto __6
 126047 	}
 126048 	if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == SQLITE_REPLACE) {
 126049 		goto __7
 126050 	}
 126051 	*(*int32)(unsafe.Pointer(bp + 48)) = rtreeDeleteRowid(tls, pRtree, (*RtreeCell)(unsafe.Pointer(bp)).FiRowid)
 126052 	goto __8
 126053 __7:
 126054 	*(*int32)(unsafe.Pointer(bp + 48)) = rtreeConstraintError(tls, pRtree, 0)
 126055 __8:
 126056 	;
 126057 __6:
 126058 	;
 126059 __5:
 126060 	;
 126061 __2:
 126062 	;
 126063 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK && (nData == 1 || coordChange != 0 && oldRowidValid != 0)) {
 126064 		goto __9
 126065 	}
 126066 	*(*int32)(unsafe.Pointer(bp + 48)) = rtreeDeleteRowid(tls, pRtree, oldRowid)
 126067 __9:
 126068 	;
 126069 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK && nData > 1 && coordChange != 0) {
 126070 		goto __10
 126071 	}
 126072 
 126073 	*(*uintptr)(unsafe.Pointer(bp + 52)) = uintptr(0)
 126074 	if !!(newRowidValid != 0) {
 126075 		goto __11
 126076 	}
 126077 	*(*int32)(unsafe.Pointer(bp + 48)) = rtreeNewRowid(tls, pRtree, bp)
 126078 __11:
 126079 	;
 126080 	*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*RtreeCell)(unsafe.Pointer(bp)).FiRowid
 126081 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK) {
 126082 		goto __12
 126083 	}
 126084 	*(*int32)(unsafe.Pointer(bp + 48)) = sChooseLeaf(tls, pRtree, bp, 0, bp+52)
 126085 __12:
 126086 	;
 126087 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK) {
 126088 		goto __13
 126089 	}
 126090 	(*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = -1
 126091 	*(*int32)(unsafe.Pointer(bp + 48)) = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 52)), bp, 0)
 126092 	rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 52)))
 126093 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK) {
 126094 		goto __14
 126095 	}
 126096 	*(*int32)(unsafe.Pointer(bp + 48)) = rc2
 126097 __14:
 126098 	;
 126099 __13:
 126100 	;
 126101 __10:
 126102 	;
 126103 	if !(*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK && nData > 1) {
 126104 		goto __15
 126105 	}
 126106 	pUp = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux
 126107 	nChange = 0
 126108 	Xsqlite3_bind_int64(tls, pUp, 1, (*RtreeCell)(unsafe.Pointer(bp)).FiRowid)
 126109 
 126110 	if !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + 2*4))) != 0) {
 126111 		goto __16
 126112 	}
 126113 	Xsqlite3_bind_null(tls, pUp, 2)
 126114 	goto __17
 126115 __16:
 126116 	p = uintptr(0)
 126117 	if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 2*4))) == SQLITE_TEXT &&
 126118 		libc.AssignUintptr(&p, geopolyFuncParam(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + 2*4)), bp+48)) != uintptr(0) &&
 126119 		*(*int32)(unsafe.Pointer(bp + 48)) == SQLITE_OK) {
 126120 		goto __18
 126121 	}
 126122 	Xsqlite3_bind_blob(tls, pUp, 2, p+4, 4+8*(*GeoPoly)(unsafe.Pointer(p)).FnVertex, libc.UintptrFromInt32(-1))
 126123 	goto __19
 126124 __18:
 126125 	Xsqlite3_bind_value(tls, pUp, 2, *(*uintptr)(unsafe.Pointer(aData + 2*4)))
 126126 __19:
 126127 	;
 126128 	Xsqlite3_free(tls, p)
 126129 	nChange = 1
 126130 __17:
 126131 	;
 126132 	jj = 1
 126133 __20:
 126134 	if !(jj < nData-2) {
 126135 		goto __22
 126136 	}
 126137 	nChange++
 126138 	Xsqlite3_bind_value(tls, pUp, jj+2, *(*uintptr)(unsafe.Pointer(aData + uintptr(jj+2)*4)))
 126139 	goto __21
 126140 __21:
 126141 	jj++
 126142 	goto __20
 126143 	goto __22
 126144 __22:
 126145 	;
 126146 	if !(nChange != 0) {
 126147 		goto __23
 126148 	}
 126149 	Xsqlite3_step(tls, pUp)
 126150 	*(*int32)(unsafe.Pointer(bp + 48)) = Xsqlite3_reset(tls, pUp)
 126151 __23:
 126152 	;
 126153 __15:
 126154 	;
 126155 geopoly_update_end:
 126156 	rtreeRelease(tls, pRtree)
 126157 	return *(*int32)(unsafe.Pointer(bp + 48))
 126158 }
 126159 
 126160 func geopolyFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr, pxFunc uintptr, ppArg uintptr) int32 {
 126161 	_ = pVtab
 126162 	_ = nArg
 126163 	if Xsqlite3_stricmp(tls, zName, ts+27669) == 0 {
 126164 		*(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct {
 126165 			f func(*libc.TLS, uintptr, int32, uintptr)
 126166 		}{geopolyOverlapFunc}))
 126167 		*(*uintptr)(unsafe.Pointer(ppArg)) = uintptr(0)
 126168 		return SQLITE_INDEX_CONSTRAINT_FUNCTION
 126169 	}
 126170 	if Xsqlite3_stricmp(tls, zName, ts+27685) == 0 {
 126171 		*(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct {
 126172 			f func(*libc.TLS, uintptr, int32, uintptr)
 126173 		}{geopolyWithinFunc}))
 126174 		*(*uintptr)(unsafe.Pointer(ppArg)) = uintptr(0)
 126175 		return SQLITE_INDEX_CONSTRAINT_FUNCTION + 1
 126176 	}
 126177 	return 0
 126178 }
 126179 
 126180 var geopolyModule = Sqlite3_module{
 126181 	FiVersion:      3,
 126182 	FxCreate:       0,
 126183 	FxConnect:      0,
 126184 	FxBestIndex:    0,
 126185 	FxDisconnect:   0,
 126186 	FxDestroy:      0,
 126187 	FxOpen:         0,
 126188 	FxClose:        0,
 126189 	FxFilter:       0,
 126190 	FxNext:         0,
 126191 	FxEof:          0,
 126192 	FxColumn:       0,
 126193 	FxRowid:        0,
 126194 	FxUpdate:       0,
 126195 	FxBegin:        0,
 126196 	FxSync:         0,
 126197 	FxCommit:       0,
 126198 	FxRollback:     0,
 126199 	FxFindFunction: 0,
 126200 	FxRename:       0,
 126201 	FxSavepoint:    0,
 126202 	FxShadowName:   0,
 126203 }
 126204 
 126205 func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 {
 126206 	var rc int32 = SQLITE_OK
 126207 	var i uint32
 126208 	for i = uint32(0); i < uint32(unsafe.Sizeof(aFunc))/uint32(unsafe.Sizeof(struct {
 126209 		FxFunc       uintptr
 126210 		FnArg        int8
 126211 		FbPure       uint8
 126212 		F__ccgo_pad1 [2]byte
 126213 		FzName       uintptr
 126214 	}{})) && rc == SQLITE_OK; i++ {
 126215 		var enc int32
 126216 		if aFunc[i].FbPure != 0 {
 126217 			enc = SQLITE_UTF8 | SQLITE_DETERMINISTIC | SQLITE_INNOCUOUS
 126218 		} else {
 126219 			enc = SQLITE_UTF8 | SQLITE_DIRECTONLY
 126220 		}
 126221 		rc = Xsqlite3_create_function(tls, db, aFunc[i].FzName, int32(aFunc[i].FnArg),
 126222 			enc, uintptr(0),
 126223 			aFunc[i].FxFunc, uintptr(0), uintptr(0))
 126224 	}
 126225 	for i = uint32(0); i < uint32(unsafe.Sizeof(aAgg))/uint32(unsafe.Sizeof(struct {
 126226 		FxStep  uintptr
 126227 		FxFinal uintptr
 126228 		FzName  uintptr
 126229 	}{})) && rc == SQLITE_OK; i++ {
 126230 		rc = Xsqlite3_create_function(tls, db, aAgg[i].FzName, 1,
 126231 			SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS, uintptr(0),
 126232 			uintptr(0), aAgg[i].FxStep, aAgg[i].FxFinal)
 126233 	}
 126234 	if rc == SQLITE_OK {
 126235 		rc = Xsqlite3_create_module_v2(tls, db, ts+27700, uintptr(unsafe.Pointer(&geopolyModule)), uintptr(0), uintptr(0))
 126236 	}
 126237 	return rc
 126238 }
 126239 
 126240 var aFunc = [12]struct {
 126241 	FxFunc       uintptr
 126242 	FnArg        int8
 126243 	FbPure       uint8
 126244 	F__ccgo_pad1 [2]byte
 126245 	FzName       uintptr
 126246 }{
 126247 	{FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 27708},
 126248 	{FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 27721},
 126249 	{FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 27734},
 126250 	{FxFunc: 0, FnArg: int8(-1), FbPure: uint8(1), FzName: ts + 27747},
 126251 	{FxFunc: 0, FnArg: int8(2), FbPure: uint8(1), FzName: ts + 27685},
 126252 	{FxFunc: 0, FnArg: int8(3), FbPure: uint8(1), FzName: ts + 27759},
 126253 	{FxFunc: 0, FnArg: int8(2), FbPure: uint8(1), FzName: ts + 27669},
 126254 	{FxFunc: 0, FnArg: int8(1), FzName: ts + 27782},
 126255 	{FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 27796},
 126256 	{FxFunc: 0, FnArg: int8(7), FbPure: uint8(1), FzName: ts + 27809},
 126257 	{FxFunc: 0, FnArg: int8(4), FbPure: uint8(1), FzName: ts + 27823},
 126258 	{FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 27839},
 126259 }
 126260 var aAgg = [1]struct {
 126261 	FxStep  uintptr
 126262 	FxFinal uintptr
 126263 	FzName  uintptr
 126264 }{
 126265 	{FxStep: 0, FxFinal: 0, FzName: ts + 27851},
 126266 }
 126267 
 126268 // Register the r-tree module with database handle db. This creates the
 126269 // virtual table module "rtree" and the debugging/analysis scalar
 126270 // function "rtreenode".
 126271 func Xsqlite3RtreeInit(tls *libc.TLS, db uintptr) int32 {
 126272 	var utf8 int32 = SQLITE_UTF8
 126273 	var rc int32
 126274 
 126275 	rc = Xsqlite3_create_function(tls, db, ts+27870, 2, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 126276 		f func(*libc.TLS, uintptr, int32, uintptr)
 126277 	}{rtreenode})), uintptr(0), uintptr(0))
 126278 	if rc == SQLITE_OK {
 126279 		rc = Xsqlite3_create_function(tls, db, ts+27880, 1, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 126280 			f func(*libc.TLS, uintptr, int32, uintptr)
 126281 		}{rtreedepth})), uintptr(0), uintptr(0))
 126282 	}
 126283 	if rc == SQLITE_OK {
 126284 		rc = Xsqlite3_create_function(tls, db, ts+27891, -1, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 126285 			f func(*libc.TLS, uintptr, int32, uintptr)
 126286 		}{rtreecheck})), uintptr(0), uintptr(0))
 126287 	}
 126288 	if rc == SQLITE_OK {
 126289 		var c uintptr = uintptr(RTREE_COORD_REAL32)
 126290 		rc = Xsqlite3_create_module_v2(tls, db, ts+27614, uintptr(unsafe.Pointer(&rtreeModule)), c, uintptr(0))
 126291 	}
 126292 	if rc == SQLITE_OK {
 126293 		var c uintptr = uintptr(RTREE_COORD_INT32)
 126294 		rc = Xsqlite3_create_module_v2(tls, db, ts+27902, uintptr(unsafe.Pointer(&rtreeModule)), c, uintptr(0))
 126295 	}
 126296 	if rc == SQLITE_OK {
 126297 		rc = sqlite3_geopoly_init(tls, db)
 126298 	}
 126299 
 126300 	return rc
 126301 }
 126302 
 126303 func rtreeFreeCallback(tls *libc.TLS, p uintptr) {
 126304 	var pInfo uintptr = p
 126305 	if (*RtreeGeomCallback)(unsafe.Pointer(pInfo)).FxDestructor != 0 {
 126306 		(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*RtreeGeomCallback)(unsafe.Pointer(pInfo)).FxDestructor})).f(tls, (*RtreeGeomCallback)(unsafe.Pointer(pInfo)).FpContext)
 126307 	}
 126308 	Xsqlite3_free(tls, p)
 126309 }
 126310 
 126311 func rtreeMatchArgFree(tls *libc.TLS, pArg uintptr) {
 126312 	var i int32
 126313 	var p uintptr = pArg
 126314 	for i = 0; i < (*RtreeMatchArg)(unsafe.Pointer(p)).FnParam; i++ {
 126315 		Xsqlite3_value_free(tls, *(*uintptr)(unsafe.Pointer((*RtreeMatchArg)(unsafe.Pointer(p)).FapSqlParam + uintptr(i)*4)))
 126316 	}
 126317 	Xsqlite3_free(tls, p)
 126318 }
 126319 
 126320 func geomCallback(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) {
 126321 	var pGeomCtx uintptr = Xsqlite3_user_data(tls, ctx)
 126322 	var pBlob uintptr
 126323 	var nBlob Sqlite3_int64
 126324 	var memErr int32 = 0
 126325 
 126326 	nBlob = Sqlite3_int64(uint32(unsafe.Sizeof(RtreeMatchArg{})) + uint32(nArg-1)*uint32(unsafe.Sizeof(RtreeDValue(0))) +
 126327 		uint32(nArg)*uint32(unsafe.Sizeof(uintptr(0))))
 126328 	pBlob = Xsqlite3_malloc64(tls, uint64(nBlob))
 126329 	if !(pBlob != 0) {
 126330 		Xsqlite3_result_error_nomem(tls, ctx)
 126331 	} else {
 126332 		var i int32
 126333 		(*RtreeMatchArg)(unsafe.Pointer(pBlob)).FiSize = U32(nBlob)
 126334 		(*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = *(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx))
 126335 		(*RtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam = pBlob + 32 + uintptr(nArg)*8
 126336 		(*RtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam = nArg
 126337 		for i = 0; i < nArg; i++ {
 126338 			*(*uintptr)(unsafe.Pointer((*RtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + uintptr(i)*4)) = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(aArg + uintptr(i)*4)))
 126339 			if *(*uintptr)(unsafe.Pointer((*RtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam + uintptr(i)*4)) == uintptr(0) {
 126340 				memErr = 1
 126341 			}
 126342 			*(*RtreeDValue)(unsafe.Pointer(pBlob + 32 + uintptr(i)*8)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(aArg + uintptr(i)*4)))
 126343 		}
 126344 		if memErr != 0 {
 126345 			Xsqlite3_result_error_nomem(tls, ctx)
 126346 			rtreeMatchArgFree(tls, pBlob)
 126347 		} else {
 126348 			Xsqlite3_result_pointer(tls, ctx, pBlob, ts+25190, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeMatchArgFree})))
 126349 		}
 126350 	}
 126351 }
 126352 
 126353 // Register a new geometry function for use with the r-tree MATCH operator.
 126354 func Xsqlite3_rtree_geometry_callback(tls *libc.TLS, db uintptr, zGeom uintptr, xGeom uintptr, pContext uintptr) int32 {
 126355 	var pGeomCtx uintptr
 126356 
 126357 	pGeomCtx = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(RtreeGeomCallback{})))
 126358 	if !(pGeomCtx != 0) {
 126359 		return SQLITE_NOMEM
 126360 	}
 126361 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = xGeom
 126362 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = uintptr(0)
 126363 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = uintptr(0)
 126364 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext
 126365 	return Xsqlite3_create_function_v2(tls, db, zGeom, -1, SQLITE_ANY,
 126366 		pGeomCtx, *(*uintptr)(unsafe.Pointer(&struct {
 126367 			f func(*libc.TLS, uintptr, int32, uintptr)
 126368 		}{geomCallback})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeFreeCallback})))
 126369 }
 126370 
 126371 // Register a new 2nd-generation geometry function for use with the
 126372 // r-tree MATCH operator.
 126373 func Xsqlite3_rtree_query_callback(tls *libc.TLS, db uintptr, zQueryFunc uintptr, xQueryFunc uintptr, pContext uintptr, xDestructor uintptr) int32 {
 126374 	var pGeomCtx uintptr
 126375 
 126376 	pGeomCtx = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(RtreeGeomCallback{})))
 126377 	if !(pGeomCtx != 0) {
 126378 		if xDestructor != 0 {
 126379 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDestructor})).f(tls, pContext)
 126380 		}
 126381 		return SQLITE_NOMEM
 126382 	}
 126383 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = uintptr(0)
 126384 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = xQueryFunc
 126385 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = xDestructor
 126386 	(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext
 126387 	return Xsqlite3_create_function_v2(tls, db, zQueryFunc, -1, SQLITE_ANY,
 126388 		pGeomCtx, *(*uintptr)(unsafe.Pointer(&struct {
 126389 			f func(*libc.TLS, uintptr, int32, uintptr)
 126390 		}{geomCallback})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeFreeCallback})))
 126391 }
 126392 
 126393 type sqlite3rbu = struct {
 126394 	FeStage         int32
 126395 	FdbMain         uintptr
 126396 	FdbRbu          uintptr
 126397 	FzTarget        uintptr
 126398 	FzRbu           uintptr
 126399 	FzState         uintptr
 126400 	FzStateDb       [5]uint8
 126401 	F__ccgo_pad1    [3]byte
 126402 	Frc             int32
 126403 	FzErrmsg        uintptr
 126404 	FnStep          int32
 126405 	FnProgress      int32
 126406 	Fobjiter        RbuObjIter
 126407 	FzVfsName       uintptr
 126408 	FpTargetFd      uintptr
 126409 	FnPagePerSector int32
 126410 	FiOalSz         I64
 126411 	FnPhaseOneStep  I64
 126412 	FpRenameArg     uintptr
 126413 	FxRename        uintptr
 126414 	FiMaxFrame      U32
 126415 	FmLock          U32
 126416 	FnFrame         int32
 126417 	FnFrameAlloc    int32
 126418 	FaFrame         uintptr
 126419 	Fpgsz           int32
 126420 	FaBuf           uintptr
 126421 	F__ccgo_pad2    [4]byte
 126422 	FiWalCksum      I64
 126423 	FszTemp         I64
 126424 	FszTempLimit    I64
 126425 	FnRbu           int32
 126426 	FpRbuFd         uintptr
 126427 }
 126428 
 126429 type Sqlite3rbu = sqlite3rbu
 126430 
 126431 type RbuFrame1 = struct {
 126432 	FiDbPage   U32
 126433 	FiWalFrame U32
 126434 }
 126435 
 126436 type RbuFrame = RbuFrame1
 126437 type RbuObjIter1 = struct {
 126438 	FpTblIter   uintptr
 126439 	FpIdxIter   uintptr
 126440 	FnTblCol    int32
 126441 	FazTblCol   uintptr
 126442 	FazTblType  uintptr
 126443 	FaiSrcOrder uintptr
 126444 	FabTblPk    uintptr
 126445 	FabNotNull  uintptr
 126446 	FabIndexed  uintptr
 126447 	FeType      int32
 126448 	FbCleanup   int32
 126449 	FzTbl       uintptr
 126450 	FzDataTbl   uintptr
 126451 	FzIdx       uintptr
 126452 	FiTnum      int32
 126453 	FiPkTnum    int32
 126454 	FbUnique    int32
 126455 	FnIndex     int32
 126456 	FnCol       int32
 126457 	FpSelect    uintptr
 126458 	FpInsert    uintptr
 126459 	FpDelete    uintptr
 126460 	FpTmpInsert uintptr
 126461 	FnIdxCol    int32
 126462 	FaIdxCol    uintptr
 126463 	FzIdxSql    uintptr
 126464 	FpRbuUpdate uintptr
 126465 }
 126466 
 126467 type RbuObjIter = RbuObjIter1
 126468 type RbuState1 = struct {
 126469 	FeStage        int32
 126470 	FzTbl          uintptr
 126471 	FzDataTbl      uintptr
 126472 	FzIdx          uintptr
 126473 	FiWalCksum     I64
 126474 	FnRow          int32
 126475 	F__ccgo_pad1   [4]byte
 126476 	FnProgress     I64
 126477 	FiCookie       U32
 126478 	F__ccgo_pad2   [4]byte
 126479 	FiOalSz        I64
 126480 	FnPhaseOneStep I64
 126481 }
 126482 
 126483 type RbuState = RbuState1
 126484 type RbuSpan1 = struct {
 126485 	FzSpan uintptr
 126486 	FnSpan int32
 126487 }
 126488 
 126489 type RbuSpan = RbuSpan1
 126490 type rbu_vfs = struct {
 126491 	Fbase     Sqlite3_vfs
 126492 	FpRealVfs uintptr
 126493 	Fmutex    uintptr
 126494 	FpRbu     uintptr
 126495 	FpMain    uintptr
 126496 	FpMainRbu uintptr
 126497 }
 126498 
 126499 type Rbu_vfs = rbu_vfs
 126500 type rbu_file = struct {
 126501 	Fbase         Sqlite3_file
 126502 	FpReal        uintptr
 126503 	FpRbuVfs      uintptr
 126504 	FpRbu         uintptr
 126505 	Fsz           I64
 126506 	FopenFlags    int32
 126507 	FiCookie      U32
 126508 	FiWriteVer    U8
 126509 	FbNolock      U8
 126510 	F__ccgo_pad1  [2]byte
 126511 	FnShm         int32
 126512 	FapShm        uintptr
 126513 	FzDel         uintptr
 126514 	FzWal         uintptr
 126515 	FpWalFd       uintptr
 126516 	FpMainNext    uintptr
 126517 	FpMainRbuNext uintptr
 126518 }
 126519 
 126520 type Rbu_file = rbu_file
 126521 type RbuUpdateStmt1 = struct {
 126522 	FzMask   uintptr
 126523 	FpUpdate uintptr
 126524 	FpNext   uintptr
 126525 }
 126526 
 126527 type RbuUpdateStmt = RbuUpdateStmt1
 126528 
 126529 func rbuDeltaGetInt(tls *libc.TLS, pz uintptr, pLen uintptr) uint32 {
 126530 	var v uint32 = uint32(0)
 126531 	var c int32
 126532 	var z uintptr = *(*uintptr)(unsafe.Pointer(pz))
 126533 	var zStart uintptr = z
 126534 	for libc.AssignInt32(&c, int32(zValue[0x7f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))])) >= 0 {
 126535 		v = v<<6 + uint32(c)
 126536 	}
 126537 	z--
 126538 	*(*int32)(unsafe.Pointer(pLen)) -= (int32(z) - int32(zStart)) / 1
 126539 	*(*uintptr)(unsafe.Pointer(pz)) = z
 126540 	return v
 126541 }
 126542 
 126543 var zValue = [128]int8{
 126544 	int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1),
 126545 	int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1),
 126546 	int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1),
 126547 	int8(0), int8(1), int8(2), int8(3), int8(4), int8(5), int8(6), int8(7), int8(8), int8(9), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1), int8(-1),
 126548 	int8(-1), int8(10), int8(11), int8(12), int8(13), int8(14), int8(15), int8(16), int8(17), int8(18), int8(19), int8(20), int8(21), int8(22), int8(23), int8(24),
 126549 	int8(25), int8(26), int8(27), int8(28), int8(29), int8(30), int8(31), int8(32), int8(33), int8(34), int8(35), int8(-1), int8(-1), int8(-1), int8(-1), int8(36),
 126550 	int8(-1), int8(37), int8(38), int8(39), int8(40), int8(41), int8(42), int8(43), int8(44), int8(45), int8(46), int8(47), int8(48), int8(49), int8(50), int8(51),
 126551 	int8(52), int8(53), int8(54), int8(55), int8(56), int8(57), int8(58), int8(59), int8(60), int8(61), int8(62), int8(-1), int8(-1), int8(-1), int8(63), int8(-1),
 126552 }
 126553 
 126554 func rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, zDelta uintptr, lenDelta int32, zOut uintptr) int32 {
 126555 	bp := tls.Alloc(8)
 126556 	defer tls.Free(8)
 126557 	*(*uintptr)(unsafe.Pointer(bp)) = zDelta
 126558 	*(*int32)(unsafe.Pointer(bp + 4)) = lenDelta
 126559 
 126560 	var limit uint32
 126561 	var total uint32 = uint32(0)
 126562 
 126563 	limit = rbuDeltaGetInt(tls, bp, bp+4)
 126564 	if int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != '\n' {
 126565 		return -1
 126566 	}
 126567 	*(*uintptr)(unsafe.Pointer(bp))++
 126568 	*(*int32)(unsafe.Pointer(bp + 4))--
 126569 	for *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))) != 0 && *(*int32)(unsafe.Pointer(bp + 4)) > 0 {
 126570 		var cnt uint32
 126571 		var ofst uint32
 126572 		cnt = rbuDeltaGetInt(tls, bp, bp+4)
 126573 		switch int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) {
 126574 		case '@':
 126575 			{
 126576 				*(*uintptr)(unsafe.Pointer(bp))++
 126577 				*(*int32)(unsafe.Pointer(bp + 4))--
 126578 				ofst = rbuDeltaGetInt(tls, bp, bp+4)
 126579 				if *(*int32)(unsafe.Pointer(bp + 4)) > 0 && int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != ',' {
 126580 					return -1
 126581 				}
 126582 				*(*uintptr)(unsafe.Pointer(bp))++
 126583 				*(*int32)(unsafe.Pointer(bp + 4))--
 126584 				total = total + cnt
 126585 				if total > limit {
 126586 					return -1
 126587 				}
 126588 				if int32(ofst+cnt) > lenSrc {
 126589 					return -1
 126590 				}
 126591 				libc.Xmemcpy(tls, zOut, zSrc+uintptr(ofst), cnt)
 126592 				zOut += uintptr(cnt)
 126593 				break
 126594 
 126595 			}
 126596 		case ':':
 126597 			{
 126598 				*(*uintptr)(unsafe.Pointer(bp))++
 126599 				*(*int32)(unsafe.Pointer(bp + 4))--
 126600 				total = total + cnt
 126601 				if total > limit {
 126602 					return -1
 126603 				}
 126604 				if int32(cnt) > *(*int32)(unsafe.Pointer(bp + 4)) {
 126605 					return -1
 126606 				}
 126607 				libc.Xmemcpy(tls, zOut, *(*uintptr)(unsafe.Pointer(bp)), cnt)
 126608 				zOut += uintptr(cnt)
 126609 				*(*uintptr)(unsafe.Pointer(bp)) += uintptr(cnt)
 126610 				*(*int32)(unsafe.Pointer(bp + 4)) -= int32(cnt)
 126611 				break
 126612 
 126613 			}
 126614 		case ';':
 126615 			{
 126616 				*(*uintptr)(unsafe.Pointer(bp))++
 126617 				*(*int32)(unsafe.Pointer(bp + 4))--
 126618 				*(*uint8)(unsafe.Pointer(zOut)) = uint8(0)
 126619 				if total != limit {
 126620 					return -1
 126621 				}
 126622 				return int32(total)
 126623 
 126624 			}
 126625 		default:
 126626 			{
 126627 				return -1
 126628 
 126629 			}
 126630 		}
 126631 	}
 126632 
 126633 	return -1
 126634 }
 126635 
 126636 func rbuDeltaOutputSize(tls *libc.TLS, zDelta uintptr, lenDelta int32) int32 {
 126637 	bp := tls.Alloc(8)
 126638 	defer tls.Free(8)
 126639 	*(*uintptr)(unsafe.Pointer(bp)) = zDelta
 126640 	*(*int32)(unsafe.Pointer(bp + 4)) = lenDelta
 126641 
 126642 	var size int32
 126643 	size = int32(rbuDeltaGetInt(tls, bp, bp+4))
 126644 	if int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != '\n' {
 126645 		return -1
 126646 	}
 126647 	return size
 126648 }
 126649 
 126650 func rbuFossilDeltaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 126651 	var aDelta uintptr
 126652 	var nDelta int32
 126653 	var aOrig uintptr
 126654 	var nOrig int32
 126655 	var nOut int32
 126656 	var nOut2 int32
 126657 	var aOut uintptr
 126658 
 126659 	nOrig = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))
 126660 	aOrig = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv)))
 126661 	nDelta = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 126662 	aDelta = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4)))
 126663 
 126664 	nOut = rbuDeltaOutputSize(tls, aDelta, nDelta)
 126665 	if nOut < 0 {
 126666 		Xsqlite3_result_error(tls, context, ts+27912, -1)
 126667 		return
 126668 	}
 126669 
 126670 	aOut = Xsqlite3_malloc(tls, nOut+1)
 126671 	if aOut == uintptr(0) {
 126672 		Xsqlite3_result_error_nomem(tls, context)
 126673 	} else {
 126674 		nOut2 = rbuDeltaApply(tls, aOrig, nOrig, aDelta, nDelta, aOut)
 126675 		if nOut2 != nOut {
 126676 			Xsqlite3_free(tls, aOut)
 126677 			Xsqlite3_result_error(tls, context, ts+27912, -1)
 126678 		} else {
 126679 			Xsqlite3_result_blob(tls, context, aOut, nOut, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 126680 		}
 126681 	}
 126682 }
 126683 
 126684 func prepareAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) int32 {
 126685 	bp := tls.Alloc(8)
 126686 	defer tls.Free(8)
 126687 
 126688 	var rc int32 = Xsqlite3_prepare_v2(tls, db, zSql, -1, ppStmt, uintptr(0))
 126689 	if rc != SQLITE_OK {
 126690 		*(*uintptr)(unsafe.Pointer(pzErrmsg)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, db)))
 126691 		*(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0)
 126692 	}
 126693 	return rc
 126694 }
 126695 
 126696 func resetAndCollectError(tls *libc.TLS, pStmt uintptr, pzErrmsg uintptr) int32 {
 126697 	bp := tls.Alloc(8)
 126698 	defer tls.Free(8)
 126699 
 126700 	var rc int32 = Xsqlite3_reset(tls, pStmt)
 126701 	if rc != SQLITE_OK {
 126702 		*(*uintptr)(unsafe.Pointer(pzErrmsg)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, Xsqlite3_db_handle(tls, pStmt))))
 126703 	}
 126704 	return rc
 126705 }
 126706 
 126707 func prepareFreeAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) int32 {
 126708 	var rc int32
 126709 
 126710 	if zSql == uintptr(0) {
 126711 		rc = SQLITE_NOMEM
 126712 		*(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0)
 126713 	} else {
 126714 		rc = prepareAndCollectError(tls, db, ppStmt, pzErrmsg, zSql)
 126715 		Xsqlite3_free(tls, zSql)
 126716 	}
 126717 	return rc
 126718 }
 126719 
 126720 func rbuObjIterFreeCols(tls *libc.TLS, pIter uintptr) {
 126721 	var i int32
 126722 	for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 126723 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)))
 126724 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(i)*4)))
 126725 	}
 126726 	Xsqlite3_free(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol)
 126727 	(*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol = uintptr(0)
 126728 	(*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType = uintptr(0)
 126729 	(*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder = uintptr(0)
 126730 	(*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk = uintptr(0)
 126731 	(*RbuObjIter)(unsafe.Pointer(pIter)).FabNotNull = uintptr(0)
 126732 	(*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol = 0
 126733 	(*RbuObjIter)(unsafe.Pointer(pIter)).FeType = 0
 126734 }
 126735 
 126736 func rbuObjIterClearStatements(tls *libc.TLS, pIter uintptr) {
 126737 	var pUp uintptr
 126738 
 126739 	Xsqlite3_finalize(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect)
 126740 	Xsqlite3_finalize(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpInsert)
 126741 	Xsqlite3_finalize(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpDelete)
 126742 	Xsqlite3_finalize(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTmpInsert)
 126743 	pUp = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate
 126744 	for pUp != 0 {
 126745 		var pTmp uintptr = (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext
 126746 		Xsqlite3_finalize(tls, (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate)
 126747 		Xsqlite3_free(tls, pUp)
 126748 		pUp = pTmp
 126749 	}
 126750 	Xsqlite3_free(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol)
 126751 	Xsqlite3_free(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql)
 126752 
 126753 	(*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect = uintptr(0)
 126754 	(*RbuObjIter)(unsafe.Pointer(pIter)).FpInsert = uintptr(0)
 126755 	(*RbuObjIter)(unsafe.Pointer(pIter)).FpDelete = uintptr(0)
 126756 	(*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = uintptr(0)
 126757 	(*RbuObjIter)(unsafe.Pointer(pIter)).FpTmpInsert = uintptr(0)
 126758 	(*RbuObjIter)(unsafe.Pointer(pIter)).FnCol = 0
 126759 	(*RbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = 0
 126760 	(*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = uintptr(0)
 126761 	(*RbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = uintptr(0)
 126762 }
 126763 
 126764 func rbuObjIterFinalize(tls *libc.TLS, pIter uintptr) {
 126765 	rbuObjIterClearStatements(tls, pIter)
 126766 	Xsqlite3_finalize(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter)
 126767 	Xsqlite3_finalize(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter)
 126768 	rbuObjIterFreeCols(tls, pIter)
 126769 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(RbuObjIter{})))
 126770 }
 126771 
 126772 func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 126773 	var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 126774 	if rc == SQLITE_OK {
 126775 		rbuObjIterClearStatements(tls, pIter)
 126776 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) {
 126777 			rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 126778 				ts+27933, uintptr(0), uintptr(0), p+36)
 126779 		}
 126780 
 126781 		if rc == SQLITE_OK {
 126782 			if (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 {
 126783 				rbuObjIterFreeCols(tls, pIter)
 126784 				(*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 0
 126785 				rc = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter)
 126786 				if rc != SQLITE_ROW {
 126787 					rc = resetAndCollectError(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, p+36)
 126788 					(*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl = uintptr(0)
 126789 				} else {
 126790 					(*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 0)
 126791 					(*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 1)
 126792 					if (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl != 0 && (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 {
 126793 						rc = SQLITE_OK
 126794 					} else {
 126795 						rc = SQLITE_NOMEM
 126796 					}
 126797 				}
 126798 			} else {
 126799 				if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) {
 126800 					var pIdx uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter
 126801 					rc = Xsqlite3_bind_text(tls, pIdx, 1, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, -1, uintptr(0))
 126802 				}
 126803 				if rc == SQLITE_OK {
 126804 					rc = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter)
 126805 					if rc != SQLITE_ROW {
 126806 						rc = resetAndCollectError(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, p+36)
 126807 						(*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 1
 126808 						(*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx = uintptr(0)
 126809 					} else {
 126810 						(*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 0)
 126811 						(*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum = Xsqlite3_column_int(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 1)
 126812 						(*RbuObjIter)(unsafe.Pointer(pIter)).FbUnique = Xsqlite3_column_int(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 2)
 126813 						if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx != 0 {
 126814 							rc = SQLITE_OK
 126815 						} else {
 126816 							rc = SQLITE_NOMEM
 126817 						}
 126818 					}
 126819 				}
 126820 			}
 126821 		}
 126822 	}
 126823 
 126824 	if rc != SQLITE_OK {
 126825 		rbuObjIterFinalize(tls, pIter)
 126826 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 126827 	}
 126828 	return rc
 126829 }
 126830 
 126831 func rbuTargetNameFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) {
 126832 	var p uintptr = Xsqlite3_user_data(tls, pCtx)
 126833 	var zIn uintptr
 126834 
 126835 	zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))
 126836 	if zIn != 0 {
 126837 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 126838 			if argc == 1 || 0 == Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))) {
 126839 				Xsqlite3_result_text(tls, pCtx, zIn, -1, uintptr(0))
 126840 			}
 126841 		} else {
 126842 			if libc.Xstrlen(tls, zIn) > Size_t(4) && libc.Xmemcmp(tls, ts+25103, zIn, uint32(4)) == 0 {
 126843 				var i int32
 126844 				for i = 4; int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) >= '0' && int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) <= '9'; i++ {
 126845 				}
 126846 				if int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) == '_' && *(*uint8)(unsafe.Pointer(zIn + uintptr(i+1))) != 0 {
 126847 					Xsqlite3_result_text(tls, pCtx, zIn+uintptr(i+1), -1, uintptr(0))
 126848 				}
 126849 			}
 126850 		}
 126851 	}
 126852 }
 126853 
 126854 func rbuObjIterFirst(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 126855 	bp := tls.Alloc(8)
 126856 	defer tls.Free(8)
 126857 
 126858 	var rc int32
 126859 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(RbuObjIter{})))
 126860 
 126861 	rc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter, p+36,
 126862 		Xsqlite3_mprintf(tls,
 126863 			ts+28104, libc.VaList(bp, func() uintptr {
 126864 				if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 126865 					return ts + 28254
 126866 				}
 126867 				return ts + 1554
 126868 			}())))
 126869 
 126870 	if rc == SQLITE_OK {
 126871 		rc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+4, p+36,
 126872 			ts+28295)
 126873 	}
 126874 
 126875 	(*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 1
 126876 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 126877 	return rbuObjIterNext(tls, p, pIter)
 126878 }
 126879 
 126880 func rbuMPrintf(tls *libc.TLS, p uintptr, zFmt uintptr, va uintptr) uintptr {
 126881 	var zSql uintptr = uintptr(0)
 126882 	var ap Va_list
 126883 	_ = ap
 126884 	ap = va
 126885 	zSql = Xsqlite3_vmprintf(tls, zFmt, ap)
 126886 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 126887 		if zSql == uintptr(0) {
 126888 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 126889 		}
 126890 	} else {
 126891 		Xsqlite3_free(tls, zSql)
 126892 		zSql = uintptr(0)
 126893 	}
 126894 	_ = ap
 126895 	return zSql
 126896 }
 126897 
 126898 func rbuMPrintfExec(tls *libc.TLS, p uintptr, db uintptr, zFmt uintptr, va uintptr) int32 {
 126899 	var ap Va_list
 126900 	_ = ap
 126901 	var zSql uintptr
 126902 	ap = va
 126903 	zSql = Xsqlite3_vmprintf(tls, zFmt, ap)
 126904 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 126905 		if zSql == uintptr(0) {
 126906 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 126907 		} else {
 126908 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), p+36)
 126909 		}
 126910 	}
 126911 	Xsqlite3_free(tls, zSql)
 126912 	_ = ap
 126913 	return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 126914 }
 126915 
 126916 func rbuMalloc(tls *libc.TLS, p uintptr, nByte Sqlite3_int64) uintptr {
 126917 	var pRet uintptr = uintptr(0)
 126918 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 126919 		pRet = Xsqlite3_malloc64(tls, uint64(nByte))
 126920 		if pRet == uintptr(0) {
 126921 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 126922 		} else {
 126923 			libc.Xmemset(tls, pRet, 0, uint32(nByte))
 126924 		}
 126925 	}
 126926 	return pRet
 126927 }
 126928 
 126929 func rbuAllocateIterArrays(tls *libc.TLS, p uintptr, pIter uintptr, nCol int32) {
 126930 	var nByte Sqlite3_int64 = Sqlite3_int64((uint32(2)*uint32(unsafe.Sizeof(uintptr(0))) + uint32(unsafe.Sizeof(int32(0))) + uint32(3)*uint32(unsafe.Sizeof(U8(0)))) * uint32(nCol))
 126931 	var azNew uintptr
 126932 
 126933 	azNew = rbuMalloc(tls, p, nByte)
 126934 	if azNew != 0 {
 126935 		(*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol = azNew
 126936 		(*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType = azNew + uintptr(nCol)*4
 126937 		(*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder = (*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(nCol)*4
 126938 		(*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk = (*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(nCol)*4
 126939 		(*RbuObjIter)(unsafe.Pointer(pIter)).FabNotNull = (*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(nCol)
 126940 		(*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed = (*RbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(nCol)
 126941 	}
 126942 }
 126943 
 126944 func rbuStrndup(tls *libc.TLS, zStr uintptr, pRc uintptr) uintptr {
 126945 	var zRet uintptr = uintptr(0)
 126946 
 126947 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 126948 		if zStr != 0 {
 126949 			var nCopy Size_t = libc.Xstrlen(tls, zStr) + Size_t(1)
 126950 			zRet = Xsqlite3_malloc64(tls, uint64(nCopy))
 126951 			if zRet != 0 {
 126952 				libc.Xmemcpy(tls, zRet, zStr, nCopy)
 126953 			} else {
 126954 				*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 126955 			}
 126956 		}
 126957 	}
 126958 
 126959 	return zRet
 126960 }
 126961 
 126962 func rbuFinalize(tls *libc.TLS, p uintptr, pStmt uintptr) {
 126963 	bp := tls.Alloc(8)
 126964 	defer tls.Free(8)
 126965 
 126966 	var db uintptr = Xsqlite3_db_handle(tls, pStmt)
 126967 	var rc int32 = Xsqlite3_finalize(tls, pStmt)
 126968 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && rc != SQLITE_OK {
 126969 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 126970 		(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, db)))
 126971 	}
 126972 }
 126973 
 126974 func rbuTableType(tls *libc.TLS, p uintptr, zTab uintptr, peType uintptr, piTnum uintptr, piPk uintptr) {
 126975 	bp := tls.Alloc(48)
 126976 	defer tls.Free(48)
 126977 
 126978 	var zOrig uintptr
 126979 	var zIdx uintptr
 126980 	var i uint32
 126981 	*(*[4]uintptr)(unsafe.Pointer(bp + 32)) = [4]uintptr{uintptr(0), uintptr(0), uintptr(0), uintptr(0)}
 126982 
 126983 	*(*int32)(unsafe.Pointer(peType)) = RBU_PK_NOTABLE
 126984 	*(*int32)(unsafe.Pointer(piPk)) = 0
 126985 
 126986 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+32, p+36,
 126987 		Xsqlite3_mprintf(tls,
 126988 			ts+28420, libc.VaList(bp, zTab)))
 126989 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK || Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32))) != SQLITE_ROW) {
 126990 		goto __1
 126991 	}
 126992 
 126993 	goto rbuTableType_end
 126994 __1:
 126995 	;
 126996 	if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), 0) != 0) {
 126997 		goto __2
 126998 	}
 126999 	*(*int32)(unsafe.Pointer(peType)) = RBU_PK_VTAB
 127000 	goto rbuTableType_end
 127001 __2:
 127002 	;
 127003 	*(*int32)(unsafe.Pointer(piTnum)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), 1)
 127004 
 127005 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+32+1*4, p+36,
 127006 		Xsqlite3_mprintf(tls, ts+28539, libc.VaList(bp+8, zTab)))
 127007 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) {
 127008 		goto __3
 127009 	}
 127010 	goto rbuTableType_end
 127011 __3:
 127012 	;
 127013 __4:
 127014 	if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 1*4))) == SQLITE_ROW) {
 127015 		goto __5
 127016 	}
 127017 	zOrig = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 1*4)), 3)
 127018 	zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 1*4)), 1)
 127019 	if !(zOrig != 0 && zIdx != 0 && int32(*(*U8)(unsafe.Pointer(zOrig))) == 'p') {
 127020 		goto __6
 127021 	}
 127022 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+32+2*4, p+36,
 127023 		Xsqlite3_mprintf(tls,
 127024 			ts+28560, libc.VaList(bp+16, zIdx)))
 127025 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 127026 		goto __7
 127027 	}
 127028 	if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 2*4))) == SQLITE_ROW) {
 127029 		goto __8
 127030 	}
 127031 	*(*int32)(unsafe.Pointer(piPk)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 2*4)), 0)
 127032 	*(*int32)(unsafe.Pointer(peType)) = RBU_PK_EXTERNAL
 127033 	goto __9
 127034 __8:
 127035 	*(*int32)(unsafe.Pointer(peType)) = RBU_PK_WITHOUT_ROWID
 127036 __9:
 127037 	;
 127038 __7:
 127039 	;
 127040 	goto rbuTableType_end
 127041 __6:
 127042 	;
 127043 	goto __4
 127044 __5:
 127045 	;
 127046 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+32+3*4, p+36,
 127047 		Xsqlite3_mprintf(tls, ts+28611, libc.VaList(bp+24, zTab)))
 127048 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 127049 		goto __10
 127050 	}
 127051 __11:
 127052 	if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 3*4))) == SQLITE_ROW) {
 127053 		goto __12
 127054 	}
 127055 	if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 + 3*4)), 5) > 0) {
 127056 		goto __13
 127057 	}
 127058 	*(*int32)(unsafe.Pointer(peType)) = RBU_PK_IPK
 127059 	goto rbuTableType_end
 127060 __13:
 127061 	;
 127062 	goto __11
 127063 __12:
 127064 	;
 127065 	*(*int32)(unsafe.Pointer(peType)) = RBU_PK_NONE
 127066 __10:
 127067 	;
 127068 rbuTableType_end:
 127069 	i = uint32(0)
 127070 __14:
 127071 	if !(i < uint32(unsafe.Sizeof([4]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))) {
 127072 		goto __16
 127073 	}
 127074 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 32 + uintptr(i)*4)))
 127075 	goto __15
 127076 __15:
 127077 	i++
 127078 	goto __14
 127079 	goto __16
 127080 __16:
 127081 }
 127082 
 127083 func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) {
 127084 	bp := tls.Alloc(24)
 127085 	defer tls.Free(24)
 127086 
 127087 	*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 127088 	var bIndex int32 = 0
 127089 
 127090 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127091 		libc.Xmemcpy(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, (*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk, uint32(unsafe.Sizeof(U8(0)))*uint32((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol))
 127092 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+16, p+36,
 127093 			Xsqlite3_mprintf(tls, ts+28632, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl)))
 127094 	}
 127095 
 127096 	(*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex = 0
 127097 	for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) {
 127098 		var zIdx uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 1)
 127099 		var bPartial int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 4)
 127100 		*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 127101 		if zIdx == uintptr(0) {
 127102 			break
 127103 		}
 127104 		if bPartial != 0 {
 127105 			libc.Xmemset(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, 0x01, uint32(unsafe.Sizeof(U8(0)))*uint32((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol))
 127106 		}
 127107 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+20, p+36,
 127108 			Xsqlite3_mprintf(tls, ts+28660, libc.VaList(bp+8, zIdx)))
 127109 		for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 20))) {
 127110 			var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 20)), 1)
 127111 			if iCid >= 0 {
 127112 				*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(iCid))) = U8(1)
 127113 			}
 127114 			if iCid == -2 {
 127115 				libc.Xmemset(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, 0x01, uint32(unsafe.Sizeof(U8(0)))*uint32((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol))
 127116 			}
 127117 		}
 127118 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 20)))
 127119 		bIndex = 1
 127120 		(*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex++
 127121 	}
 127122 
 127123 	if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID {
 127124 		(*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex--
 127125 	}
 127126 
 127127 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 16)))
 127128 	if bIndex == 0 {
 127129 		(*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed = uintptr(0)
 127130 	}
 127131 }
 127132 
 127133 func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 127134 	bp := tls.Alloc(64)
 127135 	defer tls.Free(64)
 127136 
 127137 	if (*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol == uintptr(0) {
 127138 		*(*uintptr)(unsafe.Pointer(bp + 60)) = uintptr(0)
 127139 		var nCol int32 = 0
 127140 		var i int32
 127141 		var bRbuRowid int32 = 0
 127142 		var iOrder int32 = 0
 127143 		*(*int32)(unsafe.Pointer(bp + 56)) = 0
 127144 
 127145 		rbuTableType(tls, p, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, pIter+36, bp+56, pIter+60)
 127146 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NOTABLE {
 127147 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 127148 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+19536, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))
 127149 		}
 127150 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 {
 127151 			return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 127152 		}
 127153 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) {
 127154 			(*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum = *(*int32)(unsafe.Pointer(bp + 56))
 127155 		}
 127156 
 127157 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+60, p+36,
 127158 			Xsqlite3_mprintf(tls, ts+28689, libc.VaList(bp+8, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl)))
 127159 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127160 			nCol = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 60)))
 127161 			rbuAllocateIterArrays(tls, p, pIter, nCol)
 127162 		}
 127163 		for i = 0; (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && i < nCol; i++ {
 127164 			var zName uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), i)
 127165 			if Xsqlite3_strnicmp(tls, ts+28708, zName, 4) != 0 {
 127166 				var zCopy uintptr = rbuStrndup(tls, zName, p+32)
 127167 				*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)*4)) = (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol
 127168 				*(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(libc.PostIncInt32(&(*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol, 1))*4)) = zCopy
 127169 			} else if 0 == Xsqlite3_stricmp(tls, ts+28713, zName) {
 127170 				bRbuRowid = 1
 127171 			}
 127172 		}
 127173 		Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 60)))
 127174 		*(*uintptr)(unsafe.Pointer(bp + 60)) = uintptr(0)
 127175 
 127176 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK &&
 127177 			libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 &&
 127178 			bRbuRowid != libc.Bool32((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) {
 127179 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 127180 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls,
 127181 				ts+28723, libc.VaList(bp+16, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl,
 127182 					func() uintptr {
 127183 						if bRbuRowid != 0 {
 127184 							return ts + 28752
 127185 						}
 127186 						return ts + 28765
 127187 					}()))
 127188 		}
 127189 
 127190 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127191 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+60, p+36,
 127192 				Xsqlite3_mprintf(tls, ts+28774, libc.VaList(bp+32, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl)))
 127193 		}
 127194 		for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 60))) {
 127195 			var zName uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 1)
 127196 			if zName == uintptr(0) {
 127197 				break
 127198 			}
 127199 			for i = iOrder; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127200 				if 0 == libc.Xstrcmp(tls, zName, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))) {
 127201 					break
 127202 				}
 127203 			}
 127204 			if i == (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol {
 127205 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 127206 				(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+28796,
 127207 					libc.VaList(bp+40, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zName))
 127208 			} else {
 127209 				var iPk int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 5)
 127210 				var bNotNull int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 3)
 127211 				var zType uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 2)
 127212 
 127213 				if i != iOrder {
 127214 					{
 127215 						var t int32 = *(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))
 127216 						*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)) = *(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(iOrder)*4))
 127217 						*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(iOrder)*4)) = t
 127218 					}
 127219 
 127220 					{
 127221 						var t uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127222 						*(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iOrder)*4))
 127223 						*(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iOrder)*4)) = t
 127224 					}
 127225 
 127226 				}
 127227 
 127228 				*(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iOrder)*4)) = rbuStrndup(tls, zType, p+32)
 127229 
 127230 				*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iOrder))) = U8(iPk)
 127231 				*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(iOrder))) = U8(libc.Bool32(U8(bNotNull) != 0 || iPk != 0))
 127232 				iOrder++
 127233 			}
 127234 		}
 127235 
 127236 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 60)))
 127237 		rbuObjIterCacheIndexedCols(tls, p, pIter)
 127238 
 127239 	}
 127240 
 127241 	return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 127242 }
 127243 
 127244 func rbuObjIterGetCollist(tls *libc.TLS, p uintptr, pIter uintptr) uintptr {
 127245 	bp := tls.Alloc(24)
 127246 	defer tls.Free(24)
 127247 
 127248 	var zList uintptr = uintptr(0)
 127249 	var zSep uintptr = ts + 1554
 127250 	var i int32
 127251 	for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127252 		var z uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127253 		zList = rbuMPrintf(tls, p, ts+28823, libc.VaList(bp, zList, zSep, z))
 127254 		zSep = ts + 14614
 127255 	}
 127256 	return zList
 127257 }
 127258 
 127259 func rbuObjIterGetPkList(tls *libc.TLS, p uintptr, pIter uintptr, zPre uintptr, zSeparator uintptr, zPost uintptr) uintptr {
 127260 	bp := tls.Alloc(40)
 127261 	defer tls.Free(40)
 127262 
 127263 	var iPk int32 = 1
 127264 	var zRet uintptr = uintptr(0)
 127265 	var zSep uintptr = ts + 1554
 127266 	for 1 != 0 {
 127267 		var i int32
 127268 		for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127269 			if int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == iPk {
 127270 				var zCol uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127271 				zRet = rbuMPrintf(tls, p, ts+28832, libc.VaList(bp, zRet, zSep, zPre, zCol, zPost))
 127272 				zSep = zSeparator
 127273 				break
 127274 			}
 127275 		}
 127276 		if i == (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol {
 127277 			break
 127278 		}
 127279 		iPk++
 127280 	}
 127281 	return zRet
 127282 }
 127283 
 127284 func rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, zWrite uintptr) uintptr {
 127285 	bp := tls.Alloc(76)
 127286 	defer tls.Free(76)
 127287 
 127288 	*(*uintptr)(unsafe.Pointer(bp + 72)) = uintptr(0)
 127289 	var zRet uintptr = uintptr(0)
 127290 	if bRowid != 0 {
 127291 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+72, p+36,
 127292 			Xsqlite3_mprintf(tls,
 127293 				ts+28845, libc.VaList(bp, zWrite, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl)))
 127294 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72))) {
 127295 			var iMax Sqlite3_int64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 72)), 0)
 127296 			zRet = rbuMPrintf(tls, p, ts+28877, libc.VaList(bp+16, iMax))
 127297 		}
 127298 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 72)))
 127299 	} else {
 127300 		var zOrder uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+1554, ts+14614, ts+28900)
 127301 		var zSelect uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+28906, ts+28913, ts+4957)
 127302 		var zList uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+1554, ts+14614, ts+1554)
 127303 
 127304 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127305 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+72, p+36,
 127306 				Xsqlite3_mprintf(tls,
 127307 					ts+28921,
 127308 					libc.VaList(bp+24, zSelect, zWrite, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder)))
 127309 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72))) {
 127310 				var zVal uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 72)), 0)
 127311 				zRet = rbuMPrintf(tls, p, ts+28963, libc.VaList(bp+56, zList, zVal))
 127312 			}
 127313 			rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 72)))
 127314 		}
 127315 
 127316 		Xsqlite3_free(tls, zOrder)
 127317 		Xsqlite3_free(tls, zSelect)
 127318 		Xsqlite3_free(tls, zList)
 127319 	}
 127320 	return zRet
 127321 }
 127322 
 127323 func rbuVacuumIndexStart(tls *libc.TLS, p uintptr, pIter uintptr) uintptr {
 127324 	bp := tls.Alloc(184)
 127325 	defer tls.Free(184)
 127326 
 127327 	var zOrder uintptr
 127328 	var zLhs uintptr
 127329 	var zSelect uintptr
 127330 	var zVector uintptr
 127331 	var zRet uintptr
 127332 	var bFailed int32
 127333 	var zSep uintptr
 127334 	var iCol int32
 127335 
 127336 	var i int32
 127337 	var iCid int32
 127338 	var zCollate uintptr
 127339 	var zCol uintptr
 127340 	var zQuoted uintptr
 127341 
 127342 	zOrder = uintptr(0)
 127343 	zLhs = uintptr(0)
 127344 	zSelect = uintptr(0)
 127345 	zVector = uintptr(0)
 127346 	zRet = uintptr(0)
 127347 	bFailed = 0
 127348 	zSep = ts + 1554
 127349 	iCol = 0
 127350 	*(*uintptr)(unsafe.Pointer(bp + 176)) = uintptr(0)
 127351 
 127352 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+176, p+36,
 127353 		Xsqlite3_mprintf(tls, ts+28660, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx)))
 127354 __1:
 127355 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176)))) {
 127356 		goto __2
 127357 	}
 127358 	iCid = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176)), 1)
 127359 	zCollate = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 176)), 4)
 127360 	if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176)), 3) != 0) {
 127361 		goto __3
 127362 	}
 127363 	bFailed = 1
 127364 	goto __2
 127365 __3:
 127366 	;
 127367 	if !(iCid < 0) {
 127368 		goto __4
 127369 	}
 127370 	if !((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK) {
 127371 		goto __6
 127372 	}
 127373 	i = 0
 127374 __8:
 127375 	if !(int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) {
 127376 		goto __10
 127377 	}
 127378 	goto __9
 127379 __9:
 127380 	i++
 127381 	goto __8
 127382 	goto __10
 127383 __10:
 127384 	;
 127385 	zCol = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127386 	goto __7
 127387 __6:
 127388 	zCol = ts + 28983
 127389 __7:
 127390 	;
 127391 	goto __5
 127392 __4:
 127393 	zCol = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*4))
 127394 __5:
 127395 	;
 127396 	zLhs = rbuMPrintf(tls, p, ts+28991,
 127397 		libc.VaList(bp+8, zLhs, zSep, zCol, zCollate))
 127398 	zOrder = rbuMPrintf(tls, p, ts+29012,
 127399 		libc.VaList(bp+40, zOrder, zSep, iCol, zCol, zCollate))
 127400 	zSelect = rbuMPrintf(tls, p, ts+29048,
 127401 		libc.VaList(bp+80, zSelect, zSep, iCol, zCol))
 127402 	zSep = ts + 14614
 127403 	iCol++
 127404 	goto __1
 127405 __2:
 127406 	;
 127407 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 176)))
 127408 	if !(bFailed != 0) {
 127409 		goto __11
 127410 	}
 127411 	goto index_start_out
 127412 __11:
 127413 	;
 127414 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 127415 		goto __12
 127416 	}
 127417 	*(*uintptr)(unsafe.Pointer(bp + 180)) = uintptr(0)
 127418 
 127419 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+180, p+36,
 127420 		Xsqlite3_mprintf(tls, ts+29075,
 127421 			libc.VaList(bp+112, zSelect, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder)))
 127422 	if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 180)))) {
 127423 		goto __13
 127424 	}
 127425 	zSep = ts + 1554
 127426 	iCol = 0
 127427 __14:
 127428 	if !(iCol < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol) {
 127429 		goto __16
 127430 	}
 127431 	zQuoted = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 180)), iCol)
 127432 	if !(zQuoted == uintptr(0)) {
 127433 		goto __17
 127434 	}
 127435 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 127436 	goto __18
 127437 __17:
 127438 	if !(int32(*(*uint8)(unsafe.Pointer(zQuoted))) == 'N') {
 127439 		goto __19
 127440 	}
 127441 	bFailed = 1
 127442 	goto __16
 127443 __19:
 127444 	;
 127445 __18:
 127446 	;
 127447 	zVector = rbuMPrintf(tls, p, ts+29123, libc.VaList(bp+136, zVector, zSep, zQuoted))
 127448 	zSep = ts + 14614
 127449 	goto __15
 127450 __15:
 127451 	iCol++
 127452 	goto __14
 127453 	goto __16
 127454 __16:
 127455 	;
 127456 	if !!(bFailed != 0) {
 127457 		goto __20
 127458 	}
 127459 	zRet = rbuMPrintf(tls, p, ts+29130, libc.VaList(bp+160, zLhs, zVector))
 127460 __20:
 127461 	;
 127462 __13:
 127463 	;
 127464 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 180)))
 127465 __12:
 127466 	;
 127467 index_start_out:
 127468 	Xsqlite3_free(tls, zOrder)
 127469 	Xsqlite3_free(tls, zSelect)
 127470 	Xsqlite3_free(tls, zVector)
 127471 	Xsqlite3_free(tls, zLhs)
 127472 	return zRet
 127473 }
 127474 
 127475 func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterCols uintptr, pzImposterPk uintptr, pzWhere uintptr, pnBind uintptr) uintptr {
 127476 	bp := tls.Alloc(204)
 127477 	defer tls.Free(204)
 127478 
 127479 	var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 127480 	var rc2 int32
 127481 	var zRet uintptr = uintptr(0)
 127482 	var zImpCols uintptr = uintptr(0)
 127483 	var zImpPK uintptr = uintptr(0)
 127484 	var zWhere uintptr = uintptr(0)
 127485 	var nBind int32 = 0
 127486 	var zCom uintptr = ts + 1554
 127487 	var zAnd uintptr = ts + 1554
 127488 	*(*uintptr)(unsafe.Pointer(bp + 200)) = uintptr(0)
 127489 
 127490 	if rc == SQLITE_OK {
 127491 		rc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+200, p+36,
 127492 			Xsqlite3_mprintf(tls, ts+28660, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx)))
 127493 	}
 127494 
 127495 	for rc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 200))) {
 127496 		var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200)), 1)
 127497 		var bDesc int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200)), 3)
 127498 		var zCollate uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 200)), 4)
 127499 		var zCol uintptr = uintptr(0)
 127500 		var zType uintptr
 127501 
 127502 		if iCid == -2 {
 127503 			var iSeq int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200)), 0)
 127504 			zRet = Xsqlite3_mprintf(tls, ts+29142, libc.VaList(bp+8, zRet, zCom,
 127505 				(*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol+uintptr(iSeq)*8)).FnSpan, (*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol+uintptr(iSeq)*8)).FzSpan, zCollate))
 127506 			zType = ts + 1554
 127507 		} else {
 127508 			if iCid < 0 {
 127509 				if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK {
 127510 					var i int32
 127511 					for i = 0; int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0; i++ {
 127512 					}
 127513 
 127514 					zCol = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127515 				} else if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 127516 					zCol = ts + 28983
 127517 				} else {
 127518 					zCol = ts + 28713
 127519 				}
 127520 				zType = ts + 1119
 127521 			} else {
 127522 				zCol = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCid)*4))
 127523 				zType = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCid)*4))
 127524 			}
 127525 			zRet = Xsqlite3_mprintf(tls, ts+29164, libc.VaList(bp+48, zRet, zCom, zCol, zCollate))
 127526 		}
 127527 
 127528 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FbUnique == 0 || Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200)), 5) != 0 {
 127529 			var zOrder uintptr = func() uintptr {
 127530 				if bDesc != 0 {
 127531 					return ts + 28900
 127532 				}
 127533 				return ts + 1554
 127534 			}()
 127535 			zImpPK = Xsqlite3_mprintf(tls, ts+29184,
 127536 				libc.VaList(bp+80, zImpPK, zCom, nBind, zCol, zOrder))
 127537 		}
 127538 		zImpCols = Xsqlite3_mprintf(tls, ts+29205,
 127539 			libc.VaList(bp+120, zImpCols, zCom, nBind, zCol, zType, zCollate))
 127540 		zWhere = Xsqlite3_mprintf(tls,
 127541 			ts+29238, libc.VaList(bp+168, zWhere, zAnd, nBind, zCol))
 127542 		if zRet == uintptr(0) || zImpPK == uintptr(0) || zImpCols == uintptr(0) || zWhere == uintptr(0) {
 127543 			rc = SQLITE_NOMEM
 127544 		}
 127545 		zCom = ts + 14614
 127546 		zAnd = ts + 21572
 127547 		nBind++
 127548 	}
 127549 
 127550 	rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 200)))
 127551 	if rc == SQLITE_OK {
 127552 		rc = rc2
 127553 	}
 127554 
 127555 	if rc != SQLITE_OK {
 127556 		Xsqlite3_free(tls, zRet)
 127557 		Xsqlite3_free(tls, zImpCols)
 127558 		Xsqlite3_free(tls, zImpPK)
 127559 		Xsqlite3_free(tls, zWhere)
 127560 		zRet = uintptr(0)
 127561 		zImpCols = uintptr(0)
 127562 		zImpPK = uintptr(0)
 127563 		zWhere = uintptr(0)
 127564 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 127565 	}
 127566 
 127567 	*(*uintptr)(unsafe.Pointer(pzImposterCols)) = zImpCols
 127568 	*(*uintptr)(unsafe.Pointer(pzImposterPk)) = zImpPK
 127569 	*(*uintptr)(unsafe.Pointer(pzWhere)) = zWhere
 127570 	*(*int32)(unsafe.Pointer(pnBind)) = nBind
 127571 	return zRet
 127572 }
 127573 
 127574 func rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) uintptr {
 127575 	bp := tls.Alloc(64)
 127576 	defer tls.Free(64)
 127577 
 127578 	var zList uintptr = uintptr(0)
 127579 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 {
 127580 		var zS uintptr = ts + 1554
 127581 		var i int32
 127582 		for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127583 			if *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(i))) != 0 {
 127584 				var zCol uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127585 				zList = Xsqlite3_mprintf(tls, ts+29262, libc.VaList(bp, zList, zS, zObj, zCol))
 127586 			} else {
 127587 				zList = Xsqlite3_mprintf(tls, ts+29274, libc.VaList(bp+32, zList, zS))
 127588 			}
 127589 			zS = ts + 14614
 127590 			if zList == uintptr(0) {
 127591 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 127592 				break
 127593 			}
 127594 		}
 127595 
 127596 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE {
 127597 			zList = rbuMPrintf(tls, p, ts+29283, libc.VaList(bp+48, zList, zObj))
 127598 		}
 127599 	}
 127600 	return zList
 127601 }
 127602 
 127603 func rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr {
 127604 	bp := tls.Alloc(80)
 127605 	defer tls.Free(80)
 127606 
 127607 	var zList uintptr = uintptr(0)
 127608 	if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE {
 127609 		zList = rbuMPrintf(tls, p, ts+29298, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+1))
 127610 	} else if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL {
 127611 		var zSep uintptr = ts + 1554
 127612 		var i int32
 127613 		for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127614 			if *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 {
 127615 				zList = rbuMPrintf(tls, p, ts+29312, libc.VaList(bp+8, zList, zSep, i, i+1))
 127616 				zSep = ts + 21572
 127617 			}
 127618 		}
 127619 		zList = rbuMPrintf(tls, p,
 127620 			ts+29324, libc.VaList(bp+40, zList))
 127621 
 127622 	} else {
 127623 		var zSep uintptr = ts + 1554
 127624 		var i int32
 127625 		for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127626 			if *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 {
 127627 				var zCol uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4))
 127628 				zList = rbuMPrintf(tls, p, ts+29374, libc.VaList(bp+48, zList, zSep, zCol, i+1))
 127629 				zSep = ts + 21572
 127630 			}
 127631 		}
 127632 	}
 127633 	return zList
 127634 }
 127635 
 127636 func rbuBadControlError(tls *libc.TLS, p uintptr) {
 127637 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 127638 	(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+29387, 0)
 127639 }
 127640 
 127641 func rbuObjIterGetSetlist(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr) uintptr {
 127642 	bp := tls.Alloc(112)
 127643 	defer tls.Free(112)
 127644 
 127645 	var zList uintptr = uintptr(0)
 127646 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127647 		var i int32
 127648 
 127649 		if int32(libc.Xstrlen(tls, zMask)) != (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol {
 127650 			rbuBadControlError(tls, p)
 127651 		} else {
 127652 			var zSep uintptr = ts + 1554
 127653 			for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ {
 127654 				var c uint8 = *(*uint8)(unsafe.Pointer(zMask + uintptr(*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)))))
 127655 				if int32(c) == 'x' {
 127656 					zList = rbuMPrintf(tls, p, ts+29374,
 127657 						libc.VaList(bp, zList, zSep, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)), i+1))
 127658 					zSep = ts + 14614
 127659 				} else if int32(c) == 'd' {
 127660 					zList = rbuMPrintf(tls, p, ts+29413,
 127661 						libc.VaList(bp+32, zList, zSep, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)), *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)), i+1))
 127662 					zSep = ts + 14614
 127663 				} else if int32(c) == 'f' {
 127664 					zList = rbuMPrintf(tls, p, ts+29443,
 127665 						libc.VaList(bp+72, zList, zSep, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)), *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(i)*4)), i+1))
 127666 					zSep = ts + 14614
 127667 				}
 127668 			}
 127669 		}
 127670 	}
 127671 	return zList
 127672 }
 127673 
 127674 func rbuObjIterGetBindlist(tls *libc.TLS, p uintptr, nBind int32) uintptr {
 127675 	var zRet uintptr = uintptr(0)
 127676 	var nByte Sqlite3_int64 = int64(2)*Sqlite3_int64(nBind) + int64(1)
 127677 
 127678 	zRet = rbuMalloc(tls, p, nByte)
 127679 	if zRet != 0 {
 127680 		var i int32
 127681 		for i = 0; i < nBind; i++ {
 127682 			*(*uint8)(unsafe.Pointer(zRet + uintptr(i*2))) = uint8('?')
 127683 			*(*uint8)(unsafe.Pointer(zRet + uintptr(i*2+1))) = func() uint8 {
 127684 				if i+1 == nBind {
 127685 					return uint8(0)
 127686 				}
 127687 				return uint8(',')
 127688 			}()
 127689 		}
 127690 	}
 127691 	return zRet
 127692 }
 127693 
 127694 func rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) uintptr {
 127695 	bp := tls.Alloc(64)
 127696 	defer tls.Free(64)
 127697 
 127698 	var z uintptr = uintptr(0)
 127699 
 127700 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127701 		var zSep uintptr = ts + 29480
 127702 		*(*uintptr)(unsafe.Pointer(bp + 56)) = uintptr(0)
 127703 		*(*uintptr)(unsafe.Pointer(bp + 60)) = uintptr(0)
 127704 
 127705 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+56, p+36,
 127706 			Xsqlite3_mprintf(tls, ts+28632, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl)))
 127707 		for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56))) {
 127708 			var zOrig uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 56)), 3)
 127709 			if zOrig != 0 && libc.Xstrcmp(tls, zOrig, ts+16155) == 0 {
 127710 				var zIdx uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 56)), 1)
 127711 				if zIdx != 0 {
 127712 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+60, p+36,
 127713 						Xsqlite3_mprintf(tls, ts+28660, libc.VaList(bp+8, zIdx)))
 127714 				}
 127715 				break
 127716 			}
 127717 		}
 127718 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56)))
 127719 
 127720 		for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 60))) {
 127721 			if Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 5) != 0 {
 127722 				var zCol uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 2)
 127723 				var zDesc uintptr
 127724 				if Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 60)), 3) != 0 {
 127725 					zDesc = ts + 28900
 127726 				} else {
 127727 					zDesc = ts + 1554
 127728 				}
 127729 				z = rbuMPrintf(tls, p, ts+29493, libc.VaList(bp+16, z, zSep, zCol, zDesc))
 127730 				zSep = ts + 14614
 127731 			}
 127732 		}
 127733 		z = rbuMPrintf(tls, p, ts+29504, libc.VaList(bp+48, z))
 127734 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 60)))
 127735 	}
 127736 	return z
 127737 }
 127738 
 127739 func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) {
 127740 	bp := tls.Alloc(176)
 127741 	defer tls.Free(176)
 127742 
 127743 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL {
 127744 		var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiPkTnum
 127745 		*(*uintptr)(unsafe.Pointer(bp + 168)) = uintptr(0)
 127746 		var zIdx uintptr = uintptr(0)
 127747 		*(*uintptr)(unsafe.Pointer(bp + 172)) = uintptr(0)
 127748 		var zComma uintptr = ts + 1554
 127749 		var zCols uintptr = uintptr(0)
 127750 		var zPk uintptr = uintptr(0)
 127751 
 127752 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+168, p+36,
 127753 			ts+29508)
 127754 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 127755 			Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp + 168)), 1, tnum)
 127756 			if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168))) {
 127757 				zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 168)), 0)
 127758 			}
 127759 		}
 127760 		if zIdx != 0 {
 127761 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+172, p+36,
 127762 				Xsqlite3_mprintf(tls, ts+28660, libc.VaList(bp, zIdx)))
 127763 		}
 127764 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 168)))
 127765 
 127766 		for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 172))) {
 127767 			var bKey int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 172)), 5)
 127768 			if bKey != 0 {
 127769 				var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 172)), 1)
 127770 				var bDesc int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 172)), 3)
 127771 				var zCollate uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 172)), 4)
 127772 				zCols = rbuMPrintf(tls, p, ts+29558, libc.VaList(bp+8, zCols, zComma,
 127773 					iCid, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCid)*4)), zCollate))
 127774 				zPk = rbuMPrintf(tls, p, ts+29580, libc.VaList(bp+48, zPk, zComma, iCid, func() uintptr {
 127775 					if bDesc != 0 {
 127776 						return ts + 28900
 127777 					}
 127778 					return ts + 1554
 127779 				}()))
 127780 				zComma = ts + 14614
 127781 			}
 127782 		}
 127783 		zCols = rbuMPrintf(tls, p, ts+29590, libc.VaList(bp+80, zCols))
 127784 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 172)))
 127785 
 127786 		Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+88, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 1, tnum))
 127787 		rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 127788 			ts+29605,
 127789 			libc.VaList(bp+120, zCols, zPk))
 127790 		Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+136, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 0, 0))
 127791 	}
 127792 }
 127793 
 127794 func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) {
 127795 	bp := tls.Alloc(196)
 127796 	defer tls.Free(196)
 127797 
 127798 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*RbuObjIter)(unsafe.Pointer(pIter)).FeType != RBU_PK_VTAB {
 127799 		var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum
 127800 		var zComma uintptr = ts + 1554
 127801 		var zSql uintptr = uintptr(0)
 127802 		var iCol int32
 127803 		Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 0, 1))
 127804 
 127805 		for iCol = 0; (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && iCol < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; iCol++ {
 127806 			var zPk uintptr = ts + 1554
 127807 			var zCol uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCol)*4))
 127808 			*(*uintptr)(unsafe.Pointer(bp + 192)) = uintptr(0)
 127809 
 127810 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_table_column_metadata(tls,
 127811 				(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zCol, uintptr(0), bp+192, uintptr(0), uintptr(0), uintptr(0))
 127812 
 127813 			if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK && *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0 {
 127814 				zPk = ts + 29667
 127815 			}
 127816 			zSql = rbuMPrintf(tls, p, ts+29680,
 127817 				libc.VaList(bp+32, zSql, zComma, zCol, *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblType + uintptr(iCol)*4)), zPk, *(*uintptr)(unsafe.Pointer(bp + 192)),
 127818 					func() uintptr {
 127819 						if *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabNotNull + uintptr(iCol))) != 0 {
 127820 							return ts + 29707
 127821 						}
 127822 						return ts + 1554
 127823 					}()))
 127824 			zComma = ts + 14614
 127825 		}
 127826 
 127827 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID {
 127828 			var zPk uintptr = rbuWithoutRowidPK(tls, p, pIter)
 127829 			if zPk != 0 {
 127830 				zSql = rbuMPrintf(tls, p, ts+29717, libc.VaList(bp+88, zSql, zPk))
 127831 			}
 127832 		}
 127833 
 127834 		Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+104, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 1, tnum))
 127835 		rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+29724,
 127836 			libc.VaList(bp+136, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSql,
 127837 				func() uintptr {
 127838 					if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID {
 127839 						return ts + 29756
 127840 					}
 127841 					return ts + 1554
 127842 				}()))
 127843 		Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+160, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 0, 0))
 127844 	}
 127845 }
 127846 
 127847 func rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollist uintptr, zRbuRowid uintptr) {
 127848 	bp := tls.Alloc(40)
 127849 	defer tls.Free(40)
 127850 
 127851 	var bRbuRowid int32 = libc.Bool32((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)
 127852 	var zBind uintptr = rbuObjIterGetBindlist(tls, p, (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+1+bRbuRowid)
 127853 	if zBind != 0 {
 127854 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls,
 127855 			(*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+88, p+36, Xsqlite3_mprintf(tls,
 127856 				ts+29771,
 127857 				libc.VaList(bp, p+24, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zCollist, zRbuRowid, zBind)))
 127858 	}
 127859 }
 127860 
 127861 func rbuTmpInsertFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) {
 127862 	var p uintptr = Xsqlite3_user_data(tls, pCtx)
 127863 	var rc int32 = SQLITE_OK
 127864 	var i int32
 127865 
 127866 	if Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) != 0 {
 127867 		*(*I64)(unsafe.Pointer(p + 176)) += I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)
 127868 	}
 127869 
 127870 	for i = 0; rc == SQLITE_OK && i < nVal; i++ {
 127871 		rc = Xsqlite3_bind_value(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert, i+1, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4)))
 127872 	}
 127873 	if rc == SQLITE_OK {
 127874 		Xsqlite3_step(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert)
 127875 		rc = Xsqlite3_reset(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert)
 127876 	}
 127877 
 127878 	if rc != SQLITE_OK {
 127879 		Xsqlite3_result_error_code(tls, pCtx, rc)
 127880 	}
 127881 }
 127882 
 127883 func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr {
 127884 	bp := tls.Alloc(8)
 127885 	defer tls.Free(8)
 127886 
 127887 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 127888 	*(*int32)(unsafe.Pointer(bp + 4)) = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 127889 	var zRet uintptr = uintptr(0)
 127890 
 127891 	if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 127892 		*(*int32)(unsafe.Pointer(bp + 4)) = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp, p+36,
 127893 			ts+29828)
 127894 	}
 127895 	if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 127896 		var rc2 int32
 127897 		*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx, -1, uintptr(0))
 127898 		if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 127899 			var zSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
 127900 			if zSql != 0 {
 127901 				(*RbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = libc.AssignUintptr(&zSql, rbuStrndup(tls, zSql, bp+4))
 127902 			}
 127903 			if zSql != 0 {
 127904 				var nParen int32 = 0
 127905 				var i int32
 127906 				var iIdxCol int32 = 0
 127907 				var nIdxAlloc int32 = 0
 127908 				for i = 0; *(*uint8)(unsafe.Pointer(zSql + uintptr(i))) != 0; i++ {
 127909 					var c uint8 = *(*uint8)(unsafe.Pointer(zSql + uintptr(i)))
 127910 
 127911 					if iIdxCol == nIdxAlloc {
 127912 						var aIdxCol uintptr = Xsqlite3_realloc(tls,
 127913 							(*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol, int32(uint32(nIdxAlloc+16)*uint32(unsafe.Sizeof(RbuSpan{}))))
 127914 						if aIdxCol == uintptr(0) {
 127915 							*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_NOMEM
 127916 							break
 127917 						}
 127918 						(*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = aIdxCol
 127919 						nIdxAlloc = nIdxAlloc + 16
 127920 					}
 127921 
 127922 					if int32(c) == '(' {
 127923 						if nParen == 0 {
 127924 							(*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol)).FzSpan = zSql + uintptr(i+1)
 127925 						}
 127926 						nParen++
 127927 					} else if int32(c) == ')' {
 127928 						nParen--
 127929 						if nParen == 0 {
 127930 							var nSpan int32 = (int32(zSql+uintptr(i)) - int32((*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol+uintptr(iIdxCol)*8)).FzSpan)) / 1
 127931 							(*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(libc.PostIncInt32(&iIdxCol, 1))*8)).FnSpan = nSpan
 127932 							i++
 127933 							break
 127934 						}
 127935 					} else if int32(c) == ',' && nParen == 1 {
 127936 						var nSpan int32 = (int32(zSql+uintptr(i)) - int32((*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol+uintptr(iIdxCol)*8)).FzSpan)) / 1
 127937 						(*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(libc.PostIncInt32(&iIdxCol, 1))*8)).FnSpan = nSpan
 127938 						(*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(iIdxCol)*8)).FzSpan = zSql + uintptr(i+1)
 127939 					} else if int32(c) == '"' || int32(c) == '\'' || int32(c) == '`' {
 127940 						for i++; 1 != 0; i++ {
 127941 							if int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i)))) == int32(c) {
 127942 								if int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i+1)))) != int32(c) {
 127943 									break
 127944 								}
 127945 								i++
 127946 							}
 127947 						}
 127948 					} else if int32(c) == '[' {
 127949 						for i++; 1 != 0; i++ {
 127950 							if int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i)))) == ']' {
 127951 								break
 127952 							}
 127953 						}
 127954 					} else if int32(c) == '-' && int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i+1)))) == '-' {
 127955 						for i = i + 2; *(*uint8)(unsafe.Pointer(zSql + uintptr(i))) != 0 && int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i)))) != '\n'; i++ {
 127956 						}
 127957 						if int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i)))) == 0 {
 127958 							break
 127959 						}
 127960 					} else if int32(c) == '/' && int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i+1)))) == '*' {
 127961 						for i = i + 2; *(*uint8)(unsafe.Pointer(zSql + uintptr(i))) != 0 && (int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i)))) != '*' || int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i+1)))) != '/'); i++ {
 127962 						}
 127963 						if int32(*(*uint8)(unsafe.Pointer(zSql + uintptr(i)))) == 0 {
 127964 							break
 127965 						}
 127966 						i++
 127967 					}
 127968 				}
 127969 				if *(*uint8)(unsafe.Pointer(zSql + uintptr(i))) != 0 {
 127970 					zRet = rbuStrndup(tls, zSql+uintptr(i), bp+4)
 127971 				}
 127972 				(*RbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = iIdxCol
 127973 			}
 127974 		}
 127975 
 127976 		rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 127977 		if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 127978 			*(*int32)(unsafe.Pointer(bp + 4)) = rc2
 127979 		}
 127980 	}
 127981 
 127982 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = *(*int32)(unsafe.Pointer(bp + 4))
 127983 	return zRet
 127984 }
 127985 
 127986 func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32) int32 {
 127987 	bp := tls.Alloc(616)
 127988 	defer tls.Free(616)
 127989 
 127990 	if (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0) && rbuObjIterCacheTableInfo(tls, p, pIter) == SQLITE_OK {
 127991 		var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum
 127992 		var zCollist uintptr = uintptr(0)
 127993 		var pz uintptr = p + 36
 127994 		var zIdx uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx
 127995 		var zLimit uintptr = uintptr(0)
 127996 
 127997 		if nOffset != 0 {
 127998 			zLimit = Xsqlite3_mprintf(tls, ts+29894, libc.VaList(bp, nOffset))
 127999 			if !(zLimit != 0) {
 128000 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 128001 			}
 128002 		}
 128003 
 128004 		if zIdx != 0 {
 128005 			var zTbl uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl
 128006 			*(*uintptr)(unsafe.Pointer(bp + 600)) = uintptr(0)
 128007 			*(*uintptr)(unsafe.Pointer(bp + 604)) = uintptr(0)
 128008 			*(*uintptr)(unsafe.Pointer(bp + 608)) = uintptr(0)
 128009 			var zBind uintptr = uintptr(0)
 128010 			var zPart uintptr = uintptr(0)
 128011 			*(*int32)(unsafe.Pointer(bp + 612)) = 0
 128012 
 128013 			zPart = rbuObjIterGetIndexWhere(tls, p, pIter)
 128014 			zCollist = rbuObjIterGetIndexCols(tls,
 128015 				p, pIter, bp+600, bp+604, bp+608, bp+612)
 128016 			zBind = rbuObjIterGetBindlist(tls, p, *(*int32)(unsafe.Pointer(bp + 612)))
 128017 
 128018 			Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+8, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 0, 1))
 128019 			Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+40, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 1, tnum))
 128020 			rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 128021 				ts+29914,
 128022 				libc.VaList(bp+72, zTbl, *(*uintptr)(unsafe.Pointer(bp + 600)), *(*uintptr)(unsafe.Pointer(bp + 604))))
 128023 			Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+96, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, 0, 0))
 128024 
 128025 			(*RbuObjIter)(unsafe.Pointer(pIter)).FnCol = *(*int32)(unsafe.Pointer(bp + 612))
 128026 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128027 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls,
 128028 					(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+80, p+36,
 128029 					Xsqlite3_mprintf(tls, ts+29979, libc.VaList(bp+128, zTbl, zBind)))
 128030 			}
 128031 
 128032 			if libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128033 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls,
 128034 					(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+84, p+36,
 128035 					Xsqlite3_mprintf(tls, ts+30015, libc.VaList(bp+144, zTbl, *(*uintptr)(unsafe.Pointer(bp + 608)))))
 128036 			}
 128037 
 128038 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128039 				var zSql uintptr
 128040 				if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128041 					var zStart uintptr = uintptr(0)
 128042 					if nOffset != 0 {
 128043 						zStart = rbuVacuumIndexStart(tls, p, pIter)
 128044 						if zStart != 0 {
 128045 							Xsqlite3_free(tls, zLimit)
 128046 							zLimit = uintptr(0)
 128047 						}
 128048 					}
 128049 
 128050 					zSql = Xsqlite3_mprintf(tls,
 128051 						ts+30049,
 128052 						libc.VaList(bp+160, zCollist,
 128053 							(*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl,
 128054 							zPart,
 128055 							func() uintptr {
 128056 								if zStart != 0 {
 128057 									return func() uintptr {
 128058 										if zPart != 0 {
 128059 											return ts + 30110
 128060 										}
 128061 										return ts + 30114
 128062 									}()
 128063 								}
 128064 								return ts + 1554
 128065 							}(), zStart,
 128066 							zCollist, zLimit))
 128067 					Xsqlite3_free(tls, zStart)
 128068 				} else if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE {
 128069 					zSql = Xsqlite3_mprintf(tls,
 128070 						ts+30120,
 128071 						libc.VaList(bp+216, zCollist, p+24, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl,
 128072 							zPart, zCollist, zLimit))
 128073 				} else {
 128074 					zSql = Xsqlite3_mprintf(tls,
 128075 						ts+30181,
 128076 						libc.VaList(bp+264, zCollist, p+24, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zPart,
 128077 							zCollist, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl,
 128078 							zPart,
 128079 							func() uintptr {
 128080 								if zPart != 0 {
 128081 									return ts + 30110
 128082 								}
 128083 								return ts + 30114
 128084 							}(),
 128085 							zCollist, zLimit))
 128086 				}
 128087 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128088 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+76, pz, zSql)
 128089 				} else {
 128090 					Xsqlite3_free(tls, zSql)
 128091 				}
 128092 			}
 128093 
 128094 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 600)))
 128095 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 604)))
 128096 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 608)))
 128097 			Xsqlite3_free(tls, zBind)
 128098 			Xsqlite3_free(tls, zPart)
 128099 		} else {
 128100 			var bRbuRowid int32 = libc.Bool32((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB ||
 128101 				(*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE ||
 128102 				(*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL && (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0))
 128103 			var zTbl uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl
 128104 			var zWrite uintptr
 128105 
 128106 			var zBindings uintptr = rbuObjIterGetBindlist(tls, p, (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+bRbuRowid)
 128107 			var zWhere uintptr = rbuObjIterGetWhere(tls, p, pIter)
 128108 			var zOldlist uintptr = rbuObjIterGetOldlist(tls, p, pIter, ts+6452)
 128109 			var zNewlist uintptr = rbuObjIterGetOldlist(tls, p, pIter, ts+6448)
 128110 
 128111 			zCollist = rbuObjIterGetCollist(tls, p, pIter)
 128112 			(*RbuObjIter)(unsafe.Pointer(pIter)).FnCol = (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol
 128113 
 128114 			rbuCreateImposterTable(tls, p, pIter)
 128115 			rbuCreateImposterTable2(tls, p, pIter)
 128116 			zWrite = func() uintptr {
 128117 				if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB {
 128118 					return ts + 1554
 128119 				}
 128120 				return ts + 30340
 128121 			}()
 128122 
 128123 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128124 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+80, pz,
 128125 					Xsqlite3_mprintf(tls,
 128126 						ts+30349,
 128127 						libc.VaList(bp+344, zWrite, zTbl, zCollist, func() uintptr {
 128128 							if bRbuRowid != 0 {
 128129 								return ts + 30385
 128130 							}
 128131 							return ts + 1554
 128132 						}(), zBindings)))
 128133 			}
 128134 
 128135 			if libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128136 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, pIter+84, pz,
 128137 					Xsqlite3_mprintf(tls,
 128138 						ts+30395, libc.VaList(bp+384, zWrite, zTbl, zWhere)))
 128139 			}
 128140 
 128141 			if libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 {
 128142 				var zRbuRowid uintptr = ts + 1554
 128143 				if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE {
 128144 					zRbuRowid = ts + 30423
 128145 				}
 128146 
 128147 				rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu,
 128148 					ts+30435, libc.VaList(bp+408, p+24, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, func() uintptr {
 128149 						if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL {
 128150 							return ts + 30511
 128151 						}
 128152 						return ts + 1554
 128153 					}(), (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl))
 128154 
 128155 				rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 128156 					ts+30528,
 128157 					libc.VaList(bp+440, zWrite, zTbl, zOldlist,
 128158 						zWrite, zTbl, zOldlist,
 128159 						zWrite, zTbl, zNewlist))
 128160 
 128161 				if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE {
 128162 					rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 128163 						ts+30827,
 128164 						libc.VaList(bp+512, zWrite, zTbl, zNewlist))
 128165 				}
 128166 
 128167 				rbuObjIterPrepareTmpInsert(tls, p, pIter, zCollist, zRbuRowid)
 128168 			}
 128169 
 128170 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128171 				var zRbuRowid uintptr = ts + 1554
 128172 				var zStart uintptr = uintptr(0)
 128173 				var zOrder uintptr = uintptr(0)
 128174 				if bRbuRowid != 0 {
 128175 					if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128176 						zRbuRowid = ts + 30926
 128177 					} else {
 128178 						zRbuRowid = ts + 30936
 128179 					}
 128180 				}
 128181 
 128182 				if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128183 					if nOffset != 0 {
 128184 						zStart = rbuVacuumTableStart(tls, p, pIter, bRbuRowid, zWrite)
 128185 						if zStart != 0 {
 128186 							Xsqlite3_free(tls, zLimit)
 128187 							zLimit = uintptr(0)
 128188 						}
 128189 					}
 128190 					if bRbuRowid != 0 {
 128191 						zOrder = rbuMPrintf(tls, p, ts+28983, 0)
 128192 					} else {
 128193 						zOrder = rbuObjIterGetPkList(tls, p, pIter, ts+1554, ts+14614, ts+1554)
 128194 					}
 128195 				}
 128196 
 128197 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128198 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, pIter+76, pz,
 128199 						Xsqlite3_mprintf(tls,
 128200 							ts+30947,
 128201 							libc.VaList(bp+536, zCollist,
 128202 								func() uintptr {
 128203 									if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128204 										return ts + 30995
 128205 									}
 128206 									return ts + 1554
 128207 								}(),
 128208 								zRbuRowid,
 128209 								(*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, func() uintptr {
 128210 									if zStart != 0 {
 128211 										return zStart
 128212 									}
 128213 									return ts + 1554
 128214 								}(),
 128215 								func() uintptr {
 128216 									if zOrder != 0 {
 128217 										return ts + 22906
 128218 									}
 128219 									return ts + 1554
 128220 								}(), zOrder,
 128221 								zLimit)))
 128222 				}
 128223 				Xsqlite3_free(tls, zStart)
 128224 				Xsqlite3_free(tls, zOrder)
 128225 			}
 128226 
 128227 			Xsqlite3_free(tls, zWhere)
 128228 			Xsqlite3_free(tls, zOldlist)
 128229 			Xsqlite3_free(tls, zNewlist)
 128230 			Xsqlite3_free(tls, zBindings)
 128231 		}
 128232 		Xsqlite3_free(tls, zCollist)
 128233 		Xsqlite3_free(tls, zLimit)
 128234 	}
 128235 
 128236 	return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 128237 }
 128238 
 128239 func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, ppStmt uintptr) int32 {
 128240 	bp := tls.Alloc(32)
 128241 	defer tls.Free(32)
 128242 
 128243 	var pp uintptr
 128244 	var pUp uintptr = uintptr(0)
 128245 	var nUp int32 = 0
 128246 
 128247 	*(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0)
 128248 
 128249 	for pp = pIter + 104; *(*uintptr)(unsafe.Pointer(pp)) != 0; pp = *(*uintptr)(unsafe.Pointer(pp)) + 8 {
 128250 		pUp = *(*uintptr)(unsafe.Pointer(pp))
 128251 		if libc.Xstrcmp(tls, (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask) == 0 {
 128252 			*(*uintptr)(unsafe.Pointer(pp)) = (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext
 128253 			(*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate
 128254 			(*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp
 128255 			*(*uintptr)(unsafe.Pointer(ppStmt)) = (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate
 128256 			return SQLITE_OK
 128257 		}
 128258 		nUp++
 128259 	}
 128260 
 128261 	if nUp >= SQLITE_RBU_UPDATE_CACHESIZE {
 128262 		for pp = pIter + 104; *(*uintptr)(unsafe.Pointer(pp)) != pUp; pp = *(*uintptr)(unsafe.Pointer(pp)) + 8 {
 128263 		}
 128264 		*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 128265 		Xsqlite3_finalize(tls, (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate)
 128266 		(*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate = uintptr(0)
 128267 	} else {
 128268 		pUp = rbuMalloc(tls, p, int64(uint32(unsafe.Sizeof(RbuUpdateStmt{}))+uint32((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)+uint32(1)))
 128269 	}
 128270 
 128271 	if pUp != 0 {
 128272 		var zWhere uintptr = rbuObjIterGetWhere(tls, p, pIter)
 128273 		var zSet uintptr = rbuObjIterGetSetlist(tls, p, pIter, zMask)
 128274 		var zUpdate uintptr = uintptr(0)
 128275 
 128276 		(*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = pUp + 1*12
 128277 		libc.Xmemcpy(tls, (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask, uint32((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol))
 128278 		(*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate
 128279 		(*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp
 128280 
 128281 		if zSet != 0 {
 128282 			var zPrefix uintptr = ts + 1554
 128283 
 128284 			if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType != RBU_PK_VTAB {
 128285 				zPrefix = ts + 30340
 128286 			}
 128287 			zUpdate = Xsqlite3_mprintf(tls, ts+31001,
 128288 				libc.VaList(bp, zPrefix, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSet, zWhere))
 128289 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls,
 128290 				(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, pUp+4, p+36, zUpdate)
 128291 			*(*uintptr)(unsafe.Pointer(ppStmt)) = (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate
 128292 		}
 128293 		Xsqlite3_free(tls, zWhere)
 128294 		Xsqlite3_free(tls, zSet)
 128295 	}
 128296 
 128297 	return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 128298 }
 128299 
 128300 func rbuOpenDbhandle(tls *libc.TLS, p uintptr, zName uintptr, bUseVfs int32) uintptr {
 128301 	bp := tls.Alloc(12)
 128302 	defer tls.Free(12)
 128303 
 128304 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 128305 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128306 		var flags int32 = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI
 128307 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_open_v2(tls, zName, bp+8, flags, func() uintptr {
 128308 			if bUseVfs != 0 {
 128309 				return (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName
 128310 			}
 128311 			return uintptr(0)
 128312 		}())
 128313 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 {
 128314 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))))
 128315 			Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 128316 			*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 128317 		}
 128318 	}
 128319 	return *(*uintptr)(unsafe.Pointer(bp + 8))
 128320 }
 128321 
 128322 func rbuFreeState(tls *libc.TLS, p uintptr) {
 128323 	if p != 0 {
 128324 		Xsqlite3_free(tls, (*RbuState)(unsafe.Pointer(p)).FzTbl)
 128325 		Xsqlite3_free(tls, (*RbuState)(unsafe.Pointer(p)).FzDataTbl)
 128326 		Xsqlite3_free(tls, (*RbuState)(unsafe.Pointer(p)).FzIdx)
 128327 		Xsqlite3_free(tls, p)
 128328 	}
 128329 }
 128330 
 128331 func rbuLoadState(tls *libc.TLS, p uintptr) uintptr {
 128332 	bp := tls.Alloc(16)
 128333 	defer tls.Free(16)
 128334 
 128335 	var pRet uintptr = uintptr(0)
 128336 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 128337 
 128338 	var rc2 int32
 128339 
 128340 	pRet = rbuMalloc(tls, p, int64(unsafe.Sizeof(RbuState{})))
 128341 	if pRet == uintptr(0) {
 128342 		return uintptr(0)
 128343 	}
 128344 
 128345 	*(*int32)(unsafe.Pointer(bp + 12)) = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+8, p+36,
 128346 		Xsqlite3_mprintf(tls, ts+31031, libc.VaList(bp, p+24)))
 128347 	for *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8))) {
 128348 		switch Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 0) {
 128349 		case RBU_STATE_STAGE:
 128350 			(*RbuState)(unsafe.Pointer(pRet)).FeStage = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1)
 128351 			if (*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_OAL &&
 128352 				(*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_MOVE &&
 128353 				(*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_CKPT {
 128354 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT
 128355 			}
 128356 			break
 128357 
 128358 		case RBU_STATE_TBL:
 128359 			(*RbuState)(unsafe.Pointer(pRet)).FzTbl = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1), bp+12)
 128360 			break
 128361 
 128362 		case RBU_STATE_IDX:
 128363 			(*RbuState)(unsafe.Pointer(pRet)).FzIdx = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1), bp+12)
 128364 			break
 128365 
 128366 		case RBU_STATE_ROW:
 128367 			(*RbuState)(unsafe.Pointer(pRet)).FnRow = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1)
 128368 			break
 128369 
 128370 		case RBU_STATE_PROGRESS:
 128371 			(*RbuState)(unsafe.Pointer(pRet)).FnProgress = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1)
 128372 			break
 128373 
 128374 		case RBU_STATE_CKPT:
 128375 			(*RbuState)(unsafe.Pointer(pRet)).FiWalCksum = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1)
 128376 			break
 128377 
 128378 		case RBU_STATE_COOKIE:
 128379 			(*RbuState)(unsafe.Pointer(pRet)).FiCookie = U32(Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1))
 128380 			break
 128381 
 128382 		case RBU_STATE_OALSZ:
 128383 			(*RbuState)(unsafe.Pointer(pRet)).FiOalSz = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1)
 128384 			break
 128385 
 128386 		case RBU_STATE_PHASEONESTEP:
 128387 			(*RbuState)(unsafe.Pointer(pRet)).FnPhaseOneStep = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1)
 128388 			break
 128389 
 128390 		case RBU_STATE_DATATBL:
 128391 			(*RbuState)(unsafe.Pointer(pRet)).FzDataTbl = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 1), bp+12)
 128392 			break
 128393 
 128394 		default:
 128395 			*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_CORRUPT
 128396 			break
 128397 		}
 128398 	}
 128399 	rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 128400 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 128401 		*(*int32)(unsafe.Pointer(bp + 12)) = rc2
 128402 	}
 128403 
 128404 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = *(*int32)(unsafe.Pointer(bp + 12))
 128405 	return pRet
 128406 }
 128407 
 128408 func rbuOpenDatabase(tls *libc.TLS, p uintptr, dbMain uintptr, pbRetry uintptr) {
 128409 	bp := tls.Alloc(56)
 128410 	defer tls.Free(56)
 128411 
 128412 	(*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, 1)
 128413 	(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = dbMain
 128414 
 128415 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128416 		Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+6441, SQLITE_FCNTL_RBUCNT, p)
 128417 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FzState == uintptr(0) {
 128418 			var zFile uintptr = Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+6441)
 128419 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzState = rbuMPrintf(tls, p, ts+31061, libc.VaList(bp, zFile, zFile))
 128420 		}
 128421 	}
 128422 
 128423 	if (*Sqlite3rbu)(unsafe.Pointer(p)).FzState != 0 {
 128424 		rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+31089, libc.VaList(bp+16, (*Sqlite3rbu)(unsafe.Pointer(p)).FzState))
 128425 		libc.Xmemcpy(tls, p+24, ts+3286, uint32(4))
 128426 	} else {
 128427 		libc.Xmemcpy(tls, p+24, ts+6441, uint32(4))
 128428 	}
 128429 
 128430 	rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+31107, libc.VaList(bp+24, p+24))
 128431 
 128432 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128433 		var bOpen int32 = 0
 128434 		var rc int32
 128435 		(*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu = 0
 128436 		(*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd = uintptr(0)
 128437 		rc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+6441, SQLITE_FCNTL_RBUCNT, p)
 128438 		if rc != SQLITE_NOTFOUND {
 128439 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 128440 		}
 128441 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage >= RBU_STAGE_MOVE {
 128442 			bOpen = 1
 128443 		} else {
 128444 			var pState uintptr = rbuLoadState(tls, p)
 128445 			if pState != 0 {
 128446 				bOpen = libc.Bool32((*RbuState)(unsafe.Pointer(pState)).FeStage >= RBU_STAGE_MOVE)
 128447 				rbuFreeState(tls, pState)
 128448 			}
 128449 		}
 128450 		if bOpen != 0 {
 128451 			(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu <= 1))
 128452 		}
 128453 	}
 128454 
 128455 	(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 0
 128456 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0) {
 128457 		if !((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) {
 128458 			(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget, 1)
 128459 		} else if (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FpWalFd != 0 {
 128460 			if pbRetry != 0 {
 128461 				(*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FbNolock = U8(0)
 128462 				Xsqlite3_close(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu)
 128463 				Xsqlite3_close(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain)
 128464 				(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0)
 128465 				(*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0)
 128466 				*(*int32)(unsafe.Pointer(pbRetry)) = 1
 128467 				return
 128468 			}
 128469 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 128470 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+31173, 0)
 128471 		} else {
 128472 			var zTarget uintptr
 128473 			var zExtra uintptr = uintptr(0)
 128474 			if libc.Xstrlen(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu) >= Size_t(5) && 0 == libc.Xmemcmp(tls, ts+24253, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, uint32(5)) {
 128475 				zExtra = (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu + 5
 128476 				for *(*uint8)(unsafe.Pointer(zExtra)) != 0 {
 128477 					if int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zExtra, 1)))) == '?' {
 128478 						break
 128479 					}
 128480 				}
 128481 				if int32(*(*uint8)(unsafe.Pointer(zExtra))) == 0 {
 128482 					zExtra = uintptr(0)
 128483 				}
 128484 			}
 128485 
 128486 			zTarget = Xsqlite3_mprintf(tls, ts+31205,
 128487 				libc.VaList(bp+32, Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+6441),
 128488 					func() uintptr {
 128489 						if zExtra == uintptr(0) {
 128490 							return ts + 1554
 128491 						}
 128492 						return ts + 31237
 128493 					}(), func() uintptr {
 128494 						if zExtra == uintptr(0) {
 128495 							return ts + 1554
 128496 						}
 128497 						return zExtra
 128498 					}()))
 128499 
 128500 			if zTarget == uintptr(0) {
 128501 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 128502 				return
 128503 			}
 128504 			(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, zTarget, libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu <= 1))
 128505 			Xsqlite3_free(tls, zTarget)
 128506 		}
 128507 	}
 128508 
 128509 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128510 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 128511 			ts+31239, -1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct {
 128512 				f func(*libc.TLS, uintptr, int32, uintptr)
 128513 			}{rbuTmpInsertFunc})), uintptr(0), uintptr(0))
 128514 	}
 128515 
 128516 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128517 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain,
 128518 			ts+31254, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct {
 128519 				f func(*libc.TLS, uintptr, int32, uintptr)
 128520 			}{rbuFossilDeltaFunc})), uintptr(0), uintptr(0))
 128521 	}
 128522 
 128523 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128524 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu,
 128525 			ts+31271, -1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct {
 128526 				f func(*libc.TLS, uintptr, int32, uintptr)
 128527 			}{rbuTargetNameFunc})), uintptr(0), uintptr(0))
 128528 	}
 128529 
 128530 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128531 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, SQLITE_FCNTL_RBU, p)
 128532 	}
 128533 	rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31287, 0)
 128534 
 128535 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128536 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, SQLITE_FCNTL_RBU, p)
 128537 	}
 128538 
 128539 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_NOTFOUND {
 128540 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 128541 		(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+31315, 0)
 128542 	}
 128543 }
 128544 
 128545 func rbuFileSuffix3(tls *libc.TLS, zBase uintptr, z uintptr) {
 128546 }
 128547 
 128548 func rbuShmChecksum(tls *libc.TLS, p uintptr) I64 {
 128549 	bp := tls.Alloc(4)
 128550 	defer tls.Free(4)
 128551 
 128552 	var iRet I64 = int64(0)
 128553 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128554 		var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
 128555 
 128556 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 128557 			f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32
 128558 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxShmMap})).f(tls, pDb, 0, 32*1024, 0, bp)
 128559 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128560 			iRet = I64(*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + 10*4)))<<32 + I64(*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + 11*4)))
 128561 		}
 128562 	}
 128563 	return iRet
 128564 }
 128565 
 128566 func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) {
 128567 	if pState == uintptr(0) {
 128568 		(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 0
 128569 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128570 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31287, uintptr(0), uintptr(0), uintptr(0))
 128571 		}
 128572 	}
 128573 
 128574 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128575 		var rc2 int32
 128576 		(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CAPTURE
 128577 		rc2 = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31333, uintptr(0), uintptr(0), uintptr(0))
 128578 		if rc2 != SQLITE_NOTICE {
 128579 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc2
 128580 		}
 128581 	}
 128582 
 128583 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0 {
 128584 		(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT
 128585 		(*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = func() int32 {
 128586 			if pState != 0 {
 128587 				return (*RbuState)(unsafe.Pointer(pState)).FnRow
 128588 			}
 128589 			return 0
 128590 		}()
 128591 		(*Sqlite3rbu)(unsafe.Pointer(p)).FaBuf = rbuMalloc(tls, p, int64((*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz))
 128592 		(*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum = rbuShmChecksum(tls, p)
 128593 	}
 128594 
 128595 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128596 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame == 0 || pState != 0 && (*RbuState)(unsafe.Pointer(pState)).FiWalCksum != (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum {
 128597 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE
 128598 			(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE
 128599 		} else {
 128600 			var nSectorSize int32
 128601 			var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
 128602 			var pWal uintptr = (*Rbu_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd)).FpReal
 128603 
 128604 			nSectorSize = (*struct {
 128605 				f func(*libc.TLS, uintptr) int32
 128606 			})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSectorSize})).f(tls, pDb)
 128607 			if nSectorSize > (*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz {
 128608 				(*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = nSectorSize / (*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz
 128609 			} else {
 128610 				(*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = 1
 128611 			}
 128612 
 128613 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 128614 				f func(*libc.TLS, uintptr, int32) int32
 128615 			})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pWal)).FpMethods)).FxSync})).f(tls, pWal, SQLITE_SYNC_NORMAL)
 128616 		}
 128617 	}
 128618 }
 128619 
 128620 func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 {
 128621 	var mReq U32 = U32(int32(1)<<WAL_LOCK_WRITE | int32(1)<<WAL_LOCK_CKPT | int32(1)<<WAL_LOCK_READ0)
 128622 	var iFrame U32
 128623 
 128624 	if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FmLock != mReq {
 128625 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc = SQLITE_BUSY
 128626 		return SQLITE_NOTICE | int32(3)<<8
 128627 	}
 128628 
 128629 	(*Sqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz = iAmt
 128630 	if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame == (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrameAlloc {
 128631 		var nNew int32 = func() int32 {
 128632 			if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrameAlloc != 0 {
 128633 				return (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrameAlloc
 128634 			}
 128635 			return 64
 128636 		}() * 2
 128637 		var aNew uintptr
 128638 		aNew = Xsqlite3_realloc64(tls, (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame, uint64(uint32(nNew)*uint32(unsafe.Sizeof(RbuFrame{}))))
 128639 		if aNew == uintptr(0) {
 128640 			return SQLITE_NOMEM
 128641 		}
 128642 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame = aNew
 128643 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrameAlloc = nNew
 128644 	}
 128645 
 128646 	iFrame = U32((iOff-int64(32))/I64(iAmt+24)) + U32(1)
 128647 	if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiMaxFrame < iFrame {
 128648 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiMaxFrame = iFrame
 128649 	}
 128650 	(*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame)*8)).FiWalFrame = iFrame
 128651 	(*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame)*8)).FiDbPage = U32(0)
 128652 	(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame++
 128653 	return SQLITE_OK
 128654 }
 128655 
 128656 func rbuCaptureDbWrite(tls *libc.TLS, pRbu uintptr, iOff I64) int32 {
 128657 	(*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame-1)*8)).FiDbPage = U32(iOff/I64((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz)) + U32(1)
 128658 	return SQLITE_OK
 128659 }
 128660 
 128661 func rbuCheckpointFrame(tls *libc.TLS, p uintptr, pFrame uintptr) {
 128662 	var pWal uintptr = (*Rbu_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd)).FpReal
 128663 	var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
 128664 	var iOff I64
 128665 
 128666 	iOff = I64((*RbuFrame)(unsafe.Pointer(pFrame)).FiWalFrame-U32(1))*I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz+24) + int64(32) + int64(24)
 128667 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 128668 		f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
 128669 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pWal)).FpMethods)).FxRead})).f(tls, pWal, (*Sqlite3rbu)(unsafe.Pointer(p)).FaBuf, (*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz, iOff)
 128670 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 {
 128671 		return
 128672 	}
 128673 
 128674 	iOff = I64((*RbuFrame)(unsafe.Pointer(pFrame)).FiDbPage-U32(1)) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz)
 128675 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 128676 		f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
 128677 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxWrite})).f(tls, pDb, (*Sqlite3rbu)(unsafe.Pointer(p)).FaBuf, (*Sqlite3rbu)(unsafe.Pointer(p)).Fpgsz, iOff)
 128678 }
 128679 
 128680 func rbuLockDatabase(tls *libc.TLS, db uintptr) int32 {
 128681 	bp := tls.Alloc(4)
 128682 	defer tls.Free(4)
 128683 
 128684 	var rc int32 = SQLITE_OK
 128685 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 128686 	Xsqlite3_file_control(tls, db, ts+6441, SQLITE_FCNTL_FILE_POINTER, bp)
 128687 
 128688 	if (*Sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpMethods != 0 {
 128689 		rc = (*struct {
 128690 			f func(*libc.TLS, uintptr, int32) int32
 128691 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpMethods)).FxLock})).f(tls, *(*uintptr)(unsafe.Pointer(bp)), SQLITE_LOCK_SHARED)
 128692 		if rc == SQLITE_OK {
 128693 			rc = (*struct {
 128694 				f func(*libc.TLS, uintptr, int32) int32
 128695 			})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FpMethods)).FxLock})).f(tls, *(*uintptr)(unsafe.Pointer(bp)), SQLITE_LOCK_EXCLUSIVE)
 128696 		}
 128697 	}
 128698 	return rc
 128699 }
 128700 
 128701 func rbuExclusiveCheckpoint(tls *libc.TLS, db uintptr) int32 {
 128702 	var zUri uintptr = Xsqlite3_db_filename(tls, db, uintptr(0))
 128703 	return Xsqlite3_uri_boolean(tls, zUri, ts+31368, 0)
 128704 }
 128705 
 128706 func rbuMoveOalFile(tls *libc.TLS, p uintptr) {
 128707 	bp := tls.Alloc(16)
 128708 	defer tls.Free(16)
 128709 
 128710 	var zBase uintptr = Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441)
 128711 	var zMove uintptr = zBase
 128712 	var zOal uintptr
 128713 	var zWal uintptr
 128714 
 128715 	if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128716 		zMove = Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+6441)
 128717 	}
 128718 	zOal = Xsqlite3_mprintf(tls, ts+31393, libc.VaList(bp, zMove))
 128719 	zWal = Xsqlite3_mprintf(tls, ts+31400, libc.VaList(bp+8, zMove))
 128720 
 128721 	if zWal == uintptr(0) || zOal == uintptr(0) {
 128722 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 128723 	} else {
 128724 		var dbMain uintptr = uintptr(0)
 128725 		rbuFileSuffix3(tls, zBase, zWal)
 128726 		rbuFileSuffix3(tls, zBase, zOal)
 128727 
 128728 		rbuObjIterFinalize(tls, p+48)
 128729 		Xsqlite3_close(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu)
 128730 		Xsqlite3_close(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain)
 128731 		(*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = uintptr(0)
 128732 		(*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu = uintptr(0)
 128733 
 128734 		dbMain = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget, 1)
 128735 		if dbMain != 0 {
 128736 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuLockDatabase(tls, dbMain)
 128737 		}
 128738 
 128739 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128740 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 128741 				f func(*libc.TLS, uintptr, uintptr, uintptr) int32
 128742 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3rbu)(unsafe.Pointer(p)).FxRename})).f(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FpRenameArg, zOal, zWal)
 128743 		}
 128744 
 128745 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK ||
 128746 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) ||
 128747 			rbuExclusiveCheckpoint(tls, dbMain) == 0 {
 128748 			Xsqlite3_close(tls, dbMain)
 128749 			dbMain = uintptr(0)
 128750 		}
 128751 
 128752 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128753 			rbuOpenDatabase(tls, p, dbMain, uintptr(0))
 128754 			rbuSetupCheckpoint(tls, p, uintptr(0))
 128755 		}
 128756 	}
 128757 
 128758 	Xsqlite3_free(tls, zWal)
 128759 	Xsqlite3_free(tls, zOal)
 128760 }
 128761 
 128762 func rbuStepType(tls *libc.TLS, p uintptr, pzMask uintptr) int32 {
 128763 	var iCol int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnCol
 128764 	var res int32 = 0
 128765 
 128766 	switch Xsqlite3_column_type(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) {
 128767 	case SQLITE_INTEGER:
 128768 		{
 128769 			var iVal int32 = Xsqlite3_column_int(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol)
 128770 			switch iVal {
 128771 			case 0:
 128772 				res = RBU_INSERT
 128773 				break
 128774 			case 1:
 128775 				res = RBU_DELETE
 128776 				break
 128777 			case 2:
 128778 				res = RBU_REPLACE
 128779 				break
 128780 			case 3:
 128781 				res = RBU_IDX_DELETE
 128782 				break
 128783 			case 4:
 128784 				res = RBU_IDX_INSERT
 128785 				break
 128786 			}
 128787 			break
 128788 
 128789 		}
 128790 
 128791 	case SQLITE_TEXT:
 128792 		{
 128793 			var z uintptr = Xsqlite3_column_text(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol)
 128794 			if z == uintptr(0) {
 128795 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 128796 			} else {
 128797 				*(*uintptr)(unsafe.Pointer(pzMask)) = z
 128798 			}
 128799 			res = RBU_UPDATE
 128800 
 128801 			break
 128802 
 128803 		}
 128804 
 128805 	default:
 128806 		break
 128807 	}
 128808 
 128809 	if res == 0 {
 128810 		rbuBadControlError(tls, p)
 128811 	}
 128812 	return res
 128813 }
 128814 
 128815 func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) {
 128816 	var pIter uintptr = p + 48
 128817 	var pVal uintptr
 128818 	var pWriter uintptr
 128819 	var i int32
 128820 
 128821 	if eType == RBU_DELETE {
 128822 		*(*I64)(unsafe.Pointer(p + 176)) -= I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)
 128823 	}
 128824 
 128825 	if eType == RBU_IDX_DELETE || eType == RBU_DELETE {
 128826 		pWriter = (*RbuObjIter)(unsafe.Pointer(pIter)).FpDelete
 128827 	} else {
 128828 		pWriter = (*RbuObjIter)(unsafe.Pointer(pIter)).FpInsert
 128829 	}
 128830 
 128831 	for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol; i++ {
 128832 		if eType == RBU_INSERT &&
 128833 			(*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) && (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK && *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 &&
 128834 			Xsqlite3_column_type(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == SQLITE_NULL {
 128835 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_MISMATCH
 128836 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+23891, 0)
 128837 			return
 128838 		}
 128839 
 128840 		if eType == RBU_DELETE && int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0 {
 128841 			continue
 128842 		}
 128843 
 128844 		pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i)
 128845 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, i+1, pVal)
 128846 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 {
 128847 			return
 128848 		}
 128849 	}
 128850 	if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) {
 128851 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB ||
 128852 			(*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE ||
 128853 			(*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL && (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128854 			pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol+1)
 128855 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol+1, pVal)
 128856 		}
 128857 	}
 128858 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128859 		Xsqlite3_step(tls, pWriter)
 128860 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = resetAndCollectError(tls, pWriter, p+36)
 128861 	}
 128862 }
 128863 
 128864 func rbuStep(tls *libc.TLS, p uintptr) int32 {
 128865 	bp := tls.Alloc(8)
 128866 	defer tls.Free(8)
 128867 
 128868 	var pIter uintptr = p + 48
 128869 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 128870 	var eType int32 = rbuStepType(tls, p, bp)
 128871 
 128872 	if eType != 0 {
 128873 		if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) && (eType == RBU_IDX_DELETE || eType == RBU_IDX_INSERT) {
 128874 			rbuBadControlError(tls, p)
 128875 		} else if eType == RBU_REPLACE {
 128876 			if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) {
 128877 				*(*I64)(unsafe.Pointer(p + 176)) += I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)
 128878 				rbuStepOneOp(tls, p, RBU_DELETE)
 128879 			}
 128880 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128881 				rbuStepOneOp(tls, p, RBU_INSERT)
 128882 			}
 128883 		} else if eType != RBU_UPDATE {
 128884 			rbuStepOneOp(tls, p, eType)
 128885 		} else {
 128886 			var pVal uintptr
 128887 			*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 128888 
 128889 			*(*I64)(unsafe.Pointer(p + 176)) -= I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)
 128890 			rbuGetUpdateStmt(tls, p, pIter, *(*uintptr)(unsafe.Pointer(bp)), bp+4)
 128891 			if *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
 128892 				var i int32
 128893 				for i = 0; (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol; i++ {
 128894 					var c uint8 = *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + uintptr(*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4)))))
 128895 					pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i)
 128896 					if *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0 || int32(c) != '.' {
 128897 						(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), i+1, pVal)
 128898 					}
 128899 				}
 128900 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK &&
 128901 					((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB || (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) {
 128902 					pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol+1)
 128903 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol+1, pVal)
 128904 				}
 128905 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128906 					Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 128907 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = resetAndCollectError(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), p+36)
 128908 				}
 128909 			}
 128910 		}
 128911 	}
 128912 	return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 128913 }
 128914 
 128915 func rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) {
 128916 	bp := tls.Alloc(12)
 128917 	defer tls.Free(12)
 128918 
 128919 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128920 		var dbread uintptr = func() uintptr {
 128921 			if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128922 				return (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu
 128923 			}
 128924 			return (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain
 128925 		}()
 128926 		var iCookie int32 = 1000000
 128927 
 128928 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, dbread, bp+8, p+36,
 128929 			ts+31407)
 128930 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128931 			if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8))) {
 128932 				iCookie = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 0)
 128933 			}
 128934 			rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 8)))
 128935 		}
 128936 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128937 			rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31429, libc.VaList(bp, iCookie+1))
 128938 		}
 128939 	}
 128940 }
 128941 
 128942 func rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) {
 128943 	bp := tls.Alloc(172)
 128944 	defer tls.Free(172)
 128945 
 128946 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK || (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_DONE {
 128947 		*(*uintptr)(unsafe.Pointer(bp + 168)) = uintptr(0)
 128948 		var pFd uintptr = func() uintptr {
 128949 			if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 128950 				return (*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd
 128951 			}
 128952 			return (*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd
 128953 		}()
 128954 		var rc int32
 128955 
 128956 		rc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+168, p+36,
 128957 			Xsqlite3_mprintf(tls,
 128958 				ts+31456,
 128959 				libc.VaList(bp, p+24,
 128960 					RBU_STATE_STAGE, eStage,
 128961 					RBU_STATE_TBL, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl,
 128962 					RBU_STATE_IDX, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx,
 128963 					RBU_STATE_ROW, (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep,
 128964 					RBU_STATE_PROGRESS, (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress,
 128965 					RBU_STATE_CKPT, (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum,
 128966 					RBU_STATE_COOKIE, I64((*Rbu_file)(unsafe.Pointer(pFd)).FiCookie),
 128967 					RBU_STATE_OALSZ, (*Sqlite3rbu)(unsafe.Pointer(p)).FiOalSz,
 128968 					RBU_STATE_PHASEONESTEP, (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep,
 128969 					RBU_STATE_DATATBL, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl)))
 128970 
 128971 		if rc == SQLITE_OK {
 128972 			Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168)))
 128973 			rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 168)))
 128974 		}
 128975 		if rc != SQLITE_OK {
 128976 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 128977 		}
 128978 	}
 128979 }
 128980 
 128981 func rbuCopyPragma(tls *libc.TLS, p uintptr, zPragma uintptr) {
 128982 	bp := tls.Alloc(28)
 128983 	defer tls.Free(28)
 128984 
 128985 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 128986 		*(*uintptr)(unsafe.Pointer(bp + 24)) = uintptr(0)
 128987 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+24, p+36,
 128988 			Xsqlite3_mprintf(tls, ts+31614, libc.VaList(bp, zPragma)))
 128989 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24))) {
 128990 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31629,
 128991 				libc.VaList(bp+8, zPragma, Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), 0)))
 128992 		}
 128993 		rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 24)))
 128994 	}
 128995 }
 128996 
 128997 func rbuCreateTargetSchema(tls *libc.TLS, p uintptr) {
 128998 	bp := tls.Alloc(8)
 128999 	defer tls.Free(8)
 129000 
 129001 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 129002 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 129003 
 129004 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31649, uintptr(0), uintptr(0), p+36)
 129005 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129006 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+36,
 129007 			ts+31674)
 129008 	}
 129009 
 129010 	for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) == SQLITE_ROW {
 129011 		var zSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
 129012 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, zSql, uintptr(0), uintptr(0), p+36)
 129013 	}
 129014 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp)))
 129015 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 129016 		return
 129017 	}
 129018 
 129019 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129020 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+36,
 129021 			ts+31782)
 129022 	}
 129023 
 129024 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129025 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+4, p+36,
 129026 			ts+31847)
 129027 	}
 129028 
 129029 	for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) == SQLITE_ROW {
 129030 		var i int32
 129031 		for i = 0; i < 5; i++ {
 129032 			Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), i+1, Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp)), i))
 129033 		}
 129034 		Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 129035 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 129036 	}
 129037 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129038 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+31891, uintptr(0), uintptr(0), p+36)
 129039 	}
 129040 
 129041 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp)))
 129042 	rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 4)))
 129043 }
 129044 
 129045 // Step the RBU object.
 129046 func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 {
 129047 	bp := tls.Alloc(20)
 129048 	defer tls.Free(20)
 129049 
 129050 	if p != 0 {
 129051 		switch (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage {
 129052 		case RBU_STAGE_OAL:
 129053 			{
 129054 				var pIter uintptr = p + 48
 129055 
 129056 				if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) && (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0 && (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129057 					rbuCreateTargetSchema(tls, p)
 129058 					rbuCopyPragma(tls, p, ts+17240)
 129059 					rbuCopyPragma(tls, p, ts+16351)
 129060 				}
 129061 
 129062 				for (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 {
 129063 					if (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 {
 129064 						if libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) == 0 && (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0 {
 129065 							rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu,
 129066 								ts+31916, libc.VaList(bp, p+24, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl))
 129067 						}
 129068 					} else {
 129069 						rbuObjIterPrepareAll(tls, p, pIter, 0)
 129070 
 129071 						if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129072 							var rc int32 = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect)
 129073 							if rc == SQLITE_ROW {
 129074 								(*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++
 129075 								(*Sqlite3rbu)(unsafe.Pointer(p)).FnStep++
 129076 								return rbuStep(tls, p)
 129077 							}
 129078 							(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect)
 129079 							(*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = 0
 129080 						}
 129081 					}
 129082 
 129083 					rbuObjIterNext(tls, p, pIter)
 129084 				}
 129085 
 129086 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129087 					rbuSaveState(tls, p, RBU_STAGE_MOVE)
 129088 					rbuIncrSchemaCookie(tls, p)
 129089 					if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129090 						(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+14518, uintptr(0), uintptr(0), p+36)
 129091 					}
 129092 					if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129093 						(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+14518, uintptr(0), uintptr(0), p+36)
 129094 					}
 129095 					(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_MOVE
 129096 				}
 129097 				break
 129098 
 129099 			}
 129100 			fallthrough
 129101 
 129102 		case RBU_STAGE_MOVE:
 129103 			{
 129104 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129105 					rbuMoveOalFile(tls, p)
 129106 					(*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++
 129107 				}
 129108 				break
 129109 
 129110 			}
 129111 			fallthrough
 129112 
 129113 		case RBU_STAGE_CKPT:
 129114 			{
 129115 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129116 					if (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep >= (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame {
 129117 						var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
 129118 
 129119 						(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 129120 							f func(*libc.TLS, uintptr, int32) int32
 129121 						})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})).f(tls, pDb, SQLITE_SYNC_NORMAL)
 129122 
 129123 						if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129124 							(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 129125 								f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32
 129126 							})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxShmMap})).f(tls, pDb, 0, 32*1024, 0, bp+16)
 129127 							if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129128 								*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + 24*4)) = (*Sqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame
 129129 							}
 129130 						}
 129131 
 129132 						if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129133 							(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE
 129134 							(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE
 129135 						}
 129136 					} else {
 129137 						var iSector U32
 129138 						for __ccgo := true; __ccgo; __ccgo = (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep < (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame &&
 129139 							iSector == ((*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame+uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)*8)).FiDbPage-U32(1))/U32((*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector) &&
 129140 							(*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129141 							var pFrame uintptr = (*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)*8
 129142 							iSector = ((*RbuFrame)(unsafe.Pointer(pFrame)).FiDbPage - U32(1)) / U32((*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector)
 129143 							rbuCheckpointFrame(tls, p, pFrame)
 129144 							(*Sqlite3rbu)(unsafe.Pointer(p)).FnStep++
 129145 						}
 129146 					}
 129147 					(*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++
 129148 				}
 129149 				break
 129150 
 129151 			}
 129152 			fallthrough
 129153 
 129154 		default:
 129155 			break
 129156 		}
 129157 		return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 129158 	} else {
 129159 		return SQLITE_NOMEM
 129160 	}
 129161 	return int32(0)
 129162 }
 129163 
 129164 func rbuStrCompare(tls *libc.TLS, z1 uintptr, z2 uintptr) int32 {
 129165 	if z1 == uintptr(0) && z2 == uintptr(0) {
 129166 		return 0
 129167 	}
 129168 	if z1 == uintptr(0) || z2 == uintptr(0) {
 129169 		return 1
 129170 	}
 129171 	return libc.Bool32(Xsqlite3_stricmp(tls, z1, z2) != 0)
 129172 }
 129173 
 129174 func rbuSetupOal(tls *libc.TLS, p uintptr, pState uintptr) {
 129175 	if (*RbuState)(unsafe.Pointer(pState)).FzTbl != 0 {
 129176 		var pIter uintptr = p + 48
 129177 		var rc int32 = SQLITE_OK
 129178 
 129179 		for rc == SQLITE_OK && (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0 && ((*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 ||
 129180 			rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx, (*RbuState)(unsafe.Pointer(pState)).FzIdx) != 0 ||
 129181 			(*RbuState)(unsafe.Pointer(pState)).FzDataTbl == uintptr(0) && rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (*RbuState)(unsafe.Pointer(pState)).FzTbl) != 0 ||
 129182 			(*RbuState)(unsafe.Pointer(pState)).FzDataTbl != 0 && rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, (*RbuState)(unsafe.Pointer(pState)).FzDataTbl) != 0) {
 129183 			rc = rbuObjIterNext(tls, p, pIter)
 129184 		}
 129185 
 129186 		if rc == SQLITE_OK && !(int32((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl) != 0) {
 129187 			rc = SQLITE_ERROR
 129188 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+31944, 0)
 129189 		}
 129190 
 129191 		if rc == SQLITE_OK {
 129192 			(*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = (*RbuState)(unsafe.Pointer(pState)).FnRow
 129193 			rc = rbuObjIterPrepareAll(tls, p, p+48, (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)
 129194 		}
 129195 
 129196 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 129197 	}
 129198 }
 129199 
 129200 func rbuDeleteOalFile(tls *libc.TLS, p uintptr) {
 129201 	bp := tls.Alloc(12)
 129202 	defer tls.Free(12)
 129203 
 129204 	var zOal uintptr = rbuMPrintf(tls, p, ts+31393, libc.VaList(bp, (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget))
 129205 	if zOal != 0 {
 129206 		*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 129207 		Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+6441, SQLITE_FCNTL_VFS_POINTER, bp+8)
 129208 
 129209 		(*struct {
 129210 			f func(*libc.TLS, uintptr, uintptr, int32) int32
 129211 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FxDelete})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), zOal, 0)
 129212 		Xsqlite3_free(tls, zOal)
 129213 	}
 129214 }
 129215 
 129216 func rbuCreateVfs(tls *libc.TLS, p uintptr) {
 129217 	bp := tls.Alloc(76)
 129218 	defer tls.Free(76)
 129219 
 129220 	Xsqlite3_randomness(tls, int32(unsafe.Sizeof(int32(0))), bp+8)
 129221 	Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]uint8{})), bp+12, ts+31969, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8))))
 129222 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+12, uintptr(0))
 129223 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129224 		var pVfs uintptr = Xsqlite3_vfs_find(tls, bp+12)
 129225 
 129226 		(*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName
 129227 		(*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRbu = p
 129228 	}
 129229 }
 129230 
 129231 func rbuDeleteVfs(tls *libc.TLS, p uintptr) {
 129232 	if (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName != 0 {
 129233 		Xsqlite3rbu_destroy_vfs(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName)
 129234 		(*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName = uintptr(0)
 129235 	}
 129236 }
 129237 
 129238 func rbuIndexCntFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) {
 129239 	bp := tls.Alloc(16)
 129240 	defer tls.Free(16)
 129241 
 129242 	var p uintptr = Xsqlite3_user_data(tls, pCtx)
 129243 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 129244 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 129245 	var rc int32
 129246 	var db uintptr = func() uintptr {
 129247 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 129248 			return (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu
 129249 		}
 129250 		return (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain
 129251 	}()
 129252 
 129253 	rc = prepareFreeAndCollectError(tls, db, bp+8, bp+12,
 129254 		Xsqlite3_mprintf(tls,
 129255 			ts+31980, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))))))
 129256 	if rc != SQLITE_OK {
 129257 		Xsqlite3_result_error(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 12)), -1)
 129258 	} else {
 129259 		var nIndex int32 = 0
 129260 		if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8))) {
 129261 			nIndex = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), 0)
 129262 		}
 129263 		rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 129264 		if rc == SQLITE_OK {
 129265 			Xsqlite3_result_int(tls, pCtx, nIndex)
 129266 		} else {
 129267 			Xsqlite3_result_error(tls, pCtx, Xsqlite3_errmsg(tls, db), -1)
 129268 		}
 129269 	}
 129270 
 129271 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 129272 }
 129273 
 129274 func rbuInitPhaseOneSteps(tls *libc.TLS, p uintptr) {
 129275 	bp := tls.Alloc(4)
 129276 	defer tls.Free(4)
 129277 
 129278 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129279 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 129280 		var bExists int32 = 0
 129281 
 129282 		(*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = int64(-1)
 129283 
 129284 		(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu,
 129285 			ts+32052, 1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct {
 129286 				f func(*libc.TLS, uintptr, int32, uintptr)
 129287 			}{rbuIndexCntFunc})), uintptr(0), uintptr(0))
 129288 
 129289 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129290 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+36,
 129291 				ts+32066)
 129292 		}
 129293 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129294 			if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 129295 				bExists = 1
 129296 			}
 129297 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 129298 		}
 129299 
 129300 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && bExists != 0 {
 129301 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp, p+36,
 129302 				ts+32123)
 129303 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129304 				if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 129305 					(*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
 129306 				}
 129307 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 129308 			}
 129309 		}
 129310 	}
 129311 }
 129312 
 129313 func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) uintptr {
 129314 	bp := tls.Alloc(20)
 129315 	defer tls.Free(20)
 129316 
 129317 	var p uintptr
 129318 	var nTarget Size_t
 129319 	if zTarget != 0 {
 129320 		nTarget = libc.Xstrlen(tls, zTarget)
 129321 	} else {
 129322 		nTarget = uint32(0)
 129323 	}
 129324 	var nRbu Size_t = libc.Xstrlen(tls, zRbu)
 129325 	var nByte Size_t = uint32(unsafe.Sizeof(Sqlite3rbu{})) + nTarget + uint32(1) + nRbu + uint32(1)
 129326 
 129327 	p = Xsqlite3_malloc64(tls, uint64(nByte))
 129328 	if p != 0 {
 129329 		var pState uintptr = uintptr(0)
 129330 
 129331 		libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(Sqlite3rbu{})))
 129332 		Xsqlite3rbu_rename_handler(tls, p, uintptr(0), uintptr(0))
 129333 		rbuCreateVfs(tls, p)
 129334 
 129335 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129336 			var pCsr uintptr = p + 1*256
 129337 			*(*int32)(unsafe.Pointer(bp + 16)) = 0
 129338 			if zTarget != 0 {
 129339 				(*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget = pCsr
 129340 				libc.Xmemcpy(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget, zTarget, nTarget+Size_t(1))
 129341 				pCsr += uintptr(nTarget + Size_t(1))
 129342 			}
 129343 			(*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu = pCsr
 129344 			libc.Xmemcpy(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, zRbu, nRbu+Size_t(1))
 129345 			pCsr += uintptr(nRbu + Size_t(1))
 129346 			if zState != 0 {
 129347 				(*Sqlite3rbu)(unsafe.Pointer(p)).FzState = rbuMPrintf(tls, p, ts+3663, libc.VaList(bp, zState))
 129348 			}
 129349 
 129350 			rbuOpenDatabase(tls, p, uintptr(0), bp+16)
 129351 			if *(*int32)(unsafe.Pointer(bp + 16)) != 0 {
 129352 				rbuOpenDatabase(tls, p, uintptr(0), uintptr(0))
 129353 			}
 129354 		}
 129355 
 129356 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129357 			pState = rbuLoadState(tls, p)
 129358 
 129359 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129360 				if (*RbuState)(unsafe.Pointer(pState)).FeStage == 0 {
 129361 					rbuDeleteOalFile(tls, p)
 129362 					rbuInitPhaseOneSteps(tls, p)
 129363 					(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_OAL
 129364 				} else {
 129365 					(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = (*RbuState)(unsafe.Pointer(pState)).FeStage
 129366 					(*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = (*RbuState)(unsafe.Pointer(pState)).FnPhaseOneStep
 129367 				}
 129368 				(*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress = int32((*RbuState)(unsafe.Pointer(pState)).FnProgress)
 129369 				(*Sqlite3rbu)(unsafe.Pointer(p)).FiOalSz = (*RbuState)(unsafe.Pointer(pState)).FiOalSz
 129370 			}
 129371 		}
 129372 
 129373 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd != 0 {
 129374 			if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL {
 129375 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR
 129376 				(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+32197, 0)
 129377 			} else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE {
 129378 				(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT
 129379 				(*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = 0
 129380 			}
 129381 		}
 129382 
 129383 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK &&
 129384 			((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL || (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE) &&
 129385 			(*RbuState)(unsafe.Pointer(pState)).FeStage != 0 {
 129386 			var pFd uintptr = func() uintptr {
 129387 				if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 129388 					return (*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd
 129389 				}
 129390 				return (*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd
 129391 			}()
 129392 			if (*Rbu_file)(unsafe.Pointer(pFd)).FiCookie != (*RbuState)(unsafe.Pointer(pState)).FiCookie {
 129393 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_BUSY
 129394 				(*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+32229,
 129395 					libc.VaList(bp+8, func() uintptr {
 129396 						if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 129397 							return ts + 32261
 129398 						}
 129399 						return ts + 32268
 129400 					}()))
 129401 			}
 129402 		}
 129403 
 129404 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129405 			if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL {
 129406 				var db uintptr = (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain
 129407 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+14503, uintptr(0), uintptr(0), p+36)
 129408 
 129409 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129410 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuObjIterFirst(tls, p, p+48)
 129411 				}
 129412 
 129413 				if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0) {
 129414 					(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE
 129415 					(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE
 129416 				} else {
 129417 					if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*RbuState)(unsafe.Pointer(pState)).FeStage == 0 && (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 129418 						rbuCopyPragma(tls, p, ts+16954)
 129419 						rbuCopyPragma(tls, p, ts+16366)
 129420 					}
 129421 
 129422 					if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129423 						(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, ts+32275, uintptr(0), uintptr(0), p+36)
 129424 					}
 129425 
 129426 					if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129427 						var frc int32 = Xsqlite3_file_control(tls, db, ts+6441, SQLITE_FCNTL_ZIPVFS, uintptr(0))
 129428 						if frc == SQLITE_OK {
 129429 							(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls,
 129430 								db, ts+32291, uintptr(0), uintptr(0), p+36)
 129431 						}
 129432 					}
 129433 
 129434 					if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 129435 						rbuSetupOal(tls, p, pState)
 129436 					}
 129437 				}
 129438 			} else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE {
 129439 			} else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT {
 129440 				if !((*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0)) && rbuExclusiveCheckpoint(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain) != 0 {
 129441 					(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE
 129442 					rbuLockDatabase(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain)
 129443 					(*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT
 129444 				}
 129445 				rbuSetupCheckpoint(tls, p, pState)
 129446 			} else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_DONE {
 129447 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE
 129448 			} else {
 129449 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT
 129450 			}
 129451 		}
 129452 
 129453 		rbuFreeState(tls, pState)
 129454 	}
 129455 
 129456 	return p
 129457 }
 129458 
 129459 func rbuMisuseError(tls *libc.TLS) uintptr {
 129460 	var pRet uintptr
 129461 	pRet = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(Sqlite3rbu{})))
 129462 	if pRet != 0 {
 129463 		libc.Xmemset(tls, pRet, 0, uint32(unsafe.Sizeof(Sqlite3rbu{})))
 129464 		(*Sqlite3rbu)(unsafe.Pointer(pRet)).Frc = SQLITE_MISUSE
 129465 	}
 129466 	return pRet
 129467 }
 129468 
 129469 // Open and return a new RBU handle.
 129470 func Xsqlite3rbu_open(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) uintptr {
 129471 	if zTarget == uintptr(0) || zRbu == uintptr(0) {
 129472 		return rbuMisuseError(tls)
 129473 	}
 129474 	return openRbuHandle(tls, zTarget, zRbu, zState)
 129475 }
 129476 
 129477 // Open a handle to begin or resume an RBU VACUUM operation.
 129478 func Xsqlite3rbu_vacuum(tls *libc.TLS, zTarget uintptr, zState uintptr) uintptr {
 129479 	if zTarget == uintptr(0) {
 129480 		return rbuMisuseError(tls)
 129481 	}
 129482 	if zState != 0 {
 129483 		var n int32 = int32(libc.Xstrlen(tls, zState))
 129484 		if n >= 7 && 0 == libc.Xmemcmp(tls, ts+32315, zState+uintptr(n-7), uint32(7)) {
 129485 			return rbuMisuseError(tls)
 129486 		}
 129487 	}
 129488 
 129489 	return openRbuHandle(tls, uintptr(0), zTarget, zState)
 129490 }
 129491 
 129492 // Return the database handle used by pRbu.
 129493 func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) uintptr {
 129494 	var db uintptr = uintptr(0)
 129495 	if pRbu != 0 {
 129496 		db = func() uintptr {
 129497 			if bRbu != 0 {
 129498 				return (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FdbRbu
 129499 			}
 129500 			return (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FdbMain
 129501 		}()
 129502 	}
 129503 	return db
 129504 }
 129505 
 129506 func rbuEditErrmsg(tls *libc.TLS, p uintptr) {
 129507 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_CONSTRAINT && (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0 {
 129508 		var i uint32
 129509 		var nErrmsg Size_t = libc.Xstrlen(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg)
 129510 		for i = uint32(0); i < nErrmsg-Size_t(8); i++ {
 129511 			if libc.Xmemcmp(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), ts+30340, uint32(8)) == 0 {
 129512 				var nDel int32 = 8
 129513 				for int32(*(*uint8)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+uint32(nDel))))) >= '0' && int32(*(*uint8)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg + uintptr(i+uint32(nDel))))) <= '9' {
 129514 					nDel++
 129515 				}
 129516 				libc.Xmemmove(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i), (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg+uintptr(i+uint32(nDel)), nErrmsg+Size_t(1)-i-Size_t(nDel))
 129517 				nErrmsg = nErrmsg - Size_t(nDel)
 129518 			}
 129519 		}
 129520 	}
 129521 }
 129522 
 129523 // Close the RBU handle.
 129524 func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 {
 129525 	var rc int32
 129526 	if p != 0 {
 129527 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL {
 129528 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+14518, uintptr(0), uintptr(0), p+36)
 129529 		}
 129530 
 129531 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT {
 129532 			var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
 129533 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*struct {
 129534 				f func(*libc.TLS, uintptr, int32) int32
 129535 			})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})).f(tls, pDb, SQLITE_SYNC_NORMAL)
 129536 		}
 129537 
 129538 		rbuSaveState(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage)
 129539 
 129540 		if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL {
 129541 			(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+14518, uintptr(0), uintptr(0), p+36)
 129542 		}
 129543 
 129544 		rbuObjIterFinalize(tls, p+48)
 129545 
 129546 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) && (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0 {
 129547 			var rc2 int32 = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+32323, uintptr(0), uintptr(0), uintptr(0))
 129548 			if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_DONE && rc2 != SQLITE_OK {
 129549 				(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc2
 129550 			}
 129551 		}
 129552 
 129553 		Xsqlite3_close(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu)
 129554 		Xsqlite3_close(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain)
 129555 
 129556 		rbuDeleteVfs(tls, p)
 129557 		Xsqlite3_free(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FaBuf)
 129558 		Xsqlite3_free(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame)
 129559 
 129560 		rbuEditErrmsg(tls, p)
 129561 		rc = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 129562 		if pzErrmsg != 0 {
 129563 			*(*uintptr)(unsafe.Pointer(pzErrmsg)) = (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg
 129564 		} else {
 129565 			Xsqlite3_free(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg)
 129566 		}
 129567 		Xsqlite3_free(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzState)
 129568 		Xsqlite3_free(tls, p)
 129569 	} else {
 129570 		rc = SQLITE_NOMEM
 129571 		*(*uintptr)(unsafe.Pointer(pzErrmsg)) = uintptr(0)
 129572 	}
 129573 	return rc
 129574 }
 129575 
 129576 // Return the total number of key-value operations (inserts, deletes or
 129577 // updates) that have been performed on the target database since the
 129578 // current RBU update was started.
 129579 func Xsqlite3rbu_progress(tls *libc.TLS, pRbu uintptr) Sqlite3_int64 {
 129580 	return Sqlite3_int64((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnProgress)
 129581 }
 129582 
 129583 // Return permyriadage progress indications for the two main stages of
 129584 // an RBU update.
 129585 func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uintptr) {
 129586 	var MAX_PROGRESS int32 = 10000
 129587 	switch (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage {
 129588 	case RBU_STAGE_OAL:
 129589 		if (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep > int64(0) {
 129590 			*(*int32)(unsafe.Pointer(pnOne)) = int32(I64(MAX_PROGRESS) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress) / (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep)
 129591 		} else {
 129592 			*(*int32)(unsafe.Pointer(pnOne)) = -1
 129593 		}
 129594 		*(*int32)(unsafe.Pointer(pnTwo)) = 0
 129595 		break
 129596 
 129597 	case RBU_STAGE_MOVE:
 129598 		*(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS
 129599 		*(*int32)(unsafe.Pointer(pnTwo)) = 0
 129600 		break
 129601 
 129602 	case RBU_STAGE_CKPT:
 129603 		*(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS
 129604 		*(*int32)(unsafe.Pointer(pnTwo)) = int32(I64(MAX_PROGRESS) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep) / I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame))
 129605 		break
 129606 
 129607 	case RBU_STAGE_DONE:
 129608 		*(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS
 129609 		*(*int32)(unsafe.Pointer(pnTwo)) = MAX_PROGRESS
 129610 		break
 129611 
 129612 	default:
 129613 	}
 129614 }
 129615 
 129616 // Return the current state of the RBU vacuum or update operation.
 129617 func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) int32 {
 129618 	bp := tls.Alloc(24)
 129619 	defer tls.Free(24)
 129620 
 129621 	*(*[6]int32)(unsafe.Pointer(bp)) = [6]int32{
 129622 		0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,
 129623 		0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE,
 129624 	}
 129625 
 129626 	if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_DONE {
 129627 		return SQLITE_RBU_STATE_ERROR
 129628 	} else {
 129629 		return *(*int32)(unsafe.Pointer(bp + uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage)*4))
 129630 	}
 129631 	return int32(0)
 129632 }
 129633 
 129634 func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) int32 {
 129635 	var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 129636 	if rc == SQLITE_DONE {
 129637 		return SQLITE_OK
 129638 	}
 129639 
 129640 	if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL {
 129641 		if rc == SQLITE_OK {
 129642 			rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+14518, uintptr(0), uintptr(0), uintptr(0))
 129643 		}
 129644 	}
 129645 
 129646 	if rc == SQLITE_OK && (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT {
 129647 		var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
 129648 		rc = (*struct {
 129649 			f func(*libc.TLS, uintptr, int32) int32
 129650 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})).f(tls, pDb, SQLITE_SYNC_NORMAL)
 129651 	}
 129652 
 129653 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 129654 	rbuSaveState(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage)
 129655 	rc = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc
 129656 
 129657 	if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL {
 129658 		if rc == SQLITE_OK {
 129659 			rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+14518, uintptr(0), uintptr(0), uintptr(0))
 129660 		}
 129661 		if rc == SQLITE_OK {
 129662 			var zBegin uintptr
 129663 			if (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
 129664 				zBegin = ts + 14503
 129665 			} else {
 129666 				zBegin = ts + 32275
 129667 			}
 129668 			rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, zBegin, uintptr(0), uintptr(0), uintptr(0))
 129669 		}
 129670 		if rc == SQLITE_OK {
 129671 			rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+32275, uintptr(0), uintptr(0), uintptr(0))
 129672 		}
 129673 	}
 129674 
 129675 	(*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc
 129676 	return rc
 129677 }
 129678 
 129679 func xDefaultRename(tls *libc.TLS, pArg uintptr, zOld uintptr, zNew uintptr) int32 {
 129680 	var rc int32 = SQLITE_OK
 129681 	if libc.Xrename(tls, zOld, zNew) != 0 {
 129682 		rc = SQLITE_IOERR
 129683 	} else {
 129684 		rc = SQLITE_OK
 129685 	}
 129686 	return rc
 129687 }
 129688 
 129689 func Xsqlite3rbu_rename_handler(tls *libc.TLS, pRbu uintptr, pArg uintptr, xRename uintptr) {
 129690 	if xRename != 0 {
 129691 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FxRename = xRename
 129692 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRenameArg = pArg
 129693 	} else {
 129694 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FxRename = *(*uintptr)(unsafe.Pointer(&struct {
 129695 			f func(*libc.TLS, uintptr, uintptr, uintptr) int32
 129696 		}{xDefaultRename}))
 129697 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRenameArg = uintptr(0)
 129698 	}
 129699 }
 129700 
 129701 func rbuUnlockShm(tls *libc.TLS, p uintptr) {
 129702 	if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
 129703 		var xShmLock uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmLock
 129704 		var i int32
 129705 		for i = 0; i < SQLITE_SHM_NLOCK; i++ {
 129706 			if U32(int32(1)<<i)&(*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FmLock != 0 {
 129707 				(*struct {
 129708 					f func(*libc.TLS, uintptr, int32, int32, int32) int32
 129709 				})(unsafe.Pointer(&struct{ uintptr }{xShmLock})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, i, 1, SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE)
 129710 			}
 129711 		}
 129712 		(*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FmLock = U32(0)
 129713 	}
 129714 }
 129715 
 129716 func rbuUpdateTempSize(tls *libc.TLS, pFd uintptr, nNew Sqlite3_int64) int32 {
 129717 	var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(pFd)).FpRbu
 129718 	var nDiff I64 = nNew - (*Rbu_file)(unsafe.Pointer(pFd)).Fsz
 129719 	*(*I64)(unsafe.Pointer(pRbu + 232)) += nDiff
 129720 	(*Rbu_file)(unsafe.Pointer(pFd)).Fsz = nNew
 129721 
 129722 	if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp > (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit {
 129723 		return SQLITE_FULL
 129724 	}
 129725 	return SQLITE_OK
 129726 }
 129727 
 129728 func rbuMainlistAdd(tls *libc.TLS, p uintptr) {
 129729 	var pRbuVfs uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs
 129730 	var pIter uintptr
 129731 
 129732 	Xsqlite3_mutex_enter(tls, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
 129733 	if (*Rbu_file)(unsafe.Pointer(p)).FpRbu == uintptr(0) {
 129734 		for pIter = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain; pIter != 0; pIter = (*Rbu_file)(unsafe.Pointer(pIter)).FpMainNext {
 129735 		}
 129736 		(*Rbu_file)(unsafe.Pointer(p)).FpMainNext = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain
 129737 		(*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain = p
 129738 	} else {
 129739 		for pIter = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu; pIter != 0 && pIter != p; pIter = (*Rbu_file)(unsafe.Pointer(pIter)).FpMainRbuNext {
 129740 		}
 129741 		if pIter == uintptr(0) {
 129742 			(*Rbu_file)(unsafe.Pointer(p)).FpMainRbuNext = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu
 129743 			(*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu = p
 129744 		}
 129745 	}
 129746 	Xsqlite3_mutex_leave(tls, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
 129747 }
 129748 
 129749 func rbuMainlistRemove(tls *libc.TLS, p uintptr) {
 129750 	var pp uintptr
 129751 	Xsqlite3_mutex_enter(tls, (*Rbu_vfs)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs)).Fmutex)
 129752 	for pp = (*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs + 100; *(*uintptr)(unsafe.Pointer(pp)) != 0 && *(*uintptr)(unsafe.Pointer(pp)) != p; pp = *(*uintptr)(unsafe.Pointer(pp)) + 56 {
 129753 	}
 129754 	if *(*uintptr)(unsafe.Pointer(pp)) != 0 {
 129755 		*(*uintptr)(unsafe.Pointer(pp)) = (*Rbu_file)(unsafe.Pointer(p)).FpMainNext
 129756 	}
 129757 	(*Rbu_file)(unsafe.Pointer(p)).FpMainNext = uintptr(0)
 129758 	for pp = (*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs + 104; *(*uintptr)(unsafe.Pointer(pp)) != 0 && *(*uintptr)(unsafe.Pointer(pp)) != p; pp = *(*uintptr)(unsafe.Pointer(pp)) + 60 {
 129759 	}
 129760 	if *(*uintptr)(unsafe.Pointer(pp)) != 0 {
 129761 		*(*uintptr)(unsafe.Pointer(pp)) = (*Rbu_file)(unsafe.Pointer(p)).FpMainRbuNext
 129762 	}
 129763 	(*Rbu_file)(unsafe.Pointer(p)).FpMainRbuNext = uintptr(0)
 129764 	Xsqlite3_mutex_leave(tls, (*Rbu_vfs)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs)).Fmutex)
 129765 }
 129766 
 129767 func rbuFindMaindb(tls *libc.TLS, pRbuVfs uintptr, zWal uintptr, bRbu int32) uintptr {
 129768 	var pDb uintptr
 129769 	Xsqlite3_mutex_enter(tls, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
 129770 	if bRbu != 0 {
 129771 		for pDb = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu; pDb != 0 && (*Rbu_file)(unsafe.Pointer(pDb)).FzWal != zWal; pDb = (*Rbu_file)(unsafe.Pointer(pDb)).FpMainRbuNext {
 129772 		}
 129773 	} else {
 129774 		for pDb = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain; pDb != 0 && (*Rbu_file)(unsafe.Pointer(pDb)).FzWal != zWal; pDb = (*Rbu_file)(unsafe.Pointer(pDb)).FpMainNext {
 129775 		}
 129776 	}
 129777 	Xsqlite3_mutex_leave(tls, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
 129778 	return pDb
 129779 }
 129780 
 129781 func rbuVfsClose(tls *libc.TLS, pFile uintptr) int32 {
 129782 	var p uintptr = pFile
 129783 	var rc int32
 129784 	var i int32
 129785 
 129786 	for i = 0; i < (*Rbu_file)(unsafe.Pointer(p)).FnShm; i++ {
 129787 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(i)*4)))
 129788 	}
 129789 	Xsqlite3_free(tls, (*Rbu_file)(unsafe.Pointer(p)).FapShm)
 129790 	(*Rbu_file)(unsafe.Pointer(p)).FapShm = uintptr(0)
 129791 	Xsqlite3_free(tls, (*Rbu_file)(unsafe.Pointer(p)).FzDel)
 129792 
 129793 	if (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_MAIN_DB != 0 {
 129794 		var pMeth uintptr = (*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods
 129795 		rbuMainlistRemove(tls, p)
 129796 		rbuUnlockShm(tls, p)
 129797 		if (*Sqlite3_io_methods)(unsafe.Pointer(pMeth)).FiVersion > 1 && (*Sqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmUnmap != 0 {
 129798 			(*struct {
 129799 				f func(*libc.TLS, uintptr, int32) int32
 129800 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmUnmap})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, 0)
 129801 		}
 129802 	} else if (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_DELETEONCLOSE != 0 && (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
 129803 		rbuUpdateTempSize(tls, p, int64(0))
 129804 	}
 129805 
 129806 	rc = (*struct {
 129807 		f func(*libc.TLS, uintptr) int32
 129808 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxClose})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal)
 129809 	return rc
 129810 }
 129811 
 129812 func rbuGetU32(tls *libc.TLS, aBuf uintptr) U32 {
 129813 	return U32(*(*U8)(unsafe.Pointer(aBuf)))<<24 +
 129814 		U32(*(*U8)(unsafe.Pointer(aBuf + 1)))<<16 +
 129815 		U32(*(*U8)(unsafe.Pointer(aBuf + 2)))<<8 +
 129816 		U32(*(*U8)(unsafe.Pointer(aBuf + 3)))
 129817 }
 129818 
 129819 func rbuPutU32(tls *libc.TLS, aBuf uintptr, iVal U32) {
 129820 	*(*U8)(unsafe.Pointer(aBuf)) = U8(iVal >> 24 & U32(0xFF))
 129821 	*(*U8)(unsafe.Pointer(aBuf + 1)) = U8(iVal >> 16 & U32(0xFF))
 129822 	*(*U8)(unsafe.Pointer(aBuf + 2)) = U8(iVal >> 8 & U32(0xFF))
 129823 	*(*U8)(unsafe.Pointer(aBuf + 3)) = U8(iVal >> 0 & U32(0xFF))
 129824 }
 129825 
 129826 func rbuPutU16(tls *libc.TLS, aBuf uintptr, iVal U16) {
 129827 	*(*U8)(unsafe.Pointer(aBuf)) = U8(int32(iVal) >> 8 & 0xFF)
 129828 	*(*U8)(unsafe.Pointer(aBuf + 1)) = U8(int32(iVal) >> 0 & 0xFF)
 129829 }
 129830 
 129831 func rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sqlite_int64) int32 {
 129832 	var p uintptr = pFile
 129833 	var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu
 129834 	var rc int32
 129835 
 129836 	if pRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE {
 129837 		rc = rbuCaptureWalRead(tls, (*Rbu_file)(unsafe.Pointer(p)).FpRbu, iOfst, iAmt)
 129838 	} else {
 129839 		if pRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL &&
 129840 			(*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_WAL != 0 &&
 129841 			iOfst >= (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz {
 129842 			rc = SQLITE_OK
 129843 			libc.Xmemset(tls, zBuf, 0, uint32(iAmt))
 129844 		} else {
 129845 			rc = (*struct {
 129846 				f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
 129847 			})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxRead})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst)
 129848 
 129849 			if pRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FzTarget == uintptr(0) &&
 129850 				rc == SQLITE_IOERR|int32(2)<<8 && iOfst == int64(0) &&
 129851 				(*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_MAIN_DB != 0 &&
 129852 				(*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc == SQLITE_OK {
 129853 				var pFd uintptr = (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd
 129854 				rc = (*struct {
 129855 					f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
 129856 				})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FxRead})).f(tls, pFd, zBuf, iAmt, iOfst)
 129857 				if rc == SQLITE_OK {
 129858 					var aBuf uintptr = zBuf
 129859 					var iRoot U32
 129860 					if rbuGetU32(tls, aBuf+52) != 0 {
 129861 						iRoot = uint32(1)
 129862 					} else {
 129863 						iRoot = uint32(0)
 129864 					}
 129865 					rbuPutU32(tls, aBuf+52, iRoot)
 129866 					rbuPutU32(tls, aBuf+36, uint32(0))
 129867 					rbuPutU32(tls, aBuf+32, uint32(0))
 129868 					rbuPutU32(tls, aBuf+28, uint32(1))
 129869 					rbuPutU32(tls, aBuf+24, (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd)).FiCookie+U32(1))
 129870 
 129871 					if iAmt > 100 {
 129872 						libc.Xmemset(tls, aBuf+100, 0, uint32(iAmt-100))
 129873 						rbuPutU16(tls, aBuf+105, uint16(iAmt&0xFFFF))
 129874 						*(*U8)(unsafe.Pointer(aBuf + 100)) = U8(0x0D)
 129875 					}
 129876 				}
 129877 			}
 129878 		}
 129879 		if rc == SQLITE_OK && iOfst == int64(0) && (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_MAIN_DB != 0 {
 129880 			var pBuf uintptr = zBuf
 129881 			(*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, pBuf+24)
 129882 			(*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + 19))
 129883 		}
 129884 	}
 129885 	return rc
 129886 }
 129887 
 129888 func rbuVfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sqlite_int64) int32 {
 129889 	var p uintptr = pFile
 129890 	var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu
 129891 	var rc int32
 129892 
 129893 	if pRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE {
 129894 		rc = rbuCaptureDbWrite(tls, (*Rbu_file)(unsafe.Pointer(p)).FpRbu, iOfst)
 129895 	} else {
 129896 		if pRbu != 0 {
 129897 			if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL &&
 129898 				(*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_WAL != 0 &&
 129899 				iOfst >= (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz {
 129900 				(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz = Sqlite_int64(iAmt) + iOfst
 129901 			} else if (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_DELETEONCLOSE != 0 {
 129902 				var szNew I64 = Sqlite_int64(iAmt) + iOfst
 129903 				if szNew > (*Rbu_file)(unsafe.Pointer(p)).Fsz {
 129904 					rc = rbuUpdateTempSize(tls, p, szNew)
 129905 					if rc != SQLITE_OK {
 129906 						return rc
 129907 					}
 129908 				}
 129909 			}
 129910 		}
 129911 		rc = (*struct {
 129912 			f func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32
 129913 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxWrite})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst)
 129914 		if rc == SQLITE_OK && iOfst == int64(0) && (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_MAIN_DB != 0 {
 129915 			var pBuf uintptr = zBuf
 129916 			(*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, pBuf+24)
 129917 			(*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + 19))
 129918 		}
 129919 	}
 129920 	return rc
 129921 }
 129922 
 129923 func rbuVfsTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 {
 129924 	var p uintptr = pFile
 129925 	if (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_DELETEONCLOSE != 0 && (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
 129926 		var rc int32 = rbuUpdateTempSize(tls, p, size)
 129927 		if rc != SQLITE_OK {
 129928 			return rc
 129929 		}
 129930 	}
 129931 	return (*struct {
 129932 		f func(*libc.TLS, uintptr, Sqlite3_int64) int32
 129933 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxTruncate})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, size)
 129934 }
 129935 
 129936 func rbuVfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 {
 129937 	var p uintptr = pFile
 129938 	if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == RBU_STAGE_CAPTURE {
 129939 		if (*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_MAIN_DB != 0 {
 129940 			return SQLITE_NOTICE | int32(3)<<8
 129941 		}
 129942 		return SQLITE_OK
 129943 	}
 129944 	return (*struct {
 129945 		f func(*libc.TLS, uintptr, int32) int32
 129946 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxSync})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, flags)
 129947 }
 129948 
 129949 func rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 {
 129950 	var p uintptr = pFile
 129951 	var rc int32
 129952 	rc = (*struct {
 129953 		f func(*libc.TLS, uintptr, uintptr) int32
 129954 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileSize})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, pSize)
 129955 
 129956 	if rc == SQLITE_OK && *(*Sqlite_int64)(unsafe.Pointer(pSize)) == int64(0) &&
 129957 		(*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FzTarget == uintptr(0) &&
 129958 		(*Rbu_file)(unsafe.Pointer(p)).FopenFlags&SQLITE_OPEN_MAIN_DB != 0 {
 129959 		*(*Sqlite_int64)(unsafe.Pointer(pSize)) = int64(1024)
 129960 	}
 129961 	return rc
 129962 }
 129963 
 129964 func rbuVfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 {
 129965 	var p uintptr = pFile
 129966 	var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu
 129967 	var rc int32 = SQLITE_OK
 129968 
 129969 	if eLock == SQLITE_LOCK_EXCLUSIVE &&
 129970 		((*Rbu_file)(unsafe.Pointer(p)).FbNolock != 0 || pRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != RBU_STAGE_DONE) {
 129971 		rc = SQLITE_BUSY
 129972 	} else {
 129973 		rc = (*struct {
 129974 			f func(*libc.TLS, uintptr, int32) int32
 129975 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxLock})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, eLock)
 129976 	}
 129977 
 129978 	return rc
 129979 }
 129980 
 129981 func rbuVfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 {
 129982 	var p uintptr = pFile
 129983 	return (*struct {
 129984 		f func(*libc.TLS, uintptr, int32) int32
 129985 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxUnlock})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, eLock)
 129986 }
 129987 
 129988 func rbuVfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 {
 129989 	var p uintptr = pFile
 129990 	return (*struct {
 129991 		f func(*libc.TLS, uintptr, uintptr) int32
 129992 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxCheckReservedLock})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, pResOut)
 129993 }
 129994 
 129995 func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 {
 129996 	bp := tls.Alloc(20)
 129997 	defer tls.Free(20)
 129998 
 129999 	var p uintptr = pFile
 130000 	var xControl uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileControl
 130001 	var rc int32
 130002 
 130003 	if op == SQLITE_FCNTL_RBU {
 130004 		var pRbu uintptr = pArg
 130005 
 130006 		rc = (*struct {
 130007 			f func(*libc.TLS, uintptr, int32, uintptr) int32
 130008 		})(unsafe.Pointer(&struct{ uintptr }{xControl})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, op, pArg)
 130009 
 130010 		if rc == SQLITE_NOTFOUND {
 130011 			*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 130012 			rc = (*struct {
 130013 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 130014 			})(unsafe.Pointer(&struct{ uintptr }{xControl})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, SQLITE_FCNTL_ZIPVFS, bp+16)
 130015 			if rc == SQLITE_OK {
 130016 				rc = SQLITE_ERROR
 130017 				(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FzErrmsg = Xsqlite3_mprintf(tls, ts+32350, 0)
 130018 			} else if rc == SQLITE_NOTFOUND {
 130019 				(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpTargetFd = p
 130020 				(*Rbu_file)(unsafe.Pointer(p)).FpRbu = pRbu
 130021 				rbuMainlistAdd(tls, p)
 130022 				if (*Rbu_file)(unsafe.Pointer(p)).FpWalFd != 0 {
 130023 					(*Rbu_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpWalFd)).FpRbu = pRbu
 130024 				}
 130025 				rc = SQLITE_OK
 130026 			}
 130027 		}
 130028 		return rc
 130029 	} else if op == SQLITE_FCNTL_RBUCNT {
 130030 		var pRbu uintptr = pArg
 130031 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnRbu++
 130032 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd = p
 130033 		(*Rbu_file)(unsafe.Pointer(p)).FbNolock = U8(1)
 130034 	}
 130035 
 130036 	rc = (*struct {
 130037 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 130038 	})(unsafe.Pointer(&struct{ uintptr }{xControl})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, op, pArg)
 130039 	if rc == SQLITE_OK && op == SQLITE_FCNTL_VFSNAME {
 130040 		var pRbuVfs uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs
 130041 		var zIn uintptr = *(*uintptr)(unsafe.Pointer(pArg))
 130042 		var zOut uintptr = Xsqlite3_mprintf(tls, ts+32373, libc.VaList(bp, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fbase.FzName, zIn))
 130043 		*(*uintptr)(unsafe.Pointer(pArg)) = zOut
 130044 		if zOut == uintptr(0) {
 130045 			rc = SQLITE_NOMEM
 130046 		}
 130047 	}
 130048 
 130049 	return rc
 130050 }
 130051 
 130052 func rbuVfsSectorSize(tls *libc.TLS, pFile uintptr) int32 {
 130053 	var p uintptr = pFile
 130054 	return (*struct {
 130055 		f func(*libc.TLS, uintptr) int32
 130056 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxSectorSize})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal)
 130057 }
 130058 
 130059 func rbuVfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 {
 130060 	var p uintptr = pFile
 130061 	return (*struct {
 130062 		f func(*libc.TLS, uintptr) int32
 130063 	})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxDeviceCharacteristics})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal)
 130064 }
 130065 
 130066 func rbuVfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 {
 130067 	var p uintptr = pFile
 130068 	var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu
 130069 	var rc int32 = SQLITE_OK
 130070 
 130071 	if pRbu != 0 && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL ||
 130072 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_MOVE ||
 130073 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_DONE) {
 130074 		if ofst == WAL_LOCK_CKPT && n == 1 {
 130075 			rc = SQLITE_BUSY
 130076 		}
 130077 	} else {
 130078 		var bCapture int32 = 0
 130079 		if pRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE {
 130080 			bCapture = 1
 130081 		}
 130082 		if bCapture == 0 || 0 == flags&SQLITE_SHM_UNLOCK {
 130083 			rc = (*struct {
 130084 				f func(*libc.TLS, uintptr, int32, int32, int32) int32
 130085 			})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmLock})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, ofst, n, flags)
 130086 			if bCapture != 0 && rc == SQLITE_OK {
 130087 				*(*U32)(unsafe.Pointer(pRbu + 196)) |= U32((int32(1)<<n - 1) << ofst)
 130088 			}
 130089 		}
 130090 	}
 130091 
 130092 	return rc
 130093 }
 130094 
 130095 func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) int32 {
 130096 	var p uintptr = pFile
 130097 	var rc int32 = SQLITE_OK
 130098 	var eStage int32 = func() int32 {
 130099 		if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
 130100 			return (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage
 130101 		}
 130102 		return 0
 130103 	}()
 130104 
 130105 	if eStage == RBU_STAGE_OAL {
 130106 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(iRegion+1) * uint32(unsafe.Sizeof(uintptr(0))))
 130107 		var apNew uintptr = Xsqlite3_realloc64(tls, (*Rbu_file)(unsafe.Pointer(p)).FapShm, uint64(nByte))
 130108 
 130109 		if apNew == uintptr(0) {
 130110 			rc = SQLITE_NOMEM
 130111 		} else {
 130112 			libc.Xmemset(tls, apNew+uintptr((*Rbu_file)(unsafe.Pointer(p)).FnShm)*4, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32(1+iRegion-(*Rbu_file)(unsafe.Pointer(p)).FnShm))
 130113 			(*Rbu_file)(unsafe.Pointer(p)).FapShm = apNew
 130114 			(*Rbu_file)(unsafe.Pointer(p)).FnShm = iRegion + 1
 130115 		}
 130116 
 130117 		if rc == SQLITE_OK {
 130118 			var pNew uintptr = Xsqlite3_malloc64(tls, uint64(szRegion))
 130119 			if pNew == uintptr(0) {
 130120 				rc = SQLITE_NOMEM
 130121 			} else {
 130122 				libc.Xmemset(tls, pNew, 0, uint32(szRegion))
 130123 				*(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*4)) = pNew
 130124 			}
 130125 		}
 130126 
 130127 		if rc == SQLITE_OK {
 130128 			*(*uintptr)(unsafe.Pointer(pp)) = *(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*4))
 130129 		} else {
 130130 			*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 130131 		}
 130132 	} else {
 130133 		rc = (*struct {
 130134 			f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32
 130135 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmMap})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, iRegion, szRegion, isWrite, pp)
 130136 	}
 130137 
 130138 	return rc
 130139 }
 130140 
 130141 func rbuVfsShmBarrier(tls *libc.TLS, pFile uintptr) {
 130142 	var p uintptr = pFile
 130143 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmBarrier})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal)
 130144 }
 130145 
 130146 func rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 {
 130147 	var p uintptr = pFile
 130148 	var rc int32 = SQLITE_OK
 130149 	var eStage int32 = func() int32 {
 130150 		if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
 130151 			return (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage
 130152 		}
 130153 		return 0
 130154 	}()
 130155 
 130156 	if eStage == RBU_STAGE_OAL || eStage == RBU_STAGE_MOVE {
 130157 	} else {
 130158 		rbuUnlockShm(tls, p)
 130159 		rc = (*struct {
 130160 			f func(*libc.TLS, uintptr, int32) int32
 130161 		})(unsafe.Pointer(&struct{ uintptr }{(*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmUnmap})).f(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, delFlag)
 130162 	}
 130163 	return rc
 130164 }
 130165 
 130166 func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 {
 130167 	var pRbuVfs uintptr = pVfs
 130168 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs
 130169 	var pFd uintptr = pFile
 130170 	var rc int32 = SQLITE_OK
 130171 	var zOpen uintptr = zName
 130172 	var oflags int32 = flags
 130173 
 130174 	libc.Xmemset(tls, pFd, 0, uint32(unsafe.Sizeof(Rbu_file{})))
 130175 	(*Rbu_file)(unsafe.Pointer(pFd)).FpReal = pFd + 1*64
 130176 	(*Rbu_file)(unsafe.Pointer(pFd)).FpRbuVfs = pRbuVfs
 130177 	(*Rbu_file)(unsafe.Pointer(pFd)).FopenFlags = flags
 130178 	if zName != 0 {
 130179 		if flags&SQLITE_OPEN_MAIN_DB != 0 {
 130180 			(*Rbu_file)(unsafe.Pointer(pFd)).FzWal = Xsqlite3_filename_wal(tls, zName)
 130181 		} else if flags&SQLITE_OPEN_WAL != 0 {
 130182 			var pDb uintptr = rbuFindMaindb(tls, pRbuVfs, zName, 0)
 130183 			if pDb != 0 {
 130184 				if (*Rbu_file)(unsafe.Pointer(pDb)).FpRbu != 0 && (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == RBU_STAGE_OAL {
 130185 					var nOpen Size_t
 130186 					if (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FzTarget == uintptr(0) {
 130187 						zOpen = Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FdbRbu, ts+6441)
 130188 						zOpen = Xsqlite3_filename_wal(tls, zOpen)
 130189 					}
 130190 					nOpen = libc.Xstrlen(tls, zOpen)
 130191 					*(*uint8)(unsafe.Pointer(zOpen + uintptr(nOpen-Size_t(3)))) = uint8('o')
 130192 					(*Rbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Rbu_file)(unsafe.Pointer(pDb)).FpRbu
 130193 				}
 130194 				(*Rbu_file)(unsafe.Pointer(pDb)).FpWalFd = pFd
 130195 			}
 130196 		}
 130197 	} else {
 130198 		(*Rbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRbu
 130199 	}
 130200 
 130201 	if oflags&SQLITE_OPEN_MAIN_DB != 0 &&
 130202 		Xsqlite3_uri_boolean(tls, zName, ts+32384, 0) != 0 {
 130203 		oflags = SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE
 130204 		zOpen = uintptr(0)
 130205 	}
 130206 
 130207 	if rc == SQLITE_OK {
 130208 		rc = (*struct {
 130209 			f func(*libc.TLS, uintptr, Sqlite3_filename, uintptr, int32, uintptr) int32
 130210 		})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxOpen})).f(tls, pRealVfs, zOpen, (*Rbu_file)(unsafe.Pointer(pFd)).FpReal, oflags, pOutFlags)
 130211 	}
 130212 	if (*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 {
 130213 		var pMeth uintptr = (*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods
 130214 
 130215 		if (*Sqlite3_io_methods)(unsafe.Pointer(pMeth)).FiVersion < 2 || (*Sqlite3_io_methods)(unsafe.Pointer(pMeth)).FxShmLock == uintptr(0) {
 130216 			(*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&rbuvfs_io_methods1))
 130217 		} else {
 130218 			(*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&rbuvfs_io_methods))
 130219 		}
 130220 		if flags&SQLITE_OPEN_MAIN_DB != 0 {
 130221 			rbuMainlistAdd(tls, pFd)
 130222 		}
 130223 	} else {
 130224 		Xsqlite3_free(tls, (*Rbu_file)(unsafe.Pointer(pFd)).FzDel)
 130225 	}
 130226 
 130227 	return rc
 130228 }
 130229 
 130230 var rbuvfs_io_methods = Sqlite3_io_methods{
 130231 	FiVersion:               2,
 130232 	FxClose:                 0,
 130233 	FxRead:                  0,
 130234 	FxWrite:                 0,
 130235 	FxTruncate:              0,
 130236 	FxSync:                  0,
 130237 	FxFileSize:              0,
 130238 	FxLock:                  0,
 130239 	FxUnlock:                0,
 130240 	FxCheckReservedLock:     0,
 130241 	FxFileControl:           0,
 130242 	FxSectorSize:            0,
 130243 	FxDeviceCharacteristics: 0,
 130244 	FxShmMap:                0,
 130245 	FxShmLock:               0,
 130246 	FxShmBarrier:            0,
 130247 	FxShmUnmap:              0,
 130248 }
 130249 var rbuvfs_io_methods1 = Sqlite3_io_methods{
 130250 	FiVersion:               1,
 130251 	FxClose:                 0,
 130252 	FxRead:                  0,
 130253 	FxWrite:                 0,
 130254 	FxTruncate:              0,
 130255 	FxSync:                  0,
 130256 	FxFileSize:              0,
 130257 	FxLock:                  0,
 130258 	FxUnlock:                0,
 130259 	FxCheckReservedLock:     0,
 130260 	FxFileControl:           0,
 130261 	FxSectorSize:            0,
 130262 	FxDeviceCharacteristics: 0,
 130263 }
 130264 
 130265 func rbuVfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 {
 130266 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130267 	return (*struct {
 130268 		f func(*libc.TLS, uintptr, uintptr, int32) int32
 130269 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDelete})).f(tls, pRealVfs, zPath, dirSync)
 130270 }
 130271 
 130272 func rbuVfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 {
 130273 	bp := tls.Alloc(8)
 130274 	defer tls.Free(8)
 130275 
 130276 	var pRbuVfs uintptr = pVfs
 130277 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs
 130278 	var rc int32
 130279 
 130280 	rc = (*struct {
 130281 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 130282 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxAccess})).f(tls, pRealVfs, zPath, flags, pResOut)
 130283 
 130284 	if rc == SQLITE_OK && flags == SQLITE_ACCESS_EXISTS {
 130285 		var pDb uintptr = rbuFindMaindb(tls, pRbuVfs, zPath, 1)
 130286 		if pDb != 0 && (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == RBU_STAGE_OAL {
 130287 			if *(*int32)(unsafe.Pointer(pResOut)) != 0 {
 130288 				rc = SQLITE_CANTOPEN
 130289 			} else {
 130290 				*(*Sqlite3_int64)(unsafe.Pointer(bp)) = int64(0)
 130291 				rc = rbuVfsFileSize(tls, pDb, bp)
 130292 				*(*int32)(unsafe.Pointer(pResOut)) = libc.Bool32(*(*Sqlite3_int64)(unsafe.Pointer(bp)) > int64(0))
 130293 			}
 130294 		}
 130295 	}
 130296 
 130297 	return rc
 130298 }
 130299 
 130300 func rbuVfsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 {
 130301 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130302 	return (*struct {
 130303 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 130304 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxFullPathname})).f(tls, pRealVfs, zPath, nOut, zOut)
 130305 }
 130306 
 130307 func rbuVfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr {
 130308 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130309 	return (*struct {
 130310 		f func(*libc.TLS, uintptr, uintptr) uintptr
 130311 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlOpen})).f(tls, pRealVfs, zPath)
 130312 }
 130313 
 130314 func rbuVfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) {
 130315 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130316 	(*struct {
 130317 		f func(*libc.TLS, uintptr, int32, uintptr)
 130318 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlError})).f(tls, pRealVfs, nByte, zErrMsg)
 130319 }
 130320 
 130321 func rbuVfsDlSym(tls *libc.TLS, pVfs uintptr, pArg uintptr, zSym uintptr) uintptr {
 130322 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130323 	return (*struct {
 130324 		f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr
 130325 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlSym})).f(tls, pRealVfs, pArg, zSym)
 130326 }
 130327 
 130328 func rbuVfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) {
 130329 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130330 	(*struct {
 130331 		f func(*libc.TLS, uintptr, uintptr)
 130332 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlClose})).f(tls, pRealVfs, pHandle)
 130333 }
 130334 
 130335 func rbuVfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 {
 130336 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130337 	return (*struct {
 130338 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 130339 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxRandomness})).f(tls, pRealVfs, nByte, zBufOut)
 130340 }
 130341 
 130342 func rbuVfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 {
 130343 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130344 	return (*struct {
 130345 		f func(*libc.TLS, uintptr, int32) int32
 130346 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxSleep})).f(tls, pRealVfs, nMicro)
 130347 }
 130348 
 130349 func rbuVfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 {
 130350 	var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
 130351 	return (*struct {
 130352 		f func(*libc.TLS, uintptr, uintptr) int32
 130353 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxCurrentTime})).f(tls, pRealVfs, pTimeOut)
 130354 }
 130355 
 130356 func rbuVfsGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) int32 {
 130357 	return 0
 130358 }
 130359 
 130360 // Deregister and destroy an RBU vfs created by an earlier call to
 130361 // sqlite3rbu_create_vfs().
 130362 func Xsqlite3rbu_destroy_vfs(tls *libc.TLS, zName uintptr) {
 130363 	var pVfs uintptr = Xsqlite3_vfs_find(tls, zName)
 130364 	if pVfs != 0 && (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen == *(*uintptr)(unsafe.Pointer(&struct {
 130365 		f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32
 130366 	}{rbuVfsOpen})) {
 130367 		Xsqlite3_mutex_free(tls, (*Rbu_vfs)(unsafe.Pointer(pVfs)).Fmutex)
 130368 		Xsqlite3_vfs_unregister(tls, pVfs)
 130369 		Xsqlite3_free(tls, pVfs)
 130370 	}
 130371 }
 130372 
 130373 // Create an RBU VFS named zName that accesses the underlying file-system
 130374 // via existing VFS zParent. The new object is registered as a non-default
 130375 // VFS with SQLite before returning.
 130376 func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 {
 130377 	var pNew uintptr = uintptr(0)
 130378 	var rc int32 = SQLITE_OK
 130379 	var nName Size_t
 130380 	var nByte Size_t
 130381 
 130382 	nName = libc.Xstrlen(tls, zName)
 130383 	nByte = uint32(unsafe.Sizeof(Rbu_vfs{})) + nName + uint32(1)
 130384 	pNew = Xsqlite3_malloc64(tls, uint64(nByte))
 130385 	if pNew == uintptr(0) {
 130386 		rc = SQLITE_NOMEM
 130387 	} else {
 130388 		var pParent uintptr
 130389 		libc.Xmemset(tls, pNew, 0, nByte)
 130390 		pParent = Xsqlite3_vfs_find(tls, zParent)
 130391 		if pParent == uintptr(0) {
 130392 			rc = SQLITE_NOTFOUND
 130393 		} else {
 130394 			var zSpace uintptr
 130395 			libc.Xmemcpy(tls, pNew, uintptr(unsafe.Pointer(&vfs_template)), uint32(unsafe.Sizeof(Sqlite3_vfs{})))
 130396 			(*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FmxPathname = (*Sqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname
 130397 			(*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FszOsFile = int32(uint32(unsafe.Sizeof(Rbu_file{})) + uint32((*Sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile))
 130398 			(*Rbu_vfs)(unsafe.Pointer(pNew)).FpRealVfs = pParent
 130399 			(*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = libc.AssignUintptr(&zSpace, pNew+1*108)
 130400 			libc.Xmemcpy(tls, zSpace, zName, nName)
 130401 
 130402 			(*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_RECURSIVE)
 130403 			if (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex == uintptr(0) {
 130404 				rc = SQLITE_NOMEM
 130405 			} else {
 130406 				rc = Xsqlite3_vfs_register(tls, pNew, 0)
 130407 			}
 130408 		}
 130409 
 130410 		if rc != SQLITE_OK {
 130411 			Xsqlite3_mutex_free(tls, (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex)
 130412 			Xsqlite3_free(tls, pNew)
 130413 		}
 130414 	}
 130415 
 130416 	return rc
 130417 }
 130418 
 130419 var vfs_template = Sqlite3_vfs{
 130420 	FiVersion:      1,
 130421 	FxOpen:         0,
 130422 	FxDelete:       0,
 130423 	FxAccess:       0,
 130424 	FxFullPathname: 0,
 130425 	FxDlOpen:       0,
 130426 	FxDlError:      0,
 130427 	FxDlSym:        0,
 130428 	FxDlClose:      0,
 130429 	FxRandomness:   0,
 130430 	FxSleep:        0,
 130431 	FxCurrentTime:  0,
 130432 	FxGetLastError: 0,
 130433 }
 130434 
 130435 // Configure the aggregate temp file size limit for this RBU handle.
 130436 func Xsqlite3rbu_temp_size_limit(tls *libc.TLS, pRbu uintptr, n Sqlite3_int64) Sqlite3_int64 {
 130437 	if n >= int64(0) {
 130438 		(*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit = n
 130439 	}
 130440 	return (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit
 130441 }
 130442 
 130443 func Xsqlite3rbu_temp_size(tls *libc.TLS, pRbu uintptr) Sqlite3_int64 {
 130444 	return (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp
 130445 }
 130446 
 130447 type SessionTable1 = struct {
 130448 	FpNext    uintptr
 130449 	FzName    uintptr
 130450 	FnCol     int32
 130451 	FbStat1   int32
 130452 	FazCol    uintptr
 130453 	FabPK     uintptr
 130454 	FnEntry   int32
 130455 	FnChange  int32
 130456 	FapChange uintptr
 130457 }
 130458 
 130459 type SessionTable = SessionTable1
 130460 type SessionChange1 = struct {
 130461 	Fop          U8
 130462 	FbIndirect   U8
 130463 	F__ccgo_pad1 [2]byte
 130464 	FnMaxSize    int32
 130465 	FnRecord     int32
 130466 	FaRecord     uintptr
 130467 	FpNext       uintptr
 130468 }
 130469 
 130470 type SessionChange = SessionChange1
 130471 type SessionBuffer1 = struct {
 130472 	FaBuf   uintptr
 130473 	FnBuf   int32
 130474 	FnAlloc int32
 130475 }
 130476 
 130477 type SessionBuffer = SessionBuffer1
 130478 type SessionInput1 = struct {
 130479 	FbNoDiscard int32
 130480 	FiCurrent   int32
 130481 	FiNext      int32
 130482 	FaData      uintptr
 130483 	FnData      int32
 130484 	Fbuf        SessionBuffer
 130485 	FxInput     uintptr
 130486 	FpIn        uintptr
 130487 	FbEof       int32
 130488 }
 130489 
 130490 type SessionInput = SessionInput1
 130491 
 130492 var sessions_strm_chunk_size int32 = SESSIONS_STRM_CHUNK_SIZE
 130493 
 130494 type SessionHook1 = struct {
 130495 	FpCtx   uintptr
 130496 	FxOld   uintptr
 130497 	FxNew   uintptr
 130498 	FxCount uintptr
 130499 	FxDepth uintptr
 130500 }
 130501 
 130502 type SessionHook = SessionHook1
 130503 
 130504 func sessionVarintPut(tls *libc.TLS, aBuf uintptr, iVal int32) int32 {
 130505 	return int32(func() uint8 {
 130506 		if U32(iVal) < U32(0x80) {
 130507 			return uint8(func() int32 { *(*U8)(unsafe.Pointer(aBuf)) = uint8(iVal); return 1 }())
 130508 		}
 130509 		return uint8(Xsqlite3PutVarint(tls, aBuf, uint64(iVal)))
 130510 	}())
 130511 }
 130512 
 130513 func sessionVarintLen(tls *libc.TLS, iVal int32) int32 {
 130514 	return Xsqlite3VarintLen(tls, uint64(iVal))
 130515 }
 130516 
 130517 func sessionVarintGet(tls *libc.TLS, aBuf uintptr, piVal uintptr) int32 {
 130518 	return int32(func() uint8 {
 130519 		if int32(*(*U8)(unsafe.Pointer(aBuf))) < int32(U8(0x80)) {
 130520 			return uint8(func() int32 { *(*int32)(unsafe.Pointer(piVal)) = int32(U32(*(*U8)(unsafe.Pointer(aBuf)))); return 1 }())
 130521 		}
 130522 		return Xsqlite3GetVarint32(tls, aBuf, piVal)
 130523 	}())
 130524 }
 130525 
 130526 func sessionGetI64(tls *libc.TLS, aRec uintptr) Sqlite3_int64 {
 130527 	var x U64 = U64(U32(*(*U8)(unsafe.Pointer(aRec)))<<24 | U32(int32(*(*U8)(unsafe.Pointer(aRec + 1)))<<16) | U32(int32(*(*U8)(unsafe.Pointer(aRec + 2)))<<8) | U32(*(*U8)(unsafe.Pointer(aRec + 3))))
 130528 	var y U32 = U32(*(*U8)(unsafe.Pointer(aRec + uintptr(4))))<<24 | U32(int32(*(*U8)(unsafe.Pointer(aRec + uintptr(4) + 1)))<<16) | U32(int32(*(*U8)(unsafe.Pointer(aRec + uintptr(4) + 2)))<<8) | U32(*(*U8)(unsafe.Pointer(aRec + uintptr(4) + 3)))
 130529 	x = x<<32 + U64(y)
 130530 	return Sqlite3_int64(x)
 130531 }
 130532 
 130533 func sessionPutI64(tls *libc.TLS, aBuf uintptr, i Sqlite3_int64) {
 130534 	*(*U8)(unsafe.Pointer(aBuf)) = U8(i >> 56 & int64(0xFF))
 130535 	*(*U8)(unsafe.Pointer(aBuf + 1)) = U8(i >> 48 & int64(0xFF))
 130536 	*(*U8)(unsafe.Pointer(aBuf + 2)) = U8(i >> 40 & int64(0xFF))
 130537 	*(*U8)(unsafe.Pointer(aBuf + 3)) = U8(i >> 32 & int64(0xFF))
 130538 	*(*U8)(unsafe.Pointer(aBuf + 4)) = U8(i >> 24 & int64(0xFF))
 130539 	*(*U8)(unsafe.Pointer(aBuf + 5)) = U8(i >> 16 & int64(0xFF))
 130540 	*(*U8)(unsafe.Pointer(aBuf + 6)) = U8(i >> 8 & int64(0xFF))
 130541 	*(*U8)(unsafe.Pointer(aBuf + 7)) = U8(i >> 0 & int64(0xFF))
 130542 }
 130543 
 130544 func sessionSerializeValue(tls *libc.TLS, aBuf uintptr, pValue uintptr, pnWrite uintptr) int32 {
 130545 	bp := tls.Alloc(16)
 130546 	defer tls.Free(16)
 130547 
 130548 	var nByte int32
 130549 
 130550 	if pValue != 0 {
 130551 		var eType int32
 130552 
 130553 		eType = Xsqlite3_value_type(tls, pValue)
 130554 		if aBuf != 0 {
 130555 			*(*U8)(unsafe.Pointer(aBuf)) = U8(eType)
 130556 		}
 130557 
 130558 		switch eType {
 130559 		case SQLITE_NULL:
 130560 			nByte = 1
 130561 			break
 130562 			fallthrough
 130563 
 130564 		case SQLITE_INTEGER:
 130565 			fallthrough
 130566 		case SQLITE_FLOAT:
 130567 			if aBuf != 0 {
 130568 				if eType == SQLITE_INTEGER {
 130569 					*(*U64)(unsafe.Pointer(bp)) = U64(Xsqlite3_value_int64(tls, pValue))
 130570 				} else {
 130571 					*(*float64)(unsafe.Pointer(bp + 8)) = Xsqlite3_value_double(tls, pValue)
 130572 					libc.Xmemcpy(tls, bp, bp+8, uint32(8))
 130573 				}
 130574 				sessionPutI64(tls, aBuf+1, int64(*(*U64)(unsafe.Pointer(bp))))
 130575 			}
 130576 			nByte = 9
 130577 			break
 130578 			fallthrough
 130579 
 130580 		default:
 130581 			{
 130582 				var z uintptr
 130583 				var n int32
 130584 				var nVarint int32
 130585 
 130586 				if eType == SQLITE_TEXT {
 130587 					z = Xsqlite3_value_text(tls, pValue)
 130588 				} else {
 130589 					z = Xsqlite3_value_blob(tls, pValue)
 130590 				}
 130591 				n = Xsqlite3_value_bytes(tls, pValue)
 130592 				if z == uintptr(0) && (eType != SQLITE_BLOB || n > 0) {
 130593 					return SQLITE_NOMEM
 130594 				}
 130595 				nVarint = sessionVarintLen(tls, n)
 130596 
 130597 				if aBuf != 0 {
 130598 					sessionVarintPut(tls, aBuf+1, n)
 130599 					if n > 0 {
 130600 						libc.Xmemcpy(tls, aBuf+uintptr(nVarint+1), z, uint32(n))
 130601 					}
 130602 				}
 130603 
 130604 				nByte = 1 + nVarint + n
 130605 				break
 130606 
 130607 			}
 130608 		}
 130609 	} else {
 130610 		nByte = 1
 130611 		if aBuf != 0 {
 130612 			*(*U8)(unsafe.Pointer(aBuf)) = U8(0)
 130613 		}
 130614 	}
 130615 
 130616 	if pnWrite != 0 {
 130617 		*(*Sqlite3_int64)(unsafe.Pointer(pnWrite)) += Sqlite3_int64(nByte)
 130618 	}
 130619 	return SQLITE_OK
 130620 }
 130621 
 130622 func sessionMalloc64(tls *libc.TLS, pSession uintptr, nByte I64) uintptr {
 130623 	var pRet uintptr = Xsqlite3_malloc64(tls, uint64(nByte))
 130624 	if pSession != 0 {
 130625 		*(*I64)(unsafe.Pointer(pSession + 40)) += I64(Xsqlite3_msize(tls, pRet))
 130626 	}
 130627 	return pRet
 130628 }
 130629 
 130630 func sessionFree(tls *libc.TLS, pSession uintptr, pFree uintptr) {
 130631 	if pSession != 0 {
 130632 		*(*I64)(unsafe.Pointer(pSession + 40)) -= I64(Xsqlite3_msize(tls, pFree))
 130633 	}
 130634 	Xsqlite3_free(tls, pFree)
 130635 }
 130636 
 130637 func sessionHashAppendI64(tls *libc.TLS, h uint32, i I64) uint32 {
 130638 	h = h<<3 ^ h ^ uint32(i&int64(0xFFFFFFFF))
 130639 	return h<<3 ^ h ^ uint32(i>>32&int64(0xFFFFFFFF))
 130640 }
 130641 
 130642 func sessionHashAppendBlob(tls *libc.TLS, h uint32, n int32, z uintptr) uint32 {
 130643 	var i int32
 130644 	for i = 0; i < n; i++ {
 130645 		h = h<<3 ^ h ^ uint32(*(*U8)(unsafe.Pointer(z + uintptr(i))))
 130646 	}
 130647 	return h
 130648 }
 130649 
 130650 func sessionHashAppendType(tls *libc.TLS, h uint32, eType int32) uint32 {
 130651 	return h<<3 ^ h ^ uint32(eType)
 130652 }
 130653 
 130654 func sessionPreupdateHash(tls *libc.TLS, pSession uintptr, pTab uintptr, bNew int32, piHash uintptr, pbNullPK uintptr) int32 {
 130655 	bp := tls.Alloc(24)
 130656 	defer tls.Free(24)
 130657 
 130658 	var h uint32 = uint32(0)
 130659 	var i int32
 130660 
 130661 	for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 130662 		if *(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 {
 130663 			var rc int32
 130664 			var eType int32
 130665 
 130666 			if bNew != 0 {
 130667 				rc = (*struct {
 130668 					f func(*libc.TLS, uintptr, int32, uintptr) int32
 130669 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, i, bp)
 130670 			} else {
 130671 				rc = (*struct {
 130672 					f func(*libc.TLS, uintptr, int32, uintptr) int32
 130673 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, i, bp)
 130674 			}
 130675 			if rc != SQLITE_OK {
 130676 				return rc
 130677 			}
 130678 
 130679 			eType = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130680 			h = sessionHashAppendType(tls, h, eType)
 130681 			if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 130682 				if eType == SQLITE_INTEGER {
 130683 					*(*I64)(unsafe.Pointer(bp + 8)) = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130684 				} else {
 130685 					*(*float64)(unsafe.Pointer(bp + 16)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130686 
 130687 					libc.Xmemcpy(tls, bp+8, bp+16, uint32(8))
 130688 				}
 130689 				h = sessionHashAppendI64(tls, h, *(*I64)(unsafe.Pointer(bp + 8)))
 130690 			} else if eType == SQLITE_TEXT || eType == SQLITE_BLOB {
 130691 				var z uintptr
 130692 				var n int32
 130693 				if eType == SQLITE_TEXT {
 130694 					z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130695 				} else {
 130696 					z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130697 				}
 130698 				n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130699 				if !(z != 0) && (eType != SQLITE_BLOB || n > 0) {
 130700 					return SQLITE_NOMEM
 130701 				}
 130702 				h = sessionHashAppendBlob(tls, h, n, z)
 130703 			} else {
 130704 				*(*int32)(unsafe.Pointer(pbNullPK)) = 1
 130705 			}
 130706 		}
 130707 	}
 130708 
 130709 	*(*int32)(unsafe.Pointer(piHash)) = int32(h % uint32((*SessionTable)(unsafe.Pointer(pTab)).FnChange))
 130710 	return SQLITE_OK
 130711 }
 130712 
 130713 func sessionSerialLen(tls *libc.TLS, a uintptr) int32 {
 130714 	bp := tls.Alloc(4)
 130715 	defer tls.Free(4)
 130716 
 130717 	var e int32 = int32(*(*U8)(unsafe.Pointer(a)))
 130718 
 130719 	if e == 0 || e == 0xFF {
 130720 		return 1
 130721 	}
 130722 	if e == SQLITE_NULL {
 130723 		return 1
 130724 	}
 130725 	if e == SQLITE_INTEGER || e == SQLITE_FLOAT {
 130726 		return 9
 130727 	}
 130728 	return sessionVarintGet(tls, a+1, bp) + 1 + *(*int32)(unsafe.Pointer(bp))
 130729 }
 130730 
 130731 func sessionChangeHash(tls *libc.TLS, pTab uintptr, bPkOnly int32, aRecord uintptr, nBucket int32) uint32 {
 130732 	bp := tls.Alloc(4)
 130733 	defer tls.Free(4)
 130734 
 130735 	var h uint32 = uint32(0)
 130736 	var i int32
 130737 	var a uintptr = aRecord
 130738 
 130739 	for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 130740 		var eType int32 = int32(*(*U8)(unsafe.Pointer(a)))
 130741 		var isPK int32 = int32(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))))
 130742 		if bPkOnly != 0 && isPK == 0 {
 130743 			continue
 130744 		}
 130745 
 130746 		if isPK != 0 {
 130747 			a++
 130748 			h = sessionHashAppendType(tls, h, eType)
 130749 			if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 130750 				h = sessionHashAppendI64(tls, h, sessionGetI64(tls, a))
 130751 				a += uintptr(8)
 130752 			} else {
 130753 				a += uintptr(sessionVarintGet(tls, a, bp))
 130754 				h = sessionHashAppendBlob(tls, h, *(*int32)(unsafe.Pointer(bp)), a)
 130755 				a += uintptr(*(*int32)(unsafe.Pointer(bp)))
 130756 			}
 130757 		} else {
 130758 			a += uintptr(sessionSerialLen(tls, a))
 130759 		}
 130760 	}
 130761 	return h % uint32(nBucket)
 130762 }
 130763 
 130764 func sessionChangeEqual(tls *libc.TLS, pTab uintptr, bLeftPkOnly int32, aLeft uintptr, bRightPkOnly int32, aRight uintptr) int32 {
 130765 	var a1 uintptr = aLeft
 130766 	var a2 uintptr = aRight
 130767 	var iCol int32
 130768 
 130769 	for iCol = 0; iCol < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; iCol++ {
 130770 		if *(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(iCol))) != 0 {
 130771 			var n1 int32 = sessionSerialLen(tls, a1)
 130772 			var n2 int32 = sessionSerialLen(tls, a2)
 130773 
 130774 			if n1 != n2 || libc.Xmemcmp(tls, a1, a2, uint32(n1)) != 0 {
 130775 				return 0
 130776 			}
 130777 			a1 += uintptr(n1)
 130778 			a2 += uintptr(n2)
 130779 		} else {
 130780 			if bLeftPkOnly == 0 {
 130781 				a1 += uintptr(sessionSerialLen(tls, a1))
 130782 			}
 130783 			if bRightPkOnly == 0 {
 130784 				a2 += uintptr(sessionSerialLen(tls, a2))
 130785 			}
 130786 		}
 130787 	}
 130788 
 130789 	return 1
 130790 }
 130791 
 130792 func sessionMergeRecord(tls *libc.TLS, paOut uintptr, nCol int32, aLeft uintptr, aRight uintptr) {
 130793 	var a1 uintptr = aLeft
 130794 	var a2 uintptr = aRight
 130795 	var aOut uintptr = *(*uintptr)(unsafe.Pointer(paOut))
 130796 	var iCol int32
 130797 
 130798 	for iCol = 0; iCol < nCol; iCol++ {
 130799 		var n1 int32 = sessionSerialLen(tls, a1)
 130800 		var n2 int32 = sessionSerialLen(tls, a2)
 130801 		if *(*U8)(unsafe.Pointer(a2)) != 0 {
 130802 			libc.Xmemcpy(tls, aOut, a2, uint32(n2))
 130803 			aOut += uintptr(n2)
 130804 		} else {
 130805 			libc.Xmemcpy(tls, aOut, a1, uint32(n1))
 130806 			aOut += uintptr(n1)
 130807 		}
 130808 		a1 += uintptr(n1)
 130809 		a2 += uintptr(n2)
 130810 	}
 130811 
 130812 	*(*uintptr)(unsafe.Pointer(paOut)) = aOut
 130813 }
 130814 
 130815 func sessionMergeValue(tls *libc.TLS, paOne uintptr, paTwo uintptr, pnVal uintptr) uintptr {
 130816 	var a1 uintptr = *(*uintptr)(unsafe.Pointer(paOne))
 130817 	var a2 uintptr = *(*uintptr)(unsafe.Pointer(paTwo))
 130818 	var pRet uintptr = uintptr(0)
 130819 	var n1 int32
 130820 
 130821 	if a2 != 0 {
 130822 		var n2 int32 = sessionSerialLen(tls, a2)
 130823 		if *(*U8)(unsafe.Pointer(a2)) != 0 {
 130824 			*(*int32)(unsafe.Pointer(pnVal)) = n2
 130825 			pRet = a2
 130826 		}
 130827 		*(*uintptr)(unsafe.Pointer(paTwo)) = a2 + uintptr(n2)
 130828 	}
 130829 
 130830 	n1 = sessionSerialLen(tls, a1)
 130831 	if pRet == uintptr(0) {
 130832 		*(*int32)(unsafe.Pointer(pnVal)) = n1
 130833 		pRet = a1
 130834 	}
 130835 	*(*uintptr)(unsafe.Pointer(paOne)) = a1 + uintptr(n1)
 130836 
 130837 	return pRet
 130838 }
 130839 
 130840 func sessionMergeUpdate(tls *libc.TLS, paOut uintptr, pTab uintptr, bPatchset int32, aOldRecord1 uintptr, aOldRecord2 uintptr, aNewRecord1 uintptr, aNewRecord2 uintptr) int32 {
 130841 	bp := tls.Alloc(32)
 130842 	defer tls.Free(32)
 130843 
 130844 	*(*uintptr)(unsafe.Pointer(bp)) = aOldRecord1
 130845 	*(*uintptr)(unsafe.Pointer(bp + 4)) = aOldRecord2
 130846 	*(*uintptr)(unsafe.Pointer(bp + 12)) = aNewRecord1
 130847 	*(*uintptr)(unsafe.Pointer(bp + 16)) = aNewRecord2
 130848 
 130849 	var aOut uintptr = *(*uintptr)(unsafe.Pointer(paOut))
 130850 	var i int32
 130851 
 130852 	if bPatchset == 0 {
 130853 		var bRequired int32 = 0
 130854 
 130855 		for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 130856 			var aOld uintptr
 130857 
 130858 			var aNew uintptr
 130859 
 130860 			aOld = sessionMergeValue(tls, bp, bp+4, bp+8)
 130861 			aNew = sessionMergeValue(tls, bp+12, bp+16, bp+20)
 130862 			if *(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 || *(*int32)(unsafe.Pointer(bp + 8)) != *(*int32)(unsafe.Pointer(bp + 20)) || libc.Xmemcmp(tls, aOld, aNew, uint32(*(*int32)(unsafe.Pointer(bp + 20)))) != 0 {
 130863 				if int32(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 {
 130864 					bRequired = 1
 130865 				}
 130866 				libc.Xmemcpy(tls, aOut, aOld, uint32(*(*int32)(unsafe.Pointer(bp + 8))))
 130867 				aOut += uintptr(*(*int32)(unsafe.Pointer(bp + 8)))
 130868 			} else {
 130869 				*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&aOut, 1))) = U8(0)
 130870 			}
 130871 		}
 130872 
 130873 		if !(bRequired != 0) {
 130874 			return 0
 130875 		}
 130876 	}
 130877 
 130878 	*(*uintptr)(unsafe.Pointer(bp)) = aOldRecord1
 130879 	*(*uintptr)(unsafe.Pointer(bp + 4)) = aOldRecord2
 130880 	*(*uintptr)(unsafe.Pointer(bp + 12)) = aNewRecord1
 130881 	*(*uintptr)(unsafe.Pointer(bp + 16)) = aNewRecord2
 130882 	for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 130883 		var aOld uintptr
 130884 
 130885 		var aNew uintptr
 130886 
 130887 		aOld = sessionMergeValue(tls, bp, bp+4, bp+24)
 130888 		aNew = sessionMergeValue(tls, bp+12, bp+16, bp+28)
 130889 		if bPatchset == 0 &&
 130890 			(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0 || *(*int32)(unsafe.Pointer(bp + 24)) == *(*int32)(unsafe.Pointer(bp + 28)) && 0 == libc.Xmemcmp(tls, aOld, aNew, uint32(*(*int32)(unsafe.Pointer(bp + 28))))) {
 130891 			*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&aOut, 1))) = U8(0)
 130892 		} else {
 130893 			libc.Xmemcpy(tls, aOut, aNew, uint32(*(*int32)(unsafe.Pointer(bp + 28))))
 130894 			aOut += uintptr(*(*int32)(unsafe.Pointer(bp + 28)))
 130895 		}
 130896 	}
 130897 
 130898 	*(*uintptr)(unsafe.Pointer(paOut)) = aOut
 130899 	return 1
 130900 }
 130901 
 130902 func sessionPreupdateEqual(tls *libc.TLS, pSession uintptr, pTab uintptr, pChange uintptr, op int32) int32 {
 130903 	bp := tls.Alloc(28)
 130904 	defer tls.Free(28)
 130905 
 130906 	var iCol int32
 130907 	var a uintptr = (*SessionChange)(unsafe.Pointer(pChange)).FaRecord
 130908 
 130909 	for iCol = 0; iCol < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; iCol++ {
 130910 		if !(int32(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(iCol)))) != 0) {
 130911 			a += uintptr(sessionSerialLen(tls, a))
 130912 		} else {
 130913 			var rc int32
 130914 			_ = rc
 130915 			var eType int32 = int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1))))
 130916 
 130917 			if op == SQLITE_INSERT {
 130918 				rc = (*struct {
 130919 					f func(*libc.TLS, uintptr, int32, uintptr) int32
 130920 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iCol, bp)
 130921 			} else {
 130922 				rc = (*struct {
 130923 					f func(*libc.TLS, uintptr, int32, uintptr) int32
 130924 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, iCol, bp)
 130925 			}
 130926 
 130927 			if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp))) != eType {
 130928 				return 0
 130929 			}
 130930 
 130931 			if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 130932 				*(*I64)(unsafe.Pointer(bp + 16)) = sessionGetI64(tls, a)
 130933 				a += uintptr(8)
 130934 				if eType == SQLITE_INTEGER {
 130935 					if Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(bp))) != *(*I64)(unsafe.Pointer(bp + 16)) {
 130936 						return 0
 130937 					}
 130938 				} else {
 130939 					libc.Xmemcpy(tls, bp+8, bp+16, uint32(8))
 130940 					if Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(bp))) != *(*float64)(unsafe.Pointer(bp + 8)) {
 130941 						return 0
 130942 					}
 130943 				}
 130944 			} else {
 130945 				var z uintptr
 130946 				a += uintptr(sessionVarintGet(tls, a, bp+24))
 130947 				if Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(bp))) != *(*int32)(unsafe.Pointer(bp + 24)) {
 130948 					return 0
 130949 				}
 130950 				if eType == SQLITE_TEXT {
 130951 					z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130952 				} else {
 130953 					z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(bp)))
 130954 				}
 130955 				if *(*int32)(unsafe.Pointer(bp + 24)) > 0 && libc.Xmemcmp(tls, a, z, uint32(*(*int32)(unsafe.Pointer(bp + 24)))) != 0 {
 130956 					return 0
 130957 				}
 130958 				a += uintptr(*(*int32)(unsafe.Pointer(bp + 24)))
 130959 			}
 130960 		}
 130961 	}
 130962 
 130963 	return 1
 130964 }
 130965 
 130966 func sessionGrowHash(tls *libc.TLS, pSession uintptr, bPatchset int32, pTab uintptr) int32 {
 130967 	if (*SessionTable)(unsafe.Pointer(pTab)).FnChange == 0 || (*SessionTable)(unsafe.Pointer(pTab)).FnEntry >= (*SessionTable)(unsafe.Pointer(pTab)).FnChange/2 {
 130968 		var i int32
 130969 		var apNew uintptr
 130970 		var nNew Sqlite3_int64 = int64(2) * func() int64 {
 130971 			if (*SessionTable)(unsafe.Pointer(pTab)).FnChange != 0 {
 130972 				return int64((*SessionTable)(unsafe.Pointer(pTab)).FnChange)
 130973 			}
 130974 			return int64(128)
 130975 		}()
 130976 
 130977 		apNew = sessionMalloc64(tls,
 130978 			pSession, Sqlite3_int64(unsafe.Sizeof(uintptr(0)))*nNew)
 130979 		if apNew == uintptr(0) {
 130980 			if (*SessionTable)(unsafe.Pointer(pTab)).FnChange == 0 {
 130981 				return SQLITE_ERROR
 130982 			}
 130983 			return SQLITE_OK
 130984 		}
 130985 		libc.Xmemset(tls, apNew, 0, uint32(Sqlite3_int64(unsafe.Sizeof(uintptr(0)))*nNew))
 130986 
 130987 		for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnChange; i++ {
 130988 			var p uintptr
 130989 			var pNext uintptr
 130990 			for p = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*4)); p != 0; p = pNext {
 130991 				var bPkOnly int32 = libc.Bool32(int32((*SessionChange)(unsafe.Pointer(p)).Fop) == SQLITE_DELETE && bPatchset != 0)
 130992 				var iHash int32 = int32(sessionChangeHash(tls, pTab, bPkOnly, (*SessionChange)(unsafe.Pointer(p)).FaRecord, int32(nNew)))
 130993 				pNext = (*SessionChange)(unsafe.Pointer(p)).FpNext
 130994 				(*SessionChange)(unsafe.Pointer(p)).FpNext = *(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*4))
 130995 				*(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*4)) = p
 130996 			}
 130997 		}
 130998 
 130999 		sessionFree(tls, pSession, (*SessionTable)(unsafe.Pointer(pTab)).FapChange)
 131000 		(*SessionTable)(unsafe.Pointer(pTab)).FnChange = int32(nNew)
 131001 		(*SessionTable)(unsafe.Pointer(pTab)).FapChange = apNew
 131002 	}
 131003 
 131004 	return SQLITE_OK
 131005 }
 131006 
 131007 func sessionTableInfo(tls *libc.TLS, pSession uintptr, db uintptr, zDb uintptr, zThis uintptr, pnCol uintptr, pzTab uintptr, pazCol uintptr, pabPK uintptr) int32 {
 131008 	bp := tls.Alloc(20)
 131009 	defer tls.Free(20)
 131010 
 131011 	var zPragma uintptr
 131012 
 131013 	var rc int32
 131014 	var nByte Sqlite3_int64
 131015 	var nDbCol int32 = 0
 131016 	var nThis int32
 131017 	var i int32
 131018 	var pAlloc uintptr = uintptr(0)
 131019 	var azCol uintptr = uintptr(0)
 131020 	var abPK uintptr = uintptr(0)
 131021 
 131022 	nThis = Xsqlite3Strlen30(tls, zThis)
 131023 	if nThis == 12 && 0 == Xsqlite3_stricmp(tls, ts+11348, zThis) {
 131024 		rc = Xsqlite3_table_column_metadata(tls, db, zDb, zThis, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
 131025 		if rc == SQLITE_OK {
 131026 			zPragma = Xsqlite3_mprintf(tls,
 131027 				ts+32395, 0)
 131028 		} else if rc == SQLITE_ERROR {
 131029 			zPragma = Xsqlite3_mprintf(tls, ts+1554, 0)
 131030 		} else {
 131031 			*(*uintptr)(unsafe.Pointer(pazCol)) = uintptr(0)
 131032 			*(*uintptr)(unsafe.Pointer(pabPK)) = uintptr(0)
 131033 			*(*int32)(unsafe.Pointer(pnCol)) = 0
 131034 			if pzTab != 0 {
 131035 				*(*uintptr)(unsafe.Pointer(pzTab)) = uintptr(0)
 131036 			}
 131037 			return rc
 131038 		}
 131039 	} else {
 131040 		zPragma = Xsqlite3_mprintf(tls, ts+32516, libc.VaList(bp, zDb, zThis))
 131041 	}
 131042 	if !(zPragma != 0) {
 131043 		*(*uintptr)(unsafe.Pointer(pazCol)) = uintptr(0)
 131044 		*(*uintptr)(unsafe.Pointer(pabPK)) = uintptr(0)
 131045 		*(*int32)(unsafe.Pointer(pnCol)) = 0
 131046 		if pzTab != 0 {
 131047 			*(*uintptr)(unsafe.Pointer(pzTab)) = uintptr(0)
 131048 		}
 131049 		return SQLITE_NOMEM
 131050 	}
 131051 
 131052 	rc = Xsqlite3_prepare_v2(tls, db, zPragma, -1, bp+16, uintptr(0))
 131053 	Xsqlite3_free(tls, zPragma)
 131054 	if rc != SQLITE_OK {
 131055 		*(*uintptr)(unsafe.Pointer(pazCol)) = uintptr(0)
 131056 		*(*uintptr)(unsafe.Pointer(pabPK)) = uintptr(0)
 131057 		*(*int32)(unsafe.Pointer(pnCol)) = 0
 131058 		if pzTab != 0 {
 131059 			*(*uintptr)(unsafe.Pointer(pzTab)) = uintptr(0)
 131060 		}
 131061 		return rc
 131062 	}
 131063 
 131064 	nByte = Sqlite3_int64(nThis + 1)
 131065 	for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) {
 131066 		nByte = nByte + Sqlite3_int64(Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 1))
 131067 		nDbCol++
 131068 	}
 131069 	rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
 131070 
 131071 	if rc == SQLITE_OK {
 131072 		nByte = nByte + Sqlite3_int64(uint32(nDbCol)*(uint32(unsafe.Sizeof(uintptr(0)))+uint32(unsafe.Sizeof(U8(0)))+uint32(1)))
 131073 		pAlloc = sessionMalloc64(tls, pSession, nByte)
 131074 		if pAlloc == uintptr(0) {
 131075 			rc = SQLITE_NOMEM
 131076 		}
 131077 	}
 131078 	if rc == SQLITE_OK {
 131079 		azCol = pAlloc
 131080 		pAlloc = azCol + uintptr(nDbCol)*4
 131081 		abPK = pAlloc
 131082 		pAlloc = abPK + uintptr(nDbCol)
 131083 		if pzTab != 0 {
 131084 			libc.Xmemcpy(tls, pAlloc, zThis, uint32(nThis+1))
 131085 			*(*uintptr)(unsafe.Pointer(pzTab)) = pAlloc
 131086 			pAlloc += uintptr(nThis + 1)
 131087 		}
 131088 
 131089 		i = 0
 131090 		for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) {
 131091 			var nName int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 1)
 131092 			var zName uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 1)
 131093 			if zName == uintptr(0) {
 131094 				break
 131095 			}
 131096 			libc.Xmemcpy(tls, pAlloc, zName, uint32(nName+1))
 131097 			*(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*4)) = pAlloc
 131098 			pAlloc += uintptr(nName + 1)
 131099 			*(*U8)(unsafe.Pointer(abPK + uintptr(i))) = U8(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), 5))
 131100 			i++
 131101 		}
 131102 		rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
 131103 
 131104 	}
 131105 
 131106 	if rc == SQLITE_OK {
 131107 		*(*uintptr)(unsafe.Pointer(pazCol)) = azCol
 131108 		*(*uintptr)(unsafe.Pointer(pabPK)) = abPK
 131109 		*(*int32)(unsafe.Pointer(pnCol)) = nDbCol
 131110 	} else {
 131111 		*(*uintptr)(unsafe.Pointer(pazCol)) = uintptr(0)
 131112 		*(*uintptr)(unsafe.Pointer(pabPK)) = uintptr(0)
 131113 		*(*int32)(unsafe.Pointer(pnCol)) = 0
 131114 		if pzTab != 0 {
 131115 			*(*uintptr)(unsafe.Pointer(pzTab)) = uintptr(0)
 131116 		}
 131117 		sessionFree(tls, pSession, azCol)
 131118 	}
 131119 	Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
 131120 	return rc
 131121 }
 131122 
 131123 func sessionInitTable(tls *libc.TLS, pSession uintptr, pTab uintptr) int32 {
 131124 	bp := tls.Alloc(4)
 131125 	defer tls.Free(4)
 131126 
 131127 	if (*SessionTable)(unsafe.Pointer(pTab)).FnCol == 0 {
 131128 		(*Sqlite3_session)(unsafe.Pointer(pSession)).Frc = sessionTableInfo(tls, pSession, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb, (*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb,
 131129 			(*SessionTable)(unsafe.Pointer(pTab)).FzName, pTab+8, uintptr(0), pTab+16, bp)
 131130 		if (*Sqlite3_session)(unsafe.Pointer(pSession)).Frc == SQLITE_OK {
 131131 			var i int32
 131132 			for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 131133 				if *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)) + uintptr(i))) != 0 {
 131134 					(*SessionTable)(unsafe.Pointer(pTab)).FabPK = *(*uintptr)(unsafe.Pointer(bp))
 131135 					break
 131136 				}
 131137 			}
 131138 			if 0 == Xsqlite3_stricmp(tls, ts+11348, (*SessionTable)(unsafe.Pointer(pTab)).FzName) {
 131139 				(*SessionTable)(unsafe.Pointer(pTab)).FbStat1 = 1
 131140 			}
 131141 
 131142 			if (*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0 {
 131143 				*(*I64)(unsafe.Pointer(pSession + 48)) += I64(Size_t(1+sessionVarintLen(tls, (*SessionTable)(unsafe.Pointer(pTab)).FnCol)+(*SessionTable)(unsafe.Pointer(pTab)).FnCol) + libc.Xstrlen(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName) + Size_t(1))
 131144 			}
 131145 		}
 131146 	}
 131147 	return libc.Bool32((*Sqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 || (*SessionTable)(unsafe.Pointer(pTab)).FabPK == uintptr(0))
 131148 }
 131149 
 131150 // Versions of the four methods in object SessionHook for use with the
 131151 // sqlite_stat1 table. The purpose of this is to substitute a zero-length
 131152 // blob each time a NULL value is read from the "idx" column of the
 131153 // sqlite_stat1 table.
 131154 type SessionStat1Ctx1 = struct {
 131155 	Fhook     SessionHook
 131156 	FpSession uintptr
 131157 }
 131158 
 131159 // Versions of the four methods in object SessionHook for use with the
 131160 // sqlite_stat1 table. The purpose of this is to substitute a zero-length
 131161 // blob each time a NULL value is read from the "idx" column of the
 131162 // sqlite_stat1 table.
 131163 type SessionStat1Ctx = SessionStat1Ctx1
 131164 
 131165 func sessionStat1Old(tls *libc.TLS, pCtx uintptr, iCol int32, ppVal uintptr) int32 {
 131166 	bp := tls.Alloc(4)
 131167 	defer tls.Free(4)
 131168 
 131169 	var p uintptr = pCtx
 131170 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 131171 	var rc int32 = (*struct {
 131172 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131173 	})(unsafe.Pointer(&struct{ uintptr }{(*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxOld})).f(tls, (*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx, iCol, bp)
 131174 	if rc == SQLITE_OK && iCol == 1 && Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp))) == SQLITE_NULL {
 131175 		*(*uintptr)(unsafe.Pointer(bp)) = (*Sqlite3_session)(unsafe.Pointer((*SessionStat1Ctx)(unsafe.Pointer(p)).FpSession)).FpZeroBlob
 131176 	}
 131177 	*(*uintptr)(unsafe.Pointer(ppVal)) = *(*uintptr)(unsafe.Pointer(bp))
 131178 	return rc
 131179 }
 131180 
 131181 func sessionStat1New(tls *libc.TLS, pCtx uintptr, iCol int32, ppVal uintptr) int32 {
 131182 	bp := tls.Alloc(4)
 131183 	defer tls.Free(4)
 131184 
 131185 	var p uintptr = pCtx
 131186 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 131187 	var rc int32 = (*struct {
 131188 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131189 	})(unsafe.Pointer(&struct{ uintptr }{(*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxNew})).f(tls, (*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx, iCol, bp)
 131190 	if rc == SQLITE_OK && iCol == 1 && Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp))) == SQLITE_NULL {
 131191 		*(*uintptr)(unsafe.Pointer(bp)) = (*Sqlite3_session)(unsafe.Pointer((*SessionStat1Ctx)(unsafe.Pointer(p)).FpSession)).FpZeroBlob
 131192 	}
 131193 	*(*uintptr)(unsafe.Pointer(ppVal)) = *(*uintptr)(unsafe.Pointer(bp))
 131194 	return rc
 131195 }
 131196 
 131197 func sessionStat1Count(tls *libc.TLS, pCtx uintptr) int32 {
 131198 	var p uintptr = pCtx
 131199 	return (*struct {
 131200 		f func(*libc.TLS, uintptr) int32
 131201 	})(unsafe.Pointer(&struct{ uintptr }{(*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxCount})).f(tls, (*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx)
 131202 }
 131203 
 131204 func sessionStat1Depth(tls *libc.TLS, pCtx uintptr) int32 {
 131205 	var p uintptr = pCtx
 131206 	return (*struct {
 131207 		f func(*libc.TLS, uintptr) int32
 131208 	})(unsafe.Pointer(&struct{ uintptr }{(*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxDepth})).f(tls, (*SessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx)
 131209 }
 131210 
 131211 func sessionUpdateMaxSize(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr, pC uintptr) int32 {
 131212 	bp := tls.Alloc(44)
 131213 	defer tls.Free(44)
 131214 
 131215 	*(*I64)(unsafe.Pointer(bp + 8)) = int64(2)
 131216 	if int32((*SessionChange)(unsafe.Pointer(pC)).Fop) == SQLITE_INSERT {
 131217 		if op != SQLITE_DELETE {
 131218 			var ii int32
 131219 			for ii = 0; ii < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; ii++ {
 131220 				*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 131221 				(*struct {
 131222 					f func(*libc.TLS, uintptr, int32, uintptr) int32
 131223 				})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, ii, bp)
 131224 				sessionSerializeValue(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(bp)), bp+8)
 131225 			}
 131226 		}
 131227 	} else if op == SQLITE_DELETE {
 131228 		*(*I64)(unsafe.Pointer(bp + 8)) += I64((*SessionChange)(unsafe.Pointer(pC)).FnRecord)
 131229 		if Xsqlite3_preupdate_blobwrite(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb) >= 0 {
 131230 			*(*I64)(unsafe.Pointer(bp + 8)) += I64((*SessionChange)(unsafe.Pointer(pC)).FnRecord)
 131231 		}
 131232 	} else {
 131233 		var ii int32
 131234 		var pCsr uintptr = (*SessionChange)(unsafe.Pointer(pC)).FaRecord
 131235 		for ii = 0; ii < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; ii++ {
 131236 			var bChanged int32 = 1
 131237 			var nOld int32 = 0
 131238 			var eType int32
 131239 			*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 131240 			(*struct {
 131241 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 131242 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, ii, bp+16)
 131243 			if *(*uintptr)(unsafe.Pointer(bp + 16)) == uintptr(0) {
 131244 				return SQLITE_NOMEM
 131245 			}
 131246 
 131247 			eType = int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pCsr, 1))))
 131248 			switch eType {
 131249 			case SQLITE_NULL:
 131250 				bChanged = libc.Bool32(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) != SQLITE_NULL)
 131251 				break
 131252 				fallthrough
 131253 
 131254 			case SQLITE_FLOAT:
 131255 				fallthrough
 131256 			case SQLITE_INTEGER:
 131257 				{
 131258 					if eType == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) {
 131259 						*(*Sqlite3_int64)(unsafe.Pointer(bp + 32)) = sessionGetI64(tls, pCsr)
 131260 						if eType == SQLITE_INTEGER {
 131261 							bChanged = libc.Bool32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 32)) != Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 16))))
 131262 						} else {
 131263 							libc.Xmemcpy(tls, bp+24, bp+32, uint32(8))
 131264 							bChanged = libc.Bool32(*(*float64)(unsafe.Pointer(bp + 24)) != Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(bp + 16))))
 131265 						}
 131266 					}
 131267 					nOld = 8
 131268 					pCsr += uintptr(8)
 131269 					break
 131270 
 131271 				}
 131272 				fallthrough
 131273 
 131274 			default:
 131275 				{
 131276 					nOld = sessionVarintGet(tls, pCsr, bp+40)
 131277 					pCsr += uintptr(nOld)
 131278 					nOld = nOld + *(*int32)(unsafe.Pointer(bp + 40))
 131279 
 131280 					if eType == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) &&
 131281 						*(*int32)(unsafe.Pointer(bp + 40)) == Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 16))) &&
 131282 						(*(*int32)(unsafe.Pointer(bp + 40)) == 0 || 0 == libc.Xmemcmp(tls, pCsr, Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 16))), uint32(*(*int32)(unsafe.Pointer(bp + 40))))) {
 131283 						bChanged = 0
 131284 					}
 131285 					pCsr += uintptr(*(*int32)(unsafe.Pointer(bp + 40)))
 131286 					break
 131287 
 131288 				}
 131289 			}
 131290 
 131291 			if bChanged != 0 && *(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii))) != 0 {
 131292 				*(*I64)(unsafe.Pointer(bp + 8)) = I64((*SessionChange)(unsafe.Pointer(pC)).FnRecord + 2)
 131293 				break
 131294 			}
 131295 
 131296 			if bChanged != 0 {
 131297 				*(*I64)(unsafe.Pointer(bp + 8)) += I64(1 + nOld)
 131298 				sessionSerializeValue(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(bp + 16)), bp+8)
 131299 			} else if *(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(ii))) != 0 {
 131300 				*(*I64)(unsafe.Pointer(bp + 8)) += I64(2 + nOld)
 131301 			} else {
 131302 				*(*I64)(unsafe.Pointer(bp + 8)) += int64(2)
 131303 			}
 131304 		}
 131305 	}
 131306 
 131307 	if *(*I64)(unsafe.Pointer(bp + 8)) > I64((*SessionChange)(unsafe.Pointer(pC)).FnMaxSize) {
 131308 		var nIncr int32 = int32(*(*I64)(unsafe.Pointer(bp + 8)) - I64((*SessionChange)(unsafe.Pointer(pC)).FnMaxSize))
 131309 		(*SessionChange)(unsafe.Pointer(pC)).FnMaxSize = int32(*(*I64)(unsafe.Pointer(bp + 8)))
 131310 		*(*I64)(unsafe.Pointer(pSession + 48)) += I64(nIncr)
 131311 	}
 131312 	return SQLITE_OK
 131313 }
 131314 
 131315 func sessionPreupdateOneChange(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr) {
 131316 	bp := tls.Alloc(52)
 131317 	defer tls.Free(52)
 131318 
 131319 	var rc int32
 131320 
 131321 	var p uintptr
 131322 
 131323 	var i int32
 131324 
 131325 	var pC uintptr
 131326 	*(*int32)(unsafe.Pointer(bp + 28)) = 0
 131327 	rc = SQLITE_OK
 131328 	*(*SessionStat1Ctx)(unsafe.Pointer(bp)) = SessionStat1Ctx{}
 131329 
 131330 	if !((*Sqlite3_session)(unsafe.Pointer(pSession)).Frc != 0) {
 131331 		goto __1
 131332 	}
 131333 	return
 131334 __1:
 131335 	;
 131336 	if !(sessionInitTable(tls, pSession, pTab) != 0) {
 131337 		goto __2
 131338 	}
 131339 	return
 131340 __2:
 131341 	;
 131342 	if !((*SessionTable)(unsafe.Pointer(pTab)).FnCol != (*struct {
 131343 		f func(*libc.TLS, uintptr) int32
 131344 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx)) {
 131345 		goto __3
 131346 	}
 131347 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Frc = SQLITE_SCHEMA
 131348 	return
 131349 __3:
 131350 	;
 131351 	if !(sessionGrowHash(tls, pSession, 0, pTab) != 0) {
 131352 		goto __4
 131353 	}
 131354 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Frc = SQLITE_NOMEM
 131355 	return
 131356 __4:
 131357 	;
 131358 	if !((*SessionTable)(unsafe.Pointer(pTab)).FbStat1 != 0) {
 131359 		goto __5
 131360 	}
 131361 	(*SessionStat1Ctx)(unsafe.Pointer(bp)).Fhook = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook
 131362 	(*SessionStat1Ctx)(unsafe.Pointer(bp)).FpSession = pSession
 131363 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = bp
 131364 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = *(*uintptr)(unsafe.Pointer(&struct {
 131365 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131366 	}{sessionStat1New}))
 131367 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = *(*uintptr)(unsafe.Pointer(&struct {
 131368 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131369 	}{sessionStat1Old}))
 131370 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = *(*uintptr)(unsafe.Pointer(&struct {
 131371 		f func(*libc.TLS, uintptr) int32
 131372 	}{sessionStat1Count}))
 131373 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = *(*uintptr)(unsafe.Pointer(&struct {
 131374 		f func(*libc.TLS, uintptr) int32
 131375 	}{sessionStat1Depth}))
 131376 	if !((*Sqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob == uintptr(0)) {
 131377 		goto __6
 131378 	}
 131379 	p = Xsqlite3ValueNew(tls, uintptr(0))
 131380 	if !(p == uintptr(0)) {
 131381 		goto __7
 131382 	}
 131383 	rc = SQLITE_NOMEM
 131384 	goto error_out
 131385 __7:
 131386 	;
 131387 	Xsqlite3ValueSetStr(tls, p, 0, ts+1554, uint8(0), uintptr(0))
 131388 	(*Sqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob = p
 131389 __6:
 131390 	;
 131391 __5:
 131392 	;
 131393 	rc = sessionPreupdateHash(tls, pSession, pTab, libc.Bool32(op == SQLITE_INSERT), bp+24, bp+28)
 131394 	if !(rc != SQLITE_OK) {
 131395 		goto __8
 131396 	}
 131397 	goto error_out
 131398 __8:
 131399 	;
 131400 	if !(*(*int32)(unsafe.Pointer(bp + 28)) == 0) {
 131401 		goto __9
 131402 	}
 131403 	pC = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*4))
 131404 __10:
 131405 	if !(pC != 0) {
 131406 		goto __12
 131407 	}
 131408 	if !(sessionPreupdateEqual(tls, pSession, pTab, pC, op) != 0) {
 131409 		goto __13
 131410 	}
 131411 	goto __12
 131412 __13:
 131413 	;
 131414 	goto __11
 131415 __11:
 131416 	pC = (*SessionChange)(unsafe.Pointer(pC)).FpNext
 131417 	goto __10
 131418 	goto __12
 131419 __12:
 131420 	;
 131421 	if !(pC == uintptr(0)) {
 131422 		goto __14
 131423 	}
 131424 
 131425 	(*SessionTable)(unsafe.Pointer(pTab)).FnEntry++
 131426 
 131427 	*(*Sqlite3_int64)(unsafe.Pointer(bp + 40)) = Sqlite3_int64(unsafe.Sizeof(SessionChange{}))
 131428 	i = 0
 131429 __16:
 131430 	if !(i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol) {
 131431 		goto __18
 131432 	}
 131433 	*(*uintptr)(unsafe.Pointer(bp + 32)) = uintptr(0)
 131434 	if !(op != SQLITE_INSERT) {
 131435 		goto __19
 131436 	}
 131437 	(*struct {
 131438 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131439 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, i, bp+32)
 131440 
 131441 	goto __20
 131442 __19:
 131443 	if !(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0) {
 131444 		goto __21
 131445 	}
 131446 	(*struct {
 131447 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131448 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, i, bp+32)
 131449 
 131450 __21:
 131451 	;
 131452 __20:
 131453 	;
 131454 	rc = sessionSerializeValue(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(bp + 32)), bp+40)
 131455 	if !(rc != SQLITE_OK) {
 131456 		goto __22
 131457 	}
 131458 	goto error_out
 131459 __22:
 131460 	;
 131461 	goto __17
 131462 __17:
 131463 	i++
 131464 	goto __16
 131465 	goto __18
 131466 __18:
 131467 	;
 131468 	pC = sessionMalloc64(tls, pSession, *(*Sqlite3_int64)(unsafe.Pointer(bp + 40)))
 131469 	if !!(pC != 0) {
 131470 		goto __23
 131471 	}
 131472 	rc = SQLITE_NOMEM
 131473 	goto error_out
 131474 	goto __24
 131475 __23:
 131476 	libc.Xmemset(tls, pC, 0, uint32(unsafe.Sizeof(SessionChange{})))
 131477 	(*SessionChange)(unsafe.Pointer(pC)).FaRecord = pC + 1*20
 131478 __24:
 131479 	;
 131480 	*(*Sqlite3_int64)(unsafe.Pointer(bp + 40)) = int64(0)
 131481 	i = 0
 131482 __25:
 131483 	if !(i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol) {
 131484 		goto __27
 131485 	}
 131486 	*(*uintptr)(unsafe.Pointer(bp + 48)) = uintptr(0)
 131487 	if !(op != SQLITE_INSERT) {
 131488 		goto __28
 131489 	}
 131490 	(*struct {
 131491 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131492 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, i, bp+48)
 131493 	goto __29
 131494 __28:
 131495 	if !(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i))) != 0) {
 131496 		goto __30
 131497 	}
 131498 	(*struct {
 131499 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131500 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx, i, bp+48)
 131501 __30:
 131502 	;
 131503 __29:
 131504 	;
 131505 	sessionSerializeValue(tls, (*SessionChange)(unsafe.Pointer(pC)).FaRecord+uintptr(*(*Sqlite3_int64)(unsafe.Pointer(bp + 40))), *(*uintptr)(unsafe.Pointer(bp + 48)), bp+40)
 131506 	goto __26
 131507 __26:
 131508 	i++
 131509 	goto __25
 131510 	goto __27
 131511 __27:
 131512 	;
 131513 	if !((*Sqlite3_session)(unsafe.Pointer(pSession)).FbIndirect != 0 || (*struct {
 131514 		f func(*libc.TLS, uintptr) int32
 131515 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) != 0) {
 131516 		goto __31
 131517 	}
 131518 	(*SessionChange)(unsafe.Pointer(pC)).FbIndirect = U8(1)
 131519 __31:
 131520 	;
 131521 	(*SessionChange)(unsafe.Pointer(pC)).FnRecord = int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 40)))
 131522 	(*SessionChange)(unsafe.Pointer(pC)).Fop = U8(op)
 131523 	(*SessionChange)(unsafe.Pointer(pC)).FpNext = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*4))
 131524 	*(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(*(*int32)(unsafe.Pointer(bp + 24)))*4)) = pC
 131525 
 131526 	goto __15
 131527 __14:
 131528 	if !((*SessionChange)(unsafe.Pointer(pC)).FbIndirect != 0) {
 131529 		goto __32
 131530 	}
 131531 
 131532 	if !((*struct {
 131533 		f func(*libc.TLS, uintptr) int32
 131534 	})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx) == 0 &&
 131535 		(*Sqlite3_session)(unsafe.Pointer(pSession)).FbIndirect == 0) {
 131536 		goto __33
 131537 	}
 131538 	(*SessionChange)(unsafe.Pointer(pC)).FbIndirect = U8(0)
 131539 __33:
 131540 	;
 131541 __32:
 131542 	;
 131543 __15:
 131544 	;
 131545 	if !((*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize != 0) {
 131546 		goto __34
 131547 	}
 131548 	rc = sessionUpdateMaxSize(tls, op, pSession, pTab, pC)
 131549 __34:
 131550 	;
 131551 __9:
 131552 	;
 131553 error_out:
 131554 	if !((*SessionTable)(unsafe.Pointer(pTab)).FbStat1 != 0) {
 131555 		goto __35
 131556 	}
 131557 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook = (*SessionStat1Ctx)(unsafe.Pointer(bp)).Fhook
 131558 __35:
 131559 	;
 131560 	if !(rc != SQLITE_OK) {
 131561 		goto __36
 131562 	}
 131563 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Frc = rc
 131564 __36:
 131565 }
 131566 
 131567 func sessionFindTable(tls *libc.TLS, pSession uintptr, zName uintptr, ppTab uintptr) int32 {
 131568 	var rc int32 = SQLITE_OK
 131569 	var nName int32 = Xsqlite3Strlen30(tls, zName)
 131570 	var pRet uintptr
 131571 
 131572 	for pRet = (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable; pRet != 0; pRet = (*SessionTable)(unsafe.Pointer(pRet)).FpNext {
 131573 		if 0 == Xsqlite3_strnicmp(tls, (*SessionTable)(unsafe.Pointer(pRet)).FzName, zName, nName+1) {
 131574 			break
 131575 		}
 131576 	}
 131577 
 131578 	if pRet == uintptr(0) && (*Sqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach != 0 {
 131579 		if (*Sqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter == uintptr(0) ||
 131580 			(*struct {
 131581 				f func(*libc.TLS, uintptr, uintptr) int32
 131582 			})(unsafe.Pointer(&struct{ uintptr }{(*Sqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter})).f(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).FpFilterCtx, zName) != 0 {
 131583 			rc = Xsqlite3session_attach(tls, pSession, zName)
 131584 			if rc == SQLITE_OK {
 131585 				pRet = (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable
 131586 				for pRet != 0 && (*SessionTable)(unsafe.Pointer(pRet)).FpNext != 0 {
 131587 					pRet = (*SessionTable)(unsafe.Pointer(pRet)).FpNext
 131588 				}
 131589 
 131590 			}
 131591 		}
 131592 	}
 131593 
 131594 	*(*uintptr)(unsafe.Pointer(ppTab)) = pRet
 131595 	return rc
 131596 }
 131597 
 131598 func xPreUpdate(tls *libc.TLS, pCtx uintptr, db uintptr, op int32, zDb uintptr, zName uintptr, iKey1 Sqlite3_int64, iKey2 Sqlite3_int64) {
 131599 	bp := tls.Alloc(4)
 131600 	defer tls.Free(4)
 131601 
 131602 	var pSession uintptr
 131603 	var nDb int32 = Xsqlite3Strlen30(tls, zDb)
 131604 
 131605 	_ = iKey1
 131606 	_ = iKey2
 131607 
 131608 	for pSession = pCtx; pSession != 0; pSession = (*Sqlite3_session)(unsafe.Pointer(pSession)).FpNext {
 131609 		if (*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnable == 0 {
 131610 			continue
 131611 		}
 131612 		if (*Sqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 {
 131613 			continue
 131614 		}
 131615 		if Xsqlite3_strnicmp(tls, zDb, (*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb, nDb+1) != 0 {
 131616 			continue
 131617 		}
 131618 
 131619 		(*Sqlite3_session)(unsafe.Pointer(pSession)).Frc = sessionFindTable(tls, pSession, zName, bp)
 131620 		if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 131621 			sessionPreupdateOneChange(tls, op, pSession, *(*uintptr)(unsafe.Pointer(bp)))
 131622 			if op == SQLITE_UPDATE {
 131623 				sessionPreupdateOneChange(tls, SQLITE_INSERT, pSession, *(*uintptr)(unsafe.Pointer(bp)))
 131624 			}
 131625 		}
 131626 	}
 131627 }
 131628 
 131629 func sessionPreupdateOld(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) int32 {
 131630 	return Xsqlite3_preupdate_old(tls, pCtx, iVal, ppVal)
 131631 }
 131632 
 131633 func sessionPreupdateNew(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) int32 {
 131634 	return Xsqlite3_preupdate_new(tls, pCtx, iVal, ppVal)
 131635 }
 131636 
 131637 func sessionPreupdateCount(tls *libc.TLS, pCtx uintptr) int32 {
 131638 	return Xsqlite3_preupdate_count(tls, pCtx)
 131639 }
 131640 
 131641 func sessionPreupdateDepth(tls *libc.TLS, pCtx uintptr) int32 {
 131642 	return Xsqlite3_preupdate_depth(tls, pCtx)
 131643 }
 131644 
 131645 func sessionPreupdateHooks(tls *libc.TLS, pSession uintptr) {
 131646 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb
 131647 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = *(*uintptr)(unsafe.Pointer(&struct {
 131648 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131649 	}{sessionPreupdateOld}))
 131650 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = *(*uintptr)(unsafe.Pointer(&struct {
 131651 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131652 	}{sessionPreupdateNew}))
 131653 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = *(*uintptr)(unsafe.Pointer(&struct {
 131654 		f func(*libc.TLS, uintptr) int32
 131655 	}{sessionPreupdateCount}))
 131656 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = *(*uintptr)(unsafe.Pointer(&struct {
 131657 		f func(*libc.TLS, uintptr) int32
 131658 	}{sessionPreupdateDepth}))
 131659 }
 131660 
 131661 type SessionDiffCtx1 = struct {
 131662 	FpStmt   uintptr
 131663 	FnOldOff int32
 131664 }
 131665 
 131666 type SessionDiffCtx = SessionDiffCtx1
 131667 
 131668 func sessionDiffOld(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) int32 {
 131669 	var p uintptr = pCtx
 131670 	*(*uintptr)(unsafe.Pointer(ppVal)) = Xsqlite3_column_value(tls, (*SessionDiffCtx)(unsafe.Pointer(p)).FpStmt, iVal+(*SessionDiffCtx)(unsafe.Pointer(p)).FnOldOff)
 131671 	return SQLITE_OK
 131672 }
 131673 
 131674 func sessionDiffNew(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) int32 {
 131675 	var p uintptr = pCtx
 131676 	*(*uintptr)(unsafe.Pointer(ppVal)) = Xsqlite3_column_value(tls, (*SessionDiffCtx)(unsafe.Pointer(p)).FpStmt, iVal)
 131677 	return SQLITE_OK
 131678 }
 131679 
 131680 func sessionDiffCount(tls *libc.TLS, pCtx uintptr) int32 {
 131681 	var p uintptr = pCtx
 131682 	if (*SessionDiffCtx)(unsafe.Pointer(p)).FnOldOff != 0 {
 131683 		return (*SessionDiffCtx)(unsafe.Pointer(p)).FnOldOff
 131684 	}
 131685 	return Xsqlite3_column_count(tls, (*SessionDiffCtx)(unsafe.Pointer(p)).FpStmt)
 131686 }
 131687 
 131688 func sessionDiffDepth(tls *libc.TLS, pCtx uintptr) int32 {
 131689 	_ = pCtx
 131690 	return 0
 131691 }
 131692 
 131693 func sessionDiffHooks(tls *libc.TLS, pSession uintptr, pDiffCtx uintptr) {
 131694 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = pDiffCtx
 131695 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = *(*uintptr)(unsafe.Pointer(&struct {
 131696 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131697 	}{sessionDiffOld}))
 131698 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = *(*uintptr)(unsafe.Pointer(&struct {
 131699 		f func(*libc.TLS, uintptr, int32, uintptr) int32
 131700 	}{sessionDiffNew}))
 131701 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = *(*uintptr)(unsafe.Pointer(&struct {
 131702 		f func(*libc.TLS, uintptr) int32
 131703 	}{sessionDiffCount}))
 131704 	(*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = *(*uintptr)(unsafe.Pointer(&struct {
 131705 		f func(*libc.TLS, uintptr) int32
 131706 	}{sessionDiffDepth}))
 131707 }
 131708 
 131709 func sessionExprComparePK(tls *libc.TLS, nCol int32, zDb1 uintptr, zDb2 uintptr, zTab uintptr, azCol uintptr, abPK uintptr) uintptr {
 131710 	bp := tls.Alloc(64)
 131711 	defer tls.Free(64)
 131712 
 131713 	var i int32
 131714 	var zSep uintptr = ts + 1554
 131715 	var zRet uintptr = uintptr(0)
 131716 
 131717 	for i = 0; i < nCol; i++ {
 131718 		if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 131719 			zRet = Xsqlite3_mprintf(tls, ts+32545,
 131720 				libc.VaList(bp, zRet, zSep, zDb1, zTab, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*4)), zDb2, zTab, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*4))))
 131721 			zSep = ts + 21572
 131722 			if zRet == uintptr(0) {
 131723 				break
 131724 			}
 131725 		}
 131726 	}
 131727 
 131728 	return zRet
 131729 }
 131730 
 131731 func sessionExprCompareOther(tls *libc.TLS, nCol int32, zDb1 uintptr, zDb2 uintptr, zTab uintptr, azCol uintptr, abPK uintptr) uintptr {
 131732 	bp := tls.Alloc(64)
 131733 	defer tls.Free(64)
 131734 
 131735 	var i int32
 131736 	var zSep uintptr = ts + 1554
 131737 	var zRet uintptr = uintptr(0)
 131738 	var bHave int32 = 0
 131739 
 131740 	for i = 0; i < nCol; i++ {
 131741 		if int32(*(*U8)(unsafe.Pointer(abPK + uintptr(i)))) == 0 {
 131742 			bHave = 1
 131743 			zRet = Xsqlite3_mprintf(tls,
 131744 				ts+32579,
 131745 				libc.VaList(bp, zRet, zSep, zDb1, zTab, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*4)), zDb2, zTab, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*4))))
 131746 			zSep = ts + 32620
 131747 			if zRet == uintptr(0) {
 131748 				break
 131749 			}
 131750 		}
 131751 	}
 131752 
 131753 	if bHave == 0 {
 131754 		zRet = Xsqlite3_mprintf(tls, ts+7519, 0)
 131755 	}
 131756 
 131757 	return zRet
 131758 }
 131759 
 131760 func sessionSelectFindNew(tls *libc.TLS, zDb1 uintptr, zDb2 uintptr, zTbl uintptr, zExpr uintptr) uintptr {
 131761 	bp := tls.Alloc(40)
 131762 	defer tls.Free(40)
 131763 
 131764 	var zRet uintptr = Xsqlite3_mprintf(tls,
 131765 		ts+32625,
 131766 		libc.VaList(bp, zDb1, zTbl, zDb2, zTbl, zExpr))
 131767 	return zRet
 131768 }
 131769 
 131770 func sessionDiffFindNew(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr, zDb1 uintptr, zDb2 uintptr, zExpr uintptr) int32 {
 131771 	bp := tls.Alloc(4)
 131772 	defer tls.Free(4)
 131773 
 131774 	var rc int32 = SQLITE_OK
 131775 	var zStmt uintptr = sessionSelectFindNew(tls, zDb1, zDb2, (*SessionTable)(unsafe.Pointer(pTab)).FzName, zExpr)
 131776 
 131777 	if zStmt == uintptr(0) {
 131778 		rc = SQLITE_NOMEM
 131779 	} else {
 131780 		rc = Xsqlite3_prepare(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -1, bp, uintptr(0))
 131781 		if rc == SQLITE_OK {
 131782 			var pDiffCtx uintptr = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx
 131783 			(*SessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = *(*uintptr)(unsafe.Pointer(bp))
 131784 			(*SessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = 0
 131785 			for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 131786 				sessionPreupdateOneChange(tls, op, pSession, pTab)
 131787 			}
 131788 			rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 131789 		}
 131790 		Xsqlite3_free(tls, zStmt)
 131791 	}
 131792 
 131793 	return rc
 131794 }
 131795 
 131796 func sessionDiffFindModified(tls *libc.TLS, pSession uintptr, pTab uintptr, zFrom uintptr, zExpr uintptr) int32 {
 131797 	bp := tls.Alloc(52)
 131798 	defer tls.Free(52)
 131799 
 131800 	var rc int32 = SQLITE_OK
 131801 
 131802 	var zExpr2 uintptr = sessionExprCompareOther(tls, (*SessionTable)(unsafe.Pointer(pTab)).FnCol,
 131803 		(*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb, zFrom, (*SessionTable)(unsafe.Pointer(pTab)).FzName, (*SessionTable)(unsafe.Pointer(pTab)).FazCol, (*SessionTable)(unsafe.Pointer(pTab)).FabPK)
 131804 	if zExpr2 == uintptr(0) {
 131805 		rc = SQLITE_NOMEM
 131806 	} else {
 131807 		var zStmt uintptr = Xsqlite3_mprintf(tls,
 131808 			ts+32703,
 131809 			libc.VaList(bp, (*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb, (*SessionTable)(unsafe.Pointer(pTab)).FzName, zFrom, (*SessionTable)(unsafe.Pointer(pTab)).FzName, zExpr, zExpr2))
 131810 		if zStmt == uintptr(0) {
 131811 			rc = SQLITE_NOMEM
 131812 		} else {
 131813 			rc = Xsqlite3_prepare(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -1, bp+48, uintptr(0))
 131814 
 131815 			if rc == SQLITE_OK {
 131816 				var pDiffCtx uintptr = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx
 131817 				(*SessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = *(*uintptr)(unsafe.Pointer(bp + 48))
 131818 				(*SessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = (*SessionTable)(unsafe.Pointer(pTab)).FnCol
 131819 				for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 48))) {
 131820 					sessionPreupdateOneChange(tls, SQLITE_UPDATE, pSession, pTab)
 131821 				}
 131822 				rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 48)))
 131823 			}
 131824 			Xsqlite3_free(tls, zStmt)
 131825 		}
 131826 	}
 131827 
 131828 	return rc
 131829 }
 131830 
 131831 func Xsqlite3session_diff(tls *libc.TLS, pSession uintptr, zFrom uintptr, zTbl uintptr, pzErrMsg uintptr) int32 {
 131832 	bp := tls.Alloc(24)
 131833 	defer tls.Free(24)
 131834 
 131835 	var zDb uintptr
 131836 	var rc int32
 131837 
 131838 	var i int32
 131839 	var bHasPk int32
 131840 	var bMismatch int32
 131841 
 131842 	var zExpr uintptr
 131843 	var db uintptr
 131844 
 131845 	zDb = (*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb
 131846 	rc = (*Sqlite3_session)(unsafe.Pointer(pSession)).Frc
 131847 
 131848 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(SessionDiffCtx{})))
 131849 	sessionDiffHooks(tls, pSession, bp)
 131850 
 131851 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 131852 	if !(pzErrMsg != 0) {
 131853 		goto __1
 131854 	}
 131855 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = uintptr(0)
 131856 __1:
 131857 	;
 131858 	if !(rc == SQLITE_OK) {
 131859 		goto __2
 131860 	}
 131861 	zExpr = uintptr(0)
 131862 	db = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb
 131863 
 131864 	rc = sessionFindTable(tls, pSession, zTbl, bp+8)
 131865 	if !(*(*uintptr)(unsafe.Pointer(bp + 8)) == uintptr(0)) {
 131866 		goto __3
 131867 	}
 131868 	goto diff_out
 131869 __3:
 131870 	;
 131871 	if !(sessionInitTable(tls, pSession, *(*uintptr)(unsafe.Pointer(bp + 8))) != 0) {
 131872 		goto __4
 131873 	}
 131874 	rc = (*Sqlite3_session)(unsafe.Pointer(pSession)).Frc
 131875 	goto diff_out
 131876 __4:
 131877 	;
 131878 	if !(rc == SQLITE_OK) {
 131879 		goto __5
 131880 	}
 131881 	bHasPk = 0
 131882 	bMismatch = 0
 131883 	*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 131884 	rc = sessionTableInfo(tls, uintptr(0), db, zFrom, zTbl, bp+12, uintptr(0), bp+16, bp+20)
 131885 	if !(rc == SQLITE_OK) {
 131886 		goto __6
 131887 	}
 131888 	if !((*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FnCol != *(*int32)(unsafe.Pointer(bp + 12))) {
 131889 		goto __7
 131890 	}
 131891 	bMismatch = 1
 131892 	goto __8
 131893 __7:
 131894 	i = 0
 131895 __9:
 131896 	if !(i < *(*int32)(unsafe.Pointer(bp + 12))) {
 131897 		goto __11
 131898 	}
 131899 	if !(int32(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FabPK + uintptr(i)))) != int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 20)) + uintptr(i))))) {
 131900 		goto __12
 131901 	}
 131902 	bMismatch = 1
 131903 __12:
 131904 	;
 131905 	if !(Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16)) + uintptr(i)*4)), *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FazCol + uintptr(i)*4))) != 0) {
 131906 		goto __13
 131907 	}
 131908 	bMismatch = 1
 131909 __13:
 131910 	;
 131911 	if !(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 20)) + uintptr(i))) != 0) {
 131912 		goto __14
 131913 	}
 131914 	bHasPk = 1
 131915 __14:
 131916 	;
 131917 	goto __10
 131918 __10:
 131919 	i++
 131920 	goto __9
 131921 	goto __11
 131922 __11:
 131923 	;
 131924 __8:
 131925 	;
 131926 __6:
 131927 	;
 131928 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))
 131929 	if !(bMismatch != 0) {
 131930 		goto __15
 131931 	}
 131932 	if !(pzErrMsg != 0) {
 131933 		goto __16
 131934 	}
 131935 	*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+32756, 0)
 131936 __16:
 131937 	;
 131938 	rc = SQLITE_SCHEMA
 131939 __15:
 131940 	;
 131941 	if !(bHasPk == 0) {
 131942 		goto __17
 131943 	}
 131944 
 131945 	goto diff_out
 131946 __17:
 131947 	;
 131948 __5:
 131949 	;
 131950 	if !(rc == SQLITE_OK) {
 131951 		goto __18
 131952 	}
 131953 	zExpr = sessionExprComparePK(tls, (*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FnCol,
 131954 		zDb, zFrom, (*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FzName, (*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FazCol, (*SessionTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8)))).FabPK)
 131955 __18:
 131956 	;
 131957 	if !(rc == SQLITE_OK) {
 131958 		goto __19
 131959 	}
 131960 	rc = sessionDiffFindNew(tls, SQLITE_INSERT, pSession, *(*uintptr)(unsafe.Pointer(bp + 8)), zDb, zFrom, zExpr)
 131961 __19:
 131962 	;
 131963 	if !(rc == SQLITE_OK) {
 131964 		goto __20
 131965 	}
 131966 	rc = sessionDiffFindNew(tls, SQLITE_DELETE, pSession, *(*uintptr)(unsafe.Pointer(bp + 8)), zFrom, zDb, zExpr)
 131967 __20:
 131968 	;
 131969 	if !(rc == SQLITE_OK) {
 131970 		goto __21
 131971 	}
 131972 	rc = sessionDiffFindModified(tls, pSession, *(*uintptr)(unsafe.Pointer(bp + 8)), zFrom, zExpr)
 131973 __21:
 131974 	;
 131975 	Xsqlite3_free(tls, zExpr)
 131976 __2:
 131977 	;
 131978 diff_out:
 131979 	sessionPreupdateHooks(tls, pSession)
 131980 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 131981 	return rc
 131982 }
 131983 
 131984 // Create a session object. This session object will record changes to
 131985 // database zDb attached to connection db.
 131986 func Xsqlite3session_create(tls *libc.TLS, db uintptr, zDb uintptr, ppSession uintptr) int32 {
 131987 	var pNew uintptr
 131988 	var pOld uintptr
 131989 	var nDb int32 = Xsqlite3Strlen30(tls, zDb)
 131990 
 131991 	*(*uintptr)(unsafe.Pointer(ppSession)) = uintptr(0)
 131992 
 131993 	pNew = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(Sqlite3_session{}))+uint32(nDb)+uint32(1)))
 131994 	if !(pNew != 0) {
 131995 		return SQLITE_NOMEM
 131996 	}
 131997 	libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Sqlite3_session{})))
 131998 	(*Sqlite3_session)(unsafe.Pointer(pNew)).Fdb = db
 131999 	(*Sqlite3_session)(unsafe.Pointer(pNew)).FzDb = pNew + 1*88
 132000 	(*Sqlite3_session)(unsafe.Pointer(pNew)).FbEnable = 1
 132001 	libc.Xmemcpy(tls, (*Sqlite3_session)(unsafe.Pointer(pNew)).FzDb, zDb, uint32(nDb+1))
 132002 	sessionPreupdateHooks(tls, pNew)
 132003 
 132004 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db))
 132005 	pOld = Xsqlite3_preupdate_hook(tls, db, *(*uintptr)(unsafe.Pointer(&struct {
 132006 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, Sqlite3_int64, Sqlite3_int64)
 132007 	}{xPreUpdate})), pNew)
 132008 	(*Sqlite3_session)(unsafe.Pointer(pNew)).FpNext = pOld
 132009 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db))
 132010 
 132011 	*(*uintptr)(unsafe.Pointer(ppSession)) = pNew
 132012 	return SQLITE_OK
 132013 }
 132014 
 132015 func sessionDeleteTable(tls *libc.TLS, pSession uintptr, pList uintptr) {
 132016 	var pNext uintptr
 132017 	var pTab uintptr
 132018 
 132019 	for pTab = pList; pTab != 0; pTab = pNext {
 132020 		var i int32
 132021 		pNext = (*SessionTable)(unsafe.Pointer(pTab)).FpNext
 132022 		for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnChange; i++ {
 132023 			var p uintptr
 132024 			var pNextChange uintptr
 132025 			for p = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*4)); p != 0; p = pNextChange {
 132026 				pNextChange = (*SessionChange)(unsafe.Pointer(p)).FpNext
 132027 				sessionFree(tls, pSession, p)
 132028 			}
 132029 		}
 132030 		sessionFree(tls, pSession, (*SessionTable)(unsafe.Pointer(pTab)).FazCol)
 132031 		sessionFree(tls, pSession, (*SessionTable)(unsafe.Pointer(pTab)).FapChange)
 132032 		sessionFree(tls, pSession, pTab)
 132033 	}
 132034 }
 132035 
 132036 // Delete a session object previously allocated using sqlite3session_create().
 132037 func Xsqlite3session_delete(tls *libc.TLS, pSession uintptr) {
 132038 	bp := tls.Alloc(4)
 132039 	defer tls.Free(4)
 132040 
 132041 	var db uintptr = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb
 132042 
 132043 	var pp uintptr
 132044 
 132045 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db))
 132046 	*(*uintptr)(unsafe.Pointer(bp)) = Xsqlite3_preupdate_hook(tls, db, uintptr(0), uintptr(0))
 132047 	for pp = bp; *(*uintptr)(unsafe.Pointer(pp)) != uintptr(0); pp = *(*uintptr)(unsafe.Pointer(pp)) + 60 {
 132048 		if *(*uintptr)(unsafe.Pointer(pp)) == pSession {
 132049 			*(*uintptr)(unsafe.Pointer(pp)) = (*Sqlite3_session)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext
 132050 			if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 132051 				Xsqlite3_preupdate_hook(tls, db, *(*uintptr)(unsafe.Pointer(&struct {
 132052 					f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, Sqlite3_int64, Sqlite3_int64)
 132053 				}{xPreUpdate})), *(*uintptr)(unsafe.Pointer(bp)))
 132054 			}
 132055 			break
 132056 		}
 132057 	}
 132058 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db))
 132059 	Xsqlite3ValueFree(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).FpZeroBlob)
 132060 
 132061 	sessionDeleteTable(tls, pSession, (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable)
 132062 
 132063 	Xsqlite3_free(tls, pSession)
 132064 }
 132065 
 132066 // Set a table filter on a Session Object.
 132067 func Xsqlite3session_table_filter(tls *libc.TLS, pSession uintptr, xFilter uintptr, pCtx uintptr) {
 132068 	(*Sqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = 1
 132069 	(*Sqlite3_session)(unsafe.Pointer(pSession)).FpFilterCtx = pCtx
 132070 	(*Sqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter = xFilter
 132071 }
 132072 
 132073 // Attach a table to a session. All subsequent changes made to the table
 132074 // while the session object is enabled will be recorded.
 132075 //
 132076 // Only tables that have a PRIMARY KEY defined may be attached. It does
 132077 // not matter if the PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias)
 132078 // or not.
 132079 func Xsqlite3session_attach(tls *libc.TLS, pSession uintptr, zName uintptr) int32 {
 132080 	var rc int32 = SQLITE_OK
 132081 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132082 
 132083 	if !(zName != 0) {
 132084 		(*Sqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = 1
 132085 	} else {
 132086 		var pTab uintptr
 132087 		var nName int32
 132088 
 132089 		nName = Xsqlite3Strlen30(tls, zName)
 132090 		for pTab = (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable; pTab != 0; pTab = (*SessionTable)(unsafe.Pointer(pTab)).FpNext {
 132091 			if 0 == Xsqlite3_strnicmp(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName, zName, nName+1) {
 132092 				break
 132093 			}
 132094 		}
 132095 
 132096 		if !(pTab != 0) {
 132097 			var nByte int32 = int32(uint32(unsafe.Sizeof(SessionTable{})) + uint32(nName) + uint32(1))
 132098 			pTab = sessionMalloc64(tls, pSession, int64(nByte))
 132099 			if !(pTab != 0) {
 132100 				rc = SQLITE_NOMEM
 132101 			} else {
 132102 				var ppTab uintptr
 132103 				libc.Xmemset(tls, pTab, 0, uint32(unsafe.Sizeof(SessionTable{})))
 132104 				(*SessionTable)(unsafe.Pointer(pTab)).FzName = pTab + 1*36
 132105 				libc.Xmemcpy(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName, zName, uint32(nName+1))
 132106 				for ppTab = pSession + 64; *(*uintptr)(unsafe.Pointer(ppTab)) != 0; ppTab = *(*uintptr)(unsafe.Pointer(ppTab)) {
 132107 				}
 132108 				*(*uintptr)(unsafe.Pointer(ppTab)) = pTab
 132109 			}
 132110 		}
 132111 	}
 132112 
 132113 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132114 	return rc
 132115 }
 132116 
 132117 func sessionBufferGrow(tls *libc.TLS, p uintptr, nByte I64, pRc uintptr) int32 {
 132118 	var nReq I64 = I64((*SessionBuffer)(unsafe.Pointer(p)).FnBuf) + nByte
 132119 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK && nReq > I64((*SessionBuffer)(unsafe.Pointer(p)).FnAlloc) {
 132120 		var aNew uintptr
 132121 		var nNew I64
 132122 		if (*SessionBuffer)(unsafe.Pointer(p)).FnAlloc != 0 {
 132123 			nNew = int64((*SessionBuffer)(unsafe.Pointer(p)).FnAlloc)
 132124 		} else {
 132125 			nNew = int64(128)
 132126 		}
 132127 
 132128 		for __ccgo := true; __ccgo; __ccgo = nNew < nReq {
 132129 			nNew = nNew * int64(2)
 132130 		}
 132131 
 132132 		if nNew > int64(0x7FFFFF00-1) {
 132133 			nNew = int64(0x7FFFFF00 - 1)
 132134 			if nNew < nReq {
 132135 				*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 132136 				return 1
 132137 			}
 132138 		}
 132139 
 132140 		aNew = Xsqlite3_realloc64(tls, (*SessionBuffer)(unsafe.Pointer(p)).FaBuf, uint64(nNew))
 132141 		if uintptr(0) == aNew {
 132142 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 132143 		} else {
 132144 			(*SessionBuffer)(unsafe.Pointer(p)).FaBuf = aNew
 132145 			(*SessionBuffer)(unsafe.Pointer(p)).FnAlloc = int32(nNew)
 132146 		}
 132147 	}
 132148 	return libc.Bool32(*(*int32)(unsafe.Pointer(pRc)) != SQLITE_OK)
 132149 }
 132150 
 132151 func sessionAppendValue(tls *libc.TLS, p uintptr, pVal uintptr, pRc uintptr) {
 132152 	bp := tls.Alloc(12)
 132153 	defer tls.Free(12)
 132154 
 132155 	*(*int32)(unsafe.Pointer(bp + 8)) = *(*int32)(unsafe.Pointer(pRc))
 132156 	if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 132157 		*(*Sqlite3_int64)(unsafe.Pointer(bp)) = int64(0)
 132158 		*(*int32)(unsafe.Pointer(bp + 8)) = sessionSerializeValue(tls, uintptr(0), pVal, bp)
 132159 		sessionBufferGrow(tls, p, *(*Sqlite3_int64)(unsafe.Pointer(bp)), bp+8)
 132160 		if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 132161 			*(*int32)(unsafe.Pointer(bp + 8)) = sessionSerializeValue(tls, (*SessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*SessionBuffer)(unsafe.Pointer(p)).FnBuf), pVal, uintptr(0))
 132162 			*(*int32)(unsafe.Pointer(p + 4)) += int32(*(*Sqlite3_int64)(unsafe.Pointer(bp)))
 132163 		} else {
 132164 			*(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 8))
 132165 		}
 132166 	}
 132167 }
 132168 
 132169 func sessionAppendByte(tls *libc.TLS, p uintptr, v U8, pRc uintptr) {
 132170 	if 0 == sessionBufferGrow(tls, p, int64(1), pRc) {
 132171 		*(*U8)(unsafe.Pointer((*SessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr(libc.PostIncInt32(&(*SessionBuffer)(unsafe.Pointer(p)).FnBuf, 1)))) = v
 132172 	}
 132173 }
 132174 
 132175 func sessionAppendVarint(tls *libc.TLS, p uintptr, v int32, pRc uintptr) {
 132176 	if 0 == sessionBufferGrow(tls, p, int64(9), pRc) {
 132177 		*(*int32)(unsafe.Pointer(p + 4)) += sessionVarintPut(tls, (*SessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*SessionBuffer)(unsafe.Pointer(p)).FnBuf), v)
 132178 	}
 132179 }
 132180 
 132181 func sessionAppendBlob(tls *libc.TLS, p uintptr, aBlob uintptr, nBlob int32, pRc uintptr) {
 132182 	if nBlob > 0 && 0 == sessionBufferGrow(tls, p, int64(nBlob), pRc) {
 132183 		libc.Xmemcpy(tls, (*SessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*SessionBuffer)(unsafe.Pointer(p)).FnBuf), aBlob, uint32(nBlob))
 132184 		*(*int32)(unsafe.Pointer(p + 4)) += nBlob
 132185 	}
 132186 }
 132187 
 132188 func sessionAppendStr(tls *libc.TLS, p uintptr, zStr uintptr, pRc uintptr) {
 132189 	var nStr int32 = Xsqlite3Strlen30(tls, zStr)
 132190 	if 0 == sessionBufferGrow(tls, p, int64(nStr), pRc) {
 132191 		libc.Xmemcpy(tls, (*SessionBuffer)(unsafe.Pointer(p)).FaBuf+uintptr((*SessionBuffer)(unsafe.Pointer(p)).FnBuf), zStr, uint32(nStr))
 132192 		*(*int32)(unsafe.Pointer(p + 4)) += nStr
 132193 	}
 132194 }
 132195 
 132196 func sessionAppendInteger(tls *libc.TLS, p uintptr, iVal int32, pRc uintptr) {
 132197 	bp := tls.Alloc(32)
 132198 	defer tls.Free(32)
 132199 
 132200 	Xsqlite3_snprintf(tls, int32(uint32(unsafe.Sizeof([24]uint8{}))-uint32(1)), bp+8, ts+4975, libc.VaList(bp, iVal))
 132201 	sessionAppendStr(tls, p, bp+8, pRc)
 132202 }
 132203 
 132204 func sessionAppendIdent(tls *libc.TLS, p uintptr, zStr uintptr, pRc uintptr) {
 132205 	var nStr int32 = Xsqlite3Strlen30(tls, zStr)*2 + 2 + 1
 132206 	if 0 == sessionBufferGrow(tls, p, int64(nStr), pRc) {
 132207 		var zOut uintptr = (*SessionBuffer)(unsafe.Pointer(p)).FaBuf + uintptr((*SessionBuffer)(unsafe.Pointer(p)).FnBuf)
 132208 		var zIn uintptr = zStr
 132209 		*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8('"')
 132210 		for *(*uint8)(unsafe.Pointer(zIn)) != 0 {
 132211 			if int32(*(*uint8)(unsafe.Pointer(zIn))) == '"' {
 132212 				*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8('"')
 132213 			}
 132214 			*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))
 132215 		}
 132216 		*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8('"')
 132217 		(*SessionBuffer)(unsafe.Pointer(p)).FnBuf = (int32(zOut) - int32((*SessionBuffer)(unsafe.Pointer(p)).FaBuf)) / 1
 132218 	}
 132219 }
 132220 
 132221 func sessionAppendCol(tls *libc.TLS, p uintptr, pStmt uintptr, iCol int32, pRc uintptr) {
 132222 	bp := tls.Alloc(24)
 132223 	defer tls.Free(24)
 132224 
 132225 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 132226 		var eType int32 = Xsqlite3_column_type(tls, pStmt, iCol)
 132227 		sessionAppendByte(tls, p, U8(eType), pRc)
 132228 		if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 132229 			if eType == SQLITE_INTEGER {
 132230 				*(*Sqlite3_int64)(unsafe.Pointer(bp)) = Xsqlite3_column_int64(tls, pStmt, iCol)
 132231 			} else {
 132232 				*(*float64)(unsafe.Pointer(bp + 8)) = Xsqlite3_column_double(tls, pStmt, iCol)
 132233 				libc.Xmemcpy(tls, bp, bp+8, uint32(8))
 132234 			}
 132235 			sessionPutI64(tls, bp+16, *(*Sqlite3_int64)(unsafe.Pointer(bp)))
 132236 			sessionAppendBlob(tls, p, bp+16, 8, pRc)
 132237 		}
 132238 		if eType == SQLITE_BLOB || eType == SQLITE_TEXT {
 132239 			var z uintptr
 132240 			var nByte int32
 132241 			if eType == SQLITE_BLOB {
 132242 				z = Xsqlite3_column_blob(tls, pStmt, iCol)
 132243 			} else {
 132244 				z = Xsqlite3_column_text(tls, pStmt, iCol)
 132245 			}
 132246 			nByte = Xsqlite3_column_bytes(tls, pStmt, iCol)
 132247 			if z != 0 || eType == SQLITE_BLOB && nByte == 0 {
 132248 				sessionAppendVarint(tls, p, nByte, pRc)
 132249 				sessionAppendBlob(tls, p, z, nByte, pRc)
 132250 			} else {
 132251 				*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 132252 			}
 132253 		}
 132254 	}
 132255 }
 132256 
 132257 func sessionAppendUpdate(tls *libc.TLS, pBuf uintptr, bPatchset int32, pStmt uintptr, p uintptr, abPK uintptr) int32 {
 132258 	bp := tls.Alloc(40)
 132259 	defer tls.Free(40)
 132260 
 132261 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 132262 	*(*SessionBuffer)(unsafe.Pointer(bp + 28)) = SessionBuffer{}
 132263 	var bNoop int32 = 1
 132264 	var nRewind int32 = (*SessionBuffer)(unsafe.Pointer(pBuf)).FnBuf
 132265 	var i int32
 132266 	var pCsr uintptr = (*SessionChange)(unsafe.Pointer(p)).FaRecord
 132267 
 132268 	sessionAppendByte(tls, pBuf, uint8(SQLITE_UPDATE), bp)
 132269 	sessionAppendByte(tls, pBuf, (*SessionChange)(unsafe.Pointer(p)).FbIndirect, bp)
 132270 	for i = 0; i < Xsqlite3_column_count(tls, pStmt); i++ {
 132271 		var bChanged int32 = 0
 132272 		var nAdvance int32
 132273 		var eType int32 = int32(*(*U8)(unsafe.Pointer(pCsr)))
 132274 		switch eType {
 132275 		case SQLITE_NULL:
 132276 			nAdvance = 1
 132277 			if Xsqlite3_column_type(tls, pStmt, i) != SQLITE_NULL {
 132278 				bChanged = 1
 132279 			}
 132280 			break
 132281 
 132282 		case SQLITE_FLOAT:
 132283 			fallthrough
 132284 		case SQLITE_INTEGER:
 132285 			{
 132286 				nAdvance = 9
 132287 				if eType == Xsqlite3_column_type(tls, pStmt, i) {
 132288 					*(*Sqlite3_int64)(unsafe.Pointer(bp + 16)) = sessionGetI64(tls, pCsr+1)
 132289 					if eType == SQLITE_INTEGER {
 132290 						if *(*Sqlite3_int64)(unsafe.Pointer(bp + 16)) == Xsqlite3_column_int64(tls, pStmt, i) {
 132291 							break
 132292 						}
 132293 					} else {
 132294 						libc.Xmemcpy(tls, bp+8, bp+16, uint32(8))
 132295 						if *(*float64)(unsafe.Pointer(bp + 8)) == Xsqlite3_column_double(tls, pStmt, i) {
 132296 							break
 132297 						}
 132298 					}
 132299 				}
 132300 				bChanged = 1
 132301 				break
 132302 
 132303 			}
 132304 
 132305 		default:
 132306 			{
 132307 				var nHdr int32 = 1 + sessionVarintGet(tls, pCsr+1, bp+24)
 132308 
 132309 				nAdvance = nHdr + *(*int32)(unsafe.Pointer(bp + 24))
 132310 				if eType == Xsqlite3_column_type(tls, pStmt, i) &&
 132311 					*(*int32)(unsafe.Pointer(bp + 24)) == Xsqlite3_column_bytes(tls, pStmt, i) &&
 132312 					(*(*int32)(unsafe.Pointer(bp + 24)) == 0 || 0 == libc.Xmemcmp(tls, pCsr+uintptr(nHdr), Xsqlite3_column_blob(tls, pStmt, i), uint32(*(*int32)(unsafe.Pointer(bp + 24))))) {
 132313 					break
 132314 				}
 132315 				bChanged = 1
 132316 
 132317 			}
 132318 		}
 132319 
 132320 		if bChanged != 0 {
 132321 			bNoop = 0
 132322 		}
 132323 
 132324 		if bPatchset == 0 {
 132325 			if bChanged != 0 || *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132326 				sessionAppendBlob(tls, pBuf, pCsr, nAdvance, bp)
 132327 			} else {
 132328 				sessionAppendByte(tls, pBuf, uint8(0), bp)
 132329 			}
 132330 		}
 132331 
 132332 		if bChanged != 0 || bPatchset != 0 && *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132333 			sessionAppendCol(tls, bp+28, pStmt, i, bp)
 132334 		} else {
 132335 			sessionAppendByte(tls, bp+28, uint8(0), bp)
 132336 		}
 132337 
 132338 		pCsr += uintptr(nAdvance)
 132339 	}
 132340 
 132341 	if bNoop != 0 {
 132342 		(*SessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = nRewind
 132343 	} else {
 132344 		sessionAppendBlob(tls, pBuf, (*SessionBuffer)(unsafe.Pointer(bp+28)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp+28)).FnBuf, bp)
 132345 	}
 132346 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp+28)).FaBuf)
 132347 
 132348 	return *(*int32)(unsafe.Pointer(bp))
 132349 }
 132350 
 132351 func sessionAppendDelete(tls *libc.TLS, pBuf uintptr, bPatchset int32, p uintptr, nCol int32, abPK uintptr) int32 {
 132352 	bp := tls.Alloc(8)
 132353 	defer tls.Free(8)
 132354 
 132355 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 132356 
 132357 	sessionAppendByte(tls, pBuf, uint8(SQLITE_DELETE), bp)
 132358 	sessionAppendByte(tls, pBuf, (*SessionChange)(unsafe.Pointer(p)).FbIndirect, bp)
 132359 
 132360 	if bPatchset == 0 {
 132361 		sessionAppendBlob(tls, pBuf, (*SessionChange)(unsafe.Pointer(p)).FaRecord, (*SessionChange)(unsafe.Pointer(p)).FnRecord, bp)
 132362 	} else {
 132363 		var i int32
 132364 		var a uintptr = (*SessionChange)(unsafe.Pointer(p)).FaRecord
 132365 		for i = 0; i < nCol; i++ {
 132366 			var pStart uintptr = a
 132367 			var eType int32 = int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1))))
 132368 
 132369 			switch eType {
 132370 			case 0:
 132371 				fallthrough
 132372 			case SQLITE_NULL:
 132373 				break
 132374 				fallthrough
 132375 
 132376 			case SQLITE_FLOAT:
 132377 				fallthrough
 132378 			case SQLITE_INTEGER:
 132379 				a += uintptr(8)
 132380 				break
 132381 				fallthrough
 132382 
 132383 			default:
 132384 				{
 132385 					a += uintptr(sessionVarintGet(tls, a, bp+4))
 132386 					a += uintptr(*(*int32)(unsafe.Pointer(bp + 4)))
 132387 					break
 132388 
 132389 				}
 132390 			}
 132391 			if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132392 				sessionAppendBlob(tls, pBuf, pStart, (int32(a)-int32(pStart))/1, bp)
 132393 			}
 132394 		}
 132395 
 132396 	}
 132397 
 132398 	return *(*int32)(unsafe.Pointer(bp))
 132399 }
 132400 
 132401 func sessionSelectStmt(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, nCol int32, azCol uintptr, abPK uintptr, ppStmt uintptr) int32 {
 132402 	bp := tls.Alloc(24)
 132403 	defer tls.Free(24)
 132404 
 132405 	*(*int32)(unsafe.Pointer(bp + 20)) = SQLITE_OK
 132406 	var zSql uintptr = uintptr(0)
 132407 	var nSql int32 = -1
 132408 
 132409 	if 0 == Xsqlite3_stricmp(tls, ts+11348, zTab) {
 132410 		zSql = Xsqlite3_mprintf(tls,
 132411 			ts+32783, libc.VaList(bp, zDb))
 132412 		if zSql == uintptr(0) {
 132413 			*(*int32)(unsafe.Pointer(bp + 20)) = SQLITE_NOMEM
 132414 		}
 132415 	} else {
 132416 		var i int32
 132417 		var zSep uintptr = ts + 1554
 132418 		*(*SessionBuffer)(unsafe.Pointer(bp + 8)) = SessionBuffer{}
 132419 
 132420 		sessionAppendStr(tls, bp+8, ts+32893, bp+20)
 132421 		sessionAppendIdent(tls, bp+8, zDb, bp+20)
 132422 		sessionAppendStr(tls, bp+8, ts+1567, bp+20)
 132423 		sessionAppendIdent(tls, bp+8, zTab, bp+20)
 132424 		sessionAppendStr(tls, bp+8, ts+32908, bp+20)
 132425 		for i = 0; i < nCol; i++ {
 132426 			if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132427 				sessionAppendStr(tls, bp+8, zSep, bp+20)
 132428 				sessionAppendIdent(tls, bp+8, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*4)), bp+20)
 132429 				sessionAppendStr(tls, bp+8, ts+32916, bp+20)
 132430 				sessionAppendInteger(tls, bp+8, i+1, bp+20)
 132431 				zSep = ts + 21572
 132432 			}
 132433 		}
 132434 		zSql = (*SessionBuffer)(unsafe.Pointer(bp + 8)).FaBuf
 132435 		nSql = (*SessionBuffer)(unsafe.Pointer(bp + 8)).FnBuf
 132436 	}
 132437 
 132438 	if *(*int32)(unsafe.Pointer(bp + 20)) == SQLITE_OK {
 132439 		*(*int32)(unsafe.Pointer(bp + 20)) = Xsqlite3_prepare_v2(tls, db, zSql, nSql, ppStmt, uintptr(0))
 132440 	}
 132441 	Xsqlite3_free(tls, zSql)
 132442 	return *(*int32)(unsafe.Pointer(bp + 20))
 132443 }
 132444 
 132445 func sessionSelectBind(tls *libc.TLS, pSelect uintptr, nCol int32, abPK uintptr, pChange uintptr) int32 {
 132446 	bp := tls.Alloc(24)
 132447 	defer tls.Free(24)
 132448 
 132449 	var i int32
 132450 	var rc int32 = SQLITE_OK
 132451 	var a uintptr = (*SessionChange)(unsafe.Pointer(pChange)).FaRecord
 132452 
 132453 	for i = 0; i < nCol && rc == SQLITE_OK; i++ {
 132454 		var eType int32 = int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1))))
 132455 
 132456 		switch eType {
 132457 		case 0:
 132458 			fallthrough
 132459 		case SQLITE_NULL:
 132460 			break
 132461 
 132462 		case SQLITE_INTEGER:
 132463 			{
 132464 				if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132465 					var iVal I64 = sessionGetI64(tls, a)
 132466 					rc = Xsqlite3_bind_int64(tls, pSelect, i+1, iVal)
 132467 				}
 132468 				a += uintptr(8)
 132469 				break
 132470 
 132471 			}
 132472 
 132473 		case SQLITE_FLOAT:
 132474 			{
 132475 				if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132476 					*(*I64)(unsafe.Pointer(bp + 8)) = sessionGetI64(tls, a)
 132477 					libc.Xmemcpy(tls, bp, bp+8, uint32(8))
 132478 					rc = Xsqlite3_bind_double(tls, pSelect, i+1, *(*float64)(unsafe.Pointer(bp)))
 132479 				}
 132480 				a += uintptr(8)
 132481 				break
 132482 
 132483 			}
 132484 
 132485 		case SQLITE_TEXT:
 132486 			{
 132487 				a += uintptr(sessionVarintGet(tls, a, bp+16))
 132488 				if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132489 					rc = Xsqlite3_bind_text(tls, pSelect, i+1, a, *(*int32)(unsafe.Pointer(bp + 16)), libc.UintptrFromInt32(-1))
 132490 				}
 132491 				a += uintptr(*(*int32)(unsafe.Pointer(bp + 16)))
 132492 				break
 132493 
 132494 			}
 132495 
 132496 		default:
 132497 			{
 132498 				a += uintptr(sessionVarintGet(tls, a, bp+20))
 132499 				if *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 132500 					rc = Xsqlite3_bind_blob(tls, pSelect, i+1, a, *(*int32)(unsafe.Pointer(bp + 20)), libc.UintptrFromInt32(-1))
 132501 				}
 132502 				a += uintptr(*(*int32)(unsafe.Pointer(bp + 20)))
 132503 				break
 132504 
 132505 			}
 132506 		}
 132507 	}
 132508 
 132509 	return rc
 132510 }
 132511 
 132512 func sessionAppendTableHdr(tls *libc.TLS, pBuf uintptr, bPatchset int32, pTab uintptr, pRc uintptr) {
 132513 	sessionAppendByte(tls, pBuf, func() uint8 {
 132514 		if bPatchset != 0 {
 132515 			return uint8('P')
 132516 		}
 132517 		return uint8('T')
 132518 	}(), pRc)
 132519 	sessionAppendVarint(tls, pBuf, (*SessionTable)(unsafe.Pointer(pTab)).FnCol, pRc)
 132520 	sessionAppendBlob(tls, pBuf, (*SessionTable)(unsafe.Pointer(pTab)).FabPK, (*SessionTable)(unsafe.Pointer(pTab)).FnCol, pRc)
 132521 	sessionAppendBlob(tls, pBuf, (*SessionTable)(unsafe.Pointer(pTab)).FzName, int32(libc.Xstrlen(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName))+1, pRc)
 132522 }
 132523 
 132524 func sessionGenerateChangeset(tls *libc.TLS, pSession uintptr, bPatchset int32, xOutput uintptr, pOut uintptr, pnChangeset uintptr, ppChangeset uintptr) int32 {
 132525 	bp := tls.Alloc(32)
 132526 	defer tls.Free(32)
 132527 
 132528 	var db uintptr = (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb
 132529 	var pTab uintptr
 132530 	*(*SessionBuffer)(unsafe.Pointer(bp + 12)) = SessionBuffer{}
 132531 
 132532 	if xOutput == uintptr(0) {
 132533 		*(*int32)(unsafe.Pointer(pnChangeset)) = 0
 132534 		*(*uintptr)(unsafe.Pointer(ppChangeset)) = uintptr(0)
 132535 	}
 132536 
 132537 	if (*Sqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 {
 132538 		return (*Sqlite3_session)(unsafe.Pointer(pSession)).Frc
 132539 	}
 132540 	*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3_exec(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb, ts+32922, uintptr(0), uintptr(0), uintptr(0))
 132541 	if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
 132542 		return *(*int32)(unsafe.Pointer(bp + 24))
 132543 	}
 132544 
 132545 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db))
 132546 
 132547 	for pTab = (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable; *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK && pTab != 0; pTab = (*SessionTable)(unsafe.Pointer(pTab)).FpNext {
 132548 		if (*SessionTable)(unsafe.Pointer(pTab)).FnEntry != 0 {
 132549 			var zName uintptr = (*SessionTable)(unsafe.Pointer(pTab)).FzName
 132550 			*(*int32)(unsafe.Pointer(bp)) = 0
 132551 			*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 132552 			*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 132553 			var i int32
 132554 			*(*uintptr)(unsafe.Pointer(bp + 28)) = uintptr(0)
 132555 			var nRewind int32 = (*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf
 132556 			var nNoop int32
 132557 
 132558 			*(*int32)(unsafe.Pointer(bp + 24)) = sessionTableInfo(tls, uintptr(0), db, (*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb, zName, bp, uintptr(0), bp+4, bp+8)
 132559 			if !(*(*int32)(unsafe.Pointer(bp + 24)) != 0) && ((*SessionTable)(unsafe.Pointer(pTab)).FnCol != *(*int32)(unsafe.Pointer(bp)) || libc.Xmemcmp(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), (*SessionTable)(unsafe.Pointer(pTab)).FabPK, uint32(*(*int32)(unsafe.Pointer(bp)))) != 0) {
 132560 				*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_SCHEMA
 132561 			}
 132562 
 132563 			sessionAppendTableHdr(tls, bp+12, bPatchset, pTab, bp+24)
 132564 
 132565 			if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 132566 				*(*int32)(unsafe.Pointer(bp + 24)) = sessionSelectStmt(tls,
 132567 					db, (*Sqlite3_session)(unsafe.Pointer(pSession)).FzDb, zName, *(*int32)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 4)), *(*uintptr)(unsafe.Pointer(bp + 8)), bp+28)
 132568 			}
 132569 
 132570 			nNoop = (*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf
 132571 			for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnChange && *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK; i++ {
 132572 				var p uintptr
 132573 
 132574 				for p = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*4)); *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK && p != 0; p = (*SessionChange)(unsafe.Pointer(p)).FpNext {
 132575 					*(*int32)(unsafe.Pointer(bp + 24)) = sessionSelectBind(tls, *(*uintptr)(unsafe.Pointer(bp + 28)), *(*int32)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 8)), p)
 132576 					if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
 132577 						continue
 132578 					}
 132579 					if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 28))) == SQLITE_ROW {
 132580 						if int32((*SessionChange)(unsafe.Pointer(p)).Fop) == SQLITE_INSERT {
 132581 							var iCol int32
 132582 							sessionAppendByte(tls, bp+12, uint8(SQLITE_INSERT), bp+24)
 132583 							sessionAppendByte(tls, bp+12, (*SessionChange)(unsafe.Pointer(p)).FbIndirect, bp+24)
 132584 							for iCol = 0; iCol < *(*int32)(unsafe.Pointer(bp)); iCol++ {
 132585 								sessionAppendCol(tls, bp+12, *(*uintptr)(unsafe.Pointer(bp + 28)), iCol, bp+24)
 132586 							}
 132587 						} else {
 132588 							*(*int32)(unsafe.Pointer(bp + 24)) = sessionAppendUpdate(tls, bp+12, bPatchset, *(*uintptr)(unsafe.Pointer(bp + 28)), p, *(*uintptr)(unsafe.Pointer(bp + 8)))
 132589 						}
 132590 					} else if int32((*SessionChange)(unsafe.Pointer(p)).Fop) != SQLITE_INSERT {
 132591 						*(*int32)(unsafe.Pointer(bp + 24)) = sessionAppendDelete(tls, bp+12, bPatchset, p, *(*int32)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(bp + 8)))
 132592 					}
 132593 					if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 132594 						*(*int32)(unsafe.Pointer(bp + 24)) = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 28)))
 132595 					}
 132596 
 132597 					if xOutput != 0 &&
 132598 						*(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK &&
 132599 						(*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf > nNoop &&
 132600 						(*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf > sessions_strm_chunk_size {
 132601 						*(*int32)(unsafe.Pointer(bp + 24)) = (*struct {
 132602 							f func(*libc.TLS, uintptr, uintptr, int32) int32
 132603 						})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf)
 132604 						nNoop = -1
 132605 						(*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf = 0
 132606 					}
 132607 
 132608 				}
 132609 			}
 132610 
 132611 			Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 28)))
 132612 			if (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf == nNoop {
 132613 				(*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf = nRewind
 132614 			}
 132615 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 132616 		}
 132617 	}
 132618 
 132619 	if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 132620 		if xOutput == uintptr(0) {
 132621 			*(*int32)(unsafe.Pointer(pnChangeset)) = (*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf
 132622 			*(*uintptr)(unsafe.Pointer(ppChangeset)) = (*SessionBuffer)(unsafe.Pointer(bp + 12)).FaBuf
 132623 			(*SessionBuffer)(unsafe.Pointer(bp + 12)).FaBuf = uintptr(0)
 132624 		} else if (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf > 0 {
 132625 			*(*int32)(unsafe.Pointer(bp + 24)) = (*struct {
 132626 				f func(*libc.TLS, uintptr, uintptr, int32) int32
 132627 			})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf)
 132628 		}
 132629 	}
 132630 
 132631 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf)
 132632 	Xsqlite3_exec(tls, db, ts+32942, uintptr(0), uintptr(0), uintptr(0))
 132633 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db))
 132634 	return *(*int32)(unsafe.Pointer(bp + 24))
 132635 }
 132636 
 132637 // Obtain a changeset object containing all changes recorded by the
 132638 // session object passed as the first argument.
 132639 //
 132640 // It is the responsibility of the caller to eventually free the buffer
 132641 // using sqlite3_free().
 132642 func Xsqlite3session_changeset(tls *libc.TLS, pSession uintptr, pnChangeset uintptr, ppChangeset uintptr) int32 {
 132643 	var rc int32
 132644 
 132645 	if pnChangeset == uintptr(0) || ppChangeset == uintptr(0) {
 132646 		return SQLITE_MISUSE
 132647 	}
 132648 	rc = sessionGenerateChangeset(tls, pSession, 0, uintptr(0), uintptr(0), pnChangeset, ppChangeset)
 132649 
 132650 	return rc
 132651 }
 132652 
 132653 // Streaming version of sqlite3session_changeset().
 132654 func Xsqlite3session_changeset_strm(tls *libc.TLS, pSession uintptr, xOutput uintptr, pOut uintptr) int32 {
 132655 	if xOutput == uintptr(0) {
 132656 		return SQLITE_MISUSE
 132657 	}
 132658 	return sessionGenerateChangeset(tls, pSession, 0, xOutput, pOut, uintptr(0), uintptr(0))
 132659 }
 132660 
 132661 // Streaming version of sqlite3session_patchset().
 132662 func Xsqlite3session_patchset_strm(tls *libc.TLS, pSession uintptr, xOutput uintptr, pOut uintptr) int32 {
 132663 	if xOutput == uintptr(0) {
 132664 		return SQLITE_MISUSE
 132665 	}
 132666 	return sessionGenerateChangeset(tls, pSession, 1, xOutput, pOut, uintptr(0), uintptr(0))
 132667 }
 132668 
 132669 // Obtain a patchset object containing all changes recorded by the
 132670 // session object passed as the first argument.
 132671 //
 132672 // It is the responsibility of the caller to eventually free the buffer
 132673 // using sqlite3_free().
 132674 func Xsqlite3session_patchset(tls *libc.TLS, pSession uintptr, pnPatchset uintptr, ppPatchset uintptr) int32 {
 132675 	if pnPatchset == uintptr(0) || ppPatchset == uintptr(0) {
 132676 		return SQLITE_MISUSE
 132677 	}
 132678 	return sessionGenerateChangeset(tls, pSession, 1, uintptr(0), uintptr(0), pnPatchset, ppPatchset)
 132679 }
 132680 
 132681 // Enable or disable the session object passed as the first argument.
 132682 func Xsqlite3session_enable(tls *libc.TLS, pSession uintptr, bEnable int32) int32 {
 132683 	var ret int32
 132684 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132685 	if bEnable >= 0 {
 132686 		(*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnable = bEnable
 132687 	}
 132688 	ret = (*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnable
 132689 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132690 	return ret
 132691 }
 132692 
 132693 // Enable or disable the session object passed as the first argument.
 132694 func Xsqlite3session_indirect(tls *libc.TLS, pSession uintptr, bIndirect int32) int32 {
 132695 	var ret int32
 132696 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132697 	if bIndirect >= 0 {
 132698 		(*Sqlite3_session)(unsafe.Pointer(pSession)).FbIndirect = bIndirect
 132699 	}
 132700 	ret = (*Sqlite3_session)(unsafe.Pointer(pSession)).FbIndirect
 132701 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132702 	return ret
 132703 }
 132704 
 132705 // Return true if there have been no changes to monitored tables recorded
 132706 // by the session object passed as the only argument.
 132707 func Xsqlite3session_isempty(tls *libc.TLS, pSession uintptr) int32 {
 132708 	var ret int32 = 0
 132709 	var pTab uintptr
 132710 
 132711 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132712 	for pTab = (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable; pTab != 0 && ret == 0; pTab = (*SessionTable)(unsafe.Pointer(pTab)).FpNext {
 132713 		ret = libc.Bool32((*SessionTable)(unsafe.Pointer(pTab)).FnEntry > 0)
 132714 	}
 132715 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Sqlite3_session)(unsafe.Pointer(pSession)).Fdb))
 132716 
 132717 	return libc.Bool32(ret == 0)
 132718 }
 132719 
 132720 // Return the amount of heap memory in use.
 132721 func Xsqlite3session_memory_used(tls *libc.TLS, pSession uintptr) Sqlite3_int64 {
 132722 	return (*Sqlite3_session)(unsafe.Pointer(pSession)).FnMalloc
 132723 }
 132724 
 132725 // Configure the session object passed as the first argument.
 132726 func Xsqlite3session_object_config(tls *libc.TLS, pSession uintptr, op int32, pArg uintptr) int32 {
 132727 	var rc int32 = SQLITE_OK
 132728 	switch op {
 132729 	case SQLITE_SESSION_OBJCONFIG_SIZE:
 132730 		{
 132731 			var iArg int32 = *(*int32)(unsafe.Pointer(pArg))
 132732 			if iArg >= 0 {
 132733 				if (*Sqlite3_session)(unsafe.Pointer(pSession)).FpTable != 0 {
 132734 					rc = SQLITE_MISUSE
 132735 				} else {
 132736 					(*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize = libc.Bool32(iArg != 0)
 132737 				}
 132738 			}
 132739 			*(*int32)(unsafe.Pointer(pArg)) = (*Sqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize
 132740 			break
 132741 
 132742 		}
 132743 
 132744 	default:
 132745 		rc = SQLITE_MISUSE
 132746 	}
 132747 
 132748 	return rc
 132749 }
 132750 
 132751 // Return the maximum size of sqlite3session_changeset() output.
 132752 func Xsqlite3session_changeset_size(tls *libc.TLS, pSession uintptr) Sqlite3_int64 {
 132753 	return (*Sqlite3_session)(unsafe.Pointer(pSession)).FnMaxChangesetSize
 132754 }
 132755 
 132756 func sessionChangesetStart(tls *libc.TLS, pp uintptr, xInput uintptr, pIn uintptr, nChangeset int32, pChangeset uintptr, bInvert int32, bSkipEmpty int32) int32 {
 132757 	var pRet uintptr
 132758 	var nByte int32
 132759 
 132760 	*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 132761 
 132762 	nByte = int32(unsafe.Sizeof(Sqlite3_changeset_iter{}))
 132763 	pRet = Xsqlite3_malloc(tls, nByte)
 132764 	if !(pRet != 0) {
 132765 		return SQLITE_NOMEM
 132766 	}
 132767 	libc.Xmemset(tls, pRet, 0, uint32(unsafe.Sizeof(Sqlite3_changeset_iter{})))
 132768 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FaData = pChangeset
 132769 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FnData = nChangeset
 132770 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FxInput = xInput
 132771 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FpIn = pIn
 132772 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).Fin.FbEof = func() int32 {
 132773 		if xInput != 0 {
 132774 			return 0
 132775 		}
 132776 		return 1
 132777 	}()
 132778 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).FbInvert = bInvert
 132779 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pRet)).FbSkipEmpty = bSkipEmpty
 132780 
 132781 	*(*uintptr)(unsafe.Pointer(pp)) = pRet
 132782 	return SQLITE_OK
 132783 }
 132784 
 132785 // Create an iterator used to iterate through the contents of a changeset.
 132786 func Xsqlite3changeset_start(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr) int32 {
 132787 	return sessionChangesetStart(tls, pp, uintptr(0), uintptr(0), nChangeset, pChangeset, 0, 0)
 132788 }
 132789 
 132790 func Xsqlite3changeset_start_v2(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr, flags int32) int32 {
 132791 	var bInvert int32 = libc.BoolInt32(!!(flags&SQLITE_CHANGESETSTART_INVERT != 0))
 132792 	return sessionChangesetStart(tls, pp, uintptr(0), uintptr(0), nChangeset, pChangeset, bInvert, 0)
 132793 }
 132794 
 132795 // Streaming version of sqlite3changeset_start().
 132796 func Xsqlite3changeset_start_strm(tls *libc.TLS, pp uintptr, xInput uintptr, pIn uintptr) int32 {
 132797 	return sessionChangesetStart(tls, pp, xInput, pIn, 0, uintptr(0), 0, 0)
 132798 }
 132799 
 132800 func Xsqlite3changeset_start_v2_strm(tls *libc.TLS, pp uintptr, xInput uintptr, pIn uintptr, flags int32) int32 {
 132801 	var bInvert int32 = libc.BoolInt32(!!(flags&SQLITE_CHANGESETSTART_INVERT != 0))
 132802 	return sessionChangesetStart(tls, pp, xInput, pIn, 0, uintptr(0), bInvert, 0)
 132803 }
 132804 
 132805 func sessionDiscardData(tls *libc.TLS, pIn uintptr) {
 132806 	if (*SessionInput)(unsafe.Pointer(pIn)).FxInput != 0 && (*SessionInput)(unsafe.Pointer(pIn)).FiNext >= sessions_strm_chunk_size {
 132807 		var nMove int32 = (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf - (*SessionInput)(unsafe.Pointer(pIn)).FiNext
 132808 
 132809 		if nMove > 0 {
 132810 			libc.Xmemmove(tls, (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf, (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf+uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext), uint32(nMove))
 132811 		}
 132812 		*(*int32)(unsafe.Pointer(pIn + 20 + 4)) -= (*SessionInput)(unsafe.Pointer(pIn)).FiNext
 132813 		(*SessionInput)(unsafe.Pointer(pIn)).FiNext = 0
 132814 		(*SessionInput)(unsafe.Pointer(pIn)).FnData = (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf
 132815 	}
 132816 }
 132817 
 132818 func sessionInputBuffer(tls *libc.TLS, pIn uintptr, nByte int32) int32 {
 132819 	bp := tls.Alloc(8)
 132820 	defer tls.Free(8)
 132821 
 132822 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 132823 	if (*SessionInput)(unsafe.Pointer(pIn)).FxInput != 0 {
 132824 		for !((*SessionInput)(unsafe.Pointer(pIn)).FbEof != 0) && (*SessionInput)(unsafe.Pointer(pIn)).FiNext+nByte >= (*SessionInput)(unsafe.Pointer(pIn)).FnData && *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 132825 			*(*int32)(unsafe.Pointer(bp + 4)) = sessions_strm_chunk_size
 132826 
 132827 			if (*SessionInput)(unsafe.Pointer(pIn)).FbNoDiscard == 0 {
 132828 				sessionDiscardData(tls, pIn)
 132829 			}
 132830 			if SQLITE_OK == sessionBufferGrow(tls, pIn+20, int64(*(*int32)(unsafe.Pointer(bp + 4))), bp) {
 132831 				*(*int32)(unsafe.Pointer(bp)) = (*struct {
 132832 					f func(*libc.TLS, uintptr, uintptr, uintptr) int32
 132833 				})(unsafe.Pointer(&struct{ uintptr }{(*SessionInput)(unsafe.Pointer(pIn)).FxInput})).f(tls, (*SessionInput)(unsafe.Pointer(pIn)).FpIn, (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf+uintptr((*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf), bp+4)
 132834 				if *(*int32)(unsafe.Pointer(bp + 4)) == 0 {
 132835 					(*SessionInput)(unsafe.Pointer(pIn)).FbEof = 1
 132836 				} else {
 132837 					*(*int32)(unsafe.Pointer(pIn + 20 + 4)) += *(*int32)(unsafe.Pointer(bp + 4))
 132838 				}
 132839 			}
 132840 
 132841 			(*SessionInput)(unsafe.Pointer(pIn)).FaData = (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FaBuf
 132842 			(*SessionInput)(unsafe.Pointer(pIn)).FnData = (*SessionInput)(unsafe.Pointer(pIn)).Fbuf.FnBuf
 132843 		}
 132844 	}
 132845 	return *(*int32)(unsafe.Pointer(bp))
 132846 }
 132847 
 132848 func sessionSkipRecord(tls *libc.TLS, ppRec uintptr, nCol int32) {
 132849 	bp := tls.Alloc(4)
 132850 	defer tls.Free(4)
 132851 
 132852 	var aRec uintptr = *(*uintptr)(unsafe.Pointer(ppRec))
 132853 	var i int32
 132854 	for i = 0; i < nCol; i++ {
 132855 		var eType int32 = int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&aRec, 1))))
 132856 		if eType == SQLITE_TEXT || eType == SQLITE_BLOB {
 132857 			aRec += uintptr(sessionVarintGet(tls, aRec, bp))
 132858 			aRec += uintptr(*(*int32)(unsafe.Pointer(bp)))
 132859 		} else if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 132860 			aRec += uintptr(8)
 132861 		}
 132862 	}
 132863 
 132864 	*(*uintptr)(unsafe.Pointer(ppRec)) = aRec
 132865 }
 132866 
 132867 func sessionValueSetStr(tls *libc.TLS, pVal uintptr, aData uintptr, nData int32, enc U8) int32 {
 132868 	var aCopy uintptr = Xsqlite3_malloc64(tls, uint64(Sqlite3_int64(nData)+int64(1)))
 132869 	if aCopy == uintptr(0) {
 132870 		return SQLITE_NOMEM
 132871 	}
 132872 	libc.Xmemcpy(tls, aCopy, aData, uint32(nData))
 132873 	Xsqlite3ValueSetStr(tls, pVal, nData, aCopy, enc, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 132874 	return SQLITE_OK
 132875 }
 132876 
 132877 func sessionReadRecord(tls *libc.TLS, pIn uintptr, nCol int32, abPK uintptr, apOut uintptr, pbEmpty uintptr) int32 {
 132878 	bp := tls.Alloc(24)
 132879 	defer tls.Free(24)
 132880 
 132881 	var i int32
 132882 	var rc int32 = SQLITE_OK
 132883 
 132884 	if pbEmpty != 0 {
 132885 		*(*int32)(unsafe.Pointer(pbEmpty)) = 1
 132886 	}
 132887 	for i = 0; i < nCol && rc == SQLITE_OK; i++ {
 132888 		var eType int32 = 0
 132889 		if abPK != 0 && int32(*(*U8)(unsafe.Pointer(abPK + uintptr(i)))) == 0 {
 132890 			continue
 132891 		}
 132892 		rc = sessionInputBuffer(tls, pIn, 9)
 132893 		if rc == SQLITE_OK {
 132894 			if (*SessionInput)(unsafe.Pointer(pIn)).FiNext >= (*SessionInput)(unsafe.Pointer(pIn)).FnData {
 132895 				rc = Xsqlite3CorruptError(tls, 219169)
 132896 			} else {
 132897 				eType = int32(*(*U8)(unsafe.Pointer((*SessionInput)(unsafe.Pointer(pIn)).FaData + uintptr(libc.PostIncInt32(&(*SessionInput)(unsafe.Pointer(pIn)).FiNext, 1)))))
 132898 
 132899 				if eType != 0 {
 132900 					if pbEmpty != 0 {
 132901 						*(*int32)(unsafe.Pointer(pbEmpty)) = 0
 132902 					}
 132903 					*(*uintptr)(unsafe.Pointer(apOut + uintptr(i)*4)) = Xsqlite3ValueNew(tls, uintptr(0))
 132904 					if !(int32(*(*uintptr)(unsafe.Pointer(apOut + uintptr(i)*4))) != 0) {
 132905 						rc = SQLITE_NOMEM
 132906 					}
 132907 				}
 132908 			}
 132909 		}
 132910 
 132911 		if rc == SQLITE_OK {
 132912 			var aVal uintptr = (*SessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext)
 132913 			if eType == SQLITE_TEXT || eType == SQLITE_BLOB {
 132914 				*(*int32)(unsafe.Pointer(pIn + 8)) += sessionVarintGet(tls, aVal, bp)
 132915 				rc = sessionInputBuffer(tls, pIn, *(*int32)(unsafe.Pointer(bp)))
 132916 				if rc == SQLITE_OK {
 132917 					if *(*int32)(unsafe.Pointer(bp)) < 0 || *(*int32)(unsafe.Pointer(bp)) > (*SessionInput)(unsafe.Pointer(pIn)).FnData-(*SessionInput)(unsafe.Pointer(pIn)).FiNext {
 132918 						rc = Xsqlite3CorruptError(tls, 219189)
 132919 					} else {
 132920 						var enc U8 = func() uint8 {
 132921 							if eType == SQLITE_TEXT {
 132922 								return uint8(SQLITE_UTF8)
 132923 							}
 132924 							return uint8(0)
 132925 						}()
 132926 						rc = sessionValueSetStr(tls, *(*uintptr)(unsafe.Pointer(apOut + uintptr(i)*4)), (*SessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext), *(*int32)(unsafe.Pointer(bp)), enc)
 132927 						*(*int32)(unsafe.Pointer(pIn + 8)) += *(*int32)(unsafe.Pointer(bp))
 132928 					}
 132929 				}
 132930 			}
 132931 			if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 132932 				*(*Sqlite3_int64)(unsafe.Pointer(bp + 16)) = sessionGetI64(tls, aVal)
 132933 				if eType == SQLITE_INTEGER {
 132934 					Xsqlite3VdbeMemSetInt64(tls, *(*uintptr)(unsafe.Pointer(apOut + uintptr(i)*4)), *(*Sqlite3_int64)(unsafe.Pointer(bp + 16)))
 132935 				} else {
 132936 					libc.Xmemcpy(tls, bp+8, bp+16, uint32(8))
 132937 					Xsqlite3VdbeMemSetDouble(tls, *(*uintptr)(unsafe.Pointer(apOut + uintptr(i)*4)), *(*float64)(unsafe.Pointer(bp + 8)))
 132938 				}
 132939 				*(*int32)(unsafe.Pointer(pIn + 8)) += 8
 132940 			}
 132941 		}
 132942 	}
 132943 
 132944 	return rc
 132945 }
 132946 
 132947 func sessionChangesetBufferTblhdr(tls *libc.TLS, pIn uintptr, pnByte uintptr) int32 {
 132948 	bp := tls.Alloc(4)
 132949 	defer tls.Free(4)
 132950 
 132951 	var rc int32 = SQLITE_OK
 132952 	*(*int32)(unsafe.Pointer(bp)) = 0
 132953 	var nRead int32 = 0
 132954 
 132955 	rc = sessionInputBuffer(tls, pIn, 9)
 132956 	if rc == SQLITE_OK {
 132957 		nRead = nRead + sessionVarintGet(tls, (*SessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext+nRead), bp)
 132958 
 132959 		if *(*int32)(unsafe.Pointer(bp)) < 0 || *(*int32)(unsafe.Pointer(bp)) > 65536 {
 132960 			rc = Xsqlite3CorruptError(tls, 219243)
 132961 		} else {
 132962 			rc = sessionInputBuffer(tls, pIn, nRead+*(*int32)(unsafe.Pointer(bp))+100)
 132963 			nRead = nRead + *(*int32)(unsafe.Pointer(bp))
 132964 		}
 132965 	}
 132966 
 132967 	for rc == SQLITE_OK {
 132968 		for (*SessionInput)(unsafe.Pointer(pIn)).FiNext+nRead < (*SessionInput)(unsafe.Pointer(pIn)).FnData && *(*U8)(unsafe.Pointer((*SessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext+nRead))) != 0 {
 132969 			nRead++
 132970 		}
 132971 		if (*SessionInput)(unsafe.Pointer(pIn)).FiNext+nRead < (*SessionInput)(unsafe.Pointer(pIn)).FnData {
 132972 			break
 132973 		}
 132974 		rc = sessionInputBuffer(tls, pIn, nRead+100)
 132975 	}
 132976 	*(*int32)(unsafe.Pointer(pnByte)) = nRead + 1
 132977 	return rc
 132978 }
 132979 
 132980 func sessionChangesetBufferRecord(tls *libc.TLS, pIn uintptr, nCol int32, pnByte uintptr) int32 {
 132981 	bp := tls.Alloc(4)
 132982 	defer tls.Free(4)
 132983 
 132984 	var rc int32 = SQLITE_OK
 132985 	var nByte int32 = 0
 132986 	var i int32
 132987 	for i = 0; rc == SQLITE_OK && i < nCol; i++ {
 132988 		var eType int32
 132989 		rc = sessionInputBuffer(tls, pIn, nByte+10)
 132990 		if rc == SQLITE_OK {
 132991 			eType = int32(*(*U8)(unsafe.Pointer((*SessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext+libc.PostIncInt32(&nByte, 1)))))
 132992 			if eType == SQLITE_TEXT || eType == SQLITE_BLOB {
 132993 				nByte = nByte + sessionVarintGet(tls, (*SessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pIn)).FiNext+nByte), bp)
 132994 				nByte = nByte + *(*int32)(unsafe.Pointer(bp))
 132995 				rc = sessionInputBuffer(tls, pIn, nByte)
 132996 			} else if eType == SQLITE_INTEGER || eType == SQLITE_FLOAT {
 132997 				nByte = nByte + 8
 132998 			}
 132999 		}
 133000 	}
 133001 	*(*int32)(unsafe.Pointer(pnByte)) = nByte
 133002 	return rc
 133003 }
 133004 
 133005 func sessionChangesetReadTblhdr(tls *libc.TLS, p uintptr) int32 {
 133006 	bp := tls.Alloc(8)
 133007 	defer tls.Free(8)
 133008 
 133009 	*(*int32)(unsafe.Pointer(bp + 4)) = sessionChangesetBufferTblhdr(tls, p, bp)
 133010 	if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 133011 		var nByte int32
 133012 		var nVarint int32
 133013 		nVarint = sessionVarintGet(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData+uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext), p+80)
 133014 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol > 0 {
 133015 			*(*int32)(unsafe.Pointer(bp)) -= nVarint
 133016 			*(*int32)(unsafe.Pointer(p + 8)) += nVarint
 133017 			nByte = int32(uint32((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*uint32(unsafe.Sizeof(uintptr(0)))*uint32(2) + uint32(*(*int32)(unsafe.Pointer(bp))))
 133018 			(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FnBuf = 0
 133019 			sessionBufferGrow(tls, p+44, int64(nByte), bp+4)
 133020 		} else {
 133021 			*(*int32)(unsafe.Pointer(bp + 4)) = Xsqlite3CorruptError(tls, 219331)
 133022 		}
 133023 	}
 133024 
 133025 	if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 133026 		var iPK Size_t = uint32(unsafe.Sizeof(uintptr(0))) * uint32((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol) * uint32(2)
 133027 		libc.Xmemset(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf, 0, iPK)
 133028 		libc.Xmemcpy(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf+uintptr(iPK), (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData+uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext), uint32(*(*int32)(unsafe.Pointer(bp))))
 133029 		*(*int32)(unsafe.Pointer(p + 8)) += *(*int32)(unsafe.Pointer(bp))
 133030 	}
 133031 
 133032 	(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf
 133033 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue == uintptr(0) {
 133034 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK = uintptr(0)
 133035 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab = uintptr(0)
 133036 	} else {
 133037 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*2)*4
 133038 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab = func() uintptr {
 133039 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK != 0 {
 133040 				return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)
 133041 			}
 133042 			return uintptr(0)
 133043 		}()
 133044 	}
 133045 	return libc.AssignPtrInt32(p+68, *(*int32)(unsafe.Pointer(bp + 4)))
 133046 }
 133047 
 133048 func sessionChangesetNextOne(tls *libc.TLS, p uintptr, paRec uintptr, pnRec uintptr, pbNew uintptr, pbEmpty uintptr) int32 {
 133049 	var i int32
 133050 	var op U8
 133051 
 133052 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 133053 		return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133054 	}
 133055 
 133056 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue != 0 {
 133057 		for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*2; i++ {
 133058 			Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*4)))
 133059 		}
 133060 		libc.Xmemset(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*uint32(2))
 133061 	}
 133062 
 133063 	(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = sessionInputBuffer(tls, p, 2)
 133064 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 133065 		return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133066 	}
 133067 
 133068 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData {
 133069 		return SQLITE_DONE
 133070 	}
 133071 
 133072 	sessionDiscardData(tls, p)
 133073 	(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiCurrent = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext
 133074 
 133075 	op = *(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(libc.PostIncInt32(&(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext, 1))))
 133076 	for int32(op) == 'T' || int32(op) == 'P' {
 133077 		if pbNew != 0 {
 133078 			*(*int32)(unsafe.Pointer(pbNew)) = 1
 133079 		}
 133080 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset = libc.Bool32(int32(op) == 'P')
 133081 		if sessionChangesetReadTblhdr(tls, p) != 0 {
 133082 			return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133083 		}
 133084 		if libc.AssignPtrInt32(p+68, sessionInputBuffer(tls, p, 2)) != 0 {
 133085 			return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133086 		}
 133087 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiCurrent = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext
 133088 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext >= (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FnData {
 133089 			return SQLITE_DONE
 133090 		}
 133091 		op = *(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(libc.PostIncInt32(&(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext, 1))))
 133092 	}
 133093 
 133094 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FzTab == uintptr(0) || (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 && (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 {
 133095 		return libc.AssignPtrInt32(p+68, Xsqlite3CorruptError(tls, 219417))
 133096 	}
 133097 
 133098 	(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = int32(op)
 133099 	(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbIndirect = int32(*(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr(libc.PostIncInt32(&(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext, 1)))))
 133100 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != SQLITE_UPDATE && (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != SQLITE_DELETE && (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != SQLITE_INSERT {
 133101 		return libc.AssignPtrInt32(p+68, Xsqlite3CorruptError(tls, 219423))
 133102 	}
 133103 
 133104 	if paRec != 0 {
 133105 		var nVal int32
 133106 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 && int32(op) == SQLITE_UPDATE {
 133107 			nVal = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol * 2
 133108 		} else if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 && int32(op) == SQLITE_DELETE {
 133109 			nVal = 0
 133110 			for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol; i++ {
 133111 				if *(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 {
 133112 					nVal++
 133113 				}
 133114 			}
 133115 		} else {
 133116 			nVal = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol
 133117 		}
 133118 		(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = sessionChangesetBufferRecord(tls, p, nVal, pnRec)
 133119 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 133120 			return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133121 		}
 133122 		*(*uintptr)(unsafe.Pointer(paRec)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FaData + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.FiNext)
 133123 		*(*int32)(unsafe.Pointer(p + 8)) += *(*int32)(unsafe.Pointer(pnRec))
 133124 	} else {
 133125 		var apOld uintptr = func() uintptr {
 133126 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 {
 133127 				return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*4
 133128 			}
 133129 			return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue
 133130 		}()
 133131 		var apNew uintptr = func() uintptr {
 133132 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 {
 133133 				return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue
 133134 			}
 133135 			return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*4
 133136 		}()
 133137 
 133138 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != SQLITE_INSERT && ((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 || (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == SQLITE_DELETE) {
 133139 			var abPK uintptr
 133140 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 {
 133141 				abPK = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK
 133142 			} else {
 133143 				abPK = uintptr(0)
 133144 			}
 133145 			(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = sessionReadRecord(tls, p, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol, abPK, apOld, uintptr(0))
 133146 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 133147 				return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133148 			}
 133149 		}
 133150 
 133151 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop != SQLITE_DELETE {
 133152 			(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc = sessionReadRecord(tls, p, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol, uintptr(0), apNew, pbEmpty)
 133153 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 133154 				return (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133155 			}
 133156 		}
 133157 
 133158 		if ((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset != 0 || (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0) && (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == SQLITE_UPDATE {
 133159 			for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol; i++ {
 133160 				if *(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 {
 133161 					*(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*4))
 133162 					if *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*4)) == uintptr(0) {
 133163 						return libc.AssignPtrInt32(p+68, Xsqlite3CorruptError(tls, 219467))
 133164 					}
 133165 					*(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*4)) = uintptr(0)
 133166 				}
 133167 			}
 133168 		} else if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbInvert != 0 {
 133169 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == SQLITE_INSERT {
 133170 				(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = SQLITE_DELETE
 133171 			} else if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == SQLITE_DELETE {
 133172 				(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop = SQLITE_INSERT
 133173 			}
 133174 		}
 133175 
 133176 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbPatchset == 0 && (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fop == SQLITE_UPDATE {
 133177 			for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol; i++ {
 133178 				if int32(*(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FabPK + uintptr(i)))) == 0 && *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i+(*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol)*4)) == uintptr(0) {
 133179 					Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*4)))
 133180 					*(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*4)) = uintptr(0)
 133181 				}
 133182 			}
 133183 		}
 133184 	}
 133185 
 133186 	return SQLITE_ROW
 133187 }
 133188 
 133189 func sessionChangesetNext(tls *libc.TLS, p uintptr, paRec uintptr, pnRec uintptr, pbNew uintptr) int32 {
 133190 	bp := tls.Alloc(4)
 133191 	defer tls.Free(4)
 133192 
 133193 	var rc int32
 133194 	for __ccgo := true; __ccgo; __ccgo = rc == SQLITE_ROW && (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FbSkipEmpty != 0 && *(*int32)(unsafe.Pointer(bp)) != 0 {
 133195 		*(*int32)(unsafe.Pointer(bp)) = 0
 133196 		rc = sessionChangesetNextOne(tls, p, paRec, pnRec, pbNew, bp)
 133197 	}
 133198 	return rc
 133199 }
 133200 
 133201 // Advance an iterator created by sqlite3changeset_start() to the next
 133202 // change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE
 133203 // or SQLITE_CORRUPT.
 133204 //
 133205 // This function may not be called on iterators passed to a conflict handler
 133206 // callback by changeset_apply().
 133207 func Xsqlite3changeset_next(tls *libc.TLS, p uintptr) int32 {
 133208 	return sessionChangesetNext(tls, p, uintptr(0), uintptr(0), uintptr(0))
 133209 }
 133210 
 133211 // The following function extracts information on the current change
 133212 // from a changeset iterator. It may only be called after changeset_next()
 133213 // has returned SQLITE_ROW.
 133214 func Xsqlite3changeset_op(tls *libc.TLS, pIter uintptr, pzTab uintptr, pnCol uintptr, pOp uintptr, pbIndirect uintptr) int32 {
 133215 	*(*int32)(unsafe.Pointer(pOp)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop
 133216 	*(*int32)(unsafe.Pointer(pnCol)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
 133217 	*(*uintptr)(unsafe.Pointer(pzTab)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab
 133218 	if pbIndirect != 0 {
 133219 		*(*int32)(unsafe.Pointer(pbIndirect)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect
 133220 	}
 133221 	return SQLITE_OK
 133222 }
 133223 
 133224 // Return information regarding the PRIMARY KEY and number of columns in
 133225 // the database table affected by the change that pIter currently points
 133226 // to. This function may only be called after changeset_next() returns
 133227 // SQLITE_ROW.
 133228 func Xsqlite3changeset_pk(tls *libc.TLS, pIter uintptr, pabPK uintptr, pnCol uintptr) int32 {
 133229 	*(*uintptr)(unsafe.Pointer(pabPK)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK
 133230 	if pnCol != 0 {
 133231 		*(*int32)(unsafe.Pointer(pnCol)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
 133232 	}
 133233 	return SQLITE_OK
 133234 }
 133235 
 133236 // This function may only be called while the iterator is pointing to an
 133237 // SQLITE_UPDATE or SQLITE_DELETE change (see sqlite3changeset_op()).
 133238 // Otherwise, SQLITE_MISUSE is returned.
 133239 //
 133240 // It sets *ppValue to point to an sqlite3_value structure containing the
 133241 // iVal'th value in the old.* record. Or, if that particular value is not
 133242 // included in the record (because the change is an UPDATE and the field
 133243 // was not modified and is not a PK column), set *ppValue to NULL.
 133244 //
 133245 // If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is
 133246 // not modified. Otherwise, SQLITE_OK.
 133247 func Xsqlite3changeset_old(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) int32 {
 133248 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != SQLITE_UPDATE && (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != SQLITE_DELETE {
 133249 		return SQLITE_MISUSE
 133250 	}
 133251 	if iVal < 0 || iVal >= (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol {
 133252 		return SQLITE_RANGE
 133253 	}
 133254 	*(*uintptr)(unsafe.Pointer(ppValue)) = *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(iVal)*4))
 133255 	return SQLITE_OK
 133256 }
 133257 
 133258 // This function may only be called while the iterator is pointing to an
 133259 // SQLITE_UPDATE or SQLITE_INSERT change (see sqlite3changeset_op()).
 133260 // Otherwise, SQLITE_MISUSE is returned.
 133261 //
 133262 // It sets *ppValue to point to an sqlite3_value structure containing the
 133263 // iVal'th value in the new.* record. Or, if that particular value is not
 133264 // included in the record (because the change is an UPDATE and the field
 133265 // was not modified), set *ppValue to NULL.
 133266 //
 133267 // If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is
 133268 // not modified. Otherwise, SQLITE_OK.
 133269 func Xsqlite3changeset_new(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) int32 {
 133270 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != SQLITE_UPDATE && (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop != SQLITE_INSERT {
 133271 		return SQLITE_MISUSE
 133272 	}
 133273 	if iVal < 0 || iVal >= (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol {
 133274 		return SQLITE_RANGE
 133275 	}
 133276 	*(*uintptr)(unsafe.Pointer(ppValue)) = *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+iVal)*4))
 133277 	return SQLITE_OK
 133278 }
 133279 
 133280 // This function may only be called with a changeset iterator that has been
 133281 // passed to an SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT
 133282 // conflict-handler function. Otherwise, SQLITE_MISUSE is returned.
 133283 //
 133284 // If successful, *ppValue is set to point to an sqlite3_value structure
 133285 // containing the iVal'th value of the conflicting record.
 133286 //
 133287 // If value iVal is out-of-range or some other error occurs, an SQLite error
 133288 // code is returned. Otherwise, SQLITE_OK.
 133289 func Xsqlite3changeset_conflict(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) int32 {
 133290 	if !(int32((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict) != 0) {
 133291 		return SQLITE_MISUSE
 133292 	}
 133293 	if iVal < 0 || iVal >= (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol {
 133294 		return SQLITE_RANGE
 133295 	}
 133296 	*(*uintptr)(unsafe.Pointer(ppValue)) = Xsqlite3_column_value(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict, iVal)
 133297 	return SQLITE_OK
 133298 }
 133299 
 133300 // This function may only be called with an iterator passed to an
 133301 // SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case
 133302 // it sets the output variable to the total number of known foreign key
 133303 // violations in the destination database and returns SQLITE_OK.
 133304 //
 133305 // In all other cases this function returns SQLITE_MISUSE.
 133306 func Xsqlite3changeset_fk_conflicts(tls *libc.TLS, pIter uintptr, pnOut uintptr) int32 {
 133307 	if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict != 0 || (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue != 0 {
 133308 		return SQLITE_MISUSE
 133309 	}
 133310 	*(*int32)(unsafe.Pointer(pnOut)) = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
 133311 	return SQLITE_OK
 133312 }
 133313 
 133314 // Finalize an iterator allocated with sqlite3changeset_start().
 133315 //
 133316 // This function may not be called on iterators passed to a conflict handler
 133317 // callback by changeset_apply().
 133318 func Xsqlite3changeset_finalize(tls *libc.TLS, p uintptr) int32 {
 133319 	var rc int32 = SQLITE_OK
 133320 	if p != 0 {
 133321 		var i int32
 133322 		rc = (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Frc
 133323 		if (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue != 0 {
 133324 			for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FnCol*2; i++ {
 133325 				Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(p)).FapValue + uintptr(i)*4)))
 133326 			}
 133327 		}
 133328 		Xsqlite3_free(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Ftblhdr.FaBuf)
 133329 		Xsqlite3_free(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(p)).Fin.Fbuf.FaBuf)
 133330 		Xsqlite3_free(tls, p)
 133331 	}
 133332 	return rc
 133333 }
 133334 
 133335 func sessionChangesetInvert(tls *libc.TLS, pInput uintptr, xOutput uintptr, pOut uintptr, pnInverted uintptr, ppInverted uintptr) int32 {
 133336 	bp := tls.Alloc(40)
 133337 	defer tls.Free(40)
 133338 
 133339 	var abPK uintptr
 133340 	var apVal uintptr
 133341 
 133342 	var nVar int32
 133343 
 133344 	var bIndirect int32
 133345 	var eType2 int32
 133346 	var pVal uintptr
 133347 	var pVal1 uintptr
 133348 	var iCol int32
 133349 	var eType U8
 133350 	*(*int32)(unsafe.Pointer(bp + 32)) = SQLITE_OK
 133351 	*(*int32)(unsafe.Pointer(bp + 16)) = 0
 133352 	abPK = uintptr(0)
 133353 	apVal = uintptr(0)
 133354 	*(*SessionBuffer)(unsafe.Pointer(bp + 20)) = SessionBuffer{}
 133355 
 133356 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(SessionBuffer{})))
 133357 
 133358 	if !(ppInverted != 0) {
 133359 		goto __1
 133360 	}
 133361 	*(*uintptr)(unsafe.Pointer(ppInverted)) = uintptr(0)
 133362 	*(*int32)(unsafe.Pointer(pnInverted)) = 0
 133363 __1:
 133364 	;
 133365 __2:
 133366 	if !(1 != 0) {
 133367 		goto __3
 133368 	}
 133369 
 133370 	if !(libc.AssignPtrInt32(bp+32, sessionInputBuffer(tls, pInput, 2)) != 0) {
 133371 		goto __4
 133372 	}
 133373 	goto finished_invert
 133374 __4:
 133375 	;
 133376 	if !((*SessionInput)(unsafe.Pointer(pInput)).FiNext >= (*SessionInput)(unsafe.Pointer(pInput)).FnData) {
 133377 		goto __5
 133378 	}
 133379 	goto __3
 133380 __5:
 133381 	;
 133382 	eType = *(*U8)(unsafe.Pointer((*SessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext)))
 133383 
 133384 	switch int32(eType) {
 133385 	case 'T':
 133386 		goto __7
 133387 
 133388 	case SQLITE_INSERT:
 133389 		goto __8
 133390 	case SQLITE_DELETE:
 133391 		goto __9
 133392 
 133393 	case SQLITE_UPDATE:
 133394 		goto __10
 133395 
 133396 	default:
 133397 		goto __11
 133398 	}
 133399 	goto __6
 133400 __7:
 133401 	(*SessionInput)(unsafe.Pointer(pInput)).FiNext++
 133402 	if !(libc.AssignPtrInt32(bp+32, sessionChangesetBufferTblhdr(tls, pInput, bp+12)) != 0) {
 133403 		goto __12
 133404 	}
 133405 	goto finished_invert
 133406 __12:
 133407 	;
 133408 	nVar = sessionVarintGet(tls, (*SessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext), bp+16)
 133409 	(*SessionBuffer)(unsafe.Pointer(bp + 20)).FnBuf = 0
 133410 	sessionAppendBlob(tls, bp+20, (*SessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext+nVar), *(*int32)(unsafe.Pointer(bp + 16)), bp+32)
 133411 	sessionAppendByte(tls, bp, eType, bp+32)
 133412 	sessionAppendBlob(tls, bp, (*SessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext), *(*int32)(unsafe.Pointer(bp + 12)), bp+32)
 133413 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) {
 133414 		goto __13
 133415 	}
 133416 	goto finished_invert
 133417 __13:
 133418 	;
 133419 	*(*int32)(unsafe.Pointer(pInput + 8)) += *(*int32)(unsafe.Pointer(bp + 12))
 133420 	Xsqlite3_free(tls, apVal)
 133421 	apVal = uintptr(0)
 133422 	abPK = (*SessionBuffer)(unsafe.Pointer(bp + 20)).FaBuf
 133423 	goto __6
 133424 
 133425 __8:
 133426 __9:
 133427 	bIndirect = int32(*(*U8)(unsafe.Pointer((*SessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext+1))))
 133428 	eType2 = func() int32 {
 133429 		if int32(eType) == SQLITE_DELETE {
 133430 			return SQLITE_INSERT
 133431 		}
 133432 		return SQLITE_DELETE
 133433 	}()
 133434 	*(*int32)(unsafe.Pointer(pInput + 8)) += 2
 133435 
 133436 	*(*int32)(unsafe.Pointer(bp + 32)) = sessionChangesetBufferRecord(tls, pInput, *(*int32)(unsafe.Pointer(bp + 16)), bp+36)
 133437 	sessionAppendByte(tls, bp, uint8(eType2), bp+32)
 133438 	sessionAppendByte(tls, bp, uint8(bIndirect), bp+32)
 133439 	sessionAppendBlob(tls, bp, (*SessionInput)(unsafe.Pointer(pInput)).FaData+uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext), *(*int32)(unsafe.Pointer(bp + 36)), bp+32)
 133440 	*(*int32)(unsafe.Pointer(pInput + 8)) += *(*int32)(unsafe.Pointer(bp + 36))
 133441 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != 0) {
 133442 		goto __14
 133443 	}
 133444 	goto finished_invert
 133445 __14:
 133446 	;
 133447 	goto __6
 133448 
 133449 __10:
 133450 	if !(uintptr(0) == apVal) {
 133451 		goto __15
 133452 	}
 133453 	apVal = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(uintptr(0)))*uint32(*(*int32)(unsafe.Pointer(bp + 16)))*uint32(2)))
 133454 	if !(uintptr(0) == apVal) {
 133455 		goto __16
 133456 	}
 133457 	*(*int32)(unsafe.Pointer(bp + 32)) = SQLITE_NOMEM
 133458 	goto finished_invert
 133459 __16:
 133460 	;
 133461 	libc.Xmemset(tls, apVal, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32(*(*int32)(unsafe.Pointer(bp + 16)))*uint32(2))
 133462 __15:
 133463 	;
 133464 	sessionAppendByte(tls, bp, eType, bp+32)
 133465 	sessionAppendByte(tls, bp, *(*U8)(unsafe.Pointer((*SessionInput)(unsafe.Pointer(pInput)).FaData + uintptr((*SessionInput)(unsafe.Pointer(pInput)).FiNext+1))), bp+32)
 133466 
 133467 	*(*int32)(unsafe.Pointer(pInput + 8)) += 2
 133468 	*(*int32)(unsafe.Pointer(bp + 32)) = sessionReadRecord(tls, pInput, *(*int32)(unsafe.Pointer(bp + 16)), uintptr(0), apVal, uintptr(0))
 133469 	if !(*(*int32)(unsafe.Pointer(bp + 32)) == SQLITE_OK) {
 133470 		goto __17
 133471 	}
 133472 	*(*int32)(unsafe.Pointer(bp + 32)) = sessionReadRecord(tls, pInput, *(*int32)(unsafe.Pointer(bp + 16)), uintptr(0), apVal+uintptr(*(*int32)(unsafe.Pointer(bp + 16)))*4, uintptr(0))
 133473 __17:
 133474 	;
 133475 	iCol = 0
 133476 __18:
 133477 	if !(iCol < *(*int32)(unsafe.Pointer(bp + 16))) {
 133478 		goto __20
 133479 	}
 133480 	pVal = *(*uintptr)(unsafe.Pointer(apVal + uintptr(iCol+func() int32 {
 133481 		if *(*U8)(unsafe.Pointer(abPK + uintptr(iCol))) != 0 {
 133482 			return 0
 133483 		}
 133484 		return *(*int32)(unsafe.Pointer(bp + 16))
 133485 	}())*4))
 133486 	sessionAppendValue(tls, bp, pVal, bp+32)
 133487 	goto __19
 133488 __19:
 133489 	iCol++
 133490 	goto __18
 133491 	goto __20
 133492 __20:
 133493 	;
 133494 	iCol = 0
 133495 __21:
 133496 	if !(iCol < *(*int32)(unsafe.Pointer(bp + 16))) {
 133497 		goto __23
 133498 	}
 133499 	pVal1 = func() uintptr {
 133500 		if *(*U8)(unsafe.Pointer(abPK + uintptr(iCol))) != 0 {
 133501 			return uintptr(0)
 133502 		}
 133503 		return *(*uintptr)(unsafe.Pointer(apVal + uintptr(iCol)*4))
 133504 	}()
 133505 	sessionAppendValue(tls, bp, pVal1, bp+32)
 133506 	goto __22
 133507 __22:
 133508 	iCol++
 133509 	goto __21
 133510 	goto __23
 133511 __23:
 133512 	;
 133513 	iCol = 0
 133514 __24:
 133515 	if !(iCol < *(*int32)(unsafe.Pointer(bp + 16))*2) {
 133516 		goto __26
 133517 	}
 133518 	Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(iCol)*4)))
 133519 	goto __25
 133520 __25:
 133521 	iCol++
 133522 	goto __24
 133523 	goto __26
 133524 __26:
 133525 	;
 133526 	libc.Xmemset(tls, apVal, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32(*(*int32)(unsafe.Pointer(bp + 16)))*uint32(2))
 133527 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != SQLITE_OK) {
 133528 		goto __27
 133529 	}
 133530 	goto finished_invert
 133531 __27:
 133532 	;
 133533 	goto __6
 133534 
 133535 __11:
 133536 	*(*int32)(unsafe.Pointer(bp + 32)) = Xsqlite3CorruptError(tls, 219832)
 133537 	goto finished_invert
 133538 __6:
 133539 	;
 133540 	if !(xOutput != 0 && (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf >= sessions_strm_chunk_size) {
 133541 		goto __28
 133542 	}
 133543 	*(*int32)(unsafe.Pointer(bp + 32)) = (*struct {
 133544 		f func(*libc.TLS, uintptr, uintptr, int32) int32
 133545 	})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf)
 133546 	(*SessionBuffer)(unsafe.Pointer(bp)).FnBuf = 0
 133547 	if !(*(*int32)(unsafe.Pointer(bp + 32)) != SQLITE_OK) {
 133548 		goto __29
 133549 	}
 133550 	goto finished_invert
 133551 __29:
 133552 	;
 133553 __28:
 133554 	;
 133555 	goto __2
 133556 __3:
 133557 	;
 133558 	if !(pnInverted != 0 && ppInverted != 0) {
 133559 		goto __30
 133560 	}
 133561 	*(*int32)(unsafe.Pointer(pnInverted)) = (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf
 133562 	*(*uintptr)(unsafe.Pointer(ppInverted)) = (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf
 133563 	(*SessionBuffer)(unsafe.Pointer(bp)).FaBuf = uintptr(0)
 133564 	goto __31
 133565 __30:
 133566 	if !((*SessionBuffer)(unsafe.Pointer(bp)).FnBuf > 0 && xOutput != uintptr(0)) {
 133567 		goto __32
 133568 	}
 133569 	*(*int32)(unsafe.Pointer(bp + 32)) = (*struct {
 133570 		f func(*libc.TLS, uintptr, uintptr, int32) int32
 133571 	})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf)
 133572 __32:
 133573 	;
 133574 __31:
 133575 	;
 133576 finished_invert:
 133577 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf)
 133578 	Xsqlite3_free(tls, apVal)
 133579 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp+20)).FaBuf)
 133580 	return *(*int32)(unsafe.Pointer(bp + 32))
 133581 }
 133582 
 133583 // Invert a changeset object.
 133584 func Xsqlite3changeset_invert(tls *libc.TLS, nChangeset int32, pChangeset uintptr, pnInverted uintptr, ppInverted uintptr) int32 {
 133585 	bp := tls.Alloc(44)
 133586 	defer tls.Free(44)
 133587 
 133588 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(SessionInput{})))
 133589 	(*SessionInput)(unsafe.Pointer(bp)).FnData = nChangeset
 133590 	(*SessionInput)(unsafe.Pointer(bp)).FaData = pChangeset
 133591 
 133592 	return sessionChangesetInvert(tls, bp, uintptr(0), uintptr(0), pnInverted, ppInverted)
 133593 }
 133594 
 133595 // Streaming version of sqlite3changeset_invert().
 133596 func Xsqlite3changeset_invert_strm(tls *libc.TLS, xInput uintptr, pIn uintptr, xOutput uintptr, pOut uintptr) int32 {
 133597 	bp := tls.Alloc(44)
 133598 	defer tls.Free(44)
 133599 
 133600 	var rc int32
 133601 
 133602 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(SessionInput{})))
 133603 	(*SessionInput)(unsafe.Pointer(bp)).FxInput = xInput
 133604 	(*SessionInput)(unsafe.Pointer(bp)).FpIn = pIn
 133605 
 133606 	rc = sessionChangesetInvert(tls, bp, xOutput, pOut, uintptr(0), uintptr(0))
 133607 	Xsqlite3_free(tls, (*SessionInput)(unsafe.Pointer(bp)).Fbuf.FaBuf)
 133608 	return rc
 133609 }
 133610 
 133611 type SessionUpdate1 = struct {
 133612 	FpStmt uintptr
 133613 	FaMask uintptr
 133614 	FpNext uintptr
 133615 }
 133616 
 133617 type SessionUpdate = SessionUpdate1
 133618 
 133619 type SessionApplyCtx1 = struct {
 133620 	Fdb                 uintptr
 133621 	FpDelete            uintptr
 133622 	FpInsert            uintptr
 133623 	FpSelect            uintptr
 133624 	FnCol               int32
 133625 	FazCol              uintptr
 133626 	FabPK               uintptr
 133627 	FaUpdateMask        uintptr
 133628 	FpUp                uintptr
 133629 	FbStat1             int32
 133630 	FbDeferConstraints  int32
 133631 	FbInvertConstraints int32
 133632 	Fconstraints        SessionBuffer
 133633 	Frebase             SessionBuffer
 133634 	FbRebaseStarted     U8
 133635 	FbRebase            U8
 133636 	F__ccgo_pad1        [2]byte
 133637 }
 133638 
 133639 type SessionApplyCtx = SessionApplyCtx1
 133640 
 133641 func sessionUpdateFind(tls *libc.TLS, pIter uintptr, p uintptr, bPatchset int32, ppStmt uintptr) int32 {
 133642 	bp := tls.Alloc(16)
 133643 	defer tls.Free(16)
 133644 
 133645 	*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 133646 	var pUp uintptr = uintptr(0)
 133647 	var nCol int32 = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
 133648 	var nU32 int32 = ((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol + 33) / 32
 133649 	var ii int32
 133650 
 133651 	if (*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask == uintptr(0) {
 133652 		(*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask = Xsqlite3_malloc(tls, int32(uint32(nU32)*uint32(unsafe.Sizeof(U32(0)))))
 133653 		if (*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask == uintptr(0) {
 133654 			*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_NOMEM
 133655 		}
 133656 	}
 133657 
 133658 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 133659 		libc.Xmemset(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, 0, uint32(nU32)*uint32(unsafe.Sizeof(U32(0))))
 133660 		*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_CORRUPT
 133661 		for ii = 0; ii < (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol; ii++ {
 133662 			if *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+ii)*4)) != 0 {
 133663 				*(*U32)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask + uintptr(ii/32)*4)) |= U32(int32(1) << (ii % 32))
 133664 				*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 133665 			}
 133666 		}
 133667 	}
 133668 
 133669 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 133670 		if bPatchset != 0 {
 133671 			*(*U32)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask + uintptr(nCol/32)*4)) |= U32(int32(1) << (nCol % 32))
 133672 		}
 133673 
 133674 		if (*SessionApplyCtx)(unsafe.Pointer(p)).FpUp != 0 {
 133675 			var nUp int32 = 0
 133676 			var pp uintptr = p + 32
 133677 			for 1 != 0 {
 133678 				nUp++
 133679 				if 0 == libc.Xmemcmp(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, (*SessionUpdate)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FaMask, uint32(nU32)*uint32(unsafe.Sizeof(U32(0)))) {
 133680 					pUp = *(*uintptr)(unsafe.Pointer(pp))
 133681 					*(*uintptr)(unsafe.Pointer(pp)) = (*SessionUpdate)(unsafe.Pointer(pUp)).FpNext
 133682 					(*SessionUpdate)(unsafe.Pointer(pUp)).FpNext = (*SessionApplyCtx)(unsafe.Pointer(p)).FpUp
 133683 					(*SessionApplyCtx)(unsafe.Pointer(p)).FpUp = pUp
 133684 					break
 133685 				}
 133686 
 133687 				if (*SessionUpdate)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext != 0 {
 133688 					pp = *(*uintptr)(unsafe.Pointer(pp)) + 8
 133689 				} else {
 133690 					if nUp >= SESSION_UPDATE_CACHE_SZ {
 133691 						Xsqlite3_finalize(tls, (*SessionUpdate)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpStmt)
 133692 						Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pp)))
 133693 						*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 133694 					}
 133695 					break
 133696 				}
 133697 			}
 133698 		}
 133699 
 133700 		if pUp == uintptr(0) {
 133701 			var nByte int32 = int32(uint32(unsafe.Sizeof(SessionUpdate{})) * uint32(nU32) * uint32(unsafe.Sizeof(U32(0))))
 133702 			var bStat1 int32 = libc.Bool32(Xsqlite3_stricmp(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, ts+11348) == 0)
 133703 			pUp = Xsqlite3_malloc(tls, nByte)
 133704 			if pUp == uintptr(0) {
 133705 				*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_NOMEM
 133706 			} else {
 133707 				var zSep uintptr = ts + 1554
 133708 
 133709 				libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(SessionBuffer{})))
 133710 				(*SessionUpdate)(unsafe.Pointer(pUp)).FaMask = pUp + 1*12
 133711 				libc.Xmemcpy(tls, (*SessionUpdate)(unsafe.Pointer(pUp)).FaMask, (*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask, uint32(nU32)*uint32(unsafe.Sizeof(U32(0))))
 133712 
 133713 				sessionAppendStr(tls, bp, ts+32960, bp+12)
 133714 				sessionAppendIdent(tls, bp, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, bp+12)
 133715 				sessionAppendStr(tls, bp, ts+32973, bp+12)
 133716 
 133717 				for ii = 0; ii < (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol; ii++ {
 133718 					if int32(*(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii)))) == 0 && *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+ii)*4)) != 0 {
 133719 						sessionAppendStr(tls, bp, zSep, bp+12)
 133720 						sessionAppendIdent(tls, bp, *(*uintptr)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(ii)*4)), bp+12)
 133721 						sessionAppendStr(tls, bp, ts+32979, bp+12)
 133722 						sessionAppendInteger(tls, bp, ii*2+1, bp+12)
 133723 						zSep = ts + 14614
 133724 					}
 133725 				}
 133726 
 133727 				zSep = ts + 1554
 133728 				sessionAppendStr(tls, bp, ts+32908, bp+12)
 133729 				for ii = 0; ii < (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol; ii++ {
 133730 					if *(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(ii))) != 0 || bPatchset == 0 && *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(ii)*4)) != 0 {
 133731 						sessionAppendStr(tls, bp, zSep, bp+12)
 133732 						if bStat1 != 0 && ii == 1 {
 133733 							sessionAppendStr(tls, bp,
 133734 								ts+32984, bp+12)
 133735 						} else {
 133736 							sessionAppendIdent(tls, bp, *(*uintptr)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(ii)*4)), bp+12)
 133737 							sessionAppendStr(tls, bp, ts+32916, bp+12)
 133738 							sessionAppendInteger(tls, bp, ii*2+2, bp+12)
 133739 						}
 133740 						zSep = ts + 21572
 133741 					}
 133742 				}
 133743 
 133744 				if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 133745 					var zSql uintptr = (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf
 133746 					*(*int32)(unsafe.Pointer(bp + 12)) = Xsqlite3_prepare_v2(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).Fdb, zSql, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf, pUp, uintptr(0))
 133747 				}
 133748 
 133749 				if *(*int32)(unsafe.Pointer(bp + 12)) != SQLITE_OK {
 133750 					Xsqlite3_free(tls, pUp)
 133751 					pUp = uintptr(0)
 133752 				} else {
 133753 					(*SessionUpdate)(unsafe.Pointer(pUp)).FpNext = (*SessionApplyCtx)(unsafe.Pointer(p)).FpUp
 133754 					(*SessionApplyCtx)(unsafe.Pointer(p)).FpUp = pUp
 133755 				}
 133756 				Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf)
 133757 			}
 133758 		}
 133759 	}
 133760 
 133761 	if pUp != 0 {
 133762 		*(*uintptr)(unsafe.Pointer(ppStmt)) = (*SessionUpdate)(unsafe.Pointer(pUp)).FpStmt
 133763 	} else {
 133764 		*(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0)
 133765 	}
 133766 	return *(*int32)(unsafe.Pointer(bp + 12))
 133767 }
 133768 
 133769 func sessionUpdateFree(tls *libc.TLS, p uintptr) {
 133770 	var pUp uintptr
 133771 	var pNext uintptr
 133772 	for pUp = (*SessionApplyCtx)(unsafe.Pointer(p)).FpUp; pUp != 0; pUp = pNext {
 133773 		pNext = (*SessionUpdate)(unsafe.Pointer(pUp)).FpNext
 133774 		Xsqlite3_finalize(tls, (*SessionUpdate)(unsafe.Pointer(pUp)).FpStmt)
 133775 		Xsqlite3_free(tls, pUp)
 133776 	}
 133777 	(*SessionApplyCtx)(unsafe.Pointer(p)).FpUp = uintptr(0)
 133778 	Xsqlite3_free(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask)
 133779 	(*SessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask = uintptr(0)
 133780 }
 133781 
 133782 func sessionDeleteRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) int32 {
 133783 	bp := tls.Alloc(16)
 133784 	defer tls.Free(16)
 133785 
 133786 	var i int32
 133787 	var zSep uintptr = ts + 1554
 133788 	*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 133789 	*(*SessionBuffer)(unsafe.Pointer(bp)) = SessionBuffer{}
 133790 	var nPk int32 = 0
 133791 
 133792 	sessionAppendStr(tls, bp, ts+33059, bp+12)
 133793 	sessionAppendIdent(tls, bp, zTab, bp+12)
 133794 	sessionAppendStr(tls, bp, ts+32908, bp+12)
 133795 
 133796 	for i = 0; i < (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol; i++ {
 133797 		if *(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 {
 133798 			nPk++
 133799 			sessionAppendStr(tls, bp, zSep, bp+12)
 133800 			sessionAppendIdent(tls, bp, *(*uintptr)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*4)), bp+12)
 133801 			sessionAppendStr(tls, bp, ts+32979, bp+12)
 133802 			sessionAppendInteger(tls, bp, i+1, bp+12)
 133803 			zSep = ts + 21572
 133804 		}
 133805 	}
 133806 
 133807 	if nPk < (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol {
 133808 		sessionAppendStr(tls, bp, ts+33077, bp+12)
 133809 		sessionAppendInteger(tls, bp, (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol+1, bp+12)
 133810 		sessionAppendStr(tls, bp, ts+32620, bp+12)
 133811 
 133812 		zSep = ts + 1554
 133813 		for i = 0; i < (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol; i++ {
 133814 			if !(int32(*(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i)))) != 0) {
 133815 				sessionAppendStr(tls, bp, zSep, bp+12)
 133816 				sessionAppendIdent(tls, bp, *(*uintptr)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*4)), bp+12)
 133817 				sessionAppendStr(tls, bp, ts+32916, bp+12)
 133818 				sessionAppendInteger(tls, bp, i+1, bp+12)
 133819 				zSep = ts + 33085
 133820 			}
 133821 		}
 133822 		sessionAppendStr(tls, bp, ts+4957, bp+12)
 133823 	}
 133824 
 133825 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 133826 		*(*int32)(unsafe.Pointer(bp + 12)) = Xsqlite3_prepare_v2(tls, db, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf, p+4, uintptr(0))
 133827 	}
 133828 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf)
 133829 
 133830 	return *(*int32)(unsafe.Pointer(bp + 12))
 133831 }
 133832 
 133833 func sessionSelectRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) int32 {
 133834 	return sessionSelectStmt(tls,
 133835 		db, ts+6441, zTab, (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol, (*SessionApplyCtx)(unsafe.Pointer(p)).FazCol, (*SessionApplyCtx)(unsafe.Pointer(p)).FabPK, p+12)
 133836 }
 133837 
 133838 func sessionInsertRow(tls *libc.TLS, db uintptr, zTab uintptr, p uintptr) int32 {
 133839 	bp := tls.Alloc(16)
 133840 	defer tls.Free(16)
 133841 
 133842 	*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 133843 	var i int32
 133844 	*(*SessionBuffer)(unsafe.Pointer(bp)) = SessionBuffer{}
 133845 
 133846 	sessionAppendStr(tls, bp, ts+33090, bp+12)
 133847 	sessionAppendIdent(tls, bp, zTab, bp+12)
 133848 	sessionAppendStr(tls, bp, ts+21578, bp+12)
 133849 	for i = 0; i < (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol; i++ {
 133850 		if i != 0 {
 133851 			sessionAppendStr(tls, bp, ts+14614, bp+12)
 133852 		}
 133853 		sessionAppendIdent(tls, bp, *(*uintptr)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FazCol + uintptr(i)*4)), bp+12)
 133854 	}
 133855 
 133856 	sessionAppendStr(tls, bp, ts+33108, bp+12)
 133857 	for i = 1; i < (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol; i++ {
 133858 		sessionAppendStr(tls, bp, ts+33119, bp+12)
 133859 	}
 133860 	sessionAppendStr(tls, bp, ts+4957, bp+12)
 133861 
 133862 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 133863 		*(*int32)(unsafe.Pointer(bp + 12)) = Xsqlite3_prepare_v2(tls, db, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf, p+8, uintptr(0))
 133864 	}
 133865 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf)
 133866 	return *(*int32)(unsafe.Pointer(bp + 12))
 133867 }
 133868 
 133869 func sessionPrepare(tls *libc.TLS, db uintptr, pp uintptr, zSql uintptr) int32 {
 133870 	return Xsqlite3_prepare_v2(tls, db, zSql, -1, pp, uintptr(0))
 133871 }
 133872 
 133873 func sessionStat1Sql(tls *libc.TLS, db uintptr, p uintptr) int32 {
 133874 	var rc int32 = sessionSelectRow(tls, db, ts+11348, p)
 133875 	if rc == SQLITE_OK {
 133876 		rc = sessionPrepare(tls, db, p+8,
 133877 			ts+33123)
 133878 	}
 133879 	if rc == SQLITE_OK {
 133880 		rc = sessionPrepare(tls, db, p+4,
 133881 			ts+33236)
 133882 	}
 133883 	return rc
 133884 }
 133885 
 133886 func sessionBindValue(tls *libc.TLS, pStmt uintptr, i int32, pVal uintptr) int32 {
 133887 	var eType int32 = Xsqlite3_value_type(tls, pVal)
 133888 
 133889 	if (eType == SQLITE_TEXT || eType == SQLITE_BLOB) && (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz == uintptr(0) {
 133890 		return SQLITE_NOMEM
 133891 	}
 133892 	return Xsqlite3_bind_value(tls, pStmt, i, pVal)
 133893 }
 133894 
 133895 func sessionBindRow(tls *libc.TLS, pIter uintptr, xValue uintptr, nCol int32, abPK uintptr, pStmt uintptr) int32 {
 133896 	bp := tls.Alloc(4)
 133897 	defer tls.Free(4)
 133898 
 133899 	var i int32
 133900 	var rc int32 = SQLITE_OK
 133901 
 133902 	for i = 0; rc == SQLITE_OK && i < nCol; i++ {
 133903 		if !(abPK != 0) || *(*U8)(unsafe.Pointer(abPK + uintptr(i))) != 0 {
 133904 			*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 133905 			(*struct {
 133906 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 133907 			})(unsafe.Pointer(&struct{ uintptr }{xValue})).f(tls, pIter, i, bp)
 133908 			if *(*uintptr)(unsafe.Pointer(bp)) == uintptr(0) {
 133909 				rc = Xsqlite3CorruptError(tls, 220310)
 133910 			} else {
 133911 				rc = sessionBindValue(tls, pStmt, i+1, *(*uintptr)(unsafe.Pointer(bp)))
 133912 			}
 133913 		}
 133914 	}
 133915 	return rc
 133916 }
 133917 
 133918 func sessionSeekToRow(tls *libc.TLS, pIter uintptr, abPK uintptr, pSelect uintptr) int32 {
 133919 	bp := tls.Alloc(12)
 133920 	defer tls.Free(12)
 133921 
 133922 	var rc int32
 133923 
 133924 	Xsqlite3changeset_op(tls, pIter, bp, bp+4, bp+8, uintptr(0))
 133925 	rc = sessionBindRow(tls, pIter,
 133926 		func() uintptr {
 133927 			if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_INSERT {
 133928 				return *(*uintptr)(unsafe.Pointer(&struct {
 133929 					f func(*libc.TLS, uintptr, int32, uintptr) int32
 133930 				}{Xsqlite3changeset_new}))
 133931 			}
 133932 			return *(*uintptr)(unsafe.Pointer(&struct {
 133933 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 133934 			}{Xsqlite3changeset_old}))
 133935 		}(),
 133936 		*(*int32)(unsafe.Pointer(bp + 4)), abPK, pSelect)
 133937 
 133938 	if rc == SQLITE_OK {
 133939 		rc = Xsqlite3_step(tls, pSelect)
 133940 		if rc != SQLITE_ROW {
 133941 			rc = Xsqlite3_reset(tls, pSelect)
 133942 		}
 133943 	}
 133944 
 133945 	return rc
 133946 }
 133947 
 133948 func sessionRebaseAdd(tls *libc.TLS, p uintptr, eType int32, pIter uintptr) int32 {
 133949 	bp := tls.Alloc(8)
 133950 	defer tls.Free(8)
 133951 
 133952 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 133953 	if (*SessionApplyCtx)(unsafe.Pointer(p)).FbRebase != 0 {
 133954 		var i int32
 133955 		var eOp int32 = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop
 133956 		if int32((*SessionApplyCtx)(unsafe.Pointer(p)).FbRebaseStarted) == 0 {
 133957 			var zTab uintptr = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab
 133958 			sessionAppendByte(tls, p+60, uint8('T'), bp)
 133959 			sessionAppendVarint(tls, p+60, (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol, bp)
 133960 			sessionAppendBlob(tls, p+60, (*SessionApplyCtx)(unsafe.Pointer(p)).FabPK, (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol, bp)
 133961 			sessionAppendBlob(tls, p+60, zTab, int32(libc.Xstrlen(tls, zTab))+1, bp)
 133962 			(*SessionApplyCtx)(unsafe.Pointer(p)).FbRebaseStarted = U8(1)
 133963 		}
 133964 
 133965 		sessionAppendByte(tls, p+60,
 133966 			func() uint8 {
 133967 				if eOp == SQLITE_DELETE {
 133968 					return uint8(SQLITE_DELETE)
 133969 				}
 133970 				return uint8(SQLITE_INSERT)
 133971 			}(), bp)
 133972 		sessionAppendByte(tls, p+60, uint8(libc.Bool32(eType == SQLITE_CHANGESET_REPLACE)), bp)
 133973 		for i = 0; i < (*SessionApplyCtx)(unsafe.Pointer(p)).FnCol; i++ {
 133974 			*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 133975 			if eOp == SQLITE_DELETE || eOp == SQLITE_UPDATE && *(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 {
 133976 				Xsqlite3changeset_old(tls, pIter, i, bp+4)
 133977 			} else {
 133978 				Xsqlite3changeset_new(tls, pIter, i, bp+4)
 133979 			}
 133980 			sessionAppendValue(tls, p+60, *(*uintptr)(unsafe.Pointer(bp + 4)), bp)
 133981 		}
 133982 	}
 133983 	return *(*int32)(unsafe.Pointer(bp))
 133984 }
 133985 
 133986 func sessionConflictHandler(tls *libc.TLS, eType int32, p uintptr, pIter uintptr, xConflict uintptr, pCtx uintptr, pbReplace uintptr) int32 {
 133987 	bp := tls.Alloc(16)
 133988 	defer tls.Free(16)
 133989 
 133990 	var res int32 = 0
 133991 
 133992 	Xsqlite3changeset_op(tls, pIter, bp, bp+4, bp+8, uintptr(0))
 133993 
 133994 	if pbReplace != 0 {
 133995 		*(*int32)(unsafe.Pointer(bp + 12)) = sessionSeekToRow(tls, pIter, (*SessionApplyCtx)(unsafe.Pointer(p)).FabPK, (*SessionApplyCtx)(unsafe.Pointer(p)).FpSelect)
 133996 	} else {
 133997 		*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 133998 	}
 133999 
 134000 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_ROW {
 134001 		(*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict = (*SessionApplyCtx)(unsafe.Pointer(p)).FpSelect
 134002 		res = (*struct {
 134003 			f func(*libc.TLS, uintptr, int32, uintptr) int32
 134004 		})(unsafe.Pointer(&struct{ uintptr }{xConflict})).f(tls, pCtx, eType, pIter)
 134005 		(*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict = uintptr(0)
 134006 		*(*int32)(unsafe.Pointer(bp + 12)) = Xsqlite3_reset(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpSelect)
 134007 	} else if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 134008 		if (*SessionApplyCtx)(unsafe.Pointer(p)).FbDeferConstraints != 0 && eType == SQLITE_CHANGESET_CONFLICT {
 134009 			var aBlob uintptr = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FaData + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent)
 134010 			var nBlob int32 = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiNext - (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent
 134011 			sessionAppendBlob(tls, p+48, aBlob, nBlob, bp+12)
 134012 			return SQLITE_OK
 134013 		} else {
 134014 			res = (*struct {
 134015 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 134016 			})(unsafe.Pointer(&struct{ uintptr }{xConflict})).f(tls, pCtx, eType+1, pIter)
 134017 			if res == SQLITE_CHANGESET_REPLACE {
 134018 				*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_MISUSE
 134019 			}
 134020 		}
 134021 	}
 134022 
 134023 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 134024 		switch res {
 134025 		case SQLITE_CHANGESET_REPLACE:
 134026 			*(*int32)(unsafe.Pointer(pbReplace)) = 1
 134027 			break
 134028 			fallthrough
 134029 
 134030 		case SQLITE_CHANGESET_OMIT:
 134031 			break
 134032 			fallthrough
 134033 
 134034 		case SQLITE_CHANGESET_ABORT:
 134035 			*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_ABORT
 134036 			break
 134037 			fallthrough
 134038 
 134039 		default:
 134040 			*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_MISUSE
 134041 			break
 134042 		}
 134043 		if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 134044 			*(*int32)(unsafe.Pointer(bp + 12)) = sessionRebaseAdd(tls, p, res, pIter)
 134045 		}
 134046 	}
 134047 
 134048 	return *(*int32)(unsafe.Pointer(bp + 12))
 134049 }
 134050 
 134051 func sessionApplyOneOp(tls *libc.TLS, pIter uintptr, p uintptr, xConflict uintptr, pCtx uintptr, pbReplace uintptr, pbRetry uintptr) int32 {
 134052 	bp := tls.Alloc(16)
 134053 	defer tls.Free(16)
 134054 
 134055 	var rc int32 = SQLITE_OK
 134056 
 134057 	Xsqlite3changeset_op(tls, pIter, bp, bp+4, bp+8, uintptr(0))
 134058 
 134059 	if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_DELETE {
 134060 		var abPK uintptr = func() uintptr {
 134061 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 {
 134062 				return (*SessionApplyCtx)(unsafe.Pointer(p)).FabPK
 134063 			}
 134064 			return uintptr(0)
 134065 		}()
 134066 		rc = sessionBindRow(tls, pIter, *(*uintptr)(unsafe.Pointer(&struct {
 134067 			f func(*libc.TLS, uintptr, int32, uintptr) int32
 134068 		}{Xsqlite3changeset_old})), *(*int32)(unsafe.Pointer(bp + 4)), abPK, (*SessionApplyCtx)(unsafe.Pointer(p)).FpDelete)
 134069 		if rc == SQLITE_OK && Xsqlite3_bind_parameter_count(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpDelete) > *(*int32)(unsafe.Pointer(bp + 4)) {
 134070 			rc = Xsqlite3_bind_int(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpDelete, *(*int32)(unsafe.Pointer(bp + 4))+1, libc.Bool32(pbRetry == uintptr(0) || abPK != 0))
 134071 		}
 134072 		if rc != SQLITE_OK {
 134073 			return rc
 134074 		}
 134075 
 134076 		Xsqlite3_step(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpDelete)
 134077 		rc = Xsqlite3_reset(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpDelete)
 134078 		if rc == SQLITE_OK && Xsqlite3_changes(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).Fdb) == 0 {
 134079 			rc = sessionConflictHandler(tls,
 134080 				SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry)
 134081 		} else if rc&0xff == SQLITE_CONSTRAINT {
 134082 			rc = sessionConflictHandler(tls,
 134083 				SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, uintptr(0))
 134084 		}
 134085 
 134086 	} else if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_UPDATE {
 134087 		var i int32
 134088 		*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 134089 		var bPatchset int32 = libc.Bool32(pbRetry == uintptr(0) || (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0)
 134090 
 134091 		rc = sessionUpdateFind(tls, pIter, p, bPatchset, bp+12)
 134092 
 134093 		for i = 0; rc == SQLITE_OK && i < *(*int32)(unsafe.Pointer(bp + 4)); i++ {
 134094 			var pOld uintptr = *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr(i)*4))
 134095 			var pNew uintptr = *(*uintptr)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue + uintptr((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol+i)*4))
 134096 			if *(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(p)).FabPK + uintptr(i))) != 0 || bPatchset == 0 && pOld != 0 {
 134097 				rc = sessionBindValue(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), i*2+2, pOld)
 134098 			}
 134099 			if rc == SQLITE_OK && pNew != 0 {
 134100 				rc = sessionBindValue(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), i*2+1, pNew)
 134101 			}
 134102 		}
 134103 		if rc != SQLITE_OK {
 134104 			return rc
 134105 		}
 134106 
 134107 		Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 134108 		rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 134109 
 134110 		if rc == SQLITE_OK && Xsqlite3_changes(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).Fdb) == 0 {
 134111 			rc = sessionConflictHandler(tls,
 134112 				SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry)
 134113 
 134114 		} else if rc&0xff == SQLITE_CONSTRAINT {
 134115 			rc = sessionConflictHandler(tls,
 134116 				SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, uintptr(0))
 134117 		}
 134118 
 134119 	} else {
 134120 		if (*SessionApplyCtx)(unsafe.Pointer(p)).FbStat1 != 0 {
 134121 			rc = sessionSeekToRow(tls, pIter, (*SessionApplyCtx)(unsafe.Pointer(p)).FabPK, (*SessionApplyCtx)(unsafe.Pointer(p)).FpSelect)
 134122 			if rc == SQLITE_ROW {
 134123 				rc = SQLITE_CONSTRAINT
 134124 				Xsqlite3_reset(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpSelect)
 134125 			}
 134126 		}
 134127 
 134128 		if rc == SQLITE_OK {
 134129 			rc = sessionBindRow(tls, pIter, *(*uintptr)(unsafe.Pointer(&struct {
 134130 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 134131 			}{Xsqlite3changeset_new})), *(*int32)(unsafe.Pointer(bp + 4)), uintptr(0), (*SessionApplyCtx)(unsafe.Pointer(p)).FpInsert)
 134132 			if rc != SQLITE_OK {
 134133 				return rc
 134134 			}
 134135 
 134136 			Xsqlite3_step(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpInsert)
 134137 			rc = Xsqlite3_reset(tls, (*SessionApplyCtx)(unsafe.Pointer(p)).FpInsert)
 134138 		}
 134139 
 134140 		if rc&0xff == SQLITE_CONSTRAINT {
 134141 			rc = sessionConflictHandler(tls,
 134142 				SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, pbReplace)
 134143 		}
 134144 	}
 134145 
 134146 	return rc
 134147 }
 134148 
 134149 func sessionApplyOneWithRetry(tls *libc.TLS, db uintptr, pIter uintptr, pApply uintptr, xConflict uintptr, pCtx uintptr) int32 {
 134150 	bp := tls.Alloc(8)
 134151 	defer tls.Free(8)
 134152 
 134153 	*(*int32)(unsafe.Pointer(bp)) = 0
 134154 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
 134155 	var rc int32
 134156 
 134157 	rc = sessionApplyOneOp(tls, pIter, pApply, xConflict, pCtx, bp, bp+4)
 134158 	if rc == SQLITE_OK {
 134159 		if *(*int32)(unsafe.Pointer(bp + 4)) != 0 {
 134160 			rc = sessionApplyOneOp(tls, pIter, pApply, xConflict, pCtx, uintptr(0), uintptr(0))
 134161 		} else if *(*int32)(unsafe.Pointer(bp)) != 0 {
 134162 			rc = Xsqlite3_exec(tls, db, ts+33380, uintptr(0), uintptr(0), uintptr(0))
 134163 			if rc == SQLITE_OK {
 134164 				rc = sessionBindRow(tls, pIter,
 134165 					*(*uintptr)(unsafe.Pointer(&struct {
 134166 						f func(*libc.TLS, uintptr, int32, uintptr) int32
 134167 					}{Xsqlite3changeset_new})), (*SessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete)
 134168 				Xsqlite3_bind_int(tls, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FnCol+1, 1)
 134169 			}
 134170 			if rc == SQLITE_OK {
 134171 				Xsqlite3_step(tls, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete)
 134172 				rc = Xsqlite3_reset(tls, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete)
 134173 			}
 134174 			if rc == SQLITE_OK {
 134175 				rc = sessionApplyOneOp(tls, pIter, pApply, xConflict, pCtx, uintptr(0), uintptr(0))
 134176 			}
 134177 			if rc == SQLITE_OK {
 134178 				rc = Xsqlite3_exec(tls, db, ts+33401, uintptr(0), uintptr(0), uintptr(0))
 134179 			}
 134180 		}
 134181 	}
 134182 
 134183 	return rc
 134184 }
 134185 
 134186 func sessionRetryConstraints(tls *libc.TLS, db uintptr, bPatchset int32, zTab uintptr, pApply uintptr, xConflict uintptr, pCtx uintptr) int32 {
 134187 	bp := tls.Alloc(8)
 134188 	defer tls.Free(8)
 134189 
 134190 	*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_OK
 134191 
 134192 	for (*SessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf != 0 {
 134193 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 134194 		var cons = (*SessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints
 134195 		libc.Xmemset(tls, pApply+48, 0, uint32(unsafe.Sizeof(SessionBuffer{})))
 134196 
 134197 		*(*int32)(unsafe.Pointer(bp + 4)) = sessionChangesetStart(tls,
 134198 			bp, uintptr(0), uintptr(0), cons.FnBuf, cons.FaBuf, (*SessionApplyCtx)(unsafe.Pointer(pApply)).FbInvertConstraints, 1)
 134199 		if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 134200 			var nByte Size_t = uint32(2*(*SessionApplyCtx)(unsafe.Pointer(pApply)).FnCol) * uint32(unsafe.Sizeof(uintptr(0)))
 134201 			var rc2 int32
 134202 			(*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FbPatchset = bPatchset
 134203 			(*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FzTab = zTab
 134204 			(*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnCol = (*SessionApplyCtx)(unsafe.Pointer(pApply)).FnCol
 134205 			(*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FabPK = (*SessionApplyCtx)(unsafe.Pointer(pApply)).FabPK
 134206 			sessionBufferGrow(tls, *(*uintptr)(unsafe.Pointer(bp))+44, int64(nByte), bp+4)
 134207 			(*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FapValue = (*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Ftblhdr.FaBuf
 134208 			if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 134209 				libc.Xmemset(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FapValue, 0, nByte)
 134210 			}
 134211 
 134212 			for *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK && SQLITE_ROW == Xsqlite3changeset_next(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 134213 				*(*int32)(unsafe.Pointer(bp + 4)) = sessionApplyOneWithRetry(tls, db, *(*uintptr)(unsafe.Pointer(bp)), pApply, xConflict, pCtx)
 134214 			}
 134215 
 134216 			rc2 = Xsqlite3changeset_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 134217 			if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 134218 				*(*int32)(unsafe.Pointer(bp + 4)) = rc2
 134219 			}
 134220 		}
 134221 
 134222 		Xsqlite3_free(tls, cons.FaBuf)
 134223 		if *(*int32)(unsafe.Pointer(bp + 4)) != SQLITE_OK {
 134224 			break
 134225 		}
 134226 		if (*SessionApplyCtx)(unsafe.Pointer(pApply)).Fconstraints.FnBuf >= cons.FnBuf {
 134227 			(*SessionApplyCtx)(unsafe.Pointer(pApply)).FbDeferConstraints = 0
 134228 		}
 134229 	}
 134230 
 134231 	return *(*int32)(unsafe.Pointer(bp + 4))
 134232 }
 134233 
 134234 func sessionChangesetApply(tls *libc.TLS, db uintptr, pIter uintptr, xFilter uintptr, xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) int32 {
 134235 	bp := tls.Alloc(252)
 134236 	defer tls.Free(252)
 134237 
 134238 	var schemaMismatch int32 = 0
 134239 	var rc int32 = SQLITE_OK
 134240 	*(*uintptr)(unsafe.Pointer(bp + 140)) = uintptr(0)
 134241 	var nTab int32 = 0
 134242 
 134243 	var bPatchset int32
 134244 
 134245 	(*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FbNoDiscard = 1
 134246 	libc.Xmemset(tls, bp+48, 0, uint32(unsafe.Sizeof(SessionApplyCtx{})))
 134247 	(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbRebase = U8(libc.Bool32(ppRebase != 0 && pnRebase != 0))
 134248 	(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbInvertConstraints = libc.BoolInt32(!!(flags&SQLITE_CHANGESETAPPLY_INVERT != 0))
 134249 	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, db))
 134250 	if flags&SQLITE_CHANGESETAPPLY_NOSAVEPOINT == 0 {
 134251 		rc = Xsqlite3_exec(tls, db, ts+33420, uintptr(0), uintptr(0), uintptr(0))
 134252 	}
 134253 	if rc == SQLITE_OK {
 134254 		rc = Xsqlite3_exec(tls, db, ts+33446, uintptr(0), uintptr(0), uintptr(0))
 134255 	}
 134256 	for rc == SQLITE_OK && SQLITE_ROW == Xsqlite3changeset_next(tls, pIter) {
 134257 		Xsqlite3changeset_op(tls, pIter, bp+124, bp+128, bp+132, uintptr(0))
 134258 
 134259 		if *(*uintptr)(unsafe.Pointer(bp + 140)) == uintptr(0) || Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(bp + 124)), *(*uintptr)(unsafe.Pointer(bp + 140)), nTab+1) != 0 {
 134260 			rc = sessionRetryConstraints(tls,
 134261 				db, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset, *(*uintptr)(unsafe.Pointer(bp + 140)), bp+48, xConflict, pCtx)
 134262 			if rc != SQLITE_OK {
 134263 				break
 134264 			}
 134265 
 134266 			sessionUpdateFree(tls, bp+48)
 134267 			Xsqlite3_free(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FazCol)
 134268 			Xsqlite3_finalize(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FpDelete)
 134269 			Xsqlite3_finalize(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FpInsert)
 134270 			Xsqlite3_finalize(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FpSelect)
 134271 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).Fdb = db
 134272 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FpDelete = uintptr(0)
 134273 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FpInsert = uintptr(0)
 134274 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FpSelect = uintptr(0)
 134275 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FnCol = 0
 134276 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FazCol = uintptr(0)
 134277 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FabPK = uintptr(0)
 134278 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbStat1 = 0
 134279 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbDeferConstraints = 1
 134280 			(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbRebaseStarted = U8(0)
 134281 			libc.Xmemset(tls, bp+48+48, 0, uint32(unsafe.Sizeof(SessionBuffer{})))
 134282 
 134283 			schemaMismatch = libc.Bool32(xFilter != 0 && 0 == (*struct {
 134284 				f func(*libc.TLS, uintptr, uintptr) int32
 134285 			})(unsafe.Pointer(&struct{ uintptr }{xFilter})).f(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 124))))
 134286 			if schemaMismatch != 0 {
 134287 				*(*uintptr)(unsafe.Pointer(bp + 140)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 124))))
 134288 				if *(*uintptr)(unsafe.Pointer(bp + 140)) == uintptr(0) {
 134289 					rc = SQLITE_NOMEM
 134290 					break
 134291 				}
 134292 				nTab = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 140))))
 134293 				(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FazCol = *(*uintptr)(unsafe.Pointer(bp + 140))
 134294 			} else {
 134295 				var nMinCol int32 = 0
 134296 				var i int32
 134297 
 134298 				Xsqlite3changeset_pk(tls, pIter, bp+136, uintptr(0))
 134299 				rc = sessionTableInfo(tls, uintptr(0),
 134300 					db, ts+6441, *(*uintptr)(unsafe.Pointer(bp + 124)), bp+48+16, bp+140, bp+48+20, bp+48+24)
 134301 				if rc != SQLITE_OK {
 134302 					break
 134303 				}
 134304 				for i = 0; i < (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FnCol; i++ {
 134305 					if *(*U8)(unsafe.Pointer((*SessionApplyCtx)(unsafe.Pointer(bp+48)).FabPK + uintptr(i))) != 0 {
 134306 						nMinCol = i + 1
 134307 					}
 134308 				}
 134309 
 134310 				if (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FnCol == 0 {
 134311 					schemaMismatch = 1
 134312 					Xsqlite3_log(tls, SQLITE_SCHEMA,
 134313 						ts+33476, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 140))))
 134314 				} else if (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FnCol < *(*int32)(unsafe.Pointer(bp + 128)) {
 134315 					schemaMismatch = 1
 134316 					Xsqlite3_log(tls, SQLITE_SCHEMA,
 134317 						ts+33520,
 134318 						libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(bp + 140)), (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FnCol, *(*int32)(unsafe.Pointer(bp + 128))))
 134319 				} else if *(*int32)(unsafe.Pointer(bp + 128)) < nMinCol || libc.Xmemcmp(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FabPK, *(*uintptr)(unsafe.Pointer(bp + 136)), uint32(*(*int32)(unsafe.Pointer(bp + 128)))) != 0 {
 134320 					schemaMismatch = 1
 134321 					Xsqlite3_log(tls, SQLITE_SCHEMA,
 134322 						ts+33591, libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 140))))
 134323 				} else {
 134324 					(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FnCol = *(*int32)(unsafe.Pointer(bp + 128))
 134325 					if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(bp + 140)), ts+11348) {
 134326 						if libc.AssignInt32(&rc, sessionStat1Sql(tls, db, bp+48)) != 0 {
 134327 							break
 134328 						}
 134329 						(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbStat1 = 1
 134330 					} else {
 134331 						if libc.AssignInt32(&rc, sessionSelectRow(tls, db, *(*uintptr)(unsafe.Pointer(bp + 140)), bp+48)) != 0 ||
 134332 							libc.AssignInt32(&rc, sessionDeleteRow(tls, db, *(*uintptr)(unsafe.Pointer(bp + 140)), bp+48)) != 0 ||
 134333 							libc.AssignInt32(&rc, sessionInsertRow(tls, db, *(*uintptr)(unsafe.Pointer(bp + 140)), bp+48)) != 0 {
 134334 							break
 134335 						}
 134336 						(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).FbStat1 = 0
 134337 					}
 134338 				}
 134339 				nTab = Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(bp + 140)))
 134340 			}
 134341 		}
 134342 
 134343 		if schemaMismatch != 0 {
 134344 			continue
 134345 		}
 134346 
 134347 		rc = sessionApplyOneWithRetry(tls, db, pIter, bp+48, xConflict, pCtx)
 134348 	}
 134349 
 134350 	bPatchset = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset
 134351 	if rc == SQLITE_OK {
 134352 		rc = Xsqlite3changeset_finalize(tls, pIter)
 134353 	} else {
 134354 		Xsqlite3changeset_finalize(tls, pIter)
 134355 	}
 134356 
 134357 	if rc == SQLITE_OK {
 134358 		rc = sessionRetryConstraints(tls, db, bPatchset, *(*uintptr)(unsafe.Pointer(bp + 140)), bp+48, xConflict, pCtx)
 134359 	}
 134360 
 134361 	if rc == SQLITE_OK {
 134362 		Xsqlite3_db_status(tls, db, SQLITE_DBSTATUS_DEFERRED_FKS, bp+144, bp+148, 0)
 134363 		if *(*int32)(unsafe.Pointer(bp + 144)) != 0 {
 134364 			var res int32 = SQLITE_CHANGESET_ABORT
 134365 
 134366 			libc.Xmemset(tls, bp+152, 0, uint32(unsafe.Sizeof(Sqlite3_changeset_iter{})))
 134367 			(*Sqlite3_changeset_iter)(unsafe.Pointer(bp + 152)).FnCol = *(*int32)(unsafe.Pointer(bp + 144))
 134368 			res = (*struct {
 134369 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 134370 			})(unsafe.Pointer(&struct{ uintptr }{xConflict})).f(tls, pCtx, SQLITE_CHANGESET_FOREIGN_KEY, bp+152)
 134371 			if res != SQLITE_CHANGESET_OMIT {
 134372 				rc = SQLITE_CONSTRAINT
 134373 			}
 134374 		}
 134375 	}
 134376 	Xsqlite3_exec(tls, db, ts+33651, uintptr(0), uintptr(0), uintptr(0))
 134377 
 134378 	if flags&SQLITE_CHANGESETAPPLY_NOSAVEPOINT == 0 {
 134379 		if rc == SQLITE_OK {
 134380 			rc = Xsqlite3_exec(tls, db, ts+33681, uintptr(0), uintptr(0), uintptr(0))
 134381 		} else {
 134382 			Xsqlite3_exec(tls, db, ts+33705, uintptr(0), uintptr(0), uintptr(0))
 134383 			Xsqlite3_exec(tls, db, ts+33681, uintptr(0), uintptr(0), uintptr(0))
 134384 		}
 134385 	}
 134386 
 134387 	if rc == SQLITE_OK && bPatchset == 0 && (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FbRebase != 0 {
 134388 		*(*uintptr)(unsafe.Pointer(ppRebase)) = (*SessionApplyCtx)(unsafe.Pointer(bp + 48)).Frebase.FaBuf
 134389 		*(*int32)(unsafe.Pointer(pnRebase)) = (*SessionApplyCtx)(unsafe.Pointer(bp + 48)).Frebase.FnBuf
 134390 		(*SessionApplyCtx)(unsafe.Pointer(bp + 48)).Frebase.FaBuf = uintptr(0)
 134391 	}
 134392 	sessionUpdateFree(tls, bp+48)
 134393 	Xsqlite3_finalize(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FpInsert)
 134394 	Xsqlite3_finalize(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FpDelete)
 134395 	Xsqlite3_finalize(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FpSelect)
 134396 	Xsqlite3_free(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).FazCol)
 134397 	Xsqlite3_free(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).Fconstraints.FaBuf)
 134398 	Xsqlite3_free(tls, (*SessionApplyCtx)(unsafe.Pointer(bp+48)).Frebase.FaBuf)
 134399 	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, db))
 134400 	return rc
 134401 }
 134402 
 134403 // Apply the changeset passed via pChangeset/nChangeset to the main
 134404 // database attached to handle "db".
 134405 func Xsqlite3changeset_apply_v2(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, xFilter uintptr, xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) int32 {
 134406 	bp := tls.Alloc(4)
 134407 	defer tls.Free(4)
 134408 
 134409 	var bInv int32 = libc.BoolInt32(!!(flags&SQLITE_CHANGESETAPPLY_INVERT != 0))
 134410 	var rc int32 = sessionChangesetStart(tls, bp, uintptr(0), uintptr(0), nChangeset, pChangeset, bInv, 1)
 134411 	if rc == SQLITE_OK {
 134412 		rc = sessionChangesetApply(tls,
 134413 			db, *(*uintptr)(unsafe.Pointer(bp)), xFilter, xConflict, pCtx, ppRebase, pnRebase, flags)
 134414 	}
 134415 	return rc
 134416 }
 134417 
 134418 // Apply the changeset passed via pChangeset/nChangeset to the main database
 134419 // attached to handle "db". Invoke the supplied conflict handler callback
 134420 // to resolve any conflicts encountered while applying the change.
 134421 func Xsqlite3changeset_apply(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, xFilter uintptr, xConflict uintptr, pCtx uintptr) int32 {
 134422 	return Xsqlite3changeset_apply_v2(tls,
 134423 		db, nChangeset, pChangeset, xFilter, xConflict, pCtx, uintptr(0), uintptr(0), 0)
 134424 }
 134425 
 134426 // Apply the changeset passed via xInput/pIn to the main database
 134427 // attached to handle "db". Invoke the supplied conflict handler callback
 134428 // to resolve any conflicts encountered while applying the change.
 134429 func Xsqlite3changeset_apply_v2_strm(tls *libc.TLS, db uintptr, xInput uintptr, pIn uintptr, xFilter uintptr, xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) int32 {
 134430 	bp := tls.Alloc(4)
 134431 	defer tls.Free(4)
 134432 
 134433 	var bInverse int32 = libc.BoolInt32(!!(flags&SQLITE_CHANGESETAPPLY_INVERT != 0))
 134434 	var rc int32 = sessionChangesetStart(tls, bp, xInput, pIn, 0, uintptr(0), bInverse, 1)
 134435 	if rc == SQLITE_OK {
 134436 		rc = sessionChangesetApply(tls,
 134437 			db, *(*uintptr)(unsafe.Pointer(bp)), xFilter, xConflict, pCtx, ppRebase, pnRebase, flags)
 134438 	}
 134439 	return rc
 134440 }
 134441 
 134442 func Xsqlite3changeset_apply_strm(tls *libc.TLS, db uintptr, xInput uintptr, pIn uintptr, xFilter uintptr, xConflict uintptr, pCtx uintptr) int32 {
 134443 	return Xsqlite3changeset_apply_v2_strm(tls,
 134444 		db, xInput, pIn, xFilter, xConflict, pCtx, uintptr(0), uintptr(0), 0)
 134445 }
 134446 
 134447 func sessionChangeMerge(tls *libc.TLS, pTab uintptr, bRebase int32, bPatchset int32, pExist uintptr, op2 int32, bIndirect int32, aRec uintptr, nRec int32, ppNew uintptr) int32 {
 134448 	bp := tls.Alloc(16)
 134449 	defer tls.Free(16)
 134450 
 134451 	var pNew uintptr = uintptr(0)
 134452 	var rc int32 = SQLITE_OK
 134453 
 134454 	if !(pExist != 0) {
 134455 		pNew = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(SessionChange{}))+uint32(nRec)))
 134456 		if !(pNew != 0) {
 134457 			return SQLITE_NOMEM
 134458 		}
 134459 		libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(SessionChange{})))
 134460 		(*SessionChange)(unsafe.Pointer(pNew)).Fop = U8(op2)
 134461 		(*SessionChange)(unsafe.Pointer(pNew)).FbIndirect = U8(bIndirect)
 134462 		(*SessionChange)(unsafe.Pointer(pNew)).FaRecord = pNew + 1*20
 134463 		if bIndirect == 0 || bRebase == 0 {
 134464 			(*SessionChange)(unsafe.Pointer(pNew)).FnRecord = nRec
 134465 			libc.Xmemcpy(tls, (*SessionChange)(unsafe.Pointer(pNew)).FaRecord, aRec, uint32(nRec))
 134466 		} else {
 134467 			var i int32
 134468 			var pIn uintptr = aRec
 134469 			var pOut uintptr = (*SessionChange)(unsafe.Pointer(pNew)).FaRecord
 134470 			for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 134471 				var nIn int32 = sessionSerialLen(tls, pIn)
 134472 				if int32(*(*U8)(unsafe.Pointer(pIn))) == 0 {
 134473 					*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8(0)
 134474 				} else if int32(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 {
 134475 					*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8(0xFF)
 134476 				} else {
 134477 					libc.Xmemcpy(tls, pOut, pIn, uint32(nIn))
 134478 					pOut += uintptr(nIn)
 134479 				}
 134480 				pIn += uintptr(nIn)
 134481 			}
 134482 			(*SessionChange)(unsafe.Pointer(pNew)).FnRecord = (int32(pOut) - int32((*SessionChange)(unsafe.Pointer(pNew)).FaRecord)) / 1
 134483 		}
 134484 	} else if bRebase != 0 {
 134485 		if int32((*SessionChange)(unsafe.Pointer(pExist)).Fop) == SQLITE_DELETE && (*SessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0 {
 134486 			*(*uintptr)(unsafe.Pointer(ppNew)) = pExist
 134487 		} else {
 134488 			var nByte Sqlite3_int64 = Sqlite3_int64(uint32(nRec+(*SessionChange)(unsafe.Pointer(pExist)).FnRecord) + uint32(unsafe.Sizeof(SessionChange{})))
 134489 			pNew = Xsqlite3_malloc64(tls, uint64(nByte))
 134490 			if pNew == uintptr(0) {
 134491 				rc = SQLITE_NOMEM
 134492 			} else {
 134493 				var i int32
 134494 				var a1 uintptr = (*SessionChange)(unsafe.Pointer(pExist)).FaRecord
 134495 				var a2 uintptr = aRec
 134496 				var pOut uintptr
 134497 
 134498 				libc.Xmemset(tls, pNew, 0, uint32(nByte))
 134499 				(*SessionChange)(unsafe.Pointer(pNew)).FbIndirect = U8(libc.Bool32(bIndirect != 0 || (*SessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0))
 134500 				(*SessionChange)(unsafe.Pointer(pNew)).Fop = U8(op2)
 134501 				pOut = libc.AssignPtrUintptr(pNew+12, pNew+1*20)
 134502 
 134503 				for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnCol; i++ {
 134504 					var n1 int32 = sessionSerialLen(tls, a1)
 134505 					var n2 int32 = sessionSerialLen(tls, a2)
 134506 					if int32(*(*U8)(unsafe.Pointer(a1))) == 0xFF || int32(*(*U8)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(i)))) == 0 && bIndirect != 0 {
 134507 						*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8(0xFF)
 134508 					} else if int32(*(*U8)(unsafe.Pointer(a2))) == 0 {
 134509 						libc.Xmemcpy(tls, pOut, a1, uint32(n1))
 134510 						pOut += uintptr(n1)
 134511 					} else {
 134512 						libc.Xmemcpy(tls, pOut, a2, uint32(n2))
 134513 						pOut += uintptr(n2)
 134514 					}
 134515 					a1 += uintptr(n1)
 134516 					a2 += uintptr(n2)
 134517 				}
 134518 				(*SessionChange)(unsafe.Pointer(pNew)).FnRecord = (int32(pOut) - int32((*SessionChange)(unsafe.Pointer(pNew)).FaRecord)) / 1
 134519 			}
 134520 			Xsqlite3_free(tls, pExist)
 134521 		}
 134522 	} else {
 134523 		var op1 int32 = int32((*SessionChange)(unsafe.Pointer(pExist)).Fop)
 134524 
 134525 		if op1 == SQLITE_INSERT && op2 == SQLITE_INSERT ||
 134526 			op1 == SQLITE_UPDATE && op2 == SQLITE_INSERT ||
 134527 			op1 == SQLITE_DELETE && op2 == SQLITE_UPDATE ||
 134528 			op1 == SQLITE_DELETE && op2 == SQLITE_DELETE {
 134529 			pNew = pExist
 134530 		} else if op1 == SQLITE_INSERT && op2 == SQLITE_DELETE {
 134531 			Xsqlite3_free(tls, pExist)
 134532 
 134533 		} else {
 134534 			var aExist uintptr = (*SessionChange)(unsafe.Pointer(pExist)).FaRecord
 134535 			var nByte Sqlite3_int64
 134536 
 134537 			nByte = Sqlite3_int64(uint32(unsafe.Sizeof(SessionChange{})) + uint32((*SessionChange)(unsafe.Pointer(pExist)).FnRecord) + uint32(nRec))
 134538 			pNew = Xsqlite3_malloc64(tls, uint64(nByte))
 134539 			if !(pNew != 0) {
 134540 				Xsqlite3_free(tls, pExist)
 134541 				return SQLITE_NOMEM
 134542 			}
 134543 			libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(SessionChange{})))
 134544 			(*SessionChange)(unsafe.Pointer(pNew)).FbIndirect = U8(libc.Bool32(bIndirect != 0 && (*SessionChange)(unsafe.Pointer(pExist)).FbIndirect != 0))
 134545 			*(*uintptr)(unsafe.Pointer(bp + 4)) = libc.AssignPtrUintptr(pNew+12, pNew+1*20)
 134546 
 134547 			if op1 == SQLITE_INSERT {
 134548 				*(*uintptr)(unsafe.Pointer(bp)) = aRec
 134549 
 134550 				(*SessionChange)(unsafe.Pointer(pNew)).Fop = U8(SQLITE_INSERT)
 134551 				if bPatchset == 0 {
 134552 					sessionSkipRecord(tls, bp, (*SessionTable)(unsafe.Pointer(pTab)).FnCol)
 134553 				}
 134554 				sessionMergeRecord(tls, bp+4, (*SessionTable)(unsafe.Pointer(pTab)).FnCol, aExist, *(*uintptr)(unsafe.Pointer(bp)))
 134555 			} else if op1 == SQLITE_DELETE {
 134556 				(*SessionChange)(unsafe.Pointer(pNew)).Fop = U8(SQLITE_UPDATE)
 134557 				if bPatchset != 0 {
 134558 					libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), aRec, uint32(nRec))
 134559 					*(*uintptr)(unsafe.Pointer(bp + 4)) += uintptr(nRec)
 134560 				} else {
 134561 					if 0 == sessionMergeUpdate(tls, bp+4, pTab, bPatchset, aExist, uintptr(0), aRec, uintptr(0)) {
 134562 						Xsqlite3_free(tls, pNew)
 134563 						pNew = uintptr(0)
 134564 					}
 134565 				}
 134566 			} else if op2 == SQLITE_UPDATE {
 134567 				*(*uintptr)(unsafe.Pointer(bp + 8)) = aExist
 134568 				*(*uintptr)(unsafe.Pointer(bp + 12)) = aRec
 134569 
 134570 				if bPatchset == 0 {
 134571 					sessionSkipRecord(tls, bp+8, (*SessionTable)(unsafe.Pointer(pTab)).FnCol)
 134572 					sessionSkipRecord(tls, bp+12, (*SessionTable)(unsafe.Pointer(pTab)).FnCol)
 134573 				}
 134574 				(*SessionChange)(unsafe.Pointer(pNew)).Fop = U8(SQLITE_UPDATE)
 134575 				if 0 == sessionMergeUpdate(tls, bp+4, pTab, bPatchset, aRec, aExist, *(*uintptr)(unsafe.Pointer(bp + 8)), *(*uintptr)(unsafe.Pointer(bp + 12))) {
 134576 					Xsqlite3_free(tls, pNew)
 134577 					pNew = uintptr(0)
 134578 				}
 134579 			} else {
 134580 				(*SessionChange)(unsafe.Pointer(pNew)).Fop = U8(SQLITE_DELETE)
 134581 				if bPatchset != 0 {
 134582 					libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), aRec, uint32(nRec))
 134583 					*(*uintptr)(unsafe.Pointer(bp + 4)) += uintptr(nRec)
 134584 				} else {
 134585 					sessionMergeRecord(tls, bp+4, (*SessionTable)(unsafe.Pointer(pTab)).FnCol, aRec, aExist)
 134586 				}
 134587 			}
 134588 
 134589 			if pNew != 0 {
 134590 				(*SessionChange)(unsafe.Pointer(pNew)).FnRecord = (int32(*(*uintptr)(unsafe.Pointer(bp + 4))) - int32((*SessionChange)(unsafe.Pointer(pNew)).FaRecord)) / 1
 134591 			}
 134592 			Xsqlite3_free(tls, pExist)
 134593 		}
 134594 	}
 134595 
 134596 	*(*uintptr)(unsafe.Pointer(ppNew)) = pNew
 134597 	return rc
 134598 }
 134599 
 134600 func sessionChangesetToHash(tls *libc.TLS, pIter uintptr, pGrp uintptr, bRebase int32) int32 {
 134601 	bp := tls.Alloc(32)
 134602 	defer tls.Free(32)
 134603 
 134604 	var rc int32 = SQLITE_OK
 134605 	var pTab uintptr = uintptr(0)
 134606 
 134607 	for SQLITE_ROW == sessionChangesetNext(tls, pIter, bp, bp+4, uintptr(0)) {
 134608 		var iHash int32
 134609 
 134610 		var pExist uintptr = uintptr(0)
 134611 		var pp uintptr
 134612 
 134613 		if (*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList == uintptr(0) {
 134614 			(*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset
 134615 		} else if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != (*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch {
 134616 			rc = SQLITE_ERROR
 134617 			break
 134618 		}
 134619 
 134620 		Xsqlite3changeset_op(tls, pIter, bp+8, bp+12, bp+16, bp+20)
 134621 		if !(pTab != 0) || Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(bp + 8)), (*SessionTable)(unsafe.Pointer(pTab)).FzName) != 0 {
 134622 			var nNew int32 = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 8))))
 134623 
 134624 			Xsqlite3changeset_pk(tls, pIter, bp+24, uintptr(0))
 134625 			for pTab = (*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList; pTab != 0; pTab = (*SessionTable)(unsafe.Pointer(pTab)).FpNext {
 134626 				if 0 == Xsqlite3_strnicmp(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName, *(*uintptr)(unsafe.Pointer(bp + 8)), nNew+1) {
 134627 					break
 134628 				}
 134629 			}
 134630 			if !(pTab != 0) {
 134631 				var ppTab uintptr
 134632 
 134633 				pTab = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(SessionTable{}))+uint32(*(*int32)(unsafe.Pointer(bp + 12)))+uint32(nNew)+uint32(1)))
 134634 				if !(pTab != 0) {
 134635 					rc = SQLITE_NOMEM
 134636 					break
 134637 				}
 134638 				libc.Xmemset(tls, pTab, 0, uint32(unsafe.Sizeof(SessionTable{})))
 134639 				(*SessionTable)(unsafe.Pointer(pTab)).FnCol = *(*int32)(unsafe.Pointer(bp + 12))
 134640 				(*SessionTable)(unsafe.Pointer(pTab)).FabPK = pTab + 1*36
 134641 				libc.Xmemcpy(tls, (*SessionTable)(unsafe.Pointer(pTab)).FabPK, *(*uintptr)(unsafe.Pointer(bp + 24)), uint32(*(*int32)(unsafe.Pointer(bp + 12))))
 134642 				(*SessionTable)(unsafe.Pointer(pTab)).FzName = (*SessionTable)(unsafe.Pointer(pTab)).FabPK + uintptr(*(*int32)(unsafe.Pointer(bp + 12)))
 134643 				libc.Xmemcpy(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName, *(*uintptr)(unsafe.Pointer(bp + 8)), uint32(nNew+1))
 134644 
 134645 				for ppTab = pGrp + 8; *(*uintptr)(unsafe.Pointer(ppTab)) != 0; ppTab = *(*uintptr)(unsafe.Pointer(ppTab)) {
 134646 				}
 134647 				*(*uintptr)(unsafe.Pointer(ppTab)) = pTab
 134648 			} else if (*SessionTable)(unsafe.Pointer(pTab)).FnCol != *(*int32)(unsafe.Pointer(bp + 12)) || libc.Xmemcmp(tls, (*SessionTable)(unsafe.Pointer(pTab)).FabPK, *(*uintptr)(unsafe.Pointer(bp + 24)), uint32(*(*int32)(unsafe.Pointer(bp + 12)))) != 0 {
 134649 				rc = SQLITE_SCHEMA
 134650 				break
 134651 			}
 134652 		}
 134653 
 134654 		if sessionGrowHash(tls, uintptr(0), (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset, pTab) != 0 {
 134655 			rc = SQLITE_NOMEM
 134656 			break
 134657 		}
 134658 		iHash = int32(sessionChangeHash(tls,
 134659 			pTab, libc.Bool32((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 && *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_DELETE), *(*uintptr)(unsafe.Pointer(bp)), (*SessionTable)(unsafe.Pointer(pTab)).FnChange))
 134660 
 134661 		for pp = (*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*4; *(*uintptr)(unsafe.Pointer(pp)) != 0; pp = *(*uintptr)(unsafe.Pointer(pp)) + 16 {
 134662 			var bPkOnly1 int32 = 0
 134663 			var bPkOnly2 int32 = 0
 134664 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 {
 134665 				bPkOnly1 = libc.Bool32(int32((*SessionChange)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).Fop) == SQLITE_DELETE)
 134666 				bPkOnly2 = libc.Bool32(*(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_DELETE)
 134667 			}
 134668 			if sessionChangeEqual(tls, pTab, bPkOnly1, (*SessionChange)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FaRecord, bPkOnly2, *(*uintptr)(unsafe.Pointer(bp))) != 0 {
 134669 				pExist = *(*uintptr)(unsafe.Pointer(pp))
 134670 				*(*uintptr)(unsafe.Pointer(pp)) = (*SessionChange)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext
 134671 				(*SessionTable)(unsafe.Pointer(pTab)).FnEntry--
 134672 				break
 134673 			}
 134674 		}
 134675 
 134676 		rc = sessionChangeMerge(tls, pTab, bRebase,
 134677 			(*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset, pExist, *(*int32)(unsafe.Pointer(bp + 16)), *(*int32)(unsafe.Pointer(bp + 20)), *(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), bp+28)
 134678 		if rc != 0 {
 134679 			break
 134680 		}
 134681 		if *(*uintptr)(unsafe.Pointer(bp + 28)) != 0 {
 134682 			(*SessionChange)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 28)))).FpNext = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*4))
 134683 			*(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*4)) = *(*uintptr)(unsafe.Pointer(bp + 28))
 134684 			(*SessionTable)(unsafe.Pointer(pTab)).FnEntry++
 134685 		}
 134686 	}
 134687 
 134688 	if rc == SQLITE_OK {
 134689 		rc = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Frc
 134690 	}
 134691 	return rc
 134692 }
 134693 
 134694 func sessionChangegroupOutput(tls *libc.TLS, pGrp uintptr, xOutput uintptr, pOut uintptr, pnOut uintptr, ppOut uintptr) int32 {
 134695 	bp := tls.Alloc(16)
 134696 	defer tls.Free(16)
 134697 
 134698 	*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 134699 	*(*SessionBuffer)(unsafe.Pointer(bp)) = SessionBuffer{}
 134700 	var pTab uintptr
 134701 
 134702 	for pTab = (*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList; *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK && pTab != 0; pTab = (*SessionTable)(unsafe.Pointer(pTab)).FpNext {
 134703 		var i int32
 134704 		if (*SessionTable)(unsafe.Pointer(pTab)).FnEntry == 0 {
 134705 			continue
 134706 		}
 134707 
 134708 		sessionAppendTableHdr(tls, bp, (*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch, pTab, bp+12)
 134709 		for i = 0; i < (*SessionTable)(unsafe.Pointer(pTab)).FnChange; i++ {
 134710 			var p uintptr
 134711 			for p = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(i)*4)); p != 0; p = (*SessionChange)(unsafe.Pointer(p)).FpNext {
 134712 				sessionAppendByte(tls, bp, (*SessionChange)(unsafe.Pointer(p)).Fop, bp+12)
 134713 				sessionAppendByte(tls, bp, (*SessionChange)(unsafe.Pointer(p)).FbIndirect, bp+12)
 134714 				sessionAppendBlob(tls, bp, (*SessionChange)(unsafe.Pointer(p)).FaRecord, (*SessionChange)(unsafe.Pointer(p)).FnRecord, bp+12)
 134715 				if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK && xOutput != 0 && (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf >= sessions_strm_chunk_size {
 134716 					*(*int32)(unsafe.Pointer(bp + 12)) = (*struct {
 134717 						f func(*libc.TLS, uintptr, uintptr, int32) int32
 134718 					})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf)
 134719 					(*SessionBuffer)(unsafe.Pointer(bp)).FnBuf = 0
 134720 				}
 134721 			}
 134722 		}
 134723 	}
 134724 
 134725 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 134726 		if xOutput != 0 {
 134727 			if (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf > 0 {
 134728 				*(*int32)(unsafe.Pointer(bp + 12)) = (*struct {
 134729 					f func(*libc.TLS, uintptr, uintptr, int32) int32
 134730 				})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf)
 134731 			}
 134732 		} else if ppOut != 0 {
 134733 			*(*uintptr)(unsafe.Pointer(ppOut)) = (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf
 134734 			if pnOut != 0 {
 134735 				*(*int32)(unsafe.Pointer(pnOut)) = (*SessionBuffer)(unsafe.Pointer(bp)).FnBuf
 134736 			}
 134737 			(*SessionBuffer)(unsafe.Pointer(bp)).FaBuf = uintptr(0)
 134738 		}
 134739 	}
 134740 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp)).FaBuf)
 134741 
 134742 	return *(*int32)(unsafe.Pointer(bp + 12))
 134743 }
 134744 
 134745 // Allocate a new, empty, sqlite3_changegroup.
 134746 func Xsqlite3changegroup_new(tls *libc.TLS, pp uintptr) int32 {
 134747 	var rc int32 = SQLITE_OK
 134748 	var p uintptr
 134749 	p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Sqlite3_changegroup{})))
 134750 	if p == uintptr(0) {
 134751 		rc = SQLITE_NOMEM
 134752 	} else {
 134753 		libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(Sqlite3_changegroup{})))
 134754 	}
 134755 	*(*uintptr)(unsafe.Pointer(pp)) = p
 134756 	return rc
 134757 }
 134758 
 134759 // Add the changeset currently stored in buffer pData, size nData bytes,
 134760 // to changeset-group p.
 134761 func Xsqlite3changegroup_add(tls *libc.TLS, pGrp uintptr, nData int32, pData uintptr) int32 {
 134762 	bp := tls.Alloc(4)
 134763 	defer tls.Free(4)
 134764 
 134765 	var rc int32
 134766 
 134767 	rc = Xsqlite3changeset_start(tls, bp, nData, pData)
 134768 	if rc == SQLITE_OK {
 134769 		rc = sessionChangesetToHash(tls, *(*uintptr)(unsafe.Pointer(bp)), pGrp, 0)
 134770 	}
 134771 	Xsqlite3changeset_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 134772 	return rc
 134773 }
 134774 
 134775 // Obtain a buffer containing a changeset representing the concatenation
 134776 // of all changesets added to the group so far.
 134777 func Xsqlite3changegroup_output(tls *libc.TLS, pGrp uintptr, pnData uintptr, ppData uintptr) int32 {
 134778 	return sessionChangegroupOutput(tls, pGrp, uintptr(0), uintptr(0), pnData, ppData)
 134779 }
 134780 
 134781 // Streaming versions of changegroup_add().
 134782 func Xsqlite3changegroup_add_strm(tls *libc.TLS, pGrp uintptr, xInput uintptr, pIn uintptr) int32 {
 134783 	bp := tls.Alloc(4)
 134784 	defer tls.Free(4)
 134785 
 134786 	var rc int32
 134787 
 134788 	rc = Xsqlite3changeset_start_strm(tls, bp, xInput, pIn)
 134789 	if rc == SQLITE_OK {
 134790 		rc = sessionChangesetToHash(tls, *(*uintptr)(unsafe.Pointer(bp)), pGrp, 0)
 134791 	}
 134792 	Xsqlite3changeset_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 134793 	return rc
 134794 }
 134795 
 134796 // Streaming versions of changegroup_output().
 134797 func Xsqlite3changegroup_output_strm(tls *libc.TLS, pGrp uintptr, xOutput uintptr, pOut uintptr) int32 {
 134798 	return sessionChangegroupOutput(tls, pGrp, xOutput, pOut, uintptr(0), uintptr(0))
 134799 }
 134800 
 134801 // Delete a changegroup object.
 134802 func Xsqlite3changegroup_delete(tls *libc.TLS, pGrp uintptr) {
 134803 	if pGrp != 0 {
 134804 		sessionDeleteTable(tls, uintptr(0), (*Sqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList)
 134805 		Xsqlite3_free(tls, pGrp)
 134806 	}
 134807 }
 134808 
 134809 // Combine two changesets together.
 134810 func Xsqlite3changeset_concat(tls *libc.TLS, nLeft int32, pLeft uintptr, nRight int32, pRight uintptr, pnOut uintptr, ppOut uintptr) int32 {
 134811 	bp := tls.Alloc(4)
 134812 	defer tls.Free(4)
 134813 
 134814 	var rc int32
 134815 
 134816 	rc = Xsqlite3changegroup_new(tls, bp)
 134817 	if rc == SQLITE_OK {
 134818 		rc = Xsqlite3changegroup_add(tls, *(*uintptr)(unsafe.Pointer(bp)), nLeft, pLeft)
 134819 	}
 134820 	if rc == SQLITE_OK {
 134821 		rc = Xsqlite3changegroup_add(tls, *(*uintptr)(unsafe.Pointer(bp)), nRight, pRight)
 134822 	}
 134823 	if rc == SQLITE_OK {
 134824 		rc = Xsqlite3changegroup_output(tls, *(*uintptr)(unsafe.Pointer(bp)), pnOut, ppOut)
 134825 	}
 134826 	Xsqlite3changegroup_delete(tls, *(*uintptr)(unsafe.Pointer(bp)))
 134827 
 134828 	return rc
 134829 }
 134830 
 134831 // Streaming version of sqlite3changeset_concat().
 134832 func Xsqlite3changeset_concat_strm(tls *libc.TLS, xInputA uintptr, pInA uintptr, xInputB uintptr, pInB uintptr, xOutput uintptr, pOut uintptr) int32 {
 134833 	bp := tls.Alloc(4)
 134834 	defer tls.Free(4)
 134835 
 134836 	var rc int32
 134837 
 134838 	rc = Xsqlite3changegroup_new(tls, bp)
 134839 	if rc == SQLITE_OK {
 134840 		rc = Xsqlite3changegroup_add_strm(tls, *(*uintptr)(unsafe.Pointer(bp)), xInputA, pInA)
 134841 	}
 134842 	if rc == SQLITE_OK {
 134843 		rc = Xsqlite3changegroup_add_strm(tls, *(*uintptr)(unsafe.Pointer(bp)), xInputB, pInB)
 134844 	}
 134845 	if rc == SQLITE_OK {
 134846 		rc = Xsqlite3changegroup_output_strm(tls, *(*uintptr)(unsafe.Pointer(bp)), xOutput, pOut)
 134847 	}
 134848 	Xsqlite3changegroup_delete(tls, *(*uintptr)(unsafe.Pointer(bp)))
 134849 
 134850 	return rc
 134851 }
 134852 
 134853 func sessionAppendRecordMerge(tls *libc.TLS, pBuf uintptr, nCol int32, a1 uintptr, n1 int32, a2 uintptr, n2 int32, pRc uintptr) {
 134854 	sessionBufferGrow(tls, pBuf, int64(n1+n2), pRc)
 134855 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 134856 		var i int32
 134857 		var pOut uintptr = (*SessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + uintptr((*SessionBuffer)(unsafe.Pointer(pBuf)).FnBuf)
 134858 		for i = 0; i < nCol; i++ {
 134859 			var nn1 int32 = sessionSerialLen(tls, a1)
 134860 			var nn2 int32 = sessionSerialLen(tls, a2)
 134861 			if int32(*(*U8)(unsafe.Pointer(a1))) == 0 || int32(*(*U8)(unsafe.Pointer(a1))) == 0xFF {
 134862 				libc.Xmemcpy(tls, pOut, a2, uint32(nn2))
 134863 				pOut += uintptr(nn2)
 134864 			} else {
 134865 				libc.Xmemcpy(tls, pOut, a1, uint32(nn1))
 134866 				pOut += uintptr(nn1)
 134867 			}
 134868 			a1 += uintptr(nn1)
 134869 			a2 += uintptr(nn2)
 134870 		}
 134871 
 134872 		(*SessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = (int32(pOut) - int32((*SessionBuffer)(unsafe.Pointer(pBuf)).FaBuf)) / 1
 134873 
 134874 	}
 134875 }
 134876 
 134877 func sessionAppendPartialUpdate(tls *libc.TLS, pBuf uintptr, pIter uintptr, aRec uintptr, nRec int32, aChange uintptr, nChange int32, pRc uintptr) {
 134878 	sessionBufferGrow(tls, pBuf, int64(2+nRec+nChange), pRc)
 134879 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 134880 		var bData int32 = 0
 134881 		var pOut uintptr = (*SessionBuffer)(unsafe.Pointer(pBuf)).FaBuf + uintptr((*SessionBuffer)(unsafe.Pointer(pBuf)).FnBuf)
 134882 		var i int32
 134883 		var a1 uintptr = aRec
 134884 		var a2 uintptr = aChange
 134885 
 134886 		*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8(SQLITE_UPDATE)
 134887 		*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect)
 134888 		for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol; i++ {
 134889 			var n1 int32 = sessionSerialLen(tls, a1)
 134890 			var n2 int32 = sessionSerialLen(tls, a2)
 134891 			if *(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0 || int32(*(*U8)(unsafe.Pointer(a2))) == 0 {
 134892 				if !(int32(*(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i)))) != 0) && *(*U8)(unsafe.Pointer(a1)) != 0 {
 134893 					bData = 1
 134894 				}
 134895 				libc.Xmemcpy(tls, pOut, a1, uint32(n1))
 134896 				pOut += uintptr(n1)
 134897 			} else if int32(*(*U8)(unsafe.Pointer(a2))) != 0xFF && *(*U8)(unsafe.Pointer(a1)) != 0 {
 134898 				bData = 1
 134899 				libc.Xmemcpy(tls, pOut, a2, uint32(n2))
 134900 				pOut += uintptr(n2)
 134901 			} else {
 134902 				*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8(0)
 134903 			}
 134904 			a1 += uintptr(n1)
 134905 			a2 += uintptr(n2)
 134906 		}
 134907 		if bData != 0 {
 134908 			a2 = aChange
 134909 			for i = 0; i < (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol; i++ {
 134910 				var n1 int32 = sessionSerialLen(tls, a1)
 134911 				var n2 int32 = sessionSerialLen(tls, a2)
 134912 				if *(*U8)(unsafe.Pointer((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK + uintptr(i))) != 0 || int32(*(*U8)(unsafe.Pointer(a2))) != 0xFF {
 134913 					libc.Xmemcpy(tls, pOut, a1, uint32(n1))
 134914 					pOut += uintptr(n1)
 134915 				} else {
 134916 					*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pOut, 1))) = U8(0)
 134917 				}
 134918 				a1 += uintptr(n1)
 134919 				a2 += uintptr(n2)
 134920 			}
 134921 			(*SessionBuffer)(unsafe.Pointer(pBuf)).FnBuf = (int32(pOut) - int32((*SessionBuffer)(unsafe.Pointer(pBuf)).FaBuf)) / 1
 134922 		}
 134923 	}
 134924 }
 134925 
 134926 func sessionRebase(tls *libc.TLS, p uintptr, pIter uintptr, xOutput uintptr, pOut uintptr, pnOut uintptr, ppOut uintptr) int32 {
 134927 	bp := tls.Alloc(32)
 134928 	defer tls.Free(32)
 134929 
 134930 	*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_OK
 134931 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 134932 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
 134933 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
 134934 	var pTab uintptr = uintptr(0)
 134935 	*(*SessionBuffer)(unsafe.Pointer(bp + 12)) = SessionBuffer{}
 134936 
 134937 	for SQLITE_ROW == sessionChangesetNext(tls, pIter, bp, bp+4, bp+8) {
 134938 		var pChange uintptr = uintptr(0)
 134939 		var bDone int32 = 0
 134940 
 134941 		if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
 134942 			var zTab uintptr = (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab
 134943 			for pTab = (*Sqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.FpList; pTab != 0; pTab = (*SessionTable)(unsafe.Pointer(pTab)).FpNext {
 134944 				if 0 == Xsqlite3_stricmp(tls, (*SessionTable)(unsafe.Pointer(pTab)).FzName, zTab) {
 134945 					break
 134946 				}
 134947 			}
 134948 			*(*int32)(unsafe.Pointer(bp + 8)) = 0
 134949 
 134950 			if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 {
 134951 				*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_ERROR
 134952 			}
 134953 
 134954 			sessionAppendByte(tls, bp+12, func() uint8 {
 134955 				if (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbPatchset != 0 {
 134956 					return uint8('P')
 134957 				}
 134958 				return uint8('T')
 134959 			}(), bp+24)
 134960 			sessionAppendVarint(tls, bp+12, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, bp+24)
 134961 			sessionAppendBlob(tls, bp+12, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol, bp+24)
 134962 			sessionAppendBlob(tls, bp+12, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab, int32(libc.Xstrlen(tls, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab))+1, bp+24)
 134963 		}
 134964 
 134965 		if pTab != 0 && *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 134966 			var iHash int32 = int32(sessionChangeHash(tls, pTab, 0, *(*uintptr)(unsafe.Pointer(bp)), (*SessionTable)(unsafe.Pointer(pTab)).FnChange))
 134967 
 134968 			for pChange = *(*uintptr)(unsafe.Pointer((*SessionTable)(unsafe.Pointer(pTab)).FapChange + uintptr(iHash)*4)); pChange != 0; pChange = (*SessionChange)(unsafe.Pointer(pChange)).FpNext {
 134969 				if sessionChangeEqual(tls, pTab, 0, *(*uintptr)(unsafe.Pointer(bp)), 0, (*SessionChange)(unsafe.Pointer(pChange)).FaRecord) != 0 {
 134970 					break
 134971 				}
 134972 			}
 134973 		}
 134974 
 134975 		if pChange != 0 {
 134976 			switch (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop {
 134977 			case SQLITE_INSERT:
 134978 				if int32((*SessionChange)(unsafe.Pointer(pChange)).Fop) == SQLITE_INSERT {
 134979 					bDone = 1
 134980 					if int32((*SessionChange)(unsafe.Pointer(pChange)).FbIndirect) == 0 {
 134981 						sessionAppendByte(tls, bp+12, uint8(SQLITE_UPDATE), bp+24)
 134982 						sessionAppendByte(tls, bp+12, uint8((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp+24)
 134983 						sessionAppendBlob(tls, bp+12, (*SessionChange)(unsafe.Pointer(pChange)).FaRecord, (*SessionChange)(unsafe.Pointer(pChange)).FnRecord, bp+24)
 134984 						sessionAppendBlob(tls, bp+12, *(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), bp+24)
 134985 					}
 134986 				}
 134987 				break
 134988 				fallthrough
 134989 
 134990 			case SQLITE_UPDATE:
 134991 				bDone = 1
 134992 				if int32((*SessionChange)(unsafe.Pointer(pChange)).Fop) == SQLITE_DELETE {
 134993 					if int32((*SessionChange)(unsafe.Pointer(pChange)).FbIndirect) == 0 {
 134994 						*(*uintptr)(unsafe.Pointer(bp + 28)) = *(*uintptr)(unsafe.Pointer(bp))
 134995 						sessionSkipRecord(tls, bp+28, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol)
 134996 						sessionAppendByte(tls, bp+12, uint8(SQLITE_INSERT), bp+24)
 134997 						sessionAppendByte(tls, bp+12, uint8((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp+24)
 134998 						sessionAppendRecordMerge(tls, bp+12, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol,
 134999 							*(*uintptr)(unsafe.Pointer(bp + 28)), *(*int32)(unsafe.Pointer(bp + 4))-(int32(*(*uintptr)(unsafe.Pointer(bp + 28)))-int32(*(*uintptr)(unsafe.Pointer(bp))))/1,
 135000 							(*SessionChange)(unsafe.Pointer(pChange)).FaRecord, (*SessionChange)(unsafe.Pointer(pChange)).FnRecord, bp+24)
 135001 					}
 135002 				} else {
 135003 					sessionAppendPartialUpdate(tls, bp+12, pIter,
 135004 						*(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), (*SessionChange)(unsafe.Pointer(pChange)).FaRecord, (*SessionChange)(unsafe.Pointer(pChange)).FnRecord, bp+24)
 135005 				}
 135006 				break
 135007 				fallthrough
 135008 
 135009 			default:
 135010 				bDone = 1
 135011 				if int32((*SessionChange)(unsafe.Pointer(pChange)).Fop) == SQLITE_INSERT {
 135012 					sessionAppendByte(tls, bp+12, uint8(SQLITE_DELETE), bp+24)
 135013 					sessionAppendByte(tls, bp+12, uint8((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp+24)
 135014 					sessionAppendRecordMerge(tls, bp+12, (*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol,
 135015 						(*SessionChange)(unsafe.Pointer(pChange)).FaRecord, (*SessionChange)(unsafe.Pointer(pChange)).FnRecord, *(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), bp+24)
 135016 				}
 135017 				break
 135018 			}
 135019 		}
 135020 
 135021 		if bDone == 0 {
 135022 			sessionAppendByte(tls, bp+12, uint8((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop), bp+24)
 135023 			sessionAppendByte(tls, bp+12, uint8((*Sqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect), bp+24)
 135024 			sessionAppendBlob(tls, bp+12, *(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), bp+24)
 135025 		}
 135026 		if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK && xOutput != 0 && (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf > sessions_strm_chunk_size {
 135027 			*(*int32)(unsafe.Pointer(bp + 24)) = (*struct {
 135028 				f func(*libc.TLS, uintptr, uintptr, int32) int32
 135029 			})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf)
 135030 			(*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf = 0
 135031 		}
 135032 		if *(*int32)(unsafe.Pointer(bp + 24)) != 0 {
 135033 			break
 135034 		}
 135035 	}
 135036 
 135037 	if *(*int32)(unsafe.Pointer(bp + 24)) != SQLITE_OK {
 135038 		Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf)
 135039 		libc.Xmemset(tls, bp+12, 0, uint32(unsafe.Sizeof(SessionBuffer{})))
 135040 	}
 135041 
 135042 	if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 135043 		if xOutput != 0 {
 135044 			if (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf > 0 {
 135045 				*(*int32)(unsafe.Pointer(bp + 24)) = (*struct {
 135046 					f func(*libc.TLS, uintptr, uintptr, int32) int32
 135047 				})(unsafe.Pointer(&struct{ uintptr }{xOutput})).f(tls, pOut, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf, (*SessionBuffer)(unsafe.Pointer(bp+12)).FnBuf)
 135048 			}
 135049 		} else if ppOut != 0 {
 135050 			*(*uintptr)(unsafe.Pointer(ppOut)) = (*SessionBuffer)(unsafe.Pointer(bp + 12)).FaBuf
 135051 			*(*int32)(unsafe.Pointer(pnOut)) = (*SessionBuffer)(unsafe.Pointer(bp + 12)).FnBuf
 135052 			(*SessionBuffer)(unsafe.Pointer(bp + 12)).FaBuf = uintptr(0)
 135053 		}
 135054 	}
 135055 	Xsqlite3_free(tls, (*SessionBuffer)(unsafe.Pointer(bp+12)).FaBuf)
 135056 	return *(*int32)(unsafe.Pointer(bp + 24))
 135057 }
 135058 
 135059 // Create a new rebaser object.
 135060 func Xsqlite3rebaser_create(tls *libc.TLS, ppNew uintptr) int32 {
 135061 	var rc int32 = SQLITE_OK
 135062 	var pNew uintptr
 135063 
 135064 	pNew = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Sqlite3_rebaser{})))
 135065 	if pNew == uintptr(0) {
 135066 		rc = SQLITE_NOMEM
 135067 	} else {
 135068 		libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Sqlite3_rebaser{})))
 135069 	}
 135070 	*(*uintptr)(unsafe.Pointer(ppNew)) = pNew
 135071 	return rc
 135072 }
 135073 
 135074 // Call this one or more times to configure a rebaser.
 135075 func Xsqlite3rebaser_configure(tls *libc.TLS, p uintptr, nRebase int32, pRebase uintptr) int32 {
 135076 	bp := tls.Alloc(4)
 135077 	defer tls.Free(4)
 135078 
 135079 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 135080 	var rc int32
 135081 	rc = Xsqlite3changeset_start(tls, bp, nRebase, pRebase)
 135082 	if rc == SQLITE_OK {
 135083 		rc = sessionChangesetToHash(tls, *(*uintptr)(unsafe.Pointer(bp)), p, 1)
 135084 	}
 135085 	Xsqlite3changeset_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 135086 	return rc
 135087 }
 135088 
 135089 // Rebase a changeset according to current rebaser configuration
 135090 func Xsqlite3rebaser_rebase(tls *libc.TLS, p uintptr, nIn int32, pIn uintptr, pnOut uintptr, ppOut uintptr) int32 {
 135091 	bp := tls.Alloc(4)
 135092 	defer tls.Free(4)
 135093 
 135094 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 135095 	var rc int32 = Xsqlite3changeset_start(tls, bp, nIn, pIn)
 135096 
 135097 	if rc == SQLITE_OK {
 135098 		rc = sessionRebase(tls, p, *(*uintptr)(unsafe.Pointer(bp)), uintptr(0), uintptr(0), pnOut, ppOut)
 135099 		Xsqlite3changeset_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 135100 	}
 135101 
 135102 	return rc
 135103 }
 135104 
 135105 // Rebase a changeset according to current rebaser configuration
 135106 func Xsqlite3rebaser_rebase_strm(tls *libc.TLS, p uintptr, xInput uintptr, pIn uintptr, xOutput uintptr, pOut uintptr) int32 {
 135107 	bp := tls.Alloc(4)
 135108 	defer tls.Free(4)
 135109 
 135110 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 135111 	var rc int32 = Xsqlite3changeset_start_strm(tls, bp, xInput, pIn)
 135112 
 135113 	if rc == SQLITE_OK {
 135114 		rc = sessionRebase(tls, p, *(*uintptr)(unsafe.Pointer(bp)), xOutput, pOut, uintptr(0), uintptr(0))
 135115 		Xsqlite3changeset_finalize(tls, *(*uintptr)(unsafe.Pointer(bp)))
 135116 	}
 135117 
 135118 	return rc
 135119 }
 135120 
 135121 // Destroy a rebaser object
 135122 func Xsqlite3rebaser_delete(tls *libc.TLS, p uintptr) {
 135123 	if p != 0 {
 135124 		sessionDeleteTable(tls, uintptr(0), (*Sqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.FpList)
 135125 		Xsqlite3_free(tls, p)
 135126 	}
 135127 }
 135128 
 135129 // Global configuration
 135130 func Xsqlite3session_config(tls *libc.TLS, op int32, pArg uintptr) int32 {
 135131 	var rc int32 = SQLITE_OK
 135132 	switch op {
 135133 	case SQLITE_SESSION_CONFIG_STRMSIZE:
 135134 		{
 135135 			var pInt uintptr = pArg
 135136 			if *(*int32)(unsafe.Pointer(pInt)) > 0 {
 135137 				sessions_strm_chunk_size = *(*int32)(unsafe.Pointer(pInt))
 135138 			}
 135139 			*(*int32)(unsafe.Pointer(pInt)) = sessions_strm_chunk_size
 135140 			break
 135141 
 135142 		}
 135143 	default:
 135144 		rc = SQLITE_MISUSE
 135145 		break
 135146 	}
 135147 	return rc
 135148 }
 135149 
 135150 type Fts5Global1 = struct {
 135151 	Fapi         Fts5_api
 135152 	Fdb          uintptr
 135153 	F__ccgo_pad1 [4]byte
 135154 	FiNextId     I64
 135155 	FpAux        uintptr
 135156 	FpTok        uintptr
 135157 	FpDfltTok    uintptr
 135158 	FpCsr        uintptr
 135159 }
 135160 
 135161 type Fts5Global = Fts5Global1
 135162 type Fts5Colset1 = struct {
 135163 	FnCol  int32
 135164 	FaiCol [1]int32
 135165 }
 135166 
 135167 type Fts5Colset = Fts5Colset1
 135168 
 135169 type Fts5Config1 = struct {
 135170 	Fdb               uintptr
 135171 	FzDb              uintptr
 135172 	FzName            uintptr
 135173 	FnCol             int32
 135174 	FazCol            uintptr
 135175 	FabUnindexed      uintptr
 135176 	FnPrefix          int32
 135177 	FaPrefix          uintptr
 135178 	FeContent         int32
 135179 	FzContent         uintptr
 135180 	FzContentRowid    uintptr
 135181 	FbColumnsize      int32
 135182 	FeDetail          int32
 135183 	FzContentExprlist uintptr
 135184 	FpTok             uintptr
 135185 	FpTokApi          uintptr
 135186 	FbLock            int32
 135187 	FePattern         int32
 135188 	FiCookie          int32
 135189 	Fpgsz             int32
 135190 	FnAutomerge       int32
 135191 	FnCrisisMerge     int32
 135192 	FnUsermerge       int32
 135193 	FnHashSize        int32
 135194 	FzRank            uintptr
 135195 	FzRankArgs        uintptr
 135196 	FpzErrmsg         uintptr
 135197 }
 135198 
 135199 type Fts5Config = Fts5Config1
 135200 
 135201 // Buffer object for the incremental building of string data.
 135202 type Fts5Buffer1 = struct {
 135203 	Fp      uintptr
 135204 	Fn      int32
 135205 	FnSpace int32
 135206 }
 135207 
 135208 // Buffer object for the incremental building of string data.
 135209 type Fts5Buffer = Fts5Buffer1
 135210 
 135211 type Fts5PoslistReader1 = struct {
 135212 	Fa           uintptr
 135213 	Fn           int32
 135214 	Fi           int32
 135215 	FbFlag       U8
 135216 	FbEof        U8
 135217 	F__ccgo_pad1 [2]byte
 135218 	FiPos        I64
 135219 }
 135220 
 135221 type Fts5PoslistReader = Fts5PoslistReader1
 135222 
 135223 type Fts5PoslistWriter1 = struct{ FiPrev I64 }
 135224 
 135225 type Fts5PoslistWriter = Fts5PoslistWriter1
 135226 
 135227 // Bucket of terms object used by the integrity-check in offsets=0 mode.
 135228 type Fts5Termset1 = struct{ FapHash [512]uintptr }
 135229 
 135230 // Bucket of terms object used by the integrity-check in offsets=0 mode.
 135231 type Fts5Termset = Fts5Termset1
 135232 
 135233 type Fts5Index1 = struct {
 135234 	FpConfig        uintptr
 135235 	FzDataTbl       uintptr
 135236 	FnWorkUnit      int32
 135237 	FpHash          uintptr
 135238 	FnPendingData   int32
 135239 	F__ccgo_pad1    [4]byte
 135240 	FiWriteRowid    I64
 135241 	FbDelete        int32
 135242 	Frc             int32
 135243 	FpReader        uintptr
 135244 	FpWriter        uintptr
 135245 	FpDeleter       uintptr
 135246 	FpIdxWriter     uintptr
 135247 	FpIdxDeleter    uintptr
 135248 	FpIdxSelect     uintptr
 135249 	FnRead          int32
 135250 	FpDataVersion   uintptr
 135251 	FiStructVersion I64
 135252 	FpStruct        uintptr
 135253 	F__ccgo_pad2    [4]byte
 135254 }
 135255 
 135256 type Fts5Index = Fts5Index1
 135257 type Fts5IndexIter1 = struct {
 135258 	FiRowid      I64
 135259 	FpData       uintptr
 135260 	FnData       int32
 135261 	FbEof        U8
 135262 	F__ccgo_pad1 [7]byte
 135263 }
 135264 
 135265 type Fts5IndexIter = Fts5IndexIter1
 135266 
 135267 // Virtual-table object.
 135268 type Fts5Table1 = struct {
 135269 	Fbase    Sqlite3_vtab
 135270 	FpConfig uintptr
 135271 	FpIndex  uintptr
 135272 }
 135273 
 135274 // Virtual-table object.
 135275 type Fts5Table = Fts5Table1
 135276 
 135277 // *************************************************************************
 135278 //
 135279 // Interface to code in fts5_hash.c.
 135280 type Fts5Hash1 = struct {
 135281 	FeDetail int32
 135282 	FpnByte  uintptr
 135283 	FnEntry  int32
 135284 	FnSlot   int32
 135285 	FpScan   uintptr
 135286 	FaSlot   uintptr
 135287 }
 135288 
 135289 // *************************************************************************
 135290 //
 135291 // Interface to code in fts5_hash.c.
 135292 type Fts5Hash = Fts5Hash1
 135293 
 135294 type Fts5Storage1 = struct {
 135295 	FpConfig      uintptr
 135296 	FpIndex       uintptr
 135297 	FbTotalsValid int32
 135298 	F__ccgo_pad1  [4]byte
 135299 	FnTotalRow    I64
 135300 	FaTotalSize   uintptr
 135301 	FaStmt        [11]uintptr
 135302 }
 135303 
 135304 type Fts5Storage = Fts5Storage1
 135305 
 135306 // *************************************************************************
 135307 //
 135308 // Interface to code in fts5_expr.c.
 135309 type Fts5Expr1 = struct {
 135310 	FpIndex       uintptr
 135311 	FpConfig      uintptr
 135312 	FpRoot        uintptr
 135313 	FbDesc        int32
 135314 	FnPhrase      int32
 135315 	FapExprPhrase uintptr
 135316 }
 135317 
 135318 // *************************************************************************
 135319 //
 135320 // Interface to code in fts5_expr.c.
 135321 type Fts5Expr = Fts5Expr1
 135322 type Fts5ExprNode1 = struct {
 135323 	FeType       int32
 135324 	FbEof        int32
 135325 	FbNomatch    int32
 135326 	FxNext       uintptr
 135327 	FiRowid      I64
 135328 	FpNear       uintptr
 135329 	FnChild      int32
 135330 	FapChild     [1]uintptr
 135331 	F__ccgo_pad1 [4]byte
 135332 }
 135333 
 135334 type Fts5ExprNode = Fts5ExprNode1
 135335 type Fts5Parse1 = struct {
 135336 	FpConfig      uintptr
 135337 	FzErr         uintptr
 135338 	Frc           int32
 135339 	FnPhrase      int32
 135340 	FapPhrase     uintptr
 135341 	FpExpr        uintptr
 135342 	FbPhraseToAnd int32
 135343 }
 135344 
 135345 type Fts5Parse = Fts5Parse1
 135346 type Fts5Token1 = struct {
 135347 	Fp uintptr
 135348 	Fn int32
 135349 }
 135350 
 135351 type Fts5Token = Fts5Token1
 135352 type Fts5ExprPhrase1 = struct {
 135353 	FpNode   uintptr
 135354 	Fposlist Fts5Buffer
 135355 	FnTerm   int32
 135356 	FaTerm   [1]Fts5ExprTerm
 135357 }
 135358 
 135359 type Fts5ExprPhrase = Fts5ExprPhrase1
 135360 type Fts5ExprNearset1 = struct {
 135361 	FnNear    int32
 135362 	FpColset  uintptr
 135363 	FnPhrase  int32
 135364 	FapPhrase [1]uintptr
 135365 }
 135366 
 135367 type Fts5ExprNearset = Fts5ExprNearset1
 135368 
 135369 type Fts5PoslistPopulator1 = struct {
 135370 	Fwriter Fts5PoslistWriter
 135371 	FbOk    int32
 135372 	FbMiss  int32
 135373 }
 135374 
 135375 type Fts5PoslistPopulator = Fts5PoslistPopulator1
 135376 
 135377 // The next sections is a series of control #defines.
 135378 // various aspects of the generated parser.
 135379 //
 135380 //	fts5YYCODETYPE         is the data type used to store the integer codes
 135381 //	                   that represent terminal and non-terminal symbols.
 135382 //	                   "unsigned char" is used if there are fewer than
 135383 //	                   256 symbols.  Larger types otherwise.
 135384 //	fts5YYNOCODE           is a number of type fts5YYCODETYPE that is not used for
 135385 //	                   any terminal or nonterminal symbol.
 135386 //	fts5YYFALLBACK         If defined, this indicates that one or more tokens
 135387 //	                   (also known as: "terminal symbols") have fall-back
 135388 //	                   values which should be used if the original symbol
 135389 //	                   would not parse.  This permits keywords to sometimes
 135390 //	                   be used as identifiers, for example.
 135391 //	fts5YYACTIONTYPE       is the data type used for "action codes" - numbers
 135392 //	                   that indicate what to do in response to the next
 135393 //	                   token.
 135394 //	sqlite3Fts5ParserFTS5TOKENTYPE     is the data type used for minor type for terminal
 135395 //	                   symbols.  Background: A "minor type" is a semantic
 135396 //	                   value associated with a terminal or non-terminal
 135397 //	                   symbols.  For example, for an "ID" terminal symbol,
 135398 //	                   the minor type might be the name of the identifier.
 135399 //	                   Each non-terminal can have a different minor type.
 135400 //	                   Terminal symbols all have the same minor type, though.
 135401 //	                   This macros defines the minor type for terminal
 135402 //	                   symbols.
 135403 //	fts5YYMINORTYPE        is the data type used for all minor types.
 135404 //	                   This is typically a union of many types, one of
 135405 //	                   which is sqlite3Fts5ParserFTS5TOKENTYPE.  The entry in the union
 135406 //	                   for terminal symbols is called "fts5yy0".
 135407 //	fts5YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
 135408 //	                   zero the stack is dynamically sized using realloc()
 135409 //	sqlite3Fts5ParserARG_SDECL     A static variable declaration for the %extra_argument
 135410 //	sqlite3Fts5ParserARG_PDECL     A parameter declaration for the %extra_argument
 135411 //	sqlite3Fts5ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter
 135412 //	sqlite3Fts5ParserARG_STORE     Code to store %extra_argument into fts5yypParser
 135413 //	sqlite3Fts5ParserARG_FETCH     Code to extract %extra_argument from fts5yypParser
 135414 //	sqlite3Fts5ParserCTX_*         As sqlite3Fts5ParserARG_ except for %extra_context
 135415 //	fts5YYERRORSYMBOL      is the code number of the error symbol.  If not
 135416 //	                   defined, then do no error processing.
 135417 //	fts5YYNSTATE           the combined number of states.
 135418 //	fts5YYNRULE            the number of rules in the grammar
 135419 //	fts5YYNFTS5TOKEN           Number of terminal symbols
 135420 //	fts5YY_MAX_SHIFT       Maximum value for shift actions
 135421 //	fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
 135422 //	fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
 135423 //	fts5YY_ERROR_ACTION    The fts5yy_action[] code for syntax error
 135424 //	fts5YY_ACCEPT_ACTION   The fts5yy_action[] code for accept
 135425 //	fts5YY_NO_ACTION       The fts5yy_action[] code for no-op
 135426 //	fts5YY_MIN_REDUCE      Minimum value for reduce actions
 135427 //	fts5YY_MAX_REDUCE      Maximum value for reduce actions
 135428 //
 135429 // ************ Begin control #defines ****************************************
 135430 type Fts5YYMINORTYPE = struct {
 135431 	Ffts5yyinit  int32
 135432 	F__ccgo_pad1 [4]byte
 135433 }
 135434 
 135435 var fts5yy_action = [105]uint8{
 135436 	uint8(81), uint8(20), uint8(96), uint8(6), uint8(28), uint8(99), uint8(98), uint8(26), uint8(26), uint8(18),
 135437 	uint8(96), uint8(6), uint8(28), uint8(17), uint8(98), uint8(56), uint8(26), uint8(19), uint8(96), uint8(6),
 135438 	uint8(28), uint8(14), uint8(98), uint8(14), uint8(26), uint8(31), uint8(92), uint8(96), uint8(6), uint8(28),
 135439 	uint8(108), uint8(98), uint8(25), uint8(26), uint8(21), uint8(96), uint8(6), uint8(28), uint8(78), uint8(98),
 135440 	uint8(58), uint8(26), uint8(29), uint8(96), uint8(6), uint8(28), uint8(107), uint8(98), uint8(22), uint8(26),
 135441 	uint8(24), uint8(16), uint8(12), uint8(11), uint8(1), uint8(13), uint8(13), uint8(24), uint8(16), uint8(23),
 135442 	uint8(11), uint8(33), uint8(34), uint8(13), uint8(97), uint8(8), uint8(27), uint8(32), uint8(98), uint8(7),
 135443 	uint8(26), uint8(3), uint8(4), uint8(5), uint8(3), uint8(4), uint8(5), uint8(3), uint8(83), uint8(4),
 135444 	uint8(5), uint8(3), uint8(63), uint8(5), uint8(3), uint8(62), uint8(12), uint8(2), uint8(86), uint8(13),
 135445 	uint8(9), uint8(30), uint8(10), uint8(10), uint8(54), uint8(57), uint8(75), uint8(78), uint8(78), uint8(53),
 135446 	uint8(57), uint8(15), uint8(82), uint8(82), uint8(71),
 135447 }
 135448 var fts5yy_lookahead = [121]uint8{
 135449 	uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(22), uint8(22), uint8(24), uint8(24), uint8(17),
 135450 	uint8(18), uint8(19), uint8(20), uint8(7), uint8(22), uint8(9), uint8(24), uint8(17), uint8(18), uint8(19),
 135451 	uint8(20), uint8(9), uint8(22), uint8(9), uint8(24), uint8(13), uint8(17), uint8(18), uint8(19), uint8(20),
 135452 	uint8(26), uint8(22), uint8(24), uint8(24), uint8(17), uint8(18), uint8(19), uint8(20), uint8(15), uint8(22),
 135453 	uint8(9), uint8(24), uint8(17), uint8(18), uint8(19), uint8(20), uint8(26), uint8(22), uint8(21), uint8(24),
 135454 	uint8(6), uint8(7), uint8(9), uint8(9), uint8(10), uint8(12), uint8(12), uint8(6), uint8(7), uint8(21),
 135455 	uint8(9), uint8(24), uint8(25), uint8(12), uint8(18), uint8(5), uint8(20), uint8(14), uint8(22), uint8(5),
 135456 	uint8(24), uint8(3), uint8(1), uint8(2), uint8(3), uint8(1), uint8(2), uint8(3), uint8(0), uint8(1),
 135457 	uint8(2), uint8(3), uint8(11), uint8(2), uint8(3), uint8(11), uint8(9), uint8(10), uint8(5), uint8(12),
 135458 	uint8(23), uint8(24), uint8(10), uint8(10), uint8(8), uint8(9), uint8(9), uint8(15), uint8(15), uint8(8),
 135459 	uint8(9), uint8(9), uint8(27), uint8(27), uint8(11), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 135460 	uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27),
 135461 	uint8(27),
 135462 }
 135463 var fts5yy_shift_ofst = [35]uint8{
 135464 	uint8(44), uint8(44), uint8(44), uint8(44), uint8(44), uint8(44), uint8(51), uint8(77), uint8(43), uint8(12),
 135465 	uint8(14), uint8(83), uint8(82), uint8(14), uint8(23), uint8(23), uint8(31), uint8(31), uint8(71), uint8(74),
 135466 	uint8(78), uint8(81), uint8(86), uint8(91), uint8(6), uint8(53), uint8(53), uint8(60), uint8(64), uint8(68),
 135467 	uint8(53), uint8(87), uint8(92), uint8(53), uint8(93),
 135468 }
 135469 var fts5yy_reduce_ofst = [18]int8{
 135470 	int8(-16), int8(-8), int8(0), int8(9), int8(17), int8(25), int8(46), int8(-17), int8(-17), int8(37),
 135471 	int8(67), int8(4), int8(4), int8(8), int8(4), int8(20), int8(27), int8(38),
 135472 }
 135473 var fts5yy_default = [35]uint8{
 135474 	uint8(80), uint8(80), uint8(80), uint8(80), uint8(80), uint8(80), uint8(95), uint8(80), uint8(80), uint8(105),
 135475 	uint8(80), uint8(110), uint8(110), uint8(80), uint8(110), uint8(110), uint8(80), uint8(80), uint8(80), uint8(80),
 135476 	uint8(80), uint8(91), uint8(80), uint8(80), uint8(80), uint8(101), uint8(100), uint8(80), uint8(80), uint8(90),
 135477 	uint8(103), uint8(80), uint8(80), uint8(104), uint8(80),
 135478 }
 135479 
 135480 type fts5yyStackEntry = struct {
 135481 	Fstateno     uint8
 135482 	Fmajor       uint8
 135483 	F__ccgo_pad1 [2]byte
 135484 	Fminor       Fts5YYMINORTYPE
 135485 }
 135486 
 135487 type Fts5yyStackEntry = fts5yyStackEntry
 135488 
 135489 type fts5yyParser = struct {
 135490 	Ffts5yytos      uintptr
 135491 	FpParse         uintptr
 135492 	Ffts5yystack    [100]Fts5yyStackEntry
 135493 	Ffts5yystackEnd uintptr
 135494 }
 135495 
 135496 type Fts5yyParser = fts5yyParser
 135497 
 135498 func sqlite3Fts5ParserInit(tls *libc.TLS, fts5yypRawParser uintptr) {
 135499 	var fts5yypParser uintptr = fts5yypRawParser
 135500 
 135501 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos = fts5yypParser + 8
 135502 	(*Fts5yyStackEntry)(unsafe.Pointer(fts5yypParser + 8)).Fstateno = uint8(0)
 135503 	(*Fts5yyStackEntry)(unsafe.Pointer(fts5yypParser + 8)).Fmajor = uint8(0)
 135504 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd = fts5yypParser + 8 + 99*12
 135505 }
 135506 
 135507 func sqlite3Fts5ParserAlloc(tls *libc.TLS, mallocProc uintptr) uintptr {
 135508 	var fts5yypParser uintptr
 135509 	fts5yypParser = (*struct{ f func(*libc.TLS, U64) uintptr })(unsafe.Pointer(&struct{ uintptr }{mallocProc})).f(tls, U64(unsafe.Sizeof(Fts5yyParser{})))
 135510 	if fts5yypParser != 0 {
 135511 		sqlite3Fts5ParserInit(tls, fts5yypParser)
 135512 	}
 135513 	return fts5yypParser
 135514 }
 135515 
 135516 func fts5yy_destructor(tls *libc.TLS, fts5yypParser uintptr, fts5yymajor uint8, fts5yypminor uintptr) {
 135517 	var pParse uintptr = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
 135518 	_ = pParse
 135519 
 135520 	switch int32(fts5yymajor) {
 135521 	case 16:
 135522 		{
 135523 			_ = pParse
 135524 		}
 135525 		break
 135526 	case 17:
 135527 		fallthrough
 135528 	case 18:
 135529 		fallthrough
 135530 	case 19:
 135531 		{
 135532 			sqlite3Fts5ParseNodeFree(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor)))
 135533 		}
 135534 		break
 135535 	case 20:
 135536 		fallthrough
 135537 	case 21:
 135538 		{
 135539 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor)))
 135540 		}
 135541 		break
 135542 	case 22:
 135543 		fallthrough
 135544 	case 23:
 135545 		{
 135546 			sqlite3Fts5ParseNearsetFree(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor)))
 135547 		}
 135548 		break
 135549 	case 24:
 135550 		{
 135551 			sqlite3Fts5ParsePhraseFree(tls, *(*uintptr)(unsafe.Pointer(fts5yypminor)))
 135552 		}
 135553 		break
 135554 
 135555 	default:
 135556 		break
 135557 	}
 135558 }
 135559 
 135560 func fts5yy_pop_parser_stack(tls *libc.TLS, pParser uintptr) {
 135561 	var fts5yytos uintptr
 135562 
 135563 	fts5yytos = libc.PostDecUintptr(&(*Fts5yyParser)(unsafe.Pointer(pParser)).Ffts5yytos, 12)
 135564 	fts5yy_destructor(tls, pParser, (*Fts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fmajor, fts5yytos+4)
 135565 }
 135566 
 135567 func sqlite3Fts5ParserFinalize(tls *libc.TLS, p uintptr) {
 135568 	var pParser uintptr = p
 135569 	for (*Fts5yyParser)(unsafe.Pointer(pParser)).Ffts5yytos > pParser+8 {
 135570 		fts5yy_pop_parser_stack(tls, pParser)
 135571 	}
 135572 }
 135573 
 135574 func sqlite3Fts5ParserFree(tls *libc.TLS, p uintptr, freeProc uintptr) {
 135575 	if p == uintptr(0) {
 135576 		return
 135577 	}
 135578 	sqlite3Fts5ParserFinalize(tls, p)
 135579 	(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{freeProc})).f(tls, p)
 135580 }
 135581 
 135582 func fts5yy_find_shift_action(tls *libc.TLS, iLookAhead uint8, stateno uint8) uint8 {
 135583 	var i int32
 135584 
 135585 	if int32(stateno) > Fts5YY_MAX_SHIFT {
 135586 		return stateno
 135587 	}
 135588 
 135589 	for __ccgo := true; __ccgo; __ccgo = 1 != 0 {
 135590 		i = int32(fts5yy_shift_ofst[stateno])
 135591 
 135592 		i = i + int32(iLookAhead)
 135593 
 135594 		if int32(fts5yy_lookahead[i]) != int32(iLookAhead) {
 135595 			return fts5yy_default[stateno]
 135596 		} else {
 135597 			return fts5yy_action[i]
 135598 		}
 135599 	}
 135600 	return uint8(0)
 135601 }
 135602 
 135603 func fts5yy_find_reduce_action(tls *libc.TLS, stateno uint8, iLookAhead uint8) uint8 {
 135604 	var i int32
 135605 
 135606 	i = int32(fts5yy_reduce_ofst[stateno])
 135607 
 135608 	i = i + int32(iLookAhead)
 135609 
 135610 	return fts5yy_action[i]
 135611 }
 135612 
 135613 func fts5yyStackOverflow(tls *libc.TLS, fts5yypParser uintptr) {
 135614 	var pParse uintptr = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
 135615 
 135616 	for (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos > fts5yypParser+8 {
 135617 		fts5yy_pop_parser_stack(tls, fts5yypParser)
 135618 	}
 135619 
 135620 	sqlite3Fts5ParseError(tls, pParse, ts+33733, 0)
 135621 
 135622 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse
 135623 
 135624 }
 135625 
 135626 func fts5yy_shift(tls *libc.TLS, fts5yypParser uintptr, fts5yyNewState uint8, fts5yyMajor uint8, fts5yyMinor Fts5Token) {
 135627 	var fts5yytos uintptr
 135628 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos += 12
 135629 	if (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos > (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd {
 135630 		(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos -= 12
 135631 		fts5yyStackOverflow(tls, fts5yypParser)
 135632 		return
 135633 	}
 135634 	if int32(fts5yyNewState) > Fts5YY_MAX_SHIFT {
 135635 		fts5yyNewState = uint8(int32(fts5yyNewState) + (Fts5YY_MIN_REDUCE - Fts5YY_MIN_SHIFTREDUCE))
 135636 	}
 135637 	fts5yytos = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos
 135638 	(*Fts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fstateno = fts5yyNewState
 135639 	(*Fts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fmajor = fts5yyMajor
 135640 	*(*Fts5Token)(unsafe.Pointer(fts5yytos + 4)) = fts5yyMinor
 135641 
 135642 }
 135643 
 135644 var fts5yyRuleInfoLhs = [28]uint8{
 135645 	uint8(16),
 135646 	uint8(20),
 135647 	uint8(20),
 135648 	uint8(20),
 135649 	uint8(20),
 135650 	uint8(21),
 135651 	uint8(21),
 135652 	uint8(17),
 135653 	uint8(17),
 135654 	uint8(17),
 135655 	uint8(17),
 135656 	uint8(17),
 135657 	uint8(17),
 135658 	uint8(19),
 135659 	uint8(19),
 135660 	uint8(18),
 135661 	uint8(18),
 135662 	uint8(22),
 135663 	uint8(22),
 135664 	uint8(22),
 135665 	uint8(23),
 135666 	uint8(23),
 135667 	uint8(25),
 135668 	uint8(25),
 135669 	uint8(24),
 135670 	uint8(24),
 135671 	uint8(26),
 135672 	uint8(26),
 135673 }
 135674 
 135675 var fts5yyRuleInfoNRhs = [28]int8{
 135676 	int8(-1),
 135677 	int8(-4),
 135678 	int8(-3),
 135679 	int8(-1),
 135680 	int8(-2),
 135681 	int8(-2),
 135682 	int8(-1),
 135683 	int8(-3),
 135684 	int8(-3),
 135685 	int8(-3),
 135686 	int8(-5),
 135687 	int8(-3),
 135688 	int8(-1),
 135689 	int8(-1),
 135690 	int8(-2),
 135691 	int8(-1),
 135692 	int8(-3),
 135693 	int8(-1),
 135694 	int8(-2),
 135695 	int8(-5),
 135696 	int8(-1),
 135697 	int8(-2),
 135698 	int8(0),
 135699 	int8(-2),
 135700 	int8(-4),
 135701 	int8(-2),
 135702 	int8(-1),
 135703 	int8(0),
 135704 }
 135705 
 135706 func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, fts5yyLookahead int32, fts5yyLookaheadToken Fts5Token) uint8 {
 135707 	bp := tls.Alloc(8)
 135708 	defer tls.Free(8)
 135709 
 135710 	var fts5yygoto int32
 135711 	var fts5yyact uint8
 135712 	var fts5yymsp uintptr
 135713 	var fts5yysize int32
 135714 	var pParse uintptr = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
 135715 	_ = fts5yyLookahead
 135716 	_ = fts5yyLookaheadToken
 135717 	fts5yymsp = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos
 135718 
 135719 	{
 135720 		switch fts5yyruleno {
 135721 		case uint32(0):
 135722 			{
 135723 				sqlite3Fts5ParseFinished(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135724 			}
 135725 			break
 135726 		case uint32(1):
 135727 			{
 135728 				*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = sqlite3Fts5ParseColsetInvert(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 135729 			}
 135730 			break
 135731 		case uint32(2):
 135732 			{
 135733 				*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 135734 			}
 135735 			break
 135736 		case uint32(3):
 135737 			{
 135738 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), fts5yymsp+4)
 135739 			}
 135740 			*(*uintptr)(unsafe.Pointer(fts5yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135741 			break
 135742 		case uint32(4):
 135743 			{
 135744 				*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), fts5yymsp+4)
 135745 				*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = sqlite3Fts5ParseColsetInvert(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)))
 135746 			}
 135747 			break
 135748 		case uint32(5):
 135749 			{
 135750 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)), fts5yymsp+4)
 135751 			}
 135752 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135753 			break
 135754 		case uint32(6):
 135755 			{
 135756 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), fts5yymsp+4)
 135757 			}
 135758 			*(*uintptr)(unsafe.Pointer(fts5yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135759 			break
 135760 		case uint32(7):
 135761 			{
 135762 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_AND, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)), uintptr(0))
 135763 			}
 135764 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135765 			break
 135766 		case uint32(8):
 135767 			{
 135768 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_OR, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)), uintptr(0))
 135769 			}
 135770 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135771 			break
 135772 		case uint32(9):
 135773 			{
 135774 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_NOT, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)), uintptr(0))
 135775 			}
 135776 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135777 			break
 135778 		case uint32(10):
 135779 			{
 135780 				sqlite3Fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-4)*12 + 4)))
 135781 				*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 135782 			}
 135783 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135784 			break
 135785 		case uint32(11):
 135786 			{
 135787 				*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4))
 135788 			}
 135789 			break
 135790 		case uint32(12):
 135791 			fallthrough
 135792 		case uint32(13):
 135793 			{
 135794 				*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + 4))
 135795 			}
 135796 			*(*uintptr)(unsafe.Pointer(fts5yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135797 			break
 135798 		case uint32(14):
 135799 			{
 135800 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseImplicitAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135801 			}
 135802 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135803 			break
 135804 		case uint32(15):
 135805 			{
 135806 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135807 			}
 135808 			*(*uintptr)(unsafe.Pointer(fts5yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135809 			break
 135810 		case uint32(16):
 135811 			{
 135812 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135813 				sqlite3Fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(bp)), *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)))
 135814 			}
 135815 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135816 			break
 135817 		case uint32(17):
 135818 			{
 135819 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135820 			}
 135821 			*(*uintptr)(unsafe.Pointer(fts5yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135822 			break
 135823 		case uint32(18):
 135824 			{
 135825 				sqlite3Fts5ParseSetCaret(tls, *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135826 				*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135827 			}
 135828 			break
 135829 		case uint32(19):
 135830 			{
 135831 				sqlite3Fts5ParseNear(tls, pParse, fts5yymsp+libc.UintptrFromInt32(-4)*12+4)
 135832 				sqlite3Fts5ParseSetDistance(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4)), fts5yymsp+libc.UintptrFromInt32(-1)*12+4)
 135833 				*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*12 + 4))
 135834 			}
 135835 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-4)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135836 			break
 135837 		case uint32(20):
 135838 			{
 135839 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135840 			}
 135841 			*(*uintptr)(unsafe.Pointer(fts5yymsp + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135842 			break
 135843 		case uint32(21):
 135844 			{
 135845 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseNearset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 4)))
 135846 			}
 135847 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135848 			break
 135849 		case uint32(22):
 135850 			{
 135851 				(*Fts5Token)(unsafe.Pointer(fts5yymsp + 1*12 + 4)).Fp = uintptr(0)
 135852 				(*Fts5Token)(unsafe.Pointer(fts5yymsp + 1*12 + 4)).Fn = 0
 135853 			}
 135854 			break
 135855 		case uint32(23):
 135856 			{
 135857 				*(*Fts5Token)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*Fts5Token)(unsafe.Pointer(fts5yymsp + 4))
 135858 			}
 135859 			break
 135860 		case uint32(24):
 135861 			{
 135862 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*12 + 4)), fts5yymsp+libc.UintptrFromInt32(-1)*12+4, *(*int32)(unsafe.Pointer(fts5yymsp + 4)))
 135863 			}
 135864 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135865 			break
 135866 		case uint32(25):
 135867 			{
 135868 				*(*uintptr)(unsafe.Pointer(bp)) = sqlite3Fts5ParseTerm(tls, pParse, uintptr(0), fts5yymsp+libc.UintptrFromInt32(-1)*12+4, *(*int32)(unsafe.Pointer(fts5yymsp + 4)))
 135869 			}
 135870 			*(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*12 + 4)) = *(*uintptr)(unsafe.Pointer(bp))
 135871 			break
 135872 		case uint32(26):
 135873 			{
 135874 				*(*int32)(unsafe.Pointer(fts5yymsp + 4)) = 1
 135875 			}
 135876 			break
 135877 		case uint32(27):
 135878 			{
 135879 				*(*int32)(unsafe.Pointer(fts5yymsp + 1*12 + 4)) = 0
 135880 			}
 135881 			break
 135882 		default:
 135883 			break
 135884 
 135885 		}
 135886 	}
 135887 
 135888 	fts5yygoto = int32(fts5yyRuleInfoLhs[fts5yyruleno])
 135889 	fts5yysize = int32(fts5yyRuleInfoNRhs[fts5yyruleno])
 135890 	fts5yyact = fts5yy_find_reduce_action(tls, (*Fts5yyStackEntry)(unsafe.Pointer(fts5yymsp+uintptr(fts5yysize)*12)).Fstateno, uint8(fts5yygoto))
 135891 
 135892 	fts5yymsp += 12 * uintptr(fts5yysize+1)
 135893 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos = fts5yymsp
 135894 	(*Fts5yyStackEntry)(unsafe.Pointer(fts5yymsp)).Fstateno = fts5yyact
 135895 	(*Fts5yyStackEntry)(unsafe.Pointer(fts5yymsp)).Fmajor = uint8(fts5yygoto)
 135896 
 135897 	return fts5yyact
 135898 }
 135899 
 135900 func fts5yy_syntax_error(tls *libc.TLS, fts5yypParser uintptr, fts5yymajor int32, fts5yyminor Fts5Token) {
 135901 	bp := tls.Alloc(16)
 135902 	defer tls.Free(16)
 135903 
 135904 	var pParse uintptr = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
 135905 
 135906 	_ = fts5yymajor
 135907 	sqlite3Fts5ParseError(tls,
 135908 		pParse, ts+33761, libc.VaList(bp, fts5yyminor.Fn, fts5yyminor.Fp))
 135909 
 135910 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse
 135911 
 135912 }
 135913 
 135914 func fts5yy_accept(tls *libc.TLS, fts5yypParser uintptr) {
 135915 	var pParse uintptr = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
 135916 
 135917 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse
 135918 
 135919 }
 135920 
 135921 func sqlite3Fts5Parser(tls *libc.TLS, fts5yyp uintptr, fts5yymajor int32, fts5yyminor Fts5Token, pParse uintptr) {
 135922 	bp := tls.Alloc(8)
 135923 	defer tls.Free(8)
 135924 
 135925 	var fts5yyact uint8
 135926 	var fts5yypParser uintptr = fts5yyp
 135927 
 135928 	(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse
 135929 
 135930 	fts5yyact = (*Fts5yyStackEntry)(unsafe.Pointer((*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos)).Fstateno
 135931 
 135932 	for 1 != 0 {
 135933 		fts5yyact = fts5yy_find_shift_action(tls, uint8(fts5yymajor), fts5yyact)
 135934 		if int32(fts5yyact) >= Fts5YY_MIN_REDUCE {
 135935 			var fts5yyruleno uint32 = uint32(int32(fts5yyact) - Fts5YY_MIN_REDUCE)
 135936 
 135937 			if int32(fts5yyRuleInfoNRhs[fts5yyruleno]) == 0 {
 135938 				if (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos >= (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd {
 135939 					fts5yyStackOverflow(tls, fts5yypParser)
 135940 					break
 135941 				}
 135942 			}
 135943 			fts5yyact = fts5yy_reduce(tls, fts5yypParser, fts5yyruleno, fts5yymajor, fts5yyminor)
 135944 		} else if int32(fts5yyact) <= Fts5YY_MAX_SHIFTREDUCE {
 135945 			fts5yy_shift(tls, fts5yypParser, fts5yyact, uint8(fts5yymajor), fts5yyminor)
 135946 			break
 135947 		} else if int32(fts5yyact) == Fts5YY_ACCEPT_ACTION {
 135948 			(*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos -= 12
 135949 			fts5yy_accept(tls, fts5yypParser)
 135950 			return
 135951 		} else {
 135952 			*(*Fts5Token)(unsafe.Pointer(bp)) = fts5yyminor
 135953 
 135954 			fts5yy_syntax_error(tls, fts5yypParser, fts5yymajor, fts5yyminor)
 135955 			fts5yy_destructor(tls, fts5yypParser, uint8(fts5yymajor), bp)
 135956 			break
 135957 		}
 135958 	}
 135959 	return
 135960 }
 135961 
 135962 func sqlite3Fts5ParserFallback(tls *libc.TLS, iToken int32) int32 {
 135963 	_ = iToken
 135964 	return 0
 135965 }
 135966 
 135967 // Object used to iterate through all "coalesced phrase instances" in
 135968 // a single column of the current row. If the phrase instances in the
 135969 // column being considered do not overlap, this object simply iterates
 135970 // through them. Or, if they do overlap (share one or more tokens in
 135971 // common), each set of overlapping instances is treated as a single
 135972 // match. See documentation for the highlight() auxiliary function for
 135973 // details.
 135974 //
 135975 // Usage is:
 135976 //
 135977 //	for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter);
 135978 //	   (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter);
 135979 //	   rc = fts5CInstIterNext(&iter)
 135980 //	){
 135981 //	  printf("instance starts at %d, ends at %d\n", iter.iStart, iter.iEnd);
 135982 //	}
 135983 type CInstIter1 = struct {
 135984 	FpApi   uintptr
 135985 	FpFts   uintptr
 135986 	FiCol   int32
 135987 	FiInst  int32
 135988 	FnInst  int32
 135989 	FiStart int32
 135990 	FiEnd   int32
 135991 }
 135992 
 135993 // Object used to iterate through all "coalesced phrase instances" in
 135994 // a single column of the current row. If the phrase instances in the
 135995 // column being considered do not overlap, this object simply iterates
 135996 // through them. Or, if they do overlap (share one or more tokens in
 135997 // common), each set of overlapping instances is treated as a single
 135998 // match. See documentation for the highlight() auxiliary function for
 135999 // details.
 136000 //
 136001 // Usage is:
 136002 //
 136003 //	for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter);
 136004 //	   (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter);
 136005 //	   rc = fts5CInstIterNext(&iter)
 136006 //	){
 136007 //	  printf("instance starts at %d, ends at %d\n", iter.iStart, iter.iEnd);
 136008 //	}
 136009 type CInstIter = CInstIter1
 136010 
 136011 func fts5CInstIterNext(tls *libc.TLS, pIter uintptr) int32 {
 136012 	bp := tls.Alloc(12)
 136013 	defer tls.Free(12)
 136014 
 136015 	var rc int32 = SQLITE_OK
 136016 	(*CInstIter)(unsafe.Pointer(pIter)).FiStart = -1
 136017 	(*CInstIter)(unsafe.Pointer(pIter)).FiEnd = -1
 136018 
 136019 	for rc == SQLITE_OK && (*CInstIter)(unsafe.Pointer(pIter)).FiInst < (*CInstIter)(unsafe.Pointer(pIter)).FnInst {
 136020 		rc = (*struct {
 136021 			f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32
 136022 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer((*CInstIter)(unsafe.Pointer(pIter)).FpApi)).FxInst})).f(tls, (*CInstIter)(unsafe.Pointer(pIter)).FpFts, (*CInstIter)(unsafe.Pointer(pIter)).FiInst, bp, bp+4, bp+8)
 136023 		if rc == SQLITE_OK {
 136024 			if *(*int32)(unsafe.Pointer(bp + 4)) == (*CInstIter)(unsafe.Pointer(pIter)).FiCol {
 136025 				var iEnd int32 = *(*int32)(unsafe.Pointer(bp + 8)) - 1 + (*struct {
 136026 					f func(*libc.TLS, uintptr, int32) int32
 136027 				})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer((*CInstIter)(unsafe.Pointer(pIter)).FpApi)).FxPhraseSize})).f(tls, (*CInstIter)(unsafe.Pointer(pIter)).FpFts, *(*int32)(unsafe.Pointer(bp)))
 136028 				if (*CInstIter)(unsafe.Pointer(pIter)).FiStart < 0 {
 136029 					(*CInstIter)(unsafe.Pointer(pIter)).FiStart = *(*int32)(unsafe.Pointer(bp + 8))
 136030 					(*CInstIter)(unsafe.Pointer(pIter)).FiEnd = iEnd
 136031 				} else if *(*int32)(unsafe.Pointer(bp + 8)) <= (*CInstIter)(unsafe.Pointer(pIter)).FiEnd {
 136032 					if iEnd > (*CInstIter)(unsafe.Pointer(pIter)).FiEnd {
 136033 						(*CInstIter)(unsafe.Pointer(pIter)).FiEnd = iEnd
 136034 					}
 136035 				} else {
 136036 					break
 136037 				}
 136038 			}
 136039 			(*CInstIter)(unsafe.Pointer(pIter)).FiInst++
 136040 		}
 136041 	}
 136042 
 136043 	return rc
 136044 }
 136045 
 136046 func fts5CInstIterInit(tls *libc.TLS, pApi uintptr, pFts uintptr, iCol int32, pIter uintptr) int32 {
 136047 	var rc int32
 136048 
 136049 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(CInstIter{})))
 136050 	(*CInstIter)(unsafe.Pointer(pIter)).FpApi = pApi
 136051 	(*CInstIter)(unsafe.Pointer(pIter)).FpFts = pFts
 136052 	(*CInstIter)(unsafe.Pointer(pIter)).FiCol = iCol
 136053 	rc = (*struct {
 136054 		f func(*libc.TLS, uintptr, uintptr) int32
 136055 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})).f(tls, pFts, pIter+16)
 136056 
 136057 	if rc == SQLITE_OK {
 136058 		rc = fts5CInstIterNext(tls, pIter)
 136059 	}
 136060 
 136061 	return rc
 136062 }
 136063 
 136064 // ************************************************************************
 136065 //
 136066 // Start of highlight() implementation.
 136067 type HighlightContext1 = struct {
 136068 	Fiter        CInstIter
 136069 	FiPos        int32
 136070 	FiRangeStart int32
 136071 	FiRangeEnd   int32
 136072 	FzOpen       uintptr
 136073 	FzClose      uintptr
 136074 	FzIn         uintptr
 136075 	FnIn         int32
 136076 	FiOff        int32
 136077 	FzOut        uintptr
 136078 }
 136079 
 136080 // ************************************************************************
 136081 //
 136082 // Start of highlight() implementation.
 136083 type HighlightContext = HighlightContext1
 136084 
 136085 func fts5HighlightAppend(tls *libc.TLS, pRc uintptr, p uintptr, z uintptr, n int32) {
 136086 	bp := tls.Alloc(24)
 136087 	defer tls.Free(24)
 136088 
 136089 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK && z != 0 {
 136090 		if n < 0 {
 136091 			n = int32(libc.Xstrlen(tls, z))
 136092 		}
 136093 		(*HighlightContext)(unsafe.Pointer(p)).FzOut = Xsqlite3_mprintf(tls, ts+33792, libc.VaList(bp, (*HighlightContext)(unsafe.Pointer(p)).FzOut, n, z))
 136094 		if (*HighlightContext)(unsafe.Pointer(p)).FzOut == uintptr(0) {
 136095 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 136096 		}
 136097 	}
 136098 }
 136099 
 136100 func fts5HighlightCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) int32 {
 136101 	bp := tls.Alloc(4)
 136102 	defer tls.Free(4)
 136103 
 136104 	var p uintptr = pContext
 136105 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 136106 	var iPos int32
 136107 
 136108 	_ = pToken
 136109 	_ = nToken
 136110 
 136111 	if tflags&FTS5_TOKEN_COLOCATED != 0 {
 136112 		return SQLITE_OK
 136113 	}
 136114 	iPos = libc.PostIncInt32(&(*HighlightContext)(unsafe.Pointer(p)).FiPos, 1)
 136115 
 136116 	if (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd > 0 {
 136117 		if iPos < (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart || iPos > (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd {
 136118 			return SQLITE_OK
 136119 		}
 136120 		if (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart != 0 && iPos == (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart {
 136121 			(*HighlightContext)(unsafe.Pointer(p)).FiOff = iStartOff
 136122 		}
 136123 	}
 136124 
 136125 	if iPos == (*HighlightContext)(unsafe.Pointer(p)).Fiter.FiStart {
 136126 		fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*HighlightContext)(unsafe.Pointer(p)).FiOff), iStartOff-(*HighlightContext)(unsafe.Pointer(p)).FiOff)
 136127 		fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzOpen, -1)
 136128 		(*HighlightContext)(unsafe.Pointer(p)).FiOff = iStartOff
 136129 	}
 136130 
 136131 	if iPos == (*HighlightContext)(unsafe.Pointer(p)).Fiter.FiEnd {
 136132 		if (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd != 0 && (*HighlightContext)(unsafe.Pointer(p)).Fiter.FiStart < (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart {
 136133 			fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzOpen, -1)
 136134 		}
 136135 		fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*HighlightContext)(unsafe.Pointer(p)).FiOff), iEndOff-(*HighlightContext)(unsafe.Pointer(p)).FiOff)
 136136 		fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzClose, -1)
 136137 		(*HighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff
 136138 		if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 136139 			*(*int32)(unsafe.Pointer(bp)) = fts5CInstIterNext(tls, p)
 136140 		}
 136141 	}
 136142 
 136143 	if (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd > 0 && iPos == (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd {
 136144 		fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzIn+uintptr((*HighlightContext)(unsafe.Pointer(p)).FiOff), iEndOff-(*HighlightContext)(unsafe.Pointer(p)).FiOff)
 136145 		(*HighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff
 136146 		if iPos >= (*HighlightContext)(unsafe.Pointer(p)).Fiter.FiStart && iPos < (*HighlightContext)(unsafe.Pointer(p)).Fiter.FiEnd {
 136147 			fts5HighlightAppend(tls, bp, p, (*HighlightContext)(unsafe.Pointer(p)).FzClose, -1)
 136148 		}
 136149 	}
 136150 
 136151 	return *(*int32)(unsafe.Pointer(bp))
 136152 }
 136153 
 136154 func fts5HighlightFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) {
 136155 	bp := tls.Alloc(68)
 136156 	defer tls.Free(68)
 136157 
 136158 	var iCol int32
 136159 
 136160 	if nVal != 3 {
 136161 		var zErr uintptr = ts + 33799
 136162 		Xsqlite3_result_error(tls, pCtx, zErr, -1)
 136163 		return
 136164 	}
 136165 
 136166 	iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal)))
 136167 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(HighlightContext{})))
 136168 	(*HighlightContext)(unsafe.Pointer(bp)).FzOpen = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 136169 	(*HighlightContext)(unsafe.Pointer(bp)).FzClose = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*4)))
 136170 	*(*int32)(unsafe.Pointer(bp + 64)) = (*struct {
 136171 		f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
 136172 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})).f(tls, pFts, iCol, bp+48, bp+52)
 136173 
 136174 	if (*HighlightContext)(unsafe.Pointer(bp)).FzIn != 0 {
 136175 		if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_OK {
 136176 			*(*int32)(unsafe.Pointer(bp + 64)) = fts5CInstIterInit(tls, pApi, pFts, iCol, bp)
 136177 		}
 136178 
 136179 		if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_OK {
 136180 			*(*int32)(unsafe.Pointer(bp + 64)) = (*struct {
 136181 				f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32
 136182 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize})).f(tls, pFts, (*HighlightContext)(unsafe.Pointer(bp)).FzIn, (*HighlightContext)(unsafe.Pointer(bp)).FnIn, bp, *(*uintptr)(unsafe.Pointer(&struct {
 136183 				f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 136184 			}{fts5HighlightCb})))
 136185 		}
 136186 		fts5HighlightAppend(tls, bp+64, bp, (*HighlightContext)(unsafe.Pointer(bp)).FzIn+uintptr((*HighlightContext)(unsafe.Pointer(bp)).FiOff), (*HighlightContext)(unsafe.Pointer(bp)).FnIn-(*HighlightContext)(unsafe.Pointer(bp)).FiOff)
 136187 
 136188 		if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_OK {
 136189 			Xsqlite3_result_text(tls, pCtx, (*HighlightContext)(unsafe.Pointer(bp)).FzOut, -1, libc.UintptrFromInt32(-1))
 136190 		}
 136191 		Xsqlite3_free(tls, (*HighlightContext)(unsafe.Pointer(bp)).FzOut)
 136192 	}
 136193 	if *(*int32)(unsafe.Pointer(bp + 64)) != SQLITE_OK {
 136194 		Xsqlite3_result_error_code(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 64)))
 136195 	}
 136196 }
 136197 
 136198 // Context object passed to the fts5SentenceFinderCb() function.
 136199 type Fts5SFinder1 = struct {
 136200 	FiPos        int32
 136201 	FnFirstAlloc int32
 136202 	FnFirst      int32
 136203 	FaFirst      uintptr
 136204 	FzDoc        uintptr
 136205 }
 136206 
 136207 // Context object passed to the fts5SentenceFinderCb() function.
 136208 type Fts5SFinder = Fts5SFinder1
 136209 
 136210 func fts5SentenceFinderAdd(tls *libc.TLS, p uintptr, iAdd int32) int32 {
 136211 	if (*Fts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc == (*Fts5SFinder)(unsafe.Pointer(p)).FnFirst {
 136212 		var nNew int32
 136213 		if (*Fts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc != 0 {
 136214 			nNew = (*Fts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc * 2
 136215 		} else {
 136216 			nNew = 64
 136217 		}
 136218 		var aNew uintptr
 136219 
 136220 		aNew = Xsqlite3_realloc64(tls, (*Fts5SFinder)(unsafe.Pointer(p)).FaFirst, uint64(uint32(nNew)*uint32(unsafe.Sizeof(int32(0)))))
 136221 		if aNew == uintptr(0) {
 136222 			return SQLITE_NOMEM
 136223 		}
 136224 		(*Fts5SFinder)(unsafe.Pointer(p)).FaFirst = aNew
 136225 		(*Fts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc = nNew
 136226 	}
 136227 	*(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(p)).FaFirst + uintptr(libc.PostIncInt32(&(*Fts5SFinder)(unsafe.Pointer(p)).FnFirst, 1))*4)) = iAdd
 136228 	return SQLITE_OK
 136229 }
 136230 
 136231 func fts5SentenceFinderCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) int32 {
 136232 	var rc int32 = SQLITE_OK
 136233 
 136234 	_ = pToken
 136235 	_ = nToken
 136236 	_ = iEndOff
 136237 
 136238 	if tflags&FTS5_TOKEN_COLOCATED == 0 {
 136239 		var p uintptr = pContext
 136240 		if (*Fts5SFinder)(unsafe.Pointer(p)).FiPos > 0 {
 136241 			var i int32
 136242 			var c uint8 = uint8(0)
 136243 			for i = iStartOff - 1; i >= 0; i-- {
 136244 				c = *(*uint8)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(p)).FzDoc + uintptr(i)))
 136245 				if int32(c) != ' ' && int32(c) != '\t' && int32(c) != '\n' && int32(c) != '\r' {
 136246 					break
 136247 				}
 136248 			}
 136249 			if i != iStartOff-1 && (int32(c) == '.' || int32(c) == ':') {
 136250 				rc = fts5SentenceFinderAdd(tls, p, (*Fts5SFinder)(unsafe.Pointer(p)).FiPos)
 136251 			}
 136252 		} else {
 136253 			rc = fts5SentenceFinderAdd(tls, p, 0)
 136254 		}
 136255 		(*Fts5SFinder)(unsafe.Pointer(p)).FiPos++
 136256 	}
 136257 	return rc
 136258 }
 136259 
 136260 func fts5SnippetScore(tls *libc.TLS, pApi uintptr, pFts uintptr, nDocsize int32, aSeen uintptr, iCol int32, iPos int32, nToken int32, pnScore uintptr, piPos uintptr) int32 {
 136261 	bp := tls.Alloc(16)
 136262 	defer tls.Free(16)
 136263 
 136264 	var rc int32
 136265 	var i int32
 136266 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
 136267 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
 136268 	*(*int32)(unsafe.Pointer(bp + 12)) = 0
 136269 	var iFirst int32 = -1
 136270 
 136271 	var nScore int32 = 0
 136272 	var iLast int32 = 0
 136273 	var iEnd Sqlite3_int64 = Sqlite3_int64(iPos) + Sqlite3_int64(nToken)
 136274 
 136275 	rc = (*struct {
 136276 		f func(*libc.TLS, uintptr, uintptr) int32
 136277 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})).f(tls, pFts, bp)
 136278 	for i = 0; i < *(*int32)(unsafe.Pointer(bp)) && rc == SQLITE_OK; i++ {
 136279 		rc = (*struct {
 136280 			f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32
 136281 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})).f(tls, pFts, i, bp+4, bp+8, bp+12)
 136282 		if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 8)) == iCol && *(*int32)(unsafe.Pointer(bp + 12)) >= iPos && Sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 12))) < iEnd {
 136283 			nScore = nScore + func() int32 {
 136284 				if *(*uint8)(unsafe.Pointer(aSeen + uintptr(*(*int32)(unsafe.Pointer(bp + 4))))) != 0 {
 136285 					return 1
 136286 				}
 136287 				return 1000
 136288 			}()
 136289 			*(*uint8)(unsafe.Pointer(aSeen + uintptr(*(*int32)(unsafe.Pointer(bp + 4))))) = uint8(1)
 136290 			if iFirst < 0 {
 136291 				iFirst = *(*int32)(unsafe.Pointer(bp + 12))
 136292 			}
 136293 			iLast = *(*int32)(unsafe.Pointer(bp + 12)) + (*struct {
 136294 				f func(*libc.TLS, uintptr, int32) int32
 136295 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseSize})).f(tls, pFts, *(*int32)(unsafe.Pointer(bp + 4)))
 136296 		}
 136297 	}
 136298 
 136299 	*(*int32)(unsafe.Pointer(pnScore)) = nScore
 136300 	if piPos != 0 {
 136301 		var iAdj Sqlite3_int64 = Sqlite3_int64(iFirst - (nToken-(iLast-iFirst))/2)
 136302 		if iAdj+Sqlite3_int64(nToken) > Sqlite3_int64(nDocsize) {
 136303 			iAdj = Sqlite3_int64(nDocsize - nToken)
 136304 		}
 136305 		if iAdj < int64(0) {
 136306 			iAdj = int64(0)
 136307 		}
 136308 		*(*int32)(unsafe.Pointer(piPos)) = int32(iAdj)
 136309 	}
 136310 
 136311 	return rc
 136312 }
 136313 
 136314 func fts5ValueToText(tls *libc.TLS, pVal uintptr) uintptr {
 136315 	var zRet uintptr = Xsqlite3_value_text(tls, pVal)
 136316 	if zRet != 0 {
 136317 		return zRet
 136318 	}
 136319 	return ts + 1554
 136320 }
 136321 
 136322 func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) {
 136323 	bp := tls.Alloc(124)
 136324 	defer tls.Free(124)
 136325 
 136326 	*(*int32)(unsafe.Pointer(bp + 120)) = SQLITE_OK
 136327 	var iCol int32
 136328 	var zEllips uintptr
 136329 	var nToken int32
 136330 	*(*int32)(unsafe.Pointer(bp + 64)) = 0
 136331 	var i int32
 136332 	var nPhrase int32
 136333 	var aSeen uintptr
 136334 	var iBestCol int32
 136335 	var iBestStart int32 = 0
 136336 	var nBestScore int32 = 0
 136337 	*(*int32)(unsafe.Pointer(bp + 116)) = 0
 136338 
 136339 	var nCol int32
 136340 
 136341 	if nVal != 5 {
 136342 		var zErr uintptr = ts + 33849
 136343 		Xsqlite3_result_error(tls, pCtx, zErr, -1)
 136344 		return
 136345 	}
 136346 
 136347 	nCol = (*struct {
 136348 		f func(*libc.TLS, uintptr) int32
 136349 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnCount})).f(tls, pFts)
 136350 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(HighlightContext{})))
 136351 	iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal)))
 136352 	(*HighlightContext)(unsafe.Pointer(bp)).FzOpen = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 136353 	(*HighlightContext)(unsafe.Pointer(bp)).FzClose = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*4)))
 136354 	zEllips = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 3*4)))
 136355 	nToken = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 4*4)))
 136356 
 136357 	iBestCol = func() int32 {
 136358 		if iCol >= 0 {
 136359 			return iCol
 136360 		}
 136361 		return 0
 136362 	}()
 136363 	nPhrase = (*struct {
 136364 		f func(*libc.TLS, uintptr) int32
 136365 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseCount})).f(tls, pFts)
 136366 	aSeen = Xsqlite3_malloc(tls, nPhrase)
 136367 	if aSeen == uintptr(0) {
 136368 		*(*int32)(unsafe.Pointer(bp + 120)) = SQLITE_NOMEM
 136369 	}
 136370 	if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK {
 136371 		*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136372 			f func(*libc.TLS, uintptr, uintptr) int32
 136373 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})).f(tls, pFts, bp+64)
 136374 	}
 136375 
 136376 	libc.Xmemset(tls, bp+68, 0, uint32(unsafe.Sizeof(Fts5SFinder{})))
 136377 	for i = 0; i < nCol; i++ {
 136378 		if iCol < 0 || iCol == i {
 136379 			var ii int32
 136380 			(*Fts5SFinder)(unsafe.Pointer(bp + 68)).FiPos = 0
 136381 			(*Fts5SFinder)(unsafe.Pointer(bp + 68)).FnFirst = 0
 136382 			*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136383 				f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
 136384 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})).f(tls, pFts, i, bp+68+16, bp+88)
 136385 			if *(*int32)(unsafe.Pointer(bp + 120)) != SQLITE_OK {
 136386 				break
 136387 			}
 136388 			*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136389 				f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32
 136390 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize})).f(tls, pFts,
 136391 				(*Fts5SFinder)(unsafe.Pointer(bp+68)).FzDoc, *(*int32)(unsafe.Pointer(bp + 88)), bp+68, *(*uintptr)(unsafe.Pointer(&struct {
 136392 					f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 136393 				}{fts5SentenceFinderCb})))
 136394 			if *(*int32)(unsafe.Pointer(bp + 120)) != SQLITE_OK {
 136395 				break
 136396 			}
 136397 			*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136398 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 136399 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})).f(tls, pFts, i, bp+92)
 136400 			if *(*int32)(unsafe.Pointer(bp + 120)) != SQLITE_OK {
 136401 				break
 136402 			}
 136403 
 136404 			for ii = 0; *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK && ii < *(*int32)(unsafe.Pointer(bp + 64)); ii++ {
 136405 				var jj int32
 136406 
 136407 				*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136408 					f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32
 136409 				})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})).f(tls, pFts, ii, bp+96, bp+100, bp+104)
 136410 				if *(*int32)(unsafe.Pointer(bp + 100)) != i {
 136411 					continue
 136412 				}
 136413 				if *(*int32)(unsafe.Pointer(bp + 104)) > *(*int32)(unsafe.Pointer(bp + 92)) {
 136414 					*(*int32)(unsafe.Pointer(bp + 120)) = SQLITE_CORRUPT | int32(1)<<8
 136415 				}
 136416 				if *(*int32)(unsafe.Pointer(bp + 120)) != SQLITE_OK {
 136417 					continue
 136418 				}
 136419 				libc.Xmemset(tls, aSeen, 0, uint32(nPhrase))
 136420 				*(*int32)(unsafe.Pointer(bp + 120)) = fts5SnippetScore(tls, pApi, pFts, *(*int32)(unsafe.Pointer(bp + 92)), aSeen, i,
 136421 					*(*int32)(unsafe.Pointer(bp + 104)), nToken, bp+108, bp+112)
 136422 				if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 108)) > nBestScore {
 136423 					nBestScore = *(*int32)(unsafe.Pointer(bp + 108))
 136424 					iBestCol = i
 136425 					iBestStart = *(*int32)(unsafe.Pointer(bp + 112))
 136426 					*(*int32)(unsafe.Pointer(bp + 116)) = *(*int32)(unsafe.Pointer(bp + 92))
 136427 				}
 136428 
 136429 				if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK && (*Fts5SFinder)(unsafe.Pointer(bp+68)).FnFirst != 0 && *(*int32)(unsafe.Pointer(bp + 92)) > nToken {
 136430 					for jj = 0; jj < (*Fts5SFinder)(unsafe.Pointer(bp+68)).FnFirst-1; jj++ {
 136431 						if *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+68)).FaFirst + uintptr(jj+1)*4)) > *(*int32)(unsafe.Pointer(bp + 104)) {
 136432 							break
 136433 						}
 136434 					}
 136435 
 136436 					if *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+68)).FaFirst + uintptr(jj)*4)) < *(*int32)(unsafe.Pointer(bp + 104)) {
 136437 						libc.Xmemset(tls, aSeen, 0, uint32(nPhrase))
 136438 						*(*int32)(unsafe.Pointer(bp + 120)) = fts5SnippetScore(tls, pApi, pFts, *(*int32)(unsafe.Pointer(bp + 92)), aSeen, i,
 136439 							*(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+68)).FaFirst + uintptr(jj)*4)), nToken, bp+108, uintptr(0))
 136440 
 136441 						*(*int32)(unsafe.Pointer(bp + 108)) += func() int32 {
 136442 							if *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+68)).FaFirst + uintptr(jj)*4)) == 0 {
 136443 								return 120
 136444 							}
 136445 							return 100
 136446 						}()
 136447 						if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 108)) > nBestScore {
 136448 							nBestScore = *(*int32)(unsafe.Pointer(bp + 108))
 136449 							iBestCol = i
 136450 							iBestStart = *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+68)).FaFirst + uintptr(jj)*4))
 136451 							*(*int32)(unsafe.Pointer(bp + 116)) = *(*int32)(unsafe.Pointer(bp + 92))
 136452 						}
 136453 					}
 136454 				}
 136455 			}
 136456 		}
 136457 	}
 136458 
 136459 	if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK {
 136460 		*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136461 			f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
 136462 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnText})).f(tls, pFts, iBestCol, bp+48, bp+52)
 136463 	}
 136464 	if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK && *(*int32)(unsafe.Pointer(bp + 116)) == 0 {
 136465 		*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136466 			f func(*libc.TLS, uintptr, int32, uintptr) int32
 136467 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})).f(tls, pFts, iBestCol, bp+116)
 136468 	}
 136469 	if (*HighlightContext)(unsafe.Pointer(bp)).FzIn != 0 {
 136470 		if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK {
 136471 			*(*int32)(unsafe.Pointer(bp + 120)) = fts5CInstIterInit(tls, pApi, pFts, iBestCol, bp)
 136472 		}
 136473 
 136474 		(*HighlightContext)(unsafe.Pointer(bp)).FiRangeStart = iBestStart
 136475 		(*HighlightContext)(unsafe.Pointer(bp)).FiRangeEnd = iBestStart + nToken - 1
 136476 
 136477 		if iBestStart > 0 {
 136478 			fts5HighlightAppend(tls, bp+120, bp, zEllips, -1)
 136479 		}
 136480 
 136481 		for (*HighlightContext)(unsafe.Pointer(bp)).Fiter.FiStart >= 0 && (*HighlightContext)(unsafe.Pointer(bp)).Fiter.FiStart < iBestStart && *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK {
 136482 			*(*int32)(unsafe.Pointer(bp + 120)) = fts5CInstIterNext(tls, bp)
 136483 		}
 136484 
 136485 		if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK {
 136486 			*(*int32)(unsafe.Pointer(bp + 120)) = (*struct {
 136487 				f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32
 136488 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxTokenize})).f(tls, pFts, (*HighlightContext)(unsafe.Pointer(bp)).FzIn, (*HighlightContext)(unsafe.Pointer(bp)).FnIn, bp, *(*uintptr)(unsafe.Pointer(&struct {
 136489 				f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 136490 			}{fts5HighlightCb})))
 136491 		}
 136492 		if (*HighlightContext)(unsafe.Pointer(bp)).FiRangeEnd >= *(*int32)(unsafe.Pointer(bp + 116))-1 {
 136493 			fts5HighlightAppend(tls, bp+120, bp, (*HighlightContext)(unsafe.Pointer(bp)).FzIn+uintptr((*HighlightContext)(unsafe.Pointer(bp)).FiOff), (*HighlightContext)(unsafe.Pointer(bp)).FnIn-(*HighlightContext)(unsafe.Pointer(bp)).FiOff)
 136494 		} else {
 136495 			fts5HighlightAppend(tls, bp+120, bp, zEllips, -1)
 136496 		}
 136497 	}
 136498 	if *(*int32)(unsafe.Pointer(bp + 120)) == SQLITE_OK {
 136499 		Xsqlite3_result_text(tls, pCtx, (*HighlightContext)(unsafe.Pointer(bp)).FzOut, -1, libc.UintptrFromInt32(-1))
 136500 	} else {
 136501 		Xsqlite3_result_error_code(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 120)))
 136502 	}
 136503 	Xsqlite3_free(tls, (*HighlightContext)(unsafe.Pointer(bp)).FzOut)
 136504 	Xsqlite3_free(tls, aSeen)
 136505 	Xsqlite3_free(tls, (*Fts5SFinder)(unsafe.Pointer(bp+68)).FaFirst)
 136506 }
 136507 
 136508 // The first time the bm25() function is called for a query, an instance
 136509 // of the following structure is allocated and populated.
 136510 type Fts5Bm25Data1 = struct {
 136511 	FnPhrase     int32
 136512 	F__ccgo_pad1 [4]byte
 136513 	Favgdl       float64
 136514 	FaIDF        uintptr
 136515 	FaFreq       uintptr
 136516 }
 136517 
 136518 // The first time the bm25() function is called for a query, an instance
 136519 // of the following structure is allocated and populated.
 136520 type Fts5Bm25Data = Fts5Bm25Data1
 136521 
 136522 func fts5CountCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pUserData uintptr) int32 {
 136523 	var pn uintptr = pUserData
 136524 	_ = pApi
 136525 	_ = pFts
 136526 	*(*Sqlite3_int64)(unsafe.Pointer(pn))++
 136527 	return SQLITE_OK
 136528 }
 136529 
 136530 func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) int32 {
 136531 	bp := tls.Alloc(24)
 136532 	defer tls.Free(24)
 136533 
 136534 	var rc int32 = SQLITE_OK
 136535 	var p uintptr
 136536 
 136537 	p = (*struct {
 136538 		f func(*libc.TLS, uintptr, int32) uintptr
 136539 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxGetAuxdata})).f(tls, pFts, 0)
 136540 	if p == uintptr(0) {
 136541 		var nPhrase int32
 136542 		*(*Sqlite3_int64)(unsafe.Pointer(bp)) = int64(0)
 136543 		*(*Sqlite3_int64)(unsafe.Pointer(bp + 8)) = int64(0)
 136544 		var nByte Sqlite3_int64
 136545 		var i int32
 136546 
 136547 		nPhrase = (*struct {
 136548 			f func(*libc.TLS, uintptr) int32
 136549 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseCount})).f(tls, pFts)
 136550 		nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Bm25Data{})) + uint32(nPhrase*2)*uint32(unsafe.Sizeof(float64(0))))
 136551 		p = Xsqlite3_malloc64(tls, uint64(nByte))
 136552 		if p == uintptr(0) {
 136553 			rc = SQLITE_NOMEM
 136554 		} else {
 136555 			libc.Xmemset(tls, p, 0, Size_t(nByte))
 136556 			(*Fts5Bm25Data)(unsafe.Pointer(p)).FnPhrase = nPhrase
 136557 			(*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF = p + 1*24
 136558 			(*Fts5Bm25Data)(unsafe.Pointer(p)).FaFreq = (*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(nPhrase)*8
 136559 		}
 136560 
 136561 		if rc == SQLITE_OK {
 136562 			rc = (*struct {
 136563 				f func(*libc.TLS, uintptr, uintptr) int32
 136564 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxRowCount})).f(tls, pFts, bp)
 136565 		}
 136566 
 136567 		if rc == SQLITE_OK {
 136568 			rc = (*struct {
 136569 				f func(*libc.TLS, uintptr, int32, uintptr) int32
 136570 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnTotalSize})).f(tls, pFts, -1, bp+8)
 136571 		}
 136572 		if rc == SQLITE_OK {
 136573 			(*Fts5Bm25Data)(unsafe.Pointer(p)).Favgdl = float64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8))) / float64(*(*Sqlite3_int64)(unsafe.Pointer(bp)))
 136574 		}
 136575 
 136576 		for i = 0; rc == SQLITE_OK && i < nPhrase; i++ {
 136577 			*(*Sqlite3_int64)(unsafe.Pointer(bp + 16)) = int64(0)
 136578 			rc = (*struct {
 136579 				f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32
 136580 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxQueryPhrase})).f(tls, pFts, i, bp+16, *(*uintptr)(unsafe.Pointer(&struct {
 136581 				f func(*libc.TLS, uintptr, uintptr, uintptr) int32
 136582 			}{fts5CountCb})))
 136583 			if rc == SQLITE_OK {
 136584 				var idf float64 = libc.Xlog(tls, (float64(*(*Sqlite3_int64)(unsafe.Pointer(bp))-*(*Sqlite3_int64)(unsafe.Pointer(bp + 16)))+0.5)/(float64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 16)))+0.5))
 136585 				if idf <= 0.0 {
 136586 					idf = 1e-6
 136587 				}
 136588 				*(*float64)(unsafe.Pointer((*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(i)*8)) = idf
 136589 			}
 136590 		}
 136591 
 136592 		if rc != SQLITE_OK {
 136593 			Xsqlite3_free(tls, p)
 136594 		} else {
 136595 			rc = (*struct {
 136596 				f func(*libc.TLS, uintptr, uintptr, uintptr) int32
 136597 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxSetAuxdata})).f(tls, pFts, p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 136598 		}
 136599 		if rc != SQLITE_OK {
 136600 			p = uintptr(0)
 136601 		}
 136602 	}
 136603 	*(*uintptr)(unsafe.Pointer(ppData)) = p
 136604 	return rc
 136605 }
 136606 
 136607 func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) {
 136608 	bp := tls.Alloc(24)
 136609 	defer tls.Free(24)
 136610 
 136611 	var k1 float64 = 1.2
 136612 	var b float64 = 0.75
 136613 	var rc int32
 136614 	var score float64 = 0.0
 136615 
 136616 	var i int32
 136617 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
 136618 	var D float64 = 0.0
 136619 	var aFreq uintptr = uintptr(0)
 136620 
 136621 	rc = fts5Bm25GetData(tls, pApi, pFts, bp)
 136622 	if rc == SQLITE_OK {
 136623 		aFreq = (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaFreq
 136624 		libc.Xmemset(tls, aFreq, 0, uint32(unsafe.Sizeof(float64(0)))*uint32((*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnPhrase))
 136625 		rc = (*struct {
 136626 			f func(*libc.TLS, uintptr, uintptr) int32
 136627 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})).f(tls, pFts, bp+4)
 136628 	}
 136629 	for i = 0; rc == SQLITE_OK && i < *(*int32)(unsafe.Pointer(bp + 4)); i++ {
 136630 		rc = (*struct {
 136631 			f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32
 136632 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})).f(tls, pFts, i, bp+8, bp+12, bp+16)
 136633 		if rc == SQLITE_OK {
 136634 			var w float64
 136635 			if nVal > *(*int32)(unsafe.Pointer(bp + 12)) {
 136636 				w = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(*(*int32)(unsafe.Pointer(bp + 12)))*4)))
 136637 			} else {
 136638 				w = 1.0
 136639 			}
 136640 			*(*float64)(unsafe.Pointer(aFreq + uintptr(*(*int32)(unsafe.Pointer(bp + 8)))*8)) += w
 136641 		}
 136642 	}
 136643 
 136644 	if rc == SQLITE_OK {
 136645 		rc = (*struct {
 136646 			f func(*libc.TLS, uintptr, int32, uintptr) int32
 136647 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExtensionApi)(unsafe.Pointer(pApi)).FxColumnSize})).f(tls, pFts, -1, bp+20)
 136648 		D = float64(*(*int32)(unsafe.Pointer(bp + 20)))
 136649 	}
 136650 
 136651 	if rc == SQLITE_OK {
 136652 		for i = 0; i < (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnPhrase; i++ {
 136653 			score = score + *(*float64)(unsafe.Pointer((*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaIDF + uintptr(i)*8))*(*(*float64)(unsafe.Pointer(aFreq + uintptr(i)*8))*(k1+1.0)/(*(*float64)(unsafe.Pointer(aFreq + uintptr(i)*8))+k1*(float64(1)-b+b*D/(*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Favgdl)))
 136654 		}
 136655 		Xsqlite3_result_double(tls, pCtx, -1.0*score)
 136656 	} else {
 136657 		Xsqlite3_result_error_code(tls, pCtx, rc)
 136658 	}
 136659 }
 136660 
 136661 func sqlite3Fts5AuxInit(tls *libc.TLS, pApi uintptr) int32 {
 136662 	bp := tls.Alloc(48)
 136663 	defer tls.Free(48)
 136664 
 136665 	*(*[3]Builtin)(unsafe.Pointer(bp)) = [3]Builtin{
 136666 		{FzFunc: ts + 33897, FxFunc: *(*uintptr)(unsafe.Pointer(&struct {
 136667 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr)
 136668 		}{fts5SnippetFunction}))},
 136669 		{FzFunc: ts + 33905, FxFunc: *(*uintptr)(unsafe.Pointer(&struct {
 136670 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr)
 136671 		}{fts5HighlightFunction}))},
 136672 		{FzFunc: ts + 33915, FxFunc: *(*uintptr)(unsafe.Pointer(&struct {
 136673 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr)
 136674 		}{fts5Bm25Function}))},
 136675 	}
 136676 	var rc int32 = SQLITE_OK
 136677 	var i int32
 136678 
 136679 	for i = 0; rc == SQLITE_OK && i < int32(uint32(unsafe.Sizeof([3]Builtin{}))/uint32(unsafe.Sizeof(Builtin{}))); i++ {
 136680 		rc = (*struct {
 136681 			f func(*libc.TLS, uintptr, uintptr, uintptr, Fts5_extension_function, uintptr) int32
 136682 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5_api)(unsafe.Pointer(pApi)).FxCreateFunction})).f(tls, pApi,
 136683 			(*Builtin)(unsafe.Pointer(bp+uintptr(i)*16)).FzFunc,
 136684 			(*Builtin)(unsafe.Pointer(bp+uintptr(i)*16)).FpUserData,
 136685 			(*Builtin)(unsafe.Pointer(bp+uintptr(i)*16)).FxFunc,
 136686 			(*Builtin)(unsafe.Pointer(bp+uintptr(i)*16)).FxDestroy)
 136687 	}
 136688 
 136689 	return rc
 136690 }
 136691 
 136692 type Builtin = struct {
 136693 	FzFunc     uintptr
 136694 	FpUserData uintptr
 136695 	FxFunc     Fts5_extension_function
 136696 	FxDestroy  uintptr
 136697 }
 136698 
 136699 func sqlite3Fts5BufferSize(tls *libc.TLS, pRc uintptr, pBuf uintptr, nByte U32) int32 {
 136700 	if U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) < nByte {
 136701 		var nNew U64
 136702 		if (*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace != 0 {
 136703 			nNew = uint64((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)
 136704 		} else {
 136705 			nNew = uint64(64)
 136706 		}
 136707 		var pNew uintptr
 136708 		for nNew < U64(nByte) {
 136709 			nNew = nNew * uint64(2)
 136710 		}
 136711 		pNew = Xsqlite3_realloc64(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, nNew)
 136712 		if pNew == uintptr(0) {
 136713 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 136714 			return 1
 136715 		} else {
 136716 			(*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace = int32(nNew)
 136717 			(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp = pNew
 136718 		}
 136719 	}
 136720 	return 0
 136721 }
 136722 
 136723 func sqlite3Fts5BufferAppendVarint(tls *libc.TLS, pRc uintptr, pBuf uintptr, iVal I64) {
 136724 	if func() int32 {
 136725 		if U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)+U32(9) <= U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) {
 136726 			return 0
 136727 		}
 136728 		return sqlite3Fts5BufferSize(tls, pRc, pBuf, uint32(9+(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn))
 136729 	}() != 0 {
 136730 		return
 136731 	}
 136732 	*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), uint64(iVal))
 136733 }
 136734 
 136735 func sqlite3Fts5Put32(tls *libc.TLS, aBuf uintptr, iVal int32) {
 136736 	*(*U8)(unsafe.Pointer(aBuf)) = U8(iVal >> 24 & 0x00FF)
 136737 	*(*U8)(unsafe.Pointer(aBuf + 1)) = U8(iVal >> 16 & 0x00FF)
 136738 	*(*U8)(unsafe.Pointer(aBuf + 2)) = U8(iVal >> 8 & 0x00FF)
 136739 	*(*U8)(unsafe.Pointer(aBuf + 3)) = U8(iVal >> 0 & 0x00FF)
 136740 }
 136741 
 136742 func sqlite3Fts5Get32(tls *libc.TLS, aBuf uintptr) int32 {
 136743 	return int32(U32(*(*U8)(unsafe.Pointer(aBuf)))<<24 + U32(int32(*(*U8)(unsafe.Pointer(aBuf + 1)))<<16) + U32(int32(*(*U8)(unsafe.Pointer(aBuf + 2)))<<8) + U32(*(*U8)(unsafe.Pointer(aBuf + 3))))
 136744 }
 136745 
 136746 func sqlite3Fts5BufferAppendBlob(tls *libc.TLS, pRc uintptr, pBuf uintptr, nData U32, pData uintptr) {
 136747 	if nData != 0 {
 136748 		if func() int32 {
 136749 			if U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)+nData <= U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) {
 136750 				return 0
 136751 			}
 136752 			return sqlite3Fts5BufferSize(tls, pRc, pBuf, nData+U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn))
 136753 		}() != 0 {
 136754 			return
 136755 		}
 136756 		libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), pData, nData)
 136757 		*(*int32)(unsafe.Pointer(pBuf + 4)) += int32(nData)
 136758 	}
 136759 }
 136760 
 136761 func sqlite3Fts5BufferAppendString(tls *libc.TLS, pRc uintptr, pBuf uintptr, zStr uintptr) {
 136762 	var nStr int32 = int32(libc.Xstrlen(tls, zStr))
 136763 	sqlite3Fts5BufferAppendBlob(tls, pRc, pBuf, uint32(nStr+1), zStr)
 136764 	(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn--
 136765 }
 136766 
 136767 func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFmt uintptr, va uintptr) {
 136768 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 136769 		var zTmp uintptr
 136770 		var ap Va_list
 136771 		_ = ap
 136772 		ap = va
 136773 		zTmp = Xsqlite3_vmprintf(tls, zFmt, ap)
 136774 		_ = ap
 136775 
 136776 		if zTmp == uintptr(0) {
 136777 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 136778 		} else {
 136779 			sqlite3Fts5BufferAppendString(tls, pRc, pBuf, zTmp)
 136780 			Xsqlite3_free(tls, zTmp)
 136781 		}
 136782 	}
 136783 }
 136784 
 136785 func sqlite3Fts5Mprintf(tls *libc.TLS, pRc uintptr, zFmt uintptr, va uintptr) uintptr {
 136786 	var zRet uintptr = uintptr(0)
 136787 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 136788 		var ap Va_list
 136789 		_ = ap
 136790 		ap = va
 136791 		zRet = Xsqlite3_vmprintf(tls, zFmt, ap)
 136792 		_ = ap
 136793 		if zRet == uintptr(0) {
 136794 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 136795 		}
 136796 	}
 136797 	return zRet
 136798 }
 136799 
 136800 func sqlite3Fts5BufferFree(tls *libc.TLS, pBuf uintptr) {
 136801 	Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp)
 136802 	libc.Xmemset(tls, pBuf, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 136803 }
 136804 
 136805 func sqlite3Fts5BufferZero(tls *libc.TLS, pBuf uintptr) {
 136806 	(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0
 136807 }
 136808 
 136809 func sqlite3Fts5BufferSet(tls *libc.TLS, pRc uintptr, pBuf uintptr, nData int32, pData uintptr) {
 136810 	(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0
 136811 	sqlite3Fts5BufferAppendBlob(tls, pRc, pBuf, uint32(nData), pData)
 136812 }
 136813 
 136814 func sqlite3Fts5PoslistNext64(tls *libc.TLS, a uintptr, n int32, pi uintptr, piOff uintptr) int32 {
 136815 	bp := tls.Alloc(4)
 136816 	defer tls.Free(4)
 136817 
 136818 	var i int32 = *(*int32)(unsafe.Pointer(pi))
 136819 	if i >= n {
 136820 		*(*I64)(unsafe.Pointer(piOff)) = int64(-1)
 136821 		return 1
 136822 	} else {
 136823 		var iOff I64 = *(*I64)(unsafe.Pointer(piOff))
 136824 
 136825 		{
 136826 			*(*U32)(unsafe.Pointer(bp)) = U32(*(*U8)(unsafe.Pointer(a + uintptr(libc.PostIncInt32(&i, 1)))))
 136827 			if *(*U32)(unsafe.Pointer(bp))&U32(0x80) != 0 {
 136828 				i--
 136829 				i = i + sqlite3Fts5GetVarint32(tls, a+uintptr(i), bp)
 136830 			}
 136831 		}
 136832 
 136833 		if *(*U32)(unsafe.Pointer(bp)) <= U32(1) {
 136834 			if *(*U32)(unsafe.Pointer(bp)) == U32(0) {
 136835 				*(*int32)(unsafe.Pointer(pi)) = i
 136836 				return 0
 136837 			}
 136838 			{
 136839 				*(*U32)(unsafe.Pointer(bp)) = U32(*(*U8)(unsafe.Pointer(a + uintptr(libc.PostIncInt32(&i, 1)))))
 136840 				if *(*U32)(unsafe.Pointer(bp))&U32(0x80) != 0 {
 136841 					i--
 136842 					i = i + sqlite3Fts5GetVarint32(tls, a+uintptr(i), bp)
 136843 				}
 136844 			}
 136845 
 136846 			iOff = I64(*(*U32)(unsafe.Pointer(bp))) << 32
 136847 
 136848 			{
 136849 				*(*U32)(unsafe.Pointer(bp)) = U32(*(*U8)(unsafe.Pointer(a + uintptr(libc.PostIncInt32(&i, 1)))))
 136850 				if *(*U32)(unsafe.Pointer(bp))&U32(0x80) != 0 {
 136851 					i--
 136852 					i = i + sqlite3Fts5GetVarint32(tls, a+uintptr(i), bp)
 136853 				}
 136854 			}
 136855 
 136856 			if *(*U32)(unsafe.Pointer(bp)) < U32(2) {
 136857 				*(*I64)(unsafe.Pointer(piOff)) = int64(-1)
 136858 				return 1
 136859 			}
 136860 			*(*I64)(unsafe.Pointer(piOff)) = iOff + I64((*(*U32)(unsafe.Pointer(bp))-U32(2))&U32(0x7FFFFFFF))
 136861 		} else {
 136862 			*(*I64)(unsafe.Pointer(piOff)) = iOff&(int64(0x7FFFFFFF)<<32) + (iOff+I64(*(*U32)(unsafe.Pointer(bp))-U32(2)))&int64(0x7FFFFFFF)
 136863 		}
 136864 		*(*int32)(unsafe.Pointer(pi)) = i
 136865 
 136866 		return 0
 136867 	}
 136868 	return int32(0)
 136869 }
 136870 
 136871 func sqlite3Fts5PoslistReaderNext(tls *libc.TLS, pIter uintptr) int32 {
 136872 	if sqlite3Fts5PoslistNext64(tls, (*Fts5PoslistReader)(unsafe.Pointer(pIter)).Fa, (*Fts5PoslistReader)(unsafe.Pointer(pIter)).Fn, pIter+8, pIter+16) != 0 {
 136873 		(*Fts5PoslistReader)(unsafe.Pointer(pIter)).FbEof = U8(1)
 136874 	}
 136875 	return int32((*Fts5PoslistReader)(unsafe.Pointer(pIter)).FbEof)
 136876 }
 136877 
 136878 func sqlite3Fts5PoslistReaderInit(tls *libc.TLS, a uintptr, n int32, pIter uintptr) int32 {
 136879 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(Fts5PoslistReader{})))
 136880 	(*Fts5PoslistReader)(unsafe.Pointer(pIter)).Fa = a
 136881 	(*Fts5PoslistReader)(unsafe.Pointer(pIter)).Fn = n
 136882 	sqlite3Fts5PoslistReaderNext(tls, pIter)
 136883 	return int32((*Fts5PoslistReader)(unsafe.Pointer(pIter)).FbEof)
 136884 }
 136885 
 136886 func sqlite3Fts5PoslistSafeAppend(tls *libc.TLS, pBuf uintptr, piPrev uintptr, iPos I64) {
 136887 	if iPos >= *(*I64)(unsafe.Pointer(piPrev)) {
 136888 		if iPos&colmask != *(*I64)(unsafe.Pointer(piPrev))&colmask {
 136889 			*(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(libc.PostIncInt32(&(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, 1)))) = U8(1)
 136890 			*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), uint64(iPos>>32))
 136891 			*(*I64)(unsafe.Pointer(piPrev)) = iPos & colmask
 136892 		}
 136893 		*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), uint64(iPos-*(*I64)(unsafe.Pointer(piPrev))+int64(2)))
 136894 		*(*I64)(unsafe.Pointer(piPrev)) = iPos
 136895 	}
 136896 }
 136897 
 136898 var colmask I64 = int64(0x7FFFFFFF) << 32
 136899 
 136900 func sqlite3Fts5PoslistWriterAppend(tls *libc.TLS, pBuf uintptr, pWriter uintptr, iPos I64) int32 {
 136901 	bp := tls.Alloc(4)
 136902 	defer tls.Free(4)
 136903 
 136904 	*(*int32)(unsafe.Pointer(bp)) = 0
 136905 	if func() int32 {
 136906 		if U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)+U32(5+5+5) <= U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) {
 136907 			return 0
 136908 		}
 136909 		return sqlite3Fts5BufferSize(tls, bp, pBuf, uint32(5+5+5+(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn))
 136910 	}() != 0 {
 136911 		return *(*int32)(unsafe.Pointer(bp))
 136912 	}
 136913 	sqlite3Fts5PoslistSafeAppend(tls, pBuf, pWriter, iPos)
 136914 	return SQLITE_OK
 136915 }
 136916 
 136917 func sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Sqlite3_int64) uintptr {
 136918 	var pRet uintptr = uintptr(0)
 136919 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 136920 		pRet = Xsqlite3_malloc64(tls, uint64(nByte))
 136921 		if pRet == uintptr(0) {
 136922 			if nByte > int64(0) {
 136923 				*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 136924 			}
 136925 		} else {
 136926 			libc.Xmemset(tls, pRet, 0, Size_t(nByte))
 136927 		}
 136928 	}
 136929 	return pRet
 136930 }
 136931 
 136932 func sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) uintptr {
 136933 	var zRet uintptr = uintptr(0)
 136934 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 136935 		if nIn < 0 {
 136936 			nIn = int32(libc.Xstrlen(tls, pIn))
 136937 		}
 136938 		zRet = Xsqlite3_malloc(tls, nIn+1)
 136939 		if zRet != 0 {
 136940 			libc.Xmemcpy(tls, zRet, pIn, uint32(nIn))
 136941 			*(*uint8)(unsafe.Pointer(zRet + uintptr(nIn))) = uint8(0)
 136942 		} else {
 136943 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 136944 		}
 136945 	}
 136946 	return zRet
 136947 }
 136948 
 136949 func sqlite3Fts5IsBareword(tls *libc.TLS, t uint8) int32 {
 136950 	bp := tls.Alloc(128)
 136951 	defer tls.Free(128)
 136952 
 136953 	*(*[128]U8)(unsafe.Pointer(bp)) = [128]U8{
 136954 		U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0),
 136955 		U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(1), U8(0), U8(0), U8(0), U8(0), U8(0),
 136956 		U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0),
 136957 		U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(0), U8(0), U8(0), U8(0), U8(0), U8(0),
 136958 		U8(0), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1),
 136959 		U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(0), U8(0), U8(0), U8(0), U8(1),
 136960 		U8(0), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1),
 136961 		U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(1), U8(0), U8(0), U8(0), U8(0), U8(0),
 136962 	}
 136963 
 136964 	return libc.Bool32(int32(t)&0x80 != 0 || *(*U8)(unsafe.Pointer(bp + uintptr(int32(t)))) != 0)
 136965 }
 136966 
 136967 // ************************************************************************
 136968 type Fts5TermsetEntry1 = struct {
 136969 	FpTerm uintptr
 136970 	FnTerm int32
 136971 	FiIdx  int32
 136972 	FpNext uintptr
 136973 }
 136974 
 136975 // ************************************************************************
 136976 type Fts5TermsetEntry = Fts5TermsetEntry1
 136977 
 136978 func sqlite3Fts5TermsetNew(tls *libc.TLS, pp uintptr) int32 {
 136979 	bp := tls.Alloc(4)
 136980 	defer tls.Free(4)
 136981 
 136982 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 136983 	*(*uintptr)(unsafe.Pointer(pp)) = sqlite3Fts5MallocZero(tls, bp, int64(unsafe.Sizeof(Fts5Termset{})))
 136984 	return *(*int32)(unsafe.Pointer(bp))
 136985 }
 136986 
 136987 func sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, nTerm int32, pbPresent uintptr) int32 {
 136988 	bp := tls.Alloc(4)
 136989 	defer tls.Free(4)
 136990 
 136991 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 136992 	*(*int32)(unsafe.Pointer(pbPresent)) = 0
 136993 	if p != 0 {
 136994 		var i int32
 136995 		var hash U32 = U32(13)
 136996 		var pEntry uintptr
 136997 
 136998 		for i = nTerm - 1; i >= 0; i-- {
 136999 			hash = hash<<3 ^ hash ^ U32(*(*uint8)(unsafe.Pointer(pTerm + uintptr(i))))
 137000 		}
 137001 		hash = hash<<3 ^ hash ^ U32(iIdx)
 137002 		hash = hash % U32(int32(uint32(unsafe.Sizeof([512]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))))
 137003 
 137004 		for pEntry = *(*uintptr)(unsafe.Pointer(p + uintptr(hash)*4)); pEntry != 0; pEntry = (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpNext {
 137005 			if (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FiIdx == iIdx &&
 137006 				(*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FnTerm == nTerm &&
 137007 				libc.Xmemcmp(tls, (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm, pTerm, uint32(nTerm)) == 0 {
 137008 				*(*int32)(unsafe.Pointer(pbPresent)) = 1
 137009 				break
 137010 			}
 137011 		}
 137012 
 137013 		if pEntry == uintptr(0) {
 137014 			pEntry = sqlite3Fts5MallocZero(tls, bp, int64(uint32(unsafe.Sizeof(Fts5TermsetEntry{}))+uint32(nTerm)))
 137015 			if pEntry != 0 {
 137016 				(*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm = pEntry + 1*16
 137017 				(*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FnTerm = nTerm
 137018 				(*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FiIdx = iIdx
 137019 				libc.Xmemcpy(tls, (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm, pTerm, uint32(nTerm))
 137020 				(*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpNext = *(*uintptr)(unsafe.Pointer(p + uintptr(hash)*4))
 137021 				*(*uintptr)(unsafe.Pointer(p + uintptr(hash)*4)) = pEntry
 137022 			}
 137023 		}
 137024 	}
 137025 
 137026 	return *(*int32)(unsafe.Pointer(bp))
 137027 }
 137028 
 137029 func sqlite3Fts5TermsetFree(tls *libc.TLS, p uintptr) {
 137030 	if p != 0 {
 137031 		var i U32
 137032 		for i = U32(0); i < U32(int32(uint32(unsafe.Sizeof([512]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0))))); i++ {
 137033 			var pEntry uintptr = *(*uintptr)(unsafe.Pointer(p + uintptr(i)*4))
 137034 			for pEntry != 0 {
 137035 				var pDel uintptr = pEntry
 137036 				pEntry = (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpNext
 137037 				Xsqlite3_free(tls, pDel)
 137038 			}
 137039 		}
 137040 		Xsqlite3_free(tls, p)
 137041 	}
 137042 }
 137043 
 137044 func fts5_iswhitespace(tls *libc.TLS, x uint8) int32 {
 137045 	return libc.Bool32(int32(x) == ' ')
 137046 }
 137047 
 137048 func fts5_isopenquote(tls *libc.TLS, x uint8) int32 {
 137049 	return libc.Bool32(int32(x) == '"' || int32(x) == '\'' || int32(x) == '[' || int32(x) == '`')
 137050 }
 137051 
 137052 func fts5ConfigSkipWhitespace(tls *libc.TLS, pIn uintptr) uintptr {
 137053 	var p uintptr = pIn
 137054 	if p != 0 {
 137055 		for fts5_iswhitespace(tls, *(*uint8)(unsafe.Pointer(p))) != 0 {
 137056 			p++
 137057 		}
 137058 	}
 137059 	return p
 137060 }
 137061 
 137062 func fts5ConfigSkipBareword(tls *libc.TLS, pIn uintptr) uintptr {
 137063 	var p uintptr = pIn
 137064 	for sqlite3Fts5IsBareword(tls, *(*uint8)(unsafe.Pointer(p))) != 0 {
 137065 		p++
 137066 	}
 137067 	if p == pIn {
 137068 		p = uintptr(0)
 137069 	}
 137070 	return p
 137071 }
 137072 
 137073 func fts5_isdigit(tls *libc.TLS, a uint8) int32 {
 137074 	return libc.Bool32(int32(a) >= '0' && int32(a) <= '9')
 137075 }
 137076 
 137077 func fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) uintptr {
 137078 	var p uintptr = pIn
 137079 	switch int32(*(*uint8)(unsafe.Pointer(p))) {
 137080 	case 'n':
 137081 		fallthrough
 137082 	case 'N':
 137083 		if Xsqlite3_strnicmp(tls, ts+6181, p, 4) == 0 {
 137084 			p = p + 4
 137085 		} else {
 137086 			p = uintptr(0)
 137087 		}
 137088 		break
 137089 
 137090 	case 'x':
 137091 		fallthrough
 137092 	case 'X':
 137093 		p++
 137094 		if int32(*(*uint8)(unsafe.Pointer(p))) == '\'' {
 137095 			p++
 137096 			for int32(*(*uint8)(unsafe.Pointer(p))) >= 'a' && int32(*(*uint8)(unsafe.Pointer(p))) <= 'f' ||
 137097 				int32(*(*uint8)(unsafe.Pointer(p))) >= 'A' && int32(*(*uint8)(unsafe.Pointer(p))) <= 'F' ||
 137098 				int32(*(*uint8)(unsafe.Pointer(p))) >= '0' && int32(*(*uint8)(unsafe.Pointer(p))) <= '9' {
 137099 				p++
 137100 			}
 137101 			if int32(*(*uint8)(unsafe.Pointer(p))) == '\'' && 0 == (int32(p)-int32(pIn))/1%2 {
 137102 				p++
 137103 			} else {
 137104 				p = uintptr(0)
 137105 			}
 137106 		} else {
 137107 			p = uintptr(0)
 137108 		}
 137109 		break
 137110 
 137111 	case '\'':
 137112 		p++
 137113 		for p != 0 {
 137114 			if int32(*(*uint8)(unsafe.Pointer(p))) == '\'' {
 137115 				p++
 137116 				if int32(*(*uint8)(unsafe.Pointer(p))) != '\'' {
 137117 					break
 137118 				}
 137119 			}
 137120 			p++
 137121 			if int32(*(*uint8)(unsafe.Pointer(p))) == 0 {
 137122 				p = uintptr(0)
 137123 			}
 137124 		}
 137125 		break
 137126 
 137127 	default:
 137128 		if int32(*(*uint8)(unsafe.Pointer(p))) == '+' || int32(*(*uint8)(unsafe.Pointer(p))) == '-' {
 137129 			p++
 137130 		}
 137131 		for fts5_isdigit(tls, *(*uint8)(unsafe.Pointer(p))) != 0 {
 137132 			p++
 137133 		}
 137134 
 137135 		if int32(*(*uint8)(unsafe.Pointer(p))) == '.' && fts5_isdigit(tls, *(*uint8)(unsafe.Pointer(p + 1))) != 0 {
 137136 			p += uintptr(2)
 137137 			for fts5_isdigit(tls, *(*uint8)(unsafe.Pointer(p))) != 0 {
 137138 				p++
 137139 			}
 137140 		}
 137141 		if p == pIn {
 137142 			p = uintptr(0)
 137143 		}
 137144 
 137145 		break
 137146 	}
 137147 
 137148 	return p
 137149 }
 137150 
 137151 func fts5Dequote(tls *libc.TLS, z uintptr) int32 {
 137152 	var q uint8
 137153 	var iIn int32 = 1
 137154 	var iOut int32 = 0
 137155 	q = *(*uint8)(unsafe.Pointer(z))
 137156 
 137157 	if int32(q) == '[' {
 137158 		q = uint8(']')
 137159 	}
 137160 
 137161 	for *(*uint8)(unsafe.Pointer(z + uintptr(iIn))) != 0 {
 137162 		if int32(*(*uint8)(unsafe.Pointer(z + uintptr(iIn)))) == int32(q) {
 137163 			if int32(*(*uint8)(unsafe.Pointer(z + uintptr(iIn+1)))) != int32(q) {
 137164 				iIn++
 137165 				break
 137166 			} else {
 137167 				iIn = iIn + 2
 137168 				*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = q
 137169 			}
 137170 		} else {
 137171 			*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iIn, 1))))
 137172 		}
 137173 	}
 137174 
 137175 	*(*uint8)(unsafe.Pointer(z + uintptr(iOut))) = uint8(0)
 137176 	return iIn
 137177 }
 137178 
 137179 func sqlite3Fts5Dequote(tls *libc.TLS, z uintptr) {
 137180 	var quote uint8
 137181 
 137182 	quote = *(*uint8)(unsafe.Pointer(z))
 137183 	if int32(quote) == '[' || int32(quote) == '\'' || int32(quote) == '"' || int32(quote) == '`' {
 137184 		fts5Dequote(tls, z)
 137185 	}
 137186 }
 137187 
 137188 type Fts5Enum1 = struct {
 137189 	FzName uintptr
 137190 	FeVal  int32
 137191 }
 137192 
 137193 type Fts5Enum = Fts5Enum1
 137194 
 137195 func fts5ConfigSetEnum(tls *libc.TLS, aEnum uintptr, zEnum uintptr, peVal uintptr) int32 {
 137196 	var nEnum int32 = int32(libc.Xstrlen(tls, zEnum))
 137197 	var i int32
 137198 	var iVal int32 = -1
 137199 
 137200 	for i = 0; (*Fts5Enum)(unsafe.Pointer(aEnum+uintptr(i)*8)).FzName != 0; i++ {
 137201 		if Xsqlite3_strnicmp(tls, (*Fts5Enum)(unsafe.Pointer(aEnum+uintptr(i)*8)).FzName, zEnum, nEnum) == 0 {
 137202 			if iVal >= 0 {
 137203 				return SQLITE_ERROR
 137204 			}
 137205 			iVal = (*Fts5Enum)(unsafe.Pointer(aEnum + uintptr(i)*8)).FeVal
 137206 		}
 137207 	}
 137208 
 137209 	*(*int32)(unsafe.Pointer(peVal)) = iVal
 137210 	if iVal < 0 {
 137211 		return SQLITE_ERROR
 137212 	}
 137213 	return SQLITE_OK
 137214 }
 137215 
 137216 func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCmd uintptr, zArg uintptr, pzErr uintptr) int32 {
 137217 	bp := tls.Alloc(76)
 137218 	defer tls.Free(76)
 137219 
 137220 	*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_OK
 137221 	var nCmd int32 = int32(libc.Xstrlen(tls, zCmd))
 137222 	if Xsqlite3_strnicmp(tls, ts+33920, zCmd, nCmd) == 0 {
 137223 		var nByte int32 = int32(uint32(unsafe.Sizeof(int32(0))) * uint32(FTS5_MAX_PREFIX_INDEXES))
 137224 		var p uintptr
 137225 		var bFirst int32 = 1
 137226 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix == uintptr(0) {
 137227 			(*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix = sqlite3Fts5MallocZero(tls, bp+40, int64(nByte))
 137228 			if *(*int32)(unsafe.Pointer(bp + 40)) != 0 {
 137229 				return *(*int32)(unsafe.Pointer(bp + 40))
 137230 			}
 137231 		}
 137232 
 137233 		p = zArg
 137234 		for 1 != 0 {
 137235 			var nPre int32 = 0
 137236 
 137237 			for int32(*(*uint8)(unsafe.Pointer(p))) == ' ' {
 137238 				p++
 137239 			}
 137240 			if bFirst == 0 && int32(*(*uint8)(unsafe.Pointer(p))) == ',' {
 137241 				p++
 137242 				for int32(*(*uint8)(unsafe.Pointer(p))) == ' ' {
 137243 					p++
 137244 				}
 137245 			} else if int32(*(*uint8)(unsafe.Pointer(p))) == 0 {
 137246 				break
 137247 			}
 137248 			if int32(*(*uint8)(unsafe.Pointer(p))) < '0' || int32(*(*uint8)(unsafe.Pointer(p))) > '9' {
 137249 				*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+33927, 0)
 137250 				*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137251 				break
 137252 			}
 137253 
 137254 			if (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix == FTS5_MAX_PREFIX_INDEXES {
 137255 				*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls,
 137256 					ts+33958, libc.VaList(bp, FTS5_MAX_PREFIX_INDEXES))
 137257 				*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137258 				break
 137259 			}
 137260 
 137261 			for int32(*(*uint8)(unsafe.Pointer(p))) >= '0' && int32(*(*uint8)(unsafe.Pointer(p))) <= '9' && nPre < 1000 {
 137262 				nPre = nPre*10 + (int32(*(*uint8)(unsafe.Pointer(p))) - '0')
 137263 				p++
 137264 			}
 137265 
 137266 			if nPre <= 0 || nPre >= 1000 {
 137267 				*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+33991, 0)
 137268 				*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137269 				break
 137270 			}
 137271 
 137272 			*(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr((*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix)*4)) = nPre
 137273 			(*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix++
 137274 			bFirst = 0
 137275 		}
 137276 
 137277 		return *(*int32)(unsafe.Pointer(bp + 40))
 137278 	}
 137279 
 137280 	if Xsqlite3_strnicmp(tls, ts+34028, zCmd, nCmd) == 0 {
 137281 		var p uintptr = zArg
 137282 		var nArg Sqlite3_int64 = Sqlite3_int64(libc.Xstrlen(tls, zArg) + Size_t(1))
 137283 		var azArg uintptr = sqlite3Fts5MallocZero(tls, bp+40, Sqlite3_int64(unsafe.Sizeof(uintptr(0)))*nArg)
 137284 		var pDel uintptr = sqlite3Fts5MallocZero(tls, bp+40, nArg*int64(2))
 137285 		var pSpace uintptr = pDel
 137286 
 137287 		if azArg != 0 && pSpace != 0 {
 137288 			if (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok != 0 {
 137289 				*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34037, 0)
 137290 				*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137291 			} else {
 137292 				for nArg = int64(0); p != 0 && *(*uint8)(unsafe.Pointer(p)) != 0; nArg++ {
 137293 					var p2 uintptr = fts5ConfigSkipWhitespace(tls, p)
 137294 					if int32(*(*uint8)(unsafe.Pointer(p2))) == '\'' {
 137295 						p = fts5ConfigSkipLiteral(tls, p2)
 137296 					} else {
 137297 						p = fts5ConfigSkipBareword(tls, p2)
 137298 					}
 137299 					if p != 0 {
 137300 						libc.Xmemcpy(tls, pSpace, p2, uint32((int32(p)-int32(p2))/1))
 137301 						*(*uintptr)(unsafe.Pointer(azArg + uintptr(nArg)*4)) = pSpace
 137302 						sqlite3Fts5Dequote(tls, pSpace)
 137303 						pSpace += uintptr((int32(p)-int32(p2))/1 + 1)
 137304 						p = fts5ConfigSkipWhitespace(tls, p)
 137305 					}
 137306 				}
 137307 				if p == uintptr(0) {
 137308 					*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34070, 0)
 137309 					*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137310 				} else {
 137311 					*(*int32)(unsafe.Pointer(bp + 40)) = sqlite3Fts5GetTokenizer(tls, pGlobal,
 137312 						azArg, int32(nArg), pConfig,
 137313 						pzErr)
 137314 				}
 137315 			}
 137316 		}
 137317 
 137318 		Xsqlite3_free(tls, azArg)
 137319 		Xsqlite3_free(tls, pDel)
 137320 		return *(*int32)(unsafe.Pointer(bp + 40))
 137321 	}
 137322 
 137323 	if Xsqlite3_strnicmp(tls, ts+34104, zCmd, nCmd) == 0 {
 137324 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL {
 137325 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34112, 0)
 137326 			*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137327 		} else {
 137328 			if *(*uint8)(unsafe.Pointer(zArg)) != 0 {
 137329 				(*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = FTS5_CONTENT_EXTERNAL
 137330 				(*Fts5Config)(unsafe.Pointer(pConfig)).FzContent = sqlite3Fts5Mprintf(tls, bp+40, ts+34144, libc.VaList(bp+8, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, zArg))
 137331 			} else {
 137332 				(*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = FTS5_CONTENT_NONE
 137333 			}
 137334 		}
 137335 		return *(*int32)(unsafe.Pointer(bp + 40))
 137336 	}
 137337 
 137338 	if Xsqlite3_strnicmp(tls, ts+34150, zCmd, nCmd) == 0 {
 137339 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid != 0 {
 137340 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34164, 0)
 137341 			*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137342 		} else {
 137343 			(*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid = sqlite3Fts5Strndup(tls, bp+40, zArg, -1)
 137344 		}
 137345 		return *(*int32)(unsafe.Pointer(bp + 40))
 137346 	}
 137347 
 137348 	if Xsqlite3_strnicmp(tls, ts+34202, zCmd, nCmd) == 0 {
 137349 		if int32(*(*uint8)(unsafe.Pointer(zArg))) != '0' && int32(*(*uint8)(unsafe.Pointer(zArg))) != '1' || int32(*(*uint8)(unsafe.Pointer(zArg + 1))) != 0 {
 137350 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34213, 0)
 137351 			*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137352 		} else {
 137353 			(*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zArg))) == '1')
 137354 		}
 137355 		return *(*int32)(unsafe.Pointer(bp + 40))
 137356 	}
 137357 
 137358 	if Xsqlite3_strnicmp(tls, ts+5075, zCmd, nCmd) == 0 {
 137359 		*(*[4]Fts5Enum)(unsafe.Pointer(bp + 44)) = [4]Fts5Enum{
 137360 			{FzName: ts + 8026, FeVal: FTS5_DETAIL_NONE},
 137361 			{FzName: ts + 17345},
 137362 			{FzName: ts + 34248, FeVal: FTS5_DETAIL_COLUMNS},
 137363 			{},
 137364 		}
 137365 
 137366 		if libc.AssignPtrInt32(bp+40, fts5ConfigSetEnum(tls, bp+44, zArg, pConfig+48)) != 0 {
 137367 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34256, 0)
 137368 		}
 137369 		return *(*int32)(unsafe.Pointer(bp + 40))
 137370 	}
 137371 
 137372 	*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34287, libc.VaList(bp+24, nCmd, zCmd))
 137373 	return SQLITE_ERROR
 137374 }
 137375 
 137376 func fts5ConfigDefaultTokenizer(tls *libc.TLS, pGlobal uintptr, pConfig uintptr) int32 {
 137377 	return sqlite3Fts5GetTokenizer(tls, pGlobal, uintptr(0), 0, pConfig, uintptr(0))
 137378 }
 137379 
 137380 func fts5ConfigGobbleWord(tls *libc.TLS, pRc uintptr, zIn uintptr, pzOut uintptr, pbQuoted uintptr) uintptr {
 137381 	var zRet uintptr = uintptr(0)
 137382 
 137383 	var nIn Sqlite3_int64 = Sqlite3_int64(libc.Xstrlen(tls, zIn))
 137384 	var zOut uintptr = Xsqlite3_malloc64(tls, uint64(nIn+int64(1)))
 137385 
 137386 	*(*int32)(unsafe.Pointer(pbQuoted)) = 0
 137387 	*(*uintptr)(unsafe.Pointer(pzOut)) = uintptr(0)
 137388 
 137389 	if zOut == uintptr(0) {
 137390 		*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 137391 	} else {
 137392 		libc.Xmemcpy(tls, zOut, zIn, Size_t(nIn+int64(1)))
 137393 		if fts5_isopenquote(tls, *(*uint8)(unsafe.Pointer(zOut))) != 0 {
 137394 			var ii int32 = fts5Dequote(tls, zOut)
 137395 			zRet = zIn + uintptr(ii)
 137396 			*(*int32)(unsafe.Pointer(pbQuoted)) = 1
 137397 		} else {
 137398 			zRet = fts5ConfigSkipBareword(tls, zIn)
 137399 			if zRet != 0 {
 137400 				*(*uint8)(unsafe.Pointer(zOut + uintptr((int32(zRet)-int32(zIn))/1))) = uint8(0)
 137401 			}
 137402 		}
 137403 	}
 137404 
 137405 	if zRet == uintptr(0) {
 137406 		Xsqlite3_free(tls, zOut)
 137407 	} else {
 137408 		*(*uintptr)(unsafe.Pointer(pzOut)) = zOut
 137409 	}
 137410 
 137411 	return zRet
 137412 }
 137413 
 137414 func fts5ConfigParseColumn(tls *libc.TLS, p uintptr, zCol uintptr, zArg uintptr, pzErr uintptr) int32 {
 137415 	bp := tls.Alloc(16)
 137416 	defer tls.Free(16)
 137417 
 137418 	var rc int32 = SQLITE_OK
 137419 	if 0 == Xsqlite3_stricmp(tls, zCol, ts+22238) ||
 137420 		0 == Xsqlite3_stricmp(tls, zCol, ts+16267) {
 137421 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34315, libc.VaList(bp, zCol))
 137422 		rc = SQLITE_ERROR
 137423 	} else if zArg != 0 {
 137424 		if 0 == Xsqlite3_stricmp(tls, zArg, ts+34345) {
 137425 			*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr((*Fts5Config)(unsafe.Pointer(p)).FnCol))) = U8(1)
 137426 		} else {
 137427 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34355, libc.VaList(bp+8, zArg))
 137428 			rc = SQLITE_ERROR
 137429 		}
 137430 	}
 137431 
 137432 	*(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FazCol + uintptr(libc.PostIncInt32(&(*Fts5Config)(unsafe.Pointer(p)).FnCol, 1))*4)) = zCol
 137433 	return rc
 137434 }
 137435 
 137436 func fts5ConfigMakeExprlist(tls *libc.TLS, p uintptr) int32 {
 137437 	bp := tls.Alloc(40)
 137438 	defer tls.Free(40)
 137439 
 137440 	var i int32
 137441 	*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_OK
 137442 	*(*Fts5Buffer)(unsafe.Pointer(bp + 28)) = Fts5Buffer{}
 137443 
 137444 	sqlite3Fts5BufferAppendPrintf(tls, bp+24, bp+28, ts+34386, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(p)).FzContentRowid))
 137445 	if (*Fts5Config)(unsafe.Pointer(p)).FeContent != FTS5_CONTENT_NONE {
 137446 		for i = 0; i < (*Fts5Config)(unsafe.Pointer(p)).FnCol; i++ {
 137447 			if (*Fts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_EXTERNAL {
 137448 				sqlite3Fts5BufferAppendPrintf(tls, bp+24, bp+28, ts+34391, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FazCol + uintptr(i)*4))))
 137449 			} else {
 137450 				sqlite3Fts5BufferAppendPrintf(tls, bp+24, bp+28, ts+34398, libc.VaList(bp+16, i))
 137451 			}
 137452 		}
 137453 	}
 137454 
 137455 	(*Fts5Config)(unsafe.Pointer(p)).FzContentExprlist = (*Fts5Buffer)(unsafe.Pointer(bp + 28)).Fp
 137456 	return *(*int32)(unsafe.Pointer(bp + 24))
 137457 }
 137458 
 137459 func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int32, azArg uintptr, ppOut uintptr, pzErr uintptr) int32 {
 137460 	bp := tls.Alloc(60)
 137461 	defer tls.Free(60)
 137462 
 137463 	*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_OK
 137464 	var pRet uintptr
 137465 	var i int32
 137466 	var nByte Sqlite3_int64
 137467 
 137468 	*(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pRet, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Config{}))))
 137469 	if pRet == uintptr(0) {
 137470 		return SQLITE_NOMEM
 137471 	}
 137472 	libc.Xmemset(tls, pRet, 0, uint32(unsafe.Sizeof(Fts5Config{})))
 137473 	(*Fts5Config)(unsafe.Pointer(pRet)).Fdb = db
 137474 	(*Fts5Config)(unsafe.Pointer(pRet)).FiCookie = -1
 137475 
 137476 	nByte = Sqlite3_int64(uint32(nArg) * (uint32(unsafe.Sizeof(uintptr(0))) + uint32(unsafe.Sizeof(U8(0)))))
 137477 	(*Fts5Config)(unsafe.Pointer(pRet)).FazCol = sqlite3Fts5MallocZero(tls, bp+40, nByte)
 137478 	(*Fts5Config)(unsafe.Pointer(pRet)).FabUnindexed = func() uintptr {
 137479 		if (*Fts5Config)(unsafe.Pointer(pRet)).FazCol != 0 {
 137480 			return (*Fts5Config)(unsafe.Pointer(pRet)).FazCol + uintptr(nArg)*4
 137481 		}
 137482 		return uintptr(0)
 137483 	}()
 137484 	(*Fts5Config)(unsafe.Pointer(pRet)).FzDb = sqlite3Fts5Strndup(tls, bp+40, *(*uintptr)(unsafe.Pointer(azArg + 1*4)), -1)
 137485 	(*Fts5Config)(unsafe.Pointer(pRet)).FzName = sqlite3Fts5Strndup(tls, bp+40, *(*uintptr)(unsafe.Pointer(azArg + 2*4)), -1)
 137486 	(*Fts5Config)(unsafe.Pointer(pRet)).FbColumnsize = 1
 137487 	(*Fts5Config)(unsafe.Pointer(pRet)).FeDetail = FTS5_DETAIL_FULL
 137488 	if *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && Xsqlite3_stricmp(tls, (*Fts5Config)(unsafe.Pointer(pRet)).FzName, ts+22238) == 0 {
 137489 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34406, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pRet)).FzName))
 137490 		*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137491 	}
 137492 
 137493 	for i = 3; *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && i < nArg; i++ {
 137494 		var zOrig uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4))
 137495 		var z uintptr
 137496 		*(*uintptr)(unsafe.Pointer(bp + 44)) = uintptr(0)
 137497 		*(*uintptr)(unsafe.Pointer(bp + 52)) = uintptr(0)
 137498 		var bOption int32 = 0
 137499 		*(*int32)(unsafe.Pointer(bp + 48)) = 0
 137500 
 137501 		z = fts5ConfigGobbleWord(tls, bp+40, zOrig, bp+44, bp+48)
 137502 		z = fts5ConfigSkipWhitespace(tls, z)
 137503 		if z != 0 && int32(*(*uint8)(unsafe.Pointer(z))) == '=' {
 137504 			bOption = 1
 137505 
 137506 			z++
 137507 			if *(*int32)(unsafe.Pointer(bp + 48)) != 0 {
 137508 				z = uintptr(0)
 137509 			}
 137510 		}
 137511 		z = fts5ConfigSkipWhitespace(tls, z)
 137512 		if z != 0 && *(*uint8)(unsafe.Pointer(z)) != 0 {
 137513 			z = fts5ConfigGobbleWord(tls, bp+40, z, bp+52, bp+56)
 137514 			if z != 0 && *(*uint8)(unsafe.Pointer(z)) != 0 {
 137515 				z = uintptr(0)
 137516 			}
 137517 		}
 137518 
 137519 		if *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK {
 137520 			if z == uintptr(0) {
 137521 				*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+34435, libc.VaList(bp+8, zOrig))
 137522 				*(*int32)(unsafe.Pointer(bp + 40)) = SQLITE_ERROR
 137523 			} else {
 137524 				if bOption != 0 {
 137525 					*(*int32)(unsafe.Pointer(bp + 40)) = fts5ConfigParseSpecial(tls, pGlobal, pRet,
 137526 						func() uintptr {
 137527 							if *(*uintptr)(unsafe.Pointer(bp + 44)) != 0 {
 137528 								return *(*uintptr)(unsafe.Pointer(bp + 44))
 137529 							}
 137530 							return ts + 1554
 137531 						}(),
 137532 						func() uintptr {
 137533 							if *(*uintptr)(unsafe.Pointer(bp + 52)) != 0 {
 137534 								return *(*uintptr)(unsafe.Pointer(bp + 52))
 137535 							}
 137536 							return ts + 1554
 137537 						}(),
 137538 						pzErr)
 137539 				} else {
 137540 					*(*int32)(unsafe.Pointer(bp + 40)) = fts5ConfigParseColumn(tls, pRet, *(*uintptr)(unsafe.Pointer(bp + 44)), *(*uintptr)(unsafe.Pointer(bp + 52)), pzErr)
 137541 					*(*uintptr)(unsafe.Pointer(bp + 44)) = uintptr(0)
 137542 				}
 137543 			}
 137544 		}
 137545 
 137546 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 44)))
 137547 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 52)))
 137548 	}
 137549 
 137550 	if *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pRet)).FpTok == uintptr(0) {
 137551 		*(*int32)(unsafe.Pointer(bp + 40)) = fts5ConfigDefaultTokenizer(tls, pGlobal, pRet)
 137552 	}
 137553 
 137554 	if *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0) {
 137555 		var zTail uintptr = uintptr(0)
 137556 
 137557 		if (*Fts5Config)(unsafe.Pointer(pRet)).FeContent == FTS5_CONTENT_NORMAL {
 137558 			zTail = ts + 34104
 137559 		} else if (*Fts5Config)(unsafe.Pointer(pRet)).FbColumnsize != 0 {
 137560 			zTail = ts + 34455
 137561 		}
 137562 
 137563 		if zTail != 0 {
 137564 			(*Fts5Config)(unsafe.Pointer(pRet)).FzContent = sqlite3Fts5Mprintf(tls,
 137565 				bp+40, ts+34463, libc.VaList(bp+16, (*Fts5Config)(unsafe.Pointer(pRet)).FzDb, (*Fts5Config)(unsafe.Pointer(pRet)).FzName, zTail))
 137566 		}
 137567 	}
 137568 
 137569 	if *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0) {
 137570 		(*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid = sqlite3Fts5Strndup(tls, bp+40, ts+16267, -1)
 137571 	}
 137572 
 137573 	if *(*int32)(unsafe.Pointer(bp + 40)) == SQLITE_OK {
 137574 		*(*int32)(unsafe.Pointer(bp + 40)) = fts5ConfigMakeExprlist(tls, pRet)
 137575 	}
 137576 
 137577 	if *(*int32)(unsafe.Pointer(bp + 40)) != SQLITE_OK {
 137578 		sqlite3Fts5ConfigFree(tls, pRet)
 137579 		*(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0)
 137580 	}
 137581 	return *(*int32)(unsafe.Pointer(bp + 40))
 137582 }
 137583 
 137584 func sqlite3Fts5ConfigFree(tls *libc.TLS, pConfig uintptr) {
 137585 	if pConfig != 0 {
 137586 		var i int32
 137587 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok != 0 {
 137588 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Fts5_tokenizer)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpTokApi)).FxDelete})).f(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok)
 137589 		}
 137590 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb)
 137591 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)
 137592 		for i = 0; i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 137593 			Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(i)*4)))
 137594 		}
 137595 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FazCol)
 137596 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix)
 137597 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank)
 137598 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs)
 137599 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzContent)
 137600 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid)
 137601 		Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentExprlist)
 137602 		Xsqlite3_free(tls, pConfig)
 137603 	}
 137604 }
 137605 
 137606 func sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) int32 {
 137607 	bp := tls.Alloc(52)
 137608 	defer tls.Free(52)
 137609 
 137610 	var i int32
 137611 	*(*int32)(unsafe.Pointer(bp + 48)) = SQLITE_OK
 137612 	var zSql uintptr
 137613 
 137614 	zSql = sqlite3Fts5Mprintf(tls, bp+48, ts+34474, 0)
 137615 	for i = 0; zSql != 0 && i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 137616 		var zSep uintptr = func() uintptr {
 137617 			if i == 0 {
 137618 				return ts + 1554
 137619 			}
 137620 			return ts + 14614
 137621 		}()
 137622 		zSql = sqlite3Fts5Mprintf(tls, bp+48, ts+34490, libc.VaList(bp, zSql, zSep, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(i)*4))))
 137623 	}
 137624 	zSql = sqlite3Fts5Mprintf(tls, bp+48, ts+34497,
 137625 		libc.VaList(bp+24, zSql, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, ts+22238))
 137626 
 137627 	if zSql != 0 {
 137628 		*(*int32)(unsafe.Pointer(bp + 48)) = Xsqlite3_declare_vtab(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql)
 137629 		Xsqlite3_free(tls, zSql)
 137630 	}
 137631 
 137632 	return *(*int32)(unsafe.Pointer(bp + 48))
 137633 }
 137634 
 137635 func sqlite3Fts5Tokenize(tls *libc.TLS, pConfig uintptr, flags int32, pText uintptr, nText int32, pCtx uintptr, xToken uintptr) int32 {
 137636 	if pText == uintptr(0) {
 137637 		return SQLITE_OK
 137638 	}
 137639 	return (*struct {
 137640 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32
 137641 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5_tokenizer)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpTokApi)).FxTokenize})).f(tls,
 137642 		(*Fts5Config)(unsafe.Pointer(pConfig)).FpTok, pCtx, flags, pText, nText, xToken)
 137643 }
 137644 
 137645 func fts5ConfigSkipArgs(tls *libc.TLS, pIn uintptr) uintptr {
 137646 	var p uintptr = pIn
 137647 
 137648 	for 1 != 0 {
 137649 		p = fts5ConfigSkipWhitespace(tls, p)
 137650 		p = fts5ConfigSkipLiteral(tls, p)
 137651 		p = fts5ConfigSkipWhitespace(tls, p)
 137652 		if p == uintptr(0) || int32(*(*uint8)(unsafe.Pointer(p))) == ')' {
 137653 			break
 137654 		}
 137655 		if int32(*(*uint8)(unsafe.Pointer(p))) != ',' {
 137656 			p = uintptr(0)
 137657 			break
 137658 		}
 137659 		p++
 137660 	}
 137661 
 137662 	return p
 137663 }
 137664 
 137665 func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRankArgs uintptr) int32 {
 137666 	bp := tls.Alloc(4)
 137667 	defer tls.Free(4)
 137668 
 137669 	var p uintptr = zIn
 137670 	var pRank uintptr
 137671 	var zRank uintptr = uintptr(0)
 137672 	var zRankArgs uintptr = uintptr(0)
 137673 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 137674 
 137675 	*(*uintptr)(unsafe.Pointer(pzRank)) = uintptr(0)
 137676 	*(*uintptr)(unsafe.Pointer(pzRankArgs)) = uintptr(0)
 137677 
 137678 	if p == uintptr(0) {
 137679 		*(*int32)(unsafe.Pointer(bp)) = SQLITE_ERROR
 137680 	} else {
 137681 		p = fts5ConfigSkipWhitespace(tls, p)
 137682 		pRank = p
 137683 		p = fts5ConfigSkipBareword(tls, p)
 137684 
 137685 		if p != 0 {
 137686 			zRank = sqlite3Fts5MallocZero(tls, bp, int64((int32(uintptr(1)+p)-int32(pRank))/1))
 137687 			if zRank != 0 {
 137688 				libc.Xmemcpy(tls, zRank, pRank, uint32((int32(p)-int32(pRank))/1))
 137689 			}
 137690 		} else {
 137691 			*(*int32)(unsafe.Pointer(bp)) = SQLITE_ERROR
 137692 		}
 137693 
 137694 		if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 137695 			p = fts5ConfigSkipWhitespace(tls, p)
 137696 			if int32(*(*uint8)(unsafe.Pointer(p))) != '(' {
 137697 				*(*int32)(unsafe.Pointer(bp)) = SQLITE_ERROR
 137698 			}
 137699 			p++
 137700 		}
 137701 		if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 137702 			var pArgs uintptr
 137703 			p = fts5ConfigSkipWhitespace(tls, p)
 137704 			pArgs = p
 137705 			if int32(*(*uint8)(unsafe.Pointer(p))) != ')' {
 137706 				p = fts5ConfigSkipArgs(tls, p)
 137707 				if p == uintptr(0) {
 137708 					*(*int32)(unsafe.Pointer(bp)) = SQLITE_ERROR
 137709 				} else {
 137710 					zRankArgs = sqlite3Fts5MallocZero(tls, bp, int64((int32(uintptr(1)+p)-int32(pArgs))/1))
 137711 					if zRankArgs != 0 {
 137712 						libc.Xmemcpy(tls, zRankArgs, pArgs, uint32((int32(p)-int32(pArgs))/1))
 137713 					}
 137714 				}
 137715 			}
 137716 		}
 137717 	}
 137718 
 137719 	if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
 137720 		Xsqlite3_free(tls, zRank)
 137721 
 137722 	} else {
 137723 		*(*uintptr)(unsafe.Pointer(pzRank)) = zRank
 137724 		*(*uintptr)(unsafe.Pointer(pzRankArgs)) = zRankArgs
 137725 	}
 137726 	return *(*int32)(unsafe.Pointer(bp))
 137727 }
 137728 
 137729 func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVal uintptr, pbBadkey uintptr) int32 {
 137730 	bp := tls.Alloc(8)
 137731 	defer tls.Free(8)
 137732 
 137733 	var rc int32 = SQLITE_OK
 137734 
 137735 	if 0 == Xsqlite3_stricmp(tls, zKey, ts+34523) {
 137736 		var pgsz int32 = 0
 137737 		if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) {
 137738 			pgsz = Xsqlite3_value_int(tls, pVal)
 137739 		}
 137740 		if pgsz < 32 || pgsz > 64*1024 {
 137741 			*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137742 		} else {
 137743 			(*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz = pgsz
 137744 		}
 137745 	} else if 0 == Xsqlite3_stricmp(tls, zKey, ts+34528) {
 137746 		var nHashSize int32 = -1
 137747 		if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) {
 137748 			nHashSize = Xsqlite3_value_int(tls, pVal)
 137749 		}
 137750 		if nHashSize <= 0 {
 137751 			*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137752 		} else {
 137753 			(*Fts5Config)(unsafe.Pointer(pConfig)).FnHashSize = nHashSize
 137754 		}
 137755 	} else if 0 == Xsqlite3_stricmp(tls, zKey, ts+34537) {
 137756 		var nAutomerge int32 = -1
 137757 		if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) {
 137758 			nAutomerge = Xsqlite3_value_int(tls, pVal)
 137759 		}
 137760 		if nAutomerge < 0 || nAutomerge > 64 {
 137761 			*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137762 		} else {
 137763 			if nAutomerge == 1 {
 137764 				nAutomerge = FTS5_DEFAULT_AUTOMERGE
 137765 			}
 137766 			(*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = nAutomerge
 137767 		}
 137768 	} else if 0 == Xsqlite3_stricmp(tls, zKey, ts+34547) {
 137769 		var nUsermerge int32 = -1
 137770 		if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) {
 137771 			nUsermerge = Xsqlite3_value_int(tls, pVal)
 137772 		}
 137773 		if nUsermerge < 2 || nUsermerge > 16 {
 137774 			*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137775 		} else {
 137776 			(*Fts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = nUsermerge
 137777 		}
 137778 	} else if 0 == Xsqlite3_stricmp(tls, zKey, ts+34557) {
 137779 		var nCrisisMerge int32 = -1
 137780 		if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) {
 137781 			nCrisisMerge = Xsqlite3_value_int(tls, pVal)
 137782 		}
 137783 		if nCrisisMerge < 0 {
 137784 			*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137785 		} else {
 137786 			if nCrisisMerge <= 1 {
 137787 				nCrisisMerge = FTS5_DEFAULT_CRISISMERGE
 137788 			}
 137789 			if nCrisisMerge >= FTS5_MAX_SEGMENT {
 137790 				nCrisisMerge = FTS5_MAX_SEGMENT - 1
 137791 			}
 137792 			(*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = nCrisisMerge
 137793 		}
 137794 	} else if 0 == Xsqlite3_stricmp(tls, zKey, ts+22238) {
 137795 		var zIn uintptr = Xsqlite3_value_text(tls, pVal)
 137796 
 137797 		rc = sqlite3Fts5ConfigParseRank(tls, zIn, bp, bp+4)
 137798 		if rc == SQLITE_OK {
 137799 			Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank)
 137800 			Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs)
 137801 			(*Fts5Config)(unsafe.Pointer(pConfig)).FzRank = *(*uintptr)(unsafe.Pointer(bp))
 137802 			(*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs = *(*uintptr)(unsafe.Pointer(bp + 4))
 137803 		} else if rc == SQLITE_ERROR {
 137804 			rc = SQLITE_OK
 137805 			*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137806 		}
 137807 	} else {
 137808 		*(*int32)(unsafe.Pointer(pbBadkey)) = 1
 137809 	}
 137810 	return rc
 137811 }
 137812 
 137813 func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 {
 137814 	bp := tls.Alloc(44)
 137815 	defer tls.Free(44)
 137816 
 137817 	var zSelect uintptr = ts + 34569
 137818 	var zSql uintptr
 137819 	*(*uintptr)(unsafe.Pointer(bp + 36)) = uintptr(0)
 137820 	*(*int32)(unsafe.Pointer(bp + 32)) = SQLITE_OK
 137821 	var iVersion int32 = 0
 137822 
 137823 	(*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz = FTS5_DEFAULT_PAGE_SIZE
 137824 	(*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = FTS5_DEFAULT_AUTOMERGE
 137825 	(*Fts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = FTS5_DEFAULT_USERMERGE
 137826 	(*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = FTS5_DEFAULT_CRISISMERGE
 137827 	(*Fts5Config)(unsafe.Pointer(pConfig)).FnHashSize = 1024 * 1024
 137828 
 137829 	zSql = sqlite3Fts5Mprintf(tls, bp+32, zSelect, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 137830 	if zSql != 0 {
 137831 		*(*int32)(unsafe.Pointer(bp + 32)) = Xsqlite3_prepare_v2(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, bp+36, uintptr(0))
 137832 		Xsqlite3_free(tls, zSql)
 137833 	}
 137834 
 137835 	if *(*int32)(unsafe.Pointer(bp + 32)) == SQLITE_OK {
 137836 		for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 36))) {
 137837 			var zK uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 36)), 0)
 137838 			var pVal uintptr = Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 36)), 1)
 137839 			if 0 == Xsqlite3_stricmp(tls, zK, ts+34601) {
 137840 				iVersion = Xsqlite3_value_int(tls, pVal)
 137841 			} else {
 137842 				*(*int32)(unsafe.Pointer(bp + 40)) = 0
 137843 				sqlite3Fts5ConfigSetValue(tls, pConfig, zK, pVal, bp+40)
 137844 			}
 137845 		}
 137846 		*(*int32)(unsafe.Pointer(bp + 32)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 36)))
 137847 	}
 137848 
 137849 	if *(*int32)(unsafe.Pointer(bp + 32)) == SQLITE_OK && iVersion != FTS5_CURRENT_VERSION {
 137850 		*(*int32)(unsafe.Pointer(bp + 32)) = SQLITE_ERROR
 137851 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg != 0 {
 137852 			*(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls,
 137853 				ts+34609,
 137854 				libc.VaList(bp+16, iVersion, FTS5_CURRENT_VERSION))
 137855 		}
 137856 	}
 137857 
 137858 	if *(*int32)(unsafe.Pointer(bp + 32)) == SQLITE_OK {
 137859 		(*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie = iCookie
 137860 	}
 137861 	return *(*int32)(unsafe.Pointer(bp + 32))
 137862 }
 137863 
 137864 type Fts5ExprTerm1 = struct {
 137865 	FbPrefix     U8
 137866 	FbFirst      U8
 137867 	F__ccgo_pad1 [2]byte
 137868 	FzTerm       uintptr
 137869 	FpIter       uintptr
 137870 	FpSynonym    uintptr
 137871 }
 137872 
 137873 type Fts5ExprTerm = Fts5ExprTerm1
 137874 
 137875 func sqlite3Fts5ParseError(tls *libc.TLS, pParse uintptr, zFmt uintptr, va uintptr) {
 137876 	var ap Va_list
 137877 	_ = ap
 137878 	ap = va
 137879 	if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK {
 137880 		(*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_vmprintf(tls, zFmt, ap)
 137881 		(*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR
 137882 	}
 137883 	_ = ap
 137884 }
 137885 
 137886 func fts5ExprIsspace(tls *libc.TLS, t uint8) int32 {
 137887 	return libc.Bool32(int32(t) == ' ' || int32(t) == '\t' || int32(t) == '\n' || int32(t) == '\r')
 137888 }
 137889 
 137890 func fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) int32 {
 137891 	bp := tls.Alloc(8)
 137892 	defer tls.Free(8)
 137893 
 137894 	var z uintptr = *(*uintptr)(unsafe.Pointer(pz))
 137895 	var tok int32
 137896 
 137897 	for fts5ExprIsspace(tls, *(*uint8)(unsafe.Pointer(z))) != 0 {
 137898 		z++
 137899 	}
 137900 
 137901 	(*Fts5Token)(unsafe.Pointer(pToken)).Fp = z
 137902 	(*Fts5Token)(unsafe.Pointer(pToken)).Fn = 1
 137903 	switch int32(*(*uint8)(unsafe.Pointer(z))) {
 137904 	case '(':
 137905 		tok = FTS5_LP
 137906 		break
 137907 	case ')':
 137908 		tok = FTS5_RP
 137909 		break
 137910 	case '{':
 137911 		tok = FTS5_LCP
 137912 		break
 137913 	case '}':
 137914 		tok = FTS5_RCP
 137915 		break
 137916 	case ':':
 137917 		tok = FTS5_COLON
 137918 		break
 137919 	case ',':
 137920 		tok = FTS5_COMMA
 137921 		break
 137922 	case '+':
 137923 		tok = FTS5_PLUS
 137924 		break
 137925 	case '*':
 137926 		tok = FTS5_STAR
 137927 		break
 137928 	case '-':
 137929 		tok = FTS5_MINUS
 137930 		break
 137931 	case '^':
 137932 		tok = FTS5_CARET
 137933 		break
 137934 	case 0:
 137935 		tok = FTS5_EOF
 137936 		break
 137937 
 137938 	case '"':
 137939 		{
 137940 			var z2 uintptr
 137941 			tok = FTS5_STRING
 137942 
 137943 			for z2 = z + 1; 1 != 0; z2++ {
 137944 				if int32(*(*uint8)(unsafe.Pointer(z2))) == '"' {
 137945 					z2++
 137946 					if int32(*(*uint8)(unsafe.Pointer(z2))) != '"' {
 137947 						break
 137948 					}
 137949 				}
 137950 				if int32(*(*uint8)(unsafe.Pointer(z2))) == 0 {
 137951 					sqlite3Fts5ParseError(tls, pParse, ts+34674, 0)
 137952 					return FTS5_EOF
 137953 				}
 137954 			}
 137955 			(*Fts5Token)(unsafe.Pointer(pToken)).Fn = (int32(z2) - int32(z)) / 1
 137956 			break
 137957 
 137958 		}
 137959 
 137960 	default:
 137961 		{
 137962 			var z2 uintptr
 137963 			if sqlite3Fts5IsBareword(tls, *(*uint8)(unsafe.Pointer(z))) == 0 {
 137964 				sqlite3Fts5ParseError(tls, pParse, ts+34694, libc.VaList(bp, z))
 137965 				return FTS5_EOF
 137966 			}
 137967 			tok = FTS5_STRING
 137968 			for z2 = z + 1; sqlite3Fts5IsBareword(tls, *(*uint8)(unsafe.Pointer(z2))) != 0; z2++ {
 137969 			}
 137970 			(*Fts5Token)(unsafe.Pointer(pToken)).Fn = (int32(z2) - int32(z)) / 1
 137971 			if (*Fts5Token)(unsafe.Pointer(pToken)).Fn == 2 && libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+34725, uint32(2)) == 0 {
 137972 				tok = FTS5_OR
 137973 			}
 137974 			if (*Fts5Token)(unsafe.Pointer(pToken)).Fn == 3 && libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+34728, uint32(3)) == 0 {
 137975 				tok = FTS5_NOT
 137976 			}
 137977 			if (*Fts5Token)(unsafe.Pointer(pToken)).Fn == 3 && libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+30110, uint32(3)) == 0 {
 137978 				tok = FTS5_AND
 137979 			}
 137980 			break
 137981 
 137982 		}
 137983 	}
 137984 
 137985 	*(*uintptr)(unsafe.Pointer(pz)) = (*Fts5Token)(unsafe.Pointer(pToken)).Fp + uintptr((*Fts5Token)(unsafe.Pointer(pToken)).Fn)
 137986 	return tok
 137987 }
 137988 
 137989 func fts5ParseAlloc(tls *libc.TLS, t U64) uintptr {
 137990 	return Xsqlite3_malloc64(tls, uint64(Sqlite3_int64(t)))
 137991 }
 137992 
 137993 func fts5ParseFree(tls *libc.TLS, p uintptr) {
 137994 	Xsqlite3_free(tls, p)
 137995 }
 137996 
 137997 func sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, bPhraseToAnd int32, iCol int32, zExpr uintptr, ppNew uintptr, pzErr uintptr) int32 {
 137998 	bp := tls.Alloc(40)
 137999 	defer tls.Free(40)
 138000 
 138001 	*(*uintptr)(unsafe.Pointer(bp + 28)) = zExpr
 138002 	var t int32
 138003 	var pEngine uintptr
 138004 	var pNew uintptr
 138005 
 138006 	*(*uintptr)(unsafe.Pointer(ppNew)) = uintptr(0)
 138007 	*(*uintptr)(unsafe.Pointer(pzErr)) = uintptr(0)
 138008 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Parse{})))
 138009 	(*Fts5Parse)(unsafe.Pointer(bp)).FbPhraseToAnd = bPhraseToAnd
 138010 	pEngine = sqlite3Fts5ParserAlloc(tls, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, U64) uintptr }{fts5ParseAlloc})))
 138011 	if pEngine == uintptr(0) {
 138012 		return SQLITE_NOMEM
 138013 	}
 138014 	(*Fts5Parse)(unsafe.Pointer(bp)).FpConfig = pConfig
 138015 
 138016 	for __ccgo := true; __ccgo; __ccgo = (*Fts5Parse)(unsafe.Pointer(bp)).Frc == SQLITE_OK && t != FTS5_EOF {
 138017 		t = fts5ExprGetToken(tls, bp, bp+28, bp+32)
 138018 		sqlite3Fts5Parser(tls, pEngine, t, *(*Fts5Token)(unsafe.Pointer(bp + 32)), bp)
 138019 	}
 138020 	sqlite3Fts5ParserFree(tls, pEngine, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5ParseFree})))
 138021 
 138022 	if iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol && (*Fts5Parse)(unsafe.Pointer(bp)).FpExpr != 0 && (*Fts5Parse)(unsafe.Pointer(bp)).Frc == SQLITE_OK {
 138023 		var n int32 = int32(unsafe.Sizeof(Fts5Colset{}))
 138024 		var pColset uintptr = sqlite3Fts5MallocZero(tls, bp+8, int64(n))
 138025 		if pColset != 0 {
 138026 			(*Fts5Colset)(unsafe.Pointer(pColset)).FnCol = 1
 138027 			*(*int32)(unsafe.Pointer(pColset + 4)) = iCol
 138028 			sqlite3Fts5ParseSetColset(tls, bp, (*Fts5Parse)(unsafe.Pointer(bp)).FpExpr, pColset)
 138029 		}
 138030 	}
 138031 
 138032 	if (*Fts5Parse)(unsafe.Pointer(bp)).Frc == SQLITE_OK {
 138033 		*(*uintptr)(unsafe.Pointer(ppNew)) = libc.AssignUintptr(&pNew, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Expr{}))))
 138034 		if pNew == uintptr(0) {
 138035 			(*Fts5Parse)(unsafe.Pointer(bp)).Frc = SQLITE_NOMEM
 138036 			sqlite3Fts5ParseNodeFree(tls, (*Fts5Parse)(unsafe.Pointer(bp)).FpExpr)
 138037 		} else {
 138038 			if !(int32((*Fts5Parse)(unsafe.Pointer(bp)).FpExpr) != 0) {
 138039 				var nByte int32 = int32(unsafe.Sizeof(Fts5ExprNode{}))
 138040 				(*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot = sqlite3Fts5MallocZero(tls, bp+8, int64(nByte))
 138041 				if (*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot != 0 {
 138042 					(*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FbEof = 1
 138043 				}
 138044 			} else {
 138045 				(*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot = (*Fts5Parse)(unsafe.Pointer(bp)).FpExpr
 138046 			}
 138047 			(*Fts5Expr)(unsafe.Pointer(pNew)).FpIndex = uintptr(0)
 138048 			(*Fts5Expr)(unsafe.Pointer(pNew)).FpConfig = pConfig
 138049 			(*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = (*Fts5Parse)(unsafe.Pointer(bp)).FapPhrase
 138050 			(*Fts5Expr)(unsafe.Pointer(pNew)).FnPhrase = (*Fts5Parse)(unsafe.Pointer(bp)).FnPhrase
 138051 			(*Fts5Expr)(unsafe.Pointer(pNew)).FbDesc = 0
 138052 			(*Fts5Parse)(unsafe.Pointer(bp)).FapPhrase = uintptr(0)
 138053 		}
 138054 	} else {
 138055 		sqlite3Fts5ParseNodeFree(tls, (*Fts5Parse)(unsafe.Pointer(bp)).FpExpr)
 138056 	}
 138057 
 138058 	Xsqlite3_free(tls, (*Fts5Parse)(unsafe.Pointer(bp)).FapPhrase)
 138059 	*(*uintptr)(unsafe.Pointer(pzErr)) = (*Fts5Parse)(unsafe.Pointer(bp)).FzErr
 138060 	return (*Fts5Parse)(unsafe.Pointer(bp)).Frc
 138061 }
 138062 
 138063 func fts5ExprCountChar(tls *libc.TLS, z uintptr, nByte int32) int32 {
 138064 	var nRet int32 = 0
 138065 	var ii int32
 138066 	for ii = 0; ii < nByte; ii++ {
 138067 		if int32(*(*uint8)(unsafe.Pointer(z + uintptr(ii))))&0xC0 != 0x80 {
 138068 			nRet++
 138069 		}
 138070 	}
 138071 	return nRet
 138072 }
 138073 
 138074 func sqlite3Fts5ExprPattern(tls *libc.TLS, pConfig uintptr, bGlob int32, iCol int32, zText uintptr, pp uintptr) int32 {
 138075 	bp := tls.Alloc(3)
 138076 	defer tls.Free(3)
 138077 
 138078 	var nText I64 = I64(libc.Xstrlen(tls, zText))
 138079 	var zExpr uintptr = Xsqlite3_malloc64(tls, uint64(nText*int64(4)+int64(1)))
 138080 	var rc int32 = SQLITE_OK
 138081 
 138082 	if zExpr == uintptr(0) {
 138083 		rc = SQLITE_NOMEM
 138084 	} else {
 138085 		var iOut int32 = 0
 138086 		var i int32 = 0
 138087 		var iFirst int32 = 0
 138088 
 138089 		if bGlob == 0 {
 138090 			*(*uint8)(unsafe.Pointer(bp)) = uint8('_')
 138091 			*(*uint8)(unsafe.Pointer(bp + 1)) = uint8('%')
 138092 			*(*uint8)(unsafe.Pointer(bp + 2)) = uint8(0)
 138093 		} else {
 138094 			*(*uint8)(unsafe.Pointer(bp)) = uint8('*')
 138095 			*(*uint8)(unsafe.Pointer(bp + 1)) = uint8('?')
 138096 			*(*uint8)(unsafe.Pointer(bp + 2)) = uint8('[')
 138097 		}
 138098 
 138099 		for I64(i) <= nText {
 138100 			if I64(i) == nText ||
 138101 				int32(*(*uint8)(unsafe.Pointer(zText + uintptr(i)))) == int32(*(*uint8)(unsafe.Pointer(bp))) || int32(*(*uint8)(unsafe.Pointer(zText + uintptr(i)))) == int32(*(*uint8)(unsafe.Pointer(bp + 1))) || int32(*(*uint8)(unsafe.Pointer(zText + uintptr(i)))) == int32(*(*uint8)(unsafe.Pointer(bp + 2))) {
 138102 				if fts5ExprCountChar(tls, zText+uintptr(iFirst), i-iFirst) >= 3 {
 138103 					var jj int32
 138104 					*(*uint8)(unsafe.Pointer(zExpr + uintptr(libc.PostIncInt32(&iOut, 1)))) = uint8('"')
 138105 					for jj = iFirst; jj < i; jj++ {
 138106 						*(*uint8)(unsafe.Pointer(zExpr + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*uint8)(unsafe.Pointer(zText + uintptr(jj)))
 138107 						if int32(*(*uint8)(unsafe.Pointer(zText + uintptr(jj)))) == '"' {
 138108 							*(*uint8)(unsafe.Pointer(zExpr + uintptr(libc.PostIncInt32(&iOut, 1)))) = uint8('"')
 138109 						}
 138110 					}
 138111 					*(*uint8)(unsafe.Pointer(zExpr + uintptr(libc.PostIncInt32(&iOut, 1)))) = uint8('"')
 138112 					*(*uint8)(unsafe.Pointer(zExpr + uintptr(libc.PostIncInt32(&iOut, 1)))) = uint8(' ')
 138113 				}
 138114 				if int32(*(*uint8)(unsafe.Pointer(zText + uintptr(i)))) == int32(*(*uint8)(unsafe.Pointer(bp + 2))) {
 138115 					i = i + 2
 138116 					if int32(*(*uint8)(unsafe.Pointer(zText + uintptr(i-1)))) == '^' {
 138117 						i++
 138118 					}
 138119 					for I64(i) < nText && int32(*(*uint8)(unsafe.Pointer(zText + uintptr(i)))) != ']' {
 138120 						i++
 138121 					}
 138122 				}
 138123 				iFirst = i + 1
 138124 			}
 138125 			i++
 138126 		}
 138127 		if iOut > 0 {
 138128 			var bAnd int32 = 0
 138129 			if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL {
 138130 				bAnd = 1
 138131 				if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE {
 138132 					iCol = (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol
 138133 				}
 138134 			}
 138135 			*(*uint8)(unsafe.Pointer(zExpr + uintptr(iOut))) = uint8(0)
 138136 			rc = sqlite3Fts5ExprNew(tls, pConfig, bAnd, iCol, zExpr, pp, (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)
 138137 		} else {
 138138 			*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 138139 		}
 138140 		Xsqlite3_free(tls, zExpr)
 138141 	}
 138142 
 138143 	return rc
 138144 }
 138145 
 138146 func sqlite3Fts5ParseNodeFree(tls *libc.TLS, p uintptr) {
 138147 	if p != 0 {
 138148 		var i int32
 138149 		for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(p)).FnChild; i++ {
 138150 			sqlite3Fts5ParseNodeFree(tls, *(*uintptr)(unsafe.Pointer(p + 32 + uintptr(i)*4)))
 138151 		}
 138152 		sqlite3Fts5ParseNearsetFree(tls, (*Fts5ExprNode)(unsafe.Pointer(p)).FpNear)
 138153 		Xsqlite3_free(tls, p)
 138154 	}
 138155 }
 138156 
 138157 func sqlite3Fts5ExprFree(tls *libc.TLS, p uintptr) {
 138158 	if p != 0 {
 138159 		sqlite3Fts5ParseNodeFree(tls, (*Fts5Expr)(unsafe.Pointer(p)).FpRoot)
 138160 		Xsqlite3_free(tls, (*Fts5Expr)(unsafe.Pointer(p)).FapExprPhrase)
 138161 		Xsqlite3_free(tls, p)
 138162 	}
 138163 }
 138164 
 138165 func sqlite3Fts5ExprAnd(tls *libc.TLS, pp1 uintptr, p2 uintptr) int32 {
 138166 	bp := tls.Alloc(28)
 138167 	defer tls.Free(28)
 138168 
 138169 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Parse{})))
 138170 
 138171 	if *(*uintptr)(unsafe.Pointer(pp1)) != 0 {
 138172 		var p1 uintptr = *(*uintptr)(unsafe.Pointer(pp1))
 138173 		var nPhrase int32 = (*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase + (*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase
 138174 
 138175 		(*Fts5Expr)(unsafe.Pointer(p1)).FpRoot = sqlite3Fts5ParseNode(tls, bp, FTS5_AND, (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot, (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot, uintptr(0))
 138176 		(*Fts5Expr)(unsafe.Pointer(p2)).FpRoot = uintptr(0)
 138177 
 138178 		if (*Fts5Parse)(unsafe.Pointer(bp)).Frc == SQLITE_OK {
 138179 			var ap uintptr = Xsqlite3_realloc(tls,
 138180 				(*Fts5Expr)(unsafe.Pointer(p1)).FapExprPhrase, int32(uint32(nPhrase)*uint32(unsafe.Sizeof(uintptr(0)))))
 138181 			if ap == uintptr(0) {
 138182 				(*Fts5Parse)(unsafe.Pointer(bp)).Frc = SQLITE_NOMEM
 138183 			} else {
 138184 				var i int32
 138185 				libc.Xmemmove(tls, ap+uintptr((*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase)*4, ap, uint32((*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase)*uint32(unsafe.Sizeof(uintptr(0))))
 138186 				for i = 0; i < (*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase; i++ {
 138187 					*(*uintptr)(unsafe.Pointer(ap + uintptr(i)*4)) = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(p2)).FapExprPhrase + uintptr(i)*4))
 138188 				}
 138189 				(*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase = nPhrase
 138190 				(*Fts5Expr)(unsafe.Pointer(p1)).FapExprPhrase = ap
 138191 			}
 138192 		}
 138193 		Xsqlite3_free(tls, (*Fts5Expr)(unsafe.Pointer(p2)).FapExprPhrase)
 138194 		Xsqlite3_free(tls, p2)
 138195 	} else {
 138196 		*(*uintptr)(unsafe.Pointer(pp1)) = p2
 138197 	}
 138198 
 138199 	return (*Fts5Parse)(unsafe.Pointer(bp)).Frc
 138200 }
 138201 
 138202 func fts5ExprSynonymRowid(tls *libc.TLS, pTerm uintptr, bDesc int32, pbEof uintptr) I64 {
 138203 	var iRet I64 = int64(0)
 138204 	var bRetValid int32 = 0
 138205 	var p uintptr
 138206 
 138207 	for p = pTerm; p != 0; p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym {
 138208 		if 0 == int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) {
 138209 			var iRowid I64 = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid
 138210 			if bRetValid == 0 || bDesc != libc.Bool32(iRowid < iRet) {
 138211 				iRet = iRowid
 138212 				bRetValid = 1
 138213 			}
 138214 		}
 138215 	}
 138216 
 138217 	if pbEof != 0 && bRetValid == 0 {
 138218 		*(*int32)(unsafe.Pointer(pbEof)) = 1
 138219 	}
 138220 	return iRet
 138221 }
 138222 
 138223 func fts5ExprSynonymList(tls *libc.TLS, pTerm uintptr, iRowid I64, pBuf uintptr, pa uintptr, pn uintptr) int32 {
 138224 	bp := tls.Alloc(104)
 138225 	defer tls.Free(104)
 138226 
 138227 	var aIter uintptr
 138228 	var nIter int32
 138229 	var nAlloc int32
 138230 	var rc int32
 138231 	var p uintptr
 138232 	var nByte Sqlite3_int64
 138233 	var aNew uintptr
 138234 	var pIter uintptr
 138235 	var i int32
 138236 	var iMin I64
 138237 
 138238 	var iPrev I64
 138239 	aIter = bp
 138240 	nIter = 0
 138241 	nAlloc = 4
 138242 	rc = SQLITE_OK
 138243 
 138244 	p = pTerm
 138245 __1:
 138246 	if !(p != 0) {
 138247 		goto __3
 138248 	}
 138249 	pIter = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter
 138250 	if !(int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 && (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == iRowid) {
 138251 		goto __4
 138252 	}
 138253 	if !((*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData == 0) {
 138254 		goto __5
 138255 	}
 138256 	goto __2
 138257 __5:
 138258 	;
 138259 	if !(nIter == nAlloc) {
 138260 		goto __6
 138261 	}
 138262 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5PoslistReader{})) * uint32(nAlloc) * uint32(2))
 138263 	aNew = Xsqlite3_malloc64(tls, uint64(nByte))
 138264 	if !(aNew == uintptr(0)) {
 138265 		goto __7
 138266 	}
 138267 	rc = SQLITE_NOMEM
 138268 	goto synonym_poslist_out
 138269 __7:
 138270 	;
 138271 	libc.Xmemcpy(tls, aNew, aIter, uint32(unsafe.Sizeof(Fts5PoslistReader{}))*uint32(nIter))
 138272 	nAlloc = nAlloc * 2
 138273 	if !(aIter != bp) {
 138274 		goto __8
 138275 	}
 138276 	Xsqlite3_free(tls, aIter)
 138277 __8:
 138278 	;
 138279 	aIter = aNew
 138280 __6:
 138281 	;
 138282 	sqlite3Fts5PoslistReaderInit(tls, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, aIter+uintptr(nIter)*24)
 138283 
 138284 	nIter++
 138285 __4:
 138286 	;
 138287 	goto __2
 138288 __2:
 138289 	p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym
 138290 	goto __1
 138291 	goto __3
 138292 __3:
 138293 	;
 138294 	if !(nIter == 1) {
 138295 		goto __9
 138296 	}
 138297 	*(*uintptr)(unsafe.Pointer(pa)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).Fa
 138298 	*(*int32)(unsafe.Pointer(pn)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).Fn
 138299 	goto __10
 138300 __9:
 138301 	*(*Fts5PoslistWriter)(unsafe.Pointer(bp + 96)) = Fts5PoslistWriter{}
 138302 	iPrev = int64(-1)
 138303 	sqlite3Fts5BufferZero(tls, pBuf)
 138304 __11:
 138305 	if !(1 != 0) {
 138306 		goto __12
 138307 	}
 138308 	iMin = int64(0xffffffff) | int64(0x7fffffff)<<32
 138309 	i = 0
 138310 __13:
 138311 	if !(i < nIter) {
 138312 		goto __15
 138313 	}
 138314 	if !(int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FbEof) == 0) {
 138315 		goto __16
 138316 	}
 138317 	if !((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FiPos == iPrev) {
 138318 		goto __17
 138319 	}
 138320 	if !(sqlite3Fts5PoslistReaderNext(tls, aIter+uintptr(i)*24) != 0) {
 138321 		goto __18
 138322 	}
 138323 	goto __14
 138324 __18:
 138325 	;
 138326 __17:
 138327 	;
 138328 	if !((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FiPos < iMin) {
 138329 		goto __19
 138330 	}
 138331 	iMin = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(i)*24)).FiPos
 138332 __19:
 138333 	;
 138334 __16:
 138335 	;
 138336 	goto __14
 138337 __14:
 138338 	i++
 138339 	goto __13
 138340 	goto __15
 138341 __15:
 138342 	;
 138343 	if !(iMin == int64(0xffffffff)|int64(0x7fffffff)<<32 || rc != SQLITE_OK) {
 138344 		goto __20
 138345 	}
 138346 	goto __12
 138347 __20:
 138348 	;
 138349 	rc = sqlite3Fts5PoslistWriterAppend(tls, pBuf, bp+96, iMin)
 138350 	iPrev = iMin
 138351 	goto __11
 138352 __12:
 138353 	;
 138354 	if !(rc == SQLITE_OK) {
 138355 		goto __21
 138356 	}
 138357 	*(*uintptr)(unsafe.Pointer(pa)) = (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp
 138358 	*(*int32)(unsafe.Pointer(pn)) = (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn
 138359 __21:
 138360 	;
 138361 __10:
 138362 	;
 138363 synonym_poslist_out:
 138364 	if !(aIter != bp) {
 138365 		goto __22
 138366 	}
 138367 	Xsqlite3_free(tls, aIter)
 138368 __22:
 138369 	;
 138370 	return rc
 138371 }
 138372 
 138373 func fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatch uintptr) int32 {
 138374 	bp := tls.Alloc(128)
 138375 	defer tls.Free(128)
 138376 
 138377 	var aIter uintptr
 138378 	var i int32
 138379 	var rc int32
 138380 	var bFirst int32
 138381 	var nByte Sqlite3_int64
 138382 
 138383 	var pTerm uintptr
 138384 
 138385 	var bFlag int32
 138386 
 138387 	var pPos uintptr
 138388 	var iAdj I64
 138389 	var bMatch int32
 138390 	var iPos I64
 138391 	*(*Fts5PoslistWriter)(unsafe.Pointer(bp + 120)) = Fts5PoslistWriter{}
 138392 	aIter = bp
 138393 	rc = SQLITE_OK
 138394 	bFirst = int32((*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FbFirst)
 138395 
 138396 	sqlite3Fts5BufferZero(tls, pPhrase+4)
 138397 
 138398 	if !((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > int32(uint32(unsafe.Sizeof([4]Fts5PoslistReader{}))/uint32(unsafe.Sizeof(Fts5PoslistReader{})))) {
 138399 		goto __1
 138400 	}
 138401 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5PoslistReader{})) * uint32((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm))
 138402 	aIter = Xsqlite3_malloc64(tls, uint64(nByte))
 138403 	if !!(aIter != 0) {
 138404 		goto __2
 138405 	}
 138406 	return SQLITE_NOMEM
 138407 __2:
 138408 	;
 138409 __1:
 138410 	;
 138411 	libc.Xmemset(tls, aIter, 0, uint32(unsafe.Sizeof(Fts5PoslistReader{}))*uint32((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm))
 138412 
 138413 	i = 0
 138414 __3:
 138415 	if !(i < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) {
 138416 		goto __5
 138417 	}
 138418 	pTerm = pPhrase + 20 + uintptr(i)*16
 138419 	*(*int32)(unsafe.Pointer(bp + 112)) = 0
 138420 	bFlag = 0
 138421 	*(*uintptr)(unsafe.Pointer(bp + 108)) = uintptr(0)
 138422 	if !((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0) {
 138423 		goto __6
 138424 	}
 138425 	*(*Fts5Buffer)(unsafe.Pointer(bp + 96)) = Fts5Buffer{}
 138426 	rc = fts5ExprSynonymList(tls, pTerm, (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, bp+96, bp+108, bp+112)
 138427 	if !(rc != 0) {
 138428 		goto __8
 138429 	}
 138430 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 108)))
 138431 	goto ismatch_out
 138432 __8:
 138433 	;
 138434 	if !(*(*uintptr)(unsafe.Pointer(bp + 108)) == (*Fts5Buffer)(unsafe.Pointer(bp+96)).Fp) {
 138435 		goto __9
 138436 	}
 138437 	bFlag = 1
 138438 __9:
 138439 	;
 138440 	goto __7
 138441 __6:
 138442 	*(*uintptr)(unsafe.Pointer(bp + 108)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)).FpData
 138443 	*(*int32)(unsafe.Pointer(bp + 112)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)).FnData
 138444 __7:
 138445 	;
 138446 	sqlite3Fts5PoslistReaderInit(tls, *(*uintptr)(unsafe.Pointer(bp + 108)), *(*int32)(unsafe.Pointer(bp + 112)), aIter+uintptr(i)*24)
 138447 	(*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(i)*24)).FbFlag = U8(bFlag)
 138448 	if !((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FbEof != 0) {
 138449 		goto __10
 138450 	}
 138451 	goto ismatch_out
 138452 __10:
 138453 	;
 138454 	goto __4
 138455 __4:
 138456 	i++
 138457 	goto __3
 138458 	goto __5
 138459 __5:
 138460 	;
 138461 __11:
 138462 	if !(1 != 0) {
 138463 		goto __12
 138464 	}
 138465 	iPos = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).FiPos
 138466 __13:
 138467 	bMatch = 1
 138468 	i = 0
 138469 __16:
 138470 	if !(i < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) {
 138471 		goto __18
 138472 	}
 138473 	pPos = aIter + uintptr(i)*24
 138474 	iAdj = iPos + I64(i)
 138475 	if !((*Fts5PoslistReader)(unsafe.Pointer(pPos)).FiPos != iAdj) {
 138476 		goto __19
 138477 	}
 138478 	bMatch = 0
 138479 __20:
 138480 	if !((*Fts5PoslistReader)(unsafe.Pointer(pPos)).FiPos < iAdj) {
 138481 		goto __21
 138482 	}
 138483 	if !(sqlite3Fts5PoslistReaderNext(tls, pPos) != 0) {
 138484 		goto __22
 138485 	}
 138486 	goto ismatch_out
 138487 __22:
 138488 	;
 138489 	goto __20
 138490 __21:
 138491 	;
 138492 	if !((*Fts5PoslistReader)(unsafe.Pointer(pPos)).FiPos > iAdj) {
 138493 		goto __23
 138494 	}
 138495 	iPos = (*Fts5PoslistReader)(unsafe.Pointer(pPos)).FiPos - I64(i)
 138496 __23:
 138497 	;
 138498 __19:
 138499 	;
 138500 	goto __17
 138501 __17:
 138502 	i++
 138503 	goto __16
 138504 	goto __18
 138505 __18:
 138506 	;
 138507 	goto __14
 138508 __14:
 138509 	if bMatch == 0 {
 138510 		goto __13
 138511 	}
 138512 	goto __15
 138513 __15:
 138514 	;
 138515 	if !(bFirst == 0 || int32(iPos&int64(0x7FFFFFFF)) == 0) {
 138516 		goto __24
 138517 	}
 138518 	rc = sqlite3Fts5PoslistWriterAppend(tls, pPhrase+4, bp+120, iPos)
 138519 	if !(rc != SQLITE_OK) {
 138520 		goto __25
 138521 	}
 138522 	goto ismatch_out
 138523 __25:
 138524 	;
 138525 __24:
 138526 	;
 138527 	i = 0
 138528 __26:
 138529 	if !(i < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) {
 138530 		goto __28
 138531 	}
 138532 	if !(sqlite3Fts5PoslistReaderNext(tls, aIter+uintptr(i)*24) != 0) {
 138533 		goto __29
 138534 	}
 138535 	goto ismatch_out
 138536 __29:
 138537 	;
 138538 	goto __27
 138539 __27:
 138540 	i++
 138541 	goto __26
 138542 	goto __28
 138543 __28:
 138544 	;
 138545 	goto __11
 138546 __12:
 138547 	;
 138548 ismatch_out:
 138549 	*(*int32)(unsafe.Pointer(pbMatch)) = libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0)
 138550 	i = 0
 138551 __30:
 138552 	if !(i < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm) {
 138553 		goto __32
 138554 	}
 138555 	if !((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FbFlag != 0) {
 138556 		goto __33
 138557 	}
 138558 	Xsqlite3_free(tls, (*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).Fa)
 138559 __33:
 138560 	;
 138561 	goto __31
 138562 __31:
 138563 	i++
 138564 	goto __30
 138565 	goto __32
 138566 __32:
 138567 	;
 138568 	if !(aIter != bp) {
 138569 		goto __34
 138570 	}
 138571 	Xsqlite3_free(tls, aIter)
 138572 __34:
 138573 	;
 138574 	return rc
 138575 }
 138576 
 138577 type Fts5LookaheadReader1 = struct {
 138578 	Fa           uintptr
 138579 	Fn           int32
 138580 	Fi           int32
 138581 	F__ccgo_pad1 [4]byte
 138582 	FiPos        I64
 138583 	FiLookahead  I64
 138584 }
 138585 
 138586 type Fts5LookaheadReader = Fts5LookaheadReader1
 138587 
 138588 func fts5LookaheadReaderNext(tls *libc.TLS, p uintptr) int32 {
 138589 	(*Fts5LookaheadReader)(unsafe.Pointer(p)).FiPos = (*Fts5LookaheadReader)(unsafe.Pointer(p)).FiLookahead
 138590 	if sqlite3Fts5PoslistNext64(tls, (*Fts5LookaheadReader)(unsafe.Pointer(p)).Fa, (*Fts5LookaheadReader)(unsafe.Pointer(p)).Fn, p+8, p+24) != 0 {
 138591 		(*Fts5LookaheadReader)(unsafe.Pointer(p)).FiLookahead = int64(1) << 62
 138592 	}
 138593 	return libc.Bool32((*Fts5LookaheadReader)(unsafe.Pointer(p)).FiPos == int64(1)<<62)
 138594 }
 138595 
 138596 func fts5LookaheadReaderInit(tls *libc.TLS, a uintptr, n int32, p uintptr) int32 {
 138597 	libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(Fts5LookaheadReader{})))
 138598 	(*Fts5LookaheadReader)(unsafe.Pointer(p)).Fa = a
 138599 	(*Fts5LookaheadReader)(unsafe.Pointer(p)).Fn = n
 138600 	fts5LookaheadReaderNext(tls, p)
 138601 	return fts5LookaheadReaderNext(tls, p)
 138602 }
 138603 
 138604 type Fts5NearTrimmer1 = struct {
 138605 	Freader      Fts5LookaheadReader
 138606 	Fwriter      Fts5PoslistWriter
 138607 	FpOut        uintptr
 138608 	F__ccgo_pad1 [4]byte
 138609 }
 138610 
 138611 type Fts5NearTrimmer = Fts5NearTrimmer1
 138612 
 138613 func fts5ExprNearIsMatch(tls *libc.TLS, pRc uintptr, pNear uintptr) int32 {
 138614 	bp := tls.Alloc(196)
 138615 	defer tls.Free(196)
 138616 
 138617 	var a uintptr
 138618 	var apPhrase uintptr
 138619 	var i int32
 138620 
 138621 	var bMatch int32
 138622 	var nByte Sqlite3_int64
 138623 	var pPoslist uintptr
 138624 	var pPos uintptr
 138625 	var iPos I64
 138626 	var pWriter uintptr
 138627 	var iAdv int32
 138628 	var iMin I64
 138629 	var iMax I64
 138630 	var bRet int32
 138631 	a = bp
 138632 	apPhrase = pNear + 12
 138633 	*(*int32)(unsafe.Pointer(bp + 192)) = *(*int32)(unsafe.Pointer(pRc))
 138634 
 138635 	if !((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase > int32(uint32(unsafe.Sizeof([4]Fts5NearTrimmer{}))/uint32(unsafe.Sizeof(Fts5NearTrimmer{})))) {
 138636 		goto __1
 138637 	}
 138638 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5NearTrimmer{})) * uint32((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase))
 138639 	a = sqlite3Fts5MallocZero(tls, bp+192, nByte)
 138640 	goto __2
 138641 __1:
 138642 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([4]Fts5NearTrimmer{})))
 138643 __2:
 138644 	;
 138645 	if !(*(*int32)(unsafe.Pointer(bp + 192)) != SQLITE_OK) {
 138646 		goto __3
 138647 	}
 138648 	*(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 192))
 138649 	return 0
 138650 __3:
 138651 	;
 138652 	i = 0
 138653 __4:
 138654 	if !(i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) {
 138655 		goto __6
 138656 	}
 138657 	pPoslist = *(*uintptr)(unsafe.Pointer(apPhrase + uintptr(i)*4)) + 4
 138658 	fts5LookaheadReaderInit(tls, (*Fts5Buffer)(unsafe.Pointer(pPoslist)).Fp, (*Fts5Buffer)(unsafe.Pointer(pPoslist)).Fn, a+uintptr(i)*48)
 138659 	(*Fts5Buffer)(unsafe.Pointer(pPoslist)).Fn = 0
 138660 	(*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(i)*48)).FpOut = pPoslist
 138661 	goto __5
 138662 __5:
 138663 	i++
 138664 	goto __4
 138665 	goto __6
 138666 __6:
 138667 	;
 138668 __7:
 138669 	if !(1 != 0) {
 138670 		goto __8
 138671 	}
 138672 
 138673 	iMax = (*Fts5NearTrimmer)(unsafe.Pointer(a)).Freader.FiPos
 138674 __9:
 138675 	bMatch = 1
 138676 	i = 0
 138677 __12:
 138678 	if !(i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) {
 138679 		goto __14
 138680 	}
 138681 	pPos = a + uintptr(i)*48
 138682 	iMin = iMax - I64((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(i)*4)))).FnTerm) - I64((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnNear)
 138683 	if !((*Fts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos < iMin || (*Fts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos > iMax) {
 138684 		goto __15
 138685 	}
 138686 	bMatch = 0
 138687 __16:
 138688 	if !((*Fts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos < iMin) {
 138689 		goto __17
 138690 	}
 138691 	if !(fts5LookaheadReaderNext(tls, pPos) != 0) {
 138692 		goto __18
 138693 	}
 138694 	goto ismatch_out
 138695 __18:
 138696 	;
 138697 	goto __16
 138698 __17:
 138699 	;
 138700 	if !((*Fts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos > iMax) {
 138701 		goto __19
 138702 	}
 138703 	iMax = (*Fts5LookaheadReader)(unsafe.Pointer(pPos)).FiPos
 138704 __19:
 138705 	;
 138706 __15:
 138707 	;
 138708 	goto __13
 138709 __13:
 138710 	i++
 138711 	goto __12
 138712 	goto __14
 138713 __14:
 138714 	;
 138715 	goto __10
 138716 __10:
 138717 	if bMatch == 0 {
 138718 		goto __9
 138719 	}
 138720 	goto __11
 138721 __11:
 138722 	;
 138723 	i = 0
 138724 __20:
 138725 	if !(i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) {
 138726 		goto __22
 138727 	}
 138728 	iPos = (*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(i)*48)).Freader.FiPos
 138729 	pWriter = a + uintptr(i)*48 + 32
 138730 	if !((*Fts5Buffer)(unsafe.Pointer((*Fts5NearTrimmer)(unsafe.Pointer(a+uintptr(i)*48)).FpOut)).Fn == 0 || iPos != (*Fts5PoslistWriter)(unsafe.Pointer(pWriter)).FiPrev) {
 138731 		goto __23
 138732 	}
 138733 	sqlite3Fts5PoslistWriterAppend(tls, (*Fts5NearTrimmer)(unsafe.Pointer(a+uintptr(i)*48)).FpOut, pWriter, iPos)
 138734 __23:
 138735 	;
 138736 	goto __21
 138737 __21:
 138738 	i++
 138739 	goto __20
 138740 	goto __22
 138741 __22:
 138742 	;
 138743 	iAdv = 0
 138744 	iMin = (*Fts5NearTrimmer)(unsafe.Pointer(a)).Freader.FiLookahead
 138745 	i = 0
 138746 __24:
 138747 	if !(i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) {
 138748 		goto __26
 138749 	}
 138750 	if !((*Fts5NearTrimmer)(unsafe.Pointer(a+uintptr(i)*48)).Freader.FiLookahead < iMin) {
 138751 		goto __27
 138752 	}
 138753 	iMin = (*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(i)*48)).Freader.FiLookahead
 138754 	iAdv = i
 138755 __27:
 138756 	;
 138757 	goto __25
 138758 __25:
 138759 	i++
 138760 	goto __24
 138761 	goto __26
 138762 __26:
 138763 	;
 138764 	if !(fts5LookaheadReaderNext(tls, a+uintptr(iAdv)*48) != 0) {
 138765 		goto __28
 138766 	}
 138767 	goto ismatch_out
 138768 __28:
 138769 	;
 138770 	goto __7
 138771 __8:
 138772 	;
 138773 ismatch_out:
 138774 	bRet = libc.Bool32((*Fts5Buffer)(unsafe.Pointer((*Fts5NearTrimmer)(unsafe.Pointer(a)).FpOut)).Fn > 0)
 138775 	*(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 192))
 138776 	if !(a != bp) {
 138777 		goto __29
 138778 	}
 138779 	Xsqlite3_free(tls, a)
 138780 __29:
 138781 	;
 138782 	return bRet
 138783 
 138784 	return int32(0)
 138785 }
 138786 
 138787 func fts5ExprAdvanceto(tls *libc.TLS, pIter uintptr, bDesc int32, piLast uintptr, pRc uintptr, pbEof uintptr) int32 {
 138788 	var iLast I64 = *(*I64)(unsafe.Pointer(piLast))
 138789 	var iRowid I64
 138790 
 138791 	iRowid = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid
 138792 	if bDesc == 0 && iLast > iRowid || bDesc != 0 && iLast < iRowid {
 138793 		var rc int32 = sqlite3Fts5IterNextFrom(tls, pIter, iLast)
 138794 		if rc != 0 || (*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof != 0 {
 138795 			*(*int32)(unsafe.Pointer(pRc)) = rc
 138796 			*(*int32)(unsafe.Pointer(pbEof)) = 1
 138797 			return 1
 138798 		}
 138799 		iRowid = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid
 138800 
 138801 	}
 138802 	*(*I64)(unsafe.Pointer(piLast)) = iRowid
 138803 
 138804 	return 0
 138805 }
 138806 
 138807 func fts5ExprSynonymAdvanceto(tls *libc.TLS, pTerm uintptr, bDesc int32, piLast uintptr, pRc uintptr) int32 {
 138808 	bp := tls.Alloc(4)
 138809 	defer tls.Free(4)
 138810 
 138811 	var rc int32 = SQLITE_OK
 138812 	var iLast I64 = *(*I64)(unsafe.Pointer(piLast))
 138813 	var p uintptr
 138814 	*(*int32)(unsafe.Pointer(bp)) = 0
 138815 
 138816 	for p = pTerm; rc == SQLITE_OK && p != 0; p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym {
 138817 		if int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) == 0 {
 138818 			var iRowid I64 = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid
 138819 			if bDesc == 0 && iLast > iRowid || bDesc != 0 && iLast < iRowid {
 138820 				rc = sqlite3Fts5IterNextFrom(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter, iLast)
 138821 			}
 138822 		}
 138823 	}
 138824 
 138825 	if rc != SQLITE_OK {
 138826 		*(*int32)(unsafe.Pointer(pRc)) = rc
 138827 		*(*int32)(unsafe.Pointer(bp)) = 1
 138828 	} else {
 138829 		*(*I64)(unsafe.Pointer(piLast)) = fts5ExprSynonymRowid(tls, pTerm, bDesc, bp)
 138830 	}
 138831 	return *(*int32)(unsafe.Pointer(bp))
 138832 }
 138833 
 138834 func fts5ExprNearTest(tls *libc.TLS, pRc uintptr, pExpr uintptr, pNode uintptr) int32 {
 138835 	bp := tls.Alloc(8)
 138836 	defer tls.Free(8)
 138837 
 138838 	var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear
 138839 	*(*int32)(unsafe.Pointer(bp + 4)) = *(*int32)(unsafe.Pointer(pRc))
 138840 
 138841 	if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail != FTS5_DETAIL_FULL {
 138842 		var pTerm uintptr
 138843 		var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12))
 138844 		(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 0
 138845 		for pTerm = pPhrase + 20; pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym {
 138846 			var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter
 138847 			if int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 {
 138848 				if (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid && (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData > 0 {
 138849 					(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 1
 138850 				}
 138851 			}
 138852 		}
 138853 		return (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn
 138854 	} else {
 138855 		var i int32
 138856 
 138857 		for i = 0; *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK && i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ {
 138858 			var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(i)*4))
 138859 			if (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1 || (*Fts5ExprTerm)(unsafe.Pointer(pPhrase+20)).FpSynonym != 0 ||
 138860 				(*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 || (*Fts5ExprTerm)(unsafe.Pointer(pPhrase+20)).FbFirst != 0 {
 138861 				*(*int32)(unsafe.Pointer(bp)) = 0
 138862 				*(*int32)(unsafe.Pointer(bp + 4)) = fts5ExprPhraseIsMatch(tls, pNode, pPhrase, bp)
 138863 				if *(*int32)(unsafe.Pointer(bp)) == 0 {
 138864 					break
 138865 				}
 138866 			} else {
 138867 				var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FpIter
 138868 				sqlite3Fts5BufferSet(tls, bp+4, pPhrase+4, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData)
 138869 			}
 138870 		}
 138871 
 138872 		*(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 4))
 138873 		if i == (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase && (i == 1 || fts5ExprNearIsMatch(tls, pRc, pNear) != 0) {
 138874 			return 1
 138875 		}
 138876 		return 0
 138877 	}
 138878 	return int32(0)
 138879 }
 138880 
 138881 func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 {
 138882 	var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear
 138883 	var i int32
 138884 
 138885 	for i = 0; i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ {
 138886 		var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(i)*4))
 138887 		if (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 {
 138888 			(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1
 138889 			return SQLITE_OK
 138890 		} else {
 138891 			var j int32
 138892 			for j = 0; j < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm; j++ {
 138893 				var pTerm uintptr = pPhrase + 20 + uintptr(j)*16
 138894 				var p uintptr
 138895 				var bHit int32 = 0
 138896 
 138897 				for p = pTerm; p != 0; p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym {
 138898 					var rc int32
 138899 					if (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter != 0 {
 138900 						sqlite3Fts5IterClose(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)
 138901 						(*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter = uintptr(0)
 138902 					}
 138903 					rc = sqlite3Fts5IndexQuery(tls,
 138904 						(*Fts5Expr)(unsafe.Pointer(pExpr)).FpIndex, (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm, int32(libc.Xstrlen(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm)),
 138905 						func() int32 {
 138906 							if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0 {
 138907 								return FTS5INDEX_QUERY_PREFIX
 138908 							}
 138909 							return 0
 138910 						}()|func() int32 {
 138911 							if (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc != 0 {
 138912 								return FTS5INDEX_QUERY_DESC
 138913 							}
 138914 							return 0
 138915 						}(),
 138916 						(*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset,
 138917 						p+8)
 138918 
 138919 					if rc != SQLITE_OK {
 138920 						return rc
 138921 					}
 138922 					if 0 == int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) {
 138923 						bHit = 1
 138924 					}
 138925 				}
 138926 
 138927 				if bHit == 0 {
 138928 					(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1
 138929 					return SQLITE_OK
 138930 				}
 138931 			}
 138932 		}
 138933 	}
 138934 
 138935 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0
 138936 	return SQLITE_OK
 138937 }
 138938 
 138939 func fts5RowidCmp(tls *libc.TLS, pExpr uintptr, iLhs I64, iRhs I64) int32 {
 138940 	if (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc == 0 {
 138941 		if iLhs < iRhs {
 138942 			return -1
 138943 		}
 138944 		return libc.Bool32(iLhs > iRhs)
 138945 	} else {
 138946 		if iLhs > iRhs {
 138947 			return -1
 138948 		}
 138949 		return libc.Bool32(iLhs < iRhs)
 138950 	}
 138951 	return int32(0)
 138952 }
 138953 
 138954 func fts5ExprSetEof(tls *libc.TLS, pNode uintptr) {
 138955 	var i int32
 138956 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1
 138957 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 138958 	for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 138959 		fts5ExprSetEof(tls, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)))
 138960 	}
 138961 }
 138962 
 138963 func fts5ExprNodeZeroPoslist(tls *libc.TLS, pNode uintptr) {
 138964 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING || (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM {
 138965 		var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear
 138966 		var i int32
 138967 		for i = 0; i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ {
 138968 			var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(i)*4))
 138969 			(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 0
 138970 		}
 138971 	} else {
 138972 		var i int32
 138973 		for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 138974 			fts5ExprNodeZeroPoslist(tls, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)))
 138975 		}
 138976 	}
 138977 }
 138978 
 138979 func fts5NodeCompare(tls *libc.TLS, pExpr uintptr, p1 uintptr, p2 uintptr) int32 {
 138980 	if (*Fts5ExprNode)(unsafe.Pointer(p2)).FbEof != 0 {
 138981 		return -1
 138982 	}
 138983 	if (*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof != 0 {
 138984 		return +1
 138985 	}
 138986 	return fts5RowidCmp(tls, pExpr, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid, (*Fts5ExprNode)(unsafe.Pointer(p2)).FiRowid)
 138987 }
 138988 
 138989 func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 {
 138990 	bp := tls.Alloc(12)
 138991 	defer tls.Free(12)
 138992 
 138993 	var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear
 138994 	var pLeft uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12))
 138995 	*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_OK
 138996 
 138997 	var i int32
 138998 	var j int32
 138999 	var bMatch int32
 139000 	var bDesc int32 = (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc
 139001 
 139002 	if (*Fts5ExprTerm)(unsafe.Pointer(pLeft+20)).FpSynonym != 0 {
 139003 		*(*I64)(unsafe.Pointer(bp)) = fts5ExprSynonymRowid(tls, pLeft+20, bDesc, uintptr(0))
 139004 	} else {
 139005 		*(*I64)(unsafe.Pointer(bp)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(pLeft + 20)).FpIter)).FiRowid
 139006 	}
 139007 
 139008 	for __ccgo := true; __ccgo; __ccgo = bMatch == 0 {
 139009 		bMatch = 1
 139010 		for i = 0; i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ {
 139011 			var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(i)*4))
 139012 			for j = 0; j < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm; j++ {
 139013 				var pTerm uintptr = pPhrase + 20 + uintptr(j)*16
 139014 				if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 {
 139015 					var iRowid I64 = fts5ExprSynonymRowid(tls, pTerm, bDesc, uintptr(0))
 139016 					if iRowid == *(*I64)(unsafe.Pointer(bp)) {
 139017 						continue
 139018 					}
 139019 					bMatch = 0
 139020 					if fts5ExprSynonymAdvanceto(tls, pTerm, bDesc, bp, bp+8) != 0 {
 139021 						(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139022 						(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1
 139023 						return *(*int32)(unsafe.Pointer(bp + 8))
 139024 					}
 139025 				} else {
 139026 					var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20 + uintptr(j)*16)).FpIter
 139027 					if (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == *(*I64)(unsafe.Pointer(bp)) || (*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof != 0 {
 139028 						continue
 139029 					}
 139030 					bMatch = 0
 139031 					if fts5ExprAdvanceto(tls, pIter, bDesc, bp, bp+8, pNode+4) != 0 {
 139032 						return *(*int32)(unsafe.Pointer(bp + 8))
 139033 					}
 139034 				}
 139035 			}
 139036 		}
 139037 	}
 139038 
 139039 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = *(*I64)(unsafe.Pointer(bp))
 139040 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = libc.Bool32(0 == fts5ExprNearTest(tls, bp+8, pExpr, pNode) && *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK)
 139041 
 139042 	return *(*int32)(unsafe.Pointer(bp + 8))
 139043 }
 139044 
 139045 func fts5ExprNodeNext_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 {
 139046 	var pTerm uintptr = *(*uintptr)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 12)) + 20
 139047 	var rc int32 = SQLITE_OK
 139048 
 139049 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139050 	if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 {
 139051 		var bEof int32 = 1
 139052 		var p uintptr
 139053 
 139054 		var iRowid I64 = fts5ExprSynonymRowid(tls, pTerm, (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc, uintptr(0))
 139055 
 139056 		for p = pTerm; p != 0; p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym {
 139057 			if int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) == 0 {
 139058 				var ii I64 = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid
 139059 				if ii == iRowid ||
 139060 					bFromValid != 0 && ii != iFrom && libc.Bool32(ii > iFrom) == (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc {
 139061 					if bFromValid != 0 {
 139062 						rc = sqlite3Fts5IterNextFrom(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter, iFrom)
 139063 					} else {
 139064 						rc = sqlite3Fts5IterNext(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)
 139065 					}
 139066 					if rc != SQLITE_OK {
 139067 						break
 139068 					}
 139069 					if int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof) == 0 {
 139070 						bEof = 0
 139071 					}
 139072 				} else {
 139073 					bEof = 0
 139074 				}
 139075 			}
 139076 		}
 139077 
 139078 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = libc.Bool32(rc != 0 || bEof != 0)
 139079 	} else {
 139080 		var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter
 139081 
 139082 		if bFromValid != 0 {
 139083 			rc = sqlite3Fts5IterNextFrom(tls, pIter, iFrom)
 139084 		} else {
 139085 			rc = sqlite3Fts5IterNext(tls, pIter)
 139086 		}
 139087 
 139088 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = libc.Bool32(rc != 0 || (*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof != 0)
 139089 	}
 139090 
 139091 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 {
 139092 		rc = fts5ExprNodeTest_STRING(tls, pExpr, pNode)
 139093 	}
 139094 
 139095 	return rc
 139096 }
 139097 
 139098 func fts5ExprNodeTest_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 {
 139099 	var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 12))
 139100 	var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FpIter
 139101 
 139102 	(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData
 139103 	if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail == FTS5_DETAIL_FULL {
 139104 		(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fp = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData
 139105 	}
 139106 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid
 139107 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn == 0)
 139108 	return SQLITE_OK
 139109 }
 139110 
 139111 func fts5ExprNodeNext_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 {
 139112 	var rc int32
 139113 	var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 12)) + 20)).FpIter
 139114 
 139115 	if bFromValid != 0 {
 139116 		rc = sqlite3Fts5IterNextFrom(tls, pIter, iFrom)
 139117 	} else {
 139118 		rc = sqlite3Fts5IterNext(tls, pIter)
 139119 	}
 139120 	if rc == SQLITE_OK && int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof) == 0 {
 139121 		rc = fts5ExprNodeTest_TERM(tls, pExpr, pNode)
 139122 	} else {
 139123 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1
 139124 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139125 	}
 139126 	return rc
 139127 }
 139128 
 139129 func fts5ExprNodeTest_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr) {
 139130 	var pNext uintptr = *(*uintptr)(unsafe.Pointer(pNode + 32))
 139131 	var i int32
 139132 
 139133 	for i = 1; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 139134 		var pChild uintptr = *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4))
 139135 		var cmp int32 = fts5NodeCompare(tls, pExpr, pNext, pChild)
 139136 		if cmp > 0 || cmp == 0 && (*Fts5ExprNode)(unsafe.Pointer(pChild)).FbNomatch == 0 {
 139137 			pNext = pChild
 139138 		}
 139139 	}
 139140 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(pNext)).FiRowid
 139141 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(pNext)).FbEof
 139142 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (*Fts5ExprNode)(unsafe.Pointer(pNext)).FbNomatch
 139143 }
 139144 
 139145 func fts5ExprNodeNext_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 {
 139146 	var i int32
 139147 	var iLast I64 = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid
 139148 
 139149 	for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 139150 		var p1 uintptr = *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4))
 139151 
 139152 		if (*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0 {
 139153 			if (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid == iLast ||
 139154 				bFromValid != 0 && fts5RowidCmp(tls, pExpr, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid, iFrom) < 0 {
 139155 				var rc int32 = (*struct {
 139156 					f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139157 				})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(p1)).FxNext})).f(tls, pExpr, p1, bFromValid, iFrom)
 139158 				if rc != SQLITE_OK {
 139159 					(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139160 					return rc
 139161 				}
 139162 			}
 139163 		}
 139164 	}
 139165 
 139166 	fts5ExprNodeTest_OR(tls, pExpr, pNode)
 139167 	return SQLITE_OK
 139168 }
 139169 
 139170 func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 {
 139171 	var iChild int32
 139172 	var iLast I64 = (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid
 139173 	var rc int32 = SQLITE_OK
 139174 	var bMatch int32
 139175 
 139176 	for __ccgo := true; __ccgo; __ccgo = bMatch == 0 {
 139177 		(*Fts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 0
 139178 		bMatch = 1
 139179 		for iChild = 0; iChild < (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FnChild; iChild++ {
 139180 			var pChild uintptr = *(*uintptr)(unsafe.Pointer(pAnd + 32 + uintptr(iChild)*4))
 139181 			var cmp int32 = fts5RowidCmp(tls, pExpr, iLast, (*Fts5ExprNode)(unsafe.Pointer(pChild)).FiRowid)
 139182 			if cmp > 0 {
 139183 				rc = (*struct {
 139184 					f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139185 				})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(pChild)).FxNext})).f(tls, pExpr, pChild, 1, iLast)
 139186 				if rc != SQLITE_OK {
 139187 					(*Fts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 0
 139188 					return rc
 139189 				}
 139190 			}
 139191 
 139192 			if (*Fts5ExprNode)(unsafe.Pointer(pChild)).FbEof != 0 {
 139193 				fts5ExprSetEof(tls, pAnd)
 139194 				bMatch = 1
 139195 				break
 139196 			} else if iLast != (*Fts5ExprNode)(unsafe.Pointer(pChild)).FiRowid {
 139197 				bMatch = 0
 139198 				iLast = (*Fts5ExprNode)(unsafe.Pointer(pChild)).FiRowid
 139199 			}
 139200 
 139201 			if (*Fts5ExprNode)(unsafe.Pointer(pChild)).FbNomatch != 0 {
 139202 				(*Fts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 1
 139203 			}
 139204 		}
 139205 	}
 139206 
 139207 	if (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch != 0 && pAnd != (*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot {
 139208 		fts5ExprNodeZeroPoslist(tls, pAnd)
 139209 	}
 139210 	(*Fts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid = iLast
 139211 	return SQLITE_OK
 139212 }
 139213 
 139214 func fts5ExprNodeNext_AND(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 {
 139215 	var rc int32 = (*struct {
 139216 		f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139217 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 32)))).FxNext})).f(tls, pExpr, *(*uintptr)(unsafe.Pointer(pNode + 32)), bFromValid, iFrom)
 139218 	if rc == SQLITE_OK {
 139219 		rc = fts5ExprNodeTest_AND(tls, pExpr, pNode)
 139220 	} else {
 139221 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139222 	}
 139223 	return rc
 139224 }
 139225 
 139226 func fts5ExprNodeTest_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 {
 139227 	var rc int32 = SQLITE_OK
 139228 	var p1 uintptr = *(*uintptr)(unsafe.Pointer(pNode + 32))
 139229 	var p2 uintptr = *(*uintptr)(unsafe.Pointer(pNode + 32 + 1*4))
 139230 
 139231 	for rc == SQLITE_OK && (*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0 {
 139232 		var cmp int32 = fts5NodeCompare(tls, pExpr, p1, p2)
 139233 		if cmp > 0 {
 139234 			rc = (*struct {
 139235 				f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139236 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(p2)).FxNext})).f(tls, pExpr, p2, 1, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid)
 139237 			cmp = fts5NodeCompare(tls, pExpr, p1, p2)
 139238 		}
 139239 
 139240 		if cmp != 0 || (*Fts5ExprNode)(unsafe.Pointer(p2)).FbNomatch != 0 {
 139241 			break
 139242 		}
 139243 		rc = (*struct {
 139244 			f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139245 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(p1)).FxNext})).f(tls, pExpr, p1, 0, int64(0))
 139246 	}
 139247 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof
 139248 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (*Fts5ExprNode)(unsafe.Pointer(p1)).FbNomatch
 139249 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid
 139250 	if (*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof != 0 {
 139251 		fts5ExprNodeZeroPoslist(tls, p2)
 139252 	}
 139253 	return rc
 139254 }
 139255 
 139256 func fts5ExprNodeNext_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 {
 139257 	var rc int32 = (*struct {
 139258 		f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139259 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 32)))).FxNext})).f(tls, pExpr, *(*uintptr)(unsafe.Pointer(pNode + 32)), bFromValid, iFrom)
 139260 	if rc == SQLITE_OK {
 139261 		rc = fts5ExprNodeTest_NOT(tls, pExpr, pNode)
 139262 	}
 139263 	if rc != SQLITE_OK {
 139264 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139265 	}
 139266 	return rc
 139267 }
 139268 
 139269 func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 {
 139270 	var rc int32 = SQLITE_OK
 139271 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 {
 139272 		switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType {
 139273 		case FTS5_STRING:
 139274 			{
 139275 				rc = fts5ExprNodeTest_STRING(tls, pExpr, pNode)
 139276 				break
 139277 
 139278 			}
 139279 			fallthrough
 139280 
 139281 		case FTS5_TERM:
 139282 			{
 139283 				rc = fts5ExprNodeTest_TERM(tls, pExpr, pNode)
 139284 				break
 139285 
 139286 			}
 139287 			fallthrough
 139288 
 139289 		case FTS5_AND:
 139290 			{
 139291 				rc = fts5ExprNodeTest_AND(tls, pExpr, pNode)
 139292 				break
 139293 
 139294 			}
 139295 			fallthrough
 139296 
 139297 		case FTS5_OR:
 139298 			{
 139299 				fts5ExprNodeTest_OR(tls, pExpr, pNode)
 139300 				break
 139301 
 139302 			}
 139303 			fallthrough
 139304 
 139305 		default:
 139306 			{
 139307 				rc = fts5ExprNodeTest_NOT(tls, pExpr, pNode)
 139308 				break
 139309 
 139310 			}
 139311 		}
 139312 	}
 139313 	return rc
 139314 }
 139315 
 139316 func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 {
 139317 	var rc int32 = SQLITE_OK
 139318 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0
 139319 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0
 139320 
 139321 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM || (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING {
 139322 		rc = fts5ExprNearInitAll(tls, pExpr, pNode)
 139323 	} else if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext == uintptr(0) {
 139324 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1
 139325 	} else {
 139326 		var i int32
 139327 		var nEof int32 = 0
 139328 		for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild && rc == SQLITE_OK; i++ {
 139329 			var pChild uintptr = *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4))
 139330 			rc = fts5ExprNodeFirst(tls, pExpr, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)))
 139331 
 139332 			nEof = nEof + (*Fts5ExprNode)(unsafe.Pointer(pChild)).FbEof
 139333 		}
 139334 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 32)))).FiRowid
 139335 
 139336 		switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType {
 139337 		case FTS5_AND:
 139338 			if nEof > 0 {
 139339 				fts5ExprSetEof(tls, pNode)
 139340 			}
 139341 			break
 139342 			fallthrough
 139343 
 139344 		case FTS5_OR:
 139345 			if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild == nEof {
 139346 				fts5ExprSetEof(tls, pNode)
 139347 			}
 139348 			break
 139349 			fallthrough
 139350 
 139351 		default:
 139352 			(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 32)))).FbEof
 139353 			break
 139354 		}
 139355 	}
 139356 
 139357 	if rc == SQLITE_OK {
 139358 		rc = fts5ExprNodeTest(tls, pExpr, pNode)
 139359 	}
 139360 	return rc
 139361 }
 139362 
 139363 func sqlite3Fts5ExprFirst(tls *libc.TLS, p uintptr, pIdx uintptr, iFirst I64, bDesc int32) int32 {
 139364 	var pRoot uintptr = (*Fts5Expr)(unsafe.Pointer(p)).FpRoot
 139365 	var rc int32
 139366 
 139367 	(*Fts5Expr)(unsafe.Pointer(p)).FpIndex = pIdx
 139368 	(*Fts5Expr)(unsafe.Pointer(p)).FbDesc = bDesc
 139369 	rc = fts5ExprNodeFirst(tls, p, pRoot)
 139370 
 139371 	if rc == SQLITE_OK &&
 139372 		0 == (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FbEof &&
 139373 		fts5RowidCmp(tls, p, (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iFirst) < 0 {
 139374 		rc = (*struct {
 139375 			f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139376 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})).f(tls, p, pRoot, 1, iFirst)
 139377 	}
 139378 
 139379 	for (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FbNomatch != 0 && rc == SQLITE_OK {
 139380 		rc = (*struct {
 139381 			f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139382 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})).f(tls, p, pRoot, 0, int64(0))
 139383 	}
 139384 	return rc
 139385 }
 139386 
 139387 func sqlite3Fts5ExprNext(tls *libc.TLS, p uintptr, iLast I64) int32 {
 139388 	var rc int32
 139389 	var pRoot uintptr = (*Fts5Expr)(unsafe.Pointer(p)).FpRoot
 139390 
 139391 	for __ccgo := true; __ccgo; __ccgo = (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FbNomatch != 0 {
 139392 		rc = (*struct {
 139393 			f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139394 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})).f(tls, p, pRoot, 0, int64(0))
 139395 
 139396 	}
 139397 	if fts5RowidCmp(tls, p, (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iLast) > 0 {
 139398 		(*Fts5ExprNode)(unsafe.Pointer(pRoot)).FbEof = 1
 139399 	}
 139400 	return rc
 139401 }
 139402 
 139403 func sqlite3Fts5ExprEof(tls *libc.TLS, p uintptr) int32 {
 139404 	return (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(p)).FpRoot)).FbEof
 139405 }
 139406 
 139407 func sqlite3Fts5ExprRowid(tls *libc.TLS, p uintptr) I64 {
 139408 	return (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(p)).FpRoot)).FiRowid
 139409 }
 139410 
 139411 func fts5ParseStringFromToken(tls *libc.TLS, pToken uintptr, pz uintptr) int32 {
 139412 	bp := tls.Alloc(4)
 139413 	defer tls.Free(4)
 139414 
 139415 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 139416 	*(*uintptr)(unsafe.Pointer(pz)) = sqlite3Fts5Strndup(tls, bp, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, (*Fts5Token)(unsafe.Pointer(pToken)).Fn)
 139417 	return *(*int32)(unsafe.Pointer(bp))
 139418 }
 139419 
 139420 func fts5ExprPhraseFree(tls *libc.TLS, pPhrase uintptr) {
 139421 	if pPhrase != 0 {
 139422 		var i int32
 139423 		for i = 0; i < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm; i++ {
 139424 			var pSyn uintptr
 139425 			var pNext uintptr
 139426 			var pTerm uintptr = pPhrase + 20 + uintptr(i)*16
 139427 			Xsqlite3_free(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm)
 139428 			sqlite3Fts5IterClose(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter)
 139429 			for pSyn = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym; pSyn != 0; pSyn = pNext {
 139430 				pNext = (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym
 139431 				sqlite3Fts5IterClose(tls, (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpIter)
 139432 				sqlite3Fts5BufferFree(tls, pSyn+1*16)
 139433 				Xsqlite3_free(tls, pSyn)
 139434 			}
 139435 		}
 139436 		if (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.FnSpace > 0 {
 139437 			sqlite3Fts5BufferFree(tls, pPhrase+4)
 139438 		}
 139439 		Xsqlite3_free(tls, pPhrase)
 139440 	}
 139441 }
 139442 
 139443 func sqlite3Fts5ParseSetCaret(tls *libc.TLS, pPhrase uintptr) {
 139444 	if pPhrase != 0 && (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm != 0 {
 139445 		(*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FbFirst = U8(1)
 139446 	}
 139447 }
 139448 
 139449 func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhrase uintptr) uintptr {
 139450 	var SZALLOC int32 = 8
 139451 	var pRet uintptr = uintptr(0)
 139452 
 139453 	if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK {
 139454 		if pPhrase == uintptr(0) {
 139455 			return pNear
 139456 		}
 139457 		if pNear == uintptr(0) {
 139458 			var nByte Sqlite3_int64
 139459 			nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5ExprNearset{})) + uint32(SZALLOC)*uint32(unsafe.Sizeof(uintptr(0))))
 139460 			pRet = Xsqlite3_malloc64(tls, uint64(nByte))
 139461 			if pRet == uintptr(0) {
 139462 				(*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
 139463 			} else {
 139464 				libc.Xmemset(tls, pRet, 0, Size_t(nByte))
 139465 			}
 139466 		} else if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase%SZALLOC == 0 {
 139467 			var nNew int32 = (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase + SZALLOC
 139468 			var nByte Sqlite3_int64
 139469 
 139470 			nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5ExprNearset{})) + uint32(nNew)*uint32(unsafe.Sizeof(uintptr(0))))
 139471 			pRet = Xsqlite3_realloc64(tls, pNear, uint64(nByte))
 139472 			if pRet == uintptr(0) {
 139473 				(*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
 139474 			}
 139475 		} else {
 139476 			pRet = pNear
 139477 		}
 139478 	}
 139479 
 139480 	if pRet == uintptr(0) {
 139481 		sqlite3Fts5ParseNearsetFree(tls, pNear)
 139482 		sqlite3Fts5ParsePhraseFree(tls, pPhrase)
 139483 	} else {
 139484 		if (*Fts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase > 0 {
 139485 			var pLast uintptr = *(*uintptr)(unsafe.Pointer(pRet + 12 + uintptr((*Fts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase-1)*4))
 139486 
 139487 			if (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 {
 139488 				fts5ExprPhraseFree(tls, pPhrase)
 139489 				(*Fts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase--
 139490 				(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase--
 139491 				pPhrase = pLast
 139492 			} else if (*Fts5ExprPhrase)(unsafe.Pointer(pLast)).FnTerm == 0 {
 139493 				fts5ExprPhraseFree(tls, pLast)
 139494 				*(*uintptr)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-2)*4)) = pPhrase
 139495 				(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase--
 139496 				(*Fts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase--
 139497 			}
 139498 		}
 139499 		*(*uintptr)(unsafe.Pointer(pRet + 12 + uintptr(libc.PostIncInt32(&(*Fts5ExprNearset)(unsafe.Pointer(pRet)).FnPhrase, 1))*4)) = pPhrase
 139500 	}
 139501 	return pRet
 139502 }
 139503 
 139504 type TokenCtx1 = struct {
 139505 	FpPhrase uintptr
 139506 	Frc      int32
 139507 }
 139508 
 139509 type TokenCtx = TokenCtx1
 139510 
 139511 func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) int32 {
 139512 	bp := tls.Alloc(4)
 139513 	defer tls.Free(4)
 139514 
 139515 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 139516 	var SZALLOC int32 = 8
 139517 	var pCtx uintptr = pContext
 139518 	var pPhrase uintptr = (*TokenCtx)(unsafe.Pointer(pCtx)).FpPhrase
 139519 
 139520 	_ = iUnused1
 139521 	_ = iUnused2
 139522 
 139523 	if (*TokenCtx)(unsafe.Pointer(pCtx)).Frc != SQLITE_OK {
 139524 		return (*TokenCtx)(unsafe.Pointer(pCtx)).Frc
 139525 	}
 139526 	if nToken > FTS5_MAX_TOKEN_SIZE {
 139527 		nToken = FTS5_MAX_TOKEN_SIZE
 139528 	}
 139529 
 139530 	if pPhrase != 0 && (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0 && tflags&FTS5_TOKEN_COLOCATED != 0 {
 139531 		var pSyn uintptr
 139532 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5ExprTerm{})) + uint32(unsafe.Sizeof(Fts5Buffer{})) + uint32(nToken) + uint32(1))
 139533 		pSyn = Xsqlite3_malloc64(tls, uint64(nByte))
 139534 		if pSyn == uintptr(0) {
 139535 			*(*int32)(unsafe.Pointer(bp)) = SQLITE_NOMEM
 139536 		} else {
 139537 			libc.Xmemset(tls, pSyn, 0, Size_t(nByte))
 139538 			(*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FzTerm = pSyn + uintptr(uint32(unsafe.Sizeof(Fts5ExprTerm{}))) + uintptr(uint32(unsafe.Sizeof(Fts5Buffer{})))
 139539 			libc.Xmemcpy(tls, (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FzTerm, pToken, uint32(nToken))
 139540 			(*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym = (*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20 + uintptr((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm-1)*16)).FpSynonym
 139541 			(*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20 + uintptr((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm-1)*16)).FpSynonym = pSyn
 139542 		}
 139543 	} else {
 139544 		var pTerm uintptr
 139545 		if pPhrase == uintptr(0) || (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm%SZALLOC == 0 {
 139546 			var pNew uintptr
 139547 			var nNew int32 = SZALLOC + func() int32 {
 139548 				if pPhrase != 0 {
 139549 					return (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm
 139550 				}
 139551 				return 0
 139552 			}()
 139553 
 139554 			pNew = Xsqlite3_realloc64(tls, pPhrase,
 139555 				uint64(uint32(unsafe.Sizeof(Fts5ExprPhrase{}))+uint32(unsafe.Sizeof(Fts5ExprTerm{}))*uint32(nNew)))
 139556 			if pNew == uintptr(0) {
 139557 				*(*int32)(unsafe.Pointer(bp)) = SQLITE_NOMEM
 139558 			} else {
 139559 				if pPhrase == uintptr(0) {
 139560 					libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Fts5ExprPhrase{})))
 139561 				}
 139562 				(*TokenCtx)(unsafe.Pointer(pCtx)).FpPhrase = libc.AssignUintptr(&pPhrase, pNew)
 139563 				(*Fts5ExprPhrase)(unsafe.Pointer(pNew)).FnTerm = nNew - SZALLOC
 139564 			}
 139565 		}
 139566 
 139567 		if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 139568 			pTerm = pPhrase + 20 + uintptr(libc.PostIncInt32(&(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm, 1))*16
 139569 			libc.Xmemset(tls, pTerm, 0, uint32(unsafe.Sizeof(Fts5ExprTerm{})))
 139570 			(*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm = sqlite3Fts5Strndup(tls, bp, pToken, nToken)
 139571 		}
 139572 	}
 139573 
 139574 	(*TokenCtx)(unsafe.Pointer(pCtx)).Frc = *(*int32)(unsafe.Pointer(bp))
 139575 	return *(*int32)(unsafe.Pointer(bp))
 139576 }
 139577 
 139578 func sqlite3Fts5ParsePhraseFree(tls *libc.TLS, pPhrase uintptr) {
 139579 	fts5ExprPhraseFree(tls, pPhrase)
 139580 }
 139581 
 139582 func sqlite3Fts5ParseNearsetFree(tls *libc.TLS, pNear uintptr) {
 139583 	if pNear != 0 {
 139584 		var i int32
 139585 		for i = 0; i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ {
 139586 			fts5ExprPhraseFree(tls, *(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(i)*4)))
 139587 		}
 139588 		Xsqlite3_free(tls, (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)
 139589 		Xsqlite3_free(tls, pNear)
 139590 	}
 139591 }
 139592 
 139593 func sqlite3Fts5ParseFinished(tls *libc.TLS, pParse uintptr, p uintptr) {
 139594 	(*Fts5Parse)(unsafe.Pointer(pParse)).FpExpr = p
 139595 }
 139596 
 139597 func parseGrowPhraseArray(tls *libc.TLS, pParse uintptr) int32 {
 139598 	if (*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase%8 == 0 {
 139599 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(uintptr(0))) * uint32((*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase+8))
 139600 		var apNew uintptr
 139601 		apNew = Xsqlite3_realloc64(tls, (*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase, uint64(nByte))
 139602 		if apNew == uintptr(0) {
 139603 			(*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
 139604 			return SQLITE_NOMEM
 139605 		}
 139606 		(*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase = apNew
 139607 	}
 139608 	return SQLITE_OK
 139609 }
 139610 
 139611 func sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken uintptr, bPrefix int32) uintptr {
 139612 	bp := tls.Alloc(12)
 139613 	defer tls.Free(12)
 139614 
 139615 	var pConfig uintptr = (*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig
 139616 
 139617 	var rc int32
 139618 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 139619 
 139620 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(TokenCtx{})))
 139621 	(*TokenCtx)(unsafe.Pointer(bp)).FpPhrase = pAppend
 139622 
 139623 	rc = fts5ParseStringFromToken(tls, pToken, bp+8)
 139624 	if rc == SQLITE_OK {
 139625 		var flags int32 = FTS5_TOKENIZE_QUERY | func() int32 {
 139626 			if bPrefix != 0 {
 139627 				return FTS5_TOKENIZE_PREFIX
 139628 			}
 139629 			return 0
 139630 		}()
 139631 		var n int32
 139632 		sqlite3Fts5Dequote(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 139633 		n = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 8))))
 139634 		rc = sqlite3Fts5Tokenize(tls, pConfig, flags, *(*uintptr)(unsafe.Pointer(bp + 8)), n, bp, *(*uintptr)(unsafe.Pointer(&struct {
 139635 			f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 139636 		}{fts5ParseTokenize})))
 139637 	}
 139638 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 139639 	if rc != 0 || libc.AssignInt32(&rc, (*TokenCtx)(unsafe.Pointer(bp)).Frc) != 0 {
 139640 		(*Fts5Parse)(unsafe.Pointer(pParse)).Frc = rc
 139641 		fts5ExprPhraseFree(tls, (*TokenCtx)(unsafe.Pointer(bp)).FpPhrase)
 139642 		(*TokenCtx)(unsafe.Pointer(bp)).FpPhrase = uintptr(0)
 139643 	} else {
 139644 		if pAppend == uintptr(0) {
 139645 			if parseGrowPhraseArray(tls, pParse) != 0 {
 139646 				fts5ExprPhraseFree(tls, (*TokenCtx)(unsafe.Pointer(bp)).FpPhrase)
 139647 				return uintptr(0)
 139648 			}
 139649 			(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase++
 139650 		}
 139651 
 139652 		if (*TokenCtx)(unsafe.Pointer(bp)).FpPhrase == uintptr(0) {
 139653 			(*TokenCtx)(unsafe.Pointer(bp)).FpPhrase = sqlite3Fts5MallocZero(tls, pParse+8, int64(unsafe.Sizeof(Fts5ExprPhrase{})))
 139654 		} else if (*Fts5ExprPhrase)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp)).FpPhrase)).FnTerm != 0 {
 139655 			(*Fts5ExprTerm)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp)).FpPhrase + 20 + uintptr((*Fts5ExprPhrase)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp)).FpPhrase)).FnTerm-1)*16)).FbPrefix = U8(bPrefix)
 139656 		}
 139657 		*(*uintptr)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-1)*4)) = (*TokenCtx)(unsafe.Pointer(bp)).FpPhrase
 139658 	}
 139659 
 139660 	return (*TokenCtx)(unsafe.Pointer(bp)).FpPhrase
 139661 }
 139662 
 139663 func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppNew uintptr) int32 {
 139664 	bp := tls.Alloc(12)
 139665 	defer tls.Free(12)
 139666 
 139667 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 139668 	var pOrig uintptr
 139669 	var pNew uintptr = uintptr(0)
 139670 	*(*TokenCtx)(unsafe.Pointer(bp + 4)) = TokenCtx{}
 139671 
 139672 	pOrig = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*4))
 139673 	pNew = sqlite3Fts5MallocZero(tls, bp, int64(unsafe.Sizeof(Fts5Expr{})))
 139674 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 139675 		(*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = sqlite3Fts5MallocZero(tls, bp,
 139676 			int64(unsafe.Sizeof(uintptr(0))))
 139677 	}
 139678 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 139679 		(*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot = sqlite3Fts5MallocZero(tls, bp,
 139680 			int64(unsafe.Sizeof(Fts5ExprNode{})))
 139681 	}
 139682 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 139683 		(*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear = sqlite3Fts5MallocZero(tls, bp,
 139684 			int64(uint32(unsafe.Sizeof(Fts5ExprNearset{}))+uint32(unsafe.Sizeof(uintptr(0)))))
 139685 	}
 139686 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 139687 		var pColsetOrig uintptr = (*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FpNode)).FpNear)).FpColset
 139688 		if pColsetOrig != 0 {
 139689 			var nByte Sqlite3_int64
 139690 			var pColset uintptr
 139691 			nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Colset{})) + uint32((*Fts5Colset)(unsafe.Pointer(pColsetOrig)).FnCol-1)*uint32(unsafe.Sizeof(int32(0))))
 139692 			pColset = sqlite3Fts5MallocZero(tls, bp, nByte)
 139693 			if pColset != 0 {
 139694 				libc.Xmemcpy(tls, pColset, pColsetOrig, Size_t(nByte))
 139695 			}
 139696 			(*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FpColset = pColset
 139697 		}
 139698 	}
 139699 
 139700 	if (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm != 0 {
 139701 		var i int32
 139702 		for i = 0; *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK && i < (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm; i++ {
 139703 			var tflags int32 = 0
 139704 			var p uintptr
 139705 			for p = pOrig + 20 + uintptr(i)*16; p != 0 && *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK; p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym {
 139706 				var zTerm uintptr = (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm
 139707 				*(*int32)(unsafe.Pointer(bp)) = fts5ParseTokenize(tls, bp+4, tflags, zTerm, int32(libc.Xstrlen(tls, zTerm)),
 139708 					0, 0)
 139709 				tflags = FTS5_TOKEN_COLOCATED
 139710 			}
 139711 			if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 139712 				(*Fts5ExprTerm)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp+4)).FpPhrase + 20 + uintptr(i)*16)).FbPrefix = (*Fts5ExprTerm)(unsafe.Pointer(pOrig + 20 + uintptr(i)*16)).FbPrefix
 139713 				(*Fts5ExprTerm)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp+4)).FpPhrase + 20 + uintptr(i)*16)).FbFirst = (*Fts5ExprTerm)(unsafe.Pointer(pOrig + 20 + uintptr(i)*16)).FbFirst
 139714 			}
 139715 		}
 139716 	} else {
 139717 		(*TokenCtx)(unsafe.Pointer(bp + 4)).FpPhrase = sqlite3Fts5MallocZero(tls, bp, int64(unsafe.Sizeof(Fts5ExprPhrase{})))
 139718 	}
 139719 
 139720 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK && (*TokenCtx)(unsafe.Pointer(bp+4)).FpPhrase != 0 {
 139721 		(*Fts5Expr)(unsafe.Pointer(pNew)).FpIndex = (*Fts5Expr)(unsafe.Pointer(pExpr)).FpIndex
 139722 		(*Fts5Expr)(unsafe.Pointer(pNew)).FpConfig = (*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig
 139723 		(*Fts5Expr)(unsafe.Pointer(pNew)).FnPhrase = 1
 139724 		*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase)) = (*TokenCtx)(unsafe.Pointer(bp + 4)).FpPhrase
 139725 		*(*uintptr)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 12)) = (*TokenCtx)(unsafe.Pointer(bp + 4)).FpPhrase
 139726 		(*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FnPhrase = 1
 139727 		(*Fts5ExprPhrase)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp + 4)).FpPhrase)).FpNode = (*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot
 139728 
 139729 		if (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm == 1 &&
 139730 			(*Fts5ExprTerm)(unsafe.Pointer(pOrig+20)).FpSynonym == uintptr(0) &&
 139731 			int32((*Fts5ExprTerm)(unsafe.Pointer(pOrig+20)).FbFirst) == 0 {
 139732 			(*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = FTS5_TERM
 139733 			(*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139734 				f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139735 			}{fts5ExprNodeNext_TERM}))
 139736 		} else {
 139737 			(*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = FTS5_STRING
 139738 			(*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139739 				f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139740 			}{fts5ExprNodeNext_STRING}))
 139741 		}
 139742 	} else {
 139743 		sqlite3Fts5ExprFree(tls, pNew)
 139744 		fts5ExprPhraseFree(tls, (*TokenCtx)(unsafe.Pointer(bp+4)).FpPhrase)
 139745 		pNew = uintptr(0)
 139746 	}
 139747 
 139748 	*(*uintptr)(unsafe.Pointer(ppNew)) = pNew
 139749 	return *(*int32)(unsafe.Pointer(bp))
 139750 }
 139751 
 139752 func sqlite3Fts5ParseNear(tls *libc.TLS, pParse uintptr, pTok uintptr) {
 139753 	bp := tls.Alloc(16)
 139754 	defer tls.Free(16)
 139755 
 139756 	if (*Fts5Token)(unsafe.Pointer(pTok)).Fn != 4 || libc.Xmemcmp(tls, ts+34732, (*Fts5Token)(unsafe.Pointer(pTok)).Fp, uint32(4)) != 0 {
 139757 		sqlite3Fts5ParseError(tls,
 139758 			pParse, ts+33761, libc.VaList(bp, (*Fts5Token)(unsafe.Pointer(pTok)).Fn, (*Fts5Token)(unsafe.Pointer(pTok)).Fp))
 139759 	}
 139760 }
 139761 
 139762 func sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p uintptr) {
 139763 	bp := tls.Alloc(16)
 139764 	defer tls.Free(16)
 139765 
 139766 	if pNear != 0 {
 139767 		var nNear int32 = 0
 139768 		var i int32
 139769 		if (*Fts5Token)(unsafe.Pointer(p)).Fn != 0 {
 139770 			for i = 0; i < (*Fts5Token)(unsafe.Pointer(p)).Fn; i++ {
 139771 				var c uint8 = *(*uint8)(unsafe.Pointer((*Fts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))
 139772 				if int32(c) < '0' || int32(c) > '9' {
 139773 					sqlite3Fts5ParseError(tls,
 139774 						pParse, ts+34737, libc.VaList(bp, (*Fts5Token)(unsafe.Pointer(p)).Fn, (*Fts5Token)(unsafe.Pointer(p)).Fp))
 139775 					return
 139776 				}
 139777 				nNear = nNear*10 + (int32(*(*uint8)(unsafe.Pointer((*Fts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - '0')
 139778 			}
 139779 		} else {
 139780 			nNear = FTS5_DEFAULT_NEARDIST
 139781 		}
 139782 		(*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear
 139783 	}
 139784 }
 139785 
 139786 func fts5ParseColset(tls *libc.TLS, pParse uintptr, p uintptr, iCol int32) uintptr {
 139787 	var nCol int32
 139788 	if p != 0 {
 139789 		nCol = (*Fts5Colset)(unsafe.Pointer(p)).FnCol
 139790 	} else {
 139791 		nCol = 0
 139792 	}
 139793 	var pNew uintptr
 139794 
 139795 	pNew = Xsqlite3_realloc64(tls, p, uint64(uint32(unsafe.Sizeof(Fts5Colset{}))+uint32(unsafe.Sizeof(int32(0)))*uint32(nCol)))
 139796 	if pNew == uintptr(0) {
 139797 		(*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM
 139798 	} else {
 139799 		var aiCol uintptr = pNew + 4
 139800 		var i int32
 139801 		var j int32
 139802 		for i = 0; i < nCol; i++ {
 139803 			if *(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) == iCol {
 139804 				return pNew
 139805 			}
 139806 			if *(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) > iCol {
 139807 				break
 139808 			}
 139809 		}
 139810 		for j = nCol; j > i; j-- {
 139811 			*(*int32)(unsafe.Pointer(aiCol + uintptr(j)*4)) = *(*int32)(unsafe.Pointer(aiCol + uintptr(j-1)*4))
 139812 		}
 139813 		*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)) = iCol
 139814 		(*Fts5Colset)(unsafe.Pointer(pNew)).FnCol = nCol + 1
 139815 
 139816 	}
 139817 
 139818 	return pNew
 139819 }
 139820 
 139821 func sqlite3Fts5ParseColsetInvert(tls *libc.TLS, pParse uintptr, p uintptr) uintptr {
 139822 	var pRet uintptr
 139823 	var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FnCol
 139824 
 139825 	pRet = sqlite3Fts5MallocZero(tls, pParse+8,
 139826 		int64(uint32(unsafe.Sizeof(Fts5Colset{}))+uint32(unsafe.Sizeof(int32(0)))*uint32(nCol)))
 139827 	if pRet != 0 {
 139828 		var i int32
 139829 		var iOld int32 = 0
 139830 		for i = 0; i < nCol; i++ {
 139831 			if iOld >= (*Fts5Colset)(unsafe.Pointer(p)).FnCol || *(*int32)(unsafe.Pointer(p + 4 + uintptr(iOld)*4)) != i {
 139832 				*(*int32)(unsafe.Pointer(pRet + 4 + uintptr(libc.PostIncInt32(&(*Fts5Colset)(unsafe.Pointer(pRet)).FnCol, 1))*4)) = i
 139833 			} else {
 139834 				iOld++
 139835 			}
 139836 		}
 139837 	}
 139838 
 139839 	Xsqlite3_free(tls, p)
 139840 	return pRet
 139841 }
 139842 
 139843 func sqlite3Fts5ParseColset(tls *libc.TLS, pParse uintptr, pColset uintptr, p uintptr) uintptr {
 139844 	bp := tls.Alloc(8)
 139845 	defer tls.Free(8)
 139846 
 139847 	var pRet uintptr = uintptr(0)
 139848 	var iCol int32
 139849 	var z uintptr
 139850 
 139851 	z = sqlite3Fts5Strndup(tls, pParse+8, (*Fts5Token)(unsafe.Pointer(p)).Fp, (*Fts5Token)(unsafe.Pointer(p)).Fn)
 139852 	if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK {
 139853 		var pConfig uintptr = (*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig
 139854 		sqlite3Fts5Dequote(tls, z)
 139855 		for iCol = 0; iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; iCol++ {
 139856 			if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(iCol)*4)), z) {
 139857 				break
 139858 			}
 139859 		}
 139860 		if iCol == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol {
 139861 			sqlite3Fts5ParseError(tls, pParse, ts+20575, libc.VaList(bp, z))
 139862 		} else {
 139863 			pRet = fts5ParseColset(tls, pParse, pColset, iCol)
 139864 		}
 139865 		Xsqlite3_free(tls, z)
 139866 	}
 139867 
 139868 	if pRet == uintptr(0) {
 139869 		Xsqlite3_free(tls, pColset)
 139870 	}
 139871 
 139872 	return pRet
 139873 }
 139874 
 139875 func fts5CloneColset(tls *libc.TLS, pRc uintptr, pOrig uintptr) uintptr {
 139876 	var pRet uintptr
 139877 	if pOrig != 0 {
 139878 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Colset{})) + uint32((*Fts5Colset)(unsafe.Pointer(pOrig)).FnCol-1)*uint32(unsafe.Sizeof(int32(0))))
 139879 		pRet = sqlite3Fts5MallocZero(tls, pRc, nByte)
 139880 		if pRet != 0 {
 139881 			libc.Xmemcpy(tls, pRet, pOrig, Size_t(nByte))
 139882 		}
 139883 	} else {
 139884 		pRet = uintptr(0)
 139885 	}
 139886 	return pRet
 139887 }
 139888 
 139889 func fts5MergeColset(tls *libc.TLS, pColset uintptr, pMerge uintptr) {
 139890 	var iIn int32 = 0
 139891 	var iMerge int32 = 0
 139892 	var iOut int32 = 0
 139893 
 139894 	for iIn < (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol && iMerge < (*Fts5Colset)(unsafe.Pointer(pMerge)).FnCol {
 139895 		var iDiff int32 = *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(iIn)*4)) - *(*int32)(unsafe.Pointer(pMerge + 4 + uintptr(iMerge)*4))
 139896 		if iDiff == 0 {
 139897 			*(*int32)(unsafe.Pointer(pColset + 4 + uintptr(libc.PostIncInt32(&iOut, 1))*4)) = *(*int32)(unsafe.Pointer(pMerge + 4 + uintptr(iMerge)*4))
 139898 			iMerge++
 139899 			iIn++
 139900 		} else if iDiff > 0 {
 139901 			iMerge++
 139902 		} else {
 139903 			iIn++
 139904 		}
 139905 	}
 139906 	(*Fts5Colset)(unsafe.Pointer(pColset)).FnCol = iOut
 139907 }
 139908 
 139909 func fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pNode uintptr, pColset uintptr, ppFree uintptr) {
 139910 	if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK {
 139911 		if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING || (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM {
 139912 			var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear
 139913 			if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 {
 139914 				fts5MergeColset(tls, (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, pColset)
 139915 				if (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol == 0 {
 139916 					(*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_EOF
 139917 					(*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = uintptr(0)
 139918 				}
 139919 			} else if *(*uintptr)(unsafe.Pointer(ppFree)) != 0 {
 139920 				(*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset = pColset
 139921 				*(*uintptr)(unsafe.Pointer(ppFree)) = uintptr(0)
 139922 			} else {
 139923 				(*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset = fts5CloneColset(tls, pParse+8, pColset)
 139924 			}
 139925 		} else {
 139926 			var i int32
 139927 
 139928 			for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 139929 				fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)), pColset, ppFree)
 139930 			}
 139931 		}
 139932 	}
 139933 }
 139934 
 139935 func sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pColset uintptr) {
 139936 	bp := tls.Alloc(4)
 139937 	defer tls.Free(4)
 139938 
 139939 	*(*uintptr)(unsafe.Pointer(bp)) = pColset
 139940 	if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == FTS5_DETAIL_NONE {
 139941 		sqlite3Fts5ParseError(tls, pParse,
 139942 			ts+34766, 0)
 139943 	} else {
 139944 		fts5ParseSetColset(tls, pParse, pExpr, pColset, bp)
 139945 	}
 139946 	Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp)))
 139947 }
 139948 
 139949 func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) {
 139950 	switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType {
 139951 	case FTS5_STRING:
 139952 		{
 139953 			var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear
 139954 			if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == 1 && (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12)))).FnTerm == 1 &&
 139955 				(*Fts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12))+20)).FpSynonym == uintptr(0) &&
 139956 				int32((*Fts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12))+20)).FbFirst) == 0 {
 139957 				(*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_TERM
 139958 				(*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139959 					f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139960 				}{fts5ExprNodeNext_TERM}))
 139961 			} else {
 139962 				(*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139963 					f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139964 				}{fts5ExprNodeNext_STRING}))
 139965 			}
 139966 			break
 139967 
 139968 		}
 139969 
 139970 	case FTS5_OR:
 139971 		{
 139972 			(*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139973 				f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139974 			}{fts5ExprNodeNext_OR}))
 139975 			break
 139976 
 139977 		}
 139978 
 139979 	case FTS5_AND:
 139980 		{
 139981 			(*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139982 				f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139983 			}{fts5ExprNodeNext_AND}))
 139984 			break
 139985 
 139986 		}
 139987 
 139988 	default:
 139989 		{
 139990 			(*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 139991 				f func(*libc.TLS, uintptr, uintptr, int32, I64) int32
 139992 			}{fts5ExprNodeNext_NOT}))
 139993 			break
 139994 
 139995 		}
 139996 
 139997 	}
 139998 }
 139999 
 140000 func fts5ExprAddChildren(tls *libc.TLS, p uintptr, pSub uintptr) {
 140001 	if (*Fts5ExprNode)(unsafe.Pointer(p)).FeType != FTS5_NOT && (*Fts5ExprNode)(unsafe.Pointer(pSub)).FeType == (*Fts5ExprNode)(unsafe.Pointer(p)).FeType {
 140002 		var nByte int32 = int32(uint32(unsafe.Sizeof(uintptr(0))) * uint32((*Fts5ExprNode)(unsafe.Pointer(pSub)).FnChild))
 140003 		libc.Xmemcpy(tls, p+32+uintptr((*Fts5ExprNode)(unsafe.Pointer(p)).FnChild)*4, pSub+32, uint32(nByte))
 140004 		*(*int32)(unsafe.Pointer(p + 28)) += (*Fts5ExprNode)(unsafe.Pointer(pSub)).FnChild
 140005 		Xsqlite3_free(tls, pSub)
 140006 	} else {
 140007 		*(*uintptr)(unsafe.Pointer(p + 32 + uintptr(libc.PostIncInt32(&(*Fts5ExprNode)(unsafe.Pointer(p)).FnChild, 1))*4)) = pSub
 140008 	}
 140009 }
 140010 
 140011 func fts5ParsePhraseToAnd(tls *libc.TLS, pParse uintptr, pNear uintptr) uintptr {
 140012 	var nTerm int32 = (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12)))).FnTerm
 140013 	var ii int32
 140014 	var nByte int32
 140015 	var pRet uintptr
 140016 
 140017 	nByte = int32(uint32(unsafe.Sizeof(Fts5ExprNode{})) + uint32(nTerm)*uint32(unsafe.Sizeof(uintptr(0))))
 140018 	pRet = sqlite3Fts5MallocZero(tls, pParse+8, int64(nByte))
 140019 	if pRet != 0 {
 140020 		(*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = FTS5_AND
 140021 		(*Fts5ExprNode)(unsafe.Pointer(pRet)).FnChild = nTerm
 140022 		fts5ExprAssignXNext(tls, pRet)
 140023 		(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase--
 140024 		for ii = 0; ii < nTerm; ii++ {
 140025 			var pPhrase uintptr = sqlite3Fts5MallocZero(tls,
 140026 				pParse+8, int64(unsafe.Sizeof(Fts5ExprPhrase{})))
 140027 			if pPhrase != 0 {
 140028 				if parseGrowPhraseArray(tls, pParse) != 0 {
 140029 					fts5ExprPhraseFree(tls, pPhrase)
 140030 				} else {
 140031 					*(*uintptr)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr(libc.PostIncInt32(&(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase, 1))*4)) = pPhrase
 140032 					(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm = 1
 140033 					(*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FzTerm = sqlite3Fts5Strndup(tls,
 140034 						pParse+8, (*Fts5ExprTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12))+20+uintptr(ii)*16)).FzTerm, -1)
 140035 					*(*uintptr)(unsafe.Pointer(pRet + 32 + uintptr(ii)*4)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING,
 140036 						uintptr(0), uintptr(0), sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), pPhrase))
 140037 				}
 140038 			}
 140039 		}
 140040 
 140041 		if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc != 0 {
 140042 			sqlite3Fts5ParseNodeFree(tls, pRet)
 140043 			pRet = uintptr(0)
 140044 		} else {
 140045 			sqlite3Fts5ParseNearsetFree(tls, pNear)
 140046 		}
 140047 	}
 140048 
 140049 	return pRet
 140050 }
 140051 
 140052 func sqlite3Fts5ParseNode(tls *libc.TLS, pParse uintptr, eType int32, pLeft uintptr, pRight uintptr, pNear uintptr) uintptr {
 140053 	bp := tls.Alloc(8)
 140054 	defer tls.Free(8)
 140055 
 140056 	var pRet uintptr = uintptr(0)
 140057 
 140058 	if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK {
 140059 		var nChild int32 = 0
 140060 		var nByte Sqlite3_int64
 140061 
 140062 		if eType == FTS5_STRING && pNear == uintptr(0) {
 140063 			return uintptr(0)
 140064 		}
 140065 		if eType != FTS5_STRING && pLeft == uintptr(0) {
 140066 			return pRight
 140067 		}
 140068 		if eType != FTS5_STRING && pRight == uintptr(0) {
 140069 			return pLeft
 140070 		}
 140071 
 140072 		if eType == FTS5_STRING &&
 140073 			(*Fts5Parse)(unsafe.Pointer(pParse)).FbPhraseToAnd != 0 &&
 140074 			(*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12)))).FnTerm > 1 {
 140075 			pRet = fts5ParsePhraseToAnd(tls, pParse, pNear)
 140076 		} else {
 140077 			if eType == FTS5_NOT {
 140078 				nChild = 2
 140079 			} else if eType == FTS5_AND || eType == FTS5_OR {
 140080 				nChild = 2
 140081 				if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == eType {
 140082 					nChild = nChild + ((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild - 1)
 140083 				}
 140084 				if (*Fts5ExprNode)(unsafe.Pointer(pRight)).FeType == eType {
 140085 					nChild = nChild + ((*Fts5ExprNode)(unsafe.Pointer(pRight)).FnChild - 1)
 140086 				}
 140087 			}
 140088 
 140089 			nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5ExprNode{})) + uint32(unsafe.Sizeof(uintptr(0)))*uint32(nChild-1))
 140090 			pRet = sqlite3Fts5MallocZero(tls, pParse+8, nByte)
 140091 
 140092 			if pRet != 0 {
 140093 				(*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = eType
 140094 				(*Fts5ExprNode)(unsafe.Pointer(pRet)).FpNear = pNear
 140095 				fts5ExprAssignXNext(tls, pRet)
 140096 				if eType == FTS5_STRING {
 140097 					var iPhrase int32
 140098 					for iPhrase = 0; iPhrase < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; iPhrase++ {
 140099 						(*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(iPhrase)*4)))).FpNode = pRet
 140100 						if (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNear + 12 + uintptr(iPhrase)*4)))).FnTerm == 0 {
 140101 							(*Fts5ExprNode)(unsafe.Pointer(pRet)).FxNext = uintptr(0)
 140102 							(*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = FTS5_EOF
 140103 						}
 140104 					}
 140105 
 140106 					if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != FTS5_DETAIL_FULL {
 140107 						var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(pNear + 12))
 140108 						if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase != 1 ||
 140109 							(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1 ||
 140110 							(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0 && (*Fts5ExprTerm)(unsafe.Pointer(pPhrase+20)).FbFirst != 0 {
 140111 							sqlite3Fts5ParseError(tls, pParse,
 140112 								ts+34819,
 140113 								libc.VaList(bp, func() uintptr {
 140114 									if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == 1 {
 140115 										return ts + 34869
 140116 									}
 140117 									return ts + 34732
 140118 								}()))
 140119 							Xsqlite3_free(tls, pRet)
 140120 							pRet = uintptr(0)
 140121 						}
 140122 					}
 140123 				} else {
 140124 					fts5ExprAddChildren(tls, pRet, pLeft)
 140125 					fts5ExprAddChildren(tls, pRet, pRight)
 140126 				}
 140127 			}
 140128 		}
 140129 	}
 140130 
 140131 	if pRet == uintptr(0) {
 140132 		sqlite3Fts5ParseNodeFree(tls, pLeft)
 140133 		sqlite3Fts5ParseNodeFree(tls, pRight)
 140134 		sqlite3Fts5ParseNearsetFree(tls, pNear)
 140135 	}
 140136 	return pRet
 140137 }
 140138 
 140139 func sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) uintptr {
 140140 	var pRet uintptr = uintptr(0)
 140141 	var pPrev uintptr
 140142 
 140143 	if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc != 0 {
 140144 		sqlite3Fts5ParseNodeFree(tls, pLeft)
 140145 		sqlite3Fts5ParseNodeFree(tls, pRight)
 140146 	} else {
 140147 		if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == FTS5_AND {
 140148 			pPrev = *(*uintptr)(unsafe.Pointer(pLeft + 32 + uintptr((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-1)*4))
 140149 		} else {
 140150 			pPrev = pLeft
 140151 		}
 140152 
 140153 		if (*Fts5ExprNode)(unsafe.Pointer(pRight)).FeType == FTS5_EOF {
 140154 			sqlite3Fts5ParseNodeFree(tls, pRight)
 140155 			pRet = pLeft
 140156 			(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase--
 140157 		} else if (*Fts5ExprNode)(unsafe.Pointer(pPrev)).FeType == FTS5_EOF {
 140158 			var ap uintptr
 140159 
 140160 			if pPrev == pLeft {
 140161 				pRet = pRight
 140162 			} else {
 140163 				*(*uintptr)(unsafe.Pointer(pLeft + 32 + uintptr((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-1)*4)) = pRight
 140164 				pRet = pLeft
 140165 			}
 140166 
 140167 			ap = (*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-1-(*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase)*4
 140168 
 140169 			libc.Xmemmove(tls, ap, ap+1*4, uint32(unsafe.Sizeof(uintptr(0)))*uint32((*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))
 140170 			(*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase--
 140171 
 140172 			sqlite3Fts5ParseNodeFree(tls, pPrev)
 140173 		} else {
 140174 			pRet = sqlite3Fts5ParseNode(tls, pParse, FTS5_AND, pLeft, pRight, uintptr(0))
 140175 		}
 140176 	}
 140177 
 140178 	return pRet
 140179 }
 140180 
 140181 func sqlite3Fts5ExprInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 {
 140182 	var rc int32 = SQLITE_OK
 140183 	_ = pGlobal
 140184 	_ = db
 140185 
 140186 	_ = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{sqlite3Fts5ParserFallback}))
 140187 
 140188 	return rc
 140189 }
 140190 
 140191 func sqlite3Fts5ExprPhraseCount(tls *libc.TLS, pExpr uintptr) int32 {
 140192 	return func() int32 {
 140193 		if pExpr != 0 {
 140194 			return (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase
 140195 		}
 140196 		return 0
 140197 	}()
 140198 }
 140199 
 140200 func sqlite3Fts5ExprPhraseSize(tls *libc.TLS, pExpr uintptr, iPhrase int32) int32 {
 140201 	if iPhrase < 0 || iPhrase >= (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase {
 140202 		return 0
 140203 	}
 140204 	return (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*4)))).FnTerm
 140205 }
 140206 
 140207 func sqlite3Fts5ExprPoslist(tls *libc.TLS, pExpr uintptr, iPhrase int32, pa uintptr) int32 {
 140208 	var nRet int32
 140209 	var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*4))
 140210 	var pNode uintptr = (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FpNode
 140211 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 && (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid {
 140212 		*(*uintptr)(unsafe.Pointer(pa)) = (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fp
 140213 		nRet = (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn
 140214 	} else {
 140215 		*(*uintptr)(unsafe.Pointer(pa)) = uintptr(0)
 140216 		nRet = 0
 140217 	}
 140218 	return nRet
 140219 }
 140220 
 140221 func sqlite3Fts5ExprClearPoslists(tls *libc.TLS, pExpr uintptr, bLive int32) uintptr {
 140222 	var pRet uintptr
 140223 	pRet = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(Fts5PoslistPopulator{}))*uint32((*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase)))
 140224 	if pRet != 0 {
 140225 		var i int32
 140226 		libc.Xmemset(tls, pRet, 0, uint32(unsafe.Sizeof(Fts5PoslistPopulator{}))*uint32((*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase))
 140227 		for i = 0; i < (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase; i++ {
 140228 			var pBuf uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*4)) + 4
 140229 			var pNode uintptr = (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*4)))).FpNode
 140230 
 140231 			if bLive != 0 && ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn == 0 || (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid != (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid || (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof != 0) {
 140232 				(*Fts5PoslistPopulator)(unsafe.Pointer(pRet + uintptr(i)*16)).FbMiss = 1
 140233 			} else {
 140234 				(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0
 140235 			}
 140236 		}
 140237 	}
 140238 	return pRet
 140239 }
 140240 
 140241 type Fts5ExprCtx1 = struct {
 140242 	FpExpr      uintptr
 140243 	FaPopulator uintptr
 140244 	FiOff       I64
 140245 }
 140246 
 140247 type Fts5ExprCtx = Fts5ExprCtx1
 140248 
 140249 func fts5ExprColsetTest(tls *libc.TLS, pColset uintptr, iCol int32) int32 {
 140250 	var i int32
 140251 	for i = 0; i < (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol; i++ {
 140252 		if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == iCol {
 140253 			return 1
 140254 		}
 140255 	}
 140256 	return 0
 140257 }
 140258 
 140259 func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) int32 {
 140260 	var p uintptr = pCtx
 140261 	var pExpr uintptr = (*Fts5ExprCtx)(unsafe.Pointer(p)).FpExpr
 140262 	var i int32
 140263 
 140264 	_ = iUnused1
 140265 	_ = iUnused2
 140266 
 140267 	if nToken > FTS5_MAX_TOKEN_SIZE {
 140268 		nToken = FTS5_MAX_TOKEN_SIZE
 140269 	}
 140270 	if tflags&FTS5_TOKEN_COLOCATED == 0 {
 140271 		(*Fts5ExprCtx)(unsafe.Pointer(p)).FiOff++
 140272 	}
 140273 	for i = 0; i < (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase; i++ {
 140274 		var pTerm uintptr
 140275 		if (*Fts5PoslistPopulator)(unsafe.Pointer((*Fts5ExprCtx)(unsafe.Pointer(p)).FaPopulator+uintptr(i)*16)).FbOk == 0 {
 140276 			continue
 140277 		}
 140278 		for pTerm = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*4)) + 20; pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym {
 140279 			var nTerm int32 = int32(libc.Xstrlen(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm))
 140280 			if (nTerm == nToken || nTerm < nToken && (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0) &&
 140281 				libc.Xmemcmp(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm, pToken, uint32(nTerm)) == 0 {
 140282 				var rc int32 = sqlite3Fts5PoslistWriterAppend(tls,
 140283 					*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*4))+4, (*Fts5ExprCtx)(unsafe.Pointer(p)).FaPopulator+uintptr(i)*16, (*Fts5ExprCtx)(unsafe.Pointer(p)).FiOff)
 140284 				if rc != 0 {
 140285 					return rc
 140286 				}
 140287 				break
 140288 			}
 140289 		}
 140290 	}
 140291 	return SQLITE_OK
 140292 }
 140293 
 140294 func sqlite3Fts5ExprPopulatePoslists(tls *libc.TLS, pConfig uintptr, pExpr uintptr, aPopulator uintptr, iCol int32, z uintptr, n int32) int32 {
 140295 	bp := tls.Alloc(16)
 140296 	defer tls.Free(16)
 140297 
 140298 	var i int32
 140299 
 140300 	(*Fts5ExprCtx)(unsafe.Pointer(bp)).FpExpr = pExpr
 140301 	(*Fts5ExprCtx)(unsafe.Pointer(bp)).FaPopulator = aPopulator
 140302 	(*Fts5ExprCtx)(unsafe.Pointer(bp)).FiOff = I64(iCol)<<32 - int64(1)
 140303 
 140304 	for i = 0; i < (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase; i++ {
 140305 		var pNode uintptr = (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*4)))).FpNode
 140306 		var pColset uintptr = (*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear)).FpColset
 140307 		if pColset != 0 && 0 == fts5ExprColsetTest(tls, pColset, iCol) ||
 140308 			(*Fts5PoslistPopulator)(unsafe.Pointer(aPopulator+uintptr(i)*16)).FbMiss != 0 {
 140309 			(*Fts5PoslistPopulator)(unsafe.Pointer(aPopulator + uintptr(i)*16)).FbOk = 0
 140310 		} else {
 140311 			(*Fts5PoslistPopulator)(unsafe.Pointer(aPopulator + uintptr(i)*16)).FbOk = 1
 140312 		}
 140313 	}
 140314 
 140315 	return sqlite3Fts5Tokenize(tls, pConfig,
 140316 		FTS5_TOKENIZE_DOCUMENT, z, n, bp, *(*uintptr)(unsafe.Pointer(&struct {
 140317 			f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 140318 		}{fts5ExprPopulatePoslistsCb})))
 140319 }
 140320 
 140321 func fts5ExprClearPoslists(tls *libc.TLS, pNode uintptr) {
 140322 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM || (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING {
 140323 		(*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 12)))).Fposlist.Fn = 0
 140324 	} else {
 140325 		var i int32
 140326 		for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 140327 			fts5ExprClearPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)))
 140328 		}
 140329 	}
 140330 }
 140331 
 140332 func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 {
 140333 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = iRowid
 140334 	(*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0
 140335 	switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType {
 140336 	case FTS5_TERM:
 140337 		fallthrough
 140338 	case FTS5_STRING:
 140339 		return libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 12)))).Fposlist.Fn > 0)
 140340 
 140341 	case FTS5_AND:
 140342 		{
 140343 			var i int32
 140344 			for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 140345 				if fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)), iRowid) == 0 {
 140346 					fts5ExprClearPoslists(tls, pNode)
 140347 					return 0
 140348 				}
 140349 			}
 140350 			break
 140351 
 140352 		}
 140353 
 140354 	case FTS5_OR:
 140355 		{
 140356 			var i int32
 140357 			var bRet int32 = 0
 140358 			for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ {
 140359 				if fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 32 + uintptr(i)*4)), iRowid) != 0 {
 140360 					bRet = 1
 140361 				}
 140362 			}
 140363 			return bRet
 140364 
 140365 		}
 140366 
 140367 	default:
 140368 		{
 140369 			if 0 == fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 32)), iRowid) ||
 140370 				0 != fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer(pNode + 32 + 1*4)), iRowid) {
 140371 				fts5ExprClearPoslists(tls, pNode)
 140372 				return 0
 140373 			}
 140374 			break
 140375 
 140376 		}
 140377 	}
 140378 	return 1
 140379 }
 140380 
 140381 func sqlite3Fts5ExprCheckPoslists(tls *libc.TLS, pExpr uintptr, iRowid I64) {
 140382 	fts5ExprCheckPoslists(tls, (*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot, iRowid)
 140383 }
 140384 
 140385 func sqlite3Fts5ExprPhraseCollist(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppCollist uintptr, pnCollist uintptr) int32 {
 140386 	var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*4))
 140387 	var pNode uintptr = (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FpNode
 140388 	var rc int32 = SQLITE_OK
 140389 
 140390 	if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 &&
 140391 		(*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid &&
 140392 		(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0 {
 140393 		var pTerm uintptr = pPhrase + 20
 140394 		if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 {
 140395 			var pBuf uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + 1*16
 140396 			rc = fts5ExprSynonymList(tls,
 140397 				pTerm, (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, pBuf, ppCollist, pnCollist)
 140398 		} else {
 140399 			*(*uintptr)(unsafe.Pointer(ppCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FpIter)).FpData
 140400 			*(*int32)(unsafe.Pointer(pnCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(pPhrase + 20)).FpIter)).FnData
 140401 		}
 140402 	} else {
 140403 		*(*uintptr)(unsafe.Pointer(ppCollist)) = uintptr(0)
 140404 		*(*int32)(unsafe.Pointer(pnCollist)) = 0
 140405 	}
 140406 
 140407 	return rc
 140408 }
 140409 
 140410 type Fts5HashEntry1 = struct {
 140411 	FpHashNext  uintptr
 140412 	FpScanNext  uintptr
 140413 	FnAlloc     int32
 140414 	FiSzPoslist int32
 140415 	FnData      int32
 140416 	FnKey       int32
 140417 	FbDel       U8
 140418 	FbContent   U8
 140419 	FiCol       I16
 140420 	FiPos       int32
 140421 	FiRowid     I64
 140422 }
 140423 
 140424 type Fts5HashEntry = Fts5HashEntry1
 140425 
 140426 func sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte uintptr) int32 {
 140427 	var rc int32 = SQLITE_OK
 140428 	var pNew uintptr
 140429 
 140430 	*(*uintptr)(unsafe.Pointer(ppNew)) = libc.AssignUintptr(&pNew, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Hash{}))))
 140431 	if pNew == uintptr(0) {
 140432 		rc = SQLITE_NOMEM
 140433 	} else {
 140434 		var nByte Sqlite3_int64
 140435 		libc.Xmemset(tls, pNew, 0, uint32(unsafe.Sizeof(Fts5Hash{})))
 140436 		(*Fts5Hash)(unsafe.Pointer(pNew)).FpnByte = pnByte
 140437 		(*Fts5Hash)(unsafe.Pointer(pNew)).FeDetail = (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail
 140438 
 140439 		(*Fts5Hash)(unsafe.Pointer(pNew)).FnSlot = 1024
 140440 		nByte = Sqlite3_int64(uint32(unsafe.Sizeof(uintptr(0))) * uint32((*Fts5Hash)(unsafe.Pointer(pNew)).FnSlot))
 140441 		(*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot = Xsqlite3_malloc64(tls, uint64(nByte))
 140442 		if (*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot == uintptr(0) {
 140443 			Xsqlite3_free(tls, pNew)
 140444 			*(*uintptr)(unsafe.Pointer(ppNew)) = uintptr(0)
 140445 			rc = SQLITE_NOMEM
 140446 		} else {
 140447 			libc.Xmemset(tls, (*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot, 0, Size_t(nByte))
 140448 		}
 140449 	}
 140450 	return rc
 140451 }
 140452 
 140453 func sqlite3Fts5HashFree(tls *libc.TLS, pHash uintptr) {
 140454 	if pHash != 0 {
 140455 		sqlite3Fts5HashClear(tls, pHash)
 140456 		Xsqlite3_free(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot)
 140457 		Xsqlite3_free(tls, pHash)
 140458 	}
 140459 }
 140460 
 140461 func sqlite3Fts5HashClear(tls *libc.TLS, pHash uintptr) {
 140462 	var i int32
 140463 	for i = 0; i < (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot; i++ {
 140464 		var pNext uintptr
 140465 		var pSlot uintptr
 140466 		for pSlot = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(i)*4)); pSlot != 0; pSlot = pNext {
 140467 			pNext = (*Fts5HashEntry)(unsafe.Pointer(pSlot)).FpHashNext
 140468 			Xsqlite3_free(tls, pSlot)
 140469 		}
 140470 	}
 140471 	libc.Xmemset(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot, 0, uint32((*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot)*uint32(unsafe.Sizeof(uintptr(0))))
 140472 	(*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry = 0
 140473 }
 140474 
 140475 func fts5HashKey(tls *libc.TLS, nSlot int32, p uintptr, n int32) uint32 {
 140476 	var i int32
 140477 	var h uint32 = uint32(13)
 140478 	for i = n - 1; i >= 0; i-- {
 140479 		h = h<<3 ^ h ^ uint32(*(*U8)(unsafe.Pointer(p + uintptr(i))))
 140480 	}
 140481 	return h % uint32(nSlot)
 140482 }
 140483 
 140484 func fts5HashKey2(tls *libc.TLS, nSlot int32, b U8, p uintptr, n int32) uint32 {
 140485 	var i int32
 140486 	var h uint32 = uint32(13)
 140487 	for i = n - 1; i >= 0; i-- {
 140488 		h = h<<3 ^ h ^ uint32(*(*U8)(unsafe.Pointer(p + uintptr(i))))
 140489 	}
 140490 	h = h<<3 ^ h ^ uint32(b)
 140491 	return h % uint32(nSlot)
 140492 }
 140493 
 140494 func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 {
 140495 	var nNew int32 = (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot * 2
 140496 	var i int32
 140497 	var apNew uintptr
 140498 	var apOld uintptr = (*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot
 140499 
 140500 	apNew = Xsqlite3_malloc64(tls, uint64(uint32(nNew)*uint32(unsafe.Sizeof(uintptr(0)))))
 140501 	if !(apNew != 0) {
 140502 		return SQLITE_NOMEM
 140503 	}
 140504 	libc.Xmemset(tls, apNew, 0, uint32(nNew)*uint32(unsafe.Sizeof(uintptr(0))))
 140505 
 140506 	for i = 0; i < (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot; i++ {
 140507 		for *(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*4)) != 0 {
 140508 			var iHash uint32
 140509 			var p uintptr = *(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*4))
 140510 			*(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*4)) = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext
 140511 			iHash = fts5HashKey(tls, nNew, p+1*40,
 140512 				int32(libc.Xstrlen(tls, p+1*40)))
 140513 			(*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext = *(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*4))
 140514 			*(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*4)) = p
 140515 		}
 140516 	}
 140517 
 140518 	Xsqlite3_free(tls, apOld)
 140519 	(*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot = nNew
 140520 	(*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot = apNew
 140521 	return SQLITE_OK
 140522 }
 140523 
 140524 func fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) int32 {
 140525 	var nRet int32 = 0
 140526 	if (*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist != 0 {
 140527 		var pPtr uintptr
 140528 		if p2 != 0 {
 140529 			pPtr = p2
 140530 		} else {
 140531 			pPtr = p
 140532 		}
 140533 		var nData int32 = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData
 140534 		if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_NONE {
 140535 			if (*Fts5HashEntry)(unsafe.Pointer(p)).FbDel != 0 {
 140536 				*(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&nData, 1)))) = U8(0x00)
 140537 				if (*Fts5HashEntry)(unsafe.Pointer(p)).FbContent != 0 {
 140538 					*(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&nData, 1)))) = U8(0x00)
 140539 				}
 140540 			}
 140541 		} else {
 140542 			var nSz int32 = nData - (*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist - 1
 140543 			var nPos int32 = nSz*2 + int32((*Fts5HashEntry)(unsafe.Pointer(p)).FbDel)
 140544 
 140545 			if nPos <= 127 {
 140546 				*(*U8)(unsafe.Pointer(pPtr + uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist))) = U8(nPos)
 140547 			} else {
 140548 				var nByte int32 = sqlite3Fts5GetVarintLen(tls, U32(nPos))
 140549 				libc.Xmemmove(tls, pPtr+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist+nByte), pPtr+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist+1), uint32(nSz))
 140550 				sqlite3Fts5PutVarint(tls, pPtr+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist), uint64(nPos))
 140551 				nData = nData + (nByte - 1)
 140552 			}
 140553 		}
 140554 
 140555 		nRet = nData - (*Fts5HashEntry)(unsafe.Pointer(p)).FnData
 140556 		if p2 == uintptr(0) {
 140557 			(*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = 0
 140558 			(*Fts5HashEntry)(unsafe.Pointer(p)).FbDel = U8(0)
 140559 			(*Fts5HashEntry)(unsafe.Pointer(p)).FbContent = U8(0)
 140560 			(*Fts5HashEntry)(unsafe.Pointer(p)).FnData = nData
 140561 		}
 140562 	}
 140563 	return nRet
 140564 }
 140565 
 140566 func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, iPos int32, bByte uint8, pToken uintptr, nToken int32) int32 {
 140567 	var iHash uint32
 140568 	var p uintptr
 140569 	var pPtr uintptr
 140570 	var nIncr int32 = 0
 140571 	var bNew int32
 140572 
 140573 	bNew = libc.Bool32((*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL)
 140574 
 140575 	iHash = fts5HashKey2(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, bByte, pToken, nToken)
 140576 	for p = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*4)); p != 0; p = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext {
 140577 		var zKey uintptr = p + 1*40
 140578 		if int32(*(*uint8)(unsafe.Pointer(zKey))) == int32(bByte) &&
 140579 			(*Fts5HashEntry)(unsafe.Pointer(p)).FnKey == nToken &&
 140580 			libc.Xmemcmp(tls, zKey+1, pToken, uint32(nToken)) == 0 {
 140581 			break
 140582 		}
 140583 	}
 140584 
 140585 	if p == uintptr(0) {
 140586 		var zKey uintptr
 140587 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5HashEntry{})) + uint32(nToken+1) + uint32(1) + uint32(64))
 140588 		if nByte < int64(128) {
 140589 			nByte = int64(128)
 140590 		}
 140591 
 140592 		if (*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry*2 >= (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot {
 140593 			var rc int32 = fts5HashResize(tls, pHash)
 140594 			if rc != SQLITE_OK {
 140595 				return rc
 140596 			}
 140597 			iHash = fts5HashKey2(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, bByte, pToken, nToken)
 140598 		}
 140599 
 140600 		p = Xsqlite3_malloc64(tls, uint64(nByte))
 140601 		if !(p != 0) {
 140602 			return SQLITE_NOMEM
 140603 		}
 140604 		libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(Fts5HashEntry{})))
 140605 		(*Fts5HashEntry)(unsafe.Pointer(p)).FnAlloc = int32(nByte)
 140606 		zKey = p + 1*40
 140607 		*(*uint8)(unsafe.Pointer(zKey)) = bByte
 140608 		libc.Xmemcpy(tls, zKey+1, pToken, uint32(nToken))
 140609 
 140610 		(*Fts5HashEntry)(unsafe.Pointer(p)).FnKey = nToken
 140611 		*(*uint8)(unsafe.Pointer(zKey + uintptr(nToken+1))) = uint8(0)
 140612 		(*Fts5HashEntry)(unsafe.Pointer(p)).FnData = int32(uint32(nToken+1+1) + uint32(unsafe.Sizeof(Fts5HashEntry{})))
 140613 		(*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*4))
 140614 		*(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*4)) = p
 140615 		(*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry++
 140616 
 140617 		*(*int32)(unsafe.Pointer(p + 16)) += sqlite3Fts5PutVarint(tls, p+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FnData), uint64(iRowid))
 140618 		(*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid
 140619 
 140620 		(*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData
 140621 		if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != FTS5_DETAIL_NONE {
 140622 			*(*int32)(unsafe.Pointer(p + 16)) += 1
 140623 			(*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = func() int16 {
 140624 				if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL {
 140625 					return int16(0)
 140626 				}
 140627 				return int16(-1)
 140628 			}()
 140629 		}
 140630 
 140631 	} else {
 140632 		if (*Fts5HashEntry)(unsafe.Pointer(p)).FnAlloc-(*Fts5HashEntry)(unsafe.Pointer(p)).FnData < 9+4+1+3+5 {
 140633 			var nNew Sqlite3_int64 = Sqlite3_int64((*Fts5HashEntry)(unsafe.Pointer(p)).FnAlloc * 2)
 140634 			var pNew uintptr
 140635 			var pp uintptr
 140636 			pNew = Xsqlite3_realloc64(tls, p, uint64(nNew))
 140637 			if pNew == uintptr(0) {
 140638 				return SQLITE_NOMEM
 140639 			}
 140640 			(*Fts5HashEntry)(unsafe.Pointer(pNew)).FnAlloc = int32(nNew)
 140641 			for pp = (*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*4; *(*uintptr)(unsafe.Pointer(pp)) != p; pp = *(*uintptr)(unsafe.Pointer(pp)) {
 140642 			}
 140643 			*(*uintptr)(unsafe.Pointer(pp)) = pNew
 140644 			p = pNew
 140645 		}
 140646 		nIncr = nIncr - (*Fts5HashEntry)(unsafe.Pointer(p)).FnData
 140647 	}
 140648 
 140649 	pPtr = p
 140650 
 140651 	if iRowid != (*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid {
 140652 		var iDiff U64 = U64(iRowid) - U64((*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid)
 140653 		fts5HashAddPoslistSize(tls, pHash, p, uintptr(0))
 140654 		*(*int32)(unsafe.Pointer(p + 16)) += sqlite3Fts5PutVarint(tls, pPtr+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FnData), iDiff)
 140655 		(*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid
 140656 		bNew = 1
 140657 		(*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData
 140658 		if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != FTS5_DETAIL_NONE {
 140659 			*(*int32)(unsafe.Pointer(p + 16)) += 1
 140660 			(*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = func() int16 {
 140661 				if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL {
 140662 					return int16(0)
 140663 				}
 140664 				return int16(-1)
 140665 			}()
 140666 			(*Fts5HashEntry)(unsafe.Pointer(p)).FiPos = 0
 140667 		}
 140668 	}
 140669 
 140670 	if iCol >= 0 {
 140671 		if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_NONE {
 140672 			(*Fts5HashEntry)(unsafe.Pointer(p)).FbContent = U8(1)
 140673 		} else {
 140674 			if iCol != int32((*Fts5HashEntry)(unsafe.Pointer(p)).FiCol) {
 140675 				if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL {
 140676 					*(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&(*Fts5HashEntry)(unsafe.Pointer(p)).FnData, 1)))) = U8(0x01)
 140677 					*(*int32)(unsafe.Pointer(p + 16)) += sqlite3Fts5PutVarint(tls, pPtr+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FnData), uint64(iCol))
 140678 					(*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = I16(iCol)
 140679 					(*Fts5HashEntry)(unsafe.Pointer(p)).FiPos = 0
 140680 				} else {
 140681 					bNew = 1
 140682 					(*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = I16(libc.AssignInt32(&iPos, iCol))
 140683 				}
 140684 			}
 140685 
 140686 			if bNew != 0 {
 140687 				*(*int32)(unsafe.Pointer(p + 16)) += sqlite3Fts5PutVarint(tls, pPtr+uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FnData), uint64(iPos-(*Fts5HashEntry)(unsafe.Pointer(p)).FiPos+2))
 140688 				(*Fts5HashEntry)(unsafe.Pointer(p)).FiPos = iPos
 140689 			}
 140690 		}
 140691 	} else {
 140692 		(*Fts5HashEntry)(unsafe.Pointer(p)).FbDel = U8(1)
 140693 	}
 140694 
 140695 	nIncr = nIncr + (*Fts5HashEntry)(unsafe.Pointer(p)).FnData
 140696 	*(*int32)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FpnByte)) += nIncr
 140697 	return SQLITE_OK
 140698 }
 140699 
 140700 func fts5HashEntryMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) uintptr {
 140701 	bp := tls.Alloc(4)
 140702 	defer tls.Free(4)
 140703 
 140704 	var p1 uintptr = pLeft
 140705 	var p2 uintptr = pRight
 140706 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 140707 	var ppOut uintptr = bp
 140708 
 140709 	for p1 != 0 || p2 != 0 {
 140710 		if p1 == uintptr(0) {
 140711 			*(*uintptr)(unsafe.Pointer(ppOut)) = p2
 140712 			p2 = uintptr(0)
 140713 		} else if p2 == uintptr(0) {
 140714 			*(*uintptr)(unsafe.Pointer(ppOut)) = p1
 140715 			p1 = uintptr(0)
 140716 		} else {
 140717 			var i int32 = 0
 140718 			var zKey1 uintptr = p1 + 1*40
 140719 			var zKey2 uintptr = p2 + 1*40
 140720 			for int32(*(*uint8)(unsafe.Pointer(zKey1 + uintptr(i)))) == int32(*(*uint8)(unsafe.Pointer(zKey2 + uintptr(i)))) {
 140721 				i++
 140722 			}
 140723 
 140724 			if int32(*(*uint8)(unsafe.Pointer(zKey1 + uintptr(i)))) > int32(*(*uint8)(unsafe.Pointer(zKey2 + uintptr(i)))) {
 140725 				*(*uintptr)(unsafe.Pointer(ppOut)) = p2
 140726 				ppOut = p2 + 4
 140727 				p2 = (*Fts5HashEntry)(unsafe.Pointer(p2)).FpScanNext
 140728 			} else {
 140729 				*(*uintptr)(unsafe.Pointer(ppOut)) = p1
 140730 				ppOut = p1 + 4
 140731 				p1 = (*Fts5HashEntry)(unsafe.Pointer(p1)).FpScanNext
 140732 			}
 140733 			*(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0)
 140734 		}
 140735 	}
 140736 
 140737 	return *(*uintptr)(unsafe.Pointer(bp))
 140738 }
 140739 
 140740 func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, ppSorted uintptr) int32 {
 140741 	var nMergeSlot int32 = 32
 140742 	var ap uintptr
 140743 	var pList uintptr
 140744 	var iSlot int32
 140745 	var i int32
 140746 
 140747 	*(*uintptr)(unsafe.Pointer(ppSorted)) = uintptr(0)
 140748 	ap = Xsqlite3_malloc64(tls, uint64(uint32(unsafe.Sizeof(uintptr(0)))*uint32(nMergeSlot)))
 140749 	if !(ap != 0) {
 140750 		return SQLITE_NOMEM
 140751 	}
 140752 	libc.Xmemset(tls, ap, 0, uint32(unsafe.Sizeof(uintptr(0)))*uint32(nMergeSlot))
 140753 
 140754 	for iSlot = 0; iSlot < (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot; iSlot++ {
 140755 		var pIter uintptr
 140756 		for pIter = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iSlot)*4)); pIter != 0; pIter = (*Fts5HashEntry)(unsafe.Pointer(pIter)).FpHashNext {
 140757 			if pTerm == uintptr(0) ||
 140758 				(*Fts5HashEntry)(unsafe.Pointer(pIter)).FnKey+1 >= nTerm && 0 == libc.Xmemcmp(tls, pIter+1*40, pTerm, uint32(nTerm)) {
 140759 				var pEntry uintptr = pIter
 140760 				(*Fts5HashEntry)(unsafe.Pointer(pEntry)).FpScanNext = uintptr(0)
 140761 				for i = 0; *(*uintptr)(unsafe.Pointer(ap + uintptr(i)*4)) != 0; i++ {
 140762 					pEntry = fts5HashEntryMerge(tls, pEntry, *(*uintptr)(unsafe.Pointer(ap + uintptr(i)*4)))
 140763 					*(*uintptr)(unsafe.Pointer(ap + uintptr(i)*4)) = uintptr(0)
 140764 				}
 140765 				*(*uintptr)(unsafe.Pointer(ap + uintptr(i)*4)) = pEntry
 140766 			}
 140767 		}
 140768 	}
 140769 
 140770 	pList = uintptr(0)
 140771 	for i = 0; i < nMergeSlot; i++ {
 140772 		pList = fts5HashEntryMerge(tls, pList, *(*uintptr)(unsafe.Pointer(ap + uintptr(i)*4)))
 140773 	}
 140774 
 140775 	(*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry = 0
 140776 	Xsqlite3_free(tls, ap)
 140777 	*(*uintptr)(unsafe.Pointer(ppSorted)) = pList
 140778 	return SQLITE_OK
 140779 }
 140780 
 140781 func sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintptr, nTerm int32, ppOut uintptr, pnDoclist uintptr) int32 {
 140782 	var iHash uint32 = fts5HashKey(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, pTerm, nTerm)
 140783 	var zKey uintptr = uintptr(0)
 140784 	var p uintptr
 140785 
 140786 	for p = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*4)); p != 0; p = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext {
 140787 		zKey = p + 1*40
 140788 
 140789 		if nTerm == (*Fts5HashEntry)(unsafe.Pointer(p)).FnKey+1 && libc.Xmemcmp(tls, zKey, pTerm, uint32(nTerm)) == 0 {
 140790 			break
 140791 		}
 140792 	}
 140793 
 140794 	if p != 0 {
 140795 		var nHashPre int32 = int32(uint32(unsafe.Sizeof(Fts5HashEntry{})) + uint32(nTerm) + uint32(1))
 140796 		var nList int32 = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - nHashPre
 140797 		var pRet uintptr = libc.AssignPtrUintptr(ppOut, Xsqlite3_malloc64(tls, uint64(nPre+nList+10)))
 140798 		if pRet != 0 {
 140799 			var pFaux uintptr = pRet + uintptr(nPre-nHashPre)
 140800 			libc.Xmemcpy(tls, pRet+uintptr(nPre), p+uintptr(nHashPre), uint32(nList))
 140801 			nList = nList + fts5HashAddPoslistSize(tls, pHash, p, pFaux)
 140802 			*(*int32)(unsafe.Pointer(pnDoclist)) = nList
 140803 		} else {
 140804 			*(*int32)(unsafe.Pointer(pnDoclist)) = 0
 140805 			return SQLITE_NOMEM
 140806 		}
 140807 	} else {
 140808 		*(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0)
 140809 		*(*int32)(unsafe.Pointer(pnDoclist)) = 0
 140810 	}
 140811 
 140812 	return SQLITE_OK
 140813 }
 140814 
 140815 func sqlite3Fts5HashScanInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32) int32 {
 140816 	return fts5HashEntrySort(tls, p, pTerm, nTerm, p+16)
 140817 }
 140818 
 140819 func sqlite3Fts5HashScanNext(tls *libc.TLS, p uintptr) {
 140820 	(*Fts5Hash)(unsafe.Pointer(p)).FpScan = (*Fts5HashEntry)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(p)).FpScan)).FpScanNext
 140821 }
 140822 
 140823 func sqlite3Fts5HashScanEof(tls *libc.TLS, p uintptr) int32 {
 140824 	return libc.Bool32((*Fts5Hash)(unsafe.Pointer(p)).FpScan == uintptr(0))
 140825 }
 140826 
 140827 func sqlite3Fts5HashScanEntry(tls *libc.TLS, pHash uintptr, pzTerm uintptr, ppDoclist uintptr, pnDoclist uintptr) {
 140828 	var p uintptr
 140829 	if libc.AssignUintptr(&p, (*Fts5Hash)(unsafe.Pointer(pHash)).FpScan) != 0 {
 140830 		var zKey uintptr = p + 1*40
 140831 		var nTerm int32 = int32(libc.Xstrlen(tls, zKey))
 140832 		fts5HashAddPoslistSize(tls, pHash, p, uintptr(0))
 140833 		*(*uintptr)(unsafe.Pointer(pzTerm)) = zKey
 140834 		*(*uintptr)(unsafe.Pointer(ppDoclist)) = zKey + uintptr(nTerm+1)
 140835 		*(*int32)(unsafe.Pointer(pnDoclist)) = int32(uint32((*Fts5HashEntry)(unsafe.Pointer(p)).FnData) - (uint32(unsafe.Sizeof(Fts5HashEntry{})) + uint32(nTerm) + uint32(1)))
 140836 	} else {
 140837 		*(*uintptr)(unsafe.Pointer(pzTerm)) = uintptr(0)
 140838 		*(*uintptr)(unsafe.Pointer(ppDoclist)) = uintptr(0)
 140839 		*(*int32)(unsafe.Pointer(pnDoclist)) = 0
 140840 	}
 140841 }
 140842 
 140843 type Fts5Data1 = struct {
 140844 	Fp      uintptr
 140845 	Fnn     int32
 140846 	FszLeaf int32
 140847 }
 140848 
 140849 type Fts5Data = Fts5Data1
 140850 type Fts5DlidxIter1 = struct {
 140851 	FnLvl   int32
 140852 	FiSegid int32
 140853 	FaLvl   [1]Fts5DlidxLvl
 140854 }
 140855 
 140856 type Fts5DlidxIter = Fts5DlidxIter1
 140857 type Fts5DlidxLvl1 = struct {
 140858 	FpData       uintptr
 140859 	FiOff        int32
 140860 	FbEof        int32
 140861 	FiFirstOff   int32
 140862 	FiLeafPgno   int32
 140863 	F__ccgo_pad1 [4]byte
 140864 	FiRowid      I64
 140865 }
 140866 
 140867 type Fts5DlidxLvl = Fts5DlidxLvl1
 140868 type Fts5DlidxWriter1 = struct {
 140869 	Fpgno        int32
 140870 	FbPrevValid  int32
 140871 	FiPrev       I64
 140872 	Fbuf         Fts5Buffer
 140873 	F__ccgo_pad1 [4]byte
 140874 }
 140875 
 140876 type Fts5DlidxWriter = Fts5DlidxWriter1
 140877 type Fts5Iter1 = struct {
 140878 	Fbase         Fts5IndexIter
 140879 	FpIndex       uintptr
 140880 	Fposlist      Fts5Buffer
 140881 	FpColset      uintptr
 140882 	FxSetOutputs  uintptr
 140883 	FnSeg         int32
 140884 	FbRev         int32
 140885 	FbSkipEmpty   U8
 140886 	F__ccgo_pad1  [7]byte
 140887 	FiSwitchRowid I64
 140888 	FaFirst       uintptr
 140889 	F__ccgo_pad2  [4]byte
 140890 	FaSeg         [1]Fts5SegIter
 140891 }
 140892 
 140893 type Fts5Iter = Fts5Iter1
 140894 type Fts5PageWriter1 = struct {
 140895 	Fpgno       int32
 140896 	FiPrevPgidx int32
 140897 	Fbuf        Fts5Buffer
 140898 	Fpgidx      Fts5Buffer
 140899 	Fterm       Fts5Buffer
 140900 }
 140901 
 140902 type Fts5PageWriter = Fts5PageWriter1
 140903 type Fts5SegIter1 = struct {
 140904 	FpSeg            uintptr
 140905 	Fflags           int32
 140906 	FiLeafPgno       int32
 140907 	FpLeaf           uintptr
 140908 	FpNextLeaf       uintptr
 140909 	F__ccgo_pad1     [4]byte
 140910 	FiLeafOffset     I64
 140911 	FxNext           uintptr
 140912 	FiTermLeafPgno   int32
 140913 	FiTermLeafOffset int32
 140914 	FiPgidxOff       int32
 140915 	FiEndofDoclist   int32
 140916 	FiRowidOffset    int32
 140917 	FnRowidOffset    int32
 140918 	FaRowidOffset    uintptr
 140919 	FpDlidx          uintptr
 140920 	Fterm            Fts5Buffer
 140921 	FiRowid          I64
 140922 	FnPos            int32
 140923 	FbDel            U8
 140924 	F__ccgo_pad2     [3]byte
 140925 }
 140926 
 140927 type Fts5SegIter = Fts5SegIter1
 140928 type Fts5DoclistIter1 = struct {
 140929 	FaEof        uintptr
 140930 	F__ccgo_pad1 [4]byte
 140931 	FiRowid      I64
 140932 	FaPoslist    uintptr
 140933 	FnPoslist    int32
 140934 	FnSize       int32
 140935 	F__ccgo_pad2 [4]byte
 140936 }
 140937 
 140938 type Fts5DoclistIter = Fts5DoclistIter1
 140939 type Fts5SegWriter1 = struct {
 140940 	FiSegid               int32
 140941 	Fwriter               Fts5PageWriter
 140942 	FiPrevRowid           I64
 140943 	FbFirstRowidInDoclist U8
 140944 	FbFirstRowidInPage    U8
 140945 	FbFirstTermInPage     U8
 140946 	F__ccgo_pad1          [1]byte
 140947 	FnLeafWritten         int32
 140948 	FnEmpty               int32
 140949 	FnDlidx               int32
 140950 	FaDlidx               uintptr
 140951 	Fbtterm               Fts5Buffer
 140952 	FiBtPage              int32
 140953 	F__ccgo_pad2          [4]byte
 140954 }
 140955 
 140956 type Fts5SegWriter = Fts5SegWriter1
 140957 type Fts5Structure1 = struct {
 140958 	FnRef          int32
 140959 	F__ccgo_pad1   [4]byte
 140960 	FnWriteCounter U64
 140961 	FnSegment      int32
 140962 	FnLevel        int32
 140963 	FaLevel        [1]Fts5StructureLevel
 140964 	F__ccgo_pad2   [4]byte
 140965 }
 140966 
 140967 type Fts5Structure = Fts5Structure1
 140968 type Fts5StructureLevel1 = struct {
 140969 	FnMerge int32
 140970 	FnSeg   int32
 140971 	FaSeg   uintptr
 140972 }
 140973 
 140974 type Fts5StructureLevel = Fts5StructureLevel1
 140975 type Fts5StructureSegment1 = struct {
 140976 	FiSegid    int32
 140977 	FpgnoFirst int32
 140978 	FpgnoLast  int32
 140979 }
 140980 
 140981 type Fts5StructureSegment = Fts5StructureSegment1
 140982 
 140983 type Fts5CResult1 = struct {
 140984 	FiFirst      U16
 140985 	FbTermEq     U8
 140986 	F__ccgo_pad1 [1]byte
 140987 }
 140988 
 140989 type Fts5CResult = Fts5CResult1
 140990 
 140991 func fts5PutU16(tls *libc.TLS, aOut uintptr, iVal U16) {
 140992 	*(*U8)(unsafe.Pointer(aOut)) = U8(int32(iVal) >> 8)
 140993 	*(*U8)(unsafe.Pointer(aOut + 1)) = U8(int32(iVal) & 0xFF)
 140994 }
 140995 
 140996 func fts5GetU16(tls *libc.TLS, aIn uintptr) U16 {
 140997 	return U16(int32(U16(*(*U8)(unsafe.Pointer(aIn))))<<8 + int32(*(*U8)(unsafe.Pointer(aIn + 1))))
 140998 }
 140999 
 141000 func fts5IdxMalloc(tls *libc.TLS, p uintptr, nByte Sqlite3_int64) uintptr {
 141001 	return sqlite3Fts5MallocZero(tls, p+36, nByte)
 141002 }
 141003 
 141004 func fts5BufferCompare(tls *libc.TLS, pLeft uintptr, pRight uintptr) int32 {
 141005 	var nCmp int32
 141006 	var res int32
 141007 	nCmp = func() int32 {
 141008 		if (*Fts5Buffer)(unsafe.Pointer(pLeft)).Fn < (*Fts5Buffer)(unsafe.Pointer(pRight)).Fn {
 141009 			return (*Fts5Buffer)(unsafe.Pointer(pLeft)).Fn
 141010 		}
 141011 		return (*Fts5Buffer)(unsafe.Pointer(pRight)).Fn
 141012 	}()
 141013 
 141014 	res = func() int32 {
 141015 		if nCmp <= 0 {
 141016 			return 0
 141017 		}
 141018 		return libc.Xmemcmp(tls, (*Fts5Buffer)(unsafe.Pointer(pLeft)).Fp, (*Fts5Buffer)(unsafe.Pointer(pRight)).Fp, uint32(nCmp))
 141019 	}()
 141020 	return func() int32 {
 141021 		if res == 0 {
 141022 			return (*Fts5Buffer)(unsafe.Pointer(pLeft)).Fn - (*Fts5Buffer)(unsafe.Pointer(pRight)).Fn
 141023 		}
 141024 		return res
 141025 	}()
 141026 }
 141027 
 141028 func fts5LeafFirstTermOff(tls *libc.TLS, pLeaf uintptr) int32 {
 141029 	bp := tls.Alloc(4)
 141030 	defer tls.Free(4)
 141031 
 141032 	sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf), bp)
 141033 	return *(*int32)(unsafe.Pointer(bp))
 141034 }
 141035 
 141036 func sqlite3Fts5IndexCloseReader(tls *libc.TLS, p uintptr) {
 141037 	if (*Fts5Index)(unsafe.Pointer(p)).FpReader != 0 {
 141038 		var pReader uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpReader
 141039 		(*Fts5Index)(unsafe.Pointer(p)).FpReader = uintptr(0)
 141040 		Xsqlite3_blob_close(tls, pReader)
 141041 	}
 141042 }
 141043 
 141044 func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr {
 141045 	var pRet uintptr = uintptr(0)
 141046 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141047 		var rc int32 = SQLITE_OK
 141048 
 141049 		if (*Fts5Index)(unsafe.Pointer(p)).FpReader != 0 {
 141050 			var pBlob uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpReader
 141051 			(*Fts5Index)(unsafe.Pointer(p)).FpReader = uintptr(0)
 141052 			rc = Xsqlite3_blob_reopen(tls, pBlob, iRowid)
 141053 
 141054 			(*Fts5Index)(unsafe.Pointer(p)).FpReader = pBlob
 141055 			if rc != SQLITE_OK {
 141056 				sqlite3Fts5IndexCloseReader(tls, p)
 141057 			}
 141058 			if rc == SQLITE_ABORT {
 141059 				rc = SQLITE_OK
 141060 			}
 141061 		}
 141062 
 141063 		if (*Fts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0) && rc == SQLITE_OK {
 141064 			var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 141065 			rc = Xsqlite3_blob_open(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb,
 141066 				(*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl, ts+34876, iRowid, 0, p+40)
 141067 		}
 141068 
 141069 		if rc == SQLITE_ERROR {
 141070 			rc = SQLITE_CORRUPT | int32(1)<<8
 141071 		}
 141072 
 141073 		if rc == SQLITE_OK {
 141074 			var aOut uintptr = uintptr(0)
 141075 			var nByte int32 = Xsqlite3_blob_bytes(tls, (*Fts5Index)(unsafe.Pointer(p)).FpReader)
 141076 			var nAlloc Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Data{})) + uint32(nByte) + uint32(FTS5_DATA_PADDING))
 141077 			pRet = Xsqlite3_malloc64(tls, uint64(nAlloc))
 141078 			if pRet != 0 {
 141079 				(*Fts5Data)(unsafe.Pointer(pRet)).Fnn = nByte
 141080 				aOut = libc.AssignPtrUintptr(pRet, pRet+1*12)
 141081 			} else {
 141082 				rc = SQLITE_NOMEM
 141083 			}
 141084 
 141085 			if rc == SQLITE_OK {
 141086 				rc = Xsqlite3_blob_read(tls, (*Fts5Index)(unsafe.Pointer(p)).FpReader, aOut, nByte, 0)
 141087 			}
 141088 			if rc != SQLITE_OK {
 141089 				Xsqlite3_free(tls, pRet)
 141090 				pRet = uintptr(0)
 141091 			} else {
 141092 				*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte))) = U8(0x00)
 141093 				*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte+1))) = U8(0x00)
 141094 				(*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pRet)).Fp+2))
 141095 			}
 141096 		}
 141097 		(*Fts5Index)(unsafe.Pointer(p)).Frc = rc
 141098 		(*Fts5Index)(unsafe.Pointer(p)).FnRead++
 141099 	}
 141100 
 141101 	return pRet
 141102 }
 141103 
 141104 func fts5DataRelease(tls *libc.TLS, pData uintptr) {
 141105 	Xsqlite3_free(tls, pData)
 141106 }
 141107 
 141108 func fts5LeafRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr {
 141109 	var pRet uintptr = fts5DataRead(tls, p, iRowid)
 141110 	if pRet != 0 {
 141111 		if (*Fts5Data)(unsafe.Pointer(pRet)).Fnn < 4 || (*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf > (*Fts5Data)(unsafe.Pointer(pRet)).Fnn {
 141112 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 141113 			fts5DataRelease(tls, pRet)
 141114 			pRet = uintptr(0)
 141115 		}
 141116 	}
 141117 	return pRet
 141118 }
 141119 
 141120 func fts5IndexPrepareStmt(tls *libc.TLS, p uintptr, ppStmt uintptr, zSql uintptr) int32 {
 141121 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141122 		if zSql != 0 {
 141123 			(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fdb, zSql, -1,
 141124 				uint32(SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB),
 141125 				ppStmt, uintptr(0))
 141126 		} else {
 141127 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 141128 		}
 141129 	}
 141130 	Xsqlite3_free(tls, zSql)
 141131 	return (*Fts5Index)(unsafe.Pointer(p)).Frc
 141132 }
 141133 
 141134 func fts5DataWrite(tls *libc.TLS, p uintptr, iRowid I64, pData uintptr, nData int32) {
 141135 	bp := tls.Alloc(16)
 141136 	defer tls.Free(16)
 141137 
 141138 	if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 141139 		return
 141140 	}
 141141 
 141142 	if (*Fts5Index)(unsafe.Pointer(p)).FpWriter == uintptr(0) {
 141143 		var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 141144 		fts5IndexPrepareStmt(tls, p, p+44, Xsqlite3_mprintf(tls,
 141145 			ts+34882,
 141146 			libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)))
 141147 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 141148 			return
 141149 		}
 141150 	}
 141151 
 141152 	Xsqlite3_bind_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpWriter, 1, iRowid)
 141153 	Xsqlite3_bind_blob(tls, (*Fts5Index)(unsafe.Pointer(p)).FpWriter, 2, pData, nData, uintptr(0))
 141154 	Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpWriter)
 141155 	(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpWriter)
 141156 	Xsqlite3_bind_null(tls, (*Fts5Index)(unsafe.Pointer(p)).FpWriter, 2)
 141157 }
 141158 
 141159 func fts5DataDelete(tls *libc.TLS, p uintptr, iFirst I64, iLast I64) {
 141160 	bp := tls.Alloc(16)
 141161 	defer tls.Free(16)
 141162 
 141163 	if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 141164 		return
 141165 	}
 141166 
 141167 	if (*Fts5Index)(unsafe.Pointer(p)).FpDeleter == uintptr(0) {
 141168 		var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 141169 		var zSql uintptr = Xsqlite3_mprintf(tls,
 141170 			ts+34933,
 141171 			libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 141172 		if fts5IndexPrepareStmt(tls, p, p+48, zSql) != 0 {
 141173 			return
 141174 		}
 141175 	}
 141176 
 141177 	Xsqlite3_bind_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDeleter, 1, iFirst)
 141178 	Xsqlite3_bind_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDeleter, 2, iLast)
 141179 	Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDeleter)
 141180 	(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDeleter)
 141181 }
 141182 
 141183 func fts5DataRemoveSegment(tls *libc.TLS, p uintptr, iSegid int32) {
 141184 	bp := tls.Alloc(16)
 141185 	defer tls.Free(16)
 141186 
 141187 	var iFirst I64 = I64(iSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + int64(0)
 141188 	var iLast I64 = I64(iSegid+1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + int64(0) - int64(1)
 141189 	fts5DataDelete(tls, p, iFirst, iLast)
 141190 	if (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter == uintptr(0) {
 141191 		var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 141192 		fts5IndexPrepareStmt(tls, p, p+56, Xsqlite3_mprintf(tls,
 141193 			ts+34982,
 141194 			libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)))
 141195 	}
 141196 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141197 		Xsqlite3_bind_int(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter, 1, iSegid)
 141198 		Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter)
 141199 		(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter)
 141200 	}
 141201 }
 141202 
 141203 func fts5StructureRelease(tls *libc.TLS, pStruct uintptr) {
 141204 	if pStruct != 0 && 0 >= libc.PreDecInt32(&(*Fts5Structure)(unsafe.Pointer(pStruct)).FnRef, 1) {
 141205 		var i int32
 141206 
 141207 		for i = 0; i < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; i++ {
 141208 			Xsqlite3_free(tls, (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(i)*12)).FaSeg)
 141209 		}
 141210 		Xsqlite3_free(tls, pStruct)
 141211 	}
 141212 }
 141213 
 141214 func fts5StructureRef(tls *libc.TLS, pStruct uintptr) {
 141215 	(*Fts5Structure)(unsafe.Pointer(pStruct)).FnRef++
 141216 }
 141217 
 141218 func sqlite3Fts5StructureRef(tls *libc.TLS, p uintptr) uintptr {
 141219 	fts5StructureRef(tls, (*Fts5Index)(unsafe.Pointer(p)).FpStruct)
 141220 	return (*Fts5Index)(unsafe.Pointer(p)).FpStruct
 141221 }
 141222 
 141223 func sqlite3Fts5StructureRelease(tls *libc.TLS, p uintptr) {
 141224 	if p != 0 {
 141225 		fts5StructureRelease(tls, p)
 141226 	}
 141227 }
 141228 
 141229 func sqlite3Fts5StructureTest(tls *libc.TLS, p uintptr, pStruct uintptr) int32 {
 141230 	if (*Fts5Index)(unsafe.Pointer(p)).FpStruct != pStruct {
 141231 		return SQLITE_ABORT
 141232 	}
 141233 	return SQLITE_OK
 141234 }
 141235 
 141236 func fts5StructureMakeWritable(tls *libc.TLS, pRc uintptr, pp uintptr) {
 141237 	var p uintptr = *(*uintptr)(unsafe.Pointer(pp))
 141238 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK && (*Fts5Structure)(unsafe.Pointer(p)).FnRef > 1 {
 141239 		var nByte I64 = I64(uint32(unsafe.Sizeof(Fts5Structure{})) + uint32((*Fts5Structure)(unsafe.Pointer(p)).FnLevel-1)*uint32(unsafe.Sizeof(Fts5StructureLevel{})))
 141240 		var pNew uintptr
 141241 		pNew = sqlite3Fts5MallocZero(tls, pRc, nByte)
 141242 		if pNew != 0 {
 141243 			var i int32
 141244 			libc.Xmemcpy(tls, pNew, p, uint32(nByte))
 141245 			for i = 0; i < (*Fts5Structure)(unsafe.Pointer(p)).FnLevel; i++ {
 141246 				(*Fts5StructureLevel)(unsafe.Pointer(pNew + 24 + uintptr(i)*12)).FaSeg = uintptr(0)
 141247 			}
 141248 			for i = 0; i < (*Fts5Structure)(unsafe.Pointer(p)).FnLevel; i++ {
 141249 				var pLvl uintptr = pNew + 24 + uintptr(i)*12
 141250 				nByte = I64(uint32(unsafe.Sizeof(Fts5StructureSegment{})) * uint32((*Fts5StructureLevel)(unsafe.Pointer(pNew+24+uintptr(i)*12)).FnSeg))
 141251 				(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = sqlite3Fts5MallocZero(tls, pRc, nByte)
 141252 				if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg == uintptr(0) {
 141253 					for i = 0; i < (*Fts5Structure)(unsafe.Pointer(p)).FnLevel; i++ {
 141254 						Xsqlite3_free(tls, (*Fts5StructureLevel)(unsafe.Pointer(pNew+24+uintptr(i)*12)).FaSeg)
 141255 					}
 141256 					Xsqlite3_free(tls, pNew)
 141257 					return
 141258 				}
 141259 				libc.Xmemcpy(tls, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, (*Fts5StructureLevel)(unsafe.Pointer(p+24+uintptr(i)*12)).FaSeg, uint32(nByte))
 141260 			}
 141261 			(*Fts5Structure)(unsafe.Pointer(p)).FnRef--
 141262 			(*Fts5Structure)(unsafe.Pointer(pNew)).FnRef = 1
 141263 		}
 141264 		*(*uintptr)(unsafe.Pointer(pp)) = pNew
 141265 	}
 141266 }
 141267 
 141268 func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uintptr, ppOut uintptr) int32 {
 141269 	bp := tls.Alloc(16)
 141270 	defer tls.Free(16)
 141271 
 141272 	*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_OK
 141273 	var i int32 = 0
 141274 	var iLvl int32
 141275 	*(*int32)(unsafe.Pointer(bp)) = 0
 141276 	*(*int32)(unsafe.Pointer(bp + 4)) = 0
 141277 	var nByte Sqlite3_int64
 141278 	var pRet uintptr = uintptr(0)
 141279 
 141280 	if piCookie != 0 {
 141281 		*(*int32)(unsafe.Pointer(piCookie)) = sqlite3Fts5Get32(tls, pData)
 141282 	}
 141283 	i = 4
 141284 
 141285 	i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp)
 141286 	i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp+4)
 141287 	if *(*int32)(unsafe.Pointer(bp)) > FTS5_MAX_SEGMENT || *(*int32)(unsafe.Pointer(bp)) < 0 ||
 141288 		*(*int32)(unsafe.Pointer(bp + 4)) > FTS5_MAX_SEGMENT || *(*int32)(unsafe.Pointer(bp + 4)) < 0 {
 141289 		return SQLITE_CORRUPT | int32(1)<<8
 141290 	}
 141291 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Structure{})) + uint32(unsafe.Sizeof(Fts5StructureLevel{}))*uint32(*(*int32)(unsafe.Pointer(bp))-1))
 141292 	pRet = sqlite3Fts5MallocZero(tls, bp+8, nByte)
 141293 
 141294 	if pRet != 0 {
 141295 		(*Fts5Structure)(unsafe.Pointer(pRet)).FnRef = 1
 141296 		(*Fts5Structure)(unsafe.Pointer(pRet)).FnLevel = *(*int32)(unsafe.Pointer(bp))
 141297 		(*Fts5Structure)(unsafe.Pointer(pRet)).FnSegment = *(*int32)(unsafe.Pointer(bp + 4))
 141298 		i = i + int32(sqlite3Fts5GetVarint(tls, pData+uintptr(i), pRet+8))
 141299 
 141300 		for iLvl = 0; *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK && iLvl < *(*int32)(unsafe.Pointer(bp)); iLvl++ {
 141301 			var pLvl uintptr = pRet + 24 + uintptr(iLvl)*12
 141302 			*(*int32)(unsafe.Pointer(bp + 12)) = 0
 141303 			var iSeg int32
 141304 
 141305 			if i >= nData {
 141306 				*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141307 			} else {
 141308 				i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), pLvl)
 141309 				i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), bp+12)
 141310 				if *(*int32)(unsafe.Pointer(bp + 12)) < (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge {
 141311 					*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141312 				}
 141313 				(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = sqlite3Fts5MallocZero(tls, bp+8,
 141314 					int64(uint32(*(*int32)(unsafe.Pointer(bp + 12)))*uint32(unsafe.Sizeof(Fts5StructureSegment{}))))
 141315 				*(*int32)(unsafe.Pointer(bp + 4)) -= *(*int32)(unsafe.Pointer(bp + 12))
 141316 			}
 141317 
 141318 			if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 141319 				(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg = *(*int32)(unsafe.Pointer(bp + 12))
 141320 				for iSeg = 0; iSeg < *(*int32)(unsafe.Pointer(bp + 12)); iSeg++ {
 141321 					var pSeg uintptr = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*12
 141322 					if i >= nData {
 141323 						*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141324 						break
 141325 					}
 141326 					i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), pSeg)
 141327 					i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), pSeg+4)
 141328 					i = i + sqlite3Fts5GetVarint32(tls, pData+uintptr(i), pSeg+8)
 141329 					if (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst {
 141330 						*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141331 						break
 141332 					}
 141333 				}
 141334 				if iLvl > 0 && (*Fts5StructureLevel)(unsafe.Pointer(pLvl+libc.UintptrFromInt32(-1)*12)).FnMerge != 0 && *(*int32)(unsafe.Pointer(bp + 12)) == 0 {
 141335 					*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141336 				}
 141337 				if iLvl == *(*int32)(unsafe.Pointer(bp))-1 && (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 {
 141338 					*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141339 				}
 141340 			}
 141341 		}
 141342 		if *(*int32)(unsafe.Pointer(bp + 4)) != 0 && *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 141343 			*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_CORRUPT | int32(1)<<8
 141344 		}
 141345 
 141346 		if *(*int32)(unsafe.Pointer(bp + 8)) != SQLITE_OK {
 141347 			fts5StructureRelease(tls, pRet)
 141348 			pRet = uintptr(0)
 141349 		}
 141350 	}
 141351 
 141352 	*(*uintptr)(unsafe.Pointer(ppOut)) = pRet
 141353 	return *(*int32)(unsafe.Pointer(bp + 8))
 141354 }
 141355 
 141356 func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) {
 141357 	fts5StructureMakeWritable(tls, pRc, ppStruct)
 141358 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 141359 		var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct))
 141360 		var nLevel int32 = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel
 141361 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Structure{})) + uint32(unsafe.Sizeof(Fts5StructureLevel{}))*uint32(nLevel+1))
 141362 
 141363 		pStruct = Xsqlite3_realloc64(tls, pStruct, uint64(nByte))
 141364 		if pStruct != 0 {
 141365 			libc.Xmemset(tls, pStruct+24+uintptr(nLevel)*12, 0, uint32(unsafe.Sizeof(Fts5StructureLevel{})))
 141366 			(*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel++
 141367 			*(*uintptr)(unsafe.Pointer(ppStruct)) = pStruct
 141368 		} else {
 141369 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 141370 		}
 141371 	}
 141372 }
 141373 
 141374 func fts5StructureExtendLevel(tls *libc.TLS, pRc uintptr, pStruct uintptr, iLvl int32, nExtra int32, bInsert int32) {
 141375 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 141376 		var pLvl uintptr = pStruct + 24 + uintptr(iLvl)*12
 141377 		var aNew uintptr
 141378 		var nByte Sqlite3_int64
 141379 
 141380 		nByte = Sqlite3_int64(uint32((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg+nExtra) * uint32(unsafe.Sizeof(Fts5StructureSegment{})))
 141381 		aNew = Xsqlite3_realloc64(tls, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, uint64(nByte))
 141382 		if aNew != 0 {
 141383 			if bInsert == 0 {
 141384 				libc.Xmemset(tls, aNew+uintptr((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg)*12, 0, uint32(unsafe.Sizeof(Fts5StructureSegment{}))*uint32(nExtra))
 141385 			} else {
 141386 				var nMove int32 = int32(uint32((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg) * uint32(unsafe.Sizeof(Fts5StructureSegment{})))
 141387 				libc.Xmemmove(tls, aNew+uintptr(nExtra)*12, aNew, uint32(nMove))
 141388 				libc.Xmemset(tls, aNew, 0, uint32(unsafe.Sizeof(Fts5StructureSegment{}))*uint32(nExtra))
 141389 			}
 141390 			(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = aNew
 141391 		} else {
 141392 			*(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM
 141393 		}
 141394 	}
 141395 }
 141396 
 141397 func fts5StructureReadUncached(tls *libc.TLS, p uintptr) uintptr {
 141398 	bp := tls.Alloc(8)
 141399 	defer tls.Free(8)
 141400 
 141401 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 141402 	var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 141403 
 141404 	var pData uintptr
 141405 
 141406 	pData = fts5DataRead(tls, p, int64(FTS5_STRUCTURE_ROWID))
 141407 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141408 		libc.Xmemset(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*Fts5Data)(unsafe.Pointer(pData)).Fnn), 0, uint32(FTS5_DATA_PADDING))
 141409 		(*Fts5Index)(unsafe.Pointer(p)).Frc = fts5StructureDecode(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (*Fts5Data)(unsafe.Pointer(pData)).Fnn, bp, bp+4)
 141410 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && ((*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0 || (*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie != *(*int32)(unsafe.Pointer(bp))) {
 141411 			(*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5ConfigLoad(tls, pConfig, *(*int32)(unsafe.Pointer(bp)))
 141412 		}
 141413 		fts5DataRelease(tls, pData)
 141414 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 141415 			fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 141416 			*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 141417 		}
 141418 	}
 141419 
 141420 	return *(*uintptr)(unsafe.Pointer(bp + 4))
 141421 }
 141422 
 141423 func fts5IndexDataVersion(tls *libc.TLS, p uintptr) I64 {
 141424 	bp := tls.Alloc(8)
 141425 	defer tls.Free(8)
 141426 
 141427 	var iVersion I64 = int64(0)
 141428 
 141429 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141430 		if (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion == uintptr(0) {
 141431 			(*Fts5Index)(unsafe.Pointer(p)).Frc = fts5IndexPrepareStmt(tls, p, p+68,
 141432 				Xsqlite3_mprintf(tls, ts+35022, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FzDb)))
 141433 			if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 141434 				return int64(0)
 141435 			}
 141436 		}
 141437 
 141438 		if SQLITE_ROW == Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) {
 141439 			iVersion = Xsqlite3_column_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion, 0)
 141440 		}
 141441 		(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion)
 141442 	}
 141443 
 141444 	return iVersion
 141445 }
 141446 
 141447 func fts5StructureRead(tls *libc.TLS, p uintptr) uintptr {
 141448 	if (*Fts5Index)(unsafe.Pointer(p)).FpStruct == uintptr(0) {
 141449 		(*Fts5Index)(unsafe.Pointer(p)).FiStructVersion = fts5IndexDataVersion(tls, p)
 141450 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141451 			(*Fts5Index)(unsafe.Pointer(p)).FpStruct = fts5StructureReadUncached(tls, p)
 141452 		}
 141453 	}
 141454 
 141455 	if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 141456 		return uintptr(0)
 141457 	}
 141458 
 141459 	fts5StructureRef(tls, (*Fts5Index)(unsafe.Pointer(p)).FpStruct)
 141460 	return (*Fts5Index)(unsafe.Pointer(p)).FpStruct
 141461 }
 141462 
 141463 func fts5StructureInvalidate(tls *libc.TLS, p uintptr) {
 141464 	if (*Fts5Index)(unsafe.Pointer(p)).FpStruct != 0 {
 141465 		fts5StructureRelease(tls, (*Fts5Index)(unsafe.Pointer(p)).FpStruct)
 141466 		(*Fts5Index)(unsafe.Pointer(p)).FpStruct = uintptr(0)
 141467 	}
 141468 }
 141469 
 141470 func fts5StructureWrite(tls *libc.TLS, p uintptr, pStruct uintptr) {
 141471 	bp := tls.Alloc(12)
 141472 	defer tls.Free(12)
 141473 
 141474 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141475 		var iLvl int32
 141476 		var iCookie int32
 141477 
 141478 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 141479 
 141480 		iCookie = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FiCookie
 141481 		if iCookie < 0 {
 141482 			iCookie = 0
 141483 		}
 141484 
 141485 		if 0 == sqlite3Fts5BufferSize(tls, p+36, bp, uint32(4+9+9+9)) {
 141486 			sqlite3Fts5Put32(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, iCookie)
 141487 			(*Fts5Buffer)(unsafe.Pointer(bp)).Fn = 4
 141488 			{
 141489 				*(*int32)(unsafe.Pointer(bp + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp)).Fn), uint64((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel))
 141490 			}
 141491 
 141492 			{
 141493 				*(*int32)(unsafe.Pointer(bp + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp)).Fn), uint64((*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment))
 141494 			}
 141495 
 141496 			{
 141497 				*(*int32)(unsafe.Pointer(bp + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp)).Fn), uint64(I64((*Fts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter)))
 141498 			}
 141499 
 141500 		}
 141501 
 141502 		for iLvl = 0; iLvl < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; iLvl++ {
 141503 			var iSeg int32
 141504 			var pLvl uintptr = pStruct + 24 + uintptr(iLvl)*12
 141505 			sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge))
 141506 			sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg))
 141507 
 141508 			for iSeg = 0; iSeg < (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg; iSeg++ {
 141509 				sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(iSeg)*12)).FiSegid))
 141510 				sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(iSeg)*12)).FpgnoFirst))
 141511 				sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(iSeg)*12)).FpgnoLast))
 141512 			}
 141513 		}
 141514 
 141515 		fts5DataWrite(tls, p, int64(FTS5_STRUCTURE_ROWID), (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp)).Fn)
 141516 		sqlite3Fts5BufferFree(tls, bp)
 141517 	}
 141518 }
 141519 
 141520 func fts5SegmentSize(tls *libc.TLS, pSeg uintptr) int32 {
 141521 	return 1 + (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast - (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst
 141522 }
 141523 
 141524 func fts5StructurePromoteTo(tls *libc.TLS, p uintptr, iPromote int32, szPromote int32, pStruct uintptr) {
 141525 	var il int32
 141526 	var is int32
 141527 	var pOut uintptr = pStruct + 24 + uintptr(iPromote)*12
 141528 
 141529 	if (*Fts5StructureLevel)(unsafe.Pointer(pOut)).FnMerge == 0 {
 141530 		for il = iPromote + 1; il < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; il++ {
 141531 			var pLvl uintptr = pStruct + 24 + uintptr(il)*12
 141532 			if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 {
 141533 				return
 141534 			}
 141535 			for is = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - 1; is >= 0; is-- {
 141536 				var sz int32 = fts5SegmentSize(tls, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(is)*12)
 141537 				if sz > szPromote {
 141538 					return
 141539 				}
 141540 				fts5StructureExtendLevel(tls, p+36, pStruct, iPromote, 1, 1)
 141541 				if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 141542 					return
 141543 				}
 141544 				libc.Xmemcpy(tls, (*Fts5StructureLevel)(unsafe.Pointer(pOut)).FaSeg, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(is)*12, uint32(unsafe.Sizeof(Fts5StructureSegment{})))
 141545 				(*Fts5StructureLevel)(unsafe.Pointer(pOut)).FnSeg++
 141546 				(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg--
 141547 			}
 141548 		}
 141549 	}
 141550 }
 141551 
 141552 func fts5StructurePromote(tls *libc.TLS, p uintptr, iLvl int32, pStruct uintptr) {
 141553 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141554 		var iTst int32
 141555 		var iPromote int32 = -1
 141556 		var szPromote int32 = 0
 141557 		var pSeg uintptr
 141558 		var szSeg int32
 141559 		var nSeg int32 = (*Fts5StructureLevel)(unsafe.Pointer(pStruct + 24 + uintptr(iLvl)*12)).FnSeg
 141560 
 141561 		if nSeg == 0 {
 141562 			return
 141563 		}
 141564 		pSeg = (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FaSeg + uintptr((*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FnSeg-1)*12
 141565 		szSeg = 1 + (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast - (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst
 141566 
 141567 		for iTst = iLvl - 1; iTst >= 0 && (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iTst)*12)).FnSeg == 0; iTst-- {
 141568 		}
 141569 		if iTst >= 0 {
 141570 			var i int32
 141571 			var szMax int32 = 0
 141572 			var pTst uintptr = pStruct + 24 + uintptr(iTst)*12
 141573 
 141574 			for i = 0; i < (*Fts5StructureLevel)(unsafe.Pointer(pTst)).FnSeg; i++ {
 141575 				var sz int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pTst)).FaSeg+uintptr(i)*12)).FpgnoLast - (*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pTst)).FaSeg+uintptr(i)*12)).FpgnoFirst + 1
 141576 				if sz > szMax {
 141577 					szMax = sz
 141578 				}
 141579 			}
 141580 			if szMax >= szSeg {
 141581 				iPromote = iTst
 141582 				szPromote = szMax
 141583 			}
 141584 		}
 141585 
 141586 		if iPromote < 0 {
 141587 			iPromote = iLvl
 141588 			szPromote = szSeg
 141589 		}
 141590 		fts5StructurePromoteTo(tls, p, iPromote, szPromote, pStruct)
 141591 	}
 141592 }
 141593 
 141594 func fts5DlidxLvlNext(tls *libc.TLS, pLvl uintptr) int32 {
 141595 	bp := tls.Alloc(8)
 141596 	defer tls.Free(8)
 141597 
 141598 	var pData uintptr = (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData
 141599 
 141600 	if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff == 0 {
 141601 		(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = 1
 141602 		*(*int32)(unsafe.Pointer(pLvl + 4)) += sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp+1, pLvl+16)
 141603 		*(*int32)(unsafe.Pointer(pLvl + 4)) += int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff), pLvl+24))
 141604 		(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff = (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff
 141605 	} else {
 141606 		var iOff int32
 141607 		for iOff = (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff; iOff < (*Fts5Data)(unsafe.Pointer(pData)).Fnn; iOff++ {
 141608 			if *(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(iOff))) != 0 {
 141609 				break
 141610 			}
 141611 		}
 141612 
 141613 		if iOff < (*Fts5Data)(unsafe.Pointer(pData)).Fnn {
 141614 			*(*int32)(unsafe.Pointer(pLvl + 16)) += iOff - (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff + 1
 141615 			iOff = iOff + int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr(iOff), bp))
 141616 			*(*I64)(unsafe.Pointer(pLvl + 24)) += *(*I64)(unsafe.Pointer(bp))
 141617 			(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = iOff
 141618 		} else {
 141619 			(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = 1
 141620 		}
 141621 	}
 141622 
 141623 	return (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof
 141624 }
 141625 
 141626 func fts5DlidxIterNextR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int32 {
 141627 	var pLvl uintptr = pIter + 8 + uintptr(iLvl)*32
 141628 
 141629 	if fts5DlidxLvlNext(tls, pLvl) != 0 {
 141630 		if iLvl+1 < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl {
 141631 			fts5DlidxIterNextR(tls, p, pIter, iLvl+1)
 141632 			if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FbEof == 0 {
 141633 				fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)
 141634 				libc.Xmemset(tls, pLvl, 0, uint32(unsafe.Sizeof(Fts5DlidxLvl{})))
 141635 				(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p,
 141636 					I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+I64(iLvl)<<FTS5_DATA_PAGE_B+I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FiLeafPgno))
 141637 				if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 {
 141638 					fts5DlidxLvlNext(tls, pLvl)
 141639 				}
 141640 			}
 141641 		}
 141642 	}
 141643 
 141644 	return (*Fts5DlidxLvl)(unsafe.Pointer(pIter + 8)).FbEof
 141645 }
 141646 
 141647 func fts5DlidxIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 141648 	return fts5DlidxIterNextR(tls, p, pIter, 0)
 141649 }
 141650 
 141651 func fts5DlidxIterFirst(tls *libc.TLS, pIter uintptr) int32 {
 141652 	var i int32
 141653 	for i = 0; i < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl; i++ {
 141654 		fts5DlidxLvlNext(tls, pIter+8+uintptr(i)*32)
 141655 	}
 141656 	return (*Fts5DlidxLvl)(unsafe.Pointer(pIter + 8)).FbEof
 141657 }
 141658 
 141659 func fts5DlidxIterEof(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 141660 	return libc.Bool32((*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK || (*Fts5DlidxLvl)(unsafe.Pointer(pIter+8)).FbEof != 0)
 141661 }
 141662 
 141663 func fts5DlidxIterLast(tls *libc.TLS, p uintptr, pIter uintptr) {
 141664 	var i int32
 141665 
 141666 	for i = (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl - 1; (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && i >= 0; i-- {
 141667 		var pLvl uintptr = pIter + 8 + uintptr(i)*32
 141668 		for fts5DlidxLvlNext(tls, pLvl) == 0 {
 141669 		}
 141670 		(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = 0
 141671 
 141672 		if i > 0 {
 141673 			var pChild uintptr = pLvl + libc.UintptrFromInt32(-1)*32
 141674 			fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pChild)).FpData)
 141675 			libc.Xmemset(tls, pChild, 0, uint32(unsafe.Sizeof(Fts5DlidxLvl{})))
 141676 			(*Fts5DlidxLvl)(unsafe.Pointer(pChild)).FpData = fts5DataRead(tls, p,
 141677 				I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+I64(i-1)<<FTS5_DATA_PAGE_B+I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiLeafPgno))
 141678 		}
 141679 	}
 141680 }
 141681 
 141682 func fts5DlidxLvlPrev(tls *libc.TLS, pLvl uintptr) int32 {
 141683 	bp := tls.Alloc(8)
 141684 	defer tls.Free(8)
 141685 
 141686 	var iOff int32 = (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff
 141687 
 141688 	if iOff <= (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff {
 141689 		(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = 1
 141690 	} else {
 141691 		var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp
 141692 
 141693 		var iLimit int32
 141694 		var ii int32
 141695 		var nZero int32 = 0
 141696 
 141697 		iLimit = func() int32 {
 141698 			if iOff > 9 {
 141699 				return iOff - 9
 141700 			}
 141701 			return 0
 141702 		}()
 141703 		for iOff--; iOff > iLimit; iOff-- {
 141704 			if int32(*(*U8)(unsafe.Pointer(a + uintptr(iOff-1))))&0x80 == 0 {
 141705 				break
 141706 			}
 141707 		}
 141708 
 141709 		sqlite3Fts5GetVarint(tls, a+uintptr(iOff), bp)
 141710 		*(*I64)(unsafe.Pointer(pLvl + 24)) -= *(*I64)(unsafe.Pointer(bp))
 141711 		(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiLeafPgno--
 141712 
 141713 		for ii = iOff - 1; ii >= (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff && int32(*(*U8)(unsafe.Pointer(a + uintptr(ii)))) == 0x00; ii-- {
 141714 			nZero++
 141715 		}
 141716 		if ii >= (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff && int32(*(*U8)(unsafe.Pointer(a + uintptr(ii))))&0x80 != 0 {
 141717 			var bZero int32 = 0
 141718 			if ii-8 >= (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff {
 141719 				var j int32
 141720 				for j = 1; j <= 8 && int32(*(*U8)(unsafe.Pointer(a + uintptr(ii-j))))&0x80 != 0; j++ {
 141721 				}
 141722 				bZero = libc.Bool32(j > 8)
 141723 			}
 141724 			if bZero == 0 {
 141725 				nZero--
 141726 			}
 141727 		}
 141728 		*(*int32)(unsafe.Pointer(pLvl + 16)) -= nZero
 141729 		(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = iOff - nZero
 141730 	}
 141731 
 141732 	return (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof
 141733 }
 141734 
 141735 func fts5DlidxIterPrevR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int32 {
 141736 	var pLvl uintptr = pIter + 8 + uintptr(iLvl)*32
 141737 
 141738 	if fts5DlidxLvlPrev(tls, pLvl) != 0 {
 141739 		if iLvl+1 < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl {
 141740 			fts5DlidxIterPrevR(tls, p, pIter, iLvl+1)
 141741 			if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FbEof == 0 {
 141742 				fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)
 141743 				libc.Xmemset(tls, pLvl, 0, uint32(unsafe.Sizeof(Fts5DlidxLvl{})))
 141744 				(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p,
 141745 					I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+I64(iLvl)<<FTS5_DATA_PAGE_B+I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FiLeafPgno))
 141746 				if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 {
 141747 					for fts5DlidxLvlNext(tls, pLvl) == 0 {
 141748 					}
 141749 					(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FbEof = 0
 141750 				}
 141751 			}
 141752 		}
 141753 	}
 141754 
 141755 	return (*Fts5DlidxLvl)(unsafe.Pointer(pIter + 8)).FbEof
 141756 }
 141757 
 141758 func fts5DlidxIterPrev(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 141759 	return fts5DlidxIterPrevR(tls, p, pIter, 0)
 141760 }
 141761 
 141762 func fts5DlidxIterFree(tls *libc.TLS, pIter uintptr) {
 141763 	if pIter != 0 {
 141764 		var i int32
 141765 		for i = 0; i < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl; i++ {
 141766 			fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pIter+8+uintptr(i)*32)).FpData)
 141767 		}
 141768 		Xsqlite3_free(tls, pIter)
 141769 	}
 141770 }
 141771 
 141772 func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeafPg int32) uintptr {
 141773 	var pIter uintptr = uintptr(0)
 141774 	var i int32
 141775 	var bDone int32 = 0
 141776 
 141777 	for i = 0; (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bDone == 0; i++ {
 141778 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5DlidxIter{})) + uint32(i)*uint32(unsafe.Sizeof(Fts5DlidxLvl{})))
 141779 		var pNew uintptr
 141780 
 141781 		pNew = Xsqlite3_realloc64(tls, pIter, uint64(nByte))
 141782 		if pNew == uintptr(0) {
 141783 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 141784 		} else {
 141785 			var iRowid I64 = I64(iSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + I64(i)<<FTS5_DATA_PAGE_B + I64(iLeafPg)
 141786 			var pLvl uintptr = pNew + 8 + uintptr(i)*32
 141787 			pIter = pNew
 141788 			libc.Xmemset(tls, pLvl, 0, uint32(unsafe.Sizeof(Fts5DlidxLvl{})))
 141789 			(*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, iRowid)
 141790 			if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 && int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp)))&0x0001 == 0 {
 141791 				bDone = 1
 141792 			}
 141793 			(*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl = i + 1
 141794 		}
 141795 	}
 141796 
 141797 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141798 		(*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid = iSegid
 141799 		if bRev == 0 {
 141800 			fts5DlidxIterFirst(tls, pIter)
 141801 		} else {
 141802 			fts5DlidxIterLast(tls, p, pIter)
 141803 		}
 141804 	}
 141805 
 141806 	if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 141807 		fts5DlidxIterFree(tls, pIter)
 141808 		pIter = uintptr(0)
 141809 	}
 141810 
 141811 	return pIter
 141812 }
 141813 
 141814 func fts5DlidxIterRowid(tls *libc.TLS, pIter uintptr) I64 {
 141815 	return (*Fts5DlidxLvl)(unsafe.Pointer(pIter + 8)).FiRowid
 141816 }
 141817 
 141818 func fts5DlidxIterPgno(tls *libc.TLS, pIter uintptr) int32 {
 141819 	return (*Fts5DlidxLvl)(unsafe.Pointer(pIter + 8)).FiLeafPgno
 141820 }
 141821 
 141822 func fts5SegIterNextPage(tls *libc.TLS, p uintptr, pIter uintptr) {
 141823 	var pLeaf uintptr
 141824 	var pSeg uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg
 141825 	fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 141826 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno++
 141827 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf != 0 {
 141828 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf
 141829 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0)
 141830 	} else if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno <= (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast {
 141831 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = fts5LeafRead(tls, p,
 141832 			I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+int64(0)<<FTS5_DATA_PAGE_B+I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno))
 141833 	} else {
 141834 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0)
 141835 	}
 141836 	pLeaf = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf
 141837 
 141838 	if pLeaf != 0 {
 141839 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf
 141840 		if (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf >= (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn {
 141841 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn + 1
 141842 		} else {
 141843 			*(*int32)(unsafe.Pointer(pIter + 44)) += sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff), pIter+48)
 141844 		}
 141845 	}
 141846 }
 141847 
 141848 func fts5GetPoslistSize(tls *libc.TLS, p uintptr, pnSz uintptr, pbDel uintptr) int32 {
 141849 	bp := tls.Alloc(4)
 141850 	defer tls.Free(4)
 141851 
 141852 	var n int32 = 0
 141853 	{
 141854 		*(*int32)(unsafe.Pointer(bp)) = int32(*(*U8)(unsafe.Pointer(p + uintptr(libc.PostIncInt32(&n, 1)))))
 141855 		if *(*int32)(unsafe.Pointer(bp))&0x80 != 0 {
 141856 			n--
 141857 			n = n + sqlite3Fts5GetVarint32(tls, p+uintptr(n), bp)
 141858 		}
 141859 	}
 141860 
 141861 	*(*int32)(unsafe.Pointer(pnSz)) = *(*int32)(unsafe.Pointer(bp)) / 2
 141862 	*(*int32)(unsafe.Pointer(pbDel)) = *(*int32)(unsafe.Pointer(bp)) & 0x0001
 141863 	return n
 141864 }
 141865 
 141866 func fts5SegIterLoadNPos(tls *libc.TLS, p uintptr, pIter uintptr) {
 141867 	bp := tls.Alloc(4)
 141868 	defer tls.Free(4)
 141869 
 141870 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141871 		var iOff int32 = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 141872 
 141873 		if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE {
 141874 			var iEod int32 = func() int32 {
 141875 				if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist < (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf {
 141876 					return (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist
 141877 				}
 141878 				return (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf
 141879 			}()
 141880 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FbDel = U8(0)
 141881 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos = 1
 141882 			if iOff < iEod && int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(iOff)))) == 0 {
 141883 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FbDel = U8(1)
 141884 				iOff++
 141885 				if iOff < iEod && int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(iOff)))) == 0 {
 141886 					(*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos = 1
 141887 					iOff++
 141888 				} else {
 141889 					(*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos = 0
 141890 				}
 141891 			}
 141892 		} else {
 141893 			{
 141894 				*(*int32)(unsafe.Pointer(bp)) = int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(libc.PostIncInt32(&iOff, 1)))))
 141895 				if *(*int32)(unsafe.Pointer(bp))&0x80 != 0 {
 141896 					iOff--
 141897 					iOff = iOff + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iOff), bp)
 141898 				}
 141899 			}
 141900 
 141901 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FbDel = U8(*(*int32)(unsafe.Pointer(bp)) & 0x0001)
 141902 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos = *(*int32)(unsafe.Pointer(bp)) >> 1
 141903 
 141904 		}
 141905 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iOff)
 141906 	}
 141907 }
 141908 
 141909 func fts5SegIterLoadRowid(tls *libc.TLS, p uintptr, pIter uintptr) {
 141910 	var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 141911 	var iOff I64 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset
 141912 
 141913 	if iOff >= I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) {
 141914 		fts5SegIterNextPage(tls, p, pIter)
 141915 		if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) {
 141916 			if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141917 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 141918 			}
 141919 			return
 141920 		}
 141921 		iOff = int64(4)
 141922 		a = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 141923 	}
 141924 	iOff = iOff + I64(sqlite3Fts5GetVarint(tls, a+uintptr(iOff), pIter+80))
 141925 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = iOff
 141926 }
 141927 
 141928 func fts5SegIterLoadTerm(tls *libc.TLS, p uintptr, pIter uintptr, nKeep int32) {
 141929 	bp := tls.Alloc(8)
 141930 	defer tls.Free(8)
 141931 
 141932 	var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 141933 	var iOff I64 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset
 141934 
 141935 	iOff = iOff + I64(sqlite3Fts5GetVarint32(tls, a+uintptr(iOff), bp))
 141936 	if iOff+I64(*(*int32)(unsafe.Pointer(bp))) > I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) || nKeep > (*Fts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn || *(*int32)(unsafe.Pointer(bp)) == 0 {
 141937 		(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 141938 		return
 141939 	}
 141940 	(*Fts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn = nKeep
 141941 	sqlite3Fts5BufferAppendBlob(tls, p+36, pIter+68, uint32(*(*int32)(unsafe.Pointer(bp))), a+uintptr(iOff))
 141942 
 141943 	iOff = iOff + I64(*(*int32)(unsafe.Pointer(bp)))
 141944 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset = int32(iOff)
 141945 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno
 141946 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = iOff
 141947 
 141948 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn {
 141949 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn + 1
 141950 	} else {
 141951 		*(*int32)(unsafe.Pointer(pIter + 44)) += sqlite3Fts5GetVarint32(tls, a+uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff), bp+4)
 141952 		*(*int32)(unsafe.Pointer(pIter + 48)) += *(*int32)(unsafe.Pointer(bp + 4))
 141953 	}
 141954 
 141955 	fts5SegIterLoadRowid(tls, p, pIter)
 141956 }
 141957 
 141958 func fts5SegIterSetNext(tls *libc.TLS, p uintptr, pIter uintptr) {
 141959 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags&FTS5_SEGITER_REVERSE != 0 {
 141960 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 141961 			f func(*libc.TLS, uintptr, uintptr, uintptr)
 141962 		}{fts5SegIterNext_Reverse}))
 141963 	} else if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE {
 141964 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 141965 			f func(*libc.TLS, uintptr, uintptr, uintptr)
 141966 		}{fts5SegIterNext_None}))
 141967 	} else {
 141968 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct {
 141969 			f func(*libc.TLS, uintptr, uintptr, uintptr)
 141970 		}{fts5SegIterNext}))
 141971 	}
 141972 }
 141973 
 141974 func fts5SegIterInit(tls *libc.TLS, p uintptr, pSeg uintptr, pIter uintptr) {
 141975 	if (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst == 0 {
 141976 		return
 141977 	}
 141978 
 141979 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141980 		libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(Fts5SegIter{})))
 141981 		fts5SegIterSetNext(tls, p, pIter)
 141982 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg
 141983 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst - 1
 141984 		fts5SegIterNextPage(tls, p, pIter)
 141985 	}
 141986 
 141987 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 141988 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int64(4)
 141989 
 141990 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + 1
 141991 		fts5SegIterLoadTerm(tls, p, pIter, 0)
 141992 		fts5SegIterLoadNPos(tls, p, pIter)
 141993 	}
 141994 }
 141995 
 141996 func fts5SegIterReverseInitPage(tls *libc.TLS, p uintptr, pIter uintptr) {
 141997 	bp := tls.Alloc(16)
 141998 	defer tls.Free(16)
 141999 
 142000 	var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail
 142001 	var n int32 = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf
 142002 	var i int32 = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 142003 	var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 142004 	var iRowidOffset int32 = 0
 142005 
 142006 	if n > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist {
 142007 		n = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist
 142008 	}
 142009 
 142010 	for 1 != 0 {
 142011 		*(*U64)(unsafe.Pointer(bp + 8)) = uint64(0)
 142012 
 142013 		if eDetail == FTS5_DETAIL_NONE {
 142014 			if i < n && int32(*(*U8)(unsafe.Pointer(a + uintptr(i)))) == 0 {
 142015 				i++
 142016 				if i < n && int32(*(*U8)(unsafe.Pointer(a + uintptr(i)))) == 0 {
 142017 					i++
 142018 				}
 142019 			}
 142020 		} else {
 142021 			i = i + fts5GetPoslistSize(tls, a+uintptr(i), bp, bp+4)
 142022 			i = i + *(*int32)(unsafe.Pointer(bp))
 142023 		}
 142024 		if i >= n {
 142025 			break
 142026 		}
 142027 		i = i + int32(sqlite3Fts5GetVarint(tls, a+uintptr(i), bp+8))
 142028 		*(*I64)(unsafe.Pointer(pIter + 80)) += I64(*(*U64)(unsafe.Pointer(bp + 8)))
 142029 
 142030 		if iRowidOffset >= (*Fts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset {
 142031 			var nNew int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset + 8
 142032 			var aNew uintptr = Xsqlite3_realloc64(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset, uint64(uint32(nNew)*uint32(unsafe.Sizeof(int32(0)))))
 142033 			if aNew == uintptr(0) {
 142034 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 142035 				break
 142036 			}
 142037 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset = aNew
 142038 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset = nNew
 142039 		}
 142040 
 142041 		*(*int32)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset + uintptr(libc.PostIncInt32(&iRowidOffset, 1))*4)) = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 142042 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(i)
 142043 	}
 142044 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset = iRowidOffset
 142045 	fts5SegIterLoadNPos(tls, p, pIter)
 142046 }
 142047 
 142048 func fts5SegIterReverseNewPage(tls *libc.TLS, p uintptr, pIter uintptr) {
 142049 	fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142050 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0)
 142051 	for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno {
 142052 		var pNew uintptr
 142053 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno--
 142054 		pNew = fts5DataRead(tls, p, I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+int64(0)<<FTS5_DATA_PAGE_B+I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno))
 142055 		if pNew != 0 {
 142056 			if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno == (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno {
 142057 				if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset < (*Fts5Data)(unsafe.Pointer(pNew)).FszLeaf {
 142058 					(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pNew
 142059 					(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset)
 142060 				}
 142061 			} else {
 142062 				var iRowidOff int32
 142063 				iRowidOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pNew)).Fp))
 142064 				if iRowidOff != 0 {
 142065 					if iRowidOff >= (*Fts5Data)(unsafe.Pointer(pNew)).FszLeaf {
 142066 						(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142067 					} else {
 142068 						(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pNew
 142069 						(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iRowidOff)
 142070 					}
 142071 				}
 142072 			}
 142073 
 142074 			if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 {
 142075 				var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 142076 				*(*I64)(unsafe.Pointer(pIter + 24)) += I64(sqlite3Fts5GetVarint(tls, a, pIter+80))
 142077 				break
 142078 			} else {
 142079 				fts5DataRelease(tls, pNew)
 142080 			}
 142081 		}
 142082 	}
 142083 
 142084 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 {
 142085 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn + 1
 142086 		fts5SegIterReverseInitPage(tls, p, pIter)
 142087 	}
 142088 }
 142089 
 142090 func fts5MultiIterIsEmpty(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 142091 	var pSeg uintptr = pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*96
 142092 	return libc.Bool32((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 && (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos == 0)
 142093 }
 142094 
 142095 func fts5SegIterNext_Reverse(tls *libc.TLS, p uintptr, pIter uintptr, pbUnused uintptr) {
 142096 	bp := tls.Alloc(8)
 142097 	defer tls.Free(8)
 142098 
 142099 	_ = pbUnused
 142100 
 142101 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset > 0 {
 142102 		var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 142103 		var iOff int32
 142104 
 142105 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset--
 142106 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(*(*int32)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset + uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset)*4)))
 142107 		fts5SegIterLoadNPos(tls, p, pIter)
 142108 		iOff = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 142109 		if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail != FTS5_DETAIL_NONE {
 142110 			iOff = iOff + (*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos
 142111 		}
 142112 		sqlite3Fts5GetVarint(tls, a+uintptr(iOff), bp)
 142113 		*(*I64)(unsafe.Pointer(pIter + 80)) -= I64(*(*U64)(unsafe.Pointer(bp)))
 142114 	} else {
 142115 		fts5SegIterReverseNewPage(tls, p, pIter)
 142116 	}
 142117 }
 142118 
 142119 func fts5SegIterNext_None(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) {
 142120 	bp := tls.Alloc(24)
 142121 	defer tls.Free(24)
 142122 
 142123 	var iOff int32
 142124 
 142125 	iOff = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 142126 
 142127 	if !((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg != 0 && iOff >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) {
 142128 		goto __1
 142129 	}
 142130 	fts5SegIterNextPage(tls, p, pIter)
 142131 	if !((*Fts5Index)(unsafe.Pointer(p)).Frc != 0 || (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0)) {
 142132 		goto __2
 142133 	}
 142134 	return
 142135 __2:
 142136 	;
 142137 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowid = int64(0)
 142138 	iOff = 4
 142139 __1:
 142140 	;
 142141 	if !(iOff < (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist) {
 142142 		goto __3
 142143 	}
 142144 	iOff = iOff + int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iOff), bp))
 142145 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iOff)
 142146 	*(*I64)(unsafe.Pointer(pIter + 80)) += *(*I64)(unsafe.Pointer(bp))
 142147 	goto __4
 142148 __3:
 142149 	if !((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags&FTS5_SEGITER_ONETERM == 0) {
 142150 		goto __5
 142151 	}
 142152 	if !((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg != 0) {
 142153 		goto __7
 142154 	}
 142155 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
 142156 	if !(iOff != fts5LeafFirstTermOff(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)) {
 142157 		goto __9
 142158 	}
 142159 	iOff = iOff + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iOff), bp+8)
 142160 __9:
 142161 	;
 142162 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iOff)
 142163 	fts5SegIterLoadTerm(tls, p, pIter, *(*int32)(unsafe.Pointer(bp + 8)))
 142164 	goto __8
 142165 __7:
 142166 	*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 142167 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 142168 	sqlite3Fts5HashScanNext(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash)
 142169 	sqlite3Fts5HashScanEntry(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, bp+12, bp+16, bp+20)
 142170 	if !(*(*uintptr)(unsafe.Pointer(bp + 16)) == uintptr(0)) {
 142171 		goto __10
 142172 	}
 142173 	goto next_none_eof
 142174 __10:
 142175 	;
 142176 	(*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp = *(*uintptr)(unsafe.Pointer(bp + 16))
 142177 	(*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn = *(*int32)(unsafe.Pointer(bp + 20))
 142178 	(*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf = *(*int32)(unsafe.Pointer(bp + 20))
 142179 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = *(*int32)(unsafe.Pointer(bp + 20))
 142180 	sqlite3Fts5BufferSet(tls, p+36, pIter+68, int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))), *(*uintptr)(unsafe.Pointer(bp + 12)))
 142181 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(sqlite3Fts5GetVarint(tls, *(*uintptr)(unsafe.Pointer(bp + 16)), pIter+80))
 142182 __8:
 142183 	;
 142184 	if !(pbNewTerm != 0) {
 142185 		goto __11
 142186 	}
 142187 	*(*int32)(unsafe.Pointer(pbNewTerm)) = 1
 142188 __11:
 142189 	;
 142190 	goto __6
 142191 __5:
 142192 	goto next_none_eof
 142193 __6:
 142194 	;
 142195 __4:
 142196 	;
 142197 	fts5SegIterLoadNPos(tls, p, pIter)
 142198 
 142199 	return
 142200 next_none_eof:
 142201 	fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142202 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0)
 142203 }
 142204 
 142205 func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) {
 142206 	bp := tls.Alloc(36)
 142207 	defer tls.Free(36)
 142208 
 142209 	var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf
 142210 
 142211 	var bNewTerm int32 = 0
 142212 	*(*int32)(unsafe.Pointer(bp)) = 0
 142213 	var a uintptr
 142214 	var n int32
 142215 
 142216 	a = (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp
 142217 	n = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf
 142218 
 142219 	*(*int32)(unsafe.Pointer(bp + 28)) = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset + I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos))
 142220 
 142221 	if *(*int32)(unsafe.Pointer(bp + 28)) < n {
 142222 		if *(*int32)(unsafe.Pointer(bp + 28)) >= (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist {
 142223 			bNewTerm = 1
 142224 			if *(*int32)(unsafe.Pointer(bp + 28)) != fts5LeafFirstTermOff(tls, pLeaf) {
 142225 				*(*int32)(unsafe.Pointer(bp + 28)) += sqlite3Fts5GetVarint32(tls, a+uintptr(*(*int32)(unsafe.Pointer(bp + 28))), bp)
 142226 			}
 142227 		} else {
 142228 			*(*int32)(unsafe.Pointer(bp + 28)) += int32(sqlite3Fts5GetVarint(tls, a+uintptr(*(*int32)(unsafe.Pointer(bp + 28))), bp+8))
 142229 			*(*I64)(unsafe.Pointer(pIter + 80)) += I64(*(*U64)(unsafe.Pointer(bp + 8)))
 142230 
 142231 		}
 142232 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(*(*int32)(unsafe.Pointer(bp + 28)))
 142233 
 142234 	} else if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg == uintptr(0) {
 142235 		*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 142236 		*(*uintptr)(unsafe.Pointer(bp + 16)) = uintptr(0)
 142237 		*(*int32)(unsafe.Pointer(bp + 24)) = 0
 142238 
 142239 		if 0 == (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags&FTS5_SEGITER_ONETERM {
 142240 			sqlite3Fts5HashScanNext(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash)
 142241 			sqlite3Fts5HashScanEntry(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, bp+16, bp+20, bp+24)
 142242 		}
 142243 		if *(*uintptr)(unsafe.Pointer(bp + 20)) == uintptr(0) {
 142244 			fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142245 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0)
 142246 		} else {
 142247 			(*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp = *(*uintptr)(unsafe.Pointer(bp + 20))
 142248 			(*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn = *(*int32)(unsafe.Pointer(bp + 24))
 142249 			(*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf = *(*int32)(unsafe.Pointer(bp + 24))
 142250 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = *(*int32)(unsafe.Pointer(bp + 24)) + 1
 142251 			sqlite3Fts5BufferSet(tls, p+36, pIter+68, int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 16)))),
 142252 				*(*uintptr)(unsafe.Pointer(bp + 16)))
 142253 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(sqlite3Fts5GetVarint(tls, *(*uintptr)(unsafe.Pointer(bp + 20)), pIter+80))
 142254 			*(*int32)(unsafe.Pointer(pbNewTerm)) = 1
 142255 		}
 142256 	} else {
 142257 		*(*int32)(unsafe.Pointer(bp + 28)) = 0
 142258 
 142259 		for *(*int32)(unsafe.Pointer(bp + 28)) == 0 {
 142260 			fts5SegIterNextPage(tls, p, pIter)
 142261 			pLeaf = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf
 142262 			if pLeaf == uintptr(0) {
 142263 				break
 142264 			}
 142265 
 142266 			if libc.AssignPtrInt32(bp+28, int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp))) != 0 && *(*int32)(unsafe.Pointer(bp + 28)) < (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 142267 				*(*int32)(unsafe.Pointer(bp + 28)) += int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(*(*int32)(unsafe.Pointer(bp + 28))), pIter+80))
 142268 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(*(*int32)(unsafe.Pointer(bp + 28)))
 142269 
 142270 				if (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 142271 					(*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf), pIter+48)
 142272 				}
 142273 			} else if (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 142274 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf), bp+28)
 142275 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(*(*int32)(unsafe.Pointer(bp + 28)))
 142276 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = *(*int32)(unsafe.Pointer(bp + 28))
 142277 				bNewTerm = 1
 142278 			}
 142279 
 142280 			if *(*int32)(unsafe.Pointer(bp + 28)) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 142281 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142282 				return
 142283 			}
 142284 		}
 142285 	}
 142286 
 142287 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 {
 142288 		if bNewTerm != 0 {
 142289 			if (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags&FTS5_SEGITER_ONETERM != 0 {
 142290 				fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142291 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0)
 142292 			} else {
 142293 				fts5SegIterLoadTerm(tls, p, pIter, *(*int32)(unsafe.Pointer(bp)))
 142294 				fts5SegIterLoadNPos(tls, p, pIter)
 142295 				if pbNewTerm != 0 {
 142296 					*(*int32)(unsafe.Pointer(pbNewTerm)) = 1
 142297 				}
 142298 			}
 142299 		} else {
 142300 			{
 142301 				*(*int32)(unsafe.Pointer(bp + 32)) = int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp + uintptr(libc.PostIncInt64(&(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset, 1)))))
 142302 				if *(*int32)(unsafe.Pointer(bp + 32))&0x80 != 0 {
 142303 					(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset--
 142304 					*(*I64)(unsafe.Pointer(pIter + 24)) += I64(sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset), bp+32))
 142305 				}
 142306 			}
 142307 
 142308 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FbDel = U8(*(*int32)(unsafe.Pointer(bp + 32)) & 0x0001)
 142309 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos = *(*int32)(unsafe.Pointer(bp + 32)) >> 1
 142310 
 142311 		}
 142312 	}
 142313 }
 142314 
 142315 func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) {
 142316 	var pDlidx uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpDlidx
 142317 	var pLast uintptr = uintptr(0)
 142318 	var pgnoLast int32 = 0
 142319 
 142320 	if pDlidx != 0 {
 142321 		var iSegid int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid
 142322 		pgnoLast = fts5DlidxIterPgno(tls, pDlidx)
 142323 		pLast = fts5LeafRead(tls, p, I64(iSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+int64(0)<<FTS5_DATA_PAGE_B+I64(pgnoLast))
 142324 	} else {
 142325 		var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf
 142326 
 142327 		var iPoslist int32
 142328 		if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno == (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno {
 142329 			iPoslist = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset
 142330 		} else {
 142331 			iPoslist = 4
 142332 		}
 142333 		{
 142334 			var iEnd int32 = iPoslist + 9
 142335 			for int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(libc.PostIncInt32(&iPoslist, 1)))))&0x80 != 0 && iPoslist < iEnd {
 142336 			}
 142337 		}
 142338 
 142339 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iPoslist)
 142340 
 142341 		if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 142342 			var pgno int32
 142343 			var pSeg uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg
 142344 
 142345 			for pgno = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + 1; !((*Fts5Index)(unsafe.Pointer(p)).Frc != 0) && pgno <= (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast; pgno++ {
 142346 				var iAbs I64 = I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + I64(pgno)
 142347 				var pNew uintptr = fts5LeafRead(tls, p, iAbs)
 142348 				if pNew != 0 {
 142349 					var iRowid int32
 142350 					var bTermless int32
 142351 					iRowid = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pNew)).Fp))
 142352 					bTermless = libc.Bool32((*Fts5Data)(unsafe.Pointer(pNew)).FszLeaf >= (*Fts5Data)(unsafe.Pointer(pNew)).Fnn)
 142353 					if iRowid != 0 {
 142354 						{
 142355 							var tmp uintptr
 142356 							tmp = pNew
 142357 							pNew = pLast
 142358 							pLast = tmp
 142359 						}
 142360 
 142361 						pgnoLast = pgno
 142362 					}
 142363 					fts5DataRelease(tls, pNew)
 142364 					if bTermless == 0 {
 142365 						break
 142366 					}
 142367 				}
 142368 			}
 142369 		}
 142370 	}
 142371 
 142372 	if pLast != 0 {
 142373 		var iOff int32
 142374 		fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142375 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pLast
 142376 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = pgnoLast
 142377 		iOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLast)).Fp))
 142378 		if iOff > (*Fts5Data)(unsafe.Pointer(pLast)).FszLeaf {
 142379 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142380 			return
 142381 		}
 142382 		iOff = iOff + int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pLast)).Fp+uintptr(iOff), pIter+80))
 142383 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iOff)
 142384 
 142385 		if (*Fts5Data)(unsafe.Pointer(pLast)).FszLeaf >= (*Fts5Data)(unsafe.Pointer(pLast)).Fnn {
 142386 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(pLast)).Fnn + 1
 142387 		} else {
 142388 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = fts5LeafFirstTermOff(tls, pLast)
 142389 		}
 142390 	}
 142391 
 142392 	fts5SegIterReverseInitPage(tls, p, pIter)
 142393 }
 142394 
 142395 func fts5SegIterLoadDlidx(tls *libc.TLS, p uintptr, pIter uintptr) {
 142396 	var iSeg int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid
 142397 	var bRev int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE
 142398 	var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf
 142399 
 142400 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno == (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno &&
 142401 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist < (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 142402 		return
 142403 	}
 142404 
 142405 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FpDlidx = fts5DlidxIterInit(tls, p, bRev, iSeg, (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno)
 142406 }
 142407 
 142408 func fts5LeafSeek(tls *libc.TLS, p uintptr, bGe int32, pIter uintptr, pTerm uintptr, nTerm int32) {
 142409 	bp := tls.Alloc(20)
 142410 	defer tls.Free(20)
 142411 
 142412 	var a uintptr
 142413 	var n U32
 142414 	var nMatch U32
 142415 
 142416 	var iPgidx U32
 142417 	var bEndOfPage int32
 142418 	var nCmp U32
 142419 	var i U32
 142420 
 142421 	a = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 142422 	n = U32((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn)
 142423 	nMatch = U32(0)
 142424 	*(*U32)(unsafe.Pointer(bp + 8)) = U32(0)
 142425 	*(*U32)(unsafe.Pointer(bp + 4)) = U32(0)
 142426 	bEndOfPage = 0
 142427 
 142428 	iPgidx = U32((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf)
 142429 	iPgidx = iPgidx + U32(sqlite3Fts5GetVarint32(tls, a+uintptr(iPgidx), bp))
 142430 	*(*U32)(unsafe.Pointer(bp + 12)) = *(*U32)(unsafe.Pointer(bp))
 142431 	if !(*(*U32)(unsafe.Pointer(bp + 12)) > n) {
 142432 		goto __1
 142433 	}
 142434 	(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142435 	return
 142436 __1:
 142437 	;
 142438 __2:
 142439 	if !(1 != 0) {
 142440 		goto __3
 142441 	}
 142442 
 142443 	*(*U32)(unsafe.Pointer(bp + 4)) = U32(*(*U8)(unsafe.Pointer(a + uintptr(libc.PostIncUint32(&*(*U32)(unsafe.Pointer(bp + 12)), 1)))))
 142444 	if !(*(*U32)(unsafe.Pointer(bp + 4))&U32(0x80) != 0) {
 142445 		goto __4
 142446 	}
 142447 	*(*U32)(unsafe.Pointer(bp + 12))--
 142448 	*(*U32)(unsafe.Pointer(bp + 12)) += U32(sqlite3Fts5GetVarint32(tls, a+uintptr(*(*U32)(unsafe.Pointer(bp + 12))), bp+4))
 142449 __4:
 142450 	;
 142451 	if !(*(*U32)(unsafe.Pointer(bp + 8)) < nMatch) {
 142452 		goto __5
 142453 	}
 142454 	goto search_failed
 142455 __5:
 142456 	;
 142457 	if !(*(*U32)(unsafe.Pointer(bp + 8)) == nMatch) {
 142458 		goto __6
 142459 	}
 142460 	nCmp = func() uint32 {
 142461 		if *(*U32)(unsafe.Pointer(bp + 4)) < U32(nTerm)-nMatch {
 142462 			return *(*U32)(unsafe.Pointer(bp + 4))
 142463 		}
 142464 		return U32(nTerm) - nMatch
 142465 	}()
 142466 	i = U32(0)
 142467 __7:
 142468 	if !(i < nCmp) {
 142469 		goto __9
 142470 	}
 142471 	if !(int32(*(*U8)(unsafe.Pointer(a + uintptr(*(*U32)(unsafe.Pointer(bp + 12))+i)))) != int32(*(*U8)(unsafe.Pointer(pTerm + uintptr(nMatch+i))))) {
 142472 		goto __10
 142473 	}
 142474 	goto __9
 142475 __10:
 142476 	;
 142477 	goto __8
 142478 __8:
 142479 	i++
 142480 	goto __7
 142481 	goto __9
 142482 __9:
 142483 	;
 142484 	nMatch = nMatch + i
 142485 
 142486 	if !(U32(nTerm) == nMatch) {
 142487 		goto __11
 142488 	}
 142489 	if !(i == *(*U32)(unsafe.Pointer(bp + 4))) {
 142490 		goto __13
 142491 	}
 142492 	goto search_success
 142493 	goto __14
 142494 __13:
 142495 	goto search_failed
 142496 __14:
 142497 	;
 142498 	goto __12
 142499 __11:
 142500 	if !(i < *(*U32)(unsafe.Pointer(bp + 4)) && int32(*(*U8)(unsafe.Pointer(a + uintptr(*(*U32)(unsafe.Pointer(bp + 12))+i)))) > int32(*(*U8)(unsafe.Pointer(pTerm + uintptr(nMatch))))) {
 142501 		goto __15
 142502 	}
 142503 	goto search_failed
 142504 __15:
 142505 	;
 142506 __12:
 142507 	;
 142508 __6:
 142509 	;
 142510 	if !(iPgidx >= n) {
 142511 		goto __16
 142512 	}
 142513 	bEndOfPage = 1
 142514 	goto __3
 142515 __16:
 142516 	;
 142517 	iPgidx = iPgidx + U32(sqlite3Fts5GetVarint32(tls, a+uintptr(iPgidx), bp+8))
 142518 	*(*U32)(unsafe.Pointer(bp)) += *(*U32)(unsafe.Pointer(bp + 8))
 142519 	*(*U32)(unsafe.Pointer(bp + 12)) = *(*U32)(unsafe.Pointer(bp))
 142520 
 142521 	if !(*(*U32)(unsafe.Pointer(bp + 12)) >= n) {
 142522 		goto __17
 142523 	}
 142524 	(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142525 	return
 142526 __17:
 142527 	;
 142528 	*(*U32)(unsafe.Pointer(bp + 8)) = U32(*(*U8)(unsafe.Pointer(a + uintptr(libc.PostIncUint32(&*(*U32)(unsafe.Pointer(bp + 12)), 1)))))
 142529 	if !(*(*U32)(unsafe.Pointer(bp + 8))&U32(0x80) != 0) {
 142530 		goto __18
 142531 	}
 142532 	*(*U32)(unsafe.Pointer(bp + 12))--
 142533 	*(*U32)(unsafe.Pointer(bp + 12)) += U32(sqlite3Fts5GetVarint32(tls, a+uintptr(*(*U32)(unsafe.Pointer(bp + 12))), bp+8))
 142534 __18:
 142535 	;
 142536 	goto __2
 142537 __3:
 142538 	;
 142539 search_failed:
 142540 	if !(bGe == 0) {
 142541 		goto __19
 142542 	}
 142543 	fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142544 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0)
 142545 	return
 142546 	goto __20
 142547 __19:
 142548 	if !(bEndOfPage != 0) {
 142549 		goto __21
 142550 	}
 142551 __22:
 142552 	fts5SegIterNextPage(tls, p, pIter)
 142553 	if !((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0)) {
 142554 		goto __25
 142555 	}
 142556 	return
 142557 __25:
 142558 	;
 142559 	a = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 142560 	if !(libc.Bool32((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn) == 0) {
 142561 		goto __26
 142562 	}
 142563 	iPgidx = U32((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf)
 142564 	iPgidx = iPgidx + U32(sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp+uintptr(iPgidx), bp+12))
 142565 	if !(*(*U32)(unsafe.Pointer(bp + 12)) < U32(4) || I64(*(*U32)(unsafe.Pointer(bp + 12))) >= I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf)) {
 142566 		goto __27
 142567 	}
 142568 	(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142569 	return
 142570 	goto __28
 142571 __27:
 142572 	*(*U32)(unsafe.Pointer(bp + 8)) = U32(0)
 142573 	*(*U32)(unsafe.Pointer(bp)) = *(*U32)(unsafe.Pointer(bp + 12))
 142574 	n = U32((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn)
 142575 	*(*U32)(unsafe.Pointer(bp + 12)) += U32(sqlite3Fts5GetVarint32(tls, a+uintptr(*(*U32)(unsafe.Pointer(bp + 12))), bp+4))
 142576 	goto __24
 142577 __28:
 142578 	;
 142579 __26:
 142580 	;
 142581 	goto __23
 142582 __23:
 142583 	if 1 != 0 {
 142584 		goto __22
 142585 	}
 142586 	goto __24
 142587 __24:
 142588 	;
 142589 __21:
 142590 	;
 142591 __20:
 142592 	;
 142593 search_success:
 142594 	if !(I64(*(*U32)(unsafe.Pointer(bp + 12)))+I64(*(*U32)(unsafe.Pointer(bp + 4))) > I64(n) || *(*U32)(unsafe.Pointer(bp + 4)) < U32(1)) {
 142595 		goto __29
 142596 	}
 142597 	(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142598 	return
 142599 __29:
 142600 	;
 142601 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(*(*U32)(unsafe.Pointer(bp + 12)) + *(*U32)(unsafe.Pointer(bp + 4)))
 142602 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafOffset = int32((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset)
 142603 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno
 142604 
 142605 	sqlite3Fts5BufferSet(tls, p+36, pIter+68, int32(*(*U32)(unsafe.Pointer(bp + 8))), pTerm)
 142606 	sqlite3Fts5BufferAppendBlob(tls, p+36, pIter+68, *(*U32)(unsafe.Pointer(bp + 4)), a+uintptr(*(*U32)(unsafe.Pointer(bp + 12))))
 142607 
 142608 	if !(iPgidx >= n) {
 142609 		goto __30
 142610 	}
 142611 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fnn + 1
 142612 	goto __31
 142613 __30:
 142614 	iPgidx = iPgidx + U32(sqlite3Fts5GetVarint32(tls, a+uintptr(iPgidx), bp+16))
 142615 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = int32(*(*U32)(unsafe.Pointer(bp)) + U32(*(*int32)(unsafe.Pointer(bp + 16))))
 142616 __31:
 142617 	;
 142618 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = int32(iPgidx)
 142619 
 142620 	fts5SegIterLoadRowid(tls, p, pIter)
 142621 	fts5SegIterLoadNPos(tls, p, pIter)
 142622 }
 142623 
 142624 func fts5IdxSelectStmt(tls *libc.TLS, p uintptr) uintptr {
 142625 	bp := tls.Alloc(16)
 142626 	defer tls.Free(16)
 142627 
 142628 	if (*Fts5Index)(unsafe.Pointer(p)).FpIdxSelect == uintptr(0) {
 142629 		var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 142630 		fts5IndexPrepareStmt(tls, p, p+60, Xsqlite3_mprintf(tls,
 142631 			ts+35045,
 142632 			libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)))
 142633 	}
 142634 	return (*Fts5Index)(unsafe.Pointer(p)).FpIdxSelect
 142635 }
 142636 
 142637 func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pSeg uintptr, pIter uintptr) {
 142638 	var iPg int32 = 1
 142639 	var bGe int32 = flags & FTS5INDEX_QUERY_SCAN
 142640 	var bDlidx int32 = 0
 142641 	var pIdxSelect uintptr = uintptr(0)
 142642 
 142643 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(Fts5SegIter{})))
 142644 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg
 142645 
 142646 	pIdxSelect = fts5IdxSelectStmt(tls, p)
 142647 	if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 142648 		return
 142649 	}
 142650 	Xsqlite3_bind_int(tls, pIdxSelect, 1, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)
 142651 	Xsqlite3_bind_blob(tls, pIdxSelect, 2, pTerm, nTerm, uintptr(0))
 142652 	if SQLITE_ROW == Xsqlite3_step(tls, pIdxSelect) {
 142653 		var val I64 = I64(Xsqlite3_column_int(tls, pIdxSelect, 0))
 142654 		iPg = int32(val >> 1)
 142655 		bDlidx = int32(val & int64(0x0001))
 142656 	}
 142657 	(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, pIdxSelect)
 142658 	Xsqlite3_bind_null(tls, pIdxSelect, 2)
 142659 
 142660 	if iPg < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst {
 142661 		iPg = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst
 142662 		bDlidx = 0
 142663 	}
 142664 
 142665 	(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iPg - 1
 142666 	fts5SegIterNextPage(tls, p, pIter)
 142667 
 142668 	if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 {
 142669 		fts5LeafSeek(tls, p, bGe, pIter, pTerm, nTerm)
 142670 	}
 142671 
 142672 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bGe == 0 {
 142673 		*(*int32)(unsafe.Pointer(pIter + 4)) |= FTS5_SEGITER_ONETERM
 142674 		if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 {
 142675 			if flags&FTS5INDEX_QUERY_DESC != 0 {
 142676 				*(*int32)(unsafe.Pointer(pIter + 4)) |= FTS5_SEGITER_REVERSE
 142677 			}
 142678 			if bDlidx != 0 {
 142679 				fts5SegIterLoadDlidx(tls, p, pIter)
 142680 			}
 142681 			if flags&FTS5INDEX_QUERY_DESC != 0 {
 142682 				fts5SegIterReverse(tls, p, pIter)
 142683 			}
 142684 		}
 142685 	}
 142686 
 142687 	fts5SegIterSetNext(tls, p, pIter)
 142688 
 142689 }
 142690 
 142691 func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pIter uintptr) {
 142692 	bp := tls.Alloc(16)
 142693 	defer tls.Free(16)
 142694 
 142695 	*(*int32)(unsafe.Pointer(bp + 8)) = 0
 142696 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 142697 	var n int32 = 0
 142698 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 142699 
 142700 	if pTerm == uintptr(0) || flags&FTS5INDEX_QUERY_SCAN != 0 {
 142701 		*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 142702 
 142703 		(*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashScanInit(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, pTerm, nTerm)
 142704 		sqlite3Fts5HashScanEntry(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, bp, bp+4, bp+8)
 142705 		n = func() int32 {
 142706 			if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 142707 				return int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp))))
 142708 			}
 142709 			return 0
 142710 		}()
 142711 		if *(*uintptr)(unsafe.Pointer(bp + 4)) != 0 {
 142712 			*(*uintptr)(unsafe.Pointer(bp + 12)) = fts5IdxMalloc(tls, p, int64(unsafe.Sizeof(Fts5Data{})))
 142713 			if *(*uintptr)(unsafe.Pointer(bp + 12)) != 0 {
 142714 				(*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fp = *(*uintptr)(unsafe.Pointer(bp + 4))
 142715 			}
 142716 		}
 142717 	} else {
 142718 		(*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashQuery(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, int32(unsafe.Sizeof(Fts5Data{})),
 142719 			pTerm, nTerm, bp+12, bp+8)
 142720 		if *(*uintptr)(unsafe.Pointer(bp + 12)) != 0 {
 142721 			(*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fp = *(*uintptr)(unsafe.Pointer(bp + 12)) + 1*12
 142722 		}
 142723 		*(*uintptr)(unsafe.Pointer(bp)) = pTerm
 142724 		n = nTerm
 142725 		*(*int32)(unsafe.Pointer(pIter + 4)) |= FTS5_SEGITER_ONETERM
 142726 	}
 142727 
 142728 	if *(*uintptr)(unsafe.Pointer(bp + 12)) != 0 {
 142729 		sqlite3Fts5BufferSet(tls, p+36, pIter+68, n, *(*uintptr)(unsafe.Pointer(bp)))
 142730 		(*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fnn = libc.AssignPtrInt32(*(*uintptr)(unsafe.Pointer(bp + 12))+8, *(*int32)(unsafe.Pointer(bp + 8)))
 142731 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = *(*uintptr)(unsafe.Pointer(bp + 12))
 142732 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fp, pIter+80))
 142733 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fnn
 142734 
 142735 		if flags&FTS5INDEX_QUERY_DESC != 0 {
 142736 			*(*int32)(unsafe.Pointer(pIter + 4)) |= FTS5_SEGITER_REVERSE
 142737 			fts5SegIterReverseInitPage(tls, p, pIter)
 142738 		} else {
 142739 			fts5SegIterLoadNPos(tls, p, pIter)
 142740 		}
 142741 	}
 142742 
 142743 	fts5SegIterSetNext(tls, p, pIter)
 142744 }
 142745 
 142746 func fts5SegIterClear(tls *libc.TLS, pIter uintptr) {
 142747 	sqlite3Fts5BufferFree(tls, pIter+68)
 142748 	fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)
 142749 	fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf)
 142750 	fts5DlidxIterFree(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpDlidx)
 142751 	Xsqlite3_free(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset)
 142752 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(Fts5SegIter{})))
 142753 }
 142754 
 142755 func fts5MultiIterDoCompare(tls *libc.TLS, pIter uintptr, iOut int32) int32 {
 142756 	var i1 int32
 142757 	var i2 int32
 142758 	var iRes int32
 142759 	var p1 uintptr
 142760 	var p2 uintptr
 142761 	var pRes uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(iOut)*4
 142762 
 142763 	if iOut >= (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg/2 {
 142764 		i1 = (iOut - (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg/2) * 2
 142765 		i2 = i1 + 1
 142766 	} else {
 142767 		i1 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(iOut*2)*4)).FiFirst)
 142768 		i2 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(iOut*2+1)*4)).FiFirst)
 142769 	}
 142770 	p1 = pIter + 80 + uintptr(i1)*96
 142771 	p2 = pIter + 80 + uintptr(i2)*96
 142772 
 142773 	(*Fts5CResult)(unsafe.Pointer(pRes)).FbTermEq = U8(0)
 142774 	if (*Fts5SegIter)(unsafe.Pointer(p1)).FpLeaf == uintptr(0) {
 142775 		iRes = i2
 142776 	} else if (*Fts5SegIter)(unsafe.Pointer(p2)).FpLeaf == uintptr(0) {
 142777 		iRes = i1
 142778 	} else {
 142779 		var res int32 = fts5BufferCompare(tls, p1+68, p2+68)
 142780 		if res == 0 {
 142781 			(*Fts5CResult)(unsafe.Pointer(pRes)).FbTermEq = U8(1)
 142782 			if (*Fts5SegIter)(unsafe.Pointer(p1)).FiRowid == (*Fts5SegIter)(unsafe.Pointer(p2)).FiRowid {
 142783 				(*Fts5SegIter)(unsafe.Pointer(p1)).FbDel = (*Fts5SegIter)(unsafe.Pointer(p2)).FbDel
 142784 				return i2
 142785 			}
 142786 			if libc.Bool32((*Fts5SegIter)(unsafe.Pointer(p1)).FiRowid > (*Fts5SegIter)(unsafe.Pointer(p2)).FiRowid) == (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev {
 142787 				res = -1
 142788 			} else {
 142789 				res = +1
 142790 			}
 142791 		}
 142792 
 142793 		if res < 0 {
 142794 			iRes = i1
 142795 		} else {
 142796 			iRes = i2
 142797 		}
 142798 	}
 142799 
 142800 	(*Fts5CResult)(unsafe.Pointer(pRes)).FiFirst = U16(iRes)
 142801 	return 0
 142802 }
 142803 
 142804 func fts5SegIterGotoPage(tls *libc.TLS, p uintptr, pIter uintptr, iLeafPgno int32) {
 142805 	if iLeafPgno > (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FpgnoLast {
 142806 		(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142807 	} else {
 142808 		fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf)
 142809 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0)
 142810 		(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iLeafPgno - 1
 142811 		fts5SegIterNextPage(tls, p, pIter)
 142812 
 142813 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != uintptr(0) {
 142814 			var iOff int32
 142815 			var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp
 142816 			var n int32 = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf
 142817 
 142818 			iOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp))
 142819 			if iOff < 4 || iOff >= n {
 142820 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 142821 			} else {
 142822 				iOff = iOff + int32(sqlite3Fts5GetVarint(tls, a+uintptr(iOff), pIter+80))
 142823 				(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(iOff)
 142824 				fts5SegIterLoadNPos(tls, p, pIter)
 142825 			}
 142826 		}
 142827 	}
 142828 }
 142829 
 142830 func fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) {
 142831 	var bRev int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE
 142832 	var pDlidx uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpDlidx
 142833 	var iLeafPgno int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno
 142834 	var bMove int32 = 1
 142835 
 142836 	if bRev == 0 {
 142837 		for !(fts5DlidxIterEof(tls, p, pDlidx) != 0) && iMatch > fts5DlidxIterRowid(tls, pDlidx) {
 142838 			iLeafPgno = fts5DlidxIterPgno(tls, pDlidx)
 142839 			fts5DlidxIterNext(tls, p, pDlidx)
 142840 		}
 142841 
 142842 		if iLeafPgno > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno {
 142843 			fts5SegIterGotoPage(tls, p, pIter, iLeafPgno)
 142844 			bMove = 0
 142845 		}
 142846 	} else {
 142847 		for !(fts5DlidxIterEof(tls, p, pDlidx) != 0) && iMatch < fts5DlidxIterRowid(tls, pDlidx) {
 142848 			fts5DlidxIterPrev(tls, p, pDlidx)
 142849 		}
 142850 		iLeafPgno = fts5DlidxIterPgno(tls, pDlidx)
 142851 
 142852 		if iLeafPgno < (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno {
 142853 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iLeafPgno + 1
 142854 			fts5SegIterReverseNewPage(tls, p, pIter)
 142855 			bMove = 0
 142856 		}
 142857 	}
 142858 
 142859 	for __ccgo := true; __ccgo; __ccgo = (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 142860 		if bMove != 0 && (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 142861 			(*struct {
 142862 				f func(*libc.TLS, uintptr, uintptr, uintptr)
 142863 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext})).f(tls, p, pIter, uintptr(0))
 142864 		}
 142865 		if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) {
 142866 			break
 142867 		}
 142868 		if bRev == 0 && (*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowid >= iMatch {
 142869 			break
 142870 		}
 142871 		if bRev != 0 && (*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowid <= iMatch {
 142872 			break
 142873 		}
 142874 		bMove = 1
 142875 	}
 142876 }
 142877 
 142878 func fts5MultiIterFree(tls *libc.TLS, pIter uintptr) {
 142879 	if pIter != 0 {
 142880 		var i int32
 142881 		for i = 0; i < (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg; i++ {
 142882 			fts5SegIterClear(tls, pIter+80+uintptr(i)*96)
 142883 		}
 142884 		sqlite3Fts5BufferFree(tls, pIter+28)
 142885 		Xsqlite3_free(tls, pIter)
 142886 	}
 142887 }
 142888 
 142889 func fts5MultiIterAdvanced(tls *libc.TLS, p uintptr, pIter uintptr, iChanged int32, iMinset int32) {
 142890 	var i int32
 142891 	for i = ((*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iChanged) / 2; i >= iMinset && (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK; i = i / 2 {
 142892 		var iEq int32
 142893 		if libc.AssignInt32(&iEq, fts5MultiIterDoCompare(tls, pIter, i)) != 0 {
 142894 			var pSeg uintptr = pIter + 80 + uintptr(iEq)*96
 142895 
 142896 			(*struct {
 142897 				f func(*libc.TLS, uintptr, uintptr, uintptr)
 142898 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5SegIter)(unsafe.Pointer(pSeg)).FxNext})).f(tls, p, pSeg, uintptr(0))
 142899 			i = (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iEq
 142900 		}
 142901 	}
 142902 }
 142903 
 142904 func fts5MultiIterAdvanceRowid(tls *libc.TLS, pIter uintptr, iChanged int32, ppFirst uintptr) int32 {
 142905 	var pNew uintptr = pIter + 80 + uintptr(iChanged)*96
 142906 
 142907 	if (*Fts5SegIter)(unsafe.Pointer(pNew)).FiRowid == (*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid ||
 142908 		libc.Bool32((*Fts5SegIter)(unsafe.Pointer(pNew)).FiRowid < (*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid) == (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev {
 142909 		var i int32
 142910 		var pOther uintptr = pIter + 80 + uintptr(iChanged^0x0001)*96
 142911 		(*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = func() int64 {
 142912 			if (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev != 0 {
 142913 				return int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
 142914 			}
 142915 			return int64(0xffffffff) | int64(0x7fffffff)<<32
 142916 		}()
 142917 		for i = ((*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iChanged) / 2; 1 != 0; i = i / 2 {
 142918 			var pRes uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(i)*4
 142919 
 142920 			if (*Fts5CResult)(unsafe.Pointer(pRes)).FbTermEq != 0 {
 142921 				if (*Fts5SegIter)(unsafe.Pointer(pNew)).FiRowid == (*Fts5SegIter)(unsafe.Pointer(pOther)).FiRowid {
 142922 					return 1
 142923 				} else if libc.Bool32((*Fts5SegIter)(unsafe.Pointer(pOther)).FiRowid > (*Fts5SegIter)(unsafe.Pointer(pNew)).FiRowid) == (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev {
 142924 					(*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*Fts5SegIter)(unsafe.Pointer(pOther)).FiRowid
 142925 					pNew = pOther
 142926 				} else if libc.Bool32((*Fts5SegIter)(unsafe.Pointer(pOther)).FiRowid > (*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid) == (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev {
 142927 					(*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*Fts5SegIter)(unsafe.Pointer(pOther)).FiRowid
 142928 				}
 142929 			}
 142930 			(*Fts5CResult)(unsafe.Pointer(pRes)).FiFirst = U16(int32((pNew - (pIter + 80)) / 96))
 142931 			if i == 1 {
 142932 				break
 142933 			}
 142934 
 142935 			pOther = pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(i^0x0001)*4)).FiFirst)*96
 142936 		}
 142937 	}
 142938 
 142939 	*(*uintptr)(unsafe.Pointer(ppFirst)) = pNew
 142940 	return 0
 142941 }
 142942 
 142943 func fts5MultiIterSetEof(tls *libc.TLS, pIter uintptr) {
 142944 	var pSeg uintptr = pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*96
 142945 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = U8(libc.Bool32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0)))
 142946 	(*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
 142947 }
 142948 
 142949 func fts5MultiIterNext(tls *libc.TLS, p uintptr, pIter uintptr, bFrom int32, iFrom I64) {
 142950 	bp := tls.Alloc(8)
 142951 	defer tls.Free(8)
 142952 
 142953 	var bUseFrom int32 = bFrom
 142954 
 142955 	for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 142956 		var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4)).FiFirst)
 142957 		*(*int32)(unsafe.Pointer(bp)) = 0
 142958 		*(*uintptr)(unsafe.Pointer(bp + 4)) = pIter + 80 + uintptr(iFirst)*96
 142959 
 142960 		if bUseFrom != 0 && (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpDlidx != 0 {
 142961 			fts5SegIterNextFrom(tls, p, *(*uintptr)(unsafe.Pointer(bp + 4)), iFrom)
 142962 		} else {
 142963 			(*struct {
 142964 				f func(*libc.TLS, uintptr, uintptr, uintptr)
 142965 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FxNext})).f(tls, p, *(*uintptr)(unsafe.Pointer(bp + 4)), bp)
 142966 		}
 142967 
 142968 		if (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpLeaf == uintptr(0) || *(*int32)(unsafe.Pointer(bp)) != 0 ||
 142969 			fts5MultiIterAdvanceRowid(tls, pIter, iFirst, bp+4) != 0 {
 142970 			fts5MultiIterAdvanced(tls, p, pIter, iFirst, 1)
 142971 			fts5MultiIterSetEof(tls, pIter)
 142972 			*(*uintptr)(unsafe.Pointer(bp + 4)) = pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*96
 142973 			if (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpLeaf == uintptr(0) {
 142974 				return
 142975 			}
 142976 		}
 142977 
 142978 		if int32((*Fts5Iter)(unsafe.Pointer(pIter)).FbSkipEmpty) == 0 || (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FnPos != 0 {
 142979 			(*struct {
 142980 				f func(*libc.TLS, uintptr, uintptr)
 142981 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs})).f(tls, pIter, *(*uintptr)(unsafe.Pointer(bp + 4)))
 142982 			return
 142983 		}
 142984 		bUseFrom = 0
 142985 	}
 142986 }
 142987 
 142988 func fts5MultiIterNext2(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) {
 142989 	bp := tls.Alloc(8)
 142990 	defer tls.Free(8)
 142991 
 142992 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 142993 		*(*int32)(unsafe.Pointer(pbNewTerm)) = 0
 142994 		for __ccgo := true; __ccgo; __ccgo = fts5MultiIterIsEmpty(tls, p, pIter) != 0 {
 142995 			var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4)).FiFirst)
 142996 			*(*uintptr)(unsafe.Pointer(bp + 4)) = pIter + 80 + uintptr(iFirst)*96
 142997 			*(*int32)(unsafe.Pointer(bp)) = 0
 142998 
 142999 			(*struct {
 143000 				f func(*libc.TLS, uintptr, uintptr, uintptr)
 143001 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FxNext})).f(tls, p, *(*uintptr)(unsafe.Pointer(bp + 4)), bp)
 143002 			if (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpLeaf == uintptr(0) || *(*int32)(unsafe.Pointer(bp)) != 0 ||
 143003 				fts5MultiIterAdvanceRowid(tls, pIter, iFirst, bp+4) != 0 {
 143004 				fts5MultiIterAdvanced(tls, p, pIter, iFirst, 1)
 143005 				fts5MultiIterSetEof(tls, pIter)
 143006 				*(*int32)(unsafe.Pointer(pbNewTerm)) = 1
 143007 			}
 143008 
 143009 		}
 143010 	}
 143011 }
 143012 
 143013 func fts5IterSetOutputs_Noop(tls *libc.TLS, pUnused1 uintptr, pUnused2 uintptr) {
 143014 	_ = pUnused1
 143015 	_ = pUnused2
 143016 }
 143017 
 143018 func fts5MultiIterAlloc(tls *libc.TLS, p uintptr, nSeg int32) uintptr {
 143019 	var pNew uintptr
 143020 	var nSlot int32
 143021 
 143022 	for nSlot = 2; nSlot < nSeg; nSlot = nSlot * 2 {
 143023 	}
 143024 	pNew = fts5IdxMalloc(tls, p,
 143025 		int64(uint32(unsafe.Sizeof(Fts5Iter{}))+uint32(unsafe.Sizeof(Fts5SegIter{}))*uint32(nSlot-1)+uint32(unsafe.Sizeof(Fts5CResult{}))*uint32(nSlot)))
 143026 	if pNew != 0 {
 143027 		(*Fts5Iter)(unsafe.Pointer(pNew)).FnSeg = nSlot
 143028 		(*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst = pNew + 80 + uintptr(nSlot)*96
 143029 		(*Fts5Iter)(unsafe.Pointer(pNew)).FpIndex = p
 143030 		(*Fts5Iter)(unsafe.Pointer(pNew)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143031 			f func(*libc.TLS, uintptr, uintptr)
 143032 		}{fts5IterSetOutputs_Noop}))
 143033 	}
 143034 	return pNew
 143035 }
 143036 
 143037 func fts5PoslistCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) {
 143038 	_ = pUnused
 143039 
 143040 	if nChunk > 0 {
 143041 		{
 143042 			libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pContext)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pContext)).Fn), pChunk, uint32(nChunk))
 143043 			*(*int32)(unsafe.Pointer(pContext + 4)) += nChunk
 143044 		}
 143045 
 143046 	}
 143047 }
 143048 
 143049 type PoslistCallbackCtx1 = struct {
 143050 	FpBuf    uintptr
 143051 	FpColset uintptr
 143052 	FeState  int32
 143053 }
 143054 
 143055 type PoslistCallbackCtx = PoslistCallbackCtx1
 143056 
 143057 type PoslistOffsetsCtx1 = struct {
 143058 	FpBuf    uintptr
 143059 	FpColset uintptr
 143060 	FiRead   int32
 143061 	FiWrite  int32
 143062 }
 143063 
 143064 type PoslistOffsetsCtx = PoslistOffsetsCtx1
 143065 
 143066 func fts5IndexColsetTest(tls *libc.TLS, pColset uintptr, iCol int32) int32 {
 143067 	var i int32
 143068 	for i = 0; i < (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol; i++ {
 143069 		if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == iCol {
 143070 			return 1
 143071 		}
 143072 	}
 143073 	return 0
 143074 }
 143075 
 143076 func fts5PoslistOffsetsCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) {
 143077 	bp := tls.Alloc(4)
 143078 	defer tls.Free(4)
 143079 
 143080 	var pCtx uintptr = pContext
 143081 	_ = pUnused
 143082 
 143083 	if nChunk > 0 {
 143084 		var i int32 = 0
 143085 		for i < nChunk {
 143086 			i = i + sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp)
 143087 			*(*int32)(unsafe.Pointer(bp)) += (*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiRead - 2
 143088 			(*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiRead = *(*int32)(unsafe.Pointer(bp))
 143089 			if fts5IndexColsetTest(tls, (*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpColset, *(*int32)(unsafe.Pointer(bp))) != 0 {
 143090 				{
 143091 					*(*int32)(unsafe.Pointer((*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer((*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer((*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), uint64(*(*int32)(unsafe.Pointer(bp))+2-(*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiWrite))
 143092 				}
 143093 
 143094 				(*PoslistOffsetsCtx)(unsafe.Pointer(pCtx)).FiWrite = *(*int32)(unsafe.Pointer(bp))
 143095 			}
 143096 		}
 143097 	}
 143098 }
 143099 
 143100 func fts5PoslistFilterCallback(tls *libc.TLS, pUnused uintptr, pContext uintptr, pChunk uintptr, nChunk int32) {
 143101 	bp := tls.Alloc(8)
 143102 	defer tls.Free(8)
 143103 
 143104 	var pCtx uintptr = pContext
 143105 	_ = pUnused
 143106 
 143107 	if nChunk > 0 {
 143108 		var i int32 = 0
 143109 		var iStart int32 = 0
 143110 
 143111 		if (*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState == 2 {
 143112 			{
 143113 				*(*int32)(unsafe.Pointer(bp)) = int32(*(*U8)(unsafe.Pointer(pChunk + uintptr(libc.PostIncInt32(&i, 1)))))
 143114 				if *(*int32)(unsafe.Pointer(bp))&0x80 != 0 {
 143115 					i--
 143116 					i = i + sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp)
 143117 				}
 143118 			}
 143119 
 143120 			if fts5IndexColsetTest(tls, (*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpColset, *(*int32)(unsafe.Pointer(bp))) != 0 {
 143121 				(*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = 1
 143122 				{
 143123 					*(*int32)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), uint64(1))
 143124 				}
 143125 
 143126 			} else {
 143127 				(*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = 0
 143128 			}
 143129 		}
 143130 
 143131 		for __ccgo := true; __ccgo; __ccgo = i < nChunk {
 143132 			for i < nChunk && int32(*(*U8)(unsafe.Pointer(pChunk + uintptr(i)))) != 0x01 {
 143133 				for int32(*(*U8)(unsafe.Pointer(pChunk + uintptr(i))))&0x80 != 0 {
 143134 					i++
 143135 				}
 143136 				i++
 143137 			}
 143138 			if (*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState != 0 {
 143139 				{
 143140 					libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), pChunk+uintptr(iStart), uint32(i-iStart))
 143141 					*(*int32)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 4)) += i - iStart
 143142 				}
 143143 
 143144 			}
 143145 			if i < nChunk {
 143146 				iStart = i
 143147 				i++
 143148 				if i >= nChunk {
 143149 					(*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = 2
 143150 				} else {
 143151 					{
 143152 						*(*int32)(unsafe.Pointer(bp + 4)) = int32(*(*U8)(unsafe.Pointer(pChunk + uintptr(libc.PostIncInt32(&i, 1)))))
 143153 						if *(*int32)(unsafe.Pointer(bp + 4))&0x80 != 0 {
 143154 							i--
 143155 							i = i + sqlite3Fts5GetVarint32(tls, pChunk+uintptr(i), bp+4)
 143156 						}
 143157 					}
 143158 
 143159 					(*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState = fts5IndexColsetTest(tls, (*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpColset, *(*int32)(unsafe.Pointer(bp + 4)))
 143160 					if (*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FeState != 0 {
 143161 						{
 143162 							libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf)).Fn), pChunk+uintptr(iStart), uint32(i-iStart))
 143163 							*(*int32)(unsafe.Pointer((*PoslistCallbackCtx)(unsafe.Pointer(pCtx)).FpBuf + 4)) += i - iStart
 143164 						}
 143165 
 143166 						iStart = i
 143167 					}
 143168 				}
 143169 			}
 143170 		}
 143171 	}
 143172 }
 143173 
 143174 func fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, xChunk uintptr) {
 143175 	var nRem int32 = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos
 143176 	var pData uintptr = uintptr(0)
 143177 	var pChunk uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)
 143178 	var nChunk int32 = func() int32 {
 143179 		if I64(nRem) < I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf)-(*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset {
 143180 			return nRem
 143181 		}
 143182 		return int32(I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) - (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)
 143183 	}()
 143184 	var pgno int32 = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno
 143185 	var pgnoSave int32 = 0
 143186 
 143187 	if (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fflags&FTS5_SEGITER_REVERSE == 0 {
 143188 		pgnoSave = pgno + 1
 143189 	}
 143190 
 143191 	for 1 != 0 {
 143192 		(*struct {
 143193 			f func(*libc.TLS, uintptr, uintptr, uintptr, int32)
 143194 		})(unsafe.Pointer(&struct{ uintptr }{xChunk})).f(tls, p, pCtx, pChunk, nChunk)
 143195 		nRem = nRem - nChunk
 143196 		fts5DataRelease(tls, pData)
 143197 		if nRem <= 0 {
 143198 			break
 143199 		} else if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) {
 143200 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 143201 			return
 143202 		} else {
 143203 			pgno++
 143204 			pData = fts5LeafRead(tls, p, I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+int64(0)<<FTS5_DATA_PAGE_B+I64(pgno))
 143205 			if pData == uintptr(0) {
 143206 				break
 143207 			}
 143208 			pChunk = (*Fts5Data)(unsafe.Pointer(pData)).Fp + 4
 143209 			nChunk = func() int32 {
 143210 				if nRem < (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf-4 {
 143211 					return nRem
 143212 				}
 143213 				return (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf - 4
 143214 			}()
 143215 			if pgno == pgnoSave {
 143216 				(*Fts5SegIter)(unsafe.Pointer(pSeg)).FpNextLeaf = pData
 143217 				pData = uintptr(0)
 143218 			}
 143219 		}
 143220 	}
 143221 }
 143222 
 143223 func fts5SegiterPoslist(tls *libc.TLS, p uintptr, pSeg uintptr, pColset uintptr, pBuf uintptr) {
 143224 	bp := tls.Alloc(28)
 143225 	defer tls.Free(28)
 143226 
 143227 	if 0 == func() int32 {
 143228 		if U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)+U32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos+FTS5_DATA_ZERO_PADDING) <= U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) {
 143229 			return 0
 143230 		}
 143231 		return sqlite3Fts5BufferSize(tls, p+36, pBuf, uint32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos+FTS5_DATA_ZERO_PADDING+(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn))
 143232 	}() {
 143233 		libc.Xmemset(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos), 0, uint32(FTS5_DATA_ZERO_PADDING))
 143234 		if pColset == uintptr(0) {
 143235 			fts5ChunkIterate(tls, p, pSeg, pBuf, *(*uintptr)(unsafe.Pointer(&struct {
 143236 				f func(*libc.TLS, uintptr, uintptr, uintptr, int32)
 143237 			}{fts5PoslistCallback})))
 143238 		} else {
 143239 			if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL {
 143240 				(*PoslistCallbackCtx)(unsafe.Pointer(bp)).FpBuf = pBuf
 143241 				(*PoslistCallbackCtx)(unsafe.Pointer(bp)).FpColset = pColset
 143242 				(*PoslistCallbackCtx)(unsafe.Pointer(bp)).FeState = fts5IndexColsetTest(tls, pColset, 0)
 143243 
 143244 				fts5ChunkIterate(tls, p, pSeg, bp, *(*uintptr)(unsafe.Pointer(&struct {
 143245 					f func(*libc.TLS, uintptr, uintptr, uintptr, int32)
 143246 				}{fts5PoslistFilterCallback})))
 143247 			} else {
 143248 				libc.Xmemset(tls, bp+12, 0, uint32(unsafe.Sizeof(PoslistOffsetsCtx{})))
 143249 				(*PoslistOffsetsCtx)(unsafe.Pointer(bp + 12)).FpBuf = pBuf
 143250 				(*PoslistOffsetsCtx)(unsafe.Pointer(bp + 12)).FpColset = pColset
 143251 				fts5ChunkIterate(tls, p, pSeg, bp+12, *(*uintptr)(unsafe.Pointer(&struct {
 143252 					f func(*libc.TLS, uintptr, uintptr, uintptr, int32)
 143253 				}{fts5PoslistOffsetsCallback})))
 143254 			}
 143255 		}
 143256 	}
 143257 }
 143258 
 143259 func fts5IndexExtractColset(tls *libc.TLS, pRc uintptr, pColset uintptr, pPos uintptr, nPos int32, pIter uintptr) {
 143260 	bp := tls.Alloc(4)
 143261 	defer tls.Free(4)
 143262 
 143263 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 143264 		var p uintptr = pPos
 143265 		var aCopy uintptr = p
 143266 		var pEnd uintptr = p + uintptr(nPos)
 143267 		var i int32 = 0
 143268 		*(*int32)(unsafe.Pointer(bp)) = 0
 143269 
 143270 		if (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol > 1 && sqlite3Fts5BufferSize(tls, pRc, pIter+28, uint32(nPos)) != 0 {
 143271 			return
 143272 		}
 143273 
 143274 		for 1 != 0 {
 143275 			for *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) < *(*int32)(unsafe.Pointer(bp)) {
 143276 				i++
 143277 				if i == (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol {
 143278 					(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143279 					(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn
 143280 					return
 143281 				}
 143282 			}
 143283 
 143284 			for p < pEnd && int32(*(*U8)(unsafe.Pointer(p))) != 0x01 {
 143285 				for int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))))&0x80 != 0 {
 143286 				}
 143287 			}
 143288 
 143289 			if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == *(*int32)(unsafe.Pointer(bp)) {
 143290 				if (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol == 1 {
 143291 					(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = aCopy
 143292 					(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (int32(p) - int32(aCopy)) / 1
 143293 					return
 143294 				}
 143295 				{
 143296 					libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pIter+28)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pIter+28)).Fn), aCopy, uint32((int32(p)-int32(aCopy))/1))
 143297 					*(*int32)(unsafe.Pointer(pIter + 28 + 4)) += (int32(p) - int32(aCopy)) / 1
 143298 				}
 143299 
 143300 			}
 143301 			if p >= pEnd {
 143302 				(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143303 				(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn
 143304 				return
 143305 			}
 143306 			aCopy = libc.PostIncUintptr(&p, 1)
 143307 			*(*int32)(unsafe.Pointer(bp)) = int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))))
 143308 			if *(*int32)(unsafe.Pointer(bp))&0x80 != 0 {
 143309 				p--
 143310 				p += uintptr(sqlite3Fts5GetVarint32(tls, p, bp))
 143311 			}
 143312 		}
 143313 	}
 143314 
 143315 }
 143316 
 143317 func fts5IterSetOutputs_None(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
 143318 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
 143319 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos
 143320 }
 143321 
 143322 func fts5IterSetOutputs_Nocolset(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
 143323 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
 143324 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos
 143325 
 143326 	if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset+I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos) <= I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) {
 143327 		(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)
 143328 	} else {
 143329 		sqlite3Fts5BufferZero(tls, pIter+28)
 143330 		fts5SegiterPoslist(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex, pSeg, uintptr(0), pIter+28)
 143331 		(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143332 	}
 143333 }
 143334 
 143335 func fts5IterSetOutputs_ZeroColset(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
 143336 	_ = pSeg
 143337 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = 0
 143338 }
 143339 
 143340 func fts5IterSetOutputs_Col(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
 143341 	sqlite3Fts5BufferZero(tls, pIter+28)
 143342 	fts5SegiterPoslist(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex, pSeg, (*Fts5Iter)(unsafe.Pointer(pIter)).FpColset, pIter+28)
 143343 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
 143344 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143345 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn
 143346 }
 143347 
 143348 func fts5IterSetOutputs_Col100(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
 143349 	var a uintptr
 143350 	var pEnd uintptr
 143351 	var iPrev int32
 143352 	var aiCol uintptr
 143353 	var aiColEnd uintptr
 143354 	var aOut uintptr
 143355 	var iPrevOut int32
 143356 
 143357 	if !((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset+I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos) > I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf)) {
 143358 		goto __1
 143359 	}
 143360 	fts5IterSetOutputs_Col(tls, pIter, pSeg)
 143361 	goto __2
 143362 __1:
 143363 	a = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)
 143364 	pEnd = a + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos)
 143365 	iPrev = 0
 143366 	aiCol = (*Fts5Iter)(unsafe.Pointer(pIter)).FpColset + 4
 143367 	aiColEnd = aiCol + uintptr((*Fts5Colset)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FpColset)).FnCol)*4
 143368 	aOut = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143369 	iPrevOut = 0
 143370 
 143371 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
 143372 
 143373 __3:
 143374 	if !(a < pEnd) {
 143375 		goto __4
 143376 	}
 143377 	iPrev = iPrev + (int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1)))) - 2)
 143378 __5:
 143379 	if !(*(*int32)(unsafe.Pointer(aiCol)) < iPrev) {
 143380 		goto __6
 143381 	}
 143382 	aiCol += 4
 143383 	if !(aiCol == aiColEnd) {
 143384 		goto __7
 143385 	}
 143386 	goto setoutputs_col_out
 143387 __7:
 143388 	;
 143389 	goto __5
 143390 __6:
 143391 	;
 143392 	if !(*(*int32)(unsafe.Pointer(aiCol)) == iPrev) {
 143393 		goto __8
 143394 	}
 143395 	*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&aOut, 1))) = U8(iPrev - iPrevOut + 2)
 143396 	iPrevOut = iPrev
 143397 __8:
 143398 	;
 143399 	goto __3
 143400 __4:
 143401 	;
 143402 setoutputs_col_out:
 143403 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143404 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (int32(aOut) - int32((*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp)) / 1
 143405 __2:
 143406 }
 143407 
 143408 func fts5IterSetOutputs_Full(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
 143409 	var pColset uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FpColset
 143410 	(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
 143411 
 143412 	if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset+I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos) <= I64((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) {
 143413 		var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)
 143414 		var pRc uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex + 36
 143415 		sqlite3Fts5BufferZero(tls, pIter+28)
 143416 		fts5IndexExtractColset(tls, pRc, pColset, a, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos, pIter)
 143417 	} else {
 143418 		sqlite3Fts5BufferZero(tls, pIter+28)
 143419 		fts5SegiterPoslist(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex, pSeg, pColset, pIter+28)
 143420 		(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fp
 143421 		(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*Fts5Iter)(unsafe.Pointer(pIter)).Fposlist.Fn
 143422 	}
 143423 }
 143424 
 143425 func fts5IterSetOutputCb(tls *libc.TLS, pRc uintptr, pIter uintptr) {
 143426 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 143427 		var pConfig uintptr = (*Fts5Index)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex)).FpConfig
 143428 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE {
 143429 			(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143430 				f func(*libc.TLS, uintptr, uintptr)
 143431 			}{fts5IterSetOutputs_None}))
 143432 		} else if (*Fts5Iter)(unsafe.Pointer(pIter)).FpColset == uintptr(0) {
 143433 			(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143434 				f func(*libc.TLS, uintptr, uintptr)
 143435 			}{fts5IterSetOutputs_Nocolset}))
 143436 		} else if (*Fts5Colset)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FpColset)).FnCol == 0 {
 143437 			(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143438 				f func(*libc.TLS, uintptr, uintptr)
 143439 			}{fts5IterSetOutputs_ZeroColset}))
 143440 		} else if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL {
 143441 			(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143442 				f func(*libc.TLS, uintptr, uintptr)
 143443 			}{fts5IterSetOutputs_Full}))
 143444 		} else {
 143445 			if (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol <= 100 {
 143446 				(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143447 					f func(*libc.TLS, uintptr, uintptr)
 143448 				}{fts5IterSetOutputs_Col100}))
 143449 				sqlite3Fts5BufferSize(tls, pRc, pIter+28, uint32((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))
 143450 			} else {
 143451 				(*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct {
 143452 					f func(*libc.TLS, uintptr, uintptr)
 143453 				}{fts5IterSetOutputs_Col}))
 143454 			}
 143455 		}
 143456 	}
 143457 }
 143458 
 143459 func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pColset uintptr, pTerm uintptr, nTerm int32, iLevel int32, nSegment int32, ppOut uintptr) {
 143460 	var nSeg int32
 143461 	var iIter int32
 143462 	var iSeg int32
 143463 	var pLvl uintptr
 143464 	var pNew uintptr
 143465 
 143466 	var pIter uintptr
 143467 	var pSeg uintptr
 143468 	var pIter1 uintptr
 143469 	var pEnd uintptr
 143470 	var pSeg1 uintptr
 143471 	var iEq int32
 143472 	var pSeg2 uintptr
 143473 	nSeg = 0
 143474 	iIter = 0
 143475 
 143476 	if !((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 143477 		goto __1
 143478 	}
 143479 	if !(iLevel < 0) {
 143480 		goto __2
 143481 	}
 143482 
 143483 	nSeg = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment
 143484 	nSeg = nSeg + func() int32 {
 143485 		if (*Fts5Index)(unsafe.Pointer(p)).FpHash != 0 {
 143486 			return 1
 143487 		}
 143488 		return 0
 143489 	}()
 143490 	goto __3
 143491 __2:
 143492 	nSeg = func() int32 {
 143493 		if (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLevel)*12)).FnSeg < nSegment {
 143494 			return (*Fts5StructureLevel)(unsafe.Pointer(pStruct + 24 + uintptr(iLevel)*12)).FnSeg
 143495 		}
 143496 		return nSegment
 143497 	}()
 143498 __3:
 143499 	;
 143500 __1:
 143501 	;
 143502 	*(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pNew, fts5MultiIterAlloc(tls, p, nSeg))
 143503 	if !(pNew == uintptr(0)) {
 143504 		goto __4
 143505 	}
 143506 
 143507 	goto fts5MultiIterNew_post_check
 143508 __4:
 143509 	;
 143510 	(*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = libc.Bool32(0 != flags&FTS5INDEX_QUERY_DESC)
 143511 	(*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = U8(libc.Bool32(0 != flags&FTS5INDEX_QUERY_SKIPEMPTY))
 143512 	(*Fts5Iter)(unsafe.Pointer(pNew)).FpColset = pColset
 143513 	if !(flags&FTS5INDEX_QUERY_NOOUTPUT == 0) {
 143514 		goto __5
 143515 	}
 143516 	fts5IterSetOutputCb(tls, p+36, pNew)
 143517 __5:
 143518 	;
 143519 	if !((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 143520 		goto __6
 143521 	}
 143522 	if !(iLevel < 0) {
 143523 		goto __7
 143524 	}
 143525 	pEnd = pStruct + 24 + uintptr((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel)*12
 143526 	if !((*Fts5Index)(unsafe.Pointer(p)).FpHash != 0) {
 143527 		goto __9
 143528 	}
 143529 
 143530 	pIter = pNew + 80 + uintptr(libc.PostIncInt32(&iIter, 1))*96
 143531 	fts5SegIterHashInit(tls, p, pTerm, nTerm, flags, pIter)
 143532 __9:
 143533 	;
 143534 	pLvl = pStruct + 24
 143535 __10:
 143536 	if !(pLvl < pEnd) {
 143537 		goto __12
 143538 	}
 143539 	iSeg = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - 1
 143540 __13:
 143541 	if !(iSeg >= 0) {
 143542 		goto __15
 143543 	}
 143544 	pSeg = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*12
 143545 	pIter1 = pNew + 80 + uintptr(libc.PostIncInt32(&iIter, 1))*96
 143546 	if !(pTerm == uintptr(0)) {
 143547 		goto __16
 143548 	}
 143549 	fts5SegIterInit(tls, p, pSeg, pIter1)
 143550 	goto __17
 143551 __16:
 143552 	fts5SegIterSeekInit(tls, p, pTerm, nTerm, flags, pSeg, pIter1)
 143553 __17:
 143554 	;
 143555 	goto __14
 143556 __14:
 143557 	iSeg--
 143558 	goto __13
 143559 	goto __15
 143560 __15:
 143561 	;
 143562 	goto __11
 143563 __11:
 143564 	pLvl += 12
 143565 	goto __10
 143566 	goto __12
 143567 __12:
 143568 	;
 143569 	goto __8
 143570 __7:
 143571 	pLvl = pStruct + 24 + uintptr(iLevel)*12
 143572 	iSeg = nSeg - 1
 143573 __18:
 143574 	if !(iSeg >= 0) {
 143575 		goto __20
 143576 	}
 143577 	fts5SegIterInit(tls, p, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(iSeg)*12, pNew+80+uintptr(libc.PostIncInt32(&iIter, 1))*96)
 143578 	goto __19
 143579 __19:
 143580 	iSeg--
 143581 	goto __18
 143582 	goto __20
 143583 __20:
 143584 	;
 143585 __8:
 143586 	;
 143587 __6:
 143588 	;
 143589 	if !((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 143590 		goto __21
 143591 	}
 143592 	iIter = (*Fts5Iter)(unsafe.Pointer(pNew)).FnSeg - 1
 143593 __23:
 143594 	if !(iIter > 0) {
 143595 		goto __25
 143596 	}
 143597 	if !(libc.AssignInt32(&iEq, fts5MultiIterDoCompare(tls, pNew, iIter)) != 0) {
 143598 		goto __26
 143599 	}
 143600 	pSeg1 = pNew + 80 + uintptr(iEq)*96
 143601 	if !((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) {
 143602 		goto __27
 143603 	}
 143604 	(*struct {
 143605 		f func(*libc.TLS, uintptr, uintptr, uintptr)
 143606 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5SegIter)(unsafe.Pointer(pSeg1)).FxNext})).f(tls, p, pSeg1, uintptr(0))
 143607 __27:
 143608 	;
 143609 	fts5MultiIterAdvanced(tls, p, pNew, iEq, iIter)
 143610 __26:
 143611 	;
 143612 	goto __24
 143613 __24:
 143614 	iIter--
 143615 	goto __23
 143616 	goto __25
 143617 __25:
 143618 	;
 143619 	fts5MultiIterSetEof(tls, pNew)
 143620 
 143621 	if !((*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty != 0 && fts5MultiIterIsEmpty(tls, p, pNew) != 0) {
 143622 		goto __28
 143623 	}
 143624 	fts5MultiIterNext(tls, p, pNew, 0, int64(0))
 143625 	goto __29
 143626 __28:
 143627 	if !(int32((*Fts5Iter)(unsafe.Pointer(pNew)).Fbase.FbEof) == 0) {
 143628 		goto __30
 143629 	}
 143630 	pSeg2 = pNew + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst+1*4)).FiFirst)*96
 143631 	(*struct {
 143632 		f func(*libc.TLS, uintptr, uintptr)
 143633 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5Iter)(unsafe.Pointer(pNew)).FxSetOutputs})).f(tls, pNew, pSeg2)
 143634 __30:
 143635 	;
 143636 __29:
 143637 	;
 143638 	goto __22
 143639 __21:
 143640 	fts5MultiIterFree(tls, pNew)
 143641 	*(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0)
 143642 __22:
 143643 	;
 143644 fts5MultiIterNew_post_check:
 143645 	;
 143646 	return
 143647 }
 143648 
 143649 func fts5MultiIterNew2(tls *libc.TLS, p uintptr, pData uintptr, bDesc int32, ppOut uintptr) {
 143650 	var pNew uintptr
 143651 	pNew = fts5MultiIterAlloc(tls, p, 2)
 143652 	if pNew != 0 {
 143653 		var pIter uintptr = pNew + 80 + 1*96
 143654 
 143655 		(*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags = FTS5_SEGITER_ONETERM
 143656 		if (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf > 0 {
 143657 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pData
 143658 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = I64(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, pIter+80))
 143659 			(*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(pData)).Fnn
 143660 			(*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst + 1*4)).FiFirst = U16(1)
 143661 			if bDesc != 0 {
 143662 				(*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = 1
 143663 				*(*int32)(unsafe.Pointer(pIter + 4)) |= FTS5_SEGITER_REVERSE
 143664 				fts5SegIterReverseInitPage(tls, p, pIter)
 143665 			} else {
 143666 				fts5SegIterLoadNPos(tls, p, pIter)
 143667 			}
 143668 			pData = uintptr(0)
 143669 		} else {
 143670 			(*Fts5Iter)(unsafe.Pointer(pNew)).Fbase.FbEof = U8(1)
 143671 		}
 143672 		fts5SegIterSetNext(tls, p, pIter)
 143673 
 143674 		*(*uintptr)(unsafe.Pointer(ppOut)) = pNew
 143675 	}
 143676 
 143677 	fts5DataRelease(tls, pData)
 143678 }
 143679 
 143680 func fts5MultiIterEof(tls *libc.TLS, p uintptr, pIter uintptr) int32 {
 143681 	return libc.Bool32((*Fts5Index)(unsafe.Pointer(p)).Frc != 0 || (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof != 0)
 143682 }
 143683 
 143684 func fts5MultiIterRowid(tls *libc.TLS, pIter uintptr) I64 {
 143685 	return (*Fts5SegIter)(unsafe.Pointer(pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*96)).FiRowid
 143686 }
 143687 
 143688 func fts5MultiIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) {
 143689 	for 1 != 0 {
 143690 		var iRowid I64
 143691 		fts5MultiIterNext(tls, p, pIter, 1, iMatch)
 143692 		if fts5MultiIterEof(tls, p, pIter) != 0 {
 143693 			break
 143694 		}
 143695 		iRowid = fts5MultiIterRowid(tls, pIter)
 143696 		if (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev == 0 && iRowid >= iMatch {
 143697 			break
 143698 		}
 143699 		if (*Fts5Iter)(unsafe.Pointer(pIter)).FbRev != 0 && iRowid <= iMatch {
 143700 			break
 143701 		}
 143702 	}
 143703 }
 143704 
 143705 func fts5MultiIterTerm(tls *libc.TLS, pIter uintptr, pn uintptr) uintptr {
 143706 	var p uintptr = pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*96
 143707 	*(*int32)(unsafe.Pointer(pn)) = (*Fts5SegIter)(unsafe.Pointer(p)).Fterm.Fn
 143708 	return (*Fts5SegIter)(unsafe.Pointer(p)).Fterm.Fp
 143709 }
 143710 
 143711 func fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) int32 {
 143712 	bp := tls.Alloc(252)
 143713 	defer tls.Free(252)
 143714 
 143715 	var iSegid int32 = 0
 143716 
 143717 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 143718 		if (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= FTS5_MAX_SEGMENT {
 143719 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_FULL
 143720 		} else {
 143721 			var iLvl int32
 143722 			var iSeg int32
 143723 			var i int32
 143724 			var mask U32
 143725 			libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof([63]U32{})))
 143726 			for iLvl = 0; iLvl < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; iLvl++ {
 143727 				for iSeg = 0; iSeg < (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FnSeg; iSeg++ {
 143728 					var iId int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FaSeg + uintptr(iSeg)*12)).FiSegid
 143729 					if iId <= FTS5_MAX_SEGMENT && iId > 0 {
 143730 						*(*U32)(unsafe.Pointer(bp + uintptr((iId-1)/32)*4)) |= U32(1) << ((iId - 1) % 32)
 143731 					}
 143732 				}
 143733 			}
 143734 
 143735 			for i = 0; *(*U32)(unsafe.Pointer(bp + uintptr(i)*4)) == 0xFFFFFFFF; i++ {
 143736 			}
 143737 			mask = *(*U32)(unsafe.Pointer(bp + uintptr(i)*4))
 143738 			for iSegid = 0; mask&(U32(1)<<iSegid) != 0; iSegid++ {
 143739 			}
 143740 			iSegid = iSegid + (1 + i*32)
 143741 
 143742 		}
 143743 	}
 143744 
 143745 	return iSegid
 143746 }
 143747 
 143748 func fts5IndexDiscardData(tls *libc.TLS, p uintptr) {
 143749 	if (*Fts5Index)(unsafe.Pointer(p)).FpHash != 0 {
 143750 		sqlite3Fts5HashClear(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash)
 143751 		(*Fts5Index)(unsafe.Pointer(p)).FnPendingData = 0
 143752 	}
 143753 }
 143754 
 143755 func fts5PrefixCompress(tls *libc.TLS, nOld int32, pOld uintptr, pNew uintptr) int32 {
 143756 	var i int32
 143757 	for i = 0; i < nOld; i++ {
 143758 		if int32(*(*U8)(unsafe.Pointer(pOld + uintptr(i)))) != int32(*(*U8)(unsafe.Pointer(pNew + uintptr(i)))) {
 143759 			break
 143760 		}
 143761 	}
 143762 	return i
 143763 }
 143764 
 143765 func fts5WriteDlidxClear(tls *libc.TLS, p uintptr, pWriter uintptr, bFlush int32) {
 143766 	var i int32
 143767 
 143768 	for i = 0; i < (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx; i++ {
 143769 		var pDlidx uintptr = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32
 143770 		if (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn == 0 {
 143771 			break
 143772 		}
 143773 		if bFlush != 0 {
 143774 			fts5DataWrite(tls, p,
 143775 				I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+I64(i)<<FTS5_DATA_PAGE_B+I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno),
 143776 				(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp, (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn)
 143777 		}
 143778 		sqlite3Fts5BufferZero(tls, pDlidx+16)
 143779 		(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).FbPrevValid = 0
 143780 	}
 143781 }
 143782 
 143783 func fts5WriteDlidxGrow(tls *libc.TLS, p uintptr, pWriter uintptr, nLvl int32) int32 {
 143784 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && nLvl >= (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx {
 143785 		var aDlidx uintptr = Xsqlite3_realloc64(tls,
 143786 			(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx, uint64(uint32(unsafe.Sizeof(Fts5DlidxWriter{}))*uint32(nLvl)))
 143787 		if aDlidx == uintptr(0) {
 143788 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM
 143789 		} else {
 143790 			var nByte Size_t = uint32(unsafe.Sizeof(Fts5DlidxWriter{})) * uint32(nLvl-(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx)
 143791 			libc.Xmemset(tls, aDlidx+uintptr((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx)*32, 0, nByte)
 143792 			(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx = aDlidx
 143793 			(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx = nLvl
 143794 		}
 143795 	}
 143796 	return (*Fts5Index)(unsafe.Pointer(p)).Frc
 143797 }
 143798 
 143799 func fts5WriteFlushDlidx(tls *libc.TLS, p uintptr, pWriter uintptr) int32 {
 143800 	var bFlag int32 = 0
 143801 
 143802 	if (*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fbuf.Fn > 0 && (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= FTS5_MIN_DLIDX_SIZE {
 143803 		bFlag = 1
 143804 	}
 143805 	fts5WriteDlidxClear(tls, p, pWriter, bFlag)
 143806 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty = 0
 143807 	return bFlag
 143808 }
 143809 
 143810 func fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) {
 143811 	var bFlag int32
 143812 
 143813 	if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage == 0 {
 143814 		return
 143815 	}
 143816 	bFlag = fts5WriteFlushDlidx(tls, p, pWriter)
 143817 
 143818 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 143819 		var z uintptr = func() uintptr {
 143820 			if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn > 0 {
 143821 				return (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fp
 143822 			}
 143823 			return ts + 1554
 143824 		}()
 143825 
 143826 		Xsqlite3_bind_blob(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter, 2, z, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn, uintptr(0))
 143827 		Xsqlite3_bind_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter, 3, I64(bFlag)+I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage)<<1)
 143828 		Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter)
 143829 		(*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter)
 143830 		Xsqlite3_bind_null(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter, 2)
 143831 	}
 143832 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = 0
 143833 }
 143834 
 143835 func fts5WriteBtreeTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, pTerm uintptr) {
 143836 	fts5WriteFlushBtree(tls, p, pWriter)
 143837 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 143838 		sqlite3Fts5BufferSet(tls, p+36, pWriter+76, nTerm, pTerm)
 143839 		(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno
 143840 	}
 143841 }
 143842 
 143843 func fts5WriteBtreeNoTerm(tls *libc.TLS, p uintptr, pWriter uintptr) {
 143844 	if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0 && (*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fbuf.Fn > 0 {
 143845 		var pDlidx uintptr = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx
 143846 
 143847 		sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+16, int64(0))
 143848 	}
 143849 
 143850 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty++
 143851 }
 143852 
 143853 func fts5DlidxExtractFirstRowid(tls *libc.TLS, pBuf uintptr) I64 {
 143854 	bp := tls.Alloc(8)
 143855 	defer tls.Free(8)
 143856 
 143857 	var iOff int32
 143858 
 143859 	iOff = 1 + int32(sqlite3Fts5GetVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+1, bp))
 143860 	sqlite3Fts5GetVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr(iOff), bp)
 143861 	return *(*I64)(unsafe.Pointer(bp))
 143862 }
 143863 
 143864 func fts5WriteDlidxAppend(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) {
 143865 	var i int32
 143866 	var bDone int32 = 0
 143867 
 143868 	for i = 0; (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bDone == 0; i++ {
 143869 		var iVal I64
 143870 		var pDlidx uintptr = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32
 143871 
 143872 		if (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz {
 143873 			*(*U8)(unsafe.Pointer((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp)) = U8(0x01)
 143874 			fts5DataWrite(tls, p,
 143875 				I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(1)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+I64(i)<<FTS5_DATA_PAGE_B+I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno),
 143876 				(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp, (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn)
 143877 			fts5WriteDlidxGrow(tls, p, pWriter, i+2)
 143878 			pDlidx = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32
 143879 			if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx+1*32)).Fbuf.Fn == 0 {
 143880 				var iFirst I64 = fts5DlidxExtractFirstRowid(tls, pDlidx+16)
 143881 
 143882 				(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).Fpgno = (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno
 143883 				sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+1*32+16, int64(0))
 143884 				sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+1*32+16, int64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))
 143885 				sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+1*32+16, iFirst)
 143886 				(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).FbPrevValid = 1
 143887 				(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).FiPrev = iFirst
 143888 			}
 143889 
 143890 			sqlite3Fts5BufferZero(tls, pDlidx+16)
 143891 			(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).FbPrevValid = 0
 143892 			(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno++
 143893 		} else {
 143894 			bDone = 1
 143895 		}
 143896 
 143897 		if (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).FbPrevValid != 0 {
 143898 			iVal = iRowid - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).FiPrev
 143899 		} else {
 143900 			var iPgno I64 = func() int64 {
 143901 				if i == 0 {
 143902 					return int64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno)
 143903 				}
 143904 				return int64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + libc.UintptrFromInt32(-1)*32)).Fpgno)
 143905 			}()
 143906 
 143907 			sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+16, libc.BoolInt64(!(bDone != 0)))
 143908 			sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+16, iPgno)
 143909 			iVal = iRowid
 143910 		}
 143911 
 143912 		sqlite3Fts5BufferAppendVarint(tls, p+36, pDlidx+16, iVal)
 143913 		(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).FbPrevValid = 1
 143914 		(*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).FiPrev = iRowid
 143915 	}
 143916 }
 143917 
 143918 func fts5WriteFlushLeaf(tls *libc.TLS, p uintptr, pWriter uintptr) {
 143919 	var pPage uintptr = pWriter + 4
 143920 	var iRowid I64
 143921 
 143922 	fts5PutU16(tls, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp+2, U16((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn))
 143923 
 143924 	if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage != 0 {
 143925 		fts5WriteBtreeNoTerm(tls, p, pWriter)
 143926 	} else {
 143927 		sqlite3Fts5BufferAppendBlob(tls, p+36, pPage+8, uint32((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn), (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fp)
 143928 	}
 143929 
 143930 	iRowid = I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + I64((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno)
 143931 	fts5DataWrite(tls, p, iRowid, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn)
 143932 
 143933 	sqlite3Fts5BufferZero(tls, pPage+8)
 143934 	sqlite3Fts5BufferZero(tls, pPage+20)
 143935 	sqlite3Fts5BufferAppendBlob(tls, p+36, pPage+8, uint32(4), uintptr(unsafe.Pointer(&zero)))
 143936 	(*Fts5PageWriter)(unsafe.Pointer(pPage)).FiPrevPgidx = 0
 143937 	(*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno++
 143938 
 143939 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnLeafWritten++
 143940 
 143941 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage = U8(1)
 143942 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = U8(1)
 143943 }
 143944 
 143945 var zero = [4]U8{U8(0x00), U8(0x00), U8(0x00), U8(0x00)}
 143946 
 143947 func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, pTerm uintptr) {
 143948 	var nPrefix int32
 143949 	var pPage uintptr = pWriter + 4
 143950 	var pPgidx uintptr = pWriter + 4 + 20
 143951 	var nMin int32 = func() int32 {
 143952 		if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fn < nTerm {
 143953 			return (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fn
 143954 		}
 143955 		return nTerm
 143956 	}()
 143957 
 143958 	if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn+(*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn+nTerm+2 >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz {
 143959 		if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn > 4 {
 143960 			fts5WriteFlushLeaf(tls, p, pWriter)
 143961 			if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 143962 				return
 143963 			}
 143964 		}
 143965 		if !(U32((*Fts5Buffer)(unsafe.Pointer(pPage+8)).Fn)+U32(nTerm+FTS5_DATA_PADDING) <= U32((*Fts5Buffer)(unsafe.Pointer(pPage+8)).FnSpace)) {
 143966 			sqlite3Fts5BufferSize(tls, p+36, pPage+8, uint32(nTerm+FTS5_DATA_PADDING+(*Fts5Buffer)(unsafe.Pointer(pPage+8)).Fn))
 143967 		}
 143968 	}
 143969 
 143970 	*(*int32)(unsafe.Pointer(pPgidx + 4)) += sqlite3Fts5PutVarint(tls,
 143971 		(*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn), uint64((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn-(*Fts5PageWriter)(unsafe.Pointer(pPage)).FiPrevPgidx))
 143972 	(*Fts5PageWriter)(unsafe.Pointer(pPage)).FiPrevPgidx = (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn
 143973 
 143974 	if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage != 0 {
 143975 		nPrefix = 0
 143976 		if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno != 1 {
 143977 			var n int32 = nTerm
 143978 			if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fn != 0 {
 143979 				n = 1 + fts5PrefixCompress(tls, nMin, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fp, pTerm)
 143980 			}
 143981 			fts5WriteBtreeTerm(tls, p, pWriter, n, pTerm)
 143982 			if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 143983 				return
 143984 			}
 143985 			pPage = pWriter + 4
 143986 		}
 143987 	} else {
 143988 		nPrefix = fts5PrefixCompress(tls, nMin, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fp, pTerm)
 143989 		sqlite3Fts5BufferAppendVarint(tls, p+36, pPage+8, I64(nPrefix))
 143990 	}
 143991 
 143992 	sqlite3Fts5BufferAppendVarint(tls, p+36, pPage+8, I64(nTerm)-I64(nPrefix))
 143993 	sqlite3Fts5BufferAppendBlob(tls, p+36, pPage+8, uint32(nTerm-nPrefix), pTerm+uintptr(nPrefix))
 143994 
 143995 	sqlite3Fts5BufferSet(tls, p+36, pPage+32, nTerm, pTerm)
 143996 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage = U8(0)
 143997 
 143998 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = U8(0)
 143999 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist = U8(1)
 144000 
 144001 	(*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fpgno = (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno
 144002 }
 144003 
 144004 func fts5WriteAppendRowid(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) {
 144005 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144006 		var pPage uintptr = pWriter + 4
 144007 
 144008 		if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn+(*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz {
 144009 			fts5WriteFlushLeaf(tls, p, pWriter)
 144010 		}
 144011 
 144012 		if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0 {
 144013 			fts5PutU16(tls, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp, U16((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn))
 144014 			fts5WriteDlidxAppend(tls, p, pWriter, iRowid)
 144015 		}
 144016 
 144017 		if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist != 0 || (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0 {
 144018 			sqlite3Fts5BufferAppendVarint(tls, p+36, pPage+8, iRowid)
 144019 		} else {
 144020 			sqlite3Fts5BufferAppendVarint(tls, p+36, pPage+8, int64(U64(I64(U64(iRowid)))-U64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiPrevRowid)))
 144021 		}
 144022 		(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiPrevRowid = iRowid
 144023 		(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist = U8(0)
 144024 		(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = U8(0)
 144025 	}
 144026 }
 144027 
 144028 func fts5WriteAppendPoslistData(tls *libc.TLS, p uintptr, pWriter uintptr, aData uintptr, nData int32) {
 144029 	bp := tls.Alloc(8)
 144030 	defer tls.Free(8)
 144031 
 144032 	var pPage uintptr = pWriter + 4
 144033 	var a uintptr = aData
 144034 	var n int32 = nData
 144035 
 144036 	for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK &&
 144037 		(*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn+(*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn+n >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz {
 144038 		var nReq int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz - (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn - (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn
 144039 		var nCopy int32 = 0
 144040 		for nCopy < nReq {
 144041 			nCopy = nCopy + int32(sqlite3Fts5GetVarint(tls, a+uintptr(nCopy), bp))
 144042 		}
 144043 		sqlite3Fts5BufferAppendBlob(tls, p+36, pPage+8, uint32(nCopy), a)
 144044 		a += uintptr(nCopy)
 144045 		n = n - nCopy
 144046 		fts5WriteFlushLeaf(tls, p, pWriter)
 144047 	}
 144048 	if n > 0 {
 144049 		sqlite3Fts5BufferAppendBlob(tls, p+36, pPage+8, uint32(n), a)
 144050 	}
 144051 }
 144052 
 144053 func fts5WriteFinish(tls *libc.TLS, p uintptr, pWriter uintptr, pnLeaf uintptr) {
 144054 	var i int32
 144055 	var pLeaf uintptr = pWriter + 4
 144056 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144057 		if (*Fts5PageWriter)(unsafe.Pointer(pLeaf)).Fbuf.Fn > 4 {
 144058 			fts5WriteFlushLeaf(tls, p, pWriter)
 144059 		}
 144060 		*(*int32)(unsafe.Pointer(pnLeaf)) = (*Fts5PageWriter)(unsafe.Pointer(pLeaf)).Fpgno - 1
 144061 		if (*Fts5PageWriter)(unsafe.Pointer(pLeaf)).Fpgno > 1 {
 144062 			fts5WriteFlushBtree(tls, p, pWriter)
 144063 		}
 144064 	}
 144065 	sqlite3Fts5BufferFree(tls, pLeaf+32)
 144066 	sqlite3Fts5BufferFree(tls, pLeaf+8)
 144067 	sqlite3Fts5BufferFree(tls, pLeaf+20)
 144068 	sqlite3Fts5BufferFree(tls, pWriter+76)
 144069 
 144070 	for i = 0; i < (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx; i++ {
 144071 		sqlite3Fts5BufferFree(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx+uintptr(i)*32+16)
 144072 	}
 144073 	Xsqlite3_free(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)
 144074 }
 144075 
 144076 func fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) {
 144077 	bp := tls.Alloc(16)
 144078 	defer tls.Free(16)
 144079 
 144080 	var nBuffer int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + FTS5_DATA_PADDING
 144081 
 144082 	libc.Xmemset(tls, pWriter, 0, uint32(unsafe.Sizeof(Fts5SegWriter{})))
 144083 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid = iSegid
 144084 
 144085 	fts5WriteDlidxGrow(tls, p, pWriter, 1)
 144086 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno = 1
 144087 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage = U8(1)
 144088 	(*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = 1
 144089 
 144090 	sqlite3Fts5BufferSize(tls, p+36, pWriter+4+20, uint32(nBuffer))
 144091 	sqlite3Fts5BufferSize(tls, p+36, pWriter+4+8, uint32(nBuffer))
 144092 
 144093 	if (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter == uintptr(0) {
 144094 		var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 144095 		fts5IndexPrepareStmt(tls, p, p+52, Xsqlite3_mprintf(tls,
 144096 			ts+35129,
 144097 			libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)))
 144098 	}
 144099 
 144100 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144101 		libc.Xmemset(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fp, 0, uint32(4))
 144102 		(*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fn = 4
 144103 
 144104 		Xsqlite3_bind_int(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter, 1, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)
 144105 	}
 144106 }
 144107 
 144108 func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) {
 144109 	bp := tls.Alloc(16)
 144110 	defer tls.Free(16)
 144111 
 144112 	var i int32
 144113 
 144114 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 144115 	for i = 0; i < (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg && (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK; i++ {
 144116 		var pSeg uintptr = pIter + 80 + uintptr(i)*96
 144117 		if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) {
 144118 		} else if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0) {
 144119 			(*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoLast = 0
 144120 			(*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = 0
 144121 		} else {
 144122 			var iOff int32 = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafOffset
 144123 			var iLeafRowid I64
 144124 			var pData uintptr
 144125 			var iId int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid
 144126 			*(*[4]U8)(unsafe.Pointer(bp + 12)) = [4]U8{U8(0x00), U8(0x00), U8(0x00), U8(0x00)}
 144127 
 144128 			iLeafRowid = I64(iId)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno)
 144129 			pData = fts5LeafRead(tls, p, iLeafRowid)
 144130 			if pData != 0 {
 144131 				if iOff > (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf {
 144132 					(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 144133 				} else {
 144134 					sqlite3Fts5BufferZero(tls, bp)
 144135 					if !(U32((*Fts5Buffer)(unsafe.Pointer(bp)).Fn)+U32((*Fts5Data)(unsafe.Pointer(pData)).Fnn) <= U32((*Fts5Buffer)(unsafe.Pointer(bp)).FnSpace)) {
 144136 						sqlite3Fts5BufferSize(tls, p+36, bp, uint32((*Fts5Data)(unsafe.Pointer(pData)).Fnn+(*Fts5Buffer)(unsafe.Pointer(bp)).Fn))
 144137 					}
 144138 					sqlite3Fts5BufferAppendBlob(tls, p+36, bp, uint32(unsafe.Sizeof([4]U8{})), bp+12)
 144139 					sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn))
 144140 					sqlite3Fts5BufferAppendBlob(tls, p+36, bp, uint32((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn), (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp)
 144141 					sqlite3Fts5BufferAppendBlob(tls, p+36, bp, uint32((*Fts5Data)(unsafe.Pointer(pData)).FszLeaf-iOff), (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr(iOff))
 144142 					if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144143 						fts5PutU16(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+2, U16((*Fts5Buffer)(unsafe.Pointer(bp)).Fn))
 144144 					}
 144145 
 144146 					sqlite3Fts5BufferAppendVarint(tls, p+36, bp, int64(4))
 144147 					if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno == (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno &&
 144148 						(*Fts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist < (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf &&
 144149 						(*Fts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff <= (*Fts5Data)(unsafe.Pointer(pData)).Fnn {
 144150 						var nDiff int32 = (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf - (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiEndofDoclist
 144151 						sqlite3Fts5BufferAppendVarint(tls, p+36, bp, I64((*Fts5Buffer)(unsafe.Pointer(bp)).Fn)-int64(1)-I64(nDiff)-int64(4))
 144152 						sqlite3Fts5BufferAppendBlob(tls, p+36, bp, uint32((*Fts5Data)(unsafe.Pointer(pData)).Fnn-(*Fts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff), (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiPgidxOff))
 144153 					}
 144154 
 144155 					(*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno
 144156 					fts5DataDelete(tls, p, I64(iId)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+int64(0)<<FTS5_DATA_PAGE_B+int64(1), iLeafRowid)
 144157 					fts5DataWrite(tls, p, iLeafRowid, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp)).Fn)
 144158 				}
 144159 				fts5DataRelease(tls, pData)
 144160 			}
 144161 		}
 144162 	}
 144163 	sqlite3Fts5BufferFree(tls, bp)
 144164 }
 144165 
 144166 func fts5MergeChunkCallback(tls *libc.TLS, p uintptr, pCtx uintptr, pChunk uintptr, nChunk int32) {
 144167 	var pWriter uintptr = pCtx
 144168 	fts5WriteAppendPoslistData(tls, p, pWriter, pChunk, nChunk)
 144169 }
 144170 
 144171 func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, pnRem uintptr) {
 144172 	bp := tls.Alloc(116)
 144173 	defer tls.Free(116)
 144174 
 144175 	var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct))
 144176 	var pLvl uintptr = pStruct + 24 + uintptr(iLvl)*12
 144177 	var pLvlOut uintptr
 144178 	*(*uintptr)(unsafe.Pointer(bp + 108)) = uintptr(0)
 144179 	var nRem int32
 144180 	if pnRem != 0 {
 144181 		nRem = *(*int32)(unsafe.Pointer(pnRem))
 144182 	} else {
 144183 		nRem = 0
 144184 	}
 144185 	var nInput int32
 144186 
 144187 	var pSeg uintptr
 144188 
 144189 	var bOldest int32
 144190 	var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail
 144191 	var flags int32 = FTS5INDEX_QUERY_NOOUTPUT
 144192 	var bTermWritten int32 = 0
 144193 
 144194 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5SegWriter{})))
 144195 	libc.Xmemset(tls, bp+96, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 144196 	if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 {
 144197 		pLvlOut = pStruct + 24 + uintptr(iLvl+1)*12
 144198 
 144199 		nInput = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge
 144200 		pSeg = (*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FaSeg + uintptr((*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg-1)*12
 144201 
 144202 		fts5WriteInit(tls, p, bp, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)
 144203 		(*Fts5SegWriter)(unsafe.Pointer(bp)).Fwriter.Fpgno = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast + 1
 144204 		(*Fts5SegWriter)(unsafe.Pointer(bp)).FiBtPage = 0
 144205 	} else {
 144206 		var iSegid int32 = fts5AllocateSegid(tls, p, pStruct)
 144207 
 144208 		if iLvl == (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel-1 {
 144209 			fts5StructureAddLevel(tls, p+36, ppStruct)
 144210 			pStruct = *(*uintptr)(unsafe.Pointer(ppStruct))
 144211 		}
 144212 		fts5StructureExtendLevel(tls, p+36, pStruct, iLvl+1, 1, 0)
 144213 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 144214 			return
 144215 		}
 144216 		pLvl = pStruct + 24 + uintptr(iLvl)*12
 144217 		pLvlOut = pStruct + 24 + uintptr(iLvl+1)*12
 144218 
 144219 		fts5WriteInit(tls, p, bp, iSegid)
 144220 
 144221 		pSeg = (*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FaSeg + uintptr((*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg)*12
 144222 		(*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg++
 144223 		(*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = 1
 144224 		(*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid
 144225 		(*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment++
 144226 
 144227 		nInput = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg
 144228 	}
 144229 	bOldest = libc.Bool32((*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg == 1 && (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel == iLvl+2)
 144230 
 144231 	for fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, iLvl, nInput, bp+108); fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 108))) == 0; fts5MultiIterNext(tls, p, *(*uintptr)(unsafe.Pointer(bp + 108)), 0, int64(0)) {
 144232 		var pSegIter uintptr = *(*uintptr)(unsafe.Pointer(bp + 108)) + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 108)))).FaFirst+1*4)).FiFirst)*96
 144233 		var nPos int32
 144234 
 144235 		var pTerm uintptr
 144236 
 144237 		pTerm = fts5MultiIterTerm(tls, *(*uintptr)(unsafe.Pointer(bp + 108)), bp+112)
 144238 		if *(*int32)(unsafe.Pointer(bp + 112)) != (*Fts5Buffer)(unsafe.Pointer(bp+96)).Fn || func() int32 {
 144239 			if *(*int32)(unsafe.Pointer(bp + 112)) <= 0 {
 144240 				return 0
 144241 			}
 144242 			return libc.Xmemcmp(tls, pTerm, (*Fts5Buffer)(unsafe.Pointer(bp+96)).Fp, uint32(*(*int32)(unsafe.Pointer(bp + 112))))
 144243 		}() != 0 {
 144244 			if pnRem != 0 && (*Fts5SegWriter)(unsafe.Pointer(bp)).FnLeafWritten > nRem {
 144245 				break
 144246 			}
 144247 			sqlite3Fts5BufferSet(tls, p+36, bp+96, *(*int32)(unsafe.Pointer(bp + 112)), pTerm)
 144248 			bTermWritten = 0
 144249 		}
 144250 
 144251 		if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FnPos == 0 && (bOldest != 0 || int32((*Fts5SegIter)(unsafe.Pointer(pSegIter)).FbDel) == 0) {
 144252 			continue
 144253 		}
 144254 
 144255 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bTermWritten == 0 {
 144256 			fts5WriteAppendTerm(tls, p, bp, *(*int32)(unsafe.Pointer(bp + 112)), pTerm)
 144257 			bTermWritten = 1
 144258 		}
 144259 
 144260 		fts5WriteAppendRowid(tls, p, bp, fts5MultiIterRowid(tls, *(*uintptr)(unsafe.Pointer(bp + 108))))
 144261 
 144262 		if eDetail == FTS5_DETAIL_NONE {
 144263 			if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FbDel != 0 {
 144264 				sqlite3Fts5BufferAppendVarint(tls, p+36, bp+4+8, int64(0))
 144265 				if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FnPos > 0 {
 144266 					sqlite3Fts5BufferAppendVarint(tls, p+36, bp+4+8, int64(0))
 144267 				}
 144268 			}
 144269 		} else {
 144270 			nPos = (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FnPos*2 + int32((*Fts5SegIter)(unsafe.Pointer(pSegIter)).FbDel)
 144271 			sqlite3Fts5BufferAppendVarint(tls, p+36, bp+4+8, I64(nPos))
 144272 			fts5ChunkIterate(tls, p, pSegIter, bp, *(*uintptr)(unsafe.Pointer(&struct {
 144273 				f func(*libc.TLS, uintptr, uintptr, uintptr, int32)
 144274 			}{fts5MergeChunkCallback})))
 144275 		}
 144276 	}
 144277 
 144278 	fts5WriteFinish(tls, p, bp, pSeg+8)
 144279 
 144280 	if fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 108))) != 0 {
 144281 		var i int32
 144282 
 144283 		for i = 0; i < nInput; i++ {
 144284 			fts5DataRemoveSegment(tls, p, (*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(i)*12)).FiSegid)
 144285 		}
 144286 
 144287 		if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg != nInput {
 144288 			var nMove int32 = int32(uint32((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg-nInput) * uint32(unsafe.Sizeof(Fts5StructureSegment{})))
 144289 			libc.Xmemmove(tls, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg, (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg+uintptr(nInput)*12, uint32(nMove))
 144290 		}
 144291 		*(*int32)(unsafe.Pointer(pStruct + 16)) -= nInput
 144292 		*(*int32)(unsafe.Pointer(pLvl + 4)) -= nInput
 144293 		(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge = 0
 144294 		if (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast == 0 {
 144295 			(*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg--
 144296 			(*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment--
 144297 		}
 144298 	} else {
 144299 		fts5TrimSegments(tls, p, *(*uintptr)(unsafe.Pointer(bp + 108)))
 144300 		(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge = nInput
 144301 	}
 144302 
 144303 	fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp + 108)))
 144304 	sqlite3Fts5BufferFree(tls, bp+96)
 144305 	if pnRem != 0 {
 144306 		*(*int32)(unsafe.Pointer(pnRem)) -= (*Fts5SegWriter)(unsafe.Pointer(bp)).FnLeafWritten
 144307 	}
 144308 }
 144309 
 144310 func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin int32) int32 {
 144311 	bp := tls.Alloc(8)
 144312 	defer tls.Free(8)
 144313 
 144314 	*(*int32)(unsafe.Pointer(bp + 4)) = nPg
 144315 	var bRet int32 = 0
 144316 	*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(ppStruct))
 144317 	for *(*int32)(unsafe.Pointer(bp + 4)) > 0 && (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144318 		var iLvl int32
 144319 		var iBestLvl int32 = 0
 144320 		var nBest int32 = 0
 144321 
 144322 		for iLvl = 0; iLvl < (*Fts5Structure)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnLevel; iLvl++ {
 144323 			var pLvl uintptr = *(*uintptr)(unsafe.Pointer(bp)) + 24 + uintptr(iLvl)*12
 144324 			if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0 {
 144325 				if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge > nBest {
 144326 					iBestLvl = iLvl
 144327 					nBest = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge
 144328 				}
 144329 				break
 144330 			}
 144331 			if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg > nBest {
 144332 				nBest = (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg
 144333 				iBestLvl = iLvl
 144334 			}
 144335 		}
 144336 
 144337 		if nBest < nMin && (*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))+24+uintptr(iBestLvl)*12)).FnMerge == 0 {
 144338 			break
 144339 		}
 144340 		bRet = 1
 144341 		fts5IndexMergeLevel(tls, p, bp, iBestLvl, bp+4)
 144342 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))+24+uintptr(iBestLvl)*12)).FnMerge == 0 {
 144343 			fts5StructurePromote(tls, p, iBestLvl+1, *(*uintptr)(unsafe.Pointer(bp)))
 144344 		}
 144345 	}
 144346 	*(*uintptr)(unsafe.Pointer(ppStruct)) = *(*uintptr)(unsafe.Pointer(bp))
 144347 	return bRet
 144348 }
 144349 
 144350 func fts5IndexAutomerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nLeaf int32) {
 144351 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge > 0 && *(*uintptr)(unsafe.Pointer(ppStruct)) != uintptr(0) {
 144352 		var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct))
 144353 		var nWrite U64
 144354 		var nWork int32
 144355 		var nRem int32
 144356 
 144357 		nWrite = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter
 144358 		nWork = int32((nWrite+U64(nLeaf))/U64((*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit) - nWrite/U64((*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit))
 144359 		*(*U64)(unsafe.Pointer(pStruct + 8)) += U64(nLeaf)
 144360 		nRem = (*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit * nWork * (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel
 144361 
 144362 		fts5IndexMerge(tls, p, ppStruct, nRem, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge)
 144363 	}
 144364 }
 144365 
 144366 func fts5IndexCrisismerge(tls *libc.TLS, p uintptr, ppStruct uintptr) {
 144367 	bp := tls.Alloc(4)
 144368 	defer tls.Free(4)
 144369 
 144370 	var nCrisis int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnCrisisMerge
 144371 	*(*uintptr)(unsafe.Pointer(bp)) = *(*uintptr)(unsafe.Pointer(ppStruct))
 144372 	var iLvl int32 = 0
 144373 
 144374 	for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))+24+uintptr(iLvl)*12)).FnSeg >= nCrisis {
 144375 		fts5IndexMergeLevel(tls, p, bp, iLvl, uintptr(0))
 144376 
 144377 		fts5StructurePromote(tls, p, iLvl+1, *(*uintptr)(unsafe.Pointer(bp)))
 144378 		iLvl++
 144379 	}
 144380 	*(*uintptr)(unsafe.Pointer(ppStruct)) = *(*uintptr)(unsafe.Pointer(bp))
 144381 }
 144382 
 144383 func fts5IndexReturn(tls *libc.TLS, p uintptr) int32 {
 144384 	var rc int32 = (*Fts5Index)(unsafe.Pointer(p)).Frc
 144385 	(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_OK
 144386 	return rc
 144387 }
 144388 
 144389 type Fts5FlushCtx1 = struct {
 144390 	FpIdx        uintptr
 144391 	F__ccgo_pad1 [4]byte
 144392 	Fwriter      Fts5SegWriter
 144393 }
 144394 
 144395 type Fts5FlushCtx = Fts5FlushCtx1
 144396 
 144397 func fts5PoslistPrefix(tls *libc.TLS, aBuf uintptr, nMax int32) int32 {
 144398 	bp := tls.Alloc(4)
 144399 	defer tls.Free(4)
 144400 
 144401 	var ret int32
 144402 
 144403 	ret = sqlite3Fts5GetVarint32(tls, aBuf, bp)
 144404 	if ret < nMax {
 144405 		for 1 != 0 {
 144406 			var i int32 = sqlite3Fts5GetVarint32(tls, aBuf+uintptr(ret), bp)
 144407 			if ret+i > nMax {
 144408 				break
 144409 			}
 144410 			ret = ret + i
 144411 		}
 144412 	}
 144413 	return ret
 144414 }
 144415 
 144416 func fts5FlushOneHash(tls *libc.TLS, p uintptr) {
 144417 	bp := tls.Alloc(136)
 144418 	defer tls.Free(136)
 144419 
 144420 	var pHash uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpHash
 144421 
 144422 	var iSegid int32
 144423 	*(*int32)(unsafe.Pointer(bp + 128)) = 0
 144424 
 144425 	*(*uintptr)(unsafe.Pointer(bp + 132)) = fts5StructureRead(tls, p)
 144426 	iSegid = fts5AllocateSegid(tls, p, *(*uintptr)(unsafe.Pointer(bp + 132)))
 144427 	fts5StructureInvalidate(tls, p)
 144428 
 144429 	if iSegid != 0 {
 144430 		var pgsz int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz
 144431 		var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail
 144432 		var pSeg uintptr
 144433 		var pBuf uintptr
 144434 		var pPgidx uintptr
 144435 
 144436 		fts5WriteInit(tls, p, bp, iSegid)
 144437 
 144438 		pBuf = bp + 4 + 8
 144439 		pPgidx = bp + 4 + 20
 144440 
 144441 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144442 			(*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashScanInit(tls, pHash, uintptr(0), 0)
 144443 		}
 144444 		for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && 0 == sqlite3Fts5HashScanEof(tls, pHash) {
 144445 			sqlite3Fts5HashScanEntry(tls, pHash, bp+96, bp+100, bp+104)
 144446 			fts5WriteAppendTerm(tls, p, bp, int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 96)))), *(*uintptr)(unsafe.Pointer(bp + 96)))
 144447 			if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 144448 				break
 144449 			}
 144450 
 144451 			if pgsz >= (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn+*(*int32)(unsafe.Pointer(bp + 104))+1 {
 144452 				{
 144453 					libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), *(*uintptr)(unsafe.Pointer(bp + 100)), uint32(*(*int32)(unsafe.Pointer(bp + 104))))
 144454 					*(*int32)(unsafe.Pointer(pBuf + 4)) += *(*int32)(unsafe.Pointer(bp + 104))
 144455 				}
 144456 
 144457 			} else {
 144458 				var iRowid I64 = int64(0)
 144459 				*(*U64)(unsafe.Pointer(bp + 112)) = uint64(0)
 144460 				var iOff int32 = 0
 144461 
 144462 				for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && iOff < *(*int32)(unsafe.Pointer(bp + 104)) {
 144463 					iOff = iOff + int32(sqlite3Fts5GetVarint(tls, *(*uintptr)(unsafe.Pointer(bp + 100))+uintptr(iOff), bp+112))
 144464 					iRowid = I64(U64(iRowid) + *(*U64)(unsafe.Pointer(bp + 112)))
 144465 
 144466 					if (*Fts5SegWriter)(unsafe.Pointer(bp)).FbFirstRowidInPage != 0 {
 144467 						fts5PutU16(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, U16((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn))
 144468 						*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), uint64(iRowid))
 144469 						(*Fts5SegWriter)(unsafe.Pointer(bp)).FbFirstRowidInPage = U8(0)
 144470 						fts5WriteDlidxAppend(tls, p, bp, iRowid)
 144471 						if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
 144472 							break
 144473 						}
 144474 					} else {
 144475 						*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), *(*U64)(unsafe.Pointer(bp + 112)))
 144476 					}
 144477 
 144478 					if eDetail == FTS5_DETAIL_NONE {
 144479 						if iOff < *(*int32)(unsafe.Pointer(bp + 104)) && int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 100)) + uintptr(iOff)))) == 0 {
 144480 							*(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(libc.PostIncInt32(&(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, 1)))) = U8(0)
 144481 							iOff++
 144482 							if iOff < *(*int32)(unsafe.Pointer(bp + 104)) && int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 100)) + uintptr(iOff)))) == 0 {
 144483 								*(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(libc.PostIncInt32(&(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, 1)))) = U8(0)
 144484 								iOff++
 144485 							}
 144486 						}
 144487 						if (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn >= pgsz {
 144488 							fts5WriteFlushLeaf(tls, p, bp)
 144489 						}
 144490 					} else {
 144491 						var nCopy int32 = fts5GetPoslistSize(tls, *(*uintptr)(unsafe.Pointer(bp + 100))+uintptr(iOff), bp+120, bp+124)
 144492 						nCopy = nCopy + *(*int32)(unsafe.Pointer(bp + 120))
 144493 						if (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn+nCopy <= pgsz {
 144494 							{
 144495 								libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), *(*uintptr)(unsafe.Pointer(bp + 100))+uintptr(iOff), uint32(nCopy))
 144496 								*(*int32)(unsafe.Pointer(pBuf + 4)) += nCopy
 144497 							}
 144498 
 144499 						} else {
 144500 							var pPoslist uintptr = *(*uintptr)(unsafe.Pointer(bp + 100)) + uintptr(iOff)
 144501 							var iPos int32 = 0
 144502 							for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144503 								var nSpace int32 = pgsz - (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn - (*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn
 144504 								var n int32 = 0
 144505 								if nCopy-iPos <= nSpace {
 144506 									n = nCopy - iPos
 144507 								} else {
 144508 									n = fts5PoslistPrefix(tls, pPoslist+uintptr(iPos), nSpace)
 144509 								}
 144510 
 144511 								{
 144512 									libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), pPoslist+uintptr(iPos), uint32(n))
 144513 									*(*int32)(unsafe.Pointer(pBuf + 4)) += n
 144514 								}
 144515 
 144516 								iPos = iPos + n
 144517 								if (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn+(*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn >= pgsz {
 144518 									fts5WriteFlushLeaf(tls, p, bp)
 144519 								}
 144520 								if iPos >= nCopy {
 144521 									break
 144522 								}
 144523 							}
 144524 						}
 144525 						iOff = iOff + nCopy
 144526 					}
 144527 				}
 144528 			}
 144529 
 144530 			if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144531 				sqlite3Fts5HashScanNext(tls, pHash)
 144532 			}
 144533 		}
 144534 		sqlite3Fts5HashClear(tls, pHash)
 144535 		fts5WriteFinish(tls, p, bp, bp+128)
 144536 
 144537 		if (*Fts5Structure)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 132)))).FnLevel == 0 {
 144538 			fts5StructureAddLevel(tls, p+36, bp+132)
 144539 		}
 144540 		fts5StructureExtendLevel(tls, p+36, *(*uintptr)(unsafe.Pointer(bp + 132)), 0, 1, 0)
 144541 		if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144542 			pSeg = (*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 132))+24)).FaSeg + uintptr(libc.PostIncInt32(&(*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 132))+24)).FnSeg, 1))*12
 144543 			(*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid
 144544 			(*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = 1
 144545 			(*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast = *(*int32)(unsafe.Pointer(bp + 128))
 144546 			(*Fts5Structure)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 132)))).FnSegment++
 144547 		}
 144548 		fts5StructurePromote(tls, p, 0, *(*uintptr)(unsafe.Pointer(bp + 132)))
 144549 	}
 144550 
 144551 	fts5IndexAutomerge(tls, p, bp+132, *(*int32)(unsafe.Pointer(bp + 128)))
 144552 	fts5IndexCrisismerge(tls, p, bp+132)
 144553 	fts5StructureWrite(tls, p, *(*uintptr)(unsafe.Pointer(bp + 132)))
 144554 	fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 132)))
 144555 }
 144556 
 144557 func fts5IndexFlush(tls *libc.TLS, p uintptr) {
 144558 	if (*Fts5Index)(unsafe.Pointer(p)).FnPendingData != 0 {
 144559 		(*Fts5Index)(unsafe.Pointer(p)).FnPendingData = 0
 144560 		fts5FlushOneHash(tls, p)
 144561 	}
 144562 }
 144563 
 144564 func fts5IndexOptimizeStruct(tls *libc.TLS, p uintptr, pStruct uintptr) uintptr {
 144565 	var pNew uintptr = uintptr(0)
 144566 	var nByte Sqlite3_int64 = Sqlite3_int64(unsafe.Sizeof(Fts5Structure{}))
 144567 	var nSeg int32 = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment
 144568 	var i int32
 144569 
 144570 	if nSeg < 2 {
 144571 		return uintptr(0)
 144572 	}
 144573 	for i = 0; i < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; i++ {
 144574 		var nThis int32 = (*Fts5StructureLevel)(unsafe.Pointer(pStruct + 24 + uintptr(i)*12)).FnSeg
 144575 		if nThis == nSeg || nThis == nSeg-1 && (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(i)*12)).FnMerge == nThis {
 144576 			fts5StructureRef(tls, pStruct)
 144577 			return pStruct
 144578 		}
 144579 
 144580 	}
 144581 
 144582 	nByte = nByte + Sqlite3_int64(uint32((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel+1)*uint32(unsafe.Sizeof(Fts5StructureLevel{})))
 144583 	pNew = sqlite3Fts5MallocZero(tls, p+36, nByte)
 144584 
 144585 	if pNew != 0 {
 144586 		var pLvl uintptr
 144587 		nByte = Sqlite3_int64(uint32(nSeg) * uint32(unsafe.Sizeof(Fts5StructureSegment{})))
 144588 		(*Fts5Structure)(unsafe.Pointer(pNew)).FnLevel = func() int32 {
 144589 			if (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel+1 < FTS5_MAX_LEVEL {
 144590 				return (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel + 1
 144591 			}
 144592 			return FTS5_MAX_LEVEL
 144593 		}()
 144594 		(*Fts5Structure)(unsafe.Pointer(pNew)).FnRef = 1
 144595 		(*Fts5Structure)(unsafe.Pointer(pNew)).FnWriteCounter = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnWriteCounter
 144596 		pLvl = pNew + 24 + uintptr((*Fts5Structure)(unsafe.Pointer(pNew)).FnLevel-1)*12
 144597 		(*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = sqlite3Fts5MallocZero(tls, p+36, nByte)
 144598 		if (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg != 0 {
 144599 			var iLvl int32
 144600 			var iSeg int32
 144601 			var iSegOut int32 = 0
 144602 
 144603 			for iLvl = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel - 1; iLvl >= 0; iLvl-- {
 144604 				for iSeg = 0; iSeg < (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FnSeg; iSeg++ {
 144605 					*(*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSegOut)*12)) = *(*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FaSeg + uintptr(iSeg)*12))
 144606 					iSegOut++
 144607 				}
 144608 			}
 144609 			(*Fts5Structure)(unsafe.Pointer(pNew)).FnSegment = libc.AssignPtrInt32(pLvl+4, nSeg)
 144610 		} else {
 144611 			Xsqlite3_free(tls, pNew)
 144612 			pNew = uintptr(0)
 144613 		}
 144614 	}
 144615 
 144616 	return pNew
 144617 }
 144618 
 144619 func sqlite3Fts5IndexOptimize(tls *libc.TLS, p uintptr) int32 {
 144620 	bp := tls.Alloc(8)
 144621 	defer tls.Free(8)
 144622 
 144623 	var pStruct uintptr
 144624 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 144625 
 144626 	fts5IndexFlush(tls, p)
 144627 	pStruct = fts5StructureRead(tls, p)
 144628 	fts5StructureInvalidate(tls, p)
 144629 
 144630 	if pStruct != 0 {
 144631 		*(*uintptr)(unsafe.Pointer(bp)) = fts5IndexOptimizeStruct(tls, p, pStruct)
 144632 	}
 144633 	fts5StructureRelease(tls, pStruct)
 144634 
 144635 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 144636 		var iLvl int32
 144637 		for iLvl = 0; (*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))+24+uintptr(iLvl)*12)).FnSeg == 0; iLvl++ {
 144638 		}
 144639 		for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5StructureLevel)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))+24+uintptr(iLvl)*12)).FnSeg > 0 {
 144640 			*(*int32)(unsafe.Pointer(bp + 4)) = FTS5_OPT_WORK_UNIT
 144641 			fts5IndexMergeLevel(tls, p, bp, iLvl, bp+4)
 144642 		}
 144643 
 144644 		fts5StructureWrite(tls, p, *(*uintptr)(unsafe.Pointer(bp)))
 144645 		fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp)))
 144646 	}
 144647 
 144648 	return fts5IndexReturn(tls, p)
 144649 }
 144650 
 144651 func sqlite3Fts5IndexMerge(tls *libc.TLS, p uintptr, nMerge int32) int32 {
 144652 	bp := tls.Alloc(4)
 144653 	defer tls.Free(4)
 144654 
 144655 	*(*uintptr)(unsafe.Pointer(bp)) = fts5StructureRead(tls, p)
 144656 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 144657 		var nMin int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnUsermerge
 144658 		fts5StructureInvalidate(tls, p)
 144659 		if nMerge < 0 {
 144660 			var pNew uintptr = fts5IndexOptimizeStruct(tls, p, *(*uintptr)(unsafe.Pointer(bp)))
 144661 			fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp)))
 144662 			*(*uintptr)(unsafe.Pointer(bp)) = pNew
 144663 			nMin = 2
 144664 			nMerge = nMerge * -1
 144665 		}
 144666 		if *(*uintptr)(unsafe.Pointer(bp)) != 0 && (*Fts5Structure)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FnLevel != 0 {
 144667 			if fts5IndexMerge(tls, p, bp, nMerge, nMin) != 0 {
 144668 				fts5StructureWrite(tls, p, *(*uintptr)(unsafe.Pointer(bp)))
 144669 			}
 144670 		}
 144671 		fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp)))
 144672 	}
 144673 	return fts5IndexReturn(tls, p)
 144674 }
 144675 
 144676 func fts5AppendRowid(tls *libc.TLS, p uintptr, iDelta U64, pUnused uintptr, pBuf uintptr) {
 144677 	_ = pUnused
 144678 	sqlite3Fts5BufferAppendVarint(tls, p+36, pBuf, I64(iDelta))
 144679 }
 144680 
 144681 func fts5AppendPoslist(tls *libc.TLS, p uintptr, iDelta U64, pMulti uintptr, pBuf uintptr) {
 144682 	var nData int32 = (*Fts5Iter)(unsafe.Pointer(pMulti)).Fbase.FnData
 144683 	var nByte int32 = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING
 144684 
 144685 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && 0 == func() int32 {
 144686 		if U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)+U32(nByte) <= U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace) {
 144687 			return 0
 144688 		}
 144689 		return sqlite3Fts5BufferSize(tls, p+36, pBuf, uint32(nByte+(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn))
 144690 	}() {
 144691 		{
 144692 			*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), iDelta)
 144693 		}
 144694 
 144695 		{
 144696 			*(*int32)(unsafe.Pointer(pBuf + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), uint64(nData*2))
 144697 		}
 144698 
 144699 		{
 144700 			libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), (*Fts5Iter)(unsafe.Pointer(pMulti)).Fbase.FpData, uint32(nData))
 144701 			*(*int32)(unsafe.Pointer(pBuf + 4)) += nData
 144702 		}
 144703 
 144704 		libc.Xmemset(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn), 0, uint32(FTS5_DATA_ZERO_PADDING))
 144705 	}
 144706 }
 144707 
 144708 func fts5DoclistIterNext(tls *libc.TLS, pIter uintptr) {
 144709 	bp := tls.Alloc(12)
 144710 	defer tls.Free(12)
 144711 
 144712 	var p uintptr = (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist + uintptr((*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize) + uintptr((*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist)
 144713 
 144714 	if p >= (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaEof {
 144715 		(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = uintptr(0)
 144716 	} else {
 144717 		p += uintptr(sqlite3Fts5GetVarint(tls, p, bp))
 144718 		*(*I64)(unsafe.Pointer(pIter + 8)) += *(*I64)(unsafe.Pointer(bp))
 144719 
 144720 		if int32(*(*U8)(unsafe.Pointer(p)))&0x80 != 0 {
 144721 			(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = sqlite3Fts5GetVarint32(tls, p, bp+8)
 144722 			(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = *(*int32)(unsafe.Pointer(bp + 8)) >> 1
 144723 		} else {
 144724 			(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = int32(*(*U8)(unsafe.Pointer(p))) >> 1
 144725 			(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = 1
 144726 		}
 144727 
 144728 		(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = p
 144729 		if (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist+uintptr((*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist) > (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaEof {
 144730 			(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = uintptr(0)
 144731 		}
 144732 	}
 144733 }
 144734 
 144735 func fts5DoclistIterInit(tls *libc.TLS, pBuf uintptr, pIter uintptr) {
 144736 	libc.Xmemset(tls, pIter, 0, uint32(unsafe.Sizeof(Fts5DoclistIter{})))
 144737 	if (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn > 0 {
 144738 		(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaPoslist = (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp
 144739 		(*Fts5DoclistIter)(unsafe.Pointer(pIter)).FaEof = (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)
 144740 		fts5DoclistIterNext(tls, pIter)
 144741 	}
 144742 }
 144743 
 144744 func fts5BufferSwap(tls *libc.TLS, p1 uintptr, p2 uintptr) {
 144745 	var tmp = *(*Fts5Buffer)(unsafe.Pointer(p1))
 144746 	*(*Fts5Buffer)(unsafe.Pointer(p1)) = *(*Fts5Buffer)(unsafe.Pointer(p2))
 144747 	*(*Fts5Buffer)(unsafe.Pointer(p2)) = tmp
 144748 }
 144749 
 144750 func fts5NextRowid(tls *libc.TLS, pBuf uintptr, piOff uintptr, piRowid uintptr) {
 144751 	bp := tls.Alloc(8)
 144752 	defer tls.Free(8)
 144753 
 144754 	var i int32 = *(*int32)(unsafe.Pointer(piOff))
 144755 	if i >= (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn {
 144756 		*(*int32)(unsafe.Pointer(piOff)) = -1
 144757 	} else {
 144758 		*(*int32)(unsafe.Pointer(piOff)) = i + int32(sqlite3Fts5GetVarint(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr(i), bp))
 144759 		*(*I64)(unsafe.Pointer(piRowid)) += I64(*(*U64)(unsafe.Pointer(bp)))
 144760 	}
 144761 }
 144762 
 144763 func fts5MergeRowidLists(tls *libc.TLS, p uintptr, p1 uintptr, nBuf int32, aBuf uintptr) {
 144764 	bp := tls.Alloc(40)
 144765 	defer tls.Free(40)
 144766 
 144767 	*(*int32)(unsafe.Pointer(bp + 12)) = 0
 144768 	*(*int32)(unsafe.Pointer(bp + 24)) = 0
 144769 	*(*I64)(unsafe.Pointer(bp + 16)) = int64(0)
 144770 	*(*I64)(unsafe.Pointer(bp + 32)) = int64(0)
 144771 	var iOut I64 = int64(0)
 144772 	var p2 uintptr = aBuf
 144773 
 144774 	_ = nBuf
 144775 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 144776 
 144777 	sqlite3Fts5BufferSize(tls, p+36, bp, uint32((*Fts5Buffer)(unsafe.Pointer(p1)).Fn+(*Fts5Buffer)(unsafe.Pointer(p2)).Fn))
 144778 	if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 144779 		return
 144780 	}
 144781 
 144782 	fts5NextRowid(tls, p1, bp+12, bp+16)
 144783 	fts5NextRowid(tls, p2, bp+24, bp+32)
 144784 	for *(*int32)(unsafe.Pointer(bp + 12)) >= 0 || *(*int32)(unsafe.Pointer(bp + 24)) >= 0 {
 144785 		if *(*int32)(unsafe.Pointer(bp + 12)) >= 0 && (*(*int32)(unsafe.Pointer(bp + 24)) < 0 || *(*I64)(unsafe.Pointer(bp + 16)) < *(*I64)(unsafe.Pointer(bp + 32))) {
 144786 			{
 144787 				*(*int32)(unsafe.Pointer(bp + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp)).Fn), uint64(*(*I64)(unsafe.Pointer(bp + 16))-iOut))
 144788 			}
 144789 
 144790 			iOut = *(*I64)(unsafe.Pointer(bp + 16))
 144791 			fts5NextRowid(tls, p1, bp+12, bp+16)
 144792 		} else {
 144793 			{
 144794 				*(*int32)(unsafe.Pointer(bp + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp)).Fn), uint64(*(*I64)(unsafe.Pointer(bp + 32))-iOut))
 144795 			}
 144796 
 144797 			iOut = *(*I64)(unsafe.Pointer(bp + 32))
 144798 			if *(*int32)(unsafe.Pointer(bp + 12)) >= 0 && *(*I64)(unsafe.Pointer(bp + 16)) == *(*I64)(unsafe.Pointer(bp + 32)) {
 144799 				fts5NextRowid(tls, p1, bp+12, bp+16)
 144800 			}
 144801 			fts5NextRowid(tls, p2, bp+24, bp+32)
 144802 		}
 144803 	}
 144804 
 144805 	fts5BufferSwap(tls, bp, p1)
 144806 	sqlite3Fts5BufferFree(tls, bp)
 144807 }
 144808 
 144809 type PrefixMerger1 = struct {
 144810 	Fiter        Fts5DoclistIter
 144811 	FiPos        I64
 144812 	FiOff        int32
 144813 	FaPos        uintptr
 144814 	FpNext       uintptr
 144815 	F__ccgo_pad1 [4]byte
 144816 }
 144817 
 144818 type PrefixMerger = PrefixMerger1
 144819 
 144820 func fts5PrefixMergerInsertByRowid(tls *libc.TLS, ppHead uintptr, p uintptr) {
 144821 	if (*PrefixMerger)(unsafe.Pointer(p)).Fiter.FaPoslist != 0 {
 144822 		var pp uintptr = ppHead
 144823 		for *(*uintptr)(unsafe.Pointer(pp)) != 0 && (*PrefixMerger)(unsafe.Pointer(p)).Fiter.FiRowid > (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).Fiter.FiRowid {
 144824 			pp = *(*uintptr)(unsafe.Pointer(pp)) + 48
 144825 		}
 144826 		(*PrefixMerger)(unsafe.Pointer(p)).FpNext = *(*uintptr)(unsafe.Pointer(pp))
 144827 		*(*uintptr)(unsafe.Pointer(pp)) = p
 144828 	}
 144829 }
 144830 
 144831 func fts5PrefixMergerInsertByPosition(tls *libc.TLS, ppHead uintptr, p uintptr) {
 144832 	if (*PrefixMerger)(unsafe.Pointer(p)).FiPos >= int64(0) {
 144833 		var pp uintptr = ppHead
 144834 		for *(*uintptr)(unsafe.Pointer(pp)) != 0 && (*PrefixMerger)(unsafe.Pointer(p)).FiPos > (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FiPos {
 144835 			pp = *(*uintptr)(unsafe.Pointer(pp)) + 48
 144836 		}
 144837 		(*PrefixMerger)(unsafe.Pointer(p)).FpNext = *(*uintptr)(unsafe.Pointer(pp))
 144838 		*(*uintptr)(unsafe.Pointer(pp)) = p
 144839 	}
 144840 }
 144841 
 144842 func fts5MergePrefixLists(tls *libc.TLS, p uintptr, p1 uintptr, nBuf int32, aBuf uintptr) {
 144843 	bp := tls.Alloc(936)
 144844 	defer tls.Free(936)
 144845 
 144846 	*(*uintptr)(unsafe.Pointer(bp + 896)) = uintptr(0)
 144847 	var i int32
 144848 	var nOut int32 = 0
 144849 	*(*Fts5Buffer)(unsafe.Pointer(bp + 900)) = Fts5Buffer{}
 144850 	*(*Fts5Buffer)(unsafe.Pointer(bp + 912)) = Fts5Buffer{}
 144851 	var iLastRowid I64 = int64(0)
 144852 
 144853 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(PrefixMerger{}))*uint32(nBuf+1))
 144854 	*(*uintptr)(unsafe.Pointer(bp + 896)) = bp + uintptr(nBuf)*56
 144855 	fts5DoclistIterInit(tls, p1, *(*uintptr)(unsafe.Pointer(bp + 896)))
 144856 	for i = 0; i < nBuf; i++ {
 144857 		fts5DoclistIterInit(tls, aBuf+uintptr(i)*12, bp+uintptr(i)*56)
 144858 		fts5PrefixMergerInsertByRowid(tls, bp+896, bp+uintptr(i)*56)
 144859 		nOut = nOut + (*Fts5Buffer)(unsafe.Pointer(aBuf+uintptr(i)*12)).Fn
 144860 	}
 144861 	if nOut == 0 {
 144862 		return
 144863 	}
 144864 	nOut = nOut + ((*Fts5Buffer)(unsafe.Pointer(p1)).Fn + 9 + 10*nBuf)
 144865 
 144866 	if sqlite3Fts5BufferSize(tls, p+36, bp+900, uint32(nOut)) != 0 {
 144867 		return
 144868 	}
 144869 
 144870 	for *(*uintptr)(unsafe.Pointer(bp + 896)) != 0 {
 144871 		{
 144872 			{
 144873 				*(*int32)(unsafe.Pointer(bp + 900 + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp+900)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp+900)).Fn), U64((*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).Fiter.FiRowid)-U64(iLastRowid))
 144874 			}
 144875 			iLastRowid = (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).Fiter.FiRowid
 144876 		}
 144877 
 144878 		if (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FpNext != 0 && iLastRowid == (*PrefixMerger)(unsafe.Pointer((*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FpNext)).Fiter.FiRowid {
 144879 			*(*I64)(unsafe.Pointer(bp + 928)) = int64(0)
 144880 			var nTmp int32 = FTS5_DATA_ZERO_PADDING
 144881 			var nMerge int32 = 0
 144882 			var pSave uintptr = *(*uintptr)(unsafe.Pointer(bp + 896))
 144883 			var pThis uintptr = uintptr(0)
 144884 			var nTail int32 = 0
 144885 
 144886 			*(*uintptr)(unsafe.Pointer(bp + 896)) = uintptr(0)
 144887 			for pSave != 0 && (*PrefixMerger)(unsafe.Pointer(pSave)).Fiter.FiRowid == iLastRowid {
 144888 				var pNext uintptr = (*PrefixMerger)(unsafe.Pointer(pSave)).FpNext
 144889 				(*PrefixMerger)(unsafe.Pointer(pSave)).FiOff = 0
 144890 				(*PrefixMerger)(unsafe.Pointer(pSave)).FiPos = int64(0)
 144891 				(*PrefixMerger)(unsafe.Pointer(pSave)).FaPos = (*PrefixMerger)(unsafe.Pointer(pSave)).Fiter.FaPoslist + uintptr((*PrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnSize)
 144892 				sqlite3Fts5PoslistNext64(tls, (*PrefixMerger)(unsafe.Pointer(pSave)).FaPos, (*PrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnPoslist, pSave+40, pSave+32)
 144893 				nTmp = nTmp + ((*PrefixMerger)(unsafe.Pointer(pSave)).Fiter.FnPoslist + 10)
 144894 				nMerge++
 144895 				fts5PrefixMergerInsertByPosition(tls, bp+896, pSave)
 144896 				pSave = pNext
 144897 			}
 144898 
 144899 			if *(*uintptr)(unsafe.Pointer(bp + 896)) == uintptr(0) || (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FpNext == uintptr(0) {
 144900 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 144901 				break
 144902 			}
 144903 
 144904 			if sqlite3Fts5BufferSize(tls, p+36, bp+912, uint32(nTmp+nMerge*10)) != 0 {
 144905 				break
 144906 			}
 144907 			sqlite3Fts5BufferZero(tls, bp+912)
 144908 
 144909 			pThis = *(*uintptr)(unsafe.Pointer(bp + 896))
 144910 			*(*uintptr)(unsafe.Pointer(bp + 896)) = (*PrefixMerger)(unsafe.Pointer(pThis)).FpNext
 144911 			sqlite3Fts5PoslistSafeAppend(tls, bp+912, bp+928, (*PrefixMerger)(unsafe.Pointer(pThis)).FiPos)
 144912 			sqlite3Fts5PoslistNext64(tls, (*PrefixMerger)(unsafe.Pointer(pThis)).FaPos, (*PrefixMerger)(unsafe.Pointer(pThis)).Fiter.FnPoslist, pThis+40, pThis+32)
 144913 			fts5PrefixMergerInsertByPosition(tls, bp+896, pThis)
 144914 
 144915 			for (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FpNext != 0 {
 144916 				pThis = *(*uintptr)(unsafe.Pointer(bp + 896))
 144917 				if (*PrefixMerger)(unsafe.Pointer(pThis)).FiPos != *(*I64)(unsafe.Pointer(bp + 928)) {
 144918 					sqlite3Fts5PoslistSafeAppend(tls, bp+912, bp+928, (*PrefixMerger)(unsafe.Pointer(pThis)).FiPos)
 144919 				}
 144920 				sqlite3Fts5PoslistNext64(tls, (*PrefixMerger)(unsafe.Pointer(pThis)).FaPos, (*PrefixMerger)(unsafe.Pointer(pThis)).Fiter.FnPoslist, pThis+40, pThis+32)
 144921 				*(*uintptr)(unsafe.Pointer(bp + 896)) = (*PrefixMerger)(unsafe.Pointer(pThis)).FpNext
 144922 				fts5PrefixMergerInsertByPosition(tls, bp+896, pThis)
 144923 			}
 144924 
 144925 			if (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FiPos != *(*I64)(unsafe.Pointer(bp + 928)) {
 144926 				sqlite3Fts5PoslistSafeAppend(tls, bp+912, bp+928, (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FiPos)
 144927 			}
 144928 			nTail = (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).Fiter.FnPoslist - (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FiOff
 144929 
 144930 			if (*Fts5Buffer)(unsafe.Pointer(bp+912)).Fn+nTail > nTmp-FTS5_DATA_ZERO_PADDING {
 144931 				if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 144932 					(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 144933 				}
 144934 				break
 144935 			}
 144936 			{
 144937 				*(*int32)(unsafe.Pointer(bp + 900 + 4)) += sqlite3Fts5PutVarint(tls, (*Fts5Buffer)(unsafe.Pointer(bp+900)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp+900)).Fn), uint64(((*Fts5Buffer)(unsafe.Pointer(bp+912)).Fn+nTail)*2))
 144938 			}
 144939 
 144940 			{
 144941 				libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(bp+900)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp+900)).Fn), (*Fts5Buffer)(unsafe.Pointer(bp+912)).Fp, uint32((*Fts5Buffer)(unsafe.Pointer(bp+912)).Fn))
 144942 				*(*int32)(unsafe.Pointer(bp + 900 + 4)) += (*Fts5Buffer)(unsafe.Pointer(bp + 912)).Fn
 144943 			}
 144944 
 144945 			if nTail > 0 {
 144946 				{
 144947 					libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(bp+900)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp+900)).Fn), (*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FaPos+uintptr((*PrefixMerger)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 896)))).FiOff), uint32(nTail))
 144948 					*(*int32)(unsafe.Pointer(bp + 900 + 4)) += nTail
 144949 				}
 144950 
 144951 			}
 144952 
 144953 			*(*uintptr)(unsafe.Pointer(bp + 896)) = pSave
 144954 			for i = 0; i < nBuf+1; i++ {
 144955 				var pX uintptr = bp + uintptr(i)*56
 144956 				if (*PrefixMerger)(unsafe.Pointer(pX)).Fiter.FaPoslist != 0 && (*PrefixMerger)(unsafe.Pointer(pX)).Fiter.FiRowid == iLastRowid {
 144957 					fts5DoclistIterNext(tls, pX)
 144958 					fts5PrefixMergerInsertByRowid(tls, bp+896, pX)
 144959 				}
 144960 			}
 144961 
 144962 		} else {
 144963 			var pThis uintptr = *(*uintptr)(unsafe.Pointer(bp + 896))
 144964 			var pI uintptr = pThis
 144965 			{
 144966 				libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(bp+900)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp+900)).Fn), (*Fts5DoclistIter)(unsafe.Pointer(pI)).FaPoslist, uint32((*Fts5DoclistIter)(unsafe.Pointer(pI)).FnPoslist+(*Fts5DoclistIter)(unsafe.Pointer(pI)).FnSize))
 144967 				*(*int32)(unsafe.Pointer(bp + 900 + 4)) += (*Fts5DoclistIter)(unsafe.Pointer(pI)).FnPoslist + (*Fts5DoclistIter)(unsafe.Pointer(pI)).FnSize
 144968 			}
 144969 
 144970 			fts5DoclistIterNext(tls, pI)
 144971 			*(*uintptr)(unsafe.Pointer(bp + 896)) = (*PrefixMerger)(unsafe.Pointer(pThis)).FpNext
 144972 			fts5PrefixMergerInsertByRowid(tls, bp+896, pThis)
 144973 		}
 144974 	}
 144975 
 144976 	sqlite3Fts5BufferFree(tls, p1)
 144977 	sqlite3Fts5BufferFree(tls, bp+912)
 144978 	libc.Xmemset(tls, (*Fts5Buffer)(unsafe.Pointer(bp+900)).Fp+uintptr((*Fts5Buffer)(unsafe.Pointer(bp+900)).Fn), 0, uint32(FTS5_DATA_ZERO_PADDING))
 144979 	*(*Fts5Buffer)(unsafe.Pointer(p1)) = *(*Fts5Buffer)(unsafe.Pointer(bp + 900))
 144980 }
 144981 
 144982 func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, iIdx int32, pToken uintptr, nToken int32, pColset uintptr, ppIter uintptr) {
 144983 	bp := tls.Alloc(24)
 144984 	defer tls.Free(24)
 144985 
 144986 	var pStruct uintptr
 144987 	var aBuf uintptr
 144988 	var nBuf int32 = 32
 144989 	var nMerge int32 = 1
 144990 	var xMerge uintptr
 144991 	var xAppend uintptr
 144992 	if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE {
 144993 		xMerge = *(*uintptr)(unsafe.Pointer(&struct {
 144994 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr)
 144995 		}{fts5MergeRowidLists}))
 144996 		xAppend = *(*uintptr)(unsafe.Pointer(&struct {
 144997 			f func(*libc.TLS, uintptr, U64, uintptr, uintptr)
 144998 		}{fts5AppendRowid}))
 144999 	} else {
 145000 		nMerge = FTS5_MERGE_NLIST - 1
 145001 		nBuf = nMerge * 8
 145002 		xMerge = *(*uintptr)(unsafe.Pointer(&struct {
 145003 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr)
 145004 		}{fts5MergePrefixLists}))
 145005 		xAppend = *(*uintptr)(unsafe.Pointer(&struct {
 145006 			f func(*libc.TLS, uintptr, U64, uintptr, uintptr)
 145007 		}{fts5AppendPoslist}))
 145008 	}
 145009 
 145010 	aBuf = fts5IdxMalloc(tls, p, int64(uint32(unsafe.Sizeof(Fts5Buffer{}))*uint32(nBuf)))
 145011 	pStruct = fts5StructureRead(tls, p)
 145012 
 145013 	if aBuf != 0 && pStruct != 0 {
 145014 		var flags int32 = FTS5INDEX_QUERY_SCAN |
 145015 			FTS5INDEX_QUERY_SKIPEMPTY |
 145016 			FTS5INDEX_QUERY_NOOUTPUT
 145017 		var i int32
 145018 		var iLastRowid I64 = int64(0)
 145019 		*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 145020 		var pData uintptr
 145021 
 145022 		*(*int32)(unsafe.Pointer(bp + 20)) = 1
 145023 
 145024 		libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 145025 		if iIdx != 0 {
 145026 			*(*int32)(unsafe.Pointer(bp + 16)) = 0
 145027 			var f2 int32 = FTS5INDEX_QUERY_SKIPEMPTY | FTS5INDEX_QUERY_NOOUTPUT
 145028 			*(*U8)(unsafe.Pointer(pToken)) = U8('0')
 145029 			fts5MultiIterNew(tls, p, pStruct, f2, pColset, pToken, nToken, -1, 0, bp+12)
 145030 			fts5IterSetOutputCb(tls, p+36, *(*uintptr)(unsafe.Pointer(bp + 12)))
 145031 			for ; fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 12))) == 0; fts5MultiIterNext2(tls, p, *(*uintptr)(unsafe.Pointer(bp + 12)), bp+16) {
 145032 				var pSeg uintptr = *(*uintptr)(unsafe.Pointer(bp + 12)) + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FaFirst+1*4)).FiFirst)*96
 145033 				(*struct {
 145034 					f func(*libc.TLS, uintptr, uintptr)
 145035 				})(unsafe.Pointer(&struct{ uintptr }{(*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FxSetOutputs})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), pSeg)
 145036 				if (*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FnData != 0 {
 145037 					(*struct {
 145038 						f func(*libc.TLS, uintptr, U64, uintptr, uintptr)
 145039 					})(unsafe.Pointer(&struct{ uintptr }{xAppend})).f(tls, p, U64((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FiRowid)-U64(iLastRowid), *(*uintptr)(unsafe.Pointer(bp + 12)), bp)
 145040 					iLastRowid = (*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FiRowid
 145041 				}
 145042 			}
 145043 			fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 145044 		}
 145045 
 145046 		*(*U8)(unsafe.Pointer(pToken)) = U8('0' + iIdx)
 145047 		fts5MultiIterNew(tls, p, pStruct, flags, pColset, pToken, nToken, -1, 0, bp+12)
 145048 		fts5IterSetOutputCb(tls, p+36, *(*uintptr)(unsafe.Pointer(bp + 12)))
 145049 		for ; fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 12))) == 0; fts5MultiIterNext2(tls, p, *(*uintptr)(unsafe.Pointer(bp + 12)), bp+20) {
 145050 			var pSeg uintptr = *(*uintptr)(unsafe.Pointer(bp + 12)) + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FaFirst+1*4)).FiFirst)*96
 145051 			var nTerm int32 = (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn
 145052 			var pTerm uintptr = (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp
 145053 			(*struct {
 145054 				f func(*libc.TLS, uintptr, uintptr)
 145055 			})(unsafe.Pointer(&struct{ uintptr }{(*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FxSetOutputs})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), pSeg)
 145056 
 145057 			if *(*int32)(unsafe.Pointer(bp + 20)) != 0 {
 145058 				if nTerm < nToken || libc.Xmemcmp(tls, pToken, pTerm, uint32(nToken)) != 0 {
 145059 					break
 145060 				}
 145061 			}
 145062 
 145063 			if (*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FnData == 0 {
 145064 				continue
 145065 			}
 145066 
 145067 			if (*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FiRowid <= iLastRowid && (*Fts5Buffer)(unsafe.Pointer(bp)).Fn > 0 {
 145068 				for i = 0; (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5Buffer)(unsafe.Pointer(bp)).Fn != 0; i++ {
 145069 					var i1 int32 = i * nMerge
 145070 					var iStore int32
 145071 
 145072 					for iStore = i1; iStore < i1+nMerge; iStore++ {
 145073 						if (*Fts5Buffer)(unsafe.Pointer(aBuf+uintptr(iStore)*12)).Fn == 0 {
 145074 							fts5BufferSwap(tls, bp, aBuf+uintptr(iStore)*12)
 145075 							sqlite3Fts5BufferZero(tls, bp)
 145076 							break
 145077 						}
 145078 					}
 145079 					if iStore == i1+nMerge {
 145080 						(*struct {
 145081 							f func(*libc.TLS, uintptr, uintptr, int32, uintptr)
 145082 						})(unsafe.Pointer(&struct{ uintptr }{xMerge})).f(tls, p, bp, nMerge, aBuf+uintptr(i1)*12)
 145083 						for iStore = i1; iStore < i1+nMerge; iStore++ {
 145084 							sqlite3Fts5BufferZero(tls, aBuf+uintptr(iStore)*12)
 145085 						}
 145086 					}
 145087 				}
 145088 				iLastRowid = int64(0)
 145089 			}
 145090 
 145091 			(*struct {
 145092 				f func(*libc.TLS, uintptr, U64, uintptr, uintptr)
 145093 			})(unsafe.Pointer(&struct{ uintptr }{xAppend})).f(tls, p, U64((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FiRowid)-U64(iLastRowid), *(*uintptr)(unsafe.Pointer(bp + 12)), bp)
 145094 			iLastRowid = (*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).Fbase.FiRowid
 145095 		}
 145096 
 145097 		for i = 0; i < nBuf; i = i + nMerge {
 145098 			var iFree int32
 145099 			if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 145100 				(*struct {
 145101 					f func(*libc.TLS, uintptr, uintptr, int32, uintptr)
 145102 				})(unsafe.Pointer(&struct{ uintptr }{xMerge})).f(tls, p, bp, nMerge, aBuf+uintptr(i)*12)
 145103 			}
 145104 			for iFree = i; iFree < i+nMerge; iFree++ {
 145105 				sqlite3Fts5BufferFree(tls, aBuf+uintptr(iFree)*12)
 145106 			}
 145107 		}
 145108 		fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 145109 
 145110 		pData = fts5IdxMalloc(tls, p, int64(uint32(unsafe.Sizeof(Fts5Data{}))+uint32((*Fts5Buffer)(unsafe.Pointer(bp)).Fn)+uint32(FTS5_DATA_ZERO_PADDING)))
 145111 		if pData != 0 {
 145112 			(*Fts5Data)(unsafe.Pointer(pData)).Fp = pData + 1*12
 145113 			(*Fts5Data)(unsafe.Pointer(pData)).Fnn = libc.AssignPtrInt32(pData+8, (*Fts5Buffer)(unsafe.Pointer(bp)).Fn)
 145114 			if (*Fts5Buffer)(unsafe.Pointer(bp)).Fn != 0 {
 145115 				libc.Xmemcpy(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, uint32((*Fts5Buffer)(unsafe.Pointer(bp)).Fn))
 145116 			}
 145117 			fts5MultiIterNew2(tls, p, pData, bDesc, ppIter)
 145118 		}
 145119 		sqlite3Fts5BufferFree(tls, bp)
 145120 	}
 145121 
 145122 	fts5StructureRelease(tls, pStruct)
 145123 	Xsqlite3_free(tls, aBuf)
 145124 }
 145125 
 145126 func sqlite3Fts5IndexBeginWrite(tls *libc.TLS, p uintptr, bDelete int32, iRowid I64) int32 {
 145127 	if (*Fts5Index)(unsafe.Pointer(p)).FpHash == uintptr(0) {
 145128 		(*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashNew(tls, (*Fts5Index)(unsafe.Pointer(p)).FpConfig, p+12, p+16)
 145129 	}
 145130 
 145131 	if iRowid < (*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid ||
 145132 		iRowid == (*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid && (*Fts5Index)(unsafe.Pointer(p)).FbDelete == 0 ||
 145133 		(*Fts5Index)(unsafe.Pointer(p)).FnPendingData > (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnHashSize {
 145134 		fts5IndexFlush(tls, p)
 145135 	}
 145136 
 145137 	(*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid = iRowid
 145138 	(*Fts5Index)(unsafe.Pointer(p)).FbDelete = bDelete
 145139 	return fts5IndexReturn(tls, p)
 145140 }
 145141 
 145142 func sqlite3Fts5IndexSync(tls *libc.TLS, p uintptr) int32 {
 145143 	fts5IndexFlush(tls, p)
 145144 	sqlite3Fts5IndexCloseReader(tls, p)
 145145 	return fts5IndexReturn(tls, p)
 145146 }
 145147 
 145148 func sqlite3Fts5IndexRollback(tls *libc.TLS, p uintptr) int32 {
 145149 	sqlite3Fts5IndexCloseReader(tls, p)
 145150 	fts5IndexDiscardData(tls, p)
 145151 	fts5StructureInvalidate(tls, p)
 145152 
 145153 	return SQLITE_OK
 145154 }
 145155 
 145156 func sqlite3Fts5IndexReinit(tls *libc.TLS, p uintptr) int32 {
 145157 	bp := tls.Alloc(40)
 145158 	defer tls.Free(40)
 145159 
 145160 	fts5StructureInvalidate(tls, p)
 145161 	fts5IndexDiscardData(tls, p)
 145162 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Structure{})))
 145163 	fts5DataWrite(tls, p, int64(FTS5_AVERAGES_ROWID), ts+1554, 0)
 145164 	fts5StructureWrite(tls, p, bp)
 145165 	return fts5IndexReturn(tls, p)
 145166 }
 145167 
 145168 func sqlite3Fts5IndexOpen(tls *libc.TLS, pConfig uintptr, bCreate int32, pp uintptr, pzErr uintptr) int32 {
 145169 	bp := tls.Alloc(12)
 145170 	defer tls.Free(12)
 145171 
 145172 	*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_OK
 145173 	var p uintptr
 145174 
 145175 	*(*uintptr)(unsafe.Pointer(pp)) = libc.AssignUintptr(&p, sqlite3Fts5MallocZero(tls, bp+8, int64(unsafe.Sizeof(Fts5Index{}))))
 145176 	if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 145177 		(*Fts5Index)(unsafe.Pointer(p)).FpConfig = pConfig
 145178 		(*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit = FTS5_WORK_UNIT
 145179 		(*Fts5Index)(unsafe.Pointer(p)).FzDataTbl = sqlite3Fts5Mprintf(tls, bp+8, ts+35186, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 145180 		if (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl != 0 && bCreate != 0 {
 145181 			*(*int32)(unsafe.Pointer(bp + 8)) = sqlite3Fts5CreateTable(tls,
 145182 				pConfig, ts+25103, ts+35194, 0, pzErr)
 145183 			if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 145184 				*(*int32)(unsafe.Pointer(bp + 8)) = sqlite3Fts5CreateTable(tls, pConfig, ts+11488,
 145185 					ts+35229,
 145186 					1, pzErr)
 145187 			}
 145188 			if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 145189 				*(*int32)(unsafe.Pointer(bp + 8)) = sqlite3Fts5IndexReinit(tls, p)
 145190 			}
 145191 		}
 145192 	}
 145193 
 145194 	if *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
 145195 		sqlite3Fts5IndexClose(tls, p)
 145196 		*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 145197 	}
 145198 	return *(*int32)(unsafe.Pointer(bp + 8))
 145199 }
 145200 
 145201 func sqlite3Fts5IndexClose(tls *libc.TLS, p uintptr) int32 {
 145202 	var rc int32 = SQLITE_OK
 145203 	if p != 0 {
 145204 		fts5StructureInvalidate(tls, p)
 145205 		Xsqlite3_finalize(tls, (*Fts5Index)(unsafe.Pointer(p)).FpWriter)
 145206 		Xsqlite3_finalize(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDeleter)
 145207 		Xsqlite3_finalize(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxWriter)
 145208 		Xsqlite3_finalize(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter)
 145209 		Xsqlite3_finalize(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxSelect)
 145210 		Xsqlite3_finalize(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion)
 145211 		sqlite3Fts5HashFree(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash)
 145212 		Xsqlite3_free(tls, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl)
 145213 		Xsqlite3_free(tls, p)
 145214 	}
 145215 	return rc
 145216 }
 145217 
 145218 func sqlite3Fts5IndexCharlenToBytelen(tls *libc.TLS, p uintptr, nByte int32, nChar int32) int32 {
 145219 	var n int32 = 0
 145220 	var i int32
 145221 	for i = 0; i < nChar; i++ {
 145222 		if n >= nByte {
 145223 			return 0
 145224 		}
 145225 		if int32(*(*uint8)(unsafe.Pointer(p + uintptr(libc.PostIncInt32(&n, 1))))) >= 0xc0 {
 145226 			if n >= nByte {
 145227 				return 0
 145228 			}
 145229 			for int32(*(*uint8)(unsafe.Pointer(p + uintptr(n))))&0xc0 == 0x80 {
 145230 				n++
 145231 				if n >= nByte {
 145232 					if i+1 == nChar {
 145233 						break
 145234 					}
 145235 					return 0
 145236 				}
 145237 			}
 145238 		}
 145239 	}
 145240 	return n
 145241 }
 145242 
 145243 func fts5IndexCharlen(tls *libc.TLS, pIn uintptr, nIn int32) int32 {
 145244 	var nChar int32 = 0
 145245 	var i int32 = 0
 145246 	for i < nIn {
 145247 		if int32(*(*uint8)(unsafe.Pointer(pIn + uintptr(libc.PostIncInt32(&i, 1))))) >= 0xc0 {
 145248 			for i < nIn && int32(*(*uint8)(unsafe.Pointer(pIn + uintptr(i))))&0xc0 == 0x80 {
 145249 				i++
 145250 			}
 145251 		}
 145252 		nChar++
 145253 	}
 145254 	return nChar
 145255 }
 145256 
 145257 func sqlite3Fts5IndexWrite(tls *libc.TLS, p uintptr, iCol int32, iPos int32, pToken uintptr, nToken int32) int32 {
 145258 	var i int32
 145259 	var rc int32 = SQLITE_OK
 145260 	var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 145261 
 145262 	rc = sqlite3Fts5HashWrite(tls,
 145263 		(*Fts5Index)(unsafe.Pointer(p)).FpHash, (*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid, iCol, iPos, uint8('0'), pToken, nToken)
 145264 
 145265 	for i = 0; i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix && rc == SQLITE_OK; i++ {
 145266 		var nChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(i)*4))
 145267 		var nByte int32 = sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar)
 145268 		if nByte != 0 {
 145269 			rc = sqlite3Fts5HashWrite(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash,
 145270 				(*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid, iCol, iPos, uint8('0'+i+1), pToken,
 145271 				nByte)
 145272 		}
 145273 	}
 145274 
 145275 	return rc
 145276 }
 145277 
 145278 func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int32, flags int32, pColset uintptr, ppIter uintptr) int32 {
 145279 	bp := tls.Alloc(16)
 145280 	defer tls.Free(16)
 145281 
 145282 	var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 145283 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 145284 	*(*Fts5Buffer)(unsafe.Pointer(bp)) = Fts5Buffer{}
 145285 
 145286 	if sqlite3Fts5BufferSize(tls, p+36, bp, uint32(nToken+1)) == 0 {
 145287 		var iIdx int32 = 0
 145288 		var iPrefixIdx int32 = 0
 145289 		if nToken > 0 {
 145290 			libc.Xmemcpy(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp+1, pToken, uint32(nToken))
 145291 		}
 145292 
 145293 		if flags&FTS5INDEX_QUERY_PREFIX != 0 {
 145294 			var nChar int32 = fts5IndexCharlen(tls, pToken, nToken)
 145295 			for iIdx = 1; iIdx <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix; iIdx++ {
 145296 				var nIdxChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(iIdx-1)*4))
 145297 				if nIdxChar == nChar {
 145298 					break
 145299 				}
 145300 				if nIdxChar == nChar+1 {
 145301 					iPrefixIdx = iIdx
 145302 				}
 145303 			}
 145304 		}
 145305 
 145306 		if iIdx <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix {
 145307 			var pStruct uintptr = fts5StructureRead(tls, p)
 145308 			*(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp)).Fp)) = U8('0' + iIdx)
 145309 			if pStruct != 0 {
 145310 				fts5MultiIterNew(tls, p, pStruct, flags|FTS5INDEX_QUERY_SKIPEMPTY,
 145311 					pColset, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, nToken+1, -1, 0, bp+12)
 145312 				fts5StructureRelease(tls, pStruct)
 145313 			}
 145314 		} else {
 145315 			var bDesc int32 = libc.Bool32(flags&FTS5INDEX_QUERY_DESC != 0)
 145316 			fts5SetupPrefixIter(tls, p, bDesc, iPrefixIdx, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, nToken+1, pColset, bp+12)
 145317 			if *(*uintptr)(unsafe.Pointer(bp + 12)) == uintptr(0) {
 145318 			} else {
 145319 				fts5IterSetOutputCb(tls, p+36, *(*uintptr)(unsafe.Pointer(bp + 12)))
 145320 				if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 145321 					var pSeg uintptr = *(*uintptr)(unsafe.Pointer(bp + 12)) + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FaFirst+1*4)).FiFirst)*96
 145322 					if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 {
 145323 						(*struct {
 145324 							f func(*libc.TLS, uintptr, uintptr)
 145325 						})(unsafe.Pointer(&struct{ uintptr }{(*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 12)))).FxSetOutputs})).f(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), pSeg)
 145326 					}
 145327 				}
 145328 			}
 145329 		}
 145330 
 145331 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 145332 			sqlite3Fts5IterClose(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 145333 			*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 145334 			sqlite3Fts5IndexCloseReader(tls, p)
 145335 		}
 145336 
 145337 		*(*uintptr)(unsafe.Pointer(ppIter)) = *(*uintptr)(unsafe.Pointer(bp + 12))
 145338 		sqlite3Fts5BufferFree(tls, bp)
 145339 	}
 145340 	return fts5IndexReturn(tls, p)
 145341 }
 145342 
 145343 func sqlite3Fts5IterNext(tls *libc.TLS, pIndexIter uintptr) int32 {
 145344 	var pIter uintptr = pIndexIter
 145345 
 145346 	fts5MultiIterNext(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex, pIter, 0, int64(0))
 145347 	return fts5IndexReturn(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex)
 145348 }
 145349 
 145350 func sqlite3Fts5IterNextScan(tls *libc.TLS, pIndexIter uintptr) int32 {
 145351 	var pIter uintptr = pIndexIter
 145352 	var p uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex
 145353 
 145354 	fts5MultiIterNext(tls, p, pIter, 0, int64(0))
 145355 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 145356 		var pSeg uintptr = pIter + 80 + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*96
 145357 		if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 && int32(*(*U8)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp))) != '0' {
 145358 			fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)
 145359 			(*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf = uintptr(0)
 145360 			(*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = U8(1)
 145361 		}
 145362 	}
 145363 
 145364 	return fts5IndexReturn(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex)
 145365 }
 145366 
 145367 func sqlite3Fts5IterNextFrom(tls *libc.TLS, pIndexIter uintptr, iMatch I64) int32 {
 145368 	var pIter uintptr = pIndexIter
 145369 	fts5MultiIterNextFrom(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex, pIter, iMatch)
 145370 	return fts5IndexReturn(tls, (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex)
 145371 }
 145372 
 145373 func sqlite3Fts5IterTerm(tls *libc.TLS, pIndexIter uintptr, pn uintptr) uintptr {
 145374 	bp := tls.Alloc(4)
 145375 	defer tls.Free(4)
 145376 
 145377 	var z uintptr = fts5MultiIterTerm(tls, pIndexIter, bp)
 145378 
 145379 	*(*int32)(unsafe.Pointer(pn)) = *(*int32)(unsafe.Pointer(bp)) - 1
 145380 	return func() uintptr {
 145381 		if z != 0 {
 145382 			return z + 1
 145383 		}
 145384 		return uintptr(0)
 145385 	}()
 145386 }
 145387 
 145388 func sqlite3Fts5IterClose(tls *libc.TLS, pIndexIter uintptr) {
 145389 	if pIndexIter != 0 {
 145390 		var pIter uintptr = pIndexIter
 145391 		var pIndex uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex
 145392 		fts5MultiIterFree(tls, pIter)
 145393 		sqlite3Fts5IndexCloseReader(tls, pIndex)
 145394 	}
 145395 }
 145396 
 145397 func sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize uintptr) int32 {
 145398 	var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnCol
 145399 	var pData uintptr
 145400 
 145401 	*(*I64)(unsafe.Pointer(pnRow)) = int64(0)
 145402 	libc.Xmemset(tls, anSize, 0, uint32(unsafe.Sizeof(I64(0)))*uint32(nCol))
 145403 	pData = fts5DataRead(tls, p, int64(FTS5_AVERAGES_ROWID))
 145404 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Fts5Data)(unsafe.Pointer(pData)).Fnn != 0 {
 145405 		var i int32 = 0
 145406 		var iCol int32
 145407 		i = i + int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr(i), pnRow))
 145408 		for iCol = 0; i < (*Fts5Data)(unsafe.Pointer(pData)).Fnn && iCol < nCol; iCol++ {
 145409 			i = i + int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp+uintptr(i), anSize+uintptr(iCol)*8))
 145410 		}
 145411 	}
 145412 
 145413 	fts5DataRelease(tls, pData)
 145414 	return fts5IndexReturn(tls, p)
 145415 }
 145416 
 145417 func sqlite3Fts5IndexSetAverages(tls *libc.TLS, p uintptr, pData uintptr, nData int32) int32 {
 145418 	fts5DataWrite(tls, p, int64(FTS5_AVERAGES_ROWID), pData, nData)
 145419 	return fts5IndexReturn(tls, p)
 145420 }
 145421 
 145422 func sqlite3Fts5IndexReads(tls *libc.TLS, p uintptr) int32 {
 145423 	return (*Fts5Index)(unsafe.Pointer(p)).FnRead
 145424 }
 145425 
 145426 func sqlite3Fts5IndexSetCookie(tls *libc.TLS, p uintptr, iNew int32) int32 {
 145427 	bp := tls.Alloc(8)
 145428 	defer tls.Free(8)
 145429 
 145430 	var rc int32
 145431 	var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 145432 
 145433 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 145434 
 145435 	sqlite3Fts5Put32(tls, bp, iNew)
 145436 
 145437 	rc = Xsqlite3_blob_open(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl,
 145438 		ts+34876, int64(FTS5_STRUCTURE_ROWID), 1, bp+4)
 145439 	if rc == SQLITE_OK {
 145440 		Xsqlite3_blob_write(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), bp, 4, 0)
 145441 		rc = Xsqlite3_blob_close(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 145442 	}
 145443 
 145444 	return rc
 145445 }
 145446 
 145447 func sqlite3Fts5IndexLoadConfig(tls *libc.TLS, p uintptr) int32 {
 145448 	var pStruct uintptr
 145449 	pStruct = fts5StructureRead(tls, p)
 145450 	fts5StructureRelease(tls, pStruct)
 145451 	return fts5IndexReturn(tls, p)
 145452 }
 145453 
 145454 func sqlite3Fts5IndexEntryCksum(tls *libc.TLS, iRowid I64, iCol int32, iPos int32, iIdx int32, pTerm uintptr, nTerm int32) U64 {
 145455 	var i int32
 145456 	var ret U64 = U64(iRowid)
 145457 	ret = ret + (ret<<3 + U64(iCol))
 145458 	ret = ret + (ret<<3 + U64(iPos))
 145459 	if iIdx >= 0 {
 145460 		ret = ret + (ret<<3 + U64('0'+iIdx))
 145461 	}
 145462 	for i = 0; i < nTerm; i++ {
 145463 		ret = ret + (ret<<3 + U64(*(*uint8)(unsafe.Pointer(pTerm + uintptr(i)))))
 145464 	}
 145465 	return ret
 145466 }
 145467 
 145468 func fts5IndexIntegrityCheckEmpty(tls *libc.TLS, p uintptr, pSeg uintptr, iFirst int32, iNoRowid int32, iLast int32) {
 145469 	var i int32
 145470 
 145471 	for i = iFirst; (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && i <= iLast; i++ {
 145472 		var pLeaf uintptr = fts5DataRead(tls, p, I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)+int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B)+int64(0)<<FTS5_DATA_PAGE_B+I64(i))
 145473 		if pLeaf != 0 {
 145474 			if !((*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf >= (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn) {
 145475 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145476 			}
 145477 			if i >= iNoRowid && 0 != int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)) {
 145478 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145479 			}
 145480 		}
 145481 		fts5DataRelease(tls, pLeaf)
 145482 	}
 145483 }
 145484 
 145485 func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) {
 145486 	bp := tls.Alloc(40)
 145487 	defer tls.Free(40)
 145488 
 145489 	var iTermOff int32 = 0
 145490 	var ii int32
 145491 
 145492 	*(*Fts5Buffer)(unsafe.Pointer(bp + 8)) = Fts5Buffer{}
 145493 	*(*Fts5Buffer)(unsafe.Pointer(bp + 28)) = Fts5Buffer{}
 145494 
 145495 	ii = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf
 145496 	for ii < (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn && (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 145497 		var res int32
 145498 		var iOff int32
 145499 
 145500 		ii = ii + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(ii), bp)
 145501 		iTermOff = iTermOff + *(*int32)(unsafe.Pointer(bp))
 145502 		iOff = iTermOff
 145503 
 145504 		if iOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 145505 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145506 		} else if iTermOff == *(*int32)(unsafe.Pointer(bp)) {
 145507 			iOff = iOff + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+4)
 145508 			if iOff+*(*int32)(unsafe.Pointer(bp + 4)) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 145509 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145510 			} else {
 145511 				sqlite3Fts5BufferSet(tls, p+36, bp+8, *(*int32)(unsafe.Pointer(bp + 4)), (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff))
 145512 			}
 145513 		} else {
 145514 			iOff = iOff + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+20)
 145515 			iOff = iOff + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+24)
 145516 			if *(*int32)(unsafe.Pointer(bp + 20)) > (*Fts5Buffer)(unsafe.Pointer(bp+8)).Fn || iOff+*(*int32)(unsafe.Pointer(bp + 24)) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 145517 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145518 			} else {
 145519 				(*Fts5Buffer)(unsafe.Pointer(bp + 8)).Fn = *(*int32)(unsafe.Pointer(bp + 20))
 145520 				sqlite3Fts5BufferAppendBlob(tls, p+36, bp+8, uint32(*(*int32)(unsafe.Pointer(bp + 24))), (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff))
 145521 			}
 145522 
 145523 			if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 145524 				res = fts5BufferCompare(tls, bp+8, bp+28)
 145525 				if res <= 0 {
 145526 					(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145527 				}
 145528 			}
 145529 		}
 145530 		sqlite3Fts5BufferSet(tls, p+36, bp+28, (*Fts5Buffer)(unsafe.Pointer(bp+8)).Fn, (*Fts5Buffer)(unsafe.Pointer(bp+8)).Fp)
 145531 	}
 145532 
 145533 	sqlite3Fts5BufferFree(tls, bp+8)
 145534 	sqlite3Fts5BufferFree(tls, bp+28)
 145535 }
 145536 
 145537 func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) {
 145538 	bp := tls.Alloc(40)
 145539 	defer tls.Free(40)
 145540 
 145541 	var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig
 145542 	*(*uintptr)(unsafe.Pointer(bp + 24)) = uintptr(0)
 145543 	var rc2 int32
 145544 	var iIdxPrevLeaf int32 = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst - 1
 145545 	var iDlidxPrevLeaf int32 = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast
 145546 
 145547 	if (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst == 0 {
 145548 		return
 145549 	}
 145550 
 145551 	fts5IndexPrepareStmt(tls, p, bp+24, Xsqlite3_mprintf(tls,
 145552 		ts+35273,
 145553 		libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)))
 145554 
 145555 	for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24))) {
 145556 		var iRow I64
 145557 		var pLeaf uintptr
 145558 
 145559 		var zIdxTerm uintptr = Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), 1)
 145560 		var nIdxTerm int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), 1)
 145561 		var iIdxLeaf int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), 2)
 145562 		var bIdxDlidx int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), 3)
 145563 
 145564 		if iIdxLeaf < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst {
 145565 			continue
 145566 		}
 145567 		iRow = I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + I64(iIdxLeaf)
 145568 		pLeaf = fts5LeafRead(tls, p, iRow)
 145569 		if pLeaf == uintptr(0) {
 145570 			break
 145571 		}
 145572 
 145573 		if (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn <= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 145574 			(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145575 		} else {
 145576 			var iOff int32
 145577 			var iRowidOff int32
 145578 
 145579 			var res int32
 145580 
 145581 			iOff = fts5LeafFirstTermOff(tls, pLeaf)
 145582 			iRowidOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp))
 145583 			if iRowidOff >= iOff || iOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 145584 				(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145585 			} else {
 145586 				iOff = iOff + sqlite3Fts5GetVarint32(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), bp+28)
 145587 				res = func() int32 {
 145588 					if func() int32 {
 145589 						if *(*int32)(unsafe.Pointer(bp + 28)) < nIdxTerm {
 145590 							return *(*int32)(unsafe.Pointer(bp + 28))
 145591 						}
 145592 						return nIdxTerm
 145593 					}() <= 0 {
 145594 						return 0
 145595 					}
 145596 					return libc.Xmemcmp(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iOff), zIdxTerm, func() uint32 {
 145597 						if *(*int32)(unsafe.Pointer(bp + 28)) < nIdxTerm {
 145598 							return uint32(*(*int32)(unsafe.Pointer(bp + 28)))
 145599 						}
 145600 						return uint32(nIdxTerm)
 145601 					}())
 145602 				}()
 145603 				if res == 0 {
 145604 					res = *(*int32)(unsafe.Pointer(bp + 28)) - nIdxTerm
 145605 				}
 145606 				if res < 0 {
 145607 					(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145608 				}
 145609 			}
 145610 
 145611 			fts5IntegrityCheckPgidx(tls, p, pLeaf)
 145612 		}
 145613 		fts5DataRelease(tls, pLeaf)
 145614 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 145615 			break
 145616 		}
 145617 
 145618 		fts5IndexIntegrityCheckEmpty(tls,
 145619 			p, pSeg, iIdxPrevLeaf+1, iDlidxPrevLeaf+1, iIdxLeaf-1)
 145620 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 145621 			break
 145622 		}
 145623 
 145624 		if bIdxDlidx != 0 {
 145625 			var pDlidx uintptr = uintptr(0)
 145626 			var iPrevLeaf int32 = iIdxLeaf
 145627 			var iSegid int32 = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid
 145628 			var iPg int32 = 0
 145629 			var iKey I64
 145630 
 145631 			for pDlidx = fts5DlidxIterInit(tls, p, 0, iSegid, iIdxLeaf); fts5DlidxIterEof(tls, p, pDlidx) == 0; fts5DlidxIterNext(tls, p, pDlidx) {
 145632 				for iPg = iPrevLeaf + 1; iPg < fts5DlidxIterPgno(tls, pDlidx); iPg++ {
 145633 					iKey = I64(iSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + I64(iPg)
 145634 					pLeaf = fts5DataRead(tls, p, iKey)
 145635 					if pLeaf != 0 {
 145636 						if int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)) != 0 {
 145637 							(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145638 						}
 145639 						fts5DataRelease(tls, pLeaf)
 145640 					}
 145641 				}
 145642 				iPrevLeaf = fts5DlidxIterPgno(tls, pDlidx)
 145643 
 145644 				iKey = I64(iSegid)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B) + int64(0)<<(FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B) + int64(0)<<FTS5_DATA_PAGE_B + I64(iPrevLeaf)
 145645 				pLeaf = fts5DataRead(tls, p, iKey)
 145646 				if pLeaf != 0 {
 145647 					var iRowidOff int32 = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp))
 145648 
 145649 					if iRowidOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
 145650 						(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145651 					} else {
 145652 						sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr(iRowidOff), bp+32)
 145653 						if *(*I64)(unsafe.Pointer(bp + 32)) != fts5DlidxIterRowid(tls, pDlidx) {
 145654 							(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145655 						}
 145656 					}
 145657 					fts5DataRelease(tls, pLeaf)
 145658 				}
 145659 			}
 145660 
 145661 			iDlidxPrevLeaf = iPg
 145662 			fts5DlidxIterFree(tls, pDlidx)
 145663 
 145664 		} else {
 145665 			iDlidxPrevLeaf = (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast
 145666 
 145667 		}
 145668 
 145669 		iIdxPrevLeaf = iIdxLeaf
 145670 	}
 145671 
 145672 	rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24)))
 145673 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
 145674 		(*Fts5Index)(unsafe.Pointer(p)).Frc = rc2
 145675 	}
 145676 
 145677 }
 145678 
 145679 func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64, bUseCksum int32) int32 {
 145680 	bp := tls.Alloc(32)
 145681 	defer tls.Free(32)
 145682 
 145683 	var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail
 145684 	var cksum2 U64 = uint64(0)
 145685 	*(*Fts5Buffer)(unsafe.Pointer(bp + 8)) = Fts5Buffer{}
 145686 
 145687 	var pStruct uintptr
 145688 	var iLvl int32
 145689 	var iSeg int32
 145690 
 145691 	var flags int32 = FTS5INDEX_QUERY_NOOUTPUT
 145692 
 145693 	pStruct = fts5StructureRead(tls, p)
 145694 	if pStruct == uintptr(0) {
 145695 		return fts5IndexReturn(tls, p)
 145696 	}
 145697 
 145698 	for iLvl = 0; iLvl < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; iLvl++ {
 145699 		for iSeg = 0; iSeg < (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FnSeg; iSeg++ {
 145700 			var pSeg uintptr = (*Fts5StructureLevel)(unsafe.Pointer(pStruct+24+uintptr(iLvl)*12)).FaSeg + uintptr(iSeg)*12
 145701 			fts5IndexIntegrityCheckSegment(tls, p, pSeg)
 145702 		}
 145703 	}
 145704 
 145705 	for fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, -1, 0, bp); fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp))) == 0; fts5MultiIterNext(tls, p, *(*uintptr)(unsafe.Pointer(bp)), 0, int64(0)) {
 145706 		*(*I64)(unsafe.Pointer(bp + 24)) = int64(0)
 145707 		*(*int32)(unsafe.Pointer(bp + 20)) = 0
 145708 		var iRowid I64 = fts5MultiIterRowid(tls, *(*uintptr)(unsafe.Pointer(bp)))
 145709 		var z uintptr = fts5MultiIterTerm(tls, *(*uintptr)(unsafe.Pointer(bp)), bp+4)
 145710 
 145711 		if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 {
 145712 			break
 145713 		}
 145714 
 145715 		if eDetail == FTS5_DETAIL_NONE {
 145716 			if 0 == fts5MultiIterIsEmpty(tls, p, *(*uintptr)(unsafe.Pointer(bp))) {
 145717 				cksum2 = cksum2 ^ sqlite3Fts5IndexEntryCksum(tls, iRowid, 0, 0, -1, z, *(*int32)(unsafe.Pointer(bp + 4)))
 145718 			}
 145719 		} else {
 145720 			(*Fts5Buffer)(unsafe.Pointer(bp + 8)).Fn = 0
 145721 			fts5SegiterPoslist(tls, p, *(*uintptr)(unsafe.Pointer(bp))+80+uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FaFirst+1*4)).FiFirst)*96, uintptr(0), bp+8)
 145722 			sqlite3Fts5BufferAppendBlob(tls, p+36, bp+8, uint32(4), ts+35359)
 145723 			for 0 == sqlite3Fts5PoslistNext64(tls, (*Fts5Buffer)(unsafe.Pointer(bp+8)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp+8)).Fn, bp+20, bp+24) {
 145724 				var iCol int32 = int32(*(*I64)(unsafe.Pointer(bp + 24)) >> 32)
 145725 				var iTokOff int32 = int32(*(*I64)(unsafe.Pointer(bp + 24)) & int64(0x7FFFFFFF))
 145726 				cksum2 = cksum2 ^ sqlite3Fts5IndexEntryCksum(tls, iRowid, iCol, iTokOff, -1, z, *(*int32)(unsafe.Pointer(bp + 4)))
 145727 			}
 145728 		}
 145729 	}
 145730 
 145731 	fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp)))
 145732 	if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK && bUseCksum != 0 && cksum != cksum2 {
 145733 		(*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT | int32(1)<<8
 145734 	}
 145735 
 145736 	fts5StructureRelease(tls, pStruct)
 145737 	sqlite3Fts5BufferFree(tls, bp+8)
 145738 	return fts5IndexReturn(tls, p)
 145739 }
 145740 
 145741 func sqlite3Fts5IndexInit(tls *libc.TLS, db uintptr) int32 {
 145742 	return SQLITE_OK
 145743 	_ = db
 145744 	return int32(0)
 145745 }
 145746 
 145747 func sqlite3Fts5IndexReset(tls *libc.TLS, p uintptr) int32 {
 145748 	if fts5IndexDataVersion(tls, p) != (*Fts5Index)(unsafe.Pointer(p)).FiStructVersion {
 145749 		fts5StructureInvalidate(tls, p)
 145750 	}
 145751 	return fts5IndexReturn(tls, p)
 145752 }
 145753 
 145754 type Fts5Auxdata1 = struct {
 145755 	FpAux    uintptr
 145756 	FpPtr    uintptr
 145757 	FxDelete uintptr
 145758 	FpNext   uintptr
 145759 }
 145760 
 145761 type Fts5Auxdata = Fts5Auxdata1
 145762 type Fts5Auxiliary1 = struct {
 145763 	FpGlobal   uintptr
 145764 	FzFunc     uintptr
 145765 	FpUserData uintptr
 145766 	FxFunc     Fts5_extension_function
 145767 	FxDestroy  uintptr
 145768 	FpNext     uintptr
 145769 }
 145770 
 145771 type Fts5Auxiliary = Fts5Auxiliary1
 145772 type Fts5Cursor1 = struct {
 145773 	Fbase         Sqlite3_vtab_cursor
 145774 	FpNext        uintptr
 145775 	FaColumnSize  uintptr
 145776 	F__ccgo_pad1  [4]byte
 145777 	FiCsrId       I64
 145778 	FePlan        int32
 145779 	FbDesc        int32
 145780 	FiFirstRowid  I64
 145781 	FiLastRowid   I64
 145782 	FpStmt        uintptr
 145783 	FpExpr        uintptr
 145784 	FpSorter      uintptr
 145785 	Fcsrflags     int32
 145786 	FiSpecial     I64
 145787 	FzRank        uintptr
 145788 	FzRankArgs    uintptr
 145789 	FpRank        uintptr
 145790 	FnRankArg     int32
 145791 	FapRankArg    uintptr
 145792 	FpRankArgStmt uintptr
 145793 	FpAux         uintptr
 145794 	FpAuxdata     uintptr
 145795 	FaInstIter    uintptr
 145796 	FnInstAlloc   int32
 145797 	FnInstCount   int32
 145798 	FaInst        uintptr
 145799 }
 145800 
 145801 type Fts5Cursor = Fts5Cursor1
 145802 type Fts5FullTable1 = struct {
 145803 	Fp        Fts5Table
 145804 	FpStorage uintptr
 145805 	FpGlobal  uintptr
 145806 	FpSortCsr uintptr
 145807 }
 145808 
 145809 type Fts5FullTable = Fts5FullTable1
 145810 type Fts5Sorter1 = struct {
 145811 	FpStmt       uintptr
 145812 	F__ccgo_pad1 [4]byte
 145813 	FiRowid      I64
 145814 	FaPoslist    uintptr
 145815 	FnIdx        int32
 145816 	FaIdx        [1]int32
 145817 	F__ccgo_pad2 [4]byte
 145818 }
 145819 
 145820 type Fts5Sorter = Fts5Sorter1
 145821 type Fts5TokenizerModule1 = struct {
 145822 	FzName     uintptr
 145823 	FpUserData uintptr
 145824 	Fx         Fts5_tokenizer
 145825 	FxDestroy  uintptr
 145826 	FpNext     uintptr
 145827 }
 145828 
 145829 type Fts5TokenizerModule = Fts5TokenizerModule1
 145830 
 145831 // NOTES ON TRANSACTIONS:
 145832 //
 145833 // SQLite invokes the following virtual table methods as transactions are
 145834 // opened and closed by the user:
 145835 //
 145836 //	xBegin():    Start of a new transaction.
 145837 //	xSync():     Initial part of two-phase commit.
 145838 //	xCommit():   Final part of two-phase commit.
 145839 //	xRollback(): Rollback the transaction.
 145840 //
 145841 // Anything that is required as part of a commit that may fail is performed
 145842 // in the xSync() callback. Current versions of SQLite ignore any errors
 145843 // returned by xCommit().
 145844 //
 145845 // And as sub-transactions are opened/closed:
 145846 //
 145847 //	xSavepoint(int S):  Open savepoint S.
 145848 //	xRelease(int S):    Commit and close savepoint S.
 145849 //	xRollbackTo(int S): Rollback to start of savepoint S.
 145850 //
 145851 // During a write-transaction the fts5_index.c module may cache some data
 145852 // in-memory. It is flushed to disk whenever xSync(), xRelease() or
 145853 // xSavepoint() is called. And discarded whenever xRollback() or xRollbackTo()
 145854 // is called.
 145855 //
 145856 // Additionally, if SQLITE_DEBUG is defined, an instance of the following
 145857 // structure is used to record the current transaction state. This information
 145858 // is not required, but it is used in the assert() statements executed by
 145859 // function fts5CheckTransactionState() (see below).
 145860 type Fts5TransactionState = struct {
 145861 	FeState     int32
 145862 	FiSavepoint int32
 145863 }
 145864 
 145865 type Fts5MatchPhrase = struct {
 145866 	FpPoslist uintptr
 145867 	FnTerm    int32
 145868 }
 145869 
 145870 func fts5IsContentless(tls *libc.TLS, pTab uintptr) int32 {
 145871 	return libc.Bool32((*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FeContent == FTS5_CONTENT_NONE)
 145872 }
 145873 
 145874 func fts5FreeVtab(tls *libc.TLS, pTab uintptr) {
 145875 	if pTab != 0 {
 145876 		sqlite3Fts5IndexClose(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
 145877 		sqlite3Fts5StorageClose(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 145878 		sqlite3Fts5ConfigFree(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)
 145879 		Xsqlite3_free(tls, pTab)
 145880 	}
 145881 }
 145882 
 145883 func fts5DisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 {
 145884 	fts5FreeVtab(tls, pVtab)
 145885 	return SQLITE_OK
 145886 }
 145887 
 145888 func fts5DestroyMethod(tls *libc.TLS, pVtab uintptr) int32 {
 145889 	var pTab uintptr = pVtab
 145890 	var rc int32 = sqlite3Fts5DropAll(tls, (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)
 145891 	if rc == SQLITE_OK {
 145892 		fts5FreeVtab(tls, pVtab)
 145893 	}
 145894 	return rc
 145895 }
 145896 
 145897 func fts5InitVtab(tls *libc.TLS, bCreate int32, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) int32 {
 145898 	bp := tls.Alloc(8)
 145899 	defer tls.Free(8)
 145900 
 145901 	var pGlobal uintptr = pAux
 145902 	var azConfig uintptr = argv
 145903 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 145904 	*(*uintptr)(unsafe.Pointer(bp + 4)) = uintptr(0)
 145905 	var pTab uintptr = uintptr(0)
 145906 
 145907 	pTab = sqlite3Fts5MallocZero(tls, bp, int64(unsafe.Sizeof(Fts5FullTable{})))
 145908 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 145909 		*(*int32)(unsafe.Pointer(bp)) = sqlite3Fts5ConfigParse(tls, pGlobal, db, argc, azConfig, bp+4, pzErr)
 145910 
 145911 	}
 145912 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 145913 		(*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig = *(*uintptr)(unsafe.Pointer(bp + 4))
 145914 		(*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal = pGlobal
 145915 	}
 145916 
 145917 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 145918 		*(*int32)(unsafe.Pointer(bp)) = sqlite3Fts5IndexOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), bCreate, pTab+16, pzErr)
 145919 	}
 145920 
 145921 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 145922 		*(*int32)(unsafe.Pointer(bp)) = sqlite3Fts5StorageOpen(tls,
 145923 			*(*uintptr)(unsafe.Pointer(bp + 4)), (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, bCreate, pTab+20, pzErr)
 145924 	}
 145925 
 145926 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 145927 		*(*int32)(unsafe.Pointer(bp)) = sqlite3Fts5ConfigDeclareVtab(tls, *(*uintptr)(unsafe.Pointer(bp + 4)))
 145928 	}
 145929 
 145930 	if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 145931 		(*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpzErrmsg = pzErr
 145932 		*(*int32)(unsafe.Pointer(bp)) = sqlite3Fts5IndexLoadConfig(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
 145933 		sqlite3Fts5IndexRollback(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
 145934 		(*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 4)))).FpzErrmsg = uintptr(0)
 145935 	}
 145936 
 145937 	if *(*int32)(unsafe.Pointer(bp)) != SQLITE_OK {
 145938 		fts5FreeVtab(tls, pTab)
 145939 		pTab = uintptr(0)
 145940 	} else if bCreate != 0 {
 145941 	}
 145942 	*(*uintptr)(unsafe.Pointer(ppVTab)) = pTab
 145943 	return *(*int32)(unsafe.Pointer(bp))
 145944 }
 145945 
 145946 func fts5ConnectMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 145947 	return fts5InitVtab(tls, 0, db, pAux, argc, argv, ppVtab, pzErr)
 145948 }
 145949 
 145950 func fts5CreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 145951 	return fts5InitVtab(tls, 1, db, pAux, argc, argv, ppVtab, pzErr)
 145952 }
 145953 
 145954 func fts5SetUniqueFlag(tls *libc.TLS, pIdxInfo uintptr) {
 145955 	{
 145956 		*(*int32)(unsafe.Pointer(pIdxInfo + 56)) |= SQLITE_INDEX_SCAN_UNIQUE
 145957 
 145958 	}
 145959 }
 145960 
 145961 func fts5UsePatternMatch(tls *libc.TLS, pConfig uintptr, p uintptr) int32 {
 145962 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FePattern == FTS5_PATTERN_GLOB && int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == FTS5_PATTERN_GLOB {
 145963 		return 1
 145964 	}
 145965 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FePattern == FTS5_PATTERN_LIKE &&
 145966 		(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == FTS5_PATTERN_LIKE || int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == FTS5_PATTERN_GLOB) {
 145967 		return 1
 145968 	}
 145969 	return 0
 145970 }
 145971 
 145972 func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 {
 145973 	bp := tls.Alloc(16)
 145974 	defer tls.Free(16)
 145975 
 145976 	var pTab uintptr = pVTab
 145977 	var pConfig uintptr = (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig
 145978 	var nCol int32 = (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol
 145979 	var idxFlags int32 = 0
 145980 	var i int32
 145981 	var idxStr uintptr
 145982 	var iIdxStr int32 = 0
 145983 	var iCons int32 = 0
 145984 
 145985 	var bSeenEq int32 = 0
 145986 	var bSeenGt int32 = 0
 145987 	var bSeenLt int32 = 0
 145988 	var bSeenMatch int32 = 0
 145989 	var bSeenRank int32 = 0
 145990 
 145991 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock != 0 {
 145992 		(*Fts5Table)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls,
 145993 			ts+35364, 0)
 145994 		return SQLITE_ERROR
 145995 	}
 145996 
 145997 	idxStr = Xsqlite3_malloc(tls, (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint*8+1)
 145998 	if idxStr == uintptr(0) {
 145999 		return SQLITE_NOMEM
 146000 	}
 146001 	(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxStr = idxStr
 146002 	(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FneedToFreeIdxStr = 1
 146003 
 146004 	for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ {
 146005 		var p uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12
 146006 		var iCol int32 = (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn
 146007 		if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH ||
 146008 			int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ && iCol >= nCol {
 146009 			if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 || iCol < 0 {
 146010 				(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = 1e50
 146011 
 146012 				*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr))) = uint8(0)
 146013 				return SQLITE_OK
 146014 			} else {
 146015 				if iCol == nCol+1 {
 146016 					if bSeenRank != 0 {
 146017 						continue
 146018 					}
 146019 					*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = uint8('r')
 146020 					bSeenRank = 1
 146021 				} else if iCol >= 0 {
 146022 					bSeenMatch = 1
 146023 					*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = uint8('M')
 146024 					Xsqlite3_snprintf(tls, 6, idxStr+uintptr(iIdxStr), ts+4975, libc.VaList(bp, iCol))
 146025 					idxStr += uintptr(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr)))
 146026 
 146027 				}
 146028 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1)
 146029 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1)
 146030 			}
 146031 		} else if (*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 {
 146032 			if iCol >= 0 && iCol < nCol && fts5UsePatternMatch(tls, pConfig, p) != 0 {
 146033 				*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = func() uint8 {
 146034 					if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == FTS5_PATTERN_LIKE {
 146035 						return uint8('L')
 146036 					}
 146037 					return uint8('G')
 146038 				}()
 146039 				Xsqlite3_snprintf(tls, 6, idxStr+uintptr(iIdxStr), ts+4975, libc.VaList(bp+8, iCol))
 146040 				idxStr += uintptr(libc.Xstrlen(tls, idxStr+uintptr(iIdxStr)))
 146041 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1)
 146042 
 146043 			} else if bSeenEq == 0 && int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ && iCol < 0 {
 146044 				*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = uint8('=')
 146045 				bSeenEq = 1
 146046 				(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1)
 146047 			}
 146048 		}
 146049 	}
 146050 
 146051 	if bSeenEq == 0 {
 146052 		for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ {
 146053 			var p uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12
 146054 			if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0 && (*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0 {
 146055 				var op int32 = int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop)
 146056 				if op == SQLITE_INDEX_CONSTRAINT_LT || op == SQLITE_INDEX_CONSTRAINT_LE {
 146057 					if bSeenLt != 0 {
 146058 						continue
 146059 					}
 146060 					*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = uint8('<')
 146061 					(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1)
 146062 					bSeenLt = 1
 146063 				} else if op == SQLITE_INDEX_CONSTRAINT_GT || op == SQLITE_INDEX_CONSTRAINT_GE {
 146064 					if bSeenGt != 0 {
 146065 						continue
 146066 					}
 146067 					*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = uint8('>')
 146068 					(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1)
 146069 					bSeenGt = 1
 146070 				}
 146071 			}
 146072 		}
 146073 	}
 146074 	*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr))) = uint8(0)
 146075 
 146076 	if (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == 1 {
 146077 		var iSort int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).FiColumn
 146078 		if iSort == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol+1 && bSeenMatch != 0 {
 146079 			idxFlags = idxFlags | FTS5_BI_ORDER_RANK
 146080 		} else if iSort == -1 {
 146081 			idxFlags = idxFlags | FTS5_BI_ORDER_ROWID
 146082 		}
 146083 		if idxFlags&(FTS5_BI_ORDER_RANK|FTS5_BI_ORDER_ROWID) != 0 {
 146084 			(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = 1
 146085 			if (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).Fdesc != 0 {
 146086 				idxFlags = idxFlags | FTS5_BI_ORDER_DESC
 146087 			}
 146088 		}
 146089 	}
 146090 
 146091 	if bSeenEq != 0 {
 146092 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = func() float64 {
 146093 			if bSeenMatch != 0 {
 146094 				return 100.0
 146095 			}
 146096 			return 10.0
 146097 		}()
 146098 		if bSeenMatch == 0 {
 146099 			fts5SetUniqueFlag(tls, pInfo)
 146100 		}
 146101 	} else if bSeenLt != 0 && bSeenGt != 0 {
 146102 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = func() float64 {
 146103 			if bSeenMatch != 0 {
 146104 				return 500.0
 146105 			}
 146106 			return 250000.0
 146107 		}()
 146108 	} else if bSeenLt != 0 || bSeenGt != 0 {
 146109 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = func() float64 {
 146110 			if bSeenMatch != 0 {
 146111 				return 750.0
 146112 			}
 146113 			return 750000.0
 146114 		}()
 146115 	} else {
 146116 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = func() float64 {
 146117 			if bSeenMatch != 0 {
 146118 				return 1000.0
 146119 			}
 146120 			return 1000000.0
 146121 		}()
 146122 	}
 146123 
 146124 	(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxFlags
 146125 	return SQLITE_OK
 146126 }
 146127 
 146128 func fts5NewTransaction(tls *libc.TLS, pTab uintptr) int32 {
 146129 	var pCsr uintptr
 146130 	for pCsr = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext {
 146131 		if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab {
 146132 			return SQLITE_OK
 146133 		}
 146134 	}
 146135 	return sqlite3Fts5StorageReset(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 146136 }
 146137 
 146138 func fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 {
 146139 	var pTab uintptr = pVTab
 146140 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 146141 	var pCsr uintptr = uintptr(0)
 146142 	var nByte Sqlite3_int64
 146143 	var rc int32
 146144 
 146145 	rc = fts5NewTransaction(tls, pTab)
 146146 	if rc == SQLITE_OK {
 146147 		nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Cursor{})) + uint32((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*uint32(unsafe.Sizeof(int32(0))))
 146148 		pCsr = Xsqlite3_malloc64(tls, uint64(nByte))
 146149 		if pCsr != 0 {
 146150 			var pGlobal uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal
 146151 			libc.Xmemset(tls, pCsr, 0, Size_t(nByte))
 146152 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = pCsr + 1*120
 146153 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr
 146154 			(*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr = pCsr
 146155 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId = libc.PreIncInt64(&(*Fts5Global)(unsafe.Pointer(pGlobal)).FiNextId, 1)
 146156 		} else {
 146157 			rc = SQLITE_NOMEM
 146158 		}
 146159 	}
 146160 	*(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr
 146161 	return rc
 146162 }
 146163 
 146164 func fts5StmtType(tls *libc.TLS, pCsr uintptr) int32 {
 146165 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SCAN {
 146166 		if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc != 0 {
 146167 			return FTS5_STMT_SCAN_DESC
 146168 		}
 146169 		return FTS5_STMT_SCAN_ASC
 146170 	}
 146171 	return FTS5_STMT_LOOKUP
 146172 }
 146173 
 146174 func fts5CsrNewrow(tls *libc.TLS, pCsr uintptr) {
 146175 	*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_REQUIRE_CONTENT | FTS5CSR_REQUIRE_DOCSIZE | FTS5CSR_REQUIRE_INST | FTS5CSR_REQUIRE_POSLIST
 146176 }
 146177 
 146178 func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) {
 146179 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 146180 	var pData uintptr
 146181 	var pNext uintptr
 146182 
 146183 	Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter)
 146184 	Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst)
 146185 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt != 0 {
 146186 		var eStmt int32 = fts5StmtType(tls, pCsr)
 146187 		sqlite3Fts5StorageStmtRelease(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, eStmt, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt)
 146188 	}
 146189 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 {
 146190 		var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter
 146191 		Xsqlite3_finalize(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt)
 146192 		Xsqlite3_free(tls, pSorter)
 146193 	}
 146194 
 146195 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan != FTS5_PLAN_SOURCE {
 146196 		sqlite3Fts5ExprFree(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 146197 	}
 146198 
 146199 	for pData = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata; pData != 0; pData = pNext {
 146200 		pNext = (*Fts5Auxdata)(unsafe.Pointer(pData)).FpNext
 146201 		if (*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete != 0 {
 146202 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete})).f(tls, (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr)
 146203 		}
 146204 		Xsqlite3_free(tls, pData)
 146205 	}
 146206 
 146207 	Xsqlite3_finalize(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt)
 146208 	Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg)
 146209 
 146210 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_FREE_ZRANK != 0 {
 146211 		Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank)
 146212 		Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs)
 146213 	}
 146214 
 146215 	sqlite3Fts5IndexCloseReader(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
 146216 	libc.Xmemset(tls, pCsr+24, 0, uint32(unsafe.Sizeof(Fts5Cursor{}))-uint32((int32(pCsr+24)-int32(pCsr))/1))
 146217 }
 146218 
 146219 func fts5CloseMethod(tls *libc.TLS, pCursor uintptr) int32 {
 146220 	if pCursor != 0 {
 146221 		var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab
 146222 		var pCsr uintptr = pCursor
 146223 		var pp uintptr
 146224 
 146225 		fts5FreeCursorComponents(tls, pCsr)
 146226 
 146227 		for pp = (*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal + 44; *(*uintptr)(unsafe.Pointer(pp)) != pCsr; pp = *(*uintptr)(unsafe.Pointer(pp)) + 4 {
 146228 		}
 146229 		*(*uintptr)(unsafe.Pointer(pp)) = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext
 146230 
 146231 		Xsqlite3_free(tls, pCsr)
 146232 	}
 146233 	return SQLITE_OK
 146234 }
 146235 
 146236 func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 {
 146237 	bp := tls.Alloc(4)
 146238 	defer tls.Free(4)
 146239 
 146240 	var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter
 146241 	var rc int32
 146242 
 146243 	rc = Xsqlite3_step(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt)
 146244 	if rc == SQLITE_DONE {
 146245 		rc = SQLITE_OK
 146246 		*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_EOF | FTS5CSR_REQUIRE_CONTENT
 146247 	} else if rc == SQLITE_ROW {
 146248 		var a uintptr
 146249 		var aBlob uintptr
 146250 		var nBlob int32
 146251 		var i int32
 146252 		var iOff int32 = 0
 146253 		rc = SQLITE_OK
 146254 
 146255 		(*Fts5Sorter)(unsafe.Pointer(pSorter)).FiRowid = Xsqlite3_column_int64(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 0)
 146256 		nBlob = Xsqlite3_column_bytes(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 1)
 146257 		aBlob = libc.AssignUintptr(&a, Xsqlite3_column_blob(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 1))
 146258 
 146259 		if nBlob > 0 {
 146260 			for i = 0; i < (*Fts5Sorter)(unsafe.Pointer(pSorter)).FnIdx-1; i++ {
 146261 				a += uintptr(sqlite3Fts5GetVarint32(tls, a, bp))
 146262 				iOff = iOff + *(*int32)(unsafe.Pointer(bp))
 146263 				*(*int32)(unsafe.Pointer(pSorter + 24 + uintptr(i)*4)) = iOff
 146264 			}
 146265 			*(*int32)(unsafe.Pointer(pSorter + 24 + uintptr(i)*4)) = (int32(aBlob+uintptr(nBlob)) - int32(a)) / 1
 146266 			(*Fts5Sorter)(unsafe.Pointer(pSorter)).FaPoslist = a
 146267 		}
 146268 
 146269 		fts5CsrNewrow(tls, pCsr)
 146270 	}
 146271 
 146272 	return rc
 146273 }
 146274 
 146275 func fts5TripCursors(tls *libc.TLS, pTab uintptr) {
 146276 	var pCsr uintptr
 146277 	for pCsr = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext {
 146278 		if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_MATCH &&
 146279 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab {
 146280 			*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_REQUIRE_RESEEK
 146281 		}
 146282 	}
 146283 }
 146284 
 146285 func fts5CursorReseek(tls *libc.TLS, pCsr uintptr, pbSkip uintptr) int32 {
 146286 	var rc int32 = SQLITE_OK
 146287 
 146288 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_REQUIRE_RESEEK != 0 {
 146289 		var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 146290 		var bDesc int32 = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc
 146291 		var iRowid I64 = sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 146292 
 146293 		rc = sqlite3Fts5ExprFirst(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, iRowid, bDesc)
 146294 		if rc == SQLITE_OK && iRowid != sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) {
 146295 			*(*int32)(unsafe.Pointer(pbSkip)) = 1
 146296 		}
 146297 
 146298 		*(*int32)(unsafe.Pointer(pCsr + 60)) &= libc.CplInt32(FTS5CSR_REQUIRE_RESEEK)
 146299 		fts5CsrNewrow(tls, pCsr)
 146300 		if sqlite3Fts5ExprEof(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) != 0 {
 146301 			*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_EOF
 146302 			*(*int32)(unsafe.Pointer(pbSkip)) = 1
 146303 		}
 146304 	}
 146305 	return rc
 146306 }
 146307 
 146308 func fts5NextMethod(tls *libc.TLS, pCursor uintptr) int32 {
 146309 	bp := tls.Alloc(12)
 146310 	defer tls.Free(12)
 146311 
 146312 	var pCsr uintptr = pCursor
 146313 	var rc int32
 146314 
 146315 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan < 3 {
 146316 		*(*int32)(unsafe.Pointer(bp + 8)) = 0
 146317 		if libc.AssignInt32(&rc, fts5CursorReseek(tls, pCsr, bp+8)) != 0 || *(*int32)(unsafe.Pointer(bp + 8)) != 0 {
 146318 			return rc
 146319 		}
 146320 		rc = sqlite3Fts5ExprNext(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid)
 146321 		*(*int32)(unsafe.Pointer(pCsr + 60)) |= sqlite3Fts5ExprEof(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 146322 		fts5CsrNewrow(tls, pCsr)
 146323 	} else {
 146324 		switch (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan {
 146325 		case FTS5_PLAN_SPECIAL:
 146326 			{
 146327 				*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_EOF
 146328 				rc = SQLITE_OK
 146329 				break
 146330 
 146331 			}
 146332 			fallthrough
 146333 
 146334 		case FTS5_PLAN_SORTED_MATCH:
 146335 			{
 146336 				rc = fts5SorterNext(tls, pCsr)
 146337 				break
 146338 
 146339 			}
 146340 			fallthrough
 146341 
 146342 		default:
 146343 			{
 146344 				var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FpConfig
 146345 				(*Fts5Config)(unsafe.Pointer(pConfig)).FbLock++
 146346 				rc = Xsqlite3_step(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt)
 146347 				(*Fts5Config)(unsafe.Pointer(pConfig)).FbLock--
 146348 				if rc != SQLITE_ROW {
 146349 					*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_EOF
 146350 					rc = Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt)
 146351 					if rc != SQLITE_OK {
 146352 						(*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls,
 146353 							ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb)))
 146354 					}
 146355 				} else {
 146356 					rc = SQLITE_OK
 146357 				}
 146358 				break
 146359 
 146360 			}
 146361 		}
 146362 	}
 146363 
 146364 	return rc
 146365 }
 146366 
 146367 func fts5PrepareStatement(tls *libc.TLS, ppStmt uintptr, pConfig uintptr, zFmt uintptr, va uintptr) int32 {
 146368 	bp := tls.Alloc(12)
 146369 	defer tls.Free(12)
 146370 
 146371 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 146372 	var rc int32
 146373 	var zSql uintptr
 146374 	var ap Va_list
 146375 	_ = ap
 146376 
 146377 	ap = va
 146378 	zSql = Xsqlite3_vmprintf(tls, zFmt, ap)
 146379 	if zSql == uintptr(0) {
 146380 		rc = SQLITE_NOMEM
 146381 	} else {
 146382 		rc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1,
 146383 			uint32(SQLITE_PREPARE_PERSISTENT), bp+8, uintptr(0))
 146384 		if rc != SQLITE_OK {
 146385 			*(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb)))
 146386 		}
 146387 		Xsqlite3_free(tls, zSql)
 146388 	}
 146389 
 146390 	_ = ap
 146391 	*(*uintptr)(unsafe.Pointer(ppStmt)) = *(*uintptr)(unsafe.Pointer(bp + 8))
 146392 	return rc
 146393 }
 146394 
 146395 func fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) int32 {
 146396 	bp := tls.Alloc(56)
 146397 	defer tls.Free(56)
 146398 
 146399 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 146400 	var pSorter uintptr
 146401 	var nPhrase int32
 146402 	var nByte Sqlite3_int64
 146403 	var rc int32
 146404 	var zRank uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank
 146405 	var zRankArgs uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs
 146406 
 146407 	nPhrase = sqlite3Fts5ExprPhraseCount(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 146408 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Sorter{})) + uint32(unsafe.Sizeof(int32(0)))*uint32(nPhrase-1))
 146409 	pSorter = Xsqlite3_malloc64(tls, uint64(nByte))
 146410 	if pSorter == uintptr(0) {
 146411 		return SQLITE_NOMEM
 146412 	}
 146413 	libc.Xmemset(tls, pSorter, 0, Size_t(nByte))
 146414 	(*Fts5Sorter)(unsafe.Pointer(pSorter)).FnIdx = nPhrase
 146415 
 146416 	rc = fts5PrepareStatement(tls, pSorter, pConfig,
 146417 		ts+35403,
 146418 		libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zRank, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName,
 146419 			func() uintptr {
 146420 				if zRankArgs != 0 {
 146421 					return ts + 14614
 146422 				}
 146423 				return ts + 1554
 146424 			}(),
 146425 			func() uintptr {
 146426 				if zRankArgs != 0 {
 146427 					return zRankArgs
 146428 				}
 146429 				return ts + 1554
 146430 			}(),
 146431 			func() uintptr {
 146432 				if bDesc != 0 {
 146433 					return ts + 35458
 146434 				}
 146435 				return ts + 35463
 146436 			}()))
 146437 
 146438 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = pSorter
 146439 	if rc == SQLITE_OK {
 146440 		(*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = pCsr
 146441 		rc = fts5SorterNext(tls, pCsr)
 146442 		(*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = uintptr(0)
 146443 	}
 146444 
 146445 	if rc != SQLITE_OK {
 146446 		Xsqlite3_finalize(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt)
 146447 		Xsqlite3_free(tls, pSorter)
 146448 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = uintptr(0)
 146449 	}
 146450 
 146451 	return rc
 146452 }
 146453 
 146454 func fts5CursorFirst(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) int32 {
 146455 	var rc int32
 146456 	var pExpr uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr
 146457 	rc = sqlite3Fts5ExprFirst(tls, pExpr, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid, bDesc)
 146458 	if sqlite3Fts5ExprEof(tls, pExpr) != 0 {
 146459 		*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_EOF
 146460 	}
 146461 	fts5CsrNewrow(tls, pCsr)
 146462 	return rc
 146463 }
 146464 
 146465 func fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) int32 {
 146466 	bp := tls.Alloc(16)
 146467 	defer tls.Free(16)
 146468 
 146469 	var rc int32 = SQLITE_OK
 146470 	var z uintptr = zQuery
 146471 	var n int32
 146472 
 146473 	for int32(*(*uint8)(unsafe.Pointer(z))) == ' ' {
 146474 		z++
 146475 	}
 146476 	for n = 0; *(*uint8)(unsafe.Pointer(z + uintptr(n))) != 0 && int32(*(*uint8)(unsafe.Pointer(z + uintptr(n)))) != ' '; n++ {
 146477 	}
 146478 
 146479 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SPECIAL
 146480 
 146481 	if n == 5 && 0 == Xsqlite3_strnicmp(tls, ts+35467, z, n) {
 146482 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = I64(sqlite3Fts5IndexReads(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex))
 146483 	} else if n == 2 && 0 == Xsqlite3_strnicmp(tls, ts+5057, z, n) {
 146484 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId
 146485 	} else {
 146486 		(*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+35473, libc.VaList(bp, n, z))
 146487 		rc = SQLITE_ERROR
 146488 	}
 146489 
 146490 	return rc
 146491 }
 146492 
 146493 func fts5FindAuxiliary(tls *libc.TLS, pTab uintptr, zName uintptr) uintptr {
 146494 	var pAux uintptr
 146495 
 146496 	for pAux = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpAux; pAux != 0; pAux = (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpNext {
 146497 		if Xsqlite3_stricmp(tls, zName, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc) == 0 {
 146498 			return pAux
 146499 		}
 146500 	}
 146501 
 146502 	return uintptr(0)
 146503 }
 146504 
 146505 func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 {
 146506 	bp := tls.Alloc(24)
 146507 	defer tls.Free(24)
 146508 
 146509 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 146510 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 146511 	*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_OK
 146512 	var pAux uintptr = uintptr(0)
 146513 	var zRank uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank
 146514 	var zRankArgs uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs
 146515 
 146516 	if zRankArgs != 0 {
 146517 		var zSql uintptr = sqlite3Fts5Mprintf(tls, bp+16, ts+35501, libc.VaList(bp, zRankArgs))
 146518 		if zSql != 0 {
 146519 			*(*uintptr)(unsafe.Pointer(bp + 20)) = uintptr(0)
 146520 			*(*int32)(unsafe.Pointer(bp + 16)) = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1,
 146521 				uint32(SQLITE_PREPARE_PERSISTENT), bp+20, uintptr(0))
 146522 			Xsqlite3_free(tls, zSql)
 146523 
 146524 			if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 146525 				if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 20))) {
 146526 					var nByte Sqlite3_int64
 146527 					(*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 20)))
 146528 					nByte = Sqlite3_int64(uint32(unsafe.Sizeof(uintptr(0))) * uint32((*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg))
 146529 					(*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg = sqlite3Fts5MallocZero(tls, bp+16, nByte)
 146530 					if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 146531 						var i int32
 146532 						for i = 0; i < (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg; i++ {
 146533 							*(*uintptr)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg + uintptr(i)*4)) = Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 20)), i)
 146534 						}
 146535 					}
 146536 					(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt = *(*uintptr)(unsafe.Pointer(bp + 20))
 146537 				} else {
 146538 					*(*int32)(unsafe.Pointer(bp + 16)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 20)))
 146539 
 146540 				}
 146541 			}
 146542 		}
 146543 	}
 146544 
 146545 	if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 146546 		pAux = fts5FindAuxiliary(tls, pTab, zRank)
 146547 		if pAux == uintptr(0) {
 146548 			(*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+35511, libc.VaList(bp+8, zRank))
 146549 			*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_ERROR
 146550 		}
 146551 	}
 146552 
 146553 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank = pAux
 146554 	return *(*int32)(unsafe.Pointer(bp + 16))
 146555 }
 146556 
 146557 func fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uintptr) int32 {
 146558 	bp := tls.Alloc(16)
 146559 	defer tls.Free(16)
 146560 
 146561 	var rc int32 = SQLITE_OK
 146562 	if pRank != 0 {
 146563 		var z uintptr = Xsqlite3_value_text(tls, pRank)
 146564 		*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 146565 		*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 146566 
 146567 		if z == uintptr(0) {
 146568 			if Xsqlite3_value_type(tls, pRank) == SQLITE_NULL {
 146569 				rc = SQLITE_ERROR
 146570 			}
 146571 		} else {
 146572 			rc = sqlite3Fts5ConfigParseRank(tls, z, bp+8, bp+12)
 146573 		}
 146574 		if rc == SQLITE_OK {
 146575 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank = *(*uintptr)(unsafe.Pointer(bp + 8))
 146576 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = *(*uintptr)(unsafe.Pointer(bp + 12))
 146577 			*(*int32)(unsafe.Pointer(pCsr + 60)) |= FTS5CSR_FREE_ZRANK
 146578 		} else if rc == SQLITE_ERROR {
 146579 			(*Sqlite3_vtab)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls,
 146580 				ts+35532, libc.VaList(bp, z))
 146581 		}
 146582 	} else {
 146583 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank != 0 {
 146584 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank = (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank
 146585 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs
 146586 		} else {
 146587 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank = ts + 33915
 146588 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = uintptr(0)
 146589 		}
 146590 	}
 146591 	return rc
 146592 }
 146593 
 146594 func fts5GetRowidLimit(tls *libc.TLS, pVal uintptr, iDefault I64) I64 {
 146595 	if pVal != 0 {
 146596 		var eType int32 = Xsqlite3_value_numeric_type(tls, pVal)
 146597 		if eType == SQLITE_INTEGER {
 146598 			return Xsqlite3_value_int64(tls, pVal)
 146599 		}
 146600 	}
 146601 	return iDefault
 146602 }
 146603 
 146604 func fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, nVal int32, apVal uintptr) int32 {
 146605 	bp := tls.Alloc(12)
 146606 	defer tls.Free(12)
 146607 
 146608 	var pTab uintptr
 146609 	var pConfig uintptr
 146610 	var pCsr uintptr
 146611 	var rc int32
 146612 	var bDesc int32
 146613 	var bOrderByRank int32
 146614 	var pRank uintptr
 146615 	var pRowidEq uintptr
 146616 	var pRowidLe uintptr
 146617 	var pRowidGe uintptr
 146618 	var iCol int32
 146619 	var pzErrmsg uintptr
 146620 	var i int32
 146621 	var iIdxStr int32
 146622 
 146623 	var pzErr uintptr
 146624 	var zText uintptr
 146625 	var bGlob int32
 146626 	var zText1 uintptr
 146627 	pTab = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab
 146628 	pConfig = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 146629 	pCsr = pCursor
 146630 	rc = SQLITE_OK
 146631 	pRank = uintptr(0)
 146632 	pRowidEq = uintptr(0)
 146633 	pRowidLe = uintptr(0)
 146634 	pRowidGe = uintptr(0)
 146635 	pzErrmsg = (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg
 146636 	iIdxStr = 0
 146637 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 146638 
 146639 	if !((*Fts5Config)(unsafe.Pointer(pConfig)).FbLock != 0) {
 146640 		goto __1
 146641 	}
 146642 	(*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls,
 146643 		ts+35364, 0)
 146644 	return SQLITE_ERROR
 146645 __1:
 146646 	;
 146647 	if !((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan != 0) {
 146648 		goto __2
 146649 	}
 146650 	fts5FreeCursorComponents(tls, pCsr)
 146651 	libc.Xmemset(tls, pCsr+24, 0, uint32(unsafe.Sizeof(Fts5Cursor{}))-uint32((int32(pCsr+24)-int32(pCsr))/1))
 146652 __2:
 146653 	;
 146654 	(*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pTab + 8
 146655 
 146656 	i = 0
 146657 __3:
 146658 	if !(i < nVal) {
 146659 		goto __5
 146660 	}
 146661 	switch int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1))))) {
 146662 	case 'r':
 146663 		goto __7
 146664 	case 'M':
 146665 		goto __8
 146666 	case 'L':
 146667 		goto __9
 146668 	case 'G':
 146669 		goto __10
 146670 	case '=':
 146671 		goto __11
 146672 	case '<':
 146673 		goto __12
 146674 	default:
 146675 		goto __13
 146676 	}
 146677 	goto __6
 146678 __7:
 146679 	pRank = *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4))
 146680 	goto __6
 146681 __8:
 146682 	zText = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4)))
 146683 	if !(zText == uintptr(0)) {
 146684 		goto __14
 146685 	}
 146686 	zText = ts + 1554
 146687 __14:
 146688 	;
 146689 	iCol = 0
 146690 __15:
 146691 	iCol = iCol*10 + (int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr)))) - '0')
 146692 	iIdxStr++
 146693 	goto __16
 146694 __16:
 146695 	if int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr)))) >= '0' && int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr)))) <= '9' {
 146696 		goto __15
 146697 	}
 146698 	goto __17
 146699 __17:
 146700 	;
 146701 	if !(int32(*(*uint8)(unsafe.Pointer(zText))) == '*') {
 146702 		goto __18
 146703 	}
 146704 
 146705 	rc = fts5SpecialMatch(tls, pTab, pCsr, zText+1)
 146706 	goto filter_out
 146707 	goto __19
 146708 __18:
 146709 	pzErr = pTab + 8
 146710 	rc = sqlite3Fts5ExprNew(tls, pConfig, 0, iCol, zText, bp+8, pzErr)
 146711 	if !(rc == SQLITE_OK) {
 146712 		goto __20
 146713 	}
 146714 	rc = sqlite3Fts5ExprAnd(tls, pCsr+52, *(*uintptr)(unsafe.Pointer(bp + 8)))
 146715 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 146716 __20:
 146717 	;
 146718 	if !(rc != SQLITE_OK) {
 146719 		goto __21
 146720 	}
 146721 	goto filter_out
 146722 __21:
 146723 	;
 146724 __19:
 146725 	;
 146726 	goto __6
 146727 
 146728 __9:
 146729 __10:
 146730 	bGlob = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr-1)))) == 'G')
 146731 	zText1 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4)))
 146732 	iCol = 0
 146733 __22:
 146734 	iCol = iCol*10 + (int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr)))) - '0')
 146735 	iIdxStr++
 146736 	goto __23
 146737 __23:
 146738 	if int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr)))) >= '0' && int32(*(*uint8)(unsafe.Pointer(idxStr + uintptr(iIdxStr)))) <= '9' {
 146739 		goto __22
 146740 	}
 146741 	goto __24
 146742 __24:
 146743 	;
 146744 	if !(zText1 != 0) {
 146745 		goto __25
 146746 	}
 146747 	rc = sqlite3Fts5ExprPattern(tls, pConfig, bGlob, iCol, zText1, bp+8)
 146748 __25:
 146749 	;
 146750 	if !(rc == SQLITE_OK) {
 146751 		goto __26
 146752 	}
 146753 	rc = sqlite3Fts5ExprAnd(tls, pCsr+52, *(*uintptr)(unsafe.Pointer(bp + 8)))
 146754 	*(*uintptr)(unsafe.Pointer(bp + 8)) = uintptr(0)
 146755 __26:
 146756 	;
 146757 	if !(rc != SQLITE_OK) {
 146758 		goto __27
 146759 	}
 146760 	goto filter_out
 146761 __27:
 146762 	;
 146763 	goto __6
 146764 
 146765 __11:
 146766 	pRowidEq = *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4))
 146767 	goto __6
 146768 __12:
 146769 	pRowidLe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4))
 146770 	goto __6
 146771 __13:
 146772 	;
 146773 	pRowidGe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4))
 146774 	goto __6
 146775 __6:
 146776 	;
 146777 	goto __4
 146778 __4:
 146779 	i++
 146780 	goto __3
 146781 	goto __5
 146782 __5:
 146783 	;
 146784 	bOrderByRank = func() int32 {
 146785 		if idxNum&FTS5_BI_ORDER_RANK != 0 {
 146786 			return 1
 146787 		}
 146788 		return 0
 146789 	}()
 146790 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc = libc.AssignInt32(&bDesc, func() int32 {
 146791 		if idxNum&FTS5_BI_ORDER_DESC != 0 {
 146792 			return 1
 146793 		}
 146794 		return 0
 146795 	}())
 146796 
 146797 	if !(pRowidEq != 0) {
 146798 		goto __28
 146799 	}
 146800 	pRowidLe = libc.AssignUintptr(&pRowidGe, pRowidEq)
 146801 __28:
 146802 	;
 146803 	if !(bDesc != 0) {
 146804 		goto __29
 146805 	}
 146806 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = fts5GetRowidLimit(tls, pRowidLe, int64(0xffffffff)|int64(0x7fffffff)<<32)
 146807 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = fts5GetRowidLimit(tls, pRowidGe, int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32))
 146808 	goto __30
 146809 __29:
 146810 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = fts5GetRowidLimit(tls, pRowidLe, int64(0xffffffff)|int64(0x7fffffff)<<32)
 146811 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = fts5GetRowidLimit(tls, pRowidGe, int64(-1)-(int64(0xffffffff)|int64(0x7fffffff)<<32))
 146812 __30:
 146813 	;
 146814 	if !((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr != 0) {
 146815 		goto __31
 146816 	}
 146817 
 146818 	if !((*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FbDesc != 0) {
 146819 		goto __33
 146820 	}
 146821 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid
 146822 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid
 146823 	goto __34
 146824 __33:
 146825 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiLastRowid
 146826 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid
 146827 __34:
 146828 	;
 146829 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SOURCE
 146830 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FpExpr
 146831 	rc = fts5CursorFirst(tls, pTab, pCsr, bDesc)
 146832 	goto __32
 146833 __31:
 146834 	if !((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr != 0) {
 146835 		goto __35
 146836 	}
 146837 	rc = fts5CursorParseRank(tls, pConfig, pCsr, pRank)
 146838 	if !(rc == SQLITE_OK) {
 146839 		goto __37
 146840 	}
 146841 	if !(bOrderByRank != 0) {
 146842 		goto __38
 146843 	}
 146844 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SORTED_MATCH
 146845 	rc = fts5CursorFirstSorted(tls, pTab, pCsr, bDesc)
 146846 	goto __39
 146847 __38:
 146848 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_MATCH
 146849 	rc = fts5CursorFirst(tls, pTab, pCsr, bDesc)
 146850 __39:
 146851 	;
 146852 __37:
 146853 	;
 146854 	goto __36
 146855 __35:
 146856 	if !((*Fts5Config)(unsafe.Pointer(pConfig)).FzContent == uintptr(0)) {
 146857 		goto __40
 146858 	}
 146859 	*(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls,
 146860 		ts+35565, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 146861 	rc = SQLITE_ERROR
 146862 	goto __41
 146863 __40:
 146864 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = func() int32 {
 146865 		if pRowidEq != 0 {
 146866 			return FTS5_PLAN_ROWID
 146867 		}
 146868 		return FTS5_PLAN_SCAN
 146869 	}()
 146870 	rc = sqlite3Fts5StorageStmt(tls,
 146871 		(*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, fts5StmtType(tls, pCsr), pCsr+48, pTab+8)
 146872 	if !(rc == SQLITE_OK) {
 146873 		goto __42
 146874 	}
 146875 	if !(pRowidEq != uintptr(0)) {
 146876 		goto __43
 146877 	}
 146878 
 146879 	Xsqlite3_bind_value(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 1, pRowidEq)
 146880 	goto __44
 146881 __43:
 146882 	Xsqlite3_bind_int64(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 1, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid)
 146883 	Xsqlite3_bind_int64(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 2, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiLastRowid)
 146884 __44:
 146885 	;
 146886 	rc = fts5NextMethod(tls, pCursor)
 146887 __42:
 146888 	;
 146889 __41:
 146890 	;
 146891 __36:
 146892 	;
 146893 __32:
 146894 	;
 146895 filter_out:
 146896 	sqlite3Fts5ExprFree(tls, *(*uintptr)(unsafe.Pointer(bp + 8)))
 146897 	(*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pzErrmsg
 146898 	return rc
 146899 }
 146900 
 146901 func fts5EofMethod(tls *libc.TLS, pCursor uintptr) int32 {
 146902 	var pCsr uintptr = pCursor
 146903 	return func() int32 {
 146904 		if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_EOF != 0 {
 146905 			return 1
 146906 		}
 146907 		return 0
 146908 	}()
 146909 }
 146910 
 146911 func fts5CursorRowid(tls *libc.TLS, pCsr uintptr) I64 {
 146912 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 {
 146913 		return (*Fts5Sorter)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid
 146914 	} else {
 146915 		return sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 146916 	}
 146917 	return I64(0)
 146918 }
 146919 
 146920 func fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 {
 146921 	var pCsr uintptr = pCursor
 146922 	var ePlan int32 = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan
 146923 
 146924 	switch ePlan {
 146925 	case FTS5_PLAN_SPECIAL:
 146926 		*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0)
 146927 		break
 146928 
 146929 	case FTS5_PLAN_SOURCE:
 146930 		fallthrough
 146931 	case FTS5_PLAN_MATCH:
 146932 		fallthrough
 146933 	case FTS5_PLAN_SORTED_MATCH:
 146934 		*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = fts5CursorRowid(tls, pCsr)
 146935 		break
 146936 
 146937 	default:
 146938 		*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Xsqlite3_column_int64(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 0)
 146939 		break
 146940 	}
 146941 
 146942 	return SQLITE_OK
 146943 }
 146944 
 146945 func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 {
 146946 	bp := tls.Alloc(8)
 146947 	defer tls.Free(8)
 146948 
 146949 	var rc int32 = SQLITE_OK
 146950 
 146951 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0) {
 146952 		var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 146953 		var eStmt int32 = fts5StmtType(tls, pCsr)
 146954 		rc = sqlite3Fts5StorageStmt(tls,
 146955 			(*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, eStmt, pCsr+48, func() uintptr {
 146956 				if bErrormsg != 0 {
 146957 					return pTab + 8
 146958 				}
 146959 				return uintptr(0)
 146960 			}())
 146961 
 146962 	}
 146963 
 146964 	if rc == SQLITE_OK && (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_REQUIRE_CONTENT != 0 {
 146965 		var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 146966 
 146967 		Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt)
 146968 		Xsqlite3_bind_int64(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 1, fts5CursorRowid(tls, pCsr))
 146969 		(*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FbLock++
 146970 		rc = Xsqlite3_step(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt)
 146971 		(*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FbLock--
 146972 		if rc == SQLITE_ROW {
 146973 			rc = SQLITE_OK
 146974 			*(*int32)(unsafe.Pointer(pCsr + 60)) &= libc.CplInt32(FTS5CSR_REQUIRE_CONTENT)
 146975 		} else {
 146976 			rc = Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt)
 146977 			if rc == SQLITE_OK {
 146978 				rc = SQLITE_CORRUPT | int32(1)<<8
 146979 			} else if (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FpzErrmsg != 0 {
 146980 				*(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls,
 146981 					ts+3663, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).Fdb)))
 146982 			}
 146983 		}
 146984 	}
 146985 	return rc
 146986 }
 146987 
 146988 func fts5SetVtabError(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) {
 146989 	var ap Va_list
 146990 	_ = ap
 146991 	ap = va
 146992 
 146993 	(*Fts5FullTable)(unsafe.Pointer(p)).Fp.Fbase.FzErrMsg = Xsqlite3_vmprintf(tls, zFormat, ap)
 146994 	_ = ap
 146995 }
 146996 
 146997 func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) int32 {
 146998 	bp := tls.Alloc(4)
 146999 	defer tls.Free(4)
 147000 
 147001 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 147002 	var rc int32 = SQLITE_OK
 147003 	*(*int32)(unsafe.Pointer(bp)) = 0
 147004 
 147005 	if 0 == Xsqlite3_stricmp(tls, ts+35601, zCmd) {
 147006 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 147007 			fts5SetVtabError(tls, pTab,
 147008 				ts+35612, 0)
 147009 			rc = SQLITE_ERROR
 147010 		} else {
 147011 			rc = sqlite3Fts5StorageDeleteAll(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147012 		}
 147013 	} else if 0 == Xsqlite3_stricmp(tls, ts+35692, zCmd) {
 147014 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NONE {
 147015 			fts5SetVtabError(tls, pTab,
 147016 				ts+35700, 0)
 147017 			rc = SQLITE_ERROR
 147018 		} else {
 147019 			rc = sqlite3Fts5StorageRebuild(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147020 		}
 147021 	} else if 0 == Xsqlite3_stricmp(tls, ts+16934, zCmd) {
 147022 		rc = sqlite3Fts5StorageOptimize(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147023 	} else if 0 == Xsqlite3_stricmp(tls, ts+35756, zCmd) {
 147024 		var nMerge int32 = Xsqlite3_value_int(tls, pVal)
 147025 		rc = sqlite3Fts5StorageMerge(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, nMerge)
 147026 	} else if 0 == Xsqlite3_stricmp(tls, ts+35762, zCmd) {
 147027 		var iArg int32 = Xsqlite3_value_int(tls, pVal)
 147028 		rc = sqlite3Fts5StorageIntegrity(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iArg)
 147029 	} else {
 147030 		rc = sqlite3Fts5IndexLoadConfig(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
 147031 		if rc == SQLITE_OK {
 147032 			rc = sqlite3Fts5ConfigSetValue(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, zCmd, pVal, bp)
 147033 		}
 147034 		if rc == SQLITE_OK {
 147035 			if *(*int32)(unsafe.Pointer(bp)) != 0 {
 147036 				rc = SQLITE_ERROR
 147037 			} else {
 147038 				rc = sqlite3Fts5StorageConfigValue(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zCmd, pVal, 0)
 147039 			}
 147040 		}
 147041 	}
 147042 	return rc
 147043 }
 147044 
 147045 func fts5SpecialDelete(tls *libc.TLS, pTab uintptr, apVal uintptr) int32 {
 147046 	var rc int32 = SQLITE_OK
 147047 	var eType1 int32 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 147048 	if eType1 == SQLITE_INTEGER {
 147049 		var iDel Sqlite3_int64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 147050 		rc = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, apVal+2*4)
 147051 	}
 147052 	return rc
 147053 }
 147054 
 147055 func fts5StorageInsert(tls *libc.TLS, pRc uintptr, pTab uintptr, apVal uintptr, piRowid uintptr) {
 147056 	var rc int32 = *(*int32)(unsafe.Pointer(pRc))
 147057 	if rc == SQLITE_OK {
 147058 		rc = sqlite3Fts5StorageContentInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, piRowid)
 147059 	}
 147060 	if rc == SQLITE_OK {
 147061 		rc = sqlite3Fts5StorageIndexInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, *(*I64)(unsafe.Pointer(piRowid)))
 147062 	}
 147063 	*(*int32)(unsafe.Pointer(pRc)) = rc
 147064 }
 147065 
 147066 func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, pRowid uintptr) int32 {
 147067 	bp := tls.Alloc(20)
 147068 	defer tls.Free(20)
 147069 
 147070 	var pTab uintptr = pVtab
 147071 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 147072 	var eType0 int32
 147073 	*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_OK
 147074 
 147075 	(*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pTab + 8
 147076 
 147077 	fts5TripCursors(tls, pTab)
 147078 
 147079 	eType0 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal)))
 147080 	if eType0 == SQLITE_NULL &&
 147081 		Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*4))) != SQLITE_NULL {
 147082 		var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*4)))
 147083 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL &&
 147084 			0 == Xsqlite3_stricmp(tls, ts+17479, z) {
 147085 			*(*int32)(unsafe.Pointer(bp + 16)) = fts5SpecialDelete(tls, pTab, apVal)
 147086 		} else {
 147087 			*(*int32)(unsafe.Pointer(bp + 16)) = fts5SpecialInsert(tls, pTab, z, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol+1)*4)))
 147088 		}
 147089 	} else {
 147090 		var eConflict int32 = SQLITE_ABORT
 147091 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 147092 			eConflict = Xsqlite3_vtab_on_conflict(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb)
 147093 		}
 147094 
 147095 		if eType0 == SQLITE_INTEGER && fts5IsContentless(tls, pTab) != 0 {
 147096 			(*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls,
 147097 				ts+35778,
 147098 				libc.VaList(bp, func() uintptr {
 147099 					if nArg > 1 {
 147100 						return ts + 20476
 147101 					}
 147102 					return ts + 35815
 147103 				}(), (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 147104 			*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_ERROR
 147105 		} else if nArg == 1 {
 147106 			var iDel I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal)))
 147107 			*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, uintptr(0))
 147108 		} else {
 147109 			var eType1 int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 147110 
 147111 			if eType1 != SQLITE_INTEGER && eType1 != SQLITE_NULL {
 147112 				*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_MISMATCH
 147113 			} else if eType0 != SQLITE_INTEGER {
 147114 				if eConflict == SQLITE_REPLACE && eType1 == SQLITE_INTEGER {
 147115 					var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 147116 					*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0))
 147117 				}
 147118 				fts5StorageInsert(tls, bp+16, pTab, apVal, pRowid)
 147119 			} else {
 147120 				var iOld I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal)))
 147121 				var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 147122 				if eType1 == SQLITE_INTEGER && iOld != iNew {
 147123 					if eConflict == SQLITE_REPLACE {
 147124 						*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0))
 147125 						if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 147126 							*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0))
 147127 						}
 147128 						fts5StorageInsert(tls, bp+16, pTab, apVal, pRowid)
 147129 					} else {
 147130 						*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageContentInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, pRowid)
 147131 						if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 147132 							*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0))
 147133 						}
 147134 						if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 147135 							*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageIndexInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, *(*Sqlite_int64)(unsafe.Pointer(pRowid)))
 147136 						}
 147137 					}
 147138 				} else {
 147139 					*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0))
 147140 					fts5StorageInsert(tls, bp+16, pTab, apVal, pRowid)
 147141 				}
 147142 			}
 147143 		}
 147144 	}
 147145 
 147146 	(*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0)
 147147 	return *(*int32)(unsafe.Pointer(bp + 16))
 147148 }
 147149 
 147150 func fts5SyncMethod(tls *libc.TLS, pVtab uintptr) int32 {
 147151 	var rc int32
 147152 	var pTab uintptr = pVtab
 147153 
 147154 	(*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pTab + 8
 147155 	fts5TripCursors(tls, pTab)
 147156 	rc = sqlite3Fts5StorageSync(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147157 	(*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0)
 147158 	return rc
 147159 }
 147160 
 147161 func fts5BeginMethod(tls *libc.TLS, pVtab uintptr) int32 {
 147162 	fts5NewTransaction(tls, pVtab)
 147163 	return SQLITE_OK
 147164 }
 147165 
 147166 func fts5CommitMethod(tls *libc.TLS, pVtab uintptr) int32 {
 147167 	_ = pVtab
 147168 
 147169 	return SQLITE_OK
 147170 }
 147171 
 147172 func fts5RollbackMethod(tls *libc.TLS, pVtab uintptr) int32 {
 147173 	var rc int32
 147174 	var pTab uintptr = pVtab
 147175 
 147176 	rc = sqlite3Fts5StorageRollback(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147177 	return rc
 147178 }
 147179 
 147180 func fts5ApiUserData(tls *libc.TLS, pCtx uintptr) uintptr {
 147181 	var pCsr uintptr = pCtx
 147182 	return (*Fts5Auxiliary)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAux)).FpUserData
 147183 }
 147184 
 147185 func fts5ApiColumnCount(tls *libc.TLS, pCtx uintptr) int32 {
 147186 	var pCsr uintptr = pCtx
 147187 	return (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FnCol
 147188 }
 147189 
 147190 func fts5ApiColumnTotalSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) int32 {
 147191 	var pCsr uintptr = pCtx
 147192 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 147193 	return sqlite3Fts5StorageSize(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iCol, pnToken)
 147194 }
 147195 
 147196 func fts5ApiRowCount(tls *libc.TLS, pCtx uintptr, pnRow uintptr) int32 {
 147197 	var pCsr uintptr = pCtx
 147198 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 147199 	return sqlite3Fts5StorageRowCount(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, pnRow)
 147200 }
 147201 
 147202 func fts5ApiTokenize(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pUserData uintptr, xToken uintptr) int32 {
 147203 	var pCsr uintptr = pCtx
 147204 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 147205 	return sqlite3Fts5Tokenize(tls,
 147206 		(*Fts5Table)(unsafe.Pointer(pTab)).FpConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken)
 147207 }
 147208 
 147209 func fts5ApiPhraseCount(tls *libc.TLS, pCtx uintptr) int32 {
 147210 	var pCsr uintptr = pCtx
 147211 	return sqlite3Fts5ExprPhraseCount(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 147212 }
 147213 
 147214 func fts5ApiPhraseSize(tls *libc.TLS, pCtx uintptr, iPhrase int32) int32 {
 147215 	var pCsr uintptr = pCtx
 147216 	return sqlite3Fts5ExprPhraseSize(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase)
 147217 }
 147218 
 147219 func fts5ApiColumnText(tls *libc.TLS, pCtx uintptr, iCol int32, pz uintptr, pn uintptr) int32 {
 147220 	var rc int32 = SQLITE_OK
 147221 	var pCsr uintptr = pCtx
 147222 	if fts5IsContentless(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab) != 0 ||
 147223 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SPECIAL {
 147224 		*(*uintptr)(unsafe.Pointer(pz)) = uintptr(0)
 147225 		*(*int32)(unsafe.Pointer(pn)) = 0
 147226 	} else {
 147227 		rc = fts5SeekCursor(tls, pCsr, 0)
 147228 		if rc == SQLITE_OK {
 147229 			*(*uintptr)(unsafe.Pointer(pz)) = Xsqlite3_column_text(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, iCol+1)
 147230 			*(*int32)(unsafe.Pointer(pn)) = Xsqlite3_column_bytes(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, iCol+1)
 147231 		}
 147232 	}
 147233 	return rc
 147234 }
 147235 
 147236 func fts5CsrPoslist(tls *libc.TLS, pCsr uintptr, iPhrase int32, pa uintptr, pn uintptr) int32 {
 147237 	bp := tls.Alloc(8)
 147238 	defer tls.Free(8)
 147239 
 147240 	var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig
 147241 	var rc int32 = SQLITE_OK
 147242 	var bLive int32 = libc.Bool32((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter == uintptr(0))
 147243 
 147244 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_REQUIRE_POSLIST != 0 {
 147245 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL {
 147246 			var aPopulator uintptr
 147247 			var i int32
 147248 			aPopulator = sqlite3Fts5ExprClearPoslists(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, bLive)
 147249 			if aPopulator == uintptr(0) {
 147250 				rc = SQLITE_NOMEM
 147251 			}
 147252 			for i = 0; i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol && rc == SQLITE_OK; i++ {
 147253 				rc = fts5ApiColumnText(tls, pCsr, i, bp, bp+4)
 147254 				if rc == SQLITE_OK {
 147255 					rc = sqlite3Fts5ExprPopulatePoslists(tls,
 147256 						pConfig, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, aPopulator, i, *(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)))
 147257 				}
 147258 			}
 147259 			Xsqlite3_free(tls, aPopulator)
 147260 
 147261 			if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 {
 147262 				sqlite3Fts5ExprCheckPoslists(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5Sorter)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid)
 147263 			}
 147264 		}
 147265 		*(*int32)(unsafe.Pointer(pCsr + 60)) &= libc.CplInt32(FTS5CSR_REQUIRE_POSLIST)
 147266 	}
 147267 
 147268 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 && (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL {
 147269 		var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter
 147270 		var i1 int32 = func() int32 {
 147271 			if iPhrase == 0 {
 147272 				return 0
 147273 			}
 147274 			return *(*int32)(unsafe.Pointer(pSorter + 24 + uintptr(iPhrase-1)*4))
 147275 		}()
 147276 		*(*int32)(unsafe.Pointer(pn)) = *(*int32)(unsafe.Pointer(pSorter + 24 + uintptr(iPhrase)*4)) - i1
 147277 		*(*uintptr)(unsafe.Pointer(pa)) = (*Fts5Sorter)(unsafe.Pointer(pSorter)).FaPoslist + uintptr(i1)
 147278 	} else {
 147279 		*(*int32)(unsafe.Pointer(pn)) = sqlite3Fts5ExprPoslist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, pa)
 147280 	}
 147281 
 147282 	return rc
 147283 }
 147284 
 147285 func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 {
 147286 	bp := tls.Alloc(12)
 147287 	defer tls.Free(12)
 147288 
 147289 	*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 147290 	var aIter uintptr
 147291 	var nIter int32
 147292 	var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FnCol
 147293 
 147294 	nIter = sqlite3Fts5ExprPhraseCount(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 147295 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter == uintptr(0) {
 147296 		var nByte Sqlite3_int64 = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5PoslistReader{})) * uint32(nIter))
 147297 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter = sqlite3Fts5MallocZero(tls, bp, nByte)
 147298 	}
 147299 	aIter = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInstIter
 147300 
 147301 	if aIter != 0 {
 147302 		var nInst int32 = 0
 147303 		var i int32
 147304 
 147305 		for i = 0; i < nIter && *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK; i++ {
 147306 			*(*int32)(unsafe.Pointer(bp)) = fts5CsrPoslist(tls, pCsr, i, bp+4, bp+8)
 147307 			if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 147308 				sqlite3Fts5PoslistReaderInit(tls, *(*uintptr)(unsafe.Pointer(bp + 4)), *(*int32)(unsafe.Pointer(bp + 8)), aIter+uintptr(i)*24)
 147309 			}
 147310 		}
 147311 
 147312 		if *(*int32)(unsafe.Pointer(bp)) == SQLITE_OK {
 147313 			for 1 != 0 {
 147314 				var aInst uintptr
 147315 				var iBest int32 = -1
 147316 				for i = 0; i < nIter; i++ {
 147317 					if int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FbEof) == 0 &&
 147318 						(iBest < 0 || (*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(i)*24)).FiPos < (*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*24)).FiPos) {
 147319 						iBest = i
 147320 					}
 147321 				}
 147322 				if iBest < 0 {
 147323 					break
 147324 				}
 147325 
 147326 				nInst++
 147327 				if nInst >= (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc {
 147328 					var nNewSize int32
 147329 					if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc != 0 {
 147330 						nNewSize = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc * 2
 147331 					} else {
 147332 						nNewSize = 32
 147333 					}
 147334 					aInst = Xsqlite3_realloc64(tls,
 147335 						(*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst, uint64(uint32(nNewSize)*uint32(unsafe.Sizeof(int32(0)))*uint32(3)))
 147336 					if aInst != 0 {
 147337 						(*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst = aInst
 147338 						(*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstAlloc = nNewSize
 147339 					} else {
 147340 						nInst--
 147341 						*(*int32)(unsafe.Pointer(bp)) = SQLITE_NOMEM
 147342 						break
 147343 					}
 147344 				}
 147345 
 147346 				aInst = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(3*(nInst-1))*4
 147347 				*(*int32)(unsafe.Pointer(aInst)) = iBest
 147348 				*(*int32)(unsafe.Pointer(aInst + 1*4)) = int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*24)).FiPos >> 32)
 147349 				*(*int32)(unsafe.Pointer(aInst + 2*4)) = int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*24)).FiPos & int64(0x7FFFFFFF))
 147350 				if *(*int32)(unsafe.Pointer(aInst + 1*4)) < 0 || *(*int32)(unsafe.Pointer(aInst + 1*4)) >= nCol {
 147351 					*(*int32)(unsafe.Pointer(bp)) = SQLITE_CORRUPT | int32(1)<<8
 147352 					break
 147353 				}
 147354 				sqlite3Fts5PoslistReaderNext(tls, aIter+uintptr(iBest)*24)
 147355 			}
 147356 		}
 147357 
 147358 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount = nInst
 147359 		*(*int32)(unsafe.Pointer(pCsr + 60)) &= libc.CplInt32(FTS5CSR_REQUIRE_INST)
 147360 	}
 147361 	return *(*int32)(unsafe.Pointer(bp))
 147362 }
 147363 
 147364 func fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) int32 {
 147365 	var pCsr uintptr = pCtx
 147366 	var rc int32 = SQLITE_OK
 147367 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_REQUIRE_INST == 0 ||
 147368 		SQLITE_OK == libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)) {
 147369 		*(*int32)(unsafe.Pointer(pnInst)) = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount
 147370 	}
 147371 	return rc
 147372 }
 147373 
 147374 func fts5ApiInst(tls *libc.TLS, pCtx uintptr, iIdx int32, piPhrase uintptr, piCol uintptr, piOff uintptr) int32 {
 147375 	var pCsr uintptr = pCtx
 147376 	var rc int32 = SQLITE_OK
 147377 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_REQUIRE_INST == 0 ||
 147378 		SQLITE_OK == libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)) {
 147379 		if iIdx < 0 || iIdx >= (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount {
 147380 			rc = SQLITE_RANGE
 147381 		} else {
 147382 			*(*int32)(unsafe.Pointer(piPhrase)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*3)*4))
 147383 			*(*int32)(unsafe.Pointer(piCol)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*3+1)*4))
 147384 			*(*int32)(unsafe.Pointer(piOff)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*3+2)*4))
 147385 		}
 147386 	}
 147387 	return rc
 147388 }
 147389 
 147390 func fts5ApiRowid(tls *libc.TLS, pCtx uintptr) Sqlite3_int64 {
 147391 	return fts5CursorRowid(tls, pCtx)
 147392 }
 147393 
 147394 func fts5ColumnSizeCb(tls *libc.TLS, pContext uintptr, tflags int32, pUnused uintptr, nUnused int32, iUnused1 int32, iUnused2 int32) int32 {
 147395 	var pCnt uintptr = pContext
 147396 	_ = pUnused
 147397 	_ = nUnused
 147398 	_ = iUnused1
 147399 	_ = iUnused2
 147400 	if tflags&FTS5_TOKEN_COLOCATED == 0 {
 147401 		*(*int32)(unsafe.Pointer(pCnt))++
 147402 	}
 147403 	return SQLITE_OK
 147404 }
 147405 
 147406 func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) int32 {
 147407 	bp := tls.Alloc(8)
 147408 	defer tls.Free(8)
 147409 
 147410 	var pCsr uintptr = pCtx
 147411 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 147412 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 147413 	var rc int32 = SQLITE_OK
 147414 
 147415 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&FTS5CSR_REQUIRE_DOCSIZE != 0 {
 147416 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 147417 			var iRowid I64 = fts5CursorRowid(tls, pCsr)
 147418 			rc = sqlite3Fts5StorageDocsize(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iRowid, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize)
 147419 		} else if (*Fts5Config)(unsafe.Pointer(pConfig)).FzContent == uintptr(0) {
 147420 			var i int32
 147421 			for i = 0; i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 147422 				if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 {
 147423 					*(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4)) = -1
 147424 				}
 147425 			}
 147426 		} else {
 147427 			var i int32
 147428 			for i = 0; rc == SQLITE_OK && i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 147429 				if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 {
 147430 					var p uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4
 147431 					*(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4)) = 0
 147432 					rc = fts5ApiColumnText(tls, pCtx, i, bp, bp+4)
 147433 					if rc == SQLITE_OK {
 147434 						rc = sqlite3Fts5Tokenize(tls,
 147435 							pConfig, FTS5_TOKENIZE_AUX, *(*uintptr)(unsafe.Pointer(bp)), *(*int32)(unsafe.Pointer(bp + 4)), p, *(*uintptr)(unsafe.Pointer(&struct {
 147436 								f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 147437 							}{fts5ColumnSizeCb})))
 147438 					}
 147439 				}
 147440 			}
 147441 		}
 147442 		*(*int32)(unsafe.Pointer(pCsr + 60)) &= libc.CplInt32(FTS5CSR_REQUIRE_DOCSIZE)
 147443 	}
 147444 	if iCol < 0 {
 147445 		var i int32
 147446 		*(*int32)(unsafe.Pointer(pnToken)) = 0
 147447 		for i = 0; i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 147448 			*(*int32)(unsafe.Pointer(pnToken)) += *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4))
 147449 		}
 147450 	} else if iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol {
 147451 		*(*int32)(unsafe.Pointer(pnToken)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(iCol)*4))
 147452 	} else {
 147453 		*(*int32)(unsafe.Pointer(pnToken)) = 0
 147454 		rc = SQLITE_RANGE
 147455 	}
 147456 	return rc
 147457 }
 147458 
 147459 func fts5ApiSetAuxdata(tls *libc.TLS, pCtx uintptr, pPtr uintptr, xDelete uintptr) int32 {
 147460 	bp := tls.Alloc(4)
 147461 	defer tls.Free(4)
 147462 
 147463 	var pCsr uintptr = pCtx
 147464 	var pData uintptr
 147465 
 147466 	for pData = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata; pData != 0; pData = (*Fts5Auxdata)(unsafe.Pointer(pData)).FpNext {
 147467 		if (*Fts5Auxdata)(unsafe.Pointer(pData)).FpAux == (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAux {
 147468 			break
 147469 		}
 147470 	}
 147471 
 147472 	if pData != 0 {
 147473 		if (*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete != 0 {
 147474 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete})).f(tls, (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr)
 147475 		}
 147476 	} else {
 147477 		*(*int32)(unsafe.Pointer(bp)) = SQLITE_OK
 147478 		pData = sqlite3Fts5MallocZero(tls, bp, int64(unsafe.Sizeof(Fts5Auxdata{})))
 147479 		if pData == uintptr(0) {
 147480 			if xDelete != 0 {
 147481 				(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{xDelete})).f(tls, pPtr)
 147482 			}
 147483 			return *(*int32)(unsafe.Pointer(bp))
 147484 		}
 147485 		(*Fts5Auxdata)(unsafe.Pointer(pData)).FpAux = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAux
 147486 		(*Fts5Auxdata)(unsafe.Pointer(pData)).FpNext = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata
 147487 		(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata = pData
 147488 	}
 147489 
 147490 	(*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete = xDelete
 147491 	(*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr = pPtr
 147492 	return SQLITE_OK
 147493 }
 147494 
 147495 func fts5ApiGetAuxdata(tls *libc.TLS, pCtx uintptr, bClear int32) uintptr {
 147496 	var pCsr uintptr = pCtx
 147497 	var pData uintptr
 147498 	var pRet uintptr = uintptr(0)
 147499 
 147500 	for pData = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata; pData != 0; pData = (*Fts5Auxdata)(unsafe.Pointer(pData)).FpNext {
 147501 		if (*Fts5Auxdata)(unsafe.Pointer(pData)).FpAux == (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAux {
 147502 			break
 147503 		}
 147504 	}
 147505 
 147506 	if pData != 0 {
 147507 		pRet = (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr
 147508 		if bClear != 0 {
 147509 			(*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr = uintptr(0)
 147510 			(*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete = uintptr(0)
 147511 		}
 147512 	}
 147513 
 147514 	return pRet
 147515 }
 147516 
 147517 func fts5ApiPhraseNext(tls *libc.TLS, pUnused uintptr, pIter uintptr, piCol uintptr, piOff uintptr) {
 147518 	bp := tls.Alloc(4)
 147519 	defer tls.Free(4)
 147520 
 147521 	_ = pUnused
 147522 	if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb {
 147523 		*(*int32)(unsafe.Pointer(piCol)) = -1
 147524 		*(*int32)(unsafe.Pointer(piOff)) = -1
 147525 	} else {
 147526 		*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
 147527 		if *(*int32)(unsafe.Pointer(bp)) == 1 {
 147528 			*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
 147529 			*(*int32)(unsafe.Pointer(piCol)) = *(*int32)(unsafe.Pointer(bp))
 147530 			*(*int32)(unsafe.Pointer(piOff)) = 0
 147531 			*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
 147532 		}
 147533 		*(*int32)(unsafe.Pointer(piOff)) += *(*int32)(unsafe.Pointer(bp)) - 2
 147534 	}
 147535 }
 147536 
 147537 func fts5ApiPhraseFirst(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintptr, piCol uintptr, piOff uintptr) int32 {
 147538 	bp := tls.Alloc(4)
 147539 	defer tls.Free(4)
 147540 
 147541 	var pCsr uintptr = pCtx
 147542 
 147543 	var rc int32 = fts5CsrPoslist(tls, pCsr, iPhrase, pIter, bp)
 147544 	if rc == SQLITE_OK {
 147545 		(*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = func() uintptr {
 147546 			if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 {
 147547 				return (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp)))
 147548 			}
 147549 			return uintptr(0)
 147550 		}()
 147551 		*(*int32)(unsafe.Pointer(piCol)) = 0
 147552 		*(*int32)(unsafe.Pointer(piOff)) = 0
 147553 		fts5ApiPhraseNext(tls, pCtx, pIter, piCol, piOff)
 147554 	}
 147555 	return rc
 147556 }
 147557 
 147558 func fts5ApiPhraseNextColumn(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol uintptr) {
 147559 	bp := tls.Alloc(8)
 147560 	defer tls.Free(8)
 147561 
 147562 	var pCsr uintptr = pCtx
 147563 	var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig
 147564 
 147565 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS {
 147566 		if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb {
 147567 			*(*int32)(unsafe.Pointer(piCol)) = -1
 147568 		} else {
 147569 			*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
 147570 			*(*int32)(unsafe.Pointer(piCol)) += *(*int32)(unsafe.Pointer(bp)) - 2
 147571 		}
 147572 	} else {
 147573 		for 1 != 0 {
 147574 			if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb {
 147575 				*(*int32)(unsafe.Pointer(piCol)) = -1
 147576 				return
 147577 			}
 147578 			if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == 0x01 {
 147579 				break
 147580 			}
 147581 			*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp+4))
 147582 		}
 147583 		*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(1 + sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1, piCol))
 147584 	}
 147585 }
 147586 
 147587 func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintptr, piCol uintptr) int32 {
 147588 	bp := tls.Alloc(8)
 147589 	defer tls.Free(8)
 147590 
 147591 	var rc int32 = SQLITE_OK
 147592 	var pCsr uintptr = pCtx
 147593 	var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig
 147594 
 147595 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS {
 147596 		var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter
 147597 
 147598 		if pSorter != 0 {
 147599 			var i1 int32 = func() int32 {
 147600 				if iPhrase == 0 {
 147601 					return 0
 147602 				}
 147603 				return *(*int32)(unsafe.Pointer(pSorter + 24 + uintptr(iPhrase-1)*4))
 147604 			}()
 147605 			*(*int32)(unsafe.Pointer(bp)) = *(*int32)(unsafe.Pointer(pSorter + 24 + uintptr(iPhrase)*4)) - i1
 147606 			(*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa = (*Fts5Sorter)(unsafe.Pointer(pSorter)).FaPoslist + uintptr(i1)
 147607 		} else {
 147608 			rc = sqlite3Fts5ExprPhraseCollist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, pIter, bp)
 147609 		}
 147610 		if rc == SQLITE_OK {
 147611 			(*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = func() uintptr {
 147612 				if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 {
 147613 					return (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp)))
 147614 				}
 147615 				return uintptr(0)
 147616 			}()
 147617 			*(*int32)(unsafe.Pointer(piCol)) = 0
 147618 			fts5ApiPhraseNextColumn(tls, pCtx, pIter, piCol)
 147619 		}
 147620 	} else {
 147621 		rc = fts5CsrPoslist(tls, pCsr, iPhrase, pIter, bp+4)
 147622 		if rc == SQLITE_OK {
 147623 			(*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = func() uintptr {
 147624 				if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 {
 147625 					return (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp + 4)))
 147626 				}
 147627 				return uintptr(0)
 147628 			}()
 147629 			if *(*int32)(unsafe.Pointer(bp + 4)) <= 0 {
 147630 				*(*int32)(unsafe.Pointer(piCol)) = -1
 147631 			} else if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == 0x01 {
 147632 				*(*uintptr)(unsafe.Pointer(pIter)) += uintptr(1 + sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1, piCol))
 147633 			} else {
 147634 				*(*int32)(unsafe.Pointer(piCol)) = 0
 147635 			}
 147636 		}
 147637 	}
 147638 
 147639 	return rc
 147640 }
 147641 
 147642 var sFts5Api = Fts5ExtensionApi{
 147643 	FiVersion:           2,
 147644 	FxUserData:          0,
 147645 	FxColumnCount:       0,
 147646 	FxRowCount:          0,
 147647 	FxColumnTotalSize:   0,
 147648 	FxTokenize:          0,
 147649 	FxPhraseCount:       0,
 147650 	FxPhraseSize:        0,
 147651 	FxInstCount:         0,
 147652 	FxInst:              0,
 147653 	FxRowid:             0,
 147654 	FxColumnText:        0,
 147655 	FxColumnSize:        0,
 147656 	FxQueryPhrase:       0,
 147657 	FxSetAuxdata:        0,
 147658 	FxGetAuxdata:        0,
 147659 	FxPhraseFirst:       0,
 147660 	FxPhraseNext:        0,
 147661 	FxPhraseFirstColumn: 0,
 147662 	FxPhraseNextColumn:  0,
 147663 }
 147664 
 147665 func fts5ApiQueryPhrase(tls *libc.TLS, pCtx uintptr, iPhrase int32, pUserData uintptr, xCallback uintptr) int32 {
 147666 	bp := tls.Alloc(4)
 147667 	defer tls.Free(4)
 147668 
 147669 	var pCsr uintptr = pCtx
 147670 	var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 147671 	var rc int32
 147672 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 147673 
 147674 	rc = fts5OpenMethod(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, bp)
 147675 	if rc == SQLITE_OK {
 147676 		(*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FePlan = FTS5_PLAN_MATCH
 147677 		(*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FiFirstRowid = int64(-1) - (int64(0xffffffff) | int64(0x7fffffff)<<32)
 147678 		(*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).FiLastRowid = int64(0xffffffff) | int64(0x7fffffff)<<32
 147679 		(*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fbase.FpVtab = pTab
 147680 		rc = sqlite3Fts5ExprClonePhrase(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, *(*uintptr)(unsafe.Pointer(bp))+52)
 147681 	}
 147682 
 147683 	if rc == SQLITE_OK {
 147684 		for rc = fts5CursorFirst(tls, pTab, *(*uintptr)(unsafe.Pointer(bp)), 0); rc == SQLITE_OK && (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp)))).Fcsrflags&FTS5CSR_EOF == 0; rc = fts5NextMethod(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 147685 			rc = (*struct {
 147686 				f func(*libc.TLS, uintptr, uintptr, uintptr) int32
 147687 			})(unsafe.Pointer(&struct{ uintptr }{xCallback})).f(tls, uintptr(unsafe.Pointer(&sFts5Api)), *(*uintptr)(unsafe.Pointer(bp)), pUserData)
 147688 			if rc != SQLITE_OK {
 147689 				if rc == SQLITE_DONE {
 147690 					rc = SQLITE_OK
 147691 				}
 147692 				break
 147693 			}
 147694 		}
 147695 	}
 147696 
 147697 	fts5CloseMethod(tls, *(*uintptr)(unsafe.Pointer(bp)))
 147698 	return rc
 147699 }
 147700 
 147701 func fts5ApiInvoke(tls *libc.TLS, pAux uintptr, pCsr uintptr, context uintptr, argc int32, argv uintptr) {
 147702 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAux = pAux
 147703 	(*struct {
 147704 		f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr)
 147705 	})(unsafe.Pointer(&struct{ uintptr }{(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FxFunc})).f(tls, uintptr(unsafe.Pointer(&sFts5Api)), pCsr, context, argc, argv)
 147706 	(*Fts5Cursor)(unsafe.Pointer(pCsr)).FpAux = uintptr(0)
 147707 }
 147708 
 147709 func fts5CursorFromCsrid(tls *libc.TLS, pGlobal uintptr, iCsrId I64) uintptr {
 147710 	var pCsr uintptr
 147711 	for pCsr = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext {
 147712 		if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId == iCsrId {
 147713 			break
 147714 		}
 147715 	}
 147716 	return pCsr
 147717 }
 147718 
 147719 func fts5ApiCallback(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
 147720 	bp := tls.Alloc(8)
 147721 	defer tls.Free(8)
 147722 
 147723 	var pAux uintptr
 147724 	var pCsr uintptr
 147725 	var iCsrId I64
 147726 
 147727 	pAux = Xsqlite3_user_data(tls, context)
 147728 	iCsrId = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))
 147729 
 147730 	pCsr = fts5CursorFromCsrid(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal, iCsrId)
 147731 	if pCsr == uintptr(0) || (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 0 {
 147732 		var zErr uintptr = Xsqlite3_mprintf(tls, ts+35827, libc.VaList(bp, iCsrId))
 147733 		Xsqlite3_result_error(tls, context, zErr, -1)
 147734 		Xsqlite3_free(tls, zErr)
 147735 	} else {
 147736 		fts5ApiInvoke(tls, pAux, pCsr, context, argc-1, argv+1*4)
 147737 	}
 147738 }
 147739 
 147740 func sqlite3Fts5TableFromCsrid(tls *libc.TLS, pGlobal uintptr, iCsrId I64) uintptr {
 147741 	var pCsr uintptr
 147742 	pCsr = fts5CursorFromCsrid(tls, pGlobal, iCsrId)
 147743 	if pCsr != 0 {
 147744 		return (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
 147745 	}
 147746 	return uintptr(0)
 147747 }
 147748 
 147749 func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 {
 147750 	bp := tls.Alloc(40)
 147751 	defer tls.Free(40)
 147752 
 147753 	var i int32
 147754 	*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_OK
 147755 	var nPhrase int32 = sqlite3Fts5ExprPhraseCount(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
 147756 
 147757 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 147758 	switch (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FeDetail {
 147759 	case FTS5_DETAIL_FULL:
 147760 		for i = 0; i < nPhrase-1; i++ {
 147761 			var nByte int32 = sqlite3Fts5ExprPoslist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+12)
 147762 			sqlite3Fts5BufferAppendVarint(tls, bp+16, bp, int64(nByte))
 147763 		}
 147764 
 147765 		for i = 0; i < nPhrase; i++ {
 147766 			var nPoslist int32
 147767 			nPoslist = sqlite3Fts5ExprPoslist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+20)
 147768 			sqlite3Fts5BufferAppendBlob(tls, bp+16, bp, uint32(nPoslist), *(*uintptr)(unsafe.Pointer(bp + 20)))
 147769 		}
 147770 		break
 147771 
 147772 	case FTS5_DETAIL_COLUMNS:
 147773 		for i = 0; *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK && i < nPhrase-1; i++ {
 147774 			*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5ExprPhraseCollist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+24, bp+28)
 147775 			sqlite3Fts5BufferAppendVarint(tls, bp+16, bp, int64(*(*int32)(unsafe.Pointer(bp + 28))))
 147776 		}
 147777 
 147778 		for i = 0; *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK && i < nPhrase; i++ {
 147779 			*(*int32)(unsafe.Pointer(bp + 16)) = sqlite3Fts5ExprPhraseCollist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, i, bp+32, bp+36)
 147780 			sqlite3Fts5BufferAppendBlob(tls, bp+16, bp, uint32(*(*int32)(unsafe.Pointer(bp + 36))), *(*uintptr)(unsafe.Pointer(bp + 32)))
 147781 		}
 147782 		break
 147783 
 147784 	default:
 147785 		break
 147786 	}
 147787 
 147788 	Xsqlite3_result_blob(tls, pCtx, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp)).Fn, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})))
 147789 	return *(*int32)(unsafe.Pointer(bp + 16))
 147790 }
 147791 
 147792 func fts5ColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) int32 {
 147793 	var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab
 147794 	var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
 147795 	var pCsr uintptr = pCursor
 147796 	var rc int32 = SQLITE_OK
 147797 
 147798 	if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SPECIAL {
 147799 		if iCol == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol {
 147800 			Xsqlite3_result_int64(tls, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial)
 147801 		}
 147802 	} else if iCol == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol {
 147803 		Xsqlite3_result_int64(tls, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId)
 147804 	} else if iCol == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol+1 {
 147805 		if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SOURCE {
 147806 			fts5PoslistBlob(tls, pCtx, pCsr)
 147807 		} else if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_MATCH ||
 147808 			(*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SORTED_MATCH {
 147809 			if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank != 0 || SQLITE_OK == libc.AssignInt32(&rc, fts5FindRankFunction(tls, pCsr)) {
 147810 				fts5ApiInvoke(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank, pCsr, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg)
 147811 			}
 147812 		}
 147813 	} else if !(fts5IsContentless(tls, pTab) != 0) {
 147814 		(*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = pTab + 8
 147815 		rc = fts5SeekCursor(tls, pCsr, 1)
 147816 		if rc == SQLITE_OK {
 147817 			Xsqlite3_result_value(tls, pCtx, Xsqlite3_column_value(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, iCol+1))
 147818 		}
 147819 		(*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = uintptr(0)
 147820 	}
 147821 	return rc
 147822 }
 147823 
 147824 func fts5FindFunctionMethod(tls *libc.TLS, pVtab uintptr, nUnused int32, zName uintptr, pxFunc uintptr, ppArg uintptr) int32 {
 147825 	var pTab uintptr = pVtab
 147826 	var pAux uintptr
 147827 
 147828 	_ = nUnused
 147829 	pAux = fts5FindAuxiliary(tls, pTab, zName)
 147830 	if pAux != 0 {
 147831 		*(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct {
 147832 			f func(*libc.TLS, uintptr, int32, uintptr)
 147833 		}{fts5ApiCallback}))
 147834 		*(*uintptr)(unsafe.Pointer(ppArg)) = pAux
 147835 		return 1
 147836 	}
 147837 
 147838 	return 0
 147839 }
 147840 
 147841 func fts5RenameMethod(tls *libc.TLS, pVtab uintptr, zName uintptr) int32 {
 147842 	var pTab uintptr = pVtab
 147843 	return sqlite3Fts5StorageRename(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zName)
 147844 }
 147845 
 147846 func sqlite3Fts5FlushToDisk(tls *libc.TLS, pTab uintptr) int32 {
 147847 	fts5TripCursors(tls, pTab)
 147848 	return sqlite3Fts5StorageSync(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147849 }
 147850 
 147851 func fts5SavepointMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 {
 147852 	_ = iSavepoint
 147853 
 147854 	return sqlite3Fts5FlushToDisk(tls, pVtab)
 147855 }
 147856 
 147857 func fts5ReleaseMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 {
 147858 	_ = iSavepoint
 147859 
 147860 	return sqlite3Fts5FlushToDisk(tls, pVtab)
 147861 }
 147862 
 147863 func fts5RollbackToMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 {
 147864 	var pTab uintptr = pVtab
 147865 	_ = iSavepoint
 147866 
 147867 	fts5TripCursors(tls, pTab)
 147868 	return sqlite3Fts5StorageRollback(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
 147869 }
 147870 
 147871 func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, xFunc Fts5_extension_function, xDestroy uintptr) int32 {
 147872 	var pGlobal uintptr = pApi
 147873 	var rc int32 = Xsqlite3_overload_function(tls, (*Fts5Global)(unsafe.Pointer(pGlobal)).Fdb, zName, -1)
 147874 	if rc == SQLITE_OK {
 147875 		var pAux uintptr
 147876 		var nName Sqlite3_int64
 147877 		var nByte Sqlite3_int64
 147878 
 147879 		nName = Sqlite3_int64(libc.Xstrlen(tls, zName) + Size_t(1))
 147880 		nByte = Sqlite3_int64(unsafe.Sizeof(Fts5Auxiliary{})) + nName
 147881 		pAux = Xsqlite3_malloc64(tls, uint64(nByte))
 147882 		if pAux != 0 {
 147883 			libc.Xmemset(tls, pAux, 0, Size_t(nByte))
 147884 			(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = pAux + 1*24
 147885 			libc.Xmemcpy(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc, zName, uint32(nName))
 147886 			(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal = pGlobal
 147887 			(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData = pUserData
 147888 			(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FxFunc = xFunc
 147889 			(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy = xDestroy
 147890 			(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux
 147891 			(*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux = pAux
 147892 		} else {
 147893 			rc = SQLITE_NOMEM
 147894 		}
 147895 	}
 147896 
 147897 	return rc
 147898 }
 147899 
 147900 func fts5CreateTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, pTokenizer uintptr, xDestroy uintptr) int32 {
 147901 	var pGlobal uintptr = pApi
 147902 	var pNew uintptr
 147903 	var nName Sqlite3_int64
 147904 	var nByte Sqlite3_int64
 147905 	var rc int32 = SQLITE_OK
 147906 
 147907 	nName = Sqlite3_int64(libc.Xstrlen(tls, zName) + Size_t(1))
 147908 	nByte = Sqlite3_int64(unsafe.Sizeof(Fts5TokenizerModule{})) + nName
 147909 	pNew = Xsqlite3_malloc64(tls, uint64(nByte))
 147910 	if pNew != 0 {
 147911 		libc.Xmemset(tls, pNew, 0, Size_t(nByte))
 147912 		(*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = pNew + 1*28
 147913 		libc.Xmemcpy(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName, zName, uint32(nName))
 147914 		(*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FpUserData = pUserData
 147915 		(*Fts5TokenizerModule)(unsafe.Pointer(pNew)).Fx = *(*Fts5_tokenizer)(unsafe.Pointer(pTokenizer))
 147916 		(*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FxDestroy = xDestroy
 147917 		(*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpTok
 147918 		(*Fts5Global)(unsafe.Pointer(pGlobal)).FpTok = pNew
 147919 		if (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FpNext == uintptr(0) {
 147920 			(*Fts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok = pNew
 147921 		}
 147922 	} else {
 147923 		rc = SQLITE_NOMEM
 147924 	}
 147925 
 147926 	return rc
 147927 }
 147928 
 147929 func fts5LocateTokenizer(tls *libc.TLS, pGlobal uintptr, zName uintptr) uintptr {
 147930 	var pMod uintptr = uintptr(0)
 147931 
 147932 	if zName == uintptr(0) {
 147933 		pMod = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok
 147934 	} else {
 147935 		for pMod = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpTok; pMod != 0; pMod = (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpNext {
 147936 			if Xsqlite3_stricmp(tls, zName, (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FzName) == 0 {
 147937 				break
 147938 			}
 147939 		}
 147940 	}
 147941 
 147942 	return pMod
 147943 }
 147944 
 147945 func fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData uintptr, pTokenizer uintptr) int32 {
 147946 	var rc int32 = SQLITE_OK
 147947 	var pMod uintptr
 147948 
 147949 	pMod = fts5LocateTokenizer(tls, pApi, zName)
 147950 	if pMod != 0 {
 147951 		*(*Fts5_tokenizer)(unsafe.Pointer(pTokenizer)) = (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).Fx
 147952 		*(*uintptr)(unsafe.Pointer(ppUserData)) = (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData
 147953 	} else {
 147954 		libc.Xmemset(tls, pTokenizer, 0, uint32(unsafe.Sizeof(Fts5_tokenizer{})))
 147955 		rc = SQLITE_ERROR
 147956 	}
 147957 
 147958 	return rc
 147959 }
 147960 
 147961 func sqlite3Fts5GetTokenizer(tls *libc.TLS, pGlobal uintptr, azArg uintptr, nArg int32, pConfig uintptr, pzErr uintptr) int32 {
 147962 	bp := tls.Alloc(8)
 147963 	defer tls.Free(8)
 147964 
 147965 	var pMod uintptr
 147966 	var rc int32 = SQLITE_OK
 147967 
 147968 	pMod = fts5LocateTokenizer(tls, pGlobal, func() uintptr {
 147969 		if nArg == 0 {
 147970 			return uintptr(0)
 147971 		}
 147972 		return *(*uintptr)(unsafe.Pointer(azArg))
 147973 	}())
 147974 	if pMod == uintptr(0) {
 147975 		rc = SQLITE_ERROR
 147976 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+35848, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azArg))))
 147977 	} else {
 147978 		rc = (*struct {
 147979 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 147980 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5TokenizerModule)(unsafe.Pointer(pMod)).Fx.FxCreate})).f(tls,
 147981 			(*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, func() uintptr {
 147982 				if azArg != 0 {
 147983 					return azArg + 1*4
 147984 				}
 147985 				return uintptr(0)
 147986 			}(), func() int32 {
 147987 				if nArg != 0 {
 147988 					return nArg - 1
 147989 				}
 147990 				return 0
 147991 			}(), pConfig+56)
 147992 		(*Fts5Config)(unsafe.Pointer(pConfig)).FpTokApi = pMod + 8
 147993 		if rc != SQLITE_OK {
 147994 			if pzErr != 0 {
 147995 				*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+35870, 0)
 147996 			}
 147997 		} else {
 147998 			(*Fts5Config)(unsafe.Pointer(pConfig)).FePattern = sqlite3Fts5TokenizerPattern(tls,
 147999 				(*Fts5TokenizerModule)(unsafe.Pointer(pMod)).Fx.FxCreate, (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok)
 148000 		}
 148001 	}
 148002 
 148003 	if rc != SQLITE_OK {
 148004 		(*Fts5Config)(unsafe.Pointer(pConfig)).FpTokApi = uintptr(0)
 148005 		(*Fts5Config)(unsafe.Pointer(pConfig)).FpTok = uintptr(0)
 148006 	}
 148007 
 148008 	return rc
 148009 }
 148010 
 148011 func fts5ModuleDestroy(tls *libc.TLS, pCtx uintptr) {
 148012 	var pTok uintptr
 148013 	var pNextTok uintptr
 148014 	var pAux uintptr
 148015 	var pNextAux uintptr
 148016 	var pGlobal uintptr = pCtx
 148017 
 148018 	for pAux = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux; pAux != 0; pAux = pNextAux {
 148019 		pNextAux = (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpNext
 148020 		if (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy != 0 {
 148021 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Fts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy})).f(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData)
 148022 		}
 148023 		Xsqlite3_free(tls, pAux)
 148024 	}
 148025 
 148026 	for pTok = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpTok; pTok != 0; pTok = pNextTok {
 148027 		pNextTok = (*Fts5TokenizerModule)(unsafe.Pointer(pTok)).FpNext
 148028 		if (*Fts5TokenizerModule)(unsafe.Pointer(pTok)).FxDestroy != 0 {
 148029 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*Fts5TokenizerModule)(unsafe.Pointer(pTok)).FxDestroy})).f(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pTok)).FpUserData)
 148030 		}
 148031 		Xsqlite3_free(tls, pTok)
 148032 	}
 148033 
 148034 	Xsqlite3_free(tls, pGlobal)
 148035 }
 148036 
 148037 func fts5Fts5Func(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
 148038 	var pGlobal uintptr = Xsqlite3_user_data(tls, pCtx)
 148039 	var ppApi uintptr
 148040 	_ = nArg
 148041 
 148042 	ppApi = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(apArg)), ts+35901)
 148043 	if ppApi != 0 {
 148044 		*(*uintptr)(unsafe.Pointer(ppApi)) = pGlobal
 148045 	}
 148046 }
 148047 
 148048 func fts5SourceIdFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apUnused uintptr) {
 148049 	_ = nArg
 148050 	_ = apUnused
 148051 	Xsqlite3_result_text(tls, pCtx, ts+35914, -1, libc.UintptrFromInt32(-1))
 148052 }
 148053 
 148054 func fts5ShadowName(tls *libc.TLS, zName uintptr) int32 {
 148055 	var i uint32
 148056 	for i = uint32(0); i < uint32(unsafe.Sizeof(azName2))/uint32(unsafe.Sizeof(uintptr(0))); i++ {
 148057 		if Xsqlite3_stricmp(tls, zName, azName2[i]) == 0 {
 148058 			return 1
 148059 		}
 148060 	}
 148061 	return 0
 148062 }
 148063 
 148064 var azName2 = [5]uintptr{
 148065 	ts + 36005, ts + 34104, ts + 25103, ts + 34455, ts + 11488,
 148066 }
 148067 
 148068 func fts5Init(tls *libc.TLS, db uintptr) int32 {
 148069 	var rc int32
 148070 	var pGlobal uintptr = uintptr(0)
 148071 
 148072 	pGlobal = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Global{})))
 148073 	if pGlobal == uintptr(0) {
 148074 		rc = SQLITE_NOMEM
 148075 	} else {
 148076 		var p uintptr = pGlobal
 148077 		libc.Xmemset(tls, pGlobal, 0, uint32(unsafe.Sizeof(Fts5Global{})))
 148078 		(*Fts5Global)(unsafe.Pointer(pGlobal)).Fdb = db
 148079 		(*Fts5Global)(unsafe.Pointer(pGlobal)).Fapi.FiVersion = 2
 148080 		(*Fts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateFunction = *(*uintptr)(unsafe.Pointer(&struct {
 148081 			f func(*libc.TLS, uintptr, uintptr, uintptr, Fts5_extension_function, uintptr) int32
 148082 		}{fts5CreateAux}))
 148083 		(*Fts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxCreateTokenizer = *(*uintptr)(unsafe.Pointer(&struct {
 148084 			f func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32
 148085 		}{fts5CreateTokenizer}))
 148086 		(*Fts5Global)(unsafe.Pointer(pGlobal)).Fapi.FxFindTokenizer = *(*uintptr)(unsafe.Pointer(&struct {
 148087 			f func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32
 148088 		}{fts5FindTokenizer}))
 148089 		rc = Xsqlite3_create_module_v2(tls, db, ts+36012, uintptr(unsafe.Pointer(&fts5Mod)), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5ModuleDestroy})))
 148090 		if rc == SQLITE_OK {
 148091 			rc = sqlite3Fts5IndexInit(tls, db)
 148092 		}
 148093 		if rc == SQLITE_OK {
 148094 			rc = sqlite3Fts5ExprInit(tls, pGlobal, db)
 148095 		}
 148096 		if rc == SQLITE_OK {
 148097 			rc = sqlite3Fts5AuxInit(tls, pGlobal)
 148098 		}
 148099 		if rc == SQLITE_OK {
 148100 			rc = sqlite3Fts5TokenizerInit(tls, pGlobal)
 148101 		}
 148102 		if rc == SQLITE_OK {
 148103 			rc = sqlite3Fts5VocabInit(tls, pGlobal, db)
 148104 		}
 148105 		if rc == SQLITE_OK {
 148106 			rc = Xsqlite3_create_function(tls,
 148107 				db, ts+36012, 1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct {
 148108 					f func(*libc.TLS, uintptr, int32, uintptr)
 148109 				}{fts5Fts5Func})), uintptr(0), uintptr(0))
 148110 		}
 148111 		if rc == SQLITE_OK {
 148112 			rc = Xsqlite3_create_function(tls,
 148113 				db, ts+36017, 0,
 148114 				SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
 148115 				p, *(*uintptr)(unsafe.Pointer(&struct {
 148116 					f func(*libc.TLS, uintptr, int32, uintptr)
 148117 				}{fts5SourceIdFunc})), uintptr(0), uintptr(0))
 148118 		}
 148119 	}
 148120 
 148121 	return rc
 148122 }
 148123 
 148124 var fts5Mod = Sqlite3_module{
 148125 	FiVersion:      3,
 148126 	FxCreate:       0,
 148127 	FxConnect:      0,
 148128 	FxBestIndex:    0,
 148129 	FxDisconnect:   0,
 148130 	FxDestroy:      0,
 148131 	FxOpen:         0,
 148132 	FxClose:        0,
 148133 	FxFilter:       0,
 148134 	FxNext:         0,
 148135 	FxEof:          0,
 148136 	FxColumn:       0,
 148137 	FxRowid:        0,
 148138 	FxUpdate:       0,
 148139 	FxBegin:        0,
 148140 	FxSync:         0,
 148141 	FxCommit:       0,
 148142 	FxRollback:     0,
 148143 	FxFindFunction: 0,
 148144 	FxRename:       0,
 148145 	FxSavepoint:    0,
 148146 	FxRelease:      0,
 148147 	FxRollbackTo:   0,
 148148 	FxShadowName:   0,
 148149 }
 148150 
 148151 // The following functions are used to register the module with SQLite. If
 148152 // this module is being built as part of the SQLite core (SQLITE_CORE is
 148153 // defined), then sqlite3_open() will call sqlite3Fts5Init() directly.
 148154 //
 148155 // Or, if this module is being built as a loadable extension,
 148156 // sqlite3Fts5Init() is omitted and the two standard entry points
 148157 // sqlite3_fts_init() and sqlite3_fts5_init() defined instead.
 148158 func Xsqlite3Fts5Init(tls *libc.TLS, db uintptr) int32 {
 148159 	return fts5Init(tls, db)
 148160 }
 148161 
 148162 func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, pzErrMsg uintptr) int32 {
 148163 	bp := tls.Alloc(172)
 148164 	defer tls.Free(172)
 148165 
 148166 	var rc int32 = SQLITE_OK
 148167 
 148168 	if *(*uintptr)(unsafe.Pointer(p + 28 + uintptr(eStmt)*4)) == uintptr(0) {
 148169 		*(*[11]uintptr)(unsafe.Pointer(bp + 128)) = [11]uintptr{
 148170 			ts + 36032,
 148171 			ts + 36100,
 148172 			ts + 36169,
 148173 			ts + 36202,
 148174 			ts + 36241,
 148175 			ts + 36281,
 148176 			ts + 36320,
 148177 			ts + 36361,
 148178 			ts + 36400,
 148179 			ts + 36442,
 148180 			ts + 36482,
 148181 		}
 148182 		var pC uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148183 		var zSql uintptr = uintptr(0)
 148184 
 148185 		switch eStmt {
 148186 		case FTS5_STMT_SCAN:
 148187 			zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 + uintptr(eStmt)*4)),
 148188 				libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent))
 148189 			break
 148190 			fallthrough
 148191 
 148192 		case FTS5_STMT_SCAN_ASC:
 148193 			fallthrough
 148194 		case FTS5_STMT_SCAN_DESC:
 148195 			zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 + uintptr(eStmt)*4)), libc.VaList(bp+16, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist,
 148196 				(*Fts5Config)(unsafe.Pointer(pC)).FzContent, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid,
 148197 				(*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid))
 148198 			break
 148199 			fallthrough
 148200 
 148201 		case FTS5_STMT_LOOKUP:
 148202 			zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 + uintptr(eStmt)*4)),
 148203 				libc.VaList(bp+56, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid))
 148204 			break
 148205 			fallthrough
 148206 
 148207 		case FTS5_STMT_INSERT_CONTENT:
 148208 			fallthrough
 148209 		case FTS5_STMT_REPLACE_CONTENT:
 148210 			{
 148211 				var nCol int32 = (*Fts5Config)(unsafe.Pointer(pC)).FnCol + 1
 148212 				var zBind uintptr
 148213 				var i int32
 148214 
 148215 				zBind = Xsqlite3_malloc64(tls, uint64(1+nCol*2))
 148216 				if zBind != 0 {
 148217 					for i = 0; i < nCol; i++ {
 148218 						*(*uint8)(unsafe.Pointer(zBind + uintptr(i*2))) = uint8('?')
 148219 						*(*uint8)(unsafe.Pointer(zBind + uintptr(i*2+1))) = uint8(',')
 148220 					}
 148221 					*(*uint8)(unsafe.Pointer(zBind + uintptr(i*2-1))) = uint8(0)
 148222 					zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 + uintptr(eStmt)*4)), libc.VaList(bp+80, (*Fts5Config)(unsafe.Pointer(pC)).FzDb, (*Fts5Config)(unsafe.Pointer(pC)).FzName, zBind))
 148223 					Xsqlite3_free(tls, zBind)
 148224 				}
 148225 				break
 148226 
 148227 			}
 148228 			fallthrough
 148229 
 148230 		default:
 148231 			zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 + uintptr(eStmt)*4)), libc.VaList(bp+104, (*Fts5Config)(unsafe.Pointer(pC)).FzDb, (*Fts5Config)(unsafe.Pointer(pC)).FzName))
 148232 			break
 148233 		}
 148234 
 148235 		if zSql == uintptr(0) {
 148236 			rc = SQLITE_NOMEM
 148237 		} else {
 148238 			var f int32 = SQLITE_PREPARE_PERSISTENT
 148239 			if eStmt > FTS5_STMT_LOOKUP {
 148240 				f = f | SQLITE_PREPARE_NO_VTAB
 148241 			}
 148242 			(*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock++
 148243 			rc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pC)).Fdb, zSql, -1, uint32(f), p+28+uintptr(eStmt)*4, uintptr(0))
 148244 			(*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock--
 148245 			Xsqlite3_free(tls, zSql)
 148246 			if rc != SQLITE_OK && pzErrMsg != 0 {
 148247 				*(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+3663, libc.VaList(bp+120, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pC)).Fdb)))
 148248 			}
 148249 		}
 148250 	}
 148251 
 148252 	*(*uintptr)(unsafe.Pointer(ppStmt)) = *(*uintptr)(unsafe.Pointer(p + 28 + uintptr(eStmt)*4))
 148253 	Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(ppStmt)))
 148254 	return rc
 148255 }
 148256 
 148257 func fts5ExecPrintf(tls *libc.TLS, db uintptr, pzErr uintptr, zFormat uintptr, va uintptr) int32 {
 148258 	var rc int32
 148259 	var ap Va_list
 148260 	_ = ap
 148261 	var zSql uintptr
 148262 
 148263 	ap = va
 148264 	zSql = Xsqlite3_vmprintf(tls, zFormat, ap)
 148265 
 148266 	if zSql == uintptr(0) {
 148267 		rc = SQLITE_NOMEM
 148268 	} else {
 148269 		rc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), pzErr)
 148270 		Xsqlite3_free(tls, zSql)
 148271 	}
 148272 
 148273 	_ = ap
 148274 	return rc
 148275 }
 148276 
 148277 func sqlite3Fts5DropAll(tls *libc.TLS, pConfig uintptr) int32 {
 148278 	bp := tls.Alloc(80)
 148279 	defer tls.Free(80)
 148280 
 148281 	var rc int32 = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0),
 148282 		ts+36505,
 148283 		libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName,
 148284 			(*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName,
 148285 			(*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 148286 	if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148287 		rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0),
 148288 			ts+36609,
 148289 			libc.VaList(bp+48, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 148290 	}
 148291 	if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 148292 		rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0),
 148293 			ts+36647,
 148294 			libc.VaList(bp+64, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 148295 	}
 148296 	return rc
 148297 }
 148298 
 148299 func fts5StorageRenameOne(tls *libc.TLS, pConfig uintptr, pRc uintptr, zTail uintptr, zName uintptr) {
 148300 	bp := tls.Alloc(40)
 148301 	defer tls.Free(40)
 148302 
 148303 	if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {
 148304 		*(*int32)(unsafe.Pointer(pRc)) = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0),
 148305 			ts+36685,
 148306 			libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zTail, zName, zTail))
 148307 	}
 148308 }
 148309 
 148310 func sqlite3Fts5StorageRename(tls *libc.TLS, pStorage uintptr, zName uintptr) int32 {
 148311 	bp := tls.Alloc(4)
 148312 	defer tls.Free(4)
 148313 
 148314 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(pStorage)).FpConfig
 148315 	*(*int32)(unsafe.Pointer(bp)) = sqlite3Fts5StorageSync(tls, pStorage)
 148316 
 148317 	fts5StorageRenameOne(tls, pConfig, bp, ts+25103, zName)
 148318 	fts5StorageRenameOne(tls, pConfig, bp, ts+11488, zName)
 148319 	fts5StorageRenameOne(tls, pConfig, bp, ts+36005, zName)
 148320 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148321 		fts5StorageRenameOne(tls, pConfig, bp, ts+34455, zName)
 148322 	}
 148323 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 148324 		fts5StorageRenameOne(tls, pConfig, bp, ts+34104, zName)
 148325 	}
 148326 	return *(*int32)(unsafe.Pointer(bp))
 148327 }
 148328 
 148329 func sqlite3Fts5CreateTable(tls *libc.TLS, pConfig uintptr, zPost uintptr, zDefn uintptr, bWithout int32, pzErr uintptr) int32 {
 148330 	bp := tls.Alloc(68)
 148331 	defer tls.Free(68)
 148332 
 148333 	var rc int32
 148334 	*(*uintptr)(unsafe.Pointer(bp + 64)) = uintptr(0)
 148335 
 148336 	rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, bp+64, ts+36727,
 148337 		libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, zDefn,
 148338 			func() uintptr {
 148339 				if bWithout != 0 {
 148340 					return ts + 29756
 148341 				}
 148342 				return ts + 1554
 148343 			}()))
 148344 	if *(*uintptr)(unsafe.Pointer(bp + 64)) != 0 {
 148345 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls,
 148346 			ts+36757,
 148347 			libc.VaList(bp+40, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, *(*uintptr)(unsafe.Pointer(bp + 64))))
 148348 		Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 64)))
 148349 	}
 148350 
 148351 	return rc
 148352 }
 148353 
 148354 func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCreate int32, pp uintptr, pzErr uintptr) int32 {
 148355 	bp := tls.Alloc(8)
 148356 	defer tls.Free(8)
 148357 
 148358 	var rc int32 = SQLITE_OK
 148359 	var p uintptr
 148360 	var nByte Sqlite3_int64
 148361 
 148362 	nByte = Sqlite3_int64(uint32(unsafe.Sizeof(Fts5Storage{})) +
 148363 		uint32((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*uint32(unsafe.Sizeof(I64(0))))
 148364 	*(*uintptr)(unsafe.Pointer(pp)) = libc.AssignUintptr(&p, Xsqlite3_malloc64(tls, uint64(nByte)))
 148365 	if !(p != 0) {
 148366 		return SQLITE_NOMEM
 148367 	}
 148368 
 148369 	libc.Xmemset(tls, p, 0, Size_t(nByte))
 148370 	(*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize = p + 1*72
 148371 	(*Fts5Storage)(unsafe.Pointer(p)).FpConfig = pConfig
 148372 	(*Fts5Storage)(unsafe.Pointer(p)).FpIndex = pIndex
 148373 
 148374 	if bCreate != 0 {
 148375 		if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 148376 			var nDefn int32 = 32 + (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol*10
 148377 			var zDefn uintptr = Xsqlite3_malloc64(tls, uint64(int64(32)+Sqlite3_int64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*int64(10)))
 148378 			if zDefn == uintptr(0) {
 148379 				rc = SQLITE_NOMEM
 148380 			} else {
 148381 				var i int32
 148382 				var iOff int32
 148383 				Xsqlite3_snprintf(tls, nDefn, zDefn, ts+36801, 0)
 148384 				iOff = int32(libc.Xstrlen(tls, zDefn))
 148385 				for i = 0; i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 148386 					Xsqlite3_snprintf(tls, nDefn-iOff, zDefn+uintptr(iOff), ts+36824, libc.VaList(bp, i))
 148387 					iOff = iOff + int32(libc.Xstrlen(tls, zDefn+uintptr(iOff)))
 148388 				}
 148389 				rc = sqlite3Fts5CreateTable(tls, pConfig, ts+34104, zDefn, 0, pzErr)
 148390 			}
 148391 			Xsqlite3_free(tls, zDefn)
 148392 		}
 148393 
 148394 		if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148395 			rc = sqlite3Fts5CreateTable(tls,
 148396 				pConfig, ts+34455, ts+36830, 0, pzErr)
 148397 		}
 148398 		if rc == SQLITE_OK {
 148399 			rc = sqlite3Fts5CreateTable(tls,
 148400 				pConfig, ts+36005, ts+36862, 1, pzErr)
 148401 		}
 148402 		if rc == SQLITE_OK {
 148403 			rc = sqlite3Fts5StorageConfigValue(tls, p, ts+34601, uintptr(0), FTS5_CURRENT_VERSION)
 148404 		}
 148405 	}
 148406 
 148407 	if rc != 0 {
 148408 		sqlite3Fts5StorageClose(tls, p)
 148409 		*(*uintptr)(unsafe.Pointer(pp)) = uintptr(0)
 148410 	}
 148411 	return rc
 148412 }
 148413 
 148414 func sqlite3Fts5StorageClose(tls *libc.TLS, p uintptr) int32 {
 148415 	var rc int32 = SQLITE_OK
 148416 	if p != 0 {
 148417 		var i int32
 148418 
 148419 		for i = 0; i < int32(uint32(unsafe.Sizeof([11]uintptr{}))/uint32(unsafe.Sizeof(uintptr(0)))); i++ {
 148420 			Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(p + 28 + uintptr(i)*4)))
 148421 		}
 148422 
 148423 		Xsqlite3_free(tls, p)
 148424 	}
 148425 	return rc
 148426 }
 148427 
 148428 type Fts5InsertCtx1 = struct {
 148429 	FpStorage uintptr
 148430 	FiCol     int32
 148431 	FszCol    int32
 148432 }
 148433 
 148434 type Fts5InsertCtx = Fts5InsertCtx1
 148435 
 148436 func fts5StorageInsertCallback(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) int32 {
 148437 	var pCtx uintptr = pContext
 148438 	var pIdx uintptr = (*Fts5Storage)(unsafe.Pointer((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FpStorage)).FpIndex
 148439 	_ = iUnused1
 148440 	_ = iUnused2
 148441 	if nToken > FTS5_MAX_TOKEN_SIZE {
 148442 		nToken = FTS5_MAX_TOKEN_SIZE
 148443 	}
 148444 	if tflags&FTS5_TOKEN_COLOCATED == 0 || (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0 {
 148445 		(*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol++
 148446 	}
 148447 	return sqlite3Fts5IndexWrite(tls, pIdx, (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FiCol, (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol-1, pToken, nToken)
 148448 }
 148449 
 148450 func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintptr) int32 {
 148451 	bp := tls.Alloc(16)
 148452 	defer tls.Free(16)
 148453 
 148454 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148455 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 148456 	var rc int32
 148457 	var rc2 int32
 148458 	var iCol int32
 148459 
 148460 	if apVal == uintptr(0) {
 148461 		rc = fts5StorageGetStmt(tls, p, FTS5_STMT_LOOKUP, bp, uintptr(0))
 148462 		if rc != SQLITE_OK {
 148463 			return rc
 148464 		}
 148465 		Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, iDel)
 148466 		if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) != SQLITE_ROW {
 148467 			return Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148468 		}
 148469 	}
 148470 
 148471 	(*Fts5InsertCtx)(unsafe.Pointer(bp + 4)).FpStorage = p
 148472 	(*Fts5InsertCtx)(unsafe.Pointer(bp + 4)).FiCol = -1
 148473 	rc = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 1, iDel)
 148474 	for iCol = 1; rc == SQLITE_OK && iCol <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; iCol++ {
 148475 		if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(iCol-1)))) == 0 {
 148476 			var zText uintptr
 148477 			var nText int32
 148478 
 148479 			if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 148480 				zText = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp)), iCol)
 148481 				nText = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp)), iCol)
 148482 			} else if apVal != 0 {
 148483 				zText = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(iCol-1)*4)))
 148484 				nText = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(iCol-1)*4)))
 148485 			} else {
 148486 				continue
 148487 			}
 148488 			(*Fts5InsertCtx)(unsafe.Pointer(bp + 4)).FszCol = 0
 148489 			rc = sqlite3Fts5Tokenize(tls, pConfig, FTS5_TOKENIZE_DOCUMENT,
 148490 				zText, nText, bp+4, *(*uintptr)(unsafe.Pointer(&struct {
 148491 					f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 148492 				}{fts5StorageInsertCallback})))
 148493 			*(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol-1)*8)) -= I64((*Fts5InsertCtx)(unsafe.Pointer(bp + 4)).FszCol)
 148494 			if *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol-1)*8)) < int64(0) {
 148495 				rc = SQLITE_CORRUPT | int32(1)<<8
 148496 			}
 148497 		}
 148498 	}
 148499 	if rc == SQLITE_OK && (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow < int64(1) {
 148500 		rc = SQLITE_CORRUPT | int32(1)<<8
 148501 	} else {
 148502 		(*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow--
 148503 	}
 148504 
 148505 	rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148506 	if rc == SQLITE_OK {
 148507 		rc = rc2
 148508 	}
 148509 	return rc
 148510 }
 148511 
 148512 func fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid I64, pBuf uintptr) int32 {
 148513 	bp := tls.Alloc(4)
 148514 	defer tls.Free(4)
 148515 
 148516 	var rc int32 = SQLITE_OK
 148517 	if (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 {
 148518 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 148519 		rc = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_DOCSIZE, bp, uintptr(0))
 148520 		if rc == SQLITE_OK {
 148521 			Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, iRowid)
 148522 			Xsqlite3_bind_blob(tls, *(*uintptr)(unsafe.Pointer(bp)), 2, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, uintptr(0))
 148523 			Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148524 			rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148525 			Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp)), 2)
 148526 		}
 148527 	}
 148528 	return rc
 148529 }
 148530 
 148531 func fts5StorageLoadTotals(tls *libc.TLS, p uintptr, bCache int32) int32 {
 148532 	var rc int32 = SQLITE_OK
 148533 	if (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid == 0 {
 148534 		rc = sqlite3Fts5IndexGetAverages(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, p+16, (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize)
 148535 		(*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = bCache
 148536 	}
 148537 	return rc
 148538 }
 148539 
 148540 func fts5StorageSaveTotals(tls *libc.TLS, p uintptr) int32 {
 148541 	bp := tls.Alloc(16)
 148542 	defer tls.Free(16)
 148543 
 148544 	var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol
 148545 	var i int32
 148546 
 148547 	*(*int32)(unsafe.Pointer(bp + 12)) = SQLITE_OK
 148548 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 148549 
 148550 	sqlite3Fts5BufferAppendVarint(tls, bp+12, bp, (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow)
 148551 	for i = 0; i < nCol; i++ {
 148552 		sqlite3Fts5BufferAppendVarint(tls, bp+12, bp, *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8)))
 148553 	}
 148554 	if *(*int32)(unsafe.Pointer(bp + 12)) == SQLITE_OK {
 148555 		*(*int32)(unsafe.Pointer(bp + 12)) = sqlite3Fts5IndexSetAverages(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp)).Fn)
 148556 	}
 148557 	Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp)
 148558 
 148559 	return *(*int32)(unsafe.Pointer(bp + 12))
 148560 }
 148561 
 148562 func sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel I64, apVal uintptr) int32 {
 148563 	bp := tls.Alloc(4)
 148564 	defer tls.Free(4)
 148565 
 148566 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148567 	var rc int32
 148568 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 148569 
 148570 	rc = fts5StorageLoadTotals(tls, p, 1)
 148571 
 148572 	if rc == SQLITE_OK {
 148573 		rc = fts5StorageDeleteFromIndex(tls, p, iDel, apVal)
 148574 	}
 148575 
 148576 	if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148577 		rc = fts5StorageGetStmt(tls, p, FTS5_STMT_DELETE_DOCSIZE, bp, uintptr(0))
 148578 		if rc == SQLITE_OK {
 148579 			Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, iDel)
 148580 			Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148581 			rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148582 		}
 148583 	}
 148584 
 148585 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 148586 		if rc == SQLITE_OK {
 148587 			rc = fts5StorageGetStmt(tls, p, FTS5_STMT_DELETE_CONTENT, bp, uintptr(0))
 148588 		}
 148589 		if rc == SQLITE_OK {
 148590 			Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, iDel)
 148591 			Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148592 			rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148593 		}
 148594 	}
 148595 
 148596 	return rc
 148597 }
 148598 
 148599 func sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) int32 {
 148600 	bp := tls.Alloc(48)
 148601 	defer tls.Free(48)
 148602 
 148603 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148604 	var rc int32
 148605 
 148606 	(*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0
 148607 
 148608 	rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0),
 148609 		ts+36879,
 148610 		libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName,
 148611 			(*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 148612 	if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148613 		rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0),
 148614 			ts+36929,
 148615 			libc.VaList(bp+32, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))
 148616 	}
 148617 
 148618 	if rc == SQLITE_OK {
 148619 		rc = sqlite3Fts5IndexReinit(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex)
 148620 	}
 148621 	if rc == SQLITE_OK {
 148622 		rc = sqlite3Fts5StorageConfigValue(tls, p, ts+34601, uintptr(0), FTS5_CURRENT_VERSION)
 148623 	}
 148624 	return rc
 148625 }
 148626 
 148627 func sqlite3Fts5StorageRebuild(tls *libc.TLS, p uintptr) int32 {
 148628 	bp := tls.Alloc(32)
 148629 	defer tls.Free(32)
 148630 
 148631 	*(*Fts5Buffer)(unsafe.Pointer(bp + 16)) = Fts5Buffer{}
 148632 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148633 	*(*uintptr)(unsafe.Pointer(bp + 12)) = uintptr(0)
 148634 
 148635 	var rc2 int32
 148636 
 148637 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5InsertCtx{})))
 148638 	(*Fts5InsertCtx)(unsafe.Pointer(bp)).FpStorage = p
 148639 	*(*int32)(unsafe.Pointer(bp + 28)) = sqlite3Fts5StorageDeleteAll(tls, p)
 148640 	if *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK {
 148641 		*(*int32)(unsafe.Pointer(bp + 28)) = fts5StorageLoadTotals(tls, p, 1)
 148642 	}
 148643 
 148644 	if *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK {
 148645 		*(*int32)(unsafe.Pointer(bp + 28)) = fts5StorageGetStmt(tls, p, FTS5_STMT_SCAN, bp+12, uintptr(0))
 148646 	}
 148647 
 148648 	for *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK && SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 12))) {
 148649 		var iRowid I64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), 0)
 148650 
 148651 		sqlite3Fts5BufferZero(tls, bp+16)
 148652 		*(*int32)(unsafe.Pointer(bp + 28)) = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid)
 148653 		for (*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol = 0; *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK && (*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; (*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol++ {
 148654 			(*Fts5InsertCtx)(unsafe.Pointer(bp)).FszCol = 0
 148655 			if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol)))) == 0 {
 148656 				var zText uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), (*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol+1)
 148657 				var nText int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 12)), (*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol+1)
 148658 				*(*int32)(unsafe.Pointer(bp + 28)) = sqlite3Fts5Tokenize(tls, pConfig,
 148659 					FTS5_TOKENIZE_DOCUMENT,
 148660 					zText, nText,
 148661 					bp,
 148662 					*(*uintptr)(unsafe.Pointer(&struct {
 148663 						f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 148664 					}{fts5StorageInsertCallback})))
 148665 			}
 148666 			sqlite3Fts5BufferAppendVarint(tls, bp+28, bp+16, int64((*Fts5InsertCtx)(unsafe.Pointer(bp)).FszCol))
 148667 			*(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp)).FiCol)*8)) += I64((*Fts5InsertCtx)(unsafe.Pointer(bp)).FszCol)
 148668 		}
 148669 		(*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow++
 148670 
 148671 		if *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK {
 148672 			*(*int32)(unsafe.Pointer(bp + 28)) = fts5StorageInsertDocsize(tls, p, iRowid, bp+16)
 148673 		}
 148674 	}
 148675 	Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp+16)).Fp)
 148676 	rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 12)))
 148677 	if *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK {
 148678 		*(*int32)(unsafe.Pointer(bp + 28)) = rc2
 148679 	}
 148680 
 148681 	if *(*int32)(unsafe.Pointer(bp + 28)) == SQLITE_OK {
 148682 		*(*int32)(unsafe.Pointer(bp + 28)) = fts5StorageSaveTotals(tls, p)
 148683 	}
 148684 	return *(*int32)(unsafe.Pointer(bp + 28))
 148685 }
 148686 
 148687 func sqlite3Fts5StorageOptimize(tls *libc.TLS, p uintptr) int32 {
 148688 	return sqlite3Fts5IndexOptimize(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex)
 148689 }
 148690 
 148691 func sqlite3Fts5StorageMerge(tls *libc.TLS, p uintptr, nMerge int32) int32 {
 148692 	return sqlite3Fts5IndexMerge(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, nMerge)
 148693 }
 148694 
 148695 func sqlite3Fts5StorageReset(tls *libc.TLS, p uintptr) int32 {
 148696 	return sqlite3Fts5IndexReset(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex)
 148697 }
 148698 
 148699 func fts5StorageNewRowid(tls *libc.TLS, p uintptr, piRowid uintptr) int32 {
 148700 	bp := tls.Alloc(4)
 148701 	defer tls.Free(4)
 148702 
 148703 	var rc int32 = SQLITE_MISMATCH
 148704 	if (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 {
 148705 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 148706 		rc = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_DOCSIZE, bp, uintptr(0))
 148707 		if rc == SQLITE_OK {
 148708 			Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp)), 1)
 148709 			Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp)), 2)
 148710 			Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148711 			rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148712 		}
 148713 		if rc == SQLITE_OK {
 148714 			*(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb)
 148715 		}
 148716 	}
 148717 	return rc
 148718 }
 148719 
 148720 func sqlite3Fts5StorageContentInsert(tls *libc.TLS, p uintptr, apVal uintptr, piRowid uintptr) int32 {
 148721 	bp := tls.Alloc(4)
 148722 	defer tls.Free(4)
 148723 
 148724 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148725 	var rc int32 = SQLITE_OK
 148726 
 148727 	if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL {
 148728 		if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4))) == SQLITE_INTEGER {
 148729 			*(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*4)))
 148730 		} else {
 148731 			rc = fts5StorageNewRowid(tls, p, piRowid)
 148732 		}
 148733 	} else {
 148734 		*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 148735 		var i int32
 148736 		rc = fts5StorageGetStmt(tls, p, FTS5_STMT_INSERT_CONTENT, bp, uintptr(0))
 148737 		for i = 1; rc == SQLITE_OK && i <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol+1; i++ {
 148738 			rc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp)), i, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*4)))
 148739 		}
 148740 		if rc == SQLITE_OK {
 148741 			Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148742 			rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 148743 		}
 148744 		*(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb)
 148745 	}
 148746 
 148747 	return rc
 148748 }
 148749 
 148750 func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRowid I64) int32 {
 148751 	bp := tls.Alloc(28)
 148752 	defer tls.Free(28)
 148753 
 148754 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148755 	*(*int32)(unsafe.Pointer(bp + 24)) = SQLITE_OK
 148756 
 148757 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5Buffer{})))
 148758 	(*Fts5InsertCtx)(unsafe.Pointer(bp + 12)).FpStorage = p
 148759 	*(*int32)(unsafe.Pointer(bp + 24)) = fts5StorageLoadTotals(tls, p, 1)
 148760 
 148761 	if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 148762 		*(*int32)(unsafe.Pointer(bp + 24)) = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid)
 148763 	}
 148764 	for (*Fts5InsertCtx)(unsafe.Pointer(bp + 12)).FiCol = 0; *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK && (*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; (*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FiCol++ {
 148765 		(*Fts5InsertCtx)(unsafe.Pointer(bp + 12)).FszCol = 0
 148766 		if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FiCol)))) == 0 {
 148767 			var zText uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FiCol+2)*4)))
 148768 			var nText int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FiCol+2)*4)))
 148769 			*(*int32)(unsafe.Pointer(bp + 24)) = sqlite3Fts5Tokenize(tls, pConfig,
 148770 				FTS5_TOKENIZE_DOCUMENT,
 148771 				zText, nText,
 148772 				bp+12,
 148773 				*(*uintptr)(unsafe.Pointer(&struct {
 148774 					f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 148775 				}{fts5StorageInsertCallback})))
 148776 		}
 148777 		sqlite3Fts5BufferAppendVarint(tls, bp+24, bp, int64((*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FszCol))
 148778 		*(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp+12)).FiCol)*8)) += I64((*Fts5InsertCtx)(unsafe.Pointer(bp + 12)).FszCol)
 148779 	}
 148780 	(*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow++
 148781 
 148782 	if *(*int32)(unsafe.Pointer(bp + 24)) == SQLITE_OK {
 148783 		*(*int32)(unsafe.Pointer(bp + 24)) = fts5StorageInsertDocsize(tls, p, iRowid, bp)
 148784 	}
 148785 	Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp)).Fp)
 148786 
 148787 	return *(*int32)(unsafe.Pointer(bp + 24))
 148788 }
 148789 
 148790 func fts5StorageCount(tls *libc.TLS, p uintptr, zSuffix uintptr, pnRow uintptr) int32 {
 148791 	bp := tls.Alloc(28)
 148792 	defer tls.Free(28)
 148793 
 148794 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148795 	var zSql uintptr
 148796 	var rc int32
 148797 
 148798 	zSql = Xsqlite3_mprintf(tls, ts+36958,
 148799 		libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zSuffix))
 148800 	if zSql == uintptr(0) {
 148801 		rc = SQLITE_NOMEM
 148802 	} else {
 148803 		*(*uintptr)(unsafe.Pointer(bp + 24)) = uintptr(0)
 148804 		rc = Xsqlite3_prepare_v2(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, bp+24, uintptr(0))
 148805 		if rc == SQLITE_OK {
 148806 			if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24))) {
 148807 				*(*I64)(unsafe.Pointer(pnRow)) = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 24)), 0)
 148808 			}
 148809 			rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24)))
 148810 		}
 148811 	}
 148812 
 148813 	Xsqlite3_free(tls, zSql)
 148814 	return rc
 148815 }
 148816 
 148817 // Context object used by sqlite3Fts5StorageIntegrity().
 148818 type Fts5IntegrityCtx1 = struct {
 148819 	FiRowid   I64
 148820 	FiCol     int32
 148821 	FszCol    int32
 148822 	Fcksum    U64
 148823 	FpTermset uintptr
 148824 	FpConfig  uintptr
 148825 }
 148826 
 148827 // Context object used by sqlite3Fts5StorageIntegrity().
 148828 type Fts5IntegrityCtx = Fts5IntegrityCtx1
 148829 
 148830 func fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) int32 {
 148831 	bp := tls.Alloc(4)
 148832 	defer tls.Free(4)
 148833 
 148834 	var pCtx uintptr = pContext
 148835 	var pTermset uintptr = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpTermset
 148836 
 148837 	var ii int32
 148838 	var rc int32 = SQLITE_OK
 148839 	var iPos int32
 148840 	var iCol int32
 148841 
 148842 	_ = iUnused1
 148843 	_ = iUnused2
 148844 	if nToken > FTS5_MAX_TOKEN_SIZE {
 148845 		nToken = FTS5_MAX_TOKEN_SIZE
 148846 	}
 148847 
 148848 	if tflags&FTS5_TOKEN_COLOCATED == 0 || (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0 {
 148849 		(*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol++
 148850 	}
 148851 
 148852 	switch (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FeDetail {
 148853 	case FTS5_DETAIL_FULL:
 148854 		iPos = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol - 1
 148855 		iCol = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol
 148856 		break
 148857 
 148858 	case FTS5_DETAIL_COLUMNS:
 148859 		iPos = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol
 148860 		iCol = 0
 148861 		break
 148862 
 148863 	default:
 148864 		iPos = 0
 148865 		iCol = 0
 148866 		break
 148867 	}
 148868 
 148869 	rc = sqlite3Fts5TermsetAdd(tls, pTermset, 0, pToken, nToken, bp)
 148870 	if rc == SQLITE_OK && *(*int32)(unsafe.Pointer(bp)) == 0 {
 148871 		*(*U64)(unsafe.Pointer(pCtx + 16)) ^= sqlite3Fts5IndexEntryCksum(tls,
 148872 			(*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, 0, pToken, nToken)
 148873 	}
 148874 
 148875 	for ii = 0; rc == SQLITE_OK && ii < (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix; ii++ {
 148876 		var nChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FaPrefix + uintptr(ii)*4))
 148877 		var nByte int32 = sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar)
 148878 		if nByte != 0 {
 148879 			rc = sqlite3Fts5TermsetAdd(tls, pTermset, ii+1, pToken, nByte, bp)
 148880 			if *(*int32)(unsafe.Pointer(bp)) == 0 {
 148881 				*(*U64)(unsafe.Pointer(pCtx + 16)) ^= sqlite3Fts5IndexEntryCksum(tls,
 148882 					(*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, ii+1, pToken, nByte)
 148883 			}
 148884 		}
 148885 	}
 148886 
 148887 	return rc
 148888 }
 148889 
 148890 func sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr, iArg int32) int32 {
 148891 	bp := tls.Alloc(56)
 148892 	defer tls.Free(56)
 148893 
 148894 	var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148895 	var rc int32 = SQLITE_OK
 148896 	var aColSize uintptr
 148897 	var aTotalSize uintptr
 148898 
 148899 	var bUseCksum int32
 148900 
 148901 	libc.Xmemset(tls, bp, 0, uint32(unsafe.Sizeof(Fts5IntegrityCtx{})))
 148902 	(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FpConfig = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig
 148903 	aTotalSize = Xsqlite3_malloc64(tls, uint64(uint32((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*(uint32(unsafe.Sizeof(int32(0)))+uint32(unsafe.Sizeof(I64(0))))))
 148904 	if !(aTotalSize != 0) {
 148905 		return SQLITE_NOMEM
 148906 	}
 148907 	aColSize = aTotalSize + uintptr((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*8
 148908 	libc.Xmemset(tls, aTotalSize, 0, uint32(unsafe.Sizeof(I64(0)))*uint32((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))
 148909 
 148910 	bUseCksum = libc.Bool32((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL ||
 148911 		(*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_EXTERNAL && iArg != 0)
 148912 	if bUseCksum != 0 {
 148913 		rc = fts5StorageGetStmt(tls, p, FTS5_STMT_SCAN, bp+32, uintptr(0))
 148914 		if rc == SQLITE_OK {
 148915 			var rc2 int32
 148916 			for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32))) {
 148917 				var i int32
 148918 				(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FiRowid = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), 0)
 148919 				(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FszCol = 0
 148920 				if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148921 					rc = sqlite3Fts5StorageDocsize(tls, p, (*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FiRowid, aColSize)
 148922 				}
 148923 				if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE {
 148924 					rc = sqlite3Fts5TermsetNew(tls, bp+24)
 148925 				}
 148926 				for i = 0; rc == SQLITE_OK && i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 148927 					if *(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i))) != 0 {
 148928 						continue
 148929 					}
 148930 					(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FiCol = i
 148931 					(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FszCol = 0
 148932 					if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS {
 148933 						rc = sqlite3Fts5TermsetNew(tls, bp+24)
 148934 					}
 148935 					if rc == SQLITE_OK {
 148936 						var zText uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), i+1)
 148937 						var nText int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 32)), i+1)
 148938 						rc = sqlite3Fts5Tokenize(tls, pConfig,
 148939 							FTS5_TOKENIZE_DOCUMENT,
 148940 							zText, nText,
 148941 							bp,
 148942 							*(*uintptr)(unsafe.Pointer(&struct {
 148943 								f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 148944 							}{fts5StorageIntegrityCallback})))
 148945 					}
 148946 					if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 && (*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FszCol != *(*int32)(unsafe.Pointer(aColSize + uintptr(i)*4)) {
 148947 						rc = SQLITE_CORRUPT | int32(1)<<8
 148948 					}
 148949 					*(*I64)(unsafe.Pointer(aTotalSize + uintptr(i)*8)) += I64((*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FszCol)
 148950 					if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS {
 148951 						sqlite3Fts5TermsetFree(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FpTermset)
 148952 						(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FpTermset = uintptr(0)
 148953 					}
 148954 				}
 148955 				sqlite3Fts5TermsetFree(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FpTermset)
 148956 				(*Fts5IntegrityCtx)(unsafe.Pointer(bp)).FpTermset = uintptr(0)
 148957 
 148958 				if rc != SQLITE_OK {
 148959 					break
 148960 				}
 148961 			}
 148962 			rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 32)))
 148963 			if rc == SQLITE_OK {
 148964 				rc = rc2
 148965 			}
 148966 		}
 148967 
 148968 		if rc == SQLITE_OK {
 148969 			var i int32
 148970 			rc = fts5StorageLoadTotals(tls, p, 0)
 148971 			for i = 0; rc == SQLITE_OK && i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; i++ {
 148972 				if *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8)) != *(*I64)(unsafe.Pointer(aTotalSize + uintptr(i)*8)) {
 148973 					rc = SQLITE_CORRUPT | int32(1)<<8
 148974 				}
 148975 			}
 148976 		}
 148977 
 148978 		if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
 148979 			*(*I64)(unsafe.Pointer(bp + 40)) = int64(0)
 148980 			rc = fts5StorageCount(tls, p, ts+34104, bp+40)
 148981 			if rc == SQLITE_OK && *(*I64)(unsafe.Pointer(bp + 40)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow {
 148982 				rc = SQLITE_CORRUPT | int32(1)<<8
 148983 			}
 148984 		}
 148985 		if rc == SQLITE_OK && (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
 148986 			*(*I64)(unsafe.Pointer(bp + 48)) = int64(0)
 148987 			rc = fts5StorageCount(tls, p, ts+34455, bp+48)
 148988 			if rc == SQLITE_OK && *(*I64)(unsafe.Pointer(bp + 48)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow {
 148989 				rc = SQLITE_CORRUPT | int32(1)<<8
 148990 			}
 148991 		}
 148992 	}
 148993 
 148994 	if rc == SQLITE_OK {
 148995 		rc = sqlite3Fts5IndexIntegrityCheck(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (*Fts5IntegrityCtx)(unsafe.Pointer(bp)).Fcksum, bUseCksum)
 148996 	}
 148997 
 148998 	Xsqlite3_free(tls, aTotalSize)
 148999 	return rc
 149000 }
 149001 
 149002 func sqlite3Fts5StorageStmt(tls *libc.TLS, p uintptr, eStmt int32, pp uintptr, pzErrMsg uintptr) int32 {
 149003 	var rc int32
 149004 
 149005 	rc = fts5StorageGetStmt(tls, p, eStmt, pp, pzErrMsg)
 149006 	if rc == SQLITE_OK {
 149007 		*(*uintptr)(unsafe.Pointer(p + 28 + uintptr(eStmt)*4)) = uintptr(0)
 149008 	}
 149009 	return rc
 149010 }
 149011 
 149012 func sqlite3Fts5StorageStmtRelease(tls *libc.TLS, p uintptr, eStmt int32, pStmt uintptr) {
 149013 	if *(*uintptr)(unsafe.Pointer(p + 28 + uintptr(eStmt)*4)) == uintptr(0) {
 149014 		Xsqlite3_reset(tls, pStmt)
 149015 		*(*uintptr)(unsafe.Pointer(p + 28 + uintptr(eStmt)*4)) = pStmt
 149016 	} else {
 149017 		Xsqlite3_finalize(tls, pStmt)
 149018 	}
 149019 }
 149020 
 149021 func fts5StorageDecodeSizeArray(tls *libc.TLS, aCol uintptr, nCol int32, aBlob uintptr, nBlob int32) int32 {
 149022 	var i int32
 149023 	var iOff int32 = 0
 149024 	for i = 0; i < nCol; i++ {
 149025 		if iOff >= nBlob {
 149026 			return 1
 149027 		}
 149028 		iOff = iOff + sqlite3Fts5GetVarint32(tls, aBlob+uintptr(iOff), aCol+uintptr(i)*4)
 149029 	}
 149030 	return libc.Bool32(iOff != nBlob)
 149031 }
 149032 
 149033 func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintptr) int32 {
 149034 	bp := tls.Alloc(4)
 149035 	defer tls.Free(4)
 149036 
 149037 	var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol
 149038 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 149039 	var rc int32
 149040 
 149041 	rc = fts5StorageGetStmt(tls, p, FTS5_STMT_LOOKUP_DOCSIZE, bp, uintptr(0))
 149042 	if *(*uintptr)(unsafe.Pointer(bp)) != 0 {
 149043 		var bCorrupt int32 = 1
 149044 
 149045 		Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, iRowid)
 149046 		if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp))) {
 149047 			var aBlob uintptr = Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
 149048 			var nBlob int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp)), 0)
 149049 			if 0 == fts5StorageDecodeSizeArray(tls, aCol, nCol, aBlob, nBlob) {
 149050 				bCorrupt = 0
 149051 			}
 149052 		}
 149053 		rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 149054 		if bCorrupt != 0 && rc == SQLITE_OK {
 149055 			rc = SQLITE_CORRUPT | int32(1)<<8
 149056 		}
 149057 	} else {
 149058 	}
 149059 
 149060 	return rc
 149061 }
 149062 
 149063 func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintptr) int32 {
 149064 	var rc int32 = fts5StorageLoadTotals(tls, p, 0)
 149065 	if rc == SQLITE_OK {
 149066 		*(*I64)(unsafe.Pointer(pnToken)) = int64(0)
 149067 		if iCol < 0 {
 149068 			var i int32
 149069 			for i = 0; i < (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol; i++ {
 149070 				*(*I64)(unsafe.Pointer(pnToken)) += *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8))
 149071 			}
 149072 		} else if iCol < (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol {
 149073 			*(*I64)(unsafe.Pointer(pnToken)) = *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol)*8))
 149074 		} else {
 149075 			rc = SQLITE_RANGE
 149076 		}
 149077 	}
 149078 	return rc
 149079 }
 149080 
 149081 func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 {
 149082 	var rc int32 = fts5StorageLoadTotals(tls, p, 0)
 149083 	if rc == SQLITE_OK {
 149084 		*(*I64)(unsafe.Pointer(pnRow)) = (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow
 149085 		if (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow <= int64(0) {
 149086 			rc = SQLITE_CORRUPT | int32(1)<<8
 149087 		}
 149088 	}
 149089 	return rc
 149090 }
 149091 
 149092 func sqlite3Fts5StorageSync(tls *libc.TLS, p uintptr) int32 {
 149093 	var rc int32 = SQLITE_OK
 149094 	var iLastRowid I64 = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb)
 149095 	if (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid != 0 {
 149096 		rc = fts5StorageSaveTotals(tls, p)
 149097 		(*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0
 149098 	}
 149099 	if rc == SQLITE_OK {
 149100 		rc = sqlite3Fts5IndexSync(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex)
 149101 	}
 149102 	Xsqlite3_set_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb, iLastRowid)
 149103 	return rc
 149104 }
 149105 
 149106 func sqlite3Fts5StorageRollback(tls *libc.TLS, p uintptr) int32 {
 149107 	(*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0
 149108 	return sqlite3Fts5IndexRollback(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex)
 149109 }
 149110 
 149111 func sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uintptr, iVal int32) int32 {
 149112 	bp := tls.Alloc(4)
 149113 	defer tls.Free(4)
 149114 
 149115 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 149116 	var rc int32 = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_CONFIG, bp, uintptr(0))
 149117 	if rc == SQLITE_OK {
 149118 		Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp)), 1, z, -1, uintptr(0))
 149119 		if pVal != 0 {
 149120 			Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp)), 2, pVal)
 149121 		} else {
 149122 			Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp)), 2, iVal)
 149123 		}
 149124 		Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp)))
 149125 		rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp)))
 149126 		Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp)), 1)
 149127 	}
 149128 	if rc == SQLITE_OK && pVal != 0 {
 149129 		var iNew int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie + 1
 149130 		rc = sqlite3Fts5IndexSetCookie(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, iNew)
 149131 		if rc == SQLITE_OK {
 149132 			(*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie = iNew
 149133 		}
 149134 	}
 149135 	return rc
 149136 }
 149137 
 149138 var aAsciiTokenChar = [128]uint8{
 149139 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 149140 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 149141 	uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 149142 	uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 149143 	uint8(0), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1),
 149144 	uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 149145 	uint8(0), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1),
 149146 	uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0),
 149147 }
 149148 
 149149 type AsciiTokenizer1 = struct{ FaTokenChar [128]uint8 }
 149150 
 149151 type AsciiTokenizer = AsciiTokenizer1
 149152 
 149153 func fts5AsciiAddExceptions(tls *libc.TLS, p uintptr, zArg uintptr, bTokenChars int32) {
 149154 	var i int32
 149155 	for i = 0; *(*uint8)(unsafe.Pointer(zArg + uintptr(i))) != 0; i++ {
 149156 		if int32(*(*uint8)(unsafe.Pointer(zArg + uintptr(i))))&0x80 == 0 {
 149157 			*(*uint8)(unsafe.Pointer(p + uintptr(int32(*(*uint8)(unsafe.Pointer(zArg + uintptr(i))))))) = uint8(bTokenChars)
 149158 		}
 149159 	}
 149160 }
 149161 
 149162 func fts5AsciiDelete(tls *libc.TLS, p uintptr) {
 149163 	Xsqlite3_free(tls, p)
 149164 }
 149165 
 149166 func fts5AsciiCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 {
 149167 	var rc int32 = SQLITE_OK
 149168 	var p uintptr = uintptr(0)
 149169 	_ = pUnused
 149170 	if nArg%2 != 0 {
 149171 		rc = SQLITE_ERROR
 149172 	} else {
 149173 		p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(AsciiTokenizer{})))
 149174 		if p == uintptr(0) {
 149175 			rc = SQLITE_NOMEM
 149176 		} else {
 149177 			var i int32
 149178 			libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(AsciiTokenizer{})))
 149179 			libc.Xmemcpy(tls, p, uintptr(unsafe.Pointer(&aAsciiTokenChar)), uint32(unsafe.Sizeof(aAsciiTokenChar)))
 149180 			for i = 0; rc == SQLITE_OK && i < nArg; i = i + 2 {
 149181 				var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i+1)*4))
 149182 				if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+36990) {
 149183 					fts5AsciiAddExceptions(tls, p, zArg, 1)
 149184 				} else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+37001) {
 149185 					fts5AsciiAddExceptions(tls, p, zArg, 0)
 149186 				} else {
 149187 					rc = SQLITE_ERROR
 149188 				}
 149189 			}
 149190 			if rc != SQLITE_OK {
 149191 				fts5AsciiDelete(tls, p)
 149192 				p = uintptr(0)
 149193 			}
 149194 		}
 149195 	}
 149196 
 149197 	*(*uintptr)(unsafe.Pointer(ppOut)) = p
 149198 	return rc
 149199 }
 149200 
 149201 func asciiFold(tls *libc.TLS, aOut uintptr, aIn uintptr, nByte int32) {
 149202 	var i int32
 149203 	for i = 0; i < nByte; i++ {
 149204 		var c uint8 = *(*uint8)(unsafe.Pointer(aIn + uintptr(i)))
 149205 		if int32(c) >= 'A' && int32(c) <= 'Z' {
 149206 			c = uint8(int32(c) + 32)
 149207 		}
 149208 		*(*uint8)(unsafe.Pointer(aOut + uintptr(i))) = c
 149209 	}
 149210 }
 149211 
 149212 func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, xToken uintptr) int32 {
 149213 	bp := tls.Alloc(64)
 149214 	defer tls.Free(64)
 149215 
 149216 	var p uintptr = pTokenizer
 149217 	var rc int32 = SQLITE_OK
 149218 	var ie int32
 149219 	var is int32 = 0
 149220 
 149221 	var nFold int32 = int32(unsafe.Sizeof([64]uint8{}))
 149222 	var pFold uintptr = bp
 149223 	var a uintptr = p
 149224 
 149225 	_ = iUnused
 149226 
 149227 	for is < nText && rc == SQLITE_OK {
 149228 		var nByte int32
 149229 
 149230 		for is < nText && (int32(*(*uint8)(unsafe.Pointer(pText + uintptr(is))))&0x80 == 0 && int32(*(*uint8)(unsafe.Pointer(a + uintptr(int32(*(*uint8)(unsafe.Pointer(pText + uintptr(is)))))))) == 0) {
 149231 			is++
 149232 		}
 149233 		if is == nText {
 149234 			break
 149235 		}
 149236 
 149237 		ie = is + 1
 149238 		for ie < nText && (int32(*(*uint8)(unsafe.Pointer(pText + uintptr(ie))))&0x80 != 0 || *(*uint8)(unsafe.Pointer(a + uintptr(int32(*(*uint8)(unsafe.Pointer(pText + uintptr(ie))))))) != 0) {
 149239 			ie++
 149240 		}
 149241 
 149242 		nByte = ie - is
 149243 		if nByte > nFold {
 149244 			if pFold != bp {
 149245 				Xsqlite3_free(tls, pFold)
 149246 			}
 149247 			pFold = Xsqlite3_malloc64(tls, uint64(Sqlite3_int64(nByte)*int64(2)))
 149248 			if pFold == uintptr(0) {
 149249 				rc = SQLITE_NOMEM
 149250 				break
 149251 			}
 149252 			nFold = nByte * 2
 149253 		}
 149254 		asciiFold(tls, pFold, pText+uintptr(is), nByte)
 149255 
 149256 		rc = (*struct {
 149257 			f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 149258 		})(unsafe.Pointer(&struct{ uintptr }{xToken})).f(tls, pCtx, 0, pFold, nByte, is, ie)
 149259 		is = ie + 1
 149260 	}
 149261 
 149262 	if pFold != bp {
 149263 		Xsqlite3_free(tls, pFold)
 149264 	}
 149265 	if rc == SQLITE_DONE {
 149266 		rc = SQLITE_OK
 149267 	}
 149268 	return rc
 149269 }
 149270 
 149271 type Unicode61Tokenizer1 = struct {
 149272 	FaTokenChar       [128]uint8
 149273 	FaFold            uintptr
 149274 	FnFold            int32
 149275 	FeRemoveDiacritic int32
 149276 	FnException       int32
 149277 	FaiException      uintptr
 149278 	FaCategory        [32]uint8
 149279 }
 149280 
 149281 type Unicode61Tokenizer = Unicode61Tokenizer1
 149282 
 149283 func fts5UnicodeAddExceptions(tls *libc.TLS, p uintptr, z uintptr, bTokenChars int32) int32 {
 149284 	var rc int32 = SQLITE_OK
 149285 	var n int32 = int32(libc.Xstrlen(tls, z))
 149286 	var aNew uintptr
 149287 
 149288 	if n > 0 {
 149289 		aNew = Xsqlite3_realloc64(tls, (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaiException,
 149290 			uint64(uint32(n+(*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException)*uint32(unsafe.Sizeof(int32(0)))))
 149291 		if aNew != 0 {
 149292 			var nNew int32 = (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException
 149293 			var zCsr uintptr = z
 149294 			var zTerm uintptr = z + uintptr(n)
 149295 			for zCsr < zTerm {
 149296 				var iCode U32
 149297 				var bToken int32
 149298 				iCode = U32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zCsr, 1))))
 149299 				if iCode >= U32(0xc0) {
 149300 					iCode = U32(sqlite3Utf8Trans1[iCode-U32(0xc0)])
 149301 					for zCsr != zTerm && int32(*(*uint8)(unsafe.Pointer(zCsr)))&0xc0 == 0x80 {
 149302 						iCode = iCode<<6 + U32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zCsr, 1)))))
 149303 					}
 149304 					if iCode < U32(0x80) || iCode&0xFFFFF800 == U32(0xD800) || iCode&0xFFFFFFFE == U32(0xFFFE) {
 149305 						iCode = U32(0xFFFD)
 149306 					}
 149307 				}
 149308 
 149309 				if iCode < U32(128) {
 149310 					*(*uint8)(unsafe.Pointer(p + uintptr(iCode))) = uint8(bTokenChars)
 149311 				} else {
 149312 					bToken = int32(*(*uint8)(unsafe.Pointer(p + 148 + uintptr(sqlite3Fts5UnicodeCategory(tls, iCode)))))
 149313 
 149314 					if bToken != bTokenChars && sqlite3Fts5UnicodeIsdiacritic(tls, int32(iCode)) == 0 {
 149315 						var i int32
 149316 						for i = 0; i < nNew; i++ {
 149317 							if U32(*(*int32)(unsafe.Pointer(aNew + uintptr(i)*4))) > iCode {
 149318 								break
 149319 							}
 149320 						}
 149321 						libc.Xmemmove(tls, aNew+uintptr(i+1)*4, aNew+uintptr(i)*4, uint32(nNew-i)*uint32(unsafe.Sizeof(int32(0))))
 149322 						*(*int32)(unsafe.Pointer(aNew + uintptr(i)*4)) = int32(iCode)
 149323 						nNew++
 149324 					}
 149325 				}
 149326 			}
 149327 			(*Unicode61Tokenizer)(unsafe.Pointer(p)).FaiException = aNew
 149328 			(*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException = nNew
 149329 		} else {
 149330 			rc = SQLITE_NOMEM
 149331 		}
 149332 	}
 149333 
 149334 	return rc
 149335 }
 149336 
 149337 func fts5UnicodeIsException(tls *libc.TLS, p uintptr, iCode int32) int32 {
 149338 	if (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException > 0 {
 149339 		var a uintptr = (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaiException
 149340 		var iLo int32 = 0
 149341 		var iHi int32 = (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException - 1
 149342 
 149343 		for iHi >= iLo {
 149344 			var iTest int32 = (iHi + iLo) / 2
 149345 			if iCode == *(*int32)(unsafe.Pointer(a + uintptr(iTest)*4)) {
 149346 				return 1
 149347 			} else if iCode > *(*int32)(unsafe.Pointer(a + uintptr(iTest)*4)) {
 149348 				iLo = iTest + 1
 149349 			} else {
 149350 				iHi = iTest - 1
 149351 			}
 149352 		}
 149353 	}
 149354 
 149355 	return 0
 149356 }
 149357 
 149358 func fts5UnicodeDelete(tls *libc.TLS, pTok uintptr) {
 149359 	if pTok != 0 {
 149360 		var p uintptr = pTok
 149361 		Xsqlite3_free(tls, (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaiException)
 149362 		Xsqlite3_free(tls, (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold)
 149363 		Xsqlite3_free(tls, p)
 149364 	}
 149365 	return
 149366 }
 149367 
 149368 func unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) int32 {
 149369 	var z uintptr = zCat
 149370 
 149371 	for *(*uint8)(unsafe.Pointer(z)) != 0 {
 149372 		for int32(*(*uint8)(unsafe.Pointer(z))) == ' ' || int32(*(*uint8)(unsafe.Pointer(z))) == '\t' {
 149373 			z++
 149374 		}
 149375 		if *(*uint8)(unsafe.Pointer(z)) != 0 && sqlite3Fts5UnicodeCatParse(tls, z, p+148) != 0 {
 149376 			return SQLITE_ERROR
 149377 		}
 149378 		for int32(*(*uint8)(unsafe.Pointer(z))) != ' ' && int32(*(*uint8)(unsafe.Pointer(z))) != '\t' && int32(*(*uint8)(unsafe.Pointer(z))) != 0 {
 149379 			z++
 149380 		}
 149381 	}
 149382 
 149383 	sqlite3Fts5UnicodeAscii(tls, p+148, p)
 149384 	return SQLITE_OK
 149385 }
 149386 
 149387 func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 {
 149388 	var rc int32 = SQLITE_OK
 149389 	var p uintptr = uintptr(0)
 149390 
 149391 	_ = pUnused
 149392 
 149393 	if nArg%2 != 0 {
 149394 		rc = SQLITE_ERROR
 149395 	} else {
 149396 		p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Unicode61Tokenizer{})))
 149397 		if p != 0 {
 149398 			var zCat uintptr = ts + 37012
 149399 			var i int32
 149400 			libc.Xmemset(tls, p, 0, uint32(unsafe.Sizeof(Unicode61Tokenizer{})))
 149401 
 149402 			(*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE
 149403 			(*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold = 64
 149404 			(*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold = Xsqlite3_malloc64(tls, uint64(uint32((*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold)*uint32(unsafe.Sizeof(uint8(0)))))
 149405 			if (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold == uintptr(0) {
 149406 				rc = SQLITE_NOMEM
 149407 			}
 149408 
 149409 			for i = 0; rc == SQLITE_OK && i < nArg; i = i + 2 {
 149410 				if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+37021) {
 149411 					zCat = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i+1)*4))
 149412 				}
 149413 			}
 149414 
 149415 			if rc == SQLITE_OK {
 149416 				rc = unicodeSetCategories(tls, p, zCat)
 149417 			}
 149418 
 149419 			for i = 0; rc == SQLITE_OK && i < nArg; i = i + 2 {
 149420 				var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i+1)*4))
 149421 				if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+37032) {
 149422 					if int32(*(*uint8)(unsafe.Pointer(zArg))) != '0' && int32(*(*uint8)(unsafe.Pointer(zArg))) != '1' && int32(*(*uint8)(unsafe.Pointer(zArg))) != '2' || *(*uint8)(unsafe.Pointer(zArg + 1)) != 0 {
 149423 						rc = SQLITE_ERROR
 149424 					} else {
 149425 						(*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = int32(*(*uint8)(unsafe.Pointer(zArg))) - '0'
 149426 
 149427 					}
 149428 				} else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+36990) {
 149429 					rc = fts5UnicodeAddExceptions(tls, p, zArg, 1)
 149430 				} else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+37001) {
 149431 					rc = fts5UnicodeAddExceptions(tls, p, zArg, 0)
 149432 				} else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+37021) {
 149433 				} else {
 149434 					rc = SQLITE_ERROR
 149435 				}
 149436 			}
 149437 
 149438 		} else {
 149439 			rc = SQLITE_NOMEM
 149440 		}
 149441 		if rc != SQLITE_OK {
 149442 			fts5UnicodeDelete(tls, p)
 149443 			p = uintptr(0)
 149444 		}
 149445 		*(*uintptr)(unsafe.Pointer(ppOut)) = p
 149446 	}
 149447 	return rc
 149448 }
 149449 
 149450 func fts5UnicodeIsAlnum(tls *libc.TLS, p uintptr, iCode int32) int32 {
 149451 	return int32(*(*uint8)(unsafe.Pointer(p + 148 + uintptr(sqlite3Fts5UnicodeCategory(tls, U32(iCode)))))) ^
 149452 		fts5UnicodeIsException(tls, p, iCode)
 149453 }
 149454 
 149455 func fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused int32, pText uintptr, nText int32, xToken uintptr) int32 {
 149456 	var p uintptr
 149457 	var rc int32
 149458 	var a uintptr
 149459 	var zTerm uintptr
 149460 	var zCsr uintptr
 149461 
 149462 	var aFold uintptr
 149463 	var nFold int32
 149464 	var pEnd uintptr
 149465 	var iCode U32
 149466 	var zOut uintptr
 149467 	var is int32
 149468 	var ie int32
 149469 	p = pTokenizer
 149470 	rc = SQLITE_OK
 149471 	a = p
 149472 	zTerm = pText + uintptr(nText)
 149473 	zCsr = pText
 149474 	aFold = (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold
 149475 	nFold = (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold
 149476 	pEnd = aFold + uintptr(nFold-6)
 149477 
 149478 	_ = iUnused
 149479 
 149480 __1:
 149481 	if !(rc == SQLITE_OK) {
 149482 		goto __2
 149483 	}
 149484 	zOut = aFold
 149485 
 149486 __3:
 149487 	if !(1 != 0) {
 149488 		goto __4
 149489 	}
 149490 	if !(zCsr >= zTerm) {
 149491 		goto __5
 149492 	}
 149493 	goto tokenize_done
 149494 __5:
 149495 	;
 149496 	if !(int32(*(*uint8)(unsafe.Pointer(zCsr)))&0x80 != 0) {
 149497 		goto __6
 149498 	}
 149499 
 149500 	is = (int32(zCsr) - int32(pText)) / 1
 149501 	iCode = U32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zCsr, 1))))
 149502 	if !(iCode >= U32(0xc0)) {
 149503 		goto __8
 149504 	}
 149505 	iCode = U32(sqlite3Utf8Trans1[iCode-U32(0xc0)])
 149506 __9:
 149507 	if !(zCsr != zTerm && int32(*(*uint8)(unsafe.Pointer(zCsr)))&0xc0 == 0x80) {
 149508 		goto __10
 149509 	}
 149510 	iCode = iCode<<6 + U32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zCsr, 1)))))
 149511 	goto __9
 149512 __10:
 149513 	;
 149514 	if !(iCode < U32(0x80) || iCode&0xFFFFF800 == U32(0xD800) || iCode&0xFFFFFFFE == U32(0xFFFE)) {
 149515 		goto __11
 149516 	}
 149517 	iCode = U32(0xFFFD)
 149518 __11:
 149519 	;
 149520 __8:
 149521 	;
 149522 	if !(fts5UnicodeIsAlnum(tls, p, int32(iCode)) != 0) {
 149523 		goto __12
 149524 	}
 149525 	goto non_ascii_tokenchar
 149526 __12:
 149527 	;
 149528 	goto __7
 149529 __6:
 149530 	if !(*(*uint8)(unsafe.Pointer(a + uintptr(*(*uint8)(unsafe.Pointer(zCsr))))) != 0) {
 149531 		goto __13
 149532 	}
 149533 	is = (int32(zCsr) - int32(pText)) / 1
 149534 	goto ascii_tokenchar
 149535 __13:
 149536 	;
 149537 	zCsr++
 149538 __7:
 149539 	;
 149540 	goto __3
 149541 __4:
 149542 	;
 149543 __14:
 149544 	if !(zCsr < zTerm) {
 149545 		goto __15
 149546 	}
 149547 
 149548 	if !(zOut > pEnd) {
 149549 		goto __16
 149550 	}
 149551 	aFold = Xsqlite3_malloc64(tls, uint64(Sqlite3_int64(nFold)*int64(2)))
 149552 	if !(aFold == uintptr(0)) {
 149553 		goto __17
 149554 	}
 149555 	rc = SQLITE_NOMEM
 149556 	goto tokenize_done
 149557 __17:
 149558 	;
 149559 	zOut = aFold + uintptr((int32(zOut)-int32((*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold))/1)
 149560 	libc.Xmemcpy(tls, aFold, (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold, uint32(nFold))
 149561 	Xsqlite3_free(tls, (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold)
 149562 	(*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold = aFold
 149563 	(*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold = libc.AssignInt32(&nFold, nFold*2)
 149564 	pEnd = aFold + uintptr(nFold-6)
 149565 __16:
 149566 	;
 149567 	if !(int32(*(*uint8)(unsafe.Pointer(zCsr)))&0x80 != 0) {
 149568 		goto __18
 149569 	}
 149570 
 149571 	iCode = U32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zCsr, 1))))
 149572 	if !(iCode >= U32(0xc0)) {
 149573 		goto __20
 149574 	}
 149575 	iCode = U32(sqlite3Utf8Trans1[iCode-U32(0xc0)])
 149576 __21:
 149577 	if !(zCsr != zTerm && int32(*(*uint8)(unsafe.Pointer(zCsr)))&0xc0 == 0x80) {
 149578 		goto __22
 149579 	}
 149580 	iCode = iCode<<6 + U32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zCsr, 1)))))
 149581 	goto __21
 149582 __22:
 149583 	;
 149584 	if !(iCode < U32(0x80) || iCode&0xFFFFF800 == U32(0xD800) || iCode&0xFFFFFFFE == U32(0xFFFE)) {
 149585 		goto __23
 149586 	}
 149587 	iCode = U32(0xFFFD)
 149588 __23:
 149589 	;
 149590 __20:
 149591 	;
 149592 	if !(fts5UnicodeIsAlnum(tls, p, int32(iCode)) != 0 || sqlite3Fts5UnicodeIsdiacritic(tls, int32(iCode)) != 0) {
 149593 		goto __24
 149594 	}
 149595 non_ascii_tokenchar:
 149596 	iCode = U32(sqlite3Fts5UnicodeFold(tls, int32(iCode), (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic))
 149597 	if !(iCode != 0) {
 149598 		goto __26
 149599 	}
 149600 	if !(iCode < U32(0x00080)) {
 149601 		goto __27
 149602 	}
 149603 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = U8(iCode & U32(0xFF))
 149604 	goto __28
 149605 __27:
 149606 	if !(iCode < U32(0x00800)) {
 149607 		goto __29
 149608 	}
 149609 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xC0 + int32(U8(iCode>>6&U32(0x1F))))
 149610 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 149611 	goto __30
 149612 __29:
 149613 	if !(iCode < U32(0x10000)) {
 149614 		goto __31
 149615 	}
 149616 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xE0 + int32(U8(iCode>>12&U32(0x0F))))
 149617 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 149618 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 149619 	goto __32
 149620 __31:
 149621 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xF0 + int32(U8(iCode>>18&U32(0x07))))
 149622 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>12&U32(0x3F))))
 149623 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 149624 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 149625 __32:
 149626 	;
 149627 __30:
 149628 	;
 149629 __28:
 149630 	;
 149631 __26:
 149632 	;
 149633 	goto __25
 149634 __24:
 149635 	goto __15
 149636 __25:
 149637 	;
 149638 	goto __19
 149639 __18:
 149640 	if !(int32(*(*uint8)(unsafe.Pointer(a + uintptr(*(*uint8)(unsafe.Pointer(zCsr)))))) == 0) {
 149641 		goto __33
 149642 	}
 149643 
 149644 	goto __15
 149645 	goto __34
 149646 __33:
 149647 ascii_tokenchar:
 149648 	if !(int32(*(*uint8)(unsafe.Pointer(zCsr))) >= 'A' && int32(*(*uint8)(unsafe.Pointer(zCsr))) <= 'Z') {
 149649 		goto __35
 149650 	}
 149651 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(int32(*(*uint8)(unsafe.Pointer(zCsr))) + 32)
 149652 	goto __36
 149653 __35:
 149654 	*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = *(*uint8)(unsafe.Pointer(zCsr))
 149655 __36:
 149656 	;
 149657 	zCsr++
 149658 __34:
 149659 	;
 149660 __19:
 149661 	;
 149662 	ie = (int32(zCsr) - int32(pText)) / 1
 149663 	goto __14
 149664 __15:
 149665 	;
 149666 	rc = (*struct {
 149667 		f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 149668 	})(unsafe.Pointer(&struct{ uintptr }{xToken})).f(tls, pCtx, 0, aFold, (int32(zOut)-int32(aFold))/1, is, ie)
 149669 	goto __1
 149670 __2:
 149671 	;
 149672 tokenize_done:
 149673 	if !(rc == SQLITE_DONE) {
 149674 		goto __37
 149675 	}
 149676 	rc = SQLITE_OK
 149677 __37:
 149678 	;
 149679 	return rc
 149680 }
 149681 
 149682 type PorterTokenizer1 = struct {
 149683 	Ftokenizer  Fts5_tokenizer
 149684 	FpTokenizer uintptr
 149685 	FaBuf       [128]uint8
 149686 }
 149687 
 149688 type PorterTokenizer = PorterTokenizer1
 149689 
 149690 func fts5PorterDelete(tls *libc.TLS, pTok uintptr) {
 149691 	if pTok != 0 {
 149692 		var p uintptr = pTok
 149693 		if (*PorterTokenizer)(unsafe.Pointer(p)).FpTokenizer != 0 {
 149694 			(*struct{ f func(*libc.TLS, uintptr) })(unsafe.Pointer(&struct{ uintptr }{(*PorterTokenizer)(unsafe.Pointer(p)).Ftokenizer.FxDelete})).f(tls, (*PorterTokenizer)(unsafe.Pointer(p)).FpTokenizer)
 149695 		}
 149696 		Xsqlite3_free(tls, p)
 149697 	}
 149698 }
 149699 
 149700 func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 {
 149701 	bp := tls.Alloc(4)
 149702 	defer tls.Free(4)
 149703 
 149704 	var pApi uintptr = pCtx
 149705 	var rc int32 = SQLITE_OK
 149706 	var pRet uintptr
 149707 	*(*uintptr)(unsafe.Pointer(bp)) = uintptr(0)
 149708 	var zBase uintptr = ts + 37050
 149709 
 149710 	if nArg > 0 {
 149711 		zBase = *(*uintptr)(unsafe.Pointer(azArg))
 149712 	}
 149713 
 149714 	pRet = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PorterTokenizer{})))
 149715 	if pRet != 0 {
 149716 		libc.Xmemset(tls, pRet, 0, uint32(unsafe.Sizeof(PorterTokenizer{})))
 149717 		rc = (*struct {
 149718 			f func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32
 149719 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5_api)(unsafe.Pointer(pApi)).FxFindTokenizer})).f(tls, pApi, zBase, bp, pRet)
 149720 	} else {
 149721 		rc = SQLITE_NOMEM
 149722 	}
 149723 	if rc == SQLITE_OK {
 149724 		var nArg2 int32 = func() int32 {
 149725 			if nArg > 0 {
 149726 				return nArg - 1
 149727 			}
 149728 			return 0
 149729 		}()
 149730 		var azArg2 uintptr = func() uintptr {
 149731 			if nArg2 != 0 {
 149732 				return azArg + 1*4
 149733 			}
 149734 			return uintptr(0)
 149735 		}()
 149736 		rc = (*struct {
 149737 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 149738 		})(unsafe.Pointer(&struct{ uintptr }{(*PorterTokenizer)(unsafe.Pointer(pRet)).Ftokenizer.FxCreate})).f(tls, *(*uintptr)(unsafe.Pointer(bp)), azArg2, nArg2, pRet+12)
 149739 	}
 149740 
 149741 	if rc != SQLITE_OK {
 149742 		fts5PorterDelete(tls, pRet)
 149743 		pRet = uintptr(0)
 149744 	}
 149745 	*(*uintptr)(unsafe.Pointer(ppOut)) = pRet
 149746 	return rc
 149747 }
 149748 
 149749 type PorterContext1 = struct {
 149750 	FpCtx   uintptr
 149751 	FxToken uintptr
 149752 	FaBuf   uintptr
 149753 }
 149754 
 149755 type PorterContext = PorterContext1
 149756 
 149757 type PorterRule1 = struct {
 149758 	FzSuffix uintptr
 149759 	FnSuffix int32
 149760 	FxCond   uintptr
 149761 	FzOutput uintptr
 149762 	FnOutput int32
 149763 }
 149764 
 149765 type PorterRule = PorterRule1
 149766 
 149767 func fts5PorterIsVowel(tls *libc.TLS, c uint8, bYIsVowel int32) int32 {
 149768 	return libc.Bool32(int32(c) == 'a' || int32(c) == 'e' || int32(c) == 'i' || int32(c) == 'o' || int32(c) == 'u' || bYIsVowel != 0 && int32(c) == 'y')
 149769 }
 149770 
 149771 func fts5PorterGobbleVC(tls *libc.TLS, zStem uintptr, nStem int32, bPrevCons int32) int32 {
 149772 	var i int32
 149773 	var bCons int32 = bPrevCons
 149774 
 149775 	for i = 0; i < nStem; i++ {
 149776 		if 0 == libc.AssignInt32(&bCons, libc.BoolInt32(!(fts5PorterIsVowel(tls, *(*uint8)(unsafe.Pointer(zStem + uintptr(i))), bCons) != 0))) {
 149777 			break
 149778 		}
 149779 	}
 149780 
 149781 	for i++; i < nStem; i++ {
 149782 		if libc.AssignInt32(&bCons, libc.BoolInt32(!(fts5PorterIsVowel(tls, *(*uint8)(unsafe.Pointer(zStem + uintptr(i))), bCons) != 0))) != 0 {
 149783 			return i + 1
 149784 		}
 149785 	}
 149786 	return 0
 149787 }
 149788 
 149789 func fts5Porter_MGt0(tls *libc.TLS, zStem uintptr, nStem int32) int32 {
 149790 	return libc.BoolInt32(!!(fts5PorterGobbleVC(tls, zStem, nStem, 0) != 0))
 149791 }
 149792 
 149793 func fts5Porter_MGt1(tls *libc.TLS, zStem uintptr, nStem int32) int32 {
 149794 	var n int32
 149795 	n = fts5PorterGobbleVC(tls, zStem, nStem, 0)
 149796 	if n != 0 && fts5PorterGobbleVC(tls, zStem+uintptr(n), nStem-n, 1) != 0 {
 149797 		return 1
 149798 	}
 149799 	return 0
 149800 }
 149801 
 149802 func fts5Porter_MEq1(tls *libc.TLS, zStem uintptr, nStem int32) int32 {
 149803 	var n int32
 149804 	n = fts5PorterGobbleVC(tls, zStem, nStem, 0)
 149805 	if n != 0 && 0 == fts5PorterGobbleVC(tls, zStem+uintptr(n), nStem-n, 1) {
 149806 		return 1
 149807 	}
 149808 	return 0
 149809 }
 149810 
 149811 func fts5Porter_Ostar(tls *libc.TLS, zStem uintptr, nStem int32) int32 {
 149812 	if int32(*(*uint8)(unsafe.Pointer(zStem + uintptr(nStem-1)))) == 'w' || int32(*(*uint8)(unsafe.Pointer(zStem + uintptr(nStem-1)))) == 'x' || int32(*(*uint8)(unsafe.Pointer(zStem + uintptr(nStem-1)))) == 'y' {
 149813 		return 0
 149814 	} else {
 149815 		var i int32
 149816 		var mask int32 = 0
 149817 		var bCons int32 = 0
 149818 		for i = 0; i < nStem; i++ {
 149819 			bCons = libc.BoolInt32(!(fts5PorterIsVowel(tls, *(*uint8)(unsafe.Pointer(zStem + uintptr(i))), bCons) != 0))
 149820 
 149821 			mask = mask<<1 + bCons
 149822 		}
 149823 		return libc.Bool32(mask&0x0007 == 0x0005)
 149824 	}
 149825 	return int32(0)
 149826 }
 149827 
 149828 func fts5Porter_MGt1_and_S_or_T(tls *libc.TLS, zStem uintptr, nStem int32) int32 {
 149829 	return libc.Bool32((int32(*(*uint8)(unsafe.Pointer(zStem + uintptr(nStem-1)))) == 's' || int32(*(*uint8)(unsafe.Pointer(zStem + uintptr(nStem-1)))) == 't') &&
 149830 		fts5Porter_MGt1(tls, zStem, nStem) != 0)
 149831 }
 149832 
 149833 func fts5Porter_Vowel(tls *libc.TLS, zStem uintptr, nStem int32) int32 {
 149834 	var i int32
 149835 	for i = 0; i < nStem; i++ {
 149836 		if fts5PorterIsVowel(tls, *(*uint8)(unsafe.Pointer(zStem + uintptr(i))), libc.Bool32(i > 0)) != 0 {
 149837 			return 1
 149838 		}
 149839 	}
 149840 	return 0
 149841 }
 149842 
 149843 func fts5PorterStep4(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) int32 {
 149844 	var ret int32 = 0
 149845 	var nBuf int32 = *(*int32)(unsafe.Pointer(pnBuf))
 149846 	switch int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) {
 149847 	case 'a':
 149848 		if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37060, aBuf+uintptr(nBuf-2), uint32(2)) {
 149849 			if fts5Porter_MGt1(tls, aBuf, nBuf-2) != 0 {
 149850 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2
 149851 			}
 149852 		}
 149853 		break
 149854 
 149855 	case 'c':
 149856 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37063, aBuf+uintptr(nBuf-4), uint32(4)) {
 149857 			if fts5Porter_MGt1(tls, aBuf, nBuf-4) != 0 {
 149858 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4
 149859 			}
 149860 		} else if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37068, aBuf+uintptr(nBuf-4), uint32(4)) {
 149861 			if fts5Porter_MGt1(tls, aBuf, nBuf-4) != 0 {
 149862 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4
 149863 			}
 149864 		}
 149865 		break
 149866 
 149867 	case 'e':
 149868 		if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37073, aBuf+uintptr(nBuf-2), uint32(2)) {
 149869 			if fts5Porter_MGt1(tls, aBuf, nBuf-2) != 0 {
 149870 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2
 149871 			}
 149872 		}
 149873 		break
 149874 
 149875 	case 'i':
 149876 		if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37076, aBuf+uintptr(nBuf-2), uint32(2)) {
 149877 			if fts5Porter_MGt1(tls, aBuf, nBuf-2) != 0 {
 149878 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2
 149879 			}
 149880 		}
 149881 		break
 149882 
 149883 	case 'l':
 149884 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37079, aBuf+uintptr(nBuf-4), uint32(4)) {
 149885 			if fts5Porter_MGt1(tls, aBuf, nBuf-4) != 0 {
 149886 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4
 149887 			}
 149888 		} else if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37084, aBuf+uintptr(nBuf-4), uint32(4)) {
 149889 			if fts5Porter_MGt1(tls, aBuf, nBuf-4) != 0 {
 149890 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4
 149891 			}
 149892 		}
 149893 		break
 149894 
 149895 	case 'n':
 149896 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37089, aBuf+uintptr(nBuf-3), uint32(3)) {
 149897 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149898 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149899 			}
 149900 		} else if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37093, aBuf+uintptr(nBuf-5), uint32(5)) {
 149901 			if fts5Porter_MGt1(tls, aBuf, nBuf-5) != 0 {
 149902 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5
 149903 			}
 149904 		} else if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37099, aBuf+uintptr(nBuf-4), uint32(4)) {
 149905 			if fts5Porter_MGt1(tls, aBuf, nBuf-4) != 0 {
 149906 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4
 149907 			}
 149908 		} else if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37104, aBuf+uintptr(nBuf-3), uint32(3)) {
 149909 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149910 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149911 			}
 149912 		}
 149913 		break
 149914 
 149915 	case 'o':
 149916 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37108, aBuf+uintptr(nBuf-3), uint32(3)) {
 149917 			if fts5Porter_MGt1_and_S_or_T(tls, aBuf, nBuf-3) != 0 {
 149918 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149919 			}
 149920 		} else if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37112, aBuf+uintptr(nBuf-2), uint32(2)) {
 149921 			if fts5Porter_MGt1(tls, aBuf, nBuf-2) != 0 {
 149922 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2
 149923 			}
 149924 		}
 149925 		break
 149926 
 149927 	case 's':
 149928 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37115, aBuf+uintptr(nBuf-3), uint32(3)) {
 149929 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149930 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149931 			}
 149932 		}
 149933 		break
 149934 
 149935 	case 't':
 149936 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37119, aBuf+uintptr(nBuf-3), uint32(3)) {
 149937 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149938 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149939 			}
 149940 		} else if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37123, aBuf+uintptr(nBuf-3), uint32(3)) {
 149941 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149942 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149943 			}
 149944 		}
 149945 		break
 149946 
 149947 	case 'u':
 149948 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37127, aBuf+uintptr(nBuf-3), uint32(3)) {
 149949 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149950 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149951 			}
 149952 		}
 149953 		break
 149954 
 149955 	case 'v':
 149956 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37131, aBuf+uintptr(nBuf-3), uint32(3)) {
 149957 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149958 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149959 			}
 149960 		}
 149961 		break
 149962 
 149963 	case 'z':
 149964 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37135, aBuf+uintptr(nBuf-3), uint32(3)) {
 149965 			if fts5Porter_MGt1(tls, aBuf, nBuf-3) != 0 {
 149966 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 149967 			}
 149968 		}
 149969 		break
 149970 
 149971 	}
 149972 	return ret
 149973 }
 149974 
 149975 func fts5PorterStep1B2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) int32 {
 149976 	var ret int32 = 0
 149977 	var nBuf int32 = *(*int32)(unsafe.Pointer(pnBuf))
 149978 	switch int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) {
 149979 	case 'a':
 149980 		if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37139, aBuf+uintptr(nBuf-2), uint32(2)) {
 149981 			libc.Xmemcpy(tls, aBuf+uintptr(nBuf-2), ts+37119, uint32(3))
 149982 			*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2 + 3
 149983 			ret = 1
 149984 		}
 149985 		break
 149986 
 149987 	case 'b':
 149988 		if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37142, aBuf+uintptr(nBuf-2), uint32(2)) {
 149989 			libc.Xmemcpy(tls, aBuf+uintptr(nBuf-2), ts+37145, uint32(3))
 149990 			*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2 + 3
 149991 			ret = 1
 149992 		}
 149993 		break
 149994 
 149995 	case 'i':
 149996 		if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37149, aBuf+uintptr(nBuf-2), uint32(2)) {
 149997 			libc.Xmemcpy(tls, aBuf+uintptr(nBuf-2), ts+37135, uint32(3))
 149998 			*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2 + 3
 149999 			ret = 1
 150000 		}
 150001 		break
 150002 
 150003 	}
 150004 	return ret
 150005 }
 150006 
 150007 func fts5PorterStep2(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) int32 {
 150008 	var ret int32 = 0
 150009 	var nBuf int32 = *(*int32)(unsafe.Pointer(pnBuf))
 150010 	switch int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) {
 150011 	case 'a':
 150012 		if nBuf > 7 && 0 == libc.Xmemcmp(tls, ts+37152, aBuf+uintptr(nBuf-7), uint32(7)) {
 150013 			if fts5Porter_MGt0(tls, aBuf, nBuf-7) != 0 {
 150014 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-7), ts+37119, uint32(3))
 150015 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 7 + 3
 150016 			}
 150017 		} else if nBuf > 6 && 0 == libc.Xmemcmp(tls, ts+37160, aBuf+uintptr(nBuf-6), uint32(6)) {
 150018 			if fts5Porter_MGt0(tls, aBuf, nBuf-6) != 0 {
 150019 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-6), ts+37167, uint32(4))
 150020 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 6 + 4
 150021 			}
 150022 		}
 150023 		break
 150024 
 150025 	case 'c':
 150026 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37172, aBuf+uintptr(nBuf-4), uint32(4)) {
 150027 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150028 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+37068, uint32(4))
 150029 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 4
 150030 			}
 150031 		} else if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37177, aBuf+uintptr(nBuf-4), uint32(4)) {
 150032 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150033 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+37063, uint32(4))
 150034 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 4
 150035 			}
 150036 		}
 150037 		break
 150038 
 150039 	case 'e':
 150040 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37182, aBuf+uintptr(nBuf-4), uint32(4)) {
 150041 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150042 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+37135, uint32(3))
 150043 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 3
 150044 			}
 150045 		}
 150046 		break
 150047 
 150048 	case 'g':
 150049 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37187, aBuf+uintptr(nBuf-4), uint32(4)) {
 150050 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150051 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+15480, uint32(3))
 150052 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 3
 150053 			}
 150054 		}
 150055 		break
 150056 
 150057 	case 'l':
 150058 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37192, aBuf+uintptr(nBuf-3), uint32(3)) {
 150059 			if fts5Porter_MGt0(tls, aBuf, nBuf-3) != 0 {
 150060 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-3), ts+37145, uint32(3))
 150061 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3 + 3
 150062 			}
 150063 		} else if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37196, aBuf+uintptr(nBuf-4), uint32(4)) {
 150064 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150065 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+37060, uint32(2))
 150066 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 2
 150067 			}
 150068 		} else if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37201, aBuf+uintptr(nBuf-5), uint32(5)) {
 150069 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150070 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37104, uint32(3))
 150071 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 3
 150072 			}
 150073 		} else if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37207, aBuf+uintptr(nBuf-3), uint32(3)) {
 150074 			if fts5Porter_MGt0(tls, aBuf, nBuf-3) != 0 {
 150075 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-3), ts+37211, uint32(1))
 150076 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3 + 1
 150077 			}
 150078 		} else if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37213, aBuf+uintptr(nBuf-5), uint32(5)) {
 150079 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150080 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37127, uint32(3))
 150081 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 3
 150082 			}
 150083 		}
 150084 		break
 150085 
 150086 	case 'o':
 150087 		if nBuf > 7 && 0 == libc.Xmemcmp(tls, ts+37219, aBuf+uintptr(nBuf-7), uint32(7)) {
 150088 			if fts5Porter_MGt0(tls, aBuf, nBuf-7) != 0 {
 150089 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-7), ts+37135, uint32(3))
 150090 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 7 + 3
 150091 			}
 150092 		} else if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37227, aBuf+uintptr(nBuf-5), uint32(5)) {
 150093 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150094 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37119, uint32(3))
 150095 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 3
 150096 			}
 150097 		} else if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37233, aBuf+uintptr(nBuf-4), uint32(4)) {
 150098 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150099 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+37119, uint32(3))
 150100 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 3
 150101 			}
 150102 		}
 150103 		break
 150104 
 150105 	case 's':
 150106 		if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37238, aBuf+uintptr(nBuf-5), uint32(5)) {
 150107 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150108 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37060, uint32(2))
 150109 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 2
 150110 			}
 150111 		} else if nBuf > 7 && 0 == libc.Xmemcmp(tls, ts+37244, aBuf+uintptr(nBuf-7), uint32(7)) {
 150112 			if fts5Porter_MGt0(tls, aBuf, nBuf-7) != 0 {
 150113 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-7), ts+37131, uint32(3))
 150114 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 7 + 3
 150115 			}
 150116 		} else if nBuf > 7 && 0 == libc.Xmemcmp(tls, ts+37252, aBuf+uintptr(nBuf-7), uint32(7)) {
 150117 			if fts5Porter_MGt0(tls, aBuf, nBuf-7) != 0 {
 150118 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-7), ts+37260, uint32(3))
 150119 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 7 + 3
 150120 			}
 150121 		} else if nBuf > 7 && 0 == libc.Xmemcmp(tls, ts+37264, aBuf+uintptr(nBuf-7), uint32(7)) {
 150122 			if fts5Porter_MGt0(tls, aBuf, nBuf-7) != 0 {
 150123 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-7), ts+37127, uint32(3))
 150124 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 7 + 3
 150125 			}
 150126 		}
 150127 		break
 150128 
 150129 	case 't':
 150130 		if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37272, aBuf+uintptr(nBuf-5), uint32(5)) {
 150131 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150132 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37060, uint32(2))
 150133 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 2
 150134 			}
 150135 		} else if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37278, aBuf+uintptr(nBuf-5), uint32(5)) {
 150136 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150137 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37131, uint32(3))
 150138 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 3
 150139 			}
 150140 		} else if nBuf > 6 && 0 == libc.Xmemcmp(tls, ts+37284, aBuf+uintptr(nBuf-6), uint32(6)) {
 150141 			if fts5Porter_MGt0(tls, aBuf, nBuf-6) != 0 {
 150142 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-6), ts+37145, uint32(3))
 150143 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 6 + 3
 150144 			}
 150145 		}
 150146 		break
 150147 
 150148 	}
 150149 	return ret
 150150 }
 150151 
 150152 func fts5PorterStep3(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) int32 {
 150153 	var ret int32 = 0
 150154 	var nBuf int32 = *(*int32)(unsafe.Pointer(pnBuf))
 150155 	switch int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) {
 150156 	case 'a':
 150157 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37291, aBuf+uintptr(nBuf-4), uint32(4)) {
 150158 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150159 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-4), ts+37076, uint32(2))
 150160 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4 + 2
 150161 			}
 150162 		}
 150163 		break
 150164 
 150165 	case 's':
 150166 		if nBuf > 4 && 0 == libc.Xmemcmp(tls, ts+37296, aBuf+uintptr(nBuf-4), uint32(4)) {
 150167 			if fts5Porter_MGt0(tls, aBuf, nBuf-4) != 0 {
 150168 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 4
 150169 			}
 150170 		}
 150171 		break
 150172 
 150173 	case 't':
 150174 		if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37301, aBuf+uintptr(nBuf-5), uint32(5)) {
 150175 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150176 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37076, uint32(2))
 150177 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 2
 150178 			}
 150179 		} else if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37307, aBuf+uintptr(nBuf-5), uint32(5)) {
 150180 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150181 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37076, uint32(2))
 150182 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 2
 150183 			}
 150184 		}
 150185 		break
 150186 
 150187 	case 'u':
 150188 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37260, aBuf+uintptr(nBuf-3), uint32(3)) {
 150189 			if fts5Porter_MGt0(tls, aBuf, nBuf-3) != 0 {
 150190 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 150191 			}
 150192 		}
 150193 		break
 150194 
 150195 	case 'v':
 150196 		if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37313, aBuf+uintptr(nBuf-5), uint32(5)) {
 150197 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150198 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5
 150199 			}
 150200 		}
 150201 		break
 150202 
 150203 	case 'z':
 150204 		if nBuf > 5 && 0 == libc.Xmemcmp(tls, ts+37319, aBuf+uintptr(nBuf-5), uint32(5)) {
 150205 			if fts5Porter_MGt0(tls, aBuf, nBuf-5) != 0 {
 150206 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-5), ts+37060, uint32(2))
 150207 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 5 + 2
 150208 			}
 150209 		}
 150210 		break
 150211 
 150212 	}
 150213 	return ret
 150214 }
 150215 
 150216 func fts5PorterStep1B(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) int32 {
 150217 	var ret int32 = 0
 150218 	var nBuf int32 = *(*int32)(unsafe.Pointer(pnBuf))
 150219 	switch int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) {
 150220 	case 'e':
 150221 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37325, aBuf+uintptr(nBuf-3), uint32(3)) {
 150222 			if fts5Porter_MGt0(tls, aBuf, nBuf-3) != 0 {
 150223 				libc.Xmemcpy(tls, aBuf+uintptr(nBuf-3), ts+37329, uint32(2))
 150224 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3 + 2
 150225 			}
 150226 		} else if nBuf > 2 && 0 == libc.Xmemcmp(tls, ts+37332, aBuf+uintptr(nBuf-2), uint32(2)) {
 150227 			if fts5Porter_Vowel(tls, aBuf, nBuf-2) != 0 {
 150228 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2
 150229 				ret = 1
 150230 			}
 150231 		}
 150232 		break
 150233 
 150234 	case 'n':
 150235 		if nBuf > 3 && 0 == libc.Xmemcmp(tls, ts+37335, aBuf+uintptr(nBuf-3), uint32(3)) {
 150236 			if fts5Porter_Vowel(tls, aBuf, nBuf-3) != 0 {
 150237 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 3
 150238 				ret = 1
 150239 			}
 150240 		}
 150241 		break
 150242 
 150243 	}
 150244 	return ret
 150245 }
 150246 
 150247 func fts5PorterStep1A(tls *libc.TLS, aBuf uintptr, pnBuf uintptr) {
 150248 	var nBuf int32 = *(*int32)(unsafe.Pointer(pnBuf))
 150249 	if int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-1)))) == 's' {
 150250 		if int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) == 'e' {
 150251 			if nBuf > 4 && int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-4)))) == 's' && int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-3)))) == 's' ||
 150252 				nBuf > 3 && int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-3)))) == 'i' {
 150253 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 2
 150254 			} else {
 150255 				*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 1
 150256 			}
 150257 		} else if int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(nBuf-2)))) != 's' {
 150258 			*(*int32)(unsafe.Pointer(pnBuf)) = nBuf - 1
 150259 		}
 150260 	}
 150261 }
 150262 
 150263 func fts5PorterCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iStart int32, iEnd int32) int32 {
 150264 	bp := tls.Alloc(4)
 150265 	defer tls.Free(4)
 150266 
 150267 	var p uintptr
 150268 	var aBuf uintptr
 150269 
 150270 	var c uint8
 150271 	p = pCtx
 150272 
 150273 	if !(nToken > FTS5_PORTER_MAX_TOKEN || nToken < 3) {
 150274 		goto __1
 150275 	}
 150276 	goto pass_through
 150277 __1:
 150278 	;
 150279 	aBuf = (*PorterContext)(unsafe.Pointer(p)).FaBuf
 150280 	*(*int32)(unsafe.Pointer(bp)) = nToken
 150281 	libc.Xmemcpy(tls, aBuf, pToken, uint32(*(*int32)(unsafe.Pointer(bp))))
 150282 
 150283 	fts5PorterStep1A(tls, aBuf, bp)
 150284 	if !(fts5PorterStep1B(tls, aBuf, bp) != 0) {
 150285 		goto __2
 150286 	}
 150287 	if !(fts5PorterStep1B2(tls, aBuf, bp) == 0) {
 150288 		goto __3
 150289 	}
 150290 	c = *(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-1)))
 150291 	if !(fts5PorterIsVowel(tls, c, 0) == 0 &&
 150292 		int32(c) != 'l' && int32(c) != 's' && int32(c) != 'z' && int32(c) == int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-2))))) {
 150293 		goto __4
 150294 	}
 150295 	*(*int32)(unsafe.Pointer(bp))--
 150296 	goto __5
 150297 __4:
 150298 	if !(fts5Porter_MEq1(tls, aBuf, *(*int32)(unsafe.Pointer(bp))) != 0 && fts5Porter_Ostar(tls, aBuf, *(*int32)(unsafe.Pointer(bp))) != 0) {
 150299 		goto __6
 150300 	}
 150301 	*(*uint8)(unsafe.Pointer(aBuf + uintptr(libc.PostIncInt32(&*(*int32)(unsafe.Pointer(bp)), 1)))) = uint8('e')
 150302 __6:
 150303 	;
 150304 __5:
 150305 	;
 150306 __3:
 150307 	;
 150308 __2:
 150309 	;
 150310 	if !(int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-1)))) == 'y' && fts5Porter_Vowel(tls, aBuf, *(*int32)(unsafe.Pointer(bp))-1) != 0) {
 150311 		goto __7
 150312 	}
 150313 	*(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-1))) = uint8('i')
 150314 __7:
 150315 	;
 150316 	fts5PorterStep2(tls, aBuf, bp)
 150317 	fts5PorterStep3(tls, aBuf, bp)
 150318 	fts5PorterStep4(tls, aBuf, bp)
 150319 
 150320 	if !(int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-1)))) == 'e') {
 150321 		goto __8
 150322 	}
 150323 	if !(fts5Porter_MGt1(tls, aBuf, *(*int32)(unsafe.Pointer(bp))-1) != 0 ||
 150324 		fts5Porter_MEq1(tls, aBuf, *(*int32)(unsafe.Pointer(bp))-1) != 0 && !(fts5Porter_Ostar(tls, aBuf, *(*int32)(unsafe.Pointer(bp))-1) != 0)) {
 150325 		goto __9
 150326 	}
 150327 	*(*int32)(unsafe.Pointer(bp))--
 150328 __9:
 150329 	;
 150330 __8:
 150331 	;
 150332 	if !(*(*int32)(unsafe.Pointer(bp)) > 1 && int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-1)))) == 'l' &&
 150333 		int32(*(*uint8)(unsafe.Pointer(aBuf + uintptr(*(*int32)(unsafe.Pointer(bp))-2)))) == 'l' && fts5Porter_MGt1(tls, aBuf, *(*int32)(unsafe.Pointer(bp))-1) != 0) {
 150334 		goto __10
 150335 	}
 150336 	*(*int32)(unsafe.Pointer(bp))--
 150337 __10:
 150338 	;
 150339 	return (*struct {
 150340 		f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 150341 	})(unsafe.Pointer(&struct{ uintptr }{(*PorterContext)(unsafe.Pointer(p)).FxToken})).f(tls, (*PorterContext)(unsafe.Pointer(p)).FpCtx, tflags, aBuf, *(*int32)(unsafe.Pointer(bp)), iStart, iEnd)
 150342 
 150343 pass_through:
 150344 	return (*struct {
 150345 		f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 150346 	})(unsafe.Pointer(&struct{ uintptr }{(*PorterContext)(unsafe.Pointer(p)).FxToken})).f(tls, (*PorterContext)(unsafe.Pointer(p)).FpCtx, tflags, pToken, nToken, iStart, iEnd)
 150347 }
 150348 
 150349 func fts5PorterTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, xToken uintptr) int32 {
 150350 	bp := tls.Alloc(12)
 150351 	defer tls.Free(12)
 150352 
 150353 	var p uintptr = pTokenizer
 150354 
 150355 	(*PorterContext)(unsafe.Pointer(bp)).FxToken = xToken
 150356 	(*PorterContext)(unsafe.Pointer(bp)).FpCtx = pCtx
 150357 	(*PorterContext)(unsafe.Pointer(bp)).FaBuf = p + 16
 150358 	return (*struct {
 150359 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32
 150360 	})(unsafe.Pointer(&struct{ uintptr }{(*PorterTokenizer)(unsafe.Pointer(p)).Ftokenizer.FxTokenize})).f(tls,
 150361 		(*PorterTokenizer)(unsafe.Pointer(p)).FpTokenizer, bp, flags, pText, nText, *(*uintptr)(unsafe.Pointer(&struct {
 150362 			f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 150363 		}{fts5PorterCb})))
 150364 }
 150365 
 150366 // *************************************************************************
 150367 //
 150368 // Start of trigram implementation.
 150369 type TrigramTokenizer1 = struct{ FbFold int32 }
 150370 
 150371 // *************************************************************************
 150372 //
 150373 // Start of trigram implementation.
 150374 type TrigramTokenizer = TrigramTokenizer1
 150375 
 150376 func fts5TriDelete(tls *libc.TLS, p uintptr) {
 150377 	Xsqlite3_free(tls, p)
 150378 }
 150379 
 150380 func fts5TriCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 {
 150381 	var rc int32 = SQLITE_OK
 150382 	var pNew uintptr = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(TrigramTokenizer{})))
 150383 	_ = pUnused
 150384 	if pNew == uintptr(0) {
 150385 		rc = SQLITE_NOMEM
 150386 	} else {
 150387 		var i int32
 150388 		(*TrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = 1
 150389 		for i = 0; rc == SQLITE_OK && i < nArg; i = i + 2 {
 150390 			var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i+1)*4))
 150391 			if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*4)), ts+37339) {
 150392 				if int32(*(*uint8)(unsafe.Pointer(zArg))) != '0' && int32(*(*uint8)(unsafe.Pointer(zArg))) != '1' || *(*uint8)(unsafe.Pointer(zArg + 1)) != 0 {
 150393 					rc = SQLITE_ERROR
 150394 				} else {
 150395 					(*TrigramTokenizer)(unsafe.Pointer(pNew)).FbFold = libc.Bool32(int32(*(*uint8)(unsafe.Pointer(zArg))) == '0')
 150396 				}
 150397 			} else {
 150398 				rc = SQLITE_ERROR
 150399 			}
 150400 		}
 150401 		if rc != SQLITE_OK {
 150402 			fts5TriDelete(tls, pNew)
 150403 			pNew = uintptr(0)
 150404 		}
 150405 	}
 150406 	*(*uintptr)(unsafe.Pointer(ppOut)) = pNew
 150407 	return rc
 150408 }
 150409 
 150410 func fts5TriTokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, unusedFlags int32, pText uintptr, nText int32, xToken uintptr) int32 {
 150411 	bp := tls.Alloc(32)
 150412 	defer tls.Free(32)
 150413 
 150414 	var p uintptr = pTok
 150415 	var rc int32 = SQLITE_OK
 150416 
 150417 	var zIn uintptr = pText
 150418 	var zEof uintptr = zIn + uintptr(nText)
 150419 	var iCode U32
 150420 
 150421 	_ = unusedFlags
 150422 	for 1 != 0 {
 150423 		var zOut uintptr = bp
 150424 		var iStart int32 = (int32(zIn) - int32(pText)) / 1
 150425 		var zNext uintptr
 150426 
 150427 		iCode = U32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
 150428 		if iCode >= U32(0xc0) {
 150429 			iCode = U32(sqlite3Utf8Trans1[iCode-U32(0xc0)])
 150430 			for zIn != zEof && int32(*(*uint8)(unsafe.Pointer(zIn)))&0xc0 == 0x80 {
 150431 				iCode = iCode<<6 + U32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))))
 150432 			}
 150433 			if iCode < U32(0x80) || iCode&0xFFFFF800 == U32(0xD800) || iCode&0xFFFFFFFE == U32(0xFFFE) {
 150434 				iCode = U32(0xFFFD)
 150435 			}
 150436 		}
 150437 
 150438 		if iCode == U32(0) {
 150439 			break
 150440 		}
 150441 		zNext = zIn
 150442 		if zIn < zEof {
 150443 			if (*TrigramTokenizer)(unsafe.Pointer(p)).FbFold != 0 {
 150444 				iCode = U32(sqlite3Fts5UnicodeFold(tls, int32(iCode), 0))
 150445 			}
 150446 			{
 150447 				if iCode < U32(0x00080) {
 150448 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = U8(iCode & U32(0xFF))
 150449 				} else if iCode < U32(0x00800) {
 150450 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xC0 + int32(U8(iCode>>6&U32(0x1F))))
 150451 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150452 				} else if iCode < U32(0x10000) {
 150453 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xE0 + int32(U8(iCode>>12&U32(0x0F))))
 150454 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 150455 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150456 				} else {
 150457 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xF0 + int32(U8(iCode>>18&U32(0x07))))
 150458 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>12&U32(0x3F))))
 150459 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 150460 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150461 				}
 150462 			}
 150463 
 150464 			iCode = U32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
 150465 			if iCode >= U32(0xc0) {
 150466 				iCode = U32(sqlite3Utf8Trans1[iCode-U32(0xc0)])
 150467 				for zIn != zEof && int32(*(*uint8)(unsafe.Pointer(zIn)))&0xc0 == 0x80 {
 150468 					iCode = iCode<<6 + U32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))))
 150469 				}
 150470 				if iCode < U32(0x80) || iCode&0xFFFFF800 == U32(0xD800) || iCode&0xFFFFFFFE == U32(0xFFFE) {
 150471 					iCode = U32(0xFFFD)
 150472 				}
 150473 			}
 150474 
 150475 			if iCode == U32(0) {
 150476 				break
 150477 			}
 150478 		} else {
 150479 			break
 150480 		}
 150481 		if zIn < zEof {
 150482 			if (*TrigramTokenizer)(unsafe.Pointer(p)).FbFold != 0 {
 150483 				iCode = U32(sqlite3Fts5UnicodeFold(tls, int32(iCode), 0))
 150484 			}
 150485 			{
 150486 				if iCode < U32(0x00080) {
 150487 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = U8(iCode & U32(0xFF))
 150488 				} else if iCode < U32(0x00800) {
 150489 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xC0 + int32(U8(iCode>>6&U32(0x1F))))
 150490 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150491 				} else if iCode < U32(0x10000) {
 150492 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xE0 + int32(U8(iCode>>12&U32(0x0F))))
 150493 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 150494 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150495 				} else {
 150496 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xF0 + int32(U8(iCode>>18&U32(0x07))))
 150497 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>12&U32(0x3F))))
 150498 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 150499 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150500 				}
 150501 			}
 150502 
 150503 			iCode = U32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1))))
 150504 			if iCode >= U32(0xc0) {
 150505 				iCode = U32(sqlite3Utf8Trans1[iCode-U32(0xc0)])
 150506 				for zIn != zEof && int32(*(*uint8)(unsafe.Pointer(zIn)))&0xc0 == 0x80 {
 150507 					iCode = iCode<<6 + U32(0x3f&int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zIn, 1)))))
 150508 				}
 150509 				if iCode < U32(0x80) || iCode&0xFFFFF800 == U32(0xD800) || iCode&0xFFFFFFFE == U32(0xFFFE) {
 150510 					iCode = U32(0xFFFD)
 150511 				}
 150512 			}
 150513 
 150514 			if iCode == U32(0) {
 150515 				break
 150516 			}
 150517 			if (*TrigramTokenizer)(unsafe.Pointer(p)).FbFold != 0 {
 150518 				iCode = U32(sqlite3Fts5UnicodeFold(tls, int32(iCode), 0))
 150519 			}
 150520 			{
 150521 				if iCode < U32(0x00080) {
 150522 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = U8(iCode & U32(0xFF))
 150523 				} else if iCode < U32(0x00800) {
 150524 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xC0 + int32(U8(iCode>>6&U32(0x1F))))
 150525 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150526 				} else if iCode < U32(0x10000) {
 150527 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xE0 + int32(U8(iCode>>12&U32(0x0F))))
 150528 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 150529 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150530 				} else {
 150531 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0xF0 + int32(U8(iCode>>18&U32(0x07))))
 150532 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>12&U32(0x3F))))
 150533 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode>>6&U32(0x3F))))
 150534 					*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = uint8(0x80 + int32(U8(iCode&U32(0x3F))))
 150535 				}
 150536 			}
 150537 
 150538 		} else {
 150539 			break
 150540 		}
 150541 		rc = (*struct {
 150542 			f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32
 150543 		})(unsafe.Pointer(&struct{ uintptr }{xToken})).f(tls, pCtx, 0, bp, int32((zOut-bp)/1), iStart, int32((uintptr(iStart)+zOut-bp)/1))
 150544 		if rc != SQLITE_OK {
 150545 			break
 150546 		}
 150547 		zIn = zNext
 150548 	}
 150549 
 150550 	return rc
 150551 }
 150552 
 150553 func sqlite3Fts5TokenizerPattern(tls *libc.TLS, xCreate uintptr, pTok uintptr) int32 {
 150554 	if xCreate == *(*uintptr)(unsafe.Pointer(&struct {
 150555 		f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 150556 	}{fts5TriCreate})) {
 150557 		var p uintptr = pTok
 150558 		if (*TrigramTokenizer)(unsafe.Pointer(p)).FbFold != 0 {
 150559 			return FTS5_PATTERN_LIKE
 150560 		}
 150561 		return FTS5_PATTERN_GLOB
 150562 	}
 150563 	return FTS5_PATTERN_NONE
 150564 }
 150565 
 150566 func sqlite3Fts5TokenizerInit(tls *libc.TLS, pApi uintptr) int32 {
 150567 	bp := tls.Alloc(64)
 150568 	defer tls.Free(64)
 150569 
 150570 	*(*[4]BuiltinTokenizer)(unsafe.Pointer(bp)) = [4]BuiltinTokenizer{
 150571 		{FzName: ts + 37050, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct {
 150572 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 150573 		}{fts5UnicodeCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5UnicodeDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct {
 150574 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32
 150575 		}{fts5UnicodeTokenize}))}},
 150576 		{FzName: ts + 37354, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct {
 150577 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 150578 		}{fts5AsciiCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5AsciiDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct {
 150579 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32
 150580 		}{fts5AsciiTokenize}))}},
 150581 		{FzName: ts + 37360, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct {
 150582 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 150583 		}{fts5PorterCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5PorterDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct {
 150584 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32
 150585 		}{fts5PorterTokenize}))}},
 150586 		{FzName: ts + 37367, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct {
 150587 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32
 150588 		}{fts5TriCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5TriDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct {
 150589 			f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32
 150590 		}{fts5TriTokenize}))}},
 150591 	}
 150592 
 150593 	var rc int32 = SQLITE_OK
 150594 	var i int32
 150595 
 150596 	for i = 0; rc == SQLITE_OK && i < int32(uint32(unsafe.Sizeof([4]BuiltinTokenizer{}))/uint32(unsafe.Sizeof(BuiltinTokenizer{}))); i++ {
 150597 		rc = (*struct {
 150598 			f func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32
 150599 		})(unsafe.Pointer(&struct{ uintptr }{(*Fts5_api)(unsafe.Pointer(pApi)).FxCreateTokenizer})).f(tls, pApi,
 150600 			(*BuiltinTokenizer)(unsafe.Pointer(bp+uintptr(i)*16)).FzName,
 150601 			pApi,
 150602 			bp+uintptr(i)*16+4,
 150603 			uintptr(0))
 150604 	}
 150605 
 150606 	return rc
 150607 }
 150608 
 150609 type BuiltinTokenizer = struct {
 150610 	FzName uintptr
 150611 	Fx     Fts5_tokenizer
 150612 }
 150613 
 150614 func fts5_remove_diacritic(tls *libc.TLS, c int32, bComplex int32) int32 {
 150615 	bp := tls.Alloc(378)
 150616 	defer tls.Free(378)
 150617 
 150618 	*(*[126]uint16)(unsafe.Pointer(bp)) = [126]uint16{
 150619 		uint16(0), uint16(1797), uint16(1848), uint16(1859), uint16(1891), uint16(1928), uint16(1940), uint16(1995),
 150620 		uint16(2024), uint16(2040), uint16(2060), uint16(2110), uint16(2168), uint16(2206), uint16(2264), uint16(2286),
 150621 		uint16(2344), uint16(2383), uint16(2472), uint16(2488), uint16(2516), uint16(2596), uint16(2668), uint16(2732),
 150622 		uint16(2782), uint16(2842), uint16(2894), uint16(2954), uint16(2984), uint16(3000), uint16(3028), uint16(3336),
 150623 		uint16(3456), uint16(3696), uint16(3712), uint16(3728), uint16(3744), uint16(3766), uint16(3832), uint16(3896),
 150624 		uint16(3912), uint16(3928), uint16(3944), uint16(3968), uint16(4008), uint16(4040), uint16(4056), uint16(4106),
 150625 		uint16(4138), uint16(4170), uint16(4202), uint16(4234), uint16(4266), uint16(4296), uint16(4312), uint16(4344),
 150626 		uint16(4408), uint16(4424), uint16(4442), uint16(4472), uint16(4488), uint16(4504), uint16(6148), uint16(6198),
 150627 		uint16(6264), uint16(6280), uint16(6360), uint16(6429), uint16(6505), uint16(6529), uint16(61448), uint16(61468),
 150628 		uint16(61512), uint16(61534), uint16(61592), uint16(61610), uint16(61642), uint16(61672), uint16(61688), uint16(61704),
 150629 		uint16(61726), uint16(61784), uint16(61800), uint16(61816), uint16(61836), uint16(61880), uint16(61896), uint16(61914),
 150630 		uint16(61948), uint16(61998), uint16(62062), uint16(62122), uint16(62154), uint16(62184), uint16(62200), uint16(62218),
 150631 		uint16(62252), uint16(62302), uint16(62364), uint16(62410), uint16(62442), uint16(62478), uint16(62536), uint16(62554),
 150632 		uint16(62584), uint16(62604), uint16(62640), uint16(62648), uint16(62656), uint16(62664), uint16(62730), uint16(62766),
 150633 		uint16(62830), uint16(62890), uint16(62924), uint16(62974), uint16(63032), uint16(63050), uint16(63082), uint16(63118),
 150634 		uint16(63182), uint16(63242), uint16(63274), uint16(63310), uint16(63368), uint16(63390),
 150635 	}
 150636 	*(*[126]uint8)(unsafe.Pointer(bp + 252)) = [126]uint8{
 150637 		uint8(0), uint8('a'), uint8('c'), uint8('e'), uint8('i'), uint8('n'),
 150638 		uint8('o'), uint8('u'), uint8('y'), uint8('y'), uint8('a'), uint8('c'),
 150639 		uint8('d'), uint8('e'), uint8('e'), uint8('g'), uint8('h'), uint8('i'),
 150640 		uint8('j'), uint8('k'), uint8('l'), uint8('n'), uint8('o'), uint8('r'),
 150641 		uint8('s'), uint8('t'), uint8('u'), uint8('u'), uint8('w'), uint8('y'),
 150642 		uint8('z'), uint8('o'), uint8('u'), uint8('a'), uint8('i'), uint8('o'),
 150643 		uint8('u'), uint8('u' | int32(uint8(0x80))), uint8('a' | int32(uint8(0x80))), uint8('g'), uint8('k'), uint8('o'),
 150644 		uint8('o' | int32(uint8(0x80))), uint8('j'), uint8('g'), uint8('n'), uint8('a' | int32(uint8(0x80))), uint8('a'),
 150645 		uint8('e'), uint8('i'), uint8('o'), uint8('r'), uint8('u'), uint8('s'),
 150646 		uint8('t'), uint8('h'), uint8('a'), uint8('e'), uint8('o' | int32(uint8(0x80))), uint8('o'),
 150647 		uint8('o' | int32(uint8(0x80))), uint8('y'), uint8(0), uint8(0), uint8(0), uint8(0),
 150648 		uint8(0), uint8(0), uint8(0), uint8(0), uint8('a'), uint8('b'),
 150649 		uint8('c' | int32(uint8(0x80))), uint8('d'), uint8('d'), uint8('e' | int32(uint8(0x80))), uint8('e'), uint8('e' | int32(uint8(0x80))),
 150650 		uint8('f'), uint8('g'), uint8('h'), uint8('h'), uint8('i'), uint8('i' | int32(uint8(0x80))),
 150651 		uint8('k'), uint8('l'), uint8('l' | int32(uint8(0x80))), uint8('l'), uint8('m'), uint8('n'),
 150652 		uint8('o' | int32(uint8(0x80))), uint8('p'), uint8('r'), uint8('r' | int32(uint8(0x80))), uint8('r'), uint8('s'),
 150653 		uint8('s' | int32(uint8(0x80))), uint8('t'), uint8('u'), uint8('u' | int32(uint8(0x80))), uint8('v'), uint8('w'),
 150654 		uint8('w'), uint8('x'), uint8('y'), uint8('z'), uint8('h'), uint8('t'),
 150655 		uint8('w'), uint8('y'), uint8('a'), uint8('a' | int32(uint8(0x80))), uint8('a' | int32(uint8(0x80))), uint8('a' | int32(uint8(0x80))),
 150656 		uint8('e'), uint8('e' | int32(uint8(0x80))), uint8('e' | int32(uint8(0x80))), uint8('i'), uint8('o'), uint8('o' | int32(uint8(0x80))),
 150657 		uint8('o' | int32(uint8(0x80))), uint8('o' | int32(uint8(0x80))), uint8('u'), uint8('u' | int32(uint8(0x80))), uint8('u' | int32(uint8(0x80))), uint8('y'),
 150658 	}
 150659 
 150660 	var key uint32 = uint32(c)<<3 | uint32(0x00000007)
 150661 	var iRes int32 = 0
 150662 	var iHi int32 = int32(uint32(unsafe.Sizeof([126]uint16{}))/uint32(unsafe.Sizeof(uint16(0))) - uint32(1))
 150663 	var iLo int32 = 0
 150664 	for iHi >= iLo {
 150665 		var iTest int32 = (iHi + iLo) / 2
 150666 		if key >= uint32(*(*uint16)(unsafe.Pointer(bp + uintptr(iTest)*2))) {
 150667 			iRes = iTest
 150668 			iLo = iTest + 1
 150669 		} else {
 150670 			iHi = iTest - 1
 150671 		}
 150672 	}
 150673 
 150674 	if bComplex == 0 && int32(*(*uint8)(unsafe.Pointer(bp + 252 + uintptr(iRes))))&0x80 != 0 {
 150675 		return c
 150676 	}
 150677 	if c > int32(*(*uint16)(unsafe.Pointer(bp + uintptr(iRes)*2)))>>3+int32(*(*uint16)(unsafe.Pointer(bp + uintptr(iRes)*2)))&0x07 {
 150678 		return c
 150679 	}
 150680 	return int32(*(*uint8)(unsafe.Pointer(bp + 252 + uintptr(iRes)))) & 0x7F
 150681 }
 150682 
 150683 func sqlite3Fts5UnicodeIsdiacritic(tls *libc.TLS, c int32) int32 {
 150684 	var mask0 uint32 = uint32(0x08029FDF)
 150685 	var mask1 uint32 = uint32(0x000361F8)
 150686 	if c < 768 || c > 817 {
 150687 		return 0
 150688 	}
 150689 	if c < 768+32 {
 150690 		return int32(mask0 & (uint32(1) << (c - 768)))
 150691 	}
 150692 	return int32(mask1 & (uint32(1) << (c - 768 - 32)))
 150693 }
 150694 
 150695 func sqlite3Fts5UnicodeFold(tls *libc.TLS, c int32, eRemoveDiacritic int32) int32 {
 150696 	var ret int32 = c
 150697 
 150698 	if c < 128 {
 150699 		if c >= 'A' && c <= 'Z' {
 150700 			ret = c + ('a' - 'A')
 150701 		}
 150702 	} else if c < 65536 {
 150703 		var p uintptr
 150704 		var iHi int32 = int32(uint32(unsafe.Sizeof(aEntry))/uint32(unsafe.Sizeof(TableEntry{})) - uint32(1))
 150705 		var iLo int32 = 0
 150706 		var iRes int32 = -1
 150707 
 150708 		for iHi >= iLo {
 150709 			var iTest int32 = (iHi + iLo) / 2
 150710 			var cmp int32 = c - int32(aEntry[iTest].FiCode)
 150711 			if cmp >= 0 {
 150712 				iRes = iTest
 150713 				iLo = iTest + 1
 150714 			} else {
 150715 				iHi = iTest - 1
 150716 			}
 150717 		}
 150718 
 150719 		p = uintptr(unsafe.Pointer(&aEntry)) + uintptr(iRes)*4
 150720 		if c < int32((*TableEntry)(unsafe.Pointer(p)).FiCode)+int32((*TableEntry)(unsafe.Pointer(p)).FnRange) && 0 == 0x01&int32((*TableEntry)(unsafe.Pointer(p)).Fflags)&(int32((*TableEntry)(unsafe.Pointer(p)).FiCode)^c) {
 150721 			ret = (c + int32(aiOff[int32((*TableEntry)(unsafe.Pointer(p)).Fflags)>>1])) & 0x0000FFFF
 150722 
 150723 		}
 150724 
 150725 		if eRemoveDiacritic != 0 {
 150726 			ret = fts5_remove_diacritic(tls, ret, libc.Bool32(eRemoveDiacritic == 2))
 150727 		}
 150728 	} else if c >= 66560 && c < 66600 {
 150729 		ret = c + 40
 150730 	}
 150731 
 150732 	return ret
 150733 }
 150734 
 150735 // Each entry in the following array defines a rule for folding a range
 150736 // of codepoints to lower case. The rule applies to a range of nRange
 150737 // codepoints starting at codepoint iCode.
 150738 //
 150739 // If the least significant bit in flags is clear, then the rule applies
 150740 // to all nRange codepoints (i.e. all nRange codepoints are upper case and
 150741 // need to be folded). Or, if it is set, then the rule only applies to
 150742 // every second codepoint in the range, starting with codepoint C.
 150743 //
 150744 // The 7 most significant bits in flags are an index into the aiOff[]
 150745 // array. If a specific codepoint C does require folding, then its lower
 150746 // case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).
 150747 //
 150748 // The contents of this array are generated by parsing the CaseFolding.txt
 150749 // file distributed as part of the "Unicode Character Database". See
 150750 // http://www.unicode.org for details.
 150751 type TableEntry = struct {
 150752 	FiCode  uint16
 150753 	Fflags  uint8
 150754 	FnRange uint8
 150755 }
 150756 
 150757 var aEntry = [163]TableEntry{
 150758 	{FiCode: uint16(65), Fflags: uint8(14), FnRange: uint8(26)}, {FiCode: uint16(181), Fflags: uint8(64), FnRange: uint8(1)}, {FiCode: uint16(192), Fflags: uint8(14), FnRange: uint8(23)},
 150759 	{FiCode: uint16(216), Fflags: uint8(14), FnRange: uint8(7)}, {FiCode: uint16(256), Fflags: uint8(1), FnRange: uint8(48)}, {FiCode: uint16(306), Fflags: uint8(1), FnRange: uint8(6)},
 150760 	{FiCode: uint16(313), Fflags: uint8(1), FnRange: uint8(16)}, {FiCode: uint16(330), Fflags: uint8(1), FnRange: uint8(46)}, {FiCode: uint16(376), Fflags: uint8(116), FnRange: uint8(1)},
 150761 	{FiCode: uint16(377), Fflags: uint8(1), FnRange: uint8(6)}, {FiCode: uint16(383), Fflags: uint8(104), FnRange: uint8(1)}, {FiCode: uint16(385), Fflags: uint8(50), FnRange: uint8(1)},
 150762 	{FiCode: uint16(386), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(390), Fflags: uint8(44), FnRange: uint8(1)}, {FiCode: uint16(391), FnRange: uint8(1)},
 150763 	{FiCode: uint16(393), Fflags: uint8(42), FnRange: uint8(2)}, {FiCode: uint16(395), FnRange: uint8(1)}, {FiCode: uint16(398), Fflags: uint8(32), FnRange: uint8(1)},
 150764 	{FiCode: uint16(399), Fflags: uint8(38), FnRange: uint8(1)}, {FiCode: uint16(400), Fflags: uint8(40), FnRange: uint8(1)}, {FiCode: uint16(401), FnRange: uint8(1)},
 150765 	{FiCode: uint16(403), Fflags: uint8(42), FnRange: uint8(1)}, {FiCode: uint16(404), Fflags: uint8(46), FnRange: uint8(1)}, {FiCode: uint16(406), Fflags: uint8(52), FnRange: uint8(1)},
 150766 	{FiCode: uint16(407), Fflags: uint8(48), FnRange: uint8(1)}, {FiCode: uint16(408), FnRange: uint8(1)}, {FiCode: uint16(412), Fflags: uint8(52), FnRange: uint8(1)},
 150767 	{FiCode: uint16(413), Fflags: uint8(54), FnRange: uint8(1)}, {FiCode: uint16(415), Fflags: uint8(56), FnRange: uint8(1)}, {FiCode: uint16(416), Fflags: uint8(1), FnRange: uint8(6)},
 150768 	{FiCode: uint16(422), Fflags: uint8(60), FnRange: uint8(1)}, {FiCode: uint16(423), FnRange: uint8(1)}, {FiCode: uint16(425), Fflags: uint8(60), FnRange: uint8(1)},
 150769 	{FiCode: uint16(428), FnRange: uint8(1)}, {FiCode: uint16(430), Fflags: uint8(60), FnRange: uint8(1)}, {FiCode: uint16(431), FnRange: uint8(1)},
 150770 	{FiCode: uint16(433), Fflags: uint8(58), FnRange: uint8(2)}, {FiCode: uint16(435), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(439), Fflags: uint8(62), FnRange: uint8(1)},
 150771 	{FiCode: uint16(440), FnRange: uint8(1)}, {FiCode: uint16(444), FnRange: uint8(1)}, {FiCode: uint16(452), Fflags: uint8(2), FnRange: uint8(1)},
 150772 	{FiCode: uint16(453), FnRange: uint8(1)}, {FiCode: uint16(455), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(456), FnRange: uint8(1)},
 150773 	{FiCode: uint16(458), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(459), Fflags: uint8(1), FnRange: uint8(18)}, {FiCode: uint16(478), Fflags: uint8(1), FnRange: uint8(18)},
 150774 	{FiCode: uint16(497), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(498), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(502), Fflags: uint8(122), FnRange: uint8(1)},
 150775 	{FiCode: uint16(503), Fflags: uint8(134), FnRange: uint8(1)}, {FiCode: uint16(504), Fflags: uint8(1), FnRange: uint8(40)}, {FiCode: uint16(544), Fflags: uint8(110), FnRange: uint8(1)},
 150776 	{FiCode: uint16(546), Fflags: uint8(1), FnRange: uint8(18)}, {FiCode: uint16(570), Fflags: uint8(70), FnRange: uint8(1)}, {FiCode: uint16(571), FnRange: uint8(1)},
 150777 	{FiCode: uint16(573), Fflags: uint8(108), FnRange: uint8(1)}, {FiCode: uint16(574), Fflags: uint8(68), FnRange: uint8(1)}, {FiCode: uint16(577), FnRange: uint8(1)},
 150778 	{FiCode: uint16(579), Fflags: uint8(106), FnRange: uint8(1)}, {FiCode: uint16(580), Fflags: uint8(28), FnRange: uint8(1)}, {FiCode: uint16(581), Fflags: uint8(30), FnRange: uint8(1)},
 150779 	{FiCode: uint16(582), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(837), Fflags: uint8(36), FnRange: uint8(1)}, {FiCode: uint16(880), Fflags: uint8(1), FnRange: uint8(4)},
 150780 	{FiCode: uint16(886), FnRange: uint8(1)}, {FiCode: uint16(902), Fflags: uint8(18), FnRange: uint8(1)}, {FiCode: uint16(904), Fflags: uint8(16), FnRange: uint8(3)},
 150781 	{FiCode: uint16(908), Fflags: uint8(26), FnRange: uint8(1)}, {FiCode: uint16(910), Fflags: uint8(24), FnRange: uint8(2)}, {FiCode: uint16(913), Fflags: uint8(14), FnRange: uint8(17)},
 150782 	{FiCode: uint16(931), Fflags: uint8(14), FnRange: uint8(9)}, {FiCode: uint16(962), FnRange: uint8(1)}, {FiCode: uint16(975), Fflags: uint8(4), FnRange: uint8(1)},
 150783 	{FiCode: uint16(976), Fflags: uint8(140), FnRange: uint8(1)}, {FiCode: uint16(977), Fflags: uint8(142), FnRange: uint8(1)}, {FiCode: uint16(981), Fflags: uint8(146), FnRange: uint8(1)},
 150784 	{FiCode: uint16(982), Fflags: uint8(144), FnRange: uint8(1)}, {FiCode: uint16(984), Fflags: uint8(1), FnRange: uint8(24)}, {FiCode: uint16(1008), Fflags: uint8(136), FnRange: uint8(1)},
 150785 	{FiCode: uint16(1009), Fflags: uint8(138), FnRange: uint8(1)}, {FiCode: uint16(1012), Fflags: uint8(130), FnRange: uint8(1)}, {FiCode: uint16(1013), Fflags: uint8(128), FnRange: uint8(1)},
 150786 	{FiCode: uint16(1015), FnRange: uint8(1)}, {FiCode: uint16(1017), Fflags: uint8(152), FnRange: uint8(1)}, {FiCode: uint16(1018), FnRange: uint8(1)},
 150787 	{FiCode: uint16(1021), Fflags: uint8(110), FnRange: uint8(3)}, {FiCode: uint16(1024), Fflags: uint8(34), FnRange: uint8(16)}, {FiCode: uint16(1040), Fflags: uint8(14), FnRange: uint8(32)},
 150788 	{FiCode: uint16(1120), Fflags: uint8(1), FnRange: uint8(34)}, {FiCode: uint16(1162), Fflags: uint8(1), FnRange: uint8(54)}, {FiCode: uint16(1216), Fflags: uint8(6), FnRange: uint8(1)},
 150789 	{FiCode: uint16(1217), Fflags: uint8(1), FnRange: uint8(14)}, {FiCode: uint16(1232), Fflags: uint8(1), FnRange: uint8(88)}, {FiCode: uint16(1329), Fflags: uint8(22), FnRange: uint8(38)},
 150790 	{FiCode: uint16(4256), Fflags: uint8(66), FnRange: uint8(38)}, {FiCode: uint16(4295), Fflags: uint8(66), FnRange: uint8(1)}, {FiCode: uint16(4301), Fflags: uint8(66), FnRange: uint8(1)},
 150791 	{FiCode: uint16(7680), Fflags: uint8(1), FnRange: uint8(150)}, {FiCode: uint16(7835), Fflags: uint8(132), FnRange: uint8(1)}, {FiCode: uint16(7838), Fflags: uint8(96), FnRange: uint8(1)},
 150792 	{FiCode: uint16(7840), Fflags: uint8(1), FnRange: uint8(96)}, {FiCode: uint16(7944), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(7960), Fflags: uint8(150), FnRange: uint8(6)},
 150793 	{FiCode: uint16(7976), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(7992), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8008), Fflags: uint8(150), FnRange: uint8(6)},
 150794 	{FiCode: uint16(8025), Fflags: uint8(151), FnRange: uint8(8)}, {FiCode: uint16(8040), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8072), Fflags: uint8(150), FnRange: uint8(8)},
 150795 	{FiCode: uint16(8088), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8104), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8120), Fflags: uint8(150), FnRange: uint8(2)},
 150796 	{FiCode: uint16(8122), Fflags: uint8(126), FnRange: uint8(2)}, {FiCode: uint16(8124), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8126), Fflags: uint8(100), FnRange: uint8(1)},
 150797 	{FiCode: uint16(8136), Fflags: uint8(124), FnRange: uint8(4)}, {FiCode: uint16(8140), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8152), Fflags: uint8(150), FnRange: uint8(2)},
 150798 	{FiCode: uint16(8154), Fflags: uint8(120), FnRange: uint8(2)}, {FiCode: uint16(8168), Fflags: uint8(150), FnRange: uint8(2)}, {FiCode: uint16(8170), Fflags: uint8(118), FnRange: uint8(2)},
 150799 	{FiCode: uint16(8172), Fflags: uint8(152), FnRange: uint8(1)}, {FiCode: uint16(8184), Fflags: uint8(112), FnRange: uint8(2)}, {FiCode: uint16(8186), Fflags: uint8(114), FnRange: uint8(2)},
 150800 	{FiCode: uint16(8188), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8486), Fflags: uint8(98), FnRange: uint8(1)}, {FiCode: uint16(8490), Fflags: uint8(92), FnRange: uint8(1)},
 150801 	{FiCode: uint16(8491), Fflags: uint8(94), FnRange: uint8(1)}, {FiCode: uint16(8498), Fflags: uint8(12), FnRange: uint8(1)}, {FiCode: uint16(8544), Fflags: uint8(8), FnRange: uint8(16)},
 150802 	{FiCode: uint16(8579), FnRange: uint8(1)}, {FiCode: uint16(9398), Fflags: uint8(10), FnRange: uint8(26)}, {FiCode: uint16(11264), Fflags: uint8(22), FnRange: uint8(47)},
 150803 	{FiCode: uint16(11360), FnRange: uint8(1)}, {FiCode: uint16(11362), Fflags: uint8(88), FnRange: uint8(1)}, {FiCode: uint16(11363), Fflags: uint8(102), FnRange: uint8(1)},
 150804 	{FiCode: uint16(11364), Fflags: uint8(90), FnRange: uint8(1)}, {FiCode: uint16(11367), Fflags: uint8(1), FnRange: uint8(6)}, {FiCode: uint16(11373), Fflags: uint8(84), FnRange: uint8(1)},
 150805 	{FiCode: uint16(11374), Fflags: uint8(86), FnRange: uint8(1)}, {FiCode: uint16(11375), Fflags: uint8(80), FnRange: uint8(1)}, {FiCode: uint16(11376), Fflags: uint8(82), FnRange: uint8(1)},
 150806 	{FiCode: uint16(11378), FnRange: uint8(1)}, {FiCode: uint16(11381), FnRange: uint8(1)}, {FiCode: uint16(11390), Fflags: uint8(78), FnRange: uint8(2)},
 150807 	{FiCode: uint16(11392), Fflags: uint8(1), FnRange: uint8(100)}, {FiCode: uint16(11499), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(11506), FnRange: uint8(1)},
 150808 	{FiCode: uint16(42560), Fflags: uint8(1), FnRange: uint8(46)}, {FiCode: uint16(42624), Fflags: uint8(1), FnRange: uint8(24)}, {FiCode: uint16(42786), Fflags: uint8(1), FnRange: uint8(14)},
 150809 	{FiCode: uint16(42802), Fflags: uint8(1), FnRange: uint8(62)}, {FiCode: uint16(42873), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(42877), Fflags: uint8(76), FnRange: uint8(1)},
 150810 	{FiCode: uint16(42878), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(42891), FnRange: uint8(1)}, {FiCode: uint16(42893), Fflags: uint8(74), FnRange: uint8(1)},
 150811 	{FiCode: uint16(42896), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(42912), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(42922), Fflags: uint8(72), FnRange: uint8(1)},
 150812 	{FiCode: uint16(65313), Fflags: uint8(14), FnRange: uint8(26)},
 150813 }
 150814 var aiOff = [77]uint16{
 150815 	uint16(1), uint16(2), uint16(8), uint16(15), uint16(16), uint16(26), uint16(28), uint16(32),
 150816 	uint16(37), uint16(38), uint16(40), uint16(48), uint16(63), uint16(64), uint16(69), uint16(71),
 150817 	uint16(79), uint16(80), uint16(116), uint16(202), uint16(203), uint16(205), uint16(206), uint16(207),
 150818 	uint16(209), uint16(210), uint16(211), uint16(213), uint16(214), uint16(217), uint16(218), uint16(219),
 150819 	uint16(775), uint16(7264), uint16(10792), uint16(10795), uint16(23228), uint16(23256), uint16(30204), uint16(54721),
 150820 	uint16(54753), uint16(54754), uint16(54756), uint16(54787), uint16(54793), uint16(54809), uint16(57153), uint16(57274),
 150821 	uint16(57921), uint16(58019), uint16(58363), uint16(61722), uint16(65268), uint16(65341), uint16(65373), uint16(65406),
 150822 	uint16(65408), uint16(65410), uint16(65415), uint16(65424), uint16(65436), uint16(65439), uint16(65450), uint16(65462),
 150823 	uint16(65472), uint16(65476), uint16(65478), uint16(65480), uint16(65482), uint16(65488), uint16(65506), uint16(65511),
 150824 	uint16(65514), uint16(65521), uint16(65527), uint16(65528), uint16(65529),
 150825 }
 150826 
 150827 func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int32 {
 150828 	*(*U8)(unsafe.Pointer(aArray)) = U8(1)
 150829 	switch int32(*(*uint8)(unsafe.Pointer(zCat))) {
 150830 	case 'C':
 150831 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150832 		case 'c':
 150833 			*(*U8)(unsafe.Pointer(aArray + 1)) = U8(1)
 150834 			break
 150835 		case 'f':
 150836 			*(*U8)(unsafe.Pointer(aArray + 2)) = U8(1)
 150837 			break
 150838 		case 'n':
 150839 			*(*U8)(unsafe.Pointer(aArray + 3)) = U8(1)
 150840 			break
 150841 		case 's':
 150842 			*(*U8)(unsafe.Pointer(aArray + 4)) = U8(1)
 150843 			break
 150844 		case 'o':
 150845 			*(*U8)(unsafe.Pointer(aArray + 31)) = U8(1)
 150846 			break
 150847 		case '*':
 150848 			*(*U8)(unsafe.Pointer(aArray + 1)) = U8(1)
 150849 			*(*U8)(unsafe.Pointer(aArray + 2)) = U8(1)
 150850 			*(*U8)(unsafe.Pointer(aArray + 3)) = U8(1)
 150851 			*(*U8)(unsafe.Pointer(aArray + 4)) = U8(1)
 150852 			*(*U8)(unsafe.Pointer(aArray + 31)) = U8(1)
 150853 			break
 150854 		default:
 150855 			return 1
 150856 		}
 150857 		break
 150858 
 150859 	case 'L':
 150860 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150861 		case 'l':
 150862 			*(*U8)(unsafe.Pointer(aArray + 5)) = U8(1)
 150863 			break
 150864 		case 'm':
 150865 			*(*U8)(unsafe.Pointer(aArray + 6)) = U8(1)
 150866 			break
 150867 		case 'o':
 150868 			*(*U8)(unsafe.Pointer(aArray + 7)) = U8(1)
 150869 			break
 150870 		case 't':
 150871 			*(*U8)(unsafe.Pointer(aArray + 8)) = U8(1)
 150872 			break
 150873 		case 'u':
 150874 			*(*U8)(unsafe.Pointer(aArray + 9)) = U8(1)
 150875 			break
 150876 		case 'C':
 150877 			*(*U8)(unsafe.Pointer(aArray + 30)) = U8(1)
 150878 			break
 150879 		case '*':
 150880 			*(*U8)(unsafe.Pointer(aArray + 5)) = U8(1)
 150881 			*(*U8)(unsafe.Pointer(aArray + 6)) = U8(1)
 150882 			*(*U8)(unsafe.Pointer(aArray + 7)) = U8(1)
 150883 			*(*U8)(unsafe.Pointer(aArray + 8)) = U8(1)
 150884 			*(*U8)(unsafe.Pointer(aArray + 9)) = U8(1)
 150885 			*(*U8)(unsafe.Pointer(aArray + 30)) = U8(1)
 150886 			break
 150887 		default:
 150888 			return 1
 150889 		}
 150890 		break
 150891 
 150892 	case 'M':
 150893 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150894 		case 'c':
 150895 			*(*U8)(unsafe.Pointer(aArray + 10)) = U8(1)
 150896 			break
 150897 		case 'e':
 150898 			*(*U8)(unsafe.Pointer(aArray + 11)) = U8(1)
 150899 			break
 150900 		case 'n':
 150901 			*(*U8)(unsafe.Pointer(aArray + 12)) = U8(1)
 150902 			break
 150903 		case '*':
 150904 			*(*U8)(unsafe.Pointer(aArray + 10)) = U8(1)
 150905 			*(*U8)(unsafe.Pointer(aArray + 11)) = U8(1)
 150906 			*(*U8)(unsafe.Pointer(aArray + 12)) = U8(1)
 150907 			break
 150908 		default:
 150909 			return 1
 150910 		}
 150911 		break
 150912 
 150913 	case 'N':
 150914 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150915 		case 'd':
 150916 			*(*U8)(unsafe.Pointer(aArray + 13)) = U8(1)
 150917 			break
 150918 		case 'l':
 150919 			*(*U8)(unsafe.Pointer(aArray + 14)) = U8(1)
 150920 			break
 150921 		case 'o':
 150922 			*(*U8)(unsafe.Pointer(aArray + 15)) = U8(1)
 150923 			break
 150924 		case '*':
 150925 			*(*U8)(unsafe.Pointer(aArray + 13)) = U8(1)
 150926 			*(*U8)(unsafe.Pointer(aArray + 14)) = U8(1)
 150927 			*(*U8)(unsafe.Pointer(aArray + 15)) = U8(1)
 150928 			break
 150929 		default:
 150930 			return 1
 150931 		}
 150932 		break
 150933 
 150934 	case 'P':
 150935 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150936 		case 'c':
 150937 			*(*U8)(unsafe.Pointer(aArray + 16)) = U8(1)
 150938 			break
 150939 		case 'd':
 150940 			*(*U8)(unsafe.Pointer(aArray + 17)) = U8(1)
 150941 			break
 150942 		case 'e':
 150943 			*(*U8)(unsafe.Pointer(aArray + 18)) = U8(1)
 150944 			break
 150945 		case 'f':
 150946 			*(*U8)(unsafe.Pointer(aArray + 19)) = U8(1)
 150947 			break
 150948 		case 'i':
 150949 			*(*U8)(unsafe.Pointer(aArray + 20)) = U8(1)
 150950 			break
 150951 		case 'o':
 150952 			*(*U8)(unsafe.Pointer(aArray + 21)) = U8(1)
 150953 			break
 150954 		case 's':
 150955 			*(*U8)(unsafe.Pointer(aArray + 22)) = U8(1)
 150956 			break
 150957 		case '*':
 150958 			*(*U8)(unsafe.Pointer(aArray + 16)) = U8(1)
 150959 			*(*U8)(unsafe.Pointer(aArray + 17)) = U8(1)
 150960 			*(*U8)(unsafe.Pointer(aArray + 18)) = U8(1)
 150961 			*(*U8)(unsafe.Pointer(aArray + 19)) = U8(1)
 150962 			*(*U8)(unsafe.Pointer(aArray + 20)) = U8(1)
 150963 			*(*U8)(unsafe.Pointer(aArray + 21)) = U8(1)
 150964 			*(*U8)(unsafe.Pointer(aArray + 22)) = U8(1)
 150965 			break
 150966 		default:
 150967 			return 1
 150968 		}
 150969 		break
 150970 
 150971 	case 'S':
 150972 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150973 		case 'c':
 150974 			*(*U8)(unsafe.Pointer(aArray + 23)) = U8(1)
 150975 			break
 150976 		case 'k':
 150977 			*(*U8)(unsafe.Pointer(aArray + 24)) = U8(1)
 150978 			break
 150979 		case 'm':
 150980 			*(*U8)(unsafe.Pointer(aArray + 25)) = U8(1)
 150981 			break
 150982 		case 'o':
 150983 			*(*U8)(unsafe.Pointer(aArray + 26)) = U8(1)
 150984 			break
 150985 		case '*':
 150986 			*(*U8)(unsafe.Pointer(aArray + 23)) = U8(1)
 150987 			*(*U8)(unsafe.Pointer(aArray + 24)) = U8(1)
 150988 			*(*U8)(unsafe.Pointer(aArray + 25)) = U8(1)
 150989 			*(*U8)(unsafe.Pointer(aArray + 26)) = U8(1)
 150990 			break
 150991 		default:
 150992 			return 1
 150993 		}
 150994 		break
 150995 
 150996 	case 'Z':
 150997 		switch int32(*(*uint8)(unsafe.Pointer(zCat + 1))) {
 150998 		case 'l':
 150999 			*(*U8)(unsafe.Pointer(aArray + 27)) = U8(1)
 151000 			break
 151001 		case 'p':
 151002 			*(*U8)(unsafe.Pointer(aArray + 28)) = U8(1)
 151003 			break
 151004 		case 's':
 151005 			*(*U8)(unsafe.Pointer(aArray + 29)) = U8(1)
 151006 			break
 151007 		case '*':
 151008 			*(*U8)(unsafe.Pointer(aArray + 27)) = U8(1)
 151009 			*(*U8)(unsafe.Pointer(aArray + 28)) = U8(1)
 151010 			*(*U8)(unsafe.Pointer(aArray + 29)) = U8(1)
 151011 			break
 151012 		default:
 151013 			return 1
 151014 		}
 151015 		break
 151016 
 151017 	}
 151018 	return 0
 151019 }
 151020 
 151021 var aFts5UnicodeBlock = [17]U16{
 151022 	U16(0), U16(1471), U16(1753), U16(1760), U16(1760), U16(1760), U16(1760), U16(1760), U16(1760), U16(1760),
 151023 	U16(1760), U16(1760), U16(1760), U16(1760), U16(1760), U16(1763), U16(1765),
 151024 }
 151025 var aFts5UnicodeMap = [1765]U16{
 151026 	U16(0), U16(32), U16(33), U16(36), U16(37), U16(40), U16(41), U16(42), U16(43), U16(44),
 151027 	U16(45), U16(46), U16(48), U16(58), U16(60), U16(63), U16(65), U16(91), U16(92), U16(93),
 151028 	U16(94), U16(95), U16(96), U16(97), U16(123), U16(124), U16(125), U16(126), U16(127), U16(160),
 151029 	U16(161), U16(162), U16(166), U16(167), U16(168), U16(169), U16(170), U16(171), U16(172), U16(173),
 151030 	U16(174), U16(175), U16(176), U16(177), U16(178), U16(180), U16(181), U16(182), U16(184), U16(185),
 151031 	U16(186), U16(187), U16(188), U16(191), U16(192), U16(215), U16(216), U16(223), U16(247), U16(248),
 151032 	U16(256), U16(312), U16(313), U16(329), U16(330), U16(377), U16(383), U16(385), U16(387), U16(388),
 151033 	U16(391), U16(394), U16(396), U16(398), U16(402), U16(403), U16(405), U16(406), U16(409), U16(412),
 151034 	U16(414), U16(415), U16(417), U16(418), U16(423), U16(427), U16(428), U16(431), U16(434), U16(436),
 151035 	U16(437), U16(440), U16(442), U16(443), U16(444), U16(446), U16(448), U16(452), U16(453), U16(454),
 151036 	U16(455), U16(456), U16(457), U16(458), U16(459), U16(460), U16(461), U16(477), U16(478), U16(496),
 151037 	U16(497), U16(498), U16(499), U16(500), U16(503), U16(505), U16(506), U16(564), U16(570), U16(572),
 151038 	U16(573), U16(575), U16(577), U16(580), U16(583), U16(584), U16(592), U16(660), U16(661), U16(688),
 151039 	U16(706), U16(710), U16(722), U16(736), U16(741), U16(748), U16(749), U16(750), U16(751), U16(768),
 151040 	U16(880), U16(884), U16(885), U16(886), U16(890), U16(891), U16(894), U16(900), U16(902), U16(903),
 151041 	U16(904), U16(908), U16(910), U16(912), U16(913), U16(931), U16(940), U16(975), U16(977), U16(978),
 151042 	U16(981), U16(984), U16(1008), U16(1012), U16(1014), U16(1015), U16(1018), U16(1020), U16(1021), U16(1072),
 151043 	U16(1120), U16(1154), U16(1155), U16(1160), U16(1162), U16(1217), U16(1231), U16(1232), U16(1329), U16(1369),
 151044 	U16(1370), U16(1377), U16(1417), U16(1418), U16(1423), U16(1425), U16(1470), U16(1471), U16(1472), U16(1473),
 151045 	U16(1475), U16(1476), U16(1478), U16(1479), U16(1488), U16(1520), U16(1523), U16(1536), U16(1542), U16(1545),
 151046 	U16(1547), U16(1548), U16(1550), U16(1552), U16(1563), U16(1566), U16(1568), U16(1600), U16(1601), U16(1611),
 151047 	U16(1632), U16(1642), U16(1646), U16(1648), U16(1649), U16(1748), U16(1749), U16(1750), U16(1757), U16(1758),
 151048 	U16(1759), U16(1765), U16(1767), U16(1769), U16(1770), U16(1774), U16(1776), U16(1786), U16(1789), U16(1791),
 151049 	U16(1792), U16(1807), U16(1808), U16(1809), U16(1810), U16(1840), U16(1869), U16(1958), U16(1969), U16(1984),
 151050 	U16(1994), U16(2027), U16(2036), U16(2038), U16(2039), U16(2042), U16(2048), U16(2070), U16(2074), U16(2075),
 151051 	U16(2084), U16(2085), U16(2088), U16(2089), U16(2096), U16(2112), U16(2137), U16(2142), U16(2208), U16(2210),
 151052 	U16(2276), U16(2304), U16(2307), U16(2308), U16(2362), U16(2363), U16(2364), U16(2365), U16(2366), U16(2369),
 151053 	U16(2377), U16(2381), U16(2382), U16(2384), U16(2385), U16(2392), U16(2402), U16(2404), U16(2406), U16(2416),
 151054 	U16(2417), U16(2418), U16(2425), U16(2433), U16(2434), U16(2437), U16(2447), U16(2451), U16(2474), U16(2482),
 151055 	U16(2486), U16(2492), U16(2493), U16(2494), U16(2497), U16(2503), U16(2507), U16(2509), U16(2510), U16(2519),
 151056 	U16(2524), U16(2527), U16(2530), U16(2534), U16(2544), U16(2546), U16(2548), U16(2554), U16(2555), U16(2561),
 151057 	U16(2563), U16(2565), U16(2575), U16(2579), U16(2602), U16(2610), U16(2613), U16(2616), U16(2620), U16(2622),
 151058 	U16(2625), U16(2631), U16(2635), U16(2641), U16(2649), U16(2654), U16(2662), U16(2672), U16(2674), U16(2677),
 151059 	U16(2689), U16(2691), U16(2693), U16(2703), U16(2707), U16(2730), U16(2738), U16(2741), U16(2748), U16(2749),
 151060 	U16(2750), U16(2753), U16(2759), U16(2761), U16(2763), U16(2765), U16(2768), U16(2784), U16(2786), U16(2790),
 151061 	U16(2800), U16(2801), U16(2817), U16(2818), U16(2821), U16(2831), U16(2835), U16(2858), U16(2866), U16(2869),
 151062 	U16(2876), U16(2877), U16(2878), U16(2879), U16(2880), U16(2881), U16(2887), U16(2891), U16(2893), U16(2902),
 151063 	U16(2903), U16(2908), U16(2911), U16(2914), U16(2918), U16(2928), U16(2929), U16(2930), U16(2946), U16(2947),
 151064 	U16(2949), U16(2958), U16(2962), U16(2969), U16(2972), U16(2974), U16(2979), U16(2984), U16(2990), U16(3006),
 151065 	U16(3008), U16(3009), U16(3014), U16(3018), U16(3021), U16(3024), U16(3031), U16(3046), U16(3056), U16(3059),
 151066 	U16(3065), U16(3066), U16(3073), U16(3077), U16(3086), U16(3090), U16(3114), U16(3125), U16(3133), U16(3134),
 151067 	U16(3137), U16(3142), U16(3146), U16(3157), U16(3160), U16(3168), U16(3170), U16(3174), U16(3192), U16(3199),
 151068 	U16(3202), U16(3205), U16(3214), U16(3218), U16(3242), U16(3253), U16(3260), U16(3261), U16(3262), U16(3263),
 151069 	U16(3264), U16(3270), U16(3271), U16(3274), U16(3276), U16(3285), U16(3294), U16(3296), U16(3298), U16(3302),
 151070 	U16(3313), U16(3330), U16(3333), U16(3342), U16(3346), U16(3389), U16(3390), U16(3393), U16(3398), U16(3402),
 151071 	U16(3405), U16(3406), U16(3415), U16(3424), U16(3426), U16(3430), U16(3440), U16(3449), U16(3450), U16(3458),
 151072 	U16(3461), U16(3482), U16(3507), U16(3517), U16(3520), U16(3530), U16(3535), U16(3538), U16(3542), U16(3544),
 151073 	U16(3570), U16(3572), U16(3585), U16(3633), U16(3634), U16(3636), U16(3647), U16(3648), U16(3654), U16(3655),
 151074 	U16(3663), U16(3664), U16(3674), U16(3713), U16(3716), U16(3719), U16(3722), U16(3725), U16(3732), U16(3737),
 151075 	U16(3745), U16(3749), U16(3751), U16(3754), U16(3757), U16(3761), U16(3762), U16(3764), U16(3771), U16(3773),
 151076 	U16(3776), U16(3782), U16(3784), U16(3792), U16(3804), U16(3840), U16(3841), U16(3844), U16(3859), U16(3860),
 151077 	U16(3861), U16(3864), U16(3866), U16(3872), U16(3882), U16(3892), U16(3893), U16(3894), U16(3895), U16(3896),
 151078 	U16(3897), U16(3898), U16(3899), U16(3900), U16(3901), U16(3902), U16(3904), U16(3913), U16(3953), U16(3967),
 151079 	U16(3968), U16(3973), U16(3974), U16(3976), U16(3981), U16(3993), U16(4030), U16(4038), U16(4039), U16(4046),
 151080 	U16(4048), U16(4053), U16(4057), U16(4096), U16(4139), U16(4141), U16(4145), U16(4146), U16(4152), U16(4153),
 151081 	U16(4155), U16(4157), U16(4159), U16(4160), U16(4170), U16(4176), U16(4182), U16(4184), U16(4186), U16(4190),
 151082 	U16(4193), U16(4194), U16(4197), U16(4199), U16(4206), U16(4209), U16(4213), U16(4226), U16(4227), U16(4229),
 151083 	U16(4231), U16(4237), U16(4238), U16(4239), U16(4240), U16(4250), U16(4253), U16(4254), U16(4256), U16(4295),
 151084 	U16(4301), U16(4304), U16(4347), U16(4348), U16(4349), U16(4682), U16(4688), U16(4696), U16(4698), U16(4704),
 151085 	U16(4746), U16(4752), U16(4786), U16(4792), U16(4800), U16(4802), U16(4808), U16(4824), U16(4882), U16(4888),
 151086 	U16(4957), U16(4960), U16(4969), U16(4992), U16(5008), U16(5024), U16(5120), U16(5121), U16(5741), U16(5743),
 151087 	U16(5760), U16(5761), U16(5787), U16(5788), U16(5792), U16(5867), U16(5870), U16(5888), U16(5902), U16(5906),
 151088 	U16(5920), U16(5938), U16(5941), U16(5952), U16(5970), U16(5984), U16(5998), U16(6002), U16(6016), U16(6068),
 151089 	U16(6070), U16(6071), U16(6078), U16(6086), U16(6087), U16(6089), U16(6100), U16(6103), U16(6104), U16(6107),
 151090 	U16(6108), U16(6109), U16(6112), U16(6128), U16(6144), U16(6150), U16(6151), U16(6155), U16(6158), U16(6160),
 151091 	U16(6176), U16(6211), U16(6212), U16(6272), U16(6313), U16(6314), U16(6320), U16(6400), U16(6432), U16(6435),
 151092 	U16(6439), U16(6441), U16(6448), U16(6450), U16(6451), U16(6457), U16(6464), U16(6468), U16(6470), U16(6480),
 151093 	U16(6512), U16(6528), U16(6576), U16(6593), U16(6600), U16(6608), U16(6618), U16(6622), U16(6656), U16(6679),
 151094 	U16(6681), U16(6686), U16(6688), U16(6741), U16(6742), U16(6743), U16(6744), U16(6752), U16(6753), U16(6754),
 151095 	U16(6755), U16(6757), U16(6765), U16(6771), U16(6783), U16(6784), U16(6800), U16(6816), U16(6823), U16(6824),
 151096 	U16(6912), U16(6916), U16(6917), U16(6964), U16(6965), U16(6966), U16(6971), U16(6972), U16(6973), U16(6978),
 151097 	U16(6979), U16(6981), U16(6992), U16(7002), U16(7009), U16(7019), U16(7028), U16(7040), U16(7042), U16(7043),
 151098 	U16(7073), U16(7074), U16(7078), U16(7080), U16(7082), U16(7083), U16(7084), U16(7086), U16(7088), U16(7098),
 151099 	U16(7142), U16(7143), U16(7144), U16(7146), U16(7149), U16(7150), U16(7151), U16(7154), U16(7164), U16(7168),
 151100 	U16(7204), U16(7212), U16(7220), U16(7222), U16(7227), U16(7232), U16(7245), U16(7248), U16(7258), U16(7288),
 151101 	U16(7294), U16(7360), U16(7376), U16(7379), U16(7380), U16(7393), U16(7394), U16(7401), U16(7405), U16(7406),
 151102 	U16(7410), U16(7412), U16(7413), U16(7424), U16(7468), U16(7531), U16(7544), U16(7545), U16(7579), U16(7616),
 151103 	U16(7676), U16(7680), U16(7830), U16(7838), U16(7936), U16(7944), U16(7952), U16(7960), U16(7968), U16(7976),
 151104 	U16(7984), U16(7992), U16(8000), U16(8008), U16(8016), U16(8025), U16(8027), U16(8029), U16(8031), U16(8033),
 151105 	U16(8040), U16(8048), U16(8064), U16(8072), U16(8080), U16(8088), U16(8096), U16(8104), U16(8112), U16(8118),
 151106 	U16(8120), U16(8124), U16(8125), U16(8126), U16(8127), U16(8130), U16(8134), U16(8136), U16(8140), U16(8141),
 151107 	U16(8144), U16(8150), U16(8152), U16(8157), U16(8160), U16(8168), U16(8173), U16(8178), U16(8182), U16(8184),
 151108 	U16(8188), U16(8189), U16(8192), U16(8203), U16(8208), U16(8214), U16(8216), U16(8217), U16(8218), U16(8219),
 151109 	U16(8221), U16(8222), U16(8223), U16(8224), U16(8232), U16(8233), U16(8234), U16(8239), U16(8240), U16(8249),
 151110 	U16(8250), U16(8251), U16(8255), U16(8257), U16(8260), U16(8261), U16(8262), U16(8263), U16(8274), U16(8275),
 151111 	U16(8276), U16(8277), U16(8287), U16(8288), U16(8298), U16(8304), U16(8305), U16(8308), U16(8314), U16(8317),
 151112 	U16(8318), U16(8319), U16(8320), U16(8330), U16(8333), U16(8334), U16(8336), U16(8352), U16(8400), U16(8413),
 151113 	U16(8417), U16(8418), U16(8421), U16(8448), U16(8450), U16(8451), U16(8455), U16(8456), U16(8458), U16(8459),
 151114 	U16(8462), U16(8464), U16(8467), U16(8468), U16(8469), U16(8470), U16(8472), U16(8473), U16(8478), U16(8484),
 151115 	U16(8485), U16(8486), U16(8487), U16(8488), U16(8489), U16(8490), U16(8494), U16(8495), U16(8496), U16(8500),
 151116 	U16(8501), U16(8505), U16(8506), U16(8508), U16(8510), U16(8512), U16(8517), U16(8519), U16(8522), U16(8523),
 151117 	U16(8524), U16(8526), U16(8527), U16(8528), U16(8544), U16(8579), U16(8581), U16(8585), U16(8592), U16(8597),
 151118 	U16(8602), U16(8604), U16(8608), U16(8609), U16(8611), U16(8612), U16(8614), U16(8615), U16(8622), U16(8623),
 151119 	U16(8654), U16(8656), U16(8658), U16(8659), U16(8660), U16(8661), U16(8692), U16(8960), U16(8968), U16(8972),
 151120 	U16(8992), U16(8994), U16(9001), U16(9002), U16(9003), U16(9084), U16(9085), U16(9115), U16(9140), U16(9180),
 151121 	U16(9186), U16(9216), U16(9280), U16(9312), U16(9372), U16(9450), U16(9472), U16(9655), U16(9656), U16(9665),
 151122 	U16(9666), U16(9720), U16(9728), U16(9839), U16(9840), U16(9985), U16(10088), U16(10089), U16(10090), U16(10091),
 151123 	U16(10092), U16(10093), U16(10094), U16(10095), U16(10096), U16(10097), U16(10098), U16(10099), U16(10100), U16(10101),
 151124 	U16(10102), U16(10132), U16(10176), U16(10181), U16(10182), U16(10183), U16(10214), U16(10215), U16(10216), U16(10217),
 151125 	U16(10218), U16(10219), U16(10220), U16(10221), U16(10222), U16(10223), U16(10224), U16(10240), U16(10496), U16(10627),
 151126 	U16(10628), U16(10629), U16(10630), U16(10631), U16(10632), U16(10633), U16(10634), U16(10635), U16(10636), U16(10637),
 151127 	U16(10638), U16(10639), U16(10640), U16(10641), U16(10642), U16(10643), U16(10644), U16(10645), U16(10646), U16(10647),
 151128 	U16(10648), U16(10649), U16(10712), U16(10713), U16(10714), U16(10715), U16(10716), U16(10748), U16(10749), U16(10750),
 151129 	U16(11008), U16(11056), U16(11077), U16(11079), U16(11088), U16(11264), U16(11312), U16(11360), U16(11363), U16(11365),
 151130 	U16(11367), U16(11374), U16(11377), U16(11378), U16(11380), U16(11381), U16(11383), U16(11388), U16(11390), U16(11393),
 151131 	U16(11394), U16(11492), U16(11493), U16(11499), U16(11503), U16(11506), U16(11513), U16(11517), U16(11518), U16(11520),
 151132 	U16(11559), U16(11565), U16(11568), U16(11631), U16(11632), U16(11647), U16(11648), U16(11680), U16(11688), U16(11696),
 151133 	U16(11704), U16(11712), U16(11720), U16(11728), U16(11736), U16(11744), U16(11776), U16(11778), U16(11779), U16(11780),
 151134 	U16(11781), U16(11782), U16(11785), U16(11786), U16(11787), U16(11788), U16(11789), U16(11790), U16(11799), U16(11800),
 151135 	U16(11802), U16(11803), U16(11804), U16(11805), U16(11806), U16(11808), U16(11809), U16(11810), U16(11811), U16(11812),
 151136 	U16(11813), U16(11814), U16(11815), U16(11816), U16(11817), U16(11818), U16(11823), U16(11824), U16(11834), U16(11904),
 151137 	U16(11931), U16(12032), U16(12272), U16(12288), U16(12289), U16(12292), U16(12293), U16(12294), U16(12295), U16(12296),
 151138 	U16(12297), U16(12298), U16(12299), U16(12300), U16(12301), U16(12302), U16(12303), U16(12304), U16(12305), U16(12306),
 151139 	U16(12308), U16(12309), U16(12310), U16(12311), U16(12312), U16(12313), U16(12314), U16(12315), U16(12316), U16(12317),
 151140 	U16(12318), U16(12320), U16(12321), U16(12330), U16(12334), U16(12336), U16(12337), U16(12342), U16(12344), U16(12347),
 151141 	U16(12348), U16(12349), U16(12350), U16(12353), U16(12441), U16(12443), U16(12445), U16(12447), U16(12448), U16(12449),
 151142 	U16(12539), U16(12540), U16(12543), U16(12549), U16(12593), U16(12688), U16(12690), U16(12694), U16(12704), U16(12736),
 151143 	U16(12784), U16(12800), U16(12832), U16(12842), U16(12872), U16(12880), U16(12881), U16(12896), U16(12928), U16(12938),
 151144 	U16(12977), U16(12992), U16(13056), U16(13312), U16(19893), U16(19904), U16(19968), U16(40908), U16(40960), U16(40981),
 151145 	U16(40982), U16(42128), U16(42192), U16(42232), U16(42238), U16(42240), U16(42508), U16(42509), U16(42512), U16(42528),
 151146 	U16(42538), U16(42560), U16(42606), U16(42607), U16(42608), U16(42611), U16(42612), U16(42622), U16(42623), U16(42624),
 151147 	U16(42655), U16(42656), U16(42726), U16(42736), U16(42738), U16(42752), U16(42775), U16(42784), U16(42786), U16(42800),
 151148 	U16(42802), U16(42864), U16(42865), U16(42873), U16(42878), U16(42888), U16(42889), U16(42891), U16(42896), U16(42912),
 151149 	U16(43000), U16(43002), U16(43003), U16(43010), U16(43011), U16(43014), U16(43015), U16(43019), U16(43020), U16(43043),
 151150 	U16(43045), U16(43047), U16(43048), U16(43056), U16(43062), U16(43064), U16(43065), U16(43072), U16(43124), U16(43136),
 151151 	U16(43138), U16(43188), U16(43204), U16(43214), U16(43216), U16(43232), U16(43250), U16(43256), U16(43259), U16(43264),
 151152 	U16(43274), U16(43302), U16(43310), U16(43312), U16(43335), U16(43346), U16(43359), U16(43360), U16(43392), U16(43395),
 151153 	U16(43396), U16(43443), U16(43444), U16(43446), U16(43450), U16(43452), U16(43453), U16(43457), U16(43471), U16(43472),
 151154 	U16(43486), U16(43520), U16(43561), U16(43567), U16(43569), U16(43571), U16(43573), U16(43584), U16(43587), U16(43588),
 151155 	U16(43596), U16(43597), U16(43600), U16(43612), U16(43616), U16(43632), U16(43633), U16(43639), U16(43642), U16(43643),
 151156 	U16(43648), U16(43696), U16(43697), U16(43698), U16(43701), U16(43703), U16(43705), U16(43710), U16(43712), U16(43713),
 151157 	U16(43714), U16(43739), U16(43741), U16(43742), U16(43744), U16(43755), U16(43756), U16(43758), U16(43760), U16(43762),
 151158 	U16(43763), U16(43765), U16(43766), U16(43777), U16(43785), U16(43793), U16(43808), U16(43816), U16(43968), U16(44003),
 151159 	U16(44005), U16(44006), U16(44008), U16(44009), U16(44011), U16(44012), U16(44013), U16(44016), U16(44032), U16(55203),
 151160 	U16(55216), U16(55243), U16(55296), U16(56191), U16(56319), U16(57343), U16(57344), U16(63743), U16(63744), U16(64112),
 151161 	U16(64256), U16(64275), U16(64285), U16(64286), U16(64287), U16(64297), U16(64298), U16(64312), U16(64318), U16(64320),
 151162 	U16(64323), U16(64326), U16(64434), U16(64467), U16(64830), U16(64831), U16(64848), U16(64914), U16(65008), U16(65020),
 151163 	U16(65021), U16(65024), U16(65040), U16(65047), U16(65048), U16(65049), U16(65056), U16(65072), U16(65073), U16(65075),
 151164 	U16(65077), U16(65078), U16(65079), U16(65080), U16(65081), U16(65082), U16(65083), U16(65084), U16(65085), U16(65086),
 151165 	U16(65087), U16(65088), U16(65089), U16(65090), U16(65091), U16(65092), U16(65093), U16(65095), U16(65096), U16(65097),
 151166 	U16(65101), U16(65104), U16(65108), U16(65112), U16(65113), U16(65114), U16(65115), U16(65116), U16(65117), U16(65118),
 151167 	U16(65119), U16(65122), U16(65123), U16(65124), U16(65128), U16(65129), U16(65130), U16(65136), U16(65142), U16(65279),
 151168 	U16(65281), U16(65284), U16(65285), U16(65288), U16(65289), U16(65290), U16(65291), U16(65292), U16(65293), U16(65294),
 151169 	U16(65296), U16(65306), U16(65308), U16(65311), U16(65313), U16(65339), U16(65340), U16(65341), U16(65342), U16(65343),
 151170 	U16(65344), U16(65345), U16(65371), U16(65372), U16(65373), U16(65374), U16(65375), U16(65376), U16(65377), U16(65378),
 151171 	U16(65379), U16(65380), U16(65382), U16(65392), U16(65393), U16(65438), U16(65440), U16(65474), U16(65482), U16(65490),
 151172 	U16(65498), U16(65504), U16(65506), U16(65507), U16(65508), U16(65509), U16(65512), U16(65513), U16(65517), U16(65529),
 151173 	U16(65532), U16(0), U16(13), U16(40), U16(60), U16(63), U16(80), U16(128), U16(256), U16(263),
 151174 	U16(311), U16(320), U16(373), U16(377), U16(394), U16(400), U16(464), U16(509), U16(640), U16(672),
 151175 	U16(768), U16(800), U16(816), U16(833), U16(834), U16(842), U16(896), U16(927), U16(928), U16(968),
 151176 	U16(976), U16(977), U16(1024), U16(1064), U16(1104), U16(1184), U16(2048), U16(2056), U16(2058), U16(2103),
 151177 	U16(2108), U16(2111), U16(2135), U16(2136), U16(2304), U16(2326), U16(2335), U16(2336), U16(2367), U16(2432),
 151178 	U16(2494), U16(2560), U16(2561), U16(2565), U16(2572), U16(2576), U16(2581), U16(2585), U16(2616), U16(2623),
 151179 	U16(2624), U16(2640), U16(2656), U16(2685), U16(2687), U16(2816), U16(2873), U16(2880), U16(2904), U16(2912),
 151180 	U16(2936), U16(3072), U16(3680), U16(4096), U16(4097), U16(4098), U16(4099), U16(4152), U16(4167), U16(4178),
 151181 	U16(4198), U16(4224), U16(4226), U16(4227), U16(4272), U16(4275), U16(4279), U16(4281), U16(4283), U16(4285),
 151182 	U16(4286), U16(4304), U16(4336), U16(4352), U16(4355), U16(4391), U16(4396), U16(4397), U16(4406), U16(4416),
 151183 	U16(4480), U16(4482), U16(4483), U16(4531), U16(4534), U16(4543), U16(4545), U16(4549), U16(4560), U16(5760),
 151184 	U16(5803), U16(5804), U16(5805), U16(5806), U16(5808), U16(5814), U16(5815), U16(5824), U16(8192), U16(9216),
 151185 	U16(9328), U16(12288), U16(26624), U16(28416), U16(28496), U16(28497), U16(28559), U16(28563), U16(45056), U16(53248),
 151186 	U16(53504), U16(53545), U16(53605), U16(53607), U16(53610), U16(53613), U16(53619), U16(53627), U16(53635), U16(53637),
 151187 	U16(53644), U16(53674), U16(53678), U16(53760), U16(53826), U16(53829), U16(54016), U16(54112), U16(54272), U16(54298),
 151188 	U16(54324), U16(54350), U16(54358), U16(54376), U16(54402), U16(54428), U16(54430), U16(54434), U16(54437), U16(54441),
 151189 	U16(54446), U16(54454), U16(54459), U16(54461), U16(54469), U16(54480), U16(54506), U16(54532), U16(54535), U16(54541),
 151190 	U16(54550), U16(54558), U16(54584), U16(54587), U16(54592), U16(54598), U16(54602), U16(54610), U16(54636), U16(54662),
 151191 	U16(54688), U16(54714), U16(54740), U16(54766), U16(54792), U16(54818), U16(54844), U16(54870), U16(54896), U16(54922),
 151192 	U16(54952), U16(54977), U16(54978), U16(55003), U16(55004), U16(55010), U16(55035), U16(55036), U16(55061), U16(55062),
 151193 	U16(55068), U16(55093), U16(55094), U16(55119), U16(55120), U16(55126), U16(55151), U16(55152), U16(55177), U16(55178),
 151194 	U16(55184), U16(55209), U16(55210), U16(55235), U16(55236), U16(55242), U16(55246), U16(60928), U16(60933), U16(60961),
 151195 	U16(60964), U16(60967), U16(60969), U16(60980), U16(60985), U16(60987), U16(60994), U16(60999), U16(61001), U16(61003),
 151196 	U16(61005), U16(61009), U16(61012), U16(61015), U16(61017), U16(61019), U16(61021), U16(61023), U16(61025), U16(61028),
 151197 	U16(61031), U16(61036), U16(61044), U16(61049), U16(61054), U16(61056), U16(61067), U16(61089), U16(61093), U16(61099),
 151198 	U16(61168), U16(61440), U16(61488), U16(61600), U16(61617), U16(61633), U16(61649), U16(61696), U16(61712), U16(61744),
 151199 	U16(61808), U16(61926), U16(61968), U16(62016), U16(62032), U16(62208), U16(62256), U16(62263), U16(62336), U16(62368),
 151200 	U16(62406), U16(62432), U16(62464), U16(62528), U16(62530), U16(62713), U16(62720), U16(62784), U16(62800), U16(62971),
 151201 	U16(63045), U16(63104), U16(63232), U16(0), U16(42710), U16(42752), U16(46900), U16(46912), U16(47133), U16(63488),
 151202 	U16(1), U16(32), U16(256), U16(0), U16(65533),
 151203 }
 151204 var aFts5UnicodeData = [1765]U16{
 151205 	U16(1025), U16(61), U16(117), U16(55), U16(117), U16(54), U16(50), U16(53), U16(57), U16(53),
 151206 	U16(49), U16(85), U16(333), U16(85), U16(121), U16(85), U16(841), U16(54), U16(53), U16(50),
 151207 	U16(56), U16(48), U16(56), U16(837), U16(54), U16(57), U16(50), U16(57), U16(1057), U16(61),
 151208 	U16(53), U16(151), U16(58), U16(53), U16(56), U16(58), U16(39), U16(52), U16(57), U16(34),
 151209 	U16(58), U16(56), U16(58), U16(57), U16(79), U16(56), U16(37), U16(85), U16(56), U16(47),
 151210 	U16(39), U16(51), U16(111), U16(53), U16(745), U16(57), U16(233), U16(773), U16(57), U16(261),
 151211 	U16(1822), U16(37), U16(542), U16(37), U16(1534), U16(222), U16(69), U16(73), U16(37), U16(126),
 151212 	U16(126), U16(73), U16(69), U16(137), U16(37), U16(73), U16(37), U16(105), U16(101), U16(73),
 151213 	U16(37), U16(73), U16(37), U16(190), U16(158), U16(37), U16(126), U16(126), U16(73), U16(37),
 151214 	U16(126), U16(94), U16(37), U16(39), U16(94), U16(69), U16(135), U16(41), U16(40), U16(37),
 151215 	U16(41), U16(40), U16(37), U16(41), U16(40), U16(37), U16(542), U16(37), U16(606), U16(37),
 151216 	U16(41), U16(40), U16(37), U16(126), U16(73), U16(37), U16(1886), U16(197), U16(73), U16(37),
 151217 	U16(73), U16(69), U16(126), U16(105), U16(37), U16(286), U16(2181), U16(39), U16(869), U16(582),
 151218 	U16(152), U16(390), U16(472), U16(166), U16(248), U16(38), U16(56), U16(38), U16(568), U16(3596),
 151219 	U16(158), U16(38), U16(56), U16(94), U16(38), U16(101), U16(53), U16(88), U16(41), U16(53),
 151220 	U16(105), U16(41), U16(73), U16(37), U16(553), U16(297), U16(1125), U16(94), U16(37), U16(105),
 151221 	U16(101), U16(798), U16(133), U16(94), U16(57), U16(126), U16(94), U16(37), U16(1641), U16(1541),
 151222 	U16(1118), U16(58), U16(172), U16(75), U16(1790), U16(478), U16(37), U16(2846), U16(1225), U16(38),
 151223 	U16(213), U16(1253), U16(53), U16(49), U16(55), U16(1452), U16(49), U16(44), U16(53), U16(76),
 151224 	U16(53), U16(76), U16(53), U16(44), U16(871), U16(103), U16(85), U16(162), U16(121), U16(85),
 151225 	U16(55), U16(85), U16(90), U16(364), U16(53), U16(85), U16(1031), U16(38), U16(327), U16(684),
 151226 	U16(333), U16(149), U16(71), U16(44), U16(3175), U16(53), U16(39), U16(236), U16(34), U16(58),
 151227 	U16(204), U16(70), U16(76), U16(58), U16(140), U16(71), U16(333), U16(103), U16(90), U16(39),
 151228 	U16(469), U16(34), U16(39), U16(44), U16(967), U16(876), U16(2855), U16(364), U16(39), U16(333),
 151229 	U16(1063), U16(300), U16(70), U16(58), U16(117), U16(38), U16(711), U16(140), U16(38), U16(300),
 151230 	U16(38), U16(108), U16(38), U16(172), U16(501), U16(807), U16(108), U16(53), U16(39), U16(359),
 151231 	U16(876), U16(108), U16(42), U16(1735), U16(44), U16(42), U16(44), U16(39), U16(106), U16(268),
 151232 	U16(138), U16(44), U16(74), U16(39), U16(236), U16(327), U16(76), U16(85), U16(333), U16(53),
 151233 	U16(38), U16(199), U16(231), U16(44), U16(74), U16(263), U16(71), U16(711), U16(231), U16(39),
 151234 	U16(135), U16(44), U16(39), U16(106), U16(140), U16(74), U16(74), U16(44), U16(39), U16(42),
 151235 	U16(71), U16(103), U16(76), U16(333), U16(71), U16(87), U16(207), U16(58), U16(55), U16(76),
 151236 	U16(42), U16(199), U16(71), U16(711), U16(231), U16(71), U16(71), U16(71), U16(44), U16(106),
 151237 	U16(76), U16(76), U16(108), U16(44), U16(135), U16(39), U16(333), U16(76), U16(103), U16(44),
 151238 	U16(76), U16(42), U16(295), U16(103), U16(711), U16(231), U16(71), U16(167), U16(44), U16(39),
 151239 	U16(106), U16(172), U16(76), U16(42), U16(74), U16(44), U16(39), U16(71), U16(76), U16(333),
 151240 	U16(53), U16(55), U16(44), U16(74), U16(263), U16(71), U16(711), U16(231), U16(71), U16(167),
 151241 	U16(44), U16(39), U16(42), U16(44), U16(42), U16(140), U16(74), U16(74), U16(44), U16(44),
 151242 	U16(42), U16(71), U16(103), U16(76), U16(333), U16(58), U16(39), U16(207), U16(44), U16(39),
 151243 	U16(199), U16(103), U16(135), U16(71), U16(39), U16(71), U16(71), U16(103), U16(391), U16(74),
 151244 	U16(44), U16(74), U16(106), U16(106), U16(44), U16(39), U16(42), U16(333), U16(111), U16(218),
 151245 	U16(55), U16(58), U16(106), U16(263), U16(103), U16(743), U16(327), U16(167), U16(39), U16(108),
 151246 	U16(138), U16(108), U16(140), U16(76), U16(71), U16(71), U16(76), U16(333), U16(239), U16(58),
 151247 	U16(74), U16(263), U16(103), U16(743), U16(327), U16(167), U16(44), U16(39), U16(42), U16(44),
 151248 	U16(170), U16(44), U16(74), U16(74), U16(76), U16(74), U16(39), U16(71), U16(76), U16(333),
 151249 	U16(71), U16(74), U16(263), U16(103), U16(1319), U16(39), U16(106), U16(140), U16(106), U16(106),
 151250 	U16(44), U16(39), U16(42), U16(71), U16(76), U16(333), U16(207), U16(58), U16(199), U16(74),
 151251 	U16(583), U16(775), U16(295), U16(39), U16(231), U16(44), U16(106), U16(108), U16(44), U16(266),
 151252 	U16(74), U16(53), U16(1543), U16(44), U16(71), U16(236), U16(55), U16(199), U16(38), U16(268),
 151253 	U16(53), U16(333), U16(85), U16(71), U16(39), U16(71), U16(39), U16(39), U16(135), U16(231),
 151254 	U16(103), U16(39), U16(39), U16(71), U16(135), U16(44), U16(71), U16(204), U16(76), U16(39),
 151255 	U16(167), U16(38), U16(204), U16(333), U16(135), U16(39), U16(122), U16(501), U16(58), U16(53),
 151256 	U16(122), U16(76), U16(218), U16(333), U16(335), U16(58), U16(44), U16(58), U16(44), U16(58),
 151257 	U16(44), U16(54), U16(50), U16(54), U16(50), U16(74), U16(263), U16(1159), U16(460), U16(42),
 151258 	U16(172), U16(53), U16(76), U16(167), U16(364), U16(1164), U16(282), U16(44), U16(218), U16(90),
 151259 	U16(181), U16(154), U16(85), U16(1383), U16(74), U16(140), U16(42), U16(204), U16(42), U16(76),
 151260 	U16(74), U16(76), U16(39), U16(333), U16(213), U16(199), U16(74), U16(76), U16(135), U16(108),
 151261 	U16(39), U16(106), U16(71), U16(234), U16(103), U16(140), U16(423), U16(44), U16(74), U16(76),
 151262 	U16(202), U16(44), U16(39), U16(42), U16(333), U16(106), U16(44), U16(90), U16(1225), U16(41),
 151263 	U16(41), U16(1383), U16(53), U16(38), U16(10631), U16(135), U16(231), U16(39), U16(135), U16(1319),
 151264 	U16(135), U16(1063), U16(135), U16(231), U16(39), U16(135), U16(487), U16(1831), U16(135), U16(2151),
 151265 	U16(108), U16(309), U16(655), U16(519), U16(346), U16(2727), U16(49), U16(19847), U16(85), U16(551),
 151266 	U16(61), U16(839), U16(54), U16(50), U16(2407), U16(117), U16(110), U16(423), U16(135), U16(108),
 151267 	U16(583), U16(108), U16(85), U16(583), U16(76), U16(423), U16(103), U16(76), U16(1671), U16(76),
 151268 	U16(42), U16(236), U16(266), U16(44), U16(74), U16(364), U16(117), U16(38), U16(117), U16(55),
 151269 	U16(39), U16(44), U16(333), U16(335), U16(213), U16(49), U16(149), U16(108), U16(61), U16(333),
 151270 	U16(1127), U16(38), U16(1671), U16(1319), U16(44), U16(39), U16(2247), U16(935), U16(108), U16(138),
 151271 	U16(76), U16(106), U16(74), U16(44), U16(202), U16(108), U16(58), U16(85), U16(333), U16(967),
 151272 	U16(167), U16(1415), U16(554), U16(231), U16(74), U16(333), U16(47), U16(1114), U16(743), U16(76),
 151273 	U16(106), U16(85), U16(1703), U16(42), U16(44), U16(42), U16(236), U16(44), U16(42), U16(44),
 151274 	U16(74), U16(268), U16(202), U16(332), U16(44), U16(333), U16(333), U16(245), U16(38), U16(213),
 151275 	U16(140), U16(42), U16(1511), U16(44), U16(42), U16(172), U16(42), U16(44), U16(170), U16(44),
 151276 	U16(74), U16(231), U16(333), U16(245), U16(346), U16(300), U16(314), U16(76), U16(42), U16(967),
 151277 	U16(42), U16(140), U16(74), U16(76), U16(42), U16(44), U16(74), U16(71), U16(333), U16(1415),
 151278 	U16(44), U16(42), U16(76), U16(106), U16(44), U16(42), U16(108), U16(74), U16(149), U16(1159),
 151279 	U16(266), U16(268), U16(74), U16(76), U16(181), U16(333), U16(103), U16(333), U16(967), U16(198),
 151280 	U16(85), U16(277), U16(108), U16(53), U16(428), U16(42), U16(236), U16(135), U16(44), U16(135),
 151281 	U16(74), U16(44), U16(71), U16(1413), U16(2022), U16(421), U16(38), U16(1093), U16(1190), U16(1260),
 151282 	U16(140), U16(4830), U16(261), U16(3166), U16(261), U16(265), U16(197), U16(201), U16(261), U16(265),
 151283 	U16(261), U16(265), U16(197), U16(201), U16(261), U16(41), U16(41), U16(41), U16(94), U16(229),
 151284 	U16(265), U16(453), U16(261), U16(264), U16(261), U16(264), U16(261), U16(264), U16(165), U16(69),
 151285 	U16(137), U16(40), U16(56), U16(37), U16(120), U16(101), U16(69), U16(137), U16(40), U16(120),
 151286 	U16(133), U16(69), U16(137), U16(120), U16(261), U16(169), U16(120), U16(101), U16(69), U16(137),
 151287 	U16(40), U16(88), U16(381), U16(162), U16(209), U16(85), U16(52), U16(51), U16(54), U16(84),
 151288 	U16(51), U16(54), U16(52), U16(277), U16(59), U16(60), U16(162), U16(61), U16(309), U16(52),
 151289 	U16(51), U16(149), U16(80), U16(117), U16(57), U16(54), U16(50), U16(373), U16(57), U16(53),
 151290 	U16(48), U16(341), U16(61), U16(162), U16(194), U16(47), U16(38), U16(207), U16(121), U16(54),
 151291 	U16(50), U16(38), U16(335), U16(121), U16(54), U16(50), U16(422), U16(855), U16(428), U16(139),
 151292 	U16(44), U16(107), U16(396), U16(90), U16(41), U16(154), U16(41), U16(90), U16(37), U16(105),
 151293 	U16(69), U16(105), U16(37), U16(58), U16(41), U16(90), U16(57), U16(169), U16(218), U16(41),
 151294 	U16(58), U16(41), U16(58), U16(41), U16(58), U16(137), U16(58), U16(37), U16(137), U16(37),
 151295 	U16(135), U16(37), U16(90), U16(69), U16(73), U16(185), U16(94), U16(101), U16(58), U16(57),
 151296 	U16(90), U16(37), U16(58), U16(527), U16(1134), U16(94), U16(142), U16(47), U16(185), U16(186),
 151297 	U16(89), U16(154), U16(57), U16(90), U16(57), U16(90), U16(57), U16(250), U16(57), U16(1018),
 151298 	U16(89), U16(90), U16(57), U16(58), U16(57), U16(1018), U16(8601), U16(282), U16(153), U16(666),
 151299 	U16(89), U16(250), U16(54), U16(50), U16(2618), U16(57), U16(986), U16(825), U16(1306), U16(217),
 151300 	U16(602), U16(1274), U16(378), U16(1935), U16(2522), U16(719), U16(5882), U16(57), U16(314), U16(57),
 151301 	U16(1754), U16(281), U16(3578), U16(57), U16(4634), U16(3322), U16(54), U16(50), U16(54), U16(50),
 151302 	U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50),
 151303 	U16(975), U16(1434), U16(185), U16(54), U16(50), U16(1017), U16(54), U16(50), U16(54), U16(50),
 151304 	U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(537), U16(8218), U16(4217), U16(54),
 151305 	U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54),
 151306 	U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54),
 151307 	U16(50), U16(2041), U16(54), U16(50), U16(54), U16(50), U16(1049), U16(54), U16(50), U16(8281),
 151308 	U16(1562), U16(697), U16(90), U16(217), U16(346), U16(1513), U16(1509), U16(126), U16(73), U16(69),
 151309 	U16(254), U16(105), U16(37), U16(94), U16(37), U16(94), U16(165), U16(70), U16(105), U16(37),
 151310 	U16(3166), U16(37), U16(218), U16(158), U16(108), U16(94), U16(149), U16(47), U16(85), U16(1221),
 151311 	U16(37), U16(37), U16(1799), U16(38), U16(53), U16(44), U16(743), U16(231), U16(231), U16(231),
 151312 	U16(231), U16(231), U16(231), U16(231), U16(231), U16(1036), U16(85), U16(52), U16(51), U16(52),
 151313 	U16(51), U16(117), U16(52), U16(51), U16(53), U16(52), U16(51), U16(309), U16(49), U16(85),
 151314 	U16(49), U16(53), U16(52), U16(51), U16(85), U16(52), U16(51), U16(54), U16(50), U16(54),
 151315 	U16(50), U16(54), U16(50), U16(54), U16(50), U16(181), U16(38), U16(341), U16(81), U16(858),
 151316 	U16(2874), U16(6874), U16(410), U16(61), U16(117), U16(58), U16(38), U16(39), U16(46), U16(54),
 151317 	U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(90),
 151318 	U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(49), U16(54),
 151319 	U16(82), U16(58), U16(302), U16(140), U16(74), U16(49), U16(166), U16(90), U16(110), U16(38),
 151320 	U16(39), U16(53), U16(90), U16(2759), U16(76), U16(88), U16(70), U16(39), U16(49), U16(2887),
 151321 	U16(53), U16(102), U16(39), U16(1319), U16(3015), U16(90), U16(143), U16(346), U16(871), U16(1178),
 151322 	U16(519), U16(1018), U16(335), U16(986), U16(271), U16(58), U16(495), U16(1050), U16(335), U16(1274),
 151323 	U16(495), U16(2042), U16(8218), U16(39), U16(39), U16(2074), U16(39), U16(39), U16(679), U16(38),
 151324 	U16(36583), U16(1786), U16(1287), U16(198), U16(85), U16(8583), U16(38), U16(117), U16(519), U16(333),
 151325 	U16(71), U16(1502), U16(39), U16(44), U16(107), U16(53), U16(332), U16(53), U16(38), U16(798),
 151326 	U16(44), U16(2247), U16(334), U16(76), U16(213), U16(760), U16(294), U16(88), U16(478), U16(69),
 151327 	U16(2014), U16(38), U16(261), U16(190), U16(350), U16(38), U16(88), U16(158), U16(158), U16(382),
 151328 	U16(70), U16(37), U16(231), U16(44), U16(103), U16(44), U16(135), U16(44), U16(743), U16(74),
 151329 	U16(76), U16(42), U16(154), U16(207), U16(90), U16(55), U16(58), U16(1671), U16(149), U16(74),
 151330 	U16(1607), U16(522), U16(44), U16(85), U16(333), U16(588), U16(199), U16(117), U16(39), U16(333),
 151331 	U16(903), U16(268), U16(85), U16(743), U16(364), U16(74), U16(53), U16(935), U16(108), U16(42),
 151332 	U16(1511), U16(44), U16(74), U16(140), U16(74), U16(44), U16(138), U16(437), U16(38), U16(333),
 151333 	U16(85), U16(1319), U16(204), U16(74), U16(76), U16(74), U16(76), U16(103), U16(44), U16(263),
 151334 	U16(44), U16(42), U16(333), U16(149), U16(519), U16(38), U16(199), U16(122), U16(39), U16(42),
 151335 	U16(1543), U16(44), U16(39), U16(108), U16(71), U16(76), U16(167), U16(76), U16(39), U16(44),
 151336 	U16(39), U16(71), U16(38), U16(85), U16(359), U16(42), U16(76), U16(74), U16(85), U16(39),
 151337 	U16(70), U16(42), U16(44), U16(199), U16(199), U16(199), U16(231), U16(231), U16(1127), U16(74),
 151338 	U16(44), U16(74), U16(44), U16(74), U16(53), U16(42), U16(44), U16(333), U16(39), U16(39),
 151339 	U16(743), U16(1575), U16(36), U16(68), U16(68), U16(36), U16(63), U16(63), U16(11719), U16(3399),
 151340 	U16(229), U16(165), U16(39), U16(44), U16(327), U16(57), U16(423), U16(167), U16(39), U16(71),
 151341 	U16(71), U16(3463), U16(536), U16(11623), U16(54), U16(50), U16(2055), U16(1735), U16(391), U16(55),
 151342 	U16(58), U16(524), U16(245), U16(54), U16(50), U16(53), U16(236), U16(53), U16(81), U16(80),
 151343 	U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50),
 151344 	U16(54), U16(50), U16(54), U16(50), U16(54), U16(50), U16(85), U16(54), U16(50), U16(149),
 151345 	U16(112), U16(117), U16(149), U16(49), U16(54), U16(50), U16(54), U16(50), U16(54), U16(50),
 151346 	U16(117), U16(57), U16(49), U16(121), U16(53), U16(55), U16(85), U16(167), U16(4327), U16(34),
 151347 	U16(117), U16(55), U16(117), U16(54), U16(50), U16(53), U16(57), U16(53), U16(49), U16(85),
 151348 	U16(333), U16(85), U16(121), U16(85), U16(841), U16(54), U16(53), U16(50), U16(56), U16(48),
 151349 	U16(56), U16(837), U16(54), U16(57), U16(50), U16(57), U16(54), U16(50), U16(53), U16(54),
 151350 	U16(50), U16(85), U16(327), U16(38), U16(1447), U16(70), U16(999), U16(199), U16(199), U16(199),
 151351 	U16(103), U16(87), U16(57), U16(56), U16(58), U16(87), U16(58), U16(153), U16(90), U16(98),
 151352 	U16(90), U16(391), U16(839), U16(615), U16(71), U16(487), U16(455), U16(3943), U16(117), U16(1455),
 151353 	U16(314), U16(1710), U16(143), U16(570), U16(47), U16(410), U16(1466), U16(44), U16(935), U16(1575),
 151354 	U16(999), U16(143), U16(551), U16(46), U16(263), U16(46), U16(967), U16(53), U16(1159), U16(263),
 151355 	U16(53), U16(174), U16(1289), U16(1285), U16(2503), U16(333), U16(199), U16(39), U16(1415), U16(71),
 151356 	U16(39), U16(743), U16(53), U16(271), U16(711), U16(207), U16(53), U16(839), U16(53), U16(1799),
 151357 	U16(71), U16(39), U16(108), U16(76), U16(140), U16(135), U16(103), U16(871), U16(108), U16(44),
 151358 	U16(271), U16(309), U16(935), U16(79), U16(53), U16(1735), U16(245), U16(711), U16(271), U16(615),
 151359 	U16(271), U16(2343), U16(1007), U16(42), U16(44), U16(42), U16(1703), U16(492), U16(245), U16(655),
 151360 	U16(333), U16(76), U16(42), U16(1447), U16(106), U16(140), U16(74), U16(76), U16(85), U16(34),
 151361 	U16(149), U16(807), U16(333), U16(108), U16(1159), U16(172), U16(42), U16(268), U16(333), U16(149),
 151362 	U16(76), U16(42), U16(1543), U16(106), U16(300), U16(74), U16(135), U16(149), U16(333), U16(1383),
 151363 	U16(44), U16(42), U16(44), U16(74), U16(204), U16(42), U16(44), U16(333), U16(28135), U16(3182),
 151364 	U16(149), U16(34279), U16(18215), U16(2215), U16(39), U16(1482), U16(140), U16(422), U16(71), U16(7898),
 151365 	U16(1274), U16(1946), U16(74), U16(108), U16(122), U16(202), U16(258), U16(268), U16(90), U16(236),
 151366 	U16(986), U16(140), U16(1562), U16(2138), U16(108), U16(58), U16(2810), U16(591), U16(841), U16(837),
 151367 	U16(841), U16(229), U16(581), U16(841), U16(837), U16(41), U16(73), U16(41), U16(73), U16(137),
 151368 	U16(265), U16(133), U16(37), U16(229), U16(357), U16(841), U16(837), U16(73), U16(137), U16(265),
 151369 	U16(233), U16(837), U16(73), U16(137), U16(169), U16(41), U16(233), U16(837), U16(841), U16(837),
 151370 	U16(841), U16(837), U16(841), U16(837), U16(841), U16(837), U16(841), U16(837), U16(841), U16(901),
 151371 	U16(809), U16(57), U16(805), U16(57), U16(197), U16(809), U16(57), U16(805), U16(57), U16(197),
 151372 	U16(809), U16(57), U16(805), U16(57), U16(197), U16(809), U16(57), U16(805), U16(57), U16(197),
 151373 	U16(809), U16(57), U16(805), U16(57), U16(197), U16(94), U16(1613), U16(135), U16(871), U16(71),
 151374 	U16(39), U16(39), U16(327), U16(135), U16(39), U16(39), U16(39), U16(39), U16(39), U16(39),
 151375 	U16(103), U16(71), U16(39), U16(39), U16(39), U16(39), U16(39), U16(39), U16(71), U16(39),
 151376 	U16(135), U16(231), U16(135), U16(135), U16(39), U16(327), U16(551), U16(103), U16(167), U16(551),
 151377 	U16(89), U16(1434), U16(3226), U16(506), U16(474), U16(506), U16(506), U16(367), U16(1018), U16(1946),
 151378 	U16(1402), U16(954), U16(1402), U16(314), U16(90), U16(1082), U16(218), U16(2266), U16(666), U16(1210),
 151379 	U16(186), U16(570), U16(2042), U16(58), U16(5850), U16(154), U16(2010), U16(154), U16(794), U16(2266),
 151380 	U16(378), U16(2266), U16(3738), U16(39), U16(39), U16(39), U16(39), U16(39), U16(39), U16(17351),
 151381 	U16(34), U16(3074), U16(7692), U16(63), U16(63),
 151382 }
 151383 
 151384 func sqlite3Fts5UnicodeCategory(tls *libc.TLS, iCode U32) int32 {
 151385 	var iRes int32 = -1
 151386 	var iHi int32
 151387 	var iLo int32
 151388 	var ret int32
 151389 	var iKey U16
 151390 
 151391 	if iCode >= U32(int32(1)<<20) {
 151392 		return 0
 151393 	}
 151394 	iLo = int32(aFts5UnicodeBlock[iCode>>16])
 151395 	iHi = int32(aFts5UnicodeBlock[U32(1)+iCode>>16])
 151396 	iKey = U16(iCode & U32(0xFFFF))
 151397 	for iHi > iLo {
 151398 		var iTest int32 = (iHi + iLo) / 2
 151399 
 151400 		if int32(iKey) >= int32(aFts5UnicodeMap[iTest]) {
 151401 			iRes = iTest
 151402 			iLo = iTest + 1
 151403 		} else {
 151404 			iHi = iTest
 151405 		}
 151406 	}
 151407 
 151408 	if iRes < 0 {
 151409 		return 0
 151410 	}
 151411 	if int32(iKey) >= int32(aFts5UnicodeMap[iRes])+int32(aFts5UnicodeData[iRes])>>5 {
 151412 		return 0
 151413 	}
 151414 	ret = int32(aFts5UnicodeData[iRes]) & 0x1F
 151415 	if ret != 30 {
 151416 		return ret
 151417 	}
 151418 	if (int32(iKey)-int32(aFts5UnicodeMap[iRes]))&0x01 != 0 {
 151419 		return 5
 151420 	}
 151421 	return 9
 151422 }
 151423 
 151424 func sqlite3Fts5UnicodeAscii(tls *libc.TLS, aArray uintptr, aAscii uintptr) {
 151425 	var i int32 = 0
 151426 	var iTbl int32 = 0
 151427 	for i < 128 {
 151428 		var bToken int32 = int32(*(*U8)(unsafe.Pointer(aArray + uintptr(int32(aFts5UnicodeData[iTbl])&0x1F))))
 151429 		var n int32 = int32(aFts5UnicodeData[iTbl])>>5 + i
 151430 		for ; i < 128 && i < n; i++ {
 151431 			*(*U8)(unsafe.Pointer(aAscii + uintptr(i))) = U8(bToken)
 151432 		}
 151433 		iTbl++
 151434 	}
 151435 	*(*U8)(unsafe.Pointer(aAscii)) = U8(0)
 151436 }
 151437 
 151438 func sqlite3Fts5GetVarint32(tls *libc.TLS, p uintptr, v uintptr) int32 {
 151439 	bp := tls.Alloc(8)
 151440 	defer tls.Free(8)
 151441 
 151442 	var a U32
 151443 	var b U32
 151444 
 151445 	a = U32(*(*uint8)(unsafe.Pointer(p)))
 151446 
 151447 	if !(a&U32(0x80) != 0) {
 151448 		*(*U32)(unsafe.Pointer(v)) = a
 151449 		return 1
 151450 	}
 151451 
 151452 	p++
 151453 	b = U32(*(*uint8)(unsafe.Pointer(p)))
 151454 
 151455 	if !(b&U32(0x80) != 0) {
 151456 		a = a & U32(0x7f)
 151457 		a = a << 7
 151458 		*(*U32)(unsafe.Pointer(v)) = a | b
 151459 		return 2
 151460 	}
 151461 
 151462 	p++
 151463 	a = a << 14
 151464 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
 151465 
 151466 	if !(a&U32(0x80) != 0) {
 151467 		a = a & U32(int32(0x7f)<<14|0x7f)
 151468 		b = b & U32(0x7f)
 151469 		b = b << 7
 151470 		*(*U32)(unsafe.Pointer(v)) = a | b
 151471 		return 3
 151472 	}
 151473 
 151474 	{
 151475 		var n U8
 151476 		p -= uintptr(2)
 151477 		n = sqlite3Fts5GetVarint(tls, p, bp)
 151478 		*(*U32)(unsafe.Pointer(v)) = U32(*(*U64)(unsafe.Pointer(bp))) & U32(0x7FFFFFFF)
 151479 
 151480 		return int32(n)
 151481 
 151482 	}
 151483 	return int32(0)
 151484 }
 151485 
 151486 func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 {
 151487 	var a U32
 151488 	var b U32
 151489 	var s U32
 151490 
 151491 	a = U32(*(*uint8)(unsafe.Pointer(p)))
 151492 
 151493 	if !(a&U32(0x80) != 0) {
 151494 		*(*U64)(unsafe.Pointer(v)) = U64(a)
 151495 		return U8(1)
 151496 	}
 151497 
 151498 	p++
 151499 	b = U32(*(*uint8)(unsafe.Pointer(p)))
 151500 
 151501 	if !(b&U32(0x80) != 0) {
 151502 		a = a & U32(0x7f)
 151503 		a = a << 7
 151504 		a = a | b
 151505 		*(*U64)(unsafe.Pointer(v)) = U64(a)
 151506 		return U8(2)
 151507 	}
 151508 
 151509 	p++
 151510 	a = a << 14
 151511 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
 151512 
 151513 	if !(a&U32(0x80) != 0) {
 151514 		a = a & U32(SLOT_2_0)
 151515 		b = b & U32(0x7f)
 151516 		b = b << 7
 151517 		a = a | b
 151518 		*(*U64)(unsafe.Pointer(v)) = U64(a)
 151519 		return U8(3)
 151520 	}
 151521 
 151522 	a = a & U32(SLOT_2_0)
 151523 	p++
 151524 	b = b << 14
 151525 	b = b | U32(*(*uint8)(unsafe.Pointer(p)))
 151526 
 151527 	if !(b&U32(0x80) != 0) {
 151528 		b = b & U32(SLOT_2_0)
 151529 
 151530 		a = a << 7
 151531 		a = a | b
 151532 		*(*U64)(unsafe.Pointer(v)) = U64(a)
 151533 		return U8(4)
 151534 	}
 151535 
 151536 	b = b & U32(SLOT_2_0)
 151537 	s = a
 151538 
 151539 	p++
 151540 	a = a << 14
 151541 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
 151542 
 151543 	if !(a&U32(0x80) != 0) {
 151544 		b = b << 7
 151545 		a = a | b
 151546 		s = s >> 18
 151547 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
 151548 		return U8(5)
 151549 	}
 151550 
 151551 	s = s << 7
 151552 	s = s | b
 151553 
 151554 	p++
 151555 	b = b << 14
 151556 	b = b | U32(*(*uint8)(unsafe.Pointer(p)))
 151557 
 151558 	if !(b&U32(0x80) != 0) {
 151559 		a = a & U32(SLOT_2_0)
 151560 		a = a << 7
 151561 		a = a | b
 151562 		s = s >> 18
 151563 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
 151564 		return U8(6)
 151565 	}
 151566 
 151567 	p++
 151568 	a = a << 14
 151569 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
 151570 
 151571 	if !(a&U32(0x80) != 0) {
 151572 		a = a & SLOT_4_2_0
 151573 		b = b & U32(SLOT_2_0)
 151574 		b = b << 7
 151575 		a = a | b
 151576 		s = s >> 11
 151577 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
 151578 		return U8(7)
 151579 	}
 151580 
 151581 	a = a & U32(SLOT_2_0)
 151582 	p++
 151583 	b = b << 14
 151584 	b = b | U32(*(*uint8)(unsafe.Pointer(p)))
 151585 
 151586 	if !(b&U32(0x80) != 0) {
 151587 		b = b & SLOT_4_2_0
 151588 
 151589 		a = a << 7
 151590 		a = a | b
 151591 		s = s >> 4
 151592 		*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
 151593 		return U8(8)
 151594 	}
 151595 
 151596 	p++
 151597 	a = a << 15
 151598 	a = a | U32(*(*uint8)(unsafe.Pointer(p)))
 151599 
 151600 	b = b & U32(SLOT_2_0)
 151601 	b = b << 8
 151602 	a = a | b
 151603 
 151604 	s = s << 4
 151605 	b = U32(*(*uint8)(unsafe.Pointer(p + libc.UintptrFromInt32(-4))))
 151606 	b = b & U32(0x7f)
 151607 	b = b >> 3
 151608 	s = s | b
 151609 
 151610 	*(*U64)(unsafe.Pointer(v)) = U64(s)<<32 | U64(a)
 151611 
 151612 	return U8(9)
 151613 }
 151614 
 151615 func fts5PutVarint64(tls *libc.TLS, p uintptr, v U64) int32 {
 151616 	bp := tls.Alloc(10)
 151617 	defer tls.Free(10)
 151618 
 151619 	var i int32
 151620 	var j int32
 151621 	var n int32
 151622 
 151623 	if v&(uint64(0xff000000)<<32) != 0 {
 151624 		*(*uint8)(unsafe.Pointer(p + 8)) = U8(v)
 151625 		v >>= 8
 151626 		for i = 7; i >= 0; i-- {
 151627 			*(*uint8)(unsafe.Pointer(p + uintptr(i))) = U8(v&uint64(0x7f) | uint64(0x80))
 151628 			v >>= 7
 151629 		}
 151630 		return 9
 151631 	}
 151632 	n = 0
 151633 	for __ccgo := true; __ccgo; __ccgo = v != uint64(0) {
 151634 		*(*U8)(unsafe.Pointer(bp + uintptr(libc.PostIncInt32(&n, 1)))) = U8(v&uint64(0x7f) | uint64(0x80))
 151635 		v >>= 7
 151636 	}
 151637 	*(*U8)(unsafe.Pointer(bp)) &= U8(0x7f)
 151638 
 151639 	i = 0
 151640 	j = n - 1
 151641 __1:
 151642 	if !(j >= 0) {
 151643 		goto __3
 151644 	}
 151645 	{
 151646 		*(*uint8)(unsafe.Pointer(p + uintptr(i))) = *(*U8)(unsafe.Pointer(bp + uintptr(j)))
 151647 
 151648 	}
 151649 	goto __2
 151650 __2:
 151651 	j--
 151652 	i++
 151653 	goto __1
 151654 	goto __3
 151655 __3:
 151656 	;
 151657 	return n
 151658 }
 151659 
 151660 func sqlite3Fts5PutVarint(tls *libc.TLS, p uintptr, v U64) int32 {
 151661 	if v <= uint64(0x7f) {
 151662 		*(*uint8)(unsafe.Pointer(p)) = uint8(v & uint64(0x7f))
 151663 		return 1
 151664 	}
 151665 	if v <= uint64(0x3fff) {
 151666 		*(*uint8)(unsafe.Pointer(p)) = uint8(v>>7&uint64(0x7f) | uint64(0x80))
 151667 		*(*uint8)(unsafe.Pointer(p + 1)) = uint8(v & uint64(0x7f))
 151668 		return 2
 151669 	}
 151670 	return fts5PutVarint64(tls, p, v)
 151671 }
 151672 
 151673 func sqlite3Fts5GetVarintLen(tls *libc.TLS, iVal U32) int32 {
 151674 	if iVal < U32(int32(1)<<14) {
 151675 		return 2
 151676 	}
 151677 	if iVal < U32(int32(1)<<21) {
 151678 		return 3
 151679 	}
 151680 	if iVal < U32(int32(1)<<28) {
 151681 		return 4
 151682 	}
 151683 	return 5
 151684 }
 151685 
 151686 type Fts5VocabTable1 = struct {
 151687 	Fbase     Sqlite3_vtab
 151688 	FzFts5Tbl uintptr
 151689 	FzFts5Db  uintptr
 151690 	Fdb       uintptr
 151691 	FpGlobal  uintptr
 151692 	FeType    int32
 151693 	FbBusy    uint32
 151694 }
 151695 
 151696 type Fts5VocabTable = Fts5VocabTable1
 151697 type Fts5VocabCursor1 = struct {
 151698 	Fbase        Sqlite3_vtab_cursor
 151699 	FpStmt       uintptr
 151700 	FpFts5       uintptr
 151701 	FbEof        int32
 151702 	FpIter       uintptr
 151703 	FpStruct     uintptr
 151704 	FnLeTerm     int32
 151705 	FzLeTerm     uintptr
 151706 	FiCol        int32
 151707 	FaCnt        uintptr
 151708 	FaDoc        uintptr
 151709 	F__ccgo_pad1 [4]byte
 151710 	Frowid       I64
 151711 	Fterm        Fts5Buffer
 151712 	F__ccgo_pad2 [4]byte
 151713 	FiInstPos    I64
 151714 	FiInstOff    int32
 151715 	F__ccgo_pad3 [4]byte
 151716 }
 151717 
 151718 type Fts5VocabCursor = Fts5VocabCursor1
 151719 
 151720 func fts5VocabTableType(tls *libc.TLS, zType uintptr, pzErr uintptr, peType uintptr) int32 {
 151721 	bp := tls.Alloc(12)
 151722 	defer tls.Free(12)
 151723 
 151724 	*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_OK
 151725 	var zCopy uintptr = sqlite3Fts5Strndup(tls, bp+8, zType, -1)
 151726 	if *(*int32)(unsafe.Pointer(bp + 8)) == SQLITE_OK {
 151727 		sqlite3Fts5Dequote(tls, zCopy)
 151728 		if Xsqlite3_stricmp(tls, zCopy, ts+37375) == 0 {
 151729 			*(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_COL
 151730 		} else if Xsqlite3_stricmp(tls, zCopy, ts+37379) == 0 {
 151731 			*(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_ROW
 151732 		} else if Xsqlite3_stricmp(tls, zCopy, ts+37383) == 0 {
 151733 			*(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_INSTANCE
 151734 		} else {
 151735 			*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+37392, libc.VaList(bp, zCopy))
 151736 			*(*int32)(unsafe.Pointer(bp + 8)) = SQLITE_ERROR
 151737 		}
 151738 		Xsqlite3_free(tls, zCopy)
 151739 	}
 151740 
 151741 	return *(*int32)(unsafe.Pointer(bp + 8))
 151742 }
 151743 
 151744 func fts5VocabDisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 {
 151745 	var pTab uintptr = pVtab
 151746 	Xsqlite3_free(tls, pTab)
 151747 	return SQLITE_OK
 151748 }
 151749 
 151750 func fts5VocabDestroyMethod(tls *libc.TLS, pVtab uintptr) int32 {
 151751 	var pTab uintptr = pVtab
 151752 	Xsqlite3_free(tls, pTab)
 151753 	return SQLITE_OK
 151754 }
 151755 
 151756 func fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) int32 {
 151757 	bp := tls.Alloc(20)
 151758 	defer tls.Free(20)
 151759 
 151760 	*(*[3]uintptr)(unsafe.Pointer(bp + 4)) = [3]uintptr{
 151761 		ts + 37426,
 151762 		ts + 37466,
 151763 		ts + 37501,
 151764 	}
 151765 
 151766 	var pRet uintptr = uintptr(0)
 151767 	*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_OK
 151768 	var bDb int32
 151769 
 151770 	bDb = libc.Bool32(argc == 6 && libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*4))) == Size_t(4) && libc.Xmemcmp(tls, ts+23399, *(*uintptr)(unsafe.Pointer(argv + 1*4)), uint32(4)) == 0)
 151771 
 151772 	if argc != 5 && bDb == 0 {
 151773 		*(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+37544, 0)
 151774 		*(*int32)(unsafe.Pointer(bp + 16)) = SQLITE_ERROR
 151775 	} else {
 151776 		var nByte int32
 151777 		var zDb uintptr
 151778 		if bDb != 0 {
 151779 			zDb = *(*uintptr)(unsafe.Pointer(argv + 3*4))
 151780 		} else {
 151781 			zDb = *(*uintptr)(unsafe.Pointer(argv + 1*4))
 151782 		}
 151783 		var zTab uintptr
 151784 		if bDb != 0 {
 151785 			zTab = *(*uintptr)(unsafe.Pointer(argv + 4*4))
 151786 		} else {
 151787 			zTab = *(*uintptr)(unsafe.Pointer(argv + 3*4))
 151788 		}
 151789 		var zType uintptr
 151790 		if bDb != 0 {
 151791 			zType = *(*uintptr)(unsafe.Pointer(argv + 5*4))
 151792 		} else {
 151793 			zType = *(*uintptr)(unsafe.Pointer(argv + 4*4))
 151794 		}
 151795 		var nDb int32 = int32(libc.Xstrlen(tls, zDb)) + 1
 151796 		var nTab int32 = int32(libc.Xstrlen(tls, zTab)) + 1
 151797 		*(*int32)(unsafe.Pointer(bp)) = 0
 151798 
 151799 		*(*int32)(unsafe.Pointer(bp + 16)) = fts5VocabTableType(tls, zType, pzErr, bp)
 151800 		if *(*int32)(unsafe.Pointer(bp + 16)) == SQLITE_OK {
 151801 			*(*int32)(unsafe.Pointer(bp + 16)) = Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp + 4 + uintptr(*(*int32)(unsafe.Pointer(bp)))*4)))
 151802 		}
 151803 
 151804 		nByte = int32(uint32(unsafe.Sizeof(Fts5VocabTable{})) + uint32(nDb) + uint32(nTab))
 151805 		pRet = sqlite3Fts5MallocZero(tls, bp+16, int64(nByte))
 151806 		if pRet != 0 {
 151807 			(*Fts5VocabTable)(unsafe.Pointer(pRet)).FpGlobal = pAux
 151808 			(*Fts5VocabTable)(unsafe.Pointer(pRet)).FeType = *(*int32)(unsafe.Pointer(bp))
 151809 			(*Fts5VocabTable)(unsafe.Pointer(pRet)).Fdb = db
 151810 			(*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = pRet + 1*36
 151811 			(*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db = (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl + uintptr(nTab)
 151812 			libc.Xmemcpy(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl, zTab, uint32(nTab))
 151813 			libc.Xmemcpy(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db, zDb, uint32(nDb))
 151814 			sqlite3Fts5Dequote(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl)
 151815 			sqlite3Fts5Dequote(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db)
 151816 		}
 151817 	}
 151818 
 151819 	*(*uintptr)(unsafe.Pointer(ppVTab)) = pRet
 151820 	return *(*int32)(unsafe.Pointer(bp + 16))
 151821 }
 151822 
 151823 func fts5VocabConnectMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 151824 	return fts5VocabInitVtab(tls, db, pAux, argc, argv, ppVtab, pzErr)
 151825 }
 151826 
 151827 func fts5VocabCreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 {
 151828 	return fts5VocabInitVtab(tls, db, pAux, argc, argv, ppVtab, pzErr)
 151829 }
 151830 
 151831 func fts5VocabBestIndexMethod(tls *libc.TLS, pUnused uintptr, pInfo uintptr) int32 {
 151832 	var i int32
 151833 	var iTermEq int32 = -1
 151834 	var iTermGe int32 = -1
 151835 	var iTermLe int32 = -1
 151836 	var idxNum int32 = 0
 151837 	var nArg int32 = 0
 151838 
 151839 	_ = pUnused
 151840 
 151841 	for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ {
 151842 		var p uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12
 151843 		if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 {
 151844 			continue
 151845 		}
 151846 		if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 {
 151847 			if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ {
 151848 				iTermEq = i
 151849 			}
 151850 			if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LE {
 151851 				iTermLe = i
 151852 			}
 151853 			if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LT {
 151854 				iTermLe = i
 151855 			}
 151856 			if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GE {
 151857 				iTermGe = i
 151858 			}
 151859 			if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GT {
 151860 				iTermGe = i
 151861 			}
 151862 		}
 151863 	}
 151864 
 151865 	if iTermEq >= 0 {
 151866 		idxNum = idxNum | FTS5_VOCAB_TERM_EQ
 151867 		(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermEq)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1)
 151868 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(100)
 151869 	} else {
 151870 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(1000000)
 151871 		if iTermGe >= 0 {
 151872 			idxNum = idxNum | FTS5_VOCAB_TERM_GE
 151873 			(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermGe)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1)
 151874 			(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / float64(2)
 151875 		}
 151876 		if iTermLe >= 0 {
 151877 			idxNum = idxNum | FTS5_VOCAB_TERM_LE
 151878 			(*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermLe)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1)
 151879 			(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / float64(2)
 151880 		}
 151881 	}
 151882 
 151883 	if (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == 1 &&
 151884 		(*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).FiColumn == 0 &&
 151885 		int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).Fdesc) == 0 {
 151886 		(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = 1
 151887 	}
 151888 
 151889 	(*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxNum
 151890 	return SQLITE_OK
 151891 }
 151892 
 151893 func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 {
 151894 	bp := tls.Alloc(72)
 151895 	defer tls.Free(72)
 151896 
 151897 	var pTab uintptr = pVTab
 151898 	var pFts5 uintptr = uintptr(0)
 151899 	var pCsr uintptr = uintptr(0)
 151900 	*(*int32)(unsafe.Pointer(bp + 64)) = SQLITE_OK
 151901 	*(*uintptr)(unsafe.Pointer(bp + 68)) = uintptr(0)
 151902 	var zSql uintptr = uintptr(0)
 151903 
 151904 	if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy != 0 {
 151905 		(*Sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls,
 151906 			ts+37577, libc.VaList(bp, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl))
 151907 		return SQLITE_ERROR
 151908 	}
 151909 	zSql = sqlite3Fts5Mprintf(tls, bp+64,
 151910 		ts+37608,
 151911 		libc.VaList(bp+16, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl))
 151912 	if zSql != 0 {
 151913 		*(*int32)(unsafe.Pointer(bp + 64)) = Xsqlite3_prepare_v2(tls, (*Fts5VocabTable)(unsafe.Pointer(pTab)).Fdb, zSql, -1, bp+68, uintptr(0))
 151914 	}
 151915 	Xsqlite3_free(tls, zSql)
 151916 
 151917 	if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_ERROR {
 151918 		*(*int32)(unsafe.Pointer(bp + 64)) = SQLITE_OK
 151919 	}
 151920 
 151921 	(*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(1)
 151922 	if *(*uintptr)(unsafe.Pointer(bp + 68)) != 0 && Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 68))) == SQLITE_ROW {
 151923 		var iId I64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 68)), 0)
 151924 		pFts5 = sqlite3Fts5TableFromCsrid(tls, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FpGlobal, iId)
 151925 	}
 151926 	(*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(0)
 151927 
 151928 	if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_OK {
 151929 		if pFts5 == uintptr(0) {
 151930 			*(*int32)(unsafe.Pointer(bp + 64)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 68)))
 151931 			*(*uintptr)(unsafe.Pointer(bp + 68)) = uintptr(0)
 151932 			if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_OK {
 151933 				(*Sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls,
 151934 					ts+37659, libc.VaList(bp+48, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl))
 151935 				*(*int32)(unsafe.Pointer(bp + 64)) = SQLITE_ERROR
 151936 			}
 151937 		} else {
 151938 			*(*int32)(unsafe.Pointer(bp + 64)) = sqlite3Fts5FlushToDisk(tls, pFts5)
 151939 		}
 151940 	}
 151941 
 151942 	if *(*int32)(unsafe.Pointer(bp + 64)) == SQLITE_OK {
 151943 		var nByte I64 = I64(uint32((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol)*uint32(unsafe.Sizeof(I64(0)))*uint32(2) + uint32(unsafe.Sizeof(Fts5VocabCursor{})))
 151944 		pCsr = sqlite3Fts5MallocZero(tls, bp+64, nByte)
 151945 	}
 151946 
 151947 	if pCsr != 0 {
 151948 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5 = pFts5
 151949 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt = *(*uintptr)(unsafe.Pointer(bp + 68))
 151950 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt = pCsr + 1*88
 151951 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol)*8
 151952 	} else {
 151953 		Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 68)))
 151954 	}
 151955 
 151956 	*(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr
 151957 	return *(*int32)(unsafe.Pointer(bp + 64))
 151958 }
 151959 
 151960 func fts5VocabResetCursor(tls *libc.TLS, pCsr uintptr) {
 151961 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid = int64(0)
 151962 	sqlite3Fts5IterClose(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)
 151963 	sqlite3Fts5StructureRelease(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct)
 151964 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct = uintptr(0)
 151965 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter = uintptr(0)
 151966 	Xsqlite3_free(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm)
 151967 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm = -1
 151968 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm = uintptr(0)
 151969 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 0
 151970 }
 151971 
 151972 func fts5VocabCloseMethod(tls *libc.TLS, pCursor uintptr) int32 {
 151973 	var pCsr uintptr = pCursor
 151974 	fts5VocabResetCursor(tls, pCsr)
 151975 	sqlite3Fts5BufferFree(tls, pCsr+56)
 151976 	Xsqlite3_finalize(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt)
 151977 	Xsqlite3_free(tls, pCsr)
 151978 	return SQLITE_OK
 151979 }
 151980 
 151981 func fts5VocabInstanceNewTerm(tls *libc.TLS, pCsr uintptr) int32 {
 151982 	bp := tls.Alloc(8)
 151983 	defer tls.Free(8)
 151984 
 151985 	*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_OK
 151986 
 151987 	if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 {
 151988 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1
 151989 	} else {
 151990 		var zTerm uintptr
 151991 
 151992 		zTerm = sqlite3Fts5IterTerm(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp)
 151993 		if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm >= 0 {
 151994 			var nCmp int32 = func() int32 {
 151995 				if *(*int32)(unsafe.Pointer(bp)) < (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm {
 151996 					return *(*int32)(unsafe.Pointer(bp))
 151997 				}
 151998 				return (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm
 151999 			}()
 152000 			var bCmp int32 = libc.Xmemcmp(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, uint32(nCmp))
 152001 			if bCmp < 0 || bCmp == 0 && (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < *(*int32)(unsafe.Pointer(bp)) {
 152002 				(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1
 152003 			}
 152004 		}
 152005 
 152006 		sqlite3Fts5BufferSet(tls, bp+4, pCsr+56, *(*int32)(unsafe.Pointer(bp)), zTerm)
 152007 	}
 152008 	return *(*int32)(unsafe.Pointer(bp + 4))
 152009 }
 152010 
 152011 func fts5VocabInstanceNext(tls *libc.TLS, pCsr uintptr) int32 {
 152012 	var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail
 152013 	var rc int32 = SQLITE_OK
 152014 	var pIter uintptr = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter
 152015 	var pp uintptr = pCsr + 72
 152016 	var po uintptr = pCsr + 80
 152017 
 152018 	for eDetail == FTS5_DETAIL_NONE ||
 152019 		sqlite3Fts5PoslistNext64(tls, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, po, pp) != 0 {
 152020 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos = int64(0)
 152021 		(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstOff = 0
 152022 
 152023 		rc = sqlite3Fts5IterNextScan(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)
 152024 		if rc == SQLITE_OK {
 152025 			rc = fts5VocabInstanceNewTerm(tls, pCsr)
 152026 			if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0 || eDetail == FTS5_DETAIL_NONE {
 152027 				break
 152028 			}
 152029 		}
 152030 		if rc != 0 {
 152031 			(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1
 152032 			break
 152033 		}
 152034 	}
 152035 
 152036 	return rc
 152037 }
 152038 
 152039 func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 {
 152040 	bp := tls.Alloc(24)
 152041 	defer tls.Free(24)
 152042 
 152043 	var pCsr uintptr = pCursor
 152044 	var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab
 152045 	var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol
 152046 
 152047 	*(*int32)(unsafe.Pointer(bp + 4)) = sqlite3Fts5StructureTest(tls, (*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct)
 152048 	if *(*int32)(unsafe.Pointer(bp + 4)) != SQLITE_OK {
 152049 		return *(*int32)(unsafe.Pointer(bp + 4))
 152050 	}
 152051 	(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid++
 152052 
 152053 	if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_INSTANCE {
 152054 		return fts5VocabInstanceNext(tls, pCsr)
 152055 	}
 152056 
 152057 	if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL {
 152058 		for (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++ {
 152059 			if *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) != 0 {
 152060 				break
 152061 			}
 152062 		}
 152063 	}
 152064 
 152065 	if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType != FTS5_VOCAB_COL || (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol {
 152066 		if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 {
 152067 			(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1
 152068 		} else {
 152069 			var zTerm uintptr
 152070 
 152071 			zTerm = sqlite3Fts5IterTerm(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp)
 152072 
 152073 			if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm >= 0 {
 152074 				var nCmp int32 = func() int32 {
 152075 					if *(*int32)(unsafe.Pointer(bp)) < (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm {
 152076 						return *(*int32)(unsafe.Pointer(bp))
 152077 					}
 152078 					return (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm
 152079 				}()
 152080 				var bCmp int32 = libc.Xmemcmp(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, uint32(nCmp))
 152081 				if bCmp < 0 || bCmp == 0 && (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < *(*int32)(unsafe.Pointer(bp)) {
 152082 					(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1
 152083 					return SQLITE_OK
 152084 				}
 152085 			}
 152086 
 152087 			sqlite3Fts5BufferSet(tls, bp+4, pCsr+56, *(*int32)(unsafe.Pointer(bp)), zTerm)
 152088 			libc.Xmemset(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt, 0, uint32(nCol)*uint32(unsafe.Sizeof(I64(0))))
 152089 			libc.Xmemset(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc, 0, uint32(nCol)*uint32(unsafe.Sizeof(I64(0))))
 152090 			(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = 0
 152091 
 152092 			for *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 152093 				var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail
 152094 				var pPos uintptr
 152095 				var nPos int32
 152096 				*(*I64)(unsafe.Pointer(bp + 16)) = int64(0)
 152097 				*(*int32)(unsafe.Pointer(bp + 8)) = 0
 152098 
 152099 				pPos = (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FpData
 152100 				nPos = (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FnData
 152101 
 152102 				switch (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType {
 152103 				case FTS5_VOCAB_ROW:
 152104 					if eDetail == FTS5_DETAIL_FULL {
 152105 						for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8, bp+16) {
 152106 							*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt))++
 152107 						}
 152108 					}
 152109 					*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))++
 152110 					break
 152111 					fallthrough
 152112 
 152113 				case FTS5_VOCAB_COL:
 152114 					if eDetail == FTS5_DETAIL_FULL {
 152115 						var iCol int32 = -1
 152116 						for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8, bp+16) {
 152117 							var ii int32 = int32(*(*I64)(unsafe.Pointer(bp + 16)) >> 32)
 152118 							if iCol != ii {
 152119 								if ii >= nCol {
 152120 									*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_CORRUPT | int32(1)<<8
 152121 									break
 152122 								}
 152123 								*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(ii)*8))++
 152124 								iCol = ii
 152125 							}
 152126 							*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(ii)*8))++
 152127 						}
 152128 					} else if eDetail == FTS5_DETAIL_COLUMNS {
 152129 						for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8, bp+16) {
 152130 							if *(*I64)(unsafe.Pointer(bp + 16)) >= I64(nCol) {
 152131 								*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_CORRUPT | int32(1)<<8
 152132 								break
 152133 							}
 152134 							*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(*(*I64)(unsafe.Pointer(bp + 16)))*8))++
 152135 						}
 152136 					} else {
 152137 						*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))++
 152138 					}
 152139 					break
 152140 					fallthrough
 152141 
 152142 				default:
 152143 					break
 152144 				}
 152145 
 152146 				if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 152147 					*(*int32)(unsafe.Pointer(bp + 4)) = sqlite3Fts5IterNextScan(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)
 152148 				}
 152149 				if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_INSTANCE {
 152150 					break
 152151 				}
 152152 
 152153 				if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK {
 152154 					zTerm = sqlite3Fts5IterTerm(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp)
 152155 					if *(*int32)(unsafe.Pointer(bp)) != (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn ||
 152156 						*(*int32)(unsafe.Pointer(bp)) > 0 && libc.Xmemcmp(tls, zTerm, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, uint32(*(*int32)(unsafe.Pointer(bp)))) != 0 {
 152157 						break
 152158 					}
 152159 					if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 {
 152160 						break
 152161 					}
 152162 				}
 152163 			}
 152164 		}
 152165 	}
 152166 
 152167 	if *(*int32)(unsafe.Pointer(bp + 4)) == SQLITE_OK && (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0 && (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL {
 152168 		for ; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol && *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) == int64(0); (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++ {
 152169 		}
 152170 		if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol == nCol {
 152171 			*(*int32)(unsafe.Pointer(bp + 4)) = SQLITE_CORRUPT | int32(1)<<8
 152172 		}
 152173 	}
 152174 	return *(*int32)(unsafe.Pointer(bp + 4))
 152175 }
 152176 
 152177 func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused uintptr, nUnused int32, apVal uintptr) int32 {
 152178 	var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab
 152179 	var pCsr uintptr = pCursor
 152180 	var eType int32 = (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType
 152181 	var rc int32 = SQLITE_OK
 152182 
 152183 	var iVal int32 = 0
 152184 	var f int32 = FTS5INDEX_QUERY_SCAN
 152185 	var zTerm uintptr = uintptr(0)
 152186 	var nTerm int32 = 0
 152187 
 152188 	var pEq uintptr = uintptr(0)
 152189 	var pGe uintptr = uintptr(0)
 152190 	var pLe uintptr = uintptr(0)
 152191 
 152192 	_ = zUnused
 152193 	_ = nUnused
 152194 
 152195 	fts5VocabResetCursor(tls, pCsr)
 152196 	if idxNum&FTS5_VOCAB_TERM_EQ != 0 {
 152197 		pEq = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*4))
 152198 	}
 152199 	if idxNum&FTS5_VOCAB_TERM_GE != 0 {
 152200 		pGe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*4))
 152201 	}
 152202 	if idxNum&FTS5_VOCAB_TERM_LE != 0 {
 152203 		pLe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*4))
 152204 	}
 152205 
 152206 	if pEq != 0 {
 152207 		zTerm = Xsqlite3_value_text(tls, pEq)
 152208 		nTerm = Xsqlite3_value_bytes(tls, pEq)
 152209 		f = 0
 152210 	} else {
 152211 		if pGe != 0 {
 152212 			zTerm = Xsqlite3_value_text(tls, pGe)
 152213 			nTerm = Xsqlite3_value_bytes(tls, pGe)
 152214 		}
 152215 		if pLe != 0 {
 152216 			var zCopy uintptr = Xsqlite3_value_text(tls, pLe)
 152217 			if zCopy == uintptr(0) {
 152218 				zCopy = ts + 1554
 152219 			}
 152220 			(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm = Xsqlite3_value_bytes(tls, pLe)
 152221 			(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm = Xsqlite3_malloc(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm+1)
 152222 			if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm == uintptr(0) {
 152223 				rc = SQLITE_NOMEM
 152224 			} else {
 152225 				libc.Xmemcpy(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zCopy, uint32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm+1))
 152226 			}
 152227 		}
 152228 	}
 152229 
 152230 	if rc == SQLITE_OK {
 152231 		var pIndex uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex
 152232 		rc = sqlite3Fts5IndexQuery(tls, pIndex, zTerm, nTerm, f, uintptr(0), pCsr+16)
 152233 		if rc == SQLITE_OK {
 152234 			(*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStruct = sqlite3Fts5StructureRef(tls, pIndex)
 152235 		}
 152236 	}
 152237 	if rc == SQLITE_OK && eType == FTS5_VOCAB_INSTANCE {
 152238 		rc = fts5VocabInstanceNewTerm(tls, pCsr)
 152239 	}
 152240 	if rc == SQLITE_OK && !((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) &&
 152241 		(eType != FTS5_VOCAB_INSTANCE ||
 152242 			(*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != FTS5_DETAIL_NONE) {
 152243 		rc = fts5VocabNextMethod(tls, pCursor)
 152244 	}
 152245 
 152246 	return rc
 152247 }
 152248 
 152249 func fts5VocabEofMethod(tls *libc.TLS, pCursor uintptr) int32 {
 152250 	var pCsr uintptr = pCursor
 152251 	return (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof
 152252 }
 152253 
 152254 func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) int32 {
 152255 	var pCsr uintptr = pCursor
 152256 	var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail
 152257 	var eType int32 = (*Fts5VocabTable)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FeType
 152258 	var iVal I64 = int64(0)
 152259 
 152260 	if iCol == 0 {
 152261 		Xsqlite3_result_text(tls,
 152262 			pCtx, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn, libc.UintptrFromInt32(-1))
 152263 	} else if eType == FTS5_VOCAB_COL {
 152264 		if iCol == 1 {
 152265 			if eDetail != FTS5_DETAIL_NONE {
 152266 				var z uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FazCol + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*4))
 152267 				Xsqlite3_result_text(tls, pCtx, z, -1, uintptr(0))
 152268 			}
 152269 		} else if iCol == 2 {
 152270 			iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8))
 152271 		} else {
 152272 			iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8))
 152273 		}
 152274 	} else if eType == FTS5_VOCAB_ROW {
 152275 		if iCol == 1 {
 152276 			iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))
 152277 		} else {
 152278 			iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt))
 152279 		}
 152280 	} else {
 152281 		switch iCol {
 152282 		case 1:
 152283 			Xsqlite3_result_int64(tls, pCtx, (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FiRowid)
 152284 			break
 152285 			fallthrough
 152286 		case 2:
 152287 			{
 152288 				var ii int32 = -1
 152289 				if eDetail == FTS5_DETAIL_FULL {
 152290 					ii = int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos >> 32)
 152291 				} else if eDetail == FTS5_DETAIL_COLUMNS {
 152292 					ii = int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos)
 152293 				}
 152294 				if ii >= 0 && ii < (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol {
 152295 					var z uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FazCol + uintptr(ii)*4))
 152296 					Xsqlite3_result_text(tls, pCtx, z, -1, uintptr(0))
 152297 				}
 152298 				break
 152299 
 152300 			}
 152301 			fallthrough
 152302 		default:
 152303 			{
 152304 				if eDetail == FTS5_DETAIL_FULL {
 152305 					var ii int32 = int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos & int64(0x7FFFFFFF))
 152306 					Xsqlite3_result_int(tls, pCtx, ii)
 152307 				}
 152308 				break
 152309 
 152310 			}
 152311 		}
 152312 	}
 152313 
 152314 	if iVal > int64(0) {
 152315 		Xsqlite3_result_int64(tls, pCtx, iVal)
 152316 	}
 152317 	return SQLITE_OK
 152318 }
 152319 
 152320 func fts5VocabRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 {
 152321 	var pCsr uintptr = pCursor
 152322 	*(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid
 152323 	return SQLITE_OK
 152324 }
 152325 
 152326 func sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 {
 152327 	var p uintptr = pGlobal
 152328 
 152329 	return Xsqlite3_create_module_v2(tls, db, ts+37685, uintptr(unsafe.Pointer(&fts5Vocab)), p, uintptr(0))
 152330 }
 152331 
 152332 var fts5Vocab = Sqlite3_module{
 152333 	FiVersion:    2,
 152334 	FxCreate:     0,
 152335 	FxConnect:    0,
 152336 	FxBestIndex:  0,
 152337 	FxDisconnect: 0,
 152338 	FxDestroy:    0,
 152339 	FxOpen:       0,
 152340 	FxClose:      0,
 152341 	FxFilter:     0,
 152342 	FxNext:       0,
 152343 	FxEof:        0,
 152344 	FxColumn:     0,
 152345 	FxRowid:      0,
 152346 }
 152347 
 152348 // ************* End of stmt.c ***********************************************
 152349 // Return the source-id for this library
 152350 func Xsqlite3_sourceid(tls *libc.TLS) uintptr {
 152351 	return ts + 37695
 152352 }
 152353 
 152354 func init() {
 152355 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3aEQb)) + 0)) = uintptr(unsafe.Pointer(&Xsqlite3UpperToLower)) + 210
 152356 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3aGTb)) + 0)) = uintptr(unsafe.Pointer(&Xsqlite3UpperToLower)) + 216
 152357 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&Xsqlite3aLTb)) + 0)) = uintptr(unsafe.Pointer(&Xsqlite3UpperToLower)) + 204
 152358 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAgg)) + 0)) = geopolyBBoxStep
 152359 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAgg)) + 4)) = geopolyBBoxFinal
 152360 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAlterTableFuncs)) + 16)) = renameColumnFunc
 152361 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAlterTableFuncs)) + 56)) = renameTableFunc
 152362 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAlterTableFuncs)) + 96)) = renameTableTest
 152363 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAlterTableFuncs)) + 136)) = dropColumnFunc
 152364 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aAlterTableFuncs)) + 176)) = renameQuotefixFunc
 152365 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 16)) = versionFunc
 152366 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 56)) = versionFunc
 152367 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 96)) = versionFunc
 152368 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 136)) = versionFunc
 152369 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 176)) = soundexFunc
 152370 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 216)) = loadExt
 152371 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 256)) = loadExt
 152372 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 296)) = compileoptionusedFunc
 152373 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 336)) = compileoptiongetFunc
 152374 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 376)) = versionFunc
 152375 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 416)) = versionFunc
 152376 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 456)) = versionFunc
 152377 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 496)) = versionFunc
 152378 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 536)) = trimFunc
 152379 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 576)) = trimFunc
 152380 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 616)) = trimFunc
 152381 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 656)) = trimFunc
 152382 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 696)) = trimFunc
 152383 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 736)) = trimFunc
 152384 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 776)) = minmaxFunc
 152385 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 856)) = minmaxStep
 152386 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 860)) = minMaxFinalize
 152387 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 864)) = minMaxValue
 152388 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 896)) = minmaxFunc
 152389 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 976)) = minmaxStep
 152390 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 980)) = minMaxFinalize
 152391 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 984)) = minMaxValue
 152392 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1016)) = typeofFunc
 152393 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1056)) = subtypeFunc
 152394 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1096)) = lengthFunc
 152395 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1136)) = instrFunc
 152396 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1176)) = printfFunc
 152397 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1216)) = printfFunc
 152398 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1256)) = unicodeFunc
 152399 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1296)) = charFunc
 152400 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1336)) = absFunc
 152401 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1376)) = roundFunc
 152402 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1416)) = roundFunc
 152403 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1456)) = upperFunc
 152404 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1496)) = lowerFunc
 152405 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1536)) = hexFunc
 152406 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1576)) = unhexFunc
 152407 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1616)) = unhexFunc
 152408 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1656)) = versionFunc
 152409 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1696)) = randomFunc
 152410 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1736)) = randomBlob
 152411 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1776)) = nullifFunc
 152412 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1816)) = versionFunc
 152413 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1856)) = sourceidFunc
 152414 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1896)) = errlogFunc
 152415 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1936)) = quoteFunc
 152416 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 1976)) = last_insert_rowid
 152417 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2016)) = changes
 152418 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2056)) = total_changes
 152419 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2096)) = replaceFunc
 152420 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2136)) = zeroblobFunc
 152421 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2176)) = substrFunc
 152422 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2216)) = substrFunc
 152423 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2256)) = substrFunc
 152424 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2296)) = substrFunc
 152425 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2336)) = sumStep
 152426 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2340)) = sumFinalize
 152427 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2344)) = sumFinalize
 152428 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2348)) = sumInverse
 152429 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2376)) = sumStep
 152430 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2380)) = totalFinalize
 152431 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2384)) = totalFinalize
 152432 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2388)) = sumInverse
 152433 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2416)) = sumStep
 152434 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2420)) = avgFinalize
 152435 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2424)) = avgFinalize
 152436 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2428)) = sumInverse
 152437 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2456)) = countStep
 152438 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2460)) = countFinalize
 152439 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2464)) = countFinalize
 152440 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2468)) = countInverse
 152441 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2496)) = countStep
 152442 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2500)) = countFinalize
 152443 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2504)) = countFinalize
 152444 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2508)) = countInverse
 152445 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2536)) = groupConcatStep
 152446 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2540)) = groupConcatFinalize
 152447 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2544)) = groupConcatValue
 152448 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2548)) = groupConcatInverse
 152449 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2576)) = groupConcatStep
 152450 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2580)) = groupConcatFinalize
 152451 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2584)) = groupConcatValue
 152452 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2588)) = groupConcatInverse
 152453 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2608)) = uintptr(unsafe.Pointer(&globInfo))
 152454 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2616)) = likeFunc
 152455 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2648)) = uintptr(unsafe.Pointer(&likeInfoNorm))
 152456 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2656)) = likeFunc
 152457 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2688)) = uintptr(unsafe.Pointer(&likeInfoNorm))
 152458 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2696)) = likeFunc
 152459 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2808)) = xCeil
 152460 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2816)) = ceilingFunc
 152461 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2848)) = xCeil
 152462 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2856)) = ceilingFunc
 152463 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2888)) = xFloor
 152464 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2896)) = ceilingFunc
 152465 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2928)) = libc.Xtrunc
 152466 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2936)) = ceilingFunc
 152467 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 2976)) = logFunc
 152468 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3016)) = logFunc
 152469 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3056)) = logFunc
 152470 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3096)) = logFunc
 152471 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3136)) = logFunc
 152472 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3168)) = libc.Xexp
 152473 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3176)) = math1Func
 152474 	*(*func(*libc.TLS, float64, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3208)) = libc.Xpow
 152475 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3216)) = math2Func
 152476 	*(*func(*libc.TLS, float64, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3248)) = libc.Xpow
 152477 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3256)) = math2Func
 152478 	*(*func(*libc.TLS, float64, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3288)) = libc.Xfmod
 152479 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3296)) = math2Func
 152480 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3328)) = libc.Xacos
 152481 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3336)) = math1Func
 152482 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3368)) = libc.Xasin
 152483 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3376)) = math1Func
 152484 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3408)) = libc.Xatan
 152485 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3416)) = math1Func
 152486 	*(*func(*libc.TLS, float64, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3448)) = libc.Xatan2
 152487 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3456)) = math2Func
 152488 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3488)) = libc.Xcos
 152489 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3496)) = math1Func
 152490 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3528)) = libc.Xsin
 152491 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3536)) = math1Func
 152492 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3568)) = libc.Xtan
 152493 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3576)) = math1Func
 152494 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3608)) = libc.Xcosh
 152495 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3616)) = math1Func
 152496 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3648)) = libc.Xsinh
 152497 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3656)) = math1Func
 152498 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3688)) = libc.Xtanh
 152499 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3696)) = math1Func
 152500 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3728)) = libc.Xacosh
 152501 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3736)) = math1Func
 152502 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3768)) = libc.Xasinh
 152503 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3776)) = math1Func
 152504 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3808)) = libc.Xatanh
 152505 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3816)) = math1Func
 152506 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3848)) = libc.Xsqrt
 152507 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3856)) = math1Func
 152508 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3888)) = degToRad
 152509 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3896)) = math1Func
 152510 	*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3928)) = radToDeg
 152511 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3936)) = math1Func
 152512 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 3976)) = piFunc
 152513 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 4016)) = signFunc
 152514 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 4056)) = versionFunc
 152515 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aBuiltinFunc)) + 4096)) = versionFunc
 152516 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 8)) = uintptr(unsafe.Pointer(&Xsqlite3Config))
 152517 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 16)) = juliandayFunc
 152518 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 48)) = uintptr(unsafe.Pointer(&Xsqlite3Config))
 152519 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 56)) = unixepochFunc
 152520 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 88)) = uintptr(unsafe.Pointer(&Xsqlite3Config))
 152521 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 96)) = dateFunc
 152522 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 128)) = uintptr(unsafe.Pointer(&Xsqlite3Config))
 152523 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 136)) = timeFunc
 152524 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 168)) = uintptr(unsafe.Pointer(&Xsqlite3Config))
 152525 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 176)) = datetimeFunc
 152526 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 208)) = uintptr(unsafe.Pointer(&Xsqlite3Config))
 152527 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 216)) = strftimeFunc
 152528 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 256)) = ctimeFunc
 152529 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 296)) = ctimestampFunc
 152530 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aDateTimeFuncs)) + 336)) = cdateFunc
 152531 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 0)) = geopolyAreaFunc
 152532 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 12)) = geopolyBlobFunc
 152533 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 24)) = geopolyJsonFunc
 152534 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 36)) = geopolySvgFunc
 152535 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 48)) = geopolyWithinFunc
 152536 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 60)) = geopolyContainsPointFunc
 152537 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 72)) = geopolyOverlapFunc
 152538 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 84)) = geopolyDebugFunc
 152539 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 96)) = geopolyBBoxFunc
 152540 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 108)) = geopolyXformFunc
 152541 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 120)) = geopolyRegularFunc
 152542 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 132)) = geopolyCcwFunc
 152543 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 16)) = jsonRemoveFunc
 152544 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 56)) = jsonArrayFunc
 152545 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 96)) = jsonArrayLengthFunc
 152546 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 136)) = jsonArrayLengthFunc
 152547 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 176)) = jsonExtractFunc
 152548 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 216)) = jsonExtractFunc
 152549 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 256)) = jsonExtractFunc
 152550 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 296)) = jsonSetFunc
 152551 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 336)) = jsonObjectFunc
 152552 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 376)) = jsonPatchFunc
 152553 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 416)) = jsonQuoteFunc
 152554 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 456)) = jsonRemoveFunc
 152555 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 496)) = jsonReplaceFunc
 152556 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 536)) = jsonSetFunc
 152557 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 576)) = jsonTypeFunc
 152558 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 616)) = jsonTypeFunc
 152559 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 656)) = jsonValidFunc
 152560 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 696)) = jsonArrayStep
 152561 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 700)) = jsonArrayFinal
 152562 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 704)) = jsonArrayValue
 152563 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 708)) = jsonGroupInverse
 152564 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 736)) = jsonObjectStep
 152565 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 740)) = jsonObjectFinal
 152566 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 744)) = jsonObjectValue
 152567 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aJsonFunc)) + 748)) = jsonGroupInverse
 152568 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aMod)) + 4)) = uintptr(unsafe.Pointer(&jsonEachModule))
 152569 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aMod)) + 12)) = uintptr(unsafe.Pointer(&jsonTreeModule))
 152570 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 4)) = *(*uintptr)(unsafe.Pointer(&struct {
 152571 		f func(*libc.TLS, uintptr, int32, int32) int32
 152572 	}{posixOpen}))
 152573 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 16)) = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{libc.Xclose}))
 152574 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 28)) = *(*uintptr)(unsafe.Pointer(&struct {
 152575 		f func(*libc.TLS, uintptr, int32) int32
 152576 	}{libc.Xaccess}))
 152577 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 40)) = *(*uintptr)(unsafe.Pointer(&struct {
 152578 		f func(*libc.TLS, uintptr, Size_t) uintptr
 152579 	}{libc.Xgetcwd}))
 152580 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 52)) = *(*uintptr)(unsafe.Pointer(&struct {
 152581 		f func(*libc.TLS, uintptr, uintptr) int32
 152582 	}{libc.Xstat}))
 152583 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 64)) = *(*uintptr)(unsafe.Pointer(&struct {
 152584 		f func(*libc.TLS, int32, uintptr) int32
 152585 	}{libc.Xfstat}))
 152586 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 76)) = *(*uintptr)(unsafe.Pointer(&struct {
 152587 		f func(*libc.TLS, int32, X__off64_t) int32
 152588 	}{libc.Xftruncate}))
 152589 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 88)) = *(*uintptr)(unsafe.Pointer(&struct {
 152590 		f func(*libc.TLS, int32, int32, uintptr) int32
 152591 	}{libc.Xfcntl}))
 152592 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 100)) = *(*uintptr)(unsafe.Pointer(&struct {
 152593 		f func(*libc.TLS, int32, uintptr, Size_t) Ssize_t
 152594 	}{libc.Xread}))
 152595 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 136)) = *(*uintptr)(unsafe.Pointer(&struct {
 152596 		f func(*libc.TLS, int32, uintptr, Size_t) Ssize_t
 152597 	}{libc.Xwrite}))
 152598 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 172)) = *(*uintptr)(unsafe.Pointer(&struct {
 152599 		f func(*libc.TLS, int32, X__mode_t) int32
 152600 	}{libc.Xfchmod}))
 152601 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 196)) = *(*uintptr)(unsafe.Pointer(&struct {
 152602 		f func(*libc.TLS, uintptr) int32
 152603 	}{libc.Xunlink}))
 152604 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 208)) = *(*uintptr)(unsafe.Pointer(&struct {
 152605 		f func(*libc.TLS, uintptr, uintptr) int32
 152606 	}{openDirectory}))
 152607 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 220)) = *(*uintptr)(unsafe.Pointer(&struct {
 152608 		f func(*libc.TLS, uintptr, X__mode_t) int32
 152609 	}{libc.Xmkdir}))
 152610 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 232)) = *(*uintptr)(unsafe.Pointer(&struct {
 152611 		f func(*libc.TLS, uintptr) int32
 152612 	}{libc.Xrmdir}))
 152613 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 244)) = *(*uintptr)(unsafe.Pointer(&struct {
 152614 		f func(*libc.TLS, int32, X__uid_t, X__gid_t) int32
 152615 	}{libc.Xfchown}))
 152616 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 256)) = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) X__uid_t }{libc.Xgeteuid}))
 152617 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 268)) = *(*uintptr)(unsafe.Pointer(&struct {
 152618 		f func(*libc.TLS, uintptr, Size_t, int32, int32, int32, X__off64_t) uintptr
 152619 	}{libc.Xmmap}))
 152620 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 280)) = *(*uintptr)(unsafe.Pointer(&struct {
 152621 		f func(*libc.TLS, uintptr, Size_t) int32
 152622 	}{libc.Xmunmap}))
 152623 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 292)) = *(*uintptr)(unsafe.Pointer(&struct {
 152624 		f func(*libc.TLS, uintptr, Size_t, Size_t, int32, uintptr) uintptr
 152625 	}{libc.Xmremap}))
 152626 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 304)) = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{unixGetpagesize}))
 152627 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 316)) = *(*uintptr)(unsafe.Pointer(&struct {
 152628 		f func(*libc.TLS, uintptr, uintptr, Size_t) Ssize_t
 152629 	}{libc.Xreadlink}))
 152630 	*(*Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 328)) = *(*uintptr)(unsafe.Pointer(&struct {
 152631 		f func(*libc.TLS, uintptr, uintptr) int32
 152632 	}{libc.Xlstat}))
 152633 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 20)) = uintptr(unsafe.Pointer(&posixIoFinder))
 152634 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 24)) = unixOpen
 152635 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 28)) = unixDelete
 152636 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 32)) = unixAccess
 152637 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 36)) = unixFullPathname
 152638 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 40)) = unixDlOpen
 152639 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 44)) = unixDlError
 152640 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 48)) = unixDlSym
 152641 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 52)) = unixDlClose
 152642 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 56)) = unixRandomness
 152643 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 60)) = unixSleep
 152644 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 64)) = unixCurrentTime
 152645 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 68)) = unixGetLastError
 152646 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 72)) = unixCurrentTimeInt64
 152647 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_syscall_ptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 76)) = unixSetSystemCall
 152648 	*(*func(*libc.TLS, uintptr, uintptr) Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 80)) = unixGetSystemCall
 152649 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 84)) = unixNextSystemCall
 152650 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 108)) = uintptr(unsafe.Pointer(&nolockIoFinder))
 152651 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 112)) = unixOpen
 152652 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 116)) = unixDelete
 152653 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 120)) = unixAccess
 152654 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 124)) = unixFullPathname
 152655 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 128)) = unixDlOpen
 152656 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 132)) = unixDlError
 152657 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 136)) = unixDlSym
 152658 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 140)) = unixDlClose
 152659 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 144)) = unixRandomness
 152660 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 148)) = unixSleep
 152661 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 152)) = unixCurrentTime
 152662 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 156)) = unixGetLastError
 152663 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 160)) = unixCurrentTimeInt64
 152664 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_syscall_ptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 164)) = unixSetSystemCall
 152665 	*(*func(*libc.TLS, uintptr, uintptr) Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 168)) = unixGetSystemCall
 152666 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 172)) = unixNextSystemCall
 152667 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 196)) = uintptr(unsafe.Pointer(&dotlockIoFinder))
 152668 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 200)) = unixOpen
 152669 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 204)) = unixDelete
 152670 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 208)) = unixAccess
 152671 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 212)) = unixFullPathname
 152672 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 216)) = unixDlOpen
 152673 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 220)) = unixDlError
 152674 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 224)) = unixDlSym
 152675 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 228)) = unixDlClose
 152676 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 232)) = unixRandomness
 152677 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 236)) = unixSleep
 152678 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 240)) = unixCurrentTime
 152679 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 244)) = unixGetLastError
 152680 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 248)) = unixCurrentTimeInt64
 152681 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_syscall_ptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 252)) = unixSetSystemCall
 152682 	*(*func(*libc.TLS, uintptr, uintptr) Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 256)) = unixGetSystemCall
 152683 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 260)) = unixNextSystemCall
 152684 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 284)) = uintptr(unsafe.Pointer(&posixIoFinder))
 152685 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 288)) = unixOpen
 152686 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 292)) = unixDelete
 152687 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 296)) = unixAccess
 152688 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 300)) = unixFullPathname
 152689 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 304)) = unixDlOpen
 152690 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 308)) = unixDlError
 152691 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 312)) = unixDlSym
 152692 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 316)) = unixDlClose
 152693 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 320)) = unixRandomness
 152694 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 324)) = unixSleep
 152695 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 328)) = unixCurrentTime
 152696 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 332)) = unixGetLastError
 152697 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 336)) = unixCurrentTimeInt64
 152698 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_syscall_ptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 340)) = unixSetSystemCall
 152699 	*(*func(*libc.TLS, uintptr, uintptr) Sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 344)) = unixGetSystemCall
 152700 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aVfs)) + 348)) = unixNextSystemCall
 152701 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 16)) = row_numberStepFunc
 152702 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 20)) = row_numberValueFunc
 152703 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 24)) = row_numberValueFunc
 152704 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 28)) = noopStepFunc
 152705 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 32)) = uintptr(unsafe.Pointer(&row_numberName))
 152706 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 56)) = dense_rankStepFunc
 152707 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 60)) = dense_rankValueFunc
 152708 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 64)) = dense_rankValueFunc
 152709 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 68)) = noopStepFunc
 152710 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 72)) = uintptr(unsafe.Pointer(&dense_rankName))
 152711 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 96)) = rankStepFunc
 152712 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 100)) = rankValueFunc
 152713 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 104)) = rankValueFunc
 152714 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 108)) = noopStepFunc
 152715 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 112)) = uintptr(unsafe.Pointer(&rankName))
 152716 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 136)) = percent_rankStepFunc
 152717 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 140)) = percent_rankValueFunc
 152718 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 144)) = percent_rankValueFunc
 152719 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 148)) = percent_rankInvFunc
 152720 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 152)) = uintptr(unsafe.Pointer(&percent_rankName))
 152721 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 176)) = cume_distStepFunc
 152722 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 180)) = cume_distValueFunc
 152723 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 184)) = cume_distValueFunc
 152724 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 188)) = cume_distInvFunc
 152725 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 192)) = uintptr(unsafe.Pointer(&cume_distName))
 152726 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 216)) = ntileStepFunc
 152727 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 220)) = ntileValueFunc
 152728 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 224)) = ntileValueFunc
 152729 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 228)) = ntileInvFunc
 152730 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 232)) = uintptr(unsafe.Pointer(&ntileName))
 152731 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 256)) = last_valueStepFunc
 152732 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 260)) = last_valueFinalizeFunc
 152733 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 264)) = last_valueValueFunc
 152734 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 268)) = last_valueInvFunc
 152735 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 272)) = uintptr(unsafe.Pointer(&last_valueName))
 152736 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 296)) = nth_valueStepFunc
 152737 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 300)) = nth_valueFinalizeFunc
 152738 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 304)) = noopValueFunc
 152739 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 308)) = noopStepFunc
 152740 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 312)) = uintptr(unsafe.Pointer(&nth_valueName))
 152741 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 336)) = first_valueStepFunc
 152742 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 340)) = first_valueFinalizeFunc
 152743 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 344)) = noopValueFunc
 152744 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 348)) = noopStepFunc
 152745 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 352)) = uintptr(unsafe.Pointer(&first_valueName))
 152746 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 376)) = noopStepFunc
 152747 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 380)) = noopValueFunc
 152748 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 384)) = noopValueFunc
 152749 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 388)) = noopStepFunc
 152750 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 392)) = uintptr(unsafe.Pointer(&leadName))
 152751 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 416)) = noopStepFunc
 152752 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 420)) = noopValueFunc
 152753 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 424)) = noopValueFunc
 152754 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 428)) = noopStepFunc
 152755 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 432)) = uintptr(unsafe.Pointer(&leadName))
 152756 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 456)) = noopStepFunc
 152757 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 460)) = noopValueFunc
 152758 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 464)) = noopValueFunc
 152759 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 468)) = noopStepFunc
 152760 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 472)) = uintptr(unsafe.Pointer(&leadName))
 152761 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 496)) = noopStepFunc
 152762 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 500)) = noopValueFunc
 152763 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 504)) = noopValueFunc
 152764 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 508)) = noopStepFunc
 152765 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 512)) = uintptr(unsafe.Pointer(&lagName))
 152766 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 536)) = noopStepFunc
 152767 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 540)) = noopValueFunc
 152768 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 544)) = noopValueFunc
 152769 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 548)) = noopStepFunc
 152770 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 552)) = uintptr(unsafe.Pointer(&lagName))
 152771 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 576)) = noopStepFunc
 152772 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 580)) = noopValueFunc
 152773 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 584)) = noopValueFunc
 152774 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 588)) = noopStepFunc
 152775 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aWindowFuncs)) + 592)) = uintptr(unsafe.Pointer(&lagName))
 152776 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&attach_func)) + 16)) = attachFunc
 152777 	*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 0)) = sqlite3MemMalloc
 152778 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 4)) = sqlite3MemFree
 152779 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 8)) = sqlite3MemRealloc
 152780 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 12)) = sqlite3MemSize
 152781 	*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 16)) = sqlite3MemRoundup
 152782 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 20)) = sqlite3MemInit
 152783 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods)) + 24)) = sqlite3MemShutdown
 152784 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 8)) = pcache1Init
 152785 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 12)) = pcache1Shutdown
 152786 	*(*func(*libc.TLS, int32, int32, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 16)) = pcache1Create
 152787 	*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 20)) = pcache1Cachesize
 152788 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 24)) = pcache1Pagecount
 152789 	*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 28)) = pcache1Fetch
 152790 	*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 32)) = pcache1Unpin
 152791 	*(*func(*libc.TLS, uintptr, uintptr, uint32, uint32))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 36)) = pcache1Rekey
 152792 	*(*func(*libc.TLS, uintptr, uint32))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 40)) = pcache1Truncate
 152793 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 44)) = pcache1Destroy
 152794 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&defaultMethods1)) + 48)) = pcache1Shrink
 152795 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&detach_func)) + 16)) = detachFunc
 152796 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoFinder)) + 0)) = dotlockIoFinderImpl
 152797 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 4)) = dotlockClose
 152798 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 8)) = unixRead
 152799 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 12)) = unixWrite
 152800 	*(*func(*libc.TLS, uintptr, I64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 16)) = unixTruncate
 152801 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 20)) = unixSync
 152802 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 24)) = unixFileSize
 152803 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 28)) = dotlockLock
 152804 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 32)) = dotlockUnlock
 152805 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 36)) = dotlockCheckReservedLock
 152806 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 40)) = unixFileControl
 152807 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 44)) = unixSectorSize
 152808 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 48)) = unixDeviceCharacteristics
 152809 	*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 56)) = unixShmLock
 152810 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 60)) = unixShmBarrier
 152811 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 64)) = unixShmUnmap
 152812 	*(*func(*libc.TLS, uintptr, I64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 68)) = unixFetch
 152813 	*(*func(*libc.TLS, uintptr, I64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&dotlockIoMethods)) + 72)) = unixUnfetch
 152814 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 4)) = fts5CreateMethod
 152815 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 8)) = fts5ConnectMethod
 152816 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 12)) = fts5BestIndexMethod
 152817 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 16)) = fts5DisconnectMethod
 152818 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 20)) = fts5DestroyMethod
 152819 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 24)) = fts5OpenMethod
 152820 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 28)) = fts5CloseMethod
 152821 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 32)) = fts5FilterMethod
 152822 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 36)) = fts5NextMethod
 152823 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 40)) = fts5EofMethod
 152824 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 44)) = fts5ColumnMethod
 152825 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 48)) = fts5RowidMethod
 152826 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 52)) = fts5UpdateMethod
 152827 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 56)) = fts5BeginMethod
 152828 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 60)) = fts5SyncMethod
 152829 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 64)) = fts5CommitMethod
 152830 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 68)) = fts5RollbackMethod
 152831 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 72)) = fts5FindFunctionMethod
 152832 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 76)) = fts5RenameMethod
 152833 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 80)) = fts5SavepointMethod
 152834 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 84)) = fts5ReleaseMethod
 152835 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 88)) = fts5RollbackToMethod
 152836 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Mod)) + 92)) = fts5ShadowName
 152837 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 4)) = fts5VocabCreateMethod
 152838 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 8)) = fts5VocabConnectMethod
 152839 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 12)) = fts5VocabBestIndexMethod
 152840 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 16)) = fts5VocabDisconnectMethod
 152841 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 20)) = fts5VocabDestroyMethod
 152842 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 24)) = fts5VocabOpenMethod
 152843 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 28)) = fts5VocabCloseMethod
 152844 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 32)) = fts5VocabFilterMethod
 152845 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 36)) = fts5VocabNextMethod
 152846 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 40)) = fts5VocabEofMethod
 152847 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 44)) = fts5VocabColumnMethod
 152848 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5Vocab)) + 48)) = fts5VocabRowidMethod
 152849 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 4)) = geopolyCreate
 152850 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 8)) = geopolyConnect
 152851 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 12)) = geopolyBestIndex
 152852 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 16)) = rtreeDisconnect
 152853 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 20)) = rtreeDestroy
 152854 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 24)) = rtreeOpen
 152855 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 28)) = rtreeClose
 152856 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 32)) = geopolyFilter
 152857 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 36)) = rtreeNext
 152858 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 40)) = rtreeEof
 152859 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 44)) = geopolyColumn
 152860 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 48)) = rtreeRowid
 152861 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 52)) = geopolyUpdate
 152862 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 56)) = rtreeBeginTransaction
 152863 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 60)) = rtreeEndTransaction
 152864 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 64)) = rtreeEndTransaction
 152865 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 68)) = rtreeEndTransaction
 152866 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 72)) = geopolyFindFunction
 152867 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 76)) = rtreeRename
 152868 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 80)) = rtreeSavepoint
 152869 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&geopolyModule)) + 92)) = rtreeShadowName
 152870 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 8)) = jsonEachConnect
 152871 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 12)) = jsonEachBestIndex
 152872 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 16)) = jsonEachDisconnect
 152873 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 24)) = jsonEachOpenEach
 152874 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 28)) = jsonEachClose
 152875 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 32)) = jsonEachFilter
 152876 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 36)) = jsonEachNext
 152877 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 40)) = jsonEachEof
 152878 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 44)) = jsonEachColumn
 152879 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonEachModule)) + 48)) = jsonEachRowid
 152880 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 8)) = jsonEachConnect
 152881 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 12)) = jsonEachBestIndex
 152882 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 16)) = jsonEachDisconnect
 152883 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 24)) = jsonEachOpenTree
 152884 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 28)) = jsonEachClose
 152885 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 32)) = jsonEachFilter
 152886 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 36)) = jsonEachNext
 152887 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 40)) = jsonEachEof
 152888 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 44)) = jsonEachColumn
 152889 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jsonTreeModule)) + 48)) = jsonEachRowid
 152890 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 4)) = memdbClose
 152891 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 8)) = memdbRead
 152892 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 12)) = memdbWrite
 152893 	*(*func(*libc.TLS, uintptr, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 16)) = memdbTruncate
 152894 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 20)) = memdbSync
 152895 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 24)) = memdbFileSize
 152896 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 28)) = memdbLock
 152897 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 32)) = memdbUnlock
 152898 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 40)) = memdbFileControl
 152899 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 48)) = memdbDeviceCharacteristics
 152900 	*(*func(*libc.TLS, uintptr, Sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 68)) = memdbFetch
 152901 	*(*func(*libc.TLS, uintptr, Sqlite3_int64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_io_methods)) + 72)) = memdbUnfetch
 152902 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 24)) = memdbOpen
 152903 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 32)) = memdbAccess
 152904 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 36)) = memdbFullPathname
 152905 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 40)) = memdbDlOpen
 152906 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 44)) = memdbDlError
 152907 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 48)) = memdbDlSym
 152908 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 52)) = memdbDlClose
 152909 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 56)) = memdbRandomness
 152910 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 60)) = memdbSleep
 152911 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 68)) = memdbGetLastError
 152912 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&memdb_vfs)) + 72)) = memdbCurrentTimeInt64
 152913 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoFinder)) + 0)) = nolockIoFinderImpl
 152914 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 4)) = nolockClose
 152915 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 8)) = unixRead
 152916 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 12)) = unixWrite
 152917 	*(*func(*libc.TLS, uintptr, I64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 16)) = unixTruncate
 152918 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 20)) = unixSync
 152919 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 24)) = unixFileSize
 152920 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 28)) = nolockLock
 152921 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 32)) = nolockUnlock
 152922 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 36)) = nolockCheckReservedLock
 152923 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 40)) = unixFileControl
 152924 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 44)) = unixSectorSize
 152925 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 48)) = unixDeviceCharacteristics
 152926 	*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 56)) = unixShmLock
 152927 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 60)) = unixShmBarrier
 152928 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 64)) = unixShmUnmap
 152929 	*(*func(*libc.TLS, uintptr, I64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 68)) = unixFetch
 152930 	*(*func(*libc.TLS, uintptr, I64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&nolockIoMethods)) + 72)) = unixUnfetch
 152931 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoFinder)) + 0)) = posixIoFinderImpl
 152932 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 4)) = unixClose
 152933 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 8)) = unixRead
 152934 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 12)) = unixWrite
 152935 	*(*func(*libc.TLS, uintptr, I64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 16)) = unixTruncate
 152936 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 20)) = unixSync
 152937 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 24)) = unixFileSize
 152938 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 28)) = unixLock
 152939 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 32)) = unixUnlock
 152940 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 36)) = unixCheckReservedLock
 152941 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 40)) = unixFileControl
 152942 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 44)) = unixSectorSize
 152943 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 48)) = unixDeviceCharacteristics
 152944 	*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 52)) = unixShmMap
 152945 	*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 56)) = unixShmLock
 152946 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 60)) = unixShmBarrier
 152947 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 64)) = unixShmUnmap
 152948 	*(*func(*libc.TLS, uintptr, I64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 68)) = unixFetch
 152949 	*(*func(*libc.TLS, uintptr, I64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&posixIoMethods)) + 72)) = unixUnfetch
 152950 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 8)) = pragmaVtabConnect
 152951 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 12)) = pragmaVtabBestIndex
 152952 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 16)) = pragmaVtabDisconnect
 152953 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 24)) = pragmaVtabOpen
 152954 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 28)) = pragmaVtabClose
 152955 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 32)) = pragmaVtabFilter
 152956 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 36)) = pragmaVtabNext
 152957 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 40)) = pragmaVtabEof
 152958 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 44)) = pragmaVtabColumn
 152959 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&pragmaVtabModule)) + 48)) = pragmaVtabRowid
 152960 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 4)) = rbuVfsClose
 152961 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 8)) = rbuVfsRead
 152962 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 12)) = rbuVfsWrite
 152963 	*(*func(*libc.TLS, uintptr, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 16)) = rbuVfsTruncate
 152964 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 20)) = rbuVfsSync
 152965 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 24)) = rbuVfsFileSize
 152966 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 28)) = rbuVfsLock
 152967 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 32)) = rbuVfsUnlock
 152968 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 36)) = rbuVfsCheckReservedLock
 152969 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 40)) = rbuVfsFileControl
 152970 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 44)) = rbuVfsSectorSize
 152971 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 48)) = rbuVfsDeviceCharacteristics
 152972 	*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 52)) = rbuVfsShmMap
 152973 	*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 56)) = rbuVfsShmLock
 152974 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 60)) = rbuVfsShmBarrier
 152975 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods)) + 64)) = rbuVfsShmUnmap
 152976 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 4)) = rbuVfsClose
 152977 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 8)) = rbuVfsRead
 152978 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 12)) = rbuVfsWrite
 152979 	*(*func(*libc.TLS, uintptr, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 16)) = rbuVfsTruncate
 152980 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 20)) = rbuVfsSync
 152981 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 24)) = rbuVfsFileSize
 152982 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 28)) = rbuVfsLock
 152983 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 32)) = rbuVfsUnlock
 152984 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 36)) = rbuVfsCheckReservedLock
 152985 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 40)) = rbuVfsFileControl
 152986 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 44)) = rbuVfsSectorSize
 152987 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rbuvfs_io_methods1)) + 48)) = rbuVfsDeviceCharacteristics
 152988 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 4)) = rtreeCreate
 152989 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 8)) = rtreeConnect
 152990 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 12)) = rtreeBestIndex
 152991 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 16)) = rtreeDisconnect
 152992 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 20)) = rtreeDestroy
 152993 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 24)) = rtreeOpen
 152994 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 28)) = rtreeClose
 152995 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 32)) = rtreeFilter
 152996 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 36)) = rtreeNext
 152997 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 40)) = rtreeEof
 152998 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 44)) = rtreeColumn
 152999 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 48)) = rtreeRowid
 153000 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 52)) = rtreeUpdate
 153001 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 56)) = rtreeBeginTransaction
 153002 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 60)) = rtreeEndTransaction
 153003 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 64)) = rtreeEndTransaction
 153004 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 68)) = rtreeEndTransaction
 153005 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 76)) = rtreeRename
 153006 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 80)) = rtreeSavepoint
 153007 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&rtreeModule)) + 92)) = rtreeShadowName
 153008 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 4)) = fts5ApiUserData
 153009 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 8)) = fts5ApiColumnCount
 153010 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 12)) = fts5ApiRowCount
 153011 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 16)) = fts5ApiColumnTotalSize
 153012 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 20)) = fts5ApiTokenize
 153013 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 24)) = fts5ApiPhraseCount
 153014 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 28)) = fts5ApiPhraseSize
 153015 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 32)) = fts5ApiInstCount
 153016 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 36)) = fts5ApiInst
 153017 	*(*func(*libc.TLS, uintptr) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 40)) = fts5ApiRowid
 153018 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 44)) = fts5ApiColumnText
 153019 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 48)) = fts5ApiColumnSize
 153020 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 52)) = fts5ApiQueryPhrase
 153021 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 56)) = fts5ApiSetAuxdata
 153022 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 60)) = fts5ApiGetAuxdata
 153023 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 64)) = fts5ApiPhraseFirst
 153024 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 68)) = fts5ApiPhraseNext
 153025 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 72)) = fts5ApiPhraseFirstColumn
 153026 	*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sFts5Api)) + 76)) = fts5ApiPhraseNextColumn
 153027 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMemJournalMethods)) + 4)) = memjrnlClose
 153028 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMemJournalMethods)) + 8)) = memjrnlRead
 153029 	*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMemJournalMethods)) + 12)) = memjrnlWrite
 153030 	*(*func(*libc.TLS, uintptr, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMemJournalMethods)) + 16)) = memjrnlTruncate
 153031 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMemJournalMethods)) + 20)) = memjrnlSync
 153032 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMemJournalMethods)) + 24)) = memjrnlFileSize
 153033 	*(*func(*libc.TLS) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 0)) = noopMutexInit
 153034 	*(*func(*libc.TLS) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 4)) = noopMutexEnd
 153035 	*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 8)) = noopMutexAlloc
 153036 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 12)) = noopMutexFree
 153037 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 16)) = noopMutexEnter
 153038 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 20)) = noopMutexTry
 153039 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sMutex)) + 24)) = noopMutexLeave
 153040 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 0)) = Xsqlite3_aggregate_context
 153041 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 4)) = Xsqlite3_aggregate_count
 153042 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 8)) = Xsqlite3_bind_blob
 153043 	*(*func(*libc.TLS, uintptr, int32, float64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 12)) = Xsqlite3_bind_double
 153044 	*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 16)) = Xsqlite3_bind_int
 153045 	*(*func(*libc.TLS, uintptr, int32, Sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 20)) = Xsqlite3_bind_int64
 153046 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 24)) = Xsqlite3_bind_null
 153047 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 28)) = Xsqlite3_bind_parameter_count
 153048 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 32)) = Xsqlite3_bind_parameter_index
 153049 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 36)) = Xsqlite3_bind_parameter_name
 153050 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 40)) = Xsqlite3_bind_text
 153051 	*(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 44)) = Xsqlite3_bind_text16
 153052 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 48)) = Xsqlite3_bind_value
 153053 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 52)) = Xsqlite3_busy_handler
 153054 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 56)) = Xsqlite3_busy_timeout
 153055 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 60)) = Xsqlite3_changes
 153056 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 64)) = Xsqlite3_close
 153057 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 68)) = Xsqlite3_collation_needed
 153058 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 72)) = Xsqlite3_collation_needed16
 153059 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 76)) = Xsqlite3_column_blob
 153060 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 80)) = Xsqlite3_column_bytes
 153061 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 84)) = Xsqlite3_column_bytes16
 153062 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 88)) = Xsqlite3_column_count
 153063 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 92)) = Xsqlite3_column_database_name
 153064 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 96)) = Xsqlite3_column_database_name16
 153065 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 100)) = Xsqlite3_column_decltype
 153066 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 104)) = Xsqlite3_column_decltype16
 153067 	*(*func(*libc.TLS, uintptr, int32) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 108)) = Xsqlite3_column_double
 153068 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 112)) = Xsqlite3_column_int
 153069 	*(*func(*libc.TLS, uintptr, int32) Sqlite_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 116)) = Xsqlite3_column_int64
 153070 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 120)) = Xsqlite3_column_name
 153071 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 124)) = Xsqlite3_column_name16
 153072 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 128)) = Xsqlite3_column_origin_name
 153073 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 132)) = Xsqlite3_column_origin_name16
 153074 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 136)) = Xsqlite3_column_table_name
 153075 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 140)) = Xsqlite3_column_table_name16
 153076 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 144)) = Xsqlite3_column_text
 153077 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 148)) = Xsqlite3_column_text16
 153078 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 152)) = Xsqlite3_column_type
 153079 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 156)) = Xsqlite3_column_value
 153080 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 160)) = Xsqlite3_commit_hook
 153081 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 164)) = Xsqlite3_complete
 153082 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 168)) = Xsqlite3_complete16
 153083 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 172)) = Xsqlite3_create_collation
 153084 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 176)) = Xsqlite3_create_collation16
 153085 	*(*func(*libc.TLS, uintptr, uintptr, int32, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 180)) = Xsqlite3_create_function
 153086 	*(*func(*libc.TLS, uintptr, uintptr, int32, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 184)) = Xsqlite3_create_function16
 153087 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 188)) = Xsqlite3_create_module
 153088 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 192)) = Xsqlite3_data_count
 153089 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 196)) = Xsqlite3_db_handle
 153090 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 200)) = Xsqlite3_declare_vtab
 153091 	*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 204)) = Xsqlite3_enable_shared_cache
 153092 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 208)) = Xsqlite3_errcode
 153093 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 212)) = Xsqlite3_errmsg
 153094 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 216)) = Xsqlite3_errmsg16
 153095 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_callback, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 220)) = Xsqlite3_exec
 153096 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 224)) = Xsqlite3_expired
 153097 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 228)) = Xsqlite3_finalize
 153098 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 232)) = Xsqlite3_free
 153099 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 236)) = Xsqlite3_free_table
 153100 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 240)) = Xsqlite3_get_autocommit
 153101 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 244)) = Xsqlite3_get_auxdata
 153102 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 248)) = Xsqlite3_get_table
 153103 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 256)) = Xsqlite3_interrupt
 153104 	*(*func(*libc.TLS, uintptr) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 260)) = Xsqlite3_last_insert_rowid
 153105 	*(*func(*libc.TLS) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 264)) = Xsqlite3_libversion
 153106 	*(*func(*libc.TLS) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 268)) = Xsqlite3_libversion_number
 153107 	*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 272)) = Xsqlite3_malloc
 153108 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 276)) = Xsqlite3_mprintf
 153109 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 280)) = Xsqlite3_open
 153110 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 284)) = Xsqlite3_open16
 153111 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 288)) = Xsqlite3_prepare
 153112 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 292)) = Xsqlite3_prepare16
 153113 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 296)) = Xsqlite3_profile
 153114 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 300)) = Xsqlite3_progress_handler
 153115 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 304)) = Xsqlite3_realloc
 153116 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 308)) = Xsqlite3_reset
 153117 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 312)) = Xsqlite3_result_blob
 153118 	*(*func(*libc.TLS, uintptr, float64))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 316)) = Xsqlite3_result_double
 153119 	*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 320)) = Xsqlite3_result_error
 153120 	*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 324)) = Xsqlite3_result_error16
 153121 	*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 328)) = Xsqlite3_result_int
 153122 	*(*func(*libc.TLS, uintptr, I64))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 332)) = Xsqlite3_result_int64
 153123 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 336)) = Xsqlite3_result_null
 153124 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 340)) = Xsqlite3_result_text
 153125 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 344)) = Xsqlite3_result_text16
 153126 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 348)) = Xsqlite3_result_text16be
 153127 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 352)) = Xsqlite3_result_text16le
 153128 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 356)) = Xsqlite3_result_value
 153129 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 360)) = Xsqlite3_rollback_hook
 153130 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 364)) = Xsqlite3_set_authorizer
 153131 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 368)) = Xsqlite3_set_auxdata
 153132 	*(*func(*libc.TLS, int32, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 372)) = Xsqlite3_snprintf
 153133 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 376)) = Xsqlite3_step
 153134 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 380)) = Xsqlite3_table_column_metadata
 153135 	*(*func(*libc.TLS))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 384)) = Xsqlite3_thread_cleanup
 153136 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 388)) = Xsqlite3_total_changes
 153137 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 392)) = Xsqlite3_trace
 153138 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 396)) = Xsqlite3_transfer_bindings
 153139 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 400)) = Xsqlite3_update_hook
 153140 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 404)) = Xsqlite3_user_data
 153141 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 408)) = Xsqlite3_value_blob
 153142 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 412)) = Xsqlite3_value_bytes
 153143 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 416)) = Xsqlite3_value_bytes16
 153144 	*(*func(*libc.TLS, uintptr) float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 420)) = Xsqlite3_value_double
 153145 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 424)) = Xsqlite3_value_int
 153146 	*(*func(*libc.TLS, uintptr) Sqlite_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 428)) = Xsqlite3_value_int64
 153147 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 432)) = Xsqlite3_value_numeric_type
 153148 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 436)) = Xsqlite3_value_text
 153149 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 440)) = Xsqlite3_value_text16
 153150 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 444)) = Xsqlite3_value_text16be
 153151 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 448)) = Xsqlite3_value_text16le
 153152 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 452)) = Xsqlite3_value_type
 153153 	*(*func(*libc.TLS, uintptr, Va_list) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 456)) = Xsqlite3_vmprintf
 153154 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 460)) = Xsqlite3_overload_function
 153155 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 464)) = Xsqlite3_prepare_v2
 153156 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 468)) = Xsqlite3_prepare16_v2
 153157 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 472)) = Xsqlite3_clear_bindings
 153158 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 476)) = Xsqlite3_create_module_v2
 153159 	*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 480)) = Xsqlite3_bind_zeroblob
 153160 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 484)) = Xsqlite3_blob_bytes
 153161 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 488)) = Xsqlite3_blob_close
 153162 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, Sqlite_int64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 492)) = Xsqlite3_blob_open
 153163 	*(*func(*libc.TLS, uintptr, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 496)) = Xsqlite3_blob_read
 153164 	*(*func(*libc.TLS, uintptr, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 500)) = Xsqlite3_blob_write
 153165 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 504)) = Xsqlite3_create_collation_v2
 153166 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 508)) = Xsqlite3_file_control
 153167 	*(*func(*libc.TLS, int32) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 512)) = Xsqlite3_memory_highwater
 153168 	*(*func(*libc.TLS) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 516)) = Xsqlite3_memory_used
 153169 	*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 520)) = Xsqlite3_mutex_alloc
 153170 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 524)) = Xsqlite3_mutex_enter
 153171 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 528)) = Xsqlite3_mutex_free
 153172 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 532)) = Xsqlite3_mutex_leave
 153173 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 536)) = Xsqlite3_mutex_try
 153174 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 540)) = Xsqlite3_open_v2
 153175 	*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 544)) = Xsqlite3_release_memory
 153176 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 548)) = Xsqlite3_result_error_nomem
 153177 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 552)) = Xsqlite3_result_error_toobig
 153178 	*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 556)) = Xsqlite3_sleep
 153179 	*(*func(*libc.TLS, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 560)) = Xsqlite3_soft_heap_limit
 153180 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 564)) = Xsqlite3_vfs_find
 153181 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 568)) = Xsqlite3_vfs_register
 153182 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 572)) = Xsqlite3_vfs_unregister
 153183 	*(*func(*libc.TLS) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 576)) = Xsqlite3_threadsafe
 153184 	*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 580)) = Xsqlite3_result_zeroblob
 153185 	*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 584)) = Xsqlite3_result_error_code
 153186 	*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 588)) = Xsqlite3_test_control
 153187 	*(*func(*libc.TLS, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 592)) = Xsqlite3_randomness
 153188 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 596)) = Xsqlite3_context_db_handle
 153189 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 600)) = Xsqlite3_extended_result_codes
 153190 	*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 604)) = Xsqlite3_limit
 153191 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 608)) = Xsqlite3_next_stmt
 153192 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 612)) = Xsqlite3_sql
 153193 	*(*func(*libc.TLS, int32, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 616)) = Xsqlite3_status
 153194 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 620)) = Xsqlite3_backup_finish
 153195 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 624)) = Xsqlite3_backup_init
 153196 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 628)) = Xsqlite3_backup_pagecount
 153197 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 632)) = Xsqlite3_backup_remaining
 153198 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 636)) = Xsqlite3_backup_step
 153199 	*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 640)) = Xsqlite3_compileoption_get
 153200 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 644)) = Xsqlite3_compileoption_used
 153201 	*(*func(*libc.TLS, uintptr, uintptr, int32, int32, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 648)) = Xsqlite3_create_function_v2
 153202 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 652)) = Xsqlite3_db_config
 153203 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 656)) = Xsqlite3_db_mutex
 153204 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 660)) = Xsqlite3_db_status
 153205 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 664)) = Xsqlite3_extended_errcode
 153206 	*(*func(*libc.TLS, int32, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 668)) = Xsqlite3_log
 153207 	*(*func(*libc.TLS, Sqlite3_int64) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 672)) = Xsqlite3_soft_heap_limit64
 153208 	*(*func(*libc.TLS) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 676)) = Xsqlite3_sourceid
 153209 	*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 680)) = Xsqlite3_stmt_status
 153210 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 684)) = Xsqlite3_strnicmp
 153211 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 688)) = Xsqlite3_unlock_notify
 153212 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 692)) = Xsqlite3_wal_autocheckpoint
 153213 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 696)) = Xsqlite3_wal_checkpoint
 153214 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 700)) = Xsqlite3_wal_hook
 153215 	*(*func(*libc.TLS, uintptr, Sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 704)) = Xsqlite3_blob_reopen
 153216 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 708)) = Xsqlite3_vtab_config
 153217 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 712)) = Xsqlite3_vtab_on_conflict
 153218 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 716)) = Xsqlite3_close_v2
 153219 	*(*func(*libc.TLS, uintptr, uintptr) Sqlite3_filename)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 720)) = Xsqlite3_db_filename
 153220 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 724)) = Xsqlite3_db_readonly
 153221 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 728)) = Xsqlite3_db_release_memory
 153222 	*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 732)) = Xsqlite3_errstr
 153223 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 736)) = Xsqlite3_stmt_busy
 153224 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 740)) = Xsqlite3_stmt_readonly
 153225 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 744)) = Xsqlite3_stricmp
 153226 	*(*func(*libc.TLS, Sqlite3_filename, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 748)) = Xsqlite3_uri_boolean
 153227 	*(*func(*libc.TLS, Sqlite3_filename, uintptr, Sqlite3_int64) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 752)) = Xsqlite3_uri_int64
 153228 	*(*func(*libc.TLS, Sqlite3_filename, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 756)) = Xsqlite3_uri_parameter
 153229 	*(*func(*libc.TLS, int32, uintptr, uintptr, Va_list) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 760)) = Xsqlite3_vsnprintf
 153230 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 764)) = Xsqlite3_wal_checkpoint_v2
 153231 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 768)) = Xsqlite3_auto_extension
 153232 	*(*func(*libc.TLS, uintptr, int32, uintptr, Sqlite3_uint64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 772)) = Xsqlite3_bind_blob64
 153233 	*(*func(*libc.TLS, uintptr, int32, uintptr, Sqlite3_uint64, uintptr, uint8) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 776)) = Xsqlite3_bind_text64
 153234 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 780)) = Xsqlite3_cancel_auto_extension
 153235 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 784)) = Xsqlite3_load_extension
 153236 	*(*func(*libc.TLS, Sqlite3_uint64) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 788)) = Xsqlite3_malloc64
 153237 	*(*func(*libc.TLS, uintptr) Sqlite3_uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 792)) = Xsqlite3_msize
 153238 	*(*func(*libc.TLS, uintptr, Sqlite3_uint64) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 796)) = Xsqlite3_realloc64
 153239 	*(*func(*libc.TLS))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 800)) = Xsqlite3_reset_auto_extension
 153240 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_uint64, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 804)) = Xsqlite3_result_blob64
 153241 	*(*func(*libc.TLS, uintptr, uintptr, Sqlite3_uint64, uintptr, uint8))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 808)) = Xsqlite3_result_text64
 153242 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 812)) = Xsqlite3_strglob
 153243 	*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 816)) = *(*uintptr)(unsafe.Pointer(&struct {
 153244 		f func(*libc.TLS, uintptr) uintptr
 153245 	}{Xsqlite3_value_dup}))
 153246 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 820)) = Xsqlite3_value_free
 153247 	*(*func(*libc.TLS, uintptr, U64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 824)) = Xsqlite3_result_zeroblob64
 153248 	*(*func(*libc.TLS, uintptr, int32, Sqlite3_uint64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 828)) = Xsqlite3_bind_zeroblob64
 153249 	*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 832)) = Xsqlite3_value_subtype
 153250 	*(*func(*libc.TLS, uintptr, uint32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 836)) = Xsqlite3_result_subtype
 153251 	*(*func(*libc.TLS, int32, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 840)) = Xsqlite3_status64
 153252 	*(*func(*libc.TLS, uintptr, uintptr, uint32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 844)) = Xsqlite3_strlike
 153253 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 848)) = Xsqlite3_db_cacheflush
 153254 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 852)) = Xsqlite3_system_errno
 153255 	*(*func(*libc.TLS, uintptr, uint32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 856)) = Xsqlite3_trace_v2
 153256 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 860)) = Xsqlite3_expanded_sql
 153257 	*(*func(*libc.TLS, uintptr, Sqlite3_int64))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 864)) = Xsqlite3_set_last_insert_rowid
 153258 	*(*func(*libc.TLS, uintptr, uintptr, int32, uint32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 868)) = Xsqlite3_prepare_v3
 153259 	*(*func(*libc.TLS, uintptr, uintptr, int32, uint32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 872)) = Xsqlite3_prepare16_v3
 153260 	*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 876)) = Xsqlite3_bind_pointer
 153261 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 880)) = Xsqlite3_result_pointer
 153262 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 884)) = Xsqlite3_value_pointer
 153263 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 888)) = Xsqlite3_vtab_nochange
 153264 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 892)) = Xsqlite3_value_nochange
 153265 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 896)) = Xsqlite3_vtab_collation
 153266 	*(*func(*libc.TLS) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 900)) = Xsqlite3_keyword_count
 153267 	*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 904)) = Xsqlite3_keyword_name
 153268 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 908)) = Xsqlite3_keyword_check
 153269 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 912)) = Xsqlite3_str_new
 153270 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 916)) = Xsqlite3_str_finish
 153271 	*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 920)) = Xsqlite3_str_appendf
 153272 	*(*func(*libc.TLS, uintptr, uintptr, Va_list))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 924)) = Xsqlite3_str_vappendf
 153273 	*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 928)) = Xsqlite3_str_append
 153274 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 932)) = Xsqlite3_str_appendall
 153275 	*(*func(*libc.TLS, uintptr, int32, uint8))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 936)) = Xsqlite3_str_appendchar
 153276 	*(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 940)) = Xsqlite3_str_reset
 153277 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 944)) = Xsqlite3_str_errcode
 153278 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 948)) = Xsqlite3_str_length
 153279 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 952)) = Xsqlite3_str_value
 153280 	*(*func(*libc.TLS, uintptr, uintptr, int32, int32, uintptr, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 956)) = Xsqlite3_create_window_function
 153281 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 964)) = Xsqlite3_stmt_isexplain
 153282 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 968)) = Xsqlite3_value_frombind
 153283 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 972)) = Xsqlite3_drop_modules
 153284 	*(*func(*libc.TLS, Sqlite3_int64) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 976)) = Xsqlite3_hard_heap_limit64
 153285 	*(*func(*libc.TLS, Sqlite3_filename, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 980)) = Xsqlite3_uri_key
 153286 	*(*func(*libc.TLS, Sqlite3_filename) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 984)) = Xsqlite3_filename_database
 153287 	*(*func(*libc.TLS, Sqlite3_filename) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 988)) = Xsqlite3_filename_journal
 153288 	*(*func(*libc.TLS, Sqlite3_filename) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 992)) = Xsqlite3_filename_wal
 153289 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) Sqlite3_filename)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 996)) = Xsqlite3_create_filename
 153290 	*(*func(*libc.TLS, Sqlite3_filename))(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1000)) = Xsqlite3_free_filename
 153291 	*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1004)) = Xsqlite3_database_file_object
 153292 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1008)) = Xsqlite3_txn_state
 153293 	*(*func(*libc.TLS, uintptr) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1012)) = Xsqlite3_changes64
 153294 	*(*func(*libc.TLS, uintptr) Sqlite3_int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1016)) = Xsqlite3_total_changes64
 153295 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1020)) = Xsqlite3_autovacuum_pages
 153296 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1024)) = Xsqlite3_error_offset
 153297 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1028)) = Xsqlite3_vtab_rhs_value
 153298 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1032)) = Xsqlite3_vtab_distinct
 153299 	*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1036)) = Xsqlite3_vtab_in
 153300 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1040)) = Xsqlite3_vtab_in_first
 153301 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1044)) = Xsqlite3_vtab_in_next
 153302 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, Sqlite3_int64, Sqlite3_int64, uint32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1048)) = Xsqlite3_deserialize
 153303 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, uint32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1052)) = Xsqlite3_serialize
 153304 	*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1056)) = Xsqlite3_db_name
 153305 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1060)) = Xsqlite3_value_encoding
 153306 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3Apis)) + 1064)) = Xsqlite3_is_interrupted
 153307 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3BuiltinExtensions)) + 0)) = Xsqlite3Fts5Init
 153308 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3BuiltinExtensions)) + 4)) = Xsqlite3RtreeInit
 153309 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3BuiltinExtensions)) + 8)) = sqlite3TestExtInit
 153310 	*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3BuiltinExtensions)) + 12)) = Xsqlite3JsonTableFunctions
 153311 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&statGetFuncdef)) + 16)) = statGet
 153312 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&statInitFuncdef)) + 16)) = statInit
 153313 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&statPushFuncdef)) + 16)) = statPush
 153314 	*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 24)) = rbuVfsOpen
 153315 	*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 28)) = rbuVfsDelete
 153316 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 32)) = rbuVfsAccess
 153317 	*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 36)) = rbuVfsFullPathname
 153318 	*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 40)) = rbuVfsDlOpen
 153319 	*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 44)) = rbuVfsDlError
 153320 	*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 48)) = rbuVfsDlSym
 153321 	*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 52)) = rbuVfsDlClose
 153322 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 56)) = rbuVfsRandomness
 153323 	*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 60)) = rbuVfsSleep
 153324 	*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 64)) = rbuVfsCurrentTime
 153325 	*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfs_template)) + 68)) = rbuVfsGetLastError
 153326 }
 153327 
 153328 var ts1 = "3.41.2\x00ATOMIC_INTRINSICS=1\x00COMPILER=gcc-10.2.1 20210110\x00DEFAULT_AUTOVACUUM\x00DEFAULT_CACHE_SIZE=-2000\x00DEFAULT_FILE_FORMAT=4\x00DEFAULT_JOURNAL_SIZE_LIMIT=-1\x00DEFAULT_MEMSTATUS=0\x00DEFAULT_MMAP_SIZE=0\x00DEFAULT_PAGE_SIZE=4096\x00DEFAULT_PCACHE_INITSZ=20\x00DEFAULT_RECURSIVE_TRIGGERS\x00DEFAULT_SECTOR_SIZE=4096\x00DEFAULT_SYNCHRONOUS=2\x00DEFAULT_WAL_AUTOCHECKPOINT=1000\x00DEFAULT_WAL_SYNCHRONOUS=2\x00DEFAULT_WORKER_THREADS=0\x00ENABLE_COLUMN_METADATA\x00ENABLE_FTS5\x00ENABLE_GEOPOLY\x00ENABLE_MATH_FUNCTIONS\x00ENABLE_MEMORY_MANAGEMENT\x00ENABLE_OFFSET_SQL_FUNC\x00ENABLE_PREUPDATE_HOOK\x00ENABLE_RBU\x00ENABLE_RTREE\x00ENABLE_SESSION\x00ENABLE_SNAPSHOT\x00ENABLE_STAT4\x00ENABLE_UNLOCK_NOTIFY\x00LIKE_DOESNT_MATCH_BLOBS\x00MALLOC_SOFT_LIMIT=1024\x00MAX_ATTACHED=10\x00MAX_COLUMN=2000\x00MAX_COMPOUND_SELECT=500\x00MAX_DEFAULT_PAGE_SIZE=8192\x00MAX_EXPR_DEPTH=1000\x00MAX_FUNCTION_ARG=127\x00MAX_LENGTH=1000000000\x00MAX_LIKE_PATTERN_LENGTH=50000\x00MAX_MMAP_SIZE=0x7fff0000\x00MAX_PAGE_COUNT=1073741823\x00MAX_PAGE_SIZE=65536\x00MAX_SQL_LENGTH=1000000000\x00MAX_TRIGGER_DEPTH=1000\x00MAX_VARIABLE_NUMBER=32766\x00MAX_VDBE_OP=250000000\x00MAX_WORKER_THREADS=8\x00MUTEX_NOOP\x00SOUNDEX\x00SYSTEM_MALLOC\x00TEMP_STORE=1\x00THREADSAFE=1\x00BINARY\x00ANY\x00BLOB\x00INT\x00INTEGER\x00REAL\x00TEXT\x0020b:20e\x0020c:20e\x0020e\x0040f-21a-21d\x00now\x00local time unavailable\x00second\x00minute\x00hour\x00\x00\x00day\x00\x00\x00\x00month\x00\x00year\x00\x00\x00auto\x00julianday\x00localtime\x00unixepoch\x00utc\x00weekday \x00start of \x00month\x00year\x00day\x00%02d\x00%06.3f\x00%03d\x00%.16g\x00%lld\x00%04d\x00date\x00time\x00datetime\x00strftime\x00current_time\x00current_timestamp\x00current_date\x00failed to allocate %u bytes of memory\x00failed memory resize %u to %u bytes\x00out of memory\x000123456789ABCDEF0123456789abcdef\x00-x0\x00X0\x00%\x00NaN\x00Inf\x00\x00NULL\x00(NULL)\x00.\x00(join-%u)\x00(subquery-%u)\x00thstndrd\x00922337203685477580\x00API call with %s database connection pointer\x00unopened\x00invalid\x00Savepoint\x00AutoCommit\x00Transaction\x00Checkpoint\x00JournalMode\x00Vacuum\x00VFilter\x00VUpdate\x00Init\x00Goto\x00Gosub\x00InitCoroutine\x00Yield\x00MustBeInt\x00Jump\x00Once\x00If\x00IfNot\x00IsType\x00Not\x00IfNullRow\x00SeekLT\x00SeekLE\x00SeekGE\x00SeekGT\x00IfNotOpen\x00IfNoHope\x00NoConflict\x00NotFound\x00Found\x00SeekRowid\x00NotExists\x00Last\x00IfSmaller\x00SorterSort\x00Sort\x00Rewind\x00SorterNext\x00Prev\x00Next\x00IdxLE\x00IdxGT\x00IdxLT\x00Or\x00And\x00IdxGE\x00RowSetRead\x00RowSetTest\x00Program\x00FkIfZero\x00IsNull\x00NotNull\x00Ne\x00Eq\x00Gt\x00Le\x00Lt\x00Ge\x00ElseEq\x00IfPos\x00IfNotZero\x00DecrJumpZero\x00IncrVacuum\x00VNext\x00Filter\x00PureFunc\x00Function\x00Return\x00EndCoroutine\x00HaltIfNull\x00Halt\x00Integer\x00Int64\x00String\x00BeginSubrtn\x00Null\x00SoftNull\x00Blob\x00Variable\x00Move\x00Copy\x00SCopy\x00IntCopy\x00FkCheck\x00ResultRow\x00CollSeq\x00AddImm\x00RealAffinity\x00Cast\x00Permutation\x00Compare\x00IsTrue\x00ZeroOrNull\x00Offset\x00Column\x00TypeCheck\x00Affinity\x00MakeRecord\x00Count\x00ReadCookie\x00SetCookie\x00ReopenIdx\x00BitAnd\x00BitOr\x00ShiftLeft\x00ShiftRight\x00Add\x00Subtract\x00Multiply\x00Divide\x00Remainder\x00Concat\x00OpenRead\x00OpenWrite\x00BitNot\x00OpenDup\x00OpenAutoindex\x00String8\x00OpenEphemeral\x00SorterOpen\x00SequenceTest\x00OpenPseudo\x00Close\x00ColumnsUsed\x00SeekScan\x00SeekHit\x00Sequence\x00NewRowid\x00Insert\x00RowCell\x00Delete\x00ResetCount\x00SorterCompare\x00SorterData\x00RowData\x00Rowid\x00NullRow\x00SeekEnd\x00IdxInsert\x00SorterInsert\x00IdxDelete\x00DeferredSeek\x00IdxRowid\x00FinishSeek\x00Destroy\x00Clear\x00ResetSorter\x00CreateBtree\x00SqlExec\x00ParseSchema\x00LoadAnalysis\x00DropTable\x00DropIndex\x00Real\x00DropTrigger\x00IntegrityCk\x00RowSetAdd\x00Param\x00FkCounter\x00MemMax\x00OffsetLimit\x00AggInverse\x00AggStep\x00AggStep1\x00AggValue\x00AggFinal\x00Expire\x00CursorLock\x00CursorUnlock\x00TableLock\x00VBegin\x00VCreate\x00VDestroy\x00VOpen\x00VInitIn\x00VColumn\x00VRename\x00Pagecount\x00MaxPgcnt\x00ClrSubtype\x00FilterAdd\x00Trace\x00CursorHint\x00ReleaseReg\x00Noop\x00Explain\x00Abortable\x00open\x00close\x00access\x00getcwd\x00stat\x00fstat\x00ftruncate\x00fcntl\x00read\x00pread\x00pread64\x00write\x00pwrite\x00pwrite64\x00fchmod\x00fallocate\x00unlink\x00openDirectory\x00mkdir\x00rmdir\x00fchown\x00geteuid\x00mmap\x00munmap\x00mremap\x00getpagesize\x00readlink\x00lstat\x00ioctl\x00attempt to open \"%s\" as file descriptor %d\x00/dev/null\x00os_unix.c:%d: (%d) %s(%s) - %s\x00cannot fstat db file %s\x00file unlinked while open: %s\x00multiple links to file: %s\x00file renamed while open: %s\x00%s\x00full_fsync\x00%s-shm\x00readonly_shm\x00psow\x00unix-excl\x00%s.lock\x00/var/tmp\x00/usr/tmp\x00/tmp\x00SQLITE_TMPDIR\x00TMPDIR\x00%s/etilqs_%llx%c\x00modeof\x00fsync\x00/dev/urandom\x00unix\x00unix-none\x00unix-dotfile\x00memdb\x00memdb(%p,%lld)\x00PRAGMA \"%w\".page_count\x00ATTACH x AS %Q\x00recovered %d pages from %s\x00-journal\x00-wal\x00nolock\x00immutable\x00PRAGMA table_list\x00recovered %d frames from WAL file %s\x00cannot limit WAL size: %s\x00SQLite format 3\x00:memory:\x00@  \x00\n\x00invalid page number %d\x002nd reference to page %d\x00Failed to read ptrmap key=%d\x00Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)\x00failed to get page %d\x00freelist leaf count too big on page %d\x00%s is %d but should be %d\x00size\x00overflow list length\x00Page %u: \x00unable to get the page. error code=%d\x00btreeInitPage() returns error code %d\x00free space corruption\x00On tree page %u cell %d: \x00On page %u at right child: \x00Offset %d out of range %d..%d\x00Extends off end of page\x00Rowid %lld out of order\x00Child page depth differs\x00Multiple uses for byte %u of page %u\x00Fragmentation of %d bytes reported as %d on page %u\x00Main freelist: \x00max rootpage (%d) disagrees with header (%d)\x00incremental_vacuum enabled with a max rootpage of zero\x00Page %d is never used\x00Pointer map page %d is referenced\x00unknown database %s\x00destination database is in use\x00source and destination must be distinct\x00%!.15g\x00-\x00%s%s\x00k(%d\x00B\x00,%s%s%s\x00N.\x00)\x00%.18s-%s\x00%s(%d)\x00%d\x00(blob)\x00vtab:%p\x00%c%u\x00]\x00program\x00?\x008\x0016LE\x0016BE\x00addr\x00opcode\x00p1\x00p2\x00p3\x00p4\x00p5\x00comment\x00id\x00parent\x00notused\x00detail\x00%.4c%s%.16c\x00MJ delete: %s\x00MJ collide: %s\x00-mj%06X9%02X\x00FOREIGN KEY constraint failed\x00a CHECK constraint\x00a generated column\x00an index\x00non-deterministic use of %s() in %s\x00API called with finalized prepared statement\x00API called with NULL prepared statement\x00string or blob too big\x00bind on a busy prepared statement: [%s]\x00-- \x00'%.*q'\x00zeroblob(%d)\x00x'\x00%02x\x00'\x00%s constraint failed\x00%z: %s\x00abort at %d in [%s]: %s\x00cannot store %s value in %s column %s.%s\x00cannot open savepoint - SQL statements in progress\x00no such savepoint: %s\x00cannot release savepoint - SQL statements in progress\x00cannot commit transaction - SQL statements in progress\x00cannot start a transaction within a transaction\x00cannot rollback - no transaction is active\x00cannot commit - no transaction is active\x00database schema has changed\x00index corruption\x00sqlite_master\x00SELECT*FROM\"%w\".%s WHERE %s ORDER BY rowid\x00too many levels of trigger recursion\x00cannot change %s wal mode from within a transaction\x00into\x00out of\x00database table is locked: %s\x00ValueList\x00-- %s\x00statement aborts at %d: [%s] %s\x00NOT NULL\x00UNIQUE\x00CHECK\x00FOREIGN KEY\x00cannot open value of type %s\x00null\x00real\x00integer\x00no such rowid: %lld\x00cannot open virtual table: %s\x00cannot open table without rowid: %s\x00cannot open view: %s\x00no such column: \"%s\"\x00foreign key\x00indexed\x00cannot open %s column for writing\x00sqlite_\x00sqlite_temp_master\x00sqlite_temp_schema\x00sqlite_schema\x00main\x00*\x00new\x00old\x00excluded\x00misuse of aliased aggregate %s\x00misuse of aliased window function %s\x00row value misused\x00double-quoted string literal: \"%w\"\x00coalesce\x00no such column\x00ambiguous column name\x00%s: %s.%s.%s\x00%s: %s.%s\x00%s: %s\x00partial index WHERE clauses\x00index expressions\x00CHECK constraints\x00generated columns\x00%s prohibited in %s\x00the \".\" operator\x00second argument to %#T() must be a constant between 0.0 and 1.0\x00not authorized to use function: %#T\x00non-deterministic functions\x00%#T() may not be used as a window function\x00window\x00aggregate\x00misuse of %s function %#T()\x00no such function: %#T\x00wrong number of arguments to function %#T()\x00FILTER may not be used with non-aggregate %#T()\x00subqueries\x00parameters\x00%r %s BY term out of range - should be between 1 and %d\x00too many terms in ORDER BY clause\x00ORDER\x00%r ORDER BY term does not match any column in the result set\x00too many terms in %s BY clause\x00HAVING clause on a non-aggregate query\x00GROUP\x00aggregate functions are not allowed in the GROUP BY clause\x00Expression tree is too large (maximum depth %d)\x00IN(...) element has %d term%s - expected %d\x00s\x000\x00too many arguments on function %T\x00unsafe use of %#T()\x00variable number must be between ?1 and ?%d\x00too many SQL variables\x00%d columns assigned %d values\x00too many columns in %s\x00true\x00false\x00_ROWID_\x00ROWID\x00OID\x00USING ROWID SEARCH ON TABLE %s FOR IN-OPERATOR\x00USING INDEX %s FOR IN-OPERATOR\x00sub-select returns %d columns - expected %d\x00REUSE LIST SUBQUERY %d\x00%sLIST SUBQUERY %d\x00CORRELATED \x00REUSE SUBQUERY %d\x00%sSCALAR SUBQUERY %d\x001\x000x\x00hex literal too big: %s%#T\x00generated column loop on \"%s\"\x00blob\x00text\x00numeric\x00flexnum\x00none\x00misuse of aggregate: %#T()\x00unknown function: %#T()\x00RAISE() may only be used within a trigger-program\x00B\x00C\x00D\x00E\x00F\x00table %s may not be altered\x00SELECT 1 FROM \"%w\".sqlite_master WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%' AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %d)=NULL \x00SELECT 1 FROM temp.sqlite_master WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%' AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %d)=NULL \x00UPDATE \"%w\".sqlite_master SET sql = sqlite_rename_quotefix(%Q, sql)WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%'\x00UPDATE temp.sqlite_master SET sql = sqlite_rename_quotefix('temp', sql)WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' AND sql NOT LIKE 'create virtual%%'\x00there is already another table or index with this name: %s\x00table\x00view %s may not be altered\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)AND   name NOT LIKE 'sqliteX_%%' ESCAPE 'X'\x00UPDATE %Q.sqlite_master SET tbl_name = %Q, name = CASE WHEN type='table' THEN %Q WHEN name LIKE 'sqliteX_autoindex%%' ESCAPE 'X'      AND type='index' THEN 'sqlite_autoindex_' || %Q || substr(name,%d+18) ELSE name END WHERE tbl_name=%Q COLLATE nocase AND (type='table' OR type='index' OR type='trigger');\x00sqlite_sequence\x00UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q\x00UPDATE sqlite_temp_schema SET sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), tbl_name = CASE WHEN tbl_name=%Q COLLATE nocase AND   sqlite_rename_test(%Q, sql, type, name, 1, 'after rename', 0) THEN %Q ELSE tbl_name END WHERE type IN ('view', 'trigger')\x00after rename\x00SELECT raise(ABORT,%Q) FROM \"%w\".\"%w\"\x00Cannot add a PRIMARY KEY column\x00Cannot add a UNIQUE column\x00Cannot add a REFERENCES column with non-NULL default value\x00Cannot add a NOT NULL column with default value NULL\x00Cannot add a column with non-constant default\x00cannot add a STORED column\x00UPDATE \"%w\".sqlite_master SET sql = printf('%%.%ds, ',sql) || %Q || substr(sql,1+length(printf('%%.%ds',sql))) WHERE type = 'table' AND name = %Q\x00SELECT CASE WHEN quick_check GLOB 'CHECK*' THEN raise(ABORT,'CHECK constraint failed') ELSE raise(ABORT,'NOT NULL constraint failed') END  FROM pragma_quick_check(%Q,%Q) WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'\x00virtual tables may not be altered\x00Cannot add a column to a view\x00sqlite_altertab_%s\x00view\x00virtual table\x00cannot %s %s \"%s\"\x00drop column from\x00rename columns of\x00no such column: \"%T\"\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'  AND (type != 'index' OR tbl_name = %Q)\x00UPDATE temp.sqlite_master SET sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) WHERE type IN ('trigger', 'view')\x00error in %s %s%s%s: %s\x00 \x00CREATE \x00\"%w\" \x00%Q%s\x00%.*s%s\x00cannot drop %s column: \"%s\"\x00PRIMARY KEY\x00cannot drop column \"%s\": no other columns exist\x00UPDATE \"%w\".sqlite_master SET sql = sqlite_drop_column(%d, sql, %d) WHERE (type=='table' AND tbl_name=%Q COLLATE nocase)\x00after drop column\x00sqlite_rename_column\x00sqlite_rename_table\x00sqlite_rename_test\x00sqlite_drop_column\x00sqlite_rename_quotefix\x00CREATE TABLE %Q.%s(%s)\x00DELETE FROM %Q.%s WHERE %s=%Q\x00DELETE FROM %Q.%s\x00sqlite_stat1\x00tbl,idx,stat\x00sqlite_stat4\x00tbl,idx,neq,nlt,ndlt,sample\x00sqlite_stat3\x00stat_init\x00stat_push\x00%llu\x00 %llu\x00%llu \x00stat_get\x00sqlite\\_%\x00BBB\x00idx\x00tbl\x00unordered*\x00sz=[0-9]*\x00noskipscan*\x00SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\x00SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\x00SELECT tbl,idx,stat FROM %Q.sqlite_stat1\x00x\x00\x00too many attached databases - max %d\x00database %s is already in use\x00database is already attached\x00attached databases must use the same text encoding as main database\x00unable to open database: %s\x00no such database: %s\x00cannot detach database %s\x00database %s is locked\x00sqlite_detach\x00sqlite_attach\x00%s cannot use variables\x00%s %T cannot reference objects in database %s\x00authorizer malfunction\x00%s.%s\x00%s.%z\x00access to %z is prohibited\x00not authorized\x00pragma_\x00no such view\x00no such table\x00corrupt database\x00unknown database %T\x00object name reserved for internal use: %s\x00temporary table name must be unqualified\x00%s %T already exists\x00there is already an index named %s\x00sqlite_returning\x00cannot use RETURNING in a trigger\x00too many columns on %s\x00always\x00generated\x00duplicate column name: %s\x00default value of column [%s] is not constant\x00cannot use DEFAULT on a generated column\x00generated columns cannot be part of the PRIMARY KEY\x00table \"%s\" has more than one primary key\x00AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY\x00virtual tables cannot use computed columns\x00virtual\x00stored\x00error in generated column \"%s\"\x00,\x00\n  \x00,\n  \x00\n)\x00CREATE TABLE \x00 TEXT\x00 NUM\x00 INT\x00 REAL\x00unknown datatype for %s.%s: \"%s\"\x00missing datatype for %s.%s\x00AUTOINCREMENT not allowed on WITHOUT ROWID tables\x00PRIMARY KEY missing on table %s\x00must have at least one non-generated column\x00TABLE\x00VIEW\x00CREATE %s %.*s\x00UPDATE %Q.sqlite_master SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q WHERE rowid=#%d\x00CREATE TABLE %Q.sqlite_sequence(name,seq)\x00tbl_name='%q' AND type!='trigger'\x00parameters are not allowed in views\x00view %s is circularly defined\x00corrupt schema\x00UPDATE %Q.sqlite_master SET rootpage=%d WHERE #%d AND rootpage=#%d\x00sqlite_stat%d\x00DELETE FROM %Q.sqlite_sequence WHERE name=%Q\x00DELETE FROM %Q.sqlite_master WHERE tbl_name=%Q and type!='trigger'\x00table %s may not be dropped\x00use DROP TABLE to delete table %s\x00use DROP VIEW to delete view %s\x00foreign key on %s should reference only one column of table %T\x00number of columns in foreign key does not match the number of columns in the referenced table\x00unknown column \"%s\" in foreign key definition\x00unsupported use of NULLS %s\x00FIRST\x00LAST\x00index\x00cannot create a TEMP index on non-TEMP table \"%s\"\x00table %s may not be indexed\x00views may not be indexed\x00virtual tables may not be indexed\x00there is already a table named %s\x00index %s already exists\x00sqlite_autoindex_%s_%d\x00expressions prohibited in PRIMARY KEY and UNIQUE constraints\x00conflicting ON CONFLICT clauses specified\x00invalid rootpage\x00CREATE%s INDEX %.*s\x00 UNIQUE\x00INSERT INTO %Q.sqlite_master VALUES('index',%Q,%Q,#%d,%Q);\x00name='%q' AND type='index'\x00no such index: %S\x00index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped\x00DELETE FROM %Q.sqlite_master WHERE name=%Q AND type='index'\x00too many FROM clause terms, max: %d\x00a JOIN clause is required before %s\x00ON\x00USING\x00BEGIN\x00ROLLBACK\x00COMMIT\x00RELEASE\x00unable to open a temporary database file for storing temporary tables\x00index '%q'\x00, \x00%s.rowid\x00unable to identify the object to be reindexed\x00duplicate WITH table name: %s\x00no such collation sequence: %s\x00unsafe use of virtual table \"%s\"\x00table %s may not be modified\x00cannot modify %s because it is a view\x00rows deleted\x00integer overflow\x00%.*f\x00LIKE or GLOB pattern too complex\x00ESCAPE expression must be a single character\x00%!.20e\x00%Q\x00?000\x00MATCH\x00like\x00implies_nonnull_row\x00expr_compare\x00expr_implies_expr\x00affinity\x00soundex\x00load_extension\x00sqlite_compileoption_used\x00sqlite_compileoption_get\x00unlikely\x00likelihood\x00likely\x00sqlite_offset\x00ltrim\x00rtrim\x00trim\x00min\x00max\x00typeof\x00subtype\x00length\x00instr\x00printf\x00format\x00unicode\x00char\x00abs\x00round\x00upper\x00lower\x00hex\x00unhex\x00ifnull\x00random\x00randomblob\x00nullif\x00sqlite_version\x00sqlite_source_id\x00sqlite_log\x00quote\x00last_insert_rowid\x00changes\x00total_changes\x00replace\x00zeroblob\x00substr\x00substring\x00sum\x00total\x00avg\x00count\x00group_concat\x00glob\x00ceil\x00ceiling\x00floor\x00trunc\x00ln\x00log\x00log10\x00log2\x00exp\x00pow\x00power\x00mod\x00acos\x00asin\x00atan\x00atan2\x00cos\x00sin\x00tan\x00cosh\x00sinh\x00tanh\x00acosh\x00asinh\x00atanh\x00sqrt\x00radians\x00degrees\x00pi\x00sign\x00iif\x00foreign key mismatch - \"%w\" referencing \"%w\"\x00cannot INSERT into generated column \"%s\"\x00table %S has no column named %s\x00table %S has %d columns but %d values were supplied\x00%d values for %d columns\x00UPSERT not implemented for virtual table \"%s\"\x00cannot UPSERT a view\x00rows inserted\x00sqlite3_extension_init\x00sqlite3_\x00lib\x00_init\x00no entry point [%s] in shared library [%s]\x00error during initialization: %s\x00unable to open shared library [%.*s]\x00so\x00automatic extension loading failed: %s\x00seq\x00from\x00to\x00on_update\x00on_delete\x00match\x00cid\x00name\x00type\x00notnull\x00dflt_value\x00pk\x00hidden\x00schema\x00ncol\x00wr\x00strict\x00seqno\x00desc\x00coll\x00key\x00builtin\x00enc\x00narg\x00flags\x00wdth\x00hght\x00flgs\x00unique\x00origin\x00partial\x00rowid\x00fkid\x00file\x00busy\x00checkpointed\x00database\x00status\x00cache_size\x00timeout\x00analysis_limit\x00application_id\x00auto_vacuum\x00automatic_index\x00busy_timeout\x00cache_spill\x00case_sensitive_like\x00cell_size_check\x00checkpoint_fullfsync\x00collation_list\x00compile_options\x00count_changes\x00data_version\x00database_list\x00default_cache_size\x00defer_foreign_keys\x00empty_result_callbacks\x00encoding\x00foreign_key_check\x00foreign_key_list\x00foreign_keys\x00freelist_count\x00full_column_names\x00fullfsync\x00function_list\x00hard_heap_limit\x00ignore_check_constraints\x00incremental_vacuum\x00index_info\x00index_list\x00index_xinfo\x00integrity_check\x00journal_mode\x00journal_size_limit\x00legacy_alter_table\x00locking_mode\x00max_page_count\x00mmap_size\x00module_list\x00optimize\x00page_count\x00page_size\x00pragma_list\x00query_only\x00quick_check\x00read_uncommitted\x00recursive_triggers\x00reverse_unordered_selects\x00schema_version\x00secure_delete\x00short_column_names\x00shrink_memory\x00soft_heap_limit\x00synchronous\x00table_info\x00table_list\x00table_xinfo\x00temp_store\x00temp_store_directory\x00threads\x00trusted_schema\x00user_version\x00wal_autocheckpoint\x00wal_checkpoint\x00writable_schema\x00onoffalseyestruextrafull\x00exclusive\x00normal\x00full\x00incremental\x00memory\x00temporary storage cannot be changed from within a transaction\x00SET NULL\x00SET DEFAULT\x00CASCADE\x00RESTRICT\x00NO ACTION\x00delete\x00persist\x00off\x00truncate\x00wal\x00w\x00a\x00sissii\x00utf8\x00utf16le\x00utf16be\x00-%T\x00fast\x00not a writable directory\x00Safety level may not be changed inside a transaction\x00reset\x00issisii\x00issisi\x00SELECT*FROM\"%w\"\x00shadow\x00sssiii\x00iisX\x00isiX\x00c\x00u\x00isisi\x00iss\x00is\x00iissssss\x00NONE\x00siX\x00*** in database %s ***\n\x00row not in PRIMARY KEY order for %s\x00NULL value in %s.%s\x00non-%s value in %s.%s\x00NUMERIC value in %s.%s\x00C\x00TEXT value in %s.%s\x00CHECK constraint failed in %s\x00row \x00 missing from index \x00rowid not at end-of-record for row \x00 of index \x00 values differ from index \x00non-unique entry in index \x00wrong # of entries in index \x00ok\x00unsupported encoding: %s\x00restart\x00ANALYZE \"%w\".\"%w\"\x00UTF8\x00UTF-8\x00UTF-16le\x00UTF-16be\x00UTF16le\x00UTF16be\x00UTF-16\x00UTF16\x00CREATE TABLE x\x00%c\"%s\"\x00(\"%s\"\x00,arg HIDDEN\x00,schema HIDDEN\x00PRAGMA \x00%Q.\x00=%Q\x00error in %s %s after %s: %s\x00malformed database schema (%s)\x00%z - %s\x00rename\x00drop column\x00add column\x00orphan index\x00CREATE TABLE x(type text,name text,tbl_name text,rootpage int,sql text)\x00unsupported file format\x00SELECT*FROM\"%w\".%s ORDER BY rowid\x00database schema is locked: %s\x00statement too long\x00unknown join type: %T%s%T%s%T\x00naturaleftouterightfullinnercross\x00a NATURAL join may not have an ON or USING clause\x00cannot join using column %s - column not present in both tables\x00ambiguous reference to %s in USING()\x00UNION ALL\x00INTERSECT\x00EXCEPT\x00UNION\x00USE TEMP B-TREE FOR %s\x00USE TEMP B-TREE FOR %sORDER BY\x00RIGHT PART OF \x00column%d\x00%.*z:%u\x00NUM\x00cannot use window functions in recursive queries\x00recursive aggregate queries not supported\x00SETUP\x00RECURSIVE STEP\x00SCAN %d CONSTANT ROW%s\x00S\x00COMPOUND QUERY\x00LEFT-MOST SUBQUERY\x00%s USING TEMP B-TREE\x00all VALUES must have the same number of terms\x00SELECTs to the left and right of %s do not have the same number of result columns\x00MERGE (%s)\x00LEFT\x00RIGHT\x00no such index: %s\x00'%s' is not a function\x00no such index: \"%s\"\x00multiple references to recursive table: %s\x00circular reference: %s\x00table %s has %d values for %d columns\x00multiple recursive references: %s\x00recursive reference in a subquery: %s\x00%!S\x00too many references to \"%s\": max 65535\x00access to view \"%s\" prohibited\x00..%s\x00%s.%s.%s\x00no such table: %s\x00no tables specified\x00too many columns in result set\x00DISTINCT aggregates must have exactly one argument\x00USE TEMP B-TREE FOR %s(DISTINCT)\x00SCAN %s%s%s\x00 USING COVERING INDEX \x00target object/alias may not appear in FROM clause: %s\x00expected %d columns for '%s' but got %d\x00CO-ROUTINE %!S\x00MATERIALIZE %!S\x00DISTINCT\x00GROUP BY\x00sqlite3_get_table() called with two or more incompatible queries\x00temporary trigger may not have qualified name\x00trigger\x00cannot create triggers on virtual tables\x00trigger %T already exists\x00cannot create trigger on system table\x00cannot create %s trigger on view: %S\x00BEFORE\x00AFTER\x00cannot create INSTEAD OF trigger on table: %S\x00trigger \"%s\" may not write to shadow table \"%s\"\x00INSERT INTO %Q.sqlite_master VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')\x00type='trigger' AND name='%q'\x00no such trigger: %S\x00DELETE FROM %Q.sqlite_master WHERE name=%Q AND type='trigger'\x00%s RETURNING is not available on virtual tables\x00DELETE\x00UPDATE\x00RETURNING may not use \"TABLE.*\" wildcards\x00-- TRIGGER %s\x00cannot UPDATE generated column \"%s\"\x00no such column: %s\x00rows updated\x00%r \x00%sON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint\x00CRE\x00INS\x00cannot VACUUM from within a transaction\x00cannot VACUUM - SQL statements in progress\x00non-text filename\x00ATTACH %Q AS vacuum_db\x00output file already exists\x00SELECT sql FROM \"%w\".sqlite_schema WHERE type='table'AND name<>'sqlite_sequence' AND coalesce(rootpage,1)>0\x00SELECT sql FROM \"%w\".sqlite_schema WHERE type='index'\x00SELECT'INSERT INTO vacuum_db.'||quote(name)||' SELECT*FROM\"%w\".'||quote(name)FROM vacuum_db.sqlite_schema WHERE type='table'AND coalesce(rootpage,1)>0\x00INSERT INTO vacuum_db.sqlite_schema SELECT*FROM \"%w\".sqlite_schema WHERE type IN('view','trigger') OR(type='table'AND rootpage=0)\x00CREATE VIRTUAL TABLE %T\x00UPDATE %Q.sqlite_master SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q WHERE rowid=#%d\x00name=%Q AND sql=%Q\x00vtable constructor called recursively: %s\x00vtable constructor failed: %s\x00vtable constructor did not declare schema: %s\x00no such module: %s\x00<expr>\x00 AND \x00(\x00 (\x00%s=?\x00ANY(%s)\x00>\x00<\x00%s %S\x00SEARCH\x00SCAN\x00AUTOMATIC PARTIAL COVERING INDEX\x00AUTOMATIC COVERING INDEX\x00COVERING INDEX %s\x00INDEX %s\x00 USING \x00 USING INTEGER PRIMARY KEY (%s\x00>? AND %s\x00%c?)\x00 VIRTUAL TABLE INDEX %d:%s\x00 LEFT-JOIN\x00BLOOM FILTER ON %S (\x00rowid=?\x00MULTI-INDEX OR\x00INDEX %d\x00RIGHT-JOIN %s\x00regexp\x00ON clause references tables to its right\x00NOCASE\x00too many arguments on %s() - max %d\x00automatic index on %s(%s)\x00auto-index\x00%s.xBestIndex malfunction\x00abbreviated query algorithm search\x00no query solution\x00at most %d tables in a join\x00SCAN CONSTANT ROW\x00second argument to nth_value must be a positive integer\x00argument of ntile must be a positive integer\x00row_number\x00dense_rank\x00rank\x00percent_rank\x00cume_dist\x00ntile\x00last_value\x00nth_value\x00first_value\x00lead\x00lag\x00no such window: %s\x00RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression\x00FILTER clause may only be used with aggregate window functions\x00misuse of aggregate: %s()\x00unsupported frame specification\x00PARTITION clause\x00ORDER BY clause\x00frame specification\x00cannot override %s of window: %s\x00DISTINCT is not supported for window functions\x00frame starting offset must be a non-negative integer\x00frame ending offset must be a non-negative integer\x00frame starting offset must be a non-negative number\x00frame ending offset must be a non-negative number\x00%s clause should come after %s not before\x00ORDER BY\x00LIMIT\x00too many terms in compound SELECT\x00syntax error after column name \"%.*s\"\x00parser stack overflow\x00unknown table option: %.*s\x00set list\x00near \"%T\": syntax error\x00qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers\x00the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers\x00the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers\x00incomplete input\x00unrecognized token: \"%T\"\x00%s in \"%s\"\x00create\x00temp\x00temporary\x00end\x00explain\x00unable to close due to unfinalized statements or unfinished backups\x00unknown error\x00abort due to ROLLBACK\x00another row available\x00no more rows available\x00not an error\x00SQL logic error\x00access permission denied\x00query aborted\x00database is locked\x00database table is locked\x00attempt to write a readonly database\x00interrupted\x00disk I/O error\x00database disk image is malformed\x00unknown operation\x00database or disk is full\x00unable to open database file\x00locking protocol\x00constraint failed\x00datatype mismatch\x00bad parameter or other API misuse\x00authorization denied\x00column index out of range\x00file is not a database\x00notification message\x00warning message\x00unable to delete/modify user-function due to active statements\x00unable to use function %s in the requested context\x00unknown database: %s\x00unable to delete/modify collation sequence due to active statements\x00file:\x00localhost\x00invalid uri authority: %.*s\x00vfs\x00cache\x00mode\x00no such %s mode: %s\x00%s mode not allowed: %s\x00no such vfs: %s\x00shared\x00private\x00ro\x00rw\x00rwc\x00RTRIM\x00\x00\x00\x00%s at line %d of [%.10s]\x00database corruption\x00misuse\x00cannot open file\x00no such table column: %s.%s\x00SQLITE_\x00database is deadlocked\x00array\x00object\x000123456789abcdef\x00JSON cannot hold BLOB values\x00malformed JSON\x00[0]\x00JSON path error near '%q'\x00json_%s() needs an odd number of arguments\x00$[\x00$.\x00json_object() requires an even number of arguments\x00json_object() labels must be TEXT\x00set\x00insert\x00[]\x00{}\x00CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,json HIDDEN,root HIDDEN)\x00.%.*s\x00[%d]\x00$\x00json\x00json_array\x00json_array_length\x00json_extract\x00->\x00->>\x00json_insert\x00json_object\x00json_patch\x00json_quote\x00json_remove\x00json_replace\x00json_set\x00json_type\x00json_valid\x00json_group_array\x00json_group_object\x00json_each\x00json_tree\x00%s_node\x00data\x00DROP TABLE '%q'.'%q_node';DROP TABLE '%q'.'%q_rowid';DROP TABLE '%q'.'%q_parent';\x00RtreeMatchArg\x00SELECT * FROM %Q.%Q\x00UNIQUE constraint failed: %s.%s\x00rtree constraint failed: %s.(%s<=%s)\x00ALTER TABLE %Q.'%q_node'   RENAME TO \"%w_node\";ALTER TABLE %Q.'%q_parent' RENAME TO \"%w_parent\";ALTER TABLE %Q.'%q_rowid'  RENAME TO \"%w_rowid\";\x00SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'\x00node\x00CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY,nodeno\x00,a%d\x00);CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY,data);\x00CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY,parentnode);\x00INSERT INTO \"%w\".\"%w_node\"VALUES(1,zeroblob(%d))\x00INSERT INTO\"%w\".\"%w_rowid\"(rowid,nodeno)VALUES(?1,?2)ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno\x00SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1\x00UPDATE \"%w\".\"%w_rowid\"SET \x00a%d=coalesce(?%d,a%d)\x00a%d=?%d\x00 WHERE rowid=?1\x00INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_node' WHERE nodeno = ?1\x00SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = ?1\x00INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_rowid' WHERE rowid = ?1\x00SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1\x00INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)\x00DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1\x00PRAGMA %Q.page_size\x00SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\x00undersize RTree blobs in \"%q_node\"\x00Wrong number of columns for an rtree table\x00Too few columns for an rtree table\x00Too many columns for an rtree table\x00Auxiliary rtree columns must be last\x00CREATE TABLE x(%.*s INT\x00,%.*s\x00);\x00,%.*s REAL\x00,%.*s INT\x00{%lld\x00 %g\x00}\x00Invalid argument to rtreedepth()\x00%z%s%z\x00SELECT data FROM %Q.'%q_node' WHERE nodeno=?\x00Node %lld missing from database\x00SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?1\x00SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?1\x00Mapping (%lld -> %lld) missing from %s table\x00%_rowid\x00%_parent\x00Found (%lld -> %lld) in %s table, expected (%lld -> %lld)\x00Dimension %d of cell %d on node %lld is corrupt\x00Dimension %d of cell %d on node %lld is corrupt relative to parent\x00Node %lld is too small (%d bytes)\x00Rtree depth out of range (%d)\x00Node %lld is too small for cell count of %d (%d bytes)\x00SELECT count(*) FROM %Q.'%q%s'\x00Wrong number of entries in %%%s table - expected %lld, actual %lld\x00SELECT * FROM %Q.'%q_rowid'\x00Schema corrupt or not an rtree\x00_rowid\x00_parent\x00END\x00wrong number of arguments to function rtreecheck()\x00[\x00[%!g,%!g],\x00[%!g,%!g]]\x00<polyline points=\x00%c%g,%g\x00 %g,%g'\x00 %s\x00></polyline>\x00CREATE TABLE x(_shape\x00,%s\x00rtree\x00fullscan\x00_shape does not contain a valid polygon\x00geopoly_overlap\x00geopoly_within\x00geopoly\x00geopoly_area\x00geopoly_blob\x00geopoly_json\x00geopoly_svg\x00geopoly_contains_point\x00geopoly_debug\x00geopoly_bbox\x00geopoly_xform\x00geopoly_regular\x00geopoly_ccw\x00geopoly_group_bbox\x00rtreenode\x00rtreedepth\x00rtreecheck\x00rtree_i32\x00corrupt fossil delta\x00DROP TRIGGER IF EXISTS temp.rbu_insert_tr;DROP TRIGGER IF EXISTS temp.rbu_update1_tr;DROP TRIGGER IF EXISTS temp.rbu_update2_tr;DROP TRIGGER IF EXISTS temp.rbu_delete_tr;\x00SELECT rbu_target_name(name, type='view') AS target, name FROM sqlite_schema WHERE type IN ('table', 'view') AND target IS NOT NULL  %s ORDER BY name\x00AND rootpage!=0 AND rootpage IS NOT NULL\x00SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE'   FROM main.sqlite_schema   WHERE type='index' AND tbl_name = ?\x00SELECT  (sql COLLATE nocase BETWEEN 'CREATE VIRTUAL' AND 'CREATE VIRTUAM'), rootpage  FROM sqlite_schema WHERE name=%Q\x00PRAGMA index_list=%Q\x00SELECT rootpage FROM sqlite_schema WHERE name = %Q\x00PRAGMA table_info=%Q\x00PRAGMA main.index_list = %Q\x00PRAGMA main.index_xinfo = %Q\x00SELECT * FROM '%q'\x00rbu_\x00rbu_rowid\x00table %q %s rbu_rowid column\x00may not have\x00requires\x00PRAGMA table_info(%Q)\x00column missing from %q: %s\x00%z%s\"%w\"\x00%z%s%s\"%w\"%s\x00SELECT max(_rowid_) FROM \"%s%w\"\x00 WHERE _rowid_ > %lld \x00 DESC\x00quote(\x00||','||\x00SELECT %s FROM \"%s%w\" ORDER BY %s LIMIT 1\x00 WHERE (%s) > (%s) \x00_rowid_\x00%z%s \"%w\" COLLATE %Q\x00%z%s \"rbu_imp_%d%w\" COLLATE %Q DESC\x00%z%s quote(\"rbu_imp_%d%w\")\x00SELECT %s FROM \"rbu_imp_%w\" ORDER BY %s LIMIT 1\x00%z%s%s\x00(%s) > (%s)\x00%z%s(%.*s) COLLATE %Q\x00%z%s\"%w\" COLLATE %Q\x00%z%s\"rbu_imp_%d%w\"%s\x00%z%s\"rbu_imp_%d%w\" %s COLLATE %Q\x00%z%s\"rbu_imp_%d%w\" IS ?\x00%z%s%s.\"%w\"\x00%z%sNULL\x00%z, %s._rowid_\x00_rowid_ = ?%d\x00%z%sc%d=?%d\x00_rowid_ = (SELECT id FROM rbu_imposter2 WHERE %z)\x00%z%s\"%w\"=?%d\x00invalid rbu_control value\x00%z%s\"%w\"=rbu_delta(\"%w\", ?%d)\x00%z%s\"%w\"=rbu_fossil_delta(\"%w\", ?%d)\x00PRIMARY KEY(\x00%z%s\"%w\"%s\x00%z)\x00SELECT name FROM sqlite_schema WHERE rootpage = ?\x00%z%sc%d %s COLLATE %Q\x00%z%sc%d%s\x00%z, id INTEGER\x00CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID\x00PRIMARY KEY \x00%z%s\"%w\" %s %sCOLLATE %Q%s\x00 NOT NULL\x00%z, %z\x00CREATE TABLE \"rbu_imp_%w\"(%z)%s\x00 WITHOUT ROWID\x00INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)\x00SELECT trim(sql) FROM sqlite_schema WHERE type='index' AND name=?\x00 LIMIT -1 OFFSET %d\x00CREATE TABLE \"rbu_imp_%w\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID\x00INSERT INTO \"rbu_imp_%w\" VALUES(%s)\x00DELETE FROM \"rbu_imp_%w\" WHERE %s\x00SELECT %s, 0 AS rbu_control FROM '%q' %s %s %s ORDER BY %s%s\x00AND\x00WHERE\x00SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s ORDER BY %s%s\x00SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s UNION ALL SELECT %s, rbu_control FROM '%q' %s %s typeof(rbu_control)='integer' AND rbu_control!=1 ORDER BY %s%s\x00rbu_imp_\x00INSERT INTO \"%s%w\"(%s%s) VALUES(%s)\x00, _rowid_\x00DELETE FROM \"%s%w\" WHERE %s\x00, rbu_rowid\x00CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS SELECT *%s FROM '%q' WHERE 0;\x00, 0 AS rbu_rowid\x00CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \"%s%w\" BEGIN   SELECT rbu_tmp_insert(3, %s);END;CREATE TEMP TRIGGER rbu_update1_tr BEFORE UPDATE ON \"%s%w\" BEGIN   SELECT rbu_tmp_insert(3, %s);END;CREATE TEMP TRIGGER rbu_update2_tr AFTER UPDATE ON \"%s%w\" BEGIN   SELECT rbu_tmp_insert(4, %s);END;\x00CREATE TEMP TRIGGER rbu_insert_tr AFTER INSERT ON \"%s%w\" BEGIN   SELECT rbu_tmp_insert(0, %s);END;\x00,_rowid_ \x00,rbu_rowid\x00SELECT %s,%s rbu_control%s FROM '%q'%s %s %s %s\x000 AS \x00UPDATE \"%s%w\" SET %s WHERE %s\x00SELECT k, v FROM %s.rbu_state\x00file:///%s-vacuum?modeof=%s\x00ATTACH %Q AS stat\x00CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)\x00cannot vacuum wal mode database\x00file:%s-vactmp?rbu_memory=1%s%s\x00&\x00rbu_tmp_insert\x00rbu_fossil_delta\x00rbu_target_name\x00SELECT * FROM sqlite_schema\x00rbu vfs not found\x00PRAGMA main.wal_checkpoint=restart\x00rbu_exclusive_checkpoint\x00%s-oal\x00%s-wal\x00PRAGMA schema_version\x00PRAGMA schema_version = %d\x00INSERT OR REPLACE INTO %s.rbu_state(k, v) VALUES (%d, %d), (%d, %Q), (%d, %Q), (%d, %d), (%d, %d), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %lld), (%d, %Q)  \x00PRAGMA main.%s\x00PRAGMA main.%s = %d\x00PRAGMA writable_schema=1\x00SELECT sql FROM sqlite_schema WHERE sql!='' AND rootpage!=0 AND name!='sqlite_sequence'  ORDER BY type DESC\x00SELECT * FROM sqlite_schema WHERE rootpage=0 OR rootpage IS NULL\x00INSERT INTO sqlite_schema VALUES(?,?,?,?,?)\x00PRAGMA writable_schema=0\x00DELETE FROM %s.'rbu_tmp_%q'\x00rbu_state mismatch error\x00rbu_vfs_%d\x00SELECT count(*) FROM sqlite_schema WHERE type='index' AND tbl_name = %Q\x00rbu_index_cnt\x00SELECT 1 FROM sqlite_schema WHERE tbl_name = 'rbu_count'\x00SELECT sum(cnt * (1 + rbu_index_cnt(rbu_target_name(tbl))))FROM rbu_count\x00cannot update wal mode database\x00database modified during rbu %s\x00vacuum\x00update\x00BEGIN IMMEDIATE\x00PRAGMA journal_mode=off\x00-vactmp\x00DELETE FROM stat.rbu_state\x00rbu/zipvfs setup error\x00rbu(%s)/%z\x00rbu_memory\x00SELECT 0, 'tbl',  '', 0, '', 1     UNION ALL SELECT 1, 'idx',  '', 0, '', 2     UNION ALL SELECT 2, 'stat', '', 0, '', 0\x00PRAGMA '%q'.table_info('%q')\x00%z%s\"%w\".\"%w\".\"%w\"=\"%w\".\"%w\".\"%w\"\x00%z%s\"%w\".\"%w\".\"%w\" IS NOT \"%w\".\"%w\".\"%w\"\x00 OR \x00SELECT * FROM \"%w\".\"%w\" WHERE NOT EXISTS (  SELECT 1 FROM \"%w\".\"%w\" WHERE %s)\x00SELECT * FROM \"%w\".\"%w\", \"%w\".\"%w\" WHERE %s AND (%z)\x00table schemas do not match\x00SELECT tbl, ?2, stat FROM %Q.sqlite_stat1 WHERE tbl IS ?1 AND idx IS (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)\x00SELECT * FROM \x00 WHERE \x00 IS ?\x00SAVEPOINT changeset\x00RELEASE changeset\x00UPDATE main.\x00 SET \x00 = ?\x00idx IS CASE WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL ELSE ?4 END \x00DELETE FROM main.\x00 AND (?\x00AND \x00INSERT INTO main.\x00) VALUES(?\x00, ?\x00INSERT INTO main.sqlite_stat1 VALUES(?1, CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END, ?3)\x00DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END AND (?4 OR stat IS ?3)\x00SAVEPOINT replace_op\x00RELEASE replace_op\x00SAVEPOINT changeset_apply\x00PRAGMA defer_foreign_keys = 1\x00sqlite3changeset_apply(): no such table: %s\x00sqlite3changeset_apply(): table %s has %d columns, expected %d or more\x00sqlite3changeset_apply(): primary key mismatch for table %s\x00PRAGMA defer_foreign_keys = 0\x00RELEASE changeset_apply\x00ROLLBACK TO changeset_apply\x00fts5: parser stack overflow\x00fts5: syntax error near \"%.*s\"\x00%z%.*s\x00wrong number of arguments to function highlight()\x00wrong number of arguments to function snippet()\x00snippet\x00highlight\x00bm25\x00prefix\x00malformed prefix=... directive\x00too many prefix indexes (max %d)\x00prefix length out of range (max 999)\x00tokenize\x00multiple tokenize=... directives\x00parse error in tokenize directive\x00content\x00multiple content=... directives\x00%Q.%Q\x00content_rowid\x00multiple content_rowid=... directives\x00columnsize\x00malformed columnsize=... directive\x00columns\x00malformed detail=... directive\x00unrecognized option: \"%.*s\"\x00reserved fts5 column name: %s\x00unindexed\x00unrecognized column option: %s\x00T.%Q\x00, T.%Q\x00, T.c%d\x00reserved fts5 table name: %s\x00parse error in \"%s\"\x00docsize\x00%Q.'%q_%s'\x00CREATE TABLE x(\x00%z%s%Q\x00%z, %Q HIDDEN, %s HIDDEN)\x00pgsz\x00hashsize\x00automerge\x00usermerge\x00crisismerge\x00SELECT k, v FROM %Q.'%q_config'\x00version\x00invalid fts5 file format (found %d, expected %d) - run 'rebuild'\x00unterminated string\x00fts5: syntax error near \"%.1s\"\x00OR\x00NOT\x00NEAR\x00expected integer, got \"%.*s\"\x00fts5: column queries are not supported (detail=none)\x00fts5: %s queries are not supported (detail!=full)\x00phrase\x00block\x00REPLACE INTO '%q'.'%q_data'(id, block) VALUES(?,?)\x00DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?\x00DELETE FROM '%q'.'%q_idx' WHERE segid=?\x00PRAGMA %Q.data_version\x00SELECT pgno FROM '%q'.'%q_idx' WHERE segid=? AND term<=? ORDER BY term DESC LIMIT 1\x00INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)\x00%s_data\x00id INTEGER PRIMARY KEY, block BLOB\x00segid, term, pgno, PRIMARY KEY(segid, term)\x00SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d ORDER BY 1, 2\x00\x00\x00\x00\x00\x00recursively defined fts5 content table\x00SELECT rowid, rank FROM %Q.%Q ORDER BY %s(\"%w\"%s%s) %s\x00DESC\x00ASC\x00reads\x00unknown special query: %.*s\x00SELECT %s\x00no such function: %s\x00parse error in rank function: %s\x00%s: table does not support scanning\x00delete-all\x00'delete-all' may only be used with a contentless or external content fts5 table\x00rebuild\x00'rebuild' may not be used with a contentless fts5 table\x00merge\x00integrity-check\x00cannot %s contentless fts5 table: %s\x00DELETE from\x00no such cursor: %lld\x00no such tokenizer: %s\x00error in tokenizer constructor\x00fts5_api_ptr\x00fts5: 2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da\x00config\x00fts5\x00fts5_source_id\x00SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC\x00SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC\x00SELECT %s FROM %s T WHERE T.%Q=?\x00INSERT INTO %Q.'%q_content' VALUES(%s)\x00REPLACE INTO %Q.'%q_content' VALUES(%s)\x00DELETE FROM %Q.'%q_content' WHERE id=?\x00REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\x00DELETE FROM %Q.'%q_docsize' WHERE id=?\x00SELECT sz FROM %Q.'%q_docsize' WHERE id=?\x00REPLACE INTO %Q.'%q_config' VALUES(?,?)\x00SELECT %s FROM %s AS T\x00DROP TABLE IF EXISTS %Q.'%q_data';DROP TABLE IF EXISTS %Q.'%q_idx';DROP TABLE IF EXISTS %Q.'%q_config';\x00DROP TABLE IF EXISTS %Q.'%q_docsize';\x00DROP TABLE IF EXISTS %Q.'%q_content';\x00ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';\x00CREATE TABLE %Q.'%q_%q'(%s)%s\x00fts5: error creating shadow table %q_%s: %s\x00id INTEGER PRIMARY KEY\x00, c%d\x00id INTEGER PRIMARY KEY, sz BLOB\x00k PRIMARY KEY, v\x00DELETE FROM %Q.'%q_data';DELETE FROM %Q.'%q_idx';\x00DELETE FROM %Q.'%q_docsize';\x00SELECT count(*) FROM %Q.'%q_%s'\x00tokenchars\x00separators\x00L* N* Co\x00categories\x00remove_diacritics\x00unicode61\x00al\x00ance\x00ence\x00er\x00ic\x00able\x00ible\x00ant\x00ement\x00ment\x00ent\x00ion\x00ou\x00ism\x00ate\x00iti\x00ous\x00ive\x00ize\x00at\x00bl\x00ble\x00iz\x00ational\x00tional\x00tion\x00enci\x00anci\x00izer\x00logi\x00bli\x00alli\x00entli\x00eli\x00e\x00ousli\x00ization\x00ation\x00ator\x00alism\x00iveness\x00fulness\x00ful\x00ousness\x00aliti\x00iviti\x00biliti\x00ical\x00ness\x00icate\x00iciti\x00ative\x00alize\x00eed\x00ee\x00ed\x00ing\x00case_sensitive\x00ascii\x00porter\x00trigram\x00col\x00row\x00instance\x00fts5vocab: unknown table type: %Q\x00CREATE TABlE vocab(term, col, doc, cnt)\x00CREATE TABlE vocab(term, doc, cnt)\x00CREATE TABlE vocab(term, doc, col, offset)\x00wrong number of vtable arguments\x00recursive definition for %s.%s\x00SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'\x00no such fts5 table: %s.%s\x00fts5vocab\x002023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da\x00"
 153329 var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data